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