Re: [PATCH] gspca pac7302: add test pattern/overlay control

2009-11-08 Thread Hans de Goede

Hi,

On 11/08/2009 12:05 AM, Németh Márton wrote:

From: Márton Némethnm...@freemail.hu

The Labtec Webcam 2200 (USB ID 093a:2626) device can produce some
diagnostic patterns instead of the sensor image. An overlay test
pattern also exsits which can be combined with the sensor image or
with any test patterns. Add controls to activate these test modes.



Same here again, this is completely useless to an end user, with something
like v4l2ucp we can show a nice control panel (like a soundcard mixer),
to the end user. We should only show sensible stuff there, showing this to
the end user is not sensible.

Jean-Francois Moine, can you please revert the changes adding these 2 controls.

Németh, I understand having things like this may be useful for development, 
what you
can do is add support for the standard v4l2 debugging interface, see:

linux/drivers/media/video/gspca/sn9c20x.c

Which allows one to export direct register control, and then use the existing
tools for this interface to modify these registers for testing purposes, or
even write a special userspace program to set things like this test mode.

(But this really does not belong to be visiable to the end user as a control
 at the same level as brightness and contrast).

Regards,

Hans




Signed-off-by: Márton Némethnm...@freemail.hu
Cc: Thomas Kaisertho...@kaiser-linux.li
---
diff -upr c/linux/drivers/media/video/gspca/pac7302.c 
d/linux/drivers/media/video/gspca/pac7302.c
--- c/linux/drivers/media/video/gspca/pac7302.c 2009-11-07 22:38:32.0 
+0100
+++ d/linux/drivers/media/video/gspca/pac7302.c 2009-11-08 00:55:38.0 
+0100
@@ -27,6 +27,29 @@
 addresses is a - sign that register description is not valid for the
 matching IC.

+   Register page 0:
+
+   Address Description
+   0x72/-  Different test patterns:
+ bit 0..3:  0 -  image, test pattern off
+1 -  white
+2 -  black
+3 -  red
+4 -  green
+5 -  blue
+6 -  cyan
+7 -  magenta
+8 -  yellow
+9 -  color bars
+   10 -  high resolution color pattern
+   11 -  black to white gradient from top to bottom
+   12 -  white to black gradient from left to right
+   13 -  white to black gradient repeats from left to 
right
+   14 -  dark gray (#11)
+   15 -  dark gray 2 (#11)
+ bit 4: overlay some diagnostic points over the image
+ bit 5..7: no effect
+
 Register page 1:

 AddressDescription
@@ -57,6 +80,7 @@
  0   | 0x0f..0x20 | setcolors()
  0   | 0xa2..0xab | setbrightcont()
  0   | 0x55   | setedgedetect()
+0   | 0x72   | settestpattern()
  0   | 0xc5   | setredbalance()
  0   | 0xc6   | setwhitebalance()
  0   | 0xc7   | setbluebalance()
@@ -91,6 +115,8 @@ struct sd {
__u8 hflip;
__u8 vflip;
unsigned char edge_detect;
+   unsigned char test_pattern;
+   unsigned char test_overlay;

u8 sof_read;
u8 autogain_ignore_frames;
@@ -123,9 +149,14 @@ static int sd_setexposure(struct gspca_d
  static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val);
  static int sd_setedgedetect(struct gspca_dev *gspca_dev, __s32 val);
  static int sd_getedgedetect(struct gspca_dev *gspca_dev, __s32 *val);
+static int sd_settestpattern(struct gspca_dev *gspca_dev, __s32 val);
+static int sd_gettestpattern(struct gspca_dev *gspca_dev, __s32 *val);
+static int sd_settestoverlay(struct gspca_dev *gspca_dev, __s32 val);
+static int sd_gettestoverlay(struct gspca_dev *gspca_dev, __s32 *val);

  #define V4L2_CID_PRIVATE_EDGE_DETECT (V4L2_CID_PRIVATE_BASE+0)
-
+#define V4L2_CID_PRIVATE_TEST_PATTERN (V4L2_CID_PRIVATE_BASE+1)
+#define V4L2_CID_PRIVATE_TEST_OVERLAY (V4L2_CID_PRIVATE_BASE+2)

  static struct ctrl sd_ctrls[] = {
  /* This control is pac7302 only */
@@ -307,6 +338,34 @@ static struct ctrl sd_ctrls[] = {
.set = sd_setedgedetect,
.get = sd_getedgedetect,
},
+   {
+   {
+   .id  = V4L2_CID_PRIVATE_TEST_PATTERN,
+   .type= V4L2_CTRL_TYPE_MENU,
+   .name= Test Pattern,
+   .minimum = 0,
+   .maximum = 15,
+   .step= 1,
+#define TEST_PATTERN_DEF 0
+   .default_value = TEST_PATTERN_DEF,
+   },
+   .set = sd_settestpattern,
+   .get = sd_gettestpattern,
+   },
+   {
+   {
+   .id  = V4L2_CID_PRIVATE_TEST_OVERLAY,
+   .type= V4L2_CTRL_TYPE_BOOLEAN,
+   .name= Test Overlay,
+   .minimum = 0,
+

[PATCH] gspca pac7302: add test pattern/overlay control

2009-11-07 Thread Németh Márton
From: Márton Németh nm...@freemail.hu

The Labtec Webcam 2200 (USB ID 093a:2626) device can produce some
diagnostic patterns instead of the sensor image. An overlay test
pattern also exsits which can be combined with the sensor image or
with any test patterns. Add controls to activate these test modes.

Signed-off-by: Márton Németh nm...@freemail.hu
Cc: Thomas Kaiser tho...@kaiser-linux.li
---
diff -upr c/linux/drivers/media/video/gspca/pac7302.c 
d/linux/drivers/media/video/gspca/pac7302.c
--- c/linux/drivers/media/video/gspca/pac7302.c 2009-11-07 22:38:32.0 
+0100
+++ d/linux/drivers/media/video/gspca/pac7302.c 2009-11-08 00:55:38.0 
+0100
@@ -27,6 +27,29 @@
addresses is a - sign that register description is not valid for the
matching IC.

+   Register page 0:
+
+   Address Description
+   0x72/-  Different test patterns:
+ bit 0..3:  0 - image, test pattern off
+1 - white
+2 - black
+3 - red
+4 - green
+5 - blue
+6 - cyan
+7 - magenta
+8 - yellow
+9 - color bars
+   10 - high resolution color pattern
+   11 - black to white gradient from top to bottom
+   12 - white to black gradient from left to right
+   13 - white to black gradient repeats from left to 
right
+   14 - dark gray (#11)
+   15 - dark gray 2 (#11)
+ bit 4: overlay some diagnostic points over the image
+ bit 5..7: no effect
+
Register page 1:

Address Description
@@ -57,6 +80,7 @@
 0   | 0x0f..0x20 | setcolors()
 0   | 0xa2..0xab | setbrightcont()
 0   | 0x55   | setedgedetect()
+0   | 0x72   | settestpattern()
 0   | 0xc5   | setredbalance()
 0   | 0xc6   | setwhitebalance()
 0   | 0xc7   | setbluebalance()
@@ -91,6 +115,8 @@ struct sd {
__u8 hflip;
__u8 vflip;
unsigned char edge_detect;
+   unsigned char test_pattern;
+   unsigned char test_overlay;

u8 sof_read;
u8 autogain_ignore_frames;
@@ -123,9 +149,14 @@ static int sd_setexposure(struct gspca_d
 static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val);
 static int sd_setedgedetect(struct gspca_dev *gspca_dev, __s32 val);
 static int sd_getedgedetect(struct gspca_dev *gspca_dev, __s32 *val);
+static int sd_settestpattern(struct gspca_dev *gspca_dev, __s32 val);
+static int sd_gettestpattern(struct gspca_dev *gspca_dev, __s32 *val);
+static int sd_settestoverlay(struct gspca_dev *gspca_dev, __s32 val);
+static int sd_gettestoverlay(struct gspca_dev *gspca_dev, __s32 *val);

 #define V4L2_CID_PRIVATE_EDGE_DETECT (V4L2_CID_PRIVATE_BASE+0)
-
+#define V4L2_CID_PRIVATE_TEST_PATTERN (V4L2_CID_PRIVATE_BASE+1)
+#define V4L2_CID_PRIVATE_TEST_OVERLAY (V4L2_CID_PRIVATE_BASE+2)

 static struct ctrl sd_ctrls[] = {
 /* This control is pac7302 only */
@@ -307,6 +338,34 @@ static struct ctrl sd_ctrls[] = {
.set = sd_setedgedetect,
.get = sd_getedgedetect,
},
+   {
+   {
+   .id  = V4L2_CID_PRIVATE_TEST_PATTERN,
+   .type= V4L2_CTRL_TYPE_MENU,
+   .name= Test Pattern,
+   .minimum = 0,
+   .maximum = 15,
+   .step= 1,
+#define TEST_PATTERN_DEF 0
+   .default_value = TEST_PATTERN_DEF,
+   },
+   .set = sd_settestpattern,
+   .get = sd_gettestpattern,
+   },
+   {
+   {
+   .id  = V4L2_CID_PRIVATE_TEST_OVERLAY,
+   .type= V4L2_CTRL_TYPE_BOOLEAN,
+   .name= Test Overlay,
+   .minimum = 0,
+   .maximum = 1,
+   .step= 1,
+#define TEST_OVERLAY_DEF 0
+   .default_value = TEST_OVERLAY_DEF,
+   },
+   .set = sd_settestoverlay,
+   .get = sd_gettestoverlay,
+   },

 };

@@ -595,6 +654,9 @@ static int sd_config(struct gspca_dev *g
sd-hflip = HFLIP_DEF;
sd-vflip = VFLIP_DEF;
sd-edge_detect = EDGE_DETECT_DEF;
+   sd-test_pattern = TEST_PATTERN_DEF;
+   sd-test_overlay = TEST_OVERLAY_DEF;
+
return 0;
 }

@@ -780,6 +842,23 @@ static int setedgedetect(struct gspca_de
return ret;
 }

+static int settestpattern(struct gspca_dev *gspca_dev)
+{
+   struct sd *sd = (struct sd *) gspca_dev;
+   int ret;
+   __u8 data;
+
+   ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
+   data = sd-test_pattern | (sd-test_overlay ? 0x10 : 0x00);
+   if (0 = ret)
+   ret = reg_w(gspca_dev, 0x72, data);
+
+   if (0 = ret)
+   ret =