aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorErik Andr?n <erik.andren@gmail.com>2008-12-30 13:27:17 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-04-06 20:44:39 -0400
commite4cc4fcc7b85ec32f05343b02229492c06baba1a (patch)
treeb2e3eaea31ec971963dc6532d14521882eec1d3c /drivers
parente335f224e35f413775a549889318afe6bd0342b0 (diff)
V4L/DVB (11411): gspca - m5602: Rework v4l ctrl handling in all sensors
Previously, all sensors allocated a part of a large ctrl vector. Define this vector separately for each sensor instead. Signed-off-by: Erik Andrén <erik.andren@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/m5602/Makefile3
-rw-r--r--drivers/media/video/gspca/m5602/m5602_bridge.h2
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.c2
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.h25
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.c2
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.h35
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.c2
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.h27
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.c3
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.h23
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.c2
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.h29
-rw-r--r--drivers/media/video/gspca/m5602/m5602_sensor.h5
13 files changed, 75 insertions, 85 deletions
diff --git a/drivers/media/video/gspca/m5602/Makefile b/drivers/media/video/gspca/m5602/Makefile
index 226ab4fc9d60..9fa3644f4869 100644
--- a/drivers/media/video/gspca/m5602/Makefile
+++ b/drivers/media/video/gspca/m5602/Makefile
@@ -7,5 +7,4 @@ gspca_m5602-objs := m5602_core.o \
7 m5602_s5k83a.o \ 7 m5602_s5k83a.o \
8 m5602_s5k4aa.o 8 m5602_s5k4aa.o
9 9
10EXTRA_CFLAGS += -Idrivers/media/video/gspca 10EXTRA_CFLAGS += -Idrivers/media/video/gspca \ No newline at end of file
11
diff --git a/drivers/media/video/gspca/m5602/m5602_bridge.h b/drivers/media/video/gspca/m5602/m5602_bridge.h
index a3f3b7a0c7e7..9ff41006673b 100644
--- a/drivers/media/video/gspca/m5602/m5602_bridge.h
+++ b/drivers/media/video/gspca/m5602/m5602_bridge.h
@@ -116,7 +116,7 @@ struct sd {
116 char *name; 116 char *name;
117 117
118 /* A pointer to the currently connected sensor */ 118 /* A pointer to the currently connected sensor */
119 struct m5602_sensor *sensor; 119 const struct m5602_sensor *sensor;
120 120
121 struct sd_desc *desc; 121 struct sd_desc *desc;
122 122
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
index f3e9d8f0efe9..69f8f6ce5811 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
@@ -65,7 +65,7 @@ sensor_found:
65 sd->gspca_dev.cam.cam_mode = mt9m111.modes; 65 sd->gspca_dev.cam.cam_mode = mt9m111.modes;
66 sd->gspca_dev.cam.nmodes = mt9m111.nmodes; 66 sd->gspca_dev.cam.nmodes = mt9m111.nmodes;
67 sd->desc->ctrls = mt9m111.ctrls; 67 sd->desc->ctrls = mt9m111.ctrls;
68 sd->desc->nctrls = mt9m111.nctrls; 68 sd->desc->nctrls = ARRAY_SIZE(mt9m111_ctrls);
69 return 0; 69 return 0;
70} 70}
71 71
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
index e795ab7a36c9..23b8e4f57bbf 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
@@ -94,18 +94,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
94int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val); 94int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
95int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val); 95int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val);
96 96
97static struct m5602_sensor mt9m111 = { 97const static struct ctrl mt9m111_ctrls[] = {
98 .name = "MT9M111",
99
100 .i2c_slave_id = 0xba,
101 .i2c_regW = 2,
102
103 .probe = mt9m111_probe,
104 .init = mt9m111_init,
105 .power_down = mt9m111_power_down,
106
107 .nctrls = 3,
108 .ctrls = {
109 { 98 {
110 { 99 {
111 .id = V4L2_CID_VFLIP, 100 .id = V4L2_CID_VFLIP,
@@ -144,7 +133,17 @@ static struct m5602_sensor mt9m111 = {
144 .set = mt9m111_set_gain, 133 .set = mt9m111_set_gain,
145 .get = mt9m111_get_gain 134 .get = mt9m111_get_gain
146 } 135 }
147 }, 136};
137
138static struct m5602_sensor mt9m111 = {
139 .name = "MT9M111",
140
141 .i2c_slave_id = 0xba,
142 .i2c_regW = 2,
143
144 .probe = mt9m111_probe,
145 .init = mt9m111_init,
146 .power_down = mt9m111_power_down,
148 147
149 .nmodes = 1, 148 .nmodes = 1,
150 .modes = { 149 .modes = {
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c
index 6581479c0b30..a9f6ff17ee95 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c
@@ -113,7 +113,7 @@ sensor_found:
113 sd->gspca_dev.cam.cam_mode = ov9650.modes; 113 sd->gspca_dev.cam.cam_mode = ov9650.modes;
114 sd->gspca_dev.cam.nmodes = ov9650.nmodes; 114 sd->gspca_dev.cam.nmodes = ov9650.nmodes;
115 sd->desc->ctrls = ov9650.ctrls; 115 sd->desc->ctrls = ov9650.ctrls;
116 sd->desc->nctrls = ov9650.nctrls; 116 sd->desc->nctrls = ARRAY_SIZE(ov9650_ctrls);
117 return 0; 117 return 0;
118} 118}
119 119
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.h b/drivers/media/video/gspca/m5602/m5602_ov9650.h
index fe69ddfcb002..ebf7291332cc 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.h
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.h
@@ -156,18 +156,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val);
156int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val); 156int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val);
157int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val); 157int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val);
158 158
159static struct m5602_sensor ov9650 = { 159static struct ctrl ov9650_ctrls[] = {
160 .name = "OV9650",
161 .i2c_slave_id = 0x60,
162 .i2c_regW = 1,
163 .probe = ov9650_probe,
164 .init = ov9650_init,
165 .start = ov9650_start,
166 .stop = ov9650_stop,
167 .power_down = ov9650_power_down,
168
169 .nctrls = 8,
170 .ctrls = {
171 { 160 {
172 { 161 {
173 .id = V4L2_CID_EXPOSURE, 162 .id = V4L2_CID_EXPOSURE,
@@ -267,7 +256,18 @@ static struct m5602_sensor ov9650 = {
267 .set = ov9650_set_auto_gain, 256 .set = ov9650_set_auto_gain,
268 .get = ov9650_get_auto_gain 257 .get = ov9650_get_auto_gain
269 } 258 }
270 }, 259};
260
261static struct m5602_sensor ov9650 = {
262 .name = "OV9650",
263 .i2c_slave_id = 0x60,
264 .i2c_regW = 1,
265 .probe = ov9650_probe,
266 .init = ov9650_init,
267 .start = ov9650_start,
268 .stop = ov9650_stop,
269 .power_down = ov9650_power_down,
270 .ctrls = ov9650_ctrls,
271 271
272 .nmodes = 4, 272 .nmodes = 4,
273 .modes = { 273 .modes = {
@@ -444,19 +444,10 @@ static const unsigned char init_ov9650[][3] =
444 /* Enable denoise, and white-pixel erase */ 444 /* Enable denoise, and white-pixel erase */
445 {SENSOR, OV9650_COM22, 0x23}, 445 {SENSOR, OV9650_COM22, 0x23},
446 446
447 /* Set the high bits of the exposure value */
448 {SENSOR, OV9650_AECH, ((EXPOSURE_DEFAULT & 0xff00) >> 8)},
449
450 /* Enable VARIOPIXEL */ 447 /* Enable VARIOPIXEL */
451 {SENSOR, OV9650_COM3, OV9650_VARIOPIXEL}, 448 {SENSOR, OV9650_COM3, OV9650_VARIOPIXEL},
452 {SENSOR, OV9650_COM4, OV9650_QVGA_VARIOPIXEL}, 449 {SENSOR, OV9650_COM4, OV9650_QVGA_VARIOPIXEL},
453 450
454 /* Set the low bits of the exposure value */
455 {SENSOR, OV9650_COM1, (EXPOSURE_DEFAULT & 0xff)},
456 {SENSOR, OV9650_GAIN, GAIN_DEFAULT},
457 {SENSOR, OV9650_BLUE, BLUE_GAIN_DEFAULT},
458 {SENSOR, OV9650_RED, RED_GAIN_DEFAULT},
459
460 /* Put the sensor in soft sleep mode */ 451 /* Put the sensor in soft sleep mode */
461 {SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X}, 452 {SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X},
462}; 453};
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.c b/drivers/media/video/gspca/m5602/m5602_po1030.c
index d509330f5f51..7914dcc6e2a2 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.c
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.c
@@ -62,7 +62,7 @@ sensor_found:
62 sd->gspca_dev.cam.cam_mode = po1030.modes; 62 sd->gspca_dev.cam.cam_mode = po1030.modes;
63 sd->gspca_dev.cam.nmodes = po1030.nmodes; 63 sd->gspca_dev.cam.nmodes = po1030.nmodes;
64 sd->desc->ctrls = po1030.ctrls; 64 sd->desc->ctrls = po1030.ctrls;
65 sd->desc->nctrls = po1030.nctrls; 65 sd->desc->nctrls = ARRAY_SIZE(po1030_ctrls);
66 return 0; 66 return 0;
67} 67}
68 68
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h
index def39d5bcec6..afd776a07f9d 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.h
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.h
@@ -141,18 +141,7 @@ int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
141int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); 141int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
142int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val); 142int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
143 143
144static struct m5602_sensor po1030 = { 144static struct ctrl po1030_ctrls[] = {
145 .name = "PO1030",
146
147 .i2c_slave_id = 0xdc,
148 .i2c_regW = 1,
149
150 .probe = po1030_probe,
151 .init = po1030_init,
152 .power_down = po1030_power_down,
153
154 .nctrls = 6,
155 .ctrls = {
156 { 145 {
157 { 146 {
158 .id = V4L2_CID_GAIN, 147 .id = V4L2_CID_GAIN,
@@ -230,7 +219,19 @@ static struct m5602_sensor po1030 = {
230 .set = po1030_set_vflip, 219 .set = po1030_set_vflip,
231 .get = po1030_get_vflip 220 .get = po1030_get_vflip
232 } 221 }
233 }, 222};
223
224static struct m5602_sensor po1030 = {
225 .name = "PO1030",
226
227 .i2c_slave_id = 0xdc,
228 .i2c_regW = 1,
229
230 .probe = po1030_probe,
231 .init = po1030_init,
232 .power_down = po1030_power_down,
233
234 .ctrls = po1030_ctrls,
234 235
235 .nmodes = 1, 236 .nmodes = 1,
236 .modes = { 237 .modes = {
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
index 921d009e02c4..b7f1b045dca7 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
@@ -118,8 +118,7 @@ sensor_found:
118 sd->gspca_dev.cam.cam_mode = s5k4aa.modes; 118 sd->gspca_dev.cam.cam_mode = s5k4aa.modes;
119 sd->gspca_dev.cam.nmodes = s5k4aa.nmodes; 119 sd->gspca_dev.cam.nmodes = s5k4aa.nmodes;
120 sd->desc->ctrls = s5k4aa.ctrls; 120 sd->desc->ctrls = s5k4aa.ctrls;
121 sd->desc->nctrls = s5k4aa.nctrls; 121 sd->desc->nctrls = ARRAY_SIZE(s5k4aa_ctrls);
122
123 return 0; 122 return 0;
124} 123}
125 124
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
index 0c08ccffc7ff..33ba1621bc69 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
@@ -77,16 +77,7 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
77int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val); 77int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
78int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val); 78int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val);
79 79
80static struct m5602_sensor s5k4aa = { 80static struct ctrl s5k4aa_ctrls[] = {
81 .name = "S5K4AA",
82 .probe = s5k4aa_probe,
83 .init = s5k4aa_init,
84 .start = s5k4aa_start,
85 .power_down = s5k4aa_power_down,
86 .i2c_slave_id = 0x5a,
87 .i2c_regW = 2,
88 .nctrls = 4,
89 .ctrls = {
90 { 81 {
91 { 82 {
92 .id = V4L2_CID_VFLIP, 83 .id = V4L2_CID_VFLIP,
@@ -140,7 +131,17 @@ static struct m5602_sensor s5k4aa = {
140 .set = s5k4aa_set_exposure, 131 .set = s5k4aa_set_exposure,
141 .get = s5k4aa_get_exposure 132 .get = s5k4aa_get_exposure
142 } 133 }
143 }, 134};
135
136static struct m5602_sensor s5k4aa = {
137 .name = "S5K4AA",
138 .probe = s5k4aa_probe,
139 .init = s5k4aa_init,
140 .start = s5k4aa_start,
141 .power_down = s5k4aa_power_down,
142 .i2c_slave_id = 0x5a,
143 .i2c_regW = 2,
144 .ctrls = s5k4aa_ctrls,
144 145
145 .nmodes = 1, 146 .nmodes = 1,
146 .modes = { 147 .modes = {
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
index 5ce69d74dac9..6880b31575c7 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
@@ -66,7 +66,7 @@ sensor_found:
66 sd->gspca_dev.cam.cam_mode = s5k83a.modes; 66 sd->gspca_dev.cam.cam_mode = s5k83a.modes;
67 sd->gspca_dev.cam.nmodes = s5k83a.nmodes; 67 sd->gspca_dev.cam.nmodes = s5k83a.nmodes;
68 sd->desc->ctrls = s5k83a.ctrls; 68 sd->desc->ctrls = s5k83a.ctrls;
69 sd->desc->nctrls = s5k83a.nctrls; 69 sd->desc->nctrls = ARRAY_SIZE(s5k83a_ctrls);
70 return 0; 70 return 0;
71} 71}
72 72
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
index 40ed14165c2a..ed74d9734972 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
@@ -61,17 +61,7 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
61int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); 61int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
62int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val); 62int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
63 63
64static struct m5602_sensor s5k83a = { 64static struct ctrl s5k83a_ctrls[] = {
65 .name = "S5K83A",
66 .probe = s5k83a_probe,
67 .init = s5k83a_init,
68 .start = s5k83a_start,
69 .stop = s5k83a_stop,
70 .power_down = s5k83a_power_down,
71 .i2c_slave_id = 0x5a,
72 .i2c_regW = 2,
73 .nctrls = 5,
74 .ctrls = {
75 { 65 {
76 { 66 {
77 .id = V4L2_CID_BRIGHTNESS, 67 .id = V4L2_CID_BRIGHTNESS,
@@ -136,8 +126,21 @@ static struct m5602_sensor s5k83a = {
136 }, 126 },
137 .set = s5k83a_set_vflip, 127 .set = s5k83a_set_vflip,
138 .get = s5k83a_get_vflip 128 .get = s5k83a_get_vflip
139 } 129 }
140 }, 130};
131
132
133static struct m5602_sensor s5k83a = {
134 .name = "S5K83A",
135 .probe = s5k83a_probe,
136 .init = s5k83a_init,
137 .start = s5k83a_start,
138 .stop = s5k83a_stop,
139 .power_down = s5k83a_power_down,
140 .i2c_slave_id = 0x5a,
141 .i2c_regW = 2,
142 .ctrls = s5k83a_ctrls,
143
141 .nmodes = 1, 144 .nmodes = 1,
142 .modes = { 145 .modes = {
143 { 146 {
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h
index 8eed4cc0b413..5867ee258918 100644
--- a/drivers/media/video/gspca/m5602/m5602_sensor.h
+++ b/drivers/media/video/gspca/m5602/m5602_sensor.h
@@ -24,8 +24,6 @@
24#define M5602_DEFAULT_FRAME_WIDTH 640 24#define M5602_DEFAULT_FRAME_WIDTH 640
25#define M5602_DEFAULT_FRAME_HEIGHT 480 25#define M5602_DEFAULT_FRAME_HEIGHT 480
26 26
27#define M5602_MAX_CTRLS (V4L2_CID_LASTP1 - V4L2_CID_BASE + 10)
28
29/* Enumerates all supported sensors */ 27/* Enumerates all supported sensors */
30enum sensors { 28enum sensors {
31 OV9650_SENSOR = 1, 29 OV9650_SENSOR = 1,
@@ -67,8 +65,7 @@ struct m5602_sensor {
67 /* Performs a power down sequence */ 65 /* Performs a power down sequence */
68 int (*power_down)(struct sd *sd); 66 int (*power_down)(struct sd *sd);
69 67
70 int nctrls; 68 const struct ctrl *ctrls;
71 struct ctrl ctrls[M5602_MAX_CTRLS];
72 69
73 char nmodes; 70 char nmodes;
74 struct v4l2_pix_format modes[]; 71 struct v4l2_pix_format modes[];