2 * drivers/media/video/tvp514x.c
4 * TI TVP5146/47 decoder driver
6 * Copyright (C) 2008 Texas Instruments Inc
7 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
10 * Sivaraj R <sivaraj@ti.com>
11 * Brijesh R Jadav <brijesh.j@ti.com>
12 * Hardik Shah <hardik.shah@ti.com>
13 * Manjunath Hadli <mrh@ti.com>
14 * Karicheri Muralidharan <m-karicheri2@ti.com>
16 * This package is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <linux/i2c.h>
32 #include <linux/delay.h>
33 #include <linux/videodev2.h>
35 #include <media/v4l2-device.h>
36 #include <media/v4l2-common.h>
37 #include <media/v4l2-chip-ident.h>
38 #include <media/tvp514x.h>
40 #include "tvp514x_regs.h"
43 #define TVP514X_MODULE_NAME "tvp514x"
45 /* Private macros for TVP */
46 #define I2C_RETRY_COUNT (5)
47 #define LOCK_RETRY_COUNT (5)
48 #define LOCK_RETRY_DELAY (200)
52 module_param(debug
, bool, 0644);
53 MODULE_PARM_DESC(debug
, "Debug level (0-1)");
55 MODULE_AUTHOR("Texas Instruments");
56 MODULE_DESCRIPTION("TVP514X linux decoder driver");
57 MODULE_LICENSE("GPL");
60 * enum tvp514x_std - enum for supported standards
69 * struct tvp514x_std_info - Structure to store standard informations
70 * @width: Line width in pixels
71 * @height:Number of active lines
72 * @video_std: Value to write in REG_VIDEO_STD register
73 * @standard: v4l2 standard structure information
75 struct tvp514x_std_info
{
79 struct v4l2_standard standard
;
82 static struct tvp514x_reg tvp514x_reg_list_default
[0x40];
84 * struct tvp514x_decoder - TVP5146/47 decoder object
85 * @sd: Subdevice Slave handle
86 * @tvp514x_regs: copy of hw's regs with preset values.
87 * @pdata: Board specific
89 * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
90 * @pix: Current pixel format
91 * @num_fmts: Number of formats
92 * @fmt_list: Format list
93 * @current_std: Current standard
94 * @num_stds: Number of standards
95 * @std_list: Standards list
96 * @input: Input routing at chip level
97 * @output: Output routing at chip level
99 struct tvp514x_decoder
{
100 struct v4l2_subdev sd
;
101 struct tvp514x_reg tvp514x_regs
[ARRAY_SIZE(tvp514x_reg_list_default
)];
102 const struct tvp514x_platform_data
*pdata
;
107 struct v4l2_pix_format pix
;
109 const struct v4l2_fmtdesc
*fmt_list
;
111 enum tvp514x_std current_std
;
113 struct tvp514x_std_info
*std_list
;
115 * Input and Output Routing parameters
121 /* TVP514x default register values */
122 static struct tvp514x_reg tvp514x_reg_list_default
[] = {
123 {TOK_WRITE
, REG_INPUT_SEL
, 0x05}, /* Composite selected */
124 {TOK_WRITE
, REG_AFE_GAIN_CTRL
, 0x0F},
125 {TOK_WRITE
, REG_VIDEO_STD
, 0x00}, /* Auto mode */
126 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
127 {TOK_SKIP
, REG_AUTOSWITCH_MASK
, 0x3F},
128 {TOK_WRITE
, REG_COLOR_KILLER
, 0x10},
129 {TOK_WRITE
, REG_LUMA_CONTROL1
, 0x00},
130 {TOK_WRITE
, REG_LUMA_CONTROL2
, 0x00},
131 {TOK_WRITE
, REG_LUMA_CONTROL3
, 0x02},
132 {TOK_WRITE
, REG_BRIGHTNESS
, 0x80},
133 {TOK_WRITE
, REG_CONTRAST
, 0x80},
134 {TOK_WRITE
, REG_SATURATION
, 0x80},
135 {TOK_WRITE
, REG_HUE
, 0x00},
136 {TOK_WRITE
, REG_CHROMA_CONTROL1
, 0x00},
137 {TOK_WRITE
, REG_CHROMA_CONTROL2
, 0x0E},
138 {TOK_SKIP
, 0x0F, 0x00}, /* Reserved */
139 {TOK_WRITE
, REG_COMP_PR_SATURATION
, 0x80},
140 {TOK_WRITE
, REG_COMP_Y_CONTRAST
, 0x80},
141 {TOK_WRITE
, REG_COMP_PB_SATURATION
, 0x80},
142 {TOK_SKIP
, 0x13, 0x00}, /* Reserved */
143 {TOK_WRITE
, REG_COMP_Y_BRIGHTNESS
, 0x80},
144 {TOK_SKIP
, 0x15, 0x00}, /* Reserved */
145 {TOK_SKIP
, REG_AVID_START_PIXEL_LSB
, 0x55}, /* NTSC timing */
146 {TOK_SKIP
, REG_AVID_START_PIXEL_MSB
, 0x00},
147 {TOK_SKIP
, REG_AVID_STOP_PIXEL_LSB
, 0x25},
148 {TOK_SKIP
, REG_AVID_STOP_PIXEL_MSB
, 0x03},
149 {TOK_SKIP
, REG_HSYNC_START_PIXEL_LSB
, 0x00}, /* NTSC timing */
150 {TOK_SKIP
, REG_HSYNC_START_PIXEL_MSB
, 0x00},
151 {TOK_SKIP
, REG_HSYNC_STOP_PIXEL_LSB
, 0x40},
152 {TOK_SKIP
, REG_HSYNC_STOP_PIXEL_MSB
, 0x00},
153 {TOK_SKIP
, REG_VSYNC_START_LINE_LSB
, 0x04}, /* NTSC timing */
154 {TOK_SKIP
, REG_VSYNC_START_LINE_MSB
, 0x00},
155 {TOK_SKIP
, REG_VSYNC_STOP_LINE_LSB
, 0x07},
156 {TOK_SKIP
, REG_VSYNC_STOP_LINE_MSB
, 0x00},
157 {TOK_SKIP
, REG_VBLK_START_LINE_LSB
, 0x01}, /* NTSC timing */
158 {TOK_SKIP
, REG_VBLK_START_LINE_MSB
, 0x00},
159 {TOK_SKIP
, REG_VBLK_STOP_LINE_LSB
, 0x15},
160 {TOK_SKIP
, REG_VBLK_STOP_LINE_MSB
, 0x00},
161 {TOK_SKIP
, 0x26, 0x00}, /* Reserved */
162 {TOK_SKIP
, 0x27, 0x00}, /* Reserved */
163 {TOK_SKIP
, REG_FAST_SWTICH_CONTROL
, 0xCC},
164 {TOK_SKIP
, 0x29, 0x00}, /* Reserved */
165 {TOK_SKIP
, REG_FAST_SWTICH_SCART_DELAY
, 0x00},
166 {TOK_SKIP
, 0x2B, 0x00}, /* Reserved */
167 {TOK_SKIP
, REG_SCART_DELAY
, 0x00},
168 {TOK_SKIP
, REG_CTI_DELAY
, 0x00},
169 {TOK_SKIP
, REG_CTI_CONTROL
, 0x00},
170 {TOK_SKIP
, 0x2F, 0x00}, /* Reserved */
171 {TOK_SKIP
, 0x30, 0x00}, /* Reserved */
172 {TOK_SKIP
, 0x31, 0x00}, /* Reserved */
173 {TOK_WRITE
, REG_SYNC_CONTROL
, 0x00}, /* HS, VS active high */
174 {TOK_WRITE
, REG_OUTPUT_FORMATTER1
, 0x00}, /* 10-bit BT.656 */
175 {TOK_WRITE
, REG_OUTPUT_FORMATTER2
, 0x11}, /* Enable clk & data */
176 {TOK_WRITE
, REG_OUTPUT_FORMATTER3
, 0xEE}, /* Enable AVID & FLD */
177 {TOK_WRITE
, REG_OUTPUT_FORMATTER4
, 0xAF}, /* Enable VS & HS */
178 {TOK_WRITE
, REG_OUTPUT_FORMATTER5
, 0xFF},
179 {TOK_WRITE
, REG_OUTPUT_FORMATTER6
, 0xFF},
180 {TOK_WRITE
, REG_CLEAR_LOST_LOCK
, 0x01}, /* Clear status */
185 * List of image formats supported by TVP5146/47 decoder
186 * Currently we are using 8 bit mode only, but can be
187 * extended to 10/20 bit mode.
189 static const struct v4l2_fmtdesc tvp514x_fmt_list
[] = {
192 .type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
,
194 .description
= "8-bit UYVY 4:2:2 Format",
195 .pixelformat
= V4L2_PIX_FMT_UYVY
,
200 * Supported standards -
202 * Currently supports two standards only, need to add support for rest of the
203 * modes, like SECAM, etc...
205 static struct tvp514x_std_info tvp514x_std_list
[] = {
206 /* Standard: STD_NTSC_MJ */
208 .width
= NTSC_NUM_ACTIVE_PIXELS
,
209 .height
= NTSC_NUM_ACTIVE_LINES
,
210 .video_std
= VIDEO_STD_NTSC_MJ_BIT
,
215 .frameperiod
= {1001, 30000},
218 /* Standard: STD_PAL_BDGHIN */
221 .width
= PAL_NUM_ACTIVE_PIXELS
,
222 .height
= PAL_NUM_ACTIVE_LINES
,
223 .video_std
= VIDEO_STD_PAL_BDGHIN_BIT
,
228 .frameperiod
= {1, 25},
232 /* Standard: need to add for additional standard */
236 static inline struct tvp514x_decoder
*to_decoder(struct v4l2_subdev
*sd
)
238 return container_of(sd
, struct tvp514x_decoder
, sd
);
243 * Read a value from a register in an TVP5146/47 decoder device.
244 * Returns value read if successful, or non-zero (-1) otherwise.
246 static int tvp514x_read_reg(struct v4l2_subdev
*sd
, u8 reg
)
249 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
253 err
= i2c_smbus_read_byte_data(client
, reg
);
255 if (retry
<= I2C_RETRY_COUNT
) {
256 v4l2_warn(sd
, "Read: retry ... %d\n", retry
);
258 msleep_interruptible(10);
266 static void dump_reg(struct v4l2_subdev
*sd
, u8 reg
)
270 val
= tvp514x_read_reg(sd
, reg
);
271 v4l2_info(sd
, "Reg(0x%.2X): 0x%.2X\n", reg
, val
);
275 * Write a value to a register in an TVP5146/47 decoder device.
276 * Returns zero if successful, or non-zero otherwise.
278 static int tvp514x_write_reg(struct v4l2_subdev
*sd
, u8 reg
, u8 val
)
281 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
285 err
= i2c_smbus_write_byte_data(client
, reg
, val
);
287 if (retry
<= I2C_RETRY_COUNT
) {
288 v4l2_warn(sd
, "Write: retry ... %d\n", retry
);
290 msleep_interruptible(10);
299 * tvp514x_write_regs : Initializes a list of TVP5146/47 registers
300 * if token is TOK_TERM, then entire write operation terminates
301 * if token is TOK_DELAY, then a delay of 'val' msec is introduced
302 * if token is TOK_SKIP, then the register write is skipped
303 * if token is TOK_WRITE, then the register write is performed
305 * reglist - list of registers to be written
306 * Returns zero if successful, or non-zero otherwise.
308 static int tvp514x_write_regs(struct v4l2_subdev
*sd
,
309 const struct tvp514x_reg reglist
[])
312 const struct tvp514x_reg
*next
= reglist
;
314 for (; next
->token
!= TOK_TERM
; next
++) {
315 if (next
->token
== TOK_DELAY
) {
320 if (next
->token
== TOK_SKIP
)
323 err
= tvp514x_write_reg(sd
, next
->reg
, (u8
) next
->val
);
325 v4l2_err(sd
, "Write failed. Err[%d]\n", err
);
333 * tvp514x_get_current_std:
334 * Returns the current standard detected by TVP5146/47
336 static enum tvp514x_std
tvp514x_get_current_std(struct v4l2_subdev
*sd
)
340 std
= tvp514x_read_reg(sd
, REG_VIDEO_STD
);
341 if ((std
& VIDEO_STD_MASK
) == VIDEO_STD_AUTO_SWITCH_BIT
)
342 /* use the standard status register */
343 std_status
= tvp514x_read_reg(sd
, REG_VIDEO_STD_STATUS
);
345 std_status
= std
; /* use the standard register itself */
347 switch (std_status
& VIDEO_STD_MASK
) {
348 case VIDEO_STD_NTSC_MJ_BIT
:
351 case VIDEO_STD_PAL_BDGHIN_BIT
:
352 return STD_PAL_BDGHIN
;
362 * TVP5146/47 register dump function
364 static void tvp514x_reg_dump(struct v4l2_subdev
*sd
)
366 dump_reg(sd
, REG_INPUT_SEL
);
367 dump_reg(sd
, REG_AFE_GAIN_CTRL
);
368 dump_reg(sd
, REG_VIDEO_STD
);
369 dump_reg(sd
, REG_OPERATION_MODE
);
370 dump_reg(sd
, REG_COLOR_KILLER
);
371 dump_reg(sd
, REG_LUMA_CONTROL1
);
372 dump_reg(sd
, REG_LUMA_CONTROL2
);
373 dump_reg(sd
, REG_LUMA_CONTROL3
);
374 dump_reg(sd
, REG_BRIGHTNESS
);
375 dump_reg(sd
, REG_CONTRAST
);
376 dump_reg(sd
, REG_SATURATION
);
377 dump_reg(sd
, REG_HUE
);
378 dump_reg(sd
, REG_CHROMA_CONTROL1
);
379 dump_reg(sd
, REG_CHROMA_CONTROL2
);
380 dump_reg(sd
, REG_COMP_PR_SATURATION
);
381 dump_reg(sd
, REG_COMP_Y_CONTRAST
);
382 dump_reg(sd
, REG_COMP_PB_SATURATION
);
383 dump_reg(sd
, REG_COMP_Y_BRIGHTNESS
);
384 dump_reg(sd
, REG_AVID_START_PIXEL_LSB
);
385 dump_reg(sd
, REG_AVID_START_PIXEL_MSB
);
386 dump_reg(sd
, REG_AVID_STOP_PIXEL_LSB
);
387 dump_reg(sd
, REG_AVID_STOP_PIXEL_MSB
);
388 dump_reg(sd
, REG_HSYNC_START_PIXEL_LSB
);
389 dump_reg(sd
, REG_HSYNC_START_PIXEL_MSB
);
390 dump_reg(sd
, REG_HSYNC_STOP_PIXEL_LSB
);
391 dump_reg(sd
, REG_HSYNC_STOP_PIXEL_MSB
);
392 dump_reg(sd
, REG_VSYNC_START_LINE_LSB
);
393 dump_reg(sd
, REG_VSYNC_START_LINE_MSB
);
394 dump_reg(sd
, REG_VSYNC_STOP_LINE_LSB
);
395 dump_reg(sd
, REG_VSYNC_STOP_LINE_MSB
);
396 dump_reg(sd
, REG_VBLK_START_LINE_LSB
);
397 dump_reg(sd
, REG_VBLK_START_LINE_MSB
);
398 dump_reg(sd
, REG_VBLK_STOP_LINE_LSB
);
399 dump_reg(sd
, REG_VBLK_STOP_LINE_MSB
);
400 dump_reg(sd
, REG_SYNC_CONTROL
);
401 dump_reg(sd
, REG_OUTPUT_FORMATTER1
);
402 dump_reg(sd
, REG_OUTPUT_FORMATTER2
);
403 dump_reg(sd
, REG_OUTPUT_FORMATTER3
);
404 dump_reg(sd
, REG_OUTPUT_FORMATTER4
);
405 dump_reg(sd
, REG_OUTPUT_FORMATTER5
);
406 dump_reg(sd
, REG_OUTPUT_FORMATTER6
);
407 dump_reg(sd
, REG_CLEAR_LOST_LOCK
);
411 * Configure the TVP5146/47 with the current register settings
412 * Returns zero if successful, or non-zero otherwise.
414 static int tvp514x_configure(struct v4l2_subdev
*sd
,
415 struct tvp514x_decoder
*decoder
)
419 /* common register initialization */
421 tvp514x_write_regs(sd
, decoder
->tvp514x_regs
);
426 tvp514x_reg_dump(sd
);
432 * Detect if an tvp514x is present, and if so which revision.
433 * A device is considered to be detected if the chip ID (LSB and MSB)
434 * registers match the expected values.
435 * Any value of the rom version register is accepted.
436 * Returns ENODEV error number if no device is detected, or zero
437 * if a device is detected.
439 static int tvp514x_detect(struct v4l2_subdev
*sd
,
440 struct tvp514x_decoder
*decoder
)
442 u8 chip_id_msb
, chip_id_lsb
, rom_ver
;
443 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
445 chip_id_msb
= tvp514x_read_reg(sd
, REG_CHIP_ID_MSB
);
446 chip_id_lsb
= tvp514x_read_reg(sd
, REG_CHIP_ID_LSB
);
447 rom_ver
= tvp514x_read_reg(sd
, REG_ROM_VERSION
);
449 v4l2_dbg(1, debug
, sd
,
450 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
451 chip_id_msb
, chip_id_lsb
, rom_ver
);
452 if ((chip_id_msb
!= TVP514X_CHIP_ID_MSB
)
453 || ((chip_id_lsb
!= TVP5146_CHIP_ID_LSB
)
454 && (chip_id_lsb
!= TVP5147_CHIP_ID_LSB
))) {
455 /* We didn't read the values we expected, so this must not be
458 v4l2_err(sd
, "chip id mismatch msb:0x%x lsb:0x%x\n",
459 chip_id_msb
, chip_id_lsb
);
463 decoder
->ver
= rom_ver
;
465 v4l2_info(sd
, "%s (Version - 0x%.2x) found at 0x%x (%s)\n",
466 client
->name
, decoder
->ver
,
467 client
->addr
<< 1, client
->adapter
->name
);
472 * Following are decoder interface functions implemented by
473 * TVP5146/47 decoder driver.
477 * tvp514x_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
478 * @sd: pointer to standard V4L2 sub-device structure
479 * @std_id: standard V4L2 std_id ioctl enum
481 * Returns the current standard detected by TVP5146/47. If no active input is
482 * detected, returns -EINVAL
484 static int tvp514x_querystd(struct v4l2_subdev
*sd
, v4l2_std_id
*std_id
)
486 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
487 enum tvp514x_std current_std
;
488 enum tvp514x_input input_sel
;
489 u8 sync_lock_status
, lock_mask
;
494 /* get the current standard */
495 current_std
= tvp514x_get_current_std(sd
);
496 if (current_std
== STD_INVALID
)
499 input_sel
= decoder
->input
;
502 case INPUT_CVBS_VI1A
:
503 case INPUT_CVBS_VI1B
:
504 case INPUT_CVBS_VI1C
:
505 case INPUT_CVBS_VI2A
:
506 case INPUT_CVBS_VI2B
:
507 case INPUT_CVBS_VI2C
:
508 case INPUT_CVBS_VI3A
:
509 case INPUT_CVBS_VI3B
:
510 case INPUT_CVBS_VI3C
:
511 case INPUT_CVBS_VI4A
:
512 lock_mask
= STATUS_CLR_SUBCAR_LOCK_BIT
|
513 STATUS_HORZ_SYNC_LOCK_BIT
|
514 STATUS_VIRT_SYNC_LOCK_BIT
;
517 case INPUT_SVIDEO_VI2A_VI1A
:
518 case INPUT_SVIDEO_VI2B_VI1B
:
519 case INPUT_SVIDEO_VI2C_VI1C
:
520 case INPUT_SVIDEO_VI2A_VI3A
:
521 case INPUT_SVIDEO_VI2B_VI3B
:
522 case INPUT_SVIDEO_VI2C_VI3C
:
523 case INPUT_SVIDEO_VI4A_VI1A
:
524 case INPUT_SVIDEO_VI4A_VI1B
:
525 case INPUT_SVIDEO_VI4A_VI1C
:
526 case INPUT_SVIDEO_VI4A_VI3A
:
527 case INPUT_SVIDEO_VI4A_VI3B
:
528 case INPUT_SVIDEO_VI4A_VI3C
:
529 lock_mask
= STATUS_HORZ_SYNC_LOCK_BIT
|
530 STATUS_VIRT_SYNC_LOCK_BIT
;
532 /*Need to add other interfaces*/
536 /* check whether signal is locked */
537 sync_lock_status
= tvp514x_read_reg(sd
, REG_STATUS1
);
538 if (lock_mask
!= (sync_lock_status
& lock_mask
))
539 return -EINVAL
; /* No input detected */
541 decoder
->current_std
= current_std
;
542 *std_id
= decoder
->std_list
[current_std
].standard
.id
;
544 v4l2_dbg(1, debug
, sd
, "Current STD: %s",
545 decoder
->std_list
[current_std
].standard
.name
);
550 * tvp514x_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl
551 * @sd: pointer to standard V4L2 sub-device structure
552 * @std_id: standard V4L2 v4l2_std_id ioctl enum
554 * If std_id is supported, sets the requested standard. Otherwise, returns
557 static int tvp514x_s_std(struct v4l2_subdev
*sd
, v4l2_std_id std_id
)
559 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
562 for (i
= 0; i
< decoder
->num_stds
; i
++)
563 if (std_id
& decoder
->std_list
[i
].standard
.id
)
566 if ((i
== decoder
->num_stds
) || (i
== STD_INVALID
))
569 err
= tvp514x_write_reg(sd
, REG_VIDEO_STD
,
570 decoder
->std_list
[i
].video_std
);
574 decoder
->current_std
= i
;
575 decoder
->tvp514x_regs
[REG_VIDEO_STD
].val
=
576 decoder
->std_list
[i
].video_std
;
578 v4l2_dbg(1, debug
, sd
, "Standard set to: %s",
579 decoder
->std_list
[i
].standard
.name
);
584 * tvp514x_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl
585 * @sd: pointer to standard V4L2 sub-device structure
586 * @index: number of the input
588 * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
589 * the input is not supported or there is no active signal present in the
592 static int tvp514x_s_routing(struct v4l2_subdev
*sd
,
593 u32 input
, u32 output
, u32 config
)
595 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
597 enum tvp514x_input input_sel
;
598 enum tvp514x_output output_sel
;
599 enum tvp514x_std current_std
= STD_INVALID
;
600 u8 sync_lock_status
, lock_mask
;
601 int try_count
= LOCK_RETRY_COUNT
;
603 if ((input
>= INPUT_INVALID
) ||
604 (output
>= OUTPUT_INVALID
))
605 return -EINVAL
; /* Index out of bound */
610 err
= tvp514x_write_reg(sd
, REG_INPUT_SEL
, input_sel
);
614 output_sel
|= tvp514x_read_reg(sd
,
615 REG_OUTPUT_FORMATTER1
) & 0x7;
616 err
= tvp514x_write_reg(sd
, REG_OUTPUT_FORMATTER1
,
621 decoder
->tvp514x_regs
[REG_INPUT_SEL
].val
= input_sel
;
622 decoder
->tvp514x_regs
[REG_OUTPUT_FORMATTER1
].val
= output_sel
;
625 msleep(LOCK_RETRY_DELAY
);
627 tvp514x_write_reg(sd
, REG_CLEAR_LOST_LOCK
, 0x01);
632 case INPUT_CVBS_VI1A
:
633 case INPUT_CVBS_VI1B
:
634 case INPUT_CVBS_VI1C
:
635 case INPUT_CVBS_VI2A
:
636 case INPUT_CVBS_VI2B
:
637 case INPUT_CVBS_VI2C
:
638 case INPUT_CVBS_VI3A
:
639 case INPUT_CVBS_VI3B
:
640 case INPUT_CVBS_VI3C
:
641 case INPUT_CVBS_VI4A
:
642 lock_mask
= STATUS_CLR_SUBCAR_LOCK_BIT
|
643 STATUS_HORZ_SYNC_LOCK_BIT
|
644 STATUS_VIRT_SYNC_LOCK_BIT
;
647 case INPUT_SVIDEO_VI2A_VI1A
:
648 case INPUT_SVIDEO_VI2B_VI1B
:
649 case INPUT_SVIDEO_VI2C_VI1C
:
650 case INPUT_SVIDEO_VI2A_VI3A
:
651 case INPUT_SVIDEO_VI2B_VI3B
:
652 case INPUT_SVIDEO_VI2C_VI3C
:
653 case INPUT_SVIDEO_VI4A_VI1A
:
654 case INPUT_SVIDEO_VI4A_VI1B
:
655 case INPUT_SVIDEO_VI4A_VI1C
:
656 case INPUT_SVIDEO_VI4A_VI3A
:
657 case INPUT_SVIDEO_VI4A_VI3B
:
658 case INPUT_SVIDEO_VI4A_VI3C
:
659 lock_mask
= STATUS_HORZ_SYNC_LOCK_BIT
|
660 STATUS_VIRT_SYNC_LOCK_BIT
;
662 /*Need to add other interfaces*/
667 while (try_count
-- > 0) {
668 /* Allow decoder to sync up with new input */
669 msleep(LOCK_RETRY_DELAY
);
671 /* get the current standard for future reference */
672 current_std
= tvp514x_get_current_std(sd
);
673 if (current_std
== STD_INVALID
)
676 sync_lock_status
= tvp514x_read_reg(sd
,
678 if (lock_mask
== (sync_lock_status
& lock_mask
))
679 break; /* Input detected */
682 if ((current_std
== STD_INVALID
) || (try_count
< 0))
685 decoder
->current_std
= current_std
;
686 decoder
->input
= input
;
687 decoder
->output
= output
;
689 v4l2_dbg(1, debug
, sd
, "Input set to: %d, std : %d",
690 input_sel
, current_std
);
696 * tvp514x_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl
697 * @sd: pointer to standard V4L2 sub-device structure
698 * @qctrl: standard V4L2 v4l2_queryctrl structure
700 * If the requested control is supported, returns the control information.
701 * Otherwise, returns -EINVAL if the control is not supported.
704 tvp514x_queryctrl(struct v4l2_subdev
*sd
, struct v4l2_queryctrl
*qctrl
)
712 case V4L2_CID_BRIGHTNESS
:
713 /* Brightness supported is (0-255),
715 err
= v4l2_ctrl_query_fill(qctrl
, 0, 255, 1, 128);
717 case V4L2_CID_CONTRAST
:
718 case V4L2_CID_SATURATION
:
719 /* Saturation and Contrast supported is -
720 * Contrast: 0 - 255 (Default - 128)
721 * Saturation: 0 - 255 (Default - 128)
723 err
= v4l2_ctrl_query_fill(qctrl
, 0, 255, 1, 128);
726 /* Hue Supported is -
727 * Hue - -180 - +180 (Default - 0, Step - +180)
729 err
= v4l2_ctrl_query_fill(qctrl
, -180, 180, 180, 0);
731 case V4L2_CID_AUTOGAIN
:
733 * Auto Gain supported is -
734 * 0 - 1 (Default - 1)
736 err
= v4l2_ctrl_query_fill(qctrl
, 0, 1, 1, 1);
739 v4l2_err(sd
, "invalid control id %d\n", qctrl
->id
);
743 v4l2_dbg(1, debug
, sd
, "Query Control:%s: Min - %d, Max - %d, Def - %d",
744 qctrl
->name
, qctrl
->minimum
, qctrl
->maximum
,
745 qctrl
->default_value
);
751 * tvp514x_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl
752 * @sd: pointer to standard V4L2 sub-device structure
753 * @ctrl: pointer to v4l2_control structure
755 * If the requested control is supported, returns the control's current
756 * value from the decoder. Otherwise, returns -EINVAL if the control is not
760 tvp514x_g_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
762 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
768 case V4L2_CID_BRIGHTNESS
:
769 ctrl
->value
= decoder
->tvp514x_regs
[REG_BRIGHTNESS
].val
;
771 case V4L2_CID_CONTRAST
:
772 ctrl
->value
= decoder
->tvp514x_regs
[REG_CONTRAST
].val
;
774 case V4L2_CID_SATURATION
:
775 ctrl
->value
= decoder
->tvp514x_regs
[REG_SATURATION
].val
;
778 ctrl
->value
= decoder
->tvp514x_regs
[REG_HUE
].val
;
779 if (ctrl
->value
== 0x7F)
781 else if (ctrl
->value
== 0x80)
787 case V4L2_CID_AUTOGAIN
:
788 ctrl
->value
= decoder
->tvp514x_regs
[REG_AFE_GAIN_CTRL
].val
;
789 if ((ctrl
->value
& 0x3) == 3)
796 v4l2_err(sd
, "invalid control id %d\n", ctrl
->id
);
800 v4l2_dbg(1, debug
, sd
, "Get Control: ID - %d - %d",
801 ctrl
->id
, ctrl
->value
);
806 * tvp514x_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl
807 * @sd: pointer to standard V4L2 sub-device structure
808 * @ctrl: pointer to v4l2_control structure
810 * If the requested control is supported, sets the control's current
811 * value in HW. Otherwise, returns -EINVAL if the control is not supported.
814 tvp514x_s_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
816 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
817 int err
= -EINVAL
, value
;
825 case V4L2_CID_BRIGHTNESS
:
826 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
827 v4l2_err(sd
, "invalid brightness setting %d\n",
831 err
= tvp514x_write_reg(sd
, REG_BRIGHTNESS
,
836 decoder
->tvp514x_regs
[REG_BRIGHTNESS
].val
= value
;
838 case V4L2_CID_CONTRAST
:
839 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
840 v4l2_err(sd
, "invalid contrast setting %d\n",
844 err
= tvp514x_write_reg(sd
, REG_CONTRAST
, value
);
848 decoder
->tvp514x_regs
[REG_CONTRAST
].val
= value
;
850 case V4L2_CID_SATURATION
:
851 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
852 v4l2_err(sd
, "invalid saturation setting %d\n",
856 err
= tvp514x_write_reg(sd
, REG_SATURATION
, value
);
860 decoder
->tvp514x_regs
[REG_SATURATION
].val
= value
;
865 else if (value
== -180)
870 v4l2_err(sd
, "invalid hue setting %d\n", ctrl
->value
);
873 err
= tvp514x_write_reg(sd
, REG_HUE
, value
);
877 decoder
->tvp514x_regs
[REG_HUE
].val
= value
;
879 case V4L2_CID_AUTOGAIN
:
885 v4l2_err(sd
, "invalid auto gain setting %d\n",
889 err
= tvp514x_write_reg(sd
, REG_AFE_GAIN_CTRL
, value
);
893 decoder
->tvp514x_regs
[REG_AFE_GAIN_CTRL
].val
= value
;
896 v4l2_err(sd
, "invalid control id %d\n", ctrl
->id
);
900 v4l2_dbg(1, debug
, sd
, "Set Control: ID - %d - %d",
901 ctrl
->id
, ctrl
->value
);
907 * tvp514x_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl
908 * @sd: pointer to standard V4L2 sub-device structure
909 * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
911 * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
914 tvp514x_enum_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_fmtdesc
*fmt
)
916 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
923 if ((index
>= decoder
->num_fmts
) || (index
< 0))
924 return -EINVAL
; /* Index out of bound */
926 if (fmt
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
927 return -EINVAL
; /* only capture is supported */
929 memcpy(fmt
, &decoder
->fmt_list
[index
],
930 sizeof(struct v4l2_fmtdesc
));
932 v4l2_dbg(1, debug
, sd
, "Current FMT: index - %d (%s)",
933 decoder
->fmt_list
[index
].index
,
934 decoder
->fmt_list
[index
].description
);
939 * tvp514x_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl
940 * @sd: pointer to standard V4L2 sub-device structure
941 * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
943 * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
944 * ioctl is used to negotiate the image capture size and pixel format
945 * without actually making it take effect.
948 tvp514x_try_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
950 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
952 struct v4l2_pix_format
*pix
;
953 enum tvp514x_std current_std
;
958 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
959 f
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
963 /* Calculate height and width based on current standard */
964 current_std
= tvp514x_get_current_std(sd
);
965 if (current_std
== STD_INVALID
)
968 decoder
->current_std
= current_std
;
969 pix
->width
= decoder
->std_list
[current_std
].width
;
970 pix
->height
= decoder
->std_list
[current_std
].height
;
972 for (ifmt
= 0; ifmt
< decoder
->num_fmts
; ifmt
++) {
973 if (pix
->pixelformat
==
974 decoder
->fmt_list
[ifmt
].pixelformat
)
977 if (ifmt
== decoder
->num_fmts
)
978 ifmt
= 0; /* None of the format matched, select default */
979 pix
->pixelformat
= decoder
->fmt_list
[ifmt
].pixelformat
;
981 pix
->field
= V4L2_FIELD_INTERLACED
;
982 pix
->bytesperline
= pix
->width
* 2;
983 pix
->sizeimage
= pix
->bytesperline
* pix
->height
;
984 pix
->colorspace
= V4L2_COLORSPACE_SMPTE170M
;
987 v4l2_dbg(1, debug
, sd
, "Try FMT: pixelformat - %s, bytesperline - %d"
988 "Width - %d, Height - %d",
989 decoder
->fmt_list
[ifmt
].description
, pix
->bytesperline
,
990 pix
->width
, pix
->height
);
995 * tvp514x_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl
996 * @sd: pointer to standard V4L2 sub-device structure
997 * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
999 * If the requested format is supported, configures the HW to use that
1000 * format, returns error code if format not supported or HW can't be
1001 * correctly configured.
1004 tvp514x_s_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
1006 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1007 struct v4l2_pix_format
*pix
;
1013 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1014 return -EINVAL
; /* only capture is supported */
1017 rval
= tvp514x_try_fmt_cap(sd
, f
);
1021 decoder
->pix
= *pix
;
1027 * tvp514x_g_fmt_cap - V4L2 decoder interface handler for tvp514x_g_fmt_cap
1028 * @sd: pointer to standard V4L2 sub-device structure
1029 * @f: pointer to standard V4L2 v4l2_format structure
1031 * Returns the decoder's current pixel format in the v4l2_format
1035 tvp514x_g_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
1037 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1042 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1043 return -EINVAL
; /* only capture is supported */
1045 f
->fmt
.pix
= decoder
->pix
;
1047 v4l2_dbg(1, debug
, sd
, "Current FMT: bytesperline - %d"
1048 "Width - %d, Height - %d",
1049 decoder
->pix
.bytesperline
,
1050 decoder
->pix
.width
, decoder
->pix
.height
);
1055 * tvp514x_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl
1056 * @sd: pointer to standard V4L2 sub-device structure
1057 * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
1059 * Returns the decoder's video CAPTURE parameters.
1062 tvp514x_g_parm(struct v4l2_subdev
*sd
, struct v4l2_streamparm
*a
)
1064 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1065 struct v4l2_captureparm
*cparm
;
1066 enum tvp514x_std current_std
;
1071 if (a
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1072 return -EINVAL
; /* only capture is supported */
1074 memset(a
, 0, sizeof(*a
));
1075 a
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1077 /* get the current standard */
1078 current_std
= tvp514x_get_current_std(sd
);
1079 if (current_std
== STD_INVALID
)
1082 decoder
->current_std
= current_std
;
1084 cparm
= &a
->parm
.capture
;
1085 cparm
->capability
= V4L2_CAP_TIMEPERFRAME
;
1086 cparm
->timeperframe
=
1087 decoder
->std_list
[current_std
].standard
.frameperiod
;
1093 * tvp514x_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl
1094 * @sd: pointer to standard V4L2 sub-device structure
1095 * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
1097 * Configures the decoder to use the input parameters, if possible. If
1098 * not possible, returns the appropriate error code.
1101 tvp514x_s_parm(struct v4l2_subdev
*sd
, struct v4l2_streamparm
*a
)
1103 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1104 struct v4l2_fract
*timeperframe
;
1105 enum tvp514x_std current_std
;
1110 if (a
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1111 return -EINVAL
; /* only capture is supported */
1113 timeperframe
= &a
->parm
.capture
.timeperframe
;
1115 /* get the current standard */
1116 current_std
= tvp514x_get_current_std(sd
);
1117 if (current_std
== STD_INVALID
)
1120 decoder
->current_std
= current_std
;
1123 decoder
->std_list
[current_std
].standard
.frameperiod
;
1129 * tvp514x_s_stream - V4L2 decoder interface handler for vidioc_int_s_power_num
1130 * @sd: pointer to standard V4L2 sub-device structure
1131 * @enable: streaming enable or disable
1133 * Sets streaming to enable or disable, if possible.
1135 static int tvp514x_s_stream(struct v4l2_subdev
*sd
, int enable
)
1138 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
1139 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1141 if (decoder
->streaming
== enable
)
1147 /* Power Down Sequence */
1148 err
= tvp514x_write_reg(sd
, REG_OPERATION_MODE
, 0x01);
1150 v4l2_err(sd
, "Unable to turn off decoder\n");
1153 decoder
->streaming
= enable
;
1158 struct tvp514x_reg
*int_seq
= (struct tvp514x_reg
*)
1159 client
->driver
->id_table
->driver_data
;
1161 /* Power Up Sequence */
1162 err
= tvp514x_write_regs(sd
, int_seq
);
1164 v4l2_err(sd
, "Unable to turn on decoder\n");
1167 /* Detect if not already detected */
1168 err
= tvp514x_detect(sd
, decoder
);
1170 v4l2_err(sd
, "Unable to detect decoder\n");
1173 err
= tvp514x_configure(sd
, decoder
);
1175 v4l2_err(sd
, "Unable to configure decoder\n");
1178 decoder
->streaming
= enable
;
1189 static const struct v4l2_subdev_core_ops tvp514x_core_ops
= {
1190 .queryctrl
= tvp514x_queryctrl
,
1191 .g_ctrl
= tvp514x_g_ctrl
,
1192 .s_ctrl
= tvp514x_s_ctrl
,
1193 .s_std
= tvp514x_s_std
,
1196 static const struct v4l2_subdev_video_ops tvp514x_video_ops
= {
1197 .s_routing
= tvp514x_s_routing
,
1198 .querystd
= tvp514x_querystd
,
1199 .enum_fmt
= tvp514x_enum_fmt_cap
,
1200 .g_fmt
= tvp514x_g_fmt_cap
,
1201 .try_fmt
= tvp514x_try_fmt_cap
,
1202 .s_fmt
= tvp514x_s_fmt_cap
,
1203 .g_parm
= tvp514x_g_parm
,
1204 .s_parm
= tvp514x_s_parm
,
1205 .s_stream
= tvp514x_s_stream
,
1208 static const struct v4l2_subdev_ops tvp514x_ops
= {
1209 .core
= &tvp514x_core_ops
,
1210 .video
= &tvp514x_video_ops
,
1213 static struct tvp514x_decoder tvp514x_dev
= {
1216 .fmt_list
= tvp514x_fmt_list
,
1217 .num_fmts
= ARRAY_SIZE(tvp514x_fmt_list
),
1219 .pix
= {/* Default to NTSC 8-bit YUV 422 */
1220 .width
= NTSC_NUM_ACTIVE_PIXELS
,
1221 .height
= NTSC_NUM_ACTIVE_LINES
,
1222 .pixelformat
= V4L2_PIX_FMT_UYVY
,
1223 .field
= V4L2_FIELD_INTERLACED
,
1224 .bytesperline
= NTSC_NUM_ACTIVE_PIXELS
* 2,
1226 NTSC_NUM_ACTIVE_PIXELS
* 2 * NTSC_NUM_ACTIVE_LINES
,
1227 .colorspace
= V4L2_COLORSPACE_SMPTE170M
,
1230 .current_std
= STD_NTSC_MJ
,
1231 .std_list
= tvp514x_std_list
,
1232 .num_stds
= ARRAY_SIZE(tvp514x_std_list
),
1237 * tvp514x_probe - decoder driver i2c probe handler
1238 * @client: i2c driver client device structure
1239 * @id: i2c driver id table
1241 * Register decoder as an i2c client device and V4L2
1245 tvp514x_probe(struct i2c_client
*client
, const struct i2c_device_id
*id
)
1247 struct tvp514x_decoder
*decoder
;
1248 struct v4l2_subdev
*sd
;
1250 /* Check if the adapter supports the needed features */
1251 if (!i2c_check_functionality(client
->adapter
, I2C_FUNC_SMBUS_BYTE_DATA
))
1254 if (!client
->dev
.platform_data
) {
1255 v4l2_err(client
, "No platform data!!\n");
1259 decoder
= kzalloc(sizeof(*decoder
), GFP_KERNEL
);
1264 * Initialize the tvp514x_decoder with default configuration
1266 *decoder
= tvp514x_dev
;
1267 /* Copy default register configuration */
1268 memcpy(decoder
->tvp514x_regs
, tvp514x_reg_list_default
,
1269 sizeof(tvp514x_reg_list_default
));
1272 * Copy board specific information here
1274 decoder
->pdata
= client
->dev
.platform_data
;
1277 * Fetch platform specific data, and configure the
1278 * tvp514x_reg_list[] accordingly. Since this is one
1279 * time configuration, no need to preserve.
1281 decoder
->tvp514x_regs
[REG_OUTPUT_FORMATTER2
].val
|=
1282 (decoder
->pdata
->clk_polarity
<< 1);
1283 decoder
->tvp514x_regs
[REG_SYNC_CONTROL
].val
|=
1284 ((decoder
->pdata
->hs_polarity
<< 2) |
1285 (decoder
->pdata
->vs_polarity
<< 3));
1286 /* Set default standard to auto */
1287 decoder
->tvp514x_regs
[REG_VIDEO_STD
].val
=
1288 VIDEO_STD_AUTO_SWITCH_BIT
;
1290 /* Register with V4L2 layer as slave device */
1292 v4l2_i2c_subdev_init(sd
, client
, &tvp514x_ops
);
1294 v4l2_info(sd
, "%s decoder driver registered !!\n", sd
->name
);
1301 * tvp514x_remove - decoder driver i2c remove handler
1302 * @client: i2c driver client device structure
1304 * Unregister decoder as an i2c client device and V4L2
1305 * device. Complement of tvp514x_probe().
1307 static int tvp514x_remove(struct i2c_client
*client
)
1309 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
1310 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1312 v4l2_device_unregister_subdev(sd
);
1317 * TVP5146 Init/Power on Sequence
1319 static const struct tvp514x_reg tvp5146_init_reg_seq
[] = {
1320 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x02},
1321 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1322 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0x80},
1323 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1324 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1325 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1326 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1327 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1328 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x00},
1329 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1330 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1335 * TVP5147 Init/Power on Sequence
1337 static const struct tvp514x_reg tvp5147_init_reg_seq
[] = {
1338 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x02},
1339 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1340 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0x80},
1341 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1342 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1343 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1344 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1345 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1346 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x16},
1347 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1348 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xA0},
1349 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x16},
1350 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1351 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1352 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1353 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x00},
1354 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1355 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1360 * TVP5146M2/TVP5147M1 Init/Power on Sequence
1362 static const struct tvp514x_reg tvp514xm_init_reg_seq
[] = {
1363 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1364 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1369 * I2C Device Table -
1371 * name - Name of the actual device/chip.
1372 * driver_data - Driver data
1374 static const struct i2c_device_id tvp514x_id
[] = {
1375 {"tvp5146", (unsigned long)tvp5146_init_reg_seq
},
1376 {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq
},
1377 {"tvp5147", (unsigned long)tvp5147_init_reg_seq
},
1378 {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq
},
1382 MODULE_DEVICE_TABLE(i2c
, tvp514x_id
);
1384 static struct i2c_driver tvp514x_driver
= {
1386 .owner
= THIS_MODULE
,
1387 .name
= TVP514X_MODULE_NAME
,
1389 .probe
= tvp514x_probe
,
1390 .remove
= tvp514x_remove
,
1391 .id_table
= tvp514x_id
,
1394 static int __init
tvp514x_init(void)
1396 return i2c_add_driver(&tvp514x_driver
);
1399 static void __exit
tvp514x_exit(void)
1401 i2c_del_driver(&tvp514x_driver
);
1404 module_init(tvp514x_init
);
1405 module_exit(tvp514x_exit
);