1a112cc39SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
20c0d06caSMauro Carvalho Chehab /* Subdriver for the GL860 chip with the MI1320 sensor
30c0d06caSMauro Carvalho Chehab * Author Olivier LORIN from own logs
40c0d06caSMauro Carvalho Chehab */
50c0d06caSMauro Carvalho Chehab
60c0d06caSMauro Carvalho Chehab /* Sensor : MI1320 */
70c0d06caSMauro Carvalho Chehab
80c0d06caSMauro Carvalho Chehab #include "gl860.h"
90c0d06caSMauro Carvalho Chehab
100c0d06caSMauro Carvalho Chehab static struct validx tbl_common[] = {
110c0d06caSMauro Carvalho Chehab {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba51, 0x0066}, {0xba02, 0x00f1},
120c0d06caSMauro Carvalho Chehab {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1},
130c0d06caSMauro Carvalho Chehab {0xffff, 0xffff},
140c0d06caSMauro Carvalho Chehab {0xba00, 0x00f0}, {0xba02, 0x00f1}, {0xbafa, 0x0028}, {0xba02, 0x00f1},
150c0d06caSMauro Carvalho Chehab {0xba00, 0x00f0}, {0xba01, 0x00f1}, {0xbaf0, 0x0006}, {0xba0e, 0x00f1},
160c0d06caSMauro Carvalho Chehab {0xba70, 0x0006}, {0xba0e, 0x00f1},
170c0d06caSMauro Carvalho Chehab {0xffff, 0xffff},
180c0d06caSMauro Carvalho Chehab {0xba74, 0x0006}, {0xba0e, 0x00f1},
190c0d06caSMauro Carvalho Chehab {0xffff, 0xffff},
200c0d06caSMauro Carvalho Chehab {0x0061, 0x0000}, {0x0068, 0x000d},
210c0d06caSMauro Carvalho Chehab };
220c0d06caSMauro Carvalho Chehab
230c0d06caSMauro Carvalho Chehab static struct validx tbl_init_at_startup[] = {
240c0d06caSMauro Carvalho Chehab {0x0000, 0x0000}, {0x0010, 0x0010},
250c0d06caSMauro Carvalho Chehab {35, 0xffff},
260c0d06caSMauro Carvalho Chehab {0x0008, 0x00c0}, {0x0001, 0x00c1}, {0x0001, 0x00c2}, {0x0020, 0x0006},
270c0d06caSMauro Carvalho Chehab {0x006a, 0x000d},
280c0d06caSMauro Carvalho Chehab };
290c0d06caSMauro Carvalho Chehab
300c0d06caSMauro Carvalho Chehab static struct validx tbl_sensor_settings_common[] = {
310c0d06caSMauro Carvalho Chehab {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, {0x0040, 0x0000},
320c0d06caSMauro Carvalho Chehab {0x006a, 0x0007}, {0x006a, 0x000d}, {0x0063, 0x0006},
330c0d06caSMauro Carvalho Chehab };
340c0d06caSMauro Carvalho Chehab static struct validx tbl_sensor_settings_1280[] = {
350c0d06caSMauro Carvalho Chehab {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba5a, 0x0066}, {0xba02, 0x00f1},
360c0d06caSMauro Carvalho Chehab {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xba20, 0x0065}, {0xba00, 0x00f1},
370c0d06caSMauro Carvalho Chehab };
380c0d06caSMauro Carvalho Chehab static struct validx tbl_sensor_settings_800[] = {
390c0d06caSMauro Carvalho Chehab {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba5a, 0x0066}, {0xba02, 0x00f1},
400c0d06caSMauro Carvalho Chehab {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xba20, 0x0065}, {0xba00, 0x00f1},
410c0d06caSMauro Carvalho Chehab };
420c0d06caSMauro Carvalho Chehab static struct validx tbl_sensor_settings_640[] = {
430c0d06caSMauro Carvalho Chehab {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1},
440c0d06caSMauro Carvalho Chehab {0xba51, 0x0066}, {0xba02, 0x00f1}, {0xba05, 0x0067}, {0xba05, 0x00f1},
450c0d06caSMauro Carvalho Chehab {0xba20, 0x0065}, {0xba00, 0x00f1},
460c0d06caSMauro Carvalho Chehab };
470c0d06caSMauro Carvalho Chehab static struct validx tbl_post_unset_alt[] = {
480c0d06caSMauro Carvalho Chehab {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1},
490c0d06caSMauro Carvalho Chehab {0x0061, 0x0000}, {0x0068, 0x000d},
500c0d06caSMauro Carvalho Chehab };
510c0d06caSMauro Carvalho Chehab
520c0d06caSMauro Carvalho Chehab static u8 *tbl_1280[] = {
53*3ae5c3bcSHans Verkuil (u8[]){
54*3ae5c3bcSHans Verkuil 0x0d, 0x80, 0xf1, 0x08, 0x03, 0x04, 0xf1, 0x00,
55*3ae5c3bcSHans Verkuil 0x04, 0x05, 0xf1, 0x02, 0x05, 0x00, 0xf1, 0xf1,
56*3ae5c3bcSHans Verkuil 0x06, 0x00, 0xf1, 0x0d, 0x20, 0x01, 0xf1, 0x00,
57*3ae5c3bcSHans Verkuil 0x21, 0x84, 0xf1, 0x00, 0x0d, 0x00, 0xf1, 0x08,
58*3ae5c3bcSHans Verkuil 0xf0, 0x00, 0xf1, 0x01, 0x34, 0x00, 0xf1, 0x00,
59*3ae5c3bcSHans Verkuil 0x9b, 0x43, 0xf1, 0x00, 0xa6, 0x05, 0xf1, 0x00,
60*3ae5c3bcSHans Verkuil 0xa9, 0x04, 0xf1, 0x00, 0xa1, 0x05, 0xf1, 0x00,
61*3ae5c3bcSHans Verkuil 0xa4, 0x04, 0xf1, 0x00, 0xae, 0x0a, 0xf1, 0x08
62*3ae5c3bcSHans Verkuil }, (u8[]){
63*3ae5c3bcSHans Verkuil 0xf0, 0x00, 0xf1, 0x02, 0x3a, 0x05, 0xf1, 0xf1,
64*3ae5c3bcSHans Verkuil 0x3c, 0x05, 0xf1, 0xf1, 0x59, 0x01, 0xf1, 0x47,
65*3ae5c3bcSHans Verkuil 0x5a, 0x01, 0xf1, 0x88, 0x5c, 0x0a, 0xf1, 0x06,
66*3ae5c3bcSHans Verkuil 0x5d, 0x0e, 0xf1, 0x0a, 0x64, 0x5e, 0xf1, 0x1c,
67*3ae5c3bcSHans Verkuil 0xd2, 0x00, 0xf1, 0xcf, 0xcb, 0x00, 0xf1, 0x01
68*3ae5c3bcSHans Verkuil }, (u8[]){
69*3ae5c3bcSHans Verkuil 0xd3, 0x02, 0xd4, 0x28, 0xd5, 0x01, 0xd0, 0x02,
70*3ae5c3bcSHans Verkuil 0xd1, 0x18, 0xd2, 0xc1
71*3ae5c3bcSHans Verkuil }
720c0d06caSMauro Carvalho Chehab };
730c0d06caSMauro Carvalho Chehab
740c0d06caSMauro Carvalho Chehab static u8 *tbl_800[] = {
75*3ae5c3bcSHans Verkuil (u8[]){
76*3ae5c3bcSHans Verkuil 0x0d, 0x80, 0xf1, 0x08, 0x03, 0x03, 0xf1, 0xc0,
77*3ae5c3bcSHans Verkuil 0x04, 0x05, 0xf1, 0x02, 0x05, 0x00, 0xf1, 0xf1,
78*3ae5c3bcSHans Verkuil 0x06, 0x00, 0xf1, 0x0d, 0x20, 0x01, 0xf1, 0x00,
79*3ae5c3bcSHans Verkuil 0x21, 0x84, 0xf1, 0x00, 0x0d, 0x00, 0xf1, 0x08,
80*3ae5c3bcSHans Verkuil 0xf0, 0x00, 0xf1, 0x01, 0x34, 0x00, 0xf1, 0x00,
81*3ae5c3bcSHans Verkuil 0x9b, 0x43, 0xf1, 0x00, 0xa6, 0x05, 0xf1, 0x00,
82*3ae5c3bcSHans Verkuil 0xa9, 0x03, 0xf1, 0xc0, 0xa1, 0x03, 0xf1, 0x20,
83*3ae5c3bcSHans Verkuil 0xa4, 0x02, 0xf1, 0x5a, 0xae, 0x0a, 0xf1, 0x08
84*3ae5c3bcSHans Verkuil }, (u8[]){
85*3ae5c3bcSHans Verkuil 0xf0, 0x00, 0xf1, 0x02, 0x3a, 0x05, 0xf1, 0xf1,
86*3ae5c3bcSHans Verkuil 0x3c, 0x05, 0xf1, 0xf1, 0x59, 0x01, 0xf1, 0x47,
87*3ae5c3bcSHans Verkuil 0x5a, 0x01, 0xf1, 0x88, 0x5c, 0x0a, 0xf1, 0x06,
88*3ae5c3bcSHans Verkuil 0x5d, 0x0e, 0xf1, 0x0a, 0x64, 0x5e, 0xf1, 0x1c,
89*3ae5c3bcSHans Verkuil 0xd2, 0x00, 0xf1, 0xcf, 0xcb, 0x00, 0xf1, 0x01
90*3ae5c3bcSHans Verkuil }, (u8[]){
91*3ae5c3bcSHans Verkuil 0xd3, 0x02, 0xd4, 0x18, 0xd5, 0x21, 0xd0, 0x02,
92*3ae5c3bcSHans Verkuil 0xd1, 0x10, 0xd2, 0x59
93*3ae5c3bcSHans Verkuil }
940c0d06caSMauro Carvalho Chehab };
950c0d06caSMauro Carvalho Chehab
960c0d06caSMauro Carvalho Chehab static u8 *tbl_640[] = {
97*3ae5c3bcSHans Verkuil (u8[]){
98*3ae5c3bcSHans Verkuil 0x0d, 0x80, 0xf1, 0x08, 0x03, 0x04, 0xf1, 0x04,
99*3ae5c3bcSHans Verkuil 0x04, 0x05, 0xf1, 0x02, 0x07, 0x01, 0xf1, 0x7c,
100*3ae5c3bcSHans Verkuil 0x08, 0x00, 0xf1, 0x0e, 0x21, 0x80, 0xf1, 0x00,
101*3ae5c3bcSHans Verkuil 0x0d, 0x00, 0xf1, 0x08, 0xf0, 0x00, 0xf1, 0x01,
102*3ae5c3bcSHans Verkuil 0x34, 0x10, 0xf1, 0x10, 0x3a, 0x43, 0xf1, 0x00,
103*3ae5c3bcSHans Verkuil 0xa6, 0x05, 0xf1, 0x02, 0xa9, 0x04, 0xf1, 0x04,
104*3ae5c3bcSHans Verkuil 0xa7, 0x02, 0xf1, 0x81, 0xaa, 0x01, 0xf1, 0xe2,
105*3ae5c3bcSHans Verkuil 0xae, 0x0c, 0xf1, 0x09
106*3ae5c3bcSHans Verkuil }, (u8[]){
107*3ae5c3bcSHans Verkuil 0xf0, 0x00, 0xf1, 0x02, 0x39, 0x03, 0xf1, 0xfc,
108*3ae5c3bcSHans Verkuil 0x3b, 0x04, 0xf1, 0x04, 0x57, 0x01, 0xf1, 0xb6,
109*3ae5c3bcSHans Verkuil 0x58, 0x02, 0xf1, 0x0d, 0x5c, 0x1f, 0xf1, 0x19,
110*3ae5c3bcSHans Verkuil 0x5d, 0x24, 0xf1, 0x1e, 0x64, 0x5e, 0xf1, 0x1c,
111*3ae5c3bcSHans Verkuil 0xd2, 0x00, 0xf1, 0x00, 0xcb, 0x00, 0xf1, 0x01
112*3ae5c3bcSHans Verkuil }, (u8[]){
113*3ae5c3bcSHans Verkuil 0xd3, 0x02, 0xd4, 0x10, 0xd5, 0x81, 0xd0, 0x02,
114*3ae5c3bcSHans Verkuil 0xd1, 0x08, 0xd2, 0xe1
115*3ae5c3bcSHans Verkuil }
1160c0d06caSMauro Carvalho Chehab };
1170c0d06caSMauro Carvalho Chehab
1180c0d06caSMauro Carvalho Chehab static s32 tbl_sat[] = {0x25, 0x1d, 0x15, 0x0d, 0x05, 0x4d, 0x55, 0x5d, 0x2d};
1190c0d06caSMauro Carvalho Chehab static s32 tbl_bright[] = {0, 8, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70};
1200c0d06caSMauro Carvalho Chehab static s32 tbl_backlight[] = {0x0e, 0x06, 0x02};
1210c0d06caSMauro Carvalho Chehab
1220c0d06caSMauro Carvalho Chehab static s32 tbl_cntr1[] = {
1230c0d06caSMauro Carvalho Chehab 0x90, 0x98, 0xa0, 0xa8, 0xb0, 0xb8, 0xc0, 0xc8, 0xd0, 0xe0, 0xf0};
1240c0d06caSMauro Carvalho Chehab static s32 tbl_cntr2[] = {
1250c0d06caSMauro Carvalho Chehab 0x70, 0x68, 0x60, 0x58, 0x50, 0x48, 0x40, 0x38, 0x30, 0x20, 0x10};
1260c0d06caSMauro Carvalho Chehab
1270c0d06caSMauro Carvalho Chehab static u8 dat_wbalNL[] =
1280c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x3b\x04\xf1\x2a\x47\x10\xf1\x10"
1290c0d06caSMauro Carvalho Chehab "\x9d\x3c\xf1\xae\xaf\x10\xf1\x00" "\xf0\x00\xf1\x02\x2f\x91\xf1\x20"
1300c0d06caSMauro Carvalho Chehab "\x9c\x91\xf1\x20\x37\x03\xf1\x00" "\x9d\xc5\xf1\x0f\xf0\x00\xf1\x00";
1310c0d06caSMauro Carvalho Chehab
1320c0d06caSMauro Carvalho Chehab static u8 dat_wbalLL[] =
1330c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x01\x05\x00\xf1\x0c" "\x3b\x04\xf1\x2a\x47\x40\xf1\x40"
1340c0d06caSMauro Carvalho Chehab "\x9d\x20\xf1\xae\xaf\x10\xf1\x00" "\xf0\x00\xf1\x02\x2f\xd1\xf1\x00"
1350c0d06caSMauro Carvalho Chehab "\x9c\xd1\xf1\x00\x37\x03\xf1\x00" "\x9d\xc5\xf1\x3f\xf0\x00\xf1\x00";
1360c0d06caSMauro Carvalho Chehab
1370c0d06caSMauro Carvalho Chehab static u8 dat_wbalBL[] =
1380c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x47\x10\xf1\x30\x9d\x3c\xf1\xae"
1390c0d06caSMauro Carvalho Chehab "\xaf\x10\xf1\x00\xf0\x00\xf1\x02" "\x2f\x91\xf1\x20\x9c\x91\xf1\x20"
1400c0d06caSMauro Carvalho Chehab "\x37\x03\xf1\x00\x9d\xc5\xf1\x2f" "\xf0\x00\xf1\x00";
1410c0d06caSMauro Carvalho Chehab
1420c0d06caSMauro Carvalho Chehab static u8 dat_hvflip1[] = {0xf0, 0x00, 0xf1, 0x00};
1430c0d06caSMauro Carvalho Chehab
1440c0d06caSMauro Carvalho Chehab static u8 dat_common00[] =
1450c0d06caSMauro Carvalho Chehab "\x00\x01\x07\x6a\x06\x63\x0d\x6a" "\xc0\x00\x10\x10\xc1\x03\xc2\x42"
1460c0d06caSMauro Carvalho Chehab "\xd8\x04\x58\x00\x04\x02";
1470c0d06caSMauro Carvalho Chehab static u8 dat_common01[] =
1480c0d06caSMauro Carvalho Chehab "\x0d\x00\xf1\x0b\x0d\x00\xf1\x08" "\x35\x00\xf1\x22\x68\x00\xf1\x5d"
1490c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x01\x06\x70\xf1\x0e" "\xf0\x00\xf1\x02\xdd\x18\xf1\xe0";
1500c0d06caSMauro Carvalho Chehab static u8 dat_common02[] =
1510c0d06caSMauro Carvalho Chehab "\x05\x01\xf1\x84\x06\x00\xf1\x44" "\x07\x00\xf1\xbe\x08\x00\xf1\x1e"
1520c0d06caSMauro Carvalho Chehab "\x20\x01\xf1\x03\x21\x84\xf1\x00" "\x22\x0d\xf1\x0f\x24\x80\xf1\x00"
1530c0d06caSMauro Carvalho Chehab "\x34\x18\xf1\x2d\x35\x00\xf1\x22" "\x43\x83\xf1\x83\x59\x00\xf1\xff";
1540c0d06caSMauro Carvalho Chehab static u8 dat_common03[] =
1550c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x02\x39\x06\xf1\x8c" "\x3a\x06\xf1\x8c\x3b\x03\xf1\xda"
1560c0d06caSMauro Carvalho Chehab "\x3c\x05\xf1\x30\x57\x01\xf1\x0c" "\x58\x01\xf1\x42\x59\x01\xf1\x0c"
1570c0d06caSMauro Carvalho Chehab "\x5a\x01\xf1\x42\x5c\x13\xf1\x0e" "\x5d\x17\xf1\x12\x64\x1e\xf1\x1c";
1580c0d06caSMauro Carvalho Chehab static u8 dat_common04[] =
1590c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x02\x24\x5f\xf1\x20" "\x28\xea\xf1\x02\x5f\x41\xf1\x43";
1600c0d06caSMauro Carvalho Chehab static u8 dat_common05[] =
1610c0d06caSMauro Carvalho Chehab "\x02\x00\xf1\xee\x03\x29\xf1\x1a" "\x04\x02\xf1\xa4\x09\x00\xf1\x68"
1620c0d06caSMauro Carvalho Chehab "\x0a\x00\xf1\x2a\x0b\x00\xf1\x04" "\x0c\x00\xf1\x93\x0d\x00\xf1\x82"
1630c0d06caSMauro Carvalho Chehab "\x0e\x00\xf1\x40\x0f\x00\xf1\x5f" "\x10\x00\xf1\x4e\x11\x00\xf1\x5b";
1640c0d06caSMauro Carvalho Chehab static u8 dat_common06[] =
1650c0d06caSMauro Carvalho Chehab "\x15\x00\xf1\xc9\x16\x00\xf1\x5e" "\x17\x00\xf1\x9d\x18\x00\xf1\x06"
1660c0d06caSMauro Carvalho Chehab "\x19\x00\xf1\x89\x1a\x00\xf1\x12" "\x1b\x00\xf1\xa1\x1c\x00\xf1\xe4"
1670c0d06caSMauro Carvalho Chehab "\x1d\x00\xf1\x7a\x1e\x00\xf1\x64" "\xf6\x00\xf1\x5f";
1680c0d06caSMauro Carvalho Chehab static u8 dat_common07[] =
1690c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x01\x53\x09\xf1\x03" "\x54\x3d\xf1\x1c\x55\x99\xf1\x72"
1700c0d06caSMauro Carvalho Chehab "\x56\xc1\xf1\xb1\x57\xd8\xf1\xce" "\x58\xe0\xf1\x00\xdc\x0a\xf1\x03"
1710c0d06caSMauro Carvalho Chehab "\xdd\x45\xf1\x20\xde\xae\xf1\x82" "\xdf\xdc\xf1\xc9\xe0\xf6\xf1\xea"
1720c0d06caSMauro Carvalho Chehab "\xe1\xff\xf1\x00";
1730c0d06caSMauro Carvalho Chehab static u8 dat_common08[] =
1740c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x01\x80\x00\xf1\x06" "\x81\xf6\xf1\x08\x82\xfb\xf1\xf7"
1750c0d06caSMauro Carvalho Chehab "\x83\x00\xf1\xfe\xb6\x07\xf1\x03" "\xb7\x18\xf1\x0c\x84\xfb\xf1\x06"
1760c0d06caSMauro Carvalho Chehab "\x85\xfb\xf1\xf9\x86\x00\xf1\xff" "\xb8\x07\xf1\x04\xb9\x16\xf1\x0a";
1770c0d06caSMauro Carvalho Chehab static u8 dat_common09[] =
1780c0d06caSMauro Carvalho Chehab "\x87\xfa\xf1\x05\x88\xfc\xf1\xf9" "\x89\x00\xf1\xff\xba\x06\xf1\x03"
1790c0d06caSMauro Carvalho Chehab "\xbb\x17\xf1\x09\x8a\xe8\xf1\x14" "\x8b\xf7\xf1\xf0\x8c\xfd\xf1\xfa"
1800c0d06caSMauro Carvalho Chehab "\x8d\x00\xf1\x00\xbc\x05\xf1\x01" "\xbd\x0c\xf1\x08\xbe\x00\xf1\x14";
1810c0d06caSMauro Carvalho Chehab static u8 dat_common10[] =
1820c0d06caSMauro Carvalho Chehab "\x8e\xea\xf1\x13\x8f\xf7\xf1\xf2" "\x90\xfd\xf1\xfa\x91\x00\xf1\x00"
1830c0d06caSMauro Carvalho Chehab "\xbf\x05\xf1\x01\xc0\x0a\xf1\x08" "\xc1\x00\xf1\x0c\x92\xed\xf1\x0f"
1840c0d06caSMauro Carvalho Chehab "\x93\xf9\xf1\xf4\x94\xfe\xf1\xfb" "\x95\x00\xf1\x00\xc2\x04\xf1\x01"
1850c0d06caSMauro Carvalho Chehab "\xc3\x0a\xf1\x07\xc4\x00\xf1\x10";
1860c0d06caSMauro Carvalho Chehab static u8 dat_common11[] =
1870c0d06caSMauro Carvalho Chehab "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x25\x00\xf1\x55\x34\x10\xf1\x10"
1880c0d06caSMauro Carvalho Chehab "\x35\xf0\xf1\x10\x3a\x02\xf1\x03" "\x3b\x04\xf1\x2a\x9b\x43\xf1\x00"
1890c0d06caSMauro Carvalho Chehab "\xa4\x03\xf1\xc0\xa7\x02\xf1\x81";
1900c0d06caSMauro Carvalho Chehab
1910c0d06caSMauro Carvalho Chehab static int mi1320_init_at_startup(struct gspca_dev *gspca_dev);
1920c0d06caSMauro Carvalho Chehab static int mi1320_configure_alt(struct gspca_dev *gspca_dev);
1930c0d06caSMauro Carvalho Chehab static int mi1320_init_pre_alt(struct gspca_dev *gspca_dev);
1940c0d06caSMauro Carvalho Chehab static int mi1320_init_post_alt(struct gspca_dev *gspca_dev);
1950c0d06caSMauro Carvalho Chehab static void mi1320_post_unset_alt(struct gspca_dev *gspca_dev);
1960c0d06caSMauro Carvalho Chehab static int mi1320_sensor_settings(struct gspca_dev *gspca_dev);
1970c0d06caSMauro Carvalho Chehab static int mi1320_camera_settings(struct gspca_dev *gspca_dev);
1980c0d06caSMauro Carvalho Chehab /*==========================================================================*/
1990c0d06caSMauro Carvalho Chehab
mi1320_init_settings(struct gspca_dev * gspca_dev)2000c0d06caSMauro Carvalho Chehab void mi1320_init_settings(struct gspca_dev *gspca_dev)
2010c0d06caSMauro Carvalho Chehab {
2020c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev;
2030c0d06caSMauro Carvalho Chehab
2040c0d06caSMauro Carvalho Chehab sd->vcur.backlight = 0;
2050c0d06caSMauro Carvalho Chehab sd->vcur.brightness = 0;
2060c0d06caSMauro Carvalho Chehab sd->vcur.sharpness = 6;
2070c0d06caSMauro Carvalho Chehab sd->vcur.contrast = 10;
2080c0d06caSMauro Carvalho Chehab sd->vcur.gamma = 20;
2090c0d06caSMauro Carvalho Chehab sd->vcur.hue = 0;
2100c0d06caSMauro Carvalho Chehab sd->vcur.saturation = 6;
2110c0d06caSMauro Carvalho Chehab sd->vcur.whitebal = 0;
2120c0d06caSMauro Carvalho Chehab sd->vcur.mirror = 0;
2130c0d06caSMauro Carvalho Chehab sd->vcur.flip = 0;
2140c0d06caSMauro Carvalho Chehab sd->vcur.AC50Hz = 1;
2150c0d06caSMauro Carvalho Chehab
2160c0d06caSMauro Carvalho Chehab sd->vmax.backlight = 2;
2170c0d06caSMauro Carvalho Chehab sd->vmax.brightness = 8;
2180c0d06caSMauro Carvalho Chehab sd->vmax.sharpness = 7;
2190c0d06caSMauro Carvalho Chehab sd->vmax.contrast = 0; /* 10 but not working with this driver */
2200c0d06caSMauro Carvalho Chehab sd->vmax.gamma = 40;
2210c0d06caSMauro Carvalho Chehab sd->vmax.hue = 5 + 1;
2220c0d06caSMauro Carvalho Chehab sd->vmax.saturation = 8;
2230c0d06caSMauro Carvalho Chehab sd->vmax.whitebal = 2;
2240c0d06caSMauro Carvalho Chehab sd->vmax.mirror = 1;
2250c0d06caSMauro Carvalho Chehab sd->vmax.flip = 1;
2260c0d06caSMauro Carvalho Chehab sd->vmax.AC50Hz = 1;
2270c0d06caSMauro Carvalho Chehab
2280c0d06caSMauro Carvalho Chehab sd->dev_camera_settings = mi1320_camera_settings;
2290c0d06caSMauro Carvalho Chehab sd->dev_init_at_startup = mi1320_init_at_startup;
2300c0d06caSMauro Carvalho Chehab sd->dev_configure_alt = mi1320_configure_alt;
2310c0d06caSMauro Carvalho Chehab sd->dev_init_pre_alt = mi1320_init_pre_alt;
2320c0d06caSMauro Carvalho Chehab sd->dev_post_unset_alt = mi1320_post_unset_alt;
2330c0d06caSMauro Carvalho Chehab }
2340c0d06caSMauro Carvalho Chehab
2350c0d06caSMauro Carvalho Chehab /*==========================================================================*/
2360c0d06caSMauro Carvalho Chehab
common(struct gspca_dev * gspca_dev)2370c0d06caSMauro Carvalho Chehab static void common(struct gspca_dev *gspca_dev)
2380c0d06caSMauro Carvalho Chehab {
2390c0d06caSMauro Carvalho Chehab s32 n; /* reserved for FETCH functions */
2400c0d06caSMauro Carvalho Chehab
2410c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 22, dat_common00);
2420c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL);
2430c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 32, dat_common01);
2440c0d06caSMauro Carvalho Chehab n = fetch_validx(gspca_dev, tbl_common, ARRAY_SIZE(tbl_common));
2450c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common02);
2460c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common03);
2470c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 16, dat_common04);
2480c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common05);
2490c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 44, dat_common06);
2500c0d06caSMauro Carvalho Chehab keep_on_fetching_validx(gspca_dev, tbl_common,
2510c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_common), n);
2520c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 52, dat_common07);
2530c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common08);
2540c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common09);
2550c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 56, dat_common10);
2560c0d06caSMauro Carvalho Chehab keep_on_fetching_validx(gspca_dev, tbl_common,
2570c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_common), n);
2580c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, dat_common11);
2590c0d06caSMauro Carvalho Chehab keep_on_fetching_validx(gspca_dev, tbl_common,
2600c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_common), n);
2610c0d06caSMauro Carvalho Chehab }
2620c0d06caSMauro Carvalho Chehab
mi1320_init_at_startup(struct gspca_dev * gspca_dev)2630c0d06caSMauro Carvalho Chehab static int mi1320_init_at_startup(struct gspca_dev *gspca_dev)
2640c0d06caSMauro Carvalho Chehab {
2650c0d06caSMauro Carvalho Chehab fetch_validx(gspca_dev, tbl_init_at_startup,
2660c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_init_at_startup));
2670c0d06caSMauro Carvalho Chehab
2680c0d06caSMauro Carvalho Chehab common(gspca_dev);
2690c0d06caSMauro Carvalho Chehab
2700c0d06caSMauro Carvalho Chehab /* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */
2710c0d06caSMauro Carvalho Chehab
2720c0d06caSMauro Carvalho Chehab return 0;
2730c0d06caSMauro Carvalho Chehab }
2740c0d06caSMauro Carvalho Chehab
mi1320_init_pre_alt(struct gspca_dev * gspca_dev)2750c0d06caSMauro Carvalho Chehab static int mi1320_init_pre_alt(struct gspca_dev *gspca_dev)
2760c0d06caSMauro Carvalho Chehab {
2770c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev;
2780c0d06caSMauro Carvalho Chehab
2790c0d06caSMauro Carvalho Chehab sd->mirrorMask = 0;
2800c0d06caSMauro Carvalho Chehab
2810c0d06caSMauro Carvalho Chehab sd->vold.backlight = -1;
2820c0d06caSMauro Carvalho Chehab sd->vold.brightness = -1;
2830c0d06caSMauro Carvalho Chehab sd->vold.sharpness = -1;
2840c0d06caSMauro Carvalho Chehab sd->vold.contrast = -1;
2850c0d06caSMauro Carvalho Chehab sd->vold.saturation = -1;
2860c0d06caSMauro Carvalho Chehab sd->vold.gamma = -1;
2870c0d06caSMauro Carvalho Chehab sd->vold.hue = -1;
2880c0d06caSMauro Carvalho Chehab sd->vold.whitebal = -1;
2890c0d06caSMauro Carvalho Chehab sd->vold.mirror = -1;
2900c0d06caSMauro Carvalho Chehab sd->vold.flip = -1;
2910c0d06caSMauro Carvalho Chehab sd->vold.AC50Hz = -1;
2920c0d06caSMauro Carvalho Chehab
2930c0d06caSMauro Carvalho Chehab common(gspca_dev);
2940c0d06caSMauro Carvalho Chehab
2950c0d06caSMauro Carvalho Chehab mi1320_sensor_settings(gspca_dev);
2960c0d06caSMauro Carvalho Chehab
2970c0d06caSMauro Carvalho Chehab mi1320_init_post_alt(gspca_dev);
2980c0d06caSMauro Carvalho Chehab
2990c0d06caSMauro Carvalho Chehab return 0;
3000c0d06caSMauro Carvalho Chehab }
3010c0d06caSMauro Carvalho Chehab
mi1320_init_post_alt(struct gspca_dev * gspca_dev)3020c0d06caSMauro Carvalho Chehab static int mi1320_init_post_alt(struct gspca_dev *gspca_dev)
3030c0d06caSMauro Carvalho Chehab {
3040c0d06caSMauro Carvalho Chehab mi1320_camera_settings(gspca_dev);
3050c0d06caSMauro Carvalho Chehab
3060c0d06caSMauro Carvalho Chehab return 0;
3070c0d06caSMauro Carvalho Chehab }
3080c0d06caSMauro Carvalho Chehab
mi1320_sensor_settings(struct gspca_dev * gspca_dev)3090c0d06caSMauro Carvalho Chehab static int mi1320_sensor_settings(struct gspca_dev *gspca_dev)
3100c0d06caSMauro Carvalho Chehab {
3110c0d06caSMauro Carvalho Chehab s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
3120c0d06caSMauro Carvalho Chehab
3130c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL);
3140c0d06caSMauro Carvalho Chehab
3150c0d06caSMauro Carvalho Chehab fetch_validx(gspca_dev, tbl_sensor_settings_common,
3160c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_sensor_settings_common));
3170c0d06caSMauro Carvalho Chehab
3180c0d06caSMauro Carvalho Chehab switch (reso) {
3190c0d06caSMauro Carvalho Chehab case IMAGE_1280:
3200c0d06caSMauro Carvalho Chehab fetch_validx(gspca_dev, tbl_sensor_settings_1280,
3210c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_sensor_settings_1280));
3220c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 64, tbl_1280[0]);
3230c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_1280[1]);
3240c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_1280[2]);
3250c0d06caSMauro Carvalho Chehab break;
3260c0d06caSMauro Carvalho Chehab
3270c0d06caSMauro Carvalho Chehab case IMAGE_800:
3280c0d06caSMauro Carvalho Chehab fetch_validx(gspca_dev, tbl_sensor_settings_800,
3290c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_sensor_settings_800));
3300c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 64, tbl_800[0]);
3310c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_800[1]);
3320c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_800[2]);
3330c0d06caSMauro Carvalho Chehab break;
3340c0d06caSMauro Carvalho Chehab
3350c0d06caSMauro Carvalho Chehab default:
3360c0d06caSMauro Carvalho Chehab fetch_validx(gspca_dev, tbl_sensor_settings_640,
3370c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_sensor_settings_640));
3380c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 60, tbl_640[0]);
3390c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_640[1]);
3400c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_640[2]);
3410c0d06caSMauro Carvalho Chehab break;
3420c0d06caSMauro Carvalho Chehab }
3430c0d06caSMauro Carvalho Chehab return 0;
3440c0d06caSMauro Carvalho Chehab }
3450c0d06caSMauro Carvalho Chehab
mi1320_configure_alt(struct gspca_dev * gspca_dev)3460c0d06caSMauro Carvalho Chehab static int mi1320_configure_alt(struct gspca_dev *gspca_dev)
3470c0d06caSMauro Carvalho Chehab {
3480c0d06caSMauro Carvalho Chehab s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
3490c0d06caSMauro Carvalho Chehab
3500c0d06caSMauro Carvalho Chehab switch (reso) {
3510c0d06caSMauro Carvalho Chehab case IMAGE_640:
3520c0d06caSMauro Carvalho Chehab gspca_dev->alt = 3 + 1;
3530c0d06caSMauro Carvalho Chehab break;
3540c0d06caSMauro Carvalho Chehab
3550c0d06caSMauro Carvalho Chehab case IMAGE_800:
3560c0d06caSMauro Carvalho Chehab case IMAGE_1280:
3570c0d06caSMauro Carvalho Chehab gspca_dev->alt = 1 + 1;
3580c0d06caSMauro Carvalho Chehab break;
3590c0d06caSMauro Carvalho Chehab }
3600c0d06caSMauro Carvalho Chehab return 0;
3610c0d06caSMauro Carvalho Chehab }
3620c0d06caSMauro Carvalho Chehab
mi1320_camera_settings(struct gspca_dev * gspca_dev)3630c0d06caSMauro Carvalho Chehab static int mi1320_camera_settings(struct gspca_dev *gspca_dev)
3640c0d06caSMauro Carvalho Chehab {
3650c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev;
3660c0d06caSMauro Carvalho Chehab
3670c0d06caSMauro Carvalho Chehab s32 backlight = sd->vcur.backlight;
3680c0d06caSMauro Carvalho Chehab s32 bright = sd->vcur.brightness;
3690c0d06caSMauro Carvalho Chehab s32 sharp = sd->vcur.sharpness;
3700c0d06caSMauro Carvalho Chehab s32 cntr = sd->vcur.contrast;
3710c0d06caSMauro Carvalho Chehab s32 gam = sd->vcur.gamma;
3720c0d06caSMauro Carvalho Chehab s32 hue = sd->vcur.hue;
3730c0d06caSMauro Carvalho Chehab s32 sat = sd->vcur.saturation;
3740c0d06caSMauro Carvalho Chehab s32 wbal = sd->vcur.whitebal;
3750c0d06caSMauro Carvalho Chehab s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0);
3760c0d06caSMauro Carvalho Chehab s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0);
3770c0d06caSMauro Carvalho Chehab s32 freq = (sd->vcur.AC50Hz > 0);
3780c0d06caSMauro Carvalho Chehab s32 i;
3790c0d06caSMauro Carvalho Chehab
3800c0d06caSMauro Carvalho Chehab if (freq != sd->vold.AC50Hz) {
3810c0d06caSMauro Carvalho Chehab sd->vold.AC50Hz = freq;
3820c0d06caSMauro Carvalho Chehab
3830c0d06caSMauro Carvalho Chehab freq = 2 * (freq == 0);
3840c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
3850c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba02, 0x00f1, 0, NULL);
3860c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x005b, 0, NULL);
3870c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01 + freq, 0x00f1, 0, NULL);
3880c0d06caSMauro Carvalho Chehab }
3890c0d06caSMauro Carvalho Chehab
3900c0d06caSMauro Carvalho Chehab if (wbal != sd->vold.whitebal) {
3910c0d06caSMauro Carvalho Chehab sd->vold.whitebal = wbal;
3920c0d06caSMauro Carvalho Chehab if (wbal < 0 || wbal > sd->vmax.whitebal)
3930c0d06caSMauro Carvalho Chehab wbal = 0;
3940c0d06caSMauro Carvalho Chehab
3950c0d06caSMauro Carvalho Chehab for (i = 0; i < 2; i++) {
3960c0d06caSMauro Carvalho Chehab if (wbal == 0) { /* Normal light */
3970c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
3980c0d06caSMauro Carvalho Chehab 0x0010, 0x0010, 0, NULL);
3990c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4000c0d06caSMauro Carvalho Chehab 0x0003, 0x00c1, 0, NULL);
4010c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4020c0d06caSMauro Carvalho Chehab 0x0042, 0x00c2, 0, NULL);
4030c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3,
4040c0d06caSMauro Carvalho Chehab 0xba00, 0x0200, 48, dat_wbalNL);
4050c0d06caSMauro Carvalho Chehab }
4060c0d06caSMauro Carvalho Chehab
4070c0d06caSMauro Carvalho Chehab if (wbal == 1) { /* Low light */
4080c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4090c0d06caSMauro Carvalho Chehab 0x0010, 0x0010, 0, NULL);
4100c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4110c0d06caSMauro Carvalho Chehab 0x0004, 0x00c1, 0, NULL);
4120c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4130c0d06caSMauro Carvalho Chehab 0x0043, 0x00c2, 0, NULL);
4140c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3,
4150c0d06caSMauro Carvalho Chehab 0xba00, 0x0200, 48, dat_wbalLL);
4160c0d06caSMauro Carvalho Chehab }
4170c0d06caSMauro Carvalho Chehab
4180c0d06caSMauro Carvalho Chehab if (wbal == 2) { /* Back light */
4190c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4200c0d06caSMauro Carvalho Chehab 0x0010, 0x0010, 0, NULL);
4210c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4220c0d06caSMauro Carvalho Chehab 0x0003, 0x00c1, 0, NULL);
4230c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1,
4240c0d06caSMauro Carvalho Chehab 0x0042, 0x00c2, 0, NULL);
4250c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3,
4260c0d06caSMauro Carvalho Chehab 0xba00, 0x0200, 44, dat_wbalBL);
4270c0d06caSMauro Carvalho Chehab }
4280c0d06caSMauro Carvalho Chehab }
4290c0d06caSMauro Carvalho Chehab }
4300c0d06caSMauro Carvalho Chehab
4310c0d06caSMauro Carvalho Chehab if (bright != sd->vold.brightness) {
4320c0d06caSMauro Carvalho Chehab sd->vold.brightness = bright;
4330c0d06caSMauro Carvalho Chehab if (bright < 0 || bright > sd->vmax.brightness)
4340c0d06caSMauro Carvalho Chehab bright = 0;
4350c0d06caSMauro Carvalho Chehab
4360c0d06caSMauro Carvalho Chehab bright = tbl_bright[bright];
4370c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
4380c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
4390c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + bright, 0x0034, 0, NULL);
4400c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + bright, 0x00f1, 0, NULL);
4410c0d06caSMauro Carvalho Chehab }
4420c0d06caSMauro Carvalho Chehab
4430c0d06caSMauro Carvalho Chehab if (sat != sd->vold.saturation) {
4440c0d06caSMauro Carvalho Chehab sd->vold.saturation = sat;
4450c0d06caSMauro Carvalho Chehab if (sat < 0 || sat > sd->vmax.saturation)
4460c0d06caSMauro Carvalho Chehab sat = 0;
4470c0d06caSMauro Carvalho Chehab
4480c0d06caSMauro Carvalho Chehab sat = tbl_sat[sat];
4490c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
4500c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
4510c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x0025, 0, NULL);
4520c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + sat, 0x00f1, 0, NULL);
4530c0d06caSMauro Carvalho Chehab }
4540c0d06caSMauro Carvalho Chehab
4550c0d06caSMauro Carvalho Chehab if (sharp != sd->vold.sharpness) {
4560c0d06caSMauro Carvalho Chehab sd->vold.sharpness = sharp;
4570c0d06caSMauro Carvalho Chehab if (sharp < 0 || sharp > sd->vmax.sharpness)
4580c0d06caSMauro Carvalho Chehab sharp = 0;
4590c0d06caSMauro Carvalho Chehab
4600c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
4610c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
4620c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x0005, 0, NULL);
4630c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + sharp, 0x00f1, 0, NULL);
4640c0d06caSMauro Carvalho Chehab }
4650c0d06caSMauro Carvalho Chehab
4660c0d06caSMauro Carvalho Chehab if (hue != sd->vold.hue) {
4670c0d06caSMauro Carvalho Chehab /* 0=normal 1=NB 2="sepia" 3=negative 4=other 5=other2 */
4680c0d06caSMauro Carvalho Chehab if (hue < 0 || hue > sd->vmax.hue)
4690c0d06caSMauro Carvalho Chehab hue = 0;
4700c0d06caSMauro Carvalho Chehab if (hue == sd->vmax.hue)
4710c0d06caSMauro Carvalho Chehab sd->swapRB = 1;
4720c0d06caSMauro Carvalho Chehab else
4730c0d06caSMauro Carvalho Chehab sd->swapRB = 0;
4740c0d06caSMauro Carvalho Chehab
4750c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
4760c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
4770c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba70, 0x00e2, 0, NULL);
4780c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + hue * (hue < 6), 0x00f1,
4790c0d06caSMauro Carvalho Chehab 0, NULL);
4800c0d06caSMauro Carvalho Chehab }
4810c0d06caSMauro Carvalho Chehab
4820c0d06caSMauro Carvalho Chehab if (backlight != sd->vold.backlight) {
4830c0d06caSMauro Carvalho Chehab sd->vold.backlight = backlight;
4840c0d06caSMauro Carvalho Chehab if (backlight < 0 || backlight > sd->vmax.backlight)
4850c0d06caSMauro Carvalho Chehab backlight = 0;
4860c0d06caSMauro Carvalho Chehab
4870c0d06caSMauro Carvalho Chehab backlight = tbl_backlight[backlight];
4880c0d06caSMauro Carvalho Chehab for (i = 0; i < 2; i++) {
4890c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
4900c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
4910c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba74, 0x0006, 0, NULL);
4920c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba80 + backlight, 0x00f1,
4930c0d06caSMauro Carvalho Chehab 0, NULL);
4940c0d06caSMauro Carvalho Chehab }
4950c0d06caSMauro Carvalho Chehab }
4960c0d06caSMauro Carvalho Chehab
4970c0d06caSMauro Carvalho Chehab if (hue != sd->vold.hue) {
4980c0d06caSMauro Carvalho Chehab sd->vold.hue = hue;
4990c0d06caSMauro Carvalho Chehab
5000c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
5010c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
5020c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba70, 0x00e2, 0, NULL);
5030c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + hue * (hue < 6), 0x00f1,
5040c0d06caSMauro Carvalho Chehab 0, NULL);
5050c0d06caSMauro Carvalho Chehab }
5060c0d06caSMauro Carvalho Chehab
5070c0d06caSMauro Carvalho Chehab if (mirror != sd->vold.mirror || flip != sd->vold.flip) {
5080c0d06caSMauro Carvalho Chehab u8 dat_hvflip2[4] = {0x20, 0x01, 0xf1, 0x00};
5090c0d06caSMauro Carvalho Chehab sd->vold.mirror = mirror;
5100c0d06caSMauro Carvalho Chehab sd->vold.flip = flip;
5110c0d06caSMauro Carvalho Chehab
5120c0d06caSMauro Carvalho Chehab dat_hvflip2[3] = flip + 2 * mirror;
5130c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 4, dat_hvflip1);
5140c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 4, dat_hvflip2);
5150c0d06caSMauro Carvalho Chehab }
5160c0d06caSMauro Carvalho Chehab
5170c0d06caSMauro Carvalho Chehab if (gam != sd->vold.gamma) {
5180c0d06caSMauro Carvalho Chehab sd->vold.gamma = gam;
5190c0d06caSMauro Carvalho Chehab if (gam < 0 || gam > sd->vmax.gamma)
5200c0d06caSMauro Carvalho Chehab gam = 0;
5210c0d06caSMauro Carvalho Chehab
5220c0d06caSMauro Carvalho Chehab gam = 2 * gam;
5230c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
5240c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
5250c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba04 , 0x003b, 0, NULL);
5260c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba02 + gam, 0x00f1, 0, NULL);
5270c0d06caSMauro Carvalho Chehab }
5280c0d06caSMauro Carvalho Chehab
5290c0d06caSMauro Carvalho Chehab if (cntr != sd->vold.contrast) {
5300c0d06caSMauro Carvalho Chehab sd->vold.contrast = cntr;
5310c0d06caSMauro Carvalho Chehab if (cntr < 0 || cntr > sd->vmax.contrast)
5320c0d06caSMauro Carvalho Chehab cntr = 0;
5330c0d06caSMauro Carvalho Chehab
5340c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL);
5350c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL);
5360c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + tbl_cntr1[cntr], 0x0035,
5370c0d06caSMauro Carvalho Chehab 0, NULL);
5380c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 1, 0xba00 + tbl_cntr2[cntr], 0x00f1,
5390c0d06caSMauro Carvalho Chehab 0, NULL);
5400c0d06caSMauro Carvalho Chehab }
5410c0d06caSMauro Carvalho Chehab
5420c0d06caSMauro Carvalho Chehab return 0;
5430c0d06caSMauro Carvalho Chehab }
5440c0d06caSMauro Carvalho Chehab
mi1320_post_unset_alt(struct gspca_dev * gspca_dev)5450c0d06caSMauro Carvalho Chehab static void mi1320_post_unset_alt(struct gspca_dev *gspca_dev)
5460c0d06caSMauro Carvalho Chehab {
5470c0d06caSMauro Carvalho Chehab ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL);
5480c0d06caSMauro Carvalho Chehab
5490c0d06caSMauro Carvalho Chehab fetch_validx(gspca_dev, tbl_post_unset_alt,
5500c0d06caSMauro Carvalho Chehab ARRAY_SIZE(tbl_post_unset_alt));
5510c0d06caSMauro Carvalho Chehab }
552