]> Pileus Git - ~andy/linux/commitdiff
[media] gspca-pac207: Add a led_invert module parameter
authorHans de Goede <hdegoede@redhat.com>
Thu, 29 Nov 2012 09:39:49 +0000 (06:39 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 21 Dec 2012 14:41:29 +0000 (12:41 -0200)
Some cams have their led connected in such a way that on = off and visa versa
unfortunately we cannot tell this from the driver in any way, so add a module
parameter for this.

Reported-by: Yuri Glushkov <yglushkov@yahoo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/usb/gspca/pac207.c

index d236d1791f78da1ff0bdf965b8dde6389d169155..1f253dfebe4709da0de86fe6517eca5191e5eee2 100644 (file)
@@ -55,6 +55,11 @@ MODULE_LICENSE("GPL");
 
 #define PAC207_AUTOGAIN_DEADZONE       30
 
+/* global parameters */
+static int led_invert;
+module_param(led_invert, int, 0644);
+MODULE_PARM_DESC(led_invert, "Invert led");
+
 /* specific webcam descriptor */
 struct sd {
        struct gspca_dev gspca_dev;             /* !! must be the first item */
@@ -187,10 +192,14 @@ static int sd_config(struct gspca_dev *gspca_dev,
 /* this function is called at probe and resume time */
 static int sd_init(struct gspca_dev *gspca_dev)
 {
-       pac207_write_reg(gspca_dev, 0x41, 0x00);
-                               /* Bit_0=Image Format,
-                                * Bit_1=LED,
-                                * Bit_2=Compression test mode enable */
+       u8 mode;
+
+       /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */
+       if (led_invert)
+               mode = 0x02;
+       else
+               mode = 0x00;
+       pac207_write_reg(gspca_dev, 0x41, mode);
        pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */
 
        return gspca_dev->usb_err;
@@ -303,7 +312,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
        pac207_write_reg(gspca_dev, 0x02,
                v4l2_ctrl_g_ctrl(gspca_dev->exposure)); /* PXCK = 12MHz /n */
 
-       mode = 0x02; /* Image Format (Bit 0), LED (1), Compr. test mode (2) */
+       /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */
+       if (led_invert)
+               mode = 0x00;
+       else
+               mode = 0x02;
        if (gspca_dev->width == 176) {  /* 176x144 */
                mode |= 0x01;
                PDEBUG(D_STREAM, "pac207_start mode 176x144");
@@ -325,8 +338,15 @@ static int sd_start(struct gspca_dev *gspca_dev)
 
 static void sd_stopN(struct gspca_dev *gspca_dev)
 {
+       u8 mode;
+
+       /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */
+       if (led_invert)
+               mode = 0x02;
+       else
+               mode = 0x00;
        pac207_write_reg(gspca_dev, 0x40, 0x00); /* Stop ISO pipe */
-       pac207_write_reg(gspca_dev, 0x41, 0x00); /* Turn of LED */
+       pac207_write_reg(gspca_dev, 0x41, mode); /* Turn off LED */
        pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */
 }