18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * saa7185 - Philips SAA7185B video encoder driver version 0.0.3 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Slight changes for video timing and attachment output by 88c2ecf20Sopenharmony_ci * Wolfgang Scherr <scherr@net4you.net> 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net> 118c2ecf20Sopenharmony_ci * - moved over to linux>=2.4.x i2c protocol (1/1/2003) 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/module.h> 158c2ecf20Sopenharmony_ci#include <linux/types.h> 168c2ecf20Sopenharmony_ci#include <linux/slab.h> 178c2ecf20Sopenharmony_ci#include <linux/ioctl.h> 188c2ecf20Sopenharmony_ci#include <linux/uaccess.h> 198c2ecf20Sopenharmony_ci#include <linux/i2c.h> 208c2ecf20Sopenharmony_ci#include <linux/videodev2.h> 218c2ecf20Sopenharmony_ci#include <media/v4l2-device.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Philips SAA7185 video encoder driver"); 248c2ecf20Sopenharmony_ciMODULE_AUTHOR("Dave Perks"); 258c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic int debug; 288c2ecf20Sopenharmony_cimodule_param(debug, int, 0); 298c2ecf20Sopenharmony_ciMODULE_PARM_DESC(debug, "Debug level (0-1)"); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------- */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct saa7185 { 358c2ecf20Sopenharmony_ci struct v4l2_subdev sd; 368c2ecf20Sopenharmony_ci unsigned char reg[128]; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci v4l2_std_id norm; 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistatic inline struct saa7185 *to_saa7185(struct v4l2_subdev *sd) 428c2ecf20Sopenharmony_ci{ 438c2ecf20Sopenharmony_ci return container_of(sd, struct saa7185, sd); 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------- */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic inline int saa7185_read(struct v4l2_subdev *sd) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci struct i2c_client *client = v4l2_get_subdevdata(sd); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci return i2c_smbus_read_byte(client); 538c2ecf20Sopenharmony_ci} 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic int saa7185_write(struct v4l2_subdev *sd, u8 reg, u8 value) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci struct i2c_client *client = v4l2_get_subdevdata(sd); 588c2ecf20Sopenharmony_ci struct saa7185 *encoder = to_saa7185(sd); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci v4l2_dbg(1, debug, sd, "%02x set to %02x\n", reg, value); 618c2ecf20Sopenharmony_ci encoder->reg[reg] = value; 628c2ecf20Sopenharmony_ci return i2c_smbus_write_byte_data(client, reg, value); 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic int saa7185_write_block(struct v4l2_subdev *sd, 668c2ecf20Sopenharmony_ci const u8 *data, unsigned int len) 678c2ecf20Sopenharmony_ci{ 688c2ecf20Sopenharmony_ci struct i2c_client *client = v4l2_get_subdevdata(sd); 698c2ecf20Sopenharmony_ci struct saa7185 *encoder = to_saa7185(sd); 708c2ecf20Sopenharmony_ci int ret = -1; 718c2ecf20Sopenharmony_ci u8 reg; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci /* the adv7175 has an autoincrement function, use it if 748c2ecf20Sopenharmony_ci * the adapter understands raw I2C */ 758c2ecf20Sopenharmony_ci if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 768c2ecf20Sopenharmony_ci /* do raw I2C, not smbus compatible */ 778c2ecf20Sopenharmony_ci u8 block_data[32]; 788c2ecf20Sopenharmony_ci int block_len; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci while (len >= 2) { 818c2ecf20Sopenharmony_ci block_len = 0; 828c2ecf20Sopenharmony_ci block_data[block_len++] = reg = data[0]; 838c2ecf20Sopenharmony_ci do { 848c2ecf20Sopenharmony_ci block_data[block_len++] = 858c2ecf20Sopenharmony_ci encoder->reg[reg++] = data[1]; 868c2ecf20Sopenharmony_ci len -= 2; 878c2ecf20Sopenharmony_ci data += 2; 888c2ecf20Sopenharmony_ci } while (len >= 2 && data[0] == reg && block_len < 32); 898c2ecf20Sopenharmony_ci ret = i2c_master_send(client, block_data, block_len); 908c2ecf20Sopenharmony_ci if (ret < 0) 918c2ecf20Sopenharmony_ci break; 928c2ecf20Sopenharmony_ci } 938c2ecf20Sopenharmony_ci } else { 948c2ecf20Sopenharmony_ci /* do some slow I2C emulation kind of thing */ 958c2ecf20Sopenharmony_ci while (len >= 2) { 968c2ecf20Sopenharmony_ci reg = *data++; 978c2ecf20Sopenharmony_ci ret = saa7185_write(sd, reg, *data++); 988c2ecf20Sopenharmony_ci if (ret < 0) 998c2ecf20Sopenharmony_ci break; 1008c2ecf20Sopenharmony_ci len -= 2; 1018c2ecf20Sopenharmony_ci } 1028c2ecf20Sopenharmony_ci } 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci return ret; 1058c2ecf20Sopenharmony_ci} 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------- */ 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistatic const unsigned char init_common[] = { 1108c2ecf20Sopenharmony_ci 0x3a, 0x0f, /* CBENB=0, V656=0, VY2C=1, 1118c2ecf20Sopenharmony_ci * YUV2C=1, MY2C=1, MUV2C=1 */ 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci 0x42, 0x6b, /* OVLY0=107 */ 1148c2ecf20Sopenharmony_ci 0x43, 0x00, /* OVLU0=0 white */ 1158c2ecf20Sopenharmony_ci 0x44, 0x00, /* OVLV0=0 */ 1168c2ecf20Sopenharmony_ci 0x45, 0x22, /* OVLY1=34 */ 1178c2ecf20Sopenharmony_ci 0x46, 0xac, /* OVLU1=172 yellow */ 1188c2ecf20Sopenharmony_ci 0x47, 0x0e, /* OVLV1=14 */ 1198c2ecf20Sopenharmony_ci 0x48, 0x03, /* OVLY2=3 */ 1208c2ecf20Sopenharmony_ci 0x49, 0x1d, /* OVLU2=29 cyan */ 1218c2ecf20Sopenharmony_ci 0x4a, 0xac, /* OVLV2=172 */ 1228c2ecf20Sopenharmony_ci 0x4b, 0xf0, /* OVLY3=240 */ 1238c2ecf20Sopenharmony_ci 0x4c, 0xc8, /* OVLU3=200 green */ 1248c2ecf20Sopenharmony_ci 0x4d, 0xb9, /* OVLV3=185 */ 1258c2ecf20Sopenharmony_ci 0x4e, 0xd4, /* OVLY4=212 */ 1268c2ecf20Sopenharmony_ci 0x4f, 0x38, /* OVLU4=56 magenta */ 1278c2ecf20Sopenharmony_ci 0x50, 0x47, /* OVLV4=71 */ 1288c2ecf20Sopenharmony_ci 0x51, 0xc1, /* OVLY5=193 */ 1298c2ecf20Sopenharmony_ci 0x52, 0xe3, /* OVLU5=227 red */ 1308c2ecf20Sopenharmony_ci 0x53, 0x54, /* OVLV5=84 */ 1318c2ecf20Sopenharmony_ci 0x54, 0xa3, /* OVLY6=163 */ 1328c2ecf20Sopenharmony_ci 0x55, 0x54, /* OVLU6=84 blue */ 1338c2ecf20Sopenharmony_ci 0x56, 0xf2, /* OVLV6=242 */ 1348c2ecf20Sopenharmony_ci 0x57, 0x90, /* OVLY7=144 */ 1358c2ecf20Sopenharmony_ci 0x58, 0x00, /* OVLU7=0 black */ 1368c2ecf20Sopenharmony_ci 0x59, 0x00, /* OVLV7=0 */ 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci 0x5a, 0x00, /* CHPS=0 */ 1398c2ecf20Sopenharmony_ci 0x5b, 0x76, /* GAINU=118 */ 1408c2ecf20Sopenharmony_ci 0x5c, 0xa5, /* GAINV=165 */ 1418c2ecf20Sopenharmony_ci 0x5d, 0x3c, /* BLCKL=60 */ 1428c2ecf20Sopenharmony_ci 0x5e, 0x3a, /* BLNNL=58 */ 1438c2ecf20Sopenharmony_ci 0x5f, 0x3a, /* CCRS=0, BLNVB=58 */ 1448c2ecf20Sopenharmony_ci 0x60, 0x00, /* NULL */ 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci /* 0x61 - 0x66 set according to norm */ 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci 0x67, 0x00, /* 0 : caption 1st byte odd field */ 1498c2ecf20Sopenharmony_ci 0x68, 0x00, /* 0 : caption 2nd byte odd field */ 1508c2ecf20Sopenharmony_ci 0x69, 0x00, /* 0 : caption 1st byte even field */ 1518c2ecf20Sopenharmony_ci 0x6a, 0x00, /* 0 : caption 2nd byte even field */ 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci 0x6b, 0x91, /* MODIN=2, PCREF=0, SCCLN=17 */ 1548c2ecf20Sopenharmony_ci 0x6c, 0x20, /* SRCV1=0, TRCV2=1, ORCV1=0, PRCV1=0, 1558c2ecf20Sopenharmony_ci * CBLF=0, ORCV2=0, PRCV2=0 */ 1568c2ecf20Sopenharmony_ci 0x6d, 0x00, /* SRCM1=0, CCEN=0 */ 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci 0x6e, 0x0e, /* HTRIG=0x005, approx. centered, at 1598c2ecf20Sopenharmony_ci * least for PAL */ 1608c2ecf20Sopenharmony_ci 0x6f, 0x00, /* HTRIG upper bits */ 1618c2ecf20Sopenharmony_ci 0x70, 0x20, /* PHRES=0, SBLN=1, VTRIG=0 */ 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci /* The following should not be needed */ 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci 0x71, 0x15, /* BMRQ=0x115 */ 1668c2ecf20Sopenharmony_ci 0x72, 0x90, /* EMRQ=0x690 */ 1678c2ecf20Sopenharmony_ci 0x73, 0x61, /* EMRQ=0x690, BMRQ=0x115 */ 1688c2ecf20Sopenharmony_ci 0x74, 0x00, /* NULL */ 1698c2ecf20Sopenharmony_ci 0x75, 0x00, /* NULL */ 1708c2ecf20Sopenharmony_ci 0x76, 0x00, /* NULL */ 1718c2ecf20Sopenharmony_ci 0x77, 0x15, /* BRCV=0x115 */ 1728c2ecf20Sopenharmony_ci 0x78, 0x90, /* ERCV=0x690 */ 1738c2ecf20Sopenharmony_ci 0x79, 0x61, /* ERCV=0x690, BRCV=0x115 */ 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci /* Field length controls */ 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci 0x7a, 0x70, /* FLC=0 */ 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci /* The following should not be needed if SBLN = 1 */ 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci 0x7b, 0x16, /* FAL=22 */ 1828c2ecf20Sopenharmony_ci 0x7c, 0x35, /* LAL=244 */ 1838c2ecf20Sopenharmony_ci 0x7d, 0x20, /* LAL=244, FAL=22 */ 1848c2ecf20Sopenharmony_ci}; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_cistatic const unsigned char init_pal[] = { 1878c2ecf20Sopenharmony_ci 0x61, 0x1e, /* FISE=0, PAL=1, SCBW=1, RTCE=1, 1888c2ecf20Sopenharmony_ci * YGS=1, INPI=0, DOWN=0 */ 1898c2ecf20Sopenharmony_ci 0x62, 0xc8, /* DECTYP=1, BSTA=72 */ 1908c2ecf20Sopenharmony_ci 0x63, 0xcb, /* FSC0 */ 1918c2ecf20Sopenharmony_ci 0x64, 0x8a, /* FSC1 */ 1928c2ecf20Sopenharmony_ci 0x65, 0x09, /* FSC2 */ 1938c2ecf20Sopenharmony_ci 0x66, 0x2a, /* FSC3 */ 1948c2ecf20Sopenharmony_ci}; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_cistatic const unsigned char init_ntsc[] = { 1978c2ecf20Sopenharmony_ci 0x61, 0x1d, /* FISE=1, PAL=0, SCBW=1, RTCE=1, 1988c2ecf20Sopenharmony_ci * YGS=1, INPI=0, DOWN=0 */ 1998c2ecf20Sopenharmony_ci 0x62, 0xe6, /* DECTYP=1, BSTA=102 */ 2008c2ecf20Sopenharmony_ci 0x63, 0x1f, /* FSC0 */ 2018c2ecf20Sopenharmony_ci 0x64, 0x7c, /* FSC1 */ 2028c2ecf20Sopenharmony_ci 0x65, 0xf0, /* FSC2 */ 2038c2ecf20Sopenharmony_ci 0x66, 0x21, /* FSC3 */ 2048c2ecf20Sopenharmony_ci}; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_cistatic int saa7185_init(struct v4l2_subdev *sd, u32 val) 2088c2ecf20Sopenharmony_ci{ 2098c2ecf20Sopenharmony_ci struct saa7185 *encoder = to_saa7185(sd); 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci saa7185_write_block(sd, init_common, sizeof(init_common)); 2128c2ecf20Sopenharmony_ci if (encoder->norm & V4L2_STD_NTSC) 2138c2ecf20Sopenharmony_ci saa7185_write_block(sd, init_ntsc, sizeof(init_ntsc)); 2148c2ecf20Sopenharmony_ci else 2158c2ecf20Sopenharmony_ci saa7185_write_block(sd, init_pal, sizeof(init_pal)); 2168c2ecf20Sopenharmony_ci return 0; 2178c2ecf20Sopenharmony_ci} 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_cistatic int saa7185_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) 2208c2ecf20Sopenharmony_ci{ 2218c2ecf20Sopenharmony_ci struct saa7185 *encoder = to_saa7185(sd); 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci if (std & V4L2_STD_NTSC) 2248c2ecf20Sopenharmony_ci saa7185_write_block(sd, init_ntsc, sizeof(init_ntsc)); 2258c2ecf20Sopenharmony_ci else if (std & V4L2_STD_PAL) 2268c2ecf20Sopenharmony_ci saa7185_write_block(sd, init_pal, sizeof(init_pal)); 2278c2ecf20Sopenharmony_ci else 2288c2ecf20Sopenharmony_ci return -EINVAL; 2298c2ecf20Sopenharmony_ci encoder->norm = std; 2308c2ecf20Sopenharmony_ci return 0; 2318c2ecf20Sopenharmony_ci} 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_cistatic int saa7185_s_routing(struct v4l2_subdev *sd, 2348c2ecf20Sopenharmony_ci u32 input, u32 output, u32 config) 2358c2ecf20Sopenharmony_ci{ 2368c2ecf20Sopenharmony_ci struct saa7185 *encoder = to_saa7185(sd); 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci /* RJ: input = 0: input is from SA7111 2398c2ecf20Sopenharmony_ci input = 1: input is from ZR36060 */ 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci switch (input) { 2428c2ecf20Sopenharmony_ci case 0: 2438c2ecf20Sopenharmony_ci /* turn off colorbar */ 2448c2ecf20Sopenharmony_ci saa7185_write(sd, 0x3a, 0x0f); 2458c2ecf20Sopenharmony_ci /* Switch RTCE to 1 */ 2468c2ecf20Sopenharmony_ci saa7185_write(sd, 0x61, (encoder->reg[0x61] & 0xf7) | 0x08); 2478c2ecf20Sopenharmony_ci saa7185_write(sd, 0x6e, 0x01); 2488c2ecf20Sopenharmony_ci break; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci case 1: 2518c2ecf20Sopenharmony_ci /* turn off colorbar */ 2528c2ecf20Sopenharmony_ci saa7185_write(sd, 0x3a, 0x0f); 2538c2ecf20Sopenharmony_ci /* Switch RTCE to 0 */ 2548c2ecf20Sopenharmony_ci saa7185_write(sd, 0x61, (encoder->reg[0x61] & 0xf7) | 0x00); 2558c2ecf20Sopenharmony_ci /* SW: a slight sync problem... */ 2568c2ecf20Sopenharmony_ci saa7185_write(sd, 0x6e, 0x00); 2578c2ecf20Sopenharmony_ci break; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci case 2: 2608c2ecf20Sopenharmony_ci /* turn on colorbar */ 2618c2ecf20Sopenharmony_ci saa7185_write(sd, 0x3a, 0x8f); 2628c2ecf20Sopenharmony_ci /* Switch RTCE to 0 */ 2638c2ecf20Sopenharmony_ci saa7185_write(sd, 0x61, (encoder->reg[0x61] & 0xf7) | 0x08); 2648c2ecf20Sopenharmony_ci /* SW: a slight sync problem... */ 2658c2ecf20Sopenharmony_ci saa7185_write(sd, 0x6e, 0x01); 2668c2ecf20Sopenharmony_ci break; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci default: 2698c2ecf20Sopenharmony_ci return -EINVAL; 2708c2ecf20Sopenharmony_ci } 2718c2ecf20Sopenharmony_ci return 0; 2728c2ecf20Sopenharmony_ci} 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------- */ 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_core_ops saa7185_core_ops = { 2778c2ecf20Sopenharmony_ci .init = saa7185_init, 2788c2ecf20Sopenharmony_ci}; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_video_ops saa7185_video_ops = { 2818c2ecf20Sopenharmony_ci .s_std_output = saa7185_s_std_output, 2828c2ecf20Sopenharmony_ci .s_routing = saa7185_s_routing, 2838c2ecf20Sopenharmony_ci}; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_ops saa7185_ops = { 2868c2ecf20Sopenharmony_ci .core = &saa7185_core_ops, 2878c2ecf20Sopenharmony_ci .video = &saa7185_video_ops, 2888c2ecf20Sopenharmony_ci}; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------- */ 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_cistatic int saa7185_probe(struct i2c_client *client, 2948c2ecf20Sopenharmony_ci const struct i2c_device_id *id) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci int i; 2978c2ecf20Sopenharmony_ci struct saa7185 *encoder; 2988c2ecf20Sopenharmony_ci struct v4l2_subdev *sd; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci /* Check if the adapter supports the needed features */ 3018c2ecf20Sopenharmony_ci if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 3028c2ecf20Sopenharmony_ci return -ENODEV; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci v4l_info(client, "chip found @ 0x%x (%s)\n", 3058c2ecf20Sopenharmony_ci client->addr << 1, client->adapter->name); 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); 3088c2ecf20Sopenharmony_ci if (encoder == NULL) 3098c2ecf20Sopenharmony_ci return -ENOMEM; 3108c2ecf20Sopenharmony_ci encoder->norm = V4L2_STD_NTSC; 3118c2ecf20Sopenharmony_ci sd = &encoder->sd; 3128c2ecf20Sopenharmony_ci v4l2_i2c_subdev_init(sd, client, &saa7185_ops); 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci i = saa7185_write_block(sd, init_common, sizeof(init_common)); 3158c2ecf20Sopenharmony_ci if (i >= 0) 3168c2ecf20Sopenharmony_ci i = saa7185_write_block(sd, init_ntsc, sizeof(init_ntsc)); 3178c2ecf20Sopenharmony_ci if (i < 0) 3188c2ecf20Sopenharmony_ci v4l2_dbg(1, debug, sd, "init error %d\n", i); 3198c2ecf20Sopenharmony_ci else 3208c2ecf20Sopenharmony_ci v4l2_dbg(1, debug, sd, "revision 0x%x\n", 3218c2ecf20Sopenharmony_ci saa7185_read(sd) >> 5); 3228c2ecf20Sopenharmony_ci return 0; 3238c2ecf20Sopenharmony_ci} 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_cistatic int saa7185_remove(struct i2c_client *client) 3268c2ecf20Sopenharmony_ci{ 3278c2ecf20Sopenharmony_ci struct v4l2_subdev *sd = i2c_get_clientdata(client); 3288c2ecf20Sopenharmony_ci struct saa7185 *encoder = to_saa7185(sd); 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci v4l2_device_unregister_subdev(sd); 3318c2ecf20Sopenharmony_ci /* SW: output off is active */ 3328c2ecf20Sopenharmony_ci saa7185_write(sd, 0x61, (encoder->reg[0x61]) | 0x40); 3338c2ecf20Sopenharmony_ci return 0; 3348c2ecf20Sopenharmony_ci} 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------- */ 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_cistatic const struct i2c_device_id saa7185_id[] = { 3398c2ecf20Sopenharmony_ci { "saa7185", 0 }, 3408c2ecf20Sopenharmony_ci { } 3418c2ecf20Sopenharmony_ci}; 3428c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, saa7185_id); 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_cistatic struct i2c_driver saa7185_driver = { 3458c2ecf20Sopenharmony_ci .driver = { 3468c2ecf20Sopenharmony_ci .name = "saa7185", 3478c2ecf20Sopenharmony_ci }, 3488c2ecf20Sopenharmony_ci .probe = saa7185_probe, 3498c2ecf20Sopenharmony_ci .remove = saa7185_remove, 3508c2ecf20Sopenharmony_ci .id_table = saa7185_id, 3518c2ecf20Sopenharmony_ci}; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_cimodule_i2c_driver(saa7185_driver); 354