blob: e4e8fda51ad8a015a0e7ff2922404eb1071aee03 [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -03002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * adv7170 - adv7170, adv7171 video encoder driver version 0.0.1
4 *
5 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
6 *
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -03007 * Based on adv7176 driver by:
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
10 * Copyright (C) 1999 Wolfgang Scherr <scherr@net4you.net>
11 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
12 * - some corrections for Pinnacle Systems Inc. DC10plus card.
13 *
14 * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net>
15 * - moved over to linux>=2.4.x i2c protocol (1/1/2003)
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17
18#include <linux/module.h>
Mauro Carvalho Chehab18f3fa12007-07-02 15:39:57 -030019#include <linux/types.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090020#include <linux/slab.h>
Hans Verkuilb9a21f82008-09-07 07:58:20 -030021#include <linux/ioctl.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080022#include <linux/uaccess.h>
Hans Verkuilb9a21f82008-09-07 07:58:20 -030023#include <linux/i2c.h>
Hans Verkuil7d9ef212009-02-19 14:47:22 -030024#include <linux/videodev2.h>
25#include <media/v4l2-device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver");
28MODULE_AUTHOR("Maxim Yevtyushkin");
29MODULE_LICENSE("GPL");
30
Hans Verkuil7d9ef212009-02-19 14:47:22 -030031
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030032static int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033module_param(debug, int, 0);
34MODULE_PARM_DESC(debug, "Debug level (0-1)");
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/* ----------------------------------------------------------------------- */
37
38struct adv7170 {
Hans Verkuil7d9ef212009-02-19 14:47:22 -030039 struct v4l2_subdev sd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 unsigned char reg[128];
41
Hans Verkuil107063c2009-02-18 17:26:06 -030042 v4l2_std_id norm;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 int input;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044};
45
Hans Verkuil7d9ef212009-02-19 14:47:22 -030046static inline struct adv7170 *to_adv7170(struct v4l2_subdev *sd)
47{
48 return container_of(sd, struct adv7170, sd);
49}
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051static char *inputs[] = { "pass_through", "play_back" };
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -030053static u32 adv7170_codes[] = {
54 MEDIA_BUS_FMT_UYVY8_2X8,
55 MEDIA_BUS_FMT_UYVY8_1X16,
Christian Gmeiner0d37d352011-10-27 18:50:21 -030056};
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/* ----------------------------------------------------------------------- */
59
Hans Verkuil7d9ef212009-02-19 14:47:22 -030060static inline int adv7170_write(struct v4l2_subdev *sd, u8 reg, u8 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
Hans Verkuil7d9ef212009-02-19 14:47:22 -030062 struct i2c_client *client = v4l2_get_subdevdata(sd);
63 struct adv7170 *encoder = to_adv7170(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65 encoder->reg[reg] = value;
66 return i2c_smbus_write_byte_data(client, reg, value);
67}
68
Hans Verkuil7d9ef212009-02-19 14:47:22 -030069static inline int adv7170_read(struct v4l2_subdev *sd, u8 reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070{
Hans Verkuil7d9ef212009-02-19 14:47:22 -030071 struct i2c_client *client = v4l2_get_subdevdata(sd);
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 return i2c_smbus_read_byte_data(client, reg);
74}
75
Hans Verkuil7d9ef212009-02-19 14:47:22 -030076static int adv7170_write_block(struct v4l2_subdev *sd,
Hans Verkuilb9a21f82008-09-07 07:58:20 -030077 const u8 *data, unsigned int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Hans Verkuil7d9ef212009-02-19 14:47:22 -030079 struct i2c_client *client = v4l2_get_subdevdata(sd);
80 struct adv7170 *encoder = to_adv7170(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 int ret = -1;
82 u8 reg;
83
84 /* the adv7170 has an autoincrement function, use it if
85 * the adapter understands raw I2C */
86 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
87 /* do raw I2C, not smbus compatible */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 u8 block_data[32];
Jean Delvare9aa45e32006-03-22 03:48:35 -030089 int block_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 while (len >= 2) {
Jean Delvare9aa45e32006-03-22 03:48:35 -030092 block_len = 0;
93 block_data[block_len++] = reg = data[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 do {
Jean Delvare9aa45e32006-03-22 03:48:35 -030095 block_data[block_len++] =
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 encoder->reg[reg++] = data[1];
97 len -= 2;
98 data += 2;
Hans Verkuilb9a21f82008-09-07 07:58:20 -030099 } while (len >= 2 && data[0] == reg && block_len < 32);
100 ret = i2c_master_send(client, block_data, block_len);
101 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 break;
103 }
104 } else {
105 /* do some slow I2C emulation kind of thing */
106 while (len >= 2) {
107 reg = *data++;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300108 ret = adv7170_write(sd, reg, *data++);
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300109 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 break;
111 len -= 2;
112 }
113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 return ret;
115}
116
117/* ----------------------------------------------------------------------- */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119#define TR0MODE 0x4c
120#define TR0RST 0x80
121
122#define TR1CAPT 0x00
123#define TR1PLAY 0x00
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125static const unsigned char init_NTSC[] = {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300126 0x00, 0x10, /* MR0 */
127 0x01, 0x20, /* MR1 */
128 0x02, 0x0e, /* MR2 RTC control: bits 2 and 1 */
129 0x03, 0x80, /* MR3 */
130 0x04, 0x30, /* MR4 */
131 0x05, 0x00, /* Reserved */
132 0x06, 0x00, /* Reserved */
133 0x07, TR0MODE, /* TM0 */
134 0x08, TR1CAPT, /* TM1 */
135 0x09, 0x16, /* Fsc0 */
136 0x0a, 0x7c, /* Fsc1 */
137 0x0b, 0xf0, /* Fsc2 */
138 0x0c, 0x21, /* Fsc3 */
139 0x0d, 0x00, /* Subcarrier Phase */
140 0x0e, 0x00, /* Closed Capt. Ext 0 */
141 0x0f, 0x00, /* Closed Capt. Ext 1 */
142 0x10, 0x00, /* Closed Capt. 0 */
143 0x11, 0x00, /* Closed Capt. 1 */
144 0x12, 0x00, /* Pedestal Ctl 0 */
145 0x13, 0x00, /* Pedestal Ctl 1 */
146 0x14, 0x00, /* Pedestal Ctl 2 */
147 0x15, 0x00, /* Pedestal Ctl 3 */
148 0x16, 0x00, /* CGMS_WSS_0 */
149 0x17, 0x00, /* CGMS_WSS_1 */
150 0x18, 0x00, /* CGMS_WSS_2 */
151 0x19, 0x00, /* Teletext Ctl */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152};
153
154static const unsigned char init_PAL[] = {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300155 0x00, 0x71, /* MR0 */
156 0x01, 0x20, /* MR1 */
157 0x02, 0x0e, /* MR2 RTC control: bits 2 and 1 */
158 0x03, 0x80, /* MR3 */
159 0x04, 0x30, /* MR4 */
160 0x05, 0x00, /* Reserved */
161 0x06, 0x00, /* Reserved */
162 0x07, TR0MODE, /* TM0 */
163 0x08, TR1CAPT, /* TM1 */
164 0x09, 0xcb, /* Fsc0 */
165 0x0a, 0x8a, /* Fsc1 */
166 0x0b, 0x09, /* Fsc2 */
167 0x0c, 0x2a, /* Fsc3 */
168 0x0d, 0x00, /* Subcarrier Phase */
169 0x0e, 0x00, /* Closed Capt. Ext 0 */
170 0x0f, 0x00, /* Closed Capt. Ext 1 */
171 0x10, 0x00, /* Closed Capt. 0 */
172 0x11, 0x00, /* Closed Capt. 1 */
173 0x12, 0x00, /* Pedestal Ctl 0 */
174 0x13, 0x00, /* Pedestal Ctl 1 */
175 0x14, 0x00, /* Pedestal Ctl 2 */
176 0x15, 0x00, /* Pedestal Ctl 3 */
177 0x16, 0x00, /* CGMS_WSS_0 */
178 0x17, 0x00, /* CGMS_WSS_1 */
179 0x18, 0x00, /* CGMS_WSS_2 */
180 0x19, 0x00, /* Teletext Ctl */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181};
182
183
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300184static int adv7170_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300186 struct adv7170 *encoder = to_adv7170(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Hans Verkuilcc5cef82009-03-06 10:15:01 -0300188 v4l2_dbg(1, debug, sd, "set norm %llx\n", (unsigned long long)std);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300190 if (std & V4L2_STD_NTSC) {
191 adv7170_write_block(sd, init_NTSC, sizeof(init_NTSC));
192 if (encoder->input == 0)
193 adv7170_write(sd, 0x02, 0x0e); /* Enable genlock */
194 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
195 adv7170_write(sd, 0x07, TR0MODE);
196 } else if (std & V4L2_STD_PAL) {
197 adv7170_write_block(sd, init_PAL, sizeof(init_PAL));
198 if (encoder->input == 0)
199 adv7170_write(sd, 0x02, 0x0e); /* Enable genlock */
200 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
201 adv7170_write(sd, 0x07, TR0MODE);
202 } else {
Hans Verkuilcc5cef82009-03-06 10:15:01 -0300203 v4l2_dbg(1, debug, sd, "illegal norm: %llx\n",
204 (unsigned long long)std);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 return -EINVAL;
206 }
Hans Verkuilcc5cef82009-03-06 10:15:01 -0300207 v4l2_dbg(1, debug, sd, "switched to %llx\n", (unsigned long long)std);
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300208 encoder->norm = std;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 return 0;
210}
211
Hans Verkuil5325b422009-04-02 11:26:22 -0300212static int adv7170_s_routing(struct v4l2_subdev *sd,
213 u32 input, u32 output, u32 config)
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300214{
215 struct adv7170 *encoder = to_adv7170(sd);
216
Hans Verkuil5325b422009-04-02 11:26:22 -0300217 /* RJ: input = 0: input is from decoder
218 input = 1: input is from ZR36060
219 input = 2: color bar */
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300220
221 v4l2_dbg(1, debug, sd, "set input from %s\n",
Hans Verkuil5325b422009-04-02 11:26:22 -0300222 input == 0 ? "decoder" : "ZR36060");
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300223
Hans Verkuil5325b422009-04-02 11:26:22 -0300224 switch (input) {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300225 case 0:
226 adv7170_write(sd, 0x01, 0x20);
227 adv7170_write(sd, 0x08, TR1CAPT); /* TR1 */
228 adv7170_write(sd, 0x02, 0x0e); /* Enable genlock */
229 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
230 adv7170_write(sd, 0x07, TR0MODE);
231 /* udelay(10); */
232 break;
233
234 case 1:
235 adv7170_write(sd, 0x01, 0x00);
236 adv7170_write(sd, 0x08, TR1PLAY); /* TR1 */
237 adv7170_write(sd, 0x02, 0x08);
238 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
239 adv7170_write(sd, 0x07, TR0MODE);
240 /* udelay(10); */
241 break;
242
243 default:
Hans Verkuil5325b422009-04-02 11:26:22 -0300244 v4l2_dbg(1, debug, sd, "illegal input: %d\n", input);
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300245 return -EINVAL;
246 }
Hans Verkuil5325b422009-04-02 11:26:22 -0300247 v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[input]);
248 encoder->input = input;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300249 return 0;
250}
251
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300252static int adv7170_enum_mbus_code(struct v4l2_subdev *sd,
253 struct v4l2_subdev_pad_config *cfg,
254 struct v4l2_subdev_mbus_code_enum *code)
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300255{
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300256 if (code->pad || code->index >= ARRAY_SIZE(adv7170_codes))
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300257 return -EINVAL;
258
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300259 code->code = adv7170_codes[code->index];
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300260 return 0;
261}
262
Hans Verkuilda298c62015-04-09 04:02:34 -0300263static int adv7170_get_fmt(struct v4l2_subdev *sd,
264 struct v4l2_subdev_pad_config *cfg,
265 struct v4l2_subdev_format *format)
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300266{
Hans Verkuilda298c62015-04-09 04:02:34 -0300267 struct v4l2_mbus_framefmt *mf = &format->format;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300268 u8 val = adv7170_read(sd, 0x7);
269
Hans Verkuilda298c62015-04-09 04:02:34 -0300270 if (format->pad)
271 return -EINVAL;
272
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300273 if ((val & 0x40) == (1 << 6))
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300274 mf->code = MEDIA_BUS_FMT_UYVY8_1X16;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300275 else
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300276 mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300277
278 mf->colorspace = V4L2_COLORSPACE_SMPTE170M;
279 mf->width = 0;
280 mf->height = 0;
281 mf->field = V4L2_FIELD_ANY;
282
283 return 0;
284}
285
Hans Verkuil6e80c472015-03-21 09:39:09 -0300286static int adv7170_set_fmt(struct v4l2_subdev *sd,
287 struct v4l2_subdev_pad_config *cfg,
288 struct v4l2_subdev_format *format)
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300289{
Hans Verkuil6e80c472015-03-21 09:39:09 -0300290 struct v4l2_mbus_framefmt *mf = &format->format;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300291 u8 val = adv7170_read(sd, 0x7);
Hans Verkuil6e80c472015-03-21 09:39:09 -0300292
293 if (format->pad)
294 return -EINVAL;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300295
296 switch (mf->code) {
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300297 case MEDIA_BUS_FMT_UYVY8_2X8:
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300298 val &= ~0x40;
299 break;
300
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300301 case MEDIA_BUS_FMT_UYVY8_1X16:
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300302 val |= 0x40;
303 break;
304
305 default:
306 v4l2_dbg(1, debug, sd,
307 "illegal v4l2_mbus_framefmt code: %d\n", mf->code);
308 return -EINVAL;
309 }
310
Hans Verkuil6e80c472015-03-21 09:39:09 -0300311 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
Baruch Siach5f98e5f2017-01-03 18:22:43 -0200312 return adv7170_write(sd, 0x7, val);
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300313
Baruch Siach5f98e5f2017-01-03 18:22:43 -0200314 return 0;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300315}
316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317/* ----------------------------------------------------------------------- */
318
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300319static const struct v4l2_subdev_video_ops adv7170_video_ops = {
320 .s_std_output = adv7170_s_std_output,
321 .s_routing = adv7170_s_routing,
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300322};
323
324static const struct v4l2_subdev_pad_ops adv7170_pad_ops = {
325 .enum_mbus_code = adv7170_enum_mbus_code,
Hans Verkuilda298c62015-04-09 04:02:34 -0300326 .get_fmt = adv7170_get_fmt,
Hans Verkuil6e80c472015-03-21 09:39:09 -0300327 .set_fmt = adv7170_set_fmt,
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300328};
329
330static const struct v4l2_subdev_ops adv7170_ops = {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300331 .video = &adv7170_video_ops,
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300332 .pad = &adv7170_pad_ops,
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300333};
334
335/* ----------------------------------------------------------------------- */
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -0300336
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300337static int adv7170_probe(struct i2c_client *client,
338 const struct i2c_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 struct adv7170 *encoder;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300341 struct v4l2_subdev *sd;
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300342 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
344 /* Check if the adapter supports the needed features */
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300345 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
346 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300348 v4l_info(client, "chip found @ 0x%x (%s)\n",
349 client->addr << 1, client->adapter->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
Laurent Pinchartc02b2112013-05-02 08:29:43 -0300351 encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL);
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300352 if (encoder == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 return -ENOMEM;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300354 sd = &encoder->sd;
355 v4l2_i2c_subdev_init(sd, client, &adv7170_ops);
Hans Verkuil107063c2009-02-18 17:26:06 -0300356 encoder->norm = V4L2_STD_NTSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 encoder->input = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300359 i = adv7170_write_block(sd, init_NTSC, sizeof(init_NTSC));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 if (i >= 0) {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300361 i = adv7170_write(sd, 0x07, TR0MODE | TR0RST);
362 i = adv7170_write(sd, 0x07, TR0MODE);
363 i = adv7170_read(sd, 0x12);
364 v4l2_dbg(1, debug, sd, "revision %d\n", i & 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 }
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300366 if (i < 0)
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300367 v4l2_dbg(1, debug, sd, "init error 0x%x\n", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 return 0;
369}
370
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300371static int adv7170_remove(struct i2c_client *client)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372{
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300373 struct v4l2_subdev *sd = i2c_get_clientdata(client);
374
375 v4l2_device_unregister_subdev(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 return 0;
377}
378
379/* ----------------------------------------------------------------------- */
380
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300381static const struct i2c_device_id adv7170_id[] = {
382 { "adv7170", 0 },
383 { "adv7171", 0 },
384 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385};
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300386MODULE_DEVICE_TABLE(i2c, adv7170_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
Hans Verkuilc9611802010-09-15 15:49:56 -0300388static struct i2c_driver adv7170_driver = {
389 .driver = {
Hans Verkuilc9611802010-09-15 15:49:56 -0300390 .name = "adv7170",
391 },
392 .probe = adv7170_probe,
393 .remove = adv7170_remove,
394 .id_table = adv7170_id,
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300395};
Hans Verkuilc9611802010-09-15 15:49:56 -0300396
Axel Linc6e8d862012-02-12 06:56:32 -0300397module_i2c_driver(adv7170_driver);