aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-12-05 04:18:37 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:38:56 -0500
commit577cbf49cd793c39f149b526309b080ac4ebbad4 (patch)
treebdd1b3c3ab1afaff90aa405d3b759bcae73e066e /drivers/media/video
parent8c252050146fc6f54e9bf5ef8276b25f3dd67a1c (diff)
V4L/DVB (9863): gspca - sonixj: Cleanup / simplify code.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/gspca/sonixj.c65
1 files changed, 34 insertions, 31 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 97056703e17..57232ba96b4 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -37,26 +37,26 @@ struct sd {
37 atomic_t avg_lum; 37 atomic_t avg_lum;
38 unsigned int exposure; 38 unsigned int exposure;
39 39
40 unsigned short brightness; 40 __u16 brightness;
41 unsigned char contrast; 41 __u8 contrast;
42 unsigned char colors; 42 __u8 colors;
43 unsigned char autogain; 43 __u8 autogain;
44 __u8 blue; 44 __u8 blue;
45 __u8 red; 45 __u8 red;
46 __u8 vflip; /* ov7630 only */ 46 __u8 vflip; /* ov7630 only */
47 __u8 infrared; /* mi0360 only */ 47 __u8 infrared; /* mi0360 only */
48 48
49 signed char ag_cnt; 49 __s8 ag_cnt;
50#define AG_CNT_START 13 50#define AG_CNT_START 13
51 51
52 char qindex; 52 __u8 qindex;
53 unsigned char bridge; 53 __u8 bridge;
54#define BRIDGE_SN9C102P 0 54#define BRIDGE_SN9C102P 0
55#define BRIDGE_SN9C105 1 55#define BRIDGE_SN9C105 1
56#define BRIDGE_SN9C110 2 56#define BRIDGE_SN9C110 2
57#define BRIDGE_SN9C120 3 57#define BRIDGE_SN9C120 3
58#define BRIDGE_SN9C325 4 58#define BRIDGE_SN9C325 4
59 char sensor; /* Type of image sensor chip */ 59 __u8 sensor; /* Type of image sensor chip */
60#define SENSOR_HV7131R 0 60#define SENSOR_HV7131R 0
61#define SENSOR_MI0360 1 61#define SENSOR_MI0360 1
62#define SENSOR_MO4000 2 62#define SENSOR_MO4000 2
@@ -64,7 +64,7 @@ struct sd {
64#define SENSOR_OV7630 4 64#define SENSOR_OV7630 4
65#define SENSOR_OV7648 5 65#define SENSOR_OV7648 5
66#define SENSOR_OV7660 6 66#define SENSOR_OV7660 6
67 unsigned char i2c_base; 67 __u8 i2c_base;
68}; 68};
69 69
70/* V4L2 controls supported by the driver */ 70/* V4L2 controls supported by the driver */
@@ -207,6 +207,24 @@ static struct ctrl sd_ctrls[] = {
207 }, 207 },
208}; 208};
209 209
210/* table of the disabled controls */
211static __u32 ctrl_dis[] = {
212 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
213 /* SENSOR_HV7131R 0 */
214 (1 << VFLIP_IDX),
215 /* SENSOR_MI0360 1 */
216 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
217 /* SENSOR_MO4000 2 */
218 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
219 /* SENSOR_OM6802 3 */
220 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX),
221 /* SENSOR_OV7630 4 */
222 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
223 /* SENSOR_OV7648 5 */
224 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
225 /* SENSOR_OV7660 6 */
226};
227
210static struct v4l2_pix_format vga_mode[] = { 228static struct v4l2_pix_format vga_mode[] = {
211 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 229 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
212 .bytesperline = 160, 230 .bytesperline = 160,
@@ -801,8 +819,6 @@ static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg)
801 819
802static int probesensor(struct gspca_dev *gspca_dev) 820static int probesensor(struct gspca_dev *gspca_dev)
803{ 821{
804 struct sd *sd = (struct sd *) gspca_dev;
805
806 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ 822 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
807 msleep(10); 823 msleep(10);
808 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */ 824 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
@@ -814,8 +830,7 @@ static int probesensor(struct gspca_dev *gspca_dev)
814 && gspca_dev->usb_buf[3] == 0x00 830 && gspca_dev->usb_buf[3] == 0x00
815 && gspca_dev->usb_buf[4] == 0x00) { 831 && gspca_dev->usb_buf[4] == 0x00) {
816 PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R"); 832 PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
817 sd->sensor = SENSOR_HV7131R; 833 return 0;
818 return SENSOR_HV7131R;
819 } 834 }
820 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x", 835 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
821 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], 836 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
@@ -1022,17 +1037,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
1022 sd->vflip = VFLIP_DEF; 1037 sd->vflip = VFLIP_DEF;
1023 sd->infrared = INFRARED_DEF; 1038 sd->infrared = INFRARED_DEF;
1024 1039
1025 switch (sd->sensor) { 1040 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1026 case SENSOR_OV7630:
1027 case SENSOR_OV7648:
1028 case SENSOR_OV7660:
1029 gspca_dev->ctrl_dis = (1 << AUTOGAIN_IDX);
1030 break;
1031 }
1032 if (sd->sensor != SENSOR_OV7630)
1033 gspca_dev->ctrl_dis |= (1 << VFLIP_IDX);
1034 if (sd->sensor != SENSOR_MI0360)
1035 gspca_dev->ctrl_dis |= (1 << INFRARED_IDX);
1036 return 0; 1041 return 0;
1037} 1042}
1038 1043
@@ -1040,7 +1045,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
1040static int sd_init(struct gspca_dev *gspca_dev) 1045static int sd_init(struct gspca_dev *gspca_dev)
1041{ 1046{
1042 struct sd *sd = (struct sd *) gspca_dev; 1047 struct sd *sd = (struct sd *) gspca_dev;
1043/* const __u8 *sn9c1xx; */
1044 __u8 regGpio[] = { 0x29, 0x74 }; 1048 __u8 regGpio[] = { 0x29, 0x74 };
1045 __u8 regF1; 1049 __u8 regF1;
1046 1050
@@ -1194,13 +1198,16 @@ static void setcontrast(struct gspca_dev *gspca_dev)
1194{ 1198{
1195 struct sd *sd = (struct sd *) gspca_dev; 1199 struct sd *sd = (struct sd *) gspca_dev;
1196 __u8 k2; 1200 __u8 k2;
1197 __u8 contrast[] = { 0x00, 0x00, 0x28, 0x00, 0x07, 0x00 }; 1201 __u8 contrast[6];
1198 1202
1199 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ 1203 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1200 contrast[0] = (k2 + 1) / 2; /* red */ 1204 contrast[0] = (k2 + 1) / 2; /* red */
1205 contrast[1] = 0;
1201 contrast[2] = k2; /* green */ 1206 contrast[2] = k2; /* green */
1207 contrast[3] = 0;
1202 contrast[4] = (k2 + 1) / 5; /* blue */ 1208 contrast[4] = (k2 + 1) / 5; /* blue */
1203 reg_w(gspca_dev, 0x84, contrast, 6); 1209 contrast[5] = 0;
1210 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
1204} 1211}
1205 1212
1206static void setcolors(struct gspca_dev *gspca_dev) 1213static void setcolors(struct gspca_dev *gspca_dev)
@@ -1365,10 +1372,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
1365 ov7648_InitSensor(gspca_dev); 1372 ov7648_InitSensor(gspca_dev);
1366 reg17 = 0x21; 1373 reg17 = 0x21;
1367/* reg1 = 0x42; * 42 - 46? */ 1374/* reg1 = 0x42; * 42 - 46? */
1368/* if (mode)
1369 ; * 320x2...
1370 else
1371 ; * 640x... */
1372 break; 1375 break;
1373 default: 1376 default:
1374/* case SENSOR_OV7660: */ 1377/* case SENSOR_OV7660: */