13 #define DVB_USB_LOG_PREFIX "opera"
18 #define OPERA_READ_MSG 0
19 #define OPERA_WRITE_MSG 1
20 #define OPERA_I2C_TUNER 0xd1
22 #define READ_FX2_REG_REQ 0xba
23 #define READ_MAC_ADDR 0x08
24 #define OPERA_WRITE_FX2 0xbb
25 #define OPERA_TUNER_REQ 0xb1
26 #define REG_1F_SYMBOLRATE_BYTE0 0x1f
27 #define REG_20_SYMBOLRATE_BYTE1 0x20
28 #define REG_21_SYMBOLRATE_BYTE2 0x21
30 #define ADDR_B600_VOLTAGE_13V (0x02)
31 #define ADDR_B601_VOLTAGE_18V (0x03)
32 #define ADDR_B1A6_STREAM_CTRL (0x04)
33 #define ADDR_B880_READ_REMOTE (0x05)
43 static int dvb_usb_opera1_debug;
46 "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))."
59 usb_rcvctrlpipe(dev,0) : usb_sndctrlpipe(dev, 0);
76 0x01, 0x0, buf, 1, 2000) < 1 || buf[0] != 0x08) {
99 info(
"no usb_device");
126 ret = opera1_xilinx_rw(dev->
udev, request,
145 for (i = 0; i < num; i++) {
146 if ((tmp = opera1_usb_i2c_msgxfer(d,
147 (msg[i].addr<<1)|(msg[i].flags&
I2C_M_RD?0x01:0),
153 if (dvb_usb_opera1_debug & 0x10)
154 info(
"sending i2c mesage %d %d", tmp, msg[i].len);
166 .master_xfer = opera1_i2c_xfer,
167 .functionality = opera1_i2c_func,
172 static u8 command_13v[1]={0x00};
173 static u8 command_18v[1]={0x01};
181 msg[0].
buf = command_18v;
187 static int opera1_stv0299_set_symbol_rate(
struct dvb_frontend *fe,
u32 srate,
190 stv0299_writereg(fe, 0x13, 0x98);
191 stv0299_writereg(fe, 0x14, 0x95);
198 static u8 opera1_inittab[] = {
253 .demod_address = 0xd0>>1,
260 .inittab = opera1_inittab,
261 .set_symbol_rate = opera1_stv0299_set_symbol_rate,
269 d->
fe_adap[0].fe->ops.set_voltage = opera1_set_voltage;
272 info(
"not attached stv0299");
287 u8 val = onoff ? 0x01 : 0x00;
289 if (dvb_usb_opera1_debug)
290 info(
"power %s", onoff ?
"on" :
"off");
291 return opera1_xilinx_rw(d->
udev, 0xb7, val,
295 static int opera1_streaming_ctrl(
struct dvb_usb_adapter *adap,
int onoff)
297 static u8 buf_start[2] = { 0xff, 0x03 };
298 static u8 buf_stop[2] = { 0xff, 0x00 };
299 struct i2c_msg start_tuner[] = {
302 if (dvb_usb_opera1_debug)
303 info(
"streaming %s", onoff ?
"on" :
"off");
315 if (dvb_usb_opera1_debug)
316 info(
"pidfilter index: %d pid: %d %s", index, pid,
317 onoff ?
"on" :
"off");
318 b_pid[0] = (2 *
index) + 4;
319 b_pid[1] = onoff ? (pid & 0xff) : (0x00);
320 b_pid[2] = onoff ? ((pid >> 8) & 0xff) : (0x00);
325 static int opera1_pid_filter_control(
struct dvb_usb_adapter *adap,
int onoff)
332 if (dvb_usb_opera1_debug)
333 info(
"%s hw-pidfilter", onoff ?
"enable" :
"disable");
334 for (; u < 0x7e; u += 2) {
376 const u16 startmarker1 = 0x10ed;
377 const u16 startmarker2 = 0x11ec;
378 struct i2c_msg read_remote[] = {
385 for (i = 0; i < 32; i++) {
389 send_key = send_key << 1;
391 if (send_key & 0x8000)
392 send_key = (send_key << 1) | (send_key >> 15 & 0x01);
399 for (; send_key != 0;) {
400 if (send_key >> 16 == startmarker2) {
402 }
else if (send_key >> 16 == startmarker1) {
404 (send_key & 0xfffeffff) | (startmarker1 << 16);
413 send_key = (send_key & 0xffff) | 0x0100;
415 for (i = 0; i <
ARRAY_SIZE(rc_map_opera1_table); i++) {
416 if (rc5_scan(&rc_map_opera1_table[i]) == (send_key & 0xffff)) {
418 *
event = rc_map_opera1_table[
i].
keycode;
445 static int opera1_xilinx_load_firmware(
struct usb_device *dev,
450 int ret = 0,
i,fpgasize=40;
452 info(
"start downloading fpga firmware %s",filename);
455 err(
"did not find the firmware file. (%s) "
456 "Please see linux/Documentation/dvb/ for more details on firmware-problems.",
462 if (p !=
NULL && testval != 0x67) {
464 u8 reset = 0, fpga_command = 0;
467 opera1_xilinx_rw(dev, 0xbc, 0xaa, &fpga_command, 1,
469 for (i = 0; i < fw->
size;) {
470 if ( (fw->
size - i) <fpgasize){
478 err(
"error while transferring firmware");
485 if (ret || opera1_xilinx_rw
486 (dev, 0xa0, 0xe600, &reset, 1,
488 err(
"could not restart the USB controller CPU.");
501 .firmware =
"dvb-usb-opera-01.fw",
504 .power_ctrl = opera1_power_ctrl,
505 .i2c_algo = &opera1_i2c_algo,
508 .rc_map_table = rc_map_opera1_table,
509 .rc_map_size =
ARRAY_SIZE(rc_map_opera1_table),
511 .rc_query = opera1_rc_query,
513 .read_mac_address = opera1_read_mac_address,
514 .generic_bulk_ctrl_endpoint = 0x00,
521 .frontend_attach = opera1_frontend_attach,
522 .streaming_ctrl = opera1_streaming_ctrl,
523 .tuner_attach = opera1_tuner_attach,
527 .pid_filter = opera1_pid_filter,
528 .pid_filter_ctrl = opera1_pid_filter_control,
529 .pid_filter_count = 252,
543 .num_device_descs = 1,
545 {
"Opera1 DVB-S USB2.0",
546 {&opera1_table[0],
NULL},
547 {&opera1_table[1],
NULL},
555 struct usb_device *
udev = interface_to_usbdev(intf);
559 opera1_xilinx_load_firmware(udev,
"dvb-usb-opera1-fpga-01.fw") != 0
570 static struct usb_driver opera1_driver = {
572 .probe = opera1_probe,
574 .id_table = opera1_table,