summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/dvb/cinergyT2/cinergyT2.c')
-rw-r--r--linux/drivers/media/dvb/cinergyT2/cinergyT2.c200
1 files changed, 62 insertions, 138 deletions
diff --git a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c b/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
index 3f65d61b4..3f8e4b59d 100644
--- a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -35,7 +35,6 @@
#include "dvb_demux.h"
#include "dvb_net.h"
-
#ifdef CONFIG_DVB_CINERGYT2_TUNING
#define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT)
#define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE)
@@ -52,9 +51,14 @@
#define QUERY_INTERVAL (333) /* milliseconds */
#endif
-
#define DRIVER_NAME "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"
+static int debug;
+module_param_named(debug, debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
+
+#define dprintk(level, args...) \
+ do { if ((debug & level)) { printk("%s: %s(): ",__stringify(KBUILD_MODNAME), __FUNCTION__); printk(args); } } while (0)
enum cinergyt2_ep1_cmd {
CINERGYT2_EP1_PID_TABLE_RESET = 0x01,
@@ -68,7 +72,6 @@ enum cinergyt2_ep1_cmd {
CINERGYT2_EP1_SLEEP_MODE = 0x09
};
-
struct dvbt_set_parameters_msg {
uint8_t cmd;
uint32_t freq;
@@ -77,7 +80,6 @@ struct dvbt_set_parameters_msg {
uint8_t flags;
} __attribute__((packed));
-
struct dvbt_get_status_msg {
uint32_t freq;
uint8_t bandwidth;
@@ -92,9 +94,7 @@ struct dvbt_get_status_msg {
uint8_t prev_lock_bits;
} __attribute__((packed));
-
-static
-struct dvb_frontend_info cinergyt2_fe_info = {
+static struct dvb_frontend_info cinergyt2_fe_info = {
.name = DRIVER_NAME,
.type = FE_OFDM,
.frequency_min = 174000000,
@@ -108,7 +108,6 @@ struct dvb_frontend_info cinergyt2_fe_info = {
FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER | FE_CAN_MUTE_TS
};
-
struct cinergyt2 {
struct dvb_demux demux;
struct usb_device *udev;
@@ -138,22 +137,18 @@ struct cinergyt2 {
#endif
};
-
enum {
CINERGYT2_RC_EVENT_TYPE_NONE = 0x00,
CINERGYT2_RC_EVENT_TYPE_NEC = 0x01,
CINERGYT2_RC_EVENT_TYPE_RC5 = 0x02
};
-
struct cinergyt2_rc_event {
char type;
uint32_t value;
} __attribute__((packed));
-
-static const
-uint32_t rc_keys [] = {
+static const uint32_t rc_keys [] = {
CINERGYT2_RC_EVENT_TYPE_NEC, 0xfe01eb04, KEY_POWER,
CINERGYT2_RC_EVENT_TYPE_NEC, 0xfd02eb04, KEY_1,
CINERGYT2_RC_EVENT_TYPE_NEC, 0xfc03eb04, KEY_2,
@@ -173,7 +168,7 @@ uint32_t rc_keys [] = {
CINERGYT2_RC_EVENT_TYPE_NEC, 0xeb14eb04, KEY_DOWN,
CINERGYT2_RC_EVENT_TYPE_NEC, 0xee11eb04, KEY_LEFT,
CINERGYT2_RC_EVENT_TYPE_NEC, 0xec13eb04, KEY_RIGHT,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xed12eb04, KEY_OK,
+ CINERGYT2_RC_EVENT_TYPE_NEC, 0xed12eb04, KEY_OK,
CINERGYT2_RC_EVENT_TYPE_NEC, 0xea15eb04, KEY_TEXT,
CINERGYT2_RC_EVENT_TYPE_NEC, 0xe916eb04, KEY_INFO,
CINERGYT2_RC_EVENT_TYPE_NEC, 0xe817eb04, KEY_RED,
@@ -193,9 +188,7 @@ uint32_t rc_keys [] = {
CINERGYT2_RC_EVENT_TYPE_NEC, 0xa35ceb04, KEY_NEXT
};
-
-static
-int cinergyt2_command (struct cinergyt2 *cinergyt2,
+static int cinergyt2_command (struct cinergyt2 *cinergyt2,
char *send_buf, int send_buf_len,
char *rec_buf, int rec_buf_len)
{
@@ -207,45 +200,36 @@ int cinergyt2_command (struct cinergyt2 *cinergyt2,
send_buf, send_buf_len, &actual_len, HZ);
if (ret)
- printk("%s: usb_bulk_msg (send) failed, err %i\n",
- __FUNCTION__, ret);
-
+ dprintk(1, "usb_bulk_msg (send) failed, err %i\n", ret);
+
if (!rec_buf)
rec_buf = &dummy;
-
+
ret = usb_bulk_msg(cinergyt2->udev, usb_rcvbulkpipe(cinergyt2->udev, 1),
rec_buf, rec_buf_len, &actual_len, HZ);
if (ret)
- printk("%s: usb_bulk_msg (read) failed, err %i\n",
- __FUNCTION__, ret);
+ dprintk(1, "usb_bulk_msg (read) failed, err %i\n", ret);
return ret ? ret : actual_len;
}
-
-static
-void cinergyt2_control_stream_transfer (struct cinergyt2 *cinergyt2, int enable)
+static void cinergyt2_control_stream_transfer (struct cinergyt2 *cinergyt2, int enable)
{
char buf [] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
}
-
-static
-void cinergyt2_sleep (struct cinergyt2 *cinergyt2, int sleep)
+static void cinergyt2_sleep (struct cinergyt2 *cinergyt2, int sleep)
{
char buf [] = { CINERGYT2_EP1_SLEEP_MODE, sleep ? 1 : 0 };
cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
cinergyt2->sleeping = sleep;
}
-
static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs);
-
-static
-int cinergyt2_submit_stream_urb (struct cinergyt2 *cinergyt2, struct urb *urb)
+static int cinergyt2_submit_stream_urb (struct cinergyt2 *cinergyt2, struct urb *urb)
{
int err;
@@ -258,15 +242,12 @@ int cinergyt2_submit_stream_urb (struct cinergyt2 *cinergyt2, struct urb *urb)
cinergyt2);
if ((err = usb_submit_urb(urb, GFP_ATOMIC)))
- printk("%s: urb submission failed (err = %i)!\n",
- __FUNCTION__, err);
+ dprintk(1, "urb submission failed (err = %i)!\n", err);
return err;
}
-
-static
-void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs)
+static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs)
{
struct cinergyt2 *cinergyt2 = urb->context;
@@ -278,9 +259,7 @@ void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs)
cinergyt2_submit_stream_urb(cinergyt2, urb);
}
-
-static
-void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
+static void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
{
int i;
@@ -292,29 +271,25 @@ void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
cinergyt2->streambuf, cinergyt2->streambuf_dmahandle);
}
-
-static
-int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
+static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
{
int i;
- cinergyt2->streambuf = pci_alloc_consistent(NULL,
+ cinergyt2->streambuf = pci_alloc_consistent(NULL,
STREAM_URB_COUNT*STREAM_BUF_SIZE,
&cinergyt2->streambuf_dmahandle);
if (!cinergyt2->streambuf) {
- printk("%s: failed to alloc consistent stream memory area, "
- "bailing out!\n", __FUNCTION__);
+ dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
return -ENOMEM;
}
memset(cinergyt2->streambuf, 0, STREAM_URB_COUNT*STREAM_BUF_SIZE);
for (i=0; i<STREAM_URB_COUNT; i++) {
- struct urb *urb;
+ struct urb *urb;
if (!(urb = usb_alloc_urb(0, GFP_ATOMIC))) {
- printk("%s: failed to alloc consistent stream urbs, "
- "bailing out!\n", __FUNCTION__);
+ dprintk(1, "failed to alloc consistent stream urbs, bailing out!\n");
cinergyt2_free_stream_urbs(cinergyt2);
return -ENOMEM;
}
@@ -328,9 +303,7 @@ int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
return 0;
}
-
-static
-void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
+static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
{
int i;
@@ -341,17 +314,14 @@ void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
usb_unlink_urb(cinergyt2->stream_urb[i]);
}
-
-static
-int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
+static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
{
int i, err;
for (i=0; i<STREAM_URB_COUNT; i++) {
if ((err = cinergyt2_submit_stream_urb(cinergyt2, cinergyt2->stream_urb[i]))) {
cinergyt2_stop_stream_xfer(cinergyt2);
- printk("%s: failed urb submission (%i: err = %i)!\n",
- __FUNCTION__, i, err);
+ dprintk(1, "failed urb submission (%i: err = %i)!\n", i, err);
return err;
}
}
@@ -360,9 +330,7 @@ int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
return 0;
}
-
-static
-int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
+static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
{
struct dvb_demux *demux = dvbdmxfeed->demux;
struct cinergyt2 *cinergyt2 = demux->priv;
@@ -378,16 +346,14 @@ int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
return 0;
}
-
-static
-int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
+static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
{
struct dvb_demux *demux = dvbdmxfeed->demux;
- struct cinergyt2 *cinergyt2 = demux->priv;
+ struct cinergyt2 *cinergyt2 = demux->priv;
if (down_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
-
+
if (--cinergyt2->streaming == 0)
cinergyt2_stop_stream_xfer(cinergyt2);
@@ -395,7 +361,6 @@ int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
return 0;
}
-
/**
* convert linux-dvb frontend parameter set into TPS.
* See ETSI ETS-300744, section 4.6.2, table 9 for details.
@@ -405,8 +370,7 @@ int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
*
* We replace errornous fields by default TPS fields (the ones with value 0).
*/
-static
-uint16_t compute_tps (struct dvb_frontend_parameters *p)
+static uint16_t compute_tps (struct dvb_frontend_parameters *p)
{
struct dvb_ofdm_parameters *op = &p->u.ofdm;
uint16_t tps = 0;
@@ -503,9 +467,7 @@ uint16_t compute_tps (struct dvb_frontend_parameters *p)
return tps;
}
-
-static
-int cinergyt2_open (struct inode *inode, struct file *file)
+static int cinergyt2_open (struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
struct cinergyt2 *cinergyt2 = dvbdev->priv;
@@ -526,9 +488,7 @@ int cinergyt2_open (struct inode *inode, struct file *file)
return 0;
}
-
-static
-int cinergyt2_release (struct inode *inode, struct file *file)
+static int cinergyt2_release (struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
struct cinergyt2 *cinergyt2 = dvbdev->priv;
@@ -547,9 +507,7 @@ int cinergyt2_release (struct inode *inode, struct file *file)
return dvb_generic_release(inode, file);
}
-
-static
-unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct *wait)
+static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct *wait)
{
struct dvb_device *dvbdev = file->private_data;
struct cinergyt2 *cinergyt2 = dvbdev->priv;
@@ -557,10 +515,7 @@ unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct *wait)
return (POLLIN | POLLRDNORM | POLLPRI);
}
-
-
-static
-int cinergyt2_ioctl (struct inode *inode, struct file *file,
+static int cinergyt2_ioctl (struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -631,7 +586,7 @@ int cinergyt2_ioctl (struct inode *inode, struct file *file,
case FE_GET_FRONTEND:
/**
* trivial to implement (see struct dvbt_get_status_msg).
- * equivalent to FE_READ ioctls, but needs
+ * equivalent to FE_READ ioctls, but needs
* TPS -> linux-dvb parameter set conversion. Feel free
* to implement this and send us a patch if you need this
* functionality.
@@ -645,9 +600,7 @@ int cinergyt2_ioctl (struct inode *inode, struct file *file,
return -EINVAL;
}
-
-static
-int cinergyt2_mmap(struct file *file, struct vm_area_struct *vma)
+static int cinergyt2_mmap(struct file *file, struct vm_area_struct *vma)
{
struct dvb_device *dvbdev = file->private_data;
struct cinergyt2 *cinergyt2 = dvbdev->priv;
@@ -667,7 +620,7 @@ int cinergyt2_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_flags |= (VM_IO | VM_DONTCOPY);
vma->vm_file = file;
-
+
ret = remap_page_range(vma, vma->vm_start,
virt_to_phys(cinergyt2->streambuf),
vma->vm_end - vma->vm_start,
@@ -677,9 +630,7 @@ bailout:
return ret;
}
-
-static
-struct file_operations cinergyt2_fops = {
+static struct file_operations cinergyt2_fops = {
.owner = THIS_MODULE,
.ioctl = cinergyt2_ioctl,
.poll = cinergyt2_poll,
@@ -688,19 +639,15 @@ struct file_operations cinergyt2_fops = {
.mmap = cinergyt2_mmap
};
-
-static
-struct dvb_device cinergyt2_fe_template = {
+static struct dvb_device cinergyt2_fe_template = {
.users = ~0,
.writers = 1,
.readers = (~0)-1,
.fops = &cinergyt2_fops
};
-
#ifdef ENABLE_RC
-static
-void cinergyt2_query_rc (void *data)
+static void cinergyt2_query_rc (void *data)
{
struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data;
char buf [1] = { CINERGYT2_EP1_GET_RC_EVENTS };
@@ -710,7 +657,7 @@ void cinergyt2_query_rc (void *data)
if (down_interruptible(&cinergyt2->sem))
return;
- len = cinergyt2_command(cinergyt2, buf, sizeof(buf),
+ len = cinergyt2_command(cinergyt2, buf, sizeof(buf),
(char *) rc_events, sizeof(rc_events));
for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) {
@@ -722,7 +669,7 @@ void cinergyt2_query_rc (void *data)
/**
* keyrepeat bit. If we would handle this properly
* we would need to emit down events as long the
- * keyrepeat goes, a up event if no further
+ * keyrepeat goes, a up event if no further
* repeat bits occur. Would need a timer to implement
* and no other driver does this, so we simply
* emit the last key up/down sequence again.
@@ -753,9 +700,7 @@ void cinergyt2_query_rc (void *data)
}
#endif
-
-static
-void cinergyt2_query (void *data)
+static void cinergyt2_query (void *data)
{
struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data;
char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
@@ -783,16 +728,14 @@ void cinergyt2_query (void *data)
up(&cinergyt2->sem);
}
-
-static
-int cinergyt2_probe (struct usb_interface *intf,
+static int cinergyt2_probe (struct usb_interface *intf,
const struct usb_device_id *id)
{
struct cinergyt2 *cinergyt2;
int i, err;
if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) {
- printk ("%s: out of memory?!?\n", __FUNCTION__);
+ dprintk(1, "out of memory?!?\n");
return -ENOMEM;
}
@@ -804,10 +747,9 @@ int cinergyt2_probe (struct usb_interface *intf,
INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2);
cinergyt2->udev = interface_to_usbdev(intf);
-
+
if (cinergyt2_alloc_stream_urbs (cinergyt2) < 0) {
- printk("%s: dvb_dmx_init unable to allocate stream urbs\n",
- __FUNCTION__);
+ dprintk(1, "unable to allocate stream urbs\n");
kfree(cinergyt2);
return -ENOMEM;
}
@@ -824,8 +766,7 @@ int cinergyt2_probe (struct usb_interface *intf,
DMX_MEMORY_BASED_FILTERING;
if ((err = dvb_dmx_init(&cinergyt2->demux)) < 0) {
- printk("%s: dvb_dmx_init() failed (err = %d)\n",
- __FUNCTION__, err);
+ dprintk(1, "dvb_dmx_init() failed (err = %d)\n", err);
goto bailout;
}
@@ -834,20 +775,19 @@ int cinergyt2_probe (struct usb_interface *intf,
cinergyt2->dmxdev.capabilities = 0;
if ((err = dvb_dmxdev_init(&cinergyt2->dmxdev, cinergyt2->adapter)) < 0) {
- printk("%s: dvb_dmxdev_init() failed (err = %d)\n",
- __FUNCTION__, err);
+ dprintk(1, "dvb_dmxdev_init() failed (err = %d)\n", err);
goto bailout;
}
if (dvb_net_init(cinergyt2->adapter, &cinergyt2->dvbnet, &cinergyt2->demux.dmx))
- printk("%s: dvb_net_init failed!\n", __FUNCTION__);
+ dprintk(1, "dvb_net_init() failed!\n");
dvb_register_device(cinergyt2->adapter, &cinergyt2->fedev,
&cinergyt2_fe_template, cinergyt2,
DVB_DEVICE_FRONTEND);
#ifdef ENABLE_RC
- init_input_dev(&cinergyt2->rc_input_dev);
+ init_input_dev(&cinergyt2->rc_input_dev);
cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY);
cinergyt2->rc_input_dev.keycodesize = sizeof(unsigned char);
@@ -875,9 +815,7 @@ bailout:
return -ENOMEM;
}
-
-static
-void cinergyt2_disconnect (struct usb_interface *intf)
+static void cinergyt2_disconnect (struct usb_interface *intf)
{
struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
@@ -902,9 +840,7 @@ void cinergyt2_disconnect (struct usb_interface *intf)
kfree(cinergyt2);
}
-
-static
-int cinergyt2_suspend (struct usb_interface *intf, u32 state)
+static int cinergyt2_suspend (struct usb_interface *intf, u32 state)
{
struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
@@ -927,9 +863,7 @@ int cinergyt2_suspend (struct usb_interface *intf, u32 state)
return 0;
}
-
-static
-int cinergyt2_resume (struct usb_interface *intf)
+static int cinergyt2_resume (struct usb_interface *intf)
{
struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
struct dvbt_set_parameters_msg *param = &cinergyt2->param;
@@ -952,18 +886,14 @@ int cinergyt2_resume (struct usb_interface *intf)
return 0;
}
-
-static const
-struct usb_device_id cinergyt2_table [] __devinitdata = {
+static const struct usb_device_id cinergyt2_table [] __devinitdata = {
{ USB_DEVICE(0x0ccd, 0x0038) },
{ 0 }
};
-
MODULE_DEVICE_TABLE(usb, cinergyt2_table);
-static
-struct usb_driver cinergyt2_driver = {
+static struct usb_driver cinergyt2_driver = {
.owner = THIS_MODULE,
.name = "cinergyT2",
.probe = cinergyt2_probe,
@@ -973,27 +903,21 @@ struct usb_driver cinergyt2_driver = {
.id_table = cinergyt2_table
};
-
-static
-int __init cinergyt2_init (void)
+static int __init cinergyt2_init (void)
{
int err;
if ((err = usb_register(&cinergyt2_driver)) < 0)
- printk("%s: usb_register() failed! (err %i)\n",
- __FUNCTION__, err);
+ dprintk(1, "usb_register() failed! (err %i)\n", err);
return err;
}
-
-static
-void __exit cinergyt2_exit (void)
+static void __exit cinergyt2_exit (void)
{
usb_deregister(&cinergyt2_driver);
}
-
module_init (cinergyt2_init);
module_exit (cinergyt2_exit);