diff options
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/Kconfig | 7 | ||||
-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/opera1.c | 563 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/opera1.h | 9 |
5 files changed, 586 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 8aa12722cbd6..54488737a08f 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -211,3 +211,10 @@ config DVB_USB_DTT200U | |||
211 | The receivers are also known as DTT200U (Yakumo) and UB300 (Yuan). | 211 | The receivers are also known as DTT200U (Yakumo) and UB300 (Yuan). |
212 | 212 | ||
213 | The WT-220U and its clones are pen-sized. | 213 | The WT-220U and its clones are pen-sized. |
214 | |||
215 | config DVB_USB_OPERA1 | ||
216 | tristate "Opera1 DVB-S USB2.0 receiver" | ||
217 | depends on DVB_USB | ||
218 | select DVB_STV0299 if !DVB_FE_CUSTOMISE | ||
219 | help | ||
220 | Say Y here to support the Opera DVB-S USB2.0 receiver. | ||
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 40f28f559b54..976f840cc904 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile | |||
@@ -51,4 +51,8 @@ obj-$(CONFIG_DVB_USB_TTUSB2) += dvb-usb-ttusb2.o | |||
51 | dvb-usb-dib0700-objs = dib0700_core.o dib0700_devices.o | 51 | dvb-usb-dib0700-objs = dib0700_core.o dib0700_devices.o |
52 | obj-$(CONFIG_DVB_USB_DIB0700) += dvb-usb-dib0700.o | 52 | obj-$(CONFIG_DVB_USB_DIB0700) += dvb-usb-dib0700.o |
53 | 53 | ||
54 | dvb-usb-opera-objs = opera1.o | ||
55 | obj-$(CONFIG_DVB_USB_OPERA1) += dvb-usb-opera.o | ||
56 | |||
57 | |||
54 | EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | 58 | EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index dda636af29fb..e4e60619421e 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 | 38 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 |
39 | #define USB_VID_UNIWILL 0x1584 | 39 | #define USB_VID_UNIWILL 0x1584 |
40 | #define USB_VID_WIDEVIEW 0x14aa | 40 | #define USB_VID_WIDEVIEW 0x14aa |
41 | #define USB_VID_OPERA1 0x695c | ||
41 | 42 | ||
42 | /* Product IDs */ | 43 | /* Product IDs */ |
43 | #define USB_PID_ADSTECH_USB2_COLD 0xa333 | 44 | #define USB_PID_ADSTECH_USB2_COLD 0xa333 |
@@ -142,6 +143,8 @@ | |||
142 | #define USB_PID_GENPIX_8PSK_WARM 0x0201 | 143 | #define USB_PID_GENPIX_8PSK_WARM 0x0201 |
143 | #define USB_PID_SIGMATEK_DVB_110 0x6610 | 144 | #define USB_PID_SIGMATEK_DVB_110 0x6610 |
144 | #define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 | 145 | #define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 |
146 | #define USB_PID_OPERA1_COLD 0x2830 | ||
147 | #define USB_PID_OPERA1_WARM 0x3829 | ||
145 | 148 | ||
146 | 149 | ||
147 | #endif | 150 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c new file mode 100644 index 000000000000..67c2aa59f74c --- /dev/null +++ b/drivers/media/dvb/dvb-usb/opera1.c | |||
@@ -0,0 +1,563 @@ | |||
1 | /* DVB USB framework compliant Linux driver for the Opera1 DVB-S Card | ||
2 | * | ||
3 | * Copyright (C) 2006 Mario Hlawitschka (dh1pa@amsat.org) | ||
4 | * Copyright (C) 2006 Marco Gittler (g.marco@freenet.de) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation, version 2. | ||
9 | * | ||
10 | * see Documentation/dvb/README.dvb-usb for more information | ||
11 | */ | ||
12 | |||
13 | #include "opera1.h" | ||
14 | #include "stv0299.h" | ||
15 | |||
16 | #define OPERA_READ_MSG 0 | ||
17 | #define OPERA_WRITE_MSG 1 | ||
18 | #define OPERA_I2C_TUNER 0xd1 | ||
19 | |||
20 | #define READ_FX2_REG_REQ 0xba | ||
21 | #define READ_MAC_ADDR 0x08 | ||
22 | #define OPERA_WRITE_FX2 0xbb | ||
23 | #define OPERA_TUNER_REQ 0xb1 | ||
24 | #define REG_1F_SYMBOLRATE_BYTE0 0x1f | ||
25 | #define REG_20_SYMBOLRATE_BYTE1 0x20 | ||
26 | #define REG_21_SYMBOLRATE_BYTE2 0x21 | ||
27 | |||
28 | struct opera1_state { | ||
29 | u32 last_key_pressed; | ||
30 | }; | ||
31 | struct opera_rc_keys { | ||
32 | u32 keycode; | ||
33 | u32 event; | ||
34 | }; | ||
35 | |||
36 | int dvb_usb_opera1_debug; | ||
37 | module_param_named(debug, dvb_usb_opera1_debug, int, 0644); | ||
38 | MODULE_PARM_DESC(debug, | ||
39 | "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." | ||
40 | DVB_USB_DEBUG_STATUS); | ||
41 | |||
42 | static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value, | ||
43 | u8 * data, u16 len, int flags) | ||
44 | { | ||
45 | int ret; | ||
46 | u8 r; | ||
47 | u8 u8buf[len]; | ||
48 | |||
49 | unsigned int pipe = (flags == OPERA_READ_MSG) ? | ||
50 | usb_rcvctrlpipe(dev,0) : usb_sndctrlpipe(dev, 0); | ||
51 | u8 request_type = (flags == OPERA_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; | ||
52 | |||
53 | if (flags == OPERA_WRITE_MSG) | ||
54 | memcpy(u8buf, data, len); | ||
55 | ret = | ||
56 | usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, | ||
57 | value, 0x0, u8buf, len, 2000); | ||
58 | |||
59 | if (request == OPERA_TUNER_REQ) { | ||
60 | if (usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
61 | OPERA_TUNER_REQ, USB_DIR_IN | USB_TYPE_VENDOR, | ||
62 | 0x01, 0x0, &r, 1, 2000)<1 || r!=0x08) | ||
63 | return 0; | ||
64 | } | ||
65 | if (flags == OPERA_READ_MSG) | ||
66 | memcpy(data, u8buf, len); | ||
67 | return ret; | ||
68 | } | ||
69 | |||
70 | /* I2C */ | ||
71 | |||
72 | static int opera1_usb_i2c_msgxfer(struct dvb_usb_device *dev, u16 addr, | ||
73 | u8 * buf, u16 len, int flag) | ||
74 | { | ||
75 | int ret = 0; | ||
76 | u8 request; | ||
77 | u16 value; | ||
78 | |||
79 | if (!dev) { | ||
80 | info("no usb_device"); | ||
81 | return -EINVAL; | ||
82 | } | ||
83 | if (mutex_lock_interruptible(&dev->usb_mutex) < 0) | ||
84 | return -EAGAIN; | ||
85 | |||
86 | request = (addr & 0xff00) >> 8; | ||
87 | if (!request) | ||
88 | request = 0xb1; | ||
89 | value = (addr & 0xff); | ||
90 | if (flag & OPERA_READ_MSG) { | ||
91 | value |= 0x01; | ||
92 | } | ||
93 | if (request == 0xa0) | ||
94 | value = 0xe600; | ||
95 | ret = opera1_xilinx_rw(dev->udev, request, value, buf, len, flag); | ||
96 | |||
97 | mutex_unlock(&dev->usb_mutex); | ||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | static int opera1_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | ||
102 | int num) | ||
103 | { | ||
104 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | ||
105 | int i = 0, tmp = 0; | ||
106 | |||
107 | if (!d) | ||
108 | return -ENODEV; | ||
109 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | ||
110 | return -EAGAIN; | ||
111 | |||
112 | for (i = 0; i < num; i++) { | ||
113 | if ((tmp = opera1_usb_i2c_msgxfer(d, | ||
114 | msg[i].addr, | ||
115 | msg[i].buf, | ||
116 | msg[i].len, | ||
117 | (msg[i].flags == | ||
118 | I2C_M_RD ? | ||
119 | OPERA_READ_MSG : | ||
120 | OPERA_WRITE_MSG))!= msg[i].len)) { | ||
121 | break; | ||
122 | } | ||
123 | if (dvb_usb_opera1_debug & 0x10) | ||
124 | info("sending i2c mesage %d %d", tmp, msg[i].len); | ||
125 | } | ||
126 | mutex_unlock(&d->i2c_mutex); | ||
127 | return num; | ||
128 | } | ||
129 | |||
130 | static u32 opera1_i2c_func(struct i2c_adapter *adapter) | ||
131 | { | ||
132 | return I2C_FUNC_I2C; | ||
133 | } | ||
134 | |||
135 | static struct i2c_algorithm opera1_i2c_algo = { | ||
136 | .master_xfer = opera1_i2c_xfer, | ||
137 | .functionality = opera1_i2c_func, | ||
138 | }; | ||
139 | |||
140 | static int opera1_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
141 | { | ||
142 | static u8 command_13v[1]={0x00}; | ||
143 | static u8 command_18v[1]={0x01}; | ||
144 | struct i2c_msg msg[] = { | ||
145 | {.addr = 0xb600,.flags = 0,.buf = command_13v,.len = 1}, | ||
146 | }; | ||
147 | struct dvb_usb_adapter *udev_adap = | ||
148 | (struct dvb_usb_adapter *)(fe->dvb->priv); | ||
149 | if (voltage == SEC_VOLTAGE_18) { | ||
150 | msg[0].addr = 0xb601; | ||
151 | msg[0].buf = command_18v; | ||
152 | } | ||
153 | i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1); | ||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static int opera1_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, | ||
158 | u32 ratio) | ||
159 | { | ||
160 | stv0299_writereg(fe, 0x13, 0x98); | ||
161 | stv0299_writereg(fe, 0x14, 0x95); | ||
162 | stv0299_writereg(fe, REG_1F_SYMBOLRATE_BYTE0, (ratio >> 16) & 0xff); | ||
163 | stv0299_writereg(fe, REG_20_SYMBOLRATE_BYTE1, (ratio >> 8) & 0xff); | ||
164 | stv0299_writereg(fe, REG_21_SYMBOLRATE_BYTE2, (ratio) & 0xf0); | ||
165 | return 0; | ||
166 | |||
167 | } | ||
168 | static u8 opera1_inittab[] = { | ||
169 | 0x00, 0xa1, | ||
170 | 0x01, 0x15, | ||
171 | 0x02, 0x00, | ||
172 | 0x03, 0x00, | ||
173 | 0x04, 0x7d, | ||
174 | 0x05, 0x05, | ||
175 | 0x06, 0x02, | ||
176 | 0x07, 0x00, | ||
177 | 0x0b, 0x00, | ||
178 | 0x0c, 0x01, | ||
179 | 0x0d, 0x81, | ||
180 | 0x0e, 0x44, | ||
181 | 0x0f, 0x19, | ||
182 | 0x10, 0x3f, | ||
183 | 0x11, 0x84, | ||
184 | 0x12, 0xda, | ||
185 | 0x13, 0x98, | ||
186 | 0x14, 0x95, | ||
187 | 0x15, 0xc9, | ||
188 | 0x16, 0xeb, | ||
189 | 0x17, 0x00, | ||
190 | 0x18, 0x19, | ||
191 | 0x19, 0x8b, | ||
192 | 0x1a, 0x00, | ||
193 | 0x1b, 0x82, | ||
194 | 0x1c, 0x7f, | ||
195 | 0x1d, 0x00, | ||
196 | 0x1e, 0x00, | ||
197 | REG_1F_SYMBOLRATE_BYTE0, 0x06, | ||
198 | REG_20_SYMBOLRATE_BYTE1, 0x50, | ||
199 | REG_21_SYMBOLRATE_BYTE2, 0x10, | ||
200 | 0x22, 0x00, | ||
201 | 0x23, 0x00, | ||
202 | 0x24, 0x37, | ||
203 | 0x25, 0xbc, | ||
204 | 0x26, 0x00, | ||
205 | 0x27, 0x00, | ||
206 | 0x28, 0x00, | ||
207 | 0x29, 0x1e, | ||
208 | 0x2a, 0x14, | ||
209 | 0x2b, 0x1f, | ||
210 | 0x2c, 0x09, | ||
211 | 0x2d, 0x0a, | ||
212 | 0x2e, 0x00, | ||
213 | 0x2f, 0x00, | ||
214 | 0x30, 0x00, | ||
215 | 0x31, 0x1f, | ||
216 | 0x32, 0x19, | ||
217 | 0x33, 0xfc, | ||
218 | 0x34, 0x13, | ||
219 | 0xff, 0xff, | ||
220 | }; | ||
221 | |||
222 | static struct stv0299_config opera1_stv0299_config = { | ||
223 | .demod_address = 0xd0, | ||
224 | .min_delay_ms = 100, | ||
225 | .mclk = 88000000UL, | ||
226 | .invert = 1, | ||
227 | .skip_reinit = 0, | ||
228 | .lock_output = STV0229_LOCKOUTPUT_0, | ||
229 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | ||
230 | .inittab = opera1_inittab, | ||
231 | .set_symbol_rate = opera1_stv0299_set_symbol_rate, | ||
232 | }; | ||
233 | |||
234 | static int opera1_frontend_attach(struct dvb_usb_adapter *d) | ||
235 | { | ||
236 | if ((d->fe = | ||
237 | dvb_attach(stv0299_attach, &opera1_stv0299_config, | ||
238 | &d->dev->i2c_adap)) != NULL) { | ||
239 | d->fe->ops.set_voltage = opera1_set_voltage; | ||
240 | return 0; | ||
241 | } | ||
242 | info("not attached stv0299"); | ||
243 | return -EIO; | ||
244 | } | ||
245 | |||
246 | static int opera1_tuner_attach(struct dvb_usb_adapter *adap) | ||
247 | { | ||
248 | adap->pll_addr = 0xc0; | ||
249 | adap->pll_desc = &dvb_pll_opera1; | ||
250 | adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; | ||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static int opera1_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
255 | { | ||
256 | int addr = onoff ? 0xb701 : 0xb700; | ||
257 | u8 val = onoff ? 0x01 : 0x00; | ||
258 | if (dvb_usb_opera1_debug) | ||
259 | info("power %s", onoff ? "on" : "off"); | ||
260 | return opera1_usb_i2c_msgxfer(d, addr, &val, 1, OPERA_WRITE_MSG); | ||
261 | } | ||
262 | |||
263 | static int opera1_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | ||
264 | { | ||
265 | static u8 buf_start[2] = { 0xff, 0x03 }; | ||
266 | static u8 buf_stop[2] = { 0xff, 0x00 }; | ||
267 | struct i2c_msg start_tuner[] = { | ||
268 | {.addr = 0xb1a6,.buf = onoff ? buf_start : buf_stop,.len = 2}, | ||
269 | }; | ||
270 | if (dvb_usb_opera1_debug) | ||
271 | info("streaming %s", onoff ? "on" : "off"); | ||
272 | i2c_transfer(&adap->dev->i2c_adap, start_tuner, 1); | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | static int opera1_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, | ||
277 | int onoff) | ||
278 | { | ||
279 | u8 b_pid[3]; | ||
280 | struct i2c_msg msg[] = { | ||
281 | {.addr = 0xb1a6,.buf = b_pid,.len = 3}, | ||
282 | }; | ||
283 | if (dvb_usb_opera1_debug) | ||
284 | info("pidfilter index: %d pid: %d %s", index, pid, | ||
285 | onoff ? "on" : "off"); | ||
286 | b_pid[0] = (2 * index) + 4; | ||
287 | b_pid[1] = onoff ? (pid & 0xff) : (0x00); | ||
288 | b_pid[2] = onoff ? ((pid >> 8) & 0xff) : (0x00); | ||
289 | i2c_transfer(&adap->dev->i2c_adap, msg, 1); | ||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | static int opera1_pid_filter_control(struct dvb_usb_adapter *adap, int onoff) | ||
294 | { | ||
295 | int u = 0x04; | ||
296 | u8 b_pid[3]; | ||
297 | struct i2c_msg msg[] = { | ||
298 | {.addr = 0xb1a6,.buf = b_pid,.len = 3}, | ||
299 | }; | ||
300 | if (dvb_usb_opera1_debug) | ||
301 | info("%s hw-pidfilter", onoff ? "enable" : "disable"); | ||
302 | for (; u < 0x7e; u += 2) { | ||
303 | b_pid[0] = u; | ||
304 | b_pid[1] = 0; | ||
305 | b_pid[2] = 0x80; | ||
306 | i2c_transfer(&adap->dev->i2c_adap, msg, 1); | ||
307 | } | ||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | static struct dvb_usb_rc_key opera1_rc_keys[] = { | ||
312 | {0x5f, 0xa0, KEY_1}, | ||
313 | {0x51, 0xaf, KEY_2}, | ||
314 | {0x5d, 0xa2, KEY_3}, | ||
315 | {0x41, 0xbe, KEY_4}, | ||
316 | {0x0b, 0xf5, KEY_5}, | ||
317 | {0x43, 0xbd, KEY_6}, | ||
318 | {0x47, 0xb8, KEY_7}, | ||
319 | {0x49, 0xb6, KEY_8}, | ||
320 | {0x05, 0xfa, KEY_9}, | ||
321 | {0x45, 0xba, KEY_0}, | ||
322 | {0x09, 0xf6, KEY_UP}, /*chanup */ | ||
323 | {0x1b, 0xe5, KEY_DOWN}, /*chandown */ | ||
324 | {0x5d, 0xa3, KEY_LEFT}, /*voldown */ | ||
325 | {0x5f, 0xa1, KEY_RIGHT}, /*volup */ | ||
326 | {0x07, 0xf8, KEY_SPACE}, /*tab */ | ||
327 | {0x1f, 0xe1, KEY_ENTER}, /*play ok */ | ||
328 | {0x1b, 0xe4, KEY_Z}, /*zoom */ | ||
329 | {0x59, 0xa6, KEY_M}, /*mute */ | ||
330 | {0x5b, 0xa5, KEY_F}, /*tv/f */ | ||
331 | {0x19, 0xe7, KEY_R}, /*rec */ | ||
332 | {0x01, 0xfe, KEY_S}, /*Stop */ | ||
333 | {0x03, 0xfd, KEY_P}, /*pause */ | ||
334 | {0x03, 0xfc, KEY_W}, /*<- -> */ | ||
335 | {0x07, 0xf9, KEY_C}, /*capture */ | ||
336 | {0x47, 0xb9, KEY_Q}, /*exit */ | ||
337 | {0x43, 0xbc, KEY_O}, /*power */ | ||
338 | |||
339 | }; | ||
340 | |||
341 | static int opera1_rc_query(struct dvb_usb_device *dev, u32 * event, int *state) | ||
342 | { | ||
343 | struct opera1_state *opst = dev->priv; | ||
344 | u8 rcbuffer[32]; | ||
345 | const u16 startmarker1 = 0x10ed; | ||
346 | const u16 startmarker2 = 0x11ec; | ||
347 | struct i2c_msg read_remote[] = { | ||
348 | {.addr = 0xb880,.buf = rcbuffer,.flags = I2C_M_RD,.len = 32}, | ||
349 | }; | ||
350 | int i = 0; | ||
351 | u32 send_key = 0; | ||
352 | |||
353 | if (i2c_transfer(&dev->i2c_adap, read_remote, 1) == 1) { | ||
354 | for (i = 0; i < 32; i++) { | ||
355 | if (rcbuffer[i]) | ||
356 | send_key |= 1; | ||
357 | if (i < 31) | ||
358 | send_key = send_key << 1; | ||
359 | } | ||
360 | if (send_key & 0x8000) | ||
361 | send_key = (send_key << 1) | (send_key >> 15 & 0x01); | ||
362 | |||
363 | if (send_key == 0xffff && opst->last_key_pressed != 0) { | ||
364 | *state = REMOTE_KEY_REPEAT; | ||
365 | *event = opst->last_key_pressed; | ||
366 | return 0; | ||
367 | } | ||
368 | for (; send_key != 0;) { | ||
369 | if (send_key >> 16 == startmarker2) { | ||
370 | break; | ||
371 | } else if (send_key >> 16 == startmarker1) { | ||
372 | send_key = | ||
373 | (send_key & 0xfffeffff) | (startmarker1 << 16); | ||
374 | break; | ||
375 | } else | ||
376 | send_key >>= 1; | ||
377 | } | ||
378 | |||
379 | if (send_key == 0) | ||
380 | return 0; | ||
381 | |||
382 | send_key = (send_key & 0xffff) | 0x0100; | ||
383 | |||
384 | for (i = 0; i < ARRAY_SIZE(opera1_rc_keys); i++) { | ||
385 | if ((opera1_rc_keys[i].custom * 256 + | ||
386 | opera1_rc_keys[i].data) == (send_key & 0xffff)) { | ||
387 | *state = REMOTE_KEY_PRESSED; | ||
388 | *event = opera1_rc_keys[i].event; | ||
389 | opst->last_key_pressed = | ||
390 | opera1_rc_keys[i].event; | ||
391 | break; | ||
392 | } | ||
393 | opst->last_key_pressed = 0; | ||
394 | } | ||
395 | } else | ||
396 | *state = REMOTE_NO_KEY_PRESSED; | ||
397 | return 0; | ||
398 | } | ||
399 | |||
400 | static struct usb_device_id opera1_table[] = { | ||
401 | {USB_DEVICE(USB_VID_CYPRESS, USB_PID_OPERA1_COLD)}, | ||
402 | {USB_DEVICE(USB_VID_OPERA1, USB_PID_OPERA1_WARM)}, | ||
403 | {} | ||
404 | }; | ||
405 | |||
406 | MODULE_DEVICE_TABLE(usb, opera1_table); | ||
407 | |||
408 | static int opera1_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) | ||
409 | { | ||
410 | u8 command[] = { READ_MAC_ADDR }; | ||
411 | opera1_xilinx_rw(d->udev, 0xb1, 0xa0, command, 1, OPERA_WRITE_MSG); | ||
412 | opera1_xilinx_rw(d->udev, 0xb1, 0xa1, mac, 6, OPERA_READ_MSG); | ||
413 | return 0; | ||
414 | } | ||
415 | static int opera1_xilinx_load_firmware(struct usb_device *dev, | ||
416 | const char *filename) | ||
417 | { | ||
418 | const struct firmware *fw = NULL; | ||
419 | u8 *b, *p; | ||
420 | int ret = 0, i; | ||
421 | u8 testval; | ||
422 | info("start downloading fpga firmware"); | ||
423 | |||
424 | if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) { | ||
425 | err("did not find the firmware file. (%s) " | ||
426 | "Please see linux/Documentation/dvb/ for more details on firmware-problems.", | ||
427 | filename); | ||
428 | return ret; | ||
429 | } else { | ||
430 | p = kmalloc(fw->size, GFP_KERNEL); | ||
431 | opera1_xilinx_rw(dev, 0xbc, 0x00, &testval, 1, OPERA_READ_MSG); | ||
432 | if (p != NULL && testval != 0x67) { | ||
433 | |||
434 | u8 reset = 0, fpga_command = 0; | ||
435 | memcpy(p, fw->data, fw->size); | ||
436 | /* clear fpga ? */ | ||
437 | opera1_xilinx_rw(dev, 0xbc, 0xaa, &fpga_command, 1, | ||
438 | OPERA_WRITE_MSG); | ||
439 | for (i = 0; p[i] != 0 && i < fw->size;) { | ||
440 | b = (u8 *) p + i; | ||
441 | if (opera1_xilinx_rw | ||
442 | (dev, OPERA_WRITE_FX2, 0x0, b + 1, b[0], | ||
443 | OPERA_WRITE_MSG) != b[0] | ||
444 | ) { | ||
445 | err("error while transferring firmware"); | ||
446 | ret = -EINVAL; | ||
447 | break; | ||
448 | } | ||
449 | i = i + 1 + b[0]; | ||
450 | } | ||
451 | /* restart the CPU */ | ||
452 | if (ret || opera1_xilinx_rw | ||
453 | (dev, 0xa0, 0xe600, &reset, 1, | ||
454 | OPERA_WRITE_MSG) != 1) { | ||
455 | err("could not restart the USB controller CPU."); | ||
456 | ret = -EINVAL; | ||
457 | } | ||
458 | kfree(p); | ||
459 | } | ||
460 | } | ||
461 | if (fw) { | ||
462 | release_firmware(fw); | ||
463 | } | ||
464 | return ret; | ||
465 | } | ||
466 | |||
467 | static struct dvb_usb_device_properties opera1_properties = { | ||
468 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
469 | .usb_ctrl = CYPRESS_FX2, | ||
470 | .firmware = "opera.fw", | ||
471 | .size_of_priv = sizeof(struct opera1_state), | ||
472 | |||
473 | .power_ctrl = opera1_power_ctrl, | ||
474 | .i2c_algo = &opera1_i2c_algo, | ||
475 | |||
476 | .rc_key_map = opera1_rc_keys, | ||
477 | .rc_key_map_size = ARRAY_SIZE(opera1_rc_keys), | ||
478 | .rc_interval = 200, | ||
479 | .rc_query = opera1_rc_query, | ||
480 | .read_mac_address = opera1_read_mac_address, | ||
481 | .generic_bulk_ctrl_endpoint = 0x00, | ||
482 | /* parameter for the MPEG2-data transfer */ | ||
483 | .num_adapters = 1, | ||
484 | .adapter = { | ||
485 | { | ||
486 | .frontend_attach = opera1_frontend_attach, | ||
487 | .streaming_ctrl = opera1_streaming_ctrl, | ||
488 | .tuner_attach = opera1_tuner_attach, | ||
489 | .caps = | ||
490 | DVB_USB_ADAP_HAS_PID_FILTER | | ||
491 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
492 | .pid_filter = opera1_pid_filter, | ||
493 | .pid_filter_ctrl = opera1_pid_filter_control, | ||
494 | .pid_filter_count = 252, | ||
495 | .stream = { | ||
496 | .type = USB_BULK, | ||
497 | .count = 10, | ||
498 | .endpoint = 0x82, | ||
499 | .u = { | ||
500 | .bulk = { | ||
501 | .buffersize = 4096, | ||
502 | } | ||
503 | } | ||
504 | }, | ||
505 | } | ||
506 | }, | ||
507 | .num_device_descs = 1, | ||
508 | .devices = { | ||
509 | {"Opera1 DVB-S USB2.0", | ||
510 | {&opera1_table[0], NULL}, | ||
511 | {&opera1_table[1], NULL}, | ||
512 | }, | ||
513 | } | ||
514 | }; | ||
515 | |||
516 | static int opera1_probe(struct usb_interface *intf, | ||
517 | const struct usb_device_id *id) | ||
518 | { | ||
519 | struct dvb_usb_device *d; | ||
520 | struct usb_device *udev = interface_to_usbdev(intf); | ||
521 | |||
522 | if (udev->descriptor.idProduct == USB_PID_OPERA1_WARM && | ||
523 | udev->descriptor.idVendor == USB_VID_OPERA1 && | ||
524 | (d == NULL | ||
525 | || opera1_xilinx_load_firmware(udev, "opera1-fpga.fw") != 0) | ||
526 | ) { | ||
527 | return -EINVAL; | ||
528 | } | ||
529 | |||
530 | if (dvb_usb_device_init(intf, &opera1_properties, THIS_MODULE, &d) != 0) | ||
531 | return -EINVAL; | ||
532 | return 0; | ||
533 | } | ||
534 | |||
535 | static struct usb_driver opera1_driver = { | ||
536 | .name = "opera1", | ||
537 | .probe = opera1_probe, | ||
538 | .disconnect = dvb_usb_device_exit, | ||
539 | .id_table = opera1_table, | ||
540 | }; | ||
541 | |||
542 | static int __init opera1_module_init(void) | ||
543 | { | ||
544 | int result = 0; | ||
545 | if ((result = usb_register(&opera1_driver))) { | ||
546 | err("usb_register failed. Error number %d", result); | ||
547 | } | ||
548 | return result; | ||
549 | } | ||
550 | |||
551 | static void __exit opera1_module_exit(void) | ||
552 | { | ||
553 | usb_deregister(&opera1_driver); | ||
554 | } | ||
555 | |||
556 | module_init(opera1_module_init); | ||
557 | module_exit(opera1_module_exit); | ||
558 | |||
559 | MODULE_AUTHOR("Mario Hlawitschka (c) dh1pa@amsat.org"); | ||
560 | MODULE_AUTHOR("Marco Gittler (c) g.marco@freenet.de"); | ||
561 | MODULE_DESCRIPTION("Driver for Opera1 DVB-S device"); | ||
562 | MODULE_VERSION("0.1"); | ||
563 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/dvb-usb/opera1.h b/drivers/media/dvb/dvb-usb/opera1.h new file mode 100644 index 000000000000..53174427902d --- /dev/null +++ b/drivers/media/dvb/dvb-usb/opera1.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _OPERA1_H_ | ||
2 | #define _OPERA1_H_ | ||
3 | |||
4 | #define DVB_USB_LOG_PREFIX "opera" | ||
5 | #include "dvb-usb.h" | ||
6 | |||
7 | extern int dvb_usb_opera1_debug; | ||
8 | #define deb_xfer(args...) dprintk(dvb_usb_opera1_debug,0x02,args) | ||
9 | #endif | ||