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.c168
1 files changed, 50 insertions, 118 deletions
diff --git a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c b/linux/drivers/media/dvb/cinergyT2/cinergyT2.c
index 067e7143a..4e235ad63 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)
@@ -48,9 +47,14 @@
#define ENABLE_RC (1)
#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,
@@ -64,9 +68,7 @@ enum cinergyt2_ep1_cmd {
CINERGYT2_EP1_SLEEP_MODE = 0x09
};
-
-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,
@@ -81,7 +83,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;
@@ -95,7 +96,7 @@ struct cinergyt2 {
void *streambuf;
dma_addr_t streambuf_dmahandle;
- struct urb *stream_urb [STREAM_URB_COUNT];
+ struct urb *stream_urb[STREAM_URB_COUNT];
#ifdef ENABLE_RC
struct input_dev rc_input_dev;
@@ -104,22 +105,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,
@@ -159,12 +156,9 @@ uint32_t rc_keys [] = {
CINERGYT2_RC_EVENT_TYPE_NEC, 0xa35ceb04, KEY_NEXT
};
-
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;
@@ -177,15 +171,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;
@@ -197,9 +188,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;
@@ -211,9 +200,7 @@ 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;
@@ -221,8 +208,7 @@ int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
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;
}
@@ -232,8 +218,7 @@ int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
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;
}
@@ -247,9 +232,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;
@@ -258,17 +241,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;
}
}
@@ -276,9 +256,7 @@ int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
return 0;
}
-
-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)
{
@@ -293,8 +271,7 @@ 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;
@@ -303,33 +280,26 @@ int cinergyt2_command (struct cinergyt2 *cinergyt2,
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);
up(&cinergyt2->sem);
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_control_sleep_mode (struct cinergyt2 *cinergyt2, int sleep)
+static void cinergyt2_control_sleep_mode (struct cinergyt2 *cinergyt2, int sleep)
{
char buf [] = { CINERGYT2_EP1_SLEEP_MODE, sleep ? 1 : 0 };
cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 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;
@@ -345,9 +315,7 @@ 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;
@@ -360,7 +328,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.
@@ -371,8 +338,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 *param)
+static uint16_t compute_tps (struct dvb_frontend_parameters *param)
{
uint16_t tps = 0;
struct dvb_ofdm_parameters *op = &param->u.ofdm;
@@ -469,7 +435,6 @@ uint16_t compute_tps (struct dvb_frontend_parameters *param)
return tps;
}
-
struct dvbt_set_parameters_msg {
uint8_t cmd;
uint32_t freq;
@@ -478,7 +443,6 @@ struct dvbt_set_parameters_msg {
uint8_t flags;
} __attribute__((packed));
-
struct dvbt_get_parameters_msg {
uint32_t freq;
uint8_t bandwidth;
@@ -493,27 +457,21 @@ struct dvbt_get_parameters_msg {
uint8_t prev_lock_bits;
} __attribute__((packed));
-
-static
-int cinergyt2_fe_open (struct inode *inode, struct file *file)
+static int cinergyt2_fe_open (struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
cinergyt2_control_sleep_mode((struct cinergyt2 *) dvbdev->priv, 0);
return dvb_generic_open(inode, file);
}
-
-static
-int cinergyt2_fe_release (struct inode *inode, struct file *file)
+static int cinergyt2_fe_release (struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
cinergyt2_control_sleep_mode((struct cinergyt2 *) dvbdev->priv, 1);
return dvb_generic_release (inode, file);
}
-
-static
-int cinergyt2_fe_ioctl (struct inode *inode, struct file *file,
+static int cinergyt2_fe_ioctl (struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -633,7 +591,6 @@ int cinergyt2_fe_ioctl (struct inode *inode, struct file *file,
return ret;
}
-
static
struct file_operations cinergyt2_fe_fops = {
.owner = THIS_MODULE,
@@ -647,9 +604,7 @@ struct file_operations cinergyt2_fe_fops = {
.release = cinergyt2_fe_release
};
-
-static
-struct dvb_device cinergyt2_fe_template = {
+static struct dvb_device cinergyt2_fe_template = {
.users = ~0,
.writers = 1,
.readers = (~0)-1,
@@ -657,11 +612,8 @@ struct dvb_device cinergyt2_fe_template = {
.kernel_ioctl = cinergyt2_fe_ioctl
};
-
-
#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 };
@@ -708,16 +660,13 @@ void cinergyt2_query_rc (void *data)
}
#endif
-
-static
-int cinergyt2_probe (struct usb_interface *intf,
- const struct usb_device_id *id)
+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;
}
@@ -729,8 +678,7 @@ int cinergyt2_probe (struct usb_interface *intf,
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;
}
@@ -747,7 +695,7 @@ int cinergyt2_probe (struct usb_interface *intf,
DMX_MEMORY_BASED_FILTERING;
if ((err = dvb_dmx_init(&cinergyt2->demux)) < 0) {
- printk("cinergyt2_probe: dvb_dmx_init() failed (err = %d)\n", err);
+ dprintk(1, "dvb_dmx_init() failed (err = %d)\n", err);
goto bailout;
}
@@ -756,12 +704,12 @@ int cinergyt2_probe (struct usb_interface *intf,
cinergyt2->dmxdev.capabilities = 0;
if ((err = dvb_dmxdev_init(&cinergyt2->dmxdev, cinergyt2->adapter)) < 0) {
- printk("cinergyt2_probe: dvb_dmxdev_init() failed (err = %d)\n", 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("cinergyt2_dvb: dvb_net_init failed!\n");
+ dprintk(1, "dvb_net_init() failed!\n");
dvb_register_device(cinergyt2->adapter, &cinergyt2->fedev,
&cinergyt2_fe_template, cinergyt2,
@@ -801,14 +749,10 @@ 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);
- printk("%s: \n", __FUNCTION__);
-
#ifdef ENABLE_RC
cancel_delayed_work(&cinergyt2->rc_query_work);
flush_scheduled_work();
@@ -827,53 +771,41 @@ void cinergyt2_disconnect (struct usb_interface *intf)
kfree(cinergyt2);
}
-
-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 = {
- .owner = THIS_MODULE,
- .name = "cinergyt2",
- .probe = cinergyt2_probe,
- .disconnect = cinergyt2_disconnect,
- .id_table = cinergyt2_table
+static struct usb_driver cinergyt2_driver = {
+ .owner = THIS_MODULE,
+ .name = "cinergyt2",
+ .probe = cinergyt2_probe,
+ .disconnect = cinergyt2_disconnect,
+ .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", __FILE__, err);
+ dprintk(1, "usb_register() failed! (err %i)\n", err);
return err;
}
return 0;
}
-
-static
-void __exit cinergyt2_exit (void)
+static void __exit cinergyt2_exit (void)
{
- printk ("%s: \n", __FUNCTION__);
usb_deregister(&cinergyt2_driver);
}
-
module_init (cinergyt2_init);
module_exit (cinergyt2_exit);
MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Holger Wächtler, Daniel Mack");
+MODULE_AUTHOR("Holger Waechtler, Daniel Mack");