aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-09-03 15:47:58 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-09-03 17:36:47 -0400
commit41b469745f6218efb22bec4e3940b085ffb97216 (patch)
treed85e5928ad964ce11f4a08a60fdc9b0a22a5ba22 /drivers
parentdff6d321d421c4c059aea72be70df3a8a200b8a3 (diff)
V4L/DVB (8707): gspca: Colors, hflip and vflip controls added for pac7302.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/pac7311.c107
1 files changed, 105 insertions, 2 deletions
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 3abc018f9690..a89cc9fd1531 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -40,6 +40,8 @@ struct sd {
40 unsigned char contrast; 40 unsigned char contrast;
41 unsigned char colors; 41 unsigned char colors;
42 unsigned char autogain; 42 unsigned char autogain;
43 __u8 hflip;
44 __u8 vflip;
43 45
44 char tosof; /* number of bytes before next start of frame */ 46 char tosof; /* number of bytes before next start of frame */
45 signed char ag_cnt; 47 signed char ag_cnt;
@@ -59,6 +61,10 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
59static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); 61static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
60static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); 62static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
61static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 63static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
64static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
65static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
66static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
67static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
62 68
63static struct ctrl sd_ctrls[] = { 69static struct ctrl sd_ctrls[] = {
64 { 70 {
@@ -97,7 +103,8 @@ static struct ctrl sd_ctrls[] = {
97 .type = V4L2_CTRL_TYPE_INTEGER, 103 .type = V4L2_CTRL_TYPE_INTEGER,
98 .name = "Saturation", 104 .name = "Saturation",
99 .minimum = 0, 105 .minimum = 0,
100 .maximum = 255, 106#define COLOR_MAX 255
107 .maximum = COLOR_MAX,
101 .step = 1, 108 .step = 1,
102#define COLOR_DEF 127 109#define COLOR_DEF 127
103 .default_value = COLOR_DEF, 110 .default_value = COLOR_DEF,
@@ -119,6 +126,35 @@ static struct ctrl sd_ctrls[] = {
119 .set = sd_setautogain, 126 .set = sd_setautogain,
120 .get = sd_getautogain, 127 .get = sd_getautogain,
121 }, 128 },
129/* next controls work with pac7302 only */
130 {
131 {
132 .id = V4L2_CID_HFLIP,
133 .type = V4L2_CTRL_TYPE_BOOLEAN,
134 .name = "Mirror",
135 .minimum = 0,
136 .maximum = 1,
137 .step = 1,
138#define HFLIP_DEF 0
139 .default_value = HFLIP_DEF,
140 },
141 .set = sd_sethflip,
142 .get = sd_gethflip,
143 },
144 {
145 {
146 .id = V4L2_CID_VFLIP,
147 .type = V4L2_CTRL_TYPE_BOOLEAN,
148 .name = "Vflip",
149 .minimum = 0,
150 .maximum = 1,
151 .step = 1,
152#define VFLIP_DEF 0
153 .default_value = VFLIP_DEF,
154 },
155 .set = sd_setvflip,
156 .get = sd_getvflip,
157 },
122}; 158};
123 159
124static struct v4l2_pix_format vga_mode[] = { 160static struct v4l2_pix_format vga_mode[] = {
@@ -493,8 +529,25 @@ static void setcolors(struct gspca_dev *gspca_dev)
493{ 529{
494 struct sd *sd = (struct sd *) gspca_dev; 530 struct sd *sd = (struct sd *) gspca_dev;
495 531
496 if (sd->sensor == SENSOR_PAC7302) 532 if (sd->sensor == SENSOR_PAC7302) {
533 int i, v;
534 static const int a[9] =
535 {217, -212, 0, -101, 170, -67, -38, -315, 355};
536 static const int b[9] =
537 {19, 106, 0, 19, 106, 1, 19, 106, 1};
538
539 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */
540 reg_w(gspca_dev, 0x11, 0x01);
541 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
542 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
543 for (i = 0; i < 9; i++) {
544 v = a[i] * sd->colors / COLOR_MAX + b[i];
545 reg_w(gspca_dev, 0x0f + 2 * i, (v >> 8) & 0x07);
546 reg_w(gspca_dev, 0x0f + 2 * i + 1, v);
547 }
548 reg_w(gspca_dev, 0xdc, 0x01);
497 return; 549 return;
550 }
498 reg_w(gspca_dev, 0xff, 0x01); 551 reg_w(gspca_dev, 0xff, 0x01);
499 reg_w(gspca_dev, 0x10, sd->colors); 552 reg_w(gspca_dev, 0x10, sd->colors);
500 /* load registers to sensor (Bit 0, auto clear) */ 553 /* load registers to sensor (Bit 0, auto clear) */
@@ -514,6 +567,19 @@ static void setautogain(struct gspca_dev *gspca_dev)
514 } 567 }
515} 568}
516 569
570/* this function is used by pac7302 only */
571static void sethvflip(struct gspca_dev *gspca_dev)
572{
573 struct sd *sd = (struct sd *) gspca_dev;
574 __u8 data;
575
576 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */
577 data = (sd->hflip ? 0x00 : 0x08)
578 | (sd->vflip ? 0x04 : 0x00);
579 reg_w(gspca_dev, 0x21, data);
580 reg_w(gspca_dev, 0x11, 0x01);
581}
582
517/* this function is called at open time */ 583/* this function is called at open time */
518static int sd_open(struct gspca_dev *gspca_dev) 584static int sd_open(struct gspca_dev *gspca_dev)
519{ 585{
@@ -574,6 +640,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
574 /* start stream */ 640 /* start stream */
575 reg_w(gspca_dev, 0xff, 0x01); 641 reg_w(gspca_dev, 0xff, 0x01);
576 if (sd->sensor == SENSOR_PAC7302) { 642 if (sd->sensor == SENSOR_PAC7302) {
643 sethvflip(gspca_dev);
577 reg_w(gspca_dev, 0x78, 0x01); 644 reg_w(gspca_dev, 0x78, 0x01);
578 reg_w(gspca_dev, 0xff, 0x01); 645 reg_w(gspca_dev, 0xff, 0x01);
579 reg_w(gspca_dev, 0x78, 0x01); 646 reg_w(gspca_dev, 0x78, 0x01);
@@ -790,6 +857,42 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
790 return 0; 857 return 0;
791} 858}
792 859
860static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
861{
862 struct sd *sd = (struct sd *) gspca_dev;
863
864 sd->hflip = val;
865 if (gspca_dev->streaming)
866 sethvflip(gspca_dev);
867 return 0;
868}
869
870static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
871{
872 struct sd *sd = (struct sd *) gspca_dev;
873
874 *val = sd->hflip;
875 return 0;
876}
877
878static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
879{
880 struct sd *sd = (struct sd *) gspca_dev;
881
882 sd->vflip = val;
883 if (gspca_dev->streaming)
884 sethvflip(gspca_dev);
885 return 0;
886}
887
888static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
889{
890 struct sd *sd = (struct sd *) gspca_dev;
891
892 *val = sd->vflip;
893 return 0;
894}
895
793/* sub-driver description */ 896/* sub-driver description */
794static struct sd_desc sd_desc = { 897static struct sd_desc sd_desc = {
795 .name = MODULE_NAME, 898 .name = MODULE_NAME,