diff options
author | Steven Toth <stoth@hauppauge.com> | 2008-04-18 21:39:11 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 14:09:43 -0300 |
commit | bc3c613cef903e73e7365986a1943b0124350018 (patch) | |
tree | 4414b3d5d059d0e0faacafc03724e7cbf38c9fa1 | |
parent | 9c26de555dd3c2cb9833b4d324150aa6b5547b91 (diff) |
V4L/DVB (7625): au0828: Cleanup
Signed-off-by: Steven Toth <stoth@hauppauge.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/au0828/au0828-cards.c | 13 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-core.c | 71 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-dvb.c | 53 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828-i2c.c | 45 | ||||
-rw-r--r-- | drivers/media/video/au0828/au0828.h | 9 |
5 files changed, 95 insertions, 96 deletions
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c index cbcc6f81f46..eafdc552a9f 100644 --- a/drivers/media/video/au0828/au0828-cards.c +++ b/drivers/media/video/au0828/au0828-cards.c @@ -22,12 +22,6 @@ #include "au0828.h" #include "au0828-cards.h" -#define _dbg(level, fmt, arg...)\ - do {\ - if (debug >= level) \ - printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\ - } while (0) - struct au0828_board au0828_boards[] = { [AU0828_BOARD_UNKNOWN] = { .name = "Unknown board", @@ -51,6 +45,8 @@ int au0828_tuner_callback(void *priv, int command, int arg) { struct au0828_dev *dev = priv; + dprintk(1, "%s()\n", __FUNCTION__); + switch(dev->board) { case AU0828_BOARD_HAUPPAUGE_HVR850: case AU0828_BOARD_HAUPPAUGE_HVR950Q: @@ -97,9 +93,10 @@ static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) void au0828_card_setup(struct au0828_dev *dev) { - static u8 eeprom[256]; + dprintk(1, "%s()\n", __FUNCTION__); + if (dev->i2c_rc == 0) { dev->i2c_client.addr = 0xa0 >> 1; tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom)); @@ -121,6 +118,8 @@ void au0828_card_setup(struct au0828_dev *dev) */ void au0828_gpio_setup(struct au0828_dev *dev) { + dprintk(1, "%s()\n", __FUNCTION__); + switch(dev->board) { case AU0828_BOARD_HAUPPAUGE_HVR850: case AU0828_BOARD_HAUPPAUGE_HVR950Q: diff --git a/drivers/media/video/au0828/au0828-core.c b/drivers/media/video/au0828/au0828-core.c index a3410fc8f5f..76801d135f2 100644 --- a/drivers/media/video/au0828/au0828-core.c +++ b/drivers/media/video/au0828/au0828-core.c @@ -26,25 +26,23 @@ #include "au0828.h" -static unsigned int debug; +/* + * 1 = General debug messages + * 2 = USB handling + * 4 = I2C related + * 8 = Bridge related + */ +unsigned int debug = 0; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "enable debug messages"); -#define _err(fmt, arg...)\ - do {\ - printk(KERN_ERR DRIVER_NAME "/0: " fmt, ## arg);\ - } while (0) - -#define _info(fmt, arg...)\ - do {\ - printk(KERN_INFO DRIVER_NAME "/0: " fmt, ## arg);\ - } while (0) +unsigned int usb_debug = 0; +module_param(usb_debug, int, 0644); +MODULE_PARM_DESC(usb_debug, "enable usb debug messages"); -#define _dbg(level, fmt, arg...)\ - do {\ - if (debug >= level) \ - printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\ - } while (0) +unsigned int bridge_debug = 0; +module_param(bridge_debug, int, 0644); +MODULE_PARM_DESC(bridge_debug, "enable bridge debug messages"); #define _AU0828_BULKPIPE 0x03 #define _BULKPIPESIZE 0xffff @@ -61,13 +59,13 @@ static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value, u32 au0828_readreg(struct au0828_dev *dev, u16 reg) { recv_control_msg(dev, CMD_REQUEST_IN, 0, reg, dev->ctrlmsg, 1); - _dbg(3,"%s(0x%x) = 0x%x\n", __FUNCTION__, reg, dev->ctrlmsg[0]); + dprintk(8, "%s(0x%x) = 0x%x\n", __FUNCTION__, reg, dev->ctrlmsg[0]); return dev->ctrlmsg[0]; } u32 au0828_writereg(struct au0828_dev *dev, u16 reg, u32 val) { - _dbg(3,"%s(0x%x, 0x%x)\n", __FUNCTION__, reg, val); + dprintk(8, "%s(0x%x, 0x%x)\n", __FUNCTION__, reg, val); return send_control_msg(dev, CMD_REQUEST_OUT, val, reg, dev->ctrlmsg, 0); } @@ -76,7 +74,7 @@ static void cmd_msg_dump(struct au0828_dev *dev) int i; for (i = 0;i < sizeof(dev->ctrlmsg); i+=16) - _dbg(1,"%s() %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x " + dprintk(2,"%s() %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x " "%02x %02x %02x %02x %02x %02x\n", __FUNCTION__, dev->ctrlmsg[i+0], dev->ctrlmsg[i+1], @@ -107,7 +105,7 @@ static int send_control_msg(struct au0828_dev *dev, u16 request, u32 value, status = min(status, 0); if (status < 0) { - _err("%s() Failed sending control message, error %d.\n", + printk(KERN_ERR "%s() Failed sending control message, error %d.\n", __FUNCTION__, status); } @@ -137,13 +135,12 @@ static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value, status = min(status, 0); if (status < 0) { - _err("%s() Failed receiving ctrl msg, error %d.\n", + printk(KERN_ERR "%s() Failed receiving control message, error %d.\n", __FUNCTION__, status); } else - if (debug > 4) - cmd_msg_dump(dev); + cmd_msg_dump(dev); } mutex_unlock(&dev->mutex); return status; @@ -152,7 +149,7 @@ static void au0828_usb_disconnect(struct usb_interface *interface) { struct au0828_dev *dev = usb_get_intfdata(interface); - _dbg(1,"%s()\n", __FUNCTION__); + dprintk(1,"%s()\n", __FUNCTION__); /* Digital TV */ au0828_dvb_unregister(dev); @@ -182,7 +179,7 @@ static int au0828_usb_probe (struct usb_interface *interface, if (ifnum != 0) return -ENODEV; - _dbg(1,"%s() vendor id 0x%x device id 0x%x ifnum:%d\n", + dprintk(1,"%s() vendor id 0x%x device id 0x%x ifnum:%d\n", __FUNCTION__, le16_to_cpu(usbdev->descriptor.idVendor), le16_to_cpu(usbdev->descriptor.idProduct), @@ -190,7 +187,7 @@ static int au0828_usb_probe (struct usb_interface *interface, dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) { - _err("Unable to allocate memory\n"); + printk(KERN_ERR "%s() Unable to allocate memory\n", __FUNCTION__); return -ENOMEM; } @@ -216,7 +213,7 @@ static int au0828_usb_probe (struct usb_interface *interface, /* Digital TV */ au0828_dvb_register(dev); - _info("Registered device AU0828 [%s]\n", + printk(KERN_INFO "Registered device AU0828 [%s]\n", au0828_boards[dev->board].name == NULL ? "Unset" : au0828_boards[dev->board].name); @@ -234,11 +231,29 @@ static int __init au0828_init(void) { int ret; - _info("au0828 driver loaded\n"); + if(debug) + printk(KERN_INFO "%s() Debugging is enabled\n", __FUNCTION__); + + if(usb_debug) { + printk(KERN_INFO "%s() USB Debugging is enabled\n", __FUNCTION__); + debug |= 2; + } + + if(i2c_debug) { + printk(KERN_INFO "%s() I2C Debugging is enabled\n", __FUNCTION__); + debug |= 4; + } + + if(bridge_debug) { + printk(KERN_INFO "%s() Bridge Debugging is enabled\n", __FUNCTION__); + debug |= 8; + } + + printk(KERN_INFO "au0828 driver loaded\n"); ret = usb_register(&au0828_usb_driver); if (ret) - _err("usb_register failed, error = %d\n", ret); + printk(KERN_ERR "usb_register failed, error = %d\n", ret); return ret; } diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c index ecc08a8e31c..453fb3efa3e 100644 --- a/drivers/media/video/au0828/au0828-dvb.c +++ b/drivers/media/video/au0828/au0828-dvb.c @@ -26,19 +26,11 @@ #include <media/v4l2-common.h> #include "au0828.h" - #include "au8522.h" #include "xc5000.h" DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); -unsigned int dvb_debug = 1; - -#define _dbg(level, fmt, arg...)\ - do { if (dvb_debug >= level)\ - printk(KERN_DEBUG "%s/0: " fmt, DRIVER_NAME, ## arg);\ - } while (0) - static struct au8522_config hauppauge_hvr950q_config = { .demod_address = 0x8e >> 1, .status_mode = AU8522_DEMODLOCKING, @@ -57,6 +49,8 @@ static void urb_completion(struct urb *purb) struct au0828_dev *dev = purb->context; int ptype = usb_pipetype(purb->pipe); + dprintk(2, "%s()\n", __FUNCTION__); + if (!dev) return; @@ -84,7 +78,7 @@ static int stop_urb_transfer(struct au0828_dev *dev) { int i; - printk(KERN_INFO "%s()\n", __FUNCTION__); + dprintk(2, "%s()\n", __FUNCTION__); /* FIXME: Do we need to free the transfer_buffers? */ for (i = 0; i < URB_COUNT; i++) { @@ -105,15 +99,11 @@ static int start_urb_transfer(struct au0828_dev *dev) { struct urb *purb; int i, ret = -ENOMEM; - unsigned int pipe = usb_rcvbulkpipe(dev->usbdev, _AU0828_BULKPIPE); - int pipesize = usb_maxpacket(dev->usbdev, pipe, usb_pipeout(pipe)); - int packets = _BULKPIPESIZE / pipesize; - int transfer_buflen = packets * pipesize; - printk(KERN_INFO "%s() transfer_buflen = %d\n", __FUNCTION__, transfer_buflen); + dprintk(2, "%s()\n", __FUNCTION__); if (dev->urb_streaming) { - printk("%s: iso xfer already running!\n", __FUNCTION__); + dprintk(2, "%s: iso xfer already running!\n", __FUNCTION__); return 0; } @@ -167,17 +157,15 @@ static int au0828_dvb_start_feed(struct dvb_demux_feed *feed) struct au0828_dvb *dvb = &dev->dvb; int ret = 0; - printk(KERN_INFO "%s() pid = 0x%x index = %d\n", __FUNCTION__, feed->pid, feed->index); + dprintk(1, "%s()\n", __FUNCTION__); if (!demux->dmx.frontend) return -EINVAL; - printk(KERN_INFO "%s() Preparing, feeding = %d\n", __FUNCTION__, dvb->feeding); if (dvb) { mutex_lock(&dvb->lock); if (dvb->feeding++ == 0) { - printk(KERN_INFO "%s() Starting Transport DMA\n", - __FUNCTION__); + /* Start transport */ au0828_write(dev, 0x608, 0x90); au0828_write(dev, 0x609, 0x72); au0828_write(dev, 0x60a, 0x71); @@ -197,13 +185,12 @@ static int au0828_dvb_stop_feed(struct dvb_demux_feed *feed) struct au0828_dvb *dvb = &dev->dvb; int ret = 0; - printk(KERN_INFO "%s() pid = 0x%x index = %d\n", __FUNCTION__, feed->pid, feed->index); + dprintk(1, "%s()\n", __FUNCTION__); if (dvb) { mutex_lock(&dvb->lock); if (--dvb->feeding == 0) { - printk(KERN_INFO "%s() Stopping Transport DMA\n", - __FUNCTION__); + /* Stop transport */ au0828_write(dev, 0x608, 0x00); au0828_write(dev, 0x609, 0x00); au0828_write(dev, 0x60a, 0x00); @@ -221,11 +208,13 @@ int dvb_register(struct au0828_dev *dev) struct au0828_dvb *dvb = &dev->dvb; int result; + dprintk(1, "%s()\n", __FUNCTION__); + /* register adapter */ result = dvb_register_adapter(&dvb->adapter, DRIVER_NAME, THIS_MODULE, &dev->usbdev->dev, adapter_nr); if (result < 0) { - printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", + printk(KERN_ERROR "%s: dvb_register_adapter failed (errno = %d)\n", DRIVER_NAME, result); goto fail_adapter; } @@ -234,7 +223,7 @@ int dvb_register(struct au0828_dev *dev) /* register frontend */ result = dvb_register_frontend(&dvb->adapter, dvb->frontend); if (result < 0) { - printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", + printk(KERN_ERR "%s: dvb_register_frontend failed (errno = %d)\n", DRIVER_NAME, result); goto fail_frontend; } @@ -250,7 +239,7 @@ int dvb_register(struct au0828_dev *dev) dvb->demux.stop_feed = au0828_dvb_stop_feed; result = dvb_dmx_init(&dvb->demux); if (result < 0) { - printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", + printk(KERN_ERR "%s: dvb_dmx_init failed (errno = %d)\n", DRIVER_NAME, result); goto fail_dmx; } @@ -260,7 +249,7 @@ int dvb_register(struct au0828_dev *dev) dvb->dmxdev.capabilities = 0; result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); if (result < 0) { - printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", + printk(KERN_ERR "%s: dvb_dmxdev_init failed (errno = %d)\n", DRIVER_NAME, result); goto fail_dmxdev; } @@ -268,7 +257,7 @@ int dvb_register(struct au0828_dev *dev) dvb->fe_hw.source = DMX_FRONTEND_0; result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); if (result < 0) { - printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", + printk(KERN_ERR "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", DRIVER_NAME, result); goto fail_fe_hw; } @@ -276,14 +265,14 @@ int dvb_register(struct au0828_dev *dev) dvb->fe_mem.source = DMX_MEMORY_FE; result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); if (result < 0) { - printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", + printk(KERN_ERR "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", DRIVER_NAME, result); goto fail_fe_mem; } result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); if (result < 0) { - printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", + printk(KERN_ERR "%s: connect_frontend failed (errno = %d)\n", DRIVER_NAME, result); goto fail_fe_conn; } @@ -313,6 +302,8 @@ void au0828_dvb_unregister(struct au0828_dev *dev) { struct au0828_dvb *dvb = &dev->dvb; + dprintk(1, "%s()\n", __FUNCTION__); + if(dvb->frontend == NULL) return; @@ -335,6 +326,8 @@ int au0828_dvb_register(struct au0828_dev *dev) struct au0828_dvb *dvb = &dev->dvb; int ret; + dprintk(1, "%s()\n", __FUNCTION__); + /* init frontend */ switch (dev->board) { case AU0828_BOARD_HAUPPAUGE_HVR850: @@ -355,7 +348,7 @@ int au0828_dvb_register(struct au0828_dev *dev) break; } if (NULL == dvb->frontend) { - printk("Frontend initialization failed\n"); + printk(KERN_ERR "%s() Frontend initialization failed\n", __FUNCTION__); return -1; } diff --git a/drivers/media/video/au0828/au0828-i2c.c b/drivers/media/video/au0828/au0828-i2c.c index 3e748248115..4545a9cbaa6 100644 --- a/drivers/media/video/au0828/au0828-i2c.c +++ b/drivers/media/video/au0828/au0828-i2c.c @@ -29,19 +29,14 @@ #include <media/v4l2-common.h> -static unsigned int i2c_debug; -module_param(i2c_debug, int, 0644); +unsigned int i2c_debug = 0; +module_param(i2c_debug, int, 0444); MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); -static unsigned int i2c_scan = 0; +unsigned int i2c_scan = 0; module_param(i2c_scan, int, 0444); MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); -#define dprintk(level, fmt, arg...)\ - do { if (i2c_debug >= level)\ - printk(KERN_DEBUG "%s/0: " fmt, DRIVER_NAME, ## arg);\ - } while (0) - #define I2C_WAIT_DELAY 512 #define I2C_WAIT_RETRY 64 @@ -146,7 +141,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, int i, strobe = 0; struct au0828_dev *dev = i2c_adap->algo_data; - dprintk(1, "%s()\n", __FUNCTION__); + dprintk(4, "%s()\n", __FUNCTION__); au0828_write(dev, REG_2FF, 0x01); au0828_write(dev, REG_202, 0x07); @@ -154,13 +149,11 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, /* Hardware needs 8 bit addresses */ au0828_write(dev, REG_203, msg->addr << 1); - if (i2c_debug) - dprintk(1, "SEND: %02x\n", msg->addr); + dprintk(4, "SEND: %02x\n", msg->addr); for (i=0; i < msg->len;) { - if (i2c_debug) - dprintk(1, " %02x\n", msg->buf[i]); + dprintk(4, " %02x\n", msg->buf[i]); au0828_write(dev, REG_205, msg->buf[i]); @@ -187,8 +180,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, if (!i2c_wait_done(i2c_adap)) return -EIO; - if (i2c_debug) - dprintk(1, "\n"); + dprintk(4, "\n"); return msg->len; } @@ -200,7 +192,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, struct au0828_dev *dev = i2c_adap->algo_data; int i; - dprintk(1, "%s()\n", __FUNCTION__); + dprintk(4, "%s()\n", __FUNCTION__); au0828_write(dev, REG_2FF, 0x01); au0828_write(dev, REG_202, 0x07); @@ -208,8 +200,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, /* Hardware needs 8 bit addresses */ au0828_write(dev, REG_203, msg->addr << 1); - if (i2c_debug) - dprintk(1, " RECV:\n"); + dprintk(4, " RECV:\n"); /* Deal with i2c_scan */ if (msg->len == 0) { @@ -233,14 +224,12 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, msg->buf[i-1] = au0828_read(dev, REG_209) & 0xff; - if (i2c_debug) - dprintk(1, " %02x\n", msg->buf[i-1]); + dprintk(4, " %02x\n", msg->buf[i-1]); } if (!i2c_wait_done(i2c_adap)) return -EIO; - if (i2c_debug) - dprintk(1, "\n"); + dprintk(4, "\n"); return msg->len; } @@ -250,10 +239,10 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, { int i, retval = 0; - dprintk(1, "%s(num = %d)\n", __FUNCTION__, num); + dprintk(4, "%s(num = %d)\n", __FUNCTION__, num); for (i = 0 ; i < num; i++) { - dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", + dprintk(4, "%s(num = %d) addr = 0x%02x len = 0x%x\n", __FUNCTION__, num, msgs[i].addr, msgs[i].len); if (msgs[i].flags & I2C_M_RD) { /* read */ @@ -384,6 +373,7 @@ int au0828_i2c_register(struct au0828_dev *dev) do_i2c_scan(DRIVER_NAME, &dev->i2c_client); } else printk("%s: i2c bus register FAILED\n", DRIVER_NAME); + return dev->i2c_rc; } @@ -393,10 +383,3 @@ int au0828_i2c_unregister(struct au0828_dev *dev) return 0; } -/* ----------------------------------------------------------------------- */ - -/* - * Local variables: - * c-basic-offset: 8 - * End: - */ diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h index 3dc09f8ffef..94426770a6d 100644 --- a/drivers/media/video/au0828/au0828.h +++ b/drivers/media/video/au0828/au0828.h @@ -96,6 +96,9 @@ struct au0828_buff { /* au0828-core.c */ extern u32 au0828_read(struct au0828_dev *dev, u16 reg); extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val); +extern unsigned int debug; +extern unsigned int usb_debug; +extern unsigned int bridge_debug; /* ----------------------------------------------------------- */ /* au0828-cards.c */ @@ -112,8 +115,14 @@ extern int au0828_i2c_register(struct au0828_dev *dev); extern int au0828_i2c_unregister(struct au0828_dev *dev); extern void au0828_call_i2c_clients(struct au0828_dev *dev, unsigned int cmd, void *arg); +extern unsigned int i2c_debug; /* ----------------------------------------------------------- */ /* au0828-dvb.c */ extern int au0828_dvb_register(struct au0828_dev *dev); extern void au0828_dvb_unregister(struct au0828_dev *dev); + +#define dprintk(level, fmt, arg...)\ + do { if (debug & level)\ + printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\ + } while (0) |