Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1 | /* |
| 2 | * drivers/media/video/tvp514x.c |
| 3 | * |
| 4 | * TI TVP5146/47 decoder driver |
| 5 | * |
| 6 | * Copyright (C) 2008 Texas Instruments Inc |
| 7 | * Author: Vaibhav Hiremath <hvaibhav@ti.com> |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Sivaraj R <sivaraj@ti.com> |
| 11 | * Brijesh R Jadav <brijesh.j@ti.com> |
| 12 | * Hardik Shah <hardik.shah@ti.com> |
| 13 | * Manjunath Hadli <mrh@ti.com> |
| 14 | * Karicheri Muralidharan <m-karicheri2@ti.com> |
| 15 | * |
| 16 | * This package is free software; you can redistribute it and/or modify |
| 17 | * it under the terms of the GNU General Public License version 2 as |
| 18 | * published by the Free Software Foundation. |
| 19 | * |
| 20 | * This program is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with this program; if not, write to the Free Software |
| 27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <linux/i2c.h> |
| 32 | #include <linux/delay.h> |
| 33 | #include <linux/videodev2.h> |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 34 | |
| 35 | #include <media/v4l2-device.h> |
| 36 | #include <media/v4l2-common.h> |
| 37 | #include <media/v4l2-chip-ident.h> |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 38 | #include <media/tvp514x.h> |
| 39 | |
| 40 | #include "tvp514x_regs.h" |
| 41 | |
| 42 | /* Module Name */ |
| 43 | #define TVP514X_MODULE_NAME "tvp514x" |
| 44 | |
| 45 | /* Private macros for TVP */ |
| 46 | #define I2C_RETRY_COUNT (5) |
| 47 | #define LOCK_RETRY_COUNT (5) |
| 48 | #define LOCK_RETRY_DELAY (200) |
| 49 | |
| 50 | /* Debug functions */ |
| 51 | static int debug; |
| 52 | module_param(debug, bool, 0644); |
| 53 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 54 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 55 | MODULE_AUTHOR("Texas Instruments"); |
| 56 | MODULE_DESCRIPTION("TVP514X linux decoder driver"); |
| 57 | MODULE_LICENSE("GPL"); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 58 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 59 | /* enum tvp514x_std - enum for supported standards */ |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 60 | enum tvp514x_std { |
| 61 | STD_NTSC_MJ = 0, |
| 62 | STD_PAL_BDGHIN, |
| 63 | STD_INVALID |
| 64 | }; |
| 65 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 66 | /** |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 67 | * struct tvp514x_std_info - Structure to store standard informations |
| 68 | * @width: Line width in pixels |
| 69 | * @height:Number of active lines |
| 70 | * @video_std: Value to write in REG_VIDEO_STD register |
| 71 | * @standard: v4l2 standard structure information |
| 72 | */ |
| 73 | struct tvp514x_std_info { |
| 74 | unsigned long width; |
| 75 | unsigned long height; |
| 76 | u8 video_std; |
| 77 | struct v4l2_standard standard; |
| 78 | }; |
| 79 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 80 | static struct tvp514x_reg tvp514x_reg_list_default[0x40]; |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 81 | /** |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 82 | * struct tvp514x_decoder - TVP5146/47 decoder object |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 83 | * @sd: Subdevice Slave handle |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 84 | * @tvp514x_regs: copy of hw's regs with preset values. |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 85 | * @pdata: Board specific |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 86 | * @ver: Chip version |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 87 | * @streaming: TVP5146/47 decoder streaming - enabled or disabled. |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 88 | * @pix: Current pixel format |
| 89 | * @num_fmts: Number of formats |
| 90 | * @fmt_list: Format list |
| 91 | * @current_std: Current standard |
| 92 | * @num_stds: Number of standards |
| 93 | * @std_list: Standards list |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 94 | * @input: Input routing at chip level |
| 95 | * @output: Output routing at chip level |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 96 | */ |
| 97 | struct tvp514x_decoder { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 98 | struct v4l2_subdev sd; |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 99 | struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)]; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 100 | const struct tvp514x_platform_data *pdata; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 101 | |
| 102 | int ver; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 103 | int streaming; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 104 | |
| 105 | struct v4l2_pix_format pix; |
| 106 | int num_fmts; |
| 107 | const struct v4l2_fmtdesc *fmt_list; |
| 108 | |
| 109 | enum tvp514x_std current_std; |
| 110 | int num_stds; |
| 111 | struct tvp514x_std_info *std_list; |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 112 | /* Input and Output Routing parameters */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 113 | u32 input; |
| 114 | u32 output; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | /* TVP514x default register values */ |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 118 | static struct tvp514x_reg tvp514x_reg_list_default[] = { |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 119 | /* Composite selected */ |
| 120 | {TOK_WRITE, REG_INPUT_SEL, 0x05}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 121 | {TOK_WRITE, REG_AFE_GAIN_CTRL, 0x0F}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 122 | /* Auto mode */ |
| 123 | {TOK_WRITE, REG_VIDEO_STD, 0x00}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 124 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, |
| 125 | {TOK_SKIP, REG_AUTOSWITCH_MASK, 0x3F}, |
| 126 | {TOK_WRITE, REG_COLOR_KILLER, 0x10}, |
| 127 | {TOK_WRITE, REG_LUMA_CONTROL1, 0x00}, |
| 128 | {TOK_WRITE, REG_LUMA_CONTROL2, 0x00}, |
| 129 | {TOK_WRITE, REG_LUMA_CONTROL3, 0x02}, |
| 130 | {TOK_WRITE, REG_BRIGHTNESS, 0x80}, |
| 131 | {TOK_WRITE, REG_CONTRAST, 0x80}, |
| 132 | {TOK_WRITE, REG_SATURATION, 0x80}, |
| 133 | {TOK_WRITE, REG_HUE, 0x00}, |
| 134 | {TOK_WRITE, REG_CHROMA_CONTROL1, 0x00}, |
| 135 | {TOK_WRITE, REG_CHROMA_CONTROL2, 0x0E}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 136 | /* Reserved */ |
| 137 | {TOK_SKIP, 0x0F, 0x00}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 138 | {TOK_WRITE, REG_COMP_PR_SATURATION, 0x80}, |
| 139 | {TOK_WRITE, REG_COMP_Y_CONTRAST, 0x80}, |
| 140 | {TOK_WRITE, REG_COMP_PB_SATURATION, 0x80}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 141 | /* Reserved */ |
| 142 | {TOK_SKIP, 0x13, 0x00}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 143 | {TOK_WRITE, REG_COMP_Y_BRIGHTNESS, 0x80}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 144 | /* Reserved */ |
| 145 | {TOK_SKIP, 0x15, 0x00}, |
| 146 | /* NTSC timing */ |
| 147 | {TOK_SKIP, REG_AVID_START_PIXEL_LSB, 0x55}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 148 | {TOK_SKIP, REG_AVID_START_PIXEL_MSB, 0x00}, |
| 149 | {TOK_SKIP, REG_AVID_STOP_PIXEL_LSB, 0x25}, |
| 150 | {TOK_SKIP, REG_AVID_STOP_PIXEL_MSB, 0x03}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 151 | /* NTSC timing */ |
| 152 | {TOK_SKIP, REG_HSYNC_START_PIXEL_LSB, 0x00}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 153 | {TOK_SKIP, REG_HSYNC_START_PIXEL_MSB, 0x00}, |
| 154 | {TOK_SKIP, REG_HSYNC_STOP_PIXEL_LSB, 0x40}, |
| 155 | {TOK_SKIP, REG_HSYNC_STOP_PIXEL_MSB, 0x00}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 156 | /* NTSC timing */ |
| 157 | {TOK_SKIP, REG_VSYNC_START_LINE_LSB, 0x04}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 158 | {TOK_SKIP, REG_VSYNC_START_LINE_MSB, 0x00}, |
| 159 | {TOK_SKIP, REG_VSYNC_STOP_LINE_LSB, 0x07}, |
| 160 | {TOK_SKIP, REG_VSYNC_STOP_LINE_MSB, 0x00}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 161 | /* NTSC timing */ |
| 162 | {TOK_SKIP, REG_VBLK_START_LINE_LSB, 0x01}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 163 | {TOK_SKIP, REG_VBLK_START_LINE_MSB, 0x00}, |
| 164 | {TOK_SKIP, REG_VBLK_STOP_LINE_LSB, 0x15}, |
| 165 | {TOK_SKIP, REG_VBLK_STOP_LINE_MSB, 0x00}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 166 | /* Reserved */ |
| 167 | {TOK_SKIP, 0x26, 0x00}, |
| 168 | /* Reserved */ |
| 169 | {TOK_SKIP, 0x27, 0x00}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 170 | {TOK_SKIP, REG_FAST_SWTICH_CONTROL, 0xCC}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 171 | /* Reserved */ |
| 172 | {TOK_SKIP, 0x29, 0x00}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 173 | {TOK_SKIP, REG_FAST_SWTICH_SCART_DELAY, 0x00}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 174 | /* Reserved */ |
| 175 | {TOK_SKIP, 0x2B, 0x00}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 176 | {TOK_SKIP, REG_SCART_DELAY, 0x00}, |
| 177 | {TOK_SKIP, REG_CTI_DELAY, 0x00}, |
| 178 | {TOK_SKIP, REG_CTI_CONTROL, 0x00}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 179 | /* Reserved */ |
| 180 | {TOK_SKIP, 0x2F, 0x00}, |
| 181 | /* Reserved */ |
| 182 | {TOK_SKIP, 0x30, 0x00}, |
| 183 | /* Reserved */ |
| 184 | {TOK_SKIP, 0x31, 0x00}, |
| 185 | /* HS, VS active high */ |
| 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}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 195 | {TOK_WRITE, REG_OUTPUT_FORMATTER5, 0xFF}, |
| 196 | {TOK_WRITE, REG_OUTPUT_FORMATTER6, 0xFF}, |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 197 | /* Clear status */ |
| 198 | {TOK_WRITE, REG_CLEAR_LOST_LOCK, 0x01}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 199 | {TOK_TERM, 0, 0}, |
| 200 | }; |
| 201 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 202 | /** |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 203 | * List of image formats supported by TVP5146/47 decoder |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 204 | * Currently we are using 8 bit mode only, but can be |
| 205 | * extended to 10/20 bit mode. |
| 206 | */ |
| 207 | static const struct v4l2_fmtdesc tvp514x_fmt_list[] = { |
| 208 | { |
| 209 | .index = 0, |
| 210 | .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 211 | .flags = 0, |
| 212 | .description = "8-bit UYVY 4:2:2 Format", |
| 213 | .pixelformat = V4L2_PIX_FMT_UYVY, |
| 214 | }, |
| 215 | }; |
| 216 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 217 | /** |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 218 | * Supported standards - |
| 219 | * |
| 220 | * Currently supports two standards only, need to add support for rest of the |
| 221 | * modes, like SECAM, etc... |
| 222 | */ |
| 223 | static struct tvp514x_std_info tvp514x_std_list[] = { |
| 224 | /* Standard: STD_NTSC_MJ */ |
| 225 | [STD_NTSC_MJ] = { |
| 226 | .width = NTSC_NUM_ACTIVE_PIXELS, |
| 227 | .height = NTSC_NUM_ACTIVE_LINES, |
| 228 | .video_std = VIDEO_STD_NTSC_MJ_BIT, |
| 229 | .standard = { |
| 230 | .index = 0, |
| 231 | .id = V4L2_STD_NTSC, |
| 232 | .name = "NTSC", |
| 233 | .frameperiod = {1001, 30000}, |
| 234 | .framelines = 525 |
| 235 | }, |
| 236 | /* Standard: STD_PAL_BDGHIN */ |
| 237 | }, |
| 238 | [STD_PAL_BDGHIN] = { |
| 239 | .width = PAL_NUM_ACTIVE_PIXELS, |
| 240 | .height = PAL_NUM_ACTIVE_LINES, |
| 241 | .video_std = VIDEO_STD_PAL_BDGHIN_BIT, |
| 242 | .standard = { |
| 243 | .index = 1, |
| 244 | .id = V4L2_STD_PAL, |
| 245 | .name = "PAL", |
| 246 | .frameperiod = {1, 25}, |
| 247 | .framelines = 625 |
| 248 | }, |
| 249 | }, |
| 250 | /* Standard: need to add for additional standard */ |
| 251 | }; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 252 | |
| 253 | |
| 254 | static inline struct tvp514x_decoder *to_decoder(struct v4l2_subdev *sd) |
| 255 | { |
| 256 | return container_of(sd, struct tvp514x_decoder, sd); |
| 257 | } |
| 258 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 259 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 260 | /** |
| 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 | * |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 265 | * Returns value read if successful, or non-zero (-1) otherwise. |
| 266 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 267 | static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 268 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 269 | int err, retry = 0; |
| 270 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 271 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 272 | read_again: |
| 273 | |
| 274 | err = i2c_smbus_read_byte_data(client, reg); |
Sebastian Andrzej Siewior | 6f901a9 | 2009-11-04 15:35:09 -0300 | [diff] [blame] | 275 | if (err < 0) { |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 276 | if (retry <= I2C_RETRY_COUNT) { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 277 | v4l2_warn(sd, "Read: retry ... %d\n", retry); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 278 | retry++; |
| 279 | msleep_interruptible(10); |
| 280 | goto read_again; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return err; |
| 285 | } |
| 286 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 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 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 292 | static void dump_reg(struct v4l2_subdev *sd, u8 reg) |
| 293 | { |
| 294 | u32 val; |
| 295 | |
| 296 | val = tvp514x_read_reg(sd, reg); |
| 297 | v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); |
| 298 | } |
| 299 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 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 | * |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 306 | * Write a value to a register in an TVP5146/47 decoder device. |
| 307 | * Returns zero if successful, or non-zero otherwise. |
| 308 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 309 | static int tvp514x_write_reg(struct v4l2_subdev *sd, u8 reg, u8 val) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 310 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 311 | int err, retry = 0; |
| 312 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 313 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 314 | write_again: |
| 315 | |
| 316 | err = i2c_smbus_write_byte_data(client, reg, val); |
| 317 | if (err) { |
| 318 | if (retry <= I2C_RETRY_COUNT) { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 319 | v4l2_warn(sd, "Write: retry ... %d\n", retry); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 320 | retry++; |
| 321 | msleep_interruptible(10); |
| 322 | goto write_again; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | return err; |
| 327 | } |
| 328 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 329 | /** |
| 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:- |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 335 | * if token is TOK_TERM, then entire write operation terminates |
| 336 | * if token is TOK_DELAY, then a delay of 'val' msec is introduced |
| 337 | * if token is TOK_SKIP, then the register write is skipped |
| 338 | * if token is TOK_WRITE, then the register write is performed |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 339 | * Returns zero if successful, or non-zero otherwise. |
| 340 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 341 | static int tvp514x_write_regs(struct v4l2_subdev *sd, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 342 | const struct tvp514x_reg reglist[]) |
| 343 | { |
| 344 | int err; |
| 345 | const struct tvp514x_reg *next = reglist; |
| 346 | |
| 347 | for (; next->token != TOK_TERM; next++) { |
| 348 | if (next->token == TOK_DELAY) { |
| 349 | msleep(next->val); |
| 350 | continue; |
| 351 | } |
| 352 | |
| 353 | if (next->token == TOK_SKIP) |
| 354 | continue; |
| 355 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 356 | err = tvp514x_write_reg(sd, next->reg, (u8) next->val); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 357 | if (err) { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 358 | v4l2_err(sd, "Write failed. Err[%d]\n", err); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 359 | return err; |
| 360 | } |
| 361 | } |
| 362 | return 0; |
| 363 | } |
| 364 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 365 | /** |
| 366 | * tvp514x_get_current_std() : Get 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. |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 371 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 372 | static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 373 | { |
| 374 | u8 std, std_status; |
| 375 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 376 | std = tvp514x_read_reg(sd, REG_VIDEO_STD); |
| 377 | if ((std & VIDEO_STD_MASK) == VIDEO_STD_AUTO_SWITCH_BIT) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 378 | /* use the standard status register */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 379 | std_status = tvp514x_read_reg(sd, REG_VIDEO_STD_STATUS); |
| 380 | else |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 381 | /* use the standard register itself */ |
| 382 | std_status = std; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 383 | |
| 384 | switch (std_status & VIDEO_STD_MASK) { |
| 385 | case VIDEO_STD_NTSC_MJ_BIT: |
| 386 | return STD_NTSC_MJ; |
| 387 | |
| 388 | case VIDEO_STD_PAL_BDGHIN_BIT: |
| 389 | return STD_PAL_BDGHIN; |
| 390 | |
| 391 | default: |
| 392 | return STD_INVALID; |
| 393 | } |
| 394 | |
| 395 | return STD_INVALID; |
| 396 | } |
| 397 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 398 | /* TVP5146/47 register dump function */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 399 | static void tvp514x_reg_dump(struct v4l2_subdev *sd) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 400 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 401 | dump_reg(sd, REG_INPUT_SEL); |
| 402 | dump_reg(sd, REG_AFE_GAIN_CTRL); |
| 403 | dump_reg(sd, REG_VIDEO_STD); |
| 404 | dump_reg(sd, REG_OPERATION_MODE); |
| 405 | dump_reg(sd, REG_COLOR_KILLER); |
| 406 | dump_reg(sd, REG_LUMA_CONTROL1); |
| 407 | dump_reg(sd, REG_LUMA_CONTROL2); |
| 408 | dump_reg(sd, REG_LUMA_CONTROL3); |
| 409 | dump_reg(sd, REG_BRIGHTNESS); |
| 410 | dump_reg(sd, REG_CONTRAST); |
| 411 | dump_reg(sd, REG_SATURATION); |
| 412 | dump_reg(sd, REG_HUE); |
| 413 | dump_reg(sd, REG_CHROMA_CONTROL1); |
| 414 | dump_reg(sd, REG_CHROMA_CONTROL2); |
| 415 | dump_reg(sd, REG_COMP_PR_SATURATION); |
| 416 | dump_reg(sd, REG_COMP_Y_CONTRAST); |
| 417 | dump_reg(sd, REG_COMP_PB_SATURATION); |
| 418 | dump_reg(sd, REG_COMP_Y_BRIGHTNESS); |
| 419 | dump_reg(sd, REG_AVID_START_PIXEL_LSB); |
| 420 | dump_reg(sd, REG_AVID_START_PIXEL_MSB); |
| 421 | dump_reg(sd, REG_AVID_STOP_PIXEL_LSB); |
| 422 | dump_reg(sd, REG_AVID_STOP_PIXEL_MSB); |
| 423 | dump_reg(sd, REG_HSYNC_START_PIXEL_LSB); |
| 424 | dump_reg(sd, REG_HSYNC_START_PIXEL_MSB); |
| 425 | dump_reg(sd, REG_HSYNC_STOP_PIXEL_LSB); |
| 426 | dump_reg(sd, REG_HSYNC_STOP_PIXEL_MSB); |
| 427 | dump_reg(sd, REG_VSYNC_START_LINE_LSB); |
| 428 | dump_reg(sd, REG_VSYNC_START_LINE_MSB); |
| 429 | dump_reg(sd, REG_VSYNC_STOP_LINE_LSB); |
| 430 | dump_reg(sd, REG_VSYNC_STOP_LINE_MSB); |
| 431 | dump_reg(sd, REG_VBLK_START_LINE_LSB); |
| 432 | dump_reg(sd, REG_VBLK_START_LINE_MSB); |
| 433 | dump_reg(sd, REG_VBLK_STOP_LINE_LSB); |
| 434 | dump_reg(sd, REG_VBLK_STOP_LINE_MSB); |
| 435 | dump_reg(sd, REG_SYNC_CONTROL); |
| 436 | dump_reg(sd, REG_OUTPUT_FORMATTER1); |
| 437 | dump_reg(sd, REG_OUTPUT_FORMATTER2); |
| 438 | dump_reg(sd, REG_OUTPUT_FORMATTER3); |
| 439 | dump_reg(sd, REG_OUTPUT_FORMATTER4); |
| 440 | dump_reg(sd, REG_OUTPUT_FORMATTER5); |
| 441 | dump_reg(sd, REG_OUTPUT_FORMATTER6); |
| 442 | dump_reg(sd, REG_CLEAR_LOST_LOCK); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 443 | } |
| 444 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 445 | /** |
| 446 | * tvp514x_configure() - Configure the TVP5146/47 registers |
| 447 | * @sd: ptr to v4l2_subdev struct |
| 448 | * @decoder: ptr to tvp514x_decoder structure |
| 449 | * |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 450 | * Returns zero if successful, or non-zero otherwise. |
| 451 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 452 | static int tvp514x_configure(struct v4l2_subdev *sd, |
| 453 | struct tvp514x_decoder *decoder) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 454 | { |
| 455 | int err; |
| 456 | |
| 457 | /* common register initialization */ |
| 458 | err = |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 459 | tvp514x_write_regs(sd, decoder->tvp514x_regs); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 460 | if (err) |
| 461 | return err; |
| 462 | |
| 463 | if (debug) |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 464 | tvp514x_reg_dump(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 465 | |
| 466 | return 0; |
| 467 | } |
| 468 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 469 | /** |
| 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 | * |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 474 | * A device is considered to be detected if the chip ID (LSB and MSB) |
| 475 | * registers match the expected values. |
| 476 | * Any value of the rom version register is accepted. |
| 477 | * Returns ENODEV error number if no device is detected, or zero |
| 478 | * if a device is detected. |
| 479 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 480 | static int tvp514x_detect(struct v4l2_subdev *sd, |
| 481 | struct tvp514x_decoder *decoder) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 482 | { |
| 483 | u8 chip_id_msb, chip_id_lsb, rom_ver; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 484 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 485 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 486 | chip_id_msb = tvp514x_read_reg(sd, REG_CHIP_ID_MSB); |
| 487 | chip_id_lsb = tvp514x_read_reg(sd, REG_CHIP_ID_LSB); |
| 488 | rom_ver = tvp514x_read_reg(sd, REG_ROM_VERSION); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 489 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 490 | v4l2_dbg(1, debug, sd, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 491 | "chip id detected msb:0x%x lsb:0x%x rom version:0x%x\n", |
| 492 | chip_id_msb, chip_id_lsb, rom_ver); |
| 493 | if ((chip_id_msb != TVP514X_CHIP_ID_MSB) |
| 494 | || ((chip_id_lsb != TVP5146_CHIP_ID_LSB) |
| 495 | && (chip_id_lsb != TVP5147_CHIP_ID_LSB))) { |
| 496 | /* We didn't read the values we expected, so this must not be |
| 497 | * an TVP5146/47. |
| 498 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 499 | v4l2_err(sd, "chip id mismatch msb:0x%x lsb:0x%x\n", |
| 500 | chip_id_msb, chip_id_lsb); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 501 | return -ENODEV; |
| 502 | } |
| 503 | |
| 504 | decoder->ver = rom_ver; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 505 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 506 | v4l2_info(sd, "%s (Version - 0x%.2x) found at 0x%x (%s)\n", |
| 507 | client->name, decoder->ver, |
| 508 | client->addr << 1, client->adapter->name); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 509 | return 0; |
| 510 | } |
| 511 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 512 | /** |
| 513 | * tvp514x_querystd() - V4L2 decoder interface handler for querystd |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 514 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 515 | * @std_id: standard V4L2 std_id ioctl enum |
| 516 | * |
| 517 | * Returns the current standard detected by TVP5146/47. If no active input is |
| 518 | * detected, returns -EINVAL |
| 519 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 520 | static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 521 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 522 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 523 | enum tvp514x_std current_std; |
| 524 | enum tvp514x_input input_sel; |
| 525 | u8 sync_lock_status, lock_mask; |
| 526 | |
| 527 | if (std_id == NULL) |
| 528 | return -EINVAL; |
| 529 | |
| 530 | /* get the current standard */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 531 | current_std = tvp514x_get_current_std(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 532 | if (current_std == STD_INVALID) |
| 533 | return -EINVAL; |
| 534 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 535 | input_sel = decoder->input; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 536 | |
| 537 | switch (input_sel) { |
| 538 | case INPUT_CVBS_VI1A: |
| 539 | case INPUT_CVBS_VI1B: |
| 540 | case INPUT_CVBS_VI1C: |
| 541 | case INPUT_CVBS_VI2A: |
| 542 | case INPUT_CVBS_VI2B: |
| 543 | case INPUT_CVBS_VI2C: |
| 544 | case INPUT_CVBS_VI3A: |
| 545 | case INPUT_CVBS_VI3B: |
| 546 | case INPUT_CVBS_VI3C: |
| 547 | case INPUT_CVBS_VI4A: |
| 548 | lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT | |
| 549 | STATUS_HORZ_SYNC_LOCK_BIT | |
| 550 | STATUS_VIRT_SYNC_LOCK_BIT; |
| 551 | break; |
| 552 | |
| 553 | case INPUT_SVIDEO_VI2A_VI1A: |
| 554 | case INPUT_SVIDEO_VI2B_VI1B: |
| 555 | case INPUT_SVIDEO_VI2C_VI1C: |
| 556 | case INPUT_SVIDEO_VI2A_VI3A: |
| 557 | case INPUT_SVIDEO_VI2B_VI3B: |
| 558 | case INPUT_SVIDEO_VI2C_VI3C: |
| 559 | case INPUT_SVIDEO_VI4A_VI1A: |
| 560 | case INPUT_SVIDEO_VI4A_VI1B: |
| 561 | case INPUT_SVIDEO_VI4A_VI1C: |
| 562 | case INPUT_SVIDEO_VI4A_VI3A: |
| 563 | case INPUT_SVIDEO_VI4A_VI3B: |
| 564 | case INPUT_SVIDEO_VI4A_VI3C: |
| 565 | lock_mask = STATUS_HORZ_SYNC_LOCK_BIT | |
| 566 | STATUS_VIRT_SYNC_LOCK_BIT; |
| 567 | break; |
| 568 | /*Need to add other interfaces*/ |
| 569 | default: |
| 570 | return -EINVAL; |
| 571 | } |
| 572 | /* check whether signal is locked */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 573 | sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 574 | if (lock_mask != (sync_lock_status & lock_mask)) |
| 575 | return -EINVAL; /* No input detected */ |
| 576 | |
| 577 | decoder->current_std = current_std; |
| 578 | *std_id = decoder->std_list[current_std].standard.id; |
| 579 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 580 | v4l2_dbg(1, debug, sd, "Current STD: %s", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 581 | decoder->std_list[current_std].standard.name); |
| 582 | return 0; |
| 583 | } |
| 584 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 585 | /** |
| 586 | * tvp514x_s_std() - V4L2 decoder interface handler for s_std |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 587 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 588 | * @std_id: standard V4L2 v4l2_std_id ioctl enum |
| 589 | * |
| 590 | * If std_id is supported, sets the requested standard. Otherwise, returns |
| 591 | * -EINVAL |
| 592 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 593 | static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 594 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 595 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 596 | int err, i; |
| 597 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 598 | for (i = 0; i < decoder->num_stds; i++) |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 599 | if (std_id & decoder->std_list[i].standard.id) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 600 | break; |
| 601 | |
| 602 | if ((i == decoder->num_stds) || (i == STD_INVALID)) |
| 603 | return -EINVAL; |
| 604 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 605 | err = tvp514x_write_reg(sd, REG_VIDEO_STD, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 606 | decoder->std_list[i].video_std); |
| 607 | if (err) |
| 608 | return err; |
| 609 | |
| 610 | decoder->current_std = i; |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 611 | decoder->tvp514x_regs[REG_VIDEO_STD].val = |
| 612 | decoder->std_list[i].video_std; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 613 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 614 | v4l2_dbg(1, debug, sd, "Standard set to: %s", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 615 | decoder->std_list[i].standard.name); |
| 616 | return 0; |
| 617 | } |
| 618 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 619 | /** |
| 620 | * tvp514x_s_routing() - V4L2 decoder interface handler for s_routing |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 621 | * @sd: pointer to standard V4L2 sub-device structure |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 622 | * @input: input selector for routing the signal |
| 623 | * @output: output selector for routing the signal |
| 624 | * @config: config value. Not used |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 625 | * |
| 626 | * If index is valid, selects the requested input. Otherwise, returns -EINVAL if |
| 627 | * the input is not supported or there is no active signal present in the |
| 628 | * selected input. |
| 629 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 630 | static int tvp514x_s_routing(struct v4l2_subdev *sd, |
| 631 | u32 input, u32 output, u32 config) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 632 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 633 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 634 | int err; |
| 635 | enum tvp514x_input input_sel; |
| 636 | enum tvp514x_output output_sel; |
| 637 | enum tvp514x_std current_std = STD_INVALID; |
| 638 | u8 sync_lock_status, lock_mask; |
| 639 | int try_count = LOCK_RETRY_COUNT; |
| 640 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 641 | if ((input >= INPUT_INVALID) || |
| 642 | (output >= OUTPUT_INVALID)) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 643 | /* Index out of bound */ |
| 644 | return -EINVAL; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 645 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 646 | input_sel = input; |
| 647 | output_sel = output; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 648 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 649 | err = tvp514x_write_reg(sd, REG_INPUT_SEL, input_sel); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 650 | if (err) |
| 651 | return err; |
| 652 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 653 | output_sel |= tvp514x_read_reg(sd, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 654 | REG_OUTPUT_FORMATTER1) & 0x7; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 655 | err = tvp514x_write_reg(sd, REG_OUTPUT_FORMATTER1, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 656 | output_sel); |
| 657 | if (err) |
| 658 | return err; |
| 659 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 660 | decoder->tvp514x_regs[REG_INPUT_SEL].val = input_sel; |
| 661 | decoder->tvp514x_regs[REG_OUTPUT_FORMATTER1].val = output_sel; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 662 | |
| 663 | /* Clear status */ |
| 664 | msleep(LOCK_RETRY_DELAY); |
| 665 | err = |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 666 | tvp514x_write_reg(sd, REG_CLEAR_LOST_LOCK, 0x01); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 667 | if (err) |
| 668 | return err; |
| 669 | |
| 670 | switch (input_sel) { |
| 671 | case INPUT_CVBS_VI1A: |
| 672 | case INPUT_CVBS_VI1B: |
| 673 | case INPUT_CVBS_VI1C: |
| 674 | case INPUT_CVBS_VI2A: |
| 675 | case INPUT_CVBS_VI2B: |
| 676 | case INPUT_CVBS_VI2C: |
| 677 | case INPUT_CVBS_VI3A: |
| 678 | case INPUT_CVBS_VI3B: |
| 679 | case INPUT_CVBS_VI3C: |
| 680 | case INPUT_CVBS_VI4A: |
| 681 | lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT | |
| 682 | STATUS_HORZ_SYNC_LOCK_BIT | |
| 683 | STATUS_VIRT_SYNC_LOCK_BIT; |
| 684 | break; |
| 685 | |
| 686 | case INPUT_SVIDEO_VI2A_VI1A: |
| 687 | case INPUT_SVIDEO_VI2B_VI1B: |
| 688 | case INPUT_SVIDEO_VI2C_VI1C: |
| 689 | case INPUT_SVIDEO_VI2A_VI3A: |
| 690 | case INPUT_SVIDEO_VI2B_VI3B: |
| 691 | case INPUT_SVIDEO_VI2C_VI3C: |
| 692 | case INPUT_SVIDEO_VI4A_VI1A: |
| 693 | case INPUT_SVIDEO_VI4A_VI1B: |
| 694 | case INPUT_SVIDEO_VI4A_VI1C: |
| 695 | case INPUT_SVIDEO_VI4A_VI3A: |
| 696 | case INPUT_SVIDEO_VI4A_VI3B: |
| 697 | case INPUT_SVIDEO_VI4A_VI3C: |
| 698 | lock_mask = STATUS_HORZ_SYNC_LOCK_BIT | |
| 699 | STATUS_VIRT_SYNC_LOCK_BIT; |
| 700 | break; |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 701 | /* Need to add other interfaces*/ |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 702 | default: |
| 703 | return -EINVAL; |
| 704 | } |
| 705 | |
| 706 | while (try_count-- > 0) { |
| 707 | /* Allow decoder to sync up with new input */ |
| 708 | msleep(LOCK_RETRY_DELAY); |
| 709 | |
| 710 | /* get the current standard for future reference */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 711 | current_std = tvp514x_get_current_std(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 712 | if (current_std == STD_INVALID) |
| 713 | continue; |
| 714 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 715 | sync_lock_status = tvp514x_read_reg(sd, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 716 | REG_STATUS1); |
| 717 | if (lock_mask == (sync_lock_status & lock_mask)) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 718 | /* Input detected */ |
| 719 | break; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 720 | } |
| 721 | |
Roel Kluin | 76b0811 | 2009-06-11 11:28:17 -0300 | [diff] [blame] | 722 | if ((current_std == STD_INVALID) || (try_count < 0)) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 723 | return -EINVAL; |
| 724 | |
| 725 | decoder->current_std = current_std; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 726 | decoder->input = input; |
| 727 | decoder->output = output; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 728 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 729 | v4l2_dbg(1, debug, sd, "Input set to: %d, std : %d", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 730 | input_sel, current_std); |
| 731 | |
| 732 | return 0; |
| 733 | } |
| 734 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 735 | /** |
| 736 | * tvp514x_queryctrl() - V4L2 decoder interface handler for queryctrl |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 737 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 738 | * @qctrl: standard V4L2 v4l2_queryctrl structure |
| 739 | * |
| 740 | * If the requested control is supported, returns the control information. |
| 741 | * Otherwise, returns -EINVAL if the control is not supported. |
| 742 | */ |
| 743 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 744 | tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 745 | { |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 746 | int err = -EINVAL; |
| 747 | |
| 748 | if (qctrl == NULL) |
| 749 | return err; |
| 750 | |
| 751 | switch (qctrl->id) { |
| 752 | case V4L2_CID_BRIGHTNESS: |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 753 | /* Brightness supported is (0-255), */ |
Hans Verkuil | 10afbef | 2009-02-21 18:47:24 -0300 | [diff] [blame] | 754 | err = v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 128); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 755 | break; |
| 756 | case V4L2_CID_CONTRAST: |
| 757 | case V4L2_CID_SATURATION: |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 758 | /** |
| 759 | * Saturation and Contrast supported is - |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 760 | * Contrast: 0 - 255 (Default - 128) |
| 761 | * Saturation: 0 - 255 (Default - 128) |
| 762 | */ |
| 763 | err = v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 128); |
| 764 | break; |
| 765 | case V4L2_CID_HUE: |
| 766 | /* Hue Supported is - |
| 767 | * Hue - -180 - +180 (Default - 0, Step - +180) |
| 768 | */ |
| 769 | err = v4l2_ctrl_query_fill(qctrl, -180, 180, 180, 0); |
| 770 | break; |
| 771 | case V4L2_CID_AUTOGAIN: |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 772 | /** |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 773 | * Auto Gain supported is - |
| 774 | * 0 - 1 (Default - 1) |
| 775 | */ |
| 776 | err = v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 1); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 777 | break; |
| 778 | default: |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 779 | v4l2_err(sd, "invalid control id %d\n", qctrl->id); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 780 | return err; |
| 781 | } |
| 782 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 783 | v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def - %d", |
| 784 | qctrl->name, qctrl->minimum, qctrl->maximum, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 785 | qctrl->default_value); |
| 786 | |
| 787 | return err; |
| 788 | } |
| 789 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 790 | /** |
| 791 | * tvp514x_g_ctrl() - V4L2 decoder interface handler for g_ctrl |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 792 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 793 | * @ctrl: pointer to v4l2_control structure |
| 794 | * |
| 795 | * If the requested control is supported, returns the control's current |
| 796 | * value from the decoder. Otherwise, returns -EINVAL if the control is not |
| 797 | * supported. |
| 798 | */ |
| 799 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 800 | tvp514x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 801 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 802 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 803 | |
| 804 | if (ctrl == NULL) |
| 805 | return -EINVAL; |
| 806 | |
| 807 | switch (ctrl->id) { |
| 808 | case V4L2_CID_BRIGHTNESS: |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 809 | ctrl->value = decoder->tvp514x_regs[REG_BRIGHTNESS].val; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 810 | break; |
| 811 | case V4L2_CID_CONTRAST: |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 812 | ctrl->value = decoder->tvp514x_regs[REG_CONTRAST].val; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 813 | break; |
| 814 | case V4L2_CID_SATURATION: |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 815 | ctrl->value = decoder->tvp514x_regs[REG_SATURATION].val; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 816 | break; |
| 817 | case V4L2_CID_HUE: |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 818 | ctrl->value = decoder->tvp514x_regs[REG_HUE].val; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 819 | if (ctrl->value == 0x7F) |
| 820 | ctrl->value = 180; |
| 821 | else if (ctrl->value == 0x80) |
| 822 | ctrl->value = -180; |
| 823 | else |
| 824 | ctrl->value = 0; |
| 825 | |
| 826 | break; |
| 827 | case V4L2_CID_AUTOGAIN: |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 828 | ctrl->value = decoder->tvp514x_regs[REG_AFE_GAIN_CTRL].val; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 829 | if ((ctrl->value & 0x3) == 3) |
| 830 | ctrl->value = 1; |
| 831 | else |
| 832 | ctrl->value = 0; |
| 833 | |
| 834 | break; |
| 835 | default: |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 836 | v4l2_err(sd, "invalid control id %d\n", ctrl->id); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 837 | return -EINVAL; |
| 838 | } |
| 839 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 840 | v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 841 | ctrl->id, ctrl->value); |
| 842 | return 0; |
| 843 | } |
| 844 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 845 | /** |
| 846 | * tvp514x_s_ctrl() - V4L2 decoder interface handler for s_ctrl |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 847 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 848 | * @ctrl: pointer to v4l2_control structure |
| 849 | * |
| 850 | * If the requested control is supported, sets the control's current |
| 851 | * value in HW. Otherwise, returns -EINVAL if the control is not supported. |
| 852 | */ |
| 853 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 854 | tvp514x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 855 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 856 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 857 | int err = -EINVAL, value; |
| 858 | |
| 859 | if (ctrl == NULL) |
| 860 | return err; |
| 861 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 862 | value = ctrl->value; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 863 | |
| 864 | switch (ctrl->id) { |
| 865 | case V4L2_CID_BRIGHTNESS: |
| 866 | if (ctrl->value < 0 || ctrl->value > 255) { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 867 | v4l2_err(sd, "invalid brightness setting %d\n", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 868 | ctrl->value); |
| 869 | return -ERANGE; |
| 870 | } |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 871 | err = tvp514x_write_reg(sd, REG_BRIGHTNESS, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 872 | value); |
| 873 | if (err) |
| 874 | return err; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 875 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 876 | decoder->tvp514x_regs[REG_BRIGHTNESS].val = value; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 877 | break; |
| 878 | case V4L2_CID_CONTRAST: |
| 879 | if (ctrl->value < 0 || ctrl->value > 255) { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 880 | v4l2_err(sd, "invalid contrast setting %d\n", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 881 | ctrl->value); |
| 882 | return -ERANGE; |
| 883 | } |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 884 | err = tvp514x_write_reg(sd, REG_CONTRAST, value); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 885 | if (err) |
| 886 | return err; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 887 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 888 | decoder->tvp514x_regs[REG_CONTRAST].val = value; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 889 | break; |
| 890 | case V4L2_CID_SATURATION: |
| 891 | if (ctrl->value < 0 || ctrl->value > 255) { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 892 | v4l2_err(sd, "invalid saturation setting %d\n", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 893 | ctrl->value); |
| 894 | return -ERANGE; |
| 895 | } |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 896 | err = tvp514x_write_reg(sd, REG_SATURATION, value); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 897 | if (err) |
| 898 | return err; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 899 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 900 | decoder->tvp514x_regs[REG_SATURATION].val = value; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 901 | break; |
| 902 | case V4L2_CID_HUE: |
| 903 | if (value == 180) |
| 904 | value = 0x7F; |
| 905 | else if (value == -180) |
| 906 | value = 0x80; |
| 907 | else if (value == 0) |
| 908 | value = 0; |
| 909 | else { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 910 | v4l2_err(sd, "invalid hue setting %d\n", ctrl->value); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 911 | return -ERANGE; |
| 912 | } |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 913 | err = tvp514x_write_reg(sd, REG_HUE, value); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 914 | if (err) |
| 915 | return err; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 916 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 917 | decoder->tvp514x_regs[REG_HUE].val = value; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 918 | break; |
| 919 | case V4L2_CID_AUTOGAIN: |
| 920 | if (value == 1) |
| 921 | value = 0x0F; |
| 922 | else if (value == 0) |
| 923 | value = 0x0C; |
| 924 | else { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 925 | v4l2_err(sd, "invalid auto gain setting %d\n", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 926 | ctrl->value); |
| 927 | return -ERANGE; |
| 928 | } |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 929 | err = tvp514x_write_reg(sd, REG_AFE_GAIN_CTRL, value); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 930 | if (err) |
| 931 | return err; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 932 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 933 | decoder->tvp514x_regs[REG_AFE_GAIN_CTRL].val = value; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 934 | break; |
| 935 | default: |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 936 | v4l2_err(sd, "invalid control id %d\n", ctrl->id); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 937 | return err; |
| 938 | } |
| 939 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 940 | v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 941 | ctrl->id, ctrl->value); |
| 942 | |
| 943 | return err; |
| 944 | } |
| 945 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 946 | /** |
| 947 | * tvp514x_enum_fmt_cap() - V4L2 decoder interface handler for enum_fmt |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 948 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 949 | * @fmt: standard V4L2 VIDIOC_ENUM_FMT ioctl structure |
| 950 | * |
| 951 | * Implement the VIDIOC_ENUM_FMT ioctl to enumerate supported formats |
| 952 | */ |
| 953 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 954 | tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 955 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 956 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 957 | int index; |
| 958 | |
| 959 | if (fmt == NULL) |
| 960 | return -EINVAL; |
| 961 | |
| 962 | index = fmt->index; |
| 963 | if ((index >= decoder->num_fmts) || (index < 0)) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 964 | /* Index out of bound */ |
| 965 | return -EINVAL; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 966 | |
| 967 | if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 968 | /* only capture is supported */ |
| 969 | return -EINVAL; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 970 | |
| 971 | memcpy(fmt, &decoder->fmt_list[index], |
| 972 | sizeof(struct v4l2_fmtdesc)); |
| 973 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 974 | v4l2_dbg(1, debug, sd, "Current FMT: index - %d (%s)", |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 975 | decoder->fmt_list[index].index, |
| 976 | decoder->fmt_list[index].description); |
| 977 | return 0; |
| 978 | } |
| 979 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 980 | /** |
| 981 | * tvp514x_try_fmt_cap() - V4L2 decoder interface handler for try_fmt |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 982 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 983 | * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure |
| 984 | * |
| 985 | * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This |
| 986 | * ioctl is used to negotiate the image capture size and pixel format |
| 987 | * without actually making it take effect. |
| 988 | */ |
| 989 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 990 | tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 991 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 992 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 993 | int ifmt; |
| 994 | struct v4l2_pix_format *pix; |
| 995 | enum tvp514x_std current_std; |
| 996 | |
| 997 | if (f == NULL) |
| 998 | return -EINVAL; |
| 999 | |
| 1000 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1001 | /* only capture is supported */ |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1002 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1003 | |
| 1004 | pix = &f->fmt.pix; |
| 1005 | |
| 1006 | /* Calculate height and width based on current standard */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1007 | current_std = tvp514x_get_current_std(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1008 | if (current_std == STD_INVALID) |
| 1009 | return -EINVAL; |
| 1010 | |
| 1011 | decoder->current_std = current_std; |
| 1012 | pix->width = decoder->std_list[current_std].width; |
| 1013 | pix->height = decoder->std_list[current_std].height; |
| 1014 | |
| 1015 | for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) { |
| 1016 | if (pix->pixelformat == |
| 1017 | decoder->fmt_list[ifmt].pixelformat) |
| 1018 | break; |
| 1019 | } |
| 1020 | if (ifmt == decoder->num_fmts) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1021 | /* None of the format matched, select default */ |
| 1022 | ifmt = 0; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1023 | pix->pixelformat = decoder->fmt_list[ifmt].pixelformat; |
| 1024 | |
| 1025 | pix->field = V4L2_FIELD_INTERLACED; |
| 1026 | pix->bytesperline = pix->width * 2; |
| 1027 | pix->sizeimage = pix->bytesperline * pix->height; |
| 1028 | pix->colorspace = V4L2_COLORSPACE_SMPTE170M; |
| 1029 | pix->priv = 0; |
| 1030 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1031 | v4l2_dbg(1, debug, sd, "Try FMT: pixelformat - %s, bytesperline - %d" |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1032 | "Width - %d, Height - %d", |
| 1033 | decoder->fmt_list[ifmt].description, pix->bytesperline, |
| 1034 | pix->width, pix->height); |
| 1035 | return 0; |
| 1036 | } |
| 1037 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1038 | /** |
| 1039 | * tvp514x_s_fmt_cap() - V4L2 decoder interface handler for s_fmt |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1040 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1041 | * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure |
| 1042 | * |
| 1043 | * If the requested format is supported, configures the HW to use that |
| 1044 | * format, returns error code if format not supported or HW can't be |
| 1045 | * correctly configured. |
| 1046 | */ |
| 1047 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1048 | tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1049 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1050 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1051 | struct v4l2_pix_format *pix; |
| 1052 | int rval; |
| 1053 | |
| 1054 | if (f == NULL) |
| 1055 | return -EINVAL; |
| 1056 | |
| 1057 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1058 | /* only capture is supported */ |
| 1059 | return -EINVAL; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1060 | |
| 1061 | pix = &f->fmt.pix; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1062 | rval = tvp514x_try_fmt_cap(sd, f); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1063 | if (rval) |
| 1064 | return rval; |
| 1065 | |
| 1066 | decoder->pix = *pix; |
| 1067 | |
| 1068 | return rval; |
| 1069 | } |
| 1070 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1071 | /** |
| 1072 | * tvp514x_g_fmt_cap() - V4L2 decoder interface handler for tvp514x_g_fmt_cap |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1073 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1074 | * @f: pointer to standard V4L2 v4l2_format structure |
| 1075 | * |
| 1076 | * Returns the decoder's current pixel format in the v4l2_format |
| 1077 | * parameter. |
| 1078 | */ |
| 1079 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1080 | tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1081 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1082 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1083 | |
| 1084 | if (f == NULL) |
| 1085 | return -EINVAL; |
| 1086 | |
| 1087 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1088 | /* only capture is supported */ |
| 1089 | return -EINVAL; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1090 | |
| 1091 | f->fmt.pix = decoder->pix; |
| 1092 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1093 | v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d" |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1094 | "Width - %d, Height - %d", |
| 1095 | decoder->pix.bytesperline, |
| 1096 | decoder->pix.width, decoder->pix.height); |
| 1097 | return 0; |
| 1098 | } |
| 1099 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1100 | /** |
| 1101 | * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1102 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1103 | * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure |
| 1104 | * |
| 1105 | * Returns the decoder's video CAPTURE parameters. |
| 1106 | */ |
| 1107 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1108 | tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1109 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1110 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1111 | struct v4l2_captureparm *cparm; |
| 1112 | enum tvp514x_std current_std; |
| 1113 | |
| 1114 | if (a == NULL) |
| 1115 | return -EINVAL; |
| 1116 | |
| 1117 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1118 | /* only capture is supported */ |
| 1119 | return -EINVAL; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1120 | |
| 1121 | memset(a, 0, sizeof(*a)); |
| 1122 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1123 | |
| 1124 | /* get the current standard */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1125 | current_std = tvp514x_get_current_std(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1126 | if (current_std == STD_INVALID) |
| 1127 | return -EINVAL; |
| 1128 | |
| 1129 | decoder->current_std = current_std; |
| 1130 | |
| 1131 | cparm = &a->parm.capture; |
| 1132 | cparm->capability = V4L2_CAP_TIMEPERFRAME; |
| 1133 | cparm->timeperframe = |
| 1134 | decoder->std_list[current_std].standard.frameperiod; |
| 1135 | |
| 1136 | return 0; |
| 1137 | } |
| 1138 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1139 | /** |
| 1140 | * tvp514x_s_parm() - V4L2 decoder interface handler for s_parm |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1141 | * @sd: pointer to standard V4L2 sub-device structure |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1142 | * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure |
| 1143 | * |
| 1144 | * Configures the decoder to use the input parameters, if possible. If |
| 1145 | * not possible, returns the appropriate error code. |
| 1146 | */ |
| 1147 | static int |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1148 | tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1149 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1150 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1151 | struct v4l2_fract *timeperframe; |
| 1152 | enum tvp514x_std current_std; |
| 1153 | |
| 1154 | if (a == NULL) |
| 1155 | return -EINVAL; |
| 1156 | |
| 1157 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1158 | /* only capture is supported */ |
| 1159 | return -EINVAL; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1160 | |
| 1161 | timeperframe = &a->parm.capture.timeperframe; |
| 1162 | |
| 1163 | /* get the current standard */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1164 | current_std = tvp514x_get_current_std(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1165 | if (current_std == STD_INVALID) |
| 1166 | return -EINVAL; |
| 1167 | |
| 1168 | decoder->current_std = current_std; |
| 1169 | |
| 1170 | *timeperframe = |
| 1171 | decoder->std_list[current_std].standard.frameperiod; |
| 1172 | |
| 1173 | return 0; |
| 1174 | } |
| 1175 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1176 | /** |
| 1177 | * tvp514x_s_stream() - V4L2 decoder i/f handler for s_stream |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1178 | * @sd: pointer to standard V4L2 sub-device structure |
| 1179 | * @enable: streaming enable or disable |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1180 | * |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1181 | * Sets streaming to enable or disable, if possible. |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1182 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1183 | static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1184 | { |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1185 | int err = 0; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1186 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 1187 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1188 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1189 | if (decoder->streaming == enable) |
| 1190 | return 0; |
| 1191 | |
| 1192 | switch (enable) { |
| 1193 | case 0: |
| 1194 | { |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1195 | /* Power Down Sequence */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1196 | err = tvp514x_write_reg(sd, REG_OPERATION_MODE, 0x01); |
| 1197 | if (err) { |
| 1198 | v4l2_err(sd, "Unable to turn off decoder\n"); |
| 1199 | return err; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1200 | } |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1201 | decoder->streaming = enable; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1202 | break; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1203 | } |
| 1204 | case 1: |
| 1205 | { |
| 1206 | struct tvp514x_reg *int_seq = (struct tvp514x_reg *) |
| 1207 | client->driver->id_table->driver_data; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1208 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1209 | /* Power Up Sequence */ |
| 1210 | err = tvp514x_write_regs(sd, int_seq); |
| 1211 | if (err) { |
| 1212 | v4l2_err(sd, "Unable to turn on decoder\n"); |
| 1213 | return err; |
| 1214 | } |
| 1215 | /* Detect if not already detected */ |
| 1216 | err = tvp514x_detect(sd, decoder); |
| 1217 | if (err) { |
| 1218 | v4l2_err(sd, "Unable to detect decoder\n"); |
| 1219 | return err; |
| 1220 | } |
| 1221 | err = tvp514x_configure(sd, decoder); |
| 1222 | if (err) { |
| 1223 | v4l2_err(sd, "Unable to configure decoder\n"); |
| 1224 | return err; |
| 1225 | } |
| 1226 | decoder->streaming = enable; |
| 1227 | break; |
| 1228 | } |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1229 | default: |
| 1230 | err = -ENODEV; |
| 1231 | break; |
| 1232 | } |
| 1233 | |
| 1234 | return err; |
| 1235 | } |
| 1236 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1237 | static const struct v4l2_subdev_core_ops tvp514x_core_ops = { |
| 1238 | .queryctrl = tvp514x_queryctrl, |
| 1239 | .g_ctrl = tvp514x_g_ctrl, |
| 1240 | .s_ctrl = tvp514x_s_ctrl, |
| 1241 | .s_std = tvp514x_s_std, |
| 1242 | }; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1243 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1244 | static const struct v4l2_subdev_video_ops tvp514x_video_ops = { |
| 1245 | .s_routing = tvp514x_s_routing, |
| 1246 | .querystd = tvp514x_querystd, |
| 1247 | .enum_fmt = tvp514x_enum_fmt_cap, |
| 1248 | .g_fmt = tvp514x_g_fmt_cap, |
| 1249 | .try_fmt = tvp514x_try_fmt_cap, |
| 1250 | .s_fmt = tvp514x_s_fmt_cap, |
| 1251 | .g_parm = tvp514x_g_parm, |
| 1252 | .s_parm = tvp514x_s_parm, |
| 1253 | .s_stream = tvp514x_s_stream, |
| 1254 | }; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1255 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1256 | static const struct v4l2_subdev_ops tvp514x_ops = { |
| 1257 | .core = &tvp514x_core_ops, |
| 1258 | .video = &tvp514x_video_ops, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1259 | }; |
| 1260 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1261 | static struct tvp514x_decoder tvp514x_dev = { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1262 | .streaming = 0, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1263 | |
| 1264 | .fmt_list = tvp514x_fmt_list, |
| 1265 | .num_fmts = ARRAY_SIZE(tvp514x_fmt_list), |
| 1266 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1267 | .pix = { |
| 1268 | /* Default to NTSC 8-bit YUV 422 */ |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1269 | .width = NTSC_NUM_ACTIVE_PIXELS, |
| 1270 | .height = NTSC_NUM_ACTIVE_LINES, |
| 1271 | .pixelformat = V4L2_PIX_FMT_UYVY, |
| 1272 | .field = V4L2_FIELD_INTERLACED, |
| 1273 | .bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2, |
| 1274 | .sizeimage = |
| 1275 | NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES, |
| 1276 | .colorspace = V4L2_COLORSPACE_SMPTE170M, |
| 1277 | }, |
| 1278 | |
| 1279 | .current_std = STD_NTSC_MJ, |
| 1280 | .std_list = tvp514x_std_list, |
| 1281 | .num_stds = ARRAY_SIZE(tvp514x_std_list), |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1282 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1283 | }; |
| 1284 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1285 | /** |
| 1286 | * tvp514x_probe() - decoder driver i2c probe handler |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1287 | * @client: i2c driver client device structure |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1288 | * @id: i2c driver id table |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1289 | * |
| 1290 | * Register decoder as an i2c client device and V4L2 |
| 1291 | * device. |
| 1292 | */ |
| 1293 | static int |
| 1294 | tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) |
| 1295 | { |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1296 | struct tvp514x_decoder *decoder; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1297 | struct v4l2_subdev *sd; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1298 | |
| 1299 | /* Check if the adapter supports the needed features */ |
| 1300 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
| 1301 | return -EIO; |
| 1302 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1303 | if (!client->dev.platform_data) { |
| 1304 | v4l2_err(client, "No platform data!!\n"); |
| 1305 | return -ENODEV; |
| 1306 | } |
| 1307 | |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1308 | decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); |
| 1309 | if (!decoder) |
| 1310 | return -ENOMEM; |
| 1311 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1312 | /* Initialize the tvp514x_decoder with default configuration */ |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1313 | *decoder = tvp514x_dev; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1314 | /* Copy default register configuration */ |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1315 | memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default, |
| 1316 | sizeof(tvp514x_reg_list_default)); |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1317 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1318 | /* Copy board specific information here */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1319 | decoder->pdata = client->dev.platform_data; |
| 1320 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1321 | /** |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1322 | * Fetch platform specific data, and configure the |
| 1323 | * tvp514x_reg_list[] accordingly. Since this is one |
| 1324 | * time configuration, no need to preserve. |
| 1325 | */ |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1326 | decoder->tvp514x_regs[REG_OUTPUT_FORMATTER2].val |= |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1327 | (decoder->pdata->clk_polarity << 1); |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1328 | decoder->tvp514x_regs[REG_SYNC_CONTROL].val |= |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1329 | ((decoder->pdata->hs_polarity << 2) | |
| 1330 | (decoder->pdata->vs_polarity << 3)); |
| 1331 | /* Set default standard to auto */ |
| 1332 | decoder->tvp514x_regs[REG_VIDEO_STD].val = |
| 1333 | VIDEO_STD_AUTO_SWITCH_BIT; |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1334 | |
| 1335 | /* Register with V4L2 layer as slave device */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1336 | sd = &decoder->sd; |
| 1337 | v4l2_i2c_subdev_init(sd, client, &tvp514x_ops); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1338 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1339 | v4l2_info(sd, "%s decoder driver registered !!\n", sd->name); |
| 1340 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1341 | return 0; |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1342 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1343 | } |
| 1344 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1345 | /** |
| 1346 | * tvp514x_remove() - decoder driver i2c remove handler |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1347 | * @client: i2c driver client device structure |
| 1348 | * |
| 1349 | * Unregister decoder as an i2c client device and V4L2 |
| 1350 | * device. Complement of tvp514x_probe(). |
| 1351 | */ |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1352 | static int tvp514x_remove(struct i2c_client *client) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1353 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1354 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
| 1355 | struct tvp514x_decoder *decoder = to_decoder(sd); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1356 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1357 | v4l2_device_unregister_subdev(sd); |
Sebastian Andrzej Siewior | 6722e0e | 2009-01-12 06:17:43 -0300 | [diff] [blame] | 1358 | kfree(decoder); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1359 | return 0; |
| 1360 | } |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1361 | /* TVP5146 Init/Power on Sequence */ |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1362 | static const struct tvp514x_reg tvp5146_init_reg_seq[] = { |
| 1363 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02}, |
| 1364 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, |
| 1365 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80}, |
| 1366 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01}, |
| 1367 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60}, |
| 1368 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, |
| 1369 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0}, |
| 1370 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01}, |
| 1371 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00}, |
| 1372 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, |
| 1373 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1374 | {TOK_TERM, 0, 0}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1375 | }; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1376 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1377 | /* TVP5147 Init/Power on Sequence */ |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1378 | static const struct tvp514x_reg tvp5147_init_reg_seq[] = { |
| 1379 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x02}, |
| 1380 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, |
| 1381 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0x80}, |
| 1382 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01}, |
| 1383 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60}, |
| 1384 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, |
| 1385 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0}, |
| 1386 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x01}, |
| 1387 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x16}, |
| 1388 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, |
| 1389 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xA0}, |
| 1390 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x16}, |
| 1391 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS1, 0x60}, |
| 1392 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS2, 0x00}, |
| 1393 | {TOK_WRITE, REG_VBUS_ADDRESS_ACCESS3, 0xB0}, |
| 1394 | {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00}, |
| 1395 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, |
| 1396 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1397 | {TOK_TERM, 0, 0}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1398 | }; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1399 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1400 | /* TVP5146M2/TVP5147M1 Init/Power on Sequence */ |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1401 | static const struct tvp514x_reg tvp514xm_init_reg_seq[] = { |
| 1402 | {TOK_WRITE, REG_OPERATION_MODE, 0x01}, |
| 1403 | {TOK_WRITE, REG_OPERATION_MODE, 0x00}, |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1404 | {TOK_TERM, 0, 0}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1405 | }; |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1406 | |
Muralidharan Karicheri | c1c9d09 | 2009-07-01 04:20:43 -0300 | [diff] [blame] | 1407 | /** |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1408 | * I2C Device Table - |
| 1409 | * |
| 1410 | * name - Name of the actual device/chip. |
| 1411 | * driver_data - Driver data |
| 1412 | */ |
| 1413 | static const struct i2c_device_id tvp514x_id[] = { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1414 | {"tvp5146", (unsigned long)tvp5146_init_reg_seq}, |
| 1415 | {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq}, |
| 1416 | {"tvp5147", (unsigned long)tvp5147_init_reg_seq}, |
| 1417 | {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq}, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1418 | {}, |
| 1419 | }; |
| 1420 | |
| 1421 | MODULE_DEVICE_TABLE(i2c, tvp514x_id); |
| 1422 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1423 | static struct i2c_driver tvp514x_driver = { |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1424 | .driver = { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1425 | .owner = THIS_MODULE, |
| 1426 | .name = TVP514X_MODULE_NAME, |
| 1427 | }, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1428 | .probe = tvp514x_probe, |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1429 | .remove = tvp514x_remove, |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1430 | .id_table = tvp514x_id, |
| 1431 | }; |
| 1432 | |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1433 | static int __init tvp514x_init(void) |
| 1434 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1435 | return i2c_add_driver(&tvp514x_driver); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1436 | } |
| 1437 | |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1438 | static void __exit tvp514x_exit(void) |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1439 | { |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1440 | i2c_del_driver(&tvp514x_driver); |
Vaibhav Hiremath | 07b1747c | 2008-12-05 10:19:36 -0300 | [diff] [blame] | 1441 | } |
| 1442 | |
| 1443 | module_init(tvp514x_init); |
Muralidharan Karicheri | 62ef80a | 2009-06-19 07:13:44 -0300 | [diff] [blame] | 1444 | module_exit(tvp514x_exit); |