aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/vc032x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/vc032x.c')
-rw-r--r--drivers/media/video/gspca/vc032x.c694
1 files changed, 621 insertions, 73 deletions
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index 71921c878424..4989f9afb46e 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -32,10 +32,13 @@ MODULE_LICENSE("GPL");
32struct sd { 32struct sd {
33 struct gspca_dev gspca_dev; /* !! must be the first item */ 33 struct gspca_dev gspca_dev; /* !! must be the first item */
34 34
35 u8 brightness;
36 u8 contrast;
37 u8 colors;
35 u8 hflip; 38 u8 hflip;
36 u8 vflip; 39 u8 vflip;
37 u8 lightfreq; 40 u8 lightfreq;
38 u8 sharpness; 41 s8 sharpness;
39 42
40 u8 image_offset; 43 u8 image_offset;
41 44
@@ -52,6 +55,7 @@ struct sd {
52#define SENSOR_OV7670 6 55#define SENSOR_OV7670 6
53#define SENSOR_PO1200 7 56#define SENSOR_PO1200 7
54#define SENSOR_PO3130NC 8 57#define SENSOR_PO3130NC 8
58#define SENSOR_POxxxx 9
55 u8 flags; 59 u8 flags;
56#define FL_SAMSUNG 0x01 /* SamsungQ1 (2 sensors) */ 60#define FL_SAMSUNG 0x01 /* SamsungQ1 (2 sensors) */
57#define FL_HFLIP 0x02 /* mirrored by default */ 61#define FL_HFLIP 0x02 /* mirrored by default */
@@ -59,6 +63,12 @@ struct sd {
59}; 63};
60 64
61/* V4L2 controls supported by the driver */ 65/* V4L2 controls supported by the driver */
66static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
67static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
68static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
69static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
70static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
71static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
62static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); 72static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
63static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); 73static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
64static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); 74static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
@@ -68,9 +78,54 @@ static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
68static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); 78static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
69static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); 79static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
70 80
71static struct ctrl sd_ctrls[] = { 81static const struct ctrl sd_ctrls[] = {
82#define BRIGHTNESS_IDX 0
83 {
84 {
85 .id = V4L2_CID_BRIGHTNESS,
86 .type = V4L2_CTRL_TYPE_INTEGER,
87 .name = "Brightness",
88 .minimum = 0,
89 .maximum = 255,
90 .step = 1,
91#define BRIGHTNESS_DEF 128
92 .default_value = BRIGHTNESS_DEF,
93 },
94 .set = sd_setbrightness,
95 .get = sd_getbrightness,
96 },
97#define CONTRAST_IDX 1
98 {
99 {
100 .id = V4L2_CID_CONTRAST,
101 .type = V4L2_CTRL_TYPE_INTEGER,
102 .name = "Contrast",
103 .minimum = 0,
104 .maximum = 255,
105 .step = 1,
106#define CONTRAST_DEF 127
107 .default_value = CONTRAST_DEF,
108 },
109 .set = sd_setcontrast,
110 .get = sd_getcontrast,
111 },
112#define COLORS_IDX 2
113 {
114 {
115 .id = V4L2_CID_SATURATION,
116 .type = V4L2_CTRL_TYPE_INTEGER,
117 .name = "Saturation",
118 .minimum = 1,
119 .maximum = 127,
120 .step = 1,
121#define COLOR_DEF 63
122 .default_value = COLOR_DEF,
123 },
124 .set = sd_setcolors,
125 .get = sd_getcolors,
126 },
72/* next 2 controls work with some sensors only */ 127/* next 2 controls work with some sensors only */
73#define HFLIP_IDX 0 128#define HFLIP_IDX 3
74 { 129 {
75 { 130 {
76 .id = V4L2_CID_HFLIP, 131 .id = V4L2_CID_HFLIP,
@@ -85,7 +140,7 @@ static struct ctrl sd_ctrls[] = {
85 .set = sd_sethflip, 140 .set = sd_sethflip,
86 .get = sd_gethflip, 141 .get = sd_gethflip,
87 }, 142 },
88#define VFLIP_IDX 1 143#define VFLIP_IDX 4
89 { 144 {
90 { 145 {
91 .id = V4L2_CID_VFLIP, 146 .id = V4L2_CID_VFLIP,
@@ -100,7 +155,7 @@ static struct ctrl sd_ctrls[] = {
100 .set = sd_setvflip, 155 .set = sd_setvflip,
101 .get = sd_getvflip, 156 .get = sd_getvflip,
102 }, 157 },
103#define LIGHTFREQ_IDX 2 158#define LIGHTFREQ_IDX 5
104 { 159 {
105 { 160 {
106 .id = V4L2_CID_POWER_LINE_FREQUENCY, 161 .id = V4L2_CID_POWER_LINE_FREQUENCY,
@@ -115,17 +170,16 @@ static struct ctrl sd_ctrls[] = {
115 .set = sd_setfreq, 170 .set = sd_setfreq,
116 .get = sd_getfreq, 171 .get = sd_getfreq,
117 }, 172 },
118/* po1200 only */ 173#define SHARPNESS_IDX 6
119#define SHARPNESS_IDX 3
120 { 174 {
121 { 175 {
122 .id = V4L2_CID_SHARPNESS, 176 .id = V4L2_CID_SHARPNESS,
123 .type = V4L2_CTRL_TYPE_INTEGER, 177 .type = V4L2_CTRL_TYPE_INTEGER,
124 .name = "Sharpness", 178 .name = "Sharpness",
125 .minimum = 0, 179 .minimum = -1,
126 .maximum = 2, 180 .maximum = 2,
127 .step = 1, 181 .step = 1,
128#define SHARPNESS_DEF 1 182#define SHARPNESS_DEF -1
129 .default_value = SHARPNESS_DEF, 183 .default_value = SHARPNESS_DEF,
130 }, 184 },
131 .set = sd_setsharpness, 185 .set = sd_setsharpness,
@@ -133,6 +187,42 @@ static struct ctrl sd_ctrls[] = {
133 }, 187 },
134}; 188};
135 189
190/* table of the disabled controls */
191static u32 ctrl_dis[] = {
192/* SENSOR_HV7131R 0 */
193 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
194 | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX)
195 | (1 << SHARPNESS_IDX),
196/* SENSOR_MI0360 1 */
197 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
198 | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX)
199 | (1 << SHARPNESS_IDX),
200/* SENSOR_MI1310_SOC 2 */
201 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
202 | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX),
203/* SENSOR_MI1320 3 */
204 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
205 | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX),
206/* SENSOR_MI1320_SOC 4 */
207 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
208 | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX),
209/* SENSOR_OV7660 5 */
210 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
211 | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX),
212/* SENSOR_OV7670 6 */
213 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
214 | (1 << SHARPNESS_IDX),
215/* SENSOR_PO1200 7 */
216 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
217 | (1 << LIGHTFREQ_IDX),
218/* SENSOR_PO3130NC 8 */
219 (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX)
220 | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX)
221 | (1 << SHARPNESS_IDX),
222/* SENSOR_POxxxx 9 */
223 (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX),
224};
225
136static const struct v4l2_pix_format vc0321_mode[] = { 226static const struct v4l2_pix_format vc0321_mode[] = {
137 {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, 227 {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
138 .bytesperline = 320, 228 .bytesperline = 320,
@@ -215,7 +305,7 @@ static const u8 mi0360_initVGA_JPG[][4] = {
215 {0xb3, 0x15, 0x00, 0xcc}, 305 {0xb3, 0x15, 0x00, 0xcc},
216 {0xb3, 0x16, 0x02, 0xcc}, 306 {0xb3, 0x16, 0x02, 0xcc},
217 {0xb3, 0x17, 0x7f, 0xcc}, 307 {0xb3, 0x17, 0x7f, 0xcc},
218 {0xb3, 0x35, 0xdd, 0xcc}, 308 {0xb3, 0x35, 0xdd, 0xcc}, /* i2c add: 5d */
219 {0xb3, 0x34, 0x02, 0xcc}, 309 {0xb3, 0x34, 0x02, 0xcc},
220 {0xb3, 0x00, 0x25, 0xcc}, 310 {0xb3, 0x00, 0x25, 0xcc},
221 {0xbc, 0x00, 0x71, 0xcc}, 311 {0xbc, 0x00, 0x71, 0xcc},
@@ -435,7 +525,7 @@ static const u8 mi1310_socinitVGA_JPG[][4] = {
435 {0xb3, 0x08, 0x01, 0xcc}, 525 {0xb3, 0x08, 0x01, 0xcc},
436 {0xb3, 0x09, 0x0c, 0xcc}, 526 {0xb3, 0x09, 0x0c, 0xcc},
437 {0xb3, 0x34, 0x02, 0xcc}, 527 {0xb3, 0x34, 0x02, 0xcc},
438 {0xb3, 0x35, 0xdd, 0xcc}, 528 {0xb3, 0x35, 0xdd, 0xcc}, /* i2c add: 5d */
439 {0xb3, 0x02, 0x00, 0xcc}, 529 {0xb3, 0x02, 0x00, 0xcc},
440 {0xb3, 0x03, 0x0a, 0xcc}, 530 {0xb3, 0x03, 0x0a, 0xcc},
441 {0xb3, 0x04, 0x05, 0xcc}, 531 {0xb3, 0x04, 0x05, 0xcc},
@@ -860,7 +950,8 @@ static const u8 mi1320_initVGA_data[][4] = {
860 {0xb0, 0x16, 0x03, 0xcc}, {0xb3, 0x05, 0x00, 0xcc}, 950 {0xb0, 0x16, 0x03, 0xcc}, {0xb3, 0x05, 0x00, 0xcc},
861 {0xb3, 0x06, 0x00, 0xcc}, {0xb3, 0x08, 0x01, 0xcc}, 951 {0xb3, 0x06, 0x00, 0xcc}, {0xb3, 0x08, 0x01, 0xcc},
862 {0xb3, 0x09, 0x0c, 0xcc}, {0xb3, 0x34, 0x02, 0xcc}, 952 {0xb3, 0x09, 0x0c, 0xcc}, {0xb3, 0x34, 0x02, 0xcc},
863 {0xb3, 0x35, 0xc8, 0xcc}, {0xb3, 0x02, 0x00, 0xcc}, 953 {0xb3, 0x35, 0xc8, 0xcc}, /* i2c add: 48 */
954 {0xb3, 0x02, 0x00, 0xcc},
864 {0xb3, 0x03, 0x0a, 0xcc}, {0xb3, 0x04, 0x05, 0xcc}, 955 {0xb3, 0x03, 0x0a, 0xcc}, {0xb3, 0x04, 0x05, 0xcc},
865 {0xb3, 0x20, 0x00, 0xcc}, {0xb3, 0x21, 0x00, 0xcc}, 956 {0xb3, 0x20, 0x00, 0xcc}, {0xb3, 0x21, 0x00, 0xcc},
866 {0xb3, 0x22, 0x03, 0xcc}, {0xb3, 0x23, 0xc0, 0xcc}, 957 {0xb3, 0x22, 0x03, 0xcc}, {0xb3, 0x23, 0xc0, 0xcc},
@@ -901,7 +992,8 @@ static const u8 mi1320_initVGA_data[][4] = {
901 {0xc3, 0x01, 0x03, 0xbb}, {0xc4, 0x00, 0x04, 0xbb}, 992 {0xc3, 0x01, 0x03, 0xbb}, {0xc4, 0x00, 0x04, 0xbb},
902 {0xf0, 0x00, 0x00, 0xbb}, {0x05, 0x01, 0x13, 0xbb}, 993 {0xf0, 0x00, 0x00, 0xbb}, {0x05, 0x01, 0x13, 0xbb},
903 {0x06, 0x00, 0x11, 0xbb}, {0x07, 0x00, 0x85, 0xbb}, 994 {0x06, 0x00, 0x11, 0xbb}, {0x07, 0x00, 0x85, 0xbb},
904 {0x08, 0x00, 0x27, 0xbb}, {0x20, 0x01, 0x03, 0xbb}, 995 {0x08, 0x00, 0x27, 0xbb},
996 {0x20, 0x01, 0x00, 0xbb}, /* h/v flips - was 03 */
905 {0x21, 0x80, 0x00, 0xbb}, {0x22, 0x0d, 0x0f, 0xbb}, 997 {0x21, 0x80, 0x00, 0xbb}, {0x22, 0x0d, 0x0f, 0xbb},
906 {0x24, 0x80, 0x00, 0xbb}, {0x59, 0x00, 0xff, 0xbb}, 998 {0x24, 0x80, 0x00, 0xbb}, {0x59, 0x00, 0xff, 0xbb},
907 {0xf0, 0x00, 0x02, 0xbb}, {0x39, 0x03, 0x0d, 0xbb}, 999 {0xf0, 0x00, 0x02, 0xbb}, {0x39, 0x03, 0x0d, 0xbb},
@@ -1012,7 +1104,7 @@ static const u8 mi1320_soc_InitVGA[][4] = {
1012 {0xb3, 0x08, 0x01, 0xcc}, 1104 {0xb3, 0x08, 0x01, 0xcc},
1013 {0xb3, 0x09, 0x0c, 0xcc}, 1105 {0xb3, 0x09, 0x0c, 0xcc},
1014 {0xb3, 0x34, 0x02, 0xcc}, 1106 {0xb3, 0x34, 0x02, 0xcc},
1015 {0xb3, 0x35, 0xc8, 0xcc}, 1107 {0xb3, 0x35, 0xc8, 0xcc}, /* i2c add: 48 */
1016 {0xb3, 0x02, 0x00, 0xcc}, 1108 {0xb3, 0x02, 0x00, 0xcc},
1017 {0xb3, 0x03, 0x0a, 0xcc}, 1109 {0xb3, 0x03, 0x0a, 0xcc},
1018 {0xb3, 0x04, 0x05, 0xcc}, 1110 {0xb3, 0x04, 0x05, 0xcc},
@@ -1359,7 +1451,8 @@ static const u8 po3130_initVGA_data[][4] = {
1359 {0xb3, 0x23, 0xe8, 0xcc}, {0xb8, 0x08, 0xe8, 0xcc}, 1451 {0xb3, 0x23, 0xe8, 0xcc}, {0xb8, 0x08, 0xe8, 0xcc},
1360 {0xb3, 0x14, 0x00, 0xcc}, {0xb3, 0x15, 0x00, 0xcc}, 1452 {0xb3, 0x14, 0x00, 0xcc}, {0xb3, 0x15, 0x00, 0xcc},
1361 {0xb3, 0x16, 0x02, 0xcc}, {0xb3, 0x17, 0x7f, 0xcc}, 1453 {0xb3, 0x16, 0x02, 0xcc}, {0xb3, 0x17, 0x7f, 0xcc},
1362 {0xb3, 0x34, 0x01, 0xcc}, {0xb3, 0x35, 0xf6, 0xcc}, 1454 {0xb3, 0x34, 0x01, 0xcc},
1455 {0xb3, 0x35, 0xf6, 0xcc}, /* i2c add: 76 */
1363 {0xb3, 0x00, 0x27, 0xcc}, {0xbc, 0x00, 0x71, 0xcc}, 1456 {0xb3, 0x00, 0x27, 0xcc}, {0xbc, 0x00, 0x71, 0xcc},
1364 {0xb8, 0x00, 0x21, 0xcc}, {0xb8, 0x27, 0x20, 0xcc}, 1457 {0xb8, 0x00, 0x21, 0xcc}, {0xb8, 0x27, 0x20, 0xcc},
1365 {0xb8, 0x01, 0x79, 0xcc}, {0xb8, 0x81, 0x09, 0xcc}, 1458 {0xb8, 0x01, 0x79, 0xcc}, {0xb8, 0x81, 0x09, 0xcc},
@@ -1561,7 +1654,7 @@ static const u8 hv7131r_initVGA_data[][4] = {
1561 {0xb3, 0x16, 0x02, 0xcc}, 1654 {0xb3, 0x16, 0x02, 0xcc},
1562 {0xb3, 0x17, 0x7f, 0xcc}, 1655 {0xb3, 0x17, 0x7f, 0xcc},
1563 {0xb3, 0x34, 0x01, 0xcc}, 1656 {0xb3, 0x34, 0x01, 0xcc},
1564 {0xb3, 0x35, 0x91, 0xcc}, 1657 {0xb3, 0x35, 0x91, 0xcc}, /* i2c add: 11 */
1565 {0xb3, 0x00, 0x27, 0xcc}, 1658 {0xb3, 0x00, 0x27, 0xcc},
1566 {0xbc, 0x00, 0x73, 0xcc}, 1659 {0xbc, 0x00, 0x73, 0xcc},
1567 {0xb8, 0x00, 0x23, 0xcc}, 1660 {0xb8, 0x00, 0x23, 0xcc},
@@ -1747,7 +1840,8 @@ static const u8 ov7660_initVGA_data[][4] = {
1747 {0xb3, 0x23, 0xe0, 0xcc}, {0xb3, 0x1d, 0x01, 0xcc}, 1840 {0xb3, 0x23, 0xe0, 0xcc}, {0xb3, 0x1d, 0x01, 0xcc},
1748 {0xb3, 0x1f, 0x02, 0xcc}, 1841 {0xb3, 0x1f, 0x02, 0xcc},
1749 {0xb3, 0x34, 0x01, 0xcc}, 1842 {0xb3, 0x34, 0x01, 0xcc},
1750 {0xb3, 0x35, 0xa1, 0xcc}, {0xb3, 0x00, 0x26, 0xcc}, 1843 {0xb3, 0x35, 0xa1, 0xcc}, /* i2c add: 21 */
1844 {0xb3, 0x00, 0x26, 0xcc},
1751 {0xb8, 0x00, 0x33, 0xcc}, /* 13 */ 1845 {0xb8, 0x00, 0x33, 0xcc}, /* 13 */
1752 {0xb8, 0x01, 0x7d, 0xcc}, 1846 {0xb8, 0x01, 0x7d, 0xcc},
1753 {0xbc, 0x00, 0x73, 0xcc}, {0xb8, 0x81, 0x09, 0xcc}, 1847 {0xbc, 0x00, 0x73, 0xcc}, {0xb8, 0x81, 0x09, 0xcc},
@@ -1883,7 +1977,8 @@ static const u8 ov7670_initVGA_JPG[][4] = {
1883 {0x00, 0x00, 0x10, 0xdd}, 1977 {0x00, 0x00, 0x10, 0xdd},
1884 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x10, 0xdd}, 1978 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x10, 0xdd},
1885 {0xb3, 0x00, 0x66, 0xcc}, {0xb3, 0x00, 0x67, 0xcc}, 1979 {0xb3, 0x00, 0x66, 0xcc}, {0xb3, 0x00, 0x67, 0xcc},
1886 {0xb3, 0x35, 0xa1, 0xcc}, {0xb3, 0x34, 0x01, 0xcc}, 1980 {0xb3, 0x35, 0xa1, 0xcc}, /* i2c add: 21 */
1981 {0xb3, 0x34, 0x01, 0xcc},
1887 {0xb3, 0x05, 0x01, 0xcc}, {0xb3, 0x06, 0x01, 0xcc}, 1982 {0xb3, 0x05, 0x01, 0xcc}, {0xb3, 0x06, 0x01, 0xcc},
1888 {0xb3, 0x08, 0x01, 0xcc}, {0xb3, 0x09, 0x0c, 0xcc}, 1983 {0xb3, 0x08, 0x01, 0xcc}, {0xb3, 0x09, 0x0c, 0xcc},
1889 {0xb3, 0x02, 0x02, 0xcc}, {0xb3, 0x03, 0x1f, 0xcc}, 1984 {0xb3, 0x02, 0x02, 0xcc}, {0xb3, 0x03, 0x1f, 0xcc},
@@ -2181,7 +2276,7 @@ static const u8 po1200_initVGA_data[][4] = {
2181 {0xb0, 0x54, 0x13, 0xcc}, 2276 {0xb0, 0x54, 0x13, 0xcc},
2182 {0xb3, 0x00, 0x67, 0xcc}, 2277 {0xb3, 0x00, 0x67, 0xcc},
2183 {0xb3, 0x34, 0x01, 0xcc}, 2278 {0xb3, 0x34, 0x01, 0xcc},
2184 {0xb3, 0x35, 0xdc, 0xcc}, 2279 {0xb3, 0x35, 0xdc, 0xcc}, /* i2c add: 5c */
2185 {0x00, 0x03, 0x00, 0xaa}, 2280 {0x00, 0x03, 0x00, 0xaa},
2186 {0x00, 0x12, 0x05, 0xaa}, 2281 {0x00, 0x12, 0x05, 0xaa},
2187 {0x00, 0x13, 0x02, 0xaa}, 2282 {0x00, 0x13, 0x02, 0xaa},
@@ -2408,6 +2503,251 @@ static const u8 po1200_initVGA_data[][4] = {
2408 {0x00, 0xb6, 0x39, 0xaa}, 2503 {0x00, 0xb6, 0x39, 0xaa},
2409 {0x00, 0xb7, 0x24, 0xaa}, 2504 {0x00, 0xb7, 0x24, 0xaa},
2410/*write 89 0400 1415*/ 2505/*write 89 0400 1415*/
2506 {}
2507};
2508
2509static const u8 poxxxx_init_common[][4] = {
2510 {0xb3, 0x00, 0x04, 0xcc},
2511 {0x00, 0x00, 0x10, 0xdd},
2512 {0xb3, 0x00, 0x64, 0xcc},
2513 {0x00, 0x00, 0x10, 0xdd},
2514 {0xb3, 0x00, 0x65, 0xcc},
2515 {0x00, 0x00, 0x10, 0xdd},
2516 {0xb3, 0x00, 0x67, 0xcc},
2517 {0xb0, 0x03, 0x09, 0xcc},
2518 {0xb3, 0x05, 0x00, 0xcc},
2519 {0xb3, 0x06, 0x00, 0xcc},
2520 {0xb3, 0x5c, 0x01, 0xcc},
2521 {0xb3, 0x08, 0x01, 0xcc},
2522 {0xb3, 0x09, 0x0c, 0xcc},
2523 {0xb3, 0x34, 0x01, 0xcc},
2524 {0xb3, 0x35, 0xf6, 0xcc}, /* i2c add: 76 */
2525 {0xb3, 0x02, 0xb0, 0xcc},
2526 {0xb3, 0x03, 0x18, 0xcc},
2527 {0xb3, 0x04, 0x15, 0xcc},
2528 {0xb3, 0x20, 0x00, 0xcc},
2529 {0xb3, 0x21, 0x00, 0xcc},
2530 {0xb3, 0x22, 0x04, 0xcc},
2531 {0xb3, 0x23, 0x00, 0xcc},
2532 {0xb3, 0x14, 0x00, 0xcc},
2533 {0xb3, 0x15, 0x00, 0xcc},
2534 {0xb3, 0x16, 0x04, 0xcc},
2535 {0xb3, 0x17, 0xff, 0xcc},
2536 {0xb3, 0x2c, 0x03, 0xcc},
2537 {0xb3, 0x2d, 0x56, 0xcc},
2538 {0xb3, 0x2e, 0x02, 0xcc},
2539 {0xb3, 0x2f, 0x0a, 0xcc},
2540 {0xb3, 0x40, 0x00, 0xcc},
2541 {0xb3, 0x41, 0x34, 0xcc},
2542 {0xb3, 0x42, 0x01, 0xcc},
2543 {0xb3, 0x43, 0xe0, 0xcc},
2544 {0xbc, 0x00, 0x71, 0xcc},
2545 {0xbc, 0x01, 0x01, 0xcc},
2546 {0xb3, 0x01, 0x41, 0xcc},
2547 {0xb3, 0x4d, 0x00, 0xcc},
2548 {0x00, 0x0b, 0x2a, 0xaa},
2549 {0x00, 0x0e, 0x03, 0xaa},
2550 {0x00, 0x0f, 0xea, 0xaa},
2551 {0x00, 0x12, 0x08, 0xaa},
2552 {0x00, 0x1e, 0x06, 0xaa},
2553 {0x00, 0x21, 0x00, 0xaa},
2554 {0x00, 0x31, 0x1f, 0xaa},
2555 {0x00, 0x33, 0x38, 0xaa},
2556 {0x00, 0x36, 0xc0, 0xaa},
2557 {0x00, 0x37, 0xc8, 0xaa},
2558 {0x00, 0x3b, 0x36, 0xaa},
2559 {0x00, 0x4b, 0xfe, 0xaa},
2560 {0x00, 0x4d, 0x2e, 0xaa},
2561 {0x00, 0x51, 0x1c, 0xaa},
2562 {0x00, 0x52, 0x01, 0xaa},
2563 {0x00, 0x55, 0x0a, 0xaa},
2564 {0x00, 0x56, 0x0a, 0xaa},
2565 {0x00, 0x57, 0x07, 0xaa},
2566 {0x00, 0x58, 0x07, 0xaa},
2567 {0x00, 0x59, 0x04, 0xaa},
2568 {0x00, 0x70, 0x68, 0xaa},
2569 {0x00, 0x71, 0x04, 0xaa},
2570 {0x00, 0x72, 0x10, 0xaa},
2571 {0x00, 0x80, 0x71, 0xaa},
2572 {0x00, 0x81, 0x08, 0xaa},
2573 {0x00, 0x82, 0x00, 0xaa},
2574 {0x00, 0x83, 0x55, 0xaa},
2575 {0x00, 0x84, 0x06, 0xaa},
2576 {0x00, 0x85, 0x06, 0xaa},
2577 {0x00, 0x8b, 0x25, 0xaa},
2578 {0x00, 0x8c, 0x00, 0xaa},
2579 {0x00, 0x8d, 0x86, 0xaa},
2580 {0x00, 0x8e, 0x82, 0xaa},
2581 {0x00, 0x8f, 0x2d, 0xaa},
2582 {0x00, 0x90, 0x8b, 0xaa},
2583 {0x00, 0x91, 0x81, 0xaa},
2584 {0x00, 0x92, 0x81, 0xaa},
2585 {0x00, 0x93, 0x23, 0xaa},
2586 {0x00, 0xa3, 0x2a, 0xaa},
2587 {0x00, 0xa4, 0x03, 0xaa},
2588 {0x00, 0xa5, 0xea, 0xaa},
2589 {0x00, 0xb0, 0x68, 0xaa},
2590 {0x00, 0xbc, 0x04, 0xaa},
2591 {0x00, 0xbe, 0x3b, 0xaa},
2592 {0x00, 0x4e, 0x40, 0xaa},
2593 {0x00, 0x06, 0x04, 0xaa},
2594 {0x00, 0x07, 0x03, 0xaa},
2595 {0x00, 0xcd, 0x18, 0xaa},
2596 {0x00, 0x28, 0x03, 0xaa},
2597 {0x00, 0x29, 0xef, 0xaa},
2598/* reinit on alt 2 (qvga) or alt7 (vga) */
2599 {0xb3, 0x05, 0x00, 0xcc},
2600 {0xb3, 0x06, 0x00, 0xcc},
2601 {0xb8, 0x00, 0x01, 0xcc},
2602
2603 {0x00, 0x1d, 0x85, 0xaa},
2604 {0x00, 0x1e, 0xc6, 0xaa},
2605 {0x00, 0x00, 0x40, 0xdd},
2606 {0x00, 0x1d, 0x05, 0xaa},
2607
2608 {0x00, 0xd6, 0x22, 0xaa}, /* gamma 0 */
2609 {0x00, 0x73, 0x00, 0xaa},
2610 {0x00, 0x74, 0x0a, 0xaa},
2611 {0x00, 0x75, 0x16, 0xaa},
2612 {0x00, 0x76, 0x25, 0xaa},
2613 {0x00, 0x77, 0x34, 0xaa},
2614 {0x00, 0x78, 0x49, 0xaa},
2615 {0x00, 0x79, 0x5a, 0xaa},
2616 {0x00, 0x7a, 0x7f, 0xaa},
2617 {0x00, 0x7b, 0x9b, 0xaa},
2618 {0x00, 0x7c, 0xba, 0xaa},
2619 {0x00, 0x7d, 0xd4, 0xaa},
2620 {0x00, 0x7e, 0xea, 0xaa},
2621
2622 {0x00, 0xd6, 0x62, 0xaa}, /* gamma 1 */
2623 {0x00, 0x73, 0x00, 0xaa},
2624 {0x00, 0x74, 0x0a, 0xaa},
2625 {0x00, 0x75, 0x16, 0xaa},
2626 {0x00, 0x76, 0x25, 0xaa},
2627 {0x00, 0x77, 0x34, 0xaa},
2628 {0x00, 0x78, 0x49, 0xaa},
2629 {0x00, 0x79, 0x5a, 0xaa},
2630 {0x00, 0x7a, 0x7f, 0xaa},
2631 {0x00, 0x7b, 0x9b, 0xaa},
2632 {0x00, 0x7c, 0xba, 0xaa},
2633 {0x00, 0x7d, 0xd4, 0xaa},
2634 {0x00, 0x7e, 0xea, 0xaa},
2635
2636 {0x00, 0xd6, 0xa2, 0xaa}, /* gamma 2 */
2637 {0x00, 0x73, 0x00, 0xaa},
2638 {0x00, 0x74, 0x0a, 0xaa},
2639 {0x00, 0x75, 0x16, 0xaa},
2640 {0x00, 0x76, 0x25, 0xaa},
2641 {0x00, 0x77, 0x34, 0xaa},
2642 {0x00, 0x78, 0x49, 0xaa},
2643 {0x00, 0x79, 0x5a, 0xaa},
2644 {0x00, 0x7a, 0x7f, 0xaa},
2645 {0x00, 0x7b, 0x9b, 0xaa},
2646 {0x00, 0x7c, 0xba, 0xaa},
2647 {0x00, 0x7d, 0xd4, 0xaa},
2648 {0x00, 0x7e, 0xea, 0xaa},
2649
2650 {0x00, 0xaa, 0xff, 0xaa}, /* back light comp */
2651 {0x00, 0xc4, 0x03, 0xaa},
2652 {0x00, 0xc5, 0x19, 0xaa},
2653 {0x00, 0xc6, 0x03, 0xaa},
2654 {0x00, 0xc7, 0x91, 0xaa},
2655 {0x00, 0xc8, 0x01, 0xaa},
2656 {0x00, 0xc9, 0xdd, 0xaa},
2657 {0x00, 0xca, 0x02, 0xaa},
2658 {0x00, 0xcb, 0x37, 0xaa},
2659
2660/* read d1 */
2661 {0x00, 0xd1, 0x3c, 0xaa},
2662 {0x00, 0xb8, 0x28, 0xaa},
2663 {0x00, 0xb9, 0x1e, 0xaa},
2664 {0x00, 0xb6, 0x14, 0xaa},
2665 {0x00, 0xb7, 0x0f, 0xaa},
2666 {0x00, 0x5c, 0x10, 0xaa},
2667 {0x00, 0x5d, 0x18, 0xaa},
2668 {0x00, 0x5e, 0x24, 0xaa},
2669 {0x00, 0x5f, 0x24, 0xaa},
2670 {0x00, 0x86, 0x1a, 0xaa},
2671 {0x00, 0x60, 0x00, 0xaa},
2672 {0x00, 0x61, 0x1b, 0xaa},
2673 {0x00, 0x62, 0x30, 0xaa},
2674 {0x00, 0x63, 0x40, 0xaa},
2675 {0x00, 0x87, 0x1a, 0xaa},
2676 {0x00, 0x64, 0x00, 0xaa},
2677 {0x00, 0x65, 0x08, 0xaa},
2678 {0x00, 0x66, 0x10, 0xaa},
2679 {0x00, 0x67, 0x20, 0xaa},
2680 {0x00, 0x88, 0x10, 0xaa},
2681 {0x00, 0x68, 0x00, 0xaa},
2682 {0x00, 0x69, 0x08, 0xaa},
2683 {0x00, 0x6a, 0x0f, 0xaa},
2684 {0x00, 0x6b, 0x0f, 0xaa},
2685 {0x00, 0x89, 0x07, 0xaa},
2686 {0x00, 0xd5, 0x4c, 0xaa},
2687 {0x00, 0x0a, 0x00, 0xaa},
2688 {0x00, 0x0b, 0x2a, 0xaa},
2689 {0x00, 0x0e, 0x03, 0xaa},
2690 {0x00, 0x0f, 0xea, 0xaa},
2691 {0x00, 0xa2, 0x00, 0xaa},
2692 {0x00, 0xa3, 0x2a, 0xaa},
2693 {0x00, 0xa4, 0x03, 0xaa},
2694 {0x00, 0xa5, 0xea, 0xaa},
2695 {}
2696};
2697static const u8 poxxxx_initVGA[][4] = {
2698 {0x00, 0x20, 0x11, 0xaa},
2699 {0x00, 0x33, 0x38, 0xaa},
2700 {0x00, 0xbb, 0x0d, 0xaa},
2701 {0xb3, 0x22, 0x01, 0xcc},
2702 {0xb3, 0x23, 0xe0, 0xcc},
2703 {0xb3, 0x16, 0x02, 0xcc},
2704 {0xb3, 0x17, 0x7f, 0xcc},
2705 {0xb3, 0x02, 0xb0, 0xcc},
2706 {0xb3, 0x06, 0x00, 0xcc},
2707 {0xb3, 0x5c, 0x01, 0xcc},
2708 {0x00, 0x04, 0x06, 0xaa},
2709 {0x00, 0x05, 0x3f, 0xaa},
2710 {0x00, 0x04, 0x00, 0xdd}, /* delay 1s */
2711 {}
2712};
2713static const u8 poxxxx_initQVGA[][4] = {
2714 {0x00, 0x20, 0x33, 0xaa},
2715 {0x00, 0x33, 0x38, 0xaa},
2716 {0x00, 0xbb, 0x0d, 0xaa},
2717 {0xb3, 0x22, 0x00, 0xcc},
2718 {0xb3, 0x23, 0xf0, 0xcc},
2719 {0xb3, 0x16, 0x01, 0xcc},
2720 {0xb3, 0x17, 0x3f, 0xcc},
2721 {0xb3, 0x02, 0xb0, 0xcc},
2722 {0xb3, 0x06, 0x01, 0xcc},
2723 {0xb3, 0x5c, 0x00, 0xcc},
2724 {0x00, 0x04, 0x06, 0xaa},
2725 {0x00, 0x05, 0x3f, 0xaa},
2726 {0x00, 0x04, 0x00, 0xdd}, /* delay 1s */
2727 {}
2728};
2729static const u8 poxxxx_init_end_1[][4] = {
2730 {0x00, 0x47, 0x25, 0xaa},
2731 {0x00, 0x48, 0x80, 0xaa},
2732 {0x00, 0x49, 0x1f, 0xaa},
2733 {0x00, 0x4a, 0x40, 0xaa},
2734 {0x00, 0x44, 0x40, 0xaa},
2735 {0x00, 0xab, 0x4a, 0xaa},
2736 {0x00, 0xb1, 0x00, 0xaa},
2737 {0x00, 0xb2, 0x04, 0xaa},
2738 {0x00, 0xb3, 0x08, 0xaa},
2739 {0x00, 0xb4, 0x0b, 0xaa},
2740 {0x00, 0xb5, 0x0d, 0xaa},
2741 {0x00, 0x59, 0x7e, 0xaa}, /* sharpness */
2742 {0x00, 0x16, 0x00, 0xaa}, /* white balance */
2743 {0x00, 0x18, 0x00, 0xaa},
2744 {}
2745};
2746static const u8 poxxxx_init_end_2[][4] = {
2747 {0x00, 0x1d, 0x85, 0xaa},
2748 {0x00, 0x1e, 0x06, 0xaa},
2749 {0x00, 0x1d, 0x05, 0xaa},
2750 {}
2411}; 2751};
2412 2752
2413struct sensor_info { 2753struct sensor_info {
@@ -2420,33 +2760,89 @@ struct sensor_info {
2420 u8 op; 2760 u8 op;
2421}; 2761};
2422 2762
2423static const struct sensor_info sensor_info_data[] = { 2763/* probe values */
2424/* sensorId, I2cAdd, IdAdd, VpId, m1, m2, op */ 2764static const struct sensor_info vc0321_probe_data[] = {
2765/* sensorId, I2cAdd, IdAdd, VpId, m1, m2, op */
2766/* 0 OV9640 */
2425 {-1, 0x80 | 0x30, 0x0a, 0x0000, 0x25, 0x24, 0x05}, 2767 {-1, 0x80 | 0x30, 0x0a, 0x0000, 0x25, 0x24, 0x05},
2768/* 1 ICM108T (may respond on IdAdd == 0x83 - tested in vc032x_probe_sensor) */
2426 {-1, 0x80 | 0x20, 0x82, 0x0000, 0x24, 0x25, 0x01}, 2769 {-1, 0x80 | 0x20, 0x82, 0x0000, 0x24, 0x25, 0x01},
2427/* (tested in vc032x_probe_sensor) */ 2770/* 2 PO2130 (may detect PO3130NC - tested in vc032x_probe_sensor)*/
2428/* {-1, 0x80 | 0x20, 0x83, 0x0000, 0x24, 0x25, 0x01}, */ 2771 {-1, 0x80 | 0x76, 0x00, 0x0000, 0x24, 0x25, 0x01},
2429 {SENSOR_PO3130NC, 0x80 | 0x76, 0x00, 0x3130, 0x24, 0x25, 0x01}, 2772/* 3 MI1310 */
2773 {-1, 0x80 | 0x5d, 0x00, 0x0000, 0x24, 0x25, 0x01},
2774/* 4 MI360 - tested in vc032x_probe_sensor */
2775/* {SENSOR_MI0360, 0x80 | 0x5d, 0x00, 0x8243, 0x24, 0x25, 0x01}, */
2776/* 5 7131R */
2777 {SENSOR_HV7131R, 0x80 | 0x11, 0x00, 0x0209, 0x24, 0x25, 0x01},
2778/* 6 OV7649 */
2779 {-1, 0x80 | 0x21, 0x0a, 0x0000, 0x21, 0x20, 0x05},
2780/* 7 PAS302BCW */
2781 {-1, 0x80 | 0x40, 0x00, 0x0000, 0x20, 0x22, 0x05},
2782/* 8 OV7660 */
2783 {SENSOR_OV7660, 0x80 | 0x21, 0x0a, 0x7660, 0x26, 0x26, 0x05},
2784/* 9 PO3130NC - (tested in vc032x_probe_sensor) */
2785/* {SENSOR_PO3130NC, 0x80 | 0x76, 0x00, 0x3130, 0x24, 0x25, 0x01}, */
2786/* 10 PO1030KC */
2787 {-1, 0x80 | 0x6e, 0x00, 0x0000, 0x24, 0x25, 0x01},
2788/* 11 MI1310_SOC */
2430 {SENSOR_MI1310_SOC, 0x80 | 0x5d, 0x00, 0x143a, 0x24, 0x25, 0x01}, 2789 {SENSOR_MI1310_SOC, 0x80 | 0x5d, 0x00, 0x143a, 0x24, 0x25, 0x01},
2431/* (tested in vc032x_probe_sensor) */ 2790/* 12 OV9650 */
2791 {-1, 0x80 | 0x30, 0x0a, 0x0000, 0x25, 0x24, 0x05},
2792/* 13 S5K532 */
2793 {-1, 0x80 | 0x11, 0x39, 0x0000, 0x24, 0x25, 0x01},
2794/* 14 MI360_SOC - ??? */
2795/* 15 PO1200N */
2796 {SENSOR_PO1200, 0x80 | 0x5c, 0x00, 0x1200, 0x67, 0x67, 0x01},
2797/* 16 PO3030K */
2798 {-1, 0x80 | 0x18, 0x00, 0x0000, 0x24, 0x25, 0x01},
2799/* 17 PO2030 */
2800 {-1, 0x80 | 0x6e, 0x00, 0x0000, 0x24, 0x25, 0x01},
2801/* ?? */
2802 {-1, 0x80 | 0x56, 0x01, 0x0000, 0x64, 0x67, 0x01},
2803 {SENSOR_MI1320, 0x80 | 0x48, 0x00, 0x148c, 0x64, 0x65, 0x01},
2804};
2805static const struct sensor_info vc0323_probe_data[] = {
2806/* sensorId, I2cAdd, IdAdd, VpId, m1, m2, op */
2807/* 0 OV9640 */
2808 {-1, 0x80 | 0x30, 0x0a, 0x0000, 0x25, 0x24, 0x05},
2809/* 1 ICM108T (may respond on IdAdd == 0x83 - tested in vc032x_probe_sensor) */
2810 {-1, 0x80 | 0x20, 0x82, 0x0000, 0x24, 0x25, 0x01},
2811/* 2 PO2130 (may detect PO3130NC - tested in vc032x_probe_sensor)*/
2812 {-1, 0x80 | 0x76, 0x00, 0x0000, 0x24, 0x25, 0x01},
2813/* 3 MI1310 */
2814 {-1, 0x80 | 0x5d, 0x00, 0x0000, 0x24, 0x25, 0x01},
2815/* 4 MI360 - tested in vc032x_probe_sensor */
2432/* {SENSOR_MI0360, 0x80 | 0x5d, 0x00, 0x8243, 0x24, 0x25, 0x01}, */ 2816/* {SENSOR_MI0360, 0x80 | 0x5d, 0x00, 0x8243, 0x24, 0x25, 0x01}, */
2817/* 5 7131R */
2433 {SENSOR_HV7131R, 0x80 | 0x11, 0x00, 0x0209, 0x24, 0x25, 0x01}, 2818 {SENSOR_HV7131R, 0x80 | 0x11, 0x00, 0x0209, 0x24, 0x25, 0x01},
2819/* 6 OV7649 */
2434 {-1, 0x80 | 0x21, 0x0a, 0x0000, 0x21, 0x20, 0x05}, 2820 {-1, 0x80 | 0x21, 0x0a, 0x0000, 0x21, 0x20, 0x05},
2821/* 7 PAS302BCW */
2435 {-1, 0x80 | 0x40, 0x00, 0x0000, 0x20, 0x22, 0x05}, 2822 {-1, 0x80 | 0x40, 0x00, 0x0000, 0x20, 0x22, 0x05},
2823/* 8 OV7660 */
2436 {SENSOR_OV7660, 0x80 | 0x21, 0x0a, 0x7660, 0x26, 0x26, 0x05}, 2824 {SENSOR_OV7660, 0x80 | 0x21, 0x0a, 0x7660, 0x26, 0x26, 0x05},
2437/* {SENSOR_PO3130NC, 0x80 | 0x76, 0x00, 0x0000, 0x24, 0x25, 0x01}, */ 2825/* 9 PO3130NC - (tested in vc032x_probe_sensor) */
2826/* {SENSOR_PO3130NC, 0x80 | 0x76, 0x00, 0x3130, 0x24, 0x25, 0x01}, */
2827/* 10 PO1030KC */
2438 {-1, 0x80 | 0x6e, 0x00, 0x0000, 0x24, 0x25, 0x01}, 2828 {-1, 0x80 | 0x6e, 0x00, 0x0000, 0x24, 0x25, 0x01},
2439/* {SENSOR_MI1310_SOC, 0x80 | 0x5d, 0x00, 0x0000, 0x24, 0x25, 0x01}, */ 2829/* 11 MI1310_SOC */
2440/* {-1, 0x80 | 0x30, 0x0a, 0x0000, 0x25, 0x24, 0x05}, */ 2830 {SENSOR_MI1310_SOC, 0x80 | 0x5d, 0x00, 0x143a, 0x24, 0x25, 0x01},
2831/* 12 OV9650 */
2832 {-1, 0x80 | 0x30, 0x0a, 0x0000, 0x25, 0x24, 0x05},
2833/* 13 S5K532 */
2441 {-1, 0x80 | 0x11, 0x39, 0x0000, 0x24, 0x25, 0x01}, 2834 {-1, 0x80 | 0x11, 0x39, 0x0000, 0x24, 0x25, 0x01},
2835/* 14 MI360_SOC - ??? */
2836/* 15 PO1200N */
2442 {SENSOR_PO1200, 0x80 | 0x5c, 0x00, 0x1200, 0x67, 0x67, 0x01}, 2837 {SENSOR_PO1200, 0x80 | 0x5c, 0x00, 0x1200, 0x67, 0x67, 0x01},
2838/* 16 ?? */
2443 {-1, 0x80 | 0x2d, 0x00, 0x0000, 0x65, 0x67, 0x01}, 2839 {-1, 0x80 | 0x2d, 0x00, 0x0000, 0x65, 0x67, 0x01},
2840/* 17 PO2030 */
2444 {-1, 0x80 | 0x6e, 0x00, 0x0000, 0x24, 0x25, 0x01}, 2841 {-1, 0x80 | 0x6e, 0x00, 0x0000, 0x24, 0x25, 0x01},
2842/* ?? */
2445 {-1, 0x80 | 0x56, 0x01, 0x0000, 0x64, 0x67, 0x01}, 2843 {-1, 0x80 | 0x56, 0x01, 0x0000, 0x64, 0x67, 0x01},
2446 {SENSOR_MI1320_SOC, 0x80 | 0x48, 0x00, 0x148c, 0x64, 0x67, 0x01}, 2844 {SENSOR_MI1320_SOC, 0x80 | 0x48, 0x00, 0x148c, 0x64, 0x67, 0x01},
2447/*fixme: previously detected?*/ 2845/*fixme: not in the ms-win probe - may be found before? */
2448 {SENSOR_MI1320, 0x80 | 0x48, 0x00, 0x148c, 0x64, 0x65, 0x01},
2449/*fixme: not in the ms-win probe - may be found before?*/
2450 {SENSOR_OV7670, 0x80 | 0x21, 0x0a, 0x7673, 0x66, 0x67, 0x05}, 2846 {SENSOR_OV7670, 0x80 | 0x21, 0x0a, 0x7673, 0x66, 0x67, 0x05},
2451}; 2847};
2452 2848
@@ -2520,7 +2916,7 @@ static int vc032x_probe_sensor(struct gspca_dev *gspca_dev)
2520{ 2916{
2521 struct sd *sd = (struct sd *) gspca_dev; 2917 struct sd *sd = (struct sd *) gspca_dev;
2522 struct usb_device *dev = gspca_dev->dev; 2918 struct usb_device *dev = gspca_dev->dev;
2523 int i; 2919 int i, n;
2524 u16 value; 2920 u16 value;
2525 const struct sensor_info *ptsensor_info; 2921 const struct sensor_info *ptsensor_info;
2526 2922
@@ -2531,9 +2927,16 @@ static int vc032x_probe_sensor(struct gspca_dev *gspca_dev)
2531 } 2927 }
2532 2928
2533 reg_r(gspca_dev, 0xa1, 0xbfcf, 1); 2929 reg_r(gspca_dev, 0xa1, 0xbfcf, 1);
2534 PDEBUG(D_PROBE, "check sensor header %02x", gspca_dev->usb_buf[0]); 2930 PDEBUG(D_PROBE, "vc032%d check sensor header %02x",
2535 for (i = 0; i < ARRAY_SIZE(sensor_info_data); i++) { 2931 sd->bridge == BRIDGE_VC0321 ? 1 : 3, gspca_dev->usb_buf[0]);
2536 ptsensor_info = &sensor_info_data[i]; 2932 if (sd->bridge == BRIDGE_VC0321) {
2933 ptsensor_info = vc0321_probe_data;
2934 n = ARRAY_SIZE(vc0321_probe_data);
2935 } else {
2936 ptsensor_info = vc0323_probe_data;
2937 n = ARRAY_SIZE(vc0323_probe_data);
2938 }
2939 for (i = 0; i < n; i++) {
2537 reg_w(dev, 0xa0, 0x02, 0xb334); 2940 reg_w(dev, 0xa0, 0x02, 0xb334);
2538 reg_w(dev, 0xa0, ptsensor_info->m1, 0xb300); 2941 reg_w(dev, 0xa0, ptsensor_info->m1, 0xb300);
2539 reg_w(dev, 0xa0, ptsensor_info->m2, 0xb300); 2942 reg_w(dev, 0xa0, ptsensor_info->m2, 0xb300);
@@ -2551,13 +2954,15 @@ static int vc032x_probe_sensor(struct gspca_dev *gspca_dev)
2551 return ptsensor_info->sensorId; 2954 return ptsensor_info->sensorId;
2552 2955
2553 switch (value) { 2956 switch (value) {
2957 case 0x3130:
2958 return SENSOR_PO3130NC;
2554 case 0x7673: 2959 case 0x7673:
2555 return SENSOR_OV7670; 2960 return SENSOR_OV7670;
2556 case 0x8243: 2961 case 0x8243:
2557 return SENSOR_MI0360; 2962 return SENSOR_MI0360;
2558 } 2963 }
2559/*fixme: should return here*/
2560 } 2964 }
2965 ptsensor_info++;
2561 } 2966 }
2562 return -1; 2967 return -1;
2563} 2968}
@@ -2619,7 +3024,7 @@ static void usb_exchange(struct gspca_dev *gspca_dev,
2619 i2c_write(gspca_dev, data[i][0], &data[i][1], 2); 3024 i2c_write(gspca_dev, data[i][0], &data[i][1], 2);
2620 break; 3025 break;
2621 case 0xdd: 3026 case 0xdd:
2622 msleep(data[i][2] + 10); 3027 msleep(data[i][1] * 256 + data[i][2] + 10);
2623 break; 3028 break;
2624 } 3029 }
2625 i++; 3030 i++;
@@ -2646,12 +3051,17 @@ static int sd_config(struct gspca_dev *gspca_dev,
2646 64, /* OV7670 6 */ 3051 64, /* OV7670 6 */
2647 128, /* PO1200 7 */ 3052 128, /* PO1200 7 */
2648 128, /* PO3130NC 8 */ 3053 128, /* PO3130NC 8 */
3054 128, /* POxxxx 9 */
2649 }; 3055 };
2650 3056
2651 cam = &gspca_dev->cam; 3057 cam = &gspca_dev->cam;
2652 sd->bridge = id->driver_info >> 8; 3058 sd->bridge = id->driver_info >> 8;
2653 sd->flags = id->driver_info & 0xff; 3059 sd->flags = id->driver_info & 0xff;
2654 sensor = vc032x_probe_sensor(gspca_dev); 3060 if (id->idVendor == 0x046d &&
3061 (id->idProduct == 0x0892 || id->idProduct == 0x0896))
3062 sensor = SENSOR_POxxxx;
3063 else
3064 sensor = vc032x_probe_sensor(gspca_dev);
2655 switch (sensor) { 3065 switch (sensor) {
2656 case -1: 3066 case -1:
2657 PDEBUG(D_PROBE, "Unknown sensor..."); 3067 PDEBUG(D_PROBE, "Unknown sensor...");
@@ -2684,6 +3094,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
2684 case SENSOR_PO3130NC: 3094 case SENSOR_PO3130NC:
2685 PDEBUG(D_PROBE, "Find Sensor PO3130NC"); 3095 PDEBUG(D_PROBE, "Find Sensor PO3130NC");
2686 break; 3096 break;
3097 case SENSOR_POxxxx:
3098 PDEBUG(D_PROBE, "Sensor POxxxx");
3099 break;
2687 } 3100 }
2688 sd->sensor = sensor; 3101 sd->sensor = sensor;
2689 3102
@@ -2712,28 +3125,19 @@ static int sd_config(struct gspca_dev *gspca_dev,
2712 } 3125 }
2713 cam->npkt = npkt[sd->sensor]; 3126 cam->npkt = npkt[sd->sensor];
2714 3127
3128 sd->brightness = BRIGHTNESS_DEF;
3129 sd->contrast = CONTRAST_DEF;
3130 sd->colors = COLOR_DEF;
2715 sd->hflip = HFLIP_DEF; 3131 sd->hflip = HFLIP_DEF;
2716 sd->vflip = VFLIP_DEF; 3132 sd->vflip = VFLIP_DEF;
2717 if (sd->sensor == SENSOR_OV7670)
2718 sd->flags |= FL_HFLIP | FL_VFLIP;
2719 sd->lightfreq = FREQ_DEF; 3133 sd->lightfreq = FREQ_DEF;
2720 if (sd->sensor != SENSOR_OV7670)
2721 gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX);
2722 switch (sd->sensor) {
2723 case SENSOR_MI1310_SOC:
2724 case SENSOR_MI1320_SOC:
2725 case SENSOR_OV7660:
2726 case SENSOR_OV7670:
2727 case SENSOR_PO1200:
2728 break;
2729 default:
2730 gspca_dev->ctrl_dis = (1 << HFLIP_IDX)
2731 | (1 << VFLIP_IDX);
2732 break;
2733 }
2734
2735 sd->sharpness = SHARPNESS_DEF; 3134 sd->sharpness = SHARPNESS_DEF;
2736 3135
3136 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
3137
3138 if (sd->sensor == SENSOR_OV7670)
3139 sd->flags |= FL_HFLIP | FL_VFLIP;
3140
2737 if (sd->bridge == BRIDGE_VC0321) { 3141 if (sd->bridge == BRIDGE_VC0321) {
2738 reg_r(gspca_dev, 0x8a, 0, 3); 3142 reg_r(gspca_dev, 0x8a, 0, 3);
2739 reg_w(dev, 0x87, 0x00, 0x0f0f); 3143 reg_w(dev, 0x87, 0x00, 0x0f0f);
@@ -2747,10 +3151,55 @@ static int sd_config(struct gspca_dev *gspca_dev,
2747/* this function is called at probe and resume time */ 3151/* this function is called at probe and resume time */
2748static int sd_init(struct gspca_dev *gspca_dev) 3152static int sd_init(struct gspca_dev *gspca_dev)
2749{ 3153{
3154 struct sd *sd = (struct sd *) gspca_dev;
3155
3156 if (sd->sensor == SENSOR_POxxxx) {
3157 reg_r(gspca_dev, 0xa1, 0xb300, 1);
3158 if (gspca_dev->usb_buf[0] != 0) {
3159 reg_w(gspca_dev->dev, 0xa0, 0x26, 0xb300);
3160 reg_w(gspca_dev->dev, 0xa0, 0x04, 0xb300);
3161 reg_w(gspca_dev->dev, 0xa0, 0x00, 0xb300);
3162 }
3163 }
2750 return 0; 3164 return 0;
2751} 3165}
2752 3166
2753/* some sensors only */ 3167static void setbrightness(struct gspca_dev *gspca_dev)
3168{
3169 struct sd *sd = (struct sd *) gspca_dev;
3170 u8 data;
3171
3172 if (gspca_dev->ctrl_dis & (1 << BRIGHTNESS_IDX))
3173 return;
3174 data = sd->brightness;
3175 if (data >= 0x80)
3176 data &= 0x7f;
3177 else
3178 data = 0xff ^ data;
3179 i2c_write(gspca_dev, 0x98, &data, 1);
3180}
3181
3182static void setcontrast(struct gspca_dev *gspca_dev)
3183{
3184 struct sd *sd = (struct sd *) gspca_dev;
3185
3186 if (gspca_dev->ctrl_dis & (1 << CONTRAST_IDX))
3187 return;
3188 i2c_write(gspca_dev, 0x99, &sd->contrast, 1);
3189}
3190
3191static void setcolors(struct gspca_dev *gspca_dev)
3192{
3193 struct sd *sd = (struct sd *) gspca_dev;
3194 u8 data;
3195
3196 if (gspca_dev->ctrl_dis & (1 << COLORS_IDX))
3197 return;
3198 data = sd->colors - (sd->colors >> 3) - 1;
3199 i2c_write(gspca_dev, 0x94, &data, 1);
3200 i2c_write(gspca_dev, 0x95, &sd->colors, 1);
3201}
3202
2754static void sethvflip(struct gspca_dev *gspca_dev) 3203static void sethvflip(struct gspca_dev *gspca_dev)
2755{ 3204{
2756 struct sd *sd = (struct sd *) gspca_dev; 3205 struct sd *sd = (struct sd *) gspca_dev;
@@ -2764,6 +3213,7 @@ static void sethvflip(struct gspca_dev *gspca_dev)
2764 vflip = !vflip; 3213 vflip = !vflip;
2765 switch (sd->sensor) { 3214 switch (sd->sensor) {
2766 case SENSOR_MI1310_SOC: 3215 case SENSOR_MI1310_SOC:
3216 case SENSOR_MI1320:
2767 case SENSOR_MI1320_SOC: 3217 case SENSOR_MI1320_SOC:
2768 data[0] = data[1] = 0; /* select page 0 */ 3218 data[0] = data[1] = 0; /* select page 0 */
2769 i2c_write(gspca_dev, 0xf0, data, 2); 3219 i2c_write(gspca_dev, 0xf0, data, 2);
@@ -2801,18 +3251,29 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
2801 usb_exchange(gspca_dev, ov7660_freq_tb[sd->lightfreq]); 3251 usb_exchange(gspca_dev, ov7660_freq_tb[sd->lightfreq]);
2802} 3252}
2803 3253
2804/* po1200 only */
2805static void setsharpness(struct gspca_dev *gspca_dev) 3254static void setsharpness(struct gspca_dev *gspca_dev)
2806{ 3255{
2807 struct sd *sd = (struct sd *) gspca_dev; 3256 struct sd *sd = (struct sd *) gspca_dev;
2808 u8 data; 3257 u8 data;
2809 3258
2810 if (sd->sensor != SENSOR_PO1200) 3259 switch (sd->sensor) {
2811 return; 3260 case SENSOR_PO1200:
2812 data = 0; 3261 data = 0;
2813 i2c_write(gspca_dev, 0x03, &data, 1); 3262 i2c_write(gspca_dev, 0x03, &data, 1);
2814 data = 0xb5 + sd->sharpness * 3; 3263 if (sd->sharpness < 0)
2815 i2c_write(gspca_dev, 0x61, &data, 1); 3264 data = 0x6a;
3265 else
3266 data = 0xb5 + sd->sharpness * 3;
3267 i2c_write(gspca_dev, 0x61, &data, 1);
3268 break;
3269 case SENSOR_POxxxx:
3270 if (sd->sharpness < 0)
3271 data = 0x7e; /* def = max */
3272 else
3273 data = 0x60 + sd->sharpness * 0x0f;
3274 i2c_write(gspca_dev, 0x59, &data, 1);
3275 break;
3276 }
2816} 3277}
2817 3278
2818static int sd_start(struct gspca_dev *gspca_dev) 3279static int sd_start(struct gspca_dev *gspca_dev)
@@ -2922,12 +3383,27 @@ static int sd_start(struct gspca_dev *gspca_dev)
2922 usb_exchange(gspca_dev, init); 3383 usb_exchange(gspca_dev, init);
2923 init = po3130_rundata; 3384 init = po3130_rundata;
2924 break; 3385 break;
2925 default: 3386 case SENSOR_PO1200:
2926/* case SENSOR_PO1200: */
2927 GammaT = po1200_gamma; 3387 GammaT = po1200_gamma;
2928 MatrixT = po1200_matrix; 3388 MatrixT = po1200_matrix;
2929 init = po1200_initVGA_data; 3389 init = po1200_initVGA_data;
2930 break; 3390 break;
3391 default:
3392/* case SENSOR_POxxxx: */
3393 usb_exchange(gspca_dev, poxxxx_init_common);
3394 if (mode)
3395 init = poxxxx_initQVGA;
3396 else
3397 init = poxxxx_initVGA;
3398 usb_exchange(gspca_dev, init);
3399 reg_r(gspca_dev, 0x8c, 0x0000, 3);
3400 reg_w(gspca_dev->dev, 0xa0,
3401 gspca_dev->usb_buf[2] & 1 ? 0 : 1,
3402 0xb35c);
3403 msleep(300);
3404/*fixme: i2c read 04 and 05*/
3405 init = poxxxx_init_end_1;
3406 break;
2931 } 3407 }
2932 usb_exchange(gspca_dev, init); 3408 usb_exchange(gspca_dev, init);
2933 if (GammaT && MatrixT) { 3409 if (GammaT && MatrixT) {
@@ -2936,7 +3412,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
2936 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb86c); 3412 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb86c);
2937 put_tab_to_reg(gspca_dev, MatrixT, 9, 0xb82c); 3413 put_tab_to_reg(gspca_dev, MatrixT, 9, 0xb82c);
2938 3414
2939 /* set the led on 0x0892 0x0896 */
2940 switch (sd->sensor) { 3415 switch (sd->sensor) {
2941 case SENSOR_PO1200: 3416 case SENSOR_PO1200:
2942 case SENSOR_HV7131R: 3417 case SENSOR_HV7131R:
@@ -2945,16 +3420,22 @@ static int sd_start(struct gspca_dev *gspca_dev)
2945 case SENSOR_MI1310_SOC: 3420 case SENSOR_MI1310_SOC:
2946 reg_w(gspca_dev->dev, 0x89, 0x058c, 0x0000); 3421 reg_w(gspca_dev->dev, 0x89, 0x058c, 0x0000);
2947 break; 3422 break;
2948 default:
2949 if (!(sd->flags & FL_SAMSUNG))
2950 reg_w(gspca_dev->dev, 0x89, 0xffff, 0xfdff);
2951 break;
2952 } 3423 }
2953 msleep(100); 3424 msleep(100);
2954 setsharpness(gspca_dev); 3425 setsharpness(gspca_dev);
2955 sethvflip(gspca_dev); 3426 sethvflip(gspca_dev);
2956 setlightfreq(gspca_dev); 3427 setlightfreq(gspca_dev);
2957 } 3428 }
3429 if (sd->sensor == SENSOR_POxxxx) {
3430 setcolors(gspca_dev);
3431 setbrightness(gspca_dev);
3432 setcontrast(gspca_dev);
3433
3434 /* led on */
3435 msleep(80);
3436 reg_w(gspca_dev->dev, 0x89, 0xffff, 0xfdff);
3437 usb_exchange(gspca_dev, poxxxx_init_end_2);
3438 }
2958 return 0; 3439 return 0;
2959} 3440}
2960 3441
@@ -2963,10 +3444,17 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2963 struct usb_device *dev = gspca_dev->dev; 3444 struct usb_device *dev = gspca_dev->dev;
2964 struct sd *sd = (struct sd *) gspca_dev; 3445 struct sd *sd = (struct sd *) gspca_dev;
2965 3446
2966 if (sd->sensor == SENSOR_MI1310_SOC) 3447 switch (sd->sensor) {
3448 case SENSOR_MI1310_SOC:
2967 reg_w(dev, 0x89, 0x058c, 0x00ff); 3449 reg_w(dev, 0x89, 0x058c, 0x00ff);
2968 else if (!(sd->flags & FL_SAMSUNG)) 3450 break;
2969 reg_w(dev, 0x89, 0xffff, 0xffff); 3451 case SENSOR_POxxxx:
3452 return;
3453 default:
3454 if (!(sd->flags & FL_SAMSUNG))
3455 reg_w(dev, 0x89, 0xffff, 0xffff);
3456 break;
3457 }
2970 reg_w(dev, 0xa0, 0x01, 0xb301); 3458 reg_w(dev, 0xa0, 0x01, 0xb301);
2971 reg_w(dev, 0xa0, 0x09, 0xb003); 3459 reg_w(dev, 0xa0, 0x09, 0xb003);
2972} 3460}
@@ -2984,6 +3472,12 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
2984 reg_w(dev, 0x89, 0x058c, 0x00ff); 3472 reg_w(dev, 0x89, 0x058c, 0x00ff);
2985 else if (!(sd->flags & FL_SAMSUNG)) 3473 else if (!(sd->flags & FL_SAMSUNG))
2986 reg_w(dev, 0x89, 0xffff, 0xffff); 3474 reg_w(dev, 0x89, 0xffff, 0xffff);
3475
3476 if (sd->sensor == SENSOR_POxxxx) {
3477 reg_w(dev, 0xa0, 0x26, 0xb300);
3478 reg_w(dev, 0xa0, 0x04, 0xb300);
3479 reg_w(dev, 0xa0, 0x00, 0xb300);
3480 }
2987} 3481}
2988 3482
2989static void sd_pkt_scan(struct gspca_dev *gspca_dev, 3483static void sd_pkt_scan(struct gspca_dev *gspca_dev,
@@ -3020,6 +3514,60 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
3020 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 3514 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
3021} 3515}
3022 3516
3517static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
3518{
3519 struct sd *sd = (struct sd *) gspca_dev;
3520
3521 sd->brightness = val;
3522 if (gspca_dev->streaming)
3523 setbrightness(gspca_dev);
3524 return 0;
3525}
3526
3527static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
3528{
3529 struct sd *sd = (struct sd *) gspca_dev;
3530
3531 *val = sd->brightness;
3532 return 0;
3533}
3534
3535static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
3536{
3537 struct sd *sd = (struct sd *) gspca_dev;
3538
3539 sd->contrast = val;
3540 if (gspca_dev->streaming)
3541 setcontrast(gspca_dev);
3542 return 0;
3543}
3544
3545static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
3546{
3547 struct sd *sd = (struct sd *) gspca_dev;
3548
3549 *val = sd->contrast;
3550 return 0;
3551}
3552
3553static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
3554{
3555 struct sd *sd = (struct sd *) gspca_dev;
3556
3557 sd->colors = val;
3558 if (gspca_dev->streaming)
3559 setcolors(gspca_dev);
3560 return 0;
3561}
3562
3563static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
3564{
3565 struct sd *sd = (struct sd *) gspca_dev;
3566
3567 *val = sd->colors;
3568 return 0;
3569}
3570
3023static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val) 3571static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
3024{ 3572{
3025 struct sd *sd = (struct sd *) gspca_dev; 3573 struct sd *sd = (struct sd *) gspca_dev;