aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/gspca/mars.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index adec5be646a7..a81536e78698 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -34,6 +34,8 @@ enum e_ctrl {
34 COLORS, 34 COLORS,
35 GAMMA, 35 GAMMA,
36 SHARPNESS, 36 SHARPNESS,
37 ILLUM_TOP,
38 ILLUM_BOT,
37 NCTRLS /* number of controls */ 39 NCTRLS /* number of controls */
38}; 40};
39 41
@@ -56,6 +58,8 @@ static void setbrightness(struct gspca_dev *gspca_dev);
56static void setcolors(struct gspca_dev *gspca_dev); 58static void setcolors(struct gspca_dev *gspca_dev);
57static void setgamma(struct gspca_dev *gspca_dev); 59static void setgamma(struct gspca_dev *gspca_dev);
58static void setsharpness(struct gspca_dev *gspca_dev); 60static void setsharpness(struct gspca_dev *gspca_dev);
61static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val);
62static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val);
59 63
60static const struct ctrl sd_ctrls[NCTRLS] = { 64static const struct ctrl sd_ctrls[NCTRLS] = {
61[BRIGHTNESS] = { 65[BRIGHTNESS] = {
@@ -106,6 +110,32 @@ static const struct ctrl sd_ctrls[NCTRLS] = {
106 }, 110 },
107 .set_control = setsharpness 111 .set_control = setsharpness
108 }, 112 },
113[ILLUM_TOP] = {
114 {
115 .id = V4L2_CID_ILLUMINATORS_1,
116 .type = V4L2_CTRL_TYPE_BOOLEAN,
117 .name = "Top illuminator",
118 .minimum = 0,
119 .maximum = 1,
120 .step = 1,
121 .default_value = 0,
122 .flags = V4L2_CTRL_FLAG_UPDATE,
123 },
124 .set = sd_setilluminator1
125 },
126[ILLUM_BOT] = {
127 {
128 .id = V4L2_CID_ILLUMINATORS_2,
129 .type = V4L2_CTRL_TYPE_BOOLEAN,
130 .name = "Bottom illuminator",
131 .minimum = 0,
132 .maximum = 1,
133 .step = 1,
134 .default_value = 0,
135 .flags = V4L2_CTRL_FLAG_UPDATE,
136 },
137 .set = sd_setilluminator2
138 },
109}; 139};
110 140
111static const struct v4l2_pix_format vga_mode[] = { 141static const struct v4l2_pix_format vga_mode[] = {
@@ -205,6 +235,20 @@ static void setsharpness(struct gspca_dev *gspca_dev)
205 reg_w(gspca_dev, 2); 235 reg_w(gspca_dev, 2);
206} 236}
207 237
238static void setilluminators(struct gspca_dev *gspca_dev)
239{
240 struct sd *sd = (struct sd *) gspca_dev;
241
242 gspca_dev->usb_buf[0] = 0x22;
243 if (sd->ctrls[ILLUM_TOP].val)
244 gspca_dev->usb_buf[1] = 0x76;
245 else if (sd->ctrls[ILLUM_BOT].val)
246 gspca_dev->usb_buf[1] = 0x7a;
247 else
248 gspca_dev->usb_buf[1] = 0x7e;
249 reg_w(gspca_dev, 2);
250}
251
208/* this function is called at probe time */ 252/* this function is called at probe time */
209static int sd_config(struct gspca_dev *gspca_dev, 253static int sd_config(struct gspca_dev *gspca_dev,
210 const struct usb_device_id *id) 254 const struct usb_device_id *id)
@@ -224,6 +268,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
224/* this function is called at probe and resume time */ 268/* this function is called at probe and resume time */
225static int sd_init(struct gspca_dev *gspca_dev) 269static int sd_init(struct gspca_dev *gspca_dev)
226{ 270{
271 gspca_dev->ctrl_inac = (1 << ILLUM_TOP) | (1 << ILLUM_BOT);
227 return 0; 272 return 0;
228} 273}
229 274
@@ -319,11 +364,22 @@ static int sd_start(struct gspca_dev *gspca_dev)
319 data[1] = 0x4d; /* ISOC transfering enable... */ 364 data[1] = 0x4d; /* ISOC transfering enable... */
320 reg_w(gspca_dev, 2); 365 reg_w(gspca_dev, 2);
321 366
367 gspca_dev->ctrl_inac = 0; /* activate the illuminator controls */
322 return gspca_dev->usb_err; 368 return gspca_dev->usb_err;
323} 369}
324 370
325static void sd_stopN(struct gspca_dev *gspca_dev) 371static void sd_stopN(struct gspca_dev *gspca_dev)
326{ 372{
373 struct sd *sd = (struct sd *) gspca_dev;
374
375 gspca_dev->ctrl_inac = (1 << ILLUM_TOP) | (1 << ILLUM_BOT);
376 if (sd->ctrls[ILLUM_TOP].val || sd->ctrls[ILLUM_BOT].val) {
377 sd->ctrls[ILLUM_TOP].val = 0;
378 sd->ctrls[ILLUM_BOT].val = 0;
379 setilluminators(gspca_dev);
380 msleep(20);
381 }
382
327 gspca_dev->usb_buf[0] = 1; 383 gspca_dev->usb_buf[0] = 1;
328 gspca_dev->usb_buf[1] = 0; 384 gspca_dev->usb_buf[1] = 0;
329 reg_w(gspca_dev, 2); 385 reg_w(gspca_dev, 2);
@@ -367,6 +423,30 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
367 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 423 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
368} 424}
369 425
426static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val)
427{
428 struct sd *sd = (struct sd *) gspca_dev;
429
430 /* only one illuminator may be on */
431 sd->ctrls[ILLUM_TOP].val = val;
432 if (val)
433 sd->ctrls[ILLUM_BOT].val = 0;
434 setilluminators(gspca_dev);
435 return gspca_dev->usb_err;
436}
437
438static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val)
439{
440 struct sd *sd = (struct sd *) gspca_dev;
441
442 /* only one illuminator may be on */
443 sd->ctrls[ILLUM_BOT].val = val;
444 if (val)
445 sd->ctrls[ILLUM_TOP].val = 0;
446 setilluminators(gspca_dev);
447 return gspca_dev->usb_err;
448}
449
370static int sd_set_jcomp(struct gspca_dev *gspca_dev, 450static int sd_set_jcomp(struct gspca_dev *gspca_dev,
371 struct v4l2_jpegcompression *jcomp) 451 struct v4l2_jpegcompression *jcomp)
372{ 452{