diff options
author | Patrick Boettcher <devnull@localhost> | 2005-03-30 12:40:31 +0000 |
---|---|---|
committer | Patrick Boettcher <devnull@localhost> | 2005-03-30 12:40:31 +0000 |
commit | 201fa3b5e4bf5879ef6b24ac555b4c8c1e378282 (patch) | |
tree | a720cd3376efb93bfcf13cfb5f3946c12932c782 /linux/drivers/media/dvb/dvb-usb/vp7045.c | |
parent | 68d4a468a95777934e2659e8f4bb4095a55969ca (diff) | |
download | mediapointer-dvb-s2-201fa3b5e4bf5879ef6b24ac555b4c8c1e378282.tar.gz mediapointer-dvb-s2-201fa3b5e4bf5879ef6b24ac555b4c8c1e378282.tar.bz2 |
Added support for the TwinhanDTV Alpha/MagicBox II USB2 DVB-T device in
conjunction with a neat dvb-usb-lib. All dibusb-drivers will be merged to it in
the near future.
Diffstat (limited to 'linux/drivers/media/dvb/dvb-usb/vp7045.c')
-rw-r--r-- | linux/drivers/media/dvb/dvb-usb/vp7045.c | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/linux/drivers/media/dvb/dvb-usb/vp7045.c b/linux/drivers/media/dvb/dvb-usb/vp7045.c new file mode 100644 index 000000000..97a95d513 --- /dev/null +++ b/linux/drivers/media/dvb/dvb-usb/vp7045.c @@ -0,0 +1,193 @@ +#include "vp7045.h" + +/* debug */ +int dvb_usb_vp7045_debug; +module_param_named(debug,dvb_usb_vp7045_debug, int, 0644); +MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS); + +int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec) +{ + int ret = 0; + u8 inbuf[12] = { 0 }, outbuf[20] = { 0 }; + + outbuf[0] = cmd; + + if (outlen > 19) + outlen = 19; + + if (inlen > 11) + inlen = 11; + + if (out != NULL && outlen > 0) + memcpy(&outbuf[1], out, outlen); + + deb_xfer("out buffer: "); + debug_dump(outbuf,outlen+1,deb_xfer); + + if ((ret = down_interruptible(&d->usb_sem))) + return ret; + + if (usb_control_msg(d->udev, + usb_sndctrlpipe(d->udev,0), + TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, + outbuf, 20, 2*HZ) != 20) { + err("USB control message 'out' went wrong."); + ret = -EIO; + goto unlock; + } + + msleep(msec); + + if (usb_control_msg(d->udev, + usb_rcvctrlpipe(d->udev,0), + TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, + inbuf, 12, 2*HZ) != 12) { + err("USB control message 'in' went wrong."); + ret = -EIO; + goto unlock; + } + + deb_xfer("in buffer: "); + debug_dump(inbuf,12,deb_xfer); + + if (in != NULL && inlen > 0) + memcpy(in,&inbuf[1],inlen); + +unlock: + up(&d->usb_sem); + + return ret; +} + +u8 vp7045_read_reg(struct dvb_usb_device *d, u8 reg) +{ + u8 obuf[2] = { 0 },v; + obuf[1] = reg; + + vp7045_usb_op(d,TUNER_REG_READ,obuf,2,&v,1,30); + + return v; +} + +static int vp7045_power_ctrl(struct dvb_usb_device *d, int onoff) +{ + u8 v = onoff; + deb_info("power control: %s\n",onoff ? "on" : "off"); + + return vp7045_usb_op(d,SET_TUNER_POWER,&v,1,NULL,0,150); +} + +static int vp7045_rc_query(struct dvb_usb_device *d, u8 *key_buf, int *state) +{ + deb_info("remote query\n"); + *state = REMOTE_KEY_NO; + return 0; //vp7045_usb_op(d,RC_VAL_READ,&v,1,NULL,0,20); +} + +static int vp7045_frontend_attach(struct dvb_usb_device *d) +{ + u8 buf[20]; + + vp7045_usb_op(d,VENDOR_STRING_READ,NULL,0,buf,20,0); + buf[10] = '\0'; + deb_info("firmware says: %s ",buf); + + vp7045_usb_op(d,PRODUCT_STRING_READ,NULL,0,buf,20,0); + buf[10] = '\0'; + deb_info("%s ",buf); + + vp7045_usb_op(d,FW_VERSION_READ,NULL,0,buf,20,0); + buf[10] = '\0'; + deb_info("v%s\n",buf); + + d->fe = vp7045_fe_attach(d); + + return 0; +} + +static struct dvb_usb_properties vp7045_properties; + +static int vp7045_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + return dvb_usb_device_init(intf,&vp7045_properties); +} + +static struct usb_device_id vp7045_usb_table [] = { + { USB_DEVICE(0x13d3, 0x3205) }, + { USB_DEVICE(0x13d3, 0x3206) }, + { 0 }, +}; + +static struct dvb_usb_properties vp7045_properties = { + .caps = 0, + + .usb_ctrl = CYPRESS_FX2, + .firmware = "dvb-usb-vp7045-01.fw", + + .streaming_ctrl = NULL, + .pid_filter = NULL, + .pid_filter_ctrl = NULL, + .power_ctrl = vp7045_power_ctrl, + .frontend_attach = vp7045_frontend_attach, + + .rc_interval = 400, + .remote_protocol = USB_REMOTE_PROTO_NEC, + .query_rc = vp7045_rc_query, + + /* parameter for the MPEG2-data transfer */ + .urb = { + .type = DVB_USB_BULK, + .count = 7, + .endpoint = 0x02, + .u { + .bulk = { + .buffersize = 4096, + } + } + }, + + .num_device_descs = 1, + .devices = { + { .name = "Twinhan USB2.0 DVB-T receiver (TwinhanDTV Alpha/MagicBox II)", + .cold_ids = { &vp7045_usb_table[0], NULL }, + .warm_ids = { &vp7045_usb_table[1], NULL }, + }, + { 0 }, + } +}; + +/* usb specific object needed to register this driver with the usb subsystem */ +static struct usb_driver vp7045_usb_driver = { + .owner = THIS_MODULE, + .name = "Twinhan DVB-T USB2.0", + .probe = vp7045_usb_probe, + .disconnect = dvb_usb_device_exit, + .id_table = vp7045_usb_table, +}; + +/* module stuff */ +static int __init vp7045_usb_module_init(void) +{ + int result; + if ((result = usb_register(&vp7045_usb_driver))) { + err("usb_register failed. (%d)",result); + return result; + } + + return 0; +} + +static void __exit vp7045_usb_module_exit(void) +{ + /* deregister this driver from the USB subsystem */ + usb_deregister(&vp7045_usb_driver); +} + +module_init(vp7045_usb_module_init); +module_exit(vp7045_usb_module_exit); + +MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); +MODULE_DESCRIPTION("Twinhan MagicBox/Alpha DVB-T USB2.0"); +MODULE_VERSION("0.1"); +MODULE_LICENSE("GPL"); |