1 /* DVB USB compliant linux driver for Technotrend DVB USB boxes and clones
2 * (e.g. Pinnacle 400e DVB-S USB2.0).
4 * The Pinnacle 400e uses the same protocol as the Technotrend USB1.1 boxes.
9 * 0x08 - LNBP21PD - LNB power supply
10 * 0x0e - TDA10086 - Demodulator
12 * 0x60 - TDA8263 - Tuner
15 * Copyright (c) 2002 Holger Waechtler <holger@convergence.de>
16 * Copyright (c) 2003 Felix Domke <tmbinc@elitedvb.net>
17 * Copyright (C) 2005-6 Patrick Boettcher <pb@linuxtv.org>
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the Free
21 * Software Foundation, version 2.
23 * see Documentation/dvb/README.dvb-usb for more information
25 #define DVB_USB_LOG_PREFIX "ttusb2"
35 static int dvb_usb_ttusb2_debug
;
36 #define deb_info(args...) dprintk(dvb_usb_ttusb2_debug,0x01,args)
37 module_param_named(debug
,dvb_usb_ttusb2_debug
, int, 0644);
38 MODULE_PARM_DESC(debug
, "set debugging level (1=info (or-able))." DVB_USB_DEBUG_STATUS
);
44 static int ttusb2_msg(struct dvb_usb_device
*d
, u8 cmd
,
45 u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
47 struct ttusb2_state
*st
= d
->priv
;
48 u8 s
[wlen
+4],r
[64] = { 0 };
57 memcpy(&s
[4],wbuf
,wlen
);
59 ret
= dvb_usb_generic_rw(d
, s
, wlen
+4, r
, 64, 0);
65 (rlen
> 0 && r
[3] != rlen
)) {
66 warn("there might have been an error during control message transfer. (rlen = %d, was %d)",rlen
,r
[3]);
71 memcpy(rbuf
, &r
[4], rlen
);
76 static int ttusb2_i2c_xfer(struct i2c_adapter
*adap
,struct i2c_msg msg
[],int num
)
78 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
79 static u8 obuf
[60], ibuf
[60];
82 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
86 warn("more than 2 i2c messages at a time is not handled yet. TODO.");
88 for (i
= 0; i
< num
; i
++) {
89 read
= i
+1 < num
&& (msg
[i
+1].flags
& I2C_M_RD
);
91 obuf
[0] = (msg
[i
].addr
<< 1) | read
;
96 obuf
[2] = msg
[i
+1].len
;
100 memcpy(&obuf
[3],msg
[i
].buf
,msg
[i
].len
);
102 if (ttusb2_msg(d
, CMD_I2C_XFER
, obuf
, msg
[i
].len
+3, ibuf
, obuf
[2] + 3) < 0) {
103 err("i2c transfer failed.");
108 memcpy(msg
[i
+1].buf
,&ibuf
[3],msg
[i
+1].len
);
113 mutex_unlock(&d
->i2c_mutex
);
117 static u32
ttusb2_i2c_func(struct i2c_adapter
*adapter
)
122 static struct i2c_algorithm ttusb2_i2c_algo
= {
123 .master_xfer
= ttusb2_i2c_xfer
,
124 .functionality
= ttusb2_i2c_func
,
127 /* Callbacks for DVB USB */
128 static int ttusb2_identify_state (struct usb_device
*udev
, struct
129 dvb_usb_device_properties
*props
, struct dvb_usb_device_description
**desc
,
132 *cold
= udev
->descriptor
.iManufacturer
== 0 && udev
->descriptor
.iProduct
== 0;
136 static int ttusb2_power_ctrl(struct dvb_usb_device
*d
, int onoff
)
139 ttusb2_msg(d
, CMD_POWER
, &b
, 0, NULL
, 0);
140 return ttusb2_msg(d
, CMD_POWER
, &b
, 1, NULL
, 0);
144 static struct tda10086_config tda10086_config
= {
145 .demod_address
= 0x0e,
147 <<<<<<< HEAD
:drivers
/media
/dvb
/dvb
-usb
/ttusb2
.c
150 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/media
/dvb
/dvb
-usb
/ttusb2
.c
153 static int ttusb2_frontend_attach(struct dvb_usb_adapter
*adap
)
155 if (usb_set_interface(adap
->dev
->udev
,0,3) < 0)
156 err("set interface to alts=3 failed");
158 if ((adap
->fe
= dvb_attach(tda10086_attach
, &tda10086_config
, &adap
->dev
->i2c_adap
)) == NULL
) {
159 deb_info("TDA10086 attach failed\n");
166 static int ttusb2_tuner_attach(struct dvb_usb_adapter
*adap
)
168 if (dvb_attach(tda826x_attach
, adap
->fe
, 0x60, &adap
->dev
->i2c_adap
, 0) == NULL
) {
169 deb_info("TDA8263 attach failed\n");
173 if (dvb_attach(lnbp21_attach
, adap
->fe
, &adap
->dev
->i2c_adap
, 0, 0) == NULL
) {
174 deb_info("LNBP21 attach failed\n");
180 /* DVB USB Driver stuff */
181 static struct dvb_usb_device_properties ttusb2_properties
;
183 static int ttusb2_probe(struct usb_interface
*intf
,
184 const struct usb_device_id
*id
)
186 return dvb_usb_device_init(intf
,&ttusb2_properties
,THIS_MODULE
,NULL
);
189 static struct usb_device_id ttusb2_table
[] = {
190 { USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PCTV_400E
) },
191 { USB_DEVICE(USB_VID_PINNACLE
, USB_PID_PCTV_450E
) },
192 {} /* Terminating entry */
194 MODULE_DEVICE_TABLE (usb
, ttusb2_table
);
196 static struct dvb_usb_device_properties ttusb2_properties
= {
197 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
199 .usb_ctrl
= CYPRESS_FX2
,
200 .firmware
= "dvb-usb-pctv-400e-01.fw",
202 .size_of_priv
= sizeof(struct ttusb2_state
),
207 .streaming_ctrl
= NULL
, // ttusb2_streaming_ctrl,
209 .frontend_attach
= ttusb2_frontend_attach
,
210 .tuner_attach
= ttusb2_tuner_attach
,
212 /* parameter for the MPEG2-data transfer */
228 .power_ctrl
= ttusb2_power_ctrl
,
229 .identify_state
= ttusb2_identify_state
,
231 .i2c_algo
= &ttusb2_i2c_algo
,
233 .generic_bulk_ctrl_endpoint
= 0x01,
235 .num_device_descs
= 2,
237 { "Pinnacle 400e DVB-S USB2.0",
238 { &ttusb2_table
[0], NULL
},
241 { "Pinnacle 450e DVB-S USB2.0",
242 { &ttusb2_table
[1], NULL
},
248 static struct usb_driver ttusb2_driver
= {
249 .name
= "dvb_usb_ttusb2",
250 .probe
= ttusb2_probe
,
251 .disconnect
= dvb_usb_device_exit
,
252 .id_table
= ttusb2_table
,
256 static int __init
ttusb2_module_init(void)
259 if ((result
= usb_register(&ttusb2_driver
))) {
260 err("usb_register failed. Error number %d",result
);
267 static void __exit
ttusb2_module_exit(void)
269 /* deregister this driver from the USB subsystem */
270 usb_deregister(&ttusb2_driver
);
273 module_init (ttusb2_module_init
);
274 module_exit (ttusb2_module_exit
);
276 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
277 MODULE_DESCRIPTION("Driver for Pinnacle PCTV 400e DVB-S USB2.0");
278 MODULE_VERSION("1.0");
279 MODULE_LICENSE("GPL");