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 @@
/* debug */
#ifdef CONFIG_DVB_USB_DEBUG
#define dprintk(var,level,args...) \
do { if ((var & level)) { printk(args); } } while (0)
#define dprintk(var, level, args...) \
do { if ((var & level)) { printk(args); } } while (0)
#define debug_dump(b,l,func) {\
#define debug_dump(b, l, func) {\
int loop_; \
for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \
for (loop_ = 0; loop_ < l; loop_++) \
func("%02x ", b[loop_]); \
func("\n");\
}
#define DVB_USB_DEBUG_STATUS
#else
#define dprintk(args...)
#define debug_dump(b,l,func)
#define debug_dump(b, l, func)
#define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"
......@@ -50,11 +51,14 @@
#endif
#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
#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
#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
......@@ -120,7 +124,8 @@ struct usb_data_stream_properties {
/**
* 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.
* @pid_filter_count: number of PID filter position in the optional hardware
* PID-filter.
......@@ -277,7 +282,8 @@ struct dvb_usb_device_properties {
int usb_ctrl;
#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 size_of_priv;
......@@ -351,7 +357,8 @@ struct usb_data_stream {
* @pll_addr: I2C address of the tuner for programming
* @pll_init: array containing the initialization buffer
* @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.
* @dmxdev: device's dmxdev.
......@@ -468,11 +475,13 @@ extern int dvb_usbv2_device_init(struct usb_interface *,
extern void dvb_usbv2_device_exit(struct usb_interface *);
/* 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);
/* 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 */
struct hexline {
......@@ -482,8 +491,9 @@ struct hexline {
u8 data[255];
u8 chk;
};
extern int usbv2_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
extern int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos);
extern int usbv2_cypress_load_firmware(struct usb_device *udev,
const struct firmware *fw, int type);
extern int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx,
int *pos);
#endif
......@@ -3,7 +3,8 @@
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
* 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
#define DVB_USB_COMMON_H
......@@ -14,22 +15,23 @@
extern int dvb_usb_debug;
extern int dvb_usb_disable_rc_polling;
#define deb_info(args...) dprintk(dvb_usb_debug,0x001,args)
#define deb_xfer(args...) dprintk(dvb_usb_debug,0x002,args)
#define deb_pll(args...) dprintk(dvb_usb_debug,0x004,args)
#define deb_ts(args...) dprintk(dvb_usb_debug,0x008,args)
#define deb_err(args...) dprintk(dvb_usb_debug,0x010,args)
#define deb_rc(args...) dprintk(dvb_usb_debug,0x020,args)
#define deb_fw(args...) dprintk(dvb_usb_debug,0x040,args)
#define deb_mem(args...) dprintk(dvb_usb_debug,0x080,args)
#define deb_uxfer(args...) dprintk(dvb_usb_debug,0x100,args)
#define deb_info(args...) dprintk(dvb_usb_debug, 0x001, args)
#define deb_xfer(args...) dprintk(dvb_usb_debug, 0x002, args)
#define deb_pll(args...) dprintk(dvb_usb_debug, 0x004, args)
#define deb_ts(args...) dprintk(dvb_usb_debug, 0x008, args)
#define deb_err(args...) dprintk(dvb_usb_debug, 0x010, args)
#define deb_rc(args...) dprintk(dvb_usb_debug, 0x020, args)
#define deb_fw(args...) dprintk(dvb_usb_debug, 0x040, args)
#define deb_mem(args...) dprintk(dvb_usb_debug, 0x080, args)
#define deb_uxfer(args...) dprintk(dvb_usb_debug, 0x100, args)
/* commonly used methods */
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 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_submit(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)
usb_urb_kill(&adap->fe_adap[adap->active_fe].stream);
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) {
err("error while stopping stream.");
return ret;
......@@ -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 &&
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(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
* for reception.
......@@ -62,7 +64,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
adap->props.fe[adap->active_fe].caps &
DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF &&
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);
if (ret < 0) {
err("could not handle pid_parser");
......@@ -71,7 +74,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
}
deb_ts("start feeding\n");
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) {
err("error while enabling fifo.");
return ret;
......@@ -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)
{
deb_ts("start pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid,dvbdmxfeed->type);
return dvb_usb_ctrl_feed(dvbdmxfeed,1);
deb_ts("start pid: 0x%04x, feedtype: %d\n",
dvbdmxfeed->pid, dvbdmxfeed->type);
return dvb_usb_ctrl_feed(dvbdmxfeed, 1);
}
static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
{
deb_ts("stop pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid, dvbdmxfeed->type);
return dvb_usb_ctrl_feed(dvbdmxfeed,0);
deb_ts("stop pid: 0x%04x, feedtype: %d\n",
dvbdmxfeed->pid, dvbdmxfeed->type);
return dvb_usb_ctrl_feed(dvbdmxfeed, 0);
}
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;
if (adap->dev->props.read_mac_address) {
if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0)
info("MAC address: %pM",adap->dvb_adap.proposed_mac);
if (adap->dev->props.read_mac_address(adap->dev,
adap->dvb_adap.proposed_mac) == 0)
info("MAC address: %pM", adap->dvb_adap.proposed_mac);
else
err("MAC address reading failed.");
}
......@@ -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.stop_feed = dvb_usb_stop_feed;
adap->demux.write_to_decoder = NULL;
if ((ret = dvb_dmx_init(&adap->demux)) < 0) {
err("dvb_dmx_init failed: error %d",ret);
ret = dvb_dmx_init(&adap->demux);
if (ret < 0) {
err("dvb_dmx_init failed: error %d", ret);
goto err_dmx;
}
adap->dmxdev.filternum = adap->demux.filternum;
adap->dmxdev.demux = &adap->demux.dmx;
adap->dmxdev.capabilities = 0;
if ((ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap)) < 0) {
err("dvb_dmxdev_init failed: error %d",ret);
ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap);
if (ret < 0) {
err("dvb_dmxdev_init failed: error %d", ret);
goto err_dmx_dev;
}
if ((ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net,
&adap->demux.dmx)) < 0) {
err("dvb_net_init failed: error %d",ret);
ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx);
if (ret < 0) {
err("dvb_net_init failed: error %d", ret);
goto err_net_init;
}
......@@ -225,7 +234,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
for (i = 0; i < adap->props.num_frontends; i++) {
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.",
adap->dev->desc->name, adap->id, i);
......@@ -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->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);
dvb_frontend_detach(adap->fe_adap[i].fe);
adap->fe_adap[i].fe = NULL;
......
......@@ -3,9 +3,11 @@
* Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
* 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"
......@@ -13,58 +15,71 @@
struct usb_cypress_controller {
int id;
const char *name; /* name of the usb controller */
u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */
/* name of the usb controller */
const char *name;
/* needs to be restarted, when the firmware has been downloaded. */
u16 cpu_cs_register;
};
static struct usb_cypress_controller cypress[] = {
{ .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 },
{ .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 },
{ .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 },
{ .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 },
{ .id = DEVICE_SPECIFIC, .name = "Device specific",
.cpu_cs_register = 0 },
{ .id = CYPRESS_AN2135, .name = "Cypress AN2135",
.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
*/
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);
}
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;
u8 reset;
int ret,pos=0;
int ret, pos = 0;
/* stop the CPU */
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.");
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);
ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
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);
ret = usb_cypress_writemem(udev, hx.addr, hx.data, hx.len);
if (ret != hx.len) {
err("error while transferring firmware "
err("error while transferring firmware " \
"(transferred size: %d, block size: %d)",
ret,hx.len);
ret, hx.len);
ret = -EINVAL;
break;
}
}
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;
}
if (ret == 0) {
/* restart the CPU */
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.");
ret = -EINVAL;
}
......@@ -85,32 +100,37 @@ int dvb_usb_download_firmware(struct dvb_usb_device *d)
if (ret < 0)
return ret;
if ((ret = request_firmware(&fw, name, &d->udev->dev)) != 0) {
err("did not find the firmware file. (%s) "
"Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
name,ret);
ret = request_firmware(&fw, name, &d->udev->dev);
if (ret != 0) {
err("did not find the firmware file. (%s) " \
"Please see linux/Documentation/dvb/ for more" \
" details on firmware-problems. (%d)",
name, ret);
return ret;
}
info("downloading firmware from file '%s'", name);
switch (d->props.usb_ctrl) {
case CYPRESS_AN2135:
case CYPRESS_AN2235:
case CYPRESS_FX2:
ret = usbv2_cypress_load_firmware(d->udev, fw, d->props.usb_ctrl);
break;
case DEVICE_SPECIFIC:
if (d->props.download_firmware)
ret = d->props.download_firmware(d, fw);
else {
err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one.");
ret = -EINVAL;
}
break;
default:
case CYPRESS_AN2135:
case CYPRESS_AN2235:
case CYPRESS_FX2:
ret = usbv2_cypress_load_firmware(d->udev, fw,
d->props.usb_ctrl);
break;
case DEVICE_SPECIFIC:
if (d->props.download_firmware)
ret = d->props.download_firmware(d, fw);
else {
err("BUG: driver didn't specified a download_firmware" \
"-callback, although it claims to have a" \
" DEVICE_SPECIFIC one.");
ret = -EINVAL;
break;
}
break;
default:
ret = -EINVAL;
break;
}
release_firmware(fw);
......@@ -125,7 +145,7 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx,
if (*pos >= fw->size)
return 0;
memset(hx,0,sizeof(struct hexline));
memset(hx, 0, sizeof(struct hexline));
hx->len = b[0];
......@@ -136,12 +156,13 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx,
hx->type = b[3];
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->len -= 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];
*pos += hx->len + 5;
......
......@@ -26,7 +26,8 @@ int dvb_usb_i2c_init(struct dvb_usb_device *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");
d->state |= DVB_USB_STATE_I2C;
......
This diff is collapsed.
......@@ -3,7 +3,8 @@
* Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
* 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 <linux/usb/input.h>
......@@ -112,73 +113,40 @@ static void legacy_dvb_usb_read_remote_control(struct work_struct *work)
u32 event;
int state;
/* TODO: need a lock here. We can simply skip checking for the remote control
if we're busy. */
/* TODO: need a lock here. We can simply skip checking for the remote
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)
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.");
goto schedule;
}
switch (state) {
case REMOTE_NO_KEY_PRESSED:
break;
case REMOTE_KEY_PRESSED:
deb_rc("key pressed\n");
d->last_event = event;
case REMOTE_KEY_REPEAT:
deb_rc("key repeated\n");
input_event(d->input_dev, EV_KEY, event, 1);
input_sync(d->input_dev);
input_event(d->input_dev, EV_KEY, d->last_event, 0);
input_sync(d->input_dev);
break;
default:
break;
case REMOTE_NO_KEY_PRESSED:
break;
case REMOTE_KEY_PRESSED:
deb_rc("key pressed\n");
d->last_event = event;
case REMOTE_KEY_REPEAT:
deb_rc("key repeated\n");
input_event(d->input_dev, EV_KEY, event, 1);
input_sync(d->input_dev);
input_event(d->input_dev, EV_KEY, d->last_event, 0);
input_sync(d->input_dev);
break;
default:
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_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)
......@@ -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++) {
deb_rc("setting bit for event %d item %d\n",
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_DELAY] = d->props.rc.legacy.rc_interval + 150;
......@@ -221,7 +191,8 @@ static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d)
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);
schedule_delayed_work(&d->rc_query_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);
int err;
/* TODO: need a lock here. We can simply skip checking for the remote control
if we're busy. */
/* TODO: need a lock here. We can simply skip checking for the remote
control if we're busy. */
/* when the parameter has been set to 1 via sysfs while the
* 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)
err = d->props.rc.core.rc_query(d);
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,
msecs_to_jiffies(d->props.rc.core.rc_interval));
......@@ -361,30 +333,31 @@ int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *d,
*event = 0;
*state = REMOTE_NO_KEY_PRESSED;
switch (keybuf[0]) {
case DVB_USB_RC_NEC_EMPTY:
case DVB_USB_RC_NEC_EMPTY:
break;
case DVB_USB_RC_NEC_KEY_PRESSED:
if ((u8) ~keybuf[1] != keybuf[2] ||
(u8) ~keybuf[3] != keybuf[4]) {
deb_err("remote control checksum failed.\n");
break;
case DVB_USB_RC_NEC_KEY_PRESSED:
if ((u8) ~keybuf[1] != keybuf[2] ||
(u8) ~keybuf[3] != keybuf[4]) {
deb_err("remote control checksum failed.\n");
break;
}
/* See if we can match the raw key code. */
for (i = 0; i < d->props.rc.legacy.rc_map_size; i++)
if (rc5_custom(&keymap[i]) == keybuf[1] &&
rc5_data(&keymap[i]) == keybuf[3]) {
*event = keymap[i].keycode;
*state = REMOTE_KEY_PRESSED;
return 0;
}
/* See if we can match the raw key code. */
for (i = 0; i < d->props.rc.legacy.rc_map_size; i++)
if (rc5_custom(&keymap[i]) == keybuf[1] &&
rc5_data(&keymap[i]) == keybuf[3]) {
*event = keymap[i].keycode;
*state = REMOTE_KEY_PRESSED;
return 0;
}
deb_err("key mapping failed - no appropriate key found in keymapping\n");
break;
case DVB_USB_RC_NEC_KEY_REPEATED:
*state = REMOTE_KEY_REPEAT;
break;
default:
deb_err("unknown type of remote status: %d\n",keybuf[0]);
break;
deb_err("key mapping failed - no appropriate key found in" \
" keymapping\n");
break;
case DVB_USB_RC_NEC_KEY_REPEATED:
*state = REMOTE_KEY_REPEAT;
break;
default:
deb_err("unknown type of remote status: %d\n", keybuf[0]);
break;
}
return 0;
}
......
......@@ -11,7 +11,7 @@
int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
u16 rlen, int delay_ms)
{
int actlen,ret = -ENOMEM;
int actlen, ret = -ENOMEM;
if (!d || wbuf == NULL || wlen == 0)
return -EINVAL;
......@@ -21,18 +21,19 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
return -EINVAL;
}
if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
ret = mutex_lock_interruptible(&d->usb_mutex);
if (ret)
return ret;
deb_xfer(">>> ");
debug_dump(wbuf,wlen,deb_xfer);
debug_dump(wbuf, wlen, deb_xfer);
ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev,
d->props.generic_bulk_ctrl_endpoint), wbuf,wlen,&actlen,
2000);
ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
d->props.generic_bulk_ctrl_endpoint), wbuf, wlen,
&actlen, 2000);
if (ret)
err("bulk message failed: %d (%d/%d)",ret,wlen,actlen);
err("bulk message failed: %d (%d/%d)", ret, wlen, actlen);
else
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,
if (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),rbuf,rlen,&actlen,
2000);
d->props.generic_bulk_ctrl_endpoint),
rbuf, rlen, &actlen, 2000);
if (ret)
err("recv bulk message failed: %d",ret);
err("recv bulk message failed: %d", ret);
else {
deb_xfer("<<< ");
debug_dump(rbuf,actlen,deb_xfer);
debug_dump(rbuf, actlen, deb_xfer);
}
}
......@@ -62,18 +63,20 @@ EXPORT_SYMBOL(dvb_usbv2_generic_rw);
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);
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;
if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
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;
if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
......
......@@ -18,55 +18,59 @@ static void usb_urb_complete(struct urb *urb)
int i;
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",
urb->status,urb->actual_length,urb->transfer_buffer_length,
urb->number_of_packets,urb->error_count);
urb->status, urb->actual_length, urb->transfer_buffer_length,
urb->number_of_packets, urb->error_count);
switch (urb->status) {
case 0: /* success */
case -ETIMEDOUT: /* NAK */
break;
case -ECONNRESET: /* kill */
case -ENOENT:
case -ESHUTDOWN:
return;
default: /* error */
deb_ts("urb completition error %d.\n", urb->status);
break;
case 0: /* success */
case -ETIMEDOUT: /* NAK */
break;
case -ECONNRESET: /* kill */
case -ENOENT:
case -ESHUTDOWN:
return;
default: /* error */
deb_ts("urb completition error %d.\n", urb->status);
break;
}
b = (u8 *) urb->transfer_buffer;
switch (ptype) {
case PIPE_ISOCHRONOUS:
for (i = 0; i < urb->number_of_packets; i++) {
if (urb->iso_frame_desc[i].status != 0)
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)
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].actual_length = 0;
}
debug_dump(b,20,deb_uxfer);
break;
case PIPE_BULK:
if (urb->actual_length > 0)
stream->complete(stream, b, urb->actual_length);
break;
default:
err("unknown endpoint type in completition handler.");
return;
case PIPE_ISOCHRONOUS:
for (i = 0; i < urb->number_of_packets; i++) {
if (urb->iso_frame_desc[i].status != 0)
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)
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].actual_length = 0;
}
debug_dump(b, 20, deb_uxfer);
break;
case PIPE_BULK:
if (urb->actual_length > 0)
stream->complete(stream, b, urb->actual_length);
break;
default:
err("unknown endpoint type in completition handler.");
return;
}
usb_submit_urb(urb,GFP_ATOMIC);
usb_submit_urb(urb, GFP_ATOMIC);
}
int usb_urb_kill(struct usb_data_stream *stream)
{
int 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 */
usb_kill_urb(stream->urb_list[i]);
......@@ -77,11 +81,13 @@ int usb_urb_kill(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++) {
deb_ts("submitting URB no. %d\n",i);
if ((ret = usb_submit_urb(stream->urb_list[i],GFP_ATOMIC))) {
err("could not submit URB no. %d - get them all back",i);
deb_ts("submitting URB no. %d\n", i);
ret = usb_submit_urb(stream->urb_list[i], GFP_ATOMIC);
if (ret) {
err("could not submit URB no. %d - get them all back",
i);
usb_urb_kill(stream);
return ret;
}
......@@ -95,7 +101,7 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream)
if (stream->state & USB_STATE_URB_BUF) {
while (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,
stream->buf_list[stream->buf_num],
stream->dma_addr[stream->buf_num]);
......@@ -107,26 +113,30 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream)
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_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++) {
deb_mem("allocating buffer %d\n",stream->buf_num);
if (( stream->buf_list[stream->buf_num] =
usb_alloc_coherent(stream->udev, size, GFP_ATOMIC,
&stream->dma_addr[stream->buf_num]) ) == NULL) {
deb_mem("not enough memory for urb-buffer allocation.\n");
deb_mem("allocating buffer %d\n", stream->buf_num);
stream->buf_list[stream->buf_num] = usb_alloc_coherent(
stream->udev, size, GFP_ATOMIC,
&stream->dma_addr[stream->buf_num]);
if (stream->buf_list[stream->buf_num] == NULL) {
deb_mem("not enough memory for urb-buffer" \
" allocation.\n");
usb_free_stream_buffers(stream);
return -ENOMEM;
}
deb_mem("buffer %d: %p (dma: %Lu)\n",
stream->buf_num,
stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]);
memset(stream->buf_list[stream->buf_num],0,size);
deb_mem("buffer %d: %p (dma: %llu)\n",
stream->buf_num,
stream->buf_list[stream->buf_num],
(long long)stream->dma_addr[stream->buf_num]);
memset(stream->buf_list[stream->buf_num], 0, size);
stream->state |= USB_STATE_URB_BUF;
}
deb_mem("allocation successful\n");
......@@ -138,8 +148,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
{
int i, j;
if ((i = usb_allocate_stream_buffers(stream,stream->props.count,
stream->props.u.bulk.buffersize)) < 0)
i = usb_allocate_stream_buffers(stream, stream->props.count,
stream->props.u.bulk.buffersize);
if (i < 0)
return i;
/* allocate the URBs */
......@@ -151,8 +162,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
usb_free_urb(stream->urb_list[j]);
return -ENOMEM;
}
usb_fill_bulk_urb( stream->urb_list[i], stream->udev,
usb_rcvbulkpipe(stream->udev,stream->props.endpoint),
usb_fill_bulk_urb(stream->urb_list[i], stream->udev,
usb_rcvbulkpipe(stream->udev,
stream->props.endpoint),
stream->buf_list[i],
stream->props.u.bulk.buffersize,
usb_urb_complete, 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)
{
int i,j;
int i, j;
if ((i = usb_allocate_stream_buffers(stream,stream->props.count,
stream->props.u.isoc.framesize*stream->props.u.isoc.framesperurb)) < 0)
i = usb_allocate_stream_buffers(stream, stream->props.count,
stream->props.u.isoc.framesize *
stream->props.u.isoc.framesperurb);
if (i < 0)
return i;
/* allocate the URBs */
......@@ -177,7 +191,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
struct urb *urb;
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]) {
deb_mem("not enough memory for urb_alloc_urb!\n");
for (j = 0; j < i; j++)
......@@ -190,7 +205,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
urb->dev = stream->udev;
urb->context = stream;
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->interval = stream->props.u.isoc.interval;
urb->number_of_packets = stream->props.u.isoc.framesperurb;
......@@ -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++) {
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;
}
......@@ -209,14 +226,16 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
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)
return -EINVAL;
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) {
err("there is no data callback - this doesn't make sense.");
......@@ -224,13 +243,13 @@ int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properti
}
switch (stream->props.type) {
case USB_BULK:
return usb_bulk_urb_init(stream);
case USB_ISOC:
return usb_isoc_urb_init(stream);
default:
err("unknown URB-type for data transfer.");
return -EINVAL;
case USB_BULK:
return usb_bulk_urb_init(stream);
case USB_ISOC:
return usb_isoc_urb_init(stream);
default:
err("unknown URB-type for data transfer.");
return -EINVAL;
}
}
......@@ -242,7 +261,7 @@ int usb_urb_exit(struct usb_data_stream *stream)
for (i = 0; i < stream->urbs_initialized; i++) {
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 */
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