Naming, small code changes, debug writings, etc.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
return 0;
}
-static void anysee_disconnect(struct dvb_usb_device *d)
+static void anysee_exit(struct dvb_usb_device *d)
{
return anysee_ci_release(d);
}
.get_rc_config = anysee_get_rc_config,
.frontend_ctrl = anysee_frontend_ctrl,
.streaming_ctrl = anysee_streaming_ctrl,
- .disconnect = anysee_disconnect,
+ .exit = anysee_exit,
.num_adapters = 1,
.adapter = {
#ifndef DVB_USB_H
#define DVB_USB_H
-#include <linux/input.h>
-#include <linux/usb.h>
+#include <linux/usb/input.h>
#include <linux/firmware.h>
-#include <linux/mutex.h>
#include <media/rc-core.h>
#include "dvb_frontend.h"
.rc_map = (rc), \
})
+struct dvb_usb_device;
+struct dvb_usb_adapter;
+
struct dvb_usb_driver_info {
const char *name;
const char *rc_map;
const struct dvb_usb_device_properties *props;
};
-struct dvb_usb_device;
-struct dvb_usb_adapter;
-struct usb_data_stream;
+/**
+ * struct dvb_rc properties of remote controller, using rc-core
+ * @rc_codes: name of rc codes table
+ * @protocol: type of protocol(s) currently used by the driver
+ * @allowed_protos: protocol(s) supported by the driver
+ * @driver_type: Used to point if a device supports raw mode
+ * @change_protocol: callback to change protocol
+ * @rc_query: called to query an event event.
+ * @rc_interval: time in ms between two queries.
+ * @bulk_mode: device supports bulk mode for RC (disable polling mode)
+ */
+struct dvb_usb_rc {
+ char *map_name;
+ u64 allowed_protos;
+ int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
+ int (*query) (struct dvb_usb_device *d);
+ unsigned int interval;
+ const enum rc_driver_type driver_type;
+ bool bulk_mode;
+};
/**
* Properties of USB streaming - TODO this structure should be somewhere else
struct usb_data_stream_properties {
#define USB_BULK 1
#define USB_ISOC 2
- int type;
- int count;
- int endpoint;
+ u8 type;
+ u8 count;
+ u8 endpoint;
union {
struct {
- int buffersize; /* per URB */
+ unsigned int buffersize; /* per URB */
} bulk;
struct {
int framesperurb;
#define DVB_USB_ADAP_HAS_PID_FILTER 0x01
#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
#define DVB_USB_ADAP_NEED_PID_FILTERING 0x04
- int caps;
- int size_of_priv;
+ u8 caps;
- int pid_filter_count;
+ u8 pid_filter_count;
int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
struct usb_data_stream_properties stream;
};
-/**
- * struct dvb_rc properties of remote controller, using rc-core
- * @rc_codes: name of rc codes table
- * @protocol: type of protocol(s) currently used by the driver
- * @allowed_protos: protocol(s) supported by the driver
- * @driver_type: Used to point if a device supports raw mode
- * @change_protocol: callback to change protocol
- * @rc_query: called to query an event event.
- * @rc_interval: time in ms between two queries.
- * @bulk_mode: device supports bulk mode for RC (disable polling mode)
- */
-struct dvb_usb_rc {
- char *map_name;
- u64 allowed_protos;
- int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
- int (*query) (struct dvb_usb_device *d);
- int interval;
- const enum rc_driver_type driver_type;
- bool bulk_mode;
-};
-
/**
* struct dvb_usb_device_properties - properties of a dvb-usb-device
* @owner: owner of the dvb_adapter
const char *driver_name;
struct module *owner;
short *adapter_nr;
+
u8 bInterfaceNumber;
- int size_of_priv;
+ unsigned int size_of_priv;
+ u8 generic_bulk_ctrl_endpoint;
+ u8 generic_bulk_ctrl_endpoint_response;
#define WARM 0
#define COLD 1
int (*download_firmware) (struct dvb_usb_device *,
const struct firmware *);
- int num_adapters;
- int (*get_adapter_count) (struct dvb_usb_device *);
- struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
+ struct i2c_algorithm *i2c_algo;
- int (*power_ctrl) (struct dvb_usb_device *, int);
+ unsigned int num_adapters;
+ struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
+ int (*get_adapter_count) (struct dvb_usb_device *);
+ int (*power_ctrl) (struct dvb_usb_device *, int);
int (*read_config) (struct dvb_usb_device *d);
int (*read_mac_address) (struct dvb_usb_adapter *, u8 []);
int (*frontend_attach) (struct dvb_usb_adapter *);
int (*fe_ioctl_override) (struct dvb_frontend *,
unsigned int, void *, unsigned int);
int (*init) (struct dvb_usb_device *);
- void (*disconnect) (struct dvb_usb_device *);
+ void (*exit) (struct dvb_usb_device *);
int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
#define DVB_USB_FE_TS_TYPE_188 0
#define DVB_USB_FE_TS_TYPE_204 1
#define DVB_USB_FE_TS_TYPE_RAW 2
int (*get_stream_config) (struct dvb_frontend *, u8 *,
struct usb_data_stream_properties *);
-
- struct i2c_algorithm *i2c_algo;
-
- int generic_bulk_ctrl_endpoint;
- int generic_bulk_ctrl_endpoint_response;
};
/**
*/
#define MAX_NO_URBS_FOR_DATA_STREAM 10
struct usb_data_stream {
- struct usb_device *udev;
- struct usb_data_stream_properties props;
+ struct usb_device *udev;
+ struct usb_data_stream_properties props;
#define USB_STATE_INIT 0x00
#define USB_STATE_URB_BUF 0x01
- int state;
+ u8 state;
void (*complete) (struct usb_data_stream *, u8 *, size_t);
struct dvb_usb_adapter {
const struct dvb_usb_adapter_properties *props;
struct usb_data_stream stream;
- u8 id;
+ u8 id;
u8 ts_type;
- int pid_filtering;
- int feed_count;
- int max_feed_count;
-
- /* sync frontend and streaming as those are different tasks */
- struct mutex sync_mutex;
+ bool pid_filtering;
+ u8 feed_count;
+ u8 max_feed_count;
+ s8 active_fe;
/* dvb */
struct dvb_adapter dvb_adap;
struct dmxdev dmxdev;
struct dvb_demux demux;
struct dvb_net dvb_net;
+ struct mutex sync_mutex;
struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
-
- int active_fe;
};
/**
const struct dvb_usb_device_properties *props;
const char *name;
const char *rc_map;
- struct dvb_usb_rc rc;
+
struct usb_device *udev;
+ struct usb_interface *intf;
+ struct dvb_usb_rc rc;
struct work_struct probe_work;
pid_t work_pid;
- struct usb_interface *intf;
int powered;
/* locking */
* see Documentation/dvb/README.dvb-usb for more information
*/
#include "dvb_usb_common.h"
-#include <linux/usb/input.h>
int dvb_usbv2_disable_rc_polling;
module_param_named(disable_rc_polling, dvb_usbv2_disable_rc_polling, int, 0644);
MODULE_PARM_DESC(disable_rc_polling,
- "disable remote control polling (default: 0).");
+ "disable remote control polling (default: 0)");
static int dvb_usb_force_pid_filter_usage;
module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage,
int, 0444);
-MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a" \
- " PID filter, if any (default: 0).");
+MODULE_PARM_DESC(force_pid_filter_usage, "force all DVB USB devices to use a " \
+ "PID filter, if any (default: 0)");
static int dvb_usbv2_download_firmware(struct dvb_usb_device *d, const char *name)
{
int ret;
const struct firmware *fw;
+ pr_debug("%s:\n", __func__);
if (!d->props->download_firmware) {
ret = -EINVAL;
ret = request_firmware(&fw, name, &d->udev->dev);
if (ret < 0) {
- pr_err("%s: did not find the firmware file. (%s) " \
+ pr_err("%s: Did not find the firmware file '%s'. " \
"Please see linux/Documentation/dvb/ for " \
- "more details on firmware-problems. (%d)\n",
- KBUILD_MODNAME, name, ret);
+ "more details on firmware-problems. Status " \
+ "%d\n", KBUILD_MODNAME, name, ret);
goto err;
}
name);
ret = d->props->download_firmware(d, fw);
-
release_firmware(fw);
-
if (ret < 0)
goto err;
static int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
{
int ret;
-
pr_debug("%s:\n", __func__);
if (!d->props->i2c_algo)
struct dvb_usb_device, rc_query_work.work);
int ret;
- /* 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
+ /*
+ * When the parameter has been set to 1 via sysfs while the
+ * driver was running, or when bulk mode is enabled after IR init.
*/
if (dvb_usbv2_disable_rc_polling || d->rc.bulk_mode)
return;
ret = d->rc.query(d);
- if (ret < 0)
- pr_err("%s: error %d while querying for an remote control " \
- "event\n", KBUILD_MODNAME, ret);
+ if (ret < 0) {
+ pr_err("%s: rc.query() failed=%d\n", KBUILD_MODNAME, ret);
+ return; /* stop polling */
+ }
schedule_delayed_work(&d->rc_query_work,
- msecs_to_jiffies(d->rc.interval));
+ msecs_to_jiffies(d->rc.interval));
}
static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
{
int ret;
struct rc_dev *dev;
-
pr_debug("%s:\n", __func__);
if (dvb_usbv2_disable_rc_polling || !d->props->get_rc_config)
}
dev->dev.parent = &d->udev->dev;
- dev->input_name = "IR-receiver inside an USB DVB receiver";
+ dev->input_name = d->name;
usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
dev->input_phys = d->rc_phys;
dev->allowed_protos = d->rc.allowed_protos;
dev->change_protocol = d->rc.change_protocol;
dev->priv = d;
- /* select used keymap */
if (d->rc.map_name)
dev->map_name = d->rc.map_name;
- else if (d->rc_map)
- dev->map_name = d->rc_map;
else
- dev->map_name = RC_MAP_EMPTY; /* keep rc enabled */
+ dev->map_name = d->rc_map;
ret = rc_register_device(dev);
if (ret < 0) {
int dvb_usbv2_adapter_stream_exit(struct dvb_usb_adapter *adap)
{
pr_debug("%s: adap=%d\n", __func__, adap->id);
- usb_urb_exitv2(&adap->stream);
- return 0;
+ return usb_urb_exitv2(&adap->stream);
}
static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
if (ret < 0) {
pr_debug("%s: dvb_register_adapter() failed=%d\n", __func__,
ret);
- goto err;
+ goto err_dvb_register_adapter;
}
adap->dvb_adap.priv = adap;
ret = d->props->read_mac_address(adap,
adap->dvb_adap.proposed_mac);
if (ret < 0)
- goto err_dmx;
+ goto err_dvb_dmx_init;
pr_info("%s: MAC address: %pM\n", KBUILD_MODNAME,
adap->dvb_adap.proposed_mac);
adap->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
adap->demux.priv = adap;
adap->demux.filternum = 0;
- if (adap->demux.filternum < adap->max_feed_count)
- adap->demux.filternum = adap->max_feed_count;
+ adap->demux.filternum = adap->max_feed_count;
adap->demux.feednum = adap->demux.filternum;
adap->demux.start_feed = dvb_usb_start_feed;
adap->demux.stop_feed = dvb_usb_stop_feed;
ret = dvb_dmx_init(&adap->demux);
if (ret < 0) {
pr_err("%s: dvb_dmx_init() failed=%d\n", KBUILD_MODNAME, ret);
- goto err_dmx;
+ goto err_dvb_dmx_init;
}
adap->dmxdev.filternum = adap->demux.filternum;
if (ret < 0) {
pr_err("%s: dvb_dmxdev_init() failed=%d\n", KBUILD_MODNAME,
ret);
- goto err_dmx_dev;
+ goto err_dvb_dmxdev_init;
}
ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx);
if (ret < 0) {
pr_err("%s: dvb_net_init() failed=%d\n", KBUILD_MODNAME, ret);
- goto err_net_init;
+ goto err_dvb_net_init;
}
mutex_init(&adap->sync_mutex);
return 0;
-err_net_init:
+err_dvb_net_init:
dvb_dmxdev_release(&adap->dmxdev);
-err_dmx_dev:
+err_dvb_dmxdev_init:
dvb_dmx_release(&adap->demux);
-err_dmx:
+err_dvb_dmx_init:
dvb_unregister_adapter(&adap->dvb_adap);
-err:
+err_dvb_register_adapter:
adap->dvb_adap.priv = NULL;
return ret;
}
return ret;
}
-static int dvb_usb_fe_wakeup(struct dvb_frontend *fe)
+static int dvb_usb_fe_init(struct dvb_frontend *fe)
{
int ret;
struct dvb_usb_adapter *adap = fe->dvb->priv;
for (i = 0; i < MAX_NO_OF_FE_PER_ADAP && adap->fe[i]; i++) {
adap->fe[i]->id = i;
-
/* re-assign sleep and wakeup functions */
adap->fe_init[i] = adap->fe[i]->ops.init;
- adap->fe[i]->ops.init = dvb_usb_fe_wakeup;
+ adap->fe[i]->ops.init = dvb_usb_fe_init;
adap->fe_sleep[i] = adap->fe[i]->ops.sleep;
adap->fe[i]->ops.sleep = dvb_usb_fe_sleep;
static int dvb_usbv2_adapter_exit(struct dvb_usb_device *d)
{
int i;
-
pr_debug("%s:\n", __func__);
for (i = MAX_NO_OF_ADAPTER_PER_DEVICE - 1; i >= 0; i--) {
static int dvb_usbv2_init(struct dvb_usb_device *d)
{
- int ret = 0;
+ int ret;
+ pr_debug("%s:\n", __func__);
dvb_usbv2_device_power_ctrl(d, 1);
* is this routine. Due to that we delay actual operation using workqueue
* and return always success here.
*/
-
static void dvb_usbv2_init_work(struct work_struct *work)
{
int ret;
container_of(work, struct dvb_usb_device, probe_work);
d->work_pid = current->pid;
-
pr_debug("%s: work_pid=%d\n", __func__, d->work_pid);
if (d->props->size_of_priv) {
*/
return;
} else {
- /* Unexpected error. We must unregister driver
+ /*
+ * Unexpected error. We must unregister driver
* manually from the device, because device is
* already register by returning from probe()
* with success. usb_driver_release_interface()
err_usb_driver_release_interface:
pr_info("%s: '%s' error while loading driver (%d)\n", KBUILD_MODNAME,
d->name, ret);
- /* it finally calls disconnect() which frees mem */
usb_driver_release_interface(to_usb_driver(d->intf->dev.driver),
d->intf);
pr_debug("%s: failed=%d\n", __func__, ret);
void dvb_usbv2_disconnect(struct usb_interface *intf)
{
struct dvb_usb_device *d = usb_get_intfdata(intf);
- const char *name;
-
+ const char *name = d->name;
pr_debug("%s: pid=%d work_pid=%d\n", __func__, current->pid,
d->work_pid);
if (d->work_pid != current->pid)
cancel_work_sync(&d->probe_work);
- if (d->props->disconnect)
- d->props->disconnect(d);
+ if (d->props->exit)
+ d->props->exit(d);
- name = d->name;
dvb_usbv2_exit(d);
pr_info("%s: '%s' successfully deinitialized and disconnected\n",
{
struct dvb_usb_device *d = usb_get_intfdata(intf);
int i;
-
pr_debug("%s:\n", __func__);
/* stop remote controller poll */
{
struct dvb_usb_device *d = usb_get_intfdata(intf);
int i;
-
pr_debug("%s:\n", __func__);
/* start streaming */
case -ESHUTDOWN:
return;
default: /* error */
- pr_debug("%s: URB completition failed=%d\n", __func__,
+ pr_debug("%s: urb completition failed=%d\n", __func__,
urb->status);
break;
}
{
int i;
for (i = 0; i < stream->urbs_submitted; i++) {
- pr_debug("%s: kill URB=%d\n", __func__, i);
+ pr_debug("%s: kill urb=%d\n", __func__, i);
/* stop the URB */
usb_kill_urb(stream->urb_list[i]);
}
}
for (i = 0; i < stream->urbs_initialized; i++) {
- pr_debug("%s: submit URB=%d\n", __func__, i);
+ pr_debug("%s: submit urb=%d\n", __func__, i);
ret = usb_submit_urb(stream->urb_list[i], GFP_ATOMIC);
if (ret) {
- pr_err("%s: could not submit URB no. %d - get them " \
+ pr_err("%s: could not submit urb no. %d - get them " \
"all back\n", KBUILD_MODNAME, i);
usb_urb_killv2(stream);
return ret;
usb_urb_killv2(stream);
- for (i = 0; i < stream->urbs_initialized; i++) {
- if (stream->urb_list[i] != NULL) {
- pr_debug("%s: free URB=%d\n", __func__, i);
+ for (i = stream->urbs_initialized - 1; i >= 0; i--) {
+ if (stream->urb_list[i]) {
+ pr_debug("%s: free urb=%d\n", __func__, i);
/* free the URBs */
usb_free_urb(stream->urb_list[i]);
}
/* allocate the URBs */
for (i = 0; i < stream->props.count; i++) {
- pr_debug("%s: alloc URB=%d\n", __func__, i);
+ pr_debug("%s: alloc urb=%d\n", __func__, i);
stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
if (!stream->urb_list[i]) {
pr_debug("%s: failed\n", __func__);
for (i = 0; i < stream->props.count; i++) {
struct urb *urb;
int frame_offset = 0;
- pr_debug("%s: alloc URB=%d\n", __func__, i);
+ pr_debug("%s: alloc urb=%d\n", __func__, i);
stream->urb_list[i] = usb_alloc_urb(
stream->props.u.isoc.framesperurb, GFP_ATOMIC);
if (!stream->urb_list[i]) {
__func__, num * size);
for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
- pr_debug("%s: alloc buf=%d\n", __func__, 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) {
- pr_debug("%s: failed\n", __func__);
+ if (!stream->buf_list[stream->buf_num]) {
+ pr_debug("%s: alloc buf=%d failed\n", __func__,
+ stream->buf_num);
usb_free_stream_buffers(stream);
return -ENOMEM;
}
- pr_debug("%s: buf %d: %p (dma %llu)\n", __func__,
+ pr_debug("%s: alloc buf=%d %p (dma %llu)\n", __func__,
stream->buf_num,
stream->buf_list[stream->buf_num],
(long long)stream->dma_addr[stream->buf_num]);
{
int buf_size;
- if (props == NULL)
+ if (!props)
return 0;
/* check allocated buffers are large enough for the request */
return 0;
}
- pr_debug("%s: re-alloc URBs\n", __func__);
+ pr_debug("%s: re-alloc urbs\n", __func__);
usb_urb_free_urbs(stream);
memcpy(&stream->props, props, sizeof(*props));
{
int ret;
- if (stream == NULL || props == NULL)
+ if (!stream || !props)
return -EINVAL;
memcpy(&stream->props, props, sizeof(*props));
usb_clear_halt(stream->udev, usb_rcvbulkpipe(stream->udev,
stream->props.endpoint));
- if (stream->complete == NULL) {
+ if (!stream->complete) {
pr_err("%s: there is no data callback - this doesn't make " \
"sense\n", KBUILD_MODNAME);
return -EINVAL;
return usb_urb_alloc_isoc_urbs(stream);
default:
- pr_err("%s: unknown URB-type for data transfer\n",
+ pr_err("%s: unknown urb-type for data transfer\n",
KBUILD_MODNAME);
return -EINVAL;
}