]> err.no Git - linux-2.6/blob - drivers/media/dvb/dvb-usb/dtt200u.c
[MTD] XIP cleanup
[linux-2.6] / drivers / media / dvb / dvb-usb / dtt200u.c
1 /* DVB USB library compliant Linux driver for the Yakumo/Hama/Typhoon DVB-T
2  * USB2.0 receiver.
3  *
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 */
15 int dvb_usb_dtt200u_debug;
16 module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644);
17 MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS);
18
19 static 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
31 static 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) */
46 static 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
67 static 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
77 static int dtt200u_frontend_attach(struct dvb_usb_device *d)
78 {
79         d->fe = dtt200u_fe_attach(d);
80         return 0;
81 }
82
83 static struct dvb_usb_properties dtt200u_properties;
84
85 static 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
91 static struct usb_device_id dtt200u_usb_table [] = {
92             { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_DTT200U_COLD) },
93             { USB_DEVICE(USB_VID_AVERMEDIA_UNK, USB_PID_DTT200U_WARM) },
94             { 0 },
95 };
96 MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
97
98 static 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 = {
130                 { .name = "Yakumo/Hama/Typhoon DVB-T USB2.0)",
131                   .cold_ids = { &dtt200u_usb_table[0], &dtt200u_usb_table[2] },
132                   .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 */
139 static struct usb_driver dtt200u_usb_driver = {
140         .owner          = THIS_MODULE,
141         .name           = "Yakumo/Hama/Typhoon DVB-T USB2.0",
142         .probe          = dtt200u_usb_probe,
143         .disconnect = dvb_usb_device_exit,
144         .id_table       = dtt200u_usb_table,
145 };
146
147 /* module stuff */
148 static 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
159 static void __exit dtt200u_usb_module_exit(void)
160 {
161         /* deregister this driver from the USB subsystem */
162         usb_deregister(&dtt200u_usb_driver);
163 }
164
165 module_init(dtt200u_usb_module_init);
166 module_exit(dtt200u_usb_module_exit);
167
168 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
169 MODULE_DESCRIPTION("Driver for the Yakumo/Hama/Typhoon DVB-T USB2.0 device");
170 MODULE_VERSION("1.0");
171 MODULE_LICENSE("GPL");