aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-06-12 15:45:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-04 06:56:31 -0400
commit3eee04722fa18f8e1db1730b2e508b6eb6f5336b (patch)
treefaf40a63212131139ad958298e1fe32906b051b4
parentf093c388ef8ceff605f267ae9bc212ad98543ce6 (diff)
[media] ec168: convert to new DVB USB
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-usb/ec168.c259
-rw-r--r--drivers/media/dvb/dvb-usb/ec168.h12
3 files changed, 119 insertions, 154 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 3e75fcdb33c..abbfd528a8d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -374,7 +374,7 @@ config DVB_USB_FRIIO
374 374
375config DVB_USB_EC168 375config DVB_USB_EC168
376 tristate "E3C EC168 DVB-T USB2.0 support" 376 tristate "E3C EC168 DVB-T USB2.0 support"
377 depends on DVB_USB 377 depends on DVB_USB_V2
378 select DVB_EC100 378 select DVB_EC100
379 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE 379 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE
380 help 380 help
diff --git a/drivers/media/dvb/dvb-usb/ec168.c b/drivers/media/dvb/dvb-usb/ec168.c
index b4989ba8897..864195a56af 100644
--- a/drivers/media/dvb/dvb-usb/ec168.c
+++ b/drivers/media/dvb/dvb-usb/ec168.c
@@ -29,17 +29,13 @@ module_param_named(debug, dvb_usb_ec168_debug, int, 0644);
29MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); 29MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
30DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 30DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
31 31
32static struct ec100_config ec168_ec100_config; 32static int ec168_ctrl_msg(struct dvb_usb_device *d, struct ec168_req *req)
33
34static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req)
35{ 33{
36 int ret; 34 int ret;
37 unsigned int pipe; 35 unsigned int pipe;
38 u8 request, requesttype; 36 u8 request, requesttype;
39 u8 *buf; 37 u8 *buf;
40 38
41
42
43 switch (req->cmd) { 39 switch (req->cmd) {
44 case DOWNLOAD_FIRMWARE: 40 case DOWNLOAD_FIRMWARE:
45 case GPIO: 41 case GPIO:
@@ -83,15 +79,15 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req)
83 if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) { 79 if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) {
84 /* write */ 80 /* write */
85 memcpy(buf, req->data, req->size); 81 memcpy(buf, req->data, req->size);
86 pipe = usb_sndctrlpipe(udev, 0); 82 pipe = usb_sndctrlpipe(d->udev, 0);
87 } else { 83 } else {
88 /* read */ 84 /* read */
89 pipe = usb_rcvctrlpipe(udev, 0); 85 pipe = usb_rcvctrlpipe(d->udev, 0);
90 } 86 }
91 87
92 msleep(1); /* avoid I2C errors */ 88 msleep(1); /* avoid I2C errors */
93 89
94 ret = usb_control_msg(udev, pipe, request, requesttype, req->value, 90 ret = usb_control_msg(d->udev, pipe, request, requesttype, req->value,
95 req->index, buf, req->size, EC168_USB_TIMEOUT); 91 req->index, buf, req->size, EC168_USB_TIMEOUT);
96 92
97 ec168_debug_dump(request, requesttype, req->value, req->index, buf, 93 ec168_debug_dump(request, requesttype, req->value, req->index, buf,
@@ -116,12 +112,9 @@ error:
116 return ret; 112 return ret;
117} 113}
118 114
119static int ec168_ctrl_msg(struct dvb_usb_device *d, struct ec168_req *req)
120{
121 return ec168_rw_udev(d->udev, req);
122}
123
124/* I2C */ 115/* I2C */
116static struct ec100_config ec168_ec100_config;
117
125static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], 118static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
126 int num) 119 int num)
127{ 120{
@@ -181,7 +174,6 @@ error:
181 return i; 174 return i;
182} 175}
183 176
184
185static u32 ec168_i2c_func(struct i2c_adapter *adapter) 177static u32 ec168_i2c_func(struct i2c_adapter *adapter)
186{ 178{
187 return I2C_FUNC_I2C; 179 return I2C_FUNC_I2C;
@@ -193,56 +185,32 @@ static struct i2c_algorithm ec168_i2c_algo = {
193}; 185};
194 186
195/* Callbacks for DVB USB */ 187/* Callbacks for DVB USB */
196static struct ec100_config ec168_ec100_config = { 188static int ec168_identify_state(struct dvb_usb_device *d)
197 .demod_address = 0xff, /* not real address, demod is integrated */
198};
199
200static int ec168_ec100_frontend_attach(struct dvb_usb_adapter *adap)
201{ 189{
190 int ret;
191 u8 reply;
192 struct ec168_req req = {GET_CONFIG, 0, 1, sizeof(reply), &reply};
202 deb_info("%s:\n", __func__); 193 deb_info("%s:\n", __func__);
203 adap->fe_adap[0].fe = dvb_attach(ec100_attach, &ec168_ec100_config,
204 &adap->dev->i2c_adap);
205 if (adap->fe_adap[0].fe == NULL)
206 return -ENODEV;
207 194
208 return 0; 195 ret = ec168_ctrl_msg(d, &req);
209} 196 if (ret)
197 goto error;
210 198
211static struct mxl5005s_config ec168_mxl5003s_config = { 199 deb_info("%s: reply:%02x\n", __func__, reply);
212 .i2c_address = 0xc6,
213 .if_freq = IF_FREQ_4570000HZ,
214 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
215 .agc_mode = MXL_SINGLE_AGC,
216 .tracking_filter = MXL_TF_OFF,
217 .rssi_enable = MXL_RSSI_ENABLE,
218 .cap_select = MXL_CAP_SEL_ENABLE,
219 .div_out = MXL_DIV_OUT_4,
220 .clock_out = MXL_CLOCK_OUT_DISABLE,
221 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
222 .top = MXL5005S_TOP_25P2,
223 .mod_mode = MXL_DIGITAL_MODE,
224 .if_mode = MXL_ZERO_IF,
225 .AgcMasterByte = 0x00,
226};
227 200
228static int ec168_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap) 201 if (reply == 0x01)
229{ 202 ret = WARM;
230 deb_info("%s:\n", __func__); 203 else
231 return dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 204 ret = COLD;
232 &ec168_mxl5003s_config) == NULL ? -ENODEV : 0;
233}
234 205
235static int ec168_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 206 return ret;
236{ 207error:
237 struct ec168_req req = {STREAMING_CTRL, 0x7f01, 0x0202, 0, NULL}; 208 deb_info("%s: failed:%d\n", __func__, ret);
238 deb_info("%s: onoff:%d\n", __func__, onoff); 209 return ret;
239 if (onoff)
240 req.index = 0x0102;
241 return ec168_ctrl_msg(adap->dev, &req);
242} 210}
243 211
244static int ec168_download_firmware(struct usb_device *udev, 212static int ec168_download_firmware(struct dvb_usb_device *d,
245 const struct firmware *fw) 213 const struct firmware *fw)
246{ 214{
247 int i, len, packets, remainder, ret; 215 int i, len, packets, remainder, ret;
248 u16 addr = 0x0000; /* firmware start address */ 216 u16 addr = 0x0000; /* firmware start address */
@@ -262,7 +230,7 @@ static int ec168_download_firmware(struct usb_device *udev,
262 req.index = addr; 230 req.index = addr;
263 addr += FW_PACKET_MAX_DATA; 231 addr += FW_PACKET_MAX_DATA;
264 232
265 ret = ec168_rw_udev(udev, &req); 233 ret = ec168_ctrl_msg(d, &req);
266 if (ret) { 234 if (ret) {
267 err("firmware download failed:%d packet:%d", ret, i); 235 err("firmware download failed:%d packet:%d", ret, i);
268 goto error; 236 goto error;
@@ -274,7 +242,7 @@ static int ec168_download_firmware(struct usb_device *udev,
274 req.cmd = SET_CONFIG; 242 req.cmd = SET_CONFIG;
275 req.value = 0; 243 req.value = 0;
276 req.index = 0x0001; 244 req.index = 0x0001;
277 ret = ec168_rw_udev(udev, &req); 245 ret = ec168_ctrl_msg(d, &req);
278 if (ret) 246 if (ret)
279 goto error; 247 goto error;
280 248
@@ -282,7 +250,7 @@ static int ec168_download_firmware(struct usb_device *udev,
282 req.cmd = GPIO; 250 req.cmd = GPIO;
283 req.value = 0; 251 req.value = 0;
284 req.index = 0x0206; 252 req.index = 0x0206;
285 ret = ec168_rw_udev(udev, &req); 253 ret = ec168_ctrl_msg(d, &req);
286 if (ret) 254 if (ret)
287 goto error; 255 goto error;
288 256
@@ -290,7 +258,7 @@ static int ec168_download_firmware(struct usb_device *udev,
290 req.cmd = WRITE_I2C; 258 req.cmd = WRITE_I2C;
291 req.value = 0; 259 req.value = 0;
292 req.index = 0x00c6; 260 req.index = 0x00c6;
293 ret = ec168_rw_udev(udev, &req); 261 ret = ec168_ctrl_msg(d, &req);
294 if (ret) 262 if (ret)
295 goto error; 263 goto error;
296 264
@@ -300,93 +268,76 @@ error:
300 return ret; 268 return ret;
301} 269}
302 270
303static int ec168_identify_state(struct usb_device *udev, 271static struct ec100_config ec168_ec100_config = {
304 struct dvb_usb_device_properties *props, 272 .demod_address = 0xff, /* not real address, demod is integrated */
305 struct dvb_usb_device_description **desc, int *cold) 273};
274
275static int ec168_ec100_frontend_attach(struct dvb_usb_adapter *adap)
306{ 276{
307 int ret;
308 u8 reply;
309 struct ec168_req req = {GET_CONFIG, 0, 1, sizeof(reply), &reply};
310 deb_info("%s:\n", __func__); 277 deb_info("%s:\n", __func__);
278 adap->fe[0] = dvb_attach(ec100_attach, &ec168_ec100_config,
279 &adap->dev->i2c_adap);
280 if (adap->fe[0] == NULL)
281 return -ENODEV;
311 282
312 ret = ec168_rw_udev(udev, &req); 283 return 0;
313 if (ret)
314 goto error;
315
316 deb_info("%s: reply:%02x\n", __func__, reply);
317
318 if (reply == 0x01)
319 *cold = 0;
320 else
321 *cold = 1;
322
323 return ret;
324error:
325 deb_info("%s: failed:%d\n", __func__, ret);
326 return ret;
327} 284}
328 285
329/* DVB USB Driver stuff */ 286static struct mxl5005s_config ec168_mxl5003s_config = {
330static struct dvb_usb_device_properties ec168_properties; 287 .i2c_address = 0xc6,
288 .if_freq = IF_FREQ_4570000HZ,
289 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
290 .agc_mode = MXL_SINGLE_AGC,
291 .tracking_filter = MXL_TF_OFF,
292 .rssi_enable = MXL_RSSI_ENABLE,
293 .cap_select = MXL_CAP_SEL_ENABLE,
294 .div_out = MXL_DIV_OUT_4,
295 .clock_out = MXL_CLOCK_OUT_DISABLE,
296 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
297 .top = MXL5005S_TOP_25P2,
298 .mod_mode = MXL_DIGITAL_MODE,
299 .if_mode = MXL_ZERO_IF,
300 .AgcMasterByte = 0x00,
301};
331 302
332static int ec168_probe(struct usb_interface *intf, 303static int ec168_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
333 const struct usb_device_id *id)
334{ 304{
335 int ret; 305 deb_info("%s:\n", __func__);
336 deb_info("%s: interface:%d\n", __func__, 306 return dvb_attach(mxl5005s_attach, adap->fe[0],
337 intf->cur_altsetting->desc.bInterfaceNumber); 307 &adap->dev->i2c_adap,
338 308 &ec168_mxl5003s_config) == NULL ? -ENODEV : 0;
339 ret = dvb_usb_device_init(intf, &ec168_properties, THIS_MODULE, NULL,
340 adapter_nr);
341 if (ret)
342 goto error;
343
344 return ret;
345error:
346 deb_info("%s: failed:%d\n", __func__, ret);
347 return ret;
348} 309}
349 310
350#define E3C_EC168_1689 0 311static int ec168_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
351#define E3C_EC168_FFFA 1 312{
352#define E3C_EC168_FFFB 2 313 struct ec168_req req = {STREAMING_CTRL, 0x7f01, 0x0202, 0, NULL};
353#define E3C_EC168_1001 3 314 deb_info("%s: onoff:%d\n", __func__, onoff);
354#define E3C_EC168_1002 4 315 if (onoff)
355 316 req.index = 0x0102;
356static struct usb_device_id ec168_id[] = { 317 return ec168_ctrl_msg(adap->dev, &req);
357 [E3C_EC168_1689] = 318}
358 {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168)},
359 [E3C_EC168_FFFA] =
360 {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_2)},
361 [E3C_EC168_FFFB] =
362 {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_3)},
363 [E3C_EC168_1001] =
364 {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_4)},
365 [E3C_EC168_1002] =
366 {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_5)},
367 {} /* terminating entry */
368};
369
370MODULE_DEVICE_TABLE(usb, ec168_id);
371 319
372static struct dvb_usb_device_properties ec168_properties = { 320/* DVB USB Driver stuff */
373 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 321/* bInterfaceNumber 0 is HID
322 * bInterfaceNumber 1 is DVB-T */
323static struct dvb_usb_device_properties ec168_props = {
324 .driver_name = KBUILD_MODNAME,
325 .owner = THIS_MODULE,
326 .adapter_nr = adapter_nr,
327 .bInterfaceNumber = 1,
374 328
375 .usb_ctrl = DEVICE_SPECIFIC, 329 .identify_state = ec168_identify_state,
376 .download_firmware = ec168_download_firmware,
377 .firmware = "dvb-usb-ec168.fw", 330 .firmware = "dvb-usb-ec168.fw",
378 .no_reconnect = 1, 331 .download_firmware = ec168_download_firmware,
379 332
380 .size_of_priv = 0, 333 .i2c_algo = &ec168_i2c_algo,
334 .frontend_attach = ec168_ec100_frontend_attach,
335 .tuner_attach = ec168_mxl5003s_tuner_attach,
336 .streaming_ctrl = ec168_streaming_ctrl,
381 337
382 .num_adapters = 1, 338 .num_adapters = 1,
383 .adapter = { 339 .adapter = {
384 { 340 {
385 .num_frontends = 1,
386 .fe = {{
387 .streaming_ctrl = ec168_streaming_ctrl,
388 .frontend_attach = ec168_ec100_frontend_attach,
389 .tuner_attach = ec168_mxl5003s_tuner_attach,
390 .stream = { 341 .stream = {
391 .type = USB_BULK, 342 .type = USB_BULK,
392 .count = 6, 343 .count = 6,
@@ -397,35 +348,39 @@ static struct dvb_usb_device_properties ec168_properties = {
397 } 348 }
398 } 349 }
399 }, 350 },
400 }},
401 } 351 }
402 }, 352 },
353};
403 354
404 .identify_state = ec168_identify_state, 355static const struct dvb_usb_driver_info ec168_driver_info = {
405 356 .name = "E3C EC168 reference design",
406 .i2c_algo = &ec168_i2c_algo, 357 .props = &ec168_props,
358};
407 359
408 .num_device_descs = 1, 360static const struct usb_device_id ec168_id[] = {
409 .devices = { 361 { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168),
410 { 362 .driver_info = (kernel_ulong_t) &ec168_driver_info },
411 .name = "E3C EC168 DVB-T USB2.0 reference design", 363 { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_2),
412 .cold_ids = { 364 .driver_info = (kernel_ulong_t) &ec168_driver_info },
413 &ec168_id[E3C_EC168_1689], 365 { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_3),
414 &ec168_id[E3C_EC168_FFFA], 366 .driver_info = (kernel_ulong_t) &ec168_driver_info },
415 &ec168_id[E3C_EC168_FFFB], 367 { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_4),
416 &ec168_id[E3C_EC168_1001], 368 .driver_info = (kernel_ulong_t) &ec168_driver_info },
417 &ec168_id[E3C_EC168_1002], 369 { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_5),
418 NULL}, 370 .driver_info = (kernel_ulong_t) &ec168_driver_info },
419 .warm_ids = {NULL}, 371 {}
420 },
421 }
422}; 372};
373MODULE_DEVICE_TABLE(usb, ec168_id);
423 374
424static struct usb_driver ec168_driver = { 375static struct usb_driver ec168_driver = {
425 .name = "dvb_usb_ec168", 376 .name = KBUILD_MODNAME,
426 .probe = ec168_probe, 377 .id_table = ec168_id,
427 .disconnect = dvb_usb_device_exit, 378 .probe = dvb_usbv2_probe,
428 .id_table = ec168_id, 379 .disconnect = dvb_usbv2_disconnect,
380 .suspend = dvb_usbv2_suspend,
381 .resume = dvb_usbv2_resume,
382 .no_dynamic_id = 1,
383 .soft_unbind = 1,
429}; 384};
430 385
431module_usb_driver(ec168_driver); 386module_usb_driver(ec168_driver);
diff --git a/drivers/media/dvb/dvb-usb/ec168.h b/drivers/media/dvb/dvb-usb/ec168.h
index e7e0b831314..b33267b0e5c 100644
--- a/drivers/media/dvb/dvb-usb/ec168.h
+++ b/drivers/media/dvb/dvb-usb/ec168.h
@@ -23,7 +23,17 @@
23#define EC168_H 23#define EC168_H
24 24
25#define DVB_USB_LOG_PREFIX "ec168" 25#define DVB_USB_LOG_PREFIX "ec168"
26#include "dvb-usb.h" 26#include "dvb_usb.h"
27
28#ifdef CONFIG_DVB_USB_DEBUG
29#define dprintk(var, level, args...) \
30 do { if ((var & level)) printk(args); } while (0)
31#define DVB_USB_DEBUG_STATUS
32#else
33#define dprintk(args...)
34#define debug_dump(b, l, func)
35#define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"
36#endif
27 37
28#define deb_info(args...) dprintk(dvb_usb_ec168_debug, 0x01, args) 38#define deb_info(args...) dprintk(dvb_usb_ec168_debug, 0x01, args)
29#define deb_rc(args...) dprintk(dvb_usb_ec168_debug, 0x02, args) 39#define deb_rc(args...) dprintk(dvb_usb_ec168_debug, 0x02, args)