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 dibusb_read_eeprom_byte(d
,i
, &b
);
144 mac
[5 - (i
- 136)] = b
;
150 /* USB Driver stuff */
151 static struct dvb_usb_device_properties nova_t_properties
;
153 static int nova_t_probe(struct usb_interface
*intf
,
154 const struct usb_device_id
*id
)
156 return dvb_usb_device_init(intf
, &nova_t_properties
,
157 THIS_MODULE
, NULL
, adapter_nr
);
160 /* do not change the order of the ID table */
161 static struct usb_device_id nova_t_table
[] = {
162 /* 00 */ { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_WINTV_NOVA_T_USB2_COLD
) },
163 /* 01 */ { USB_DEVICE(USB_VID_HAUPPAUGE
, USB_PID_WINTV_NOVA_T_USB2_WARM
) },
164 { } /* Terminating entry */
166 MODULE_DEVICE_TABLE(usb
, nova_t_table
);
168 static struct dvb_usb_device_properties nova_t_properties
= {
169 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
171 .usb_ctrl
= CYPRESS_FX2
,
172 .firmware
= "dvb-usb-nova-t-usb2-02.fw",
179 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
| DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
180 .pid_filter_count
= 32,
182 .streaming_ctrl
= dibusb2_0_streaming_ctrl
,
183 .pid_filter
= dibusb_pid_filter
,
184 .pid_filter_ctrl
= dibusb_pid_filter_ctrl
,
185 .frontend_attach
= dibusb_dib3000mc_frontend_attach
,
186 .tuner_attach
= dibusb_dib3000mc_tuner_attach
,
188 /* parameter for the MPEG2-data transfer */
200 .size_of_priv
= sizeof(struct dibusb_state
),
203 .size_of_priv
= sizeof(struct dibusb_device_state
),
205 .power_ctrl
= dibusb2_0_power_ctrl
,
206 .read_mac_address
= nova_t_read_mac_address
,
210 .rc_map_table
= rc_map_haupp_table
,
211 .rc_map_size
= ARRAY_SIZE(rc_map_haupp_table
),
212 .rc_query
= nova_t_rc_query
,
215 .i2c_algo
= &dibusb_i2c_algo
,
217 .generic_bulk_ctrl_endpoint
= 0x01,
219 .num_device_descs
= 1,
221 { "Hauppauge WinTV-NOVA-T usb2",
222 { &nova_t_table
[0], NULL
},
223 { &nova_t_table
[1], NULL
},
229 static struct usb_driver nova_t_driver
= {
230 .name
= "dvb_usb_nova_t_usb2",
231 .probe
= nova_t_probe
,
232 .disconnect
= dvb_usb_device_exit
,
233 .id_table
= nova_t_table
,
236 module_usb_driver(nova_t_driver
);
238 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
239 MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2");
240 MODULE_VERSION("1.0");
241 MODULE_LICENSE("GPL");