aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tvp514x.c
diff options
context:
space:
mode:
authorMuralidharan Karicheri <m-karicheri2@ti.com>2009-07-01 03:20:43 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:18:11 -0400
commitc1c9d09cd368f75bbd10253b8266898fb9fecc7f (patch)
tree2b5a96fea0ece02e2bd6a9a1f6308f7594124cb1 /drivers/media/video/tvp514x.c
parent62ef80a1f3fb69711dc7e59394ddc8e88097a7cc (diff)
V4L/DVB (12247): tvp514x: formatting comments as per kernel documentation
Fix documentation style based on comments from Mauro. Reviewed by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Muralidharan Karicheri <m-karicheri2@ti.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/tvp514x.c')
-rw-r--r--drivers/media/video/tvp514x.c275
1 files changed, 157 insertions, 118 deletions
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index c8386e2f7a99..244372627df2 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -56,16 +56,14 @@ MODULE_AUTHOR("Texas Instruments");
56MODULE_DESCRIPTION("TVP514X linux decoder driver"); 56MODULE_DESCRIPTION("TVP514X linux decoder driver");
57MODULE_LICENSE("GPL"); 57MODULE_LICENSE("GPL");
58 58
59/* 59/* enum tvp514x_std - enum for supported standards */
60 * enum tvp514x_std - enum for supported standards
61 */
62enum tvp514x_std { 60enum tvp514x_std {
63 STD_NTSC_MJ = 0, 61 STD_NTSC_MJ = 0,
64 STD_PAL_BDGHIN, 62 STD_PAL_BDGHIN,
65 STD_INVALID 63 STD_INVALID
66}; 64};
67 65
68/* 66/**
69 * struct tvp514x_std_info - Structure to store standard informations 67 * struct tvp514x_std_info - Structure to store standard informations
70 * @width: Line width in pixels 68 * @width: Line width in pixels
71 * @height:Number of active lines 69 * @height:Number of active lines
@@ -80,7 +78,7 @@ struct tvp514x_std_info {
80}; 78};
81 79
82static struct tvp514x_reg tvp514x_reg_list_default[0x40]; 80static struct tvp514x_reg tvp514x_reg_list_default[0x40];
83/* 81/**
84 * struct tvp514x_decoder - TVP5146/47 decoder object 82 * struct tvp514x_decoder - TVP5146/47 decoder object
85 * @sd: Subdevice Slave handle 83 * @sd: Subdevice Slave handle
86 * @tvp514x_regs: copy of hw's regs with preset values. 84 * @tvp514x_regs: copy of hw's regs with preset values.
@@ -111,18 +109,18 @@ struct tvp514x_decoder {
111 enum tvp514x_std current_std; 109 enum tvp514x_std current_std;
112 int num_stds; 110 int num_stds;
113 struct tvp514x_std_info *std_list; 111 struct tvp514x_std_info *std_list;
114 /* 112 /* Input and Output Routing parameters */
115 * Input and Output Routing parameters
116 */
117 u32 input; 113 u32 input;
118 u32 output; 114 u32 output;
119}; 115};
120 116
121/* TVP514x default register values */ 117/* TVP514x default register values */
122static struct tvp514x_reg tvp514x_reg_list_default[] = { 118static struct tvp514x_reg tvp514x_reg_list_default[] = {
123 {TOK_WRITE, REG_INPUT_SEL, 0x05}, /* Composite selected */ 119 /* Composite selected */
120 {TOK_WRITE, REG_INPUT_SEL, 0x05},
124 {TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F}, 121 {TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F},
125 {TOK_WRITE, REG_VIDEO_STD, 0x00}, /* Auto mode */ 122 /* Auto mode */
123 {TOK_WRITE, REG_VIDEO_STD, 0x00},
126 {TOK_WRITE, REG_OPERATION_MODE, 0x00}, 124 {TOK_WRITE, REG_OPERATION_MODE, 0x00},
127 {TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F}, 125 {TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F},
128 {TOK_WRITE, REG_COLOR_KILLER, 0x10}, 126 {TOK_WRITE, REG_COLOR_KILLER, 0x10},
@@ -135,53 +133,73 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = {
135 {TOK_WRITE, REG_HUE, 0x00}, 133 {TOK_WRITE, REG_HUE, 0x00},
136 {TOK_WRITE, REG_CHROMA_CONTROL1, 0x00}, 134 {TOK_WRITE, REG_CHROMA_CONTROL1, 0x00},
137 {TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E}, 135 {TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E},
138 {TOK_SKIP, 0x0F, 0x00}, /* Reserved */ 136 /* Reserved */
137 {TOK_SKIP, 0x0F, 0x00},
139 {TOK_WRITE, REG_COMP_PR_SATURATION, 0x80}, 138 {TOK_WRITE, REG_COMP_PR_SATURATION, 0x80},
140 {TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80}, 139 {TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80},
141 {TOK_WRITE, REG_COMP_PB_SATURATION, 0x80}, 140 {TOK_WRITE, REG_COMP_PB_SATURATION, 0x80},
142 {TOK_SKIP, 0x13, 0x00}, /* Reserved */ 141 /* Reserved */
142 {TOK_SKIP, 0x13, 0x00},
143 {TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80}, 143 {TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80},
144 {TOK_SKIP, 0x15, 0x00}, /* Reserved */ 144 /* Reserved */
145 {TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55}, /* NTSC timing */ 145 {TOK_SKIP, 0x15, 0x00},
146 /* NTSC timing */
147 {TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55},
146 {TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00}, 148 {TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00},
147 {TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25}, 149 {TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25},
148 {TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03}, 150 {TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03},
149 {TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00}, /* NTSC timing */ 151 /* NTSC timing */
152 {TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00},
150 {TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00}, 153 {TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00},
151 {TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40}, 154 {TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40},
152 {TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00}, 155 {TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00},
153 {TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04}, /* NTSC timing */ 156 /* NTSC timing */
157 {TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04},
154 {TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00}, 158 {TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00},
155 {TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07}, 159 {TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07},
156 {TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00}, 160 {TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00},
157 {TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01}, /* NTSC timing */ 161 /* NTSC timing */
162 {TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01},
158 {TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00}, 163 {TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00},
159 {TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15}, 164 {TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15},
160 {TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00}, 165 {TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00},
161 {TOK_SKIP, 0x26, 0x00}, /* Reserved */ 166 /* Reserved */
162 {TOK_SKIP, 0x27, 0x00}, /* Reserved */ 167 {TOK_SKIP, 0x26, 0x00},
168 /* Reserved */
169 {TOK_SKIP, 0x27, 0x00},
163 {TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC}, 170 {TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC},
164 {TOK_SKIP, 0x29, 0x00}, /* Reserved */ 171 /* Reserved */
172 {TOK_SKIP, 0x29, 0x00},
165 {TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00}, 173 {TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00},
166 {TOK_SKIP, 0x2B, 0x00}, /* Reserved */ 174 /* Reserved */
175 {TOK_SKIP, 0x2B, 0x00},
167 {TOK_SKIP, REG_SCART_DELAY, 0x00}, 176 {TOK_SKIP, REG_SCART_DELAY, 0x00},
168 {TOK_SKIP, REG_CTI_DELAY, 0x00}, 177 {TOK_SKIP, REG_CTI_DELAY, 0x00},
169 {TOK_SKIP, REG_CTI_CONTROL, 0x00}, 178 {TOK_SKIP, REG_CTI_CONTROL, 0x00},
170 {TOK_SKIP, 0x2F, 0x00}, /* Reserved */ 179 /* Reserved */
171 {TOK_SKIP, 0x30, 0x00}, /* Reserved */ 180 {TOK_SKIP, 0x2F, 0x00},
172 {TOK_SKIP, 0x31, 0x00}, /* Reserved */ 181 /* Reserved */
173 {TOK_WRITE, REG_SYNC_CONTROL, 0x00}, /* HS, VS active high */ 182 {TOK_SKIP, 0x30, 0x00},
174 {TOK_WRITE, REG_OUTPUT_FORMATTER1, 0x00}, /* 10-bit BT.656 */ 183 /* Reserved */
175 {TOK_WRITE, REG_OUTPUT_FORMATTER2, 0x11}, /* Enable clk & data */ 184 {TOK_SKIP, 0x31, 0x00},
176 {TOK_WRITE, REG_OUTPUT_FORMATTER3, 0xEE}, /* Enable AVID & FLD */ 185 /* HS, VS active high */
177 {TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF}, /* Enable VS & HS */ 186 {TOK_WRITE, REG_SYNC_CONTROL, 0x00},
187 /* 10-bit BT.656 */
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},
193 /* Enable VS & HS */
194 {TOK_WRITE, REG_OUTPUT_FORMATTER4, 0xAF},
178 {TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF}, 195 {TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF},
179 {TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF}, 196 {TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF},
180 {TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01}, /* Clear status */ 197 /* Clear status */
198 {TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01},
181 {TOK_TERM, 0, 0}, 199 {TOK_TERM, 0, 0},
182}; 200};
183 201
184/* 202/**
185 * List of image formats supported by TVP5146/47 decoder 203 * List of image formats supported by TVP5146/47 decoder
186 * Currently we are using 8 bit mode only, but can be 204 * Currently we are using 8 bit mode only, but can be
187 * extended to 10/20 bit mode. 205 * extended to 10/20 bit mode.
@@ -196,7 +214,7 @@ static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
196 }, 214 },
197}; 215};
198 216
199/* 217/**
200 * Supported standards - 218 * Supported standards -
201 * 219 *
202 * Currently supports two standards only, need to add support for rest of the 220 * Currently supports two standards only, need to add support for rest of the
@@ -239,8 +257,11 @@ static inline struct tvp514x_decoder *to_decoder(struct v4l2_subdev *sd)
239} 257}
240 258
241 259
242/* 260/**
243 * Read a value from a register in an TVP5146/47 decoder device. 261 * tvp514x_read_reg() - Read a value from a register in an TVP5146/47.
262 * @sd: ptr to v4l2_subdev struct
263 * @reg: TVP5146/47 register address
264 *
244 * Returns value read if successful, or non-zero (-1) otherwise. 265 * Returns value read if successful, or non-zero (-1) otherwise.
245 */ 266 */
246static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg) 267static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg)
@@ -263,6 +284,11 @@ read_again:
263 return err; 284 return err;
264} 285}
265 286
287/**
288 * dump_reg() - dump the register content of TVP5146/47.
289 * @sd: ptr to v4l2_subdev struct
290 * @reg: TVP5146/47 register address
291 */
266static void dump_reg(struct v4l2_subdev *sd, u8 reg) 292static void dump_reg(struct v4l2_subdev *sd, u8 reg)
267{ 293{
268 u32 val; 294 u32 val;
@@ -271,7 +297,12 @@ static void dump_reg(struct v4l2_subdev *sd, u8 reg)
271 v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); 297 v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val);
272} 298}
273 299
274/* 300/**
301 * tvp514x_write_reg() - Write a value to a register in TVP5146/47
302 * @sd: ptr to v4l2_subdev struct
303 * @reg: TVP5146/47 register address
304 * @val: value to be written to the register
305 *
275 * Write a value to a register in an TVP5146/47 decoder device. 306 * Write a value to a register in an TVP5146/47 decoder device.
276 * Returns zero if successful, or non-zero otherwise. 307 * Returns zero if successful, or non-zero otherwise.
277 */ 308 */
@@ -295,14 +326,16 @@ write_again:
295 return err; 326 return err;
296} 327}
297 328
298/* 329/**
299 * tvp514x_write_regs : Initializes a list of TVP5146/47 registers 330 * tvp514x_write_regs() : Initializes a list of TVP5146/47 registers
331 * @sd: ptr to v4l2_subdev struct
332 * @reglist: list of TVP5146/47 registers and values
333 *
334 * Initializes a list of TVP5146/47 registers:-
300 * if token is TOK_TERM, then entire write operation terminates 335 * if token is TOK_TERM, then entire write operation terminates
301 * if token is TOK_DELAY, then a delay of 'val' msec is introduced 336 * 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 337 * if token is TOK_SKIP, then the register write is skipped
303 * if token is TOK_WRITE, then the register write is performed 338 * if token is TOK_WRITE, then the register write is performed
304 *
305 * reglist - list of registers to be written
306 * Returns zero if successful, or non-zero otherwise. 339 * Returns zero if successful, or non-zero otherwise.
307 */ 340 */
308static int tvp514x_write_regs(struct v4l2_subdev *sd, 341static int tvp514x_write_regs(struct v4l2_subdev *sd,
@@ -329,9 +362,12 @@ static int tvp514x_write_regs(struct v4l2_subdev *sd,
329 return 0; 362 return 0;
330} 363}
331 364
332/* 365/**
333 * tvp514x_get_current_std: 366 * tvp514x_get_current_std() : Get the current standard detected by TVP5146/47
334 * Returns the current standard detected by TVP5146/47 367 * @sd: ptr to v4l2_subdev struct
368 *
369 * Get current standard detected by TVP5146/47, STD_INVALID if there is no
370 * standard detected.
335 */ 371 */
336static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd) 372static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd)
337{ 373{
@@ -342,7 +378,8 @@ static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd)
342 /* use the standard status register */ 378 /* use the standard status register */
343 std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS); 379 std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS);
344 else 380 else
345 std_status = std; /* use the standard register itself */ 381 /* use the standard register itself */
382 std_status = std;
346 383
347 switch (std_status & VIDEO_STD_MASK) { 384 switch (std_status & VIDEO_STD_MASK) {
348 case VIDEO_STD_NTSC_MJ_BIT: 385 case VIDEO_STD_NTSC_MJ_BIT:
@@ -358,9 +395,7 @@ static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd)
358 return STD_INVALID; 395 return STD_INVALID;
359} 396}
360 397
361/* 398/* TVP5146/47 register dump function */
362 * TVP5146/47 register dump function
363 */
364static void tvp514x_reg_dump(struct v4l2_subdev *sd) 399static void tvp514x_reg_dump(struct v4l2_subdev *sd)
365{ 400{
366 dump_reg(sd, REG_INPUT_SEL); 401 dump_reg(sd, REG_INPUT_SEL);
@@ -407,8 +442,11 @@ static void tvp514x_reg_dump(struct v4l2_subdev *sd)
407 dump_reg(sd, REG_CLEAR_LOST_LOCK); 442 dump_reg(sd, REG_CLEAR_LOST_LOCK);
408} 443}
409 444
410/* 445/**
411 * Configure the TVP5146/47 with the current register settings 446 * tvp514x_configure() - Configure the TVP5146/47 registers
447 * @sd: ptr to v4l2_subdev struct
448 * @decoder: ptr to tvp514x_decoder structure
449 *
412 * Returns zero if successful, or non-zero otherwise. 450 * Returns zero if successful, or non-zero otherwise.
413 */ 451 */
414static int tvp514x_configure(struct v4l2_subdev *sd, 452static int tvp514x_configure(struct v4l2_subdev *sd,
@@ -428,8 +466,11 @@ static int tvp514x_configure(struct v4l2_subdev *sd,
428 return 0; 466 return 0;
429} 467}
430 468
431/* 469/**
432 * Detect if an tvp514x is present, and if so which revision. 470 * tvp514x_detect() - Detect if an tvp514x is present, and if so which revision.
471 * @sd: pointer to standard V4L2 sub-device structure
472 * @decoder: pointer to tvp514x_decoder structure
473 *
433 * A device is considered to be detected if the chip ID (LSB and MSB) 474 * A device is considered to be detected if the chip ID (LSB and MSB)
434 * registers match the expected values. 475 * registers match the expected values.
435 * Any value of the rom version register is accepted. 476 * Any value of the rom version register is accepted.
@@ -468,13 +509,8 @@ static int tvp514x_detect(struct v4l2_subdev *sd,
468 return 0; 509 return 0;
469} 510}
470 511
471/* 512/**
472 * Following are decoder interface functions implemented by 513 * tvp514x_querystd() - V4L2 decoder interface handler for querystd
473 * TVP5146/47 decoder driver.
474 */
475
476/*
477 * tvp514x_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl
478 * @sd: pointer to standard V4L2 sub-device structure 514 * @sd: pointer to standard V4L2 sub-device structure
479 * @std_id: standard V4L2 std_id ioctl enum 515 * @std_id: standard V4L2 std_id ioctl enum
480 * 516 *
@@ -546,8 +582,8 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
546 return 0; 582 return 0;
547} 583}
548 584
549/* 585/**
550 * tvp514x_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl 586 * tvp514x_s_std() - V4L2 decoder interface handler for s_std
551 * @sd: pointer to standard V4L2 sub-device structure 587 * @sd: pointer to standard V4L2 sub-device structure
552 * @std_id: standard V4L2 v4l2_std_id ioctl enum 588 * @std_id: standard V4L2 v4l2_std_id ioctl enum
553 * 589 *
@@ -580,10 +616,12 @@ static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id)
580 return 0; 616 return 0;
581} 617}
582 618
583/* 619/**
584 * tvp514x_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl 620 * tvp514x_s_routing() - V4L2 decoder interface handler for s_routing
585 * @sd: pointer to standard V4L2 sub-device structure 621 * @sd: pointer to standard V4L2 sub-device structure
586 * @index: number of the input 622 * @input: input selector for routing the signal
623 * @output: output selector for routing the signal
624 * @config: config value. Not used
587 * 625 *
588 * If index is valid, selects the requested input. Otherwise, returns -EINVAL if 626 * 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 627 * the input is not supported or there is no active signal present in the
@@ -602,7 +640,8 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
602 640
603 if ((input >= INPUT_INVALID) || 641 if ((input >= INPUT_INVALID) ||
604 (output >= OUTPUT_INVALID)) 642 (output >= OUTPUT_INVALID))
605 return -EINVAL; /* Index out of bound */ 643 /* Index out of bound */
644 return -EINVAL;
606 645
607 input_sel = input; 646 input_sel = input;
608 output_sel = output; 647 output_sel = output;
@@ -659,7 +698,7 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
659 lock_mask = STATUS_HORZ_SYNC_LOCK_BIT | 698 lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
660 STATUS_VIRT_SYNC_LOCK_BIT; 699 STATUS_VIRT_SYNC_LOCK_BIT;
661 break; 700 break;
662 /*Need to add other interfaces*/ 701 /* Need to add other interfaces*/
663 default: 702 default:
664 return -EINVAL; 703 return -EINVAL;
665 } 704 }
@@ -676,7 +715,8 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
676 sync_lock_status = tvp514x_read_reg(sd, 715 sync_lock_status = tvp514x_read_reg(sd,
677 REG_STATUS1); 716 REG_STATUS1);
678 if (lock_mask == (sync_lock_status & lock_mask)) 717 if (lock_mask == (sync_lock_status & lock_mask))
679 break; /* Input detected */ 718 /* Input detected */
719 break;
680 } 720 }
681 721
682 if ((current_std == STD_INVALID) || (try_count < 0)) 722 if ((current_std == STD_INVALID) || (try_count < 0))
@@ -692,8 +732,8 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
692 return 0; 732 return 0;
693} 733}
694 734
695/* 735/**
696 * tvp514x_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl 736 * tvp514x_queryctrl() - V4L2 decoder interface handler for queryctrl
697 * @sd: pointer to standard V4L2 sub-device structure 737 * @sd: pointer to standard V4L2 sub-device structure
698 * @qctrl: standard V4L2 v4l2_queryctrl structure 738 * @qctrl: standard V4L2 v4l2_queryctrl structure
699 * 739 *
@@ -710,13 +750,13 @@ tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
710 750
711 switch (qctrl->id) { 751 switch (qctrl->id) {
712 case V4L2_CID_BRIGHTNESS: 752 case V4L2_CID_BRIGHTNESS:
713 /* Brightness supported is (0-255), 753 /* Brightness supported is (0-255), */
714 */
715 err = v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 128); 754 err = v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 128);
716 break; 755 break;
717 case V4L2_CID_CONTRAST: 756 case V4L2_CID_CONTRAST:
718 case V4L2_CID_SATURATION: 757 case V4L2_CID_SATURATION:
719 /* Saturation and Contrast supported is - 758 /**
759 * Saturation and Contrast supported is -
720 * Contrast: 0 - 255 (Default - 128) 760 * Contrast: 0 - 255 (Default - 128)
721 * Saturation: 0 - 255 (Default - 128) 761 * Saturation: 0 - 255 (Default - 128)
722 */ 762 */
@@ -729,7 +769,7 @@ tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
729 err = v4l2_ctrl_query_fill(qctrl, -180, 180, 180, 0); 769 err = v4l2_ctrl_query_fill(qctrl, -180, 180, 180, 0);
730 break; 770 break;
731 case V4L2_CID_AUTOGAIN: 771 case V4L2_CID_AUTOGAIN:
732 /* 772 /**
733 * Auto Gain supported is - 773 * Auto Gain supported is -
734 * 0 - 1 (Default - 1) 774 * 0 - 1 (Default - 1)
735 */ 775 */
@@ -747,8 +787,8 @@ tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
747 return err; 787 return err;
748} 788}
749 789
750/* 790/**
751 * tvp514x_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl 791 * tvp514x_g_ctrl() - V4L2 decoder interface handler for g_ctrl
752 * @sd: pointer to standard V4L2 sub-device structure 792 * @sd: pointer to standard V4L2 sub-device structure
753 * @ctrl: pointer to v4l2_control structure 793 * @ctrl: pointer to v4l2_control structure
754 * 794 *
@@ -802,8 +842,8 @@ tvp514x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
802 return 0; 842 return 0;
803} 843}
804 844
805/* 845/**
806 * tvp514x_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl 846 * tvp514x_s_ctrl() - V4L2 decoder interface handler for s_ctrl
807 * @sd: pointer to standard V4L2 sub-device structure 847 * @sd: pointer to standard V4L2 sub-device structure
808 * @ctrl: pointer to v4l2_control structure 848 * @ctrl: pointer to v4l2_control structure
809 * 849 *
@@ -903,8 +943,8 @@ tvp514x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
903 return err; 943 return err;
904} 944}
905 945
906/* 946/**
907 * tvp514x_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl 947 * tvp514x_enum_fmt_cap() - V4L2 decoder interface handler for enum_fmt
908 * @sd: pointer to standard V4L2 sub-device structure 948 * @sd: pointer to standard V4L2 sub-device structure
909 * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure 949 * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure
910 * 950 *
@@ -921,10 +961,12 @@ tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
921 961
922 index = fmt->index; 962 index = fmt->index;
923 if ((index >= decoder->num_fmts) || (index < 0)) 963 if ((index >= decoder->num_fmts) || (index < 0))
924 return -EINVAL; /* Index out of bound */ 964 /* Index out of bound */
965 return -EINVAL;
925 966
926 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 967 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
927 return -EINVAL; /* only capture is supported */ 968 /* only capture is supported */
969 return -EINVAL;
928 970
929 memcpy(fmt, &decoder->fmt_list[index], 971 memcpy(fmt, &decoder->fmt_list[index],
930 sizeof(struct v4l2_fmtdesc)); 972 sizeof(struct v4l2_fmtdesc));
@@ -935,8 +977,8 @@ tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
935 return 0; 977 return 0;
936} 978}
937 979
938/* 980/**
939 * tvp514x_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl 981 * tvp514x_try_fmt_cap() - V4L2 decoder interface handler for try_fmt
940 * @sd: pointer to standard V4L2 sub-device structure 982 * @sd: pointer to standard V4L2 sub-device structure
941 * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure 983 * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
942 * 984 *
@@ -956,6 +998,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
956 return -EINVAL; 998 return -EINVAL;
957 999
958 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1000 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1001 /* only capture is supported */
959 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1002 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
960 1003
961 pix = &f->fmt.pix; 1004 pix = &f->fmt.pix;
@@ -975,7 +1018,8 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
975 break; 1018 break;
976 } 1019 }
977 if (ifmt == decoder->num_fmts) 1020 if (ifmt == decoder->num_fmts)
978 ifmt = 0; /* None of the format matched, select default */ 1021 /* None of the format matched, select default */
1022 ifmt = 0;
979 pix->pixelformat = decoder->fmt_list[ifmt].pixelformat; 1023 pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
980 1024
981 pix->field = V4L2_FIELD_INTERLACED; 1025 pix->field = V4L2_FIELD_INTERLACED;
@@ -991,8 +1035,8 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
991 return 0; 1035 return 0;
992} 1036}
993 1037
994/* 1038/**
995 * tvp514x_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl 1039 * tvp514x_s_fmt_cap() - V4L2 decoder interface handler for s_fmt
996 * @sd: pointer to standard V4L2 sub-device structure 1040 * @sd: pointer to standard V4L2 sub-device structure
997 * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure 1041 * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
998 * 1042 *
@@ -1011,7 +1055,8 @@ tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
1011 return -EINVAL; 1055 return -EINVAL;
1012 1056
1013 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1057 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1014 return -EINVAL; /* only capture is supported */ 1058 /* only capture is supported */
1059 return -EINVAL;
1015 1060
1016 pix = &f->fmt.pix; 1061 pix = &f->fmt.pix;
1017 rval = tvp514x_try_fmt_cap(sd, f); 1062 rval = tvp514x_try_fmt_cap(sd, f);
@@ -1023,8 +1068,8 @@ tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
1023 return rval; 1068 return rval;
1024} 1069}
1025 1070
1026/* 1071/**
1027 * tvp514x_g_fmt_cap - V4L2 decoder interface handler for tvp514x_g_fmt_cap 1072 * tvp514x_g_fmt_cap() - V4L2 decoder interface handler for tvp514x_g_fmt_cap
1028 * @sd: pointer to standard V4L2 sub-device structure 1073 * @sd: pointer to standard V4L2 sub-device structure
1029 * @f: pointer to standard V4L2 v4l2_format structure 1074 * @f: pointer to standard V4L2 v4l2_format structure
1030 * 1075 *
@@ -1040,7 +1085,8 @@ tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
1040 return -EINVAL; 1085 return -EINVAL;
1041 1086
1042 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1087 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1043 return -EINVAL; /* only capture is supported */ 1088 /* only capture is supported */
1089 return -EINVAL;
1044 1090
1045 f->fmt.pix = decoder->pix; 1091 f->fmt.pix = decoder->pix;
1046 1092
@@ -1051,8 +1097,8 @@ tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
1051 return 0; 1097 return 0;
1052} 1098}
1053 1099
1054/* 1100/**
1055 * tvp514x_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl 1101 * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm
1056 * @sd: pointer to standard V4L2 sub-device structure 1102 * @sd: pointer to standard V4L2 sub-device structure
1057 * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure 1103 * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
1058 * 1104 *
@@ -1069,7 +1115,8 @@ tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
1069 return -EINVAL; 1115 return -EINVAL;
1070 1116
1071 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1117 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1072 return -EINVAL; /* only capture is supported */ 1118 /* only capture is supported */
1119 return -EINVAL;
1073 1120
1074 memset(a, 0, sizeof(*a)); 1121 memset(a, 0, sizeof(*a));
1075 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1122 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1089,8 +1136,8 @@ tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
1089 return 0; 1136 return 0;
1090} 1137}
1091 1138
1092/* 1139/**
1093 * tvp514x_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl 1140 * tvp514x_s_parm() - V4L2 decoder interface handler for s_parm
1094 * @sd: pointer to standard V4L2 sub-device structure 1141 * @sd: pointer to standard V4L2 sub-device structure
1095 * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure 1142 * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
1096 * 1143 *
@@ -1108,7 +1155,8 @@ tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
1108 return -EINVAL; 1155 return -EINVAL;
1109 1156
1110 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1157 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1111 return -EINVAL; /* only capture is supported */ 1158 /* only capture is supported */
1159 return -EINVAL;
1112 1160
1113 timeperframe = &a->parm.capture.timeperframe; 1161 timeperframe = &a->parm.capture.timeperframe;
1114 1162
@@ -1125,8 +1173,8 @@ tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
1125 return 0; 1173 return 0;
1126} 1174}
1127 1175
1128/* 1176/**
1129 * tvp514x_s_stream - V4L2 decoder interface handler for vidioc_int_s_power_num 1177 * tvp514x_s_stream() - V4L2 decoder i/f handler for s_stream
1130 * @sd: pointer to standard V4L2 sub-device structure 1178 * @sd: pointer to standard V4L2 sub-device structure
1131 * @enable: streaming enable or disable 1179 * @enable: streaming enable or disable
1132 * 1180 *
@@ -1216,7 +1264,8 @@ static struct tvp514x_decoder tvp514x_dev = {
1216 .fmt_list = tvp514x_fmt_list, 1264 .fmt_list = tvp514x_fmt_list,
1217 .num_fmts = ARRAY_SIZE(tvp514x_fmt_list), 1265 .num_fmts = ARRAY_SIZE(tvp514x_fmt_list),
1218 1266
1219 .pix = {/* Default to NTSC 8-bit YUV 422 */ 1267 .pix = {
1268 /* Default to NTSC 8-bit YUV 422 */
1220 .width = NTSC_NUM_ACTIVE_PIXELS, 1269 .width = NTSC_NUM_ACTIVE_PIXELS,
1221 .height = NTSC_NUM_ACTIVE_LINES, 1270 .height = NTSC_NUM_ACTIVE_LINES,
1222 .pixelformat = V4L2_PIX_FMT_UYVY, 1271 .pixelformat = V4L2_PIX_FMT_UYVY,
@@ -1233,8 +1282,8 @@ static struct tvp514x_decoder tvp514x_dev = {
1233 1282
1234}; 1283};
1235 1284
1236/* 1285/**
1237 * tvp514x_probe - decoder driver i2c probe handler 1286 * tvp514x_probe() - decoder driver i2c probe handler
1238 * @client: i2c driver client device structure 1287 * @client: i2c driver client device structure
1239 * @id: i2c driver id table 1288 * @id: i2c driver id table
1240 * 1289 *
@@ -1260,20 +1309,16 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
1260 if (!decoder) 1309 if (!decoder)
1261 return -ENOMEM; 1310 return -ENOMEM;
1262 1311
1263 /* 1312 /* Initialize the tvp514x_decoder with default configuration */
1264 * Initialize the tvp514x_decoder with default configuration
1265 */
1266 *decoder = tvp514x_dev; 1313 *decoder = tvp514x_dev;
1267 /* Copy default register configuration */ 1314 /* Copy default register configuration */
1268 memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default, 1315 memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default,
1269 sizeof(tvp514x_reg_list_default)); 1316 sizeof(tvp514x_reg_list_default));
1270 1317
1271 /* 1318 /* Copy board specific information here */
1272 * Copy board specific information here
1273 */
1274 decoder->pdata = client->dev.platform_data; 1319 decoder->pdata = client->dev.platform_data;
1275 1320
1276 /* 1321 /**
1277 * Fetch platform specific data, and configure the 1322 * Fetch platform specific data, and configure the
1278 * tvp514x_reg_list[] accordingly. Since this is one 1323 * tvp514x_reg_list[] accordingly. Since this is one
1279 * time configuration, no need to preserve. 1324 * time configuration, no need to preserve.
@@ -1297,8 +1342,8 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
1297 1342
1298} 1343}
1299 1344
1300/* 1345/**
1301 * tvp514x_remove - decoder driver i2c remove handler 1346 * tvp514x_remove() - decoder driver i2c remove handler
1302 * @client: i2c driver client device structure 1347 * @client: i2c driver client device structure
1303 * 1348 *
1304 * Unregister decoder as an i2c client device and V4L2 1349 * Unregister decoder as an i2c client device and V4L2
@@ -1313,9 +1358,7 @@ static int tvp514x_remove(struct i2c_client *client)
1313 kfree(decoder); 1358 kfree(decoder);
1314 return 0; 1359 return 0;
1315} 1360}
1316/* 1361/* TVP5146 Init/Power on Sequence */
1317 * TVP5146 Init/Power on Sequence
1318 */
1319static const struct tvp514x_reg tvp5146_init_reg_seq[] = { 1362static const struct tvp514x_reg tvp5146_init_reg_seq[] = {
1320 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02}, 1363 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
1321 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, 1364 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
@@ -1331,9 +1374,7 @@ static const struct tvp514x_reg tvp5146_init_reg_seq[] = {
1331 {TOK_TERM, 0, 0}, 1374 {TOK_TERM, 0, 0},
1332}; 1375};
1333 1376
1334/* 1377/* TVP5147 Init/Power on Sequence */
1335 * TVP5147 Init/Power on Sequence
1336 */
1337static const struct tvp514x_reg tvp5147_init_reg_seq[] = { 1378static const struct tvp514x_reg tvp5147_init_reg_seq[] = {
1338 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02}, 1379 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02},
1339 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, 1380 {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00},
@@ -1356,16 +1397,14 @@ static const struct tvp514x_reg tvp5147_init_reg_seq[] = {
1356 {TOK_TERM, 0, 0}, 1397 {TOK_TERM, 0, 0},
1357}; 1398};
1358 1399
1359/* 1400/* TVP5146M2/TVP5147M1 Init/Power on Sequence */
1360 * TVP5146M2/TVP5147M1 Init/Power on Sequence
1361 */
1362static const struct tvp514x_reg tvp514xm_init_reg_seq[] = { 1401static const struct tvp514x_reg tvp514xm_init_reg_seq[] = {
1363 {TOK_WRITE, REG_OPERATION_MODE, 0x01}, 1402 {TOK_WRITE, REG_OPERATION_MODE, 0x01},
1364 {TOK_WRITE, REG_OPERATION_MODE, 0x00}, 1403 {TOK_WRITE, REG_OPERATION_MODE, 0x00},
1365 {TOK_TERM, 0, 0}, 1404 {TOK_TERM, 0, 0},
1366}; 1405};
1367 1406
1368/* 1407/**
1369 * I2C Device Table - 1408 * I2C Device Table -
1370 * 1409 *
1371 * name - Name of the actual device/chip. 1410 * name - Name of the actual device/chip.