18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* Subdriver for the GL860 chip with the OV9655 sensor 38c2ecf20Sopenharmony_ci * Author Olivier LORIN, from logs done by Simon (Sur3) and Almighurt 48c2ecf20Sopenharmony_ci * on dsd's weblog 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* Sensor : OV9655 */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "gl860.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistatic struct validx tbl_init_at_startup[] = { 128c2ecf20Sopenharmony_ci {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001, 0x00c1}, 138c2ecf20Sopenharmony_ci {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d}, 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci {0x0040, 0x0000}, 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic struct validx tbl_commmon[] = { 198c2ecf20Sopenharmony_ci {0x0041, 0x0000}, {0x006a, 0x0007}, {0x0063, 0x0006}, {0x006a, 0x000d}, 208c2ecf20Sopenharmony_ci {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0001, 0x00c1}, {0x0041, 0x00c2}, 218c2ecf20Sopenharmony_ci {0x0004, 0x00d8}, {0x0012, 0x0004}, {0x0000, 0x0058}, {0x0040, 0x0000}, 228c2ecf20Sopenharmony_ci {0x00f3, 0x0006}, {0x0058, 0x0000}, {0x0048, 0x0000}, {0x0061, 0x0000}, 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistatic s32 tbl_length[] = {12, 56, 52, 54, 56, 42, 32, 12}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic u8 *tbl_640[] = { 288c2ecf20Sopenharmony_ci "\x00\x40\x07\x6a\x06\xf3\x0d\x6a" "\x10\x10\xc1\x01" 298c2ecf20Sopenharmony_ci , 308c2ecf20Sopenharmony_ci "\x12\x80\x00\x00\x01\x98\x02\x80" "\x03\x12\x04\x03\x0b\x57\x0e\x61" 318c2ecf20Sopenharmony_ci "\x0f\x42\x11\x01\x12\x60\x13\x00" "\x14\x3a\x16\x24\x17\x14\x18\x00" 328c2ecf20Sopenharmony_ci "\x19\x01\x1a\x3d\x1e\x04\x24\x3c" "\x25\x36\x26\x72\x27\x08\x28\x08" 338c2ecf20Sopenharmony_ci "\x29\x15\x2a\x00\x2b\x00\x2c\x08" 348c2ecf20Sopenharmony_ci , 358c2ecf20Sopenharmony_ci "\x32\xff\x33\x00\x34\x3d\x35\x00" "\x36\xfa\x38\x72\x39\x57\x3a\x00" 368c2ecf20Sopenharmony_ci "\x3b\x0c\x3d\x99\x3e\x0c\x3f\xc1" "\x40\xc0\x41\x00\x42\xc0\x43\x0a" 378c2ecf20Sopenharmony_ci "\x44\xf0\x45\x46\x46\x62\x47\x2a" "\x48\x3c\x4a\xee\x4b\xe7\x4c\xe7" 388c2ecf20Sopenharmony_ci "\x4d\xe7\x4e\xe7" 398c2ecf20Sopenharmony_ci , 408c2ecf20Sopenharmony_ci "\x4f\x98\x50\x98\x51\x00\x52\x28" "\x53\x70\x54\x98\x58\x1a\x59\x85" 418c2ecf20Sopenharmony_ci "\x5a\xa9\x5b\x64\x5c\x84\x5d\x53" "\x5e\x0e\x5f\xf0\x60\xf0\x61\xf0" 428c2ecf20Sopenharmony_ci "\x62\x00\x63\x00\x64\x02\x65\x20" "\x66\x00\x69\x0a\x6b\x5a\x6c\x04" 438c2ecf20Sopenharmony_ci "\x6d\x55\x6e\x00\x6f\x9d" 448c2ecf20Sopenharmony_ci , 458c2ecf20Sopenharmony_ci "\x70\x15\x71\x78\x72\x00\x73\x00" "\x74\x3a\x75\x35\x76\x01\x77\x02" 468c2ecf20Sopenharmony_ci "\x7a\x24\x7b\x04\x7c\x07\x7d\x10" "\x7e\x28\x7f\x36\x80\x44\x81\x52" 478c2ecf20Sopenharmony_ci "\x82\x60\x83\x6c\x84\x78\x85\x8c" "\x86\x9e\x87\xbb\x88\xd2\x89\xe5" 488c2ecf20Sopenharmony_ci "\x8a\x23\x8c\x8d\x90\x7c\x91\x7b" 498c2ecf20Sopenharmony_ci , 508c2ecf20Sopenharmony_ci "\x9d\x02\x9e\x02\x9f\x74\xa0\x73" "\xa1\x40\xa4\x50\xa5\x68\xa6\x70" 518c2ecf20Sopenharmony_ci "\xa8\xc1\xa9\xef\xaa\x92\xab\x04" "\xac\x80\xad\x80\xae\x80\xaf\x80" 528c2ecf20Sopenharmony_ci "\xb2\xf2\xb3\x20\xb4\x20\xb5\x00" "\xb6\xaf" 538c2ecf20Sopenharmony_ci , 548c2ecf20Sopenharmony_ci "\xbb\xae\xbc\x4f\xbd\x4e\xbe\x6a" "\xbf\x68\xc0\xaa\xc1\xc0\xc2\x01" 558c2ecf20Sopenharmony_ci "\xc3\x4e\xc6\x85\xc7\x81\xc9\xe0" "\xca\xe8\xcb\xf0\xcc\xd8\xcd\x93" 568c2ecf20Sopenharmony_ci , 578c2ecf20Sopenharmony_ci "\xd0\x01\xd1\x08\xd2\xe0\xd3\x01" "\xd4\x10\xd5\x80" 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic u8 *tbl_1280[] = { 618c2ecf20Sopenharmony_ci "\x00\x40\x07\x6a\x06\xf3\x0d\x6a" "\x10\x10\xc1\x01" 628c2ecf20Sopenharmony_ci , 638c2ecf20Sopenharmony_ci "\x12\x80\x00\x00\x01\x98\x02\x80" "\x03\x12\x04\x01\x0b\x57\x0e\x61" 648c2ecf20Sopenharmony_ci "\x0f\x42\x11\x00\x12\x00\x13\x00" "\x14\x3a\x16\x24\x17\x1b\x18\xbb" 658c2ecf20Sopenharmony_ci "\x19\x01\x1a\x81\x1e\x04\x24\x3c" "\x25\x36\x26\x72\x27\x08\x28\x08" 668c2ecf20Sopenharmony_ci "\x29\x15\x2a\x00\x2b\x00\x2c\x08" 678c2ecf20Sopenharmony_ci , 688c2ecf20Sopenharmony_ci "\x32\xa4\x33\x00\x34\x3d\x35\x00" "\x36\xf8\x38\x72\x39\x57\x3a\x00" 698c2ecf20Sopenharmony_ci "\x3b\x0c\x3d\x99\x3e\x0c\x3f\xc2" "\x40\xc0\x41\x00\x42\xc0\x43\x0a" 708c2ecf20Sopenharmony_ci "\x44\xf0\x45\x46\x46\x62\x47\x2a" "\x48\x3c\x4a\xec\x4b\xe8\x4c\xe8" 718c2ecf20Sopenharmony_ci "\x4d\xe8\x4e\xe8" 728c2ecf20Sopenharmony_ci , 738c2ecf20Sopenharmony_ci "\x4f\x98\x50\x98\x51\x00\x52\x28" "\x53\x70\x54\x98\x58\x1a\x59\x85" 748c2ecf20Sopenharmony_ci "\x5a\xa9\x5b\x64\x5c\x84\x5d\x53" "\x5e\x0e\x5f\xf0\x60\xf0\x61\xf0" 758c2ecf20Sopenharmony_ci "\x62\x00\x63\x00\x64\x02\x65\x20" "\x66\x00\x69\x02\x6b\x5a\x6c\x04" 768c2ecf20Sopenharmony_ci "\x6d\x55\x6e\x00\x6f\x9d" 778c2ecf20Sopenharmony_ci , 788c2ecf20Sopenharmony_ci "\x70\x08\x71\x78\x72\x00\x73\x01" "\x74\x3a\x75\x35\x76\x01\x77\x02" 798c2ecf20Sopenharmony_ci "\x7a\x24\x7b\x04\x7c\x07\x7d\x10" "\x7e\x28\x7f\x36\x80\x44\x81\x52" 808c2ecf20Sopenharmony_ci "\x82\x60\x83\x6c\x84\x78\x85\x8c" "\x86\x9e\x87\xbb\x88\xd2\x89\xe5" 818c2ecf20Sopenharmony_ci "\x8a\x23\x8c\x0d\x90\x90\x91\x90" 828c2ecf20Sopenharmony_ci , 838c2ecf20Sopenharmony_ci "\x9d\x02\x9e\x02\x9f\x94\xa0\x94" "\xa1\x01\xa4\x50\xa5\x68\xa6\x70" 848c2ecf20Sopenharmony_ci "\xa8\xc1\xa9\xef\xaa\x92\xab\x04" "\xac\x80\xad\x80\xae\x80\xaf\x80" 858c2ecf20Sopenharmony_ci "\xb2\xf2\xb3\x20\xb4\x20\xb5\x00" "\xb6\xaf" 868c2ecf20Sopenharmony_ci , 878c2ecf20Sopenharmony_ci "\xbb\xae\xbc\x38\xbd\x39\xbe\x01" "\xbf\x01\xc0\xe2\xc1\xc0\xc2\x01" 888c2ecf20Sopenharmony_ci "\xc3\x4e\xc6\x85\xc7\x81\xc9\xe0" "\xca\xe8\xcb\xf0\xcc\xd8\xcd\x93" 898c2ecf20Sopenharmony_ci , 908c2ecf20Sopenharmony_ci "\xd0\x21\xd1\x18\xd2\xe0\xd3\x01" "\xd4\x28\xd5\x00" 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic u8 c04[] = {0x04}; 948c2ecf20Sopenharmony_cistatic u8 dat_post1[] = "\x04\x00\x10\x20\xa1\x00\x00\x02"; 958c2ecf20Sopenharmony_cistatic u8 dat_post2[] = "\x10\x10\xc1\x02"; 968c2ecf20Sopenharmony_cistatic u8 dat_post3[] = "\x04\x00\x10\x7c\xa1\x00\x00\x04"; 978c2ecf20Sopenharmony_cistatic u8 dat_post4[] = "\x10\x02\xc1\x06"; 988c2ecf20Sopenharmony_cistatic u8 dat_post5[] = "\x04\x00\x10\x7b\xa1\x00\x00\x08"; 998c2ecf20Sopenharmony_cistatic u8 dat_post6[] = "\x10\x10\xc1\x05"; 1008c2ecf20Sopenharmony_cistatic u8 dat_post7[] = "\x04\x00\x10\x7c\xa1\x00\x00\x08"; 1018c2ecf20Sopenharmony_cistatic u8 dat_post8[] = "\x04\x00\x10\x7c\xa1\x00\x00\x09"; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistatic struct validx tbl_init_post_alt[] = { 1048c2ecf20Sopenharmony_ci {0x6032, 0x00ff}, {0x6032, 0x00ff}, {0x6032, 0x00ff}, {0x603c, 0x00ff}, 1058c2ecf20Sopenharmony_ci {0x6003, 0x00ff}, {0x6032, 0x00ff}, {0x6032, 0x00ff}, {0x6001, 0x00ff}, 1068c2ecf20Sopenharmony_ci {0x6000, 0x801e}, 1078c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1088c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6000, 0x801e}, 1098c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1108c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6012, 0x0003}, {0x6000, 0x801e}, 1118c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1128c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6000, 0x801e}, 1138c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1148c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6012, 0x0003}, 1158c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1168c2ecf20Sopenharmony_ci {0x6000, 0x801e}, 1178c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1188c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6000, 0x801e}, 1198c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1208c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6012, 0x0003}, {0x6000, 0x801e}, 1218c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1228c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6000, 0x801e}, 1238c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1248c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6012, 0x0003}, 1258c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1268c2ecf20Sopenharmony_ci {0x6000, 0x801e}, 1278c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1288c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6000, 0x801e}, 1298c2ecf20Sopenharmony_ci {0xffff, 0xffff}, 1308c2ecf20Sopenharmony_ci {0x6004, 0x001e}, {0x6012, 0x0003}, 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistatic int ov9655_init_at_startup(struct gspca_dev *gspca_dev); 1348c2ecf20Sopenharmony_cistatic int ov9655_configure_alt(struct gspca_dev *gspca_dev); 1358c2ecf20Sopenharmony_cistatic int ov9655_init_pre_alt(struct gspca_dev *gspca_dev); 1368c2ecf20Sopenharmony_cistatic int ov9655_init_post_alt(struct gspca_dev *gspca_dev); 1378c2ecf20Sopenharmony_cistatic void ov9655_post_unset_alt(struct gspca_dev *gspca_dev); 1388c2ecf20Sopenharmony_cistatic int ov9655_camera_settings(struct gspca_dev *gspca_dev); 1398c2ecf20Sopenharmony_ci/*==========================================================================*/ 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_civoid ov9655_init_settings(struct gspca_dev *gspca_dev) 1428c2ecf20Sopenharmony_ci{ 1438c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci sd->vcur.backlight = 0; 1468c2ecf20Sopenharmony_ci sd->vcur.brightness = 128; 1478c2ecf20Sopenharmony_ci sd->vcur.sharpness = 0; 1488c2ecf20Sopenharmony_ci sd->vcur.contrast = 0; 1498c2ecf20Sopenharmony_ci sd->vcur.gamma = 0; 1508c2ecf20Sopenharmony_ci sd->vcur.hue = 0; 1518c2ecf20Sopenharmony_ci sd->vcur.saturation = 0; 1528c2ecf20Sopenharmony_ci sd->vcur.whitebal = 0; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci sd->vmax.backlight = 0; 1558c2ecf20Sopenharmony_ci sd->vmax.brightness = 255; 1568c2ecf20Sopenharmony_ci sd->vmax.sharpness = 0; 1578c2ecf20Sopenharmony_ci sd->vmax.contrast = 0; 1588c2ecf20Sopenharmony_ci sd->vmax.gamma = 0; 1598c2ecf20Sopenharmony_ci sd->vmax.hue = 0 + 1; 1608c2ecf20Sopenharmony_ci sd->vmax.saturation = 0; 1618c2ecf20Sopenharmony_ci sd->vmax.whitebal = 0; 1628c2ecf20Sopenharmony_ci sd->vmax.mirror = 0; 1638c2ecf20Sopenharmony_ci sd->vmax.flip = 0; 1648c2ecf20Sopenharmony_ci sd->vmax.AC50Hz = 0; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci sd->dev_camera_settings = ov9655_camera_settings; 1678c2ecf20Sopenharmony_ci sd->dev_init_at_startup = ov9655_init_at_startup; 1688c2ecf20Sopenharmony_ci sd->dev_configure_alt = ov9655_configure_alt; 1698c2ecf20Sopenharmony_ci sd->dev_init_pre_alt = ov9655_init_pre_alt; 1708c2ecf20Sopenharmony_ci sd->dev_post_unset_alt = ov9655_post_unset_alt; 1718c2ecf20Sopenharmony_ci} 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/*==========================================================================*/ 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_cistatic int ov9655_init_at_startup(struct gspca_dev *gspca_dev) 1768c2ecf20Sopenharmony_ci{ 1778c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_init_at_startup, 1788c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_at_startup)); 1798c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_commmon, ARRAY_SIZE(tbl_commmon)); 1808c2ecf20Sopenharmony_ci/* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL);*/ 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci return 0; 1838c2ecf20Sopenharmony_ci} 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_cistatic int ov9655_init_pre_alt(struct gspca_dev *gspca_dev) 1868c2ecf20Sopenharmony_ci{ 1878c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci sd->vold.brightness = -1; 1908c2ecf20Sopenharmony_ci sd->vold.hue = -1; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci fetch_validx(gspca_dev, tbl_commmon, ARRAY_SIZE(tbl_commmon)); 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci ov9655_init_post_alt(gspca_dev); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci return 0; 1978c2ecf20Sopenharmony_ci} 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_cistatic int ov9655_init_post_alt(struct gspca_dev *gspca_dev) 2008c2ecf20Sopenharmony_ci{ 2018c2ecf20Sopenharmony_ci s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 2028c2ecf20Sopenharmony_ci s32 n; /* reserved for FETCH functions */ 2038c2ecf20Sopenharmony_ci s32 i; 2048c2ecf20Sopenharmony_ci u8 **tbl; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci tbl = (reso == IMAGE_640) ? tbl_640 : tbl_1280; 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 2118c2ecf20Sopenharmony_ci tbl_length[0], tbl[0]); 2128c2ecf20Sopenharmony_ci for (i = 1; i < 7; i++) 2138c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 2148c2ecf20Sopenharmony_ci tbl_length[i], tbl[i]); 2158c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 2168c2ecf20Sopenharmony_ci tbl_length[7], tbl[7]); 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci n = fetch_validx(gspca_dev, tbl_init_post_alt, 2198c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt)); 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2228c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2238c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2248c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2258c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2268c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2278c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2288c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2298c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2308c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2318c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2328c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2338c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post1); 2348c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2358c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2388c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2398c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2408c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2418c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2428c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2438c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2448c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2458c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2468c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2478c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2488c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2498c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post1); 2508c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2518c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2548c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2558c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2568c2ecf20Sopenharmony_ci ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); 2578c2ecf20Sopenharmony_ci keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, 2588c2ecf20Sopenharmony_ci ARRAY_SIZE(tbl_init_post_alt), n); 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post1); 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4, dat_post2); 2638c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post3); 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4, dat_post4); 2668c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post5); 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4, dat_post6); 2698c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post7); 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post8); 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci ov9655_camera_settings(gspca_dev); 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci return 0; 2768c2ecf20Sopenharmony_ci} 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_cistatic int ov9655_configure_alt(struct gspca_dev *gspca_dev) 2798c2ecf20Sopenharmony_ci{ 2808c2ecf20Sopenharmony_ci s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci switch (reso) { 2838c2ecf20Sopenharmony_ci case IMAGE_640: 2848c2ecf20Sopenharmony_ci gspca_dev->alt = 1 + 1; 2858c2ecf20Sopenharmony_ci break; 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci default: 2888c2ecf20Sopenharmony_ci gspca_dev->alt = 1 + 1; 2898c2ecf20Sopenharmony_ci break; 2908c2ecf20Sopenharmony_ci } 2918c2ecf20Sopenharmony_ci return 0; 2928c2ecf20Sopenharmony_ci} 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_cistatic int ov9655_camera_settings(struct gspca_dev *gspca_dev) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci u8 dat_bright[] = "\x04\x00\x10\x7c\xa1\x00\x00\x70"; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci s32 bright = sd->vcur.brightness; 3018c2ecf20Sopenharmony_ci s32 hue = sd->vcur.hue; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci if (bright != sd->vold.brightness) { 3048c2ecf20Sopenharmony_ci sd->vold.brightness = bright; 3058c2ecf20Sopenharmony_ci if (bright < 0 || bright > sd->vmax.brightness) 3068c2ecf20Sopenharmony_ci bright = 0; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci dat_bright[3] = bright; 3098c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_bright); 3108c2ecf20Sopenharmony_ci } 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci if (hue != sd->vold.hue) { 3138c2ecf20Sopenharmony_ci sd->vold.hue = hue; 3148c2ecf20Sopenharmony_ci sd->swapRB = (hue != 0); 3158c2ecf20Sopenharmony_ci } 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci return 0; 3188c2ecf20Sopenharmony_ci} 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_cistatic void ov9655_post_unset_alt(struct gspca_dev *gspca_dev) 3218c2ecf20Sopenharmony_ci{ 3228c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); 3238c2ecf20Sopenharmony_ci ctrl_out(gspca_dev, 0x40, 1, 0x0061, 0x0000, 0, NULL); 3248c2ecf20Sopenharmony_ci} 325