diff options
Diffstat (limited to 'drivers/media/usb/gspca/zc3xx.c')
| -rw-r--r-- | drivers/media/usb/gspca/zc3xx.c | 335 |
1 files changed, 172 insertions, 163 deletions
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c index cbfc2f921427..5bcbf0d40147 100644 --- a/drivers/media/usb/gspca/zc3xx.c +++ b/drivers/media/usb/gspca/zc3xx.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Z-Star/Vimicro zc301/zc302p/vc30x driver * * Copyright (C) 2009-2012 Jean-Francois Moine <http://moinejf.free.fr> * Copyright (C) 2004 2005 2006 Michel Xhaard mxhaard@magic.fr - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -25,8 +12,7 @@ #include "gspca.h" #include "jpeg.h" -MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, " - "Serge A. Suchkov <Serge.A.S@tochka.ru>"); +MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, Serge A. Suchkov <Serge.A.S@tochka.ru>"); MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver"); MODULE_LICENSE("GPL"); @@ -53,7 +39,6 @@ struct sd { struct v4l2_ctrl *jpegqual; struct work_struct work; - struct workqueue_struct *work_thread; u8 reg08; /* webcam compression quality */ @@ -338,7 +323,7 @@ static const struct usb_action adcm2700_60HZ[] = { {0xaa, 0x28, 0x0002}, /* 00,28,02,aa */ {} }; -static const struct usb_action adcm2700_NoFliker[] = { +static const struct usb_action adcm2700_NoFlicker[] = { {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */ {0xaa, 0xfe, 0x0002}, /* 00,fe,02,aa */ {0xa0, 0x0a, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,0a,cc */ @@ -540,7 +525,7 @@ static const struct usb_action cs2102_60HZ[] = { {0xa0, 0xff, ZC3XX_R020_HSYNC_3}, {} }; -static const struct usb_action cs2102_NoFlikerScale[] = { +static const struct usb_action cs2102_NoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xaa, 0x23, 0x0001}, {0xaa, 0x24, 0x005f}, @@ -562,7 +547,7 @@ static const struct usb_action cs2102_NoFlikerScale[] = { {0xa0, 0xff, ZC3XX_R020_HSYNC_3}, {} }; -static const struct usb_action cs2102_NoFliker[] = { +static const struct usb_action cs2102_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xaa, 0x23, 0x0000}, {0xaa, 0x24, 0x00af}, @@ -1400,7 +1385,7 @@ static const struct usb_action gc0305_60HZ[] = { {} }; -static const struct usb_action gc0305_NoFliker[] = { +static const struct usb_action gc0305_NoFlicker[] = { {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc */ {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ @@ -1725,7 +1710,7 @@ static const struct usb_action hdcs2020_60HZ[] = { {0xa0, 0x2c, ZC3XX_R01F_HSYNC_2}, /* 00,1f,2c,cc */ {} }; -static const struct usb_action hdcs2020_NoFliker[] = { +static const struct usb_action hdcs2020_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xaa, 0x13, 0x0010}, /* 00,13,10,aa */ {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ @@ -1940,7 +1925,7 @@ static const struct usb_action hv7131b_60HZScale[] = { /* 320x240 */ {0xa0, 0x40, ZC3XX_R020_HSYNC_3}, /* 00,20,40,cc */ {} }; -static const struct usb_action hv7131b_NoFliker[] = { /* 640x480*/ +static const struct usb_action hv7131b_NoFlicker[] = { /* 640x480*/ {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xaa, 0x25, 0x0003}, /* 00,25,03,aa */ {0xaa, 0x26, 0x0000}, /* 00,26,00,aa */ @@ -1965,7 +1950,7 @@ static const struct usb_action hv7131b_NoFliker[] = { /* 640x480*/ {0xa0, 0x03, ZC3XX_R020_HSYNC_3}, /* 00,20,03,cc */ {} }; -static const struct usb_action hv7131b_NoFlikerScale[] = { /* 320x240 */ +static const struct usb_action hv7131b_NoFlickerScale[] = { /* 320x240 */ {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xaa, 0x25, 0x0003}, /* 00,25,03,aa */ {0xaa, 0x26, 0x0000}, /* 00,26,00,aa */ @@ -2156,7 +2141,7 @@ static const struct usb_action hv7131r_60HZScale[] = { {0xa0, 0x08, ZC3XX_R020_HSYNC_3}, {} }; -static const struct usb_action hv7131r_NoFliker[] = { +static const struct usb_action hv7131r_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xa0, 0x2f, ZC3XX_R190_EXPOSURELIMITHIGH}, {0xa0, 0xf8, ZC3XX_R191_EXPOSURELIMITMID}, @@ -2174,7 +2159,7 @@ static const struct usb_action hv7131r_NoFliker[] = { {0xa0, 0x08, ZC3XX_R020_HSYNC_3}, {} }; -static const struct usb_action hv7131r_NoFlikerScale[] = { +static const struct usb_action hv7131r_NoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xa0, 0x2f, ZC3XX_R190_EXPOSURELIMITHIGH}, {0xa0, 0xf8, ZC3XX_R191_EXPOSURELIMITMID}, @@ -2677,7 +2662,7 @@ static const struct usb_action icm105a_60HZ[] = { {0xa0, 0xc0, ZC3XX_R1A8_DIGITALGAIN}, /* 01,a8,c0,cc */ {} }; -static const struct usb_action icm105a_NoFlikerScale[] = { +static const struct usb_action icm105a_NoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */ {0xaa, 0x0c, 0x0004}, /* 00,0c,04,aa */ @@ -2708,7 +2693,7 @@ static const struct usb_action icm105a_NoFlikerScale[] = { {0xa0, 0xff, ZC3XX_R020_HSYNC_3}, /* 00,20,ff,cc */ {} }; -static const struct usb_action icm105a_NoFliker[] = { +static const struct usb_action icm105a_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */ {0xaa, 0x0c, 0x0004}, /* 00,0c,04,aa */ @@ -3024,7 +3009,7 @@ static const struct usb_action mc501cb_60HZScale[] = { {} }; -static const struct usb_action mc501cb_NoFliker[] = { +static const struct usb_action mc501cb_NoFlicker[] = { {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */ @@ -3036,7 +3021,7 @@ static const struct usb_action mc501cb_NoFliker[] = { {} }; -static const struct usb_action mc501cb_NoFlikerScale[] = { +static const struct usb_action mc501cb_NoFlickerScale[] = { {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */ @@ -3190,10 +3175,10 @@ static const struct usb_action ov7620_InitialScale[] = { /* 320x240 */ {} }; static const struct usb_action ov7620_50HZ[] = { - {0xaa, 0x13, 0x00a3}, /* 00,13,a3,aa */ {0xdd, 0x00, 0x0100}, /* 00,01,00,dd */ {0xaa, 0x2b, 0x0096}, /* 00,2b,96,aa */ - {0xaa, 0x75, 0x008a}, /* 00,75,8a,aa */ + /* enable 1/120s & 1/100s exposures for banding filter */ + {0xaa, 0x75, 0x008e}, {0xaa, 0x2d, 0x0005}, /* 00,2d,05,aa */ {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ {0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,04,cc */ @@ -3201,18 +3186,16 @@ static const struct usb_action ov7620_50HZ[] = { {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* 01,95,00,cc */ {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* 01,96,00,cc */ {0xa0, 0x83, ZC3XX_R197_ANTIFLICKERLOW}, /* 01,97,83,cc */ - {0xaa, 0x10, 0x0082}, /* 00,10,82,aa */ {0xaa, 0x76, 0x0003}, /* 00,76,03,aa */ /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT}, * 00,02,40,cc * if mode0 (640x480) */ {} }; static const struct usb_action ov7620_60HZ[] = { - {0xaa, 0x13, 0x00a3}, /* 00,13,a3,aa */ - /* (bug in zs211.inf) */ {0xdd, 0x00, 0x0100}, /* 00,01,00,dd */ {0xaa, 0x2b, 0x0000}, /* 00,2b,00,aa */ - {0xaa, 0x75, 0x008a}, /* 00,75,8a,aa */ + /* enable 1/120s & 1/100s exposures for banding filter */ + {0xaa, 0x75, 0x008e}, {0xaa, 0x2d, 0x0005}, /* 00,2d,05,aa */ {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ {0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,04,cc */ @@ -3220,7 +3203,6 @@ static const struct usb_action ov7620_60HZ[] = { {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* 01,95,00,cc */ {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* 01,96,00,cc */ {0xa0, 0x83, ZC3XX_R197_ANTIFLICKERLOW}, /* 01,97,83,cc */ - {0xaa, 0x10, 0x0020}, /* 00,10,20,aa */ {0xaa, 0x76, 0x0003}, /* 00,76,03,aa */ /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT}, * 00,02,40,cc * if mode0 (640x480) */ @@ -3229,12 +3211,11 @@ static const struct usb_action ov7620_60HZ[] = { {0xa1, 0x01, 0x0037}, */ {} }; -static const struct usb_action ov7620_NoFliker[] = { - {0xaa, 0x13, 0x00a3}, /* 00,13,a3,aa */ - /* (bug in zs211.inf) */ +static const struct usb_action ov7620_NoFlicker[] = { {0xdd, 0x00, 0x0100}, /* 00,01,00,dd */ {0xaa, 0x2b, 0x0000}, /* 00,2b,00,aa */ - {0xaa, 0x75, 0x008e}, /* 00,75,8e,aa */ + /* disable 1/120s & 1/100s exposures for banding filter */ + {0xaa, 0x75, 0x008a}, {0xaa, 0x2d, 0x0001}, /* 00,2d,01,aa */ {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ {0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,04,cc */ @@ -3612,7 +3593,7 @@ static const struct usb_action pas106b_InitialScale[] = { /* 176x144 */ {0xaa, 0x14, 0x0081}, /* Other registers */ {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, -/* Frame retreiving */ +/* Frame retrieving */ {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* Gains */ {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN}, @@ -3728,7 +3709,7 @@ static const struct usb_action pas106b_Initial[] = { /* 352x288 */ {0xaa, 0x14, 0x0081}, /* Other registers */ {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, -/* Frame retreiving */ +/* Frame retrieving */ {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* Gains */ {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN}, @@ -3846,7 +3827,7 @@ static const struct usb_action pas106b_60HZ[] = { {0xa0, 0x04, ZC3XX_R1A9_DIGITALLIMITDIFF}, /* 01,a9,04,cc */ {} }; -static const struct usb_action pas106b_NoFliker[] = { +static const struct usb_action pas106b_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ {0xa0, 0x06, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,06,cc */ {0xa0, 0x50, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,50,cc */ @@ -4070,7 +4051,7 @@ static const struct usb_action pas202b_60HZScale[] = { {0xa0, 0x0e, ZC3XX_R088_EXPTIMELOW}, /* 00,88,0e,cc */ {} }; -static const struct usb_action pas202b_NoFliker[] = { +static const struct usb_action pas202b_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xa0, 0x20, ZC3XX_R087_EXPTIMEMID}, /* 00,87,20,cc */ {0xa0, 0x21, ZC3XX_R088_EXPTIMELOW}, /* 00,88,21,cc */ @@ -4099,7 +4080,7 @@ static const struct usb_action pas202b_NoFliker[] = { {0xa0, 0x0e, ZC3XX_R088_EXPTIMELOW}, /* 00,88,0e,cc */ {} }; -static const struct usb_action pas202b_NoFlikerScale[] = { +static const struct usb_action pas202b_NoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xa0, 0x20, ZC3XX_R087_EXPTIMEMID}, /* 00,87,20,cc */ {0xa0, 0x21, ZC3XX_R088_EXPTIMELOW}, /* 00,88,21,cc */ @@ -4328,7 +4309,7 @@ static const struct usb_action mt9v111_1_AE60HZScale[] = { {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, {} }; -static const struct usb_action mt9v111_1_AENoFliker[] = { +static const struct usb_action mt9v111_1_AENoFlicker[] = { {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xbb, 0x00, 0x0509}, @@ -4351,7 +4332,7 @@ static const struct usb_action mt9v111_1_AENoFliker[] = { {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, {} }; -static const struct usb_action mt9v111_1_AENoFlikerScale[] = { +static const struct usb_action mt9v111_1_AENoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xbb, 0x00, 0x0534}, @@ -4573,7 +4554,7 @@ static const struct usb_action mt9v111_3_AE60HZScale[] = { {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, {} }; -static const struct usb_action mt9v111_3_AENoFliker[] = { +static const struct usb_action mt9v111_3_AENoFlicker[] = { {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xaa, 0x05, 0x0034}, @@ -4596,7 +4577,7 @@ static const struct usb_action mt9v111_3_AENoFliker[] = { {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, {} }; -static const struct usb_action mt9v111_3_AENoFlikerScale[] = { +static const struct usb_action mt9v111_3_AENoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xaa, 0x05, 0x0034}, @@ -4806,7 +4787,7 @@ static const struct usb_action pb0330_60HZScale[] = { {0xa0, 0xd0, ZC3XX_R020_HSYNC_3}, {} }; -static const struct usb_action pb0330_NoFliker[] = { +static const struct usb_action pb0330_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xbb, 0x00, 0x0509}, {0xbb, 0x02, 0x0940}, @@ -4828,7 +4809,7 @@ static const struct usb_action pb0330_NoFliker[] = { {0xa0, 0xe0, ZC3XX_R020_HSYNC_3}, {} }; -static const struct usb_action pb0330_NoFlikerScale[] = { +static const struct usb_action pb0330_NoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, {0xbb, 0x00, 0x0535}, {0xbb, 0x01, 0x0980}, @@ -5050,7 +5031,7 @@ static const struct usb_action po2030_60HZ[] = { {} }; -static const struct usb_action po2030_NoFliker[] = { +static const struct usb_action po2030_NoFlicker[] = { {0xa0, 0x02, ZC3XX_R180_AUTOCORRECTENABLE}, /* 01,80,02,cc */ {0xaa, 0x8d, 0x000d}, /* 00,8d,0d,aa */ {0xaa, 0x1a, 0x0000}, /* 00,1a,00,aa */ @@ -5234,7 +5215,7 @@ static const struct usb_action tas5130c_60HZScale[] = { {0xa0, 0x50, ZC3XX_R11D_GLOBALGAIN}, {} }; -static const struct usb_action tas5130c_NoFliker[] = { +static const struct usb_action tas5130c_NoFlicker[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xaa, 0xa3, 0x0001}, /* 00,a3,01,aa */ {0xaa, 0xa4, 0x0040}, /* 00,a4,40,aa */ @@ -5260,7 +5241,7 @@ static const struct usb_action tas5130c_NoFliker[] = { {} }; -static const struct usb_action tas5130c_NoFlikerScale[] = { +static const struct usb_action tas5130c_NoFlickerScale[] = { {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ {0xaa, 0xa3, 0x0001}, /* 00,a3,01,aa */ {0xaa, 0xa4, 0x0090}, /* 00,a4,90,aa */ @@ -5501,7 +5482,7 @@ static const struct usb_action gc0303_60HZScale[] = { {} }; -static const struct usb_action gc0303_NoFliker[] = { +static const struct usb_action gc0303_NoFlicker[] = { {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ @@ -5523,7 +5504,7 @@ static const struct usb_action gc0303_NoFliker[] = { {} }; -static const struct usb_action gc0303_NoFlikerScale[] = { +static const struct usb_action gc0303_NoFlickerScale[] = { {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ @@ -5784,16 +5765,34 @@ static void setcontrast(struct gspca_dev *gspca_dev, static s32 getexposure(struct gspca_dev *gspca_dev) { - return (i2c_read(gspca_dev, 0x25) << 9) - | (i2c_read(gspca_dev, 0x26) << 1) - | (i2c_read(gspca_dev, 0x27) >> 7); + struct sd *sd = (struct sd *) gspca_dev; + + switch (sd->sensor) { + case SENSOR_HV7131R: + return (i2c_read(gspca_dev, 0x25) << 9) + | (i2c_read(gspca_dev, 0x26) << 1) + | (i2c_read(gspca_dev, 0x27) >> 7); + case SENSOR_OV7620: + return i2c_read(gspca_dev, 0x10); + default: + return -1; + } } static void setexposure(struct gspca_dev *gspca_dev, s32 val) { - i2c_write(gspca_dev, 0x25, val >> 9, 0x00); - i2c_write(gspca_dev, 0x26, val >> 1, 0x00); - i2c_write(gspca_dev, 0x27, val << 7, 0x00); + struct sd *sd = (struct sd *) gspca_dev; + + switch (sd->sensor) { + case SENSOR_HV7131R: + i2c_write(gspca_dev, 0x25, val >> 9, 0x00); + i2c_write(gspca_dev, 0x26, val >> 1, 0x00); + i2c_write(gspca_dev, 0x27, val << 7, 0x00); + break; + case SENSOR_OV7620: + i2c_write(gspca_dev, 0x10, val, 0x00); + break; + } } static void setquality(struct gspca_dev *gspca_dev) @@ -5807,7 +5806,7 @@ static void setquality(struct gspca_dev *gspca_dev) * Valid frequencies are: * 50Hz, for European and Asian lighting (default) * 60Hz, for American lighting - * 0 = No Fliker (for outdoore usage) + * 0 = No Flicker (for outdoor usage) */ static void setlightfreq(struct gspca_dev *gspca_dev, s32 val) { @@ -5815,80 +5814,80 @@ static void setlightfreq(struct gspca_dev *gspca_dev, s32 val) int i, mode; const struct usb_action *zc3_freq; static const struct usb_action *freq_tb[SENSOR_MAX][6] = { - [SENSOR_ADCM2700] = - {adcm2700_NoFliker, adcm2700_NoFliker, + [SENSOR_ADCM2700] = { + adcm2700_NoFlicker, adcm2700_NoFlicker, adcm2700_50HZ, adcm2700_50HZ, adcm2700_60HZ, adcm2700_60HZ}, - [SENSOR_CS2102] = - {cs2102_NoFliker, cs2102_NoFlikerScale, + [SENSOR_CS2102] = { + cs2102_NoFlicker, cs2102_NoFlickerScale, cs2102_50HZ, cs2102_50HZScale, cs2102_60HZ, cs2102_60HZScale}, - [SENSOR_CS2102K] = - {cs2102_NoFliker, cs2102_NoFlikerScale, + [SENSOR_CS2102K] = { + cs2102_NoFlicker, cs2102_NoFlickerScale, NULL, NULL, /* currently disabled */ NULL, NULL}, - [SENSOR_GC0303] = - {gc0303_NoFliker, gc0303_NoFlikerScale, + [SENSOR_GC0303] = { + gc0303_NoFlicker, gc0303_NoFlickerScale, gc0303_50HZ, gc0303_50HZScale, gc0303_60HZ, gc0303_60HZScale}, - [SENSOR_GC0305] = - {gc0305_NoFliker, gc0305_NoFliker, + [SENSOR_GC0305] = { + gc0305_NoFlicker, gc0305_NoFlicker, gc0305_50HZ, gc0305_50HZ, gc0305_60HZ, gc0305_60HZ}, - [SENSOR_HDCS2020] = - {hdcs2020_NoFliker, hdcs2020_NoFliker, + [SENSOR_HDCS2020] = { + hdcs2020_NoFlicker, hdcs2020_NoFlicker, hdcs2020_50HZ, hdcs2020_50HZ, hdcs2020_60HZ, hdcs2020_60HZ}, - [SENSOR_HV7131B] = - {hv7131b_NoFliker, hv7131b_NoFlikerScale, + [SENSOR_HV7131B] = { + hv7131b_NoFlicker, hv7131b_NoFlickerScale, hv7131b_50HZ, hv7131b_50HZScale, hv7131b_60HZ, hv7131b_60HZScale}, - [SENSOR_HV7131R] = - {hv7131r_NoFliker, hv7131r_NoFlikerScale, + [SENSOR_HV7131R] = { + hv7131r_NoFlicker, hv7131r_NoFlickerScale, hv7131r_50HZ, hv7131r_50HZScale, hv7131r_60HZ, hv7131r_60HZScale}, - [SENSOR_ICM105A] = - {icm105a_NoFliker, icm105a_NoFlikerScale, + [SENSOR_ICM105A] = { + icm105a_NoFlicker, icm105a_NoFlickerScale, icm105a_50HZ, icm105a_50HZScale, icm105a_60HZ, icm105a_60HZScale}, - [SENSOR_MC501CB] = - {mc501cb_NoFliker, mc501cb_NoFlikerScale, + [SENSOR_MC501CB] = { + mc501cb_NoFlicker, mc501cb_NoFlickerScale, mc501cb_50HZ, mc501cb_50HZScale, mc501cb_60HZ, mc501cb_60HZScale}, - [SENSOR_MT9V111_1] = - {mt9v111_1_AENoFliker, mt9v111_1_AENoFlikerScale, + [SENSOR_MT9V111_1] = { + mt9v111_1_AENoFlicker, mt9v111_1_AENoFlickerScale, mt9v111_1_AE50HZ, mt9v111_1_AE50HZScale, mt9v111_1_AE60HZ, mt9v111_1_AE60HZScale}, - [SENSOR_MT9V111_3] = - {mt9v111_3_AENoFliker, mt9v111_3_AENoFlikerScale, + [SENSOR_MT9V111_3] = { + mt9v111_3_AENoFlicker, mt9v111_3_AENoFlickerScale, mt9v111_3_AE50HZ, mt9v111_3_AE50HZScale, mt9v111_3_AE60HZ, mt9v111_3_AE60HZScale}, - [SENSOR_OV7620] = - {ov7620_NoFliker, ov7620_NoFliker, + [SENSOR_OV7620] = { + ov7620_NoFlicker, ov7620_NoFlicker, ov7620_50HZ, ov7620_50HZ, ov7620_60HZ, ov7620_60HZ}, - [SENSOR_OV7630C] = - {NULL, NULL, + [SENSOR_OV7630C] = { + NULL, NULL, NULL, NULL, NULL, NULL}, - [SENSOR_PAS106] = - {pas106b_NoFliker, pas106b_NoFliker, + [SENSOR_PAS106] = { + pas106b_NoFlicker, pas106b_NoFlicker, pas106b_50HZ, pas106b_50HZ, pas106b_60HZ, pas106b_60HZ}, - [SENSOR_PAS202B] = - {pas202b_NoFliker, pas202b_NoFlikerScale, + [SENSOR_PAS202B] = { + pas202b_NoFlicker, pas202b_NoFlickerScale, pas202b_50HZ, pas202b_50HZScale, pas202b_60HZ, pas202b_60HZScale}, - [SENSOR_PB0330] = - {pb0330_NoFliker, pb0330_NoFlikerScale, + [SENSOR_PB0330] = { + pb0330_NoFlicker, pb0330_NoFlickerScale, pb0330_50HZ, pb0330_50HZScale, pb0330_60HZ, pb0330_60HZScale}, - [SENSOR_PO2030] = - {po2030_NoFliker, po2030_NoFliker, + [SENSOR_PO2030] = { + po2030_NoFlicker, po2030_NoFlicker, po2030_50HZ, po2030_50HZ, po2030_60HZ, po2030_60HZ}, - [SENSOR_TAS5130C] = - {tas5130c_NoFliker, tas5130c_NoFlikerScale, + [SENSOR_TAS5130C] = { + tas5130c_NoFlicker, tas5130c_NoFlickerScale, tas5130c_50HZ, tas5130c_50HZScale, tas5130c_60HZ, tas5130c_60HZScale}, }; @@ -5924,7 +5923,12 @@ static void setlightfreq(struct gspca_dev *gspca_dev, s32 val) static void setautogain(struct gspca_dev *gspca_dev, s32 val) { - reg_w(gspca_dev, val ? 0x42 : 0x02, 0x0180); + struct sd *sd = (struct sd *) gspca_dev; + + if (sd->sensor == SENSOR_OV7620) + i2c_write(gspca_dev, 0x13, val ? 0xa3 : 0x80, 0x00); + else + reg_w(gspca_dev, val ? 0x42 : 0x02, 0x0180); } /* @@ -5942,23 +5946,23 @@ static void transfer_update(struct work_struct *work) reg07 = 0; good = 0; - for (;;) { + while (1) { msleep(100); /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */ mutex_lock(&gspca_dev->usb_lock); #ifdef CONFIG_PM if (gspca_dev->frozen) - goto err; + break; #endif if (!gspca_dev->present || !gspca_dev->streaming) - goto err; + break; /* Bit 0 of register 11 indicates FIFO overflow */ gspca_dev->usb_err = 0; reg11 = reg_r(gspca_dev, 0x0011); if (gspca_dev->usb_err) - goto err; + break; change = reg11 & 0x01; if (change) { /* overflow */ @@ -5987,12 +5991,12 @@ static void transfer_update(struct work_struct *work) gspca_dev->usb_err = 0; reg_w(gspca_dev, reg07, 0x0007); if (gspca_dev->usb_err) - goto err; + break; } mutex_unlock(&gspca_dev->usb_lock); } - return; -err: + + /* Something went wrong. Unlock and return */ mutex_unlock(&gspca_dev->usb_lock); } @@ -6047,7 +6051,7 @@ static int sif_probe(struct gspca_dev *gspca_dev) msleep(150); checkword = ((i2c_read(gspca_dev, 0x00) & 0x0f) << 4) | ((i2c_read(gspca_dev, 0x01) & 0xf0) >> 4); - PDEBUG(D_PROBE, "probe sif 0x%04x", checkword); + gspca_dbg(gspca_dev, D_PROBE, "probe sif 0x%04x\n", checkword); if (checkword == 0x0007) { send_unknown(gspca_dev, SENSOR_PAS106); return 0x0f; /* PAS106 */ @@ -6135,7 +6139,7 @@ ov_check: i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */ retword = i2c_read(gspca_dev, 0x0a) << 8; retword |= i2c_read(gspca_dev, 0x0b); - PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 2wr ov vga 0x%04x\n", retword); switch (retword) { case 0x7631: /* OV7630C */ reg_w(gspca_dev, 0x06, 0x0010); @@ -6192,7 +6196,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x02, 0x0010); retword = reg_r(gspca_dev, 0x000b) << 8; retword |= reg_r(gspca_dev, 0x000a); - PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga 1 0x%04x\n", retword); reg_r(gspca_dev, 0x0010); if ((retword & 0xff00) == 0x6400) return 0x02; /* TAS5130C */ @@ -6212,7 +6216,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x01, 0x0012); retword = i2c_read(gspca_dev, 0x00); if (retword != 0) { - PDEBUG(D_PROBE, "probe 3wr vga type 0a"); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga type 0a\n"); return 0x0a; /* PB0330 */ } @@ -6226,7 +6230,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x01, 0x0012); retword = i2c_read(gspca_dev, 0x00); if (retword != 0) { - PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga type %02x\n", + retword); if (retword == 0x0011) /* gc0303 */ return 0x0303; if (retword == 0x0029) /* gc0305 */ @@ -6257,12 +6262,13 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0x05, 0x0012); retword = i2c_read(gspca_dev, 0x00) << 8; /* ID 0 */ retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */ - PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga 2 0x%04x\n", retword); if (retword == 0x2030) { u8 retbyte; retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ - PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); + gspca_dbg(gspca_dev, D_PROBE, "sensor PO2030 rev 0x%02x\n", + retbyte); send_unknown(gspca_dev, SENSOR_PO2030); return retword; @@ -6278,7 +6284,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) reg_w(gspca_dev, 0xd3, 0x008b); retword = i2c_read(gspca_dev, 0x01); if (retword != 0) { - PDEBUG(D_PROBE, "probe 3wr vga type 0a ? ret: %04x", retword); + gspca_dbg(gspca_dev, D_PROBE, "probe 3wr vga type 0a ? ret: %04x\n", + retword); return 0x16; /* adcm2700 (6100/6200) */ } return -1; @@ -6360,7 +6367,7 @@ static int zcxx_s_ctrl(struct v4l2_ctrl *ctrl) if (ctrl->val <= jpeg_qual[i]) break; } - if (i > 0 && i == qual && ctrl->val < jpeg_qual[i]) + if (i == ARRAY_SIZE(jpeg_qual) || (i > 0 && i == qual && ctrl->val < jpeg_qual[i])) i--; /* With high quality settings we need max bandwidth */ @@ -6442,6 +6449,9 @@ static int sd_init_controls(struct gspca_dev *gspca_dev) if (sd->sensor == SENSOR_HV7131R) sd->exposure = v4l2_ctrl_new_std(hdl, &zcxx_ctrl_ops, V4L2_CID_EXPOSURE, 0x30d, 0x493e, 1, 0x927); + else if (sd->sensor == SENSOR_OV7620) + sd->exposure = v4l2_ctrl_new_std(hdl, &zcxx_ctrl_ops, + V4L2_CID_EXPOSURE, 0, 255, 1, 0x41); sd->autogain = v4l2_ctrl_new_std(hdl, &zcxx_ctrl_ops, V4L2_CID_AUTOGAIN, 0, 1, 1, 1); if (sd->sensor != SENSOR_OV7630C) @@ -6461,7 +6471,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev) return hdl->error; } v4l2_ctrl_cluster(3, &sd->gamma); - if (sd->sensor == SENSOR_HV7131R) + if (sd->sensor == SENSOR_HV7131R || sd->sensor == SENSOR_OV7620) v4l2_ctrl_auto_cluster(2, &sd->autogain, 0, true); return 0; } @@ -6496,19 +6506,20 @@ static int sd_init(struct gspca_dev *gspca_dev) sensor = zcxx_probeSensor(gspca_dev); if (sensor >= 0) - PDEBUG(D_PROBE, "probe sensor -> %04x", sensor); + gspca_dbg(gspca_dev, D_PROBE, "probe sensor -> %04x\n", sensor); if ((unsigned) force_sensor < SENSOR_MAX) { sd->sensor = force_sensor; - PDEBUG(D_PROBE, "sensor forced to %d", force_sensor); + gspca_dbg(gspca_dev, D_PROBE, "sensor forced to %d\n", + force_sensor); } else { switch (sensor) { case -1: switch (sd->sensor) { case SENSOR_MC501CB: - PDEBUG(D_PROBE, "Sensor MC501CB"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor MC501CB\n"); break; case SENSOR_GC0303: - PDEBUG(D_PROBE, "Sensor GC0303"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor GC0303\n"); break; default: pr_warn("Unknown sensor - set to TAS5130C\n"); @@ -6518,100 +6529,101 @@ static int sd_init(struct gspca_dev *gspca_dev) case 0: /* check the sensor type */ sensor = i2c_read(gspca_dev, 0x00); - PDEBUG(D_PROBE, "Sensor hv7131 type %d", sensor); + gspca_dbg(gspca_dev, D_PROBE, "Sensor hv7131 type %d\n", + sensor); switch (sensor) { case 0: /* hv7131b */ case 1: /* hv7131e */ - PDEBUG(D_PROBE, "Find Sensor HV7131B"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131B\n"); sd->sensor = SENSOR_HV7131B; break; default: /* case 2: * hv7131r */ - PDEBUG(D_PROBE, "Find Sensor HV7131R"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131R\n"); sd->sensor = SENSOR_HV7131R; break; } break; case 0x02: - PDEBUG(D_PROBE, "Sensor TAS5130C"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor TAS5130C\n"); sd->sensor = SENSOR_TAS5130C; break; case 0x04: - PDEBUG(D_PROBE, "Find Sensor CS2102"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor CS2102\n"); sd->sensor = SENSOR_CS2102; break; case 0x08: - PDEBUG(D_PROBE, "Find Sensor HDCS2020"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HDCS2020\n"); sd->sensor = SENSOR_HDCS2020; break; case 0x0a: - PDEBUG(D_PROBE, - "Find Sensor PB0330. Chip revision %x", - sd->chip_revision); + gspca_dbg(gspca_dev, D_PROBE, + "Find Sensor PB0330. Chip revision %x\n", + sd->chip_revision); sd->sensor = SENSOR_PB0330; break; case 0x0c: - PDEBUG(D_PROBE, "Find Sensor ICM105A"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor ICM105A\n"); sd->sensor = SENSOR_ICM105A; break; case 0x0e: - PDEBUG(D_PROBE, "Find Sensor PAS202B"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PAS202B\n"); sd->sensor = SENSOR_PAS202B; break; case 0x0f: - PDEBUG(D_PROBE, "Find Sensor PAS106"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PAS106\n"); sd->sensor = SENSOR_PAS106; break; case 0x10: case 0x12: - PDEBUG(D_PROBE, "Find Sensor TAS5130C"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor TAS5130C\n"); sd->sensor = SENSOR_TAS5130C; break; case 0x11: - PDEBUG(D_PROBE, "Find Sensor HV7131R"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131R\n"); sd->sensor = SENSOR_HV7131R; break; case 0x13: case 0x15: - PDEBUG(D_PROBE, - "Sensor MT9V111. Chip revision %04x", - sd->chip_revision); + gspca_dbg(gspca_dev, D_PROBE, + "Sensor MT9V111. Chip revision %04x\n", + sd->chip_revision); sd->sensor = sd->bridge == BRIDGE_ZC301 ? SENSOR_MT9V111_1 : SENSOR_MT9V111_3; break; case 0x14: - PDEBUG(D_PROBE, - "Find Sensor CS2102K?. Chip revision %x", - sd->chip_revision); + gspca_dbg(gspca_dev, D_PROBE, + "Find Sensor CS2102K?. Chip revision %x\n", + sd->chip_revision); sd->sensor = SENSOR_CS2102K; break; case 0x16: - PDEBUG(D_PROBE, "Find Sensor ADCM2700"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor ADCM2700\n"); sd->sensor = SENSOR_ADCM2700; break; case 0x29: - PDEBUG(D_PROBE, "Find Sensor GC0305"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor GC0305\n"); sd->sensor = SENSOR_GC0305; break; case 0x0303: - PDEBUG(D_PROBE, "Sensor GC0303"); + gspca_dbg(gspca_dev, D_PROBE, "Sensor GC0303\n"); sd->sensor = SENSOR_GC0303; break; case 0x2030: - PDEBUG(D_PROBE, "Find Sensor PO2030"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PO2030\n"); sd->sensor = SENSOR_PO2030; break; case 0x7620: - PDEBUG(D_PROBE, "Find Sensor OV7620"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7620\n"); sd->sensor = SENSOR_OV7620; break; case 0x7631: - PDEBUG(D_PROBE, "Find Sensor OV7630C"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7630C\n"); sd->sensor = SENSOR_OV7630C; break; case 0x7648: - PDEBUG(D_PROBE, "Find Sensor OV7648"); + gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7648\n"); sd->sensor = SENSOR_OV7620; /* same sensor (?) */ break; default: @@ -6700,7 +6712,8 @@ static int sd_start(struct gspca_dev *gspca_dev) }; /* create the JPEG header */ - jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, + jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height, + gspca_dev->pixfmt.width, 0x21); /* JPEG 422 */ mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; @@ -6753,7 +6766,7 @@ static int sd_start(struct gspca_dev *gspca_dev) case SENSOR_HV7131R: case SENSOR_TAS5130C: reg_r(gspca_dev, 0x0008); - /* fall thru */ + fallthrough; case SENSOR_PO2030: reg_w(gspca_dev, 0x03, 0x0008); break; @@ -6802,7 +6815,7 @@ static int sd_start(struct gspca_dev *gspca_dev) case SENSOR_TAS5130C: reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */ reg_w(gspca_dev, 0x15, 0x01ae); - /* fall thru */ + fallthrough; case SENSOR_PAS202B: case SENSOR_PO2030: /* reg_w(gspca_dev, 0x40, ZC3XX_R117_GGAIN); in win traces */ @@ -6825,8 +6838,7 @@ static int sd_start(struct gspca_dev *gspca_dev) return gspca_dev->usb_err; /* Start the transfer parameters update thread */ - sd->work_thread = create_singlethread_workqueue(KBUILD_MODNAME); - queue_work(sd->work_thread, &sd->work); + schedule_work(&sd->work); return 0; } @@ -6837,12 +6849,9 @@ static void sd_stop0(struct gspca_dev *gspca_dev) { struct sd *sd = (struct sd *) gspca_dev; - if (sd->work_thread != NULL) { - mutex_unlock(&gspca_dev->usb_lock); - destroy_workqueue(sd->work_thread); - mutex_lock(&gspca_dev->usb_lock); - sd->work_thread = NULL; - } + mutex_unlock(&gspca_dev->usb_lock); + flush_work(&sd->work); + mutex_lock(&gspca_dev->usb_lock); if (!gspca_dev->present) return; send_unknown(gspca_dev, sd->sensor); @@ -6904,7 +6913,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, #if IS_ENABLED(CONFIG_INPUT) static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, u8 *data, /* interrupt packet data */ - int len) /* interrput packet length */ + int len) /* interrupt packet length */ { if (len == 8 && data[4] == 1) { input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); |
