aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-09-03 15:47:57 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-09-03 17:36:46 -0400
commitdff6d321d421c4c059aea72be70df3a8a200b8a3 (patch)
tree43a59aec996409c3aa456d5c593dd2801ebc5e05 /drivers/media/video
parent3a1ea7050345734acc3a33b2b00a611b9b7bf640 (diff)
V4L/DVB (8706): Make contrast and brightness work for pac7302.
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/pac7311.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 3c9f2b14ca8c..3abc018f9690 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -82,9 +82,10 @@ static struct ctrl sd_ctrls[] = {
82 .type = V4L2_CTRL_TYPE_INTEGER, 82 .type = V4L2_CTRL_TYPE_INTEGER,
83 .name = "Contrast", 83 .name = "Contrast",
84 .minimum = 0, 84 .minimum = 0,
85 .maximum = 255, 85#define CONTRAST_MAX 255
86 .maximum = CONTRAST_MAX,
86 .step = 1, 87 .step = 1,
87#define CONTRAST_DEF 127 88#define CONTRAST_DEF 60
88 .default_value = CONTRAST_DEF, 89 .default_value = CONTRAST_DEF,
89 }, 90 },
90 .set = sd_setcontrast, 91 .set = sd_setcontrast,
@@ -94,7 +95,7 @@ static struct ctrl sd_ctrls[] = {
94 { 95 {
95 .id = V4L2_CID_SATURATION, 96 .id = V4L2_CID_SATURATION,
96 .type = V4L2_CTRL_TYPE_INTEGER, 97 .type = V4L2_CTRL_TYPE_INTEGER,
97 .name = "Color", 98 .name = "Saturation",
98 .minimum = 0, 99 .minimum = 0,
99 .maximum = 255, 100 .maximum = 255,
100 .step = 1, 101 .step = 1,
@@ -429,13 +430,42 @@ static int sd_config(struct gspca_dev *gspca_dev,
429 return 0; 430 return 0;
430} 431}
431 432
433/* rev 12a only */
434static void setbrightcont(struct gspca_dev *gspca_dev)
435{
436 struct sd *sd = (struct sd *) gspca_dev;
437 int i, v;
438 static const __u8 max[10] =
439 {0x29, 0x33, 0x42, 0x5a, 0x6e, 0x80, 0x9f, 0xbb,
440 0xd4, 0xec};
441 static const __u8 delta[10] =
442 {0x35, 0x33, 0x33, 0x2f, 0x2a, 0x25, 0x1e, 0x17,
443 0x11, 0x0b};
444
445 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
446 for (i = 0; i < 10; i++) {
447 v = max[i];
448 v += (sd->brightness - BRIGHTNESS_MAX)
449 * 150 / BRIGHTNESS_MAX; /* 200 ? */
450 v -= delta[i] * sd->contrast / CONTRAST_MAX;
451 if (v < 0)
452 v = 0;
453 else if (v > 0xff)
454 v = 0xff;
455 reg_w(gspca_dev, 0xa2 + i, v);
456 }
457 reg_w(gspca_dev, 0xdc, 0x01);
458}
459
432static void setbrightness(struct gspca_dev *gspca_dev) 460static void setbrightness(struct gspca_dev *gspca_dev)
433{ 461{
434 struct sd *sd = (struct sd *) gspca_dev; 462 struct sd *sd = (struct sd *) gspca_dev;
435 int brightness; 463 int brightness;
436 464
437 if (sd->sensor == SENSOR_PAC7302) 465 if (sd->sensor == SENSOR_PAC7302) {
466 setbrightcont(gspca_dev);
438 return; 467 return;
468 }
439/*jfm: inverted?*/ 469/*jfm: inverted?*/
440 brightness = BRIGHTNESS_MAX - sd->brightness; 470 brightness = BRIGHTNESS_MAX - sd->brightness;
441 reg_w(gspca_dev, 0xff, 0x04); 471 reg_w(gspca_dev, 0xff, 0x04);
@@ -449,13 +479,14 @@ static void setcontrast(struct gspca_dev *gspca_dev)
449{ 479{
450 struct sd *sd = (struct sd *) gspca_dev; 480 struct sd *sd = (struct sd *) gspca_dev;
451 481
452 if (sd->sensor == SENSOR_PAC7302) 482 if (sd->sensor == SENSOR_PAC7302) {
483 setbrightcont(gspca_dev);
453 return; 484 return;
485 }
454 reg_w(gspca_dev, 0xff, 0x01); 486 reg_w(gspca_dev, 0xff, 0x01);
455 reg_w(gspca_dev, 0x80, sd->contrast); 487 reg_w(gspca_dev, 0x80, sd->contrast);
456 /* load registers to sensor (Bit 0, auto clear) */ 488 /* load registers to sensor (Bit 0, auto clear) */
457 reg_w(gspca_dev, 0x11, 0x01); 489 reg_w(gspca_dev, 0x11, 0x01);
458 PDEBUG(D_CONF|D_STREAM, "contrast: %i", sd->contrast);
459} 490}
460 491
461static void setcolors(struct gspca_dev *gspca_dev) 492static void setcolors(struct gspca_dev *gspca_dev)