Commit 4e60d951 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] dvb_usb_v2: fix issues raised by checkpatch.pl

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8b9dff58
...@@ -27,18 +27,19 @@ ...@@ -27,18 +27,19 @@
/* debug */ /* debug */
#ifdef CONFIG_DVB_USB_DEBUG #ifdef CONFIG_DVB_USB_DEBUG
#define dprintk(var,level,args...) \ #define dprintk(var, level, args...) \
do { if ((var & level)) { printk(args); } } while (0) do { if ((var & level)) { printk(args); } } while (0)
#define debug_dump(b,l,func) {\ #define debug_dump(b, l, func) {\
int loop_; \ int loop_; \
for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \ for (loop_ = 0; loop_ < l; loop_++) \
func("%02x ", b[loop_]); \
func("\n");\ func("\n");\
} }
#define DVB_USB_DEBUG_STATUS #define DVB_USB_DEBUG_STATUS
#else #else
#define dprintk(args...) #define dprintk(args...)
#define debug_dump(b,l,func) #define debug_dump(b, l, func)
#define DVB_USB_DEBUG_STATUS " (debugging is not enabled)" #define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"
...@@ -50,11 +51,14 @@ ...@@ -50,11 +51,14 @@
#endif #endif
#undef err #undef err
#define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) #define err(format, arg...) \
printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
#undef info #undef info
#define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) #define info(format, arg...) \
printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
#undef warn #undef warn
#define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) #define warn(format, arg...) \
printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
/** /**
* struct dvb_usb_device_description - name and its according USB IDs * struct dvb_usb_device_description - name and its according USB IDs
...@@ -120,7 +124,8 @@ struct usb_data_stream_properties { ...@@ -120,7 +124,8 @@ struct usb_data_stream_properties {
/** /**
* struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter. * struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter.
* A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device. * A DVB-USB-Adapter is basically a dvb_adapter which is present on a
* USB-device.
* @caps: capabilities of the DVB USB device. * @caps: capabilities of the DVB USB device.
* @pid_filter_count: number of PID filter position in the optional hardware * @pid_filter_count: number of PID filter position in the optional hardware
* PID-filter. * PID-filter.
...@@ -277,7 +282,8 @@ struct dvb_usb_device_properties { ...@@ -277,7 +282,8 @@ struct dvb_usb_device_properties {
int usb_ctrl; int usb_ctrl;
#define RECONNECTS_USB 1 #define RECONNECTS_USB 1
int (*download_firmware) (struct dvb_usb_device *, const struct firmware *); int (*download_firmware) (struct dvb_usb_device *,
const struct firmware *);
int (*get_firmware_name) (struct dvb_usb_device *, const char **); int (*get_firmware_name) (struct dvb_usb_device *, const char **);
int size_of_priv; int size_of_priv;
...@@ -351,7 +357,8 @@ struct usb_data_stream { ...@@ -351,7 +357,8 @@ struct usb_data_stream {
* @pll_addr: I2C address of the tuner for programming * @pll_addr: I2C address of the tuner for programming
* @pll_init: array containing the initialization buffer * @pll_init: array containing the initialization buffer
* @pll_desc: pointer to the appropriate struct dvb_pll_desc * @pll_desc: pointer to the appropriate struct dvb_pll_desc
* @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or
* the board
* *
* @dvb_adap: device's dvb_adapter. * @dvb_adap: device's dvb_adapter.
* @dmxdev: device's dmxdev. * @dmxdev: device's dmxdev.
...@@ -468,11 +475,13 @@ extern int dvb_usbv2_device_init(struct usb_interface *, ...@@ -468,11 +475,13 @@ extern int dvb_usbv2_device_init(struct usb_interface *,
extern void dvb_usbv2_device_exit(struct usb_interface *); extern void dvb_usbv2_device_exit(struct usb_interface *);
/* the generic read/write method for device control */ /* the generic read/write method for device control */
extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int); extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,
int);
extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16); extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16);
/* commonly used remote control parsing */ /* commonly used remote control parsing */
extern int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *); extern int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *,
int *);
/* commonly used firmware download types and function */ /* commonly used firmware download types and function */
struct hexline { struct hexline {
...@@ -482,8 +491,9 @@ struct hexline { ...@@ -482,8 +491,9 @@ struct hexline {
u8 data[255]; u8 data[255];
u8 chk; u8 chk;
}; };
extern int usbv2_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type); extern int usbv2_cypress_load_firmware(struct usb_device *udev,
extern int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos); const struct firmware *fw, int type);
extern int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx,
int *pos);
#endif #endif
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
* see dvb-usb-init.c for copyright information. * see dvb-usb-init.c for copyright information.
* *
* a header file containing prototypes and types for internal use of the dvb-usb-lib * a header file containing prototypes and types for internal use of the
* dvb-usb-lib
*/ */
#ifndef DVB_USB_COMMON_H #ifndef DVB_USB_COMMON_H
#define DVB_USB_COMMON_H #define DVB_USB_COMMON_H
...@@ -14,22 +15,23 @@ ...@@ -14,22 +15,23 @@
extern int dvb_usb_debug; extern int dvb_usb_debug;
extern int dvb_usb_disable_rc_polling; extern int dvb_usb_disable_rc_polling;
#define deb_info(args...) dprintk(dvb_usb_debug,0x001,args) #define deb_info(args...) dprintk(dvb_usb_debug, 0x001, args)
#define deb_xfer(args...) dprintk(dvb_usb_debug,0x002,args) #define deb_xfer(args...) dprintk(dvb_usb_debug, 0x002, args)
#define deb_pll(args...) dprintk(dvb_usb_debug,0x004,args) #define deb_pll(args...) dprintk(dvb_usb_debug, 0x004, args)
#define deb_ts(args...) dprintk(dvb_usb_debug,0x008,args) #define deb_ts(args...) dprintk(dvb_usb_debug, 0x008, args)
#define deb_err(args...) dprintk(dvb_usb_debug,0x010,args) #define deb_err(args...) dprintk(dvb_usb_debug, 0x010, args)
#define deb_rc(args...) dprintk(dvb_usb_debug,0x020,args) #define deb_rc(args...) dprintk(dvb_usb_debug, 0x020, args)
#define deb_fw(args...) dprintk(dvb_usb_debug,0x040,args) #define deb_fw(args...) dprintk(dvb_usb_debug, 0x040, args)
#define deb_mem(args...) dprintk(dvb_usb_debug,0x080,args) #define deb_mem(args...) dprintk(dvb_usb_debug, 0x080, args)
#define deb_uxfer(args...) dprintk(dvb_usb_debug,0x100,args) #define deb_uxfer(args...) dprintk(dvb_usb_debug, 0x100, args)
/* commonly used methods */ /* commonly used methods */
extern int dvb_usb_download_firmware(struct dvb_usb_device *); extern int dvb_usb_download_firmware(struct dvb_usb_device *);
extern int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff); extern int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff);
extern int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props); extern int usb_urb_init(struct usb_data_stream *stream,
struct usb_data_stream_properties *props);
extern int usb_urb_exit(struct usb_data_stream *stream); extern int usb_urb_exit(struct usb_data_stream *stream);
extern int usb_urb_submit(struct usb_data_stream *stream); extern int usb_urb_submit(struct usb_data_stream *stream);
extern int usb_urb_kill(struct usb_data_stream *stream); extern int usb_urb_kill(struct usb_data_stream *stream);
......
...@@ -30,7 +30,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -30,7 +30,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
usb_urb_kill(&adap->fe_adap[adap->active_fe].stream); usb_urb_kill(&adap->fe_adap[adap->active_fe].stream);
if (adap->props.fe[adap->active_fe].streaming_ctrl != NULL) { if (adap->props.fe[adap->active_fe].streaming_ctrl != NULL) {
ret = adap->props.fe[adap->active_fe].streaming_ctrl(adap, 0); ret = adap->props.fe[adap->active_fe].streaming_ctrl(
adap, 0);
if (ret < 0) { if (ret < 0) {
err("error while stopping stream."); err("error while stopping stream.");
return ret; return ret;
...@@ -48,7 +49,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -48,7 +49,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER && if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER &&
adap->fe_adap[adap->active_fe].pid_filtering && adap->fe_adap[adap->active_fe].pid_filtering &&
adap->props.fe[adap->active_fe].pid_filter != NULL) adap->props.fe[adap->active_fe].pid_filter != NULL)
adap->props.fe[adap->active_fe].pid_filter(adap, dvbdmxfeed->index, dvbdmxfeed->pid, onoff); adap->props.fe[adap->active_fe].pid_filter(adap,
dvbdmxfeed->index, dvbdmxfeed->pid, onoff);
/* start the feed if this was the first feed and there is still a feed /* start the feed if this was the first feed and there is still a feed
* for reception. * for reception.
...@@ -62,7 +64,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -62,7 +64,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
adap->props.fe[adap->active_fe].caps & adap->props.fe[adap->active_fe].caps &
DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF && DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF &&
adap->props.fe[adap->active_fe].pid_filter_ctrl != NULL) { adap->props.fe[adap->active_fe].pid_filter_ctrl != NULL) {
ret = adap->props.fe[adap->active_fe].pid_filter_ctrl(adap, ret = adap->props.fe[adap->active_fe].pid_filter_ctrl(
adap,
adap->fe_adap[adap->active_fe].pid_filtering); adap->fe_adap[adap->active_fe].pid_filtering);
if (ret < 0) { if (ret < 0) {
err("could not handle pid_parser"); err("could not handle pid_parser");
...@@ -71,7 +74,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -71,7 +74,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
} }
deb_ts("start feeding\n"); deb_ts("start feeding\n");
if (adap->props.fe[adap->active_fe].streaming_ctrl != NULL) { if (adap->props.fe[adap->active_fe].streaming_ctrl != NULL) {
ret = adap->props.fe[adap->active_fe].streaming_ctrl(adap, 1); ret = adap->props.fe[adap->active_fe].streaming_ctrl(
adap, 1);
if (ret < 0) { if (ret < 0) {
err("error while enabling fifo."); err("error while enabling fifo.");
return ret; return ret;
...@@ -84,14 +88,16 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -84,14 +88,16 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
static int dvb_usb_start_feed(struct dvb_demux_feed *dvbdmxfeed) static int dvb_usb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
{ {
deb_ts("start pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid,dvbdmxfeed->type); deb_ts("start pid: 0x%04x, feedtype: %d\n",
return dvb_usb_ctrl_feed(dvbdmxfeed,1); dvbdmxfeed->pid, dvbdmxfeed->type);
return dvb_usb_ctrl_feed(dvbdmxfeed, 1);
} }
static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
{ {
deb_ts("stop pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid, dvbdmxfeed->type); deb_ts("stop pid: 0x%04x, feedtype: %d\n",
return dvb_usb_ctrl_feed(dvbdmxfeed,0); dvbdmxfeed->pid, dvbdmxfeed->type);
return dvb_usb_ctrl_feed(dvbdmxfeed, 0);
} }
int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
...@@ -109,8 +115,9 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -109,8 +115,9 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
adap->dvb_adap.fe_ioctl_override = adap->props.fe_ioctl_override; adap->dvb_adap.fe_ioctl_override = adap->props.fe_ioctl_override;
if (adap->dev->props.read_mac_address) { if (adap->dev->props.read_mac_address) {
if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0) if (adap->dev->props.read_mac_address(adap->dev,
info("MAC address: %pM",adap->dvb_adap.proposed_mac); adap->dvb_adap.proposed_mac) == 0)
info("MAC address: %pM", adap->dvb_adap.proposed_mac);
else else
err("MAC address reading failed."); err("MAC address reading failed.");
} }
...@@ -128,22 +135,24 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -128,22 +135,24 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
adap->demux.start_feed = dvb_usb_start_feed; adap->demux.start_feed = dvb_usb_start_feed;
adap->demux.stop_feed = dvb_usb_stop_feed; adap->demux.stop_feed = dvb_usb_stop_feed;
adap->demux.write_to_decoder = NULL; adap->demux.write_to_decoder = NULL;
if ((ret = dvb_dmx_init(&adap->demux)) < 0) { ret = dvb_dmx_init(&adap->demux);
err("dvb_dmx_init failed: error %d",ret); if (ret < 0) {
err("dvb_dmx_init failed: error %d", ret);
goto err_dmx; goto err_dmx;
} }
adap->dmxdev.filternum = adap->demux.filternum; adap->dmxdev.filternum = adap->demux.filternum;
adap->dmxdev.demux = &adap->demux.dmx; adap->dmxdev.demux = &adap->demux.dmx;
adap->dmxdev.capabilities = 0; adap->dmxdev.capabilities = 0;
if ((ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap)) < 0) { ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap);
err("dvb_dmxdev_init failed: error %d",ret); if (ret < 0) {
err("dvb_dmxdev_init failed: error %d", ret);
goto err_dmx_dev; goto err_dmx_dev;
} }
if ((ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx);
&adap->demux.dmx)) < 0) { if (ret < 0) {
err("dvb_net_init failed: error %d",ret); err("dvb_net_init failed: error %d", ret);
goto err_net_init; goto err_net_init;
} }
...@@ -225,7 +234,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) ...@@ -225,7 +234,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
for (i = 0; i < adap->props.num_frontends; i++) { for (i = 0; i < adap->props.num_frontends; i++) {
if (adap->props.fe[i].frontend_attach == NULL) { if (adap->props.fe[i].frontend_attach == NULL) {
err("strange: '%s' #%d,%d " err("strange: '%s' #%d,%d " \
"doesn't want to attach a frontend.", "doesn't want to attach a frontend.",
adap->dev->desc->name, adap->id, i); adap->dev->desc->name, adap->id, i);
...@@ -250,7 +259,8 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) ...@@ -250,7 +259,8 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
adap->fe_adap[i].fe_sleep = adap->fe_adap[i].fe->ops.sleep; adap->fe_adap[i].fe_sleep = adap->fe_adap[i].fe->ops.sleep;
adap->fe_adap[i].fe->ops.sleep = dvb_usb_fe_sleep; adap->fe_adap[i].fe->ops.sleep = dvb_usb_fe_sleep;
if (dvb_register_frontend(&adap->dvb_adap, adap->fe_adap[i].fe)) { if (dvb_register_frontend(&adap->dvb_adap,
adap->fe_adap[i].fe)) {
err("Frontend %d registration failed.", i); err("Frontend %d registration failed.", i);
dvb_frontend_detach(adap->fe_adap[i].fe); dvb_frontend_detach(adap->fe_adap[i].fe);
adap->fe_adap[i].fe = NULL; adap->fe_adap[i].fe = NULL;
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
* Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
* see dvb-usb-init.c for copyright information. * see dvb-usb-init.c for copyright information.
* *
* This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices. * This file contains functions for downloading the firmware to Cypress FX 1
* and 2 based devices.
* *
* FIXME: This part does actually not belong to dvb-usb, but to the usb-subsystem. * FIXME: This part does actually not belong to dvb-usb, but to the
* usb-subsystem.
*/ */
#include "dvb_usb_common.h" #include "dvb_usb_common.h"
...@@ -13,58 +15,71 @@ ...@@ -13,58 +15,71 @@
struct usb_cypress_controller { struct usb_cypress_controller {
int id; int id;
const char *name; /* name of the usb controller */ /* name of the usb controller */
u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */ const char *name;
/* needs to be restarted, when the firmware has been downloaded. */
u16 cpu_cs_register;
}; };
static struct usb_cypress_controller cypress[] = { static struct usb_cypress_controller cypress[] = {
{ .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 }, { .id = DEVICE_SPECIFIC, .name = "Device specific",
{ .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 }, .cpu_cs_register = 0 },
{ .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 }, { .id = CYPRESS_AN2135, .name = "Cypress AN2135",
{ .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, .cpu_cs_register = 0x7f92 },
{ .id = CYPRESS_AN2235, .name = "Cypress AN2235",
.cpu_cs_register = 0x7f92 },
{ .id = CYPRESS_FX2, .name = "Cypress FX2",
.cpu_cs_register = 0xe600 },
}; };
/* /*
* load a firmware packet to the device * load a firmware packet to the device
*/ */
static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len) static int usb_cypress_writemem(struct usb_device *udev, u16 addr, u8 *data,
u8 len)
{ {
return usb_control_msg(udev, usb_sndctrlpipe(udev,0), return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000); 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000);
} }
int usbv2_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) int usbv2_cypress_load_firmware(struct usb_device *udev,
const struct firmware *fw, int type)
{ {
struct hexline hx; struct hexline hx;
u8 reset; u8 reset;
int ret,pos=0; int ret, pos = 0;
/* stop the CPU */ /* stop the CPU */
reset = 1; reset = 1;
if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) ret = usb_cypress_writemem(udev, cypress[type].cpu_cs_register,
&reset, 1);
if (ret != 1)
err("could not stop the USB controller CPU."); err("could not stop the USB controller CPU.");
while ((ret = dvb_usbv2_get_hexline(fw,&hx,&pos)) > 0) { while ((ret = dvb_usbv2_get_hexline(fw, &hx, &pos)) > 0) {
deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk); deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",
ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); hx.addr, hx.len, hx.chk);
ret = usb_cypress_writemem(udev, hx.addr, hx.data, hx.len);
if (ret != hx.len) { if (ret != hx.len) {
err("error while transferring firmware " err("error while transferring firmware " \
"(transferred size: %d, block size: %d)", "(transferred size: %d, block size: %d)",
ret,hx.len); ret, hx.len);
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
} }
if (ret < 0) { if (ret < 0) {
err("firmware download failed at %d with %d",pos,ret); err("firmware download failed at %d with %d", pos, ret);
return ret; return ret;
} }
if (ret == 0) { if (ret == 0) {
/* restart the CPU */ /* restart the CPU */
reset = 0; reset = 0;
if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) { if (ret || usb_cypress_writemem(udev,
cypress[type].cpu_cs_register,
&reset, 1) != 1) {
err("could not restart the USB controller CPU."); err("could not restart the USB controller CPU.");
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -85,10 +100,12 @@ int dvb_usb_download_firmware(struct dvb_usb_device *d) ...@@ -85,10 +100,12 @@ int dvb_usb_download_firmware(struct dvb_usb_device *d)
if (ret < 0) if (ret < 0)
return ret; return ret;
if ((ret = request_firmware(&fw, name, &d->udev->dev)) != 0) { ret = request_firmware(&fw, name, &d->udev->dev);
err("did not find the firmware file. (%s) " if (ret != 0) {
"Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)", err("did not find the firmware file. (%s) " \
name,ret); "Please see linux/Documentation/dvb/ for more" \
" details on firmware-problems. (%d)",
name, ret);
return ret; return ret;
} }
...@@ -98,13 +115,16 @@ int dvb_usb_download_firmware(struct dvb_usb_device *d) ...@@ -98,13 +115,16 @@ int dvb_usb_download_firmware(struct dvb_usb_device *d)
case CYPRESS_AN2135: case CYPRESS_AN2135:
case CYPRESS_AN2235: case CYPRESS_AN2235:
case CYPRESS_FX2: case CYPRESS_FX2:
ret = usbv2_cypress_load_firmware(d->udev, fw, d->props.usb_ctrl); ret = usbv2_cypress_load_firmware(d->udev, fw,
d->props.usb_ctrl);
break; break;
case DEVICE_SPECIFIC: case DEVICE_SPECIFIC:
if (d->props.download_firmware) if (d->props.download_firmware)
ret = d->props.download_firmware(d, fw); ret = d->props.download_firmware(d, fw);
else { else {
err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one."); err("BUG: driver didn't specified a download_firmware" \
"-callback, although it claims to have a" \
" DEVICE_SPECIFIC one.");
ret = -EINVAL; ret = -EINVAL;
} }
break; break;
...@@ -125,7 +145,7 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, ...@@ -125,7 +145,7 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx,
if (*pos >= fw->size) if (*pos >= fw->size)
return 0; return 0;
memset(hx,0,sizeof(struct hexline)); memset(hx, 0, sizeof(struct hexline));
hx->len = b[0]; hx->len = b[0];
...@@ -136,12 +156,13 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, ...@@ -136,12 +156,13 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx,
hx->type = b[3]; hx->type = b[3];
if (hx->type == 0x04) { if (hx->type == 0x04) {
/* b[4] and b[5] are the Extended linear address record data field */ /* b[4] and b[5] are the Extended linear address record data
* field */
hx->addr |= (b[4] << 24) | (b[5] << 16); hx->addr |= (b[4] << 24) | (b[5] << 16);
/* hx->len -= 2; /* hx->len -= 2;
data_offs += 2; */ data_offs += 2; */
} }
memcpy(hx->data,&b[data_offs],hx->len); memcpy(hx->data, &b[data_offs], hx->len);
hx->chk = b[hx->len + data_offs]; hx->chk = b[hx->len + data_offs];
*pos += hx->len + 5; *pos += hx->len + 5;
......
...@@ -26,7 +26,8 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d) ...@@ -26,7 +26,8 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
i2c_set_adapdata(&d->i2c_adap, d); i2c_set_adapdata(&d->i2c_adap, d);
if ((ret = i2c_add_adapter(&d->i2c_adap)) < 0) ret = i2c_add_adapter(&d->i2c_adap);
if (ret < 0)
err("could not add i2c adapter"); err("could not add i2c adapter");
d->state |= DVB_USB_STATE_I2C; d->state |= DVB_USB_STATE_I2C;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
* Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the
* Software Foundation, version 2. * Free Software Foundation, version 2.
* *
* see Documentation/dvb/README.dvb-usb for more information * see Documentation/dvb/README.dvb-usb for more information
*/ */
...@@ -16,15 +16,20 @@ ...@@ -16,15 +16,20 @@
/* debug */ /* debug */
int dvb_usb_debug; int dvb_usb_debug;
module_param_named(debug, dvb_usb_debug, int, 0644); module_param_named(debug, dvb_usb_debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64,mem=128,uxfer=256 (or-able))." DVB_USB_DEBUG_STATUS); MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8"\
",err=16,rc=32,fw=64,mem=128,uxfer=256 (or-able))."
DVB_USB_DEBUG_STATUS);
int dvb_usb_disable_rc_polling; int dvb_usb_disable_rc_polling;
module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644); module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); MODULE_PARM_DESC(disable_rc_polling,
"disable remote control polling (default: 0).");
static int dvb_usb_force_pid_filter_usage; static int dvb_usb_force_pid_filter_usage;
module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444); module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage,
MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a PID filter, if any (default: 0)."); int, 0444);
MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a" \
" PID filter, if any (default: 0).");
static int dvb_usb_adapter_init(struct dvb_usb_device *d) static int dvb_usb_adapter_init(struct dvb_usb_device *d)
{ {
...@@ -36,23 +41,34 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) ...@@ -36,23 +41,34 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d)
adap->dev = d; adap->dev = d;
adap->id = n; adap->id = n;
memcpy(&adap->props, &d->props.adapter[n], sizeof(struct dvb_usb_adapter_properties)); memcpy(&adap->props, &d->props.adapter[n],
sizeof(struct dvb_usb_adapter_properties));
for (o = 0; o < adap->props.num_frontends; o++) { for (o = 0; o < adap->props.num_frontends; o++) {
struct dvb_usb_adapter_fe_properties *props = &adap->props.fe[o]; struct dvb_usb_adapter_fe_properties *props =
/* speed - when running at FULL speed we need a HW PID filter */ &adap->props.fe[o];
if (d->udev->speed == USB_SPEED_FULL && !(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) { /* speed - when running at FULL speed we need a HW
err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); * PID filter */
if (d->udev->speed == USB_SPEED_FULL &&
!(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) {
err("This USB2.0 device cannot be run on a" \
" USB1.1 port. (it lacks a" \
" hardware PID filter)");
return -ENODEV; return -ENODEV;
} }
if ((d->udev->speed == USB_SPEED_FULL && props->caps & DVB_USB_ADAP_HAS_PID_FILTER) || if ((d->udev->speed == USB_SPEED_FULL &&
props->caps & DVB_USB_ADAP_HAS_PID_FILTER) ||
(props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) { (props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) {
info("will use the device's hardware PID filter (table count: %d).", props->pid_filter_count); info("will use the device's hardware PID" \
" filter (table count: %d).",
props->pid_filter_count);
adap->fe_adap[o].pid_filtering = 1; adap->fe_adap[o].pid_filtering = 1;
adap->fe_adap[o].max_feed_count = props->pid_filter_count; adap->fe_adap[o].max_feed_count =
props->pid_filter_count;
} else { } else {
info("will pass the complete MPEG2 transport stream to the software demuxer."); info("will pass the complete MPEG2 transport" \
" stream to the software demuxer.");
adap->fe_adap[o].pid_filtering = 0; adap->fe_adap[o].pid_filtering = 0;
adap->fe_adap[o].max_feed_count = 255; adap->fe_adap[o].max_feed_count = 255;
} }
...@@ -62,31 +78,40 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) ...@@ -62,31 +78,40 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d)
props->caps & DVB_USB_ADAP_HAS_PID_FILTER) { props->caps & DVB_USB_ADAP_HAS_PID_FILTER) {
info("pid filter enabled by module option."); info("pid filter enabled by module option.");
adap->fe_adap[o].pid_filtering = 1; adap->fe_adap[o].pid_filtering = 1;
adap->fe_adap[o].max_feed_count = props->pid_filter_count; adap->fe_adap[o].max_feed_count =
props->pid_filter_count;
} }
if (props->size_of_priv > 0) { if (props->size_of_priv > 0) {
adap->fe_adap[o].priv = kzalloc(props->size_of_priv, GFP_KERNEL); adap->fe_adap[o].priv = kzalloc(props->size_of_priv, GFP_KERNEL);
if (adap->fe_adap[o].priv == NULL) { if (adap->fe_adap[o].priv == NULL) {
err("no memory for priv for adapter %d fe %d.", n, o); err("no memory for priv for adapter" \
" %d fe %d.", n, o);
return -ENOMEM; return -ENOMEM;
} }
} }
} }
if (adap->props.size_of_priv > 0) { if (adap->props.size_of_priv > 0) {
adap->priv = kzalloc(adap->props.size_of_priv, GFP_KERNEL); adap->priv = kzalloc(adap->props.size_of_priv,
GFP_KERNEL);
if (adap->priv == NULL) { if (adap->priv == NULL) {
err("no memory for priv for adapter %d.", n); err("no memory for priv for adapter %d.", n);
return -ENOMEM; return -ENOMEM;
} }
} }
if ((ret = dvb_usb_adapter_stream_init(adap)) || ret = dvb_usb_adapter_stream_init(adap);
(ret = dvb_usb_adapter_dvb_init(adap)) || if (ret)
(ret = dvb_usb_adapter_frontend_init(adap))) { return ret;
ret = dvb_usb_adapter_dvb_init(adap);
if (ret)
return ret;
ret = dvb_usb_adapter_frontend_init(adap);
if (ret)
return ret; return ret;
}
/* use exclusive FE lock if there is multiple shared FEs */ /* use exclusive FE lock if there is multiple shared FEs */
if (adap->fe_adap[1].fe) if (adap->fe_adap[1].fe)
...@@ -101,8 +126,10 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) ...@@ -101,8 +126,10 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d)
* sometimes a timeout occures, this helps * sometimes a timeout occures, this helps
*/ */
if (d->props.generic_bulk_ctrl_endpoint != 0) { if (d->props.generic_bulk_ctrl_endpoint != 0) {
usb_clear_halt(d->udev, usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); usb_clear_halt(d->udev, usb_sndbulkpipe(d->udev,
usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); d->props.generic_bulk_ctrl_endpoint));
usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev,
d->props.generic_bulk_ctrl_endpoint));
} }
return 0; return 0;
...@@ -150,7 +177,11 @@ static int dvb_usb_init(struct dvb_usb_device *d) ...@@ -150,7 +177,11 @@ static int dvb_usb_init(struct dvb_usb_device *d)
/* check the capabilities and set appropriate variables */ /* check the capabilities and set appropriate variables */
dvb_usb_device_power_ctrl(d, 1); dvb_usb_device_power_ctrl(d, 1);
if ((ret = dvb_usb_i2c_init(d)) || (ret = dvb_usb_adapter_init(d))) { ret = dvb_usb_i2c_init(d);
if (ret == 0)
ret = dvb_usb_adapter_init(d);
if (ret) {
dvb_usb_exit(d); dvb_usb_exit(d);
return ret; return ret;
} }
...@@ -158,7 +189,8 @@ static int dvb_usb_init(struct dvb_usb_device *d) ...@@ -158,7 +189,8 @@ static int dvb_usb_init(struct dvb_usb_device *d)
if (d->props.init) if (d->props.init)
d->props.init(d); d->props.init(d);
if ((ret = dvb_usb_remote_init(d))) ret = dvb_usb_remote_init(d);
if (ret)
err("could not initialize remote control."); err("could not initialize remote control.");
dvb_usb_device_power_ctrl(d, 0); dvb_usb_device_power_ctrl(d, 0);
...@@ -167,7 +199,9 @@ static int dvb_usb_init(struct dvb_usb_device *d) ...@@ -167,7 +199,9 @@ static int dvb_usb_init(struct dvb_usb_device *d)
} }
/* determine the name and the state of the just found USB device */ /* determine the name and the state of the just found USB device */
static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device *udev, struct dvb_usb_device_properties *props, bool *cold) static struct dvb_usb_device_description *dvb_usb_find_device(
struct usb_device *udev,
struct dvb_usb_device_properties *props, bool *cold)
{ {
int i, j; int i, j;
struct dvb_usb_device_description *desc = NULL; struct dvb_usb_device_description *desc = NULL;
...@@ -175,9 +209,10 @@ static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device ...@@ -175,9 +209,10 @@ static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device
*cold = true; *cold = true;
for (i = 0; i < props->num_device_descs; i++) { for (i = 0; i < props->num_device_descs; i++) {
for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].cold_ids[j] != NULL; j++) { for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].cold_ids[j] != NULL; j++) {
deb_info("check for cold %x %x\n", props->devices[i].cold_ids[j]->idVendor, props->devices[i].cold_ids[j]->idProduct); deb_info("check for cold %x %x\n",
props->devices[i].cold_ids[j]->idVendor,
props->devices[i].cold_ids[j]->idProduct);
if (props->devices[i].cold_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) && if (props->devices[i].cold_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) &&
props->devices[i].cold_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { props->devices[i].cold_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) {
*cold = true; *cold = true;
...@@ -190,7 +225,10 @@ static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device ...@@ -190,7 +225,10 @@ static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device
break; break;
for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].warm_ids[j] != NULL; j++) { for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].warm_ids[j] != NULL; j++) {
deb_info("check for warm %x %x\n", props->devices[i].warm_ids[j]->idVendor, props->devices[i].warm_ids[j]->idProduct); deb_info("check for warm %x %x\n",
props->devices[i].warm_ids[j]->idVendor,
props->devices[i].warm_ids[j]->idProduct);
if (props->devices[i].warm_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) && if (props->devices[i].warm_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) &&
props->devices[i].warm_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { props->devices[i].warm_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) {
*cold = false; *cold = false;
...@@ -210,7 +248,8 @@ int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff) ...@@ -210,7 +248,8 @@ int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff)
else else
d->powered--; d->powered--;
if (d->powered == 0 || (onoff && d->powered == 1)) { /* when switching from 1 to 0 or from 0 to 1 */ if (d->powered == 0 || (onoff && d->powered == 1)) {
/* when switching from 1 to 0 or from 0 to 1 */
deb_info("power control: %d\n", onoff); deb_info("power control: %d\n", onoff);
if (d->props.power_ctrl) if (d->props.power_ctrl)
return d->props.power_ctrl(d, onoff); return d->props.power_ctrl(d, onoff);
...@@ -250,8 +289,12 @@ int dvb_usbv2_device_init(struct usb_interface *intf, ...@@ -250,8 +289,12 @@ int dvb_usbv2_device_init(struct usb_interface *intf,
} }
} }
if ((desc = dvb_usb_find_device(udev, props, &cold)) == NULL) { desc = dvb_usb_find_device(udev, props, &cold);
deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n");
if (desc == NULL) {
deb_err("something went very wrong, device was not found in" \
" current device list - let's see what" \
" comes next.\n");
ret = -ENODEV; ret = -ENODEV;
goto err_kfree; goto err_kfree;
} }
...@@ -271,7 +314,8 @@ int dvb_usbv2_device_init(struct usb_interface *intf, ...@@ -271,7 +314,8 @@ int dvb_usbv2_device_init(struct usb_interface *intf,
} }
if (cold) { if (cold) {
info("found a '%s' in cold state, will try to load a firmware", desc->name); info("found a '%s' in cold state, will try to load a firmware",
desc->name);
ret = dvb_usb_download_firmware(d); ret = dvb_usb_download_firmware(d);
if (ret == 0) { if (ret == 0) {
; ;
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
* see dvb-usb-init.c for copyright information. * see dvb-usb-init.c for copyright information.
* *
* This file contains functions for initializing the input-device and for handling remote-control-queries. * This file contains functions for initializing the input-device and for
* handling remote-control-queries.
*/ */
#include "dvb_usb_common.h" #include "dvb_usb_common.h"
#include <linux/usb/input.h> #include <linux/usb/input.h>
...@@ -112,14 +113,15 @@ static void legacy_dvb_usb_read_remote_control(struct work_struct *work) ...@@ -112,14 +113,15 @@ static void legacy_dvb_usb_read_remote_control(struct work_struct *work)
u32 event; u32 event;
int state; int state;
/* TODO: need a lock here. We can simply skip checking for the remote control /* TODO: need a lock here. We can simply skip checking for the remote
if we're busy. */ control if we're busy. */
/* when the parameter has been set to 1 via sysfs while the driver was running */ /* when the parameter has been set to 1 via sysfs while the driver
was running */
if (dvb_usb_disable_rc_polling) if (dvb_usb_disable_rc_polling)
return; return;
if (d->props.rc.legacy.rc_query(d,&event,&state)) { if (d->props.rc.legacy.rc_query(d, &event, &state)) {
err("error while querying for an remote control event."); err("error while querying for an remote control event.");
goto schedule; goto schedule;
} }
...@@ -142,43 +144,9 @@ static void legacy_dvb_usb_read_remote_control(struct work_struct *work) ...@@ -142,43 +144,9 @@ static void legacy_dvb_usb_read_remote_control(struct work_struct *work)
break; break;
} }
/* improved repeat handling ???
switch (state) {
case REMOTE_NO_KEY_PRESSED:
deb_rc("NO KEY PRESSED\n");
if (d->last_state != REMOTE_NO_KEY_PRESSED) {
deb_rc("releasing event %d\n",d->last_event);
input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
input_sync(d->rc_input_dev);
}
d->last_state = REMOTE_NO_KEY_PRESSED;
d->last_event = 0;
break;
case REMOTE_KEY_PRESSED:
deb_rc("KEY PRESSED\n");
deb_rc("pressing event %d\n",event);
input_event(d->rc_input_dev, EV_KEY, event, 1);
input_sync(d->rc_input_dev);
d->last_event = event;
d->last_state = REMOTE_KEY_PRESSED;
break;
case REMOTE_KEY_REPEAT:
deb_rc("KEY_REPEAT\n");
if (d->last_state != REMOTE_NO_KEY_PRESSED) {
deb_rc("repeating event %d\n",d->last_event);
input_event(d->rc_input_dev, EV_KEY, d->last_event, 2);
input_sync(d->rc_input_dev);
d->last_state = REMOTE_KEY_REPEAT;
}
default:
break;
}
*/
schedule: schedule:
schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc.legacy.rc_interval)); schedule_delayed_work(&d->rc_query_work,
msecs_to_jiffies(d->props.rc.legacy.rc_interval));
} }
static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d) static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d)
...@@ -206,10 +174,12 @@ static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d) ...@@ -206,10 +174,12 @@ static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d)
for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
deb_rc("setting bit for event %d item %d\n", deb_rc("setting bit for event %d item %d\n",
d->props.rc.legacy.rc_map_table[i].keycode, i); d->props.rc.legacy.rc_map_table[i].keycode, i);
set_bit(d->props.rc.legacy.rc_map_table[i].keycode, input_dev->keybit); set_bit(d->props.rc.legacy.rc_map_table[i].keycode,
input_dev->keybit);
} }
/* setting these two values to non-zero, we have to manage key repeats */ /* setting these two values to non-zero, we have to manage key
repeats */
input_dev->rep[REP_PERIOD] = d->props.rc.legacy.rc_interval; input_dev->rep[REP_PERIOD] = d->props.rc.legacy.rc_interval;
input_dev->rep[REP_DELAY] = d->props.rc.legacy.rc_interval + 150; input_dev->rep[REP_DELAY] = d->props.rc.legacy.rc_interval + 150;
...@@ -221,7 +191,8 @@ static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d) ...@@ -221,7 +191,8 @@ static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d)
rc_interval = d->props.rc.legacy.rc_interval; rc_interval = d->props.rc.legacy.rc_interval;
INIT_DELAYED_WORK(&d->rc_query_work, legacy_dvb_usb_read_remote_control); INIT_DELAYED_WORK(&d->rc_query_work,
legacy_dvb_usb_read_remote_control);
info("schedule remote query interval to %d msecs.", rc_interval); info("schedule remote query interval to %d msecs.", rc_interval);
schedule_delayed_work(&d->rc_query_work, schedule_delayed_work(&d->rc_query_work,
...@@ -243,8 +214,8 @@ static void dvb_usb_read_remote_control(struct work_struct *work) ...@@ -243,8 +214,8 @@ static void dvb_usb_read_remote_control(struct work_struct *work)
container_of(work, struct dvb_usb_device, rc_query_work.work); container_of(work, struct dvb_usb_device, rc_query_work.work);
int err; int err;
/* TODO: need a lock here. We can simply skip checking for the remote control /* TODO: need a lock here. We can simply skip checking for the remote
if we're busy. */ control if we're busy. */
/* when the parameter has been set to 1 via sysfs while the /* when the parameter has been set to 1 via sysfs while the
* driver was running, or when bulk mode is enabled after IR init * driver was running, or when bulk mode is enabled after IR init
...@@ -254,7 +225,8 @@ static void dvb_usb_read_remote_control(struct work_struct *work) ...@@ -254,7 +225,8 @@ static void dvb_usb_read_remote_control(struct work_struct *work)
err = d->props.rc.core.rc_query(d); err = d->props.rc.core.rc_query(d);
if (err) if (err)
err("error %d while querying for an remote control event.", err); err("error %d while querying for an remote control event.",
err);
schedule_delayed_work(&d->rc_query_work, schedule_delayed_work(&d->rc_query_work,
msecs_to_jiffies(d->props.rc.core.rc_interval)); msecs_to_jiffies(d->props.rc.core.rc_interval));
...@@ -377,13 +349,14 @@ int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *d, ...@@ -377,13 +349,14 @@ int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *d,
*state = REMOTE_KEY_PRESSED; *state = REMOTE_KEY_PRESSED;
return 0; return 0;
} }
deb_err("key mapping failed - no appropriate key found in keymapping\n"); deb_err("key mapping failed - no appropriate key found in" \
" keymapping\n");
break; break;
case DVB_USB_RC_NEC_KEY_REPEATED: case DVB_USB_RC_NEC_KEY_REPEATED:
*state = REMOTE_KEY_REPEAT; *state = REMOTE_KEY_REPEAT;
break; break;
default: default:
deb_err("unknown type of remote status: %d\n",keybuf[0]); deb_err("unknown type of remote status: %d\n", keybuf[0]);
break; break;
} }
return 0; return 0;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
u16 rlen, int delay_ms) u16 rlen, int delay_ms)
{ {
int actlen,ret = -ENOMEM; int actlen, ret = -ENOMEM;
if (!d || wbuf == NULL || wlen == 0) if (!d || wbuf == NULL || wlen == 0)
return -EINVAL; return -EINVAL;
...@@ -21,18 +21,19 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, ...@@ -21,18 +21,19 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
return -EINVAL; return -EINVAL;
} }
if ((ret = mutex_lock_interruptible(&d->usb_mutex))) ret = mutex_lock_interruptible(&d->usb_mutex);
if (ret)
return ret; return ret;
deb_xfer(">>> "); deb_xfer(">>> ");
debug_dump(wbuf,wlen,deb_xfer); debug_dump(wbuf, wlen, deb_xfer);
ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev, ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
d->props.generic_bulk_ctrl_endpoint), wbuf,wlen,&actlen, d->props.generic_bulk_ctrl_endpoint), wbuf, wlen,
2000); &actlen, 2000);
if (ret) if (ret)
err("bulk message failed: %d (%d/%d)",ret,wlen,actlen); err("bulk message failed: %d (%d/%d)", ret, wlen, actlen);
else else
ret = actlen != wlen ? -1 : 0; ret = actlen != wlen ? -1 : 0;
...@@ -41,17 +42,17 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, ...@@ -41,17 +42,17 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
if (delay_ms) if (delay_ms)
msleep(delay_ms); msleep(delay_ms);
ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev, ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev,
d->props.generic_bulk_ctrl_endpoint_response ? d->props.generic_bulk_ctrl_endpoint_response ?
d->props.generic_bulk_ctrl_endpoint_response : d->props.generic_bulk_ctrl_endpoint_response :
d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen, d->props.generic_bulk_ctrl_endpoint),
2000); rbuf, rlen, &actlen, 2000);
if (ret) if (ret)
err("recv bulk message failed: %d",ret); err("recv bulk message failed: %d", ret);
else { else {
deb_xfer("<<< "); deb_xfer("<<< ");
debug_dump(rbuf,actlen,deb_xfer); debug_dump(rbuf, actlen, deb_xfer);
} }
} }
...@@ -62,18 +63,20 @@ EXPORT_SYMBOL(dvb_usbv2_generic_rw); ...@@ -62,18 +63,20 @@ EXPORT_SYMBOL(dvb_usbv2_generic_rw);
int dvb_usbv2_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len) int dvb_usbv2_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len)
{ {
return dvb_usbv2_generic_rw(d,buf,len,NULL,0,0); return dvb_usbv2_generic_rw(d, buf, len, NULL, 0, 0);
} }
EXPORT_SYMBOL(dvb_usbv2_generic_write); EXPORT_SYMBOL(dvb_usbv2_generic_write);
static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer, size_t length) static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer,
size_t length)
{ {
struct dvb_usb_adapter *adap = stream->user_priv; struct dvb_usb_adapter *adap = stream->user_priv;
if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB) if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
dvb_dmx_swfilter(&adap->demux, buffer, length); dvb_dmx_swfilter(&adap->demux, buffer, length);
} }
static void dvb_usb_data_complete_204(struct usb_data_stream *stream, u8 *buffer, size_t length) static void dvb_usb_data_complete_204(struct usb_data_stream *stream,
u8 *buffer, size_t length)
{ {
struct dvb_usb_adapter *adap = stream->user_priv; struct dvb_usb_adapter *adap = stream->user_priv;
if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB) if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
......
...@@ -18,10 +18,11 @@ static void usb_urb_complete(struct urb *urb) ...@@ -18,10 +18,11 @@ static void usb_urb_complete(struct urb *urb)
int i; int i;
u8 *b; u8 *b;
deb_uxfer("'%s' urb completed. status: %d, length: %d/%d, pack_num: %d, errors: %d\n", deb_uxfer("'%s' urb completed. status: %d, length: %d/%d," \
" pack_num: %d, errors: %d\n",
ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk",
urb->status,urb->actual_length,urb->transfer_buffer_length, urb->status, urb->actual_length, urb->transfer_buffer_length,
urb->number_of_packets,urb->error_count); urb->number_of_packets, urb->error_count);
switch (urb->status) { switch (urb->status) {
case 0: /* success */ case 0: /* success */
...@@ -40,16 +41,19 @@ static void usb_urb_complete(struct urb *urb) ...@@ -40,16 +41,19 @@ static void usb_urb_complete(struct urb *urb)
switch (ptype) { switch (ptype) {
case PIPE_ISOCHRONOUS: case PIPE_ISOCHRONOUS:
for (i = 0; i < urb->number_of_packets; i++) { for (i = 0; i < urb->number_of_packets; i++) {
if (urb->iso_frame_desc[i].status != 0) if (urb->iso_frame_desc[i].status != 0)
deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status); deb_ts("iso frame descriptor has an" \
" error: %d\n",
urb->iso_frame_desc[i].status);
else if (urb->iso_frame_desc[i].actual_length > 0) else if (urb->iso_frame_desc[i].actual_length > 0)
stream->complete(stream, b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length); stream->complete(stream,
b + urb->iso_frame_desc[i].offset,
urb->iso_frame_desc[i].actual_length);
urb->iso_frame_desc[i].status = 0; urb->iso_frame_desc[i].status = 0;
urb->iso_frame_desc[i].actual_length = 0; urb->iso_frame_desc[i].actual_length = 0;
} }
debug_dump(b,20,deb_uxfer); debug_dump(b, 20, deb_uxfer);
break; break;
case PIPE_BULK: case PIPE_BULK:
if (urb->actual_length > 0) if (urb->actual_length > 0)
...@@ -59,14 +63,14 @@ static void usb_urb_complete(struct urb *urb) ...@@ -59,14 +63,14 @@ static void usb_urb_complete(struct urb *urb)
err("unknown endpoint type in completition handler."); err("unknown endpoint type in completition handler.");
return; return;
} }
usb_submit_urb(urb,GFP_ATOMIC); usb_submit_urb(urb, GFP_ATOMIC);
} }
int usb_urb_kill(struct usb_data_stream *stream) int usb_urb_kill(struct usb_data_stream *stream)
{ {
int i; int i;
for (i = 0; i < stream->urbs_submitted; i++) { for (i = 0; i < stream->urbs_submitted; i++) {
deb_ts("killing URB no. %d.\n",i); deb_ts("killing URB no. %d.\n", i);
/* stop the URB */ /* stop the URB */
usb_kill_urb(stream->urb_list[i]); usb_kill_urb(stream->urb_list[i]);
...@@ -77,11 +81,13 @@ int usb_urb_kill(struct usb_data_stream *stream) ...@@ -77,11 +81,13 @@ int usb_urb_kill(struct usb_data_stream *stream)
int usb_urb_submit(struct usb_data_stream *stream) int usb_urb_submit(struct usb_data_stream *stream)
{ {
int i,ret; int i, ret;
for (i = 0; i < stream->urbs_initialized; i++) { for (i = 0; i < stream->urbs_initialized; i++) {
deb_ts("submitting URB no. %d\n",i); deb_ts("submitting URB no. %d\n", i);
if ((ret = usb_submit_urb(stream->urb_list[i],GFP_ATOMIC))) { ret = usb_submit_urb(stream->urb_list[i], GFP_ATOMIC);
err("could not submit URB no. %d - get them all back",i); if (ret) {
err("could not submit URB no. %d - get them all back",
i);
usb_urb_kill(stream); usb_urb_kill(stream);
return ret; return ret;
} }
...@@ -95,7 +101,7 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream) ...@@ -95,7 +101,7 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream)
if (stream->state & USB_STATE_URB_BUF) { if (stream->state & USB_STATE_URB_BUF) {
while (stream->buf_num) { while (stream->buf_num) {
stream->buf_num--; stream->buf_num--;
deb_mem("freeing buffer %d\n",stream->buf_num); deb_mem("freeing buffer %d\n", stream->buf_num);
usb_free_coherent(stream->udev, stream->buf_size, usb_free_coherent(stream->udev, stream->buf_size,
stream->buf_list[stream->buf_num], stream->buf_list[stream->buf_num],
stream->dma_addr[stream->buf_num]); stream->dma_addr[stream->buf_num]);
...@@ -107,26 +113,30 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream) ...@@ -107,26 +113,30 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream)
return 0; return 0;
} }
static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, unsigned long size) static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num,
unsigned long size)
{ {
stream->buf_num = 0; stream->buf_num = 0;
stream->buf_size = size; stream->buf_size = size;
deb_mem("all in all I will use %lu bytes for streaming\n",num*size); deb_mem("all in all I will use %lu bytes for streaming\n", num * size);
for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
deb_mem("allocating buffer %d\n",stream->buf_num); deb_mem("allocating buffer %d\n", stream->buf_num);
if (( stream->buf_list[stream->buf_num] = stream->buf_list[stream->buf_num] = usb_alloc_coherent(
usb_alloc_coherent(stream->udev, size, GFP_ATOMIC, stream->udev, size, GFP_ATOMIC,
&stream->dma_addr[stream->buf_num]) ) == NULL) { &stream->dma_addr[stream->buf_num]);
deb_mem("not enough memory for urb-buffer allocation.\n"); if (stream->buf_list[stream->buf_num] == NULL) {
deb_mem("not enough memory for urb-buffer" \
" allocation.\n");
usb_free_stream_buffers(stream); usb_free_stream_buffers(stream);
return -ENOMEM; return -ENOMEM;
} }
deb_mem("buffer %d: %p (dma: %Lu)\n", deb_mem("buffer %d: %p (dma: %llu)\n",
stream->buf_num, stream->buf_num,
stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]); stream->buf_list[stream->buf_num],
memset(stream->buf_list[stream->buf_num],0,size); (long long)stream->dma_addr[stream->buf_num]);
memset(stream->buf_list[stream->buf_num], 0, size);
stream->state |= USB_STATE_URB_BUF; stream->state |= USB_STATE_URB_BUF;
} }
deb_mem("allocation successful\n"); deb_mem("allocation successful\n");
...@@ -138,8 +148,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) ...@@ -138,8 +148,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
{ {
int i, j; int i, j;
if ((i = usb_allocate_stream_buffers(stream,stream->props.count, i = usb_allocate_stream_buffers(stream, stream->props.count,
stream->props.u.bulk.buffersize)) < 0) stream->props.u.bulk.buffersize);
if (i < 0)
return i; return i;
/* allocate the URBs */ /* allocate the URBs */
...@@ -151,8 +162,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) ...@@ -151,8 +162,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
usb_free_urb(stream->urb_list[j]); usb_free_urb(stream->urb_list[j]);
return -ENOMEM; return -ENOMEM;
} }
usb_fill_bulk_urb( stream->urb_list[i], stream->udev, usb_fill_bulk_urb(stream->urb_list[i], stream->udev,
usb_rcvbulkpipe(stream->udev,stream->props.endpoint), usb_rcvbulkpipe(stream->udev,
stream->props.endpoint),
stream->buf_list[i], stream->buf_list[i],
stream->props.u.bulk.buffersize, stream->props.u.bulk.buffersize,
usb_urb_complete, stream); usb_urb_complete, stream);
...@@ -166,10 +178,12 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) ...@@ -166,10 +178,12 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
static int usb_isoc_urb_init(struct usb_data_stream *stream) static int usb_isoc_urb_init(struct usb_data_stream *stream)
{ {
int i,j; int i, j;
if ((i = usb_allocate_stream_buffers(stream,stream->props.count, i = usb_allocate_stream_buffers(stream, stream->props.count,
stream->props.u.isoc.framesize*stream->props.u.isoc.framesperurb)) < 0) stream->props.u.isoc.framesize *
stream->props.u.isoc.framesperurb);
if (i < 0)
return i; return i;
/* allocate the URBs */ /* allocate the URBs */
...@@ -177,7 +191,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) ...@@ -177,7 +191,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
struct urb *urb; struct urb *urb;
int frame_offset = 0; int frame_offset = 0;
stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC); stream->urb_list[i] = usb_alloc_urb(
stream->props.u.isoc.framesperurb, GFP_ATOMIC);
if (!stream->urb_list[i]) { if (!stream->urb_list[i]) {
deb_mem("not enough memory for urb_alloc_urb!\n"); deb_mem("not enough memory for urb_alloc_urb!\n");
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
...@@ -190,7 +205,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) ...@@ -190,7 +205,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
urb->dev = stream->udev; urb->dev = stream->udev;
urb->context = stream; urb->context = stream;
urb->complete = usb_urb_complete; urb->complete = usb_urb_complete;
urb->pipe = usb_rcvisocpipe(stream->udev,stream->props.endpoint); urb->pipe = usb_rcvisocpipe(stream->udev,
stream->props.endpoint);
urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
urb->interval = stream->props.u.isoc.interval; urb->interval = stream->props.u.isoc.interval;
urb->number_of_packets = stream->props.u.isoc.framesperurb; urb->number_of_packets = stream->props.u.isoc.framesperurb;
...@@ -200,7 +216,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) ...@@ -200,7 +216,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
for (j = 0; j < stream->props.u.isoc.framesperurb; j++) { for (j = 0; j < stream->props.u.isoc.framesperurb; j++) {
urb->iso_frame_desc[j].offset = frame_offset; urb->iso_frame_desc[j].offset = frame_offset;
urb->iso_frame_desc[j].length = stream->props.u.isoc.framesize; urb->iso_frame_desc[j].length =
stream->props.u.isoc.framesize;
frame_offset += stream->props.u.isoc.framesize; frame_offset += stream->props.u.isoc.framesize;
} }
...@@ -209,14 +226,16 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) ...@@ -209,14 +226,16 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
return 0; return 0;
} }
int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props) int usb_urb_init(struct usb_data_stream *stream,
struct usb_data_stream_properties *props)
{ {
if (stream == NULL || props == NULL) if (stream == NULL || props == NULL)
return -EINVAL; return -EINVAL;
memcpy(&stream->props, props, sizeof(*props)); memcpy(&stream->props, props, sizeof(*props));
usb_clear_halt(stream->udev,usb_rcvbulkpipe(stream->udev,stream->props.endpoint)); usb_clear_halt(stream->udev, usb_rcvbulkpipe(stream->udev,
stream->props.endpoint));
if (stream->complete == NULL) { if (stream->complete == NULL) {
err("there is no data callback - this doesn't make sense."); err("there is no data callback - this doesn't make sense.");
...@@ -242,7 +261,7 @@ int usb_urb_exit(struct usb_data_stream *stream) ...@@ -242,7 +261,7 @@ int usb_urb_exit(struct usb_data_stream *stream)
for (i = 0; i < stream->urbs_initialized; i++) { for (i = 0; i < stream->urbs_initialized; i++) {
if (stream->urb_list[i] != NULL) { if (stream->urb_list[i] != NULL) {
deb_mem("freeing URB no. %d.\n",i); deb_mem("freeing URB no. %d.\n", i);
/* free the URBs */ /* free the URBs */
usb_free_urb(stream->urb_list[i]); usb_free_urb(stream->urb_list[i]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment