1*a112cc39SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2be9904bdSOlivier Lorin /* Subdriver for the GL860 chip with the MI2020 sensor 3a13ee1ddSOlivier Lorin * Author Olivier LORIN, from logs by Iceman/Soro2005 + Fret_saw/Hulkie/Tricid 4a13ee1ddSOlivier Lorin * with the help of Kytrix/BUGabundo/Blazercist. 5a13ee1ddSOlivier Lorin * Driver achieved thanks to a webcam gift by Kytrix. 64f7cb883SOlivier Lorin */ 74f7cb883SOlivier Lorin 84f7cb883SOlivier Lorin /* Sensor : MI2020 */ 94f7cb883SOlivier Lorin 104f7cb883SOlivier Lorin #include "gl860.h" 114f7cb883SOlivier Lorin 12a13ee1ddSOlivier Lorin static u8 dat_wbal1[] = {0x8c, 0xa2, 0x0c}; 13a13ee1ddSOlivier Lorin 144f7cb883SOlivier Lorin static u8 dat_bright1[] = {0x8c, 0xa2, 0x06}; 154f7cb883SOlivier Lorin static u8 dat_bright3[] = {0x8c, 0xa1, 0x02}; 164f7cb883SOlivier Lorin static u8 dat_bright4[] = {0x90, 0x00, 0x0f}; 174f7cb883SOlivier Lorin static u8 dat_bright5[] = {0x8c, 0xa1, 0x03}; 184f7cb883SOlivier Lorin static u8 dat_bright6[] = {0x90, 0x00, 0x05}; 194f7cb883SOlivier Lorin 204f7cb883SOlivier Lorin static u8 dat_hvflip1[] = {0x8c, 0x27, 0x19}; 214f7cb883SOlivier Lorin static u8 dat_hvflip3[] = {0x8c, 0x27, 0x3b}; 224f7cb883SOlivier Lorin static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03}; 234f7cb883SOlivier Lorin static u8 dat_hvflip6[] = {0x90, 0x00, 0x06}; 244f7cb883SOlivier Lorin 25a13ee1ddSOlivier Lorin static struct idxdata tbl_middle_hvflip_low[] = { 26ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x06}}, 27ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, 28ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x06}}, 29ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, 30ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x06}}, 31ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, 32ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x06}}, 33ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, 34a13ee1ddSOlivier Lorin }; 35a13ee1ddSOlivier Lorin 36a13ee1ddSOlivier Lorin static struct idxdata tbl_middle_hvflip_big[] = { 37ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, 38ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, 39ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, 40ae5fd3d5SIsmael Luceno {102, {0xff, 0xff, 0xff}}, 41ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, 42ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, 43ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, 44a13ee1ddSOlivier Lorin }; 45a13ee1ddSOlivier Lorin 46a13ee1ddSOlivier Lorin static struct idxdata tbl_end_hvflip[] = { 47ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, 48ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, 49ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, 50ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, 51ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, 52ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, 53ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, 54a13ee1ddSOlivier Lorin }; 55a13ee1ddSOlivier Lorin 564f7cb883SOlivier Lorin static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 }; 574f7cb883SOlivier Lorin 584f7cb883SOlivier Lorin static u8 dat_multi5[] = { 0x8c, 0xa1, 0x03 }; 594f7cb883SOlivier Lorin static u8 dat_multi6[] = { 0x90, 0x00, 0x05 }; 604f7cb883SOlivier Lorin 61a13ee1ddSOlivier Lorin static struct validx tbl_init_at_startup[] = { 62a13ee1ddSOlivier Lorin {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001, 0x00c1}, 63a13ee1ddSOlivier Lorin {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d}, 64a13ee1ddSOlivier Lorin {53, 0xffff}, 65a13ee1ddSOlivier Lorin {0x0040, 0x0000}, {0x0063, 0x0006}, 664f7cb883SOlivier Lorin }; 674f7cb883SOlivier Lorin 68a13ee1ddSOlivier Lorin static struct validx tbl_common_0B[] = { 69a13ee1ddSOlivier Lorin {0x0002, 0x0004}, {0x006a, 0x0007}, {0x00ef, 0x0006}, {0x006a, 0x000d}, 704f7cb883SOlivier Lorin {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, 714f7cb883SOlivier Lorin {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000}, 724f7cb883SOlivier Lorin }; 734f7cb883SOlivier Lorin 74a13ee1ddSOlivier Lorin static struct idxdata tbl_common_3B[] = { 75ae5fd3d5SIsmael Luceno {0x33, {0x86, 0x25, 0x01}}, {0x33, {0x86, 0x25, 0x00}}, 76ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 77ae5fd3d5SIsmael Luceno {0x30, {0x1a, 0x0a, 0xcc}}, {0x32, {0x02, 0x00, 0x08}}, 78ae5fd3d5SIsmael Luceno {0x33, {0xf4, 0x03, 0x1d}}, 79ae5fd3d5SIsmael Luceno {6, {0xff, 0xff, 0xff}}, /* 12 */ 80ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, {0x34, {0x1c, 0x01, 0x28}}, 81ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, 82ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, /* - */ 83ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, {0x32, {0x14, 0x06, 0xe6}}, 84ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x22, 0x23}}, {0x33, {0x90, 0x00, 0x00}}, 85ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x0f}}, {0x33, {0x90, 0x00, 0x0d}}, 86ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x10}}, {0x33, {0x90, 0x00, 0x0b}}, 87ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x11}}, {0x33, {0x90, 0x00, 0x07}}, 88ae5fd3d5SIsmael Luceno {0x33, {0xf4, 0x03, 0x1d}}, {0x35, {0xa2, 0x00, 0xe2}}, 89ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xab, 0x05}}, {0x33, {0x90, 0x00, 0x01}}, 90ae5fd3d5SIsmael Luceno {0x32, {0x6e, 0x00, 0x86}}, {0x32, {0x70, 0x0f, 0xaa}}, 91ae5fd3d5SIsmael Luceno {0x32, {0x72, 0x0f, 0xe4}}, {0x33, {0x8c, 0xa3, 0x4a}}, 92ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x5a}}, {0x33, {0x8c, 0xa3, 0x4b}}, 93ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0xa6}}, {0x33, {0x8c, 0xa3, 0x61}}, 94ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0xc8}}, {0x33, {0x8c, 0xa3, 0x62}}, 95ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0xe1}}, {0x34, {0xce, 0x01, 0xa8}}, 96ae5fd3d5SIsmael Luceno {0x34, {0xd0, 0x66, 0x33}}, {0x34, {0xd2, 0x31, 0x9a}}, 97ae5fd3d5SIsmael Luceno {0x34, {0xd4, 0x94, 0x63}}, {0x34, {0xd6, 0x4b, 0x25}}, 98ae5fd3d5SIsmael Luceno {0x34, {0xd8, 0x26, 0x70}}, {0x34, {0xda, 0x72, 0x4c}}, 99ae5fd3d5SIsmael Luceno {0x34, {0xdc, 0xff, 0x04}}, {0x34, {0xde, 0x01, 0x5b}}, 100ae5fd3d5SIsmael Luceno {0x34, {0xe6, 0x01, 0x13}}, {0x34, {0xee, 0x0b, 0xf0}}, 101ae5fd3d5SIsmael Luceno {0x34, {0xf6, 0x0b, 0xa4}}, {0x35, {0x00, 0xf6, 0xe7}}, 102ae5fd3d5SIsmael Luceno {0x35, {0x08, 0x0d, 0xfd}}, {0x35, {0x10, 0x25, 0x63}}, 103ae5fd3d5SIsmael Luceno {0x35, {0x18, 0x35, 0x6c}}, {0x35, {0x20, 0x42, 0x7e}}, 104ae5fd3d5SIsmael Luceno {0x35, {0x28, 0x19, 0x44}}, {0x35, {0x30, 0x39, 0xd4}}, 105ae5fd3d5SIsmael Luceno {0x35, {0x38, 0xf5, 0xa8}}, {0x35, {0x4c, 0x07, 0x90}}, 106ae5fd3d5SIsmael Luceno {0x35, {0x44, 0x07, 0xb8}}, {0x35, {0x5c, 0x06, 0x88}}, 107ae5fd3d5SIsmael Luceno {0x35, {0x54, 0x07, 0xff}}, {0x34, {0xe0, 0x01, 0x52}}, 108ae5fd3d5SIsmael Luceno {0x34, {0xe8, 0x00, 0xcc}}, {0x34, {0xf0, 0x0d, 0x83}}, 109ae5fd3d5SIsmael Luceno {0x34, {0xf8, 0x0c, 0xb3}}, {0x35, {0x02, 0xfe, 0xba}}, 110ae5fd3d5SIsmael Luceno {0x35, {0x0a, 0x04, 0xe0}}, {0x35, {0x12, 0x1c, 0x63}}, 111ae5fd3d5SIsmael Luceno {0x35, {0x1a, 0x2b, 0x5a}}, {0x35, {0x22, 0x32, 0x5e}}, 112ae5fd3d5SIsmael Luceno {0x35, {0x2a, 0x0d, 0x28}}, {0x35, {0x32, 0x2c, 0x02}}, 113ae5fd3d5SIsmael Luceno {0x35, {0x3a, 0xf4, 0xfa}}, {0x35, {0x4e, 0x07, 0xef}}, 114ae5fd3d5SIsmael Luceno {0x35, {0x46, 0x07, 0x88}}, {0x35, {0x5e, 0x07, 0xc1}}, 115ae5fd3d5SIsmael Luceno {0x35, {0x56, 0x04, 0x64}}, {0x34, {0xe4, 0x01, 0x15}}, 116ae5fd3d5SIsmael Luceno {0x34, {0xec, 0x00, 0x82}}, {0x34, {0xf4, 0x0c, 0xce}}, 117ae5fd3d5SIsmael Luceno {0x34, {0xfc, 0x0c, 0xba}}, {0x35, {0x06, 0x1f, 0x02}}, 118ae5fd3d5SIsmael Luceno {0x35, {0x0e, 0x02, 0xe3}}, {0x35, {0x16, 0x1a, 0x50}}, 119ae5fd3d5SIsmael Luceno {0x35, {0x1e, 0x24, 0x39}}, {0x35, {0x26, 0x23, 0x4c}}, 120ae5fd3d5SIsmael Luceno {0x35, {0x2e, 0xf9, 0x1b}}, {0x35, {0x36, 0x23, 0x19}}, 121ae5fd3d5SIsmael Luceno {0x35, {0x3e, 0x12, 0x08}}, {0x35, {0x52, 0x07, 0x22}}, 122ae5fd3d5SIsmael Luceno {0x35, {0x4a, 0x03, 0xd3}}, {0x35, {0x62, 0x06, 0x54}}, 123ae5fd3d5SIsmael Luceno {0x35, {0x5a, 0x04, 0x5d}}, {0x34, {0xe2, 0x01, 0x04}}, 124ae5fd3d5SIsmael Luceno {0x34, {0xea, 0x00, 0xa0}}, {0x34, {0xf2, 0x0c, 0xbc}}, 125ae5fd3d5SIsmael Luceno {0x34, {0xfa, 0x0c, 0x5b}}, {0x35, {0x04, 0x17, 0xf2}}, 126ae5fd3d5SIsmael Luceno {0x35, {0x0c, 0x02, 0x08}}, {0x35, {0x14, 0x28, 0x43}}, 127ae5fd3d5SIsmael Luceno {0x35, {0x1c, 0x28, 0x62}}, {0x35, {0x24, 0x2b, 0x60}}, 128ae5fd3d5SIsmael Luceno {0x35, {0x2c, 0x07, 0x33}}, {0x35, {0x34, 0x1f, 0xb0}}, 129ae5fd3d5SIsmael Luceno {0x35, {0x3c, 0xed, 0xcd}}, {0x35, {0x50, 0x00, 0x06}}, 130ae5fd3d5SIsmael Luceno {0x35, {0x48, 0x07, 0xff}}, {0x35, {0x60, 0x05, 0x89}}, 131ae5fd3d5SIsmael Luceno {0x35, {0x58, 0x07, 0xff}}, {0x35, {0x40, 0x00, 0xa0}}, 132ae5fd3d5SIsmael Luceno {0x35, {0x42, 0x00, 0x00}}, {0x32, {0x10, 0x01, 0xfc}}, 133ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x18}}, {0x33, {0x90, 0x00, 0x3c}}, 134ae5fd3d5SIsmael Luceno {0x33, {0x78, 0x00, 0x00}}, 135ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 136ae5fd3d5SIsmael Luceno {0x35, {0xb8, 0x1f, 0x20}}, {0x33, {0x8c, 0xa2, 0x06}}, 137ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x10}}, {0x33, {0x8c, 0xa2, 0x07}}, 138ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x08}}, {0x33, {0x8c, 0xa2, 0x42}}, 139ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x0b}}, {0x33, {0x8c, 0xa2, 0x4a}}, 140ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x8c}}, {0x35, {0xba, 0xfa, 0x08}}, 141ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x02}}, {0x33, {0x90, 0x00, 0x22}}, 142ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x03}}, {0x33, {0x90, 0x00, 0xbb}}, 143ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x04}}, {0x33, {0x90, 0x00, 0x80}}, 144ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x9d}}, {0x33, {0x90, 0x00, 0x00}}, 145ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x9e}}, {0x33, {0x90, 0x00, 0x00}}, 146ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x0c}}, {0x33, {0x90, 0x00, 0x17}}, 147ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x15}}, {0x33, {0x90, 0x00, 0x04}}, 148ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa2, 0x14}}, {0x33, {0x90, 0x00, 0x20}}, 149ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x00}}, 150ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x17}}, {0x33, {0x90, 0x21, 0x11}}, 151ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x1b}}, {0x33, {0x90, 0x02, 0x4f}}, 152ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x25}}, {0x33, {0x90, 0x06, 0x0f}}, 153ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x39}}, {0x33, {0x90, 0x21, 0x11}}, 154ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x3d}}, {0x33, {0x90, 0x01, 0x20}}, 155ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x47}}, {0x33, {0x90, 0x09, 0x4c}}, 156ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x03}}, {0x33, {0x90, 0x02, 0x84}}, 157ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x05}}, {0x33, {0x90, 0x01, 0xe2}}, 158ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x07}}, {0x33, {0x90, 0x06, 0x40}}, 159ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x09}}, {0x33, {0x90, 0x04, 0xb0}}, 160ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x0d}}, {0x33, {0x90, 0x00, 0x00}}, 161ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x0f}}, {0x33, {0x90, 0x00, 0x00}}, 162ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x11}}, {0x33, {0x90, 0x04, 0xbd}}, 163ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x13}}, {0x33, {0x90, 0x06, 0x4d}}, 164ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x15}}, {0x33, {0x90, 0x00, 0x00}}, 165ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x17}}, {0x33, {0x90, 0x21, 0x11}}, 166ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x19}}, {0x33, {0x90, 0x04, 0x6c}}, 167ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x1b}}, {0x33, {0x90, 0x02, 0x4f}}, 168ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x1d}}, {0x33, {0x90, 0x01, 0x02}}, 169ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x1f}}, {0x33, {0x90, 0x02, 0x79}}, 170ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x21}}, {0x33, {0x90, 0x01, 0x55}}, 171ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x23}}, {0x33, {0x90, 0x02, 0x85}}, 172ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x25}}, {0x33, {0x90, 0x06, 0x0f}}, 173ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x27}}, {0x33, {0x90, 0x20, 0x20}}, 174ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x29}}, {0x33, {0x90, 0x20, 0x20}}, 175ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x2b}}, {0x33, {0x90, 0x10, 0x20}}, 176ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x2d}}, {0x33, {0x90, 0x20, 0x07}}, 177ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x2f}}, {0x33, {0x90, 0x00, 0x04}}, 178ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x31}}, {0x33, {0x90, 0x00, 0x04}}, 179ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x33}}, {0x33, {0x90, 0x04, 0xbb}}, 180ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x35}}, {0x33, {0x90, 0x06, 0x4b}}, 181ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x37}}, {0x33, {0x90, 0x00, 0x00}}, 182ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x39}}, {0x33, {0x90, 0x21, 0x11}}, 183ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x3b}}, {0x33, {0x90, 0x00, 0x24}}, 184ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x3d}}, {0x33, {0x90, 0x01, 0x20}}, 185ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x41}}, {0x33, {0x90, 0x01, 0x69}}, 186ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x45}}, {0x33, {0x90, 0x04, 0xed}}, 187ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x47}}, {0x33, {0x90, 0x09, 0x4c}}, 188ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x51}}, {0x33, {0x90, 0x00, 0x00}}, 189ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x53}}, {0x33, {0x90, 0x03, 0x20}}, 190ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x55}}, {0x33, {0x90, 0x00, 0x00}}, 191ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x57}}, {0x33, {0x90, 0x02, 0x58}}, 192ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x5f}}, {0x33, {0x90, 0x00, 0x00}}, 193ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x61}}, {0x33, {0x90, 0x06, 0x40}}, 194ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x63}}, {0x33, {0x90, 0x00, 0x00}}, 195ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x65}}, {0x33, {0x90, 0x04, 0xb0}}, 196ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x22, 0x2e}}, {0x33, {0x90, 0x00, 0xa1}}, 197ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x08}}, {0x33, {0x90, 0x00, 0x1f}}, 198ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x09}}, {0x33, {0x90, 0x00, 0x21}}, 199ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x0a}}, {0x33, {0x90, 0x00, 0x25}}, 200ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x0b}}, {0x33, {0x90, 0x00, 0x27}}, 201ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x24, 0x11}}, {0x33, {0x90, 0x00, 0xa1}}, 202ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x24, 0x13}}, {0x33, {0x90, 0x00, 0xc1}}, 203ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x24, 0x15}}, {0x33, {0x90, 0x00, 0x6a}}, 204ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x24, 0x17}}, {0x33, {0x90, 0x00, 0x80}}, 205ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, 206ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 207ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, 208ae5fd3d5SIsmael Luceno {3, {0xff, 0xff, 0xff}}, 2094f7cb883SOlivier Lorin }; 2104f7cb883SOlivier Lorin 211be9904bdSOlivier Lorin static struct idxdata tbl_init_post_alt_low1[] = { 212ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x15}}, {0x33, {0x90, 0x00, 0x25}}, 213ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x22, 0x2e}}, {0x33, {0x90, 0x00, 0x81}}, 214ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x08}}, {0x33, {0x90, 0x00, 0x17}}, 215ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x09}}, {0x33, {0x90, 0x00, 0x1a}}, 216ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x0a}}, {0x33, {0x90, 0x00, 0x1d}}, 217ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa4, 0x0b}}, {0x33, {0x90, 0x00, 0x20}}, 218ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x24, 0x11}}, {0x33, {0x90, 0x00, 0x81}}, 219ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x24, 0x13}}, {0x33, {0x90, 0x00, 0x9b}}, 2204f7cb883SOlivier Lorin }; 2214f7cb883SOlivier Lorin 222be9904bdSOlivier Lorin static struct idxdata tbl_init_post_alt_low2[] = { 223ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x03}}, {0x33, {0x90, 0x03, 0x24}}, 224ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x05}}, {0x33, {0x90, 0x02, 0x58}}, 225ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, 226ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 227ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, 228ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 2294f7cb883SOlivier Lorin }; 2304f7cb883SOlivier Lorin 231be9904bdSOlivier Lorin static struct idxdata tbl_init_post_alt_low3[] = { 232ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, {0x34, {0x1c, 0x01, 0x28}}, 233ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, 234ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 235ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, {0x32, {0x14, 0x06, 0xe6}}, 236ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, 237ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, 238ae5fd3d5SIsmael Luceno {0x33, {0x2e, 0x01, 0x00}}, {0x34, {0x04, 0x00, 0x2a}}, 239ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, 240ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x95}}, {0x33, {0x90, 0x01, 0x00}}, 241ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 242ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, 243ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, 244ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, 245ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 246ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, 247ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, 248ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, 249ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 250ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, 251ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 252ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, 253ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 254ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, 255ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 256ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, 2574f7cb883SOlivier Lorin }; 2584f7cb883SOlivier Lorin 259a13ee1ddSOlivier Lorin static struct idxdata tbl_init_post_alt_big[] = { 260ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, 261ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 262ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, 263ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 264ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, {0x34, {0x1c, 0x01, 0x28}}, 265ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, 266ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 267ae5fd3d5SIsmael Luceno {0x34, {0x1e, 0x8f, 0x09}}, {0x32, {0x14, 0x06, 0xe6}}, 268ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, 269ae5fd3d5SIsmael Luceno {0x33, {0x90, 0x00, 0x05}}, 270ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 271ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, 272ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 273ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, 274ae5fd3d5SIsmael Luceno {2, {0xff, 0xff, 0xff}}, 275ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, 276ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, 277ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x30}}, {0x33, {0x90, 0x00, 0x03}}, 278ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x31}}, {0x33, {0x90, 0x00, 0x02}}, 279ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x32}}, {0x33, {0x90, 0x00, 0x03}}, 280ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x34}}, {0x33, {0x90, 0x00, 0x03}}, 281ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, 282ae5fd3d5SIsmael Luceno {0x33, {0x2e, 0x01, 0x00}}, {0x34, {0x04, 0x00, 0x2a}}, 283ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, 284ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0x27, 0x97}}, {0x33, {0x90, 0x01, 0x00}}, 285ae5fd3d5SIsmael Luceno {51, {0xff, 0xff, 0xff}}, 286ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, 287ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, 288ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, 289ae5fd3d5SIsmael Luceno {51, {0xff, 0xff, 0xff}}, 290ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, 291ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, 292ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, 293ae5fd3d5SIsmael Luceno {51, {0xff, 0xff, 0xff}}, 2944f7cb883SOlivier Lorin }; 2954f7cb883SOlivier Lorin 296a13ee1ddSOlivier Lorin static struct idxdata tbl_init_post_alt_3B[] = { 297ae5fd3d5SIsmael Luceno {0x32, {0x10, 0x01, 0xf8}}, {0x34, {0xce, 0x01, 0xa8}}, 298ae5fd3d5SIsmael Luceno {0x34, {0xd0, 0x66, 0x33}}, {0x34, {0xd2, 0x31, 0x9a}}, 299ae5fd3d5SIsmael Luceno {0x34, {0xd4, 0x94, 0x63}}, {0x34, {0xd6, 0x4b, 0x25}}, 300ae5fd3d5SIsmael Luceno {0x34, {0xd8, 0x26, 0x70}}, {0x34, {0xda, 0x72, 0x4c}}, 301ae5fd3d5SIsmael Luceno {0x34, {0xdc, 0xff, 0x04}}, {0x34, {0xde, 0x01, 0x5b}}, 302ae5fd3d5SIsmael Luceno {0x34, {0xe6, 0x01, 0x13}}, {0x34, {0xee, 0x0b, 0xf0}}, 303ae5fd3d5SIsmael Luceno {0x34, {0xf6, 0x0b, 0xa4}}, {0x35, {0x00, 0xf6, 0xe7}}, 304ae5fd3d5SIsmael Luceno {0x35, {0x08, 0x0d, 0xfd}}, {0x35, {0x10, 0x25, 0x63}}, 305ae5fd3d5SIsmael Luceno {0x35, {0x18, 0x35, 0x6c}}, {0x35, {0x20, 0x42, 0x7e}}, 306ae5fd3d5SIsmael Luceno {0x35, {0x28, 0x19, 0x44}}, {0x35, {0x30, 0x39, 0xd4}}, 307ae5fd3d5SIsmael Luceno {0x35, {0x38, 0xf5, 0xa8}}, {0x35, {0x4c, 0x07, 0x90}}, 308ae5fd3d5SIsmael Luceno {0x35, {0x44, 0x07, 0xb8}}, {0x35, {0x5c, 0x06, 0x88}}, 309ae5fd3d5SIsmael Luceno {0x35, {0x54, 0x07, 0xff}}, {0x34, {0xe0, 0x01, 0x52}}, 310ae5fd3d5SIsmael Luceno {0x34, {0xe8, 0x00, 0xcc}}, {0x34, {0xf0, 0x0d, 0x83}}, 311ae5fd3d5SIsmael Luceno {0x34, {0xf8, 0x0c, 0xb3}}, {0x35, {0x02, 0xfe, 0xba}}, 312ae5fd3d5SIsmael Luceno {0x35, {0x0a, 0x04, 0xe0}}, {0x35, {0x12, 0x1c, 0x63}}, 313ae5fd3d5SIsmael Luceno {0x35, {0x1a, 0x2b, 0x5a}}, {0x35, {0x22, 0x32, 0x5e}}, 314ae5fd3d5SIsmael Luceno {0x35, {0x2a, 0x0d, 0x28}}, {0x35, {0x32, 0x2c, 0x02}}, 315ae5fd3d5SIsmael Luceno {0x35, {0x3a, 0xf4, 0xfa}}, {0x35, {0x4e, 0x07, 0xef}}, 316ae5fd3d5SIsmael Luceno {0x35, {0x46, 0x07, 0x88}}, {0x35, {0x5e, 0x07, 0xc1}}, 317ae5fd3d5SIsmael Luceno {0x35, {0x56, 0x04, 0x64}}, {0x34, {0xe4, 0x01, 0x15}}, 318ae5fd3d5SIsmael Luceno {0x34, {0xec, 0x00, 0x82}}, {0x34, {0xf4, 0x0c, 0xce}}, 319ae5fd3d5SIsmael Luceno {0x34, {0xfc, 0x0c, 0xba}}, {0x35, {0x06, 0x1f, 0x02}}, 320ae5fd3d5SIsmael Luceno {0x35, {0x0e, 0x02, 0xe3}}, {0x35, {0x16, 0x1a, 0x50}}, 321ae5fd3d5SIsmael Luceno {0x35, {0x1e, 0x24, 0x39}}, {0x35, {0x26, 0x23, 0x4c}}, 322ae5fd3d5SIsmael Luceno {0x35, {0x2e, 0xf9, 0x1b}}, {0x35, {0x36, 0x23, 0x19}}, 323ae5fd3d5SIsmael Luceno {0x35, {0x3e, 0x12, 0x08}}, {0x35, {0x52, 0x07, 0x22}}, 324ae5fd3d5SIsmael Luceno {0x35, {0x4a, 0x03, 0xd3}}, {0x35, {0x62, 0x06, 0x54}}, 325ae5fd3d5SIsmael Luceno {0x35, {0x5a, 0x04, 0x5d}}, {0x34, {0xe2, 0x01, 0x04}}, 326ae5fd3d5SIsmael Luceno {0x34, {0xea, 0x00, 0xa0}}, {0x34, {0xf2, 0x0c, 0xbc}}, 327ae5fd3d5SIsmael Luceno {0x34, {0xfa, 0x0c, 0x5b}}, {0x35, {0x04, 0x17, 0xf2}}, 328ae5fd3d5SIsmael Luceno {0x35, {0x0c, 0x02, 0x08}}, {0x35, {0x14, 0x28, 0x43}}, 329ae5fd3d5SIsmael Luceno {0x35, {0x1c, 0x28, 0x62}}, {0x35, {0x24, 0x2b, 0x60}}, 330ae5fd3d5SIsmael Luceno {0x35, {0x2c, 0x07, 0x33}}, {0x35, {0x34, 0x1f, 0xb0}}, 331ae5fd3d5SIsmael Luceno {0x35, {0x3c, 0xed, 0xcd}}, {0x35, {0x50, 0x00, 0x06}}, 332ae5fd3d5SIsmael Luceno {0x35, {0x48, 0x07, 0xff}}, {0x35, {0x60, 0x05, 0x89}}, 333ae5fd3d5SIsmael Luceno {0x35, {0x58, 0x07, 0xff}}, {0x35, {0x40, 0x00, 0xa0}}, 334ae5fd3d5SIsmael Luceno {0x35, {0x42, 0x00, 0x00}}, {0x32, {0x10, 0x01, 0xfc}}, 335ae5fd3d5SIsmael Luceno {0x33, {0x8c, 0xa1, 0x18}}, {0x33, {0x90, 0x00, 0x3c}}, 3364f7cb883SOlivier Lorin }; 3374f7cb883SOlivier Lorin 3384f7cb883SOlivier Lorin static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81"; 3394f7cb883SOlivier Lorin static u8 *dat_800 = "\xd0\x02\xd1\x10\xd2\x57\xd3\x02\xd4\x18\xd5\x21"; 3404f7cb883SOlivier Lorin static u8 *dat_1280 = "\xd0\x02\xd1\x20\xd2\x01\xd3\x02\xd4\x28\xd5\x01"; 3414f7cb883SOlivier Lorin static u8 *dat_1600 = "\xd0\x02\xd1\x20\xd2\xaf\xd3\x02\xd4\x30\xd5\x41"; 3424f7cb883SOlivier Lorin 3434f7cb883SOlivier Lorin static int mi2020_init_at_startup(struct gspca_dev *gspca_dev); 3444f7cb883SOlivier Lorin static int mi2020_configure_alt(struct gspca_dev *gspca_dev); 3454f7cb883SOlivier Lorin static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev); 3464f7cb883SOlivier Lorin static int mi2020_init_post_alt(struct gspca_dev *gspca_dev); 3474f7cb883SOlivier Lorin static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev); 3484f7cb883SOlivier Lorin static int mi2020_camera_settings(struct gspca_dev *gspca_dev); 3494f7cb883SOlivier Lorin /*==========================================================================*/ 3504f7cb883SOlivier Lorin 3514f7cb883SOlivier Lorin void mi2020_init_settings(struct gspca_dev *gspca_dev) 3524f7cb883SOlivier Lorin { 3534f7cb883SOlivier Lorin struct sd *sd = (struct sd *) gspca_dev; 3544f7cb883SOlivier Lorin 3554f7cb883SOlivier Lorin sd->vcur.backlight = 0; 3564f7cb883SOlivier Lorin sd->vcur.brightness = 70; 3574f7cb883SOlivier Lorin sd->vcur.sharpness = 20; 3584f7cb883SOlivier Lorin sd->vcur.contrast = 0; 3594f7cb883SOlivier Lorin sd->vcur.gamma = 0; 3604f7cb883SOlivier Lorin sd->vcur.hue = 0; 3614f7cb883SOlivier Lorin sd->vcur.saturation = 60; 362a13ee1ddSOlivier Lorin sd->vcur.whitebal = 0; /* 50, not done by hardware */ 3634f7cb883SOlivier Lorin sd->vcur.mirror = 0; 3644f7cb883SOlivier Lorin sd->vcur.flip = 0; 3654f7cb883SOlivier Lorin sd->vcur.AC50Hz = 1; 3664f7cb883SOlivier Lorin 3674f7cb883SOlivier Lorin sd->vmax.backlight = 64; 3684f7cb883SOlivier Lorin sd->vmax.brightness = 128; 3694f7cb883SOlivier Lorin sd->vmax.sharpness = 40; 3704f7cb883SOlivier Lorin sd->vmax.contrast = 3; 3714f7cb883SOlivier Lorin sd->vmax.gamma = 2; 372a13ee1ddSOlivier Lorin sd->vmax.hue = 0 + 1; /* 200, not done by hardware */ 373a13ee1ddSOlivier Lorin sd->vmax.saturation = 0; /* 100, not done by hardware */ 374a13ee1ddSOlivier Lorin sd->vmax.whitebal = 2; /* 100, not done by hardware */ 3754f7cb883SOlivier Lorin sd->vmax.mirror = 1; 3764f7cb883SOlivier Lorin sd->vmax.flip = 1; 3774f7cb883SOlivier Lorin sd->vmax.AC50Hz = 1; 3784f7cb883SOlivier Lorin 3794f7cb883SOlivier Lorin sd->dev_camera_settings = mi2020_camera_settings; 3804f7cb883SOlivier Lorin sd->dev_init_at_startup = mi2020_init_at_startup; 3814f7cb883SOlivier Lorin sd->dev_configure_alt = mi2020_configure_alt; 3824f7cb883SOlivier Lorin sd->dev_init_pre_alt = mi2020_init_pre_alt; 3834f7cb883SOlivier Lorin sd->dev_post_unset_alt = mi2020_post_unset_alt; 3844f7cb883SOlivier Lorin } 3854f7cb883SOlivier Lorin 3864f7cb883SOlivier Lorin /*==========================================================================*/ 3874f7cb883SOlivier Lorin 3884f7cb883SOlivier Lorin static void common(struct gspca_dev *gspca_dev) 3894f7cb883SOlivier Lorin { 390a13ee1ddSOlivier Lorin fetch_validx(gspca_dev, tbl_common_0B, ARRAY_SIZE(tbl_common_0B)); 391a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_common_3B, ARRAY_SIZE(tbl_common_3B)); 392a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL); 3934f7cb883SOlivier Lorin } 3944f7cb883SOlivier Lorin 3954f7cb883SOlivier Lorin static int mi2020_init_at_startup(struct gspca_dev *gspca_dev) 3964f7cb883SOlivier Lorin { 3974f7cb883SOlivier Lorin u8 c; 3984f7cb883SOlivier Lorin 3994f7cb883SOlivier Lorin ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c); 4004f7cb883SOlivier Lorin ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c); 4014f7cb883SOlivier Lorin 4024f7cb883SOlivier Lorin fetch_validx(gspca_dev, tbl_init_at_startup, 4034f7cb883SOlivier Lorin ARRAY_SIZE(tbl_init_at_startup)); 4044f7cb883SOlivier Lorin 405a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x7a00, 0x8030, 0, NULL); 406a13ee1ddSOlivier Lorin ctrl_in(gspca_dev, 0xc0, 2, 0x7a00, 0x8030, 1, &c); 407a13ee1ddSOlivier Lorin 4084f7cb883SOlivier Lorin common(gspca_dev); 4094f7cb883SOlivier Lorin 410a13ee1ddSOlivier Lorin msleep(61); 411a13ee1ddSOlivier Lorin /* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */ 412a13ee1ddSOlivier Lorin /* msleep(36); */ 413a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL); 414a13ee1ddSOlivier Lorin 4154f7cb883SOlivier Lorin return 0; 4164f7cb883SOlivier Lorin } 4174f7cb883SOlivier Lorin 4184f7cb883SOlivier Lorin static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev) 4194f7cb883SOlivier Lorin { 4204f7cb883SOlivier Lorin struct sd *sd = (struct sd *) gspca_dev; 4214f7cb883SOlivier Lorin 4224f7cb883SOlivier Lorin sd->mirrorMask = 0; 423a13ee1ddSOlivier Lorin sd->vold.hue = -1; 4244f7cb883SOlivier Lorin 425a13ee1ddSOlivier Lorin /* These controls need to be reset */ 4264f7cb883SOlivier Lorin sd->vold.brightness = -1; 4274f7cb883SOlivier Lorin sd->vold.sharpness = -1; 428a13ee1ddSOlivier Lorin 429a13ee1ddSOlivier Lorin /* If not different from default, they do not need to be set */ 430a13ee1ddSOlivier Lorin sd->vold.contrast = 0; 431a13ee1ddSOlivier Lorin sd->vold.gamma = 0; 432a13ee1ddSOlivier Lorin sd->vold.backlight = 0; 4334f7cb883SOlivier Lorin 4344f7cb883SOlivier Lorin mi2020_init_post_alt(gspca_dev); 4354f7cb883SOlivier Lorin 4364f7cb883SOlivier Lorin return 0; 4374f7cb883SOlivier Lorin } 4384f7cb883SOlivier Lorin 4394f7cb883SOlivier Lorin static int mi2020_init_post_alt(struct gspca_dev *gspca_dev) 4404f7cb883SOlivier Lorin { 4414f7cb883SOlivier Lorin struct sd *sd = (struct sd *) gspca_dev; 4424f7cb883SOlivier Lorin s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 4434f7cb883SOlivier Lorin 4444f7cb883SOlivier Lorin s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); 4454f7cb883SOlivier Lorin s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); 4464f7cb883SOlivier Lorin s32 freq = (sd->vcur.AC50Hz > 0); 447a13ee1ddSOlivier Lorin s32 wbal = sd->vcur.whitebal; 4484f7cb883SOlivier Lorin 4494f7cb883SOlivier Lorin u8 dat_freq2[] = {0x90, 0x00, 0x80}; 4504f7cb883SOlivier Lorin u8 dat_multi1[] = {0x8c, 0xa7, 0x00}; 4514f7cb883SOlivier Lorin u8 dat_multi2[] = {0x90, 0x00, 0x00}; 4524f7cb883SOlivier Lorin u8 dat_multi3[] = {0x8c, 0xa7, 0x00}; 4534f7cb883SOlivier Lorin u8 dat_multi4[] = {0x90, 0x00, 0x00}; 4544f7cb883SOlivier Lorin u8 dat_hvflip2[] = {0x90, 0x04, 0x6c}; 4554f7cb883SOlivier Lorin u8 dat_hvflip4[] = {0x90, 0x00, 0x24}; 456a13ee1ddSOlivier Lorin u8 dat_wbal2[] = {0x90, 0x00, 0x00}; 4574f7cb883SOlivier Lorin u8 c; 4584f7cb883SOlivier Lorin 4594f7cb883SOlivier Lorin sd->nbIm = -1; 4604f7cb883SOlivier Lorin 4614f7cb883SOlivier Lorin dat_freq2[2] = freq ? 0xc0 : 0x80; 4624f7cb883SOlivier Lorin dat_multi1[2] = 0x9d; 4634f7cb883SOlivier Lorin dat_multi3[2] = dat_multi1[2] + 1; 464a13ee1ddSOlivier Lorin if (wbal == 0) { 465a13ee1ddSOlivier Lorin dat_multi4[2] = dat_multi2[2] = 0; 466a13ee1ddSOlivier Lorin dat_wbal2[2] = 0x17; 467a13ee1ddSOlivier Lorin } else if (wbal == 1) { 468a13ee1ddSOlivier Lorin dat_multi4[2] = dat_multi2[2] = 0; 469a13ee1ddSOlivier Lorin dat_wbal2[2] = 0x35; 470a13ee1ddSOlivier Lorin } else if (wbal == 2) { 471a13ee1ddSOlivier Lorin dat_multi4[2] = dat_multi2[2] = 0x20; 472a13ee1ddSOlivier Lorin dat_wbal2[2] = 0x17; 473a13ee1ddSOlivier Lorin } 4744f7cb883SOlivier Lorin dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror); 4754f7cb883SOlivier Lorin dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror); 4764f7cb883SOlivier Lorin 4774f7cb883SOlivier Lorin msleep(200); 4784f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); 479a13ee1ddSOlivier Lorin msleep(2); 4804f7cb883SOlivier Lorin 4814f7cb883SOlivier Lorin common(gspca_dev); 4824f7cb883SOlivier Lorin 483a13ee1ddSOlivier Lorin msleep(142); 4844f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL); 4854f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0003, 0x00c1, 0, NULL); 4864f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0042, 0x00c2, 0, NULL); 4874f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x006a, 0x000d, 0, NULL); 4884f7cb883SOlivier Lorin 4894f7cb883SOlivier Lorin switch (reso) { 4904f7cb883SOlivier Lorin case IMAGE_640: 4914f7cb883SOlivier Lorin case IMAGE_800: 4924f7cb883SOlivier Lorin if (reso != IMAGE_800) 4934f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4944f7cb883SOlivier Lorin 12, dat_640); 4954f7cb883SOlivier Lorin else 4964f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4974f7cb883SOlivier Lorin 12, dat_800); 4984f7cb883SOlivier Lorin 499be9904bdSOlivier Lorin fetch_idxdata(gspca_dev, tbl_init_post_alt_low1, 500be9904bdSOlivier Lorin ARRAY_SIZE(tbl_init_post_alt_low1)); 5014f7cb883SOlivier Lorin 5024f7cb883SOlivier Lorin if (reso == IMAGE_800) 503be9904bdSOlivier Lorin fetch_idxdata(gspca_dev, tbl_init_post_alt_low2, 504be9904bdSOlivier Lorin ARRAY_SIZE(tbl_init_post_alt_low2)); 5054f7cb883SOlivier Lorin 506be9904bdSOlivier Lorin fetch_idxdata(gspca_dev, tbl_init_post_alt_low3, 507be9904bdSOlivier Lorin ARRAY_SIZE(tbl_init_post_alt_low3)); 5084f7cb883SOlivier Lorin 5094f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL); 5104f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); 5114f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); 5124f7cb883SOlivier Lorin msleep(120); 5134f7cb883SOlivier Lorin break; 5144f7cb883SOlivier Lorin 5154f7cb883SOlivier Lorin case IMAGE_1280: 5164f7cb883SOlivier Lorin case IMAGE_1600: 5174f7cb883SOlivier Lorin if (reso == IMAGE_1280) { 5184f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 5194f7cb883SOlivier Lorin 12, dat_1280); 5204f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5214f7cb883SOlivier Lorin 3, "\x8c\x27\x07"); 5224f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5234f7cb883SOlivier Lorin 3, "\x90\x05\x04"); 5244f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5254f7cb883SOlivier Lorin 3, "\x8c\x27\x09"); 5264f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5274f7cb883SOlivier Lorin 3, "\x90\x04\x02"); 5284f7cb883SOlivier Lorin } else { 5294f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 5304f7cb883SOlivier Lorin 12, dat_1600); 5314f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5324f7cb883SOlivier Lorin 3, "\x8c\x27\x07"); 5334f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5344f7cb883SOlivier Lorin 3, "\x90\x06\x40"); 5354f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5364f7cb883SOlivier Lorin 3, "\x8c\x27\x09"); 5374f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 5384f7cb883SOlivier Lorin 3, "\x90\x04\xb0"); 5394f7cb883SOlivier Lorin } 5404f7cb883SOlivier Lorin 541a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_init_post_alt_big, 542a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_init_post_alt_big)); 5434f7cb883SOlivier Lorin 5444f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL); 5454f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); 5464f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); 5474f7cb883SOlivier Lorin msleep(1850); 5484f7cb883SOlivier Lorin } 5494f7cb883SOlivier Lorin 550a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL); 551a13ee1ddSOlivier Lorin msleep(40); 552a13ee1ddSOlivier Lorin 5534f7cb883SOlivier Lorin /* AC power frequency */ 5544f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1); 5554f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2); 556a13ee1ddSOlivier Lorin msleep(33); 557a13ee1ddSOlivier Lorin /* light source */ 5584f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); 5594f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); 5604f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); 5614f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); 562a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal1); 563a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal2); 5644f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); 5654f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); 566a13ee1ddSOlivier Lorin msleep(7); 5674f7cb883SOlivier Lorin ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c); 5684f7cb883SOlivier Lorin 569a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_init_post_alt_3B, 570a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_init_post_alt_3B)); 5714f7cb883SOlivier Lorin 572a13ee1ddSOlivier Lorin /* hvflip */ 5734f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1); 5744f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2); 5754f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3); 5764f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4); 5774f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5); 5784f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6); 579a13ee1ddSOlivier Lorin msleep(250); 5804f7cb883SOlivier Lorin 581a13ee1ddSOlivier Lorin if (reso == IMAGE_640 || reso == IMAGE_800) 582a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_middle_hvflip_low, 583a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_middle_hvflip_low)); 584a13ee1ddSOlivier Lorin else 585a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_middle_hvflip_big, 586a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_middle_hvflip_big)); 587a13ee1ddSOlivier Lorin 588a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_end_hvflip, 589a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_end_hvflip)); 590a13ee1ddSOlivier Lorin 591a13ee1ddSOlivier Lorin sd->nbIm = 0; 5924f7cb883SOlivier Lorin 5934f7cb883SOlivier Lorin sd->vold.mirror = mirror; 5944f7cb883SOlivier Lorin sd->vold.flip = flip; 5954f7cb883SOlivier Lorin sd->vold.AC50Hz = freq; 596a13ee1ddSOlivier Lorin sd->vold.whitebal = wbal; 5974f7cb883SOlivier Lorin 5984f7cb883SOlivier Lorin mi2020_camera_settings(gspca_dev); 5994f7cb883SOlivier Lorin 6004f7cb883SOlivier Lorin return 0; 6014f7cb883SOlivier Lorin } 6024f7cb883SOlivier Lorin 6034f7cb883SOlivier Lorin static int mi2020_configure_alt(struct gspca_dev *gspca_dev) 6044f7cb883SOlivier Lorin { 6054f7cb883SOlivier Lorin s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 6064f7cb883SOlivier Lorin 6074f7cb883SOlivier Lorin switch (reso) { 6084f7cb883SOlivier Lorin case IMAGE_640: 6094f7cb883SOlivier Lorin gspca_dev->alt = 3 + 1; 6104f7cb883SOlivier Lorin break; 6114f7cb883SOlivier Lorin 6124f7cb883SOlivier Lorin case IMAGE_800: 6134f7cb883SOlivier Lorin case IMAGE_1280: 6144f7cb883SOlivier Lorin case IMAGE_1600: 6154f7cb883SOlivier Lorin gspca_dev->alt = 1 + 1; 6164f7cb883SOlivier Lorin break; 6174f7cb883SOlivier Lorin } 6184f7cb883SOlivier Lorin return 0; 6194f7cb883SOlivier Lorin } 6204f7cb883SOlivier Lorin 621c6dc725cSJean-François Moine static int mi2020_camera_settings(struct gspca_dev *gspca_dev) 6224f7cb883SOlivier Lorin { 6234f7cb883SOlivier Lorin struct sd *sd = (struct sd *) gspca_dev; 624a13ee1ddSOlivier Lorin s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 6254f7cb883SOlivier Lorin 6264f7cb883SOlivier Lorin s32 backlight = sd->vcur.backlight; 6274f7cb883SOlivier Lorin s32 bright = sd->vcur.brightness; 6284f7cb883SOlivier Lorin s32 sharp = sd->vcur.sharpness; 6294f7cb883SOlivier Lorin s32 cntr = sd->vcur.contrast; 6304f7cb883SOlivier Lorin s32 gam = sd->vcur.gamma; 6314f7cb883SOlivier Lorin s32 hue = (sd->vcur.hue > 0); 6324f7cb883SOlivier Lorin s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); 6334f7cb883SOlivier Lorin s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); 6344f7cb883SOlivier Lorin s32 freq = (sd->vcur.AC50Hz > 0); 635a13ee1ddSOlivier Lorin s32 wbal = sd->vcur.whitebal; 6364f7cb883SOlivier Lorin 6374f7cb883SOlivier Lorin u8 dat_sharp[] = {0x6c, 0x00, 0x08}; 6384f7cb883SOlivier Lorin u8 dat_bright2[] = {0x90, 0x00, 0x00}; 6394f7cb883SOlivier Lorin u8 dat_freq2[] = {0x90, 0x00, 0x80}; 6404f7cb883SOlivier Lorin u8 dat_multi1[] = {0x8c, 0xa7, 0x00}; 6414f7cb883SOlivier Lorin u8 dat_multi2[] = {0x90, 0x00, 0x00}; 6424f7cb883SOlivier Lorin u8 dat_multi3[] = {0x8c, 0xa7, 0x00}; 6434f7cb883SOlivier Lorin u8 dat_multi4[] = {0x90, 0x00, 0x00}; 6444f7cb883SOlivier Lorin u8 dat_hvflip2[] = {0x90, 0x04, 0x6c}; 6454f7cb883SOlivier Lorin u8 dat_hvflip4[] = {0x90, 0x00, 0x24}; 646a13ee1ddSOlivier Lorin u8 dat_wbal2[] = {0x90, 0x00, 0x00}; 6474f7cb883SOlivier Lorin 6484f7cb883SOlivier Lorin /* Less than 4 images received -> too early to set the settings */ 6494f7cb883SOlivier Lorin if (sd->nbIm < 4) { 6504f7cb883SOlivier Lorin sd->waitSet = 1; 6514f7cb883SOlivier Lorin return 0; 6524f7cb883SOlivier Lorin } 6534f7cb883SOlivier Lorin sd->waitSet = 0; 6544f7cb883SOlivier Lorin 6554f7cb883SOlivier Lorin if (freq != sd->vold.AC50Hz) { 6564f7cb883SOlivier Lorin sd->vold.AC50Hz = freq; 6574f7cb883SOlivier Lorin 6584f7cb883SOlivier Lorin dat_freq2[2] = freq ? 0xc0 : 0x80; 6594f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1); 6604f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2); 6614f7cb883SOlivier Lorin msleep(20); 6624f7cb883SOlivier Lorin } 6634f7cb883SOlivier Lorin 664a13ee1ddSOlivier Lorin if (wbal != sd->vold.whitebal) { 665a13ee1ddSOlivier Lorin sd->vold.whitebal = wbal; 666a13ee1ddSOlivier Lorin if (wbal < 0 || wbal > sd->vmax.whitebal) 667a13ee1ddSOlivier Lorin wbal = 0; 668a13ee1ddSOlivier Lorin 669a13ee1ddSOlivier Lorin dat_multi1[2] = 0x9d; 670a13ee1ddSOlivier Lorin dat_multi3[2] = dat_multi1[2] + 1; 671a13ee1ddSOlivier Lorin if (wbal == 0) { 672a13ee1ddSOlivier Lorin dat_multi4[2] = dat_multi2[2] = 0; 673a13ee1ddSOlivier Lorin dat_wbal2[2] = 0x17; 674a13ee1ddSOlivier Lorin } else if (wbal == 1) { 675a13ee1ddSOlivier Lorin dat_multi4[2] = dat_multi2[2] = 0; 676a13ee1ddSOlivier Lorin dat_wbal2[2] = 0x35; 677a13ee1ddSOlivier Lorin } else if (wbal == 2) { 678a13ee1ddSOlivier Lorin dat_multi4[2] = dat_multi2[2] = 0x20; 679a13ee1ddSOlivier Lorin dat_wbal2[2] = 0x17; 680a13ee1ddSOlivier Lorin } 681a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); 682a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); 683a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); 684a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); 685a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal1); 686a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal2); 687a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); 688a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); 689a13ee1ddSOlivier Lorin } 690a13ee1ddSOlivier Lorin 6914f7cb883SOlivier Lorin if (mirror != sd->vold.mirror || flip != sd->vold.flip) { 6924f7cb883SOlivier Lorin sd->vold.mirror = mirror; 6934f7cb883SOlivier Lorin sd->vold.flip = flip; 6944f7cb883SOlivier Lorin 6954f7cb883SOlivier Lorin dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror); 6964f7cb883SOlivier Lorin dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror); 697a13ee1ddSOlivier Lorin 698a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_init_post_alt_3B, 699a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_init_post_alt_3B)); 700a13ee1ddSOlivier Lorin 7014f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1); 7024f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2); 7034f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3); 7044f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4); 7054f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5); 7064f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6); 707a13ee1ddSOlivier Lorin msleep(40); 7084f7cb883SOlivier Lorin 709a13ee1ddSOlivier Lorin if (reso == IMAGE_640 || reso == IMAGE_800) 710a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_middle_hvflip_low, 711a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_middle_hvflip_low)); 712a13ee1ddSOlivier Lorin else 713a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_middle_hvflip_big, 714a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_middle_hvflip_big)); 715a13ee1ddSOlivier Lorin 716a13ee1ddSOlivier Lorin fetch_idxdata(gspca_dev, tbl_end_hvflip, 717a13ee1ddSOlivier Lorin ARRAY_SIZE(tbl_end_hvflip)); 718a13ee1ddSOlivier Lorin } 719a13ee1ddSOlivier Lorin 720a13ee1ddSOlivier Lorin if (bright != sd->vold.brightness) { 721a13ee1ddSOlivier Lorin sd->vold.brightness = bright; 722a13ee1ddSOlivier Lorin if (bright < 0 || bright > sd->vmax.brightness) 723a13ee1ddSOlivier Lorin bright = 0; 724a13ee1ddSOlivier Lorin 725a13ee1ddSOlivier Lorin dat_bright2[2] = bright; 726a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright1); 727a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright2); 728a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright3); 729a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright4); 730a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright5); 731a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright6); 732a13ee1ddSOlivier Lorin } 733a13ee1ddSOlivier Lorin 734a13ee1ddSOlivier Lorin if (cntr != sd->vold.contrast || gam != sd->vold.gamma) { 735a13ee1ddSOlivier Lorin sd->vold.contrast = cntr; 736a13ee1ddSOlivier Lorin if (cntr < 0 || cntr > sd->vmax.contrast) 737a13ee1ddSOlivier Lorin cntr = 0; 738a13ee1ddSOlivier Lorin sd->vold.gamma = gam; 739a13ee1ddSOlivier Lorin if (gam < 0 || gam > sd->vmax.gamma) 740a13ee1ddSOlivier Lorin gam = 0; 741a13ee1ddSOlivier Lorin 742a13ee1ddSOlivier Lorin dat_multi1[2] = 0x6d; 743a13ee1ddSOlivier Lorin dat_multi3[2] = dat_multi1[2] + 1; 744a13ee1ddSOlivier Lorin if (cntr == 0) 745a13ee1ddSOlivier Lorin cntr = 4; 746a13ee1ddSOlivier Lorin dat_multi4[2] = dat_multi2[2] = cntr * 0x10 + 2 - gam; 747a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); 748a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); 749a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); 750a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); 751a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); 752a13ee1ddSOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); 7534f7cb883SOlivier Lorin } 7544f7cb883SOlivier Lorin 7554f7cb883SOlivier Lorin if (backlight != sd->vold.backlight) { 7564f7cb883SOlivier Lorin sd->vold.backlight = backlight; 7574f7cb883SOlivier Lorin if (backlight < 0 || backlight > sd->vmax.backlight) 7584f7cb883SOlivier Lorin backlight = 0; 7594f7cb883SOlivier Lorin 7604f7cb883SOlivier Lorin dat_multi1[2] = 0x9d; 7614f7cb883SOlivier Lorin dat_multi3[2] = dat_multi1[2] + 1; 7624f7cb883SOlivier Lorin dat_multi4[2] = dat_multi2[2] = backlight; 7634f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); 7644f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); 7654f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); 7664f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); 7674f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); 7684f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); 7694f7cb883SOlivier Lorin } 7704f7cb883SOlivier Lorin 7714f7cb883SOlivier Lorin if (sharp != sd->vold.sharpness) { 7724f7cb883SOlivier Lorin sd->vold.sharpness = sharp; 7734f7cb883SOlivier Lorin if (sharp < 0 || sharp > sd->vmax.sharpness) 7744f7cb883SOlivier Lorin sharp = 0; 7754f7cb883SOlivier Lorin 7764f7cb883SOlivier Lorin dat_sharp[1] = sharp; 7774f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0032, 3, dat_sharp); 7784f7cb883SOlivier Lorin } 7794f7cb883SOlivier Lorin 7804f7cb883SOlivier Lorin if (hue != sd->vold.hue) { 7814f7cb883SOlivier Lorin sd->swapRB = hue; 7824f7cb883SOlivier Lorin sd->vold.hue = hue; 7834f7cb883SOlivier Lorin } 7844f7cb883SOlivier Lorin 7854f7cb883SOlivier Lorin return 0; 7864f7cb883SOlivier Lorin } 7874f7cb883SOlivier Lorin 7884f7cb883SOlivier Lorin static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev) 7894f7cb883SOlivier Lorin { 7904f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); 791a13ee1ddSOlivier Lorin msleep(40); 7924f7cb883SOlivier Lorin ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL); 7934f7cb883SOlivier Lorin } 794