diff options
author | Muralidharan Karicheri <m-karicheri2@ti.com> | 2009-06-19 06:13:44 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:18:09 -0400 |
commit | 62ef80a1f3fb69711dc7e59394ddc8e88097a7cc (patch) | |
tree | 62140698eaf8cbe3c9f522deb846b7cc40dc4081 /drivers/media/video/tvp514x.c | |
parent | 6bcbc08faa575e82f9701c4022847ea594806bcb (diff) |
V4L/DVB (12246): tvp514x: Migration to sub-device framework
This patch converts TVP514x driver to sub-device framework
from V4L2-int framework.
[hverkuil@xs4all.nl: remove inline from the dump_reg function]
Signed-off-by: Brijesh Jadav <brijesh.j@ti.com>
Signed-off-by: Hardik Shah <hardik.shah@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Murali 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.c | 875 |
1 files changed, 349 insertions, 526 deletions
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c index 3750f7fadb12..c8386e2f7a99 100644 --- a/drivers/media/video/tvp514x.c +++ b/drivers/media/video/tvp514x.c | |||
@@ -31,7 +31,10 @@ | |||
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/videodev2.h> | 33 | #include <linux/videodev2.h> |
34 | #include <media/v4l2-int-device.h> | 34 | |
35 | #include <media/v4l2-device.h> | ||
36 | #include <media/v4l2-common.h> | ||
37 | #include <media/v4l2-chip-ident.h> | ||
35 | #include <media/tvp514x.h> | 38 | #include <media/tvp514x.h> |
36 | 39 | ||
37 | #include "tvp514x_regs.h" | 40 | #include "tvp514x_regs.h" |
@@ -49,13 +52,11 @@ static int debug; | |||
49 | module_param(debug, bool, 0644); | 52 | module_param(debug, bool, 0644); |
50 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 53 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
51 | 54 | ||
52 | #define dump_reg(client, reg, val) \ | 55 | MODULE_AUTHOR("Texas Instruments"); |
53 | do { \ | 56 | MODULE_DESCRIPTION("TVP514X linux decoder driver"); |
54 | val = tvp514x_read_reg(client, reg); \ | 57 | MODULE_LICENSE("GPL"); |
55 | v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \ | ||
56 | } while (0) | ||
57 | 58 | ||
58 | /** | 59 | /* |
59 | * enum tvp514x_std - enum for supported standards | 60 | * enum tvp514x_std - enum for supported standards |
60 | */ | 61 | */ |
61 | enum tvp514x_std { | 62 | enum tvp514x_std { |
@@ -64,15 +65,7 @@ enum tvp514x_std { | |||
64 | STD_INVALID | 65 | STD_INVALID |
65 | }; | 66 | }; |
66 | 67 | ||
67 | /** | 68 | /* |
68 | * enum tvp514x_state - enum for different decoder states | ||
69 | */ | ||
70 | enum tvp514x_state { | ||
71 | STATE_NOT_DETECTED, | ||
72 | STATE_DETECTED | ||
73 | }; | ||
74 | |||
75 | /** | ||
76 | * struct tvp514x_std_info - Structure to store standard informations | 69 | * struct tvp514x_std_info - Structure to store standard informations |
77 | * @width: Line width in pixels | 70 | * @width: Line width in pixels |
78 | * @height:Number of active lines | 71 | * @height:Number of active lines |
@@ -87,35 +80,29 @@ struct tvp514x_std_info { | |||
87 | }; | 80 | }; |
88 | 81 | ||
89 | static struct tvp514x_reg tvp514x_reg_list_default[0x40]; | 82 | static struct tvp514x_reg tvp514x_reg_list_default[0x40]; |
90 | /** | 83 | /* |
91 | * struct tvp514x_decoder - TVP5146/47 decoder object | 84 | * struct tvp514x_decoder - TVP5146/47 decoder object |
92 | * @v4l2_int_device: Slave handle | 85 | * @sd: Subdevice Slave handle |
93 | * @tvp514x_slave: Slave pointer which is used by @v4l2_int_device | ||
94 | * @tvp514x_regs: copy of hw's regs with preset values. | 86 | * @tvp514x_regs: copy of hw's regs with preset values. |
95 | * @pdata: Board specific | 87 | * @pdata: Board specific |
96 | * @client: I2C client data | ||
97 | * @id: Entry from I2C table | ||
98 | * @ver: Chip version | 88 | * @ver: Chip version |
99 | * @state: TVP5146/47 decoder state - detected or not-detected | 89 | * @streaming: TVP5146/47 decoder streaming - enabled or disabled. |
100 | * @pix: Current pixel format | 90 | * @pix: Current pixel format |
101 | * @num_fmts: Number of formats | 91 | * @num_fmts: Number of formats |
102 | * @fmt_list: Format list | 92 | * @fmt_list: Format list |
103 | * @current_std: Current standard | 93 | * @current_std: Current standard |
104 | * @num_stds: Number of standards | 94 | * @num_stds: Number of standards |
105 | * @std_list: Standards list | 95 | * @std_list: Standards list |
106 | * @route: input and output routing at chip level | 96 | * @input: Input routing at chip level |
97 | * @output: Output routing at chip level | ||
107 | */ | 98 | */ |
108 | struct tvp514x_decoder { | 99 | struct tvp514x_decoder { |
109 | struct v4l2_int_device v4l2_int_device; | 100 | struct v4l2_subdev sd; |
110 | struct v4l2_int_slave tvp514x_slave; | ||
111 | struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)]; | 101 | struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)]; |
112 | const struct tvp514x_platform_data *pdata; | 102 | const struct tvp514x_platform_data *pdata; |
113 | struct i2c_client *client; | ||
114 | |||
115 | struct i2c_device_id *id; | ||
116 | 103 | ||
117 | int ver; | 104 | int ver; |
118 | enum tvp514x_state state; | 105 | int streaming; |
119 | 106 | ||
120 | struct v4l2_pix_format pix; | 107 | struct v4l2_pix_format pix; |
121 | int num_fmts; | 108 | int num_fmts; |
@@ -124,8 +111,11 @@ struct tvp514x_decoder { | |||
124 | enum tvp514x_std current_std; | 111 | enum tvp514x_std current_std; |
125 | int num_stds; | 112 | int num_stds; |
126 | struct tvp514x_std_info *std_list; | 113 | struct tvp514x_std_info *std_list; |
127 | 114 | /* | |
128 | struct v4l2_routing route; | 115 | * Input and Output Routing parameters |
116 | */ | ||
117 | u32 input; | ||
118 | u32 output; | ||
129 | }; | 119 | }; |
130 | 120 | ||
131 | /* TVP514x default register values */ | 121 | /* TVP514x default register values */ |
@@ -191,7 +181,8 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = { | |||
191 | {TOK_TERM, 0, 0}, | 181 | {TOK_TERM, 0, 0}, |
192 | }; | 182 | }; |
193 | 183 | ||
194 | /* List of image formats supported by TVP5146/47 decoder | 184 | /* |
185 | * List of image formats supported by TVP5146/47 decoder | ||
195 | * Currently we are using 8 bit mode only, but can be | 186 | * Currently we are using 8 bit mode only, but can be |
196 | * extended to 10/20 bit mode. | 187 | * extended to 10/20 bit mode. |
197 | */ | 188 | */ |
@@ -240,35 +231,29 @@ static struct tvp514x_std_info tvp514x_std_list[] = { | |||
240 | }, | 231 | }, |
241 | /* Standard: need to add for additional standard */ | 232 | /* Standard: need to add for additional standard */ |
242 | }; | 233 | }; |
243 | /* | 234 | |
244 | * Control structure for Auto Gain | 235 | |
245 | * This is temporary data, will get replaced once | 236 | static inline struct tvp514x_decoder *to_decoder(struct v4l2_subdev *sd) |
246 | * v4l2_ctrl_query_fill supports it. | 237 | { |
247 | */ | 238 | return container_of(sd, struct tvp514x_decoder, sd); |
248 | static const struct v4l2_queryctrl tvp514x_autogain_ctrl = { | 239 | } |
249 | .id = V4L2_CID_AUTOGAIN, | 240 | |
250 | .name = "Gain, Automatic", | ||
251 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
252 | .minimum = 0, | ||
253 | .maximum = 1, | ||
254 | .step = 1, | ||
255 | .default_value = 1, | ||
256 | }; | ||
257 | 241 | ||
258 | /* | 242 | /* |
259 | * Read a value from a register in an TVP5146/47 decoder device. | 243 | * Read a value from a register in an TVP5146/47 decoder device. |
260 | * Returns value read if successful, or non-zero (-1) otherwise. | 244 | * Returns value read if successful, or non-zero (-1) otherwise. |
261 | */ | 245 | */ |
262 | static int tvp514x_read_reg(struct i2c_client *client, u8 reg) | 246 | static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg) |
263 | { | 247 | { |
264 | int err; | 248 | int err, retry = 0; |
265 | int retry = 0; | 249 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
250 | |||
266 | read_again: | 251 | read_again: |
267 | 252 | ||
268 | err = i2c_smbus_read_byte_data(client, reg); | 253 | err = i2c_smbus_read_byte_data(client, reg); |
269 | if (err == -1) { | 254 | if (err == -1) { |
270 | if (retry <= I2C_RETRY_COUNT) { | 255 | if (retry <= I2C_RETRY_COUNT) { |
271 | v4l_warn(client, "Read: retry ... %d\n", retry); | 256 | v4l2_warn(sd, "Read: retry ... %d\n", retry); |
272 | retry++; | 257 | retry++; |
273 | msleep_interruptible(10); | 258 | msleep_interruptible(10); |
274 | goto read_again; | 259 | goto read_again; |
@@ -278,20 +263,29 @@ read_again: | |||
278 | return err; | 263 | return err; |
279 | } | 264 | } |
280 | 265 | ||
266 | static void dump_reg(struct v4l2_subdev *sd, u8 reg) | ||
267 | { | ||
268 | u32 val; | ||
269 | |||
270 | val = tvp514x_read_reg(sd, reg); | ||
271 | v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); | ||
272 | } | ||
273 | |||
281 | /* | 274 | /* |
282 | * Write a value to a register in an TVP5146/47 decoder device. | 275 | * Write a value to a register in an TVP5146/47 decoder device. |
283 | * Returns zero if successful, or non-zero otherwise. | 276 | * Returns zero if successful, or non-zero otherwise. |
284 | */ | 277 | */ |
285 | static int tvp514x_write_reg(struct i2c_client *client, u8 reg, u8 val) | 278 | static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val) |
286 | { | 279 | { |
287 | int err; | 280 | int err, retry = 0; |
288 | int retry = 0; | 281 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
282 | |||
289 | write_again: | 283 | write_again: |
290 | 284 | ||
291 | err = i2c_smbus_write_byte_data(client, reg, val); | 285 | err = i2c_smbus_write_byte_data(client, reg, val); |
292 | if (err) { | 286 | if (err) { |
293 | if (retry <= I2C_RETRY_COUNT) { | 287 | if (retry <= I2C_RETRY_COUNT) { |
294 | v4l_warn(client, "Write: retry ... %d\n", retry); | 288 | v4l2_warn(sd, "Write: retry ... %d\n", retry); |
295 | retry++; | 289 | retry++; |
296 | msleep_interruptible(10); | 290 | msleep_interruptible(10); |
297 | goto write_again; | 291 | goto write_again; |
@@ -311,7 +305,7 @@ write_again: | |||
311 | * reglist - list of registers to be written | 305 | * reglist - list of registers to be written |
312 | * Returns zero if successful, or non-zero otherwise. | 306 | * Returns zero if successful, or non-zero otherwise. |
313 | */ | 307 | */ |
314 | static int tvp514x_write_regs(struct i2c_client *client, | 308 | static int tvp514x_write_regs(struct v4l2_subdev *sd, |
315 | const struct tvp514x_reg reglist[]) | 309 | const struct tvp514x_reg reglist[]) |
316 | { | 310 | { |
317 | int err; | 311 | int err; |
@@ -326,9 +320,9 @@ static int tvp514x_write_regs(struct i2c_client *client, | |||
326 | if (next->token == TOK_SKIP) | 320 | if (next->token == TOK_SKIP) |
327 | continue; | 321 | continue; |
328 | 322 | ||
329 | err = tvp514x_write_reg(client, next->reg, (u8) next->val); | 323 | err = tvp514x_write_reg(sd, next->reg, (u8) next->val); |
330 | if (err) { | 324 | if (err) { |
331 | v4l_err(client, "Write failed. Err[%d]\n", err); | 325 | v4l2_err(sd, "Write failed. Err[%d]\n", err); |
332 | return err; | 326 | return err; |
333 | } | 327 | } |
334 | } | 328 | } |
@@ -339,17 +333,15 @@ static int tvp514x_write_regs(struct i2c_client *client, | |||
339 | * tvp514x_get_current_std: | 333 | * tvp514x_get_current_std: |
340 | * Returns the current standard detected by TVP5146/47 | 334 | * Returns the current standard detected by TVP5146/47 |
341 | */ | 335 | */ |
342 | static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder | 336 | static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd) |
343 | *decoder) | ||
344 | { | 337 | { |
345 | u8 std, std_status; | 338 | u8 std, std_status; |
346 | 339 | ||
347 | std = tvp514x_read_reg(decoder->client, REG_VIDEO_STD); | 340 | std = tvp514x_read_reg(sd, REG_VIDEO_STD); |
348 | if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) { | 341 | if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) |
349 | /* use the standard status register */ | 342 | /* use the standard status register */ |
350 | std_status = tvp514x_read_reg(decoder->client, | 343 | std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS); |
351 | REG_VIDEO_STD_STATUS); | 344 | else |
352 | } else | ||
353 | std_status = std; /* use the standard register itself */ | 345 | std_status = std; /* use the standard register itself */ |
354 | 346 | ||
355 | switch (std_status & VIDEO_STD_MASK) { | 347 | switch (std_status & VIDEO_STD_MASK) { |
@@ -369,70 +361,69 @@ static enum tvp514x_std tvp514x_get_current_std(struct tvp514x_decoder | |||
369 | /* | 361 | /* |
370 | * TVP5146/47 register dump function | 362 | * TVP5146/47 register dump function |
371 | */ | 363 | */ |
372 | static void tvp514x_reg_dump(struct tvp514x_decoder *decoder) | 364 | static void tvp514x_reg_dump(struct v4l2_subdev *sd) |
373 | { | 365 | { |
374 | u8 value; | 366 | dump_reg(sd, REG_INPUT_SEL); |
375 | 367 | dump_reg(sd, REG_AFE_GAIN_CTRL); | |
376 | dump_reg(decoder->client, REG_INPUT_SEL, value); | 368 | dump_reg(sd, REG_VIDEO_STD); |
377 | dump_reg(decoder->client, REG_AFE_GAIN_CTRL, value); | 369 | dump_reg(sd, REG_OPERATION_MODE); |
378 | dump_reg(decoder->client, REG_VIDEO_STD, value); | 370 | dump_reg(sd, REG_COLOR_KILLER); |
379 | dump_reg(decoder->client, REG_OPERATION_MODE, value); | 371 | dump_reg(sd, REG_LUMA_CONTROL1); |
380 | dump_reg(decoder->client, REG_COLOR_KILLER, value); | 372 | dump_reg(sd, REG_LUMA_CONTROL2); |
381 | dump_reg(decoder->client, REG_LUMA_CONTROL1, value); | 373 | dump_reg(sd, REG_LUMA_CONTROL3); |
382 | dump_reg(decoder->client, REG_LUMA_CONTROL2, value); | 374 | dump_reg(sd, REG_BRIGHTNESS); |
383 | dump_reg(decoder->client, REG_LUMA_CONTROL3, value); | 375 | dump_reg(sd, REG_CONTRAST); |
384 | dump_reg(decoder->client, REG_BRIGHTNESS, value); | 376 | dump_reg(sd, REG_SATURATION); |
385 | dump_reg(decoder->client, REG_CONTRAST, value); | 377 | dump_reg(sd, REG_HUE); |
386 | dump_reg(decoder->client, REG_SATURATION, value); | 378 | dump_reg(sd, REG_CHROMA_CONTROL1); |
387 | dump_reg(decoder->client, REG_HUE, value); | 379 | dump_reg(sd, REG_CHROMA_CONTROL2); |
388 | dump_reg(decoder->client, REG_CHROMA_CONTROL1, value); | 380 | dump_reg(sd, REG_COMP_PR_SATURATION); |
389 | dump_reg(decoder->client, REG_CHROMA_CONTROL2, value); | 381 | dump_reg(sd, REG_COMP_Y_CONTRAST); |
390 | dump_reg(decoder->client, REG_COMP_PR_SATURATION, value); | 382 | dump_reg(sd, REG_COMP_PB_SATURATION); |
391 | dump_reg(decoder->client, REG_COMP_Y_CONTRAST, value); | 383 | dump_reg(sd, REG_COMP_Y_BRIGHTNESS); |
392 | dump_reg(decoder->client, REG_COMP_PB_SATURATION, value); | 384 | dump_reg(sd, REG_AVID_START_PIXEL_LSB); |
393 | dump_reg(decoder->client, REG_COMP_Y_BRIGHTNESS, value); | 385 | dump_reg(sd, REG_AVID_START_PIXEL_MSB); |
394 | dump_reg(decoder->client, REG_AVID_START_PIXEL_LSB, value); | 386 | dump_reg(sd, REG_AVID_STOP_PIXEL_LSB); |
395 | dump_reg(decoder->client, REG_AVID_START_PIXEL_MSB, value); | 387 | dump_reg(sd, REG_AVID_STOP_PIXEL_MSB); |
396 | dump_reg(decoder->client, REG_AVID_STOP_PIXEL_LSB, value); | 388 | dump_reg(sd, REG_HSYNC_START_PIXEL_LSB); |
397 | dump_reg(decoder->client, REG_AVID_STOP_PIXEL_MSB, value); | 389 | dump_reg(sd, REG_HSYNC_START_PIXEL_MSB); |
398 | dump_reg(decoder->client, REG_HSYNC_START_PIXEL_LSB, value); | 390 | dump_reg(sd, REG_HSYNC_STOP_PIXEL_LSB); |
399 | dump_reg(decoder->client, REG_HSYNC_START_PIXEL_MSB, value); | 391 | dump_reg(sd, REG_HSYNC_STOP_PIXEL_MSB); |
400 | dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_LSB, value); | 392 | dump_reg(sd, REG_VSYNC_START_LINE_LSB); |
401 | dump_reg(decoder->client, REG_HSYNC_STOP_PIXEL_MSB, value); | 393 | dump_reg(sd, REG_VSYNC_START_LINE_MSB); |
402 | dump_reg(decoder->client, REG_VSYNC_START_LINE_LSB, value); | 394 | dump_reg(sd, REG_VSYNC_STOP_LINE_LSB); |
403 | dump_reg(decoder->client, REG_VSYNC_START_LINE_MSB, value); | 395 | dump_reg(sd, REG_VSYNC_STOP_LINE_MSB); |
404 | dump_reg(decoder->client, REG_VSYNC_STOP_LINE_LSB, value); | 396 | dump_reg(sd, REG_VBLK_START_LINE_LSB); |
405 | dump_reg(decoder->client, REG_VSYNC_STOP_LINE_MSB, value); | 397 | dump_reg(sd, REG_VBLK_START_LINE_MSB); |
406 | dump_reg(decoder->client, REG_VBLK_START_LINE_LSB, value); | 398 | dump_reg(sd, REG_VBLK_STOP_LINE_LSB); |
407 | dump_reg(decoder->client, REG_VBLK_START_LINE_MSB, value); | 399 | dump_reg(sd, REG_VBLK_STOP_LINE_MSB); |
408 | dump_reg(decoder->client, REG_VBLK_STOP_LINE_LSB, value); | 400 | dump_reg(sd, REG_SYNC_CONTROL); |
409 | dump_reg(decoder->client, REG_VBLK_STOP_LINE_MSB, value); | 401 | dump_reg(sd, REG_OUTPUT_FORMATTER1); |
410 | dump_reg(decoder->client, REG_SYNC_CONTROL, value); | 402 | dump_reg(sd, REG_OUTPUT_FORMATTER2); |
411 | dump_reg(decoder->client, REG_OUTPUT_FORMATTER1, value); | 403 | dump_reg(sd, REG_OUTPUT_FORMATTER3); |
412 | dump_reg(decoder->client, REG_OUTPUT_FORMATTER2, value); | 404 | dump_reg(sd, REG_OUTPUT_FORMATTER4); |
413 | dump_reg(decoder->client, REG_OUTPUT_FORMATTER3, value); | 405 | dump_reg(sd, REG_OUTPUT_FORMATTER5); |
414 | dump_reg(decoder->client, REG_OUTPUT_FORMATTER4, value); | 406 | dump_reg(sd, REG_OUTPUT_FORMATTER6); |
415 | dump_reg(decoder->client, REG_OUTPUT_FORMATTER5, value); | 407 | dump_reg(sd, REG_CLEAR_LOST_LOCK); |
416 | dump_reg(decoder->client, REG_OUTPUT_FORMATTER6, value); | ||
417 | dump_reg(decoder->client, REG_CLEAR_LOST_LOCK, value); | ||
418 | } | 408 | } |
419 | 409 | ||
420 | /* | 410 | /* |
421 | * Configure the TVP5146/47 with the current register settings | 411 | * Configure the TVP5146/47 with the current register settings |
422 | * Returns zero if successful, or non-zero otherwise. | 412 | * Returns zero if successful, or non-zero otherwise. |
423 | */ | 413 | */ |
424 | static int tvp514x_configure(struct tvp514x_decoder *decoder) | 414 | static int tvp514x_configure(struct v4l2_subdev *sd, |
415 | struct tvp514x_decoder *decoder) | ||
425 | { | 416 | { |
426 | int err; | 417 | int err; |
427 | 418 | ||
428 | /* common register initialization */ | 419 | /* common register initialization */ |
429 | err = | 420 | err = |
430 | tvp514x_write_regs(decoder->client, decoder->tvp514x_regs); | 421 | tvp514x_write_regs(sd, decoder->tvp514x_regs); |
431 | if (err) | 422 | if (err) |
432 | return err; | 423 | return err; |
433 | 424 | ||
434 | if (debug) | 425 | if (debug) |
435 | tvp514x_reg_dump(decoder); | 426 | tvp514x_reg_dump(sd); |
436 | 427 | ||
437 | return 0; | 428 | return 0; |
438 | } | 429 | } |
@@ -445,15 +436,17 @@ static int tvp514x_configure(struct tvp514x_decoder *decoder) | |||
445 | * Returns ENODEV error number if no device is detected, or zero | 436 | * Returns ENODEV error number if no device is detected, or zero |
446 | * if a device is detected. | 437 | * if a device is detected. |
447 | */ | 438 | */ |
448 | static int tvp514x_detect(struct tvp514x_decoder *decoder) | 439 | static int tvp514x_detect(struct v4l2_subdev *sd, |
440 | struct tvp514x_decoder *decoder) | ||
449 | { | 441 | { |
450 | u8 chip_id_msb, chip_id_lsb, rom_ver; | 442 | u8 chip_id_msb, chip_id_lsb, rom_ver; |
443 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
451 | 444 | ||
452 | chip_id_msb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_MSB); | 445 | chip_id_msb = tvp514x_read_reg(sd, REG_CHIP_ID_MSB); |
453 | chip_id_lsb = tvp514x_read_reg(decoder->client, REG_CHIP_ID_LSB); | 446 | chip_id_lsb = tvp514x_read_reg(sd, REG_CHIP_ID_LSB); |
454 | rom_ver = tvp514x_read_reg(decoder->client, REG_ROM_VERSION); | 447 | rom_ver = tvp514x_read_reg(sd, REG_ROM_VERSION); |
455 | 448 | ||
456 | v4l_dbg(1, debug, decoder->client, | 449 | v4l2_dbg(1, debug, sd, |
457 | "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n", | 450 | "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n", |
458 | chip_id_msb, chip_id_lsb, rom_ver); | 451 | chip_id_msb, chip_id_lsb, rom_ver); |
459 | if ((chip_id_msb != TVP514X_CHIP_ID_MSB) | 452 | if ((chip_id_msb != TVP514X_CHIP_ID_MSB) |
@@ -462,19 +455,16 @@ static int tvp514x_detect(struct tvp514x_decoder *decoder) | |||
462 | /* We didn't read the values we expected, so this must not be | 455 | /* We didn't read the values we expected, so this must not be |
463 | * an TVP5146/47. | 456 | * an TVP5146/47. |
464 | */ | 457 | */ |
465 | v4l_err(decoder->client, | 458 | v4l2_err(sd, "chip id mismatch msb:0x%x lsb:0x%x\n", |
466 | "chip id mismatch msb:0x%x lsb:0x%x\n", | 459 | chip_id_msb, chip_id_lsb); |
467 | chip_id_msb, chip_id_lsb); | ||
468 | return -ENODEV; | 460 | return -ENODEV; |
469 | } | 461 | } |
470 | 462 | ||
471 | decoder->ver = rom_ver; | 463 | decoder->ver = rom_ver; |
472 | decoder->state = STATE_DETECTED; | ||
473 | 464 | ||
474 | v4l_info(decoder->client, | 465 | v4l2_info(sd, "%s (Version - 0x%.2x) found at 0x%x (%s)\n", |
475 | "%s found at 0x%x (%s)\n", decoder->client->name, | 466 | client->name, decoder->ver, |
476 | decoder->client->addr << 1, | 467 | client->addr << 1, client->adapter->name); |
477 | decoder->client->adapter->name); | ||
478 | return 0; | 468 | return 0; |
479 | } | 469 | } |
480 | 470 | ||
@@ -483,17 +473,17 @@ static int tvp514x_detect(struct tvp514x_decoder *decoder) | |||
483 | * TVP5146/47 decoder driver. | 473 | * TVP5146/47 decoder driver. |
484 | */ | 474 | */ |
485 | 475 | ||
486 | /** | 476 | /* |
487 | * ioctl_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl | 477 | * tvp514x_querystd - V4L2 decoder interface handler for VIDIOC_QUERYSTD ioctl |
488 | * @s: pointer to standard V4L2 device structure | 478 | * @sd: pointer to standard V4L2 sub-device structure |
489 | * @std_id: standard V4L2 std_id ioctl enum | 479 | * @std_id: standard V4L2 std_id ioctl enum |
490 | * | 480 | * |
491 | * Returns the current standard detected by TVP5146/47. If no active input is | 481 | * Returns the current standard detected by TVP5146/47. If no active input is |
492 | * detected, returns -EINVAL | 482 | * detected, returns -EINVAL |
493 | */ | 483 | */ |
494 | static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id) | 484 | static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id) |
495 | { | 485 | { |
496 | struct tvp514x_decoder *decoder = s->priv; | 486 | struct tvp514x_decoder *decoder = to_decoder(sd); |
497 | enum tvp514x_std current_std; | 487 | enum tvp514x_std current_std; |
498 | enum tvp514x_input input_sel; | 488 | enum tvp514x_input input_sel; |
499 | u8 sync_lock_status, lock_mask; | 489 | u8 sync_lock_status, lock_mask; |
@@ -502,11 +492,11 @@ static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id) | |||
502 | return -EINVAL; | 492 | return -EINVAL; |
503 | 493 | ||
504 | /* get the current standard */ | 494 | /* get the current standard */ |
505 | current_std = tvp514x_get_current_std(decoder); | 495 | current_std = tvp514x_get_current_std(sd); |
506 | if (current_std == STD_INVALID) | 496 | if (current_std == STD_INVALID) |
507 | return -EINVAL; | 497 | return -EINVAL; |
508 | 498 | ||
509 | input_sel = decoder->route.input; | 499 | input_sel = decoder->input; |
510 | 500 | ||
511 | switch (input_sel) { | 501 | switch (input_sel) { |
512 | case INPUT_CVBS_VI1A: | 502 | case INPUT_CVBS_VI1A: |
@@ -544,42 +534,39 @@ static int ioctl_querystd(struct v4l2_int_device *s, v4l2_std_id *std_id) | |||
544 | return -EINVAL; | 534 | return -EINVAL; |
545 | } | 535 | } |
546 | /* check whether signal is locked */ | 536 | /* check whether signal is locked */ |
547 | sync_lock_status = tvp514x_read_reg(decoder->client, REG_STATUS1); | 537 | sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1); |
548 | if (lock_mask != (sync_lock_status & lock_mask)) | 538 | if (lock_mask != (sync_lock_status & lock_mask)) |
549 | return -EINVAL; /* No input detected */ | 539 | return -EINVAL; /* No input detected */ |
550 | 540 | ||
551 | decoder->current_std = current_std; | 541 | decoder->current_std = current_std; |
552 | *std_id = decoder->std_list[current_std].standard.id; | 542 | *std_id = decoder->std_list[current_std].standard.id; |
553 | 543 | ||
554 | v4l_dbg(1, debug, decoder->client, "Current STD: %s", | 544 | v4l2_dbg(1, debug, sd, "Current STD: %s", |
555 | decoder->std_list[current_std].standard.name); | 545 | decoder->std_list[current_std].standard.name); |
556 | return 0; | 546 | return 0; |
557 | } | 547 | } |
558 | 548 | ||
559 | /** | 549 | /* |
560 | * ioctl_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl | 550 | * tvp514x_s_std - V4L2 decoder interface handler for VIDIOC_S_STD ioctl |
561 | * @s: pointer to standard V4L2 device structure | 551 | * @sd: pointer to standard V4L2 sub-device structure |
562 | * @std_id: standard V4L2 v4l2_std_id ioctl enum | 552 | * @std_id: standard V4L2 v4l2_std_id ioctl enum |
563 | * | 553 | * |
564 | * If std_id is supported, sets the requested standard. Otherwise, returns | 554 | * If std_id is supported, sets the requested standard. Otherwise, returns |
565 | * -EINVAL | 555 | * -EINVAL |
566 | */ | 556 | */ |
567 | static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id) | 557 | static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id) |
568 | { | 558 | { |
569 | struct tvp514x_decoder *decoder = s->priv; | 559 | struct tvp514x_decoder *decoder = to_decoder(sd); |
570 | int err, i; | 560 | int err, i; |
571 | 561 | ||
572 | if (std_id == NULL) | ||
573 | return -EINVAL; | ||
574 | |||
575 | for (i = 0; i < decoder->num_stds; i++) | 562 | for (i = 0; i < decoder->num_stds; i++) |
576 | if (*std_id & decoder->std_list[i].standard.id) | 563 | if (std_id & decoder->std_list[i].standard.id) |
577 | break; | 564 | break; |
578 | 565 | ||
579 | if ((i == decoder->num_stds) || (i == STD_INVALID)) | 566 | if ((i == decoder->num_stds) || (i == STD_INVALID)) |
580 | return -EINVAL; | 567 | return -EINVAL; |
581 | 568 | ||
582 | err = tvp514x_write_reg(decoder->client, REG_VIDEO_STD, | 569 | err = tvp514x_write_reg(sd, REG_VIDEO_STD, |
583 | decoder->std_list[i].video_std); | 570 | decoder->std_list[i].video_std); |
584 | if (err) | 571 | if (err) |
585 | return err; | 572 | return err; |
@@ -588,24 +575,24 @@ static int ioctl_s_std(struct v4l2_int_device *s, v4l2_std_id *std_id) | |||
588 | decoder->tvp514x_regs[REG_VIDEO_STD].val = | 575 | decoder->tvp514x_regs[REG_VIDEO_STD].val = |
589 | decoder->std_list[i].video_std; | 576 | decoder->std_list[i].video_std; |
590 | 577 | ||
591 | v4l_dbg(1, debug, decoder->client, "Standard set to: %s", | 578 | v4l2_dbg(1, debug, sd, "Standard set to: %s", |
592 | decoder->std_list[i].standard.name); | 579 | decoder->std_list[i].standard.name); |
593 | return 0; | 580 | return 0; |
594 | } | 581 | } |
595 | 582 | ||
596 | /** | 583 | /* |
597 | * ioctl_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl | 584 | * tvp514x_s_routing - V4L2 decoder interface handler for VIDIOC_S_INPUT ioctl |
598 | * @s: pointer to standard V4L2 device structure | 585 | * @sd: pointer to standard V4L2 sub-device structure |
599 | * @index: number of the input | 586 | * @index: number of the input |
600 | * | 587 | * |
601 | * If index is valid, selects the requested input. Otherwise, returns -EINVAL if | 588 | * If index is valid, selects the requested input. Otherwise, returns -EINVAL if |
602 | * the input is not supported or there is no active signal present in the | 589 | * the input is not supported or there is no active signal present in the |
603 | * selected input. | 590 | * selected input. |
604 | */ | 591 | */ |
605 | static int ioctl_s_routing(struct v4l2_int_device *s, | 592 | static int tvp514x_s_routing(struct v4l2_subdev *sd, |
606 | struct v4l2_routing *route) | 593 | u32 input, u32 output, u32 config) |
607 | { | 594 | { |
608 | struct tvp514x_decoder *decoder = s->priv; | 595 | struct tvp514x_decoder *decoder = to_decoder(sd); |
609 | int err; | 596 | int err; |
610 | enum tvp514x_input input_sel; | 597 | enum tvp514x_input input_sel; |
611 | enum tvp514x_output output_sel; | 598 | enum tvp514x_output output_sel; |
@@ -613,20 +600,20 @@ static int ioctl_s_routing(struct v4l2_int_device *s, | |||
613 | u8 sync_lock_status, lock_mask; | 600 | u8 sync_lock_status, lock_mask; |
614 | int try_count = LOCK_RETRY_COUNT; | 601 | int try_count = LOCK_RETRY_COUNT; |
615 | 602 | ||
616 | if ((!route) || (route->input >= INPUT_INVALID) || | 603 | if ((input >= INPUT_INVALID) || |
617 | (route->output >= OUTPUT_INVALID)) | 604 | (output >= OUTPUT_INVALID)) |
618 | return -EINVAL; /* Index out of bound */ | 605 | return -EINVAL; /* Index out of bound */ |
619 | 606 | ||
620 | input_sel = route->input; | 607 | input_sel = input; |
621 | output_sel = route->output; | 608 | output_sel = output; |
622 | 609 | ||
623 | err = tvp514x_write_reg(decoder->client, REG_INPUT_SEL, input_sel); | 610 | err = tvp514x_write_reg(sd, REG_INPUT_SEL, input_sel); |
624 | if (err) | 611 | if (err) |
625 | return err; | 612 | return err; |
626 | 613 | ||
627 | output_sel |= tvp514x_read_reg(decoder->client, | 614 | output_sel |= tvp514x_read_reg(sd, |
628 | REG_OUTPUT_FORMATTER1) & 0x7; | 615 | REG_OUTPUT_FORMATTER1) & 0x7; |
629 | err = tvp514x_write_reg(decoder->client, REG_OUTPUT_FORMATTER1, | 616 | err = tvp514x_write_reg(sd, REG_OUTPUT_FORMATTER1, |
630 | output_sel); | 617 | output_sel); |
631 | if (err) | 618 | if (err) |
632 | return err; | 619 | return err; |
@@ -637,7 +624,7 @@ static int ioctl_s_routing(struct v4l2_int_device *s, | |||
637 | /* Clear status */ | 624 | /* Clear status */ |
638 | msleep(LOCK_RETRY_DELAY); | 625 | msleep(LOCK_RETRY_DELAY); |
639 | err = | 626 | err = |
640 | tvp514x_write_reg(decoder->client, REG_CLEAR_LOST_LOCK, 0x01); | 627 | tvp514x_write_reg(sd, REG_CLEAR_LOST_LOCK, 0x01); |
641 | if (err) | 628 | if (err) |
642 | return err; | 629 | return err; |
643 | 630 | ||
@@ -682,11 +669,11 @@ static int ioctl_s_routing(struct v4l2_int_device *s, | |||
682 | msleep(LOCK_RETRY_DELAY); | 669 | msleep(LOCK_RETRY_DELAY); |
683 | 670 | ||
684 | /* get the current standard for future reference */ | 671 | /* get the current standard for future reference */ |
685 | current_std = tvp514x_get_current_std(decoder); | 672 | current_std = tvp514x_get_current_std(sd); |
686 | if (current_std == STD_INVALID) | 673 | if (current_std == STD_INVALID) |
687 | continue; | 674 | continue; |
688 | 675 | ||
689 | sync_lock_status = tvp514x_read_reg(decoder->client, | 676 | sync_lock_status = tvp514x_read_reg(sd, |
690 | REG_STATUS1); | 677 | REG_STATUS1); |
691 | if (lock_mask == (sync_lock_status & lock_mask)) | 678 | if (lock_mask == (sync_lock_status & lock_mask)) |
692 | break; /* Input detected */ | 679 | break; /* Input detected */ |
@@ -696,28 +683,26 @@ static int ioctl_s_routing(struct v4l2_int_device *s, | |||
696 | return -EINVAL; | 683 | return -EINVAL; |
697 | 684 | ||
698 | decoder->current_std = current_std; | 685 | decoder->current_std = current_std; |
699 | decoder->route.input = route->input; | 686 | decoder->input = input; |
700 | decoder->route.output = route->output; | 687 | decoder->output = output; |
701 | 688 | ||
702 | v4l_dbg(1, debug, decoder->client, | 689 | v4l2_dbg(1, debug, sd, "Input set to: %d, std : %d", |
703 | "Input set to: %d, std : %d", | ||
704 | input_sel, current_std); | 690 | input_sel, current_std); |
705 | 691 | ||
706 | return 0; | 692 | return 0; |
707 | } | 693 | } |
708 | 694 | ||
709 | /** | 695 | /* |
710 | * ioctl_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl | 696 | * tvp514x_queryctrl - V4L2 decoder interface handler for VIDIOC_QUERYCTRL ioctl |
711 | * @s: pointer to standard V4L2 device structure | 697 | * @sd: pointer to standard V4L2 sub-device structure |
712 | * @qctrl: standard V4L2 v4l2_queryctrl structure | 698 | * @qctrl: standard V4L2 v4l2_queryctrl structure |
713 | * | 699 | * |
714 | * If the requested control is supported, returns the control information. | 700 | * If the requested control is supported, returns the control information. |
715 | * Otherwise, returns -EINVAL if the control is not supported. | 701 | * Otherwise, returns -EINVAL if the control is not supported. |
716 | */ | 702 | */ |
717 | static int | 703 | static int |
718 | ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl) | 704 | tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl) |
719 | { | 705 | { |
720 | struct tvp514x_decoder *decoder = s->priv; | ||
721 | int err = -EINVAL; | 706 | int err = -EINVAL; |
722 | 707 | ||
723 | if (qctrl == NULL) | 708 | if (qctrl == NULL) |
@@ -744,30 +729,27 @@ ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl) | |||
744 | err = v4l2_ctrl_query_fill(qctrl, -180, 180, 180, 0); | 729 | err = v4l2_ctrl_query_fill(qctrl, -180, 180, 180, 0); |
745 | break; | 730 | break; |
746 | case V4L2_CID_AUTOGAIN: | 731 | case V4L2_CID_AUTOGAIN: |
747 | /* Autogain is either 0 or 1*/ | 732 | /* |
748 | memcpy(qctrl, &tvp514x_autogain_ctrl, | 733 | * Auto Gain supported is - |
749 | sizeof(struct v4l2_queryctrl)); | 734 | * 0 - 1 (Default - 1) |
750 | err = 0; | 735 | */ |
736 | err = v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 1); | ||
751 | break; | 737 | break; |
752 | default: | 738 | default: |
753 | v4l_err(decoder->client, | 739 | v4l2_err(sd, "invalid control id %d\n", qctrl->id); |
754 | "invalid control id %d\n", qctrl->id); | ||
755 | return err; | 740 | return err; |
756 | } | 741 | } |
757 | 742 | ||
758 | v4l_dbg(1, debug, decoder->client, | 743 | v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def - %d", |
759 | "Query Control: %s : Min - %d, Max - %d, Def - %d", | 744 | qctrl->name, qctrl->minimum, qctrl->maximum, |
760 | qctrl->name, | ||
761 | qctrl->minimum, | ||
762 | qctrl->maximum, | ||
763 | qctrl->default_value); | 745 | qctrl->default_value); |
764 | 746 | ||
765 | return err; | 747 | return err; |
766 | } | 748 | } |
767 | 749 | ||
768 | /** | 750 | /* |
769 | * ioctl_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl | 751 | * tvp514x_g_ctrl - V4L2 decoder interface handler for VIDIOC_G_CTRL ioctl |
770 | * @s: pointer to standard V4L2 device structure | 752 | * @sd: pointer to standard V4L2 sub-device structure |
771 | * @ctrl: pointer to v4l2_control structure | 753 | * @ctrl: pointer to v4l2_control structure |
772 | * | 754 | * |
773 | * If the requested control is supported, returns the control's current | 755 | * If the requested control is supported, returns the control's current |
@@ -775,9 +757,9 @@ ioctl_queryctrl(struct v4l2_int_device *s, struct v4l2_queryctrl *qctrl) | |||
775 | * supported. | 757 | * supported. |
776 | */ | 758 | */ |
777 | static int | 759 | static int |
778 | ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl) | 760 | tvp514x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) |
779 | { | 761 | { |
780 | struct tvp514x_decoder *decoder = s->priv; | 762 | struct tvp514x_decoder *decoder = to_decoder(sd); |
781 | 763 | ||
782 | if (ctrl == NULL) | 764 | if (ctrl == NULL) |
783 | return -EINVAL; | 765 | return -EINVAL; |
@@ -811,74 +793,70 @@ ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl) | |||
811 | 793 | ||
812 | break; | 794 | break; |
813 | default: | 795 | default: |
814 | v4l_err(decoder->client, | 796 | v4l2_err(sd, "invalid control id %d\n", ctrl->id); |
815 | "invalid control id %d\n", ctrl->id); | ||
816 | return -EINVAL; | 797 | return -EINVAL; |
817 | } | 798 | } |
818 | 799 | ||
819 | v4l_dbg(1, debug, decoder->client, | 800 | v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d", |
820 | "Get Control: ID - %d - %d", | ||
821 | ctrl->id, ctrl->value); | 801 | ctrl->id, ctrl->value); |
822 | return 0; | 802 | return 0; |
823 | } | 803 | } |
824 | 804 | ||
825 | /** | 805 | /* |
826 | * ioctl_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl | 806 | * tvp514x_s_ctrl - V4L2 decoder interface handler for VIDIOC_S_CTRL ioctl |
827 | * @s: pointer to standard V4L2 device structure | 807 | * @sd: pointer to standard V4L2 sub-device structure |
828 | * @ctrl: pointer to v4l2_control structure | 808 | * @ctrl: pointer to v4l2_control structure |
829 | * | 809 | * |
830 | * If the requested control is supported, sets the control's current | 810 | * If the requested control is supported, sets the control's current |
831 | * value in HW. Otherwise, returns -EINVAL if the control is not supported. | 811 | * value in HW. Otherwise, returns -EINVAL if the control is not supported. |
832 | */ | 812 | */ |
833 | static int | 813 | static int |
834 | ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl) | 814 | tvp514x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) |
835 | { | 815 | { |
836 | struct tvp514x_decoder *decoder = s->priv; | 816 | struct tvp514x_decoder *decoder = to_decoder(sd); |
837 | int err = -EINVAL, value; | 817 | int err = -EINVAL, value; |
838 | 818 | ||
839 | if (ctrl == NULL) | 819 | if (ctrl == NULL) |
840 | return err; | 820 | return err; |
841 | 821 | ||
842 | value = (__s32) ctrl->value; | 822 | value = ctrl->value; |
843 | 823 | ||
844 | switch (ctrl->id) { | 824 | switch (ctrl->id) { |
845 | case V4L2_CID_BRIGHTNESS: | 825 | case V4L2_CID_BRIGHTNESS: |
846 | if (ctrl->value < 0 || ctrl->value > 255) { | 826 | if (ctrl->value < 0 || ctrl->value > 255) { |
847 | v4l_err(decoder->client, | 827 | v4l2_err(sd, "invalid brightness setting %d\n", |
848 | "invalid brightness setting %d\n", | ||
849 | ctrl->value); | 828 | ctrl->value); |
850 | return -ERANGE; | 829 | return -ERANGE; |
851 | } | 830 | } |
852 | err = tvp514x_write_reg(decoder->client, REG_BRIGHTNESS, | 831 | err = tvp514x_write_reg(sd, REG_BRIGHTNESS, |
853 | value); | 832 | value); |
854 | if (err) | 833 | if (err) |
855 | return err; | 834 | return err; |
835 | |||
856 | decoder->tvp514x_regs[REG_BRIGHTNESS].val = value; | 836 | decoder->tvp514x_regs[REG_BRIGHTNESS].val = value; |
857 | break; | 837 | break; |
858 | case V4L2_CID_CONTRAST: | 838 | case V4L2_CID_CONTRAST: |
859 | if (ctrl->value < 0 || ctrl->value > 255) { | 839 | if (ctrl->value < 0 || ctrl->value > 255) { |
860 | v4l_err(decoder->client, | 840 | v4l2_err(sd, "invalid contrast setting %d\n", |
861 | "invalid contrast setting %d\n", | ||
862 | ctrl->value); | 841 | ctrl->value); |
863 | return -ERANGE; | 842 | return -ERANGE; |
864 | } | 843 | } |
865 | err = tvp514x_write_reg(decoder->client, REG_CONTRAST, | 844 | err = tvp514x_write_reg(sd, REG_CONTRAST, value); |
866 | value); | ||
867 | if (err) | 845 | if (err) |
868 | return err; | 846 | return err; |
847 | |||
869 | decoder->tvp514x_regs[REG_CONTRAST].val = value; | 848 | decoder->tvp514x_regs[REG_CONTRAST].val = value; |
870 | break; | 849 | break; |
871 | case V4L2_CID_SATURATION: | 850 | case V4L2_CID_SATURATION: |
872 | if (ctrl->value < 0 || ctrl->value > 255) { | 851 | if (ctrl->value < 0 || ctrl->value > 255) { |
873 | v4l_err(decoder->client, | 852 | v4l2_err(sd, "invalid saturation setting %d\n", |
874 | "invalid saturation setting %d\n", | ||
875 | ctrl->value); | 853 | ctrl->value); |
876 | return -ERANGE; | 854 | return -ERANGE; |
877 | } | 855 | } |
878 | err = tvp514x_write_reg(decoder->client, REG_SATURATION, | 856 | err = tvp514x_write_reg(sd, REG_SATURATION, value); |
879 | value); | ||
880 | if (err) | 857 | if (err) |
881 | return err; | 858 | return err; |
859 | |||
882 | decoder->tvp514x_regs[REG_SATURATION].val = value; | 860 | decoder->tvp514x_regs[REG_SATURATION].val = value; |
883 | break; | 861 | break; |
884 | case V4L2_CID_HUE: | 862 | case V4L2_CID_HUE: |
@@ -889,15 +867,13 @@ ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl) | |||
889 | else if (value == 0) | 867 | else if (value == 0) |
890 | value = 0; | 868 | value = 0; |
891 | else { | 869 | else { |
892 | v4l_err(decoder->client, | 870 | v4l2_err(sd, "invalid hue setting %d\n", ctrl->value); |
893 | "invalid hue setting %d\n", | ||
894 | ctrl->value); | ||
895 | return -ERANGE; | 871 | return -ERANGE; |
896 | } | 872 | } |
897 | err = tvp514x_write_reg(decoder->client, REG_HUE, | 873 | err = tvp514x_write_reg(sd, REG_HUE, value); |
898 | value); | ||
899 | if (err) | 874 | if (err) |
900 | return err; | 875 | return err; |
876 | |||
901 | decoder->tvp514x_regs[REG_HUE].val = value; | 877 | decoder->tvp514x_regs[REG_HUE].val = value; |
902 | break; | 878 | break; |
903 | case V4L2_CID_AUTOGAIN: | 879 | case V4L2_CID_AUTOGAIN: |
@@ -906,41 +882,38 @@ ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *ctrl) | |||
906 | else if (value == 0) | 882 | else if (value == 0) |
907 | value = 0x0C; | 883 | value = 0x0C; |
908 | else { | 884 | else { |
909 | v4l_err(decoder->client, | 885 | v4l2_err(sd, "invalid auto gain setting %d\n", |
910 | "invalid auto gain setting %d\n", | ||
911 | ctrl->value); | 886 | ctrl->value); |
912 | return -ERANGE; | 887 | return -ERANGE; |
913 | } | 888 | } |
914 | err = tvp514x_write_reg(decoder->client, REG_AFE_GAIN_CTRL, | 889 | err = tvp514x_write_reg(sd, REG_AFE_GAIN_CTRL, value); |
915 | value); | ||
916 | if (err) | 890 | if (err) |
917 | return err; | 891 | return err; |
892 | |||
918 | decoder->tvp514x_regs[REG_AFE_GAIN_CTRL].val = value; | 893 | decoder->tvp514x_regs[REG_AFE_GAIN_CTRL].val = value; |
919 | break; | 894 | break; |
920 | default: | 895 | default: |
921 | v4l_err(decoder->client, | 896 | v4l2_err(sd, "invalid control id %d\n", ctrl->id); |
922 | "invalid control id %d\n", ctrl->id); | ||
923 | return err; | 897 | return err; |
924 | } | 898 | } |
925 | 899 | ||
926 | v4l_dbg(1, debug, decoder->client, | 900 | v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d", |
927 | "Set Control: ID - %d - %d", | ||
928 | ctrl->id, ctrl->value); | 901 | ctrl->id, ctrl->value); |
929 | 902 | ||
930 | return err; | 903 | return err; |
931 | } | 904 | } |
932 | 905 | ||
933 | /** | 906 | /* |
934 | * ioctl_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl | 907 | * tvp514x_enum_fmt_cap - Implement the CAPTURE buffer VIDIOC_ENUM_FMT ioctl |
935 | * @s: pointer to standard V4L2 device structure | 908 | * @sd: pointer to standard V4L2 sub-device structure |
936 | * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure | 909 | * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure |
937 | * | 910 | * |
938 | * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats | 911 | * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats |
939 | */ | 912 | */ |
940 | static int | 913 | static int |
941 | ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt) | 914 | tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt) |
942 | { | 915 | { |
943 | struct tvp514x_decoder *decoder = s->priv; | 916 | struct tvp514x_decoder *decoder = to_decoder(sd); |
944 | int index; | 917 | int index; |
945 | 918 | ||
946 | if (fmt == NULL) | 919 | if (fmt == NULL) |
@@ -956,16 +929,15 @@ ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt) | |||
956 | memcpy(fmt, &decoder->fmt_list[index], | 929 | memcpy(fmt, &decoder->fmt_list[index], |
957 | sizeof(struct v4l2_fmtdesc)); | 930 | sizeof(struct v4l2_fmtdesc)); |
958 | 931 | ||
959 | v4l_dbg(1, debug, decoder->client, | 932 | v4l2_dbg(1, debug, sd, "Current FMT: index - %d (%s)", |
960 | "Current FMT: index - %d (%s)", | ||
961 | decoder->fmt_list[index].index, | 933 | decoder->fmt_list[index].index, |
962 | decoder->fmt_list[index].description); | 934 | decoder->fmt_list[index].description); |
963 | return 0; | 935 | return 0; |
964 | } | 936 | } |
965 | 937 | ||
966 | /** | 938 | /* |
967 | * ioctl_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl | 939 | * tvp514x_try_fmt_cap - Implement the CAPTURE buffer VIDIOC_TRY_FMT ioctl |
968 | * @s: pointer to standard V4L2 device structure | 940 | * @sd: pointer to standard V4L2 sub-device structure |
969 | * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure | 941 | * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure |
970 | * | 942 | * |
971 | * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This | 943 | * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This |
@@ -973,9 +945,9 @@ ioctl_enum_fmt_cap(struct v4l2_int_device *s, struct v4l2_fmtdesc *fmt) | |||
973 | * without actually making it take effect. | 945 | * without actually making it take effect. |
974 | */ | 946 | */ |
975 | static int | 947 | static int |
976 | ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | 948 | tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) |
977 | { | 949 | { |
978 | struct tvp514x_decoder *decoder = s->priv; | 950 | struct tvp514x_decoder *decoder = to_decoder(sd); |
979 | int ifmt; | 951 | int ifmt; |
980 | struct v4l2_pix_format *pix; | 952 | struct v4l2_pix_format *pix; |
981 | enum tvp514x_std current_std; | 953 | enum tvp514x_std current_std; |
@@ -989,7 +961,7 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | |||
989 | pix = &f->fmt.pix; | 961 | pix = &f->fmt.pix; |
990 | 962 | ||
991 | /* Calculate height and width based on current standard */ | 963 | /* Calculate height and width based on current standard */ |
992 | current_std = tvp514x_get_current_std(decoder); | 964 | current_std = tvp514x_get_current_std(sd); |
993 | if (current_std == STD_INVALID) | 965 | if (current_std == STD_INVALID) |
994 | return -EINVAL; | 966 | return -EINVAL; |
995 | 967 | ||
@@ -1012,17 +984,16 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | |||
1012 | pix->colorspace = V4L2_COLORSPACE_SMPTE170M; | 984 | pix->colorspace = V4L2_COLORSPACE_SMPTE170M; |
1013 | pix->priv = 0; | 985 | pix->priv = 0; |
1014 | 986 | ||
1015 | v4l_dbg(1, debug, decoder->client, | 987 | v4l2_dbg(1, debug, sd, "Try FMT: pixelformat - %s, bytesperline - %d" |
1016 | "Try FMT: pixelformat - %s, bytesperline - %d" | ||
1017 | "Width - %d, Height - %d", | 988 | "Width - %d, Height - %d", |
1018 | decoder->fmt_list[ifmt].description, pix->bytesperline, | 989 | decoder->fmt_list[ifmt].description, pix->bytesperline, |
1019 | pix->width, pix->height); | 990 | pix->width, pix->height); |
1020 | return 0; | 991 | return 0; |
1021 | } | 992 | } |
1022 | 993 | ||
1023 | /** | 994 | /* |
1024 | * ioctl_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl | 995 | * tvp514x_s_fmt_cap - V4L2 decoder interface handler for VIDIOC_S_FMT ioctl |
1025 | * @s: pointer to standard V4L2 device structure | 996 | * @sd: pointer to standard V4L2 sub-device structure |
1026 | * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure | 997 | * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure |
1027 | * | 998 | * |
1028 | * If the requested format is supported, configures the HW to use that | 999 | * If the requested format is supported, configures the HW to use that |
@@ -1030,9 +1001,9 @@ ioctl_try_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | |||
1030 | * correctly configured. | 1001 | * correctly configured. |
1031 | */ | 1002 | */ |
1032 | static int | 1003 | static int |
1033 | ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | 1004 | tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) |
1034 | { | 1005 | { |
1035 | struct tvp514x_decoder *decoder = s->priv; | 1006 | struct tvp514x_decoder *decoder = to_decoder(sd); |
1036 | struct v4l2_pix_format *pix; | 1007 | struct v4l2_pix_format *pix; |
1037 | int rval; | 1008 | int rval; |
1038 | 1009 | ||
@@ -1043,7 +1014,7 @@ ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | |||
1043 | return -EINVAL; /* only capture is supported */ | 1014 | return -EINVAL; /* only capture is supported */ |
1044 | 1015 | ||
1045 | pix = &f->fmt.pix; | 1016 | pix = &f->fmt.pix; |
1046 | rval = ioctl_try_fmt_cap(s, f); | 1017 | rval = tvp514x_try_fmt_cap(sd, f); |
1047 | if (rval) | 1018 | if (rval) |
1048 | return rval; | 1019 | return rval; |
1049 | 1020 | ||
@@ -1052,18 +1023,18 @@ ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | |||
1052 | return rval; | 1023 | return rval; |
1053 | } | 1024 | } |
1054 | 1025 | ||
1055 | /** | 1026 | /* |
1056 | * ioctl_g_fmt_cap - V4L2 decoder interface handler for ioctl_g_fmt_cap | 1027 | * tvp514x_g_fmt_cap - V4L2 decoder interface handler for tvp514x_g_fmt_cap |
1057 | * @s: pointer to standard V4L2 device structure | 1028 | * @sd: pointer to standard V4L2 sub-device structure |
1058 | * @f: pointer to standard V4L2 v4l2_format structure | 1029 | * @f: pointer to standard V4L2 v4l2_format structure |
1059 | * | 1030 | * |
1060 | * Returns the decoder's current pixel format in the v4l2_format | 1031 | * Returns the decoder's current pixel format in the v4l2_format |
1061 | * parameter. | 1032 | * parameter. |
1062 | */ | 1033 | */ |
1063 | static int | 1034 | static int |
1064 | ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | 1035 | tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) |
1065 | { | 1036 | { |
1066 | struct tvp514x_decoder *decoder = s->priv; | 1037 | struct tvp514x_decoder *decoder = to_decoder(sd); |
1067 | 1038 | ||
1068 | if (f == NULL) | 1039 | if (f == NULL) |
1069 | return -EINVAL; | 1040 | return -EINVAL; |
@@ -1073,25 +1044,24 @@ ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | |||
1073 | 1044 | ||
1074 | f->fmt.pix = decoder->pix; | 1045 | f->fmt.pix = decoder->pix; |
1075 | 1046 | ||
1076 | v4l_dbg(1, debug, decoder->client, | 1047 | v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d" |
1077 | "Current FMT: bytesperline - %d" | ||
1078 | "Width - %d, Height - %d", | 1048 | "Width - %d, Height - %d", |
1079 | decoder->pix.bytesperline, | 1049 | decoder->pix.bytesperline, |
1080 | decoder->pix.width, decoder->pix.height); | 1050 | decoder->pix.width, decoder->pix.height); |
1081 | return 0; | 1051 | return 0; |
1082 | } | 1052 | } |
1083 | 1053 | ||
1084 | /** | 1054 | /* |
1085 | * ioctl_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl | 1055 | * tvp514x_g_parm - V4L2 decoder interface handler for VIDIOC_G_PARM ioctl |
1086 | * @s: pointer to standard V4L2 device structure | 1056 | * @sd: pointer to standard V4L2 sub-device structure |
1087 | * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure | 1057 | * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure |
1088 | * | 1058 | * |
1089 | * Returns the decoder's video CAPTURE parameters. | 1059 | * Returns the decoder's video CAPTURE parameters. |
1090 | */ | 1060 | */ |
1091 | static int | 1061 | static int |
1092 | ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | 1062 | tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) |
1093 | { | 1063 | { |
1094 | struct tvp514x_decoder *decoder = s->priv; | 1064 | struct tvp514x_decoder *decoder = to_decoder(sd); |
1095 | struct v4l2_captureparm *cparm; | 1065 | struct v4l2_captureparm *cparm; |
1096 | enum tvp514x_std current_std; | 1066 | enum tvp514x_std current_std; |
1097 | 1067 | ||
@@ -1105,7 +1075,7 @@ ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | |||
1105 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1075 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1106 | 1076 | ||
1107 | /* get the current standard */ | 1077 | /* get the current standard */ |
1108 | current_std = tvp514x_get_current_std(decoder); | 1078 | current_std = tvp514x_get_current_std(sd); |
1109 | if (current_std == STD_INVALID) | 1079 | if (current_std == STD_INVALID) |
1110 | return -EINVAL; | 1080 | return -EINVAL; |
1111 | 1081 | ||
@@ -1119,18 +1089,18 @@ ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | |||
1119 | return 0; | 1089 | return 0; |
1120 | } | 1090 | } |
1121 | 1091 | ||
1122 | /** | 1092 | /* |
1123 | * ioctl_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl | 1093 | * tvp514x_s_parm - V4L2 decoder interface handler for VIDIOC_S_PARM ioctl |
1124 | * @s: pointer to standard V4L2 device structure | 1094 | * @sd: pointer to standard V4L2 sub-device structure |
1125 | * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure | 1095 | * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure |
1126 | * | 1096 | * |
1127 | * Configures the decoder to use the input parameters, if possible. If | 1097 | * Configures the decoder to use the input parameters, if possible. If |
1128 | * not possible, returns the appropriate error code. | 1098 | * not possible, returns the appropriate error code. |
1129 | */ | 1099 | */ |
1130 | static int | 1100 | static int |
1131 | ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | 1101 | tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) |
1132 | { | 1102 | { |
1133 | struct tvp514x_decoder *decoder = s->priv; | 1103 | struct tvp514x_decoder *decoder = to_decoder(sd); |
1134 | struct v4l2_fract *timeperframe; | 1104 | struct v4l2_fract *timeperframe; |
1135 | enum tvp514x_std current_std; | 1105 | enum tvp514x_std current_std; |
1136 | 1106 | ||
@@ -1143,7 +1113,7 @@ ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | |||
1143 | timeperframe = &a->parm.capture.timeperframe; | 1113 | timeperframe = &a->parm.capture.timeperframe; |
1144 | 1114 | ||
1145 | /* get the current standard */ | 1115 | /* get the current standard */ |
1146 | current_std = tvp514x_get_current_std(decoder); | 1116 | current_std = tvp514x_get_current_std(sd); |
1147 | if (current_std == STD_INVALID) | 1117 | if (current_std == STD_INVALID) |
1148 | return -EINVAL; | 1118 | return -EINVAL; |
1149 | 1119 | ||
@@ -1155,112 +1125,59 @@ ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | |||
1155 | return 0; | 1125 | return 0; |
1156 | } | 1126 | } |
1157 | 1127 | ||
1158 | /** | 1128 | /* |
1159 | * ioctl_g_ifparm - V4L2 decoder interface handler for vidioc_int_g_ifparm_num | 1129 | * tvp514x_s_stream - V4L2 decoder interface handler for vidioc_int_s_power_num |
1160 | * @s: pointer to standard V4L2 device structure | 1130 | * @sd: pointer to standard V4L2 sub-device structure |
1161 | * @p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure | 1131 | * @enable: streaming enable or disable |
1162 | * | ||
1163 | * Gets slave interface parameters. | ||
1164 | * Calculates the required xclk value to support the requested | ||
1165 | * clock parameters in p. This value is returned in the p | ||
1166 | * parameter. | ||
1167 | */ | ||
1168 | static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) | ||
1169 | { | ||
1170 | struct tvp514x_decoder *decoder = s->priv; | ||
1171 | int rval; | ||
1172 | |||
1173 | if (p == NULL) | ||
1174 | return -EINVAL; | ||
1175 | |||
1176 | if (NULL == decoder->pdata->ifparm) | ||
1177 | return -EINVAL; | ||
1178 | |||
1179 | rval = decoder->pdata->ifparm(p); | ||
1180 | if (rval) { | ||
1181 | v4l_err(decoder->client, "g_ifparm.Err[%d]\n", rval); | ||
1182 | return rval; | ||
1183 | } | ||
1184 | |||
1185 | p->u.bt656.clock_curr = TVP514X_XCLK_BT656; | ||
1186 | |||
1187 | return 0; | ||
1188 | } | ||
1189 | |||
1190 | /** | ||
1191 | * ioctl_g_priv - V4L2 decoder interface handler for vidioc_int_g_priv_num | ||
1192 | * @s: pointer to standard V4L2 device structure | ||
1193 | * @p: void pointer to hold decoder's private data address | ||
1194 | * | ||
1195 | * Returns device's (decoder's) private data area address in p parameter | ||
1196 | */ | ||
1197 | static int ioctl_g_priv(struct v4l2_int_device *s, void *p) | ||
1198 | { | ||
1199 | struct tvp514x_decoder *decoder = s->priv; | ||
1200 | |||
1201 | if (NULL == decoder->pdata->priv_data_set) | ||
1202 | return -EINVAL; | ||
1203 | |||
1204 | return decoder->pdata->priv_data_set(p); | ||
1205 | } | ||
1206 | |||
1207 | /** | ||
1208 | * ioctl_s_power - V4L2 decoder interface handler for vidioc_int_s_power_num | ||
1209 | * @s: pointer to standard V4L2 device structure | ||
1210 | * @on: power state to which device is to be set | ||
1211 | * | 1132 | * |
1212 | * Sets devices power state to requrested state, if possible. | 1133 | * Sets streaming to enable or disable, if possible. |
1213 | */ | 1134 | */ |
1214 | static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on) | 1135 | static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable) |
1215 | { | 1136 | { |
1216 | struct tvp514x_decoder *decoder = s->priv; | ||
1217 | int err = 0; | 1137 | int err = 0; |
1138 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
1139 | struct tvp514x_decoder *decoder = to_decoder(sd); | ||
1218 | 1140 | ||
1219 | switch (on) { | 1141 | if (decoder->streaming == enable) |
1220 | case V4L2_POWER_OFF: | 1142 | return 0; |
1221 | /* Power Down Sequence */ | ||
1222 | err = | ||
1223 | tvp514x_write_reg(decoder->client, REG_OPERATION_MODE, | ||
1224 | 0x01); | ||
1225 | /* Disable mux for TVP5146/47 decoder data path */ | ||
1226 | if (decoder->pdata->power_set) | ||
1227 | err |= decoder->pdata->power_set(on); | ||
1228 | decoder->state = STATE_NOT_DETECTED; | ||
1229 | break; | ||
1230 | 1143 | ||
1231 | case V4L2_POWER_STANDBY: | 1144 | switch (enable) { |
1232 | if (decoder->pdata->power_set) | 1145 | case 0: |
1233 | err = decoder->pdata->power_set(on); | 1146 | { |
1147 | /* Power Down Sequence */ | ||
1148 | err = tvp514x_write_reg(sd, REG_OPERATION_MODE, 0x01); | ||
1149 | if (err) { | ||
1150 | v4l2_err(sd, "Unable to turn off decoder\n"); | ||
1151 | return err; | ||
1152 | } | ||
1153 | decoder->streaming = enable; | ||
1234 | break; | 1154 | break; |
1155 | } | ||
1156 | case 1: | ||
1157 | { | ||
1158 | struct tvp514x_reg *int_seq = (struct tvp514x_reg *) | ||
1159 | client->driver->id_table->driver_data; | ||
1235 | 1160 | ||
1236 | case V4L2_POWER_ON: | 1161 | /* Power Up Sequence */ |
1237 | /* Enable mux for TVP5146/47 decoder data path */ | 1162 | err = tvp514x_write_regs(sd, int_seq); |
1238 | if ((decoder->pdata->power_set) && | 1163 | if (err) { |
1239 | (decoder->state == STATE_NOT_DETECTED)) { | 1164 | v4l2_err(sd, "Unable to turn on decoder\n"); |
1240 | int i; | 1165 | return err; |
1241 | struct tvp514x_init_seq *int_seq = | 1166 | } |
1242 | (struct tvp514x_init_seq *) | 1167 | /* Detect if not already detected */ |
1243 | decoder->id->driver_data; | 1168 | err = tvp514x_detect(sd, decoder); |
1244 | 1169 | if (err) { | |
1245 | err = decoder->pdata->power_set(on); | 1170 | v4l2_err(sd, "Unable to detect decoder\n"); |
1246 | 1171 | return err; | |
1247 | /* Power Up Sequence */ | ||
1248 | for (i = 0; i < int_seq->no_regs; i++) { | ||
1249 | err |= tvp514x_write_reg(decoder->client, | ||
1250 | int_seq->init_reg_seq[i].reg, | ||
1251 | int_seq->init_reg_seq[i].val); | ||
1252 | } | ||
1253 | /* Detect the sensor is not already detected */ | ||
1254 | err |= tvp514x_detect(decoder); | ||
1255 | if (err) { | ||
1256 | v4l_err(decoder->client, | ||
1257 | "Unable to detect decoder\n"); | ||
1258 | return err; | ||
1259 | } | ||
1260 | } | 1172 | } |
1261 | err |= tvp514x_configure(decoder); | 1173 | err = tvp514x_configure(sd, decoder); |
1174 | if (err) { | ||
1175 | v4l2_err(sd, "Unable to configure decoder\n"); | ||
1176 | return err; | ||
1177 | } | ||
1178 | decoder->streaming = enable; | ||
1262 | break; | 1179 | break; |
1263 | 1180 | } | |
1264 | default: | 1181 | default: |
1265 | err = -ENODEV; | 1182 | err = -ENODEV; |
1266 | break; | 1183 | break; |
@@ -1269,93 +1186,37 @@ static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on) | |||
1269 | return err; | 1186 | return err; |
1270 | } | 1187 | } |
1271 | 1188 | ||
1272 | /** | 1189 | static const struct v4l2_subdev_core_ops tvp514x_core_ops = { |
1273 | * ioctl_init - V4L2 decoder interface handler for VIDIOC_INT_INIT | 1190 | .queryctrl = tvp514x_queryctrl, |
1274 | * @s: pointer to standard V4L2 device structure | 1191 | .g_ctrl = tvp514x_g_ctrl, |
1275 | * | 1192 | .s_ctrl = tvp514x_s_ctrl, |
1276 | * Initialize the decoder device (calls tvp514x_configure()) | 1193 | .s_std = tvp514x_s_std, |
1277 | */ | 1194 | }; |
1278 | static int ioctl_init(struct v4l2_int_device *s) | ||
1279 | { | ||
1280 | struct tvp514x_decoder *decoder = s->priv; | ||
1281 | |||
1282 | /* Set default standard to auto */ | ||
1283 | decoder->tvp514x_regs[REG_VIDEO_STD].val = | ||
1284 | VIDEO_STD_AUTO_SWITCH_BIT; | ||
1285 | |||
1286 | return tvp514x_configure(decoder); | ||
1287 | } | ||
1288 | |||
1289 | /** | ||
1290 | * ioctl_dev_exit - V4L2 decoder interface handler for vidioc_int_dev_exit_num | ||
1291 | * @s: pointer to standard V4L2 device structure | ||
1292 | * | ||
1293 | * Delinitialise the dev. at slave detach. The complement of ioctl_dev_init. | ||
1294 | */ | ||
1295 | static int ioctl_dev_exit(struct v4l2_int_device *s) | ||
1296 | { | ||
1297 | return 0; | ||
1298 | } | ||
1299 | |||
1300 | /** | ||
1301 | * ioctl_dev_init - V4L2 decoder interface handler for vidioc_int_dev_init_num | ||
1302 | * @s: pointer to standard V4L2 device structure | ||
1303 | * | ||
1304 | * Initialise the device when slave attaches to the master. Returns 0 if | ||
1305 | * TVP5146/47 device could be found, otherwise returns appropriate error. | ||
1306 | */ | ||
1307 | static int ioctl_dev_init(struct v4l2_int_device *s) | ||
1308 | { | ||
1309 | struct tvp514x_decoder *decoder = s->priv; | ||
1310 | int err; | ||
1311 | |||
1312 | err = tvp514x_detect(decoder); | ||
1313 | if (err < 0) { | ||
1314 | v4l_err(decoder->client, | ||
1315 | "Unable to detect decoder\n"); | ||
1316 | return err; | ||
1317 | } | ||
1318 | |||
1319 | v4l_info(decoder->client, | ||
1320 | "chip version 0x%.2x detected\n", decoder->ver); | ||
1321 | 1195 | ||
1322 | return 0; | 1196 | static const struct v4l2_subdev_video_ops tvp514x_video_ops = { |
1323 | } | 1197 | .s_routing = tvp514x_s_routing, |
1198 | .querystd = tvp514x_querystd, | ||
1199 | .enum_fmt = tvp514x_enum_fmt_cap, | ||
1200 | .g_fmt = tvp514x_g_fmt_cap, | ||
1201 | .try_fmt = tvp514x_try_fmt_cap, | ||
1202 | .s_fmt = tvp514x_s_fmt_cap, | ||
1203 | .g_parm = tvp514x_g_parm, | ||
1204 | .s_parm = tvp514x_s_parm, | ||
1205 | .s_stream = tvp514x_s_stream, | ||
1206 | }; | ||
1324 | 1207 | ||
1325 | static struct v4l2_int_ioctl_desc tvp514x_ioctl_desc[] = { | 1208 | static const struct v4l2_subdev_ops tvp514x_ops = { |
1326 | {vidioc_int_dev_init_num, (v4l2_int_ioctl_func*) ioctl_dev_init}, | 1209 | .core = &tvp514x_core_ops, |
1327 | {vidioc_int_dev_exit_num, (v4l2_int_ioctl_func*) ioctl_dev_exit}, | 1210 | .video = &tvp514x_video_ops, |
1328 | {vidioc_int_s_power_num, (v4l2_int_ioctl_func*) ioctl_s_power}, | ||
1329 | {vidioc_int_g_priv_num, (v4l2_int_ioctl_func*) ioctl_g_priv}, | ||
1330 | {vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*) ioctl_g_ifparm}, | ||
1331 | {vidioc_int_init_num, (v4l2_int_ioctl_func*) ioctl_init}, | ||
1332 | {vidioc_int_enum_fmt_cap_num, | ||
1333 | (v4l2_int_ioctl_func *) ioctl_enum_fmt_cap}, | ||
1334 | {vidioc_int_try_fmt_cap_num, | ||
1335 | (v4l2_int_ioctl_func *) ioctl_try_fmt_cap}, | ||
1336 | {vidioc_int_g_fmt_cap_num, | ||
1337 | (v4l2_int_ioctl_func *) ioctl_g_fmt_cap}, | ||
1338 | {vidioc_int_s_fmt_cap_num, | ||
1339 | (v4l2_int_ioctl_func *) ioctl_s_fmt_cap}, | ||
1340 | {vidioc_int_g_parm_num, (v4l2_int_ioctl_func *) ioctl_g_parm}, | ||
1341 | {vidioc_int_s_parm_num, (v4l2_int_ioctl_func *) ioctl_s_parm}, | ||
1342 | {vidioc_int_queryctrl_num, | ||
1343 | (v4l2_int_ioctl_func *) ioctl_queryctrl}, | ||
1344 | {vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func *) ioctl_g_ctrl}, | ||
1345 | {vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func *) ioctl_s_ctrl}, | ||
1346 | {vidioc_int_querystd_num, (v4l2_int_ioctl_func *) ioctl_querystd}, | ||
1347 | {vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std}, | ||
1348 | {vidioc_int_s_video_routing_num, | ||
1349 | (v4l2_int_ioctl_func *) ioctl_s_routing}, | ||
1350 | }; | 1211 | }; |
1351 | 1212 | ||
1352 | static struct tvp514x_decoder tvp514x_dev = { | 1213 | static struct tvp514x_decoder tvp514x_dev = { |
1353 | .state = STATE_NOT_DETECTED, | 1214 | .streaming = 0, |
1354 | 1215 | ||
1355 | .fmt_list = tvp514x_fmt_list, | 1216 | .fmt_list = tvp514x_fmt_list, |
1356 | .num_fmts = ARRAY_SIZE(tvp514x_fmt_list), | 1217 | .num_fmts = ARRAY_SIZE(tvp514x_fmt_list), |
1357 | 1218 | ||
1358 | .pix = { /* Default to NTSC 8-bit YUV 422 */ | 1219 | .pix = {/* Default to NTSC 8-bit YUV 422 */ |
1359 | .width = NTSC_NUM_ACTIVE_PIXELS, | 1220 | .width = NTSC_NUM_ACTIVE_PIXELS, |
1360 | .height = NTSC_NUM_ACTIVE_LINES, | 1221 | .height = NTSC_NUM_ACTIVE_LINES, |
1361 | .pixelformat = V4L2_PIX_FMT_UYVY, | 1222 | .pixelformat = V4L2_PIX_FMT_UYVY, |
@@ -1369,20 +1230,13 @@ static struct tvp514x_decoder tvp514x_dev = { | |||
1369 | .current_std = STD_NTSC_MJ, | 1230 | .current_std = STD_NTSC_MJ, |
1370 | .std_list = tvp514x_std_list, | 1231 | .std_list = tvp514x_std_list, |
1371 | .num_stds = ARRAY_SIZE(tvp514x_std_list), | 1232 | .num_stds = ARRAY_SIZE(tvp514x_std_list), |
1372 | .v4l2_int_device = { | 1233 | |
1373 | .module = THIS_MODULE, | ||
1374 | .name = TVP514X_MODULE_NAME, | ||
1375 | .type = v4l2_int_type_slave, | ||
1376 | }, | ||
1377 | .tvp514x_slave = { | ||
1378 | .ioctls = tvp514x_ioctl_desc, | ||
1379 | .num_ioctls = ARRAY_SIZE(tvp514x_ioctl_desc), | ||
1380 | }, | ||
1381 | }; | 1234 | }; |
1382 | 1235 | ||
1383 | /** | 1236 | /* |
1384 | * tvp514x_probe - decoder driver i2c probe handler | 1237 | * tvp514x_probe - decoder driver i2c probe handler |
1385 | * @client: i2c driver client device structure | 1238 | * @client: i2c driver client device structure |
1239 | * @id: i2c driver id table | ||
1386 | * | 1240 | * |
1387 | * Register decoder as an i2c client device and V4L2 | 1241 | * Register decoder as an i2c client device and V4L2 |
1388 | * device. | 1242 | * device. |
@@ -1391,82 +1245,71 @@ static int | |||
1391 | tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) | 1245 | tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) |
1392 | { | 1246 | { |
1393 | struct tvp514x_decoder *decoder; | 1247 | struct tvp514x_decoder *decoder; |
1394 | int err; | 1248 | struct v4l2_subdev *sd; |
1395 | 1249 | ||
1396 | /* Check if the adapter supports the needed features */ | 1250 | /* Check if the adapter supports the needed features */ |
1397 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1251 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1398 | return -EIO; | 1252 | return -EIO; |
1399 | 1253 | ||
1254 | if (!client->dev.platform_data) { | ||
1255 | v4l2_err(client, "No platform data!!\n"); | ||
1256 | return -ENODEV; | ||
1257 | } | ||
1258 | |||
1400 | decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); | 1259 | decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); |
1401 | if (!decoder) | 1260 | if (!decoder) |
1402 | return -ENOMEM; | 1261 | return -ENOMEM; |
1403 | 1262 | ||
1404 | if (!client->dev.platform_data) { | 1263 | /* |
1405 | v4l_err(client, "No platform data!!\n"); | 1264 | * Initialize the tvp514x_decoder with default configuration |
1406 | err = -ENODEV; | 1265 | */ |
1407 | goto out_free; | ||
1408 | } | ||
1409 | |||
1410 | *decoder = tvp514x_dev; | 1266 | *decoder = tvp514x_dev; |
1411 | decoder->v4l2_int_device.priv = decoder; | 1267 | /* Copy default register configuration */ |
1412 | decoder->pdata = client->dev.platform_data; | ||
1413 | decoder->v4l2_int_device.u.slave = &decoder->tvp514x_slave; | ||
1414 | memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default, | 1268 | memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default, |
1415 | sizeof(tvp514x_reg_list_default)); | 1269 | sizeof(tvp514x_reg_list_default)); |
1270 | |||
1271 | /* | ||
1272 | * Copy board specific information here | ||
1273 | */ | ||
1274 | decoder->pdata = client->dev.platform_data; | ||
1275 | |||
1416 | /* | 1276 | /* |
1417 | * Fetch platform specific data, and configure the | 1277 | * Fetch platform specific data, and configure the |
1418 | * tvp514x_reg_list[] accordingly. Since this is one | 1278 | * tvp514x_reg_list[] accordingly. Since this is one |
1419 | * time configuration, no need to preserve. | 1279 | * time configuration, no need to preserve. |
1420 | */ | 1280 | */ |
1421 | decoder->tvp514x_regs[REG_OUTPUT_FORMATTER2].val |= | 1281 | decoder->tvp514x_regs[REG_OUTPUT_FORMATTER2].val |= |
1422 | (decoder->pdata->clk_polarity << 1); | 1282 | (decoder->pdata->clk_polarity << 1); |
1423 | decoder->tvp514x_regs[REG_SYNC_CONTROL].val |= | 1283 | decoder->tvp514x_regs[REG_SYNC_CONTROL].val |= |
1424 | ((decoder->pdata->hs_polarity << 2) | | 1284 | ((decoder->pdata->hs_polarity << 2) | |
1425 | (decoder->pdata->vs_polarity << 3)); | 1285 | (decoder->pdata->vs_polarity << 3)); |
1426 | /* | 1286 | /* Set default standard to auto */ |
1427 | * Save the id data, required for power up sequence | 1287 | decoder->tvp514x_regs[REG_VIDEO_STD].val = |
1428 | */ | 1288 | VIDEO_STD_AUTO_SWITCH_BIT; |
1429 | decoder->id = (struct i2c_device_id *)id; | ||
1430 | /* Attach to Master */ | ||
1431 | strcpy(decoder->v4l2_int_device.u.slave->attach_to, | ||
1432 | decoder->pdata->master); | ||
1433 | decoder->client = client; | ||
1434 | i2c_set_clientdata(client, decoder); | ||
1435 | 1289 | ||
1436 | /* Register with V4L2 layer as slave device */ | 1290 | /* Register with V4L2 layer as slave device */ |
1437 | err = v4l2_int_device_register(&decoder->v4l2_int_device); | 1291 | sd = &decoder->sd; |
1438 | if (err) { | 1292 | v4l2_i2c_subdev_init(sd, client, &tvp514x_ops); |
1439 | i2c_set_clientdata(client, NULL); | 1293 | |
1440 | v4l_err(client, | 1294 | v4l2_info(sd, "%s decoder driver registered !!\n", sd->name); |
1441 | "Unable to register to v4l2. Err[%d]\n", err); | 1295 | |
1442 | goto out_free; | ||
1443 | |||
1444 | } else | ||
1445 | v4l_info(client, "Registered to v4l2 master %s!!\n", | ||
1446 | decoder->pdata->master); | ||
1447 | return 0; | 1296 | return 0; |
1448 | 1297 | ||
1449 | out_free: | ||
1450 | kfree(decoder); | ||
1451 | return err; | ||
1452 | } | 1298 | } |
1453 | 1299 | ||
1454 | /** | 1300 | /* |
1455 | * tvp514x_remove - decoder driver i2c remove handler | 1301 | * tvp514x_remove - decoder driver i2c remove handler |
1456 | * @client: i2c driver client device structure | 1302 | * @client: i2c driver client device structure |
1457 | * | 1303 | * |
1458 | * Unregister decoder as an i2c client device and V4L2 | 1304 | * Unregister decoder as an i2c client device and V4L2 |
1459 | * device. Complement of tvp514x_probe(). | 1305 | * device. Complement of tvp514x_probe(). |
1460 | */ | 1306 | */ |
1461 | static int __exit tvp514x_remove(struct i2c_client *client) | 1307 | static int tvp514x_remove(struct i2c_client *client) |
1462 | { | 1308 | { |
1463 | struct tvp514x_decoder *decoder = i2c_get_clientdata(client); | 1309 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
1464 | 1310 | struct tvp514x_decoder *decoder = to_decoder(sd); | |
1465 | if (!client->adapter) | ||
1466 | return -ENODEV; /* our client isn't attached */ | ||
1467 | 1311 | ||
1468 | v4l2_int_device_unregister(&decoder->v4l2_int_device); | 1312 | v4l2_device_unregister_subdev(sd); |
1469 | i2c_set_clientdata(client, NULL); | ||
1470 | kfree(decoder); | 1313 | kfree(decoder); |
1471 | return 0; | 1314 | return 0; |
1472 | } | 1315 | } |
@@ -1485,11 +1328,9 @@ static const struct tvp514x_reg tvp5146_init_reg_seq[] = { | |||
1485 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00}, | 1328 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00}, |
1486 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, | 1329 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, |
1487 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, | 1330 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, |
1331 | {TOK_TERM, 0, 0}, | ||
1488 | }; | 1332 | }; |
1489 | static const struct tvp514x_init_seq tvp5146_init = { | 1333 | |
1490 | .no_regs = ARRAY_SIZE(tvp5146_init_reg_seq), | ||
1491 | .init_reg_seq = tvp5146_init_reg_seq, | ||
1492 | }; | ||
1493 | /* | 1334 | /* |
1494 | * TVP5147 Init/Power on Sequence | 1335 | * TVP5147 Init/Power on Sequence |
1495 | */ | 1336 | */ |
@@ -1512,22 +1353,18 @@ static const struct tvp514x_reg tvp5147_init_reg_seq[] = { | |||
1512 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00}, | 1353 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00}, |
1513 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, | 1354 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, |
1514 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, | 1355 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, |
1356 | {TOK_TERM, 0, 0}, | ||
1515 | }; | 1357 | }; |
1516 | static const struct tvp514x_init_seq tvp5147_init = { | 1358 | |
1517 | .no_regs = ARRAY_SIZE(tvp5147_init_reg_seq), | ||
1518 | .init_reg_seq = tvp5147_init_reg_seq, | ||
1519 | }; | ||
1520 | /* | 1359 | /* |
1521 | * TVP5146M2/TVP5147M1 Init/Power on Sequence | 1360 | * TVP5146M2/TVP5147M1 Init/Power on Sequence |
1522 | */ | 1361 | */ |
1523 | static const struct tvp514x_reg tvp514xm_init_reg_seq[] = { | 1362 | static const struct tvp514x_reg tvp514xm_init_reg_seq[] = { |
1524 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, | 1363 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, |
1525 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, | 1364 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, |
1365 | {TOK_TERM, 0, 0}, | ||
1526 | }; | 1366 | }; |
1527 | static const struct tvp514x_init_seq tvp514xm_init = { | 1367 | |
1528 | .no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq), | ||
1529 | .init_reg_seq = tvp514xm_init_reg_seq, | ||
1530 | }; | ||
1531 | /* | 1368 | /* |
1532 | * I2C Device Table - | 1369 | * I2C Device Table - |
1533 | * | 1370 | * |
@@ -1535,48 +1372,34 @@ static const struct tvp514x_init_seq tvp514xm_init = { | |||
1535 | * driver_data - Driver data | 1372 | * driver_data - Driver data |
1536 | */ | 1373 | */ |
1537 | static const struct i2c_device_id tvp514x_id[] = { | 1374 | static const struct i2c_device_id tvp514x_id[] = { |
1538 | {"tvp5146", (unsigned long)&tvp5146_init}, | 1375 | {"tvp5146", (unsigned long)tvp5146_init_reg_seq}, |
1539 | {"tvp5146m2", (unsigned long)&tvp514xm_init}, | 1376 | {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq}, |
1540 | {"tvp5147", (unsigned long)&tvp5147_init}, | 1377 | {"tvp5147", (unsigned long)tvp5147_init_reg_seq}, |
1541 | {"tvp5147m1", (unsigned long)&tvp514xm_init}, | 1378 | {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq}, |
1542 | {}, | 1379 | {}, |
1543 | }; | 1380 | }; |
1544 | 1381 | ||
1545 | MODULE_DEVICE_TABLE(i2c, tvp514x_id); | 1382 | MODULE_DEVICE_TABLE(i2c, tvp514x_id); |
1546 | 1383 | ||
1547 | static struct i2c_driver tvp514x_i2c_driver = { | 1384 | static struct i2c_driver tvp514x_driver = { |
1548 | .driver = { | 1385 | .driver = { |
1549 | .name = TVP514X_MODULE_NAME, | 1386 | .owner = THIS_MODULE, |
1550 | .owner = THIS_MODULE, | 1387 | .name = TVP514X_MODULE_NAME, |
1551 | }, | 1388 | }, |
1552 | .probe = tvp514x_probe, | 1389 | .probe = tvp514x_probe, |
1553 | .remove = __exit_p(tvp514x_remove), | 1390 | .remove = tvp514x_remove, |
1554 | .id_table = tvp514x_id, | 1391 | .id_table = tvp514x_id, |
1555 | }; | 1392 | }; |
1556 | 1393 | ||
1557 | /** | ||
1558 | * tvp514x_init | ||
1559 | * | ||
1560 | * Module init function | ||
1561 | */ | ||
1562 | static int __init tvp514x_init(void) | 1394 | static int __init tvp514x_init(void) |
1563 | { | 1395 | { |
1564 | return i2c_add_driver(&tvp514x_i2c_driver); | 1396 | return i2c_add_driver(&tvp514x_driver); |
1565 | } | 1397 | } |
1566 | 1398 | ||
1567 | /** | 1399 | static void __exit tvp514x_exit(void) |
1568 | * tvp514x_cleanup | ||
1569 | * | ||
1570 | * Module exit function | ||
1571 | */ | ||
1572 | static void __exit tvp514x_cleanup(void) | ||
1573 | { | 1400 | { |
1574 | i2c_del_driver(&tvp514x_i2c_driver); | 1401 | i2c_del_driver(&tvp514x_driver); |
1575 | } | 1402 | } |
1576 | 1403 | ||
1577 | module_init(tvp514x_init); | 1404 | module_init(tvp514x_init); |
1578 | module_exit(tvp514x_cleanup); | 1405 | module_exit(tvp514x_exit); |
1579 | |||
1580 | MODULE_AUTHOR("Texas Instruments"); | ||
1581 | MODULE_DESCRIPTION("TVP514X linux decoder driver"); | ||
1582 | MODULE_LICENSE("GPL"); | ||