blob: 73933147342947387555c8eb35951262f6c7bc07 [file] [log] [blame]
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -03001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * adv7170 - adv7170, adv7171 video encoder driver version 0.0.1
3 *
4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
5 *
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -03006 * Based on adv7176 driver by:
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
9 * Copyright (C) 1999 Wolfgang Scherr <scherr@net4you.net>
10 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
11 * - some corrections for Pinnacle Systems Inc. DC10plus card.
12 *
13 * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net>
14 * - moved over to linux>=2.4.x i2c protocol (1/1/2003)
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 */
26
27#include <linux/module.h>
Mauro Carvalho Chehab18f3fa12007-07-02 15:39:57 -030028#include <linux/types.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Hans Verkuilb9a21f82008-09-07 07:58:20 -030030#include <linux/ioctl.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080031#include <linux/uaccess.h>
Hans Verkuilb9a21f82008-09-07 07:58:20 -030032#include <linux/i2c.h>
Hans Verkuil7d9ef212009-02-19 14:47:22 -030033#include <linux/videodev2.h>
34#include <media/v4l2-device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver");
37MODULE_AUTHOR("Maxim Yevtyushkin");
38MODULE_LICENSE("GPL");
39
Hans Verkuil7d9ef212009-02-19 14:47:22 -030040
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030041static int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042module_param(debug, int, 0);
43MODULE_PARM_DESC(debug, "Debug level (0-1)");
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045/* ----------------------------------------------------------------------- */
46
47struct adv7170 {
Hans Verkuil7d9ef212009-02-19 14:47:22 -030048 struct v4l2_subdev sd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 unsigned char reg[128];
50
Hans Verkuil107063c2009-02-18 17:26:06 -030051 v4l2_std_id norm;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 int input;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053};
54
Hans Verkuil7d9ef212009-02-19 14:47:22 -030055static inline struct adv7170 *to_adv7170(struct v4l2_subdev *sd)
56{
57 return container_of(sd, struct adv7170, sd);
58}
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static char *inputs[] = { "pass_through", "play_back" };
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -030062static u32 adv7170_codes[] = {
63 MEDIA_BUS_FMT_UYVY8_2X8,
64 MEDIA_BUS_FMT_UYVY8_1X16,
Christian Gmeiner0d37d352011-10-27 18:50:21 -030065};
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/* ----------------------------------------------------------------------- */
68
Hans Verkuil7d9ef212009-02-19 14:47:22 -030069static inline int adv7170_write(struct v4l2_subdev *sd, u8 reg, u8 value)
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 struct adv7170 *encoder = to_adv7170(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74 encoder->reg[reg] = value;
75 return i2c_smbus_write_byte_data(client, reg, value);
76}
77
Hans Verkuil7d9ef212009-02-19 14:47:22 -030078static inline int adv7170_read(struct v4l2_subdev *sd, u8 reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
Hans Verkuil7d9ef212009-02-19 14:47:22 -030080 struct i2c_client *client = v4l2_get_subdevdata(sd);
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 return i2c_smbus_read_byte_data(client, reg);
83}
84
Hans Verkuil7d9ef212009-02-19 14:47:22 -030085static int adv7170_write_block(struct v4l2_subdev *sd,
Hans Verkuilb9a21f82008-09-07 07:58:20 -030086 const u8 *data, unsigned int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
Hans Verkuil7d9ef212009-02-19 14:47:22 -030088 struct i2c_client *client = v4l2_get_subdevdata(sd);
89 struct adv7170 *encoder = to_adv7170(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 int ret = -1;
91 u8 reg;
92
93 /* the adv7170 has an autoincrement function, use it if
94 * the adapter understands raw I2C */
95 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
96 /* do raw I2C, not smbus compatible */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 u8 block_data[32];
Jean Delvare9aa45e32006-03-22 03:48:35 -030098 int block_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 while (len >= 2) {
Jean Delvare9aa45e32006-03-22 03:48:35 -0300101 block_len = 0;
102 block_data[block_len++] = reg = data[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 do {
Jean Delvare9aa45e32006-03-22 03:48:35 -0300104 block_data[block_len++] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 encoder->reg[reg++] = data[1];
106 len -= 2;
107 data += 2;
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300108 } while (len >= 2 && data[0] == reg && block_len < 32);
109 ret = i2c_master_send(client, block_data, block_len);
110 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 break;
112 }
113 } else {
114 /* do some slow I2C emulation kind of thing */
115 while (len >= 2) {
116 reg = *data++;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300117 ret = adv7170_write(sd, reg, *data++);
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300118 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 break;
120 len -= 2;
121 }
122 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 return ret;
124}
125
126/* ----------------------------------------------------------------------- */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128#define TR0MODE 0x4c
129#define TR0RST 0x80
130
131#define TR1CAPT 0x00
132#define TR1PLAY 0x00
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134static const unsigned char init_NTSC[] = {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300135 0x00, 0x10, /* MR0 */
136 0x01, 0x20, /* MR1 */
137 0x02, 0x0e, /* MR2 RTC control: bits 2 and 1 */
138 0x03, 0x80, /* MR3 */
139 0x04, 0x30, /* MR4 */
140 0x05, 0x00, /* Reserved */
141 0x06, 0x00, /* Reserved */
142 0x07, TR0MODE, /* TM0 */
143 0x08, TR1CAPT, /* TM1 */
144 0x09, 0x16, /* Fsc0 */
145 0x0a, 0x7c, /* Fsc1 */
146 0x0b, 0xf0, /* Fsc2 */
147 0x0c, 0x21, /* Fsc3 */
148 0x0d, 0x00, /* Subcarrier Phase */
149 0x0e, 0x00, /* Closed Capt. Ext 0 */
150 0x0f, 0x00, /* Closed Capt. Ext 1 */
151 0x10, 0x00, /* Closed Capt. 0 */
152 0x11, 0x00, /* Closed Capt. 1 */
153 0x12, 0x00, /* Pedestal Ctl 0 */
154 0x13, 0x00, /* Pedestal Ctl 1 */
155 0x14, 0x00, /* Pedestal Ctl 2 */
156 0x15, 0x00, /* Pedestal Ctl 3 */
157 0x16, 0x00, /* CGMS_WSS_0 */
158 0x17, 0x00, /* CGMS_WSS_1 */
159 0x18, 0x00, /* CGMS_WSS_2 */
160 0x19, 0x00, /* Teletext Ctl */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161};
162
163static const unsigned char init_PAL[] = {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300164 0x00, 0x71, /* MR0 */
165 0x01, 0x20, /* MR1 */
166 0x02, 0x0e, /* MR2 RTC control: bits 2 and 1 */
167 0x03, 0x80, /* MR3 */
168 0x04, 0x30, /* MR4 */
169 0x05, 0x00, /* Reserved */
170 0x06, 0x00, /* Reserved */
171 0x07, TR0MODE, /* TM0 */
172 0x08, TR1CAPT, /* TM1 */
173 0x09, 0xcb, /* Fsc0 */
174 0x0a, 0x8a, /* Fsc1 */
175 0x0b, 0x09, /* Fsc2 */
176 0x0c, 0x2a, /* Fsc3 */
177 0x0d, 0x00, /* Subcarrier Phase */
178 0x0e, 0x00, /* Closed Capt. Ext 0 */
179 0x0f, 0x00, /* Closed Capt. Ext 1 */
180 0x10, 0x00, /* Closed Capt. 0 */
181 0x11, 0x00, /* Closed Capt. 1 */
182 0x12, 0x00, /* Pedestal Ctl 0 */
183 0x13, 0x00, /* Pedestal Ctl 1 */
184 0x14, 0x00, /* Pedestal Ctl 2 */
185 0x15, 0x00, /* Pedestal Ctl 3 */
186 0x16, 0x00, /* CGMS_WSS_0 */
187 0x17, 0x00, /* CGMS_WSS_1 */
188 0x18, 0x00, /* CGMS_WSS_2 */
189 0x19, 0x00, /* Teletext Ctl */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190};
191
192
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300193static int adv7170_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194{
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300195 struct adv7170 *encoder = to_adv7170(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Hans Verkuilcc5cef82009-03-06 10:15:01 -0300197 v4l2_dbg(1, debug, sd, "set norm %llx\n", (unsigned long long)std);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300199 if (std & V4L2_STD_NTSC) {
200 adv7170_write_block(sd, init_NTSC, sizeof(init_NTSC));
201 if (encoder->input == 0)
202 adv7170_write(sd, 0x02, 0x0e); /* Enable genlock */
203 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
204 adv7170_write(sd, 0x07, TR0MODE);
205 } else if (std & V4L2_STD_PAL) {
206 adv7170_write_block(sd, init_PAL, sizeof(init_PAL));
207 if (encoder->input == 0)
208 adv7170_write(sd, 0x02, 0x0e); /* Enable genlock */
209 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
210 adv7170_write(sd, 0x07, TR0MODE);
211 } else {
Hans Verkuilcc5cef82009-03-06 10:15:01 -0300212 v4l2_dbg(1, debug, sd, "illegal norm: %llx\n",
213 (unsigned long long)std);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 return -EINVAL;
215 }
Hans Verkuilcc5cef82009-03-06 10:15:01 -0300216 v4l2_dbg(1, debug, sd, "switched to %llx\n", (unsigned long long)std);
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300217 encoder->norm = std;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 return 0;
219}
220
Hans Verkuil5325b422009-04-02 11:26:22 -0300221static int adv7170_s_routing(struct v4l2_subdev *sd,
222 u32 input, u32 output, u32 config)
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300223{
224 struct adv7170 *encoder = to_adv7170(sd);
225
Hans Verkuil5325b422009-04-02 11:26:22 -0300226 /* RJ: input = 0: input is from decoder
227 input = 1: input is from ZR36060
228 input = 2: color bar */
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300229
230 v4l2_dbg(1, debug, sd, "set input from %s\n",
Hans Verkuil5325b422009-04-02 11:26:22 -0300231 input == 0 ? "decoder" : "ZR36060");
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300232
Hans Verkuil5325b422009-04-02 11:26:22 -0300233 switch (input) {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300234 case 0:
235 adv7170_write(sd, 0x01, 0x20);
236 adv7170_write(sd, 0x08, TR1CAPT); /* TR1 */
237 adv7170_write(sd, 0x02, 0x0e); /* Enable genlock */
238 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
239 adv7170_write(sd, 0x07, TR0MODE);
240 /* udelay(10); */
241 break;
242
243 case 1:
244 adv7170_write(sd, 0x01, 0x00);
245 adv7170_write(sd, 0x08, TR1PLAY); /* TR1 */
246 adv7170_write(sd, 0x02, 0x08);
247 adv7170_write(sd, 0x07, TR0MODE | TR0RST);
248 adv7170_write(sd, 0x07, TR0MODE);
249 /* udelay(10); */
250 break;
251
252 default:
Hans Verkuil5325b422009-04-02 11:26:22 -0300253 v4l2_dbg(1, debug, sd, "illegal input: %d\n", input);
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300254 return -EINVAL;
255 }
Hans Verkuil5325b422009-04-02 11:26:22 -0300256 v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[input]);
257 encoder->input = input;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300258 return 0;
259}
260
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300261static int adv7170_enum_mbus_code(struct v4l2_subdev *sd,
262 struct v4l2_subdev_pad_config *cfg,
263 struct v4l2_subdev_mbus_code_enum *code)
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300264{
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300265 if (code->pad || code->index >= ARRAY_SIZE(adv7170_codes))
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300266 return -EINVAL;
267
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300268 code->code = adv7170_codes[code->index];
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300269 return 0;
270}
271
Hans Verkuilda298c62015-04-09 04:02:34 -0300272static int adv7170_get_fmt(struct v4l2_subdev *sd,
273 struct v4l2_subdev_pad_config *cfg,
274 struct v4l2_subdev_format *format)
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300275{
Hans Verkuilda298c62015-04-09 04:02:34 -0300276 struct v4l2_mbus_framefmt *mf = &format->format;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300277 u8 val = adv7170_read(sd, 0x7);
278
Hans Verkuilda298c62015-04-09 04:02:34 -0300279 if (format->pad)
280 return -EINVAL;
281
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300282 if ((val & 0x40) == (1 << 6))
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300283 mf->code = MEDIA_BUS_FMT_UYVY8_1X16;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300284 else
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300285 mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300286
287 mf->colorspace = V4L2_COLORSPACE_SMPTE170M;
288 mf->width = 0;
289 mf->height = 0;
290 mf->field = V4L2_FIELD_ANY;
291
292 return 0;
293}
294
Hans Verkuil6e80c472015-03-21 09:39:09 -0300295static int adv7170_set_fmt(struct v4l2_subdev *sd,
296 struct v4l2_subdev_pad_config *cfg,
297 struct v4l2_subdev_format *format)
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300298{
Hans Verkuil6e80c472015-03-21 09:39:09 -0300299 struct v4l2_mbus_framefmt *mf = &format->format;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300300 u8 val = adv7170_read(sd, 0x7);
Hans Verkuil6e80c472015-03-21 09:39:09 -0300301
302 if (format->pad)
303 return -EINVAL;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300304
305 switch (mf->code) {
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300306 case MEDIA_BUS_FMT_UYVY8_2X8:
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300307 val &= ~0x40;
308 break;
309
Boris BREZILLONf5fe58f2014-11-10 14:28:29 -0300310 case MEDIA_BUS_FMT_UYVY8_1X16:
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300311 val |= 0x40;
312 break;
313
314 default:
315 v4l2_dbg(1, debug, sd,
316 "illegal v4l2_mbus_framefmt code: %d\n", mf->code);
317 return -EINVAL;
318 }
319
Hans Verkuil6e80c472015-03-21 09:39:09 -0300320 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
Baruch Siach5f98e5f2017-01-03 18:22:43 -0200321 return adv7170_write(sd, 0x7, val);
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300322
Baruch Siach5f98e5f2017-01-03 18:22:43 -0200323 return 0;
Christian Gmeiner0d37d352011-10-27 18:50:21 -0300324}
325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326/* ----------------------------------------------------------------------- */
327
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300328static const struct v4l2_subdev_video_ops adv7170_video_ops = {
329 .s_std_output = adv7170_s_std_output,
330 .s_routing = adv7170_s_routing,
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300331};
332
333static const struct v4l2_subdev_pad_ops adv7170_pad_ops = {
334 .enum_mbus_code = adv7170_enum_mbus_code,
Hans Verkuilda298c62015-04-09 04:02:34 -0300335 .get_fmt = adv7170_get_fmt,
Hans Verkuil6e80c472015-03-21 09:39:09 -0300336 .set_fmt = adv7170_set_fmt,
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300337};
338
339static const struct v4l2_subdev_ops adv7170_ops = {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300340 .video = &adv7170_video_ops,
Hans Verkuilebcff5f2015-04-09 04:01:33 -0300341 .pad = &adv7170_pad_ops,
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300342};
343
344/* ----------------------------------------------------------------------- */
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -0300345
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300346static int adv7170_probe(struct i2c_client *client,
347 const struct i2c_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 struct adv7170 *encoder;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300350 struct v4l2_subdev *sd;
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300351 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /* Check if the adapter supports the needed features */
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300354 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
355 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300357 v4l_info(client, "chip found @ 0x%x (%s)\n",
358 client->addr << 1, client->adapter->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
Laurent Pinchartc02b2112013-05-02 08:29:43 -0300360 encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL);
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300361 if (encoder == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 return -ENOMEM;
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300363 sd = &encoder->sd;
364 v4l2_i2c_subdev_init(sd, client, &adv7170_ops);
Hans Verkuil107063c2009-02-18 17:26:06 -0300365 encoder->norm = V4L2_STD_NTSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 encoder->input = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300368 i = adv7170_write_block(sd, init_NTSC, sizeof(init_NTSC));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 if (i >= 0) {
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300370 i = adv7170_write(sd, 0x07, TR0MODE | TR0RST);
371 i = adv7170_write(sd, 0x07, TR0MODE);
372 i = adv7170_read(sd, 0x12);
373 v4l2_dbg(1, debug, sd, "revision %d\n", i & 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 }
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300375 if (i < 0)
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300376 v4l2_dbg(1, debug, sd, "init error 0x%x\n", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 return 0;
378}
379
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300380static int adv7170_remove(struct i2c_client *client)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381{
Hans Verkuil7d9ef212009-02-19 14:47:22 -0300382 struct v4l2_subdev *sd = i2c_get_clientdata(client);
383
384 v4l2_device_unregister_subdev(sd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 return 0;
386}
387
388/* ----------------------------------------------------------------------- */
389
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300390static const struct i2c_device_id adv7170_id[] = {
391 { "adv7170", 0 },
392 { "adv7171", 0 },
393 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394};
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300395MODULE_DEVICE_TABLE(i2c, adv7170_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
Hans Verkuilc9611802010-09-15 15:49:56 -0300397static struct i2c_driver adv7170_driver = {
398 .driver = {
Hans Verkuilc9611802010-09-15 15:49:56 -0300399 .name = "adv7170",
400 },
401 .probe = adv7170_probe,
402 .remove = adv7170_remove,
403 .id_table = adv7170_id,
Hans Verkuilb9a21f82008-09-07 07:58:20 -0300404};
Hans Verkuilc9611802010-09-15 15:49:56 -0300405
Axel Linc6e8d862012-02-12 06:56:32 -0300406module_i2c_driver(adv7170_driver);