blob: 1ebd3eff96d11379f84635a48e736f2294a1443b [file] [log] [blame]
Patrick Boettcherfb41f5a2005-07-07 17:58:23 -07001/* DVB USB library compliant Linux driver for the WideView/ Yakumo/ Hama/
2 * Typhoon/ Yuan DVB-T USB2.0 receiver.
Johannes Stezenbach776338e2005-06-23 22:02:35 -07003 *
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
5 *
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.
9 *
10 * see Documentation/dvb/README.dvb-usb for more information
11 */
12#include "dtt200u.h"
13
14/* debug */
15int dvb_usb_dtt200u_debug;
16module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644);
17MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS);
18
19static int dtt200u_streaming_ctrl(struct dvb_usb_device *d, int onoff)
20{
21 u8 b_streaming[2] = { SET_TS_CTRL, onoff };
22 u8 b_rst_pid = RESET_PID_FILTER;
23
24 dvb_usb_generic_write(d,b_streaming,2);
25
26 if (!onoff)
27 dvb_usb_generic_write(d,&b_rst_pid,1);
28 return 0;
29}
30
31static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
32{
33 u8 b_pid[4];
34 pid = onoff ? pid : 0;
35
36 b_pid[0] = SET_PID_FILTER;
37 b_pid[1] = index;
38 b_pid[2] = pid & 0xff;
39 b_pid[3] = (pid >> 8) & 0xff;
40
41 return dvb_usb_generic_write(d,b_pid,4);
42}
43
44/* remote control */
45/* key list for the tiny remote control (Yakumo, don't know about the others) */
46static struct dvb_usb_rc_key dtt200u_rc_keys[] = {
47 { 0x80, 0x01, KEY_MUTE },
48 { 0x80, 0x02, KEY_CHANNELDOWN },
49 { 0x80, 0x03, KEY_VOLUMEDOWN },
50 { 0x80, 0x04, KEY_1 },
51 { 0x80, 0x05, KEY_2 },
52 { 0x80, 0x06, KEY_3 },
53 { 0x80, 0x07, KEY_4 },
54 { 0x80, 0x08, KEY_5 },
55 { 0x80, 0x09, KEY_6 },
56 { 0x80, 0x0a, KEY_7 },
57 { 0x00, 0x0c, KEY_ZOOM },
58 { 0x80, 0x0d, KEY_0 },
59 { 0x00, 0x0e, KEY_SELECT },
60 { 0x80, 0x12, KEY_POWER },
61 { 0x80, 0x1a, KEY_CHANNELUP },
62 { 0x80, 0x1b, KEY_8 },
63 { 0x80, 0x1e, KEY_VOLUMEUP },
64 { 0x80, 0x1f, KEY_9 },
65};
66
67static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
68{
69 u8 key[5],cmd = GET_RC_KEY;
70 dvb_usb_generic_rw(d,&cmd,1,key,5,0);
71 dvb_usb_nec_rc_key_to_event(d,key,event,state);
72 if (key[0] != 0)
73 deb_info("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
74 return 0;
75}
76
77static int dtt200u_frontend_attach(struct dvb_usb_device *d)
78{
79 d->fe = dtt200u_fe_attach(d);
80 return 0;
81}
82
83static struct dvb_usb_properties dtt200u_properties;
84
85static int dtt200u_usb_probe(struct usb_interface *intf,
86 const struct usb_device_id *id)
87{
88 return dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE);
89}
90
91static struct usb_device_id dtt200u_usb_table [] = {
Patrick Boettcherfb41f5a2005-07-07 17:58:23 -070092 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) },
93 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) },
Johannes Stezenbach776338e2005-06-23 22:02:35 -070094 { 0 },
95};
96MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
97
98static struct dvb_usb_properties dtt200u_properties = {
99 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
100 .pid_filter_count = 255, /* It is a guess, but there are at least 10 */
101
102 .usb_ctrl = CYPRESS_FX2,
103 .firmware = "dvb-usb-dtt200u-01.fw",
104
105 .streaming_ctrl = dtt200u_streaming_ctrl,
106 .pid_filter = dtt200u_pid_filter,
107 .frontend_attach = dtt200u_frontend_attach,
108
109 .rc_interval = 200,
110 .rc_key_map = dtt200u_rc_keys,
111 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
112 .rc_query = dtt200u_rc_query,
113
114 .generic_bulk_ctrl_endpoint = 0x01,
115
116 /* parameter for the MPEG2-data transfer */
117 .urb = {
118 .type = DVB_USB_BULK,
119 .count = 7,
120 .endpoint = 0x02,
121 .u = {
122 .bulk = {
123 .buffersize = 4096,
124 }
125 }
126 },
127
128 .num_device_descs = 1,
129 .devices = {
Patrick Boettcherfb41f5a2005-07-07 17:58:23 -0700130 { .name = "WideView/Yakumo/Hama/Typhoon DVB-T USB2.0)",
131 .cold_ids = { &dtt200u_usb_table[0], NULL },
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700132 .warm_ids = { &dtt200u_usb_table[1], NULL },
133 },
134 { 0 },
135 }
136};
137
138/* usb specific object needed to register this driver with the usb subsystem */
139static struct usb_driver dtt200u_usb_driver = {
140 .owner = THIS_MODULE,
Patrick Boettcherfb41f5a2005-07-07 17:58:23 -0700141 .name = "dtt200u",
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700142 .probe = dtt200u_usb_probe,
143 .disconnect = dvb_usb_device_exit,
144 .id_table = dtt200u_usb_table,
145};
146
147/* module stuff */
148static int __init dtt200u_usb_module_init(void)
149{
150 int result;
151 if ((result = usb_register(&dtt200u_usb_driver))) {
152 err("usb_register failed. (%d)",result);
153 return result;
154 }
155
156 return 0;
157}
158
159static void __exit dtt200u_usb_module_exit(void)
160{
161 /* deregister this driver from the USB subsystem */
162 usb_deregister(&dtt200u_usb_driver);
163}
164
165module_init(dtt200u_usb_module_init);
166module_exit(dtt200u_usb_module_exit);
167
168MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
Patrick Boettcherfb41f5a2005-07-07 17:58:23 -0700169MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon DVB-T USB2.0 device");
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700170MODULE_VERSION("1.0");
171MODULE_LICENSE("GPL");