diff options
author | Jean-François Moine <moinejf@free.fr> | 2010-10-02 03:27:02 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-20 23:18:28 -0400 |
commit | 62833acd7d3328d17d18f595b4b074865bf1b7f2 (patch) | |
tree | 2bc3466f04dcaa2924ab60474c25e3c8911db023 /drivers/media/video/gspca/ov519.c | |
parent | 016f2362278b1f235223b12744585676be2a89a7 (diff) |
[media] gspca - ov519: Use the new video control mechanism
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/ov519.c')
-rw-r--r-- | drivers/media/video/gspca/ov519.c | 316 |
1 files changed, 75 insertions, 241 deletions
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index 17b0d51d91e5..2417a7e70a42 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
@@ -57,10 +57,24 @@ static int frame_rate; | |||
57 | * are getting "Failed to read sensor ID..." */ | 57 | * are getting "Failed to read sensor ID..." */ |
58 | static int i2c_detect_tries = 10; | 58 | static int i2c_detect_tries = 10; |
59 | 59 | ||
60 | /* controls */ | ||
61 | enum e_ctrl { | ||
62 | BRIGHTNESS, | ||
63 | CONTRAST, | ||
64 | COLORS, | ||
65 | HFLIP, | ||
66 | VFLIP, | ||
67 | AUTOBRIGHT, | ||
68 | FREQ, | ||
69 | NCTRL /* number of controls */ | ||
70 | }; | ||
71 | |||
60 | /* ov519 device descriptor */ | 72 | /* ov519 device descriptor */ |
61 | struct sd { | 73 | struct sd { |
62 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 74 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
63 | 75 | ||
76 | struct gspca_ctrl ctrls[NCTRL]; | ||
77 | |||
64 | __u8 packet_nr; | 78 | __u8 packet_nr; |
65 | 79 | ||
66 | char bridge; | 80 | char bridge; |
@@ -82,13 +96,6 @@ struct sd { | |||
82 | /* Determined by sensor type */ | 96 | /* Determined by sensor type */ |
83 | __u8 sif; | 97 | __u8 sif; |
84 | 98 | ||
85 | __u8 brightness; | ||
86 | __u8 contrast; | ||
87 | __u8 colors; | ||
88 | __u8 hflip; | ||
89 | __u8 vflip; | ||
90 | __u8 autobrightness; | ||
91 | __u8 freq; | ||
92 | __u8 quality; | 99 | __u8 quality; |
93 | #define QUALITY_MIN 50 | 100 | #define QUALITY_MIN 50 |
94 | #define QUALITY_MAX 70 | 101 | #define QUALITY_MAX 70 |
@@ -130,29 +137,16 @@ struct sd { | |||
130 | #include "w996Xcf.c" | 137 | #include "w996Xcf.c" |
131 | 138 | ||
132 | /* V4L2 controls supported by the driver */ | 139 | /* V4L2 controls supported by the driver */ |
133 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
134 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
135 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | ||
136 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
137 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | ||
138 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | ||
139 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | ||
140 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
141 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | ||
142 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
143 | static int sd_setautobrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
144 | static int sd_getautobrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
145 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | ||
146 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | ||
147 | static void setbrightness(struct gspca_dev *gspca_dev); | 140 | static void setbrightness(struct gspca_dev *gspca_dev); |
148 | static void setcontrast(struct gspca_dev *gspca_dev); | 141 | static void setcontrast(struct gspca_dev *gspca_dev); |
149 | static void setcolors(struct gspca_dev *gspca_dev); | 142 | static void setcolors(struct gspca_dev *gspca_dev); |
150 | static void setautobrightness(struct sd *sd); | 143 | static void sethvflip(struct gspca_dev *gspca_dev); |
151 | static void setfreq(struct sd *sd); | 144 | static void setautobright(struct gspca_dev *gspca_dev); |
145 | static void setfreq(struct gspca_dev *gspca_dev); | ||
146 | static void setfreq_i(struct sd *sd); | ||
152 | 147 | ||
153 | static const struct ctrl sd_ctrls[] = { | 148 | static const struct ctrl sd_ctrls[] = { |
154 | #define BRIGHTNESS_IDX 0 | 149 | [BRIGHTNESS] = { |
155 | { | ||
156 | { | 150 | { |
157 | .id = V4L2_CID_BRIGHTNESS, | 151 | .id = V4L2_CID_BRIGHTNESS, |
158 | .type = V4L2_CTRL_TYPE_INTEGER, | 152 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -160,14 +154,11 @@ static const struct ctrl sd_ctrls[] = { | |||
160 | .minimum = 0, | 154 | .minimum = 0, |
161 | .maximum = 255, | 155 | .maximum = 255, |
162 | .step = 1, | 156 | .step = 1, |
163 | #define BRIGHTNESS_DEF 127 | 157 | .default_value = 127, |
164 | .default_value = BRIGHTNESS_DEF, | ||
165 | }, | 158 | }, |
166 | .set = sd_setbrightness, | 159 | .set_control = setbrightness, |
167 | .get = sd_getbrightness, | ||
168 | }, | 160 | }, |
169 | #define CONTRAST_IDX 1 | 161 | [CONTRAST] = { |
170 | { | ||
171 | { | 162 | { |
172 | .id = V4L2_CID_CONTRAST, | 163 | .id = V4L2_CID_CONTRAST, |
173 | .type = V4L2_CTRL_TYPE_INTEGER, | 164 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -175,14 +166,11 @@ static const struct ctrl sd_ctrls[] = { | |||
175 | .minimum = 0, | 166 | .minimum = 0, |
176 | .maximum = 255, | 167 | .maximum = 255, |
177 | .step = 1, | 168 | .step = 1, |
178 | #define CONTRAST_DEF 127 | 169 | .default_value = 127, |
179 | .default_value = CONTRAST_DEF, | ||
180 | }, | 170 | }, |
181 | .set = sd_setcontrast, | 171 | .set_control = setcontrast, |
182 | .get = sd_getcontrast, | ||
183 | }, | 172 | }, |
184 | #define COLOR_IDX 2 | 173 | [COLORS] = { |
185 | { | ||
186 | { | 174 | { |
187 | .id = V4L2_CID_SATURATION, | 175 | .id = V4L2_CID_SATURATION, |
188 | .type = V4L2_CTRL_TYPE_INTEGER, | 176 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -190,15 +178,12 @@ static const struct ctrl sd_ctrls[] = { | |||
190 | .minimum = 0, | 178 | .minimum = 0, |
191 | .maximum = 255, | 179 | .maximum = 255, |
192 | .step = 1, | 180 | .step = 1, |
193 | #define COLOR_DEF 127 | 181 | .default_value = 127, |
194 | .default_value = COLOR_DEF, | ||
195 | }, | 182 | }, |
196 | .set = sd_setcolors, | 183 | .set_control = setcolors, |
197 | .get = sd_getcolors, | ||
198 | }, | 184 | }, |
199 | /* The flip controls work with ov7670 only */ | 185 | /* The flip controls work with ov7670 only */ |
200 | #define HFLIP_IDX 3 | 186 | [HFLIP] = { |
201 | { | ||
202 | { | 187 | { |
203 | .id = V4L2_CID_HFLIP, | 188 | .id = V4L2_CID_HFLIP, |
204 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 189 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -206,14 +191,11 @@ static const struct ctrl sd_ctrls[] = { | |||
206 | .minimum = 0, | 191 | .minimum = 0, |
207 | .maximum = 1, | 192 | .maximum = 1, |
208 | .step = 1, | 193 | .step = 1, |
209 | #define HFLIP_DEF 0 | 194 | .default_value = 0, |
210 | .default_value = HFLIP_DEF, | ||
211 | }, | 195 | }, |
212 | .set = sd_sethflip, | 196 | .set_control = sethvflip, |
213 | .get = sd_gethflip, | ||
214 | }, | 197 | }, |
215 | #define VFLIP_IDX 4 | 198 | [VFLIP] = { |
216 | { | ||
217 | { | 199 | { |
218 | .id = V4L2_CID_VFLIP, | 200 | .id = V4L2_CID_VFLIP, |
219 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 201 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -221,14 +203,11 @@ static const struct ctrl sd_ctrls[] = { | |||
221 | .minimum = 0, | 203 | .minimum = 0, |
222 | .maximum = 1, | 204 | .maximum = 1, |
223 | .step = 1, | 205 | .step = 1, |
224 | #define VFLIP_DEF 0 | 206 | .default_value = 0, |
225 | .default_value = VFLIP_DEF, | ||
226 | }, | 207 | }, |
227 | .set = sd_setvflip, | 208 | .set_control = sethvflip, |
228 | .get = sd_getvflip, | ||
229 | }, | 209 | }, |
230 | #define AUTOBRIGHT_IDX 5 | 210 | [AUTOBRIGHT] = { |
231 | { | ||
232 | { | 211 | { |
233 | .id = V4L2_CID_AUTOBRIGHTNESS, | 212 | .id = V4L2_CID_AUTOBRIGHTNESS, |
234 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 213 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -236,14 +215,11 @@ static const struct ctrl sd_ctrls[] = { | |||
236 | .minimum = 0, | 215 | .minimum = 0, |
237 | .maximum = 1, | 216 | .maximum = 1, |
238 | .step = 1, | 217 | .step = 1, |
239 | #define AUTOBRIGHT_DEF 1 | 218 | .default_value = 1, |
240 | .default_value = AUTOBRIGHT_DEF, | ||
241 | }, | 219 | }, |
242 | .set = sd_setautobrightness, | 220 | .set_control = setautobright, |
243 | .get = sd_getautobrightness, | ||
244 | }, | 221 | }, |
245 | #define FREQ_IDX 6 | 222 | [FREQ] = { |
246 | { | ||
247 | { | 223 | { |
248 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 224 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
249 | .type = V4L2_CTRL_TYPE_MENU, | 225 | .type = V4L2_CTRL_TYPE_MENU, |
@@ -251,26 +227,9 @@ static const struct ctrl sd_ctrls[] = { | |||
251 | .minimum = 0, | 227 | .minimum = 0, |
252 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ | 228 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ |
253 | .step = 1, | 229 | .step = 1, |
254 | #define FREQ_DEF 0 | 230 | .default_value = 0, |
255 | .default_value = FREQ_DEF, | ||
256 | }, | ||
257 | .set = sd_setfreq, | ||
258 | .get = sd_getfreq, | ||
259 | }, | ||
260 | #define OV7670_FREQ_IDX 7 | ||
261 | { | ||
262 | { | ||
263 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | ||
264 | .type = V4L2_CTRL_TYPE_MENU, | ||
265 | .name = "Light frequency filter", | ||
266 | .minimum = 0, | ||
267 | .maximum = 3, /* 0: 0, 1: 50Hz, 2:60Hz 3: Auto Hz */ | ||
268 | .step = 1, | ||
269 | #define OV7670_FREQ_DEF 3 | ||
270 | .default_value = OV7670_FREQ_DEF, | ||
271 | }, | 231 | }, |
272 | .set = sd_setfreq, | 232 | .set_control = setfreq, |
273 | .get = sd_getfreq, | ||
274 | }, | 233 | }, |
275 | }; | 234 | }; |
276 | 235 | ||
@@ -3139,36 +3098,23 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3139 | goto error; | 3098 | goto error; |
3140 | break; | 3099 | break; |
3141 | } | 3100 | } |
3142 | sd->brightness = BRIGHTNESS_DEF; | 3101 | gspca_dev->cam.ctrls = sd->ctrls; |
3143 | if (sd->sensor == SEN_OV6630 || sd->sensor == SEN_OV66308AF) | 3102 | if (sd->sensor == SEN_OV7670) |
3144 | sd->contrast = 200; /* The default is too low for the ov6630 */ | 3103 | gspca_dev->ctrl_dis = 1 << COLORS; |
3145 | else | 3104 | else |
3146 | sd->contrast = CONTRAST_DEF; | 3105 | gspca_dev->ctrl_dis = (1 << HFLIP) | (1 << VFLIP); |
3147 | sd->colors = COLOR_DEF; | ||
3148 | sd->hflip = HFLIP_DEF; | ||
3149 | sd->vflip = VFLIP_DEF; | ||
3150 | sd->autobrightness = AUTOBRIGHT_DEF; | ||
3151 | if (sd->sensor == SEN_OV7670) { | ||
3152 | sd->freq = OV7670_FREQ_DEF; | ||
3153 | gspca_dev->ctrl_dis = (1 << FREQ_IDX) | (1 << COLOR_IDX); | ||
3154 | } else { | ||
3155 | sd->freq = FREQ_DEF; | ||
3156 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | | ||
3157 | (1 << OV7670_FREQ_IDX); | ||
3158 | } | ||
3159 | sd->quality = QUALITY_DEF; | 3106 | sd->quality = QUALITY_DEF; |
3160 | if (sd->sensor == SEN_OV7640 || | 3107 | if (sd->sensor == SEN_OV7640 || |
3161 | sd->sensor == SEN_OV7648) | 3108 | sd->sensor == SEN_OV7648) |
3162 | gspca_dev->ctrl_dis |= (1 << AUTOBRIGHT_IDX) | | 3109 | gspca_dev->ctrl_dis |= (1 << AUTOBRIGHT) | (1 << CONTRAST); |
3163 | (1 << CONTRAST_IDX); | ||
3164 | if (sd->sensor == SEN_OV7670) | 3110 | if (sd->sensor == SEN_OV7670) |
3165 | gspca_dev->ctrl_dis |= 1 << AUTOBRIGHT_IDX; | 3111 | gspca_dev->ctrl_dis |= 1 << AUTOBRIGHT; |
3166 | /* OV8610 Frequency filter control should work but needs testing */ | 3112 | /* OV8610 Frequency filter control should work but needs testing */ |
3167 | if (sd->sensor == SEN_OV8610) | 3113 | if (sd->sensor == SEN_OV8610) |
3168 | gspca_dev->ctrl_dis |= 1 << FREQ_IDX; | 3114 | gspca_dev->ctrl_dis |= 1 << FREQ; |
3169 | /* No controls for the OV2610/OV3610 */ | 3115 | /* No controls for the OV2610/OV3610 */ |
3170 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) | 3116 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) |
3171 | gspca_dev->ctrl_dis |= 0xFF; | 3117 | gspca_dev->ctrl_dis |= (1 << NCTRL) - 1; |
3172 | 3118 | ||
3173 | return 0; | 3119 | return 0; |
3174 | error: | 3120 | error: |
@@ -3203,6 +3149,8 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
3203 | break; | 3149 | break; |
3204 | case SEN_OV6630: | 3150 | case SEN_OV6630: |
3205 | case SEN_OV66308AF: | 3151 | case SEN_OV66308AF: |
3152 | sd->ctrls[CONTRAST].def = 200; | ||
3153 | /* The default is too low for the ov6630 */ | ||
3206 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | 3154 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) |
3207 | return -EIO; | 3155 | return -EIO; |
3208 | break; | 3156 | break; |
@@ -3225,6 +3173,8 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
3225 | return -EIO; | 3173 | return -EIO; |
3226 | break; | 3174 | break; |
3227 | case SEN_OV7670: | 3175 | case SEN_OV7670: |
3176 | sd->ctrls[FREQ].max = 3; /* auto */ | ||
3177 | sd->ctrls[FREQ].def = 3; | ||
3228 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) | 3178 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) |
3229 | return -EIO; | 3179 | return -EIO; |
3230 | break; | 3180 | break; |
@@ -3795,15 +3745,17 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3795 | return 0; | 3745 | return 0; |
3796 | } | 3746 | } |
3797 | 3747 | ||
3798 | static void sethvflip(struct sd *sd) | 3748 | static void sethvflip(struct gspca_dev *gspca_dev) |
3799 | { | 3749 | { |
3750 | struct sd *sd = (struct sd *) gspca_dev; | ||
3751 | |||
3800 | if (sd->sensor != SEN_OV7670) | 3752 | if (sd->sensor != SEN_OV7670) |
3801 | return; | 3753 | return; |
3802 | if (sd->gspca_dev.streaming) | 3754 | if (sd->gspca_dev.streaming) |
3803 | ov51x_stop(sd); | 3755 | ov51x_stop(sd); |
3804 | i2c_w_mask(sd, OV7670_REG_MVFP, | 3756 | i2c_w_mask(sd, OV7670_REG_MVFP, |
3805 | OV7670_MVFP_MIRROR * sd->hflip | 3757 | OV7670_MVFP_MIRROR * sd->ctrls[HFLIP].val |
3806 | | OV7670_MVFP_VFLIP * sd->vflip, | 3758 | | OV7670_MVFP_VFLIP * sd->ctrls[VFLIP].val, |
3807 | OV7670_MVFP_MIRROR | OV7670_MVFP_VFLIP); | 3759 | OV7670_MVFP_MIRROR | OV7670_MVFP_VFLIP); |
3808 | if (sd->gspca_dev.streaming) | 3760 | if (sd->gspca_dev.streaming) |
3809 | ov51x_restart(sd); | 3761 | ov51x_restart(sd); |
@@ -3954,9 +3906,9 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
3954 | setcontrast(gspca_dev); | 3906 | setcontrast(gspca_dev); |
3955 | setbrightness(gspca_dev); | 3907 | setbrightness(gspca_dev); |
3956 | setcolors(gspca_dev); | 3908 | setcolors(gspca_dev); |
3957 | sethvflip(sd); | 3909 | sethvflip(gspca_dev); |
3958 | setautobrightness(sd); | 3910 | setautobright(gspca_dev); |
3959 | setfreq(sd); | 3911 | setfreq_i(sd); |
3960 | 3912 | ||
3961 | /* Force clear snapshot state in case the snapshot button was | 3913 | /* Force clear snapshot state in case the snapshot button was |
3962 | pressed while we weren't streaming */ | 3914 | pressed while we weren't streaming */ |
@@ -4211,7 +4163,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
4211 | struct sd *sd = (struct sd *) gspca_dev; | 4163 | struct sd *sd = (struct sd *) gspca_dev; |
4212 | int val; | 4164 | int val; |
4213 | 4165 | ||
4214 | val = sd->brightness; | 4166 | val = sd->ctrls[BRIGHTNESS].val; |
4215 | switch (sd->sensor) { | 4167 | switch (sd->sensor) { |
4216 | case SEN_OV8610: | 4168 | case SEN_OV8610: |
4217 | case SEN_OV7610: | 4169 | case SEN_OV7610: |
@@ -4226,7 +4178,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
4226 | case SEN_OV7620: | 4178 | case SEN_OV7620: |
4227 | case SEN_OV7620AE: | 4179 | case SEN_OV7620AE: |
4228 | /* 7620 doesn't like manual changes when in auto mode */ | 4180 | /* 7620 doesn't like manual changes when in auto mode */ |
4229 | if (!sd->autobrightness) | 4181 | if (!sd->ctrls[AUTOBRIGHT].val) |
4230 | i2c_w(sd, OV7610_REG_BRT, val); | 4182 | i2c_w(sd, OV7610_REG_BRT, val); |
4231 | break; | 4183 | break; |
4232 | case SEN_OV7670: | 4184 | case SEN_OV7670: |
@@ -4242,7 +4194,7 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
4242 | struct sd *sd = (struct sd *) gspca_dev; | 4194 | struct sd *sd = (struct sd *) gspca_dev; |
4243 | int val; | 4195 | int val; |
4244 | 4196 | ||
4245 | val = sd->contrast; | 4197 | val = sd->ctrls[CONTRAST].val; |
4246 | switch (sd->sensor) { | 4198 | switch (sd->sensor) { |
4247 | case SEN_OV7610: | 4199 | case SEN_OV7610: |
4248 | case SEN_OV6620: | 4200 | case SEN_OV6620: |
@@ -4284,7 +4236,7 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
4284 | struct sd *sd = (struct sd *) gspca_dev; | 4236 | struct sd *sd = (struct sd *) gspca_dev; |
4285 | int val; | 4237 | int val; |
4286 | 4238 | ||
4287 | val = sd->colors; | 4239 | val = sd->ctrls[COLORS].val; |
4288 | switch (sd->sensor) { | 4240 | switch (sd->sensor) { |
4289 | case SEN_OV8610: | 4241 | case SEN_OV8610: |
4290 | case SEN_OV7610: | 4242 | case SEN_OV7610: |
@@ -4314,23 +4266,25 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
4314 | } | 4266 | } |
4315 | } | 4267 | } |
4316 | 4268 | ||
4317 | static void setautobrightness(struct sd *sd) | 4269 | static void setautobright(struct gspca_dev *gspca_dev) |
4318 | { | 4270 | { |
4271 | struct sd *sd = (struct sd *) gspca_dev; | ||
4272 | |||
4319 | if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7648 || | 4273 | if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7648 || |
4320 | sd->sensor == SEN_OV7670 || | 4274 | sd->sensor == SEN_OV7670 || |
4321 | sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) | 4275 | sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) |
4322 | return; | 4276 | return; |
4323 | 4277 | ||
4324 | i2c_w_mask(sd, 0x2d, sd->autobrightness ? 0x10 : 0x00, 0x10); | 4278 | i2c_w_mask(sd, 0x2d, sd->ctrls[AUTOBRIGHT].val ? 0x10 : 0x00, 0x10); |
4325 | } | 4279 | } |
4326 | 4280 | ||
4327 | static void setfreq(struct sd *sd) | 4281 | static void setfreq_i(struct sd *sd) |
4328 | { | 4282 | { |
4329 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) | 4283 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) |
4330 | return; | 4284 | return; |
4331 | 4285 | ||
4332 | if (sd->sensor == SEN_OV7670) { | 4286 | if (sd->sensor == SEN_OV7670) { |
4333 | switch (sd->freq) { | 4287 | switch (sd->ctrls[FREQ].val) { |
4334 | case 0: /* Banding filter disabled */ | 4288 | case 0: /* Banding filter disabled */ |
4335 | i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_BFILT); | 4289 | i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_BFILT); |
4336 | break; | 4290 | break; |
@@ -4352,7 +4306,7 @@ static void setfreq(struct sd *sd) | |||
4352 | break; | 4306 | break; |
4353 | } | 4307 | } |
4354 | } else { | 4308 | } else { |
4355 | switch (sd->freq) { | 4309 | switch (sd->ctrls[FREQ].val) { |
4356 | case 0: /* Banding filter disabled */ | 4310 | case 0: /* Banding filter disabled */ |
4357 | i2c_w_mask(sd, 0x2d, 0x00, 0x04); | 4311 | i2c_w_mask(sd, 0x2d, 0x00, 0x04); |
4358 | i2c_w_mask(sd, 0x2a, 0x00, 0x80); | 4312 | i2c_w_mask(sd, 0x2a, 0x00, 0x80); |
@@ -4384,135 +4338,15 @@ static void setfreq(struct sd *sd) | |||
4384 | } | 4338 | } |
4385 | } | 4339 | } |
4386 | } | 4340 | } |
4387 | 4341 | static void setfreq(struct gspca_dev *gspca_dev) | |
4388 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
4389 | { | ||
4390 | struct sd *sd = (struct sd *) gspca_dev; | ||
4391 | |||
4392 | sd->brightness = val; | ||
4393 | if (gspca_dev->streaming) | ||
4394 | setbrightness(gspca_dev); | ||
4395 | return 0; | ||
4396 | } | ||
4397 | |||
4398 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
4399 | { | ||
4400 | struct sd *sd = (struct sd *) gspca_dev; | ||
4401 | |||
4402 | *val = sd->brightness; | ||
4403 | return 0; | ||
4404 | } | ||
4405 | |||
4406 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | ||
4407 | { | ||
4408 | struct sd *sd = (struct sd *) gspca_dev; | ||
4409 | |||
4410 | sd->contrast = val; | ||
4411 | if (gspca_dev->streaming) | ||
4412 | setcontrast(gspca_dev); | ||
4413 | return 0; | ||
4414 | } | ||
4415 | |||
4416 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | ||
4417 | { | ||
4418 | struct sd *sd = (struct sd *) gspca_dev; | ||
4419 | |||
4420 | *val = sd->contrast; | ||
4421 | return 0; | ||
4422 | } | ||
4423 | |||
4424 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) | ||
4425 | { | ||
4426 | struct sd *sd = (struct sd *) gspca_dev; | ||
4427 | |||
4428 | sd->colors = val; | ||
4429 | if (gspca_dev->streaming) | ||
4430 | setcolors(gspca_dev); | ||
4431 | return 0; | ||
4432 | } | ||
4433 | |||
4434 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | ||
4435 | { | ||
4436 | struct sd *sd = (struct sd *) gspca_dev; | ||
4437 | |||
4438 | *val = sd->colors; | ||
4439 | return 0; | ||
4440 | } | ||
4441 | |||
4442 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val) | ||
4443 | { | 4342 | { |
4444 | struct sd *sd = (struct sd *) gspca_dev; | 4343 | struct sd *sd = (struct sd *) gspca_dev; |
4445 | 4344 | ||
4446 | sd->hflip = val; | 4345 | setfreq_i(sd); |
4447 | if (gspca_dev->streaming) | ||
4448 | sethvflip(sd); | ||
4449 | return 0; | ||
4450 | } | ||
4451 | |||
4452 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
4453 | { | ||
4454 | struct sd *sd = (struct sd *) gspca_dev; | ||
4455 | 4346 | ||
4456 | *val = sd->hflip; | 4347 | /* Ugly but necessary */ |
4457 | return 0; | 4348 | if (sd->bridge == BRIDGE_W9968CF) |
4458 | } | 4349 | w9968cf_set_crop_window(sd); |
4459 | |||
4460 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) | ||
4461 | { | ||
4462 | struct sd *sd = (struct sd *) gspca_dev; | ||
4463 | |||
4464 | sd->vflip = val; | ||
4465 | if (gspca_dev->streaming) | ||
4466 | sethvflip(sd); | ||
4467 | return 0; | ||
4468 | } | ||
4469 | |||
4470 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
4471 | { | ||
4472 | struct sd *sd = (struct sd *) gspca_dev; | ||
4473 | |||
4474 | *val = sd->vflip; | ||
4475 | return 0; | ||
4476 | } | ||
4477 | |||
4478 | static int sd_setautobrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
4479 | { | ||
4480 | struct sd *sd = (struct sd *) gspca_dev; | ||
4481 | |||
4482 | sd->autobrightness = val; | ||
4483 | if (gspca_dev->streaming) | ||
4484 | setautobrightness(sd); | ||
4485 | return 0; | ||
4486 | } | ||
4487 | |||
4488 | static int sd_getautobrightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
4489 | { | ||
4490 | struct sd *sd = (struct sd *) gspca_dev; | ||
4491 | |||
4492 | *val = sd->autobrightness; | ||
4493 | return 0; | ||
4494 | } | ||
4495 | |||
4496 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) | ||
4497 | { | ||
4498 | struct sd *sd = (struct sd *) gspca_dev; | ||
4499 | |||
4500 | sd->freq = val; | ||
4501 | if (gspca_dev->streaming) { | ||
4502 | setfreq(sd); | ||
4503 | /* Ugly but necessary */ | ||
4504 | if (sd->bridge == BRIDGE_W9968CF) | ||
4505 | w9968cf_set_crop_window(sd); | ||
4506 | } | ||
4507 | return 0; | ||
4508 | } | ||
4509 | |||
4510 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | ||
4511 | { | ||
4512 | struct sd *sd = (struct sd *) gspca_dev; | ||
4513 | |||
4514 | *val = sd->freq; | ||
4515 | return 0; | ||
4516 | } | 4350 | } |
4517 | 4351 | ||
4518 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 4352 | static int sd_querymenu(struct gspca_dev *gspca_dev, |