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/slab.h>
33 #include <linux/delay.h>
34 #include <linux/videodev2.h>
36 #include <media/v4l2-device.h>
37 #include <media/v4l2-common.h>
38 #include <media/v4l2-chip-ident.h>
39 #include <media/tvp514x.h>
41 #include "tvp514x_regs.h"
44 #define TVP514X_MODULE_NAME "tvp514x"
46 /* Private macros for TVP */
47 #define I2C_RETRY_COUNT (5)
48 #define LOCK_RETRY_COUNT (5)
49 #define LOCK_RETRY_DELAY (200)
53 module_param(debug
, bool, 0644);
54 MODULE_PARM_DESC(debug
, "Debug level (0-1)");
56 MODULE_AUTHOR("Texas Instruments");
57 MODULE_DESCRIPTION("TVP514X linux decoder driver");
58 MODULE_LICENSE("GPL");
60 /* enum tvp514x_std - enum for supported standards */
68 * struct tvp514x_std_info - Structure to store standard informations
69 * @width: Line width in pixels
70 * @height:Number of active lines
71 * @video_std: Value to write in REG_VIDEO_STD register
72 * @standard: v4l2 standard structure information
74 struct tvp514x_std_info
{
78 struct v4l2_standard standard
;
81 static struct tvp514x_reg tvp514x_reg_list_default
[0x40];
83 * struct tvp514x_decoder - TVP5146/47 decoder object
84 * @sd: Subdevice Slave handle
85 * @tvp514x_regs: copy of hw's regs with preset values.
86 * @pdata: Board specific
88 * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
89 * @pix: Current pixel format
90 * @num_fmts: Number of formats
91 * @fmt_list: Format list
92 * @current_std: Current standard
93 * @num_stds: Number of standards
94 * @std_list: Standards list
95 * @input: Input routing at chip level
96 * @output: Output routing at chip level
98 struct tvp514x_decoder
{
99 struct v4l2_subdev sd
;
100 struct tvp514x_reg tvp514x_regs
[ARRAY_SIZE(tvp514x_reg_list_default
)];
101 const struct tvp514x_platform_data
*pdata
;
106 struct v4l2_pix_format pix
;
108 const struct v4l2_fmtdesc
*fmt_list
;
110 enum tvp514x_std current_std
;
112 struct tvp514x_std_info
*std_list
;
113 /* Input and Output Routing parameters */
118 /* TVP514x default register values */
119 static struct tvp514x_reg tvp514x_reg_list_default
[] = {
120 /* Composite selected */
121 {TOK_WRITE
, REG_INPUT_SEL
, 0x05},
122 {TOK_WRITE
, REG_AFE_GAIN_CTRL
, 0x0F},
124 {TOK_WRITE
, REG_VIDEO_STD
, 0x00},
125 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
126 {TOK_SKIP
, REG_AUTOSWITCH_MASK
, 0x3F},
127 {TOK_WRITE
, REG_COLOR_KILLER
, 0x10},
128 {TOK_WRITE
, REG_LUMA_CONTROL1
, 0x00},
129 {TOK_WRITE
, REG_LUMA_CONTROL2
, 0x00},
130 {TOK_WRITE
, REG_LUMA_CONTROL3
, 0x02},
131 {TOK_WRITE
, REG_BRIGHTNESS
, 0x80},
132 {TOK_WRITE
, REG_CONTRAST
, 0x80},
133 {TOK_WRITE
, REG_SATURATION
, 0x80},
134 {TOK_WRITE
, REG_HUE
, 0x00},
135 {TOK_WRITE
, REG_CHROMA_CONTROL1
, 0x00},
136 {TOK_WRITE
, REG_CHROMA_CONTROL2
, 0x0E},
138 {TOK_SKIP
, 0x0F, 0x00},
139 {TOK_WRITE
, REG_COMP_PR_SATURATION
, 0x80},
140 {TOK_WRITE
, REG_COMP_Y_CONTRAST
, 0x80},
141 {TOK_WRITE
, REG_COMP_PB_SATURATION
, 0x80},
143 {TOK_SKIP
, 0x13, 0x00},
144 {TOK_WRITE
, REG_COMP_Y_BRIGHTNESS
, 0x80},
146 {TOK_SKIP
, 0x15, 0x00},
148 {TOK_SKIP
, REG_AVID_START_PIXEL_LSB
, 0x55},
149 {TOK_SKIP
, REG_AVID_START_PIXEL_MSB
, 0x00},
150 {TOK_SKIP
, REG_AVID_STOP_PIXEL_LSB
, 0x25},
151 {TOK_SKIP
, REG_AVID_STOP_PIXEL_MSB
, 0x03},
153 {TOK_SKIP
, REG_HSYNC_START_PIXEL_LSB
, 0x00},
154 {TOK_SKIP
, REG_HSYNC_START_PIXEL_MSB
, 0x00},
155 {TOK_SKIP
, REG_HSYNC_STOP_PIXEL_LSB
, 0x40},
156 {TOK_SKIP
, REG_HSYNC_STOP_PIXEL_MSB
, 0x00},
158 {TOK_SKIP
, REG_VSYNC_START_LINE_LSB
, 0x04},
159 {TOK_SKIP
, REG_VSYNC_START_LINE_MSB
, 0x00},
160 {TOK_SKIP
, REG_VSYNC_STOP_LINE_LSB
, 0x07},
161 {TOK_SKIP
, REG_VSYNC_STOP_LINE_MSB
, 0x00},
163 {TOK_SKIP
, REG_VBLK_START_LINE_LSB
, 0x01},
164 {TOK_SKIP
, REG_VBLK_START_LINE_MSB
, 0x00},
165 {TOK_SKIP
, REG_VBLK_STOP_LINE_LSB
, 0x15},
166 {TOK_SKIP
, REG_VBLK_STOP_LINE_MSB
, 0x00},
168 {TOK_SKIP
, 0x26, 0x00},
170 {TOK_SKIP
, 0x27, 0x00},
171 {TOK_SKIP
, REG_FAST_SWTICH_CONTROL
, 0xCC},
173 {TOK_SKIP
, 0x29, 0x00},
174 {TOK_SKIP
, REG_FAST_SWTICH_SCART_DELAY
, 0x00},
176 {TOK_SKIP
, 0x2B, 0x00},
177 {TOK_SKIP
, REG_SCART_DELAY
, 0x00},
178 {TOK_SKIP
, REG_CTI_DELAY
, 0x00},
179 {TOK_SKIP
, REG_CTI_CONTROL
, 0x00},
181 {TOK_SKIP
, 0x2F, 0x00},
183 {TOK_SKIP
, 0x30, 0x00},
185 {TOK_SKIP
, 0x31, 0x00},
186 /* HS, VS active high */
187 {TOK_WRITE
, REG_SYNC_CONTROL
, 0x00},
189 {TOK_WRITE
, REG_OUTPUT_FORMATTER1
, 0x00},
190 /* Enable clk & data */
191 {TOK_WRITE
, REG_OUTPUT_FORMATTER2
, 0x11},
192 /* Enable AVID & FLD */
193 {TOK_WRITE
, REG_OUTPUT_FORMATTER3
, 0xEE},
195 {TOK_WRITE
, REG_OUTPUT_FORMATTER4
, 0xAF},
196 {TOK_WRITE
, REG_OUTPUT_FORMATTER5
, 0xFF},
197 {TOK_WRITE
, REG_OUTPUT_FORMATTER6
, 0xFF},
199 {TOK_WRITE
, REG_CLEAR_LOST_LOCK
, 0x01},
204 * List of image formats supported by TVP5146/47 decoder
205 * Currently we are using 8 bit mode only, but can be
206 * extended to 10/20 bit mode.
208 static const struct v4l2_fmtdesc tvp514x_fmt_list
[] = {
211 .type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
,
213 .description
= "8-bit UYVY 4:2:2 Format",
214 .pixelformat
= V4L2_PIX_FMT_UYVY
,
219 * Supported standards -
221 * Currently supports two standards only, need to add support for rest of the
222 * modes, like SECAM, etc...
224 static struct tvp514x_std_info tvp514x_std_list
[] = {
225 /* Standard: STD_NTSC_MJ */
227 .width
= NTSC_NUM_ACTIVE_PIXELS
,
228 .height
= NTSC_NUM_ACTIVE_LINES
,
229 .video_std
= VIDEO_STD_NTSC_MJ_BIT
,
234 .frameperiod
= {1001, 30000},
237 /* Standard: STD_PAL_BDGHIN */
240 .width
= PAL_NUM_ACTIVE_PIXELS
,
241 .height
= PAL_NUM_ACTIVE_LINES
,
242 .video_std
= VIDEO_STD_PAL_BDGHIN_BIT
,
247 .frameperiod
= {1, 25},
251 /* Standard: need to add for additional standard */
255 static inline struct tvp514x_decoder
*to_decoder(struct v4l2_subdev
*sd
)
257 return container_of(sd
, struct tvp514x_decoder
, sd
);
262 * tvp514x_read_reg() - Read a value from a register in an TVP5146/47.
263 * @sd: ptr to v4l2_subdev struct
264 * @reg: TVP5146/47 register address
266 * Returns value read if successful, or non-zero (-1) otherwise.
268 static int tvp514x_read_reg(struct v4l2_subdev
*sd
, u8 reg
)
271 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
275 err
= i2c_smbus_read_byte_data(client
, reg
);
277 if (retry
<= I2C_RETRY_COUNT
) {
278 v4l2_warn(sd
, "Read: retry ... %d\n", retry
);
280 msleep_interruptible(10);
289 * dump_reg() - dump the register content of TVP5146/47.
290 * @sd: ptr to v4l2_subdev struct
291 * @reg: TVP5146/47 register address
293 static void dump_reg(struct v4l2_subdev
*sd
, u8 reg
)
297 val
= tvp514x_read_reg(sd
, reg
);
298 v4l2_info(sd
, "Reg(0x%.2X): 0x%.2X\n", reg
, val
);
302 * tvp514x_write_reg() - Write a value to a register in TVP5146/47
303 * @sd: ptr to v4l2_subdev struct
304 * @reg: TVP5146/47 register address
305 * @val: value to be written to the register
307 * Write a value to a register in an TVP5146/47 decoder device.
308 * Returns zero if successful, or non-zero otherwise.
310 static int tvp514x_write_reg(struct v4l2_subdev
*sd
, u8 reg
, u8 val
)
313 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
317 err
= i2c_smbus_write_byte_data(client
, reg
, val
);
319 if (retry
<= I2C_RETRY_COUNT
) {
320 v4l2_warn(sd
, "Write: retry ... %d\n", retry
);
322 msleep_interruptible(10);
331 * tvp514x_write_regs() : Initializes a list of TVP5146/47 registers
332 * @sd: ptr to v4l2_subdev struct
333 * @reglist: list of TVP5146/47 registers and values
335 * Initializes a list of TVP5146/47 registers:-
336 * if token is TOK_TERM, then entire write operation terminates
337 * if token is TOK_DELAY, then a delay of 'val' msec is introduced
338 * if token is TOK_SKIP, then the register write is skipped
339 * if token is TOK_WRITE, then the register write is performed
340 * Returns zero if successful, or non-zero otherwise.
342 static int tvp514x_write_regs(struct v4l2_subdev
*sd
,
343 const struct tvp514x_reg reglist
[])
346 const struct tvp514x_reg
*next
= reglist
;
348 for (; next
->token
!= TOK_TERM
; next
++) {
349 if (next
->token
== TOK_DELAY
) {
354 if (next
->token
== TOK_SKIP
)
357 err
= tvp514x_write_reg(sd
, next
->reg
, (u8
) next
->val
);
359 v4l2_err(sd
, "Write failed. Err[%d]\n", err
);
367 * tvp514x_get_current_std() : Get the current standard detected by TVP5146/47
368 * @sd: ptr to v4l2_subdev struct
370 * Get current standard detected by TVP5146/47, STD_INVALID if there is no
373 static enum tvp514x_std
tvp514x_get_current_std(struct v4l2_subdev
*sd
)
377 std
= tvp514x_read_reg(sd
, REG_VIDEO_STD
);
378 if ((std
& VIDEO_STD_MASK
) == VIDEO_STD_AUTO_SWITCH_BIT
)
379 /* use the standard status register */
380 std_status
= tvp514x_read_reg(sd
, REG_VIDEO_STD_STATUS
);
382 /* use the standard register itself */
385 switch (std_status
& VIDEO_STD_MASK
) {
386 case VIDEO_STD_NTSC_MJ_BIT
:
389 case VIDEO_STD_PAL_BDGHIN_BIT
:
390 return STD_PAL_BDGHIN
;
399 /* TVP5146/47 register dump function */
400 static void tvp514x_reg_dump(struct v4l2_subdev
*sd
)
402 dump_reg(sd
, REG_INPUT_SEL
);
403 dump_reg(sd
, REG_AFE_GAIN_CTRL
);
404 dump_reg(sd
, REG_VIDEO_STD
);
405 dump_reg(sd
, REG_OPERATION_MODE
);
406 dump_reg(sd
, REG_COLOR_KILLER
);
407 dump_reg(sd
, REG_LUMA_CONTROL1
);
408 dump_reg(sd
, REG_LUMA_CONTROL2
);
409 dump_reg(sd
, REG_LUMA_CONTROL3
);
410 dump_reg(sd
, REG_BRIGHTNESS
);
411 dump_reg(sd
, REG_CONTRAST
);
412 dump_reg(sd
, REG_SATURATION
);
413 dump_reg(sd
, REG_HUE
);
414 dump_reg(sd
, REG_CHROMA_CONTROL1
);
415 dump_reg(sd
, REG_CHROMA_CONTROL2
);
416 dump_reg(sd
, REG_COMP_PR_SATURATION
);
417 dump_reg(sd
, REG_COMP_Y_CONTRAST
);
418 dump_reg(sd
, REG_COMP_PB_SATURATION
);
419 dump_reg(sd
, REG_COMP_Y_BRIGHTNESS
);
420 dump_reg(sd
, REG_AVID_START_PIXEL_LSB
);
421 dump_reg(sd
, REG_AVID_START_PIXEL_MSB
);
422 dump_reg(sd
, REG_AVID_STOP_PIXEL_LSB
);
423 dump_reg(sd
, REG_AVID_STOP_PIXEL_MSB
);
424 dump_reg(sd
, REG_HSYNC_START_PIXEL_LSB
);
425 dump_reg(sd
, REG_HSYNC_START_PIXEL_MSB
);
426 dump_reg(sd
, REG_HSYNC_STOP_PIXEL_LSB
);
427 dump_reg(sd
, REG_HSYNC_STOP_PIXEL_MSB
);
428 dump_reg(sd
, REG_VSYNC_START_LINE_LSB
);
429 dump_reg(sd
, REG_VSYNC_START_LINE_MSB
);
430 dump_reg(sd
, REG_VSYNC_STOP_LINE_LSB
);
431 dump_reg(sd
, REG_VSYNC_STOP_LINE_MSB
);
432 dump_reg(sd
, REG_VBLK_START_LINE_LSB
);
433 dump_reg(sd
, REG_VBLK_START_LINE_MSB
);
434 dump_reg(sd
, REG_VBLK_STOP_LINE_LSB
);
435 dump_reg(sd
, REG_VBLK_STOP_LINE_MSB
);
436 dump_reg(sd
, REG_SYNC_CONTROL
);
437 dump_reg(sd
, REG_OUTPUT_FORMATTER1
);
438 dump_reg(sd
, REG_OUTPUT_FORMATTER2
);
439 dump_reg(sd
, REG_OUTPUT_FORMATTER3
);
440 dump_reg(sd
, REG_OUTPUT_FORMATTER4
);
441 dump_reg(sd
, REG_OUTPUT_FORMATTER5
);
442 dump_reg(sd
, REG_OUTPUT_FORMATTER6
);
443 dump_reg(sd
, REG_CLEAR_LOST_LOCK
);
447 * tvp514x_configure() - Configure the TVP5146/47 registers
448 * @sd: ptr to v4l2_subdev struct
449 * @decoder: ptr to tvp514x_decoder structure
451 * Returns zero if successful, or non-zero otherwise.
453 static int tvp514x_configure(struct v4l2_subdev
*sd
,
454 struct tvp514x_decoder
*decoder
)
458 /* common register initialization */
460 tvp514x_write_regs(sd
, decoder
->tvp514x_regs
);
465 tvp514x_reg_dump(sd
);
471 * tvp514x_detect() - Detect if an tvp514x is present, and if so which revision.
472 * @sd: pointer to standard V4L2 sub-device structure
473 * @decoder: pointer to tvp514x_decoder structure
475 * A device is considered to be detected if the chip ID (LSB and MSB)
476 * registers match the expected values.
477 * Any value of the rom version register is accepted.
478 * Returns ENODEV error number if no device is detected, or zero
479 * if a device is detected.
481 static int tvp514x_detect(struct v4l2_subdev
*sd
,
482 struct tvp514x_decoder
*decoder
)
484 u8 chip_id_msb
, chip_id_lsb
, rom_ver
;
485 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
487 chip_id_msb
= tvp514x_read_reg(sd
, REG_CHIP_ID_MSB
);
488 chip_id_lsb
= tvp514x_read_reg(sd
, REG_CHIP_ID_LSB
);
489 rom_ver
= tvp514x_read_reg(sd
, REG_ROM_VERSION
);
491 v4l2_dbg(1, debug
, sd
,
492 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
493 chip_id_msb
, chip_id_lsb
, rom_ver
);
494 if ((chip_id_msb
!= TVP514X_CHIP_ID_MSB
)
495 || ((chip_id_lsb
!= TVP5146_CHIP_ID_LSB
)
496 && (chip_id_lsb
!= TVP5147_CHIP_ID_LSB
))) {
497 /* We didn't read the values we expected, so this must not be
500 v4l2_err(sd
, "chip id mismatch msb:0x%x lsb:0x%x\n",
501 chip_id_msb
, chip_id_lsb
);
505 decoder
->ver
= rom_ver
;
507 v4l2_info(sd
, "%s (Version - 0x%.2x) found at 0x%x (%s)\n",
508 client
->name
, decoder
->ver
,
509 client
->addr
<< 1, client
->adapter
->name
);
514 * tvp514x_querystd() - V4L2 decoder interface handler for querystd
515 * @sd: pointer to standard V4L2 sub-device structure
516 * @std_id: standard V4L2 std_id ioctl enum
518 * Returns the current standard detected by TVP5146/47. If no active input is
519 * detected, returns -EINVAL
521 static int tvp514x_querystd(struct v4l2_subdev
*sd
, v4l2_std_id
*std_id
)
523 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
524 enum tvp514x_std current_std
;
525 enum tvp514x_input input_sel
;
526 u8 sync_lock_status
, lock_mask
;
531 /* get the current standard */
532 current_std
= tvp514x_get_current_std(sd
);
533 if (current_std
== STD_INVALID
)
536 input_sel
= decoder
->input
;
539 case INPUT_CVBS_VI1A
:
540 case INPUT_CVBS_VI1B
:
541 case INPUT_CVBS_VI1C
:
542 case INPUT_CVBS_VI2A
:
543 case INPUT_CVBS_VI2B
:
544 case INPUT_CVBS_VI2C
:
545 case INPUT_CVBS_VI3A
:
546 case INPUT_CVBS_VI3B
:
547 case INPUT_CVBS_VI3C
:
548 case INPUT_CVBS_VI4A
:
549 lock_mask
= STATUS_CLR_SUBCAR_LOCK_BIT
|
550 STATUS_HORZ_SYNC_LOCK_BIT
|
551 STATUS_VIRT_SYNC_LOCK_BIT
;
554 case INPUT_SVIDEO_VI2A_VI1A
:
555 case INPUT_SVIDEO_VI2B_VI1B
:
556 case INPUT_SVIDEO_VI2C_VI1C
:
557 case INPUT_SVIDEO_VI2A_VI3A
:
558 case INPUT_SVIDEO_VI2B_VI3B
:
559 case INPUT_SVIDEO_VI2C_VI3C
:
560 case INPUT_SVIDEO_VI4A_VI1A
:
561 case INPUT_SVIDEO_VI4A_VI1B
:
562 case INPUT_SVIDEO_VI4A_VI1C
:
563 case INPUT_SVIDEO_VI4A_VI3A
:
564 case INPUT_SVIDEO_VI4A_VI3B
:
565 case INPUT_SVIDEO_VI4A_VI3C
:
566 lock_mask
= STATUS_HORZ_SYNC_LOCK_BIT
|
567 STATUS_VIRT_SYNC_LOCK_BIT
;
569 /*Need to add other interfaces*/
573 /* check whether signal is locked */
574 sync_lock_status
= tvp514x_read_reg(sd
, REG_STATUS1
);
575 if (lock_mask
!= (sync_lock_status
& lock_mask
))
576 return -EINVAL
; /* No input detected */
578 decoder
->current_std
= current_std
;
579 *std_id
= decoder
->std_list
[current_std
].standard
.id
;
581 v4l2_dbg(1, debug
, sd
, "Current STD: %s",
582 decoder
->std_list
[current_std
].standard
.name
);
587 * tvp514x_s_std() - V4L2 decoder interface handler for s_std
588 * @sd: pointer to standard V4L2 sub-device structure
589 * @std_id: standard V4L2 v4l2_std_id ioctl enum
591 * If std_id is supported, sets the requested standard. Otherwise, returns
594 static int tvp514x_s_std(struct v4l2_subdev
*sd
, v4l2_std_id std_id
)
596 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
599 for (i
= 0; i
< decoder
->num_stds
; i
++)
600 if (std_id
& decoder
->std_list
[i
].standard
.id
)
603 if ((i
== decoder
->num_stds
) || (i
== STD_INVALID
))
606 err
= tvp514x_write_reg(sd
, REG_VIDEO_STD
,
607 decoder
->std_list
[i
].video_std
);
611 decoder
->current_std
= i
;
612 decoder
->tvp514x_regs
[REG_VIDEO_STD
].val
=
613 decoder
->std_list
[i
].video_std
;
615 v4l2_dbg(1, debug
, sd
, "Standard set to: %s",
616 decoder
->std_list
[i
].standard
.name
);
621 * tvp514x_s_routing() - V4L2 decoder interface handler for s_routing
622 * @sd: pointer to standard V4L2 sub-device structure
623 * @input: input selector for routing the signal
624 * @output: output selector for routing the signal
625 * @config: config value. Not used
627 * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
628 * the input is not supported or there is no active signal present in the
631 static int tvp514x_s_routing(struct v4l2_subdev
*sd
,
632 u32 input
, u32 output
, u32 config
)
634 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
636 enum tvp514x_input input_sel
;
637 enum tvp514x_output output_sel
;
638 enum tvp514x_std current_std
= STD_INVALID
;
639 u8 sync_lock_status
, lock_mask
;
640 int try_count
= LOCK_RETRY_COUNT
;
642 if ((input
>= INPUT_INVALID
) ||
643 (output
>= OUTPUT_INVALID
))
644 /* Index out of bound */
650 err
= tvp514x_write_reg(sd
, REG_INPUT_SEL
, input_sel
);
654 output_sel
|= tvp514x_read_reg(sd
,
655 REG_OUTPUT_FORMATTER1
) & 0x7;
656 err
= tvp514x_write_reg(sd
, REG_OUTPUT_FORMATTER1
,
661 decoder
->tvp514x_regs
[REG_INPUT_SEL
].val
= input_sel
;
662 decoder
->tvp514x_regs
[REG_OUTPUT_FORMATTER1
].val
= output_sel
;
665 msleep(LOCK_RETRY_DELAY
);
667 tvp514x_write_reg(sd
, REG_CLEAR_LOST_LOCK
, 0x01);
672 case INPUT_CVBS_VI1A
:
673 case INPUT_CVBS_VI1B
:
674 case INPUT_CVBS_VI1C
:
675 case INPUT_CVBS_VI2A
:
676 case INPUT_CVBS_VI2B
:
677 case INPUT_CVBS_VI2C
:
678 case INPUT_CVBS_VI3A
:
679 case INPUT_CVBS_VI3B
:
680 case INPUT_CVBS_VI3C
:
681 case INPUT_CVBS_VI4A
:
682 lock_mask
= STATUS_CLR_SUBCAR_LOCK_BIT
|
683 STATUS_HORZ_SYNC_LOCK_BIT
|
684 STATUS_VIRT_SYNC_LOCK_BIT
;
687 case INPUT_SVIDEO_VI2A_VI1A
:
688 case INPUT_SVIDEO_VI2B_VI1B
:
689 case INPUT_SVIDEO_VI2C_VI1C
:
690 case INPUT_SVIDEO_VI2A_VI3A
:
691 case INPUT_SVIDEO_VI2B_VI3B
:
692 case INPUT_SVIDEO_VI2C_VI3C
:
693 case INPUT_SVIDEO_VI4A_VI1A
:
694 case INPUT_SVIDEO_VI4A_VI1B
:
695 case INPUT_SVIDEO_VI4A_VI1C
:
696 case INPUT_SVIDEO_VI4A_VI3A
:
697 case INPUT_SVIDEO_VI4A_VI3B
:
698 case INPUT_SVIDEO_VI4A_VI3C
:
699 lock_mask
= STATUS_HORZ_SYNC_LOCK_BIT
|
700 STATUS_VIRT_SYNC_LOCK_BIT
;
702 /* Need to add other interfaces*/
707 while (try_count
-- > 0) {
708 /* Allow decoder to sync up with new input */
709 msleep(LOCK_RETRY_DELAY
);
711 /* get the current standard for future reference */
712 current_std
= tvp514x_get_current_std(sd
);
713 if (current_std
== STD_INVALID
)
716 sync_lock_status
= tvp514x_read_reg(sd
,
718 if (lock_mask
== (sync_lock_status
& lock_mask
))
723 if ((current_std
== STD_INVALID
) || (try_count
< 0))
726 decoder
->current_std
= current_std
;
727 decoder
->input
= input
;
728 decoder
->output
= output
;
730 v4l2_dbg(1, debug
, sd
, "Input set to: %d, std : %d",
731 input_sel
, current_std
);
737 * tvp514x_queryctrl() - V4L2 decoder interface handler for queryctrl
738 * @sd: pointer to standard V4L2 sub-device structure
739 * @qctrl: standard V4L2 v4l2_queryctrl structure
741 * If the requested control is supported, returns the control information.
742 * Otherwise, returns -EINVAL if the control is not supported.
745 tvp514x_queryctrl(struct v4l2_subdev
*sd
, struct v4l2_queryctrl
*qctrl
)
753 case V4L2_CID_BRIGHTNESS
:
754 /* Brightness supported is (0-255), */
755 err
= v4l2_ctrl_query_fill(qctrl
, 0, 255, 1, 128);
757 case V4L2_CID_CONTRAST
:
758 case V4L2_CID_SATURATION
:
760 * Saturation and Contrast supported is -
761 * Contrast: 0 - 255 (Default - 128)
762 * Saturation: 0 - 255 (Default - 128)
764 err
= v4l2_ctrl_query_fill(qctrl
, 0, 255, 1, 128);
767 /* Hue Supported is -
768 * Hue - -180 - +180 (Default - 0, Step - +180)
770 err
= v4l2_ctrl_query_fill(qctrl
, -180, 180, 180, 0);
772 case V4L2_CID_AUTOGAIN
:
774 * Auto Gain supported is -
775 * 0 - 1 (Default - 1)
777 err
= v4l2_ctrl_query_fill(qctrl
, 0, 1, 1, 1);
780 v4l2_err(sd
, "invalid control id %d\n", qctrl
->id
);
784 v4l2_dbg(1, debug
, sd
, "Query Control:%s: Min - %d, Max - %d, Def - %d",
785 qctrl
->name
, qctrl
->minimum
, qctrl
->maximum
,
786 qctrl
->default_value
);
792 * tvp514x_g_ctrl() - V4L2 decoder interface handler for g_ctrl
793 * @sd: pointer to standard V4L2 sub-device structure
794 * @ctrl: pointer to v4l2_control structure
796 * If the requested control is supported, returns the control's current
797 * value from the decoder. Otherwise, returns -EINVAL if the control is not
801 tvp514x_g_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
803 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
809 case V4L2_CID_BRIGHTNESS
:
810 ctrl
->value
= decoder
->tvp514x_regs
[REG_BRIGHTNESS
].val
;
812 case V4L2_CID_CONTRAST
:
813 ctrl
->value
= decoder
->tvp514x_regs
[REG_CONTRAST
].val
;
815 case V4L2_CID_SATURATION
:
816 ctrl
->value
= decoder
->tvp514x_regs
[REG_SATURATION
].val
;
819 ctrl
->value
= decoder
->tvp514x_regs
[REG_HUE
].val
;
820 if (ctrl
->value
== 0x7F)
822 else if (ctrl
->value
== 0x80)
828 case V4L2_CID_AUTOGAIN
:
829 ctrl
->value
= decoder
->tvp514x_regs
[REG_AFE_GAIN_CTRL
].val
;
830 if ((ctrl
->value
& 0x3) == 3)
837 v4l2_err(sd
, "invalid control id %d\n", ctrl
->id
);
841 v4l2_dbg(1, debug
, sd
, "Get Control: ID - %d - %d",
842 ctrl
->id
, ctrl
->value
);
847 * tvp514x_s_ctrl() - V4L2 decoder interface handler for s_ctrl
848 * @sd: pointer to standard V4L2 sub-device structure
849 * @ctrl: pointer to v4l2_control structure
851 * If the requested control is supported, sets the control's current
852 * value in HW. Otherwise, returns -EINVAL if the control is not supported.
855 tvp514x_s_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
857 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
858 int err
= -EINVAL
, value
;
866 case V4L2_CID_BRIGHTNESS
:
867 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
868 v4l2_err(sd
, "invalid brightness setting %d\n",
872 err
= tvp514x_write_reg(sd
, REG_BRIGHTNESS
,
877 decoder
->tvp514x_regs
[REG_BRIGHTNESS
].val
= value
;
879 case V4L2_CID_CONTRAST
:
880 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
881 v4l2_err(sd
, "invalid contrast setting %d\n",
885 err
= tvp514x_write_reg(sd
, REG_CONTRAST
, value
);
889 decoder
->tvp514x_regs
[REG_CONTRAST
].val
= value
;
891 case V4L2_CID_SATURATION
:
892 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
893 v4l2_err(sd
, "invalid saturation setting %d\n",
897 err
= tvp514x_write_reg(sd
, REG_SATURATION
, value
);
901 decoder
->tvp514x_regs
[REG_SATURATION
].val
= value
;
906 else if (value
== -180)
911 v4l2_err(sd
, "invalid hue setting %d\n", ctrl
->value
);
914 err
= tvp514x_write_reg(sd
, REG_HUE
, value
);
918 decoder
->tvp514x_regs
[REG_HUE
].val
= value
;
920 case V4L2_CID_AUTOGAIN
:
926 v4l2_err(sd
, "invalid auto gain setting %d\n",
930 err
= tvp514x_write_reg(sd
, REG_AFE_GAIN_CTRL
, value
);
934 decoder
->tvp514x_regs
[REG_AFE_GAIN_CTRL
].val
= value
;
937 v4l2_err(sd
, "invalid control id %d\n", ctrl
->id
);
941 v4l2_dbg(1, debug
, sd
, "Set Control: ID - %d - %d",
942 ctrl
->id
, ctrl
->value
);
948 * tvp514x_enum_fmt_cap() - V4L2 decoder interface handler for enum_fmt
949 * @sd: pointer to standard V4L2 sub-device structure
950 * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
952 * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
955 tvp514x_enum_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_fmtdesc
*fmt
)
957 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
964 if ((index
>= decoder
->num_fmts
) || (index
< 0))
965 /* Index out of bound */
968 if (fmt
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
969 /* only capture is supported */
972 memcpy(fmt
, &decoder
->fmt_list
[index
],
973 sizeof(struct v4l2_fmtdesc
));
975 v4l2_dbg(1, debug
, sd
, "Current FMT: index - %d (%s)",
976 decoder
->fmt_list
[index
].index
,
977 decoder
->fmt_list
[index
].description
);
982 * tvp514x_try_fmt_cap() - V4L2 decoder interface handler for try_fmt
983 * @sd: pointer to standard V4L2 sub-device structure
984 * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
986 * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
987 * ioctl is used to negotiate the image capture size and pixel format
988 * without actually making it take effect.
991 tvp514x_try_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
993 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
995 struct v4l2_pix_format
*pix
;
996 enum tvp514x_std current_std
;
1001 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1002 /* only capture is supported */
1003 f
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1007 /* Calculate height and width based on current standard */
1008 current_std
= tvp514x_get_current_std(sd
);
1009 if (current_std
== STD_INVALID
)
1012 decoder
->current_std
= current_std
;
1013 pix
->width
= decoder
->std_list
[current_std
].width
;
1014 pix
->height
= decoder
->std_list
[current_std
].height
;
1016 for (ifmt
= 0; ifmt
< decoder
->num_fmts
; ifmt
++) {
1017 if (pix
->pixelformat
==
1018 decoder
->fmt_list
[ifmt
].pixelformat
)
1021 if (ifmt
== decoder
->num_fmts
)
1022 /* None of the format matched, select default */
1024 pix
->pixelformat
= decoder
->fmt_list
[ifmt
].pixelformat
;
1026 pix
->field
= V4L2_FIELD_INTERLACED
;
1027 pix
->bytesperline
= pix
->width
* 2;
1028 pix
->sizeimage
= pix
->bytesperline
* pix
->height
;
1029 pix
->colorspace
= V4L2_COLORSPACE_SMPTE170M
;
1032 v4l2_dbg(1, debug
, sd
, "Try FMT: pixelformat - %s, bytesperline - %d"
1033 "Width - %d, Height - %d",
1034 decoder
->fmt_list
[ifmt
].description
, pix
->bytesperline
,
1035 pix
->width
, pix
->height
);
1040 * tvp514x_s_fmt_cap() - V4L2 decoder interface handler for s_fmt
1041 * @sd: pointer to standard V4L2 sub-device structure
1042 * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
1044 * If the requested format is supported, configures the HW to use that
1045 * format, returns error code if format not supported or HW can't be
1046 * correctly configured.
1049 tvp514x_s_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
1051 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1052 struct v4l2_pix_format
*pix
;
1058 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1059 /* only capture is supported */
1063 rval
= tvp514x_try_fmt_cap(sd
, f
);
1067 decoder
->pix
= *pix
;
1073 * tvp514x_g_fmt_cap() - V4L2 decoder interface handler for tvp514x_g_fmt_cap
1074 * @sd: pointer to standard V4L2 sub-device structure
1075 * @f: pointer to standard V4L2 v4l2_format structure
1077 * Returns the decoder's current pixel format in the v4l2_format
1081 tvp514x_g_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
1083 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1088 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1089 /* only capture is supported */
1092 f
->fmt
.pix
= decoder
->pix
;
1094 v4l2_dbg(1, debug
, sd
, "Current FMT: bytesperline - %d"
1095 "Width - %d, Height - %d",
1096 decoder
->pix
.bytesperline
,
1097 decoder
->pix
.width
, decoder
->pix
.height
);
1102 * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm
1103 * @sd: pointer to standard V4L2 sub-device structure
1104 * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
1106 * Returns the decoder's video CAPTURE parameters.
1109 tvp514x_g_parm(struct v4l2_subdev
*sd
, struct v4l2_streamparm
*a
)
1111 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1112 struct v4l2_captureparm
*cparm
;
1113 enum tvp514x_std current_std
;
1118 if (a
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1119 /* only capture is supported */
1122 memset(a
, 0, sizeof(*a
));
1123 a
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1125 /* get the current standard */
1126 current_std
= tvp514x_get_current_std(sd
);
1127 if (current_std
== STD_INVALID
)
1130 decoder
->current_std
= current_std
;
1132 cparm
= &a
->parm
.capture
;
1133 cparm
->capability
= V4L2_CAP_TIMEPERFRAME
;
1134 cparm
->timeperframe
=
1135 decoder
->std_list
[current_std
].standard
.frameperiod
;
1141 * tvp514x_s_parm() - V4L2 decoder interface handler for s_parm
1142 * @sd: pointer to standard V4L2 sub-device structure
1143 * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
1145 * Configures the decoder to use the input parameters, if possible. If
1146 * not possible, returns the appropriate error code.
1149 tvp514x_s_parm(struct v4l2_subdev
*sd
, struct v4l2_streamparm
*a
)
1151 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1152 struct v4l2_fract
*timeperframe
;
1153 enum tvp514x_std current_std
;
1158 if (a
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1159 /* only capture is supported */
1162 timeperframe
= &a
->parm
.capture
.timeperframe
;
1164 /* get the current standard */
1165 current_std
= tvp514x_get_current_std(sd
);
1166 if (current_std
== STD_INVALID
)
1169 decoder
->current_std
= current_std
;
1172 decoder
->std_list
[current_std
].standard
.frameperiod
;
1178 * tvp514x_s_stream() - V4L2 decoder i/f handler for s_stream
1179 * @sd: pointer to standard V4L2 sub-device structure
1180 * @enable: streaming enable or disable
1182 * Sets streaming to enable or disable, if possible.
1184 static int tvp514x_s_stream(struct v4l2_subdev
*sd
, int enable
)
1187 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
1188 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1190 if (decoder
->streaming
== enable
)
1196 /* Power Down Sequence */
1197 err
= tvp514x_write_reg(sd
, REG_OPERATION_MODE
, 0x01);
1199 v4l2_err(sd
, "Unable to turn off decoder\n");
1202 decoder
->streaming
= enable
;
1207 struct tvp514x_reg
*int_seq
= (struct tvp514x_reg
*)
1208 client
->driver
->id_table
->driver_data
;
1210 /* Power Up Sequence */
1211 err
= tvp514x_write_regs(sd
, int_seq
);
1213 v4l2_err(sd
, "Unable to turn on decoder\n");
1216 /* Detect if not already detected */
1217 err
= tvp514x_detect(sd
, decoder
);
1219 v4l2_err(sd
, "Unable to detect decoder\n");
1222 err
= tvp514x_configure(sd
, decoder
);
1224 v4l2_err(sd
, "Unable to configure decoder\n");
1227 decoder
->streaming
= enable
;
1238 static const struct v4l2_subdev_core_ops tvp514x_core_ops
= {
1239 .queryctrl
= tvp514x_queryctrl
,
1240 .g_ctrl
= tvp514x_g_ctrl
,
1241 .s_ctrl
= tvp514x_s_ctrl
,
1242 .s_std
= tvp514x_s_std
,
1245 static const struct v4l2_subdev_video_ops tvp514x_video_ops
= {
1246 .s_routing
= tvp514x_s_routing
,
1247 .querystd
= tvp514x_querystd
,
1248 .enum_fmt
= tvp514x_enum_fmt_cap
,
1249 .g_fmt
= tvp514x_g_fmt_cap
,
1250 .try_fmt
= tvp514x_try_fmt_cap
,
1251 .s_fmt
= tvp514x_s_fmt_cap
,
1252 .g_parm
= tvp514x_g_parm
,
1253 .s_parm
= tvp514x_s_parm
,
1254 .s_stream
= tvp514x_s_stream
,
1257 static const struct v4l2_subdev_ops tvp514x_ops
= {
1258 .core
= &tvp514x_core_ops
,
1259 .video
= &tvp514x_video_ops
,
1262 static struct tvp514x_decoder tvp514x_dev
= {
1265 .fmt_list
= tvp514x_fmt_list
,
1266 .num_fmts
= ARRAY_SIZE(tvp514x_fmt_list
),
1269 /* Default to NTSC 8-bit YUV 422 */
1270 .width
= NTSC_NUM_ACTIVE_PIXELS
,
1271 .height
= NTSC_NUM_ACTIVE_LINES
,
1272 .pixelformat
= V4L2_PIX_FMT_UYVY
,
1273 .field
= V4L2_FIELD_INTERLACED
,
1274 .bytesperline
= NTSC_NUM_ACTIVE_PIXELS
* 2,
1276 NTSC_NUM_ACTIVE_PIXELS
* 2 * NTSC_NUM_ACTIVE_LINES
,
1277 .colorspace
= V4L2_COLORSPACE_SMPTE170M
,
1280 .current_std
= STD_NTSC_MJ
,
1281 .std_list
= tvp514x_std_list
,
1282 .num_stds
= ARRAY_SIZE(tvp514x_std_list
),
1287 * tvp514x_probe() - decoder driver i2c probe handler
1288 * @client: i2c driver client device structure
1289 * @id: i2c driver id table
1291 * Register decoder as an i2c client device and V4L2
1295 tvp514x_probe(struct i2c_client
*client
, const struct i2c_device_id
*id
)
1297 struct tvp514x_decoder
*decoder
;
1298 struct v4l2_subdev
*sd
;
1300 /* Check if the adapter supports the needed features */
1301 if (!i2c_check_functionality(client
->adapter
, I2C_FUNC_SMBUS_BYTE_DATA
))
1304 if (!client
->dev
.platform_data
) {
1305 v4l2_err(client
, "No platform data!!\n");
1309 decoder
= kzalloc(sizeof(*decoder
), GFP_KERNEL
);
1313 /* Initialize the tvp514x_decoder with default configuration */
1314 *decoder
= tvp514x_dev
;
1315 /* Copy default register configuration */
1316 memcpy(decoder
->tvp514x_regs
, tvp514x_reg_list_default
,
1317 sizeof(tvp514x_reg_list_default
));
1319 /* Copy board specific information here */
1320 decoder
->pdata
= client
->dev
.platform_data
;
1323 * Fetch platform specific data, and configure the
1324 * tvp514x_reg_list[] accordingly. Since this is one
1325 * time configuration, no need to preserve.
1327 decoder
->tvp514x_regs
[REG_OUTPUT_FORMATTER2
].val
|=
1328 (decoder
->pdata
->clk_polarity
<< 1);
1329 decoder
->tvp514x_regs
[REG_SYNC_CONTROL
].val
|=
1330 ((decoder
->pdata
->hs_polarity
<< 2) |
1331 (decoder
->pdata
->vs_polarity
<< 3));
1332 /* Set default standard to auto */
1333 decoder
->tvp514x_regs
[REG_VIDEO_STD
].val
=
1334 VIDEO_STD_AUTO_SWITCH_BIT
;
1336 /* Register with V4L2 layer as slave device */
1338 v4l2_i2c_subdev_init(sd
, client
, &tvp514x_ops
);
1340 v4l2_info(sd
, "%s decoder driver registered !!\n", sd
->name
);
1347 * tvp514x_remove() - decoder driver i2c remove handler
1348 * @client: i2c driver client device structure
1350 * Unregister decoder as an i2c client device and V4L2
1351 * device. Complement of tvp514x_probe().
1353 static int tvp514x_remove(struct i2c_client
*client
)
1355 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
1356 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1358 v4l2_device_unregister_subdev(sd
);
1362 /* TVP5146 Init/Power on Sequence */
1363 static const struct tvp514x_reg tvp5146_init_reg_seq
[] = {
1364 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x02},
1365 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1366 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0x80},
1367 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1368 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1369 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1370 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1371 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1372 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x00},
1373 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1374 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1378 /* TVP5147 Init/Power on Sequence */
1379 static const struct tvp514x_reg tvp5147_init_reg_seq
[] = {
1380 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x02},
1381 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1382 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0x80},
1383 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1384 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1385 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1386 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1387 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1388 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x16},
1389 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1390 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xA0},
1391 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x16},
1392 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1393 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1394 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1395 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x00},
1396 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1397 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1401 /* TVP5146M2/TVP5147M1 Init/Power on Sequence */
1402 static const struct tvp514x_reg tvp514xm_init_reg_seq
[] = {
1403 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1404 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1409 * I2C Device Table -
1411 * name - Name of the actual device/chip.
1412 * driver_data - Driver data
1414 static const struct i2c_device_id tvp514x_id
[] = {
1415 {"tvp5146", (unsigned long)tvp5146_init_reg_seq
},
1416 {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq
},
1417 {"tvp5147", (unsigned long)tvp5147_init_reg_seq
},
1418 {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq
},
1422 MODULE_DEVICE_TABLE(i2c
, tvp514x_id
);
1424 static struct i2c_driver tvp514x_driver
= {
1426 .owner
= THIS_MODULE
,
1427 .name
= TVP514X_MODULE_NAME
,
1429 .probe
= tvp514x_probe
,
1430 .remove
= tvp514x_remove
,
1431 .id_table
= tvp514x_id
,
1434 static int __init
tvp514x_init(void)
1436 return i2c_add_driver(&tvp514x_driver
);
1439 static void __exit
tvp514x_exit(void)
1441 i2c_del_driver(&tvp514x_driver
);
1444 module_init(tvp514x_init
);
1445 module_exit(tvp514x_exit
);