1 /* DVB USB framework compliant Linux driver for the Hauppauge WinTV-NOVA-T usb2
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
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.
10 * see Documentation/dvb/README.dvb-usb for more information
15 module_param(debug, int, 0644);
16 MODULE_PARM_DESC(debug, "set debugging level (1=rc,2=eeprom (|-able))." DVB_USB_DEBUG_STATUS);
18 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
20 #define deb_rc(args...) dprintk(debug,0x01,args)
21 #define deb_ee(args...) dprintk(debug,0x02,args)
23 /* Hauppauge NOVA-T USB2 keys */
24 static struct rc_map_table rc_map_haupp_table[] = {
35 { 0x1e0a, KEY_KPASTERISK },
37 { 0x1e0c, KEY_RADIO },
39 { 0x1e0e, KEY_GRAVE }, /* # */
41 { 0x1e10, KEY_VOLUMEUP },
42 { 0x1e11, KEY_VOLUMEDOWN },
43 { 0x1e12, KEY_CHANNEL },
47 { 0x1e17, KEY_RIGHT },
48 { 0x1e18, KEY_VIDEO },
49 { 0x1e19, KEY_AUDIO },
50 { 0x1e1a, KEY_IMAGES },
55 { 0x1e20, KEY_CHANNELUP },
56 { 0x1e21, KEY_CHANNELDOWN },
57 { 0x1e24, KEY_LAST }, /* Skip backwards */
60 { 0x1e2e, KEY_GREEN },
61 { 0x1e30, KEY_PAUSE },
62 { 0x1e32, KEY_REWIND },
63 { 0x1e34, KEY_FASTFORWARD },
66 { 0x1e37, KEY_RECORD },
67 { 0x1e38, KEY_YELLOW },
69 { 0x1e3d, KEY_POWER },
72 /* Firmware bug? sometimes, when a new key is pressed, the previous pressed key
73 * is delivered. No workaround yet, maybe a new firmware.
75 static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
77 u8 key[5],cmd[2] = { DIBUSB_REQ_POLL_REMOTE, 0x35 }, data,toggle,custom;
80 struct dibusb_device_state *st = d->priv;
82 dvb_usb_generic_rw(d,cmd,2,key,5,0);
84 *state = REMOTE_NO_KEY_PRESSED;
86 case DIBUSB_RC_HAUPPAUGE_KEY_PRESSED:
87 raw = ((key[1] << 8) | key[2]) >> 3;
88 toggle = !!(raw & 0x800);
90 custom = (raw >> 6) & 0x1f;
92 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle);
94 for (i = 0; i < ARRAY_SIZE(rc_map_haupp_table); i++) {
95 if (rc5_data(&rc_map_haupp_table[i]) == data &&
96 rc5_custom(&rc_map_haupp_table[i]) == custom) {
98 deb_rc("c: %x, d: %x\n", rc5_data(&rc_map_haupp_table[i]),
99 rc5_custom(&rc_map_haupp_table[i]));
101 *event = rc_map_haupp_table[i].keycode;
102 *state = REMOTE_KEY_PRESSED;
103 if (st->old_toggle == toggle) {
104 if (st->last_repeat_count++ < 2)
105 *state = REMOTE_NO_KEY_PRESSED;
107 st->last_repeat_count = 0;
108 st->old_toggle = toggle;
115 case DIBUSB_RC_HAUPPAUGE_KEY_EMPTY:
123 static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
132 /* this is a complete guess, but works for my box */
133 for (i = 136; i < 139; i++) {
134 ret = dibusb_read_eeprom_byte(d, i, &b);
138 mac[5 - (i - 136)] = b;
144 /* USB Driver stuff */
145 static struct dvb_usb_device_properties nova_t_properties;
147 static int nova_t_probe(struct usb_interface *intf,
148 const struct usb_device_id *id)
150 return dvb_usb_device_init(intf, &nova_t_properties,
151 THIS_MODULE, NULL, adapter_nr);
154 /* do not change the order of the ID table */
155 static struct usb_device_id nova_t_table [] = {
156 /* 00 */ { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_WINTV_NOVA_T_USB2_COLD) },
157 /* 01 */ { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_WINTV_NOVA_T_USB2_WARM) },
158 { } /* Terminating entry */
160 MODULE_DEVICE_TABLE(usb, nova_t_table);
162 static struct dvb_usb_device_properties nova_t_properties = {
163 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
165 .usb_ctrl = CYPRESS_FX2,
166 .firmware = "/*(DEBLOBBED)*/",
173 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
174 .pid_filter_count = 32,
176 .streaming_ctrl = dibusb2_0_streaming_ctrl,
177 .pid_filter = dibusb_pid_filter,
178 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
179 .frontend_attach = dibusb_dib3000mc_frontend_attach,
180 .tuner_attach = dibusb_dib3000mc_tuner_attach,
182 /* parameter for the MPEG2-data transfer */
194 .size_of_priv = sizeof(struct dibusb_state),
197 .size_of_priv = sizeof(struct dibusb_device_state),
199 .power_ctrl = dibusb2_0_power_ctrl,
200 .read_mac_address = nova_t_read_mac_address,
204 .rc_map_table = rc_map_haupp_table,
205 .rc_map_size = ARRAY_SIZE(rc_map_haupp_table),
206 .rc_query = nova_t_rc_query,
209 .i2c_algo = &dibusb_i2c_algo,
211 .generic_bulk_ctrl_endpoint = 0x01,
213 .num_device_descs = 1,
215 { "Hauppauge WinTV-NOVA-T usb2",
216 { &nova_t_table[0], NULL },
217 { &nova_t_table[1], NULL },
223 static struct usb_driver nova_t_driver = {
224 .name = "dvb_usb_nova_t_usb2",
225 .probe = nova_t_probe,
226 .disconnect = dvb_usb_device_exit,
227 .id_table = nova_t_table,
230 module_usb_driver(nova_t_driver);
232 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
233 MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2");
234 MODULE_VERSION("1.0");
235 MODULE_LICENSE("GPL");