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");
59 /* enum tvp514x_std - enum for supported standards */
67 * struct tvp514x_std_info - Structure to store standard informations
68 * @width: Line width in pixels
69 * @height:Number of active lines
70 * @video_std: Value to write in REG_VIDEO_STD register
71 * @standard: v4l2 standard structure information
73 struct tvp514x_std_info
{
77 struct v4l2_standard standard
;
80 static struct tvp514x_reg tvp514x_reg_list_default
[0x40];
82 * struct tvp514x_decoder - TVP5146/47 decoder object
83 * @sd: Subdevice Slave handle
84 * @tvp514x_regs: copy of hw's regs with preset values.
85 * @pdata: Board specific
87 * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
88 * @pix: Current pixel format
89 * @num_fmts: Number of formats
90 * @fmt_list: Format list
91 * @current_std: Current standard
92 * @num_stds: Number of standards
93 * @std_list: Standards list
94 * @input: Input routing at chip level
95 * @output: Output routing at chip level
97 struct tvp514x_decoder
{
98 struct v4l2_subdev sd
;
99 struct tvp514x_reg tvp514x_regs
[ARRAY_SIZE(tvp514x_reg_list_default
)];
100 const struct tvp514x_platform_data
*pdata
;
105 struct v4l2_pix_format pix
;
107 const struct v4l2_fmtdesc
*fmt_list
;
109 enum tvp514x_std current_std
;
111 struct tvp514x_std_info
*std_list
;
112 /* Input and Output Routing parameters */
117 /* TVP514x default register values */
118 static struct tvp514x_reg tvp514x_reg_list_default
[] = {
119 /* Composite selected */
120 {TOK_WRITE
, REG_INPUT_SEL
, 0x05},
121 {TOK_WRITE
, REG_AFE_GAIN_CTRL
, 0x0F},
123 {TOK_WRITE
, REG_VIDEO_STD
, 0x00},
124 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
125 {TOK_SKIP
, REG_AUTOSWITCH_MASK
, 0x3F},
126 {TOK_WRITE
, REG_COLOR_KILLER
, 0x10},
127 {TOK_WRITE
, REG_LUMA_CONTROL1
, 0x00},
128 {TOK_WRITE
, REG_LUMA_CONTROL2
, 0x00},
129 {TOK_WRITE
, REG_LUMA_CONTROL3
, 0x02},
130 {TOK_WRITE
, REG_BRIGHTNESS
, 0x80},
131 {TOK_WRITE
, REG_CONTRAST
, 0x80},
132 {TOK_WRITE
, REG_SATURATION
, 0x80},
133 {TOK_WRITE
, REG_HUE
, 0x00},
134 {TOK_WRITE
, REG_CHROMA_CONTROL1
, 0x00},
135 {TOK_WRITE
, REG_CHROMA_CONTROL2
, 0x0E},
137 {TOK_SKIP
, 0x0F, 0x00},
138 {TOK_WRITE
, REG_COMP_PR_SATURATION
, 0x80},
139 {TOK_WRITE
, REG_COMP_Y_CONTRAST
, 0x80},
140 {TOK_WRITE
, REG_COMP_PB_SATURATION
, 0x80},
142 {TOK_SKIP
, 0x13, 0x00},
143 {TOK_WRITE
, REG_COMP_Y_BRIGHTNESS
, 0x80},
145 {TOK_SKIP
, 0x15, 0x00},
147 {TOK_SKIP
, REG_AVID_START_PIXEL_LSB
, 0x55},
148 {TOK_SKIP
, REG_AVID_START_PIXEL_MSB
, 0x00},
149 {TOK_SKIP
, REG_AVID_STOP_PIXEL_LSB
, 0x25},
150 {TOK_SKIP
, REG_AVID_STOP_PIXEL_MSB
, 0x03},
152 {TOK_SKIP
, REG_HSYNC_START_PIXEL_LSB
, 0x00},
153 {TOK_SKIP
, REG_HSYNC_START_PIXEL_MSB
, 0x00},
154 {TOK_SKIP
, REG_HSYNC_STOP_PIXEL_LSB
, 0x40},
155 {TOK_SKIP
, REG_HSYNC_STOP_PIXEL_MSB
, 0x00},
157 {TOK_SKIP
, REG_VSYNC_START_LINE_LSB
, 0x04},
158 {TOK_SKIP
, REG_VSYNC_START_LINE_MSB
, 0x00},
159 {TOK_SKIP
, REG_VSYNC_STOP_LINE_LSB
, 0x07},
160 {TOK_SKIP
, REG_VSYNC_STOP_LINE_MSB
, 0x00},
162 {TOK_SKIP
, REG_VBLK_START_LINE_LSB
, 0x01},
163 {TOK_SKIP
, REG_VBLK_START_LINE_MSB
, 0x00},
164 {TOK_SKIP
, REG_VBLK_STOP_LINE_LSB
, 0x15},
165 {TOK_SKIP
, REG_VBLK_STOP_LINE_MSB
, 0x00},
167 {TOK_SKIP
, 0x26, 0x00},
169 {TOK_SKIP
, 0x27, 0x00},
170 {TOK_SKIP
, REG_FAST_SWTICH_CONTROL
, 0xCC},
172 {TOK_SKIP
, 0x29, 0x00},
173 {TOK_SKIP
, REG_FAST_SWTICH_SCART_DELAY
, 0x00},
175 {TOK_SKIP
, 0x2B, 0x00},
176 {TOK_SKIP
, REG_SCART_DELAY
, 0x00},
177 {TOK_SKIP
, REG_CTI_DELAY
, 0x00},
178 {TOK_SKIP
, REG_CTI_CONTROL
, 0x00},
180 {TOK_SKIP
, 0x2F, 0x00},
182 {TOK_SKIP
, 0x30, 0x00},
184 {TOK_SKIP
, 0x31, 0x00},
185 /* HS, VS active high */
186 {TOK_WRITE
, REG_SYNC_CONTROL
, 0x00},
188 {TOK_WRITE
, REG_OUTPUT_FORMATTER1
, 0x00},
189 /* Enable clk & data */
190 {TOK_WRITE
, REG_OUTPUT_FORMATTER2
, 0x11},
191 /* Enable AVID & FLD */
192 {TOK_WRITE
, REG_OUTPUT_FORMATTER3
, 0xEE},
194 {TOK_WRITE
, REG_OUTPUT_FORMATTER4
, 0xAF},
195 {TOK_WRITE
, REG_OUTPUT_FORMATTER5
, 0xFF},
196 {TOK_WRITE
, REG_OUTPUT_FORMATTER6
, 0xFF},
198 {TOK_WRITE
, REG_CLEAR_LOST_LOCK
, 0x01},
203 * List of image formats supported by TVP5146/47 decoder
204 * Currently we are using 8 bit mode only, but can be
205 * extended to 10/20 bit mode.
207 static const struct v4l2_fmtdesc tvp514x_fmt_list
[] = {
210 .type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
,
212 .description
= "8-bit UYVY 4:2:2 Format",
213 .pixelformat
= V4L2_PIX_FMT_UYVY
,
217 .type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
,
219 .description
= "8-bit YUYV 4:2:2 Format",
220 .pixelformat
= V4L2_PIX_FMT_YUYV
,
225 * Supported standards -
227 * Currently supports two standards only, need to add support for rest of the
228 * modes, like SECAM, etc...
230 static struct tvp514x_std_info tvp514x_std_list
[] = {
231 /* Standard: STD_NTSC_MJ */
233 .width
= NTSC_NUM_ACTIVE_PIXELS
,
234 .height
= NTSC_NUM_ACTIVE_LINES
,
235 .video_std
= VIDEO_STD_NTSC_MJ_BIT
,
240 .frameperiod
= {1001, 30000},
243 /* Standard: STD_PAL_BDGHIN */
246 .width
= PAL_NUM_ACTIVE_PIXELS
,
247 .height
= PAL_NUM_ACTIVE_LINES
,
248 .video_std
= VIDEO_STD_PAL_BDGHIN_BIT
,
253 .frameperiod
= {1, 25},
257 /* Standard: need to add for additional standard */
261 static inline struct tvp514x_decoder
*to_decoder(struct v4l2_subdev
*sd
)
263 return container_of(sd
, struct tvp514x_decoder
, sd
);
268 * tvp514x_read_reg() - Read a value from a register in an TVP5146/47.
269 * @sd: ptr to v4l2_subdev struct
270 * @reg: TVP5146/47 register address
272 * Returns value read if successful, or non-zero (-1) otherwise.
274 static int tvp514x_read_reg(struct v4l2_subdev
*sd
, u8 reg
)
277 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
281 err
= i2c_smbus_read_byte_data(client
, reg
);
283 if (retry
<= I2C_RETRY_COUNT
) {
284 v4l2_warn(sd
, "Read: retry ... %d\n", retry
);
286 msleep_interruptible(10);
295 * dump_reg() - dump the register content of TVP5146/47.
296 * @sd: ptr to v4l2_subdev struct
297 * @reg: TVP5146/47 register address
299 static void dump_reg(struct v4l2_subdev
*sd
, u8 reg
)
303 val
= tvp514x_read_reg(sd
, reg
);
304 v4l2_info(sd
, "Reg(0x%.2X): 0x%.2X\n", reg
, val
);
308 * tvp514x_write_reg() - Write a value to a register in TVP5146/47
309 * @sd: ptr to v4l2_subdev struct
310 * @reg: TVP5146/47 register address
311 * @val: value to be written to the register
313 * Write a value to a register in an TVP5146/47 decoder device.
314 * Returns zero if successful, or non-zero otherwise.
316 static int tvp514x_write_reg(struct v4l2_subdev
*sd
, u8 reg
, u8 val
)
319 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
323 err
= i2c_smbus_write_byte_data(client
, reg
, val
);
325 if (retry
<= I2C_RETRY_COUNT
) {
326 v4l2_warn(sd
, "Write: retry ... %d\n", retry
);
328 msleep_interruptible(10);
337 * tvp514x_write_regs() : Initializes a list of TVP5146/47 registers
338 * @sd: ptr to v4l2_subdev struct
339 * @reglist: list of TVP5146/47 registers and values
341 * Initializes a list of TVP5146/47 registers:-
342 * if token is TOK_TERM, then entire write operation terminates
343 * if token is TOK_DELAY, then a delay of 'val' msec is introduced
344 * if token is TOK_SKIP, then the register write is skipped
345 * if token is TOK_WRITE, then the register write is performed
346 * Returns zero if successful, or non-zero otherwise.
348 static int tvp514x_write_regs(struct v4l2_subdev
*sd
,
349 const struct tvp514x_reg reglist
[])
352 const struct tvp514x_reg
*next
= reglist
;
354 for (; next
->token
!= TOK_TERM
; next
++) {
355 if (next
->token
== TOK_DELAY
) {
360 if (next
->token
== TOK_SKIP
)
363 err
= tvp514x_write_reg(sd
, next
->reg
, (u8
) next
->val
);
365 v4l2_err(sd
, "Write failed. Err[%d]\n", err
);
373 * tvp514x_get_current_std() : Get the current standard detected by TVP5146/47
374 * @sd: ptr to v4l2_subdev struct
376 * Get current standard detected by TVP5146/47, STD_INVALID if there is no
379 static enum tvp514x_std
tvp514x_get_current_std(struct v4l2_subdev
*sd
)
383 std
= tvp514x_read_reg(sd
, REG_VIDEO_STD
);
384 if ((std
& VIDEO_STD_MASK
) == VIDEO_STD_AUTO_SWITCH_BIT
)
385 /* use the standard status register */
386 std_status
= tvp514x_read_reg(sd
, REG_VIDEO_STD_STATUS
);
388 /* use the standard register itself */
391 switch (std_status
& VIDEO_STD_MASK
) {
392 case VIDEO_STD_NTSC_MJ_BIT
:
395 case VIDEO_STD_PAL_BDGHIN_BIT
:
396 return STD_PAL_BDGHIN
;
405 /* TVP5146/47 register dump function */
406 static void tvp514x_reg_dump(struct v4l2_subdev
*sd
)
408 dump_reg(sd
, REG_INPUT_SEL
);
409 dump_reg(sd
, REG_AFE_GAIN_CTRL
);
410 dump_reg(sd
, REG_VIDEO_STD
);
411 dump_reg(sd
, REG_OPERATION_MODE
);
412 dump_reg(sd
, REG_COLOR_KILLER
);
413 dump_reg(sd
, REG_LUMA_CONTROL1
);
414 dump_reg(sd
, REG_LUMA_CONTROL2
);
415 dump_reg(sd
, REG_LUMA_CONTROL3
);
416 dump_reg(sd
, REG_BRIGHTNESS
);
417 dump_reg(sd
, REG_CONTRAST
);
418 dump_reg(sd
, REG_SATURATION
);
419 dump_reg(sd
, REG_HUE
);
420 dump_reg(sd
, REG_CHROMA_CONTROL1
);
421 dump_reg(sd
, REG_CHROMA_CONTROL2
);
422 dump_reg(sd
, REG_COMP_PR_SATURATION
);
423 dump_reg(sd
, REG_COMP_Y_CONTRAST
);
424 dump_reg(sd
, REG_COMP_PB_SATURATION
);
425 dump_reg(sd
, REG_COMP_Y_BRIGHTNESS
);
426 dump_reg(sd
, REG_AVID_START_PIXEL_LSB
);
427 dump_reg(sd
, REG_AVID_START_PIXEL_MSB
);
428 dump_reg(sd
, REG_AVID_STOP_PIXEL_LSB
);
429 dump_reg(sd
, REG_AVID_STOP_PIXEL_MSB
);
430 dump_reg(sd
, REG_HSYNC_START_PIXEL_LSB
);
431 dump_reg(sd
, REG_HSYNC_START_PIXEL_MSB
);
432 dump_reg(sd
, REG_HSYNC_STOP_PIXEL_LSB
);
433 dump_reg(sd
, REG_HSYNC_STOP_PIXEL_MSB
);
434 dump_reg(sd
, REG_VSYNC_START_LINE_LSB
);
435 dump_reg(sd
, REG_VSYNC_START_LINE_MSB
);
436 dump_reg(sd
, REG_VSYNC_STOP_LINE_LSB
);
437 dump_reg(sd
, REG_VSYNC_STOP_LINE_MSB
);
438 dump_reg(sd
, REG_VBLK_START_LINE_LSB
);
439 dump_reg(sd
, REG_VBLK_START_LINE_MSB
);
440 dump_reg(sd
, REG_VBLK_STOP_LINE_LSB
);
441 dump_reg(sd
, REG_VBLK_STOP_LINE_MSB
);
442 dump_reg(sd
, REG_SYNC_CONTROL
);
443 dump_reg(sd
, REG_OUTPUT_FORMATTER1
);
444 dump_reg(sd
, REG_OUTPUT_FORMATTER2
);
445 dump_reg(sd
, REG_OUTPUT_FORMATTER3
);
446 dump_reg(sd
, REG_OUTPUT_FORMATTER4
);
447 dump_reg(sd
, REG_OUTPUT_FORMATTER5
);
448 dump_reg(sd
, REG_OUTPUT_FORMATTER6
);
449 dump_reg(sd
, REG_CLEAR_LOST_LOCK
);
453 * tvp514x_configure() - Configure the TVP5146/47 registers
454 * @sd: ptr to v4l2_subdev struct
455 * @decoder: ptr to tvp514x_decoder structure
457 * Returns zero if successful, or non-zero otherwise.
459 static int tvp514x_configure(struct v4l2_subdev
*sd
,
460 struct tvp514x_decoder
*decoder
)
464 /* common register initialization */
466 tvp514x_write_regs(sd
, decoder
->tvp514x_regs
);
471 tvp514x_reg_dump(sd
);
477 * tvp514x_detect() - Detect if an tvp514x is present, and if so which revision.
478 * @sd: pointer to standard V4L2 sub-device structure
479 * @decoder: pointer to tvp514x_decoder structure
481 * A device is considered to be detected if the chip ID (LSB and MSB)
482 * registers match the expected values.
483 * Any value of the rom version register is accepted.
484 * Returns ENODEV error number if no device is detected, or zero
485 * if a device is detected.
487 static int tvp514x_detect(struct v4l2_subdev
*sd
,
488 struct tvp514x_decoder
*decoder
)
490 u8 chip_id_msb
, chip_id_lsb
, rom_ver
;
491 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
493 chip_id_msb
= tvp514x_read_reg(sd
, REG_CHIP_ID_MSB
);
494 chip_id_lsb
= tvp514x_read_reg(sd
, REG_CHIP_ID_LSB
);
495 rom_ver
= tvp514x_read_reg(sd
, REG_ROM_VERSION
);
497 v4l2_dbg(1, debug
, sd
,
498 "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n",
499 chip_id_msb
, chip_id_lsb
, rom_ver
);
500 if ((chip_id_msb
!= TVP514X_CHIP_ID_MSB
)
501 || ((chip_id_lsb
!= TVP5146_CHIP_ID_LSB
)
502 && (chip_id_lsb
!= TVP5147_CHIP_ID_LSB
))) {
503 /* We didn't read the values we expected, so this must not be
506 v4l2_err(sd
, "chip id mismatch msb:0x%x lsb:0x%x\n",
507 chip_id_msb
, chip_id_lsb
);
511 decoder
->ver
= rom_ver
;
513 v4l2_info(sd
, "%s (Version - 0x%.2x) found at 0x%x (%s)\n",
514 client
->name
, decoder
->ver
,
515 client
->addr
<< 1, client
->adapter
->name
);
520 * tvp514x_querystd() - V4L2 decoder interface handler for querystd
521 * @sd: pointer to standard V4L2 sub-device structure
522 * @std_id: standard V4L2 std_id ioctl enum
524 * Returns the current standard detected by TVP5146/47. If no active input is
525 * detected, returns -EINVAL
527 static int tvp514x_querystd(struct v4l2_subdev
*sd
, v4l2_std_id
*std_id
)
529 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
530 enum tvp514x_std current_std
;
531 enum tvp514x_input input_sel
;
532 u8 sync_lock_status
, lock_mask
;
538 err
= tvp514x_write_reg(sd
, REG_VIDEO_STD
,
539 VIDEO_STD_AUTO_SWITCH_BIT
);
543 msleep(LOCK_RETRY_DELAY
);
545 /* get the current standard */
546 current_std
= tvp514x_get_current_std(sd
);
547 if (current_std
== STD_INVALID
)
550 input_sel
= decoder
->input
;
553 case INPUT_CVBS_VI1A
:
554 case INPUT_CVBS_VI1B
:
555 case INPUT_CVBS_VI1C
:
556 case INPUT_CVBS_VI2A
:
557 case INPUT_CVBS_VI2B
:
558 case INPUT_CVBS_VI2C
:
559 case INPUT_CVBS_VI3A
:
560 case INPUT_CVBS_VI3B
:
561 case INPUT_CVBS_VI3C
:
562 case INPUT_CVBS_VI4A
:
563 lock_mask
= STATUS_CLR_SUBCAR_LOCK_BIT
|
564 STATUS_HORZ_SYNC_LOCK_BIT
|
565 STATUS_VIRT_SYNC_LOCK_BIT
;
568 case INPUT_SVIDEO_VI2A_VI1A
:
569 case INPUT_SVIDEO_VI2B_VI1B
:
570 case INPUT_SVIDEO_VI2C_VI1C
:
571 case INPUT_SVIDEO_VI2A_VI3A
:
572 case INPUT_SVIDEO_VI2B_VI3B
:
573 case INPUT_SVIDEO_VI2C_VI3C
:
574 case INPUT_SVIDEO_VI4A_VI1A
:
575 case INPUT_SVIDEO_VI4A_VI1B
:
576 case INPUT_SVIDEO_VI4A_VI1C
:
577 case INPUT_SVIDEO_VI4A_VI3A
:
578 case INPUT_SVIDEO_VI4A_VI3B
:
579 case INPUT_SVIDEO_VI4A_VI3C
:
580 lock_mask
= STATUS_HORZ_SYNC_LOCK_BIT
|
581 STATUS_VIRT_SYNC_LOCK_BIT
;
583 /*Need to add other interfaces*/
587 /* check whether signal is locked */
588 sync_lock_status
= tvp514x_read_reg(sd
, REG_STATUS1
);
589 if (lock_mask
!= (sync_lock_status
& lock_mask
))
590 return -EINVAL
; /* No input detected */
592 decoder
->current_std
= current_std
;
593 *std_id
= decoder
->std_list
[current_std
].standard
.id
;
595 v4l2_dbg(1, debug
, sd
, "Current STD: %s",
596 decoder
->std_list
[current_std
].standard
.name
);
601 * tvp514x_s_std() - V4L2 decoder interface handler for s_std
602 * @sd: pointer to standard V4L2 sub-device structure
603 * @std_id: standard V4L2 v4l2_std_id ioctl enum
605 * If std_id is supported, sets the requested standard. Otherwise, returns
608 static int tvp514x_s_std(struct v4l2_subdev
*sd
, v4l2_std_id std_id
)
610 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
613 for (i
= 0; i
< decoder
->num_stds
; i
++)
614 if (std_id
& decoder
->std_list
[i
].standard
.id
)
617 if ((i
== decoder
->num_stds
) || (i
== STD_INVALID
))
620 err
= tvp514x_write_reg(sd
, REG_VIDEO_STD
,
621 decoder
->std_list
[i
].video_std
);
625 decoder
->current_std
= i
;
626 decoder
->tvp514x_regs
[REG_VIDEO_STD
].val
=
627 decoder
->std_list
[i
].video_std
;
629 v4l2_dbg(1, debug
, sd
, "Standard set to: %s",
630 decoder
->std_list
[i
].standard
.name
);
635 * tvp514x_s_routing() - V4L2 decoder interface handler for s_routing
636 * @sd: pointer to standard V4L2 sub-device structure
637 * @input: input selector for routing the signal
638 * @output: output selector for routing the signal
639 * @config: config value. Not used
641 * If index is valid, selects the requested input. Otherwise, returns -EINVAL if
642 * the input is not supported or there is no active signal present in the
645 static int tvp514x_s_routing(struct v4l2_subdev
*sd
,
646 u32 input
, u32 output
, u32 config
)
648 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
650 enum tvp514x_input input_sel
;
651 enum tvp514x_output output_sel
;
652 enum tvp514x_std current_std
= STD_INVALID
;
653 u8 sync_lock_status
, lock_mask
;
654 int try_count
= LOCK_RETRY_COUNT
;
656 if ((input
>= INPUT_INVALID
) ||
657 (output
>= OUTPUT_INVALID
))
658 /* Index out of bound */
661 /* Since this api is goint to detect the input, it is required
662 to set the standard in the auto switch mode */
663 err
= tvp514x_write_reg(sd
, REG_VIDEO_STD
,
664 VIDEO_STD_AUTO_SWITCH_BIT
);
668 msleep(LOCK_RETRY_DELAY
);
673 err
= tvp514x_write_reg(sd
, REG_INPUT_SEL
, input_sel
);
677 output_sel
|= tvp514x_read_reg(sd
,
678 REG_OUTPUT_FORMATTER1
) & 0x7;
679 err
= tvp514x_write_reg(sd
, REG_OUTPUT_FORMATTER1
,
684 decoder
->tvp514x_regs
[REG_INPUT_SEL
].val
= input_sel
;
685 decoder
->tvp514x_regs
[REG_OUTPUT_FORMATTER1
].val
= output_sel
;
688 msleep(LOCK_RETRY_DELAY
);
690 tvp514x_write_reg(sd
, REG_CLEAR_LOST_LOCK
, 0x01);
695 case INPUT_CVBS_VI1A
:
696 case INPUT_CVBS_VI1B
:
697 case INPUT_CVBS_VI1C
:
698 case INPUT_CVBS_VI2A
:
699 case INPUT_CVBS_VI2B
:
700 case INPUT_CVBS_VI2C
:
701 case INPUT_CVBS_VI3A
:
702 case INPUT_CVBS_VI3B
:
703 case INPUT_CVBS_VI3C
:
704 case INPUT_CVBS_VI4A
:
705 lock_mask
= STATUS_CLR_SUBCAR_LOCK_BIT
|
706 STATUS_HORZ_SYNC_LOCK_BIT
|
707 STATUS_VIRT_SYNC_LOCK_BIT
;
710 case INPUT_SVIDEO_VI2A_VI1A
:
711 case INPUT_SVIDEO_VI2B_VI1B
:
712 case INPUT_SVIDEO_VI2C_VI1C
:
713 case INPUT_SVIDEO_VI2A_VI3A
:
714 case INPUT_SVIDEO_VI2B_VI3B
:
715 case INPUT_SVIDEO_VI2C_VI3C
:
716 case INPUT_SVIDEO_VI4A_VI1A
:
717 case INPUT_SVIDEO_VI4A_VI1B
:
718 case INPUT_SVIDEO_VI4A_VI1C
:
719 case INPUT_SVIDEO_VI4A_VI3A
:
720 case INPUT_SVIDEO_VI4A_VI3B
:
721 case INPUT_SVIDEO_VI4A_VI3C
:
722 lock_mask
= STATUS_HORZ_SYNC_LOCK_BIT
|
723 STATUS_VIRT_SYNC_LOCK_BIT
;
725 /* Need to add other interfaces*/
730 while (try_count
-- > 0) {
731 /* Allow decoder to sync up with new input */
732 msleep(LOCK_RETRY_DELAY
);
734 /* get the current standard for future reference */
735 current_std
= tvp514x_get_current_std(sd
);
736 if (current_std
== STD_INVALID
)
739 sync_lock_status
= tvp514x_read_reg(sd
,
741 if (lock_mask
== (sync_lock_status
& lock_mask
))
746 if ((current_std
== STD_INVALID
) || (try_count
< 0))
749 decoder
->current_std
= current_std
;
750 decoder
->input
= input
;
751 decoder
->output
= output
;
753 v4l2_dbg(1, debug
, sd
, "Input set to: %d, std : %d",
754 input_sel
, current_std
);
760 * tvp514x_queryctrl() - V4L2 decoder interface handler for queryctrl
761 * @sd: pointer to standard V4L2 sub-device structure
762 * @qctrl: standard V4L2 v4l2_queryctrl structure
764 * If the requested control is supported, returns the control information.
765 * Otherwise, returns -EINVAL if the control is not supported.
768 tvp514x_queryctrl(struct v4l2_subdev
*sd
, struct v4l2_queryctrl
*qctrl
)
776 case V4L2_CID_BRIGHTNESS
:
777 /* Brightness supported is (0-255), */
778 err
= v4l2_ctrl_query_fill(qctrl
, 0, 255, 1, 128);
780 case V4L2_CID_CONTRAST
:
781 case V4L2_CID_SATURATION
:
783 * Saturation and Contrast supported is -
784 * Contrast: 0 - 255 (Default - 128)
785 * Saturation: 0 - 255 (Default - 128)
787 err
= v4l2_ctrl_query_fill(qctrl
, 0, 255, 1, 128);
790 /* Hue Supported is -
791 * Hue - -180 - +180 (Default - 0, Step - +180)
793 err
= v4l2_ctrl_query_fill(qctrl
, -180, 180, 180, 0);
795 case V4L2_CID_AUTOGAIN
:
797 * Auto Gain supported is -
798 * 0 - 1 (Default - 1)
800 err
= v4l2_ctrl_query_fill(qctrl
, 0, 1, 1, 1);
803 v4l2_err(sd
, "invalid control id %d\n", qctrl
->id
);
807 v4l2_dbg(1, debug
, sd
, "Query Control:%s: Min - %d, Max - %d, Def - %d",
808 qctrl
->name
, qctrl
->minimum
, qctrl
->maximum
,
809 qctrl
->default_value
);
815 * tvp514x_g_ctrl() - V4L2 decoder interface handler for g_ctrl
816 * @sd: pointer to standard V4L2 sub-device structure
817 * @ctrl: pointer to v4l2_control structure
819 * If the requested control is supported, returns the control's current
820 * value from the decoder. Otherwise, returns -EINVAL if the control is not
824 tvp514x_g_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
826 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
832 case V4L2_CID_BRIGHTNESS
:
833 ctrl
->value
= decoder
->tvp514x_regs
[REG_BRIGHTNESS
].val
;
835 case V4L2_CID_CONTRAST
:
836 ctrl
->value
= decoder
->tvp514x_regs
[REG_CONTRAST
].val
;
838 case V4L2_CID_SATURATION
:
839 ctrl
->value
= decoder
->tvp514x_regs
[REG_SATURATION
].val
;
842 ctrl
->value
= decoder
->tvp514x_regs
[REG_HUE
].val
;
843 if (ctrl
->value
== 0x7F)
845 else if (ctrl
->value
== 0x80)
851 case V4L2_CID_AUTOGAIN
:
852 ctrl
->value
= decoder
->tvp514x_regs
[REG_AFE_GAIN_CTRL
].val
;
853 if ((ctrl
->value
& 0x3) == 3)
860 v4l2_err(sd
, "invalid control id %d\n", ctrl
->id
);
864 v4l2_dbg(1, debug
, sd
, "Get Control: ID - %d - %d",
865 ctrl
->id
, ctrl
->value
);
870 * tvp514x_s_ctrl() - V4L2 decoder interface handler for s_ctrl
871 * @sd: pointer to standard V4L2 sub-device structure
872 * @ctrl: pointer to v4l2_control structure
874 * If the requested control is supported, sets the control's current
875 * value in HW. Otherwise, returns -EINVAL if the control is not supported.
878 tvp514x_s_ctrl(struct v4l2_subdev
*sd
, struct v4l2_control
*ctrl
)
880 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
881 int err
= -EINVAL
, value
;
889 case V4L2_CID_BRIGHTNESS
:
890 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
891 v4l2_err(sd
, "invalid brightness setting %d\n",
895 err
= tvp514x_write_reg(sd
, REG_BRIGHTNESS
,
900 decoder
->tvp514x_regs
[REG_BRIGHTNESS
].val
= value
;
902 case V4L2_CID_CONTRAST
:
903 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
904 v4l2_err(sd
, "invalid contrast setting %d\n",
908 err
= tvp514x_write_reg(sd
, REG_CONTRAST
, value
);
912 decoder
->tvp514x_regs
[REG_CONTRAST
].val
= value
;
914 case V4L2_CID_SATURATION
:
915 if (ctrl
->value
< 0 || ctrl
->value
> 255) {
916 v4l2_err(sd
, "invalid saturation setting %d\n",
920 err
= tvp514x_write_reg(sd
, REG_SATURATION
, value
);
924 decoder
->tvp514x_regs
[REG_SATURATION
].val
= value
;
929 else if (value
== -180)
934 v4l2_err(sd
, "invalid hue setting %d\n", ctrl
->value
);
937 err
= tvp514x_write_reg(sd
, REG_HUE
, value
);
941 decoder
->tvp514x_regs
[REG_HUE
].val
= value
;
943 case V4L2_CID_AUTOGAIN
:
949 v4l2_err(sd
, "invalid auto gain setting %d\n",
953 err
= tvp514x_write_reg(sd
, REG_AFE_GAIN_CTRL
, value
);
957 decoder
->tvp514x_regs
[REG_AFE_GAIN_CTRL
].val
= value
;
960 v4l2_err(sd
, "invalid control id %d\n", ctrl
->id
);
964 v4l2_dbg(1, debug
, sd
, "Set Control: ID - %d - %d",
965 ctrl
->id
, ctrl
->value
);
971 * tvp514x_enum_fmt_cap() - V4L2 decoder interface handler for enum_fmt
972 * @sd: pointer to standard V4L2 sub-device structure
973 * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
975 * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats
978 tvp514x_enum_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_fmtdesc
*fmt
)
980 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
987 if ((index
>= decoder
->num_fmts
) || (index
< 0))
988 /* Index out of bound */
991 if (fmt
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
992 /* only capture is supported */
995 memcpy(fmt
, &decoder
->fmt_list
[index
],
996 sizeof(struct v4l2_fmtdesc
));
998 v4l2_dbg(1, debug
, sd
, "Current FMT: index - %d (%s)",
999 decoder
->fmt_list
[index
].index
,
1000 decoder
->fmt_list
[index
].description
);
1005 * tvp514x_try_fmt_cap() - V4L2 decoder interface handler for try_fmt
1006 * @sd: pointer to standard V4L2 sub-device structure
1007 * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
1009 * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
1010 * ioctl is used to negotiate the image capture size and pixel format
1011 * without actually making it take effect.
1014 tvp514x_try_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
1016 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1018 struct v4l2_pix_format
*pix
;
1019 enum tvp514x_std current_std
;
1024 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1025 /* only capture is supported */
1026 f
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1030 /* Calculate height and width based on current standard */
1031 current_std
= tvp514x_get_current_std(sd
);
1032 if (current_std
== STD_INVALID
)
1035 decoder
->current_std
= current_std
;
1036 pix
->width
= decoder
->std_list
[current_std
].width
;
1037 pix
->height
= decoder
->std_list
[current_std
].height
;
1039 for (ifmt
= 0; ifmt
< decoder
->num_fmts
; ifmt
++) {
1040 if (pix
->pixelformat
==
1041 decoder
->fmt_list
[ifmt
].pixelformat
)
1044 if (ifmt
== decoder
->num_fmts
)
1045 /* None of the format matched, select default */
1047 pix
->pixelformat
= decoder
->fmt_list
[ifmt
].pixelformat
;
1049 pix
->field
= V4L2_FIELD_INTERLACED
;
1050 pix
->bytesperline
= pix
->width
* 2;
1051 pix
->sizeimage
= pix
->bytesperline
* pix
->height
;
1052 pix
->colorspace
= V4L2_COLORSPACE_SMPTE170M
;
1055 v4l2_dbg(1, debug
, sd
, "Try FMT: pixelformat - %s, bytesperline - %d"
1056 "Width - %d, Height - %d",
1057 decoder
->fmt_list
[ifmt
].description
, pix
->bytesperline
,
1058 pix
->width
, pix
->height
);
1063 * tvp514x_s_fmt_cap() - V4L2 decoder interface handler for s_fmt
1064 * @sd: pointer to standard V4L2 sub-device structure
1065 * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
1067 * If the requested format is supported, configures the HW to use that
1068 * format, returns error code if format not supported or HW can't be
1069 * correctly configured.
1072 tvp514x_s_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
1074 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1075 struct v4l2_pix_format
*pix
;
1081 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1082 /* only capture is supported */
1086 rval
= tvp514x_try_fmt_cap(sd
, f
);
1090 decoder
->pix
= *pix
;
1096 * tvp514x_g_fmt_cap() - V4L2 decoder interface handler for tvp514x_g_fmt_cap
1097 * @sd: pointer to standard V4L2 sub-device structure
1098 * @f: pointer to standard V4L2 v4l2_format structure
1100 * Returns the decoder's current pixel format in the v4l2_format
1104 tvp514x_g_fmt_cap(struct v4l2_subdev
*sd
, struct v4l2_format
*f
)
1106 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1111 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1112 /* only capture is supported */
1115 f
->fmt
.pix
= decoder
->pix
;
1117 v4l2_dbg(1, debug
, sd
, "Current FMT: bytesperline - %d"
1118 "Width - %d, Height - %d",
1119 decoder
->pix
.bytesperline
,
1120 decoder
->pix
.width
, decoder
->pix
.height
);
1125 * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm
1126 * @sd: pointer to standard V4L2 sub-device structure
1127 * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
1129 * Returns the decoder's video CAPTURE parameters.
1132 tvp514x_g_parm(struct v4l2_subdev
*sd
, struct v4l2_streamparm
*a
)
1134 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1135 struct v4l2_captureparm
*cparm
;
1136 enum tvp514x_std current_std
;
1141 if (a
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1142 /* only capture is supported */
1145 memset(a
, 0, sizeof(*a
));
1146 a
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
1148 /* get the current standard */
1149 current_std
= tvp514x_get_current_std(sd
);
1150 if (current_std
== STD_INVALID
)
1153 decoder
->current_std
= current_std
;
1155 cparm
= &a
->parm
.capture
;
1156 cparm
->capability
= V4L2_CAP_TIMEPERFRAME
;
1157 cparm
->timeperframe
=
1158 decoder
->std_list
[current_std
].standard
.frameperiod
;
1164 * tvp514x_s_parm() - V4L2 decoder interface handler for s_parm
1165 * @sd: pointer to standard V4L2 sub-device structure
1166 * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
1168 * Configures the decoder to use the input parameters, if possible. If
1169 * not possible, returns the appropriate error code.
1172 tvp514x_s_parm(struct v4l2_subdev
*sd
, struct v4l2_streamparm
*a
)
1174 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1175 struct v4l2_fract
*timeperframe
;
1176 enum tvp514x_std current_std
;
1181 if (a
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1182 /* only capture is supported */
1185 timeperframe
= &a
->parm
.capture
.timeperframe
;
1187 /* get the current standard */
1188 current_std
= tvp514x_get_current_std(sd
);
1189 if (current_std
== STD_INVALID
)
1192 decoder
->current_std
= current_std
;
1195 decoder
->std_list
[current_std
].standard
.frameperiod
;
1201 * tvp514x_s_stream() - V4L2 decoder i/f handler for s_stream
1202 * @sd: pointer to standard V4L2 sub-device structure
1203 * @enable: streaming enable or disable
1205 * Sets streaming to enable or disable, if possible.
1207 static int tvp514x_s_stream(struct v4l2_subdev
*sd
, int enable
)
1210 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
1211 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1213 if (decoder
->streaming
== enable
)
1219 /* Power Down Sequence */
1220 err
= tvp514x_write_reg(sd
, REG_OPERATION_MODE
, 0x01);
1222 v4l2_err(sd
, "Unable to turn off decoder\n");
1225 decoder
->streaming
= enable
;
1230 struct tvp514x_reg
*int_seq
= (struct tvp514x_reg
*)
1231 client
->driver
->id_table
->driver_data
;
1233 /* Power Up Sequence */
1234 err
= tvp514x_write_regs(sd
, int_seq
);
1236 v4l2_err(sd
, "Unable to turn on decoder\n");
1239 /* Detect if not already detected */
1240 err
= tvp514x_detect(sd
, decoder
);
1242 v4l2_err(sd
, "Unable to detect decoder\n");
1245 err
= tvp514x_configure(sd
, decoder
);
1247 v4l2_err(sd
, "Unable to configure decoder\n");
1250 decoder
->streaming
= enable
;
1261 static const struct v4l2_subdev_core_ops tvp514x_core_ops
= {
1262 .queryctrl
= tvp514x_queryctrl
,
1263 .g_ctrl
= tvp514x_g_ctrl
,
1264 .s_ctrl
= tvp514x_s_ctrl
,
1265 .s_std
= tvp514x_s_std
,
1268 static const struct v4l2_subdev_video_ops tvp514x_video_ops
= {
1269 .s_routing
= tvp514x_s_routing
,
1270 .querystd
= tvp514x_querystd
,
1271 .enum_fmt
= tvp514x_enum_fmt_cap
,
1272 .g_fmt
= tvp514x_g_fmt_cap
,
1273 .try_fmt
= tvp514x_try_fmt_cap
,
1274 .s_fmt
= tvp514x_s_fmt_cap
,
1275 .g_parm
= tvp514x_g_parm
,
1276 .s_parm
= tvp514x_s_parm
,
1277 .s_stream
= tvp514x_s_stream
,
1280 static const struct v4l2_subdev_ops tvp514x_ops
= {
1281 .core
= &tvp514x_core_ops
,
1282 .video
= &tvp514x_video_ops
,
1285 static struct tvp514x_decoder tvp514x_dev
= {
1288 .fmt_list
= tvp514x_fmt_list
,
1289 .num_fmts
= ARRAY_SIZE(tvp514x_fmt_list
),
1292 /* Default to NTSC 8-bit YUV 422 */
1293 .width
= NTSC_NUM_ACTIVE_PIXELS
,
1294 .height
= NTSC_NUM_ACTIVE_LINES
,
1295 .pixelformat
= V4L2_PIX_FMT_UYVY
,
1296 .field
= V4L2_FIELD_INTERLACED
,
1297 .bytesperline
= NTSC_NUM_ACTIVE_PIXELS
* 2,
1299 NTSC_NUM_ACTIVE_PIXELS
* 2 * NTSC_NUM_ACTIVE_LINES
,
1300 .colorspace
= V4L2_COLORSPACE_SMPTE170M
,
1303 .current_std
= STD_NTSC_MJ
,
1304 .std_list
= tvp514x_std_list
,
1305 .num_stds
= ARRAY_SIZE(tvp514x_std_list
),
1310 * tvp514x_probe() - decoder driver i2c probe handler
1311 * @client: i2c driver client device structure
1312 * @id: i2c driver id table
1314 * Register decoder as an i2c client device and V4L2
1318 tvp514x_probe(struct i2c_client
*client
, const struct i2c_device_id
*id
)
1320 struct tvp514x_decoder
*decoder
;
1321 struct v4l2_subdev
*sd
;
1323 /* Check if the adapter supports the needed features */
1324 if (!i2c_check_functionality(client
->adapter
, I2C_FUNC_SMBUS_BYTE_DATA
))
1327 if (!client
->dev
.platform_data
) {
1328 v4l2_err(client
, "No platform data!!\n");
1332 decoder
= kzalloc(sizeof(*decoder
), GFP_KERNEL
);
1336 /* Initialize the tvp514x_decoder with default configuration */
1337 *decoder
= tvp514x_dev
;
1338 /* Copy default register configuration */
1339 memcpy(decoder
->tvp514x_regs
, tvp514x_reg_list_default
,
1340 sizeof(tvp514x_reg_list_default
));
1342 /* Copy board specific information here */
1343 decoder
->pdata
= client
->dev
.platform_data
;
1346 * Fetch platform specific data, and configure the
1347 * tvp514x_reg_list[] accordingly. Since this is one
1348 * time configuration, no need to preserve.
1350 decoder
->tvp514x_regs
[REG_OUTPUT_FORMATTER2
].val
|=
1351 (decoder
->pdata
->clk_polarity
<< 1);
1352 decoder
->tvp514x_regs
[REG_SYNC_CONTROL
].val
|=
1353 ((decoder
->pdata
->hs_polarity
<< 2) |
1354 (decoder
->pdata
->vs_polarity
<< 3));
1355 /* Set default standard to auto */
1356 decoder
->tvp514x_regs
[REG_VIDEO_STD
].val
=
1357 VIDEO_STD_AUTO_SWITCH_BIT
;
1359 /* Register with V4L2 layer as slave device */
1361 v4l2_i2c_subdev_init(sd
, client
, &tvp514x_ops
);
1363 v4l2_info(sd
, "%s decoder driver registered !!\n", sd
->name
);
1370 * tvp514x_remove() - decoder driver i2c remove handler
1371 * @client: i2c driver client device structure
1373 * Unregister decoder as an i2c client device and V4L2
1374 * device. Complement of tvp514x_probe().
1376 static int tvp514x_remove(struct i2c_client
*client
)
1378 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
1379 struct tvp514x_decoder
*decoder
= to_decoder(sd
);
1381 v4l2_device_unregister_subdev(sd
);
1385 /* TVP5146 Init/Power on Sequence */
1386 static const struct tvp514x_reg tvp5146_init_reg_seq
[] = {
1387 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x02},
1388 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1389 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0x80},
1390 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1391 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1392 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1393 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1394 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
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 /* TVP5147 Init/Power on Sequence */
1402 static const struct tvp514x_reg tvp5147_init_reg_seq
[] = {
1403 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x02},
1404 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1405 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0x80},
1406 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1407 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1408 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1409 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1410 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x01},
1411 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x16},
1412 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1413 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xA0},
1414 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x16},
1415 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS1
, 0x60},
1416 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS2
, 0x00},
1417 {TOK_WRITE
, REG_VBUS_ADDRESS_ACCESS3
, 0xB0},
1418 {TOK_WRITE
, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR
, 0x00},
1419 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1420 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1424 /* TVP5146M2/TVP5147M1 Init/Power on Sequence */
1425 static const struct tvp514x_reg tvp514xm_init_reg_seq
[] = {
1426 {TOK_WRITE
, REG_OPERATION_MODE
, 0x01},
1427 {TOK_WRITE
, REG_OPERATION_MODE
, 0x00},
1432 * I2C Device Table -
1434 * name - Name of the actual device/chip.
1435 * driver_data - Driver data
1437 static const struct i2c_device_id tvp514x_id
[] = {
1438 {"tvp5146", (unsigned long)tvp5146_init_reg_seq
},
1439 {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq
},
1440 {"tvp5147", (unsigned long)tvp5147_init_reg_seq
},
1441 {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq
},
1445 MODULE_DEVICE_TABLE(i2c
, tvp514x_id
);
1447 static struct i2c_driver tvp514x_driver
= {
1449 .owner
= THIS_MODULE
,
1450 .name
= TVP514X_MODULE_NAME
,
1452 .probe
= tvp514x_probe
,
1453 .remove
= tvp514x_remove
,
1454 .id_table
= tvp514x_id
,
1457 static int __init
tvp514x_init(void)
1459 return i2c_add_driver(&tvp514x_driver
);
1462 static void __exit
tvp514x_exit(void)
1464 i2c_del_driver(&tvp514x_driver
);
1467 module_init(tvp514x_init
);
1468 module_exit(tvp514x_exit
);