18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* Subdriver for the GL860 chip with the MI1320 sensor 38c2ecf20Sopenharmony_ci * Author Olivier LORIN from own logs 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci/* Sensor : MI1320 */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "gl860.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistatic struct validx tbl_common[] = { 118c2ecf20Sopenharmony_ci {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba51, 0x0066}, {0xba02, 0x00f1}, 128c2ecf20Sopenharmony_ci {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1}, 138c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 148c2ecf20Sopenharmony_ci {0xba00, 0x00f0}, {0xba02, 0x00f1}, {0xbafa, 0x0028}, {0xba02, 0x00f1}, 158c2ecf20Sopenharmony_ci {0xba00, 0x00f0}, {0xba01, 0x00f1}, {0xbaf0, 0x0006}, {0xba0e, 0x00f1}, 168c2ecf20Sopenharmony_ci {0xba70, 0x0006}, {0xba0e, 0x00f1}, 178c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 188c2ecf20Sopenharmony_ci {0xba74, 0x0006}, {0xba0e, 0x00f1}, 198c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 208c2ecf20Sopenharmony_ci {0x0061, 0x0000}, {0x0068, 0x000d}, 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic struct validx tbl_init_at_startup[] = { 248c2ecf20Sopenharmony_ci {0x0000, 0x0000}, {0x0010, 0x0010}, 258c2ecf20Sopenharmony_ci {35, 0xffff}, 268c2ecf20Sopenharmony_ci {0x0008, 0x00c0}, {0x0001, 0x00c1}, {0x0001, 0x00c2}, {0x0020, 0x0006}, 278c2ecf20Sopenharmony_ci {0x006a, 0x000d}, 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic struct validx tbl_sensor_settings_common[] = { 318c2ecf20Sopenharmony_ci {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, {0x0040, 0x0000}, 328c2ecf20Sopenharmony_ci {0x006a, 0x0007}, {0x006a, 0x000d}, {0x0063, 0x0006}, 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_cistatic struct validx tbl_sensor_settings_1280[] = { 358c2ecf20Sopenharmony_ci {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba5a, 0x0066}, {0xba02, 0x00f1}, 368c2ecf20Sopenharmony_ci {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xba20, 0x0065}, {0xba00, 0x00f1}, 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_cistatic struct validx tbl_sensor_settings_800[] = { 398c2ecf20Sopenharmony_ci {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba5a, 0x0066}, {0xba02, 0x00f1}, 408c2ecf20Sopenharmony_ci {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xba20, 0x0065}, {0xba00, 0x00f1}, 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_cistatic struct validx tbl_sensor_settings_640[] = { 438c2ecf20Sopenharmony_ci {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1}, 448c2ecf20Sopenharmony_ci {0xba51, 0x0066}, {0xba02, 0x00f1}, {0xba05, 0x0067}, {0xba05, 0x00f1}, 458c2ecf20Sopenharmony_ci {0xba20, 0x0065}, {0xba00, 0x00f1}, 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_cistatic struct validx tbl_post_unset_alt[] = { 488c2ecf20Sopenharmony_ci {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1}, 498c2ecf20Sopenharmony_ci {0x0061, 0x0000}, {0x0068, 0x000d}, 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic u8 *tbl_1280[] = { 538c2ecf20Sopenharmony_ci "\x0d\x80\xf1\x08\x03\x04\xf1\x00" "\x04\x05\xf1\x02\x05\x00\xf1\xf1" 548c2ecf20Sopenharmony_ci "\x06\x00\xf1\x0d\x20\x01\xf1\x00" "\x21\x84\xf1\x00\x0d\x00\xf1\x08" 558c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x34\x00\xf1\x00" "\x9b\x43\xf1\x00\xa6\x05\xf1\x00" 568c2ecf20Sopenharmony_ci "\xa9\x04\xf1\x00\xa1\x05\xf1\x00" "\xa4\x04\xf1\x00\xae\x0a\xf1\x08" 578c2ecf20Sopenharmony_ci , 588c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x02\x3a\x05\xf1\xf1" "\x3c\x05\xf1\xf1\x59\x01\xf1\x47" 598c2ecf20Sopenharmony_ci "\x5a\x01\xf1\x88\x5c\x0a\xf1\x06" "\x5d\x0e\xf1\x0a\x64\x5e\xf1\x1c" 608c2ecf20Sopenharmony_ci "\xd2\x00\xf1\xcf\xcb\x00\xf1\x01" 618c2ecf20Sopenharmony_ci , 628c2ecf20Sopenharmony_ci "\xd3\x02\xd4\x28\xd5\x01\xd0\x02" "\xd1\x18\xd2\xc1" 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic u8 *tbl_800[] = { 668c2ecf20Sopenharmony_ci "\x0d\x80\xf1\x08\x03\x03\xf1\xc0" "\x04\x05\xf1\x02\x05\x00\xf1\xf1" 678c2ecf20Sopenharmony_ci "\x06\x00\xf1\x0d\x20\x01\xf1\x00" "\x21\x84\xf1\x00\x0d\x00\xf1\x08" 688c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x34\x00\xf1\x00" "\x9b\x43\xf1\x00\xa6\x05\xf1\x00" 698c2ecf20Sopenharmony_ci "\xa9\x03\xf1\xc0\xa1\x03\xf1\x20" "\xa4\x02\xf1\x5a\xae\x0a\xf1\x08" 708c2ecf20Sopenharmony_ci , 718c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x02\x3a\x05\xf1\xf1" "\x3c\x05\xf1\xf1\x59\x01\xf1\x47" 728c2ecf20Sopenharmony_ci "\x5a\x01\xf1\x88\x5c\x0a\xf1\x06" "\x5d\x0e\xf1\x0a\x64\x5e\xf1\x1c" 738c2ecf20Sopenharmony_ci "\xd2\x00\xf1\xcf\xcb\x00\xf1\x01" 748c2ecf20Sopenharmony_ci , 758c2ecf20Sopenharmony_ci "\xd3\x02\xd4\x18\xd5\x21\xd0\x02" "\xd1\x10\xd2\x59" 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic u8 *tbl_640[] = { 798c2ecf20Sopenharmony_ci "\x0d\x80\xf1\x08\x03\x04\xf1\x04" "\x04\x05\xf1\x02\x07\x01\xf1\x7c" 808c2ecf20Sopenharmony_ci "\x08\x00\xf1\x0e\x21\x80\xf1\x00" "\x0d\x00\xf1\x08\xf0\x00\xf1\x01" 818c2ecf20Sopenharmony_ci "\x34\x10\xf1\x10\x3a\x43\xf1\x00" "\xa6\x05\xf1\x02\xa9\x04\xf1\x04" 828c2ecf20Sopenharmony_ci "\xa7\x02\xf1\x81\xaa\x01\xf1\xe2" "\xae\x0c\xf1\x09" 838c2ecf20Sopenharmony_ci , 848c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x02\x39\x03\xf1\xfc" "\x3b\x04\xf1\x04\x57\x01\xf1\xb6" 858c2ecf20Sopenharmony_ci "\x58\x02\xf1\x0d\x5c\x1f\xf1\x19" "\x5d\x24\xf1\x1e\x64\x5e\xf1\x1c" 868c2ecf20Sopenharmony_ci "\xd2\x00\xf1\x00\xcb\x00\xf1\x01" 878c2ecf20Sopenharmony_ci , 888c2ecf20Sopenharmony_ci "\xd3\x02\xd4\x10\xd5\x81\xd0\x02" "\xd1\x08\xd2\xe1" 898c2ecf20Sopenharmony_ci}; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic s32 tbl_sat[] = {0x25, 0x1d, 0x15, 0x0d, 0x05, 0x4d, 0x55, 0x5d, 0x2d}; 928c2ecf20Sopenharmony_cistatic s32 tbl_bright[] = {0, 8, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70}; 938c2ecf20Sopenharmony_cistatic s32 tbl_backlight[] = {0x0e, 0x06, 0x02}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistatic s32 tbl_cntr1[] = { 968c2ecf20Sopenharmony_ci 0x90, 0x98, 0xa0, 0xa8, 0xb0, 0xb8, 0xc0, 0xc8, 0xd0, 0xe0, 0xf0}; 978c2ecf20Sopenharmony_cistatic s32 tbl_cntr2[] = { 988c2ecf20Sopenharmony_ci 0x70, 0x68, 0x60, 0x58, 0x50, 0x48, 0x40, 0x38, 0x30, 0x20, 0x10}; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cistatic u8 dat_wbalNL[] = 1018c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x3b\x04\xf1\x2a\x47\x10\xf1\x10" 1028c2ecf20Sopenharmony_ci "\x9d\x3c\xf1\xae\xaf\x10\xf1\x00" "\xf0\x00\xf1\x02\x2f\x91\xf1\x20" 1038c2ecf20Sopenharmony_ci "\x9c\x91\xf1\x20\x37\x03\xf1\x00" "\x9d\xc5\xf1\x0f\xf0\x00\xf1\x00"; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic u8 dat_wbalLL[] = 1068c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x05\x00\xf1\x0c" "\x3b\x04\xf1\x2a\x47\x40\xf1\x40" 1078c2ecf20Sopenharmony_ci "\x9d\x20\xf1\xae\xaf\x10\xf1\x00" "\xf0\x00\xf1\x02\x2f\xd1\xf1\x00" 1088c2ecf20Sopenharmony_ci "\x9c\xd1\xf1\x00\x37\x03\xf1\x00" "\x9d\xc5\xf1\x3f\xf0\x00\xf1\x00"; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_cistatic u8 dat_wbalBL[] = 1118c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x47\x10\xf1\x30\x9d\x3c\xf1\xae" 1128c2ecf20Sopenharmony_ci "\xaf\x10\xf1\x00\xf0\x00\xf1\x02" "\x2f\x91\xf1\x20\x9c\x91\xf1\x20" 1138c2ecf20Sopenharmony_ci "\x37\x03\xf1\x00\x9d\xc5\xf1\x2f" "\xf0\x00\xf1\x00"; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistatic u8 dat_hvflip1[] = {0xf0, 0x00, 0xf1, 0x00}; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistatic u8 dat_common00[] = 1188c2ecf20Sopenharmony_ci "\x00\x01\x07\x6a\x06\x63\x0d\x6a" "\xc0\x00\x10\x10\xc1\x03\xc2\x42" 1198c2ecf20Sopenharmony_ci "\xd8\x04\x58\x00\x04\x02"; 1208c2ecf20Sopenharmony_cistatic u8 dat_common01[] = 1218c2ecf20Sopenharmony_ci "\x0d\x00\xf1\x0b\x0d\x00\xf1\x08" "\x35\x00\xf1\x22\x68\x00\xf1\x5d" 1228c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x06\x70\xf1\x0e" "\xf0\x00\xf1\x02\xdd\x18\xf1\xe0"; 1238c2ecf20Sopenharmony_cistatic u8 dat_common02[] = 1248c2ecf20Sopenharmony_ci "\x05\x01\xf1\x84\x06\x00\xf1\x44" "\x07\x00\xf1\xbe\x08\x00\xf1\x1e" 1258c2ecf20Sopenharmony_ci "\x20\x01\xf1\x03\x21\x84\xf1\x00" "\x22\x0d\xf1\x0f\x24\x80\xf1\x00" 1268c2ecf20Sopenharmony_ci "\x34\x18\xf1\x2d\x35\x00\xf1\x22" "\x43\x83\xf1\x83\x59\x00\xf1\xff"; 1278c2ecf20Sopenharmony_cistatic u8 dat_common03[] = 1288c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x02\x39\x06\xf1\x8c" "\x3a\x06\xf1\x8c\x3b\x03\xf1\xda" 1298c2ecf20Sopenharmony_ci "\x3c\x05\xf1\x30\x57\x01\xf1\x0c" "\x58\x01\xf1\x42\x59\x01\xf1\x0c" 1308c2ecf20Sopenharmony_ci "\x5a\x01\xf1\x42\x5c\x13\xf1\x0e" "\x5d\x17\xf1\x12\x64\x1e\xf1\x1c"; 1318c2ecf20Sopenharmony_cistatic u8 dat_common04[] = 1328c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x02\x24\x5f\xf1\x20" "\x28\xea\xf1\x02\x5f\x41\xf1\x43"; 1338c2ecf20Sopenharmony_cistatic u8 dat_common05[] = 1348c2ecf20Sopenharmony_ci "\x02\x00\xf1\xee\x03\x29\xf1\x1a" "\x04\x02\xf1\xa4\x09\x00\xf1\x68" 1358c2ecf20Sopenharmony_ci "\x0a\x00\xf1\x2a\x0b\x00\xf1\x04" "\x0c\x00\xf1\x93\x0d\x00\xf1\x82" 1368c2ecf20Sopenharmony_ci "\x0e\x00\xf1\x40\x0f\x00\xf1\x5f" "\x10\x00\xf1\x4e\x11\x00\xf1\x5b"; 1378c2ecf20Sopenharmony_cistatic u8 dat_common06[] = 1388c2ecf20Sopenharmony_ci "\x15\x00\xf1\xc9\x16\x00\xf1\x5e" "\x17\x00\xf1\x9d\x18\x00\xf1\x06" 1398c2ecf20Sopenharmony_ci "\x19\x00\xf1\x89\x1a\x00\xf1\x12" "\x1b\x00\xf1\xa1\x1c\x00\xf1\xe4" 1408c2ecf20Sopenharmony_ci "\x1d\x00\xf1\x7a\x1e\x00\xf1\x64" "\xf6\x00\xf1\x5f"; 1418c2ecf20Sopenharmony_cistatic u8 dat_common07[] = 1428c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x53\x09\xf1\x03" "\x54\x3d\xf1\x1c\x55\x99\xf1\x72" 1438c2ecf20Sopenharmony_ci "\x56\xc1\xf1\xb1\x57\xd8\xf1\xce" "\x58\xe0\xf1\x00\xdc\x0a\xf1\x03" 1448c2ecf20Sopenharmony_ci "\xdd\x45\xf1\x20\xde\xae\xf1\x82" "\xdf\xdc\xf1\xc9\xe0\xf6\xf1\xea" 1458c2ecf20Sopenharmony_ci "\xe1\xff\xf1\x00"; 1468c2ecf20Sopenharmony_cistatic u8 dat_common08[] = 1478c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x80\x00\xf1\x06" "\x81\xf6\xf1\x08\x82\xfb\xf1\xf7" 1488c2ecf20Sopenharmony_ci "\x83\x00\xf1\xfe\xb6\x07\xf1\x03" "\xb7\x18\xf1\x0c\x84\xfb\xf1\x06" 1498c2ecf20Sopenharmony_ci "\x85\xfb\xf1\xf9\x86\x00\xf1\xff" "\xb8\x07\xf1\x04\xb9\x16\xf1\x0a"; 1508c2ecf20Sopenharmony_cistatic u8 dat_common09[] = 1518c2ecf20Sopenharmony_ci "\x87\xfa\xf1\x05\x88\xfc\xf1\xf9" "\x89\x00\xf1\xff\xba\x06\xf1\x03" 1528c2ecf20Sopenharmony_ci "\xbb\x17\xf1\x09\x8a\xe8\xf1\x14" "\x8b\xf7\xf1\xf0\x8c\xfd\xf1\xfa" 1538c2ecf20Sopenharmony_ci "\x8d\x00\xf1\x00\xbc\x05\xf1\x01" "\xbd\x0c\xf1\x08\xbe\x00\xf1\x14"; 1548c2ecf20Sopenharmony_cistatic u8 dat_common10[] = 1558c2ecf20Sopenharmony_ci "\x8e\xea\xf1\x13\x8f\xf7\xf1\xf2" "\x90\xfd\xf1\xfa\x91\x00\xf1\x00" 1568c2ecf20Sopenharmony_ci "\xbf\x05\xf1\x01\xc0\x0a\xf1\x08" "\xc1\x00\xf1\x0c\x92\xed\xf1\x0f" 1578c2ecf20Sopenharmony_ci "\x93\xf9\xf1\xf4\x94\xfe\xf1\xfb" "\x95\x00\xf1\x00\xc2\x04\xf1\x01" 1588c2ecf20Sopenharmony_ci "\xc3\x0a\xf1\x07\xc4\x00\xf1\x10"; 1598c2ecf20Sopenharmony_cistatic u8 dat_common11[] = 1608c2ecf20Sopenharmony_ci "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x25\x00\xf1\x55\x34\x10\xf1\x10" 1618c2ecf20Sopenharmony_ci "\x35\xf0\xf1\x10\x3a\x02\xf1\x03" "\x3b\x04\xf1\x2a\x9b\x43\xf1\x00" 1628c2ecf20Sopenharmony_ci "\xa4\x03\xf1\xc0\xa7\x02\xf1\x81"; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_cistatic int mi1320_init_at_startup(struct gspca_dev *gspca_dev); 1658c2ecf20Sopenharmony_cistatic int mi1320_configure_alt(struct gspca_dev *gspca_dev); 1668c2ecf20Sopenharmony_cistatic int mi1320_init_pre_alt(struct gspca_dev *gspca_dev); 1678c2ecf20Sopenharmony_cistatic int mi1320_init_post_alt(struct gspca_dev *gspca_dev); 1688c2ecf20Sopenharmony_cistatic void mi1320_post_unset_alt(struct gspca_dev *gspca_dev); 1698c2ecf20Sopenharmony_cistatic int mi1320_sensor_settings(struct gspca_dev *gspca_dev); 1708c2ecf20Sopenharmony_cistatic int mi1320_camera_settings(struct gspca_dev *gspca_dev); 1718c2ecf20Sopenharmony_ci/*==========================================================================*/ 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_civoid mi1320_init_settings(struct gspca_dev *gspca_dev) 1748c2ecf20Sopenharmony_ci{ 1758c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci sd->vcur.backlight = 0; 1788c2ecf20Sopenharmony_ci sd->vcur.brightness = 0; 1798c2ecf20Sopenharmony_ci sd->vcur.sharpness = 6; 1808c2ecf20Sopenharmony_ci sd->vcur.contrast = 10; 1818c2ecf20Sopenharmony_ci sd->vcur.gamma = 20; 1828c2ecf20Sopenharmony_ci sd->vcur.hue = 0; 1838c2ecf20Sopenharmony_ci sd->vcur.saturation = 6; 1848c2ecf20Sopenharmony_ci sd->vcur.whitebal = 0; 1858c2ecf20Sopenharmony_ci sd->vcur.mirror = 0; 1868c2ecf20Sopenharmony_ci sd->vcur.flip = 0; 1878c2ecf20Sopenharmony_ci sd->vcur.AC50Hz = 1; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci sd->vmax.backlight = 2; 1908c2ecf20Sopenharmony_ci sd->vmax.brightness = 8; 1918c2ecf20Sopenharmony_ci sd->vmax.sharpness = 7; 1928c2ecf20Sopenharmony_ci sd->vmax.contrast = 0; /* 10 but not working with this driver */ 1938c2ecf20Sopenharmony_ci sd->vmax.gamma = 40; 1948c2ecf20Sopenharmony_ci sd->vmax.hue = 5 + 1; 1958c2ecf20Sopenharmony_ci sd->vmax.saturation = 8; 1968c2ecf20Sopenharmony_ci sd->vmax.whitebal = 2; 1978c2ecf20Sopenharmony_ci sd->vmax.mirror = 1; 1988c2ecf20Sopenharmony_ci sd->vmax.flip = 1; 1998c2ecf20Sopenharmony_ci sd->vmax.AC50Hz = 1; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci sd->dev_camera_settings = mi1320_camera_settings; 2028c2ecf20Sopenharmony_ci sd->dev_init_at_startup = mi1320_init_at_startup; 2038c2ecf20Sopenharmony_ci sd->dev_configure_alt = mi1320_configure_alt; 2048c2ecf20Sopenharmony_ci sd->dev_init_pre_alt = mi1320_init_pre_alt; 2058c2ecf20Sopenharmony_ci sd->dev_post_unset_alt = mi1320_post_unset_alt; 2068c2ecf20Sopenharmony_ci} 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/*==========================================================================*/ 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_cistatic void common(struct gspca_dev *gspca_dev) 2118c2ecf20Sopenharmony_ci{ 2128c2ecf20Sopenharmony_ci s32 n; /* reserved for FETCH functions */ 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 22, dat_common00); 2158c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL); 2168c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 32, dat_common01); 2178c2ecf20Sopenharmony_ci n = fetch_validx(gspca_dev, tbl_common, ARRAY_SIZE(tbl_common)); 2188c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common02); 2198c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common03); 2208c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 16, dat_common04); 2218c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common05); 2228c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 44, dat_common06); 2238c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_common, 2248c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_common), n); 2258c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 52, dat_common07); 2268c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common08); 2278c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, dat_common09); 2288c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 56, dat_common10); 2298c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_common, 2308c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_common), n); 2318c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, dat_common11); 2328c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_common, 2338c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_common), n); 2348c2ecf20Sopenharmony_ci} 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_cistatic int mi1320_init_at_startup(struct gspca_dev *gspca_dev) 2378c2ecf20Sopenharmony_ci{ 2388c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_init_at_startup, 2398c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_at_startup)); 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci common(gspca_dev); 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */ 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci return 0; 2468c2ecf20Sopenharmony_ci} 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_cistatic int mi1320_init_pre_alt(struct gspca_dev *gspca_dev) 2498c2ecf20Sopenharmony_ci{ 2508c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci sd->mirrorMask = 0; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci sd->vold.backlight = -1; 2558c2ecf20Sopenharmony_ci sd->vold.brightness = -1; 2568c2ecf20Sopenharmony_ci sd->vold.sharpness = -1; 2578c2ecf20Sopenharmony_ci sd->vold.contrast = -1; 2588c2ecf20Sopenharmony_ci sd->vold.saturation = -1; 2598c2ecf20Sopenharmony_ci sd->vold.gamma = -1; 2608c2ecf20Sopenharmony_ci sd->vold.hue = -1; 2618c2ecf20Sopenharmony_ci sd->vold.whitebal = -1; 2628c2ecf20Sopenharmony_ci sd->vold.mirror = -1; 2638c2ecf20Sopenharmony_ci sd->vold.flip = -1; 2648c2ecf20Sopenharmony_ci sd->vold.AC50Hz = -1; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci common(gspca_dev); 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci mi1320_sensor_settings(gspca_dev); 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci mi1320_init_post_alt(gspca_dev); 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci return 0; 2738c2ecf20Sopenharmony_ci} 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_cistatic int mi1320_init_post_alt(struct gspca_dev *gspca_dev) 2768c2ecf20Sopenharmony_ci{ 2778c2ecf20Sopenharmony_ci mi1320_camera_settings(gspca_dev); 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci return 0; 2808c2ecf20Sopenharmony_ci} 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cistatic int mi1320_sensor_settings(struct gspca_dev *gspca_dev) 2838c2ecf20Sopenharmony_ci{ 2848c2ecf20Sopenharmony_ci s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_sensor_settings_common, 2898c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_sensor_settings_common)); 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci switch (reso) { 2928c2ecf20Sopenharmony_ci case IMAGE_1280: 2938c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_sensor_settings_1280, 2948c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_sensor_settings_1280)); 2958c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 64, tbl_1280[0]); 2968c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_1280[1]); 2978c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_1280[2]); 2988c2ecf20Sopenharmony_ci break; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci case IMAGE_800: 3018c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_sensor_settings_800, 3028c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_sensor_settings_800)); 3038c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 64, tbl_800[0]); 3048c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_800[1]); 3058c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_800[2]); 3068c2ecf20Sopenharmony_ci break; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci default: 3098c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_sensor_settings_640, 3108c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_sensor_settings_640)); 3118c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 60, tbl_640[0]); 3128c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_640[1]); 3138c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_640[2]); 3148c2ecf20Sopenharmony_ci break; 3158c2ecf20Sopenharmony_ci } 3168c2ecf20Sopenharmony_ci return 0; 3178c2ecf20Sopenharmony_ci} 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_cistatic int mi1320_configure_alt(struct gspca_dev *gspca_dev) 3208c2ecf20Sopenharmony_ci{ 3218c2ecf20Sopenharmony_ci s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci switch (reso) { 3248c2ecf20Sopenharmony_ci case IMAGE_640: 3258c2ecf20Sopenharmony_ci gspca_dev->alt = 3 + 1; 3268c2ecf20Sopenharmony_ci break; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci case IMAGE_800: 3298c2ecf20Sopenharmony_ci case IMAGE_1280: 3308c2ecf20Sopenharmony_ci gspca_dev->alt = 1 + 1; 3318c2ecf20Sopenharmony_ci break; 3328c2ecf20Sopenharmony_ci } 3338c2ecf20Sopenharmony_ci return 0; 3348c2ecf20Sopenharmony_ci} 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_cistatic int mi1320_camera_settings(struct gspca_dev *gspca_dev) 3378c2ecf20Sopenharmony_ci{ 3388c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci s32 backlight = sd->vcur.backlight; 3418c2ecf20Sopenharmony_ci s32 bright = sd->vcur.brightness; 3428c2ecf20Sopenharmony_ci s32 sharp = sd->vcur.sharpness; 3438c2ecf20Sopenharmony_ci s32 cntr = sd->vcur.contrast; 3448c2ecf20Sopenharmony_ci s32 gam = sd->vcur.gamma; 3458c2ecf20Sopenharmony_ci s32 hue = sd->vcur.hue; 3468c2ecf20Sopenharmony_ci s32 sat = sd->vcur.saturation; 3478c2ecf20Sopenharmony_ci s32 wbal = sd->vcur.whitebal; 3488c2ecf20Sopenharmony_ci s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); 3498c2ecf20Sopenharmony_ci s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); 3508c2ecf20Sopenharmony_ci s32 freq = (sd->vcur.AC50Hz > 0); 3518c2ecf20Sopenharmony_ci s32 i; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci if (freq != sd->vold.AC50Hz) { 3548c2ecf20Sopenharmony_ci sd->vold.AC50Hz = freq; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci freq = 2 * (freq == 0); 3578c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 3588c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba02, 0x00f1, 0, NULL); 3598c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x005b, 0, NULL); 3608c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01 + freq, 0x00f1, 0, NULL); 3618c2ecf20Sopenharmony_ci } 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci if (wbal != sd->vold.whitebal) { 3648c2ecf20Sopenharmony_ci sd->vold.whitebal = wbal; 3658c2ecf20Sopenharmony_ci if (wbal < 0 || wbal > sd->vmax.whitebal) 3668c2ecf20Sopenharmony_ci wbal = 0; 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci for (i = 0; i < 2; i++) { 3698c2ecf20Sopenharmony_ci if (wbal == 0) { /* Normal light */ 3708c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3718c2ecf20Sopenharmony_ci 0x0010, 0x0010, 0, NULL); 3728c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3738c2ecf20Sopenharmony_ci 0x0003, 0x00c1, 0, NULL); 3748c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3758c2ecf20Sopenharmony_ci 0x0042, 0x00c2, 0, NULL); 3768c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 3778c2ecf20Sopenharmony_ci 0xba00, 0x0200, 48, dat_wbalNL); 3788c2ecf20Sopenharmony_ci } 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci if (wbal == 1) { /* Low light */ 3818c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3828c2ecf20Sopenharmony_ci 0x0010, 0x0010, 0, NULL); 3838c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3848c2ecf20Sopenharmony_ci 0x0004, 0x00c1, 0, NULL); 3858c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3868c2ecf20Sopenharmony_ci 0x0043, 0x00c2, 0, NULL); 3878c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 3888c2ecf20Sopenharmony_ci 0xba00, 0x0200, 48, dat_wbalLL); 3898c2ecf20Sopenharmony_ci } 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci if (wbal == 2) { /* Back light */ 3928c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3938c2ecf20Sopenharmony_ci 0x0010, 0x0010, 0, NULL); 3948c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3958c2ecf20Sopenharmony_ci 0x0003, 0x00c1, 0, NULL); 3968c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 3978c2ecf20Sopenharmony_ci 0x0042, 0x00c2, 0, NULL); 3988c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 3998c2ecf20Sopenharmony_ci 0xba00, 0x0200, 44, dat_wbalBL); 4008c2ecf20Sopenharmony_ci } 4018c2ecf20Sopenharmony_ci } 4028c2ecf20Sopenharmony_ci } 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci if (bright != sd->vold.brightness) { 4058c2ecf20Sopenharmony_ci sd->vold.brightness = bright; 4068c2ecf20Sopenharmony_ci if (bright < 0 || bright > sd->vmax.brightness) 4078c2ecf20Sopenharmony_ci bright = 0; 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci bright = tbl_bright[bright]; 4108c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 4118c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 4128c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + bright, 0x0034, 0, NULL); 4138c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + bright, 0x00f1, 0, NULL); 4148c2ecf20Sopenharmony_ci } 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci if (sat != sd->vold.saturation) { 4178c2ecf20Sopenharmony_ci sd->vold.saturation = sat; 4188c2ecf20Sopenharmony_ci if (sat < 0 || sat > sd->vmax.saturation) 4198c2ecf20Sopenharmony_ci sat = 0; 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci sat = tbl_sat[sat]; 4228c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 4238c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 4248c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x0025, 0, NULL); 4258c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + sat, 0x00f1, 0, NULL); 4268c2ecf20Sopenharmony_ci } 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci if (sharp != sd->vold.sharpness) { 4298c2ecf20Sopenharmony_ci sd->vold.sharpness = sharp; 4308c2ecf20Sopenharmony_ci if (sharp < 0 || sharp > sd->vmax.sharpness) 4318c2ecf20Sopenharmony_ci sharp = 0; 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 4348c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 4358c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x0005, 0, NULL); 4368c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + sharp, 0x00f1, 0, NULL); 4378c2ecf20Sopenharmony_ci } 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci if (hue != sd->vold.hue) { 4408c2ecf20Sopenharmony_ci /* 0=normal 1=NB 2="sepia" 3=negative 4=other 5=other2 */ 4418c2ecf20Sopenharmony_ci if (hue < 0 || hue > sd->vmax.hue) 4428c2ecf20Sopenharmony_ci hue = 0; 4438c2ecf20Sopenharmony_ci if (hue == sd->vmax.hue) 4448c2ecf20Sopenharmony_ci sd->swapRB = 1; 4458c2ecf20Sopenharmony_ci else 4468c2ecf20Sopenharmony_ci sd->swapRB = 0; 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 4498c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 4508c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba70, 0x00e2, 0, NULL); 4518c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + hue * (hue < 6), 0x00f1, 4528c2ecf20Sopenharmony_ci 0, NULL); 4538c2ecf20Sopenharmony_ci } 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci if (backlight != sd->vold.backlight) { 4568c2ecf20Sopenharmony_ci sd->vold.backlight = backlight; 4578c2ecf20Sopenharmony_ci if (backlight < 0 || backlight > sd->vmax.backlight) 4588c2ecf20Sopenharmony_ci backlight = 0; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci backlight = tbl_backlight[backlight]; 4618c2ecf20Sopenharmony_ci for (i = 0; i < 2; i++) { 4628c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 4638c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 4648c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba74, 0x0006, 0, NULL); 4658c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba80 + backlight, 0x00f1, 4668c2ecf20Sopenharmony_ci 0, NULL); 4678c2ecf20Sopenharmony_ci } 4688c2ecf20Sopenharmony_ci } 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci if (hue != sd->vold.hue) { 4718c2ecf20Sopenharmony_ci sd->vold.hue = hue; 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 4748c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 4758c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba70, 0x00e2, 0, NULL); 4768c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + hue * (hue < 6), 0x00f1, 4778c2ecf20Sopenharmony_ci 0, NULL); 4788c2ecf20Sopenharmony_ci } 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci if (mirror != sd->vold.mirror || flip != sd->vold.flip) { 4818c2ecf20Sopenharmony_ci u8 dat_hvflip2[4] = {0x20, 0x01, 0xf1, 0x00}; 4828c2ecf20Sopenharmony_ci sd->vold.mirror = mirror; 4838c2ecf20Sopenharmony_ci sd->vold.flip = flip; 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ci dat_hvflip2[3] = flip + 2 * mirror; 4868c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 4, dat_hvflip1); 4878c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 4, dat_hvflip2); 4888c2ecf20Sopenharmony_ci } 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci if (gam != sd->vold.gamma) { 4918c2ecf20Sopenharmony_ci sd->vold.gamma = gam; 4928c2ecf20Sopenharmony_ci if (gam < 0 || gam > sd->vmax.gamma) 4938c2ecf20Sopenharmony_ci gam = 0; 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci gam = 2 * gam; 4968c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 4978c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 4988c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba04 , 0x003b, 0, NULL); 4998c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba02 + gam, 0x00f1, 0, NULL); 5008c2ecf20Sopenharmony_ci } 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci if (cntr != sd->vold.contrast) { 5038c2ecf20Sopenharmony_ci sd->vold.contrast = cntr; 5048c2ecf20Sopenharmony_ci if (cntr < 0 || cntr > sd->vmax.contrast) 5058c2ecf20Sopenharmony_ci cntr = 0; 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); 5088c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); 5098c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + tbl_cntr1[cntr], 0x0035, 5108c2ecf20Sopenharmony_ci 0, NULL); 5118c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0xba00 + tbl_cntr2[cntr], 0x00f1, 5128c2ecf20Sopenharmony_ci 0, NULL); 5138c2ecf20Sopenharmony_ci } 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci return 0; 5168c2ecf20Sopenharmony_ci} 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_cistatic void mi1320_post_unset_alt(struct gspca_dev *gspca_dev) 5198c2ecf20Sopenharmony_ci{ 5208c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_post_unset_alt, 5238c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_post_unset_alt)); 5248c2ecf20Sopenharmony_ci} 525