diff options
author | Igor M. Liplianin <liplianin@me.by> | 2011-09-23 17:33:50 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-09-23 23:07:42 -0400 |
commit | 4e2c53fde651be6225d9f940c02b2eabc2f9591c (patch) | |
tree | 7427afe586aed591065cae6c6737be6f8df932b3 | |
parent | 600836cc7b049f3eb47e9b39f379aa4b0926188a (diff) |
[media] dvb: Add support for pctv452e
Signed-off-by: Igor M. Liplianin <liplianin@me.by>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/dvb-usb/Kconfig | 13 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/Makefile | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 3 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/pctv452e.c | 1093 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/Kconfig | 10 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/lnbp22.c | 148 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/lnbp22.h | 57 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/ttpci-eeprom.c | 29 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/ttpci-eeprom.h | 1 |
10 files changed, 1359 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 2c77382775c1..58257165761e 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -258,6 +258,19 @@ config DVB_USB_AF9005_REMOTE | |||
258 | Say Y here to support the default remote control decoding for the | 258 | Say Y here to support the default remote control decoding for the |
259 | Afatech AF9005 based receiver. | 259 | Afatech AF9005 based receiver. |
260 | 260 | ||
261 | config DVB_USB_PCTV452E | ||
262 | tristate "Pinnacle PCTV HDTV Pro USB device/TT Connect S2-3600" | ||
263 | depends on DVB_USB | ||
264 | select TTPCI_EEPROM | ||
265 | select DVB_LNBP22 if !DVB_FE_CUSTOMISE | ||
266 | select DVB_STB0899 if !DVB_FE_CUSTOMISE | ||
267 | select DVB_STB6100 if !DVB_FE_CUSTOMISE | ||
268 | help | ||
269 | Support for external USB adapter designed by Pinnacle, | ||
270 | shipped under the brand name 'PCTV HDTV Pro USB'. | ||
271 | Also supports TT Connect S2-3600/3650 cards. | ||
272 | Say Y if you own such a device and want to use it. | ||
273 | |||
261 | config DVB_USB_DW2102 | 274 | config DVB_USB_DW2102 |
262 | tristate "DvbWorld & TeVii DVB-S/S2 USB2.0 support" | 275 | tristate "DvbWorld & TeVii DVB-S/S2 USB2.0 support" |
263 | depends on DVB_USB | 276 | depends on DVB_USB |
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 06f75f645963..7d0710bb1978 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile | |||
@@ -64,6 +64,9 @@ obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o | |||
64 | dvb-usb-anysee-objs = anysee.o | 64 | dvb-usb-anysee-objs = anysee.o |
65 | obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o | 65 | obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o |
66 | 66 | ||
67 | dvb-usb-pctv452e-objs = pctv452e.o | ||
68 | obj-$(CONFIG_DVB_USB_PCTV452E) += dvb-usb-pctv452e.o | ||
69 | |||
67 | dvb-usb-dw2102-objs = dw2102.o | 70 | dvb-usb-dw2102-objs = dw2102.o |
68 | obj-$(CONFIG_DVB_USB_DW2102) += dvb-usb-dw2102.o | 71 | obj-$(CONFIG_DVB_USB_DW2102) += dvb-usb-dw2102.o |
69 | 72 | ||
@@ -104,4 +107,5 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o | |||
104 | ccflags-y += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | 107 | ccflags-y += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ |
105 | # due to tuner-xc3028 | 108 | # due to tuner-xc3028 |
106 | ccflags-y += -Idrivers/media/common/tuners | 109 | ccflags-y += -Idrivers/media/common/tuners |
110 | EXTRA_CFLAGS += -Idrivers/media/dvb/ttpci | ||
107 | 111 | ||
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 7433261b229d..2ad33ba92ba2 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -241,6 +241,9 @@ | |||
241 | #define USB_PID_PCTV_200E 0x020e | 241 | #define USB_PID_PCTV_200E 0x020e |
242 | #define USB_PID_PCTV_400E 0x020f | 242 | #define USB_PID_PCTV_400E 0x020f |
243 | #define USB_PID_PCTV_450E 0x0222 | 243 | #define USB_PID_PCTV_450E 0x0222 |
244 | #define USB_PID_PCTV_452E 0x021f | ||
245 | #define USB_PID_TECHNOTREND_CONNECT_S2_3600 0x3007 | ||
246 | #define USB_PID_TECHNOTREND_CONNECT_S2_3650_CI 0x300a | ||
244 | #define USB_PID_NEBULA_DIGITV 0x0201 | 247 | #define USB_PID_NEBULA_DIGITV 0x0201 |
245 | #define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 | 248 | #define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 |
246 | #define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 | 249 | #define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 |
diff --git a/drivers/media/dvb/dvb-usb/pctv452e.c b/drivers/media/dvb/dvb-usb/pctv452e.c new file mode 100644 index 000000000000..9a5c81112807 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/pctv452e.c | |||
@@ -0,0 +1,1093 @@ | |||
1 | /* | ||
2 | * PCTV 452e DVB driver | ||
3 | * | ||
4 | * Copyright (c) 2006-2008 Dominik Kuhlen <dkuhlen@gmx.net> | ||
5 | * | ||
6 | * TT connect S2-3650-CI Common Interface support, MAC readout | ||
7 | * Copyright (C) 2008 Michael H. Schimek <mschimek@gmx.at> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License as | ||
11 | * published by the Free Software Foundation; either version 2 of | ||
12 | * the License, or (at your option) any later version. | ||
13 | */ | ||
14 | |||
15 | /* dvb usb framework */ | ||
16 | #define DVB_USB_LOG_PREFIX "pctv452e" | ||
17 | #include "dvb-usb.h" | ||
18 | |||
19 | /* Demodulator */ | ||
20 | #include "stb0899_drv.h" | ||
21 | #include "stb0899_reg.h" | ||
22 | #include "stb0899_cfg.h" | ||
23 | /* Tuner */ | ||
24 | #include "stb6100.h" | ||
25 | #include "stb6100_cfg.h" | ||
26 | /* FE Power */ | ||
27 | #include "lnbp22.h" | ||
28 | |||
29 | #include "dvb_ca_en50221.h" | ||
30 | #include "ttpci-eeprom.h" | ||
31 | |||
32 | static int debug; | ||
33 | module_param(debug, int, 0644); | ||
34 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | ||
35 | |||
36 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
37 | |||
38 | #define ISOC_INTERFACE_ALTERNATIVE 3 | ||
39 | |||
40 | #define SYNC_BYTE_OUT 0xaa | ||
41 | #define SYNC_BYTE_IN 0x55 | ||
42 | |||
43 | /* guessed: (copied from ttusb-budget) */ | ||
44 | #define PCTV_CMD_RESET 0x15 | ||
45 | /* command to poll IR receiver */ | ||
46 | #define PCTV_CMD_IR 0x1b | ||
47 | /* command to send I2C */ | ||
48 | #define PCTV_CMD_I2C 0x31 | ||
49 | |||
50 | #define I2C_ADDR_STB0899 (0xd0 >> 1) | ||
51 | #define I2C_ADDR_STB6100 (0xc0 >> 1) | ||
52 | #define I2C_ADDR_LNBP22 (0x10 >> 1) | ||
53 | #define I2C_ADDR_24C16 (0xa0 >> 1) | ||
54 | #define I2C_ADDR_24C64 (0xa2 >> 1) | ||
55 | |||
56 | |||
57 | /* pctv452e sends us this amount of data for each issued usb-command */ | ||
58 | #define PCTV_ANSWER_LEN 64 | ||
59 | /* Wait up to 1000ms for device */ | ||
60 | #define PCTV_TIMEOUT 1000 | ||
61 | |||
62 | |||
63 | #define PCTV_LED_GPIO STB0899_GPIO01 | ||
64 | #define PCTV_LED_GREEN 0x82 | ||
65 | #define PCTV_LED_ORANGE 0x02 | ||
66 | |||
67 | #define ci_dbg(format, arg...) \ | ||
68 | do { \ | ||
69 | if (0) \ | ||
70 | printk(KERN_DEBUG DVB_USB_LOG_PREFIX \ | ||
71 | ": " format "\n" , ## arg); \ | ||
72 | } while (0) | ||
73 | |||
74 | enum { | ||
75 | TT3650_CMD_CI_TEST = 0x40, | ||
76 | TT3650_CMD_CI_RD_CTRL, | ||
77 | TT3650_CMD_CI_WR_CTRL, | ||
78 | TT3650_CMD_CI_RD_ATTR, | ||
79 | TT3650_CMD_CI_WR_ATTR, | ||
80 | TT3650_CMD_CI_RESET, | ||
81 | TT3650_CMD_CI_SET_VIDEO_PORT | ||
82 | }; | ||
83 | |||
84 | |||
85 | static struct stb0899_postproc pctv45e_postproc[] = { | ||
86 | { PCTV_LED_GPIO, STB0899_GPIOPULLUP }, | ||
87 | { 0, 0 } | ||
88 | }; | ||
89 | |||
90 | /* | ||
91 | * stores all private variables for communication with the PCTV452e DVB-S2 | ||
92 | */ | ||
93 | struct pctv452e_state { | ||
94 | struct dvb_ca_en50221 ca; | ||
95 | struct mutex ca_mutex; | ||
96 | |||
97 | u8 c; /* transaction counter, wraps around... */ | ||
98 | u8 initialized; /* set to 1 if 0x15 has been sent */ | ||
99 | u16 last_rc_key; | ||
100 | }; | ||
101 | |||
102 | static int tt3650_ci_msg(struct dvb_usb_device *d, u8 cmd, u8 *data, | ||
103 | unsigned int write_len, unsigned int read_len) | ||
104 | { | ||
105 | struct pctv452e_state *state = (struct pctv452e_state *)d->priv; | ||
106 | u8 buf[64]; | ||
107 | u8 id; | ||
108 | unsigned int rlen; | ||
109 | int ret; | ||
110 | |||
111 | BUG_ON(NULL == data && 0 != (write_len | read_len)); | ||
112 | BUG_ON(write_len > 64 - 4); | ||
113 | BUG_ON(read_len > 64 - 4); | ||
114 | |||
115 | id = state->c++; | ||
116 | |||
117 | buf[0] = SYNC_BYTE_OUT; | ||
118 | buf[1] = id; | ||
119 | buf[2] = cmd; | ||
120 | buf[3] = write_len; | ||
121 | |||
122 | memcpy(buf + 4, data, write_len); | ||
123 | |||
124 | rlen = (read_len > 0) ? 64 : 0; | ||
125 | ret = dvb_usb_generic_rw(d, buf, 4 + write_len, | ||
126 | buf, rlen, /* delay_ms */ 0); | ||
127 | if (0 != ret) | ||
128 | goto failed; | ||
129 | |||
130 | ret = -EIO; | ||
131 | if (SYNC_BYTE_IN != buf[0] || id != buf[1]) | ||
132 | goto failed; | ||
133 | |||
134 | memcpy(data, buf + 4, read_len); | ||
135 | |||
136 | return 0; | ||
137 | |||
138 | failed: | ||
139 | err("CI error %d; %02X %02X %02X -> %02X %02X %02X.", | ||
140 | ret, SYNC_BYTE_OUT, id, cmd, buf[0], buf[1], buf[2]); | ||
141 | |||
142 | return ret; | ||
143 | } | ||
144 | |||
145 | static int tt3650_ci_msg_locked(struct dvb_ca_en50221 *ca, | ||
146 | u8 cmd, u8 *data, unsigned int write_len, | ||
147 | unsigned int read_len) | ||
148 | { | ||
149 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | ||
150 | struct pctv452e_state *state = (struct pctv452e_state *)d->priv; | ||
151 | int ret; | ||
152 | |||
153 | mutex_lock(&state->ca_mutex); | ||
154 | ret = tt3650_ci_msg(d, cmd, data, write_len, read_len); | ||
155 | mutex_unlock(&state->ca_mutex); | ||
156 | |||
157 | return ret; | ||
158 | } | ||
159 | |||
160 | static int tt3650_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, | ||
161 | int slot, int address) | ||
162 | { | ||
163 | u8 buf[3]; | ||
164 | int ret; | ||
165 | |||
166 | if (0 != slot) | ||
167 | return -EINVAL; | ||
168 | |||
169 | buf[0] = (address >> 8) & 0x0F; | ||
170 | buf[1] = address; | ||
171 | |||
172 | ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_ATTR, buf, 2, 3); | ||
173 | |||
174 | ci_dbg("%s %04x -> %d 0x%02x", | ||
175 | __func__, address, ret, buf[2]); | ||
176 | |||
177 | if (ret < 0) | ||
178 | return ret; | ||
179 | |||
180 | return buf[2]; | ||
181 | } | ||
182 | |||
183 | static int tt3650_ci_write_attribute_mem(struct dvb_ca_en50221 *ca, | ||
184 | int slot, int address, u8 value) | ||
185 | { | ||
186 | u8 buf[3]; | ||
187 | |||
188 | ci_dbg("%s %d 0x%04x 0x%02x", | ||
189 | __func__, slot, address, value); | ||
190 | |||
191 | if (0 != slot) | ||
192 | return -EINVAL; | ||
193 | |||
194 | buf[0] = (address >> 8) & 0x0F; | ||
195 | buf[1] = address; | ||
196 | buf[2] = value; | ||
197 | |||
198 | return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_ATTR, buf, 3, 3); | ||
199 | } | ||
200 | |||
201 | static int tt3650_ci_read_cam_control(struct dvb_ca_en50221 *ca, | ||
202 | int slot, | ||
203 | u8 address) | ||
204 | { | ||
205 | u8 buf[2]; | ||
206 | int ret; | ||
207 | |||
208 | if (0 != slot) | ||
209 | return -EINVAL; | ||
210 | |||
211 | buf[0] = address & 3; | ||
212 | |||
213 | ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_CTRL, buf, 1, 2); | ||
214 | |||
215 | ci_dbg("%s 0x%02x -> %d 0x%02x", | ||
216 | __func__, address, ret, buf[1]); | ||
217 | |||
218 | if (ret < 0) | ||
219 | return ret; | ||
220 | |||
221 | return buf[1]; | ||
222 | } | ||
223 | |||
224 | static int tt3650_ci_write_cam_control(struct dvb_ca_en50221 *ca, | ||
225 | int slot, | ||
226 | u8 address, | ||
227 | u8 value) | ||
228 | { | ||
229 | u8 buf[2]; | ||
230 | |||
231 | ci_dbg("%s %d 0x%02x 0x%02x", | ||
232 | __func__, slot, address, value); | ||
233 | |||
234 | if (0 != slot) | ||
235 | return -EINVAL; | ||
236 | |||
237 | buf[0] = address; | ||
238 | buf[1] = value; | ||
239 | |||
240 | return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_CTRL, buf, 2, 2); | ||
241 | } | ||
242 | |||
243 | static int tt3650_ci_set_video_port(struct dvb_ca_en50221 *ca, | ||
244 | int slot, | ||
245 | int enable) | ||
246 | { | ||
247 | u8 buf[1]; | ||
248 | int ret; | ||
249 | |||
250 | ci_dbg("%s %d %d", __func__, slot, enable); | ||
251 | |||
252 | if (0 != slot) | ||
253 | return -EINVAL; | ||
254 | |||
255 | enable = !!enable; | ||
256 | buf[0] = enable; | ||
257 | |||
258 | ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1); | ||
259 | if (ret < 0) | ||
260 | return ret; | ||
261 | |||
262 | if (enable != buf[0]) { | ||
263 | err("CI not %sabled.", enable ? "en" : "dis"); | ||
264 | return -EIO; | ||
265 | } | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | static int tt3650_ci_slot_shutdown(struct dvb_ca_en50221 *ca, int slot) | ||
271 | { | ||
272 | return tt3650_ci_set_video_port(ca, slot, /* enable */ 0); | ||
273 | } | ||
274 | |||
275 | static int tt3650_ci_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) | ||
276 | { | ||
277 | return tt3650_ci_set_video_port(ca, slot, /* enable */ 1); | ||
278 | } | ||
279 | |||
280 | static int tt3650_ci_slot_reset(struct dvb_ca_en50221 *ca, int slot) | ||
281 | { | ||
282 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | ||
283 | struct pctv452e_state *state = (struct pctv452e_state *)d->priv; | ||
284 | u8 buf[1]; | ||
285 | int ret; | ||
286 | |||
287 | ci_dbg("%s %d", __func__, slot); | ||
288 | |||
289 | if (0 != slot) | ||
290 | return -EINVAL; | ||
291 | |||
292 | buf[0] = 0; | ||
293 | |||
294 | mutex_lock(&state->ca_mutex); | ||
295 | |||
296 | ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1); | ||
297 | if (0 != ret) | ||
298 | goto failed; | ||
299 | |||
300 | msleep(500); | ||
301 | |||
302 | buf[0] = 1; | ||
303 | |||
304 | ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1); | ||
305 | if (0 != ret) | ||
306 | goto failed; | ||
307 | |||
308 | msleep(500); | ||
309 | |||
310 | buf[0] = 0; /* FTA */ | ||
311 | |||
312 | ret = tt3650_ci_msg(d, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1); | ||
313 | |||
314 | failed: | ||
315 | mutex_unlock(&state->ca_mutex); | ||
316 | |||
317 | return ret; | ||
318 | } | ||
319 | |||
320 | static int tt3650_ci_poll_slot_status(struct dvb_ca_en50221 *ca, | ||
321 | int slot, | ||
322 | int open) | ||
323 | { | ||
324 | u8 buf[1]; | ||
325 | int ret; | ||
326 | |||
327 | if (0 != slot) | ||
328 | return -EINVAL; | ||
329 | |||
330 | ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_TEST, buf, 0, 1); | ||
331 | if (0 != ret) | ||
332 | return ret; | ||
333 | |||
334 | if (1 == buf[0]) | ||
335 | return DVB_CA_EN50221_POLL_CAM_PRESENT | | ||
336 | DVB_CA_EN50221_POLL_CAM_READY; | ||
337 | |||
338 | return 0; | ||
339 | |||
340 | } | ||
341 | |||
342 | static void tt3650_ci_uninit(struct dvb_usb_device *d) | ||
343 | { | ||
344 | struct pctv452e_state *state; | ||
345 | |||
346 | ci_dbg("%s", __func__); | ||
347 | |||
348 | if (NULL == d) | ||
349 | return; | ||
350 | |||
351 | state = (struct pctv452e_state *)d->priv; | ||
352 | if (NULL == state) | ||
353 | return; | ||
354 | |||
355 | if (NULL == state->ca.data) | ||
356 | return; | ||
357 | |||
358 | /* Error ignored. */ | ||
359 | tt3650_ci_set_video_port(&state->ca, /* slot */ 0, /* enable */ 0); | ||
360 | |||
361 | dvb_ca_en50221_release(&state->ca); | ||
362 | |||
363 | memset(&state->ca, 0, sizeof(state->ca)); | ||
364 | } | ||
365 | |||
366 | static int tt3650_ci_init(struct dvb_usb_adapter *a) | ||
367 | { | ||
368 | struct dvb_usb_device *d = a->dev; | ||
369 | struct pctv452e_state *state = (struct pctv452e_state *)d->priv; | ||
370 | int ret; | ||
371 | |||
372 | ci_dbg("%s", __func__); | ||
373 | |||
374 | mutex_init(&state->ca_mutex); | ||
375 | |||
376 | state->ca.owner = THIS_MODULE; | ||
377 | state->ca.read_attribute_mem = tt3650_ci_read_attribute_mem; | ||
378 | state->ca.write_attribute_mem = tt3650_ci_write_attribute_mem; | ||
379 | state->ca.read_cam_control = tt3650_ci_read_cam_control; | ||
380 | state->ca.write_cam_control = tt3650_ci_write_cam_control; | ||
381 | state->ca.slot_reset = tt3650_ci_slot_reset; | ||
382 | state->ca.slot_shutdown = tt3650_ci_slot_shutdown; | ||
383 | state->ca.slot_ts_enable = tt3650_ci_slot_ts_enable; | ||
384 | state->ca.poll_slot_status = tt3650_ci_poll_slot_status; | ||
385 | state->ca.data = d; | ||
386 | |||
387 | ret = dvb_ca_en50221_init(&a->dvb_adap, | ||
388 | &state->ca, | ||
389 | /* flags */ 0, | ||
390 | /* n_slots */ 1); | ||
391 | if (0 != ret) { | ||
392 | err("Cannot initialize CI: Error %d.", ret); | ||
393 | memset(&state->ca, 0, sizeof(state->ca)); | ||
394 | return ret; | ||
395 | } | ||
396 | |||
397 | info("CI initialized."); | ||
398 | |||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | #define CMD_BUFFER_SIZE 0x28 | ||
403 | static int pctv452e_i2c_msg(struct dvb_usb_device *d, u8 addr, | ||
404 | const u8 *snd_buf, u8 snd_len, | ||
405 | u8 *rcv_buf, u8 rcv_len) | ||
406 | { | ||
407 | struct pctv452e_state *state = (struct pctv452e_state *)d->priv; | ||
408 | u8 buf[64]; | ||
409 | u8 id; | ||
410 | int ret; | ||
411 | |||
412 | id = state->c++; | ||
413 | |||
414 | ret = -EINVAL; | ||
415 | if (snd_len > 64 - 7 || rcv_len > 64 - 7) | ||
416 | goto failed; | ||
417 | |||
418 | buf[0] = SYNC_BYTE_OUT; | ||
419 | buf[1] = id; | ||
420 | buf[2] = PCTV_CMD_I2C; | ||
421 | buf[3] = snd_len + 3; | ||
422 | buf[4] = addr << 1; | ||
423 | buf[5] = snd_len; | ||
424 | buf[6] = rcv_len; | ||
425 | |||
426 | memcpy(buf + 7, snd_buf, snd_len); | ||
427 | |||
428 | ret = dvb_usb_generic_rw(d, buf, 7 + snd_len, | ||
429 | buf, /* rcv_len */ 64, | ||
430 | /* delay_ms */ 0); | ||
431 | if (ret < 0) | ||
432 | goto failed; | ||
433 | |||
434 | /* TT USB protocol error. */ | ||
435 | ret = -EIO; | ||
436 | if (SYNC_BYTE_IN != buf[0] || id != buf[1]) | ||
437 | goto failed; | ||
438 | |||
439 | /* I2C device didn't respond as expected. */ | ||
440 | ret = -EREMOTEIO; | ||
441 | if (buf[5] < snd_len || buf[6] < rcv_len) | ||
442 | goto failed; | ||
443 | |||
444 | memcpy(rcv_buf, buf + 7, rcv_len); | ||
445 | |||
446 | return rcv_len; | ||
447 | |||
448 | failed: | ||
449 | err("I2C error %d; %02X %02X %02X %02X %02X -> " | ||
450 | "%02X %02X %02X %02X %02X.", | ||
451 | ret, SYNC_BYTE_OUT, id, addr << 1, snd_len, rcv_len, | ||
452 | buf[0], buf[1], buf[4], buf[5], buf[6]); | ||
453 | |||
454 | return ret; | ||
455 | } | ||
456 | |||
457 | static int pctv452e_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msg, | ||
458 | int num) | ||
459 | { | ||
460 | struct dvb_usb_device *d = i2c_get_adapdata(adapter); | ||
461 | int i; | ||
462 | |||
463 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | ||
464 | return -EAGAIN; | ||
465 | |||
466 | for (i = 0; i < num; i++) { | ||
467 | u8 addr, snd_len, rcv_len, *snd_buf, *rcv_buf; | ||
468 | int ret; | ||
469 | |||
470 | if (msg[i].flags & I2C_M_RD) { | ||
471 | addr = msg[i].addr; | ||
472 | snd_buf = NULL; | ||
473 | snd_len = 0; | ||
474 | rcv_buf = msg[i].buf; | ||
475 | rcv_len = msg[i].len; | ||
476 | } else { | ||
477 | addr = msg[i].addr; | ||
478 | snd_buf = msg[i].buf; | ||
479 | snd_len = msg[i].len; | ||
480 | rcv_buf = NULL; | ||
481 | rcv_len = 0; | ||
482 | } | ||
483 | |||
484 | ret = pctv452e_i2c_msg(d, addr, snd_buf, snd_len, rcv_buf, | ||
485 | rcv_len); | ||
486 | if (ret < rcv_len) | ||
487 | break; | ||
488 | } | ||
489 | |||
490 | mutex_unlock(&d->i2c_mutex); | ||
491 | return i; | ||
492 | } | ||
493 | |||
494 | static u32 pctv452e_i2c_func(struct i2c_adapter *adapter) | ||
495 | { | ||
496 | return I2C_FUNC_I2C; | ||
497 | } | ||
498 | |||
499 | static int pctv452e_power_ctrl(struct dvb_usb_device *d, int i) | ||
500 | { | ||
501 | struct pctv452e_state *state = (struct pctv452e_state *)d->priv; | ||
502 | u8 b0[] = { 0xaa, 0, PCTV_CMD_RESET, 1, 0 }; | ||
503 | u8 rx[PCTV_ANSWER_LEN]; | ||
504 | int ret; | ||
505 | |||
506 | info("%s: %d\n", __func__, i); | ||
507 | |||
508 | if (!i) | ||
509 | return 0; | ||
510 | |||
511 | if (state->initialized) | ||
512 | return 0; | ||
513 | |||
514 | /* hmm where shoud this should go? */ | ||
515 | ret = usb_set_interface(d->udev, 0, ISOC_INTERFACE_ALTERNATIVE); | ||
516 | if (ret != 0) | ||
517 | info("%s: Warning set interface returned: %d\n", | ||
518 | __func__, ret); | ||
519 | |||
520 | /* this is a one-time initialization, dont know where to put */ | ||
521 | b0[1] = state->c++; | ||
522 | /* reset board */ | ||
523 | ret = dvb_usb_generic_rw(d, b0, sizeof(b0), rx, PCTV_ANSWER_LEN, 0); | ||
524 | if (ret) | ||
525 | return ret; | ||
526 | |||
527 | b0[1] = state->c++; | ||
528 | b0[4] = 1; | ||
529 | /* reset board (again?) */ | ||
530 | ret = dvb_usb_generic_rw(d, b0, sizeof(b0), rx, PCTV_ANSWER_LEN, 0); | ||
531 | if (ret) | ||
532 | return ret; | ||
533 | |||
534 | state->initialized = 1; | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
539 | static int pctv452e_rc_query(struct dvb_usb_device *d) | ||
540 | { | ||
541 | struct pctv452e_state *state = (struct pctv452e_state *)d->priv; | ||
542 | u8 b[CMD_BUFFER_SIZE]; | ||
543 | u8 rx[PCTV_ANSWER_LEN]; | ||
544 | int ret, i; | ||
545 | u8 id = state->c++; | ||
546 | |||
547 | /* prepare command header */ | ||
548 | b[0] = SYNC_BYTE_OUT; | ||
549 | b[1] = id; | ||
550 | b[2] = PCTV_CMD_IR; | ||
551 | b[3] = 0; | ||
552 | |||
553 | /* send ir request */ | ||
554 | ret = dvb_usb_generic_rw(d, b, 4, rx, PCTV_ANSWER_LEN, 0); | ||
555 | if (ret != 0) | ||
556 | return ret; | ||
557 | |||
558 | if (debug > 3) { | ||
559 | info("%s: read: %2d: %02x %02x %02x: ", __func__, | ||
560 | ret, rx[0], rx[1], rx[2]); | ||
561 | for (i = 0; (i < rx[3]) && ((i+3) < PCTV_ANSWER_LEN); i++) | ||
562 | info(" %02x", rx[i+3]); | ||
563 | |||
564 | info("\n"); | ||
565 | } | ||
566 | |||
567 | if ((rx[3] == 9) && (rx[12] & 0x01)) { | ||
568 | /* got a "press" event */ | ||
569 | state->last_rc_key = (rx[7] << 8) | rx[6]; | ||
570 | if (debug > 2) | ||
571 | info("%s: cmd=0x%02x sys=0x%02x\n", | ||
572 | __func__, rx[6], rx[7]); | ||
573 | |||
574 | rc_keydown(d->rc_dev, state->last_rc_key, 0); | ||
575 | } else if (state->last_rc_key) { | ||
576 | rc_keyup(d->rc_dev); | ||
577 | state->last_rc_key = 0; | ||
578 | } | ||
579 | |||
580 | return 0; | ||
581 | } | ||
582 | |||
583 | static int pctv452e_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) | ||
584 | { | ||
585 | const u8 mem_addr[] = { 0x1f, 0xcc }; | ||
586 | u8 encoded_mac[20]; | ||
587 | int ret; | ||
588 | |||
589 | ret = -EAGAIN; | ||
590 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | ||
591 | goto failed; | ||
592 | |||
593 | ret = pctv452e_i2c_msg(d, I2C_ADDR_24C16, | ||
594 | mem_addr + 1, /* snd_len */ 1, | ||
595 | encoded_mac, /* rcv_len */ 20); | ||
596 | if (-EREMOTEIO == ret) | ||
597 | /* Caution! A 24C16 interprets 0xA2 0x1F 0xCC as a | ||
598 | byte write if /WC is low. */ | ||
599 | ret = pctv452e_i2c_msg(d, I2C_ADDR_24C64, | ||
600 | mem_addr, 2, | ||
601 | encoded_mac, 20); | ||
602 | |||
603 | mutex_unlock(&d->i2c_mutex); | ||
604 | |||
605 | if (20 != ret) | ||
606 | goto failed; | ||
607 | |||
608 | ret = ttpci_eeprom_decode_mac(mac, encoded_mac); | ||
609 | if (0 != ret) | ||
610 | goto failed; | ||
611 | |||
612 | return 0; | ||
613 | |||
614 | failed: | ||
615 | memset(mac, 0, 6); | ||
616 | |||
617 | return ret; | ||
618 | } | ||
619 | |||
620 | static const struct stb0899_s1_reg pctv452e_init_dev[] = { | ||
621 | { STB0899_DISCNTRL1, 0x26 }, | ||
622 | { STB0899_DISCNTRL2, 0x80 }, | ||
623 | { STB0899_DISRX_ST0, 0x04 }, | ||
624 | { STB0899_DISRX_ST1, 0x20 }, | ||
625 | { STB0899_DISPARITY, 0x00 }, | ||
626 | { STB0899_DISFIFO, 0x00 }, | ||
627 | { STB0899_DISF22, 0x99 }, | ||
628 | { STB0899_DISF22RX, 0x85 }, /* 0xa8 */ | ||
629 | { STB0899_ACRPRESC, 0x11 }, | ||
630 | { STB0899_ACRDIV1, 0x0a }, | ||
631 | { STB0899_ACRDIV2, 0x05 }, | ||
632 | { STB0899_DACR1 , 0x00 }, | ||
633 | { STB0899_DACR2 , 0x00 }, | ||
634 | { STB0899_OUTCFG, 0x00 }, | ||
635 | { STB0899_MODECFG, 0x00 }, /* Inversion */ | ||
636 | { STB0899_IRQMSK_3, 0xf3 }, | ||
637 | { STB0899_IRQMSK_2, 0xfc }, | ||
638 | { STB0899_IRQMSK_1, 0xff }, | ||
639 | { STB0899_IRQMSK_0, 0xff }, | ||
640 | { STB0899_I2CCFG, 0x88 }, | ||
641 | { STB0899_I2CRPT, 0x58 }, | ||
642 | { STB0899_GPIO00CFG, 0x82 }, | ||
643 | { STB0899_GPIO01CFG, 0x82 }, /* LED: 0x02 green, 0x82 orange */ | ||
644 | { STB0899_GPIO02CFG, 0x82 }, | ||
645 | { STB0899_GPIO03CFG, 0x82 }, | ||
646 | { STB0899_GPIO04CFG, 0x82 }, | ||
647 | { STB0899_GPIO05CFG, 0x82 }, | ||
648 | { STB0899_GPIO06CFG, 0x82 }, | ||
649 | { STB0899_GPIO07CFG, 0x82 }, | ||
650 | { STB0899_GPIO08CFG, 0x82 }, | ||
651 | { STB0899_GPIO09CFG, 0x82 }, | ||
652 | { STB0899_GPIO10CFG, 0x82 }, | ||
653 | { STB0899_GPIO11CFG, 0x82 }, | ||
654 | { STB0899_GPIO12CFG, 0x82 }, | ||
655 | { STB0899_GPIO13CFG, 0x82 }, | ||
656 | { STB0899_GPIO14CFG, 0x82 }, | ||
657 | { STB0899_GPIO15CFG, 0x82 }, | ||
658 | { STB0899_GPIO16CFG, 0x82 }, | ||
659 | { STB0899_GPIO17CFG, 0x82 }, | ||
660 | { STB0899_GPIO18CFG, 0x82 }, | ||
661 | { STB0899_GPIO19CFG, 0x82 }, | ||
662 | { STB0899_GPIO20CFG, 0x82 }, | ||
663 | { STB0899_SDATCFG, 0xb8 }, | ||
664 | { STB0899_SCLTCFG, 0xba }, | ||
665 | { STB0899_AGCRFCFG, 0x1c }, /* 0x11 DVB-S; 0x1c DVB-S2 (1c, rjkm) */ | ||
666 | { STB0899_GPIO22, 0x82 }, | ||
667 | { STB0899_GPIO21, 0x91 }, | ||
668 | { STB0899_DIRCLKCFG, 0x82 }, | ||
669 | { STB0899_CLKOUT27CFG, 0x7e }, | ||
670 | { STB0899_STDBYCFG, 0x82 }, | ||
671 | { STB0899_CS0CFG, 0x82 }, | ||
672 | { STB0899_CS1CFG, 0x82 }, | ||
673 | { STB0899_DISEQCOCFG, 0x20 }, | ||
674 | { STB0899_NCOARSE, 0x15 }, /* 0x15 27Mhz, F/3 198MHz, F/6 108MHz */ | ||
675 | { STB0899_SYNTCTRL, 0x00 }, /* 0x00 CLKI, 0x02 XTALI */ | ||
676 | { STB0899_FILTCTRL, 0x00 }, | ||
677 | { STB0899_SYSCTRL, 0x00 }, | ||
678 | { STB0899_STOPCLK1, 0x20 }, /* orig: 0x00 budget-ci: 0x20 */ | ||
679 | { STB0899_STOPCLK2, 0x00 }, | ||
680 | { STB0899_INTBUFCTRL, 0x0a }, | ||
681 | { STB0899_AGC2I1, 0x00 }, | ||
682 | { STB0899_AGC2I2, 0x00 }, | ||
683 | { STB0899_AGCIQIN, 0x00 }, | ||
684 | { STB0899_TSTRES, 0x40 }, /* rjkm */ | ||
685 | { 0xffff, 0xff }, | ||
686 | }; | ||
687 | |||
688 | static const struct stb0899_s1_reg pctv452e_init_s1_demod[] = { | ||
689 | { STB0899_DEMOD, 0x00 }, | ||
690 | { STB0899_RCOMPC, 0xc9 }, | ||
691 | { STB0899_AGC1CN, 0x01 }, | ||
692 | { STB0899_AGC1REF, 0x10 }, | ||
693 | { STB0899_RTC, 0x23 }, | ||
694 | { STB0899_TMGCFG, 0x4e }, | ||
695 | { STB0899_AGC2REF, 0x34 }, | ||
696 | { STB0899_TLSR, 0x84 }, | ||
697 | { STB0899_CFD, 0xf7 }, | ||
698 | { STB0899_ACLC, 0x87 }, | ||
699 | { STB0899_BCLC, 0x94 }, | ||
700 | { STB0899_EQON, 0x41 }, | ||
701 | { STB0899_LDT, 0xf1 }, | ||
702 | { STB0899_LDT2, 0xe3 }, | ||
703 | { STB0899_EQUALREF, 0xb4 }, | ||
704 | { STB0899_TMGRAMP, 0x10 }, | ||
705 | { STB0899_TMGTHD, 0x30 }, | ||
706 | { STB0899_IDCCOMP, 0xfd }, | ||
707 | { STB0899_QDCCOMP, 0xff }, | ||
708 | { STB0899_POWERI, 0x0c }, | ||
709 | { STB0899_POWERQ, 0x0f }, | ||
710 | { STB0899_RCOMP, 0x6c }, | ||
711 | { STB0899_AGCIQIN, 0x80 }, | ||
712 | { STB0899_AGC2I1, 0x06 }, | ||
713 | { STB0899_AGC2I2, 0x00 }, | ||
714 | { STB0899_TLIR, 0x30 }, | ||
715 | { STB0899_RTF, 0x7f }, | ||
716 | { STB0899_DSTATUS, 0x00 }, | ||
717 | { STB0899_LDI, 0xbc }, | ||
718 | { STB0899_CFRM, 0xea }, | ||
719 | { STB0899_CFRL, 0x31 }, | ||
720 | { STB0899_NIRM, 0x2b }, | ||
721 | { STB0899_NIRL, 0x80 }, | ||
722 | { STB0899_ISYMB, 0x1d }, | ||
723 | { STB0899_QSYMB, 0xa6 }, | ||
724 | { STB0899_SFRH, 0x2f }, | ||
725 | { STB0899_SFRM, 0x68 }, | ||
726 | { STB0899_SFRL, 0x40 }, | ||
727 | { STB0899_SFRUPH, 0x2f }, | ||
728 | { STB0899_SFRUPM, 0x68 }, | ||
729 | { STB0899_SFRUPL, 0x40 }, | ||
730 | { STB0899_EQUAI1, 0x02 }, | ||
731 | { STB0899_EQUAQ1, 0xff }, | ||
732 | { STB0899_EQUAI2, 0x04 }, | ||
733 | { STB0899_EQUAQ2, 0x05 }, | ||
734 | { STB0899_EQUAI3, 0x02 }, | ||
735 | { STB0899_EQUAQ3, 0xfd }, | ||
736 | { STB0899_EQUAI4, 0x03 }, | ||
737 | { STB0899_EQUAQ4, 0x07 }, | ||
738 | { STB0899_EQUAI5, 0x08 }, | ||
739 | { STB0899_EQUAQ5, 0xf5 }, | ||
740 | { STB0899_DSTATUS2, 0x00 }, | ||
741 | { STB0899_VSTATUS, 0x00 }, | ||
742 | { STB0899_VERROR, 0x86 }, | ||
743 | { STB0899_IQSWAP, 0x2a }, | ||
744 | { STB0899_ECNT1M, 0x00 }, | ||
745 | { STB0899_ECNT1L, 0x00 }, | ||
746 | { STB0899_ECNT2M, 0x00 }, | ||
747 | { STB0899_ECNT2L, 0x00 }, | ||
748 | { STB0899_ECNT3M, 0x0a }, | ||
749 | { STB0899_ECNT3L, 0xad }, | ||
750 | { STB0899_FECAUTO1, 0x06 }, | ||
751 | { STB0899_FECM, 0x01 }, | ||
752 | { STB0899_VTH12, 0xb0 }, | ||
753 | { STB0899_VTH23, 0x7a }, | ||
754 | { STB0899_VTH34, 0x58 }, | ||
755 | { STB0899_VTH56, 0x38 }, | ||
756 | { STB0899_VTH67, 0x34 }, | ||
757 | { STB0899_VTH78, 0x24 }, | ||
758 | { STB0899_PRVIT, 0xff }, | ||
759 | { STB0899_VITSYNC, 0x19 }, | ||
760 | { STB0899_RSULC, 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */ | ||
761 | { STB0899_TSULC, 0x42 }, | ||
762 | { STB0899_RSLLC, 0x41 }, | ||
763 | { STB0899_TSLPL, 0x12 }, | ||
764 | { STB0899_TSCFGH, 0x0c }, | ||
765 | { STB0899_TSCFGM, 0x00 }, | ||
766 | { STB0899_TSCFGL, 0x00 }, | ||
767 | { STB0899_TSOUT, 0x69 }, /* 0x0d for CAM */ | ||
768 | { STB0899_RSSYNCDEL, 0x00 }, | ||
769 | { STB0899_TSINHDELH, 0x02 }, | ||
770 | { STB0899_TSINHDELM, 0x00 }, | ||
771 | { STB0899_TSINHDELL, 0x00 }, | ||
772 | { STB0899_TSLLSTKM, 0x1b }, | ||
773 | { STB0899_TSLLSTKL, 0xb3 }, | ||
774 | { STB0899_TSULSTKM, 0x00 }, | ||
775 | { STB0899_TSULSTKL, 0x00 }, | ||
776 | { STB0899_PCKLENUL, 0xbc }, | ||
777 | { STB0899_PCKLENLL, 0xcc }, | ||
778 | { STB0899_RSPCKLEN, 0xbd }, | ||
779 | { STB0899_TSSTATUS, 0x90 }, | ||
780 | { STB0899_ERRCTRL1, 0xb6 }, | ||
781 | { STB0899_ERRCTRL2, 0x95 }, | ||
782 | { STB0899_ERRCTRL3, 0x8d }, | ||
783 | { STB0899_DMONMSK1, 0x27 }, | ||
784 | { STB0899_DMONMSK0, 0x03 }, | ||
785 | { STB0899_DEMAPVIT, 0x5c }, | ||
786 | { STB0899_PLPARM, 0x19 }, | ||
787 | { STB0899_PDELCTRL, 0x48 }, | ||
788 | { STB0899_PDELCTRL2, 0x00 }, | ||
789 | { STB0899_BBHCTRL1, 0x00 }, | ||
790 | { STB0899_BBHCTRL2, 0x00 }, | ||
791 | { STB0899_HYSTTHRESH, 0x77 }, | ||
792 | { STB0899_MATCSTM, 0x00 }, | ||
793 | { STB0899_MATCSTL, 0x00 }, | ||
794 | { STB0899_UPLCSTM, 0x00 }, | ||
795 | { STB0899_UPLCSTL, 0x00 }, | ||
796 | { STB0899_DFLCSTM, 0x00 }, | ||
797 | { STB0899_DFLCSTL, 0x00 }, | ||
798 | { STB0899_SYNCCST, 0x00 }, | ||
799 | { STB0899_SYNCDCSTM, 0x00 }, | ||
800 | { STB0899_SYNCDCSTL, 0x00 }, | ||
801 | { STB0899_ISI_ENTRY, 0x00 }, | ||
802 | { STB0899_ISI_BIT_EN, 0x00 }, | ||
803 | { STB0899_MATSTRM, 0xf0 }, | ||
804 | { STB0899_MATSTRL, 0x02 }, | ||
805 | { STB0899_UPLSTRM, 0x45 }, | ||
806 | { STB0899_UPLSTRL, 0x60 }, | ||
807 | { STB0899_DFLSTRM, 0xe3 }, | ||
808 | { STB0899_DFLSTRL, 0x00 }, | ||
809 | { STB0899_SYNCSTR, 0x47 }, | ||
810 | { STB0899_SYNCDSTRM, 0x05 }, | ||
811 | { STB0899_SYNCDSTRL, 0x18 }, | ||
812 | { STB0899_CFGPDELSTATUS1, 0x19 }, | ||
813 | { STB0899_CFGPDELSTATUS2, 0x2b }, | ||
814 | { STB0899_BBFERRORM, 0x00 }, | ||
815 | { STB0899_BBFERRORL, 0x01 }, | ||
816 | { STB0899_UPKTERRORM, 0x00 }, | ||
817 | { STB0899_UPKTERRORL, 0x00 }, | ||
818 | { 0xffff, 0xff }, | ||
819 | }; | ||
820 | |||
821 | static struct stb0899_config stb0899_config = { | ||
822 | .init_dev = pctv452e_init_dev, | ||
823 | .init_s2_demod = stb0899_s2_init_2, | ||
824 | .init_s1_demod = pctv452e_init_s1_demod, | ||
825 | .init_s2_fec = stb0899_s2_init_4, | ||
826 | .init_tst = stb0899_s1_init_5, | ||
827 | |||
828 | .demod_address = I2C_ADDR_STB0899, /* I2C Address */ | ||
829 | .block_sync_mode = STB0899_SYNC_FORCED, /* ? */ | ||
830 | |||
831 | .xtal_freq = 27000000, /* Assume Hz ? */ | ||
832 | .inversion = IQ_SWAP_ON, /* ? */ | ||
833 | |||
834 | .lo_clk = 76500000, | ||
835 | .hi_clk = 99000000, | ||
836 | |||
837 | .ts_output_mode = 0, /* Use parallel mode */ | ||
838 | .clock_polarity = 0, | ||
839 | .data_clk_parity = 0, | ||
840 | .fec_mode = 0, | ||
841 | |||
842 | .esno_ave = STB0899_DVBS2_ESNO_AVE, | ||
843 | .esno_quant = STB0899_DVBS2_ESNO_QUANT, | ||
844 | .avframes_coarse = STB0899_DVBS2_AVFRAMES_COARSE, | ||
845 | .avframes_fine = STB0899_DVBS2_AVFRAMES_FINE, | ||
846 | .miss_threshold = STB0899_DVBS2_MISS_THRESHOLD, | ||
847 | .uwp_threshold_acq = STB0899_DVBS2_UWP_THRESHOLD_ACQ, | ||
848 | .uwp_threshold_track = STB0899_DVBS2_UWP_THRESHOLD_TRACK, | ||
849 | .uwp_threshold_sof = STB0899_DVBS2_UWP_THRESHOLD_SOF, | ||
850 | .sof_search_timeout = STB0899_DVBS2_SOF_SEARCH_TIMEOUT, | ||
851 | |||
852 | .btr_nco_bits = STB0899_DVBS2_BTR_NCO_BITS, | ||
853 | .btr_gain_shift_offset = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET, | ||
854 | .crl_nco_bits = STB0899_DVBS2_CRL_NCO_BITS, | ||
855 | .ldpc_max_iter = STB0899_DVBS2_LDPC_MAX_ITER, | ||
856 | |||
857 | .tuner_get_frequency = stb6100_get_frequency, | ||
858 | .tuner_set_frequency = stb6100_set_frequency, | ||
859 | .tuner_set_bandwidth = stb6100_set_bandwidth, | ||
860 | .tuner_get_bandwidth = stb6100_get_bandwidth, | ||
861 | .tuner_set_rfsiggain = NULL, | ||
862 | |||
863 | /* helper for switching LED green/orange */ | ||
864 | .postproc = pctv45e_postproc | ||
865 | }; | ||
866 | |||
867 | static struct stb6100_config stb6100_config = { | ||
868 | .tuner_address = I2C_ADDR_STB6100, | ||
869 | .refclock = 27000000 | ||
870 | }; | ||
871 | |||
872 | |||
873 | static struct i2c_algorithm pctv452e_i2c_algo = { | ||
874 | .master_xfer = pctv452e_i2c_xfer, | ||
875 | .functionality = pctv452e_i2c_func | ||
876 | }; | ||
877 | |||
878 | static int pctv452e_frontend_attach(struct dvb_usb_adapter *a) | ||
879 | { | ||
880 | struct usb_device_id *id; | ||
881 | |||
882 | a->fe_adap[0].fe = dvb_attach(stb0899_attach, &stb0899_config, | ||
883 | &a->dev->i2c_adap); | ||
884 | if (!a->fe_adap[0].fe) | ||
885 | return -ENODEV; | ||
886 | if ((dvb_attach(lnbp22_attach, a->fe_adap[0].fe, | ||
887 | &a->dev->i2c_adap)) == 0) | ||
888 | err("Cannot attach lnbp22\n"); | ||
889 | |||
890 | id = a->dev->desc->warm_ids[0]; | ||
891 | if (USB_VID_TECHNOTREND == id->idVendor | ||
892 | && USB_PID_TECHNOTREND_CONNECT_S2_3650_CI == id->idProduct) | ||
893 | /* Error ignored. */ | ||
894 | tt3650_ci_init(a); | ||
895 | |||
896 | return 0; | ||
897 | } | ||
898 | |||
899 | static int pctv452e_tuner_attach(struct dvb_usb_adapter *a) | ||
900 | { | ||
901 | if (!a->fe_adap[0].fe) | ||
902 | return -ENODEV; | ||
903 | if (dvb_attach(stb6100_attach, a->fe_adap[0].fe, &stb6100_config, | ||
904 | &a->dev->i2c_adap) == 0) { | ||
905 | err("%s failed\n", __func__); | ||
906 | return -ENODEV; | ||
907 | } | ||
908 | |||
909 | return 0; | ||
910 | } | ||
911 | |||
912 | static struct usb_device_id pctv452e_usb_table[] = { | ||
913 | {USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_452E)}, | ||
914 | {USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_CONNECT_S2_3600)}, | ||
915 | {USB_DEVICE(USB_VID_TECHNOTREND, | ||
916 | USB_PID_TECHNOTREND_CONNECT_S2_3650_CI)}, | ||
917 | {} | ||
918 | }; | ||
919 | MODULE_DEVICE_TABLE(usb, pctv452e_usb_table); | ||
920 | |||
921 | static struct dvb_usb_device_properties pctv452e_properties = { | ||
922 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, /* more ? */ | ||
923 | .usb_ctrl = DEVICE_SPECIFIC, | ||
924 | |||
925 | .size_of_priv = sizeof(struct pctv452e_state), | ||
926 | |||
927 | .power_ctrl = pctv452e_power_ctrl, | ||
928 | |||
929 | .rc.core = { | ||
930 | .rc_codes = RC_MAP_DIB0700_RC5_TABLE, | ||
931 | .allowed_protos = RC_TYPE_UNKNOWN, | ||
932 | .rc_query = pctv452e_rc_query, | ||
933 | .rc_interval = 100, | ||
934 | }, | ||
935 | |||
936 | .num_adapters = 1, | ||
937 | .adapter = {{ | ||
938 | .num_frontends = 1, | ||
939 | .fe = {{ | ||
940 | .frontend_attach = pctv452e_frontend_attach, | ||
941 | .tuner_attach = pctv452e_tuner_attach, | ||
942 | |||
943 | /* parameter for the MPEG2-data transfer */ | ||
944 | .stream = { | ||
945 | .type = USB_ISOC, | ||
946 | .count = 4, | ||
947 | .endpoint = 0x02, | ||
948 | .u = { | ||
949 | .isoc = { | ||
950 | .framesperurb = 4, | ||
951 | .framesize = 940, | ||
952 | .interval = 1 | ||
953 | } | ||
954 | } | ||
955 | }, | ||
956 | } }, | ||
957 | } }, | ||
958 | |||
959 | .i2c_algo = &pctv452e_i2c_algo, | ||
960 | |||
961 | .generic_bulk_ctrl_endpoint = 1, /* allow generice rw function */ | ||
962 | |||
963 | .num_device_descs = 1, | ||
964 | .devices = { | ||
965 | { .name = "PCTV HDTV USB", | ||
966 | .cold_ids = { NULL, NULL }, /* this is a warm only device */ | ||
967 | .warm_ids = { &pctv452e_usb_table[0], NULL } | ||
968 | }, | ||
969 | { 0 }, | ||
970 | } | ||
971 | }; | ||
972 | |||
973 | static struct dvb_usb_device_properties tt_connect_s2_3600_properties = { | ||
974 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, /* more ? */ | ||
975 | .usb_ctrl = DEVICE_SPECIFIC, | ||
976 | |||
977 | .size_of_priv = sizeof(struct pctv452e_state), | ||
978 | |||
979 | .power_ctrl = pctv452e_power_ctrl, | ||
980 | .read_mac_address = pctv452e_read_mac_address, | ||
981 | |||
982 | .rc.core = { | ||
983 | .rc_codes = RC_MAP_TT_1500, | ||
984 | .allowed_protos = RC_TYPE_UNKNOWN, | ||
985 | .rc_query = pctv452e_rc_query, | ||
986 | .rc_interval = 100, | ||
987 | }, | ||
988 | |||
989 | .num_adapters = 1, | ||
990 | .adapter = {{ | ||
991 | .num_frontends = 1, | ||
992 | .fe = {{ | ||
993 | .frontend_attach = pctv452e_frontend_attach, | ||
994 | .tuner_attach = pctv452e_tuner_attach, | ||
995 | |||
996 | /* parameter for the MPEG2-data transfer */ | ||
997 | .stream = { | ||
998 | .type = USB_ISOC, | ||
999 | .count = 7, | ||
1000 | .endpoint = 0x02, | ||
1001 | .u = { | ||
1002 | .isoc = { | ||
1003 | .framesperurb = 4, | ||
1004 | .framesize = 940, | ||
1005 | .interval = 1 | ||
1006 | } | ||
1007 | } | ||
1008 | }, | ||
1009 | |||
1010 | } }, | ||
1011 | } }, | ||
1012 | |||
1013 | .i2c_algo = &pctv452e_i2c_algo, | ||
1014 | |||
1015 | .generic_bulk_ctrl_endpoint = 1, /* allow generice rw function*/ | ||
1016 | |||
1017 | .num_device_descs = 2, | ||
1018 | .devices = { | ||
1019 | { .name = "Technotrend TT Connect S2-3600", | ||
1020 | .cold_ids = { NULL, NULL }, /* this is a warm only device */ | ||
1021 | .warm_ids = { &pctv452e_usb_table[1], NULL } | ||
1022 | }, | ||
1023 | { .name = "Technotrend TT Connect S2-3650-CI", | ||
1024 | .cold_ids = { NULL, NULL }, | ||
1025 | .warm_ids = { &pctv452e_usb_table[2], NULL } | ||
1026 | }, | ||
1027 | { 0 }, | ||
1028 | } | ||
1029 | }; | ||
1030 | |||
1031 | static void pctv452e_usb_disconnect(struct usb_interface *intf) | ||
1032 | { | ||
1033 | struct dvb_usb_device *d = usb_get_intfdata(intf); | ||
1034 | |||
1035 | tt3650_ci_uninit(d); | ||
1036 | dvb_usb_device_exit(intf); | ||
1037 | } | ||
1038 | |||
1039 | static int pctv452e_usb_probe(struct usb_interface *intf, | ||
1040 | const struct usb_device_id *id) | ||
1041 | { | ||
1042 | if (0 == dvb_usb_device_init(intf, &pctv452e_properties, | ||
1043 | THIS_MODULE, NULL, adapter_nr) || | ||
1044 | 0 == dvb_usb_device_init(intf, &tt_connect_s2_3600_properties, | ||
1045 | THIS_MODULE, NULL, adapter_nr)) | ||
1046 | return 0; | ||
1047 | |||
1048 | return -ENODEV; | ||
1049 | } | ||
1050 | |||
1051 | static struct usb_driver pctv452e_usb_driver = { | ||
1052 | .name = "pctv452e", | ||
1053 | .probe = pctv452e_usb_probe, | ||
1054 | .disconnect = pctv452e_usb_disconnect, | ||
1055 | .id_table = pctv452e_usb_table, | ||
1056 | }; | ||
1057 | |||
1058 | static struct usb_driver tt_connects2_3600_usb_driver = { | ||
1059 | .name = "dvb-usb-tt-connect-s2-3600-01.fw", | ||
1060 | .probe = pctv452e_usb_probe, | ||
1061 | .disconnect = pctv452e_usb_disconnect, | ||
1062 | .id_table = pctv452e_usb_table, | ||
1063 | }; | ||
1064 | |||
1065 | static int __init pctv452e_usb_init(void) | ||
1066 | { | ||
1067 | int ret = usb_register(&pctv452e_usb_driver); | ||
1068 | |||
1069 | if (ret) { | ||
1070 | err("%s: usb_register failed! Error %d", __FILE__, ret); | ||
1071 | return ret; | ||
1072 | } | ||
1073 | ret = usb_register(&tt_connects2_3600_usb_driver); | ||
1074 | if (ret) | ||
1075 | err("%s: usb_register failed! Error %d", __FILE__, ret); | ||
1076 | |||
1077 | return ret; | ||
1078 | } | ||
1079 | |||
1080 | static void __exit pctv452e_usb_exit(void) | ||
1081 | { | ||
1082 | usb_deregister(&pctv452e_usb_driver); | ||
1083 | usb_deregister(&tt_connects2_3600_usb_driver); | ||
1084 | } | ||
1085 | |||
1086 | module_init(pctv452e_usb_init); | ||
1087 | module_exit(pctv452e_usb_exit); | ||
1088 | |||
1089 | MODULE_AUTHOR("Dominik Kuhlen <dkuhlen@gmx.net>"); | ||
1090 | MODULE_AUTHOR("Andre Weidemann <Andre.Weidemann@web.de>"); | ||
1091 | MODULE_AUTHOR("Michael H. Schimek <mschimek@gmx.at>"); | ||
1092 | MODULE_DESCRIPTION("Pinnacle PCTV HDTV USB DVB / TT connect S2-3600 Driver"); | ||
1093 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index 28fbb5c8c0a3..4a2d2e6c91ab 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
@@ -607,6 +607,16 @@ config DVB_LNBP21 | |||
607 | help | 607 | help |
608 | An SEC control chips. | 608 | An SEC control chips. |
609 | 609 | ||
610 | config DVB_LNBP22 | ||
611 | tristate "LNBP22 SEC controllers" | ||
612 | depends on DVB_CORE && I2C | ||
613 | default m if DVB_FE_CUSTOMISE | ||
614 | help | ||
615 | LNB power supply and control voltage | ||
616 | regulator chip with step-up converter | ||
617 | and I2C interface. | ||
618 | Say Y when you want to support this chip. | ||
619 | |||
610 | config DVB_ISL6405 | 620 | config DVB_ISL6405 |
611 | tristate "ISL6405 SEC controller" | 621 | tristate "ISL6405 SEC controller" |
612 | depends on DVB_CORE && I2C | 622 | depends on DVB_CORE && I2C |
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 36c8d81e096a..f639f6781551 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile | |||
@@ -52,6 +52,7 @@ obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o | |||
52 | obj-$(CONFIG_DVB_LGDT3305) += lgdt3305.o | 52 | obj-$(CONFIG_DVB_LGDT3305) += lgdt3305.o |
53 | obj-$(CONFIG_DVB_CX24123) += cx24123.o | 53 | obj-$(CONFIG_DVB_CX24123) += cx24123.o |
54 | obj-$(CONFIG_DVB_LNBP21) += lnbp21.o | 54 | obj-$(CONFIG_DVB_LNBP21) += lnbp21.o |
55 | obj-$(CONFIG_DVB_LNBP22) += lnbp22.o | ||
55 | obj-$(CONFIG_DVB_ISL6405) += isl6405.o | 56 | obj-$(CONFIG_DVB_ISL6405) += isl6405.o |
56 | obj-$(CONFIG_DVB_ISL6421) += isl6421.o | 57 | obj-$(CONFIG_DVB_ISL6421) += isl6421.o |
57 | obj-$(CONFIG_DVB_TDA10086) += tda10086.o | 58 | obj-$(CONFIG_DVB_TDA10086) += tda10086.o |
diff --git a/drivers/media/dvb/frontends/lnbp22.c b/drivers/media/dvb/frontends/lnbp22.c new file mode 100644 index 000000000000..84ad0390a4a1 --- /dev/null +++ b/drivers/media/dvb/frontends/lnbp22.c | |||
@@ -0,0 +1,148 @@ | |||
1 | /* | ||
2 | * lnbp22.h - driver for lnb supply and control ic lnbp22 | ||
3 | * | ||
4 | * Copyright (C) 2006 Dominik Kuhlen | ||
5 | * Based on lnbp21 driver | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
22 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html | ||
23 | * | ||
24 | * | ||
25 | * the project's page is at http://www.linuxtv.org | ||
26 | */ | ||
27 | #include <linux/delay.h> | ||
28 | #include <linux/errno.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/moduleparam.h> | ||
33 | #include <linux/string.h> | ||
34 | #include <linux/slab.h> | ||
35 | |||
36 | #include "dvb_frontend.h" | ||
37 | #include "lnbp22.h" | ||
38 | |||
39 | static int debug; | ||
40 | module_param(debug, int, 0644); | ||
41 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | ||
42 | |||
43 | |||
44 | #define dprintk(lvl, arg...) if (debug >= (lvl)) printk(arg) | ||
45 | |||
46 | struct lnbp22 { | ||
47 | u8 config[4]; | ||
48 | struct i2c_adapter *i2c; | ||
49 | }; | ||
50 | |||
51 | static int lnbp22_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
52 | { | ||
53 | struct lnbp22 *lnbp22 = (struct lnbp22 *)fe->sec_priv; | ||
54 | struct i2c_msg msg = { | ||
55 | .addr = 0x08, | ||
56 | .flags = 0, | ||
57 | .buf = (char *)&lnbp22->config, | ||
58 | .len = sizeof(lnbp22->config), | ||
59 | }; | ||
60 | |||
61 | dprintk(1, "%s: %d (18V=%d 13V=%d)\n", __func__, voltage, | ||
62 | SEC_VOLTAGE_18, SEC_VOLTAGE_13); | ||
63 | |||
64 | lnbp22->config[3] = 0x60; /* Power down */ | ||
65 | switch (voltage) { | ||
66 | case SEC_VOLTAGE_OFF: | ||
67 | break; | ||
68 | case SEC_VOLTAGE_13: | ||
69 | lnbp22->config[3] |= LNBP22_EN; | ||
70 | break; | ||
71 | case SEC_VOLTAGE_18: | ||
72 | lnbp22->config[3] |= (LNBP22_EN | LNBP22_VSEL); | ||
73 | break; | ||
74 | default: | ||
75 | return -EINVAL; | ||
76 | }; | ||
77 | |||
78 | dprintk(1, "%s: 0x%02x)\n", __func__, lnbp22->config[3]); | ||
79 | return (i2c_transfer(lnbp22->i2c, &msg, 1) == 1) ? 0 : -EIO; | ||
80 | } | ||
81 | |||
82 | static int lnbp22_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) | ||
83 | { | ||
84 | struct lnbp22 *lnbp22 = (struct lnbp22 *) fe->sec_priv; | ||
85 | struct i2c_msg msg = { | ||
86 | .addr = 0x08, | ||
87 | .flags = 0, | ||
88 | .buf = (char *)&lnbp22->config, | ||
89 | .len = sizeof(lnbp22->config), | ||
90 | }; | ||
91 | |||
92 | dprintk(1, "%s: %d\n", __func__, (int)arg); | ||
93 | if (arg) | ||
94 | lnbp22->config[3] |= LNBP22_LLC; | ||
95 | else | ||
96 | lnbp22->config[3] &= ~LNBP22_LLC; | ||
97 | |||
98 | return (i2c_transfer(lnbp22->i2c, &msg, 1) == 1) ? 0 : -EIO; | ||
99 | } | ||
100 | |||
101 | static void lnbp22_release(struct dvb_frontend *fe) | ||
102 | { | ||
103 | dprintk(1, "%s\n", __func__); | ||
104 | /* LNBP power off */ | ||
105 | lnbp22_set_voltage(fe, SEC_VOLTAGE_OFF); | ||
106 | |||
107 | /* free data */ | ||
108 | kfree(fe->sec_priv); | ||
109 | fe->sec_priv = NULL; | ||
110 | } | ||
111 | |||
112 | struct dvb_frontend *lnbp22_attach(struct dvb_frontend *fe, | ||
113 | struct i2c_adapter *i2c) | ||
114 | { | ||
115 | struct lnbp22 *lnbp22 = kmalloc(sizeof(struct lnbp22), GFP_KERNEL); | ||
116 | if (!lnbp22) | ||
117 | return NULL; | ||
118 | |||
119 | /* default configuration */ | ||
120 | lnbp22->config[0] = 0x00; /* ? */ | ||
121 | lnbp22->config[1] = 0x28; /* ? */ | ||
122 | lnbp22->config[2] = 0x48; /* ? */ | ||
123 | lnbp22->config[3] = 0x60; /* Power down */ | ||
124 | lnbp22->i2c = i2c; | ||
125 | fe->sec_priv = lnbp22; | ||
126 | |||
127 | /* detect if it is present or not */ | ||
128 | if (lnbp22_set_voltage(fe, SEC_VOLTAGE_OFF)) { | ||
129 | dprintk(0, "%s LNBP22 not found\n", __func__); | ||
130 | kfree(lnbp22); | ||
131 | fe->sec_priv = NULL; | ||
132 | return NULL; | ||
133 | } | ||
134 | |||
135 | /* install release callback */ | ||
136 | fe->ops.release_sec = lnbp22_release; | ||
137 | |||
138 | /* override frontend ops */ | ||
139 | fe->ops.set_voltage = lnbp22_set_voltage; | ||
140 | fe->ops.enable_high_lnb_voltage = lnbp22_enable_high_lnb_voltage; | ||
141 | |||
142 | return fe; | ||
143 | } | ||
144 | EXPORT_SYMBOL(lnbp22_attach); | ||
145 | |||
146 | MODULE_DESCRIPTION("Driver for lnb supply and control ic lnbp22"); | ||
147 | MODULE_AUTHOR("Dominik Kuhlen"); | ||
148 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/lnbp22.h b/drivers/media/dvb/frontends/lnbp22.h new file mode 100644 index 000000000000..63e2dec7e68a --- /dev/null +++ b/drivers/media/dvb/frontends/lnbp22.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * lnbp22.h - driver for lnb supply and control ic lnbp22 | ||
3 | * | ||
4 | * Copyright (C) 2006 Dominik Kuhlen | ||
5 | * Based on lnbp21.h | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
22 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html | ||
23 | * | ||
24 | * | ||
25 | * the project's page is at http://www.linuxtv.org | ||
26 | */ | ||
27 | |||
28 | #ifndef _LNBP22_H | ||
29 | #define _LNBP22_H | ||
30 | |||
31 | /* Enable */ | ||
32 | #define LNBP22_EN 0x10 | ||
33 | /* Voltage selection */ | ||
34 | #define LNBP22_VSEL 0x02 | ||
35 | /* Plus 1 Volt Bit */ | ||
36 | #define LNBP22_LLC 0x01 | ||
37 | |||
38 | #include <linux/dvb/frontend.h> | ||
39 | |||
40 | #if defined(CONFIG_DVB_LNBP22) || \ | ||
41 | (defined(CONFIG_DVB_LNBP22_MODULE) && defined(MODULE)) | ||
42 | /* | ||
43 | * override_set and override_clear control which system register bits (above) | ||
44 | * to always set & clear | ||
45 | */ | ||
46 | extern struct dvb_frontend *lnbp22_attach(struct dvb_frontend *fe, | ||
47 | struct i2c_adapter *i2c); | ||
48 | #else | ||
49 | static inline struct dvb_frontend *lnbp22_attach(struct dvb_frontend *fe, | ||
50 | struct i2c_adapter *i2c) | ||
51 | { | ||
52 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
53 | return NULL; | ||
54 | } | ||
55 | #endif /* CONFIG_DVB_LNBP22 */ | ||
56 | |||
57 | #endif /* _LNBP22_H */ | ||
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.c b/drivers/media/dvb/ttpci/ttpci-eeprom.c index 7dd54b3026a2..32d43156c548 100644 --- a/drivers/media/dvb/ttpci/ttpci-eeprom.c +++ b/drivers/media/dvb/ttpci/ttpci-eeprom.c | |||
@@ -85,6 +85,35 @@ static int getmac_tt(u8 * decodedMAC, u8 * encodedMAC) | |||
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | int ttpci_eeprom_decode_mac(u8 *decodedMAC, u8 *encodedMAC) | ||
89 | { | ||
90 | u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c, | ||
91 | 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6, | ||
92 | 0x1d, 0x36, 0x64, 0x78}; | ||
93 | u8 data[20]; | ||
94 | int i; | ||
95 | |||
96 | memcpy(data, encodedMAC, 20); | ||
97 | |||
98 | for (i = 0; i < 20; i++) | ||
99 | data[i] ^= xor[i]; | ||
100 | for (i = 0; i < 10; i++) | ||
101 | data[i] = ((data[2 * i + 1] << 8) | data[2 * i]) | ||
102 | >> ((data[2 * i + 1] >> 6) & 3); | ||
103 | |||
104 | if (check_mac_tt(data)) | ||
105 | return -ENODEV; | ||
106 | |||
107 | decodedMAC[0] = data[2]; | ||
108 | decodedMAC[1] = data[1]; | ||
109 | decodedMAC[2] = data[0]; | ||
110 | decodedMAC[3] = data[6]; | ||
111 | decodedMAC[4] = data[5]; | ||
112 | decodedMAC[5] = data[4]; | ||
113 | return 0; | ||
114 | } | ||
115 | EXPORT_SYMBOL(ttpci_eeprom_decode_mac); | ||
116 | |||
88 | static int ttpci_eeprom_read_encodedMAC(struct i2c_adapter *adapter, u8 * encodedMAC) | 117 | static int ttpci_eeprom_read_encodedMAC(struct i2c_adapter *adapter, u8 * encodedMAC) |
89 | { | 118 | { |
90 | int ret; | 119 | int ret; |
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.h b/drivers/media/dvb/ttpci/ttpci-eeprom.h index e2dc6cfe205c..dcc33d5a5cb1 100644 --- a/drivers/media/dvb/ttpci/ttpci-eeprom.h +++ b/drivers/media/dvb/ttpci/ttpci-eeprom.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
30 | 30 | ||
31 | extern int ttpci_eeprom_decode_mac(u8 *decodedMAC, u8 *encodedMAC); | ||
31 | extern int ttpci_eeprom_parse_mac(struct i2c_adapter *adapter, u8 *propsed_mac); | 32 | extern int ttpci_eeprom_parse_mac(struct i2c_adapter *adapter, u8 *propsed_mac); |
32 | 33 | ||
33 | #endif | 34 | #endif |