blob: b167ffab25202106da0bc956b8304430a48634e8 [file] [log] [blame]
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001/*
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -02002 * tvp5150 - Texas Instruments TVP5150A/AM1 video decoder driver
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08003 *
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -02004 * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org)
5 * This code is placed under the terms of the GNU General Public License v2
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08006 */
7
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08008#include <linux/i2c.h>
9#include <linux/videodev.h>
10#include <linux/delay.h>
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -080011#include <linux/video_decoder.h>
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -020012#include <media/v4l2-common.h>
Hans Verkuilc7c0b342006-04-02 13:35:00 -030013#include <media/tvp5150.h>
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080014
15#include "tvp5150_reg.h"
16
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -020017MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver");
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080018MODULE_AUTHOR("Mauro Carvalho Chehab");
19MODULE_LICENSE("GPL");
20
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -020021/* standard i2c insmod options */
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080022static unsigned short normal_i2c[] = {
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -080023 0xb8 >> 1,
24 0xba >> 1,
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080025 I2C_CLIENT_END
26};
27
28I2C_CLIENT_INSMOD;
29
30static int debug = 0;
31module_param(debug, int, 0);
32MODULE_PARM_DESC(debug, "Debug level (0-1)");
33
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -020034#define tvp5150_err(fmt, arg...) do { \
35 printk(KERN_ERR "%s %d-%04x: " fmt, c->driver->driver.name, \
36 i2c_adapter_id(c->adapter), c->addr , ## arg); } while (0)
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -020037#define tvp5150_info(fmt, arg...) do { \
Mauro Carvalho Chehabcab462f2006-01-09 15:53:26 -020038 printk(KERN_INFO "%s %d-%04x: " fmt, c->driver->driver.name, \
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -020039 i2c_adapter_id(c->adapter), c->addr , ## arg); } while (0)
40#define tvp5150_dbg(num, fmt, arg...) \
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080041 do { \
42 if (debug >= num) \
Mauro Carvalho Chehabcab462f2006-01-09 15:53:26 -020043 printk(KERN_DEBUG "%s debug %d-%04x: " fmt,\
44 c->driver->driver.name, \
45 i2c_adapter_id(c->adapter), \
46 c->addr , ## arg); } while (0)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080047
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080048/* supported controls */
49static struct v4l2_queryctrl tvp5150_qctrl[] = {
50 {
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -020051 .id = V4L2_CID_BRIGHTNESS,
52 .type = V4L2_CTRL_TYPE_INTEGER,
53 .name = "Brightness",
54 .minimum = 0,
55 .maximum = 255,
56 .step = 1,
Mauro Carvalho Chehab75bc8012006-03-28 10:02:28 -030057 .default_value = 128,
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -020058 .flags = 0,
59 }, {
60 .id = V4L2_CID_CONTRAST,
61 .type = V4L2_CTRL_TYPE_INTEGER,
62 .name = "Contrast",
63 .minimum = 0,
64 .maximum = 255,
65 .step = 0x1,
Mauro Carvalho Chehab75bc8012006-03-28 10:02:28 -030066 .default_value = 128,
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -020067 .flags = 0,
68 }, {
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080069 .id = V4L2_CID_SATURATION,
70 .type = V4L2_CTRL_TYPE_INTEGER,
71 .name = "Saturation",
72 .minimum = 0,
73 .maximum = 255,
74 .step = 0x1,
Mauro Carvalho Chehab75bc8012006-03-28 10:02:28 -030075 .default_value = 128,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080076 .flags = 0,
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -020077 }, {
78 .id = V4L2_CID_HUE,
79 .type = V4L2_CTRL_TYPE_INTEGER,
80 .name = "Hue",
81 .minimum = -128,
82 .maximum = 127,
83 .step = 0x1,
Mauro Carvalho Chehab75bc8012006-03-28 10:02:28 -030084 .default_value = 0,
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -020085 .flags = 0,
86 }
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080087};
88
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080089struct tvp5150 {
90 struct i2c_client *client;
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -080091
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -020092 v4l2_std_id norm; /* Current set standard */
Hans Verkuilc7c0b342006-04-02 13:35:00 -030093 struct v4l2_routing route;
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -080094 int enable;
95 int bright;
96 int contrast;
97 int hue;
98 int sat;
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -080099};
100
Arjan van de Ven858119e2006-01-14 13:20:43 -0800101static int tvp5150_read(struct i2c_client *c, unsigned char addr)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800102{
103 unsigned char buffer[1];
104 int rc;
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800105
106 buffer[0] = addr;
107 if (1 != (rc = i2c_master_send(c, buffer, 1)))
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200108 tvp5150_dbg(0, "i2c i/o error: rc == %d (should be 1)\n", rc);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800109
110 msleep(10);
111
112 if (1 != (rc = i2c_master_recv(c, buffer, 1)))
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200113 tvp5150_dbg(0, "i2c i/o error: rc == %d (should be 1)\n", rc);
114
115 tvp5150_dbg(2, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800116
117 return (buffer[0]);
118}
119
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800120static inline void tvp5150_write(struct i2c_client *c, unsigned char addr,
121 unsigned char value)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800122{
123 unsigned char buffer[2];
124 int rc;
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800125
126 buffer[0] = addr;
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800127 buffer[1] = value;
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200128 tvp5150_dbg(2, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0], buffer[1]);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800129 if (2 != (rc = i2c_master_send(c, buffer, 2)))
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200130 tvp5150_dbg(0, "i2c i/o error: rc == %d (should be 2)\n", rc);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800131}
132
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200133static void dump_reg_range(struct i2c_client *c, char *s, u8 init, const u8 end,int max_line)
134{
135 int i=0;
136
137 while (init!=(u8)(end+1)) {
138 if ((i%max_line) == 0) {
139 if (i>0)
140 printk("\n");
141 printk("tvp5150: %s reg 0x%02x = ",s,init);
142 }
143 printk("%02x ",tvp5150_read(c, init));
144
145 init++;
146 i++;
147 }
148 printk("\n");
149}
150
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800151static void dump_reg(struct i2c_client *c)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800152{
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800153 printk("tvp5150: Video input source selection #1 = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200154 tvp5150_read(c, TVP5150_VD_IN_SRC_SEL_1));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800155 printk("tvp5150: Analog channel controls = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200156 tvp5150_read(c, TVP5150_ANAL_CHL_CTL));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800157 printk("tvp5150: Operation mode controls = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200158 tvp5150_read(c, TVP5150_OP_MODE_CTL));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800159 printk("tvp5150: Miscellaneous controls = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200160 tvp5150_read(c, TVP5150_MISC_CTL));
161 printk("tvp5150: Autoswitch mask= 0x%02x\n",
162 tvp5150_read(c, TVP5150_AUTOSW_MSK));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800163 printk("tvp5150: Color killer threshold control = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200164 tvp5150_read(c, TVP5150_COLOR_KIL_THSH_CTL));
165 printk("tvp5150: Luminance processing controls #1 #2 and #3 = %02x %02x %02x\n",
166 tvp5150_read(c, TVP5150_LUMA_PROC_CTL_1),
167 tvp5150_read(c, TVP5150_LUMA_PROC_CTL_2),
168 tvp5150_read(c, TVP5150_LUMA_PROC_CTL_3));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800169 printk("tvp5150: Brightness control = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200170 tvp5150_read(c, TVP5150_BRIGHT_CTL));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800171 printk("tvp5150: Color saturation control = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200172 tvp5150_read(c, TVP5150_SATURATION_CTL));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800173 printk("tvp5150: Hue control = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200174 tvp5150_read(c, TVP5150_HUE_CTL));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800175 printk("tvp5150: Contrast control = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200176 tvp5150_read(c, TVP5150_CONTRAST_CTL));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800177 printk("tvp5150: Outputs and data rates select = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200178 tvp5150_read(c, TVP5150_DATA_RATE_SEL));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800179 printk("tvp5150: Configuration shared pins = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200180 tvp5150_read(c, TVP5150_CONF_SHARED_PIN));
181 printk("tvp5150: Active video cropping start = 0x%02x%02x\n",
182 tvp5150_read(c, TVP5150_ACT_VD_CROP_ST_MSB),
183 tvp5150_read(c, TVP5150_ACT_VD_CROP_ST_LSB));
184 printk("tvp5150: Active video cropping stop = 0x%02x%02x\n",
185 tvp5150_read(c, TVP5150_ACT_VD_CROP_STP_MSB),
186 tvp5150_read(c, TVP5150_ACT_VD_CROP_STP_LSB));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800187 printk("tvp5150: Genlock/RTC = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200188 tvp5150_read(c, TVP5150_GENLOCK));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800189 printk("tvp5150: Horizontal sync start = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200190 tvp5150_read(c, TVP5150_HORIZ_SYNC_START));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800191 printk("tvp5150: Vertical blanking start = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200192 tvp5150_read(c, TVP5150_VERT_BLANKING_START));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800193 printk("tvp5150: Vertical blanking stop = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200194 tvp5150_read(c, TVP5150_VERT_BLANKING_STOP));
195 printk("tvp5150: Chrominance processing control #1 and #2 = %02x %02x\n",
196 tvp5150_read(c, TVP5150_CHROMA_PROC_CTL_1),
197 tvp5150_read(c, TVP5150_CHROMA_PROC_CTL_2));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800198 printk("tvp5150: Interrupt reset register B = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200199 tvp5150_read(c, TVP5150_INT_RESET_REG_B));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800200 printk("tvp5150: Interrupt enable register B = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200201 tvp5150_read(c, TVP5150_INT_ENABLE_REG_B));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800202 printk("tvp5150: Interrupt configuration register B = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200203 tvp5150_read(c, TVP5150_INTT_CONFIG_REG_B));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800204 printk("tvp5150: Video standard = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200205 tvp5150_read(c, TVP5150_VIDEO_STD));
206 printk("tvp5150: Chroma gain factor: Cb=0x%02x Cr=0x%02x\n",
207 tvp5150_read(c, TVP5150_CB_GAIN_FACT),
208 tvp5150_read(c, TVP5150_CR_GAIN_FACTOR));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800209 printk("tvp5150: Macrovision on counter = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200210 tvp5150_read(c, TVP5150_MACROVISION_ON_CTR));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800211 printk("tvp5150: Macrovision off counter = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200212 tvp5150_read(c, TVP5150_MACROVISION_OFF_CTR));
213 printk("tvp5150: ITU-R BT.656.%d timing(TVP5150AM1 only)\n",
214 (tvp5150_read(c, TVP5150_REV_SELECT)&1)?3:4);
215 printk("tvp5150: Device ID = %02x%02x\n",
216 tvp5150_read(c, TVP5150_MSB_DEV_ID),
217 tvp5150_read(c, TVP5150_LSB_DEV_ID));
218 printk("tvp5150: ROM version = (hex) %02x.%02x\n",
219 tvp5150_read(c, TVP5150_ROM_MAJOR_VER),
220 tvp5150_read(c, TVP5150_ROM_MINOR_VER));
221 printk("tvp5150: Vertical line count = 0x%02x%02x\n",
222 tvp5150_read(c, TVP5150_VERT_LN_COUNT_MSB),
223 tvp5150_read(c, TVP5150_VERT_LN_COUNT_LSB));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800224 printk("tvp5150: Interrupt status register B = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200225 tvp5150_read(c, TVP5150_INT_STATUS_REG_B));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800226 printk("tvp5150: Interrupt active register B = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200227 tvp5150_read(c, TVP5150_INT_ACTIVE_REG_B));
228 printk("tvp5150: Status regs #1 to #5 = %02x %02x %02x %02x %02x\n",
229 tvp5150_read(c, TVP5150_STATUS_REG_1),
230 tvp5150_read(c, TVP5150_STATUS_REG_2),
231 tvp5150_read(c, TVP5150_STATUS_REG_3),
232 tvp5150_read(c, TVP5150_STATUS_REG_4),
233 tvp5150_read(c, TVP5150_STATUS_REG_5));
234
235 dump_reg_range(c,"Teletext filter 1", TVP5150_TELETEXT_FIL1_INI,
236 TVP5150_TELETEXT_FIL1_END,8);
237 dump_reg_range(c,"Teletext filter 2", TVP5150_TELETEXT_FIL2_INI,
238 TVP5150_TELETEXT_FIL2_END,8);
239
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800240 printk("tvp5150: Teletext filter enable = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200241 tvp5150_read(c, TVP5150_TELETEXT_FIL_ENA));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800242 printk("tvp5150: Interrupt status register A = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200243 tvp5150_read(c, TVP5150_INT_STATUS_REG_A));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800244 printk("tvp5150: Interrupt enable register A = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200245 tvp5150_read(c, TVP5150_INT_ENABLE_REG_A));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800246 printk("tvp5150: Interrupt configuration = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200247 tvp5150_read(c, TVP5150_INT_CONF));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800248 printk("tvp5150: VDP status register = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200249 tvp5150_read(c, TVP5150_VDP_STATUS_REG));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800250 printk("tvp5150: FIFO word count = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200251 tvp5150_read(c, TVP5150_FIFO_WORD_COUNT));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800252 printk("tvp5150: FIFO interrupt threshold = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200253 tvp5150_read(c, TVP5150_FIFO_INT_THRESHOLD));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800254 printk("tvp5150: FIFO reset = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200255 tvp5150_read(c, TVP5150_FIFO_RESET));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800256 printk("tvp5150: Line number interrupt = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200257 tvp5150_read(c, TVP5150_LINE_NUMBER_INT));
258 printk("tvp5150: Pixel alignment register = 0x%02x%02x\n",
259 tvp5150_read(c, TVP5150_PIX_ALIGN_REG_HIGH),
260 tvp5150_read(c, TVP5150_PIX_ALIGN_REG_LOW));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800261 printk("tvp5150: FIFO output control = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200262 tvp5150_read(c, TVP5150_FIFO_OUT_CTRL));
263 printk("tvp5150: Full field enable = 0x%02x\n",
264 tvp5150_read(c, TVP5150_FULL_FIELD_ENA));
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800265 printk("tvp5150: Full field mode register = 0x%02x\n",
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200266 tvp5150_read(c, TVP5150_FULL_FIELD_MODE_REG));
267
268 dump_reg_range(c,"CC data", TVP5150_CC_DATA_INI,
269 TVP5150_CC_DATA_END,8);
270
271 dump_reg_range(c,"WSS data", TVP5150_WSS_DATA_INI,
272 TVP5150_WSS_DATA_END,8);
273
274 dump_reg_range(c,"VPS data", TVP5150_VPS_DATA_INI,
275 TVP5150_VPS_DATA_END,8);
276
277 dump_reg_range(c,"VITC data", TVP5150_VITC_DATA_INI,
278 TVP5150_VITC_DATA_END,10);
279
280 dump_reg_range(c,"Line mode", TVP5150_LINE_MODE_INI,
281 TVP5150_LINE_MODE_END,8);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800282}
283
284/****************************************************************************
285 Basic functions
286 ****************************************************************************/
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800287
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300288static inline void tvp5150_selmux(struct i2c_client *c)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800289{
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200290 int opmode=0;
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -0800291 struct tvp5150 *decoder = i2c_get_clientdata(c);
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300292 int input = 0;
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800293
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300294 if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable)
295 input = 8;
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -0800296
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200297 switch (input) {
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300298 case TVP5150_COMPOSITE1:
299 input |= 2;
300 /* fall through */
301 case TVP5150_COMPOSITE0:
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200302 opmode=0x30; /* TV Mode */
303 break;
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300304 case TVP5150_SVIDEO:
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200305 default:
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300306 input |= 1;
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200307 opmode=0; /* Auto Mode */
308 break;
309 }
310
311 tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800312 tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800313};
314
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200315struct i2c_reg_value {
316 unsigned char reg;
317 unsigned char value;
318};
319
320/* Default values as sugested at TVP5150AM1 datasheet */
321static const struct i2c_reg_value tvp5150_init_default[] = {
322 { /* 0x00 */
323 TVP5150_VD_IN_SRC_SEL_1,0x00
324 },
325 { /* 0x01 */
326 TVP5150_ANAL_CHL_CTL,0x15
327 },
328 { /* 0x02 */
329 TVP5150_OP_MODE_CTL,0x00
330 },
331 { /* 0x03 */
332 TVP5150_MISC_CTL,0x01
333 },
334 { /* 0x06 */
335 TVP5150_COLOR_KIL_THSH_CTL,0x10
336 },
337 { /* 0x07 */
338 TVP5150_LUMA_PROC_CTL_1,0x60
339 },
340 { /* 0x08 */
341 TVP5150_LUMA_PROC_CTL_2,0x00
342 },
343 { /* 0x09 */
344 TVP5150_BRIGHT_CTL,0x80
345 },
346 { /* 0x0a */
347 TVP5150_SATURATION_CTL,0x80
348 },
349 { /* 0x0b */
350 TVP5150_HUE_CTL,0x00
351 },
352 { /* 0x0c */
353 TVP5150_CONTRAST_CTL,0x80
354 },
355 { /* 0x0d */
356 TVP5150_DATA_RATE_SEL,0x47
357 },
358 { /* 0x0e */
359 TVP5150_LUMA_PROC_CTL_3,0x00
360 },
361 { /* 0x0f */
362 TVP5150_CONF_SHARED_PIN,0x08
363 },
364 { /* 0x11 */
365 TVP5150_ACT_VD_CROP_ST_MSB,0x00
366 },
367 { /* 0x12 */
368 TVP5150_ACT_VD_CROP_ST_LSB,0x00
369 },
370 { /* 0x13 */
371 TVP5150_ACT_VD_CROP_STP_MSB,0x00
372 },
373 { /* 0x14 */
374 TVP5150_ACT_VD_CROP_STP_LSB,0x00
375 },
376 { /* 0x15 */
377 TVP5150_GENLOCK,0x01
378 },
379 { /* 0x16 */
380 TVP5150_HORIZ_SYNC_START,0x80
381 },
382 { /* 0x18 */
383 TVP5150_VERT_BLANKING_START,0x00
384 },
385 { /* 0x19 */
386 TVP5150_VERT_BLANKING_STOP,0x00
387 },
388 { /* 0x1a */
389 TVP5150_CHROMA_PROC_CTL_1,0x0c
390 },
391 { /* 0x1b */
392 TVP5150_CHROMA_PROC_CTL_2,0x14
393 },
394 { /* 0x1c */
395 TVP5150_INT_RESET_REG_B,0x00
396 },
397 { /* 0x1d */
398 TVP5150_INT_ENABLE_REG_B,0x00
399 },
400 { /* 0x1e */
401 TVP5150_INTT_CONFIG_REG_B,0x00
402 },
403 { /* 0x28 */
404 TVP5150_VIDEO_STD,0x00
405 },
406 { /* 0x2e */
407 TVP5150_MACROVISION_ON_CTR,0x0f
408 },
409 { /* 0x2f */
410 TVP5150_MACROVISION_OFF_CTR,0x01
411 },
412 { /* 0xbb */
413 TVP5150_TELETEXT_FIL_ENA,0x00
414 },
415 { /* 0xc0 */
416 TVP5150_INT_STATUS_REG_A,0x00
417 },
418 { /* 0xc1 */
419 TVP5150_INT_ENABLE_REG_A,0x00
420 },
421 { /* 0xc2 */
422 TVP5150_INT_CONF,0x04
423 },
424 { /* 0xc8 */
425 TVP5150_FIFO_INT_THRESHOLD,0x80
426 },
427 { /* 0xc9 */
428 TVP5150_FIFO_RESET,0x00
429 },
430 { /* 0xca */
431 TVP5150_LINE_NUMBER_INT,0x00
432 },
433 { /* 0xcb */
434 TVP5150_PIX_ALIGN_REG_LOW,0x4e
435 },
436 { /* 0xcc */
437 TVP5150_PIX_ALIGN_REG_HIGH,0x00
438 },
439 { /* 0xcd */
440 TVP5150_FIFO_OUT_CTRL,0x01
441 },
442 { /* 0xcf */
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200443 TVP5150_FULL_FIELD_ENA,0x00
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200444 },
445 { /* 0xd0 */
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200446 TVP5150_LINE_MODE_INI,0x00
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200447 },
448 { /* 0xfc */
449 TVP5150_FULL_FIELD_MODE_REG,0x7f
450 },
451 { /* end of data */
452 0xff,0xff
453 }
454};
455
456/* Default values as sugested at TVP5150AM1 datasheet */
457static const struct i2c_reg_value tvp5150_init_enable[] = {
458 {
459 TVP5150_CONF_SHARED_PIN, 2
460 },{ /* Automatic offset and AGC enabled */
461 TVP5150_ANAL_CHL_CTL, 0x15
462 },{ /* Activate YCrCb output 0x9 or 0xd ? */
463 TVP5150_MISC_CTL, 0x6f
464 },{ /* Activates video std autodetection for all standards */
465 TVP5150_AUTOSW_MSK, 0x0
466 },{ /* Default format: 0x47. For 4:2:2: 0x40 */
467 TVP5150_DATA_RATE_SEL, 0x47
468 },{
469 TVP5150_CHROMA_PROC_CTL_1, 0x0c
470 },{
471 TVP5150_CHROMA_PROC_CTL_2, 0x54
472 },{ /* Non documented, but initialized on WinTV USB2 */
473 0x27, 0x20
474 },{
475 0xff,0xff
476 }
477};
478
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200479struct tvp5150_vbi_type {
480 unsigned int vbi_type;
481 unsigned int ini_line;
482 unsigned int end_line;
483 unsigned int by_field :1;
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200484};
485
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200486struct i2c_vbi_ram_value {
487 u16 reg;
488 struct tvp5150_vbi_type type;
489 unsigned char values[16];
490};
491
492/* This struct have the values for each supported VBI Standard
493 * by
494 tvp5150_vbi_types should follow the same order as vbi_ram_default
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200495 * value 0 means rom position 0x10, value 1 means rom position 0x30
496 * and so on. There are 16 possible locations from 0 to 15.
497 */
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200498
Adrian Bunka9cff902006-01-15 06:56:15 -0200499static struct i2c_vbi_ram_value vbi_ram_default[] =
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200500{
Hans Verkuil9bc74002006-03-29 18:02:51 -0300501 /* FIXME: Current api doesn't handle all VBI types, those not
502 yet supported are placed under #if 0 */
503#if 0
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200504 {0x010, /* Teletext, SECAM, WST System A */
505 {V4L2_SLICED_TELETEXT_SECAM,6,23,1},
506 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26,
507 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200508 },
Hans Verkuil9bc74002006-03-29 18:02:51 -0300509#endif
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200510 {0x030, /* Teletext, PAL, WST System B */
Hans Verkuil9bc74002006-03-29 18:02:51 -0300511 {V4L2_SLICED_TELETEXT_B,6,22,1},
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200512 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b,
513 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200514 },
Hans Verkuil9bc74002006-03-29 18:02:51 -0300515#if 0
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200516 {0x050, /* Teletext, PAL, WST System C */
517 {V4L2_SLICED_TELETEXT_PAL_C,6,22,1},
518 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
519 0xa6, 0x98, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200520 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200521 {0x070, /* Teletext, NTSC, WST System B */
522 {V4L2_SLICED_TELETEXT_NTSC_B,10,21,1},
523 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x23,
524 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200525 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200526 {0x090, /* Tetetext, NTSC NABTS System C */
527 {V4L2_SLICED_TELETEXT_NTSC_C,10,21,1},
528 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
529 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x15, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200530 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200531 {0x0b0, /* Teletext, NTSC-J, NABTS System D */
532 {V4L2_SLICED_TELETEXT_NTSC_D,10,21,1},
533 { 0xaa, 0xaa, 0xff, 0xff, 0xa7, 0x2e, 0x20, 0x23,
534 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200535 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200536 {0x0d0, /* Closed Caption, PAL/SECAM */
537 {V4L2_SLICED_CAPTION_625,22,22,1},
538 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
539 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200540 },
Hans Verkuil9bc74002006-03-29 18:02:51 -0300541#endif
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200542 {0x0f0, /* Closed Caption, NTSC */
543 {V4L2_SLICED_CAPTION_525,21,21,1},
544 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
545 0x69, 0x8c, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200546 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200547 {0x110, /* Wide Screen Signal, PAL/SECAM */
Mauro Carvalho Chehab12db5602006-01-23 17:11:08 -0200548 {V4L2_SLICED_WSS_625,23,23,1},
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200549 { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42,
550 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200551 },
Hans Verkuil9bc74002006-03-29 18:02:51 -0300552#if 0
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200553 {0x130, /* Wide Screen Signal, NTSC C */
554 {V4L2_SLICED_WSS_525,20,20,1},
555 { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43,
556 0x69, 0x7c, 0x08, 0x00, 0x00, 0x00, 0x39, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200557 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200558 {0x150, /* Vertical Interval Timecode (VITC), PAL/SECAM */
559 {V4l2_SLICED_VITC_625,6,22,0},
560 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
561 0xa6, 0x85, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200562 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200563 {0x170, /* Vertical Interval Timecode (VITC), NTSC */
564 {V4l2_SLICED_VITC_525,10,20,0},
565 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
566 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200567 },
Hans Verkuil9bc74002006-03-29 18:02:51 -0300568#endif
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200569 {0x190, /* Video Program System (VPS), PAL */
570 {V4L2_SLICED_VPS,16,16,0},
571 { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d,
572 0xa6, 0xda, 0x0b, 0x00, 0x00, 0x00, 0x60, 0x00 }
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200573 },
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200574 /* 0x1d0 User programmable */
575
576 /* End of struct */
577 { (u16)-1 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200578};
579
580static int tvp5150_write_inittab(struct i2c_client *c,
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200581 const struct i2c_reg_value *regs)
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200582{
583 while (regs->reg != 0xff) {
584 tvp5150_write(c, regs->reg, regs->value);
585 regs++;
586 }
587 return 0;
588}
589
590static int tvp5150_vdp_init(struct i2c_client *c,
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200591 const struct i2c_vbi_ram_value *regs)
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200592{
593 unsigned int i;
594
595 /* Disable Full Field */
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200596 tvp5150_write(c, TVP5150_FULL_FIELD_ENA, 0);
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200597
598 /* Before programming, Line mode should be at 0xff */
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200599 for (i=TVP5150_LINE_MODE_INI; i<=TVP5150_LINE_MODE_END; i++)
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200600 tvp5150_write(c, i, 0xff);
601
602 /* Load Ram Table */
603 while (regs->reg != (u16)-1 ) {
604 tvp5150_write(c, TVP5150_CONF_RAM_ADDR_HIGH,regs->reg>>8);
605 tvp5150_write(c, TVP5150_CONF_RAM_ADDR_LOW,regs->reg);
606
607 for (i=0;i<16;i++)
608 tvp5150_write(c, TVP5150_VDP_CONF_RAM_DATA,regs->values[i]);
609
610 regs++;
611 }
612 return 0;
613}
614
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200615/* Fills VBI capabilities based on i2c_vbi_ram_value struct */
616static void tvp5150_vbi_get_cap(const struct i2c_vbi_ram_value *regs,
617 struct v4l2_sliced_vbi_cap *cap)
618{
619 int line;
620
621 memset(cap, 0, sizeof *cap);
622
623 while (regs->reg != (u16)-1 ) {
624 for (line=regs->type.ini_line;line<=regs->type.end_line;line++) {
625 cap->service_lines[0][line] |= regs->type.vbi_type;
626 }
627 cap->service_set |= regs->type.vbi_type;
628
629 regs++;
630 }
631}
632
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200633/* Set vbi processing
634 * type - one of tvp5150_vbi_types
635 * line - line to gather data
636 * fields: bit 0 field1, bit 1, field2
637 * flags (default=0xf0) is a bitmask, were set means:
638 * bit 7: enable filtering null bytes on CC
639 * bit 6: send data also to FIFO
640 * bit 5: don't allow data with errors on FIFO
641 * bit 4: enable ECC when possible
642 * pix_align = pix alignment:
643 * LSB = field1
644 * MSB = field2
645 */
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200646static int tvp5150_set_vbi(struct i2c_client *c,
647 const struct i2c_vbi_ram_value *regs,
648 unsigned int type,u8 flags, int line,
649 const int fields)
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200650{
651 struct tvp5150 *decoder = i2c_get_clientdata(c);
652 v4l2_std_id std=decoder->norm;
653 u8 reg;
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200654 int pos=0;
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200655
656 if (std == V4L2_STD_ALL) {
657 tvp5150_err("VBI can't be configured without knowing number of lines\n");
Mauro Carvalho Chehab12db5602006-01-23 17:11:08 -0200658 return 0;
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200659 } else if (std && V4L2_STD_625_50) {
660 /* Don't follow NTSC Line number convension */
661 line += 3;
662 }
663
664 if (line<6||line>27)
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200665 return 0;
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200666
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200667 while (regs->reg != (u16)-1 ) {
668 if ((type & regs->type.vbi_type) &&
669 (line>=regs->type.ini_line) &&
670 (line<=regs->type.end_line)) {
671 type=regs->type.vbi_type;
672 break;
673 }
674
675 regs++;
676 pos++;
677 }
678 if (regs->reg == (u16)-1)
679 return 0;
680
681 type=pos | (flags & 0xf0);
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200682 reg=((line-6)<<1)+TVP5150_LINE_MODE_INI;
683
684 if (fields&1) {
685 tvp5150_write(c, reg, type);
686 }
687
688 if (fields&2) {
689 tvp5150_write(c, reg+1, type);
690 }
691
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200692 return type;
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -0200693}
694
Mauro Carvalho Chehab12db5602006-01-23 17:11:08 -0200695static int tvp5150_get_vbi(struct i2c_client *c,
696 const struct i2c_vbi_ram_value *regs, int line)
697{
698 struct tvp5150 *decoder = i2c_get_clientdata(c);
699 v4l2_std_id std=decoder->norm;
700 u8 reg;
701 int pos, type=0;
702
703 if (std == V4L2_STD_ALL) {
704 tvp5150_err("VBI can't be configured without knowing number of lines\n");
705 return 0;
706 } else if (std && V4L2_STD_625_50) {
707 /* Don't follow NTSC Line number convension */
708 line += 3;
709 }
710
711 if (line<6||line>27)
712 return 0;
713
714 reg=((line-6)<<1)+TVP5150_LINE_MODE_INI;
715
716 pos=tvp5150_read(c, reg)&0x0f;
717 if (pos<0x0f)
718 type=regs[pos].type.vbi_type;
719
720 pos=tvp5150_read(c, reg+1)&0x0f;
721 if (pos<0x0f)
722 type|=regs[pos].type.vbi_type;
723
724 return type;
725}
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200726static int tvp5150_set_std(struct i2c_client *c, v4l2_std_id std)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800727{
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -0800728 struct tvp5150 *decoder = i2c_get_clientdata(c);
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200729 int fmt=0;
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -0800730
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200731 decoder->norm=std;
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800732
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200733 /* First tests should be against specific std */
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800734
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200735 if (std == V4L2_STD_ALL) {
736 fmt=0; /* Autodetect mode */
737 } else if (std & V4L2_STD_NTSC_443) {
738 fmt=0xa;
739 } else if (std & V4L2_STD_PAL_M) {
740 fmt=0x6;
741 } else if (std & (V4L2_STD_PAL_N| V4L2_STD_PAL_Nc)) {
742 fmt=0x8;
743 } else {
744 /* Then, test against generic ones */
745 if (std & V4L2_STD_NTSC) {
746 fmt=0x2;
747 } else if (std & V4L2_STD_PAL) {
748 fmt=0x4;
749 } else if (std & V4L2_STD_SECAM) {
750 fmt=0xc;
751 }
752 }
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800753
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200754 tvp5150_dbg(1,"Set video std register to %d.\n",fmt);
755 tvp5150_write(c, TVP5150_VIDEO_STD, fmt);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800756
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200757 return 0;
758}
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800759
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200760static inline void tvp5150_reset(struct i2c_client *c)
761{
Mauro Carvalho Chehabe36eaa72006-01-23 09:48:34 -0200762 u8 msb_id, lsb_id, msb_rom, lsb_rom;
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200763 struct tvp5150 *decoder = i2c_get_clientdata(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800764
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200765 msb_id=tvp5150_read(c,TVP5150_MSB_DEV_ID);
766 lsb_id=tvp5150_read(c,TVP5150_LSB_DEV_ID);
767 msb_rom=tvp5150_read(c,TVP5150_ROM_MAJOR_VER);
768 lsb_rom=tvp5150_read(c,TVP5150_ROM_MINOR_VER);
769
Mauro Carvalho Chehabe36eaa72006-01-23 09:48:34 -0200770 if ((msb_rom==4)&&(lsb_rom==0)) { /* Is TVP5150AM1 */
771 tvp5150_info("tvp%02x%02xam1 detected.\n",msb_id, lsb_id);
772
773 /* ITU-T BT.656.4 timing */
774 tvp5150_write(c,TVP5150_REV_SELECT,0);
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200775 } else {
Mauro Carvalho Chehabe36eaa72006-01-23 09:48:34 -0200776 if ((msb_rom==3)||(lsb_rom==0x21)) { /* Is TVP5150A */
777 tvp5150_info("tvp%02x%02xa detected.\n",msb_id, lsb_id);
778 } else {
779 tvp5150_info("*** unknown tvp%02x%02x chip detected.\n",msb_id,lsb_id);
780 tvp5150_info("*** Rom ver is %d.%d\n",msb_rom,lsb_rom);
781 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200782 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200783
784 /* Initializes TVP5150 to its default values */
785 tvp5150_write_inittab(c, tvp5150_init_default);
786
787 /* Initializes VDP registers */
788 tvp5150_vdp_init(c, vbi_ram_default);
789
790 /* Selects decoder input */
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300791 tvp5150_selmux(c);
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800792
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200793 /* Initializes TVP5150 to stream enabled values */
794 tvp5150_write_inittab(c, tvp5150_init_enable);
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800795
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200796 /* Initialize image preferences */
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -0800797 tvp5150_write(c, TVP5150_BRIGHT_CTL, decoder->bright >> 8);
798 tvp5150_write(c, TVP5150_CONTRAST_CTL, decoder->contrast >> 8);
799 tvp5150_write(c, TVP5150_SATURATION_CTL, decoder->contrast >> 8);
800 tvp5150_write(c, TVP5150_HUE_CTL, (decoder->hue - 32768) >> 8);
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200801
802 tvp5150_set_std(c, decoder->norm);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -0800803};
804
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800805static int tvp5150_get_ctrl(struct i2c_client *c, struct v4l2_control *ctrl)
806{
807/* struct tvp5150 *decoder = i2c_get_clientdata(c); */
808
809 switch (ctrl->id) {
810 case V4L2_CID_BRIGHTNESS:
811 ctrl->value = tvp5150_read(c, TVP5150_BRIGHT_CTL);
812 return 0;
813 case V4L2_CID_CONTRAST:
814 ctrl->value = tvp5150_read(c, TVP5150_CONTRAST_CTL);
815 return 0;
816 case V4L2_CID_SATURATION:
817 ctrl->value = tvp5150_read(c, TVP5150_SATURATION_CTL);
818 return 0;
819 case V4L2_CID_HUE:
820 ctrl->value = tvp5150_read(c, TVP5150_HUE_CTL);
821 return 0;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800822 }
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200823 return -EINVAL;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800824}
825
826static int tvp5150_set_ctrl(struct i2c_client *c, struct v4l2_control *ctrl)
827{
828/* struct tvp5150 *decoder = i2c_get_clientdata(c); */
829
830 switch (ctrl->id) {
831 case V4L2_CID_BRIGHTNESS:
832 tvp5150_write(c, TVP5150_BRIGHT_CTL, ctrl->value);
833 return 0;
834 case V4L2_CID_CONTRAST:
835 tvp5150_write(c, TVP5150_CONTRAST_CTL, ctrl->value);
836 return 0;
837 case V4L2_CID_SATURATION:
838 tvp5150_write(c, TVP5150_SATURATION_CTL, ctrl->value);
839 return 0;
840 case V4L2_CID_HUE:
841 tvp5150_write(c, TVP5150_HUE_CTL, ctrl->value);
842 return 0;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800843 }
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200844 return -EINVAL;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800845}
846
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800847/****************************************************************************
848 I2C Command
849 ****************************************************************************/
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200850static int tvp5150_command(struct i2c_client *c,
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800851 unsigned int cmd, void *arg)
852{
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200853 struct tvp5150 *decoder = i2c_get_clientdata(c);
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800854
855 switch (cmd) {
856
857 case 0:
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200858 case VIDIOC_INT_RESET:
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200859 tvp5150_reset(c);
860 break;
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300861 case VIDIOC_INT_G_VIDEO_ROUTING:
862 {
863 struct v4l2_routing *route = arg;
864
865 *route = decoder->route;
866 break;
867 }
868 case VIDIOC_INT_S_VIDEO_ROUTING:
869 {
870 struct v4l2_routing *route = arg;
871
872 decoder->route = *route;
873 tvp5150_selmux(c);
874 break;
875 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200876 case VIDIOC_S_STD:
877 if (decoder->norm == *(v4l2_std_id *)arg)
878 break;
879 return tvp5150_set_std(c, *(v4l2_std_id *)arg);
880 case VIDIOC_G_STD:
881 *(v4l2_std_id *)arg = decoder->norm;
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800882 break;
883
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200884 case VIDIOC_G_SLICED_VBI_CAP:
885 {
886 struct v4l2_sliced_vbi_cap *cap = arg;
887 tvp5150_dbg(1, "VIDIOC_G_SLICED_VBI_CAP\n");
888
889 tvp5150_vbi_get_cap(vbi_ram_default, cap);
890 break;
891 }
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200892 case VIDIOC_S_FMT:
893 {
894 struct v4l2_format *fmt;
895 struct v4l2_sliced_vbi_format *svbi;
896 int i;
Mauro Carvalho Chehab6ac48b42006-01-23 17:11:05 -0200897
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200898 fmt = arg;
899 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
900 return -EINVAL;
901 svbi = &fmt->fmt.sliced;
902 if (svbi->service_set != 0) {
903 for (i = 0; i <= 23; i++) {
904 svbi->service_lines[1][i] = 0;
905
906 svbi->service_lines[0][i]=tvp5150_set_vbi(c,
907 vbi_ram_default,
908 svbi->service_lines[0][i],0xf0,i,3);
909 }
Mauro Carvalho Chehab12db5602006-01-23 17:11:08 -0200910 /* Enables FIFO */
911 tvp5150_write(c, TVP5150_FIFO_OUT_CTRL,1);
912 } else {
913 /* Disables FIFO*/
914 tvp5150_write(c, TVP5150_FIFO_OUT_CTRL,0);
915
916 /* Disable Full Field */
917 tvp5150_write(c, TVP5150_FULL_FIELD_ENA, 0);
918
919 /* Disable Line modes */
920 for (i=TVP5150_LINE_MODE_INI; i<=TVP5150_LINE_MODE_END; i++)
921 tvp5150_write(c, i, 0xff);
Mauro Carvalho Chehab2701dac2006-01-23 17:11:06 -0200922 }
923 break;
924 }
Mauro Carvalho Chehab12db5602006-01-23 17:11:08 -0200925 case VIDIOC_G_FMT:
926 {
927 struct v4l2_format *fmt;
928 struct v4l2_sliced_vbi_format *svbi;
929
930 int i, mask=0;
931
932 fmt = arg;
933 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
934 return -EINVAL;
935 svbi = &fmt->fmt.sliced;
936 memset(svbi, 0, sizeof(*svbi));
937
938 for (i = 0; i <= 23; i++) {
939 svbi->service_lines[0][i]=tvp5150_get_vbi(c,
940 vbi_ram_default,i);
941 mask|=svbi->service_lines[0][i];
942 }
943 svbi->service_set=mask;
944 break;
945 }
946
Mauro Carvalho Chehab21dcd8c2006-01-09 15:25:37 -0200947#ifdef CONFIG_VIDEO_ADV_DEBUG
948 case VIDIOC_INT_G_REGISTER:
949 {
950 struct v4l2_register *reg = arg;
951
952 if (reg->i2c_id != I2C_DRIVERID_TVP5150)
953 return -EINVAL;
954 reg->val = tvp5150_read(c, reg->reg & 0xff);
955 break;
956 }
957
958 case VIDIOC_INT_S_REGISTER:
959 {
960 struct v4l2_register *reg = arg;
961
962 if (reg->i2c_id != I2C_DRIVERID_TVP5150)
963 return -EINVAL;
964 if (!capable(CAP_SYS_ADMIN))
965 return -EPERM;
966 tvp5150_write(c, reg->reg & 0xff, reg->val & 0xff);
967 break;
968 }
969#endif
970
Mauro Carvalho Chehab12db5602006-01-23 17:11:08 -0200971 case VIDIOC_LOG_STATUS:
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200972 dump_reg(c);
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800973 break;
974
Hans Verkuilab4cecf2006-04-01 16:40:21 -0300975 case VIDIOC_G_TUNER:
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800976 {
Hans Verkuilab4cecf2006-04-01 16:40:21 -0300977 struct v4l2_tuner *vt = arg;
978 int status = tvp5150_read(c, 0x88);
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800979
Hans Verkuilab4cecf2006-04-01 16:40:21 -0300980 vt->signal = ((status & 0x04) && (status & 0x02)) ? 0xffff : 0x0;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800981 break;
982 }
983 case VIDIOC_QUERYCTRL:
984 {
985 struct v4l2_queryctrl *qc = arg;
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200986 int i;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800987
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -0200988 tvp5150_dbg(1, "VIDIOC_QUERYCTRL called\n");
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800989
Mauro Carvalho Chehabc0477ad2006-01-09 15:25:14 -0200990 for (i = 0; i < ARRAY_SIZE(tvp5150_qctrl); i++)
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800991 if (qc->id && qc->id == tvp5150_qctrl[i].id) {
992 memcpy(qc, &(tvp5150_qctrl[i]),
993 sizeof(*qc));
994 return 0;
995 }
996
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -0800997 return -EINVAL;
998 }
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800999 case VIDIOC_G_CTRL:
1000 {
1001 struct v4l2_control *ctrl = arg;
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001002 tvp5150_dbg(1, "VIDIOC_G_CTRL called\n");
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -08001003
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001004 return tvp5150_get_ctrl(c, ctrl);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001005 }
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001006 case VIDIOC_S_CTRL:
1007 {
1008 struct v4l2_control *ctrl = arg;
1009 u8 i, n;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001010 n = sizeof(tvp5150_qctrl) / sizeof(tvp5150_qctrl[0]);
1011 for (i = 0; i < n; i++)
1012 if (ctrl->id == tvp5150_qctrl[i].id) {
1013 if (ctrl->value <
1014 tvp5150_qctrl[i].minimum
1015 || ctrl->value >
1016 tvp5150_qctrl[i].maximum)
1017 return -ERANGE;
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001018 tvp5150_dbg(1,
1019 "VIDIOC_S_CTRL: id=%d, value=%d\n",
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001020 ctrl->id, ctrl->value);
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001021 return tvp5150_set_ctrl(c, ctrl);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001022 }
1023 return -EINVAL;
1024 }
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -08001025
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -08001026 default:
1027 return -EINVAL;
1028 }
1029
1030 return 0;
1031}
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001032
1033/****************************************************************************
1034 I2C Client & Driver
1035 ****************************************************************************/
1036static struct i2c_driver driver;
1037
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001038static struct i2c_client client_template = {
1039 .name = "(unset)",
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001040 .driver = &driver,
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001041};
1042
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001043static int tvp5150_detect_client(struct i2c_adapter *adapter,
1044 int address, int kind)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001045{
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001046 struct i2c_client *c;
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001047 struct tvp5150 *core;
1048 int rv;
1049
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001050 if (debug)
1051 printk( KERN_INFO
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001052 "tvp5150.c: detecting tvp5150 client on address 0x%x\n",
1053 address << 1);
1054
1055 client_template.adapter = adapter;
1056 client_template.addr = address;
1057
1058 /* Check if the adapter supports the needed features */
1059 if (!i2c_check_functionality
1060 (adapter,
1061 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
1062 return 0;
1063
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001064 c = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
1065 if (c == 0)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001066 return -ENOMEM;
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001067 memcpy(c, &client_template, sizeof(struct i2c_client));
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001068
Panagiotis Issaris74081872006-01-11 19:40:56 -02001069 core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001070 if (core == 0) {
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001071 kfree(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001072 return -ENOMEM;
1073 }
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001074 i2c_set_clientdata(c, core);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001075
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001076 rv = i2c_attach_client(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001077
Mauro Carvalho Chehab3ad96832006-01-23 17:11:05 -02001078 core->norm = V4L2_STD_ALL; /* Default is autodetect */
Hans Verkuilc7c0b342006-04-02 13:35:00 -03001079 core->route.input = TVP5150_COMPOSITE1;
Mauro Carvalho Chehab4c86f972005-11-08 21:36:43 -08001080 core->enable = 1;
1081 core->bright = 32768;
1082 core->contrast = 32768;
1083 core->hue = 32768;
1084 core->sat = 32768;
1085
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001086 if (rv) {
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001087 kfree(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001088 kfree(core);
1089 return rv;
1090 }
1091
Markus Rechbergerf1e5ee42006-02-07 04:01:19 +01001092 if (debug > 1)
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001093 dump_reg(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001094 return 0;
1095}
1096
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001097static int tvp5150_attach_adapter(struct i2c_adapter *adapter)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001098{
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001099 if (debug)
1100 printk( KERN_INFO
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001101 "tvp5150.c: starting probe for adapter %s (0x%x)\n",
1102 adapter->name, adapter->id);
1103 return i2c_probe(adapter, &addr_data, &tvp5150_detect_client);
1104}
1105
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001106static int tvp5150_detach_client(struct i2c_client *c)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001107{
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001108 struct tvp5150 *decoder = i2c_get_clientdata(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001109 int err;
1110
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001111 tvp5150_dbg(1,
1112 "tvp5150.c: removing tvp5150 adapter on address 0x%x\n",
1113 c->addr << 1);
1114
1115 err = i2c_detach_client(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001116 if (err) {
1117 return err;
1118 }
1119
1120 kfree(decoder);
Mauro Carvalho Chehabe1bc80a2006-01-09 15:25:36 -02001121 kfree(c);
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001122
1123 return 0;
1124}
1125
1126/* ----------------------------------------------------------------------- */
1127
1128static struct i2c_driver driver = {
Laurent Riffard604f28e2005-11-26 20:43:39 +01001129 .driver = {
Laurent Riffard604f28e2005-11-26 20:43:39 +01001130 .name = "tvp5150",
1131 },
Mauro Carvalho Chehabcab462f2006-01-09 15:53:26 -02001132 .id = I2C_DRIVERID_TVP5150,
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001133
1134 .attach_adapter = tvp5150_attach_adapter,
1135 .detach_client = tvp5150_detach_client,
Mauro Carvalho Chehab84486d52005-11-08 21:36:41 -08001136
1137 .command = tvp5150_command,
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001138};
1139
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001140static int __init tvp5150_init(void)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001141{
1142 return i2c_add_driver(&driver);
1143}
1144
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001145static void __exit tvp5150_exit(void)
Mauro Carvalho Chehabcd4665c2005-11-08 21:36:40 -08001146{
1147 i2c_del_driver(&driver);
1148}
1149
1150module_init(tvp5150_init);
1151module_exit(tvp5150_exit);