Linux 3.11-rc3
[cris-mirror.git] / drivers / media / i2c / tvp5150.c
blob89c0b13463b73354b3fa56ce5bcc57b2fe989613
1 /*
2 * tvp5150 - Texas Instruments TVP5150A/AM1 video decoder driver
4 * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org)
5 * This code is placed under the terms of the GNU General Public License v2
6 */
8 #include <linux/i2c.h>
9 #include <linux/slab.h>
10 #include <linux/videodev2.h>
11 #include <linux/delay.h>
12 #include <linux/module.h>
13 #include <media/v4l2-device.h>
14 #include <media/tvp5150.h>
15 #include <media/v4l2-ctrls.h>
17 #include "tvp5150_reg.h"
19 #define TVP5150_H_MAX 720
20 #define TVP5150_V_MAX_525_60 480
21 #define TVP5150_V_MAX_OTHERS 576
22 #define TVP5150_MAX_CROP_LEFT 511
23 #define TVP5150_MAX_CROP_TOP 127
24 #define TVP5150_CROP_SHIFT 2
26 MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver");
27 MODULE_AUTHOR("Mauro Carvalho Chehab");
28 MODULE_LICENSE("GPL");
31 static int debug;
32 module_param(debug, int, 0);
33 MODULE_PARM_DESC(debug, "Debug level (0-2)");
35 struct tvp5150 {
36 struct v4l2_subdev sd;
37 struct v4l2_ctrl_handler hdl;
38 struct v4l2_rect rect;
40 v4l2_std_id norm; /* Current set standard */
41 u32 input;
42 u32 output;
43 int enable;
46 static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd)
48 return container_of(sd, struct tvp5150, sd);
51 static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
53 return &container_of(ctrl->handler, struct tvp5150, hdl)->sd;
56 static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr)
58 struct i2c_client *c = v4l2_get_subdevdata(sd);
59 unsigned char buffer[1];
60 int rc;
62 buffer[0] = addr;
64 rc = i2c_master_send(c, buffer, 1);
65 if (rc < 0) {
66 v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc);
67 return rc;
70 msleep(10);
72 rc = i2c_master_recv(c, buffer, 1);
73 if (rc < 0) {
74 v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc);
75 return rc;
78 v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]);
80 return (buffer[0]);
83 static inline void tvp5150_write(struct v4l2_subdev *sd, unsigned char addr,
84 unsigned char value)
86 struct i2c_client *c = v4l2_get_subdevdata(sd);
87 unsigned char buffer[2];
88 int rc;
90 buffer[0] = addr;
91 buffer[1] = value;
92 v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0], buffer[1]);
93 if (2 != (rc = i2c_master_send(c, buffer, 2)))
94 v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 2)\n", rc);
97 static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init,
98 const u8 end, int max_line)
100 int i = 0;
102 while (init != (u8)(end + 1)) {
103 if ((i % max_line) == 0) {
104 if (i > 0)
105 printk("\n");
106 printk("tvp5150: %s reg 0x%02x = ", s, init);
108 printk("%02x ", tvp5150_read(sd, init));
110 init++;
111 i++;
113 printk("\n");
116 static int tvp5150_log_status(struct v4l2_subdev *sd)
118 printk("tvp5150: Video input source selection #1 = 0x%02x\n",
119 tvp5150_read(sd, TVP5150_VD_IN_SRC_SEL_1));
120 printk("tvp5150: Analog channel controls = 0x%02x\n",
121 tvp5150_read(sd, TVP5150_ANAL_CHL_CTL));
122 printk("tvp5150: Operation mode controls = 0x%02x\n",
123 tvp5150_read(sd, TVP5150_OP_MODE_CTL));
124 printk("tvp5150: Miscellaneous controls = 0x%02x\n",
125 tvp5150_read(sd, TVP5150_MISC_CTL));
126 printk("tvp5150: Autoswitch mask= 0x%02x\n",
127 tvp5150_read(sd, TVP5150_AUTOSW_MSK));
128 printk("tvp5150: Color killer threshold control = 0x%02x\n",
129 tvp5150_read(sd, TVP5150_COLOR_KIL_THSH_CTL));
130 printk("tvp5150: Luminance processing controls #1 #2 and #3 = %02x %02x %02x\n",
131 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_1),
132 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_2),
133 tvp5150_read(sd, TVP5150_LUMA_PROC_CTL_3));
134 printk("tvp5150: Brightness control = 0x%02x\n",
135 tvp5150_read(sd, TVP5150_BRIGHT_CTL));
136 printk("tvp5150: Color saturation control = 0x%02x\n",
137 tvp5150_read(sd, TVP5150_SATURATION_CTL));
138 printk("tvp5150: Hue control = 0x%02x\n",
139 tvp5150_read(sd, TVP5150_HUE_CTL));
140 printk("tvp5150: Contrast control = 0x%02x\n",
141 tvp5150_read(sd, TVP5150_CONTRAST_CTL));
142 printk("tvp5150: Outputs and data rates select = 0x%02x\n",
143 tvp5150_read(sd, TVP5150_DATA_RATE_SEL));
144 printk("tvp5150: Configuration shared pins = 0x%02x\n",
145 tvp5150_read(sd, TVP5150_CONF_SHARED_PIN));
146 printk("tvp5150: Active video cropping start = 0x%02x%02x\n",
147 tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_MSB),
148 tvp5150_read(sd, TVP5150_ACT_VD_CROP_ST_LSB));
149 printk("tvp5150: Active video cropping stop = 0x%02x%02x\n",
150 tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_MSB),
151 tvp5150_read(sd, TVP5150_ACT_VD_CROP_STP_LSB));
152 printk("tvp5150: Genlock/RTC = 0x%02x\n",
153 tvp5150_read(sd, TVP5150_GENLOCK));
154 printk("tvp5150: Horizontal sync start = 0x%02x\n",
155 tvp5150_read(sd, TVP5150_HORIZ_SYNC_START));
156 printk("tvp5150: Vertical blanking start = 0x%02x\n",
157 tvp5150_read(sd, TVP5150_VERT_BLANKING_START));
158 printk("tvp5150: Vertical blanking stop = 0x%02x\n",
159 tvp5150_read(sd, TVP5150_VERT_BLANKING_STOP));
160 printk("tvp5150: Chrominance processing control #1 and #2 = %02x %02x\n",
161 tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_1),
162 tvp5150_read(sd, TVP5150_CHROMA_PROC_CTL_2));
163 printk("tvp5150: Interrupt reset register B = 0x%02x\n",
164 tvp5150_read(sd, TVP5150_INT_RESET_REG_B));
165 printk("tvp5150: Interrupt enable register B = 0x%02x\n",
166 tvp5150_read(sd, TVP5150_INT_ENABLE_REG_B));
167 printk("tvp5150: Interrupt configuration register B = 0x%02x\n",
168 tvp5150_read(sd, TVP5150_INTT_CONFIG_REG_B));
169 printk("tvp5150: Video standard = 0x%02x\n",
170 tvp5150_read(sd, TVP5150_VIDEO_STD));
171 printk("tvp5150: Chroma gain factor: Cb=0x%02x Cr=0x%02x\n",
172 tvp5150_read(sd, TVP5150_CB_GAIN_FACT),
173 tvp5150_read(sd, TVP5150_CR_GAIN_FACTOR));
174 printk("tvp5150: Macrovision on counter = 0x%02x\n",
175 tvp5150_read(sd, TVP5150_MACROVISION_ON_CTR));
176 printk("tvp5150: Macrovision off counter = 0x%02x\n",
177 tvp5150_read(sd, TVP5150_MACROVISION_OFF_CTR));
178 printk("tvp5150: ITU-R BT.656.%d timing(TVP5150AM1 only)\n",
179 (tvp5150_read(sd, TVP5150_REV_SELECT) & 1) ? 3 : 4);
180 printk("tvp5150: Device ID = %02x%02x\n",
181 tvp5150_read(sd, TVP5150_MSB_DEV_ID),
182 tvp5150_read(sd, TVP5150_LSB_DEV_ID));
183 printk("tvp5150: ROM version = (hex) %02x.%02x\n",
184 tvp5150_read(sd, TVP5150_ROM_MAJOR_VER),
185 tvp5150_read(sd, TVP5150_ROM_MINOR_VER));
186 printk("tvp5150: Vertical line count = 0x%02x%02x\n",
187 tvp5150_read(sd, TVP5150_VERT_LN_COUNT_MSB),
188 tvp5150_read(sd, TVP5150_VERT_LN_COUNT_LSB));
189 printk("tvp5150: Interrupt status register B = 0x%02x\n",
190 tvp5150_read(sd, TVP5150_INT_STATUS_REG_B));
191 printk("tvp5150: Interrupt active register B = 0x%02x\n",
192 tvp5150_read(sd, TVP5150_INT_ACTIVE_REG_B));
193 printk("tvp5150: Status regs #1 to #5 = %02x %02x %02x %02x %02x\n",
194 tvp5150_read(sd, TVP5150_STATUS_REG_1),
195 tvp5150_read(sd, TVP5150_STATUS_REG_2),
196 tvp5150_read(sd, TVP5150_STATUS_REG_3),
197 tvp5150_read(sd, TVP5150_STATUS_REG_4),
198 tvp5150_read(sd, TVP5150_STATUS_REG_5));
200 dump_reg_range(sd, "Teletext filter 1", TVP5150_TELETEXT_FIL1_INI,
201 TVP5150_TELETEXT_FIL1_END, 8);
202 dump_reg_range(sd, "Teletext filter 2", TVP5150_TELETEXT_FIL2_INI,
203 TVP5150_TELETEXT_FIL2_END, 8);
205 printk("tvp5150: Teletext filter enable = 0x%02x\n",
206 tvp5150_read(sd, TVP5150_TELETEXT_FIL_ENA));
207 printk("tvp5150: Interrupt status register A = 0x%02x\n",
208 tvp5150_read(sd, TVP5150_INT_STATUS_REG_A));
209 printk("tvp5150: Interrupt enable register A = 0x%02x\n",
210 tvp5150_read(sd, TVP5150_INT_ENABLE_REG_A));
211 printk("tvp5150: Interrupt configuration = 0x%02x\n",
212 tvp5150_read(sd, TVP5150_INT_CONF));
213 printk("tvp5150: VDP status register = 0x%02x\n",
214 tvp5150_read(sd, TVP5150_VDP_STATUS_REG));
215 printk("tvp5150: FIFO word count = 0x%02x\n",
216 tvp5150_read(sd, TVP5150_FIFO_WORD_COUNT));
217 printk("tvp5150: FIFO interrupt threshold = 0x%02x\n",
218 tvp5150_read(sd, TVP5150_FIFO_INT_THRESHOLD));
219 printk("tvp5150: FIFO reset = 0x%02x\n",
220 tvp5150_read(sd, TVP5150_FIFO_RESET));
221 printk("tvp5150: Line number interrupt = 0x%02x\n",
222 tvp5150_read(sd, TVP5150_LINE_NUMBER_INT));
223 printk("tvp5150: Pixel alignment register = 0x%02x%02x\n",
224 tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_HIGH),
225 tvp5150_read(sd, TVP5150_PIX_ALIGN_REG_LOW));
226 printk("tvp5150: FIFO output control = 0x%02x\n",
227 tvp5150_read(sd, TVP5150_FIFO_OUT_CTRL));
228 printk("tvp5150: Full field enable = 0x%02x\n",
229 tvp5150_read(sd, TVP5150_FULL_FIELD_ENA));
230 printk("tvp5150: Full field mode register = 0x%02x\n",
231 tvp5150_read(sd, TVP5150_FULL_FIELD_MODE_REG));
233 dump_reg_range(sd, "CC data", TVP5150_CC_DATA_INI,
234 TVP5150_CC_DATA_END, 8);
236 dump_reg_range(sd, "WSS data", TVP5150_WSS_DATA_INI,
237 TVP5150_WSS_DATA_END, 8);
239 dump_reg_range(sd, "VPS data", TVP5150_VPS_DATA_INI,
240 TVP5150_VPS_DATA_END, 8);
242 dump_reg_range(sd, "VITC data", TVP5150_VITC_DATA_INI,
243 TVP5150_VITC_DATA_END, 10);
245 dump_reg_range(sd, "Line mode", TVP5150_LINE_MODE_INI,
246 TVP5150_LINE_MODE_END, 8);
247 return 0;
250 /****************************************************************************
251 Basic functions
252 ****************************************************************************/
254 static inline void tvp5150_selmux(struct v4l2_subdev *sd)
256 int opmode = 0;
257 struct tvp5150 *decoder = to_tvp5150(sd);
258 int input = 0;
259 int val;
261 if ((decoder->output & TVP5150_BLACK_SCREEN) || !decoder->enable)
262 input = 8;
264 switch (decoder->input) {
265 case TVP5150_COMPOSITE1:
266 input |= 2;
267 /* fall through */
268 case TVP5150_COMPOSITE0:
269 break;
270 case TVP5150_SVIDEO:
271 default:
272 input |= 1;
273 break;
276 v4l2_dbg(1, debug, sd, "Selecting video route: route input=%i, output=%i "
277 "=> tvp5150 input=%i, opmode=%i\n",
278 decoder->input, decoder->output,
279 input, opmode);
281 tvp5150_write(sd, TVP5150_OP_MODE_CTL, opmode);
282 tvp5150_write(sd, TVP5150_VD_IN_SRC_SEL_1, input);
284 /* Svideo should enable YCrCb output and disable GPCL output
285 * For Composite and TV, it should be the reverse
287 val = tvp5150_read(sd, TVP5150_MISC_CTL);
288 if (val < 0) {
289 v4l2_err(sd, "%s: failed with error = %d\n", __func__, val);
290 return;
293 if (decoder->input == TVP5150_SVIDEO)
294 val = (val & ~0x40) | 0x10;
295 else
296 val = (val & ~0x10) | 0x40;
297 tvp5150_write(sd, TVP5150_MISC_CTL, val);
300 struct i2c_reg_value {
301 unsigned char reg;
302 unsigned char value;
305 /* Default values as sugested at TVP5150AM1 datasheet */
306 static const struct i2c_reg_value tvp5150_init_default[] = {
307 { /* 0x00 */
308 TVP5150_VD_IN_SRC_SEL_1,0x00
310 { /* 0x01 */
311 TVP5150_ANAL_CHL_CTL,0x15
313 { /* 0x02 */
314 TVP5150_OP_MODE_CTL,0x00
316 { /* 0x03 */
317 TVP5150_MISC_CTL,0x01
319 { /* 0x06 */
320 TVP5150_COLOR_KIL_THSH_CTL,0x10
322 { /* 0x07 */
323 TVP5150_LUMA_PROC_CTL_1,0x60
325 { /* 0x08 */
326 TVP5150_LUMA_PROC_CTL_2,0x00
328 { /* 0x09 */
329 TVP5150_BRIGHT_CTL,0x80
331 { /* 0x0a */
332 TVP5150_SATURATION_CTL,0x80
334 { /* 0x0b */
335 TVP5150_HUE_CTL,0x00
337 { /* 0x0c */
338 TVP5150_CONTRAST_CTL,0x80
340 { /* 0x0d */
341 TVP5150_DATA_RATE_SEL,0x47
343 { /* 0x0e */
344 TVP5150_LUMA_PROC_CTL_3,0x00
346 { /* 0x0f */
347 TVP5150_CONF_SHARED_PIN,0x08
349 { /* 0x11 */
350 TVP5150_ACT_VD_CROP_ST_MSB,0x00
352 { /* 0x12 */
353 TVP5150_ACT_VD_CROP_ST_LSB,0x00
355 { /* 0x13 */
356 TVP5150_ACT_VD_CROP_STP_MSB,0x00
358 { /* 0x14 */
359 TVP5150_ACT_VD_CROP_STP_LSB,0x00
361 { /* 0x15 */
362 TVP5150_GENLOCK,0x01
364 { /* 0x16 */
365 TVP5150_HORIZ_SYNC_START,0x80
367 { /* 0x18 */
368 TVP5150_VERT_BLANKING_START,0x00
370 { /* 0x19 */
371 TVP5150_VERT_BLANKING_STOP,0x00
373 { /* 0x1a */
374 TVP5150_CHROMA_PROC_CTL_1,0x0c
376 { /* 0x1b */
377 TVP5150_CHROMA_PROC_CTL_2,0x14
379 { /* 0x1c */
380 TVP5150_INT_RESET_REG_B,0x00
382 { /* 0x1d */
383 TVP5150_INT_ENABLE_REG_B,0x00
385 { /* 0x1e */
386 TVP5150_INTT_CONFIG_REG_B,0x00
388 { /* 0x28 */
389 TVP5150_VIDEO_STD,0x00
391 { /* 0x2e */
392 TVP5150_MACROVISION_ON_CTR,0x0f
394 { /* 0x2f */
395 TVP5150_MACROVISION_OFF_CTR,0x01
397 { /* 0xbb */
398 TVP5150_TELETEXT_FIL_ENA,0x00
400 { /* 0xc0 */
401 TVP5150_INT_STATUS_REG_A,0x00
403 { /* 0xc1 */
404 TVP5150_INT_ENABLE_REG_A,0x00
406 { /* 0xc2 */
407 TVP5150_INT_CONF,0x04
409 { /* 0xc8 */
410 TVP5150_FIFO_INT_THRESHOLD,0x80
412 { /* 0xc9 */
413 TVP5150_FIFO_RESET,0x00
415 { /* 0xca */
416 TVP5150_LINE_NUMBER_INT,0x00
418 { /* 0xcb */
419 TVP5150_PIX_ALIGN_REG_LOW,0x4e
421 { /* 0xcc */
422 TVP5150_PIX_ALIGN_REG_HIGH,0x00
424 { /* 0xcd */
425 TVP5150_FIFO_OUT_CTRL,0x01
427 { /* 0xcf */
428 TVP5150_FULL_FIELD_ENA,0x00
430 { /* 0xd0 */
431 TVP5150_LINE_MODE_INI,0x00
433 { /* 0xfc */
434 TVP5150_FULL_FIELD_MODE_REG,0x7f
436 { /* end of data */
437 0xff,0xff
441 /* Default values as sugested at TVP5150AM1 datasheet */
442 static const struct i2c_reg_value tvp5150_init_enable[] = {
444 TVP5150_CONF_SHARED_PIN, 2
445 },{ /* Automatic offset and AGC enabled */
446 TVP5150_ANAL_CHL_CTL, 0x15
447 },{ /* Activate YCrCb output 0x9 or 0xd ? */
448 TVP5150_MISC_CTL, 0x6f
449 },{ /* Activates video std autodetection for all standards */
450 TVP5150_AUTOSW_MSK, 0x0
451 },{ /* Default format: 0x47. For 4:2:2: 0x40 */
452 TVP5150_DATA_RATE_SEL, 0x47
454 TVP5150_CHROMA_PROC_CTL_1, 0x0c
456 TVP5150_CHROMA_PROC_CTL_2, 0x54
457 },{ /* Non documented, but initialized on WinTV USB2 */
458 0x27, 0x20
460 0xff,0xff
464 struct tvp5150_vbi_type {
465 unsigned int vbi_type;
466 unsigned int ini_line;
467 unsigned int end_line;
468 unsigned int by_field :1;
471 struct i2c_vbi_ram_value {
472 u16 reg;
473 struct tvp5150_vbi_type type;
474 unsigned char values[16];
477 /* This struct have the values for each supported VBI Standard
478 * by
479 tvp5150_vbi_types should follow the same order as vbi_ram_default
480 * value 0 means rom position 0x10, value 1 means rom position 0x30
481 * and so on. There are 16 possible locations from 0 to 15.
484 static struct i2c_vbi_ram_value vbi_ram_default[] =
486 /* FIXME: Current api doesn't handle all VBI types, those not
487 yet supported are placed under #if 0 */
488 #if 0
489 {0x010, /* Teletext, SECAM, WST System A */
490 {V4L2_SLICED_TELETEXT_SECAM,6,23,1},
491 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26,
492 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 }
494 #endif
495 {0x030, /* Teletext, PAL, WST System B */
496 {V4L2_SLICED_TELETEXT_B,6,22,1},
497 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b,
498 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 }
500 #if 0
501 {0x050, /* Teletext, PAL, WST System C */
502 {V4L2_SLICED_TELETEXT_PAL_C,6,22,1},
503 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
504 0xa6, 0x98, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
506 {0x070, /* Teletext, NTSC, WST System B */
507 {V4L2_SLICED_TELETEXT_NTSC_B,10,21,1},
508 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x23,
509 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
511 {0x090, /* Tetetext, NTSC NABTS System C */
512 {V4L2_SLICED_TELETEXT_NTSC_C,10,21,1},
513 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
514 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x15, 0x00 }
516 {0x0b0, /* Teletext, NTSC-J, NABTS System D */
517 {V4L2_SLICED_TELETEXT_NTSC_D,10,21,1},
518 { 0xaa, 0xaa, 0xff, 0xff, 0xa7, 0x2e, 0x20, 0x23,
519 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
521 {0x0d0, /* Closed Caption, PAL/SECAM */
522 {V4L2_SLICED_CAPTION_625,22,22,1},
523 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
524 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
526 #endif
527 {0x0f0, /* Closed Caption, NTSC */
528 {V4L2_SLICED_CAPTION_525,21,21,1},
529 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
530 0x69, 0x8c, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
532 {0x110, /* Wide Screen Signal, PAL/SECAM */
533 {V4L2_SLICED_WSS_625,23,23,1},
534 { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42,
535 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 }
537 #if 0
538 {0x130, /* Wide Screen Signal, NTSC C */
539 {V4L2_SLICED_WSS_525,20,20,1},
540 { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43,
541 0x69, 0x7c, 0x08, 0x00, 0x00, 0x00, 0x39, 0x00 }
543 {0x150, /* Vertical Interval Timecode (VITC), PAL/SECAM */
544 {V4l2_SLICED_VITC_625,6,22,0},
545 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
546 0xa6, 0x85, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
548 {0x170, /* Vertical Interval Timecode (VITC), NTSC */
549 {V4l2_SLICED_VITC_525,10,20,0},
550 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
551 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
553 #endif
554 {0x190, /* Video Program System (VPS), PAL */
555 {V4L2_SLICED_VPS,16,16,0},
556 { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d,
557 0xa6, 0xda, 0x0b, 0x00, 0x00, 0x00, 0x60, 0x00 }
559 /* 0x1d0 User programmable */
561 /* End of struct */
562 { (u16)-1 }
565 static int tvp5150_write_inittab(struct v4l2_subdev *sd,
566 const struct i2c_reg_value *regs)
568 while (regs->reg != 0xff) {
569 tvp5150_write(sd, regs->reg, regs->value);
570 regs++;
572 return 0;
575 static int tvp5150_vdp_init(struct v4l2_subdev *sd,
576 const struct i2c_vbi_ram_value *regs)
578 unsigned int i;
580 /* Disable Full Field */
581 tvp5150_write(sd, TVP5150_FULL_FIELD_ENA, 0);
583 /* Before programming, Line mode should be at 0xff */
584 for (i = TVP5150_LINE_MODE_INI; i <= TVP5150_LINE_MODE_END; i++)
585 tvp5150_write(sd, i, 0xff);
587 /* Load Ram Table */
588 while (regs->reg != (u16)-1) {
589 tvp5150_write(sd, TVP5150_CONF_RAM_ADDR_HIGH, regs->reg >> 8);
590 tvp5150_write(sd, TVP5150_CONF_RAM_ADDR_LOW, regs->reg);
592 for (i = 0; i < 16; i++)
593 tvp5150_write(sd, TVP5150_VDP_CONF_RAM_DATA, regs->values[i]);
595 regs++;
597 return 0;
600 /* Fills VBI capabilities based on i2c_vbi_ram_value struct */
601 static int tvp5150_g_sliced_vbi_cap(struct v4l2_subdev *sd,
602 struct v4l2_sliced_vbi_cap *cap)
604 const struct i2c_vbi_ram_value *regs = vbi_ram_default;
605 int line;
607 v4l2_dbg(1, debug, sd, "g_sliced_vbi_cap\n");
608 memset(cap, 0, sizeof *cap);
610 while (regs->reg != (u16)-1 ) {
611 for (line=regs->type.ini_line;line<=regs->type.end_line;line++) {
612 cap->service_lines[0][line] |= regs->type.vbi_type;
614 cap->service_set |= regs->type.vbi_type;
616 regs++;
618 return 0;
621 /* Set vbi processing
622 * type - one of tvp5150_vbi_types
623 * line - line to gather data
624 * fields: bit 0 field1, bit 1, field2
625 * flags (default=0xf0) is a bitmask, were set means:
626 * bit 7: enable filtering null bytes on CC
627 * bit 6: send data also to FIFO
628 * bit 5: don't allow data with errors on FIFO
629 * bit 4: enable ECC when possible
630 * pix_align = pix alignment:
631 * LSB = field1
632 * MSB = field2
634 static int tvp5150_set_vbi(struct v4l2_subdev *sd,
635 const struct i2c_vbi_ram_value *regs,
636 unsigned int type,u8 flags, int line,
637 const int fields)
639 struct tvp5150 *decoder = to_tvp5150(sd);
640 v4l2_std_id std = decoder->norm;
641 u8 reg;
642 int pos=0;
644 if (std == V4L2_STD_ALL) {
645 v4l2_err(sd, "VBI can't be configured without knowing number of lines\n");
646 return 0;
647 } else if (std & V4L2_STD_625_50) {
648 /* Don't follow NTSC Line number convension */
649 line += 3;
652 if (line<6||line>27)
653 return 0;
655 while (regs->reg != (u16)-1 ) {
656 if ((type & regs->type.vbi_type) &&
657 (line>=regs->type.ini_line) &&
658 (line<=regs->type.end_line)) {
659 type=regs->type.vbi_type;
660 break;
663 regs++;
664 pos++;
666 if (regs->reg == (u16)-1)
667 return 0;
669 type=pos | (flags & 0xf0);
670 reg=((line-6)<<1)+TVP5150_LINE_MODE_INI;
672 if (fields&1) {
673 tvp5150_write(sd, reg, type);
676 if (fields&2) {
677 tvp5150_write(sd, reg+1, type);
680 return type;
683 static int tvp5150_get_vbi(struct v4l2_subdev *sd,
684 const struct i2c_vbi_ram_value *regs, int line)
686 struct tvp5150 *decoder = to_tvp5150(sd);
687 v4l2_std_id std = decoder->norm;
688 u8 reg;
689 int pos, type = 0;
690 int i, ret = 0;
692 if (std == V4L2_STD_ALL) {
693 v4l2_err(sd, "VBI can't be configured without knowing number of lines\n");
694 return 0;
695 } else if (std & V4L2_STD_625_50) {
696 /* Don't follow NTSC Line number convension */
697 line += 3;
700 if (line < 6 || line > 27)
701 return 0;
703 reg = ((line - 6) << 1) + TVP5150_LINE_MODE_INI;
705 for (i = 0; i <= 1; i++) {
706 ret = tvp5150_read(sd, reg + i);
707 if (ret < 0) {
708 v4l2_err(sd, "%s: failed with error = %d\n",
709 __func__, ret);
710 return 0;
712 pos = ret & 0x0f;
713 if (pos < 0x0f)
714 type |= regs[pos].type.vbi_type;
717 return type;
720 static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std)
722 struct tvp5150 *decoder = to_tvp5150(sd);
723 int fmt = 0;
725 decoder->norm = std;
727 /* First tests should be against specific std */
729 if (std == V4L2_STD_NTSC_443) {
730 fmt = VIDEO_STD_NTSC_4_43_BIT;
731 } else if (std == V4L2_STD_PAL_M) {
732 fmt = VIDEO_STD_PAL_M_BIT;
733 } else if (std == V4L2_STD_PAL_N || std == V4L2_STD_PAL_Nc) {
734 fmt = VIDEO_STD_PAL_COMBINATION_N_BIT;
735 } else {
736 /* Then, test against generic ones */
737 if (std & V4L2_STD_NTSC)
738 fmt = VIDEO_STD_NTSC_MJ_BIT;
739 else if (std & V4L2_STD_PAL)
740 fmt = VIDEO_STD_PAL_BDGHIN_BIT;
741 else if (std & V4L2_STD_SECAM)
742 fmt = VIDEO_STD_SECAM_BIT;
745 v4l2_dbg(1, debug, sd, "Set video std register to %d.\n", fmt);
746 tvp5150_write(sd, TVP5150_VIDEO_STD, fmt);
747 return 0;
750 static int tvp5150_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
752 struct tvp5150 *decoder = to_tvp5150(sd);
754 if (decoder->norm == std)
755 return 0;
757 /* Change cropping height limits */
758 if (std & V4L2_STD_525_60)
759 decoder->rect.height = TVP5150_V_MAX_525_60;
760 else
761 decoder->rect.height = TVP5150_V_MAX_OTHERS;
764 return tvp5150_set_std(sd, std);
767 static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
769 struct tvp5150 *decoder = to_tvp5150(sd);
771 /* Initializes TVP5150 to its default values */
772 tvp5150_write_inittab(sd, tvp5150_init_default);
774 /* Initializes VDP registers */
775 tvp5150_vdp_init(sd, vbi_ram_default);
777 /* Selects decoder input */
778 tvp5150_selmux(sd);
780 /* Initializes TVP5150 to stream enabled values */
781 tvp5150_write_inittab(sd, tvp5150_init_enable);
783 /* Initialize image preferences */
784 v4l2_ctrl_handler_setup(&decoder->hdl);
786 tvp5150_set_std(sd, decoder->norm);
787 return 0;
790 static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
792 struct v4l2_subdev *sd = to_sd(ctrl);
794 switch (ctrl->id) {
795 case V4L2_CID_BRIGHTNESS:
796 tvp5150_write(sd, TVP5150_BRIGHT_CTL, ctrl->val);
797 return 0;
798 case V4L2_CID_CONTRAST:
799 tvp5150_write(sd, TVP5150_CONTRAST_CTL, ctrl->val);
800 return 0;
801 case V4L2_CID_SATURATION:
802 tvp5150_write(sd, TVP5150_SATURATION_CTL, ctrl->val);
803 return 0;
804 case V4L2_CID_HUE:
805 tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val);
806 return 0;
808 return -EINVAL;
811 static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
813 int val = tvp5150_read(sd, TVP5150_STATUS_REG_5);
815 switch (val & 0x0F) {
816 case 0x01:
817 return V4L2_STD_NTSC;
818 case 0x03:
819 return V4L2_STD_PAL;
820 case 0x05:
821 return V4L2_STD_PAL_M;
822 case 0x07:
823 return V4L2_STD_PAL_N | V4L2_STD_PAL_Nc;
824 case 0x09:
825 return V4L2_STD_NTSC_443;
826 case 0xb:
827 return V4L2_STD_SECAM;
828 default:
829 return V4L2_STD_UNKNOWN;
833 static int tvp5150_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
834 enum v4l2_mbus_pixelcode *code)
836 if (index)
837 return -EINVAL;
839 *code = V4L2_MBUS_FMT_UYVY8_2X8;
840 return 0;
843 static int tvp5150_mbus_fmt(struct v4l2_subdev *sd,
844 struct v4l2_mbus_framefmt *f)
846 struct tvp5150 *decoder = to_tvp5150(sd);
848 if (f == NULL)
849 return -EINVAL;
851 tvp5150_reset(sd, 0);
853 f->width = decoder->rect.width;
854 f->height = decoder->rect.height;
856 f->code = V4L2_MBUS_FMT_UYVY8_2X8;
857 f->field = V4L2_FIELD_SEQ_TB;
858 f->colorspace = V4L2_COLORSPACE_SMPTE170M;
860 v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width,
861 f->height);
862 return 0;
865 static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
867 struct v4l2_rect rect = a->c;
868 struct tvp5150 *decoder = to_tvp5150(sd);
869 v4l2_std_id std;
870 int hmax;
872 v4l2_dbg(1, debug, sd, "%s left=%d, top=%d, width=%d, height=%d\n",
873 __func__, rect.left, rect.top, rect.width, rect.height);
875 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
876 return -EINVAL;
878 /* tvp5150 has some special limits */
879 rect.left = clamp(rect.left, 0, TVP5150_MAX_CROP_LEFT);
880 rect.width = clamp(rect.width,
881 TVP5150_H_MAX - TVP5150_MAX_CROP_LEFT - rect.left,
882 TVP5150_H_MAX - rect.left);
883 rect.top = clamp(rect.top, 0, TVP5150_MAX_CROP_TOP);
885 /* Calculate height based on current standard */
886 if (decoder->norm == V4L2_STD_ALL)
887 std = tvp5150_read_std(sd);
888 else
889 std = decoder->norm;
891 if (std & V4L2_STD_525_60)
892 hmax = TVP5150_V_MAX_525_60;
893 else
894 hmax = TVP5150_V_MAX_OTHERS;
896 rect.height = clamp(rect.height,
897 hmax - TVP5150_MAX_CROP_TOP - rect.top,
898 hmax - rect.top);
900 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, rect.top);
901 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP,
902 rect.top + rect.height - hmax);
903 tvp5150_write(sd, TVP5150_ACT_VD_CROP_ST_MSB,
904 rect.left >> TVP5150_CROP_SHIFT);
905 tvp5150_write(sd, TVP5150_ACT_VD_CROP_ST_LSB,
906 rect.left | (1 << TVP5150_CROP_SHIFT));
907 tvp5150_write(sd, TVP5150_ACT_VD_CROP_STP_MSB,
908 (rect.left + rect.width - TVP5150_MAX_CROP_LEFT) >>
909 TVP5150_CROP_SHIFT);
910 tvp5150_write(sd, TVP5150_ACT_VD_CROP_STP_LSB,
911 rect.left + rect.width - TVP5150_MAX_CROP_LEFT);
913 decoder->rect = rect;
915 return 0;
918 static int tvp5150_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
920 struct tvp5150 *decoder = container_of(sd, struct tvp5150, sd);
922 a->c = decoder->rect;
923 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
925 return 0;
928 static int tvp5150_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
930 struct tvp5150 *decoder = container_of(sd, struct tvp5150, sd);
931 v4l2_std_id std;
933 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
934 return -EINVAL;
936 a->bounds.left = 0;
937 a->bounds.top = 0;
938 a->bounds.width = TVP5150_H_MAX;
940 /* Calculate height based on current standard */
941 if (decoder->norm == V4L2_STD_ALL)
942 std = tvp5150_read_std(sd);
943 else
944 std = decoder->norm;
946 if (std & V4L2_STD_525_60)
947 a->bounds.height = TVP5150_V_MAX_525_60;
948 else
949 a->bounds.height = TVP5150_V_MAX_OTHERS;
951 a->defrect = a->bounds;
952 a->pixelaspect.numerator = 1;
953 a->pixelaspect.denominator = 1;
955 return 0;
958 /****************************************************************************
959 I2C Command
960 ****************************************************************************/
962 static int tvp5150_s_routing(struct v4l2_subdev *sd,
963 u32 input, u32 output, u32 config)
965 struct tvp5150 *decoder = to_tvp5150(sd);
967 decoder->input = input;
968 decoder->output = output;
969 tvp5150_selmux(sd);
970 return 0;
973 static int tvp5150_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)
975 /* this is for capturing 36 raw vbi lines
976 if there's a way to cut off the beginning 2 vbi lines
977 with the tvp5150 then the vbi line count could be lowered
978 to 17 lines/field again, although I couldn't find a register
979 which could do that cropping */
980 if (fmt->sample_format == V4L2_PIX_FMT_GREY)
981 tvp5150_write(sd, TVP5150_LUMA_PROC_CTL_1, 0x70);
982 if (fmt->count[0] == 18 && fmt->count[1] == 18) {
983 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, 0x00);
984 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP, 0x01);
986 return 0;
989 static int tvp5150_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *svbi)
991 int i;
993 if (svbi->service_set != 0) {
994 for (i = 0; i <= 23; i++) {
995 svbi->service_lines[1][i] = 0;
996 svbi->service_lines[0][i] =
997 tvp5150_set_vbi(sd, vbi_ram_default,
998 svbi->service_lines[0][i], 0xf0, i, 3);
1000 /* Enables FIFO */
1001 tvp5150_write(sd, TVP5150_FIFO_OUT_CTRL, 1);
1002 } else {
1003 /* Disables FIFO*/
1004 tvp5150_write(sd, TVP5150_FIFO_OUT_CTRL, 0);
1006 /* Disable Full Field */
1007 tvp5150_write(sd, TVP5150_FULL_FIELD_ENA, 0);
1009 /* Disable Line modes */
1010 for (i = TVP5150_LINE_MODE_INI; i <= TVP5150_LINE_MODE_END; i++)
1011 tvp5150_write(sd, i, 0xff);
1013 return 0;
1016 static int tvp5150_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *svbi)
1018 int i, mask = 0;
1020 memset(svbi->service_lines, 0, sizeof(svbi->service_lines));
1022 for (i = 0; i <= 23; i++) {
1023 svbi->service_lines[0][i] =
1024 tvp5150_get_vbi(sd, vbi_ram_default, i);
1025 mask |= svbi->service_lines[0][i];
1027 svbi->service_set = mask;
1028 return 0;
1031 #ifdef CONFIG_VIDEO_ADV_DEBUG
1032 static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1034 int res;
1036 res = tvp5150_read(sd, reg->reg & 0xff);
1037 if (res < 0) {
1038 v4l2_err(sd, "%s: failed with error = %d\n", __func__, res);
1039 return res;
1042 reg->val = res;
1043 reg->size = 1;
1044 return 0;
1047 static int tvp5150_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg)
1049 tvp5150_write(sd, reg->reg & 0xff, reg->val & 0xff);
1050 return 0;
1052 #endif
1054 static int tvp5150_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
1056 int status = tvp5150_read(sd, 0x88);
1058 vt->signal = ((status & 0x04) && (status & 0x02)) ? 0xffff : 0x0;
1059 return 0;
1062 /* ----------------------------------------------------------------------- */
1064 static const struct v4l2_ctrl_ops tvp5150_ctrl_ops = {
1065 .s_ctrl = tvp5150_s_ctrl,
1068 static const struct v4l2_subdev_core_ops tvp5150_core_ops = {
1069 .log_status = tvp5150_log_status,
1070 .s_std = tvp5150_s_std,
1071 .reset = tvp5150_reset,
1072 #ifdef CONFIG_VIDEO_ADV_DEBUG
1073 .g_register = tvp5150_g_register,
1074 .s_register = tvp5150_s_register,
1075 #endif
1078 static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
1079 .g_tuner = tvp5150_g_tuner,
1082 static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
1083 .s_routing = tvp5150_s_routing,
1084 .enum_mbus_fmt = tvp5150_enum_mbus_fmt,
1085 .s_mbus_fmt = tvp5150_mbus_fmt,
1086 .try_mbus_fmt = tvp5150_mbus_fmt,
1087 .g_mbus_fmt = tvp5150_mbus_fmt,
1088 .s_crop = tvp5150_s_crop,
1089 .g_crop = tvp5150_g_crop,
1090 .cropcap = tvp5150_cropcap,
1093 static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
1094 .g_sliced_vbi_cap = tvp5150_g_sliced_vbi_cap,
1095 .g_sliced_fmt = tvp5150_g_sliced_fmt,
1096 .s_sliced_fmt = tvp5150_s_sliced_fmt,
1097 .s_raw_fmt = tvp5150_s_raw_fmt,
1100 static const struct v4l2_subdev_ops tvp5150_ops = {
1101 .core = &tvp5150_core_ops,
1102 .tuner = &tvp5150_tuner_ops,
1103 .video = &tvp5150_video_ops,
1104 .vbi = &tvp5150_vbi_ops,
1108 /****************************************************************************
1109 I2C Client & Driver
1110 ****************************************************************************/
1112 static int tvp5150_probe(struct i2c_client *c,
1113 const struct i2c_device_id *id)
1115 struct tvp5150 *core;
1116 struct v4l2_subdev *sd;
1117 int tvp5150_id[4];
1118 int i, res;
1120 /* Check if the adapter supports the needed features */
1121 if (!i2c_check_functionality(c->adapter,
1122 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
1123 return -EIO;
1125 core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
1126 if (!core)
1127 return -ENOMEM;
1128 sd = &core->sd;
1129 v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
1132 * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID,
1133 * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER
1135 for (i = 0; i < 4; i++) {
1136 res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
1137 if (res < 0)
1138 return res;
1139 tvp5150_id[i] = res;
1142 v4l_info(c, "chip found @ 0x%02x (%s)\n",
1143 c->addr << 1, c->adapter->name);
1145 if (tvp5150_id[2] == 4 && tvp5150_id[3] == 0) { /* Is TVP5150AM1 */
1146 v4l2_info(sd, "tvp%02x%02xam1 detected.\n",
1147 tvp5150_id[0], tvp5150_id[1]);
1149 /* ITU-T BT.656.4 timing */
1150 tvp5150_write(sd, TVP5150_REV_SELECT, 0);
1151 } else {
1152 /* Is TVP5150A */
1153 if (tvp5150_id[2] == 3 || tvp5150_id[3] == 0x21) {
1154 v4l2_info(sd, "tvp%02x%02xa detected.\n",
1155 tvp5150_id[2], tvp5150_id[3]);
1156 } else {
1157 v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
1158 tvp5150_id[2], tvp5150_id[3]);
1159 v4l2_info(sd, "*** Rom ver is %d.%d\n",
1160 tvp5150_id[2], tvp5150_id[3]);
1164 core->norm = V4L2_STD_ALL; /* Default is autodetect */
1165 core->input = TVP5150_COMPOSITE1;
1166 core->enable = 1;
1168 v4l2_ctrl_handler_init(&core->hdl, 4);
1169 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1170 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
1171 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1172 V4L2_CID_CONTRAST, 0, 255, 1, 128);
1173 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1174 V4L2_CID_SATURATION, 0, 255, 1, 128);
1175 v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1176 V4L2_CID_HUE, -128, 127, 1, 0);
1177 sd->ctrl_handler = &core->hdl;
1178 if (core->hdl.error) {
1179 res = core->hdl.error;
1180 v4l2_ctrl_handler_free(&core->hdl);
1181 return res;
1183 v4l2_ctrl_handler_setup(&core->hdl);
1185 /* Default is no cropping */
1186 core->rect.top = 0;
1187 if (tvp5150_read_std(sd) & V4L2_STD_525_60)
1188 core->rect.height = TVP5150_V_MAX_525_60;
1189 else
1190 core->rect.height = TVP5150_V_MAX_OTHERS;
1191 core->rect.left = 0;
1192 core->rect.width = TVP5150_H_MAX;
1194 if (debug > 1)
1195 tvp5150_log_status(sd);
1196 return 0;
1199 static int tvp5150_remove(struct i2c_client *c)
1201 struct v4l2_subdev *sd = i2c_get_clientdata(c);
1202 struct tvp5150 *decoder = to_tvp5150(sd);
1204 v4l2_dbg(1, debug, sd,
1205 "tvp5150.c: removing tvp5150 adapter on address 0x%x\n",
1206 c->addr << 1);
1208 v4l2_device_unregister_subdev(sd);
1209 v4l2_ctrl_handler_free(&decoder->hdl);
1210 return 0;
1213 /* ----------------------------------------------------------------------- */
1215 static const struct i2c_device_id tvp5150_id[] = {
1216 { "tvp5150", 0 },
1219 MODULE_DEVICE_TABLE(i2c, tvp5150_id);
1221 static struct i2c_driver tvp5150_driver = {
1222 .driver = {
1223 .owner = THIS_MODULE,
1224 .name = "tvp5150",
1226 .probe = tvp5150_probe,
1227 .remove = tvp5150_remove,
1228 .id_table = tvp5150_id,
1231 module_i2c_driver(tvp5150_driver);