aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-12-13 05:45:34 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:39:03 -0500
commit47a42b0b9cc9c328ce33af9e4bab58e57d643908 (patch)
treeac7e22b7b1c00d585cdd602b76f3abb795f444f9 /drivers
parentf8ea4af42b03976eb986742957fc7c581b620937 (diff)
V4L/DVB (9880): gspca - vc032x: Add V&H flips and sharpness controls for sensor po1200.
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/vc032x.c77
1 files changed, 68 insertions, 9 deletions
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index 87d9df8cd1cb..1793da4f5850 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -35,6 +35,7 @@ struct sd {
35 __u8 hflip; 35 __u8 hflip;
36 __u8 vflip; 36 __u8 vflip;
37 __u8 lightfreq; 37 __u8 lightfreq;
38 __u8 sharpness;
38 39
39 char bridge; 40 char bridge;
40#define BRIDGE_VC0321 0 41#define BRIDGE_VC0321 0
@@ -57,6 +58,8 @@ static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
57static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); 58static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
58static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); 59static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
59static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); 60static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
61static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
62static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
60 63
61static struct ctrl sd_ctrls[] = { 64static struct ctrl sd_ctrls[] = {
62/* next 2 controls work with ov7660 and ov7670 only */ 65/* next 2 controls work with ov7660 and ov7670 only */
@@ -105,6 +108,22 @@ static struct ctrl sd_ctrls[] = {
105 .set = sd_setfreq, 108 .set = sd_setfreq,
106 .get = sd_getfreq, 109 .get = sd_getfreq,
107 }, 110 },
111/* po1200 only */
112#define SHARPNESS_IDX 3
113 {
114 {
115 .id = V4L2_CID_SHARPNESS,
116 .type = V4L2_CTRL_TYPE_INTEGER,
117 .name = "Sharpness",
118 .minimum = 0,
119 .maximum = 2,
120 .step = 1,
121#define SHARPNESS_DEF 1
122 .default_value = SHARPNESS_DEF,
123 },
124 .set = sd_setsharpness,
125 .get = sd_getsharpness,
126 },
108}; 127};
109 128
110static struct v4l2_pix_format vc0321_mode[] = { 129static struct v4l2_pix_format vc0321_mode[] = {
@@ -1519,7 +1538,7 @@ static const __u8 po1200_initVGA_data[][4] = {
1519 {0x00, 0x03, 0x00, 0xaa}, 1538 {0x00, 0x03, 0x00, 0xaa},
1520 {0x00, 0x12, 0x05, 0xaa}, 1539 {0x00, 0x12, 0x05, 0xaa},
1521 {0x00, 0x13, 0x02, 0xaa}, 1540 {0x00, 0x13, 0x02, 0xaa},
1522 {0x00, 0x1e, 0xc6, 0xaa}, 1541 {0x00, 0x1e, 0xc6, 0xaa}, /* h/v flip */
1523 {0x00, 0x21, 0x00, 0xaa}, 1542 {0x00, 0x21, 0x00, 0xaa},
1524 {0x00, 0x25, 0x02, 0xaa}, 1543 {0x00, 0x25, 0x02, 0xaa},
1525 {0x00, 0x3c, 0x4f, 0xaa}, 1544 {0x00, 0x3c, 0x4f, 0xaa},
@@ -1529,7 +1548,7 @@ static const __u8 po1200_initVGA_data[][4] = {
1529 {0x00, 0x55, 0xfe, 0xaa}, 1548 {0x00, 0x55, 0xfe, 0xaa},
1530 {0x00, 0x59, 0xd3, 0xaa}, 1549 {0x00, 0x59, 0xd3, 0xaa},
1531 {0x00, 0x5e, 0x04, 0xaa}, 1550 {0x00, 0x5e, 0x04, 0xaa},
1532 {0x00, 0x61, 0xb8, 0xaa}, 1551 {0x00, 0x61, 0xb8, 0xaa}, /* sharpness */
1533 {0x00, 0x62, 0x02, 0xaa}, 1552 {0x00, 0x62, 0x02, 0xaa},
1534 {0x00, 0xa7, 0x31, 0xaa}, 1553 {0x00, 0xa7, 0x31, 0xaa},
1535 {0x00, 0xa9, 0x66, 0xaa}, 1554 {0x00, 0xa9, 0x66, 0xaa},
@@ -1625,7 +1644,7 @@ static const __u8 po1200_initVGA_data[][4] = {
1625 {0x00, 0x20, 0xc4, 0xaa}, 1644 {0x00, 0x20, 0xc4, 0xaa},
1626 {0x00, 0x13, 0x03, 0xaa}, 1645 {0x00, 0x13, 0x03, 0xaa},
1627 {0x00, 0x3c, 0x50, 0xaa}, 1646 {0x00, 0x3c, 0x50, 0xaa},
1628 {0x00, 0x61, 0x6a, 0xaa}, 1647 {0x00, 0x61, 0x6a, 0xaa}, /* sharpness? */
1629 {0x00, 0x51, 0x5b, 0xaa}, 1648 {0x00, 0x51, 0x5b, 0xaa},
1630 {0x00, 0x52, 0x91, 0xaa}, 1649 {0x00, 0x52, 0x91, 0xaa},
1631 {0x00, 0x53, 0x4c, 0xaa}, 1650 {0x00, 0x53, 0x4c, 0xaa},
@@ -1680,7 +1699,7 @@ static const __u8 po1200_initVGA_data[][4] = {
1680 {0x00, 0xe2, 0x01, 0xaa}, 1699 {0x00, 0xe2, 0x01, 0xaa},
1681 {0x00, 0xd6, 0x40, 0xaa}, 1700 {0x00, 0xd6, 0x40, 0xaa},
1682 {0x00, 0xe4, 0x40, 0xaa}, 1701 {0x00, 0xe4, 0x40, 0xaa},
1683 {0x00, 0xa8, 0x9f, 0xaa}, 1702 {0x00, 0xa8, 0x8f, 0xaa},
1684 {0x00, 0xb4, 0x16, 0xaa}, 1703 {0x00, 0xb4, 0x16, 0xaa},
1685 {0xb0, 0x02, 0x06, 0xcc}, 1704 {0xb0, 0x02, 0x06, 0xcc},
1686 {0xb0, 0x18, 0x06, 0xcc}, 1705 {0xb0, 0x18, 0x06, 0xcc},
@@ -1718,8 +1737,6 @@ static const __u8 po1200_initVGA_data[][4] = {
1718 {0x00, 0x95, 0x85, 0xaa}, 1737 {0x00, 0x95, 0x85, 0xaa},
1719/*matrix*/ 1738/*matrix*/
1720 {0x00, 0x03, 0x00, 0xaa}, 1739 {0x00, 0x03, 0x00, 0xaa},
1721 {0x00, 0x61, 0xb8, 0xaa},
1722 {0x00, 0x03, 0x00, 0xaa},
1723 {0x00, 0x4d, 0x20, 0xaa}, 1740 {0x00, 0x4d, 0x20, 0xaa},
1724 {0xb8, 0x22, 0x40, 0xcc}, 1741 {0xb8, 0x22, 0x40, 0xcc},
1725 {0xb8, 0x23, 0x40, 0xcc}, 1742 {0xb8, 0x23, 0x40, 0xcc},
@@ -1739,9 +1756,6 @@ static const __u8 po1200_initVGA_data[][4] = {
1739 {0x00, 0x00, 0x18, 0xdd}, 1756 {0x00, 0x00, 0x18, 0xdd},
1740/*read bfff*/ 1757/*read bfff*/
1741 {0x00, 0x03, 0x00, 0xaa}, 1758 {0x00, 0x03, 0x00, 0xaa},
1742 {0x00, 0x1e, 0x46, 0xaa},
1743 {0x00, 0xa8, 0x8f, 0xaa},
1744 {0x00, 0x03, 0x00, 0xaa},
1745 {0x00, 0xb4, 0x1c, 0xaa}, 1759 {0x00, 0xb4, 0x1c, 0xaa},
1746 {0x00, 0xb5, 0x92, 0xaa}, 1760 {0x00, 0xb5, 0x92, 0xaa},
1747 {0x00, 0xb6, 0x39, 0xaa}, 1761 {0x00, 0xb6, 0x39, 0xaa},
@@ -2027,6 +2041,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
2027 switch (sd->sensor) { 2041 switch (sd->sensor) {
2028 case SENSOR_OV7660: 2042 case SENSOR_OV7660:
2029 case SENSOR_OV7670: 2043 case SENSOR_OV7670:
2044 case SENSOR_PO1200:
2030 break; 2045 break;
2031 default: 2046 default:
2032 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) 2047 gspca_dev->ctrl_dis = (1 << HFLIP_IDX)
@@ -2034,6 +2049,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
2034 break; 2049 break;
2035 } 2050 }
2036 2051
2052 sd->sharpness = SHARPNESS_DEF;
2053
2037 if (sd->bridge == BRIDGE_VC0321) { 2054 if (sd->bridge == BRIDGE_VC0321) {
2038 reg_r(gspca_dev, 0x8a, 0, 3); 2055 reg_r(gspca_dev, 0x8a, 0, 3);
2039 reg_w(dev, 0x87, 0x00, 0x0f0f); 2056 reg_w(dev, 0x87, 0x00, 0x0f0f);
@@ -2063,6 +2080,14 @@ static void sethvflip(struct gspca_dev *gspca_dev)
2063 case SENSOR_OV7670: 2080 case SENSOR_OV7670:
2064 data = 7; 2081 data = 7;
2065 break; 2082 break;
2083 case SENSOR_PO1200:
2084 data = 0;
2085 i2c_write(gspca_dev, 0x03, &data, 1);
2086 data = 0x80 * sd->hflip
2087 | 0x40 * sd->vflip
2088 | 0x06;
2089 i2c_write(gspca_dev, 0x1e, &data, 1);
2090 return;
2066 default: 2091 default:
2067 return; 2092 return;
2068 } 2093 }
@@ -2082,6 +2107,20 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
2082 usb_exchange(gspca_dev, ov7660_freq_tb[sd->lightfreq]); 2107 usb_exchange(gspca_dev, ov7660_freq_tb[sd->lightfreq]);
2083} 2108}
2084 2109
2110/* po1200 only */
2111static void setsharpness(struct gspca_dev *gspca_dev)
2112{
2113 struct sd *sd = (struct sd *) gspca_dev;
2114 __u8 data;
2115
2116 if (sd->sensor != SENSOR_PO1200)
2117 return;
2118 data = 0;
2119 i2c_write(gspca_dev, 0x03, &data, 1);
2120 data = 0xb5 + sd->sharpness * 3;
2121 i2c_write(gspca_dev, 0x61, &data, 1);
2122}
2123
2085static int sd_start(struct gspca_dev *gspca_dev) 2124static int sd_start(struct gspca_dev *gspca_dev)
2086{ 2125{
2087 struct sd *sd = (struct sd *) gspca_dev; 2126 struct sd *sd = (struct sd *) gspca_dev;
@@ -2218,6 +2257,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
2218 sethvflip(gspca_dev); 2257 sethvflip(gspca_dev);
2219 setlightfreq(gspca_dev); 2258 setlightfreq(gspca_dev);
2220 } else { 2259 } else {
2260 setsharpness(gspca_dev);
2261 sethvflip(gspca_dev);
2221 reg_w(gspca_dev->dev, 0x89, 0x0400, 0x1415); 2262 reg_w(gspca_dev->dev, 0x89, 0x0400, 0x1415);
2222 } 2263 }
2223 } 2264 }
@@ -2328,6 +2369,24 @@ static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2328 return 0; 2369 return 0;
2329} 2370}
2330 2371
2372static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2373{
2374 struct sd *sd = (struct sd *) gspca_dev;
2375
2376 sd->sharpness = val;
2377 if (gspca_dev->streaming)
2378 setsharpness(gspca_dev);
2379 return 0;
2380}
2381
2382static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2383{
2384 struct sd *sd = (struct sd *) gspca_dev;
2385
2386 *val = sd->sharpness;
2387 return 0;
2388}
2389
2331static int sd_querymenu(struct gspca_dev *gspca_dev, 2390static int sd_querymenu(struct gspca_dev *gspca_dev,
2332 struct v4l2_querymenu *menu) 2391 struct v4l2_querymenu *menu)
2333{ 2392{