diff options
author | Erik Andrén <erik.andren@gmail.com> | 2009-01-22 02:04:59 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:48 -0400 |
commit | c9304e43fb71ad790c5fc995de55e7c95abe5b4a (patch) | |
tree | e4abe51049299f85265f488e71a668cf41b3e363 /drivers/media/video/gspca/m5602 | |
parent | 2b622e2d0022fd9220d6f712ab59bff768c098e7 (diff) |
V4L/DVB (11642): gspca - m5602-ov7660: Add a gain ctrl
Signed-off-by: Erik Andrén <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/m5602')
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_ov7660.c | 65 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_ov7660.h | 2 |
2 files changed, 62 insertions, 5 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.c b/drivers/media/video/gspca/m5602/m5602_ov7660.c index 1c20a3bfaaff..bfa28de6cbb0 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov7660.c +++ b/drivers/media/video/gspca/m5602/m5602_ov7660.c | |||
@@ -18,7 +18,26 @@ | |||
18 | 18 | ||
19 | #include "m5602_ov7660.h" | 19 | #include "m5602_ov7660.h" |
20 | 20 | ||
21 | const static struct ctrl ov7660_ctrls[] = {}; | 21 | static int ov7660_get_gain(struct gspca_dev *gspca_dev, __s32 *val); |
22 | static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val); | ||
23 | |||
24 | const static struct ctrl ov7660_ctrls[] = { | ||
25 | #define GAIN_IDX 1 | ||
26 | { | ||
27 | { | ||
28 | .id = V4L2_CID_GAIN, | ||
29 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
30 | .name = "gain", | ||
31 | .minimum = 0x00, | ||
32 | .maximum = 0xff, | ||
33 | .step = 0x1, | ||
34 | .default_value = DEFAULT_GAIN, | ||
35 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
36 | }, | ||
37 | .set = ov7660_set_gain, | ||
38 | .get = ov7660_get_gain | ||
39 | }, | ||
40 | }; | ||
22 | 41 | ||
23 | static struct v4l2_pix_format ov7660_modes[] = { | 42 | static struct v4l2_pix_format ov7660_modes[] = { |
24 | { | 43 | { |
@@ -85,6 +104,11 @@ int ov7660_probe(struct sd *sd) | |||
85 | return -ENODEV; | 104 | return -ENODEV; |
86 | 105 | ||
87 | sensor_found: | 106 | sensor_found: |
107 | sensor_settings = kmalloc( | ||
108 | ARRAY_SIZE(ov7660_ctrls) * sizeof(s32), GFP_KERNEL); | ||
109 | if (!sensor_settings) | ||
110 | return -ENOMEM; | ||
111 | |||
88 | sd->gspca_dev.cam.cam_mode = ov7660_modes; | 112 | sd->gspca_dev.cam.cam_mode = ov7660_modes; |
89 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov7660_modes); | 113 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov7660_modes); |
90 | sd->desc->ctrls = ov7660_ctrls; | 114 | sd->desc->ctrls = ov7660_ctrls; |
@@ -100,6 +124,7 @@ sensor_found: | |||
100 | int ov7660_init(struct sd *sd) | 124 | int ov7660_init(struct sd *sd) |
101 | { | 125 | { |
102 | int i, err = 0; | 126 | int i, err = 0; |
127 | s32 *sensor_settings = sd->sensor_priv; | ||
103 | 128 | ||
104 | /* Init the sensor */ | 129 | /* Init the sensor */ |
105 | for (i = 0; i < ARRAY_SIZE(init_ov7660); i++) { | 130 | for (i = 0; i < ARRAY_SIZE(init_ov7660); i++) { |
@@ -119,6 +144,10 @@ int ov7660_init(struct sd *sd) | |||
119 | if (dump_sensor) | 144 | if (dump_sensor) |
120 | ov7660_dump_registers(sd); | 145 | ov7660_dump_registers(sd); |
121 | 146 | ||
147 | err = ov7660_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]); | ||
148 | if (err < 0) | ||
149 | return err; | ||
150 | |||
122 | return err; | 151 | return err; |
123 | } | 152 | } |
124 | 153 | ||
@@ -132,7 +161,38 @@ int ov7660_stop(struct sd *sd) | |||
132 | return 0; | 161 | return 0; |
133 | } | 162 | } |
134 | 163 | ||
135 | void ov7660_disconnect(struct sd *sd) {} | 164 | void ov7660_disconnect(struct sd *sd) |
165 | { | ||
166 | ov7660_stop(sd); | ||
167 | |||
168 | sd->sensor = NULL; | ||
169 | kfree(sd->sensor_priv); | ||
170 | } | ||
171 | |||
172 | static int ov7660_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | ||
173 | { | ||
174 | struct sd *sd = (struct sd *) gspca_dev; | ||
175 | s32 *sensor_settings = sd->sensor_priv; | ||
176 | |||
177 | *val = sensor_settings[GAIN_IDX]; | ||
178 | PDEBUG(D_V4L2, "Read gain %d", *val); | ||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val) | ||
183 | { | ||
184 | int err; | ||
185 | u8 i2c_data; | ||
186 | struct sd *sd = (struct sd *) gspca_dev; | ||
187 | s32 *sensor_settings = sd->sensor_priv; | ||
188 | |||
189 | PDEBUG(D_V4L2, "Setting gain to %d", val); | ||
190 | |||
191 | sensor_settings[GAIN_IDX] = val; | ||
192 | |||
193 | err = m5602_write_sensor(sd, OV7660_GAIN, &i2c_data, 1); | ||
194 | return err; | ||
195 | } | ||
136 | 196 | ||
137 | static void ov7660_dump_registers(struct sd *sd) | 197 | static void ov7660_dump_registers(struct sd *sd) |
138 | { | 198 | { |
@@ -165,4 +225,3 @@ static void ov7660_dump_registers(struct sd *sd) | |||
165 | m5602_write_sensor(sd, address, &old_value, 1); | 225 | m5602_write_sensor(sd, address, &old_value, 1); |
166 | } | 226 | } |
167 | } | 227 | } |
168 | |||
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.h b/drivers/media/video/gspca/m5602/m5602_ov7660.h index 15ab706d5dd3..570715fff763 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov7660.h +++ b/drivers/media/video/gspca/m5602/m5602_ov7660.h | |||
@@ -179,7 +179,6 @@ static const unsigned char init_ov7660[][4] = | |||
179 | 179 | ||
180 | {SENSOR, OV7660_AECH, DEFAULT_EXPOSURE}, | 180 | {SENSOR, OV7660_AECH, DEFAULT_EXPOSURE}, |
181 | {SENSOR, OV7660_COM1, 0x00}, | 181 | {SENSOR, OV7660_COM1, 0x00}, |
182 | {SENSOR, OV7660_GAIN, DEFAULT_GAIN}, | ||
183 | 182 | ||
184 | {BRIDGE, M5602_XB_GPIO_DIR, 0x01}, | 183 | {BRIDGE, M5602_XB_GPIO_DIR, 0x01}, |
185 | {BRIDGE, M5602_XB_GPIO_DAT, 0x04}, | 184 | {BRIDGE, M5602_XB_GPIO_DAT, 0x04}, |
@@ -262,7 +261,6 @@ static const unsigned char init_ov7660[][4] = | |||
262 | 261 | ||
263 | {SENSOR, OV7660_AECH, 0x20}, | 262 | {SENSOR, OV7660_AECH, 0x20}, |
264 | {SENSOR, OV7660_COM1, 0x00}, | 263 | {SENSOR, OV7660_COM1, 0x00}, |
265 | {SENSOR, OV7660_GAIN, DEFAULT_GAIN}, | ||
266 | {SENSOR, OV7660_OFON, 0x0c}, | 264 | {SENSOR, OV7660_OFON, 0x0c}, |
267 | {SENSOR, OV7660_COM2, 0x11}, | 265 | {SENSOR, OV7660_COM2, 0x11}, |
268 | {SENSOR, OV7660_COM7, 0x05}, | 266 | {SENSOR, OV7660_COM7, 0x05}, |