1 // SPDX-License-Identifier: GPL-2.0-only
2 /* DVB USB framework compliant Linux driver for the Hauppauge WinTV-NOVA-T usb2
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
7 * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
12 module_param(debug, int, 0644);
13 MODULE_PARM_DESC(debug, "set debugging level (1=rc,2=eeprom (|-able))." DVB_USB_DEBUG_STATUS);
15 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
17 #define deb_rc(args...) dprintk(debug,0x01,args)
18 #define deb_ee(args...) dprintk(debug,0x02,args)
20 /* Hauppauge NOVA-T USB2 keys */
21 static struct rc_map_table rc_map_haupp_table[] = {
32 { 0x1e0a, KEY_KPASTERISK },
34 { 0x1e0c, KEY_RADIO },
36 { 0x1e0e, KEY_GRAVE }, /* # */
38 { 0x1e10, KEY_VOLUMEUP },
39 { 0x1e11, KEY_VOLUMEDOWN },
40 { 0x1e12, KEY_CHANNEL },
44 { 0x1e17, KEY_RIGHT },
45 { 0x1e18, KEY_VIDEO },
46 { 0x1e19, KEY_AUDIO },
47 { 0x1e1a, KEY_IMAGES },
52 { 0x1e20, KEY_CHANNELUP },
53 { 0x1e21, KEY_CHANNELDOWN },
54 { 0x1e24, KEY_LAST }, /* Skip backwards */
57 { 0x1e2e, KEY_GREEN },
58 { 0x1e30, KEY_PAUSE },
59 { 0x1e32, KEY_REWIND },
60 { 0x1e34, KEY_FASTFORWARD },
63 { 0x1e37, KEY_RECORD },
64 { 0x1e38, KEY_YELLOW },
66 { 0x1e3d, KEY_POWER },
69 /* Firmware bug? sometimes, when a new key is pressed, the previous pressed key
70 * is delivered. No workaround yet, maybe a new firmware.
72 static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
74 u8 *buf, data, toggle, custom;
77 struct dibusb_device_state *st = d->priv;
79 buf = kmalloc(5, GFP_KERNEL);
83 buf[0] = DIBUSB_REQ_POLL_REMOTE;
85 ret = dvb_usb_generic_rw(d, buf, 2, buf, 5, 0);
89 *state = REMOTE_NO_KEY_PRESSED;
91 case DIBUSB_RC_HAUPPAUGE_KEY_PRESSED:
92 raw = ((buf[1] << 8) | buf[2]) >> 3;
93 toggle = !!(raw & 0x800);
95 custom = (raw >> 6) & 0x1f;
97 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",
98 buf[1], buf[2], buf[3], custom, data, toggle);
100 for (i = 0; i < ARRAY_SIZE(rc_map_haupp_table); i++) {
101 if (rc5_data(&rc_map_haupp_table[i]) == data &&
102 rc5_custom(&rc_map_haupp_table[i]) == custom) {
104 deb_rc("c: %x, d: %x\n", rc5_data(&rc_map_haupp_table[i]),
105 rc5_custom(&rc_map_haupp_table[i]));
107 *event = rc_map_haupp_table[i].keycode;
108 *state = REMOTE_KEY_PRESSED;
109 if (st->old_toggle == toggle) {
110 if (st->last_repeat_count++ < 2)
111 *state = REMOTE_NO_KEY_PRESSED;
113 st->last_repeat_count = 0;
114 st->old_toggle = toggle;
121 case DIBUSB_RC_HAUPPAUGE_KEY_EMPTY:
131 static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
140 /* this is a complete guess, but works for my box */
141 for (i = 136; i < 139; i++) {
142 ret = dibusb_read_eeprom_byte(d, i, &b);
146 mac[5 - (i - 136)] = b;
152 /* USB Driver stuff */
153 static struct dvb_usb_device_properties nova_t_properties;
155 static int nova_t_probe(struct usb_interface *intf,
156 const struct usb_device_id *id)
158 return dvb_usb_device_init(intf, &nova_t_properties,
159 THIS_MODULE, NULL, adapter_nr);
162 /* do not change the order of the ID table */
164 HAUPPAUGE_WINTV_NOVA_T_USB2_COLD,
165 HAUPPAUGE_WINTV_NOVA_T_USB2_WARM,
168 static struct usb_device_id nova_t_table[] = {
169 DVB_USB_DEV(HAUPPAUGE, HAUPPAUGE_WINTV_NOVA_T_USB2_COLD),
170 DVB_USB_DEV(HAUPPAUGE, HAUPPAUGE_WINTV_NOVA_T_USB2_WARM),
174 MODULE_DEVICE_TABLE(usb, nova_t_table);
176 static struct dvb_usb_device_properties nova_t_properties = {
177 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
179 .usb_ctrl = CYPRESS_FX2,
180 .firmware = "/*(DEBLOBBED)*/",
187 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
188 .pid_filter_count = 32,
190 .streaming_ctrl = dibusb2_0_streaming_ctrl,
191 .pid_filter = dibusb_pid_filter,
192 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
193 .frontend_attach = dibusb_dib3000mc_frontend_attach,
194 .tuner_attach = dibusb_dib3000mc_tuner_attach,
196 /* parameter for the MPEG2-data transfer */
208 .size_of_priv = sizeof(struct dibusb_state),
211 .size_of_priv = sizeof(struct dibusb_device_state),
213 .power_ctrl = dibusb2_0_power_ctrl,
214 .read_mac_address = nova_t_read_mac_address,
218 .rc_map_table = rc_map_haupp_table,
219 .rc_map_size = ARRAY_SIZE(rc_map_haupp_table),
220 .rc_query = nova_t_rc_query,
223 .i2c_algo = &dibusb_i2c_algo,
225 .generic_bulk_ctrl_endpoint = 0x01,
227 .num_device_descs = 1,
229 { "Hauppauge WinTV-NOVA-T usb2",
230 { &nova_t_table[HAUPPAUGE_WINTV_NOVA_T_USB2_COLD], NULL },
231 { &nova_t_table[HAUPPAUGE_WINTV_NOVA_T_USB2_WARM], NULL },
237 static struct usb_driver nova_t_driver = {
238 .name = "dvb_usb_nova_t_usb2",
239 .probe = nova_t_probe,
240 .disconnect = dvb_usb_device_exit,
241 .id_table = nova_t_table,
244 module_usb_driver(nova_t_driver);
246 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
247 MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2");
248 MODULE_VERSION("1.0");
249 MODULE_LICENSE("GPL");