18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Quickcam cameras initialization data 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#define MODULE_NAME "tv8532" 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "gspca.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciMODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 128c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("TV8532 USB Camera Driver"); 138c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* specific webcam descriptor */ 168c2ecf20Sopenharmony_cistruct sd { 178c2ecf20Sopenharmony_ci struct gspca_dev gspca_dev; /* !! must be the first item */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci __u8 packet; 208c2ecf20Sopenharmony_ci}; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic const struct v4l2_pix_format sif_mode[] = { 238c2ecf20Sopenharmony_ci {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 248c2ecf20Sopenharmony_ci .bytesperline = 176, 258c2ecf20Sopenharmony_ci .sizeimage = 176 * 144, 268c2ecf20Sopenharmony_ci .colorspace = V4L2_COLORSPACE_SRGB, 278c2ecf20Sopenharmony_ci .priv = 1}, 288c2ecf20Sopenharmony_ci {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 298c2ecf20Sopenharmony_ci .bytesperline = 352, 308c2ecf20Sopenharmony_ci .sizeimage = 352 * 288, 318c2ecf20Sopenharmony_ci .colorspace = V4L2_COLORSPACE_SRGB, 328c2ecf20Sopenharmony_ci .priv = 0}, 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* TV-8532A (ICM532A) registers (LE) */ 368c2ecf20Sopenharmony_ci#define R00_PART_CONTROL 0x00 378c2ecf20Sopenharmony_ci#define LATENT_CHANGE 0x80 388c2ecf20Sopenharmony_ci#define EXPO_CHANGE 0x04 398c2ecf20Sopenharmony_ci#define R01_TIMING_CONTROL_LOW 0x01 408c2ecf20Sopenharmony_ci#define CMD_EEprom_Open 0x30 418c2ecf20Sopenharmony_ci#define CMD_EEprom_Close 0x29 428c2ecf20Sopenharmony_ci#define R03_TABLE_ADDR 0x03 438c2ecf20Sopenharmony_ci#define R04_WTRAM_DATA_L 0x04 448c2ecf20Sopenharmony_ci#define R05_WTRAM_DATA_M 0x05 458c2ecf20Sopenharmony_ci#define R06_WTRAM_DATA_H 0x06 468c2ecf20Sopenharmony_ci#define R07_TABLE_LEN 0x07 478c2ecf20Sopenharmony_ci#define R08_RAM_WRITE_ACTION 0x08 488c2ecf20Sopenharmony_ci#define R0C_AD_WIDTHL 0x0c 498c2ecf20Sopenharmony_ci#define R0D_AD_WIDTHH 0x0d 508c2ecf20Sopenharmony_ci#define R0E_AD_HEIGHTL 0x0e 518c2ecf20Sopenharmony_ci#define R0F_AD_HEIGHTH 0x0f 528c2ecf20Sopenharmony_ci#define R10_AD_COL_BEGINL 0x10 538c2ecf20Sopenharmony_ci#define R11_AD_COL_BEGINH 0x11 548c2ecf20Sopenharmony_ci#define MIRROR 0x04 /* [10] */ 558c2ecf20Sopenharmony_ci#define R14_AD_ROW_BEGINL 0x14 568c2ecf20Sopenharmony_ci#define R15_AD_ROWBEGINH 0x15 578c2ecf20Sopenharmony_ci#define R1C_AD_EXPOSE_TIMEL 0x1c 588c2ecf20Sopenharmony_ci#define R20_GAIN_G1L 0x20 598c2ecf20Sopenharmony_ci#define R21_GAIN_G1H 0x21 608c2ecf20Sopenharmony_ci#define R22_GAIN_RL 0x22 618c2ecf20Sopenharmony_ci#define R23_GAIN_RH 0x23 628c2ecf20Sopenharmony_ci#define R24_GAIN_BL 0x24 638c2ecf20Sopenharmony_ci#define R25_GAIN_BH 0x25 648c2ecf20Sopenharmony_ci#define R26_GAIN_G2L 0x26 658c2ecf20Sopenharmony_ci#define R27_GAIN_G2H 0x27 668c2ecf20Sopenharmony_ci#define R28_QUANT 0x28 678c2ecf20Sopenharmony_ci#define R29_LINE 0x29 688c2ecf20Sopenharmony_ci#define R2C_POLARITY 0x2c 698c2ecf20Sopenharmony_ci#define R2D_POINT 0x2d 708c2ecf20Sopenharmony_ci#define R2E_POINTH 0x2e 718c2ecf20Sopenharmony_ci#define R2F_POINTB 0x2f 728c2ecf20Sopenharmony_ci#define R30_POINTBH 0x30 738c2ecf20Sopenharmony_ci#define R31_UPD 0x31 748c2ecf20Sopenharmony_ci#define R2A_HIGH_BUDGET 0x2a 758c2ecf20Sopenharmony_ci#define R2B_LOW_BUDGET 0x2b 768c2ecf20Sopenharmony_ci#define R34_VID 0x34 778c2ecf20Sopenharmony_ci#define R35_VIDH 0x35 788c2ecf20Sopenharmony_ci#define R36_PID 0x36 798c2ecf20Sopenharmony_ci#define R37_PIDH 0x37 808c2ecf20Sopenharmony_ci#define R39_Test1 0x39 /* GPIO */ 818c2ecf20Sopenharmony_ci#define R3B_Test3 0x3b /* GPIO */ 828c2ecf20Sopenharmony_ci#define R83_AD_IDH 0x83 838c2ecf20Sopenharmony_ci#define R91_AD_SLOPEREG 0x91 848c2ecf20Sopenharmony_ci#define R94_AD_BITCONTROL 0x94 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic const u8 eeprom_data[][3] = { 878c2ecf20Sopenharmony_ci/* dataH dataM dataL */ 888c2ecf20Sopenharmony_ci {0x01, 0x00, 0x01}, 898c2ecf20Sopenharmony_ci {0x01, 0x80, 0x11}, 908c2ecf20Sopenharmony_ci {0x05, 0x00, 0x14}, 918c2ecf20Sopenharmony_ci {0x05, 0x00, 0x1c}, 928c2ecf20Sopenharmony_ci {0x0d, 0x00, 0x1e}, 938c2ecf20Sopenharmony_ci {0x05, 0x00, 0x1f}, 948c2ecf20Sopenharmony_ci {0x05, 0x05, 0x19}, 958c2ecf20Sopenharmony_ci {0x05, 0x01, 0x1b}, 968c2ecf20Sopenharmony_ci {0x05, 0x09, 0x1e}, 978c2ecf20Sopenharmony_ci {0x0d, 0x89, 0x2e}, 988c2ecf20Sopenharmony_ci {0x05, 0x89, 0x2f}, 998c2ecf20Sopenharmony_ci {0x05, 0x0d, 0xd9}, 1008c2ecf20Sopenharmony_ci {0x05, 0x09, 0xf1}, 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* write 1 byte */ 1058c2ecf20Sopenharmony_cistatic void reg_w1(struct gspca_dev *gspca_dev, 1068c2ecf20Sopenharmony_ci __u16 index, __u8 value) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci gspca_dev->usb_buf[0] = value; 1098c2ecf20Sopenharmony_ci usb_control_msg(gspca_dev->dev, 1108c2ecf20Sopenharmony_ci usb_sndctrlpipe(gspca_dev->dev, 0), 1118c2ecf20Sopenharmony_ci 0x02, 1128c2ecf20Sopenharmony_ci USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1138c2ecf20Sopenharmony_ci 0, /* value */ 1148c2ecf20Sopenharmony_ci index, gspca_dev->usb_buf, 1, 500); 1158c2ecf20Sopenharmony_ci} 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* write 2 bytes */ 1188c2ecf20Sopenharmony_cistatic void reg_w2(struct gspca_dev *gspca_dev, 1198c2ecf20Sopenharmony_ci u16 index, u16 value) 1208c2ecf20Sopenharmony_ci{ 1218c2ecf20Sopenharmony_ci gspca_dev->usb_buf[0] = value; 1228c2ecf20Sopenharmony_ci gspca_dev->usb_buf[1] = value >> 8; 1238c2ecf20Sopenharmony_ci usb_control_msg(gspca_dev->dev, 1248c2ecf20Sopenharmony_ci usb_sndctrlpipe(gspca_dev->dev, 0), 1258c2ecf20Sopenharmony_ci 0x02, 1268c2ecf20Sopenharmony_ci USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1278c2ecf20Sopenharmony_ci 0, /* value */ 1288c2ecf20Sopenharmony_ci index, gspca_dev->usb_buf, 2, 500); 1298c2ecf20Sopenharmony_ci} 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistatic void tv_8532WriteEEprom(struct gspca_dev *gspca_dev) 1328c2ecf20Sopenharmony_ci{ 1338c2ecf20Sopenharmony_ci int i; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R01_TIMING_CONTROL_LOW, CMD_EEprom_Open); 1368c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(eeprom_data); i++) { 1378c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R03_TABLE_ADDR, i); 1388c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R04_WTRAM_DATA_L, eeprom_data[i][2]); 1398c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R05_WTRAM_DATA_M, eeprom_data[i][1]); 1408c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R06_WTRAM_DATA_H, eeprom_data[i][0]); 1418c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R08_RAM_WRITE_ACTION, 0); 1428c2ecf20Sopenharmony_ci } 1438c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R07_TABLE_LEN, i); 1448c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R01_TIMING_CONTROL_LOW, CMD_EEprom_Close); 1458c2ecf20Sopenharmony_ci} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci/* this function is called at probe time */ 1488c2ecf20Sopenharmony_cistatic int sd_config(struct gspca_dev *gspca_dev, 1498c2ecf20Sopenharmony_ci const struct usb_device_id *id) 1508c2ecf20Sopenharmony_ci{ 1518c2ecf20Sopenharmony_ci struct cam *cam; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci cam = &gspca_dev->cam; 1548c2ecf20Sopenharmony_ci cam->cam_mode = sif_mode; 1558c2ecf20Sopenharmony_ci cam->nmodes = ARRAY_SIZE(sif_mode); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci return 0; 1588c2ecf20Sopenharmony_ci} 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistatic void tv_8532_setReg(struct gspca_dev *gspca_dev) 1618c2ecf20Sopenharmony_ci{ 1628c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R3B_Test3, 0x0a); /* Test0Sel = 10 */ 1638c2ecf20Sopenharmony_ci /******************************************************/ 1648c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R0E_AD_HEIGHTL, 0x90); 1658c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R0F_AD_HEIGHTH, 0x01); 1668c2ecf20Sopenharmony_ci reg_w2(gspca_dev, R1C_AD_EXPOSE_TIMEL, 0x018f); 1678c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R10_AD_COL_BEGINL, 0x44); 1688c2ecf20Sopenharmony_ci /* begin active line */ 1698c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R11_AD_COL_BEGINH, 0x00); 1708c2ecf20Sopenharmony_ci /* mirror and digital gain */ 1718c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R14_AD_ROW_BEGINL, 0x0a); 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R94_AD_BITCONTROL, 0x02); 1748c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R91_AD_SLOPEREG, 0x00); 1758c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R00_PART_CONTROL, LATENT_CHANGE | EXPO_CHANGE); 1768c2ecf20Sopenharmony_ci /* = 0x84 */ 1778c2ecf20Sopenharmony_ci} 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* this function is called at probe and resume time */ 1808c2ecf20Sopenharmony_cistatic int sd_init(struct gspca_dev *gspca_dev) 1818c2ecf20Sopenharmony_ci{ 1828c2ecf20Sopenharmony_ci tv_8532WriteEEprom(gspca_dev); 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci return 0; 1858c2ecf20Sopenharmony_ci} 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistatic void setexposure(struct gspca_dev *gspca_dev, s32 val) 1888c2ecf20Sopenharmony_ci{ 1898c2ecf20Sopenharmony_ci reg_w2(gspca_dev, R1C_AD_EXPOSE_TIMEL, val); 1908c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R00_PART_CONTROL, LATENT_CHANGE | EXPO_CHANGE); 1918c2ecf20Sopenharmony_ci /* 0x84 */ 1928c2ecf20Sopenharmony_ci} 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistatic void setgain(struct gspca_dev *gspca_dev, s32 val) 1958c2ecf20Sopenharmony_ci{ 1968c2ecf20Sopenharmony_ci reg_w2(gspca_dev, R20_GAIN_G1L, val); 1978c2ecf20Sopenharmony_ci reg_w2(gspca_dev, R22_GAIN_RL, val); 1988c2ecf20Sopenharmony_ci reg_w2(gspca_dev, R24_GAIN_BL, val); 1998c2ecf20Sopenharmony_ci reg_w2(gspca_dev, R26_GAIN_G2L, val); 2008c2ecf20Sopenharmony_ci} 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci/* -- start the camera -- */ 2038c2ecf20Sopenharmony_cistatic int sd_start(struct gspca_dev *gspca_dev) 2048c2ecf20Sopenharmony_ci{ 2058c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R0C_AD_WIDTHL, 0xe8); /* 0x20; 0x0c */ 2088c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R0D_AD_WIDTHH, 0x03); 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci /************************************************/ 2118c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R28_QUANT, 0x90); 2128c2ecf20Sopenharmony_ci /* 0x72 compressed mode 0x28 */ 2138c2ecf20Sopenharmony_ci if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { 2148c2ecf20Sopenharmony_ci /* 176x144 */ 2158c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R29_LINE, 0x41); 2168c2ecf20Sopenharmony_ci /* CIF - 2 lines/packet */ 2178c2ecf20Sopenharmony_ci } else { 2188c2ecf20Sopenharmony_ci /* 352x288 */ 2198c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R29_LINE, 0x81); 2208c2ecf20Sopenharmony_ci /* CIF - 2 lines/packet */ 2218c2ecf20Sopenharmony_ci } 2228c2ecf20Sopenharmony_ci /************************************************/ 2238c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R2C_POLARITY, 0x10); /* slow clock */ 2248c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R2D_POINT, 0x14); 2258c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R2E_POINTH, 0x01); 2268c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R2F_POINTB, 0x12); 2278c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R30_POINTBH, 0x01); 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci tv_8532_setReg(gspca_dev); 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci /************************************************/ 2328c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R31_UPD, 0x01); /* update registers */ 2338c2ecf20Sopenharmony_ci msleep(200); 2348c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R31_UPD, 0x00); /* end update */ 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci gspca_dev->empty_packet = 0; /* check the empty packets */ 2378c2ecf20Sopenharmony_ci sd->packet = 0; /* ignore the first packets */ 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci return 0; 2408c2ecf20Sopenharmony_ci} 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistatic void sd_stopN(struct gspca_dev *gspca_dev) 2438c2ecf20Sopenharmony_ci{ 2448c2ecf20Sopenharmony_ci reg_w1(gspca_dev, R3B_Test3, 0x0b); /* Test0Sel = 11 = GPIO */ 2458c2ecf20Sopenharmony_ci} 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_cistatic void sd_pkt_scan(struct gspca_dev *gspca_dev, 2488c2ecf20Sopenharmony_ci u8 *data, /* isoc packet */ 2498c2ecf20Sopenharmony_ci int len) /* iso packet length */ 2508c2ecf20Sopenharmony_ci{ 2518c2ecf20Sopenharmony_ci struct sd *sd = (struct sd *) gspca_dev; 2528c2ecf20Sopenharmony_ci int packet_type0, packet_type1; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci packet_type0 = packet_type1 = INTER_PACKET; 2558c2ecf20Sopenharmony_ci if (gspca_dev->empty_packet) { 2568c2ecf20Sopenharmony_ci gspca_dev->empty_packet = 0; 2578c2ecf20Sopenharmony_ci sd->packet = gspca_dev->pixfmt.height / 2; 2588c2ecf20Sopenharmony_ci packet_type0 = FIRST_PACKET; 2598c2ecf20Sopenharmony_ci } else if (sd->packet == 0) 2608c2ecf20Sopenharmony_ci return; /* 2 more lines in 352x288 ! */ 2618c2ecf20Sopenharmony_ci sd->packet--; 2628c2ecf20Sopenharmony_ci if (sd->packet == 0) 2638c2ecf20Sopenharmony_ci packet_type1 = LAST_PACKET; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci /* each packet contains: 2668c2ecf20Sopenharmony_ci * - header 2 bytes 2678c2ecf20Sopenharmony_ci * - RGRG line 2688c2ecf20Sopenharmony_ci * - 4 bytes 2698c2ecf20Sopenharmony_ci * - GBGB line 2708c2ecf20Sopenharmony_ci * - 4 bytes 2718c2ecf20Sopenharmony_ci */ 2728c2ecf20Sopenharmony_ci gspca_frame_add(gspca_dev, packet_type0, 2738c2ecf20Sopenharmony_ci data + 2, gspca_dev->pixfmt.width); 2748c2ecf20Sopenharmony_ci gspca_frame_add(gspca_dev, packet_type1, 2758c2ecf20Sopenharmony_ci data + gspca_dev->pixfmt.width + 5, 2768c2ecf20Sopenharmony_ci gspca_dev->pixfmt.width); 2778c2ecf20Sopenharmony_ci} 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_cistatic int sd_s_ctrl(struct v4l2_ctrl *ctrl) 2808c2ecf20Sopenharmony_ci{ 2818c2ecf20Sopenharmony_ci struct gspca_dev *gspca_dev = 2828c2ecf20Sopenharmony_ci container_of(ctrl->handler, struct gspca_dev, ctrl_handler); 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci gspca_dev->usb_err = 0; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci if (!gspca_dev->streaming) 2878c2ecf20Sopenharmony_ci return 0; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci switch (ctrl->id) { 2908c2ecf20Sopenharmony_ci case V4L2_CID_EXPOSURE: 2918c2ecf20Sopenharmony_ci setexposure(gspca_dev, ctrl->val); 2928c2ecf20Sopenharmony_ci break; 2938c2ecf20Sopenharmony_ci case V4L2_CID_GAIN: 2948c2ecf20Sopenharmony_ci setgain(gspca_dev, ctrl->val); 2958c2ecf20Sopenharmony_ci break; 2968c2ecf20Sopenharmony_ci } 2978c2ecf20Sopenharmony_ci return gspca_dev->usb_err; 2988c2ecf20Sopenharmony_ci} 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_cistatic const struct v4l2_ctrl_ops sd_ctrl_ops = { 3018c2ecf20Sopenharmony_ci .s_ctrl = sd_s_ctrl, 3028c2ecf20Sopenharmony_ci}; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_cistatic int sd_init_controls(struct gspca_dev *gspca_dev) 3058c2ecf20Sopenharmony_ci{ 3068c2ecf20Sopenharmony_ci struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci gspca_dev->vdev.ctrl_handler = hdl; 3098c2ecf20Sopenharmony_ci v4l2_ctrl_handler_init(hdl, 2); 3108c2ecf20Sopenharmony_ci v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 3118c2ecf20Sopenharmony_ci V4L2_CID_EXPOSURE, 0, 0x18f, 1, 0x18f); 3128c2ecf20Sopenharmony_ci v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 3138c2ecf20Sopenharmony_ci V4L2_CID_GAIN, 0, 0x7ff, 1, 0x100); 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci if (hdl->error) { 3168c2ecf20Sopenharmony_ci pr_err("Could not initialize controls\n"); 3178c2ecf20Sopenharmony_ci return hdl->error; 3188c2ecf20Sopenharmony_ci } 3198c2ecf20Sopenharmony_ci return 0; 3208c2ecf20Sopenharmony_ci} 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci/* sub-driver description */ 3238c2ecf20Sopenharmony_cistatic const struct sd_desc sd_desc = { 3248c2ecf20Sopenharmony_ci .name = MODULE_NAME, 3258c2ecf20Sopenharmony_ci .config = sd_config, 3268c2ecf20Sopenharmony_ci .init = sd_init, 3278c2ecf20Sopenharmony_ci .init_controls = sd_init_controls, 3288c2ecf20Sopenharmony_ci .start = sd_start, 3298c2ecf20Sopenharmony_ci .stopN = sd_stopN, 3308c2ecf20Sopenharmony_ci .pkt_scan = sd_pkt_scan, 3318c2ecf20Sopenharmony_ci}; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci/* -- module initialisation -- */ 3348c2ecf20Sopenharmony_cistatic const struct usb_device_id device_table[] = { 3358c2ecf20Sopenharmony_ci {USB_DEVICE(0x046d, 0x0920)}, 3368c2ecf20Sopenharmony_ci {USB_DEVICE(0x046d, 0x0921)}, 3378c2ecf20Sopenharmony_ci {USB_DEVICE(0x0545, 0x808b)}, 3388c2ecf20Sopenharmony_ci {USB_DEVICE(0x0545, 0x8333)}, 3398c2ecf20Sopenharmony_ci {USB_DEVICE(0x0923, 0x010f)}, 3408c2ecf20Sopenharmony_ci {} 3418c2ecf20Sopenharmony_ci}; 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(usb, device_table); 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci/* -- device connect -- */ 3468c2ecf20Sopenharmony_cistatic int sd_probe(struct usb_interface *intf, 3478c2ecf20Sopenharmony_ci const struct usb_device_id *id) 3488c2ecf20Sopenharmony_ci{ 3498c2ecf20Sopenharmony_ci return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 3508c2ecf20Sopenharmony_ci THIS_MODULE); 3518c2ecf20Sopenharmony_ci} 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_cistatic struct usb_driver sd_driver = { 3548c2ecf20Sopenharmony_ci .name = MODULE_NAME, 3558c2ecf20Sopenharmony_ci .id_table = device_table, 3568c2ecf20Sopenharmony_ci .probe = sd_probe, 3578c2ecf20Sopenharmony_ci .disconnect = gspca_disconnect, 3588c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 3598c2ecf20Sopenharmony_ci .suspend = gspca_suspend, 3608c2ecf20Sopenharmony_ci .resume = gspca_resume, 3618c2ecf20Sopenharmony_ci .reset_resume = gspca_resume, 3628c2ecf20Sopenharmony_ci#endif 3638c2ecf20Sopenharmony_ci}; 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_cimodule_usb_driver(sd_driver); 366