[PATCH] v4l: 673: initial code for texas instruments tvp5150a and tvp5150am1
[deliverable/linux.git] / drivers / media / video / tvp5150.c
CommitLineData
cd4665c5
MCC
1/*
2 * tvp5150 - Texas Instruments TVP5150A(M) video decoder driver
3 *
4 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br)
5 * This code is placed under the terms of the GNU General Public License
6 */
7
8#include <linux/videodev.h>
9#include <linux/i2c.h>
10#include <linux/videodev.h>
11#include <linux/delay.h>
12
13#include "tvp5150_reg.h"
14
15MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver");/* standard i2c insmod options */
16MODULE_AUTHOR("Mauro Carvalho Chehab");
17MODULE_LICENSE("GPL");
18
19static unsigned short normal_i2c[] = {
20 0xb8 >>1,
21 0xba >>1,
22 I2C_CLIENT_END
23};
24
25I2C_CLIENT_INSMOD;
26
27static int debug = 0;
28module_param(debug, int, 0);
29MODULE_PARM_DESC(debug, "Debug level (0-1)");
30
31#define dprintk(num, format, args...) \
32 do { \
33 if (debug >= num) \
34 printk(format , ##args); \
35 } while (0)
36
37struct tvp5150 {
38 struct i2c_client *client;
39};
40
41static inline int tvp5150_read(struct i2c_client *c,unsigned char addr)
42{
43 unsigned char buffer[1];
44 int rc;
45/* struct tvp5150 *core = i2c_get_clientdata(c); */
46
47 buffer[0] = addr;
48 if (1 != (rc = i2c_master_send(c, buffer, 1)))
49 dprintk(0,"i2c i/o error: rc == %d (should be 1)\n", rc);
50
51 msleep(10);
52
53 if (1 != (rc = i2c_master_recv(c, buffer, 1)))
54 dprintk(0,"i2c i/o error: rc == %d (should be 1)\n", rc);
55
56 return (buffer[0]);
57}
58
59static inline void tvp5150_write(struct i2c_client *c,unsigned char addr, unsigned char value)
60{
61 unsigned char buffer[2];
62 int rc;
63/* struct tvp5150 *core = i2c_get_clientdata(c); */
64
65 buffer[0] = addr;
66 buffer[2] = addr;
67 if (2 != (rc = i2c_master_send(c, buffer, 2)))
68 dprintk(0,"i2c i/o error: rc == %d (should be 2)\n", rc);
69}
70
71static void dump_reg (struct i2c_client *c)
72{
73 dprintk (2, "tvp5150: Video input source selection #1 = 0x%02x\n", tvp5150_read(c,TVP5150_VD_IN_SRC_SEL_1));
74 dprintk (2, "tvp5150: Analog channel controls = 0x%02x\n", tvp5150_read(c,TVP5150_ANAL_CHL_CTL));
75 dprintk (2, "tvp5150: Operation mode controls = 0x%02x\n", tvp5150_read(c,TVP5150_OP_MODE_CTL));
76 dprintk (2, "tvp5150: Miscellaneous controls = 0x%02x\n", tvp5150_read(c,TVP5150_MISC_CTL));
77 dprintk (2, "tvp5150: Autoswitch mask: TVP5150A / TVP5150AM = 0x%02x\n", tvp5150_read(c,TVP5150_AUTOSW_MSK));
78 dprintk (2, "tvp5150: Color killer threshold control = 0x%02x\n", tvp5150_read(c,TVP5150_COLOR_KIL_THSH_CTL));
79 dprintk (2, "tvp5150: Luminance processing control #1 = 0x%02x\n", tvp5150_read(c,TVP5150_LUMA_PROC_CTL_1));
80 dprintk (2, "tvp5150: Luminance processing control #2 = 0x%02x\n", tvp5150_read(c,TVP5150_LUMA_PROC_CTL_2));
81 dprintk (2, "tvp5150: Brightness control = 0x%02x\n", tvp5150_read(c,TVP5150_BRIGHT_CTL));
82 dprintk (2, "tvp5150: Color saturation control = 0x%02x\n", tvp5150_read(c,TVP5150_SATURATION_CTL));
83 dprintk (2, "tvp5150: Hue control = 0x%02x\n", tvp5150_read(c,TVP5150_HUE_CTL));
84 dprintk (2, "tvp5150: Contrast control = 0x%02x\n", tvp5150_read(c,TVP5150_CONTRAST_CTL));
85 dprintk (2, "tvp5150: Outputs and data rates select = 0x%02x\n", tvp5150_read(c,TVP5150_DATA_RATE_SEL));
86 dprintk (2, "tvp5150: Luminance processing control #3 = 0x%02x\n", tvp5150_read(c,TVP5150_LUMA_PROC_CTL_3));
87 dprintk (2, "tvp5150: Configuration shared pins = 0x%02x\n", tvp5150_read(c,TVP5150_CONF_SHARED_PIN));
88 dprintk (2, "tvp5150: Active video cropping start MSB = 0x%02x\n", tvp5150_read(c,TVP5150_ACT_VD_CROP_ST_MSB));
89 dprintk (2, "tvp5150: Active video cropping start LSB = 0x%02x\n", tvp5150_read(c,TVP5150_ACT_VD_CROP_ST_LSB));
90 dprintk (2, "tvp5150: Active video cropping stop MSB = 0x%02x\n", tvp5150_read(c,TVP5150_ACT_VD_CROP_STP_MSB));
91 dprintk (2, "tvp5150: Active video cropping stop LSB = 0x%02x\n", tvp5150_read(c,TVP5150_ACT_VD_CROP_STP_LSB));
92 dprintk (2, "tvp5150: Genlock/RTC = 0x%02x\n", tvp5150_read(c,TVP5150_GENLOCK));
93 dprintk (2, "tvp5150: Horizontal sync start = 0x%02x\n", tvp5150_read(c,TVP5150_HORIZ_SYNC_START));
94 dprintk (2, "tvp5150: Vertical blanking start = 0x%02x\n", tvp5150_read(c,TVP5150_VERT_BLANKING_START));
95 dprintk (2, "tvp5150: Vertical blanking stop = 0x%02x\n", tvp5150_read(c,TVP5150_VERT_BLANKING_STOP));
96 dprintk (2, "tvp5150: Chrominance processing control #1 = 0x%02x\n", tvp5150_read(c,TVP5150_CHROMA_PROC_CTL_1));
97 dprintk (2, "tvp5150: Chrominance processing control #2 = 0x%02x\n", tvp5150_read(c,TVP5150_CHROMA_PROC_CTL_2));
98 dprintk (2, "tvp5150: Interrupt reset register B = 0x%02x\n", tvp5150_read(c,TVP5150_INT_RESET_REG_B));
99 dprintk (2, "tvp5150: Interrupt enable register B = 0x%02x\n", tvp5150_read(c,TVP5150_INT_ENABLE_REG_B));
100 dprintk (2, "tvp5150: Interrupt configuration register B = 0x%02x\n", tvp5150_read(c,TVP5150_INTT_CONFIG_REG_B));
101 dprintk (2, "tvp5150: Video standard = 0x%02x\n", tvp5150_read(c,TVP5150_VIDEO_STD));
102 dprintk (2, "tvp5150: Cb gain factor = 0x%02x\n", tvp5150_read(c,TVP5150_CB_GAIN_FACT));
103 dprintk (2, "tvp5150: Cr gain factor = 0x%02x\n", tvp5150_read(c,TVP5150_CR_GAIN_FACTOR));
104 dprintk (2, "tvp5150: Macrovision on counter = 0x%02x\n", tvp5150_read(c,TVP5150_MACROVISION_ON_CTR));
105 dprintk (2, "tvp5150: Macrovision off counter = 0x%02x\n", tvp5150_read(c,TVP5150_MACROVISION_OFF_CTR));
106 dprintk (2, "tvp5150: revision select (TVP5150AM1 only) = 0x%02x\n", tvp5150_read(c,TVP5150_REV_SELECT));
107 dprintk (2, "tvp5150: MSB of device ID = 0x%02x\n", tvp5150_read(c,TVP5150_MSB_DEV_ID));
108 dprintk (2, "tvp5150: LSB of device ID = 0x%02x\n", tvp5150_read(c,TVP5150_LSB_DEV_ID));
109 dprintk (2, "tvp5150: ROM major version = 0x%02x\n", tvp5150_read(c,TVP5150_ROM_MAJOR_VER));
110 dprintk (2, "tvp5150: ROM minor version = 0x%02x\n", tvp5150_read(c,TVP5150_ROM_MINOR_VER));
111 dprintk (2, "tvp5150: Vertical line count MSB = 0x%02x\n", tvp5150_read(c,TVP5150_VERT_LN_COUNT_MSB));
112 dprintk (2, "tvp5150: Vertical line count LSB = 0x%02x\n", tvp5150_read(c,TVP5150_VERT_LN_COUNT_LSB));
113 dprintk (2, "tvp5150: Interrupt status register B = 0x%02x\n", tvp5150_read(c,TVP5150_INT_STATUS_REG_B));
114 dprintk (2, "tvp5150: Interrupt active register B = 0x%02x\n", tvp5150_read(c,TVP5150_INT_ACTIVE_REG_B));
115 dprintk (2, "tvp5150: Status register #1 = 0x%02x\n", tvp5150_read(c,TVP5150_STATUS_REG_1));
116 dprintk (2, "tvp5150: Status register #2 = 0x%02x\n", tvp5150_read(c,TVP5150_STATUS_REG_2));
117 dprintk (2, "tvp5150: Status register #3 = 0x%02x\n", tvp5150_read(c,TVP5150_STATUS_REG_3));
118 dprintk (2, "tvp5150: Status register #4 = 0x%02x\n", tvp5150_read(c,TVP5150_STATUS_REG_4));
119 dprintk (2, "tvp5150: Status register #5 = 0x%02x\n", tvp5150_read(c,TVP5150_STATUS_REG_5));
120 dprintk (2, "tvp5150: Closed caption data registers = 0x%02x\n", tvp5150_read(c,TVP5150_CC_DATA_REG1));
121 dprintk (2, "tvp5150: Closed caption data registers = 0x%02x\n", tvp5150_read(c,TVP5150_CC_DATA_REG2));
122 dprintk (2, "tvp5150: Closed caption data registers = 0x%02x\n", tvp5150_read(c,TVP5150_CC_DATA_REG3));
123 dprintk (2, "tvp5150: Closed caption data registers = 0x%02x\n", tvp5150_read(c,TVP5150_CC_DATA_REG4));
124 dprintk (2, "tvp5150: WSS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_WSS_DATA_REG1));
125 dprintk (2, "tvp5150: WSS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_WSS_DATA_REG2));
126 dprintk (2, "tvp5150: WSS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_WSS_DATA_REG3));
127 dprintk (2, "tvp5150: WSS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_WSS_DATA_REG4));
128 dprintk (2, "tvp5150: WSS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_WSS_DATA_REG5));
129 dprintk (2, "tvp5150: WSS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_WSS_DATA_REG6));
130 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG1));
131 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG2));
132 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG3));
133 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG4));
134 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG5));
135 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG6));
136 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG7));
137 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG8));
138 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG9));
139 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG10));
140 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG11));
141 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG12));
142 dprintk (2, "tvp5150: VPS data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VPS_DATA_REG13));
143 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG1));
144 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG2));
145 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG3));
146 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG4));
147 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG5));
148 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG6));
149 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG7));
150 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG8));
151 dprintk (2, "tvp5150: VITC data registers = 0x%02x\n", tvp5150_read(c,TVP5150_VITC_DATA_REG9));
152 dprintk (2, "tvp5150: VBI FIFO read data = 0x%02x\n", tvp5150_read(c,TVP5150_VBI_FIFO_READ_DATA));
153 dprintk (2, "tvp5150: Teletext filter 1 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_1_1));
154 dprintk (2, "tvp5150: Teletext filter 1 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_1_2));
155 dprintk (2, "tvp5150: Teletext filter 1 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_1_3));
156 dprintk (2, "tvp5150: Teletext filter 1 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_1_4));
157 dprintk (2, "tvp5150: Teletext filter 1 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_1_5));
158 dprintk (2, "tvp5150: Teletext filter 2 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_2_1));
159 dprintk (2, "tvp5150: Teletext filter 2 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_2_2));
160 dprintk (2, "tvp5150: Teletext filter 2 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_2_3));
161 dprintk (2, "tvp5150: Teletext filter 2 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_2_4));
162 dprintk (2, "tvp5150: Teletext filter 2 = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_2_5));
163 dprintk (2, "tvp5150: Teletext filter enable = 0x%02x\n", tvp5150_read(c,TVP5150_TELETEXT_FIL_ENA));
164 dprintk (2, "tvp5150: Interrupt status register A = 0x%02x\n", tvp5150_read(c,TVP5150_INT_STATUS_REG_A));
165 dprintk (2, "tvp5150: Interrupt enable register A = 0x%02x\n", tvp5150_read(c,TVP5150_INT_ENABLE_REG_A));
166 dprintk (2, "tvp5150: Interrupt configuration = 0x%02x\n", tvp5150_read(c,TVP5150_INT_CONF));
167 dprintk (2, "tvp5150: VDP configuration RAM data = 0x%02x\n", tvp5150_read(c,TVP5150_VDP_CONF_RAM_DATA));
168 dprintk (2, "tvp5150: Configuration RAM address low byte = 0x%02x\n", tvp5150_read(c,TVP5150_CONF_RAM_ADDR_LOW));
169 dprintk (2, "tvp5150: Configuration RAM address high byte = 0x%02x\n", tvp5150_read(c,TVP5150_CONF_RAM_ADDR_HIGH));
170 dprintk (2, "tvp5150: VDP status register = 0x%02x\n", tvp5150_read(c,TVP5150_VDP_STATUS_REG));
171 dprintk (2, "tvp5150: FIFO word count = 0x%02x\n", tvp5150_read(c,TVP5150_FIFO_WORD_COUNT));
172 dprintk (2, "tvp5150: FIFO interrupt threshold = 0x%02x\n", tvp5150_read(c,TVP5150_FIFO_INT_THRESHOLD));
173 dprintk (2, "tvp5150: FIFO reset = 0x%02x\n", tvp5150_read(c,TVP5150_FIFO_RESET));
174 dprintk (2, "tvp5150: Line number interrupt = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_NUMBER_INT));
175 dprintk (2, "tvp5150: Pixel alignment register low byte = 0x%02x\n", tvp5150_read(c,TVP5150_PIX_ALIGN_REG_LOW));
176 dprintk (2, "tvp5150: Pixel alignment register high byte = 0x%02x\n", tvp5150_read(c,TVP5150_PIX_ALIGN_REG_HIGH));
177 dprintk (2, "tvp5150: FIFO output control = 0x%02x\n", tvp5150_read(c,TVP5150_FIFO_OUT_CTRL));
178 dprintk (2, "tvp5150: Full field enable 1 = 0x%02x\n", tvp5150_read(c,TVP5150_FULL_FIELD_ENA_1));
179 dprintk (2, "tvp5150: Full field enable 2 = 0x%02x\n", tvp5150_read(c,TVP5150_FULL_FIELD_ENA_2));
180 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_1));
181 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_2));
182 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_3));
183 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_4));
184 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_5));
185 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_6));
186 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_7));
187 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_8));
188 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_9));
189 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_10));
190 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_11));
191 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_12));
192 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_13));
193 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_14));
194 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_15));
195 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_16));
196 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_17));
197 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_18));
198 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_19));
199 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_20));
200 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_21));
201 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_22));
202 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_23));
203 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_24));
204 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_25));
205 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_27));
206 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_28));
207 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_29));
208 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_30));
209 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_31));
210 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_32));
211 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_33));
212 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_34));
213 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_35));
214 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_36));
215 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_37));
216 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_38));
217 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_39));
218 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_40));
219 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_41));
220 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_42));
221 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_43));
222 dprintk (2, "tvp5150: Line mode registers = 0x%02x\n", tvp5150_read(c,TVP5150_LINE_MODE_REG_44));
223 dprintk (2, "tvp5150: Full field mode register = 0x%02x\n", tvp5150_read(c,TVP5150_FULL_FIELD_MODE_REG));
224}
225
226/****************************************************************************
227 Basic functions
228 ****************************************************************************/
229enum tvp5150_input {
230 TVP5150_ANALOG_CH0 = 0,
231 TVP5150_SVIDEO = 1,
232 TVP5150_ANALOG_CH1 = 2,
233 TVP5150_BLACK_SCREEN = 8
234};
235
236static inline void tvp5150_selmux(struct i2c_client *c, enum tvp5150_input input)
237{
238 tvp5150_write(c,TVP5150_VD_IN_SRC_SEL_1,input);
239};
240
241static inline void tvp5150_reset(struct i2c_client *c)
242{
243 /* Automatic offset and AGC enabled*/
244 tvp5150_write(c,TVP5150_ANAL_CHL_CTL,0x15);
245
246 /* Normal Operation */
247 tvp5150_write(c,TVP5150_OP_MODE_CTL,0x00);
248
249 /* Activate YCrCb output 0x9 or 0xd ? */
250 tvp5150_write(c,TVP5150_MISC_CTL,0x09);
251
252 /* Activates video std autodetection for PAL/M and PAL/N */
253 tvp5150_write(c,TVP5150_AUTOSW_MSK,0xf0);
254
255 /* Default format: 0x47, 4:2:2: 0x40 */
256 tvp5150_write(c,TVP5150_DATA_RATE_SEL,0x47);
257
258 tvp5150_selmux(c,TVP5150_ANALOG_CH0);
259};
260
261
262/****************************************************************************
263 I2C Client & Driver
264 ****************************************************************************/
265static struct i2c_driver driver;
266
267static struct i2c_client client_template =
268{
269 .name = "(unset)",
270 .flags = I2C_CLIENT_ALLOW_USE,
271 .driver = &driver,
272};
273
274static int
275tvp5150_detect_client (struct i2c_adapter *adapter,
276 int address,
277 int kind)
278{
279 struct i2c_client *client;
280 struct tvp5150 *core;
281 int rv;
282
283 dprintk(1,
284 KERN_INFO
285 "tvp5150.c: detecting tvp5150 client on address 0x%x\n",
286 address << 1);
287
288 client_template.adapter = adapter;
289 client_template.addr = address;
290
291 /* Check if the adapter supports the needed features */
292 if (!i2c_check_functionality
293 (adapter,
294 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
295 return 0;
296
297 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
298 if (client == 0)
299 return -ENOMEM;
300 memcpy(client,&client_template,sizeof(struct i2c_client));
301
302 core = kmalloc(sizeof(struct tvp5150), GFP_KERNEL);
303 if (core == 0) {
304 kfree(client);
305 return -ENOMEM;
306 }
307 memset(core, 0, sizeof(struct tvp5150));
308 i2c_set_clientdata(client, core);
309
310 rv = i2c_attach_client(client);
311
312 if (rv) {
313 kfree(client);
314 kfree(core);
315 return rv;
316 }
317
318 tvp5150_reset(client);
319 dump_reg (client);
320
321 return 0;
322}
323
324static int
325tvp5150_attach_adapter (struct i2c_adapter *adapter)
326{
327 dprintk(1,
328 KERN_INFO
329 "tvp5150.c: starting probe for adapter %s (0x%x)\n",
330 adapter->name, adapter->id);
331 return i2c_probe(adapter, &addr_data, &tvp5150_detect_client);
332}
333
334static int
335tvp5150_detach_client (struct i2c_client *client)
336{
337 struct tvp5150 *decoder = i2c_get_clientdata(client);
338 int err;
339
340 err = i2c_detach_client(client);
341 if (err) {
342 return err;
343 }
344
345 kfree(decoder);
346 kfree(client);
347
348 return 0;
349}
350
351/* ----------------------------------------------------------------------- */
352
353static struct i2c_driver driver = {
354 .owner = THIS_MODULE,
355 .name = "tvp5150",
356
357 /* FIXME */
358 .id = I2C_DRIVERID_SAA7110,
359 .flags = I2C_DF_NOTIFY,
360
361 .attach_adapter = tvp5150_attach_adapter,
362 .detach_client = tvp5150_detach_client,
363};
364
365static int __init
366tvp5150_init (void)
367{
368 return i2c_add_driver(&driver);
369}
370
371static void __exit
372tvp5150_exit (void)
373{
374 i2c_del_driver(&driver);
375}
376
377module_init(tvp5150_init);
378module_exit(tvp5150_exit);
This page took 0.05387 seconds and 5 git commands to generate.