2 * DVB USB Linux driver for Alcor Micro AU6610 DVB-T USB2.0.
4 * Copyright (C) 2006 Antti Palosaari <crope@iki.fi>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 static int dvb_usb_au6610_debug
;
27 module_param_named(debug
, dvb_usb_au6610_debug
, int, 0644);
28 MODULE_PARM_DESC(debug
, "set debugging level" DVB_USB_DEBUG_STATUS
);
29 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
31 static int au6610_usb_msg(struct dvb_usb_device
*d
, u8 operation
, u8 addr
,
32 u8
*wbuf
, u16 wlen
, u8
*rbuf
, u16 rlen
)
39 * allocate enough for all known requests,
40 * read returns 5 and write 6 bytes
42 usb_buf
= kmalloc(6, GFP_KERNEL
);
55 warn("wlen = %x, aborting.", wlen
);
60 ret
= usb_control_msg(d
->udev
, usb_rcvctrlpipe(d
->udev
, 0), operation
,
61 USB_TYPE_VENDOR
|USB_DIR_IN
, addr
<< 1, index
,
62 usb_buf
, 6, AU6610_USB_TIMEOUT
);
67 case AU6610_REQ_I2C_READ
:
68 case AU6610_REQ_USB_READ
:
69 /* requested value is always 5th byte in buffer */
77 static int au6610_i2c_msg(struct dvb_usb_device
*d
, u8 addr
,
78 u8
*wbuf
, u16 wlen
, u8
*rbuf
, u16 rlen
)
81 u8 wo
= (rbuf
== NULL
|| rlen
== 0); /* write-only */
84 request
= AU6610_REQ_I2C_WRITE
;
86 request
= AU6610_REQ_I2C_READ
;
89 return au6610_usb_msg(d
, request
, addr
, wbuf
, wlen
, rbuf
, rlen
);
94 static int au6610_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
97 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
103 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
106 for (i
= 0; i
< num
; i
++) {
107 /* write/read request */
108 if (i
+1 < num
&& (msg
[i
+1].flags
& I2C_M_RD
)) {
109 if (au6610_i2c_msg(d
, msg
[i
].addr
, msg
[i
].buf
,
110 msg
[i
].len
, msg
[i
+1].buf
,
114 } else if (au6610_i2c_msg(d
, msg
[i
].addr
, msg
[i
].buf
,
115 msg
[i
].len
, NULL
, 0) < 0)
119 mutex_unlock(&d
->i2c_mutex
);
124 static u32
au6610_i2c_func(struct i2c_adapter
*adapter
)
129 static struct i2c_algorithm au6610_i2c_algo
= {
130 .master_xfer
= au6610_i2c_xfer
,
131 .functionality
= au6610_i2c_func
,
134 /* Callbacks for DVB USB */
135 static struct zl10353_config au6610_zl10353_config
= {
136 .demod_address
= 0x0f,
141 static int au6610_zl10353_frontend_attach(struct dvb_usb_adapter
*adap
)
143 adap
->fe_adap
[0].fe
= dvb_attach(zl10353_attach
, &au6610_zl10353_config
,
144 &adap
->dev
->i2c_adap
);
145 if (adap
->fe_adap
[0].fe
== NULL
)
151 static struct qt1010_config au6610_qt1010_config
= {
155 static int au6610_qt1010_tuner_attach(struct dvb_usb_adapter
*adap
)
157 return dvb_attach(qt1010_attach
,
158 adap
->fe_adap
[0].fe
, &adap
->dev
->i2c_adap
,
159 &au6610_qt1010_config
) == NULL
? -ENODEV
: 0;
162 /* DVB USB Driver stuff */
163 static struct dvb_usb_device_properties au6610_properties
;
165 static int au6610_probe(struct usb_interface
*intf
,
166 const struct usb_device_id
*id
)
168 struct dvb_usb_device
*d
;
169 struct usb_host_interface
*alt
;
172 if (intf
->num_altsetting
< AU6610_ALTSETTING_COUNT
)
175 ret
= dvb_usb_device_init(intf
, &au6610_properties
, THIS_MODULE
, &d
,
178 alt
= usb_altnum_to_altsetting(intf
, AU6610_ALTSETTING
);
181 deb_info("%s: no alt found!\n", __func__
);
184 ret
= usb_set_interface(d
->udev
, alt
->desc
.bInterfaceNumber
,
185 alt
->desc
.bAlternateSetting
);
191 static struct usb_device_id au6610_table
[] = {
192 { USB_DEVICE(USB_VID_ALCOR_MICRO
, USB_PID_SIGMATEK_DVB_110
) },
193 { } /* Terminating entry */
195 MODULE_DEVICE_TABLE(usb
, au6610_table
);
197 static struct dvb_usb_device_properties au6610_properties
= {
198 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
200 .usb_ctrl
= DEVICE_SPECIFIC
,
209 .frontend_attach
= au6610_zl10353_frontend_attach
,
210 .tuner_attach
= au6610_qt1010_tuner_attach
,
228 .i2c_algo
= &au6610_i2c_algo
,
230 .num_device_descs
= 1,
233 .name
= "Sigmatek DVB-110 DVB-T USB2.0",
235 .warm_ids
= {&au6610_table
[0], NULL
},
240 static struct usb_driver au6610_driver
= {
241 .name
= "dvb_usb_au6610",
242 .probe
= au6610_probe
,
243 .disconnect
= dvb_usb_device_exit
,
244 .id_table
= au6610_table
,
247 module_usb_driver(au6610_driver
);
249 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
250 MODULE_DESCRIPTION("Driver for Alcor Micro AU6610 DVB-T USB2.0");
251 MODULE_VERSION("0.1");
252 MODULE_LICENSE("GPL");