提交 18b548ca 编写于 作者: J Jean Delvare 提交者: Mauro Carvalho Chehab

V4L/DVB (5884): zr36067: clean up debug function

Debugging cleanups to the zr36067 driver:

* Use module_param_named() to declare the debug parameter, so we can
  use a single global variable to handle the debug level. This makes
  the driver a bit smaller (by 648 bytes on x86_64), thanks to one
  less level of indirection on every use.

* Change the debug parameter sysfs permissions, so that the debug
  level can be adjusted at runtime, as is done in many other
  media/video drivers.

* The debug level is between 0 and 5, not 0 and 4.

* Move the zr_debug export and dprintk macro definition to a header
  file so that we don't have to define them in each source file.

* Simplify a duplicate test on zr_debug.

Note that zr_debug was subsequently renamed to debug_zr36067 to avoid
possible conflicts with other Zoran device drivers, on a suggestion
by Trent Piepho.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Signed-off-by: NTrent Piepho <xyzzy@speakeasy.org>
Acked-by: NRonald S. Bultje <rbultje@ronald.bitfreak.net>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 63116feb
...@@ -145,10 +145,9 @@ module_param(pass_through, int, 0); ...@@ -145,10 +145,9 @@ module_param(pass_through, int, 0);
MODULE_PARM_DESC(pass_through, MODULE_PARM_DESC(pass_through,
"Pass TV signal through to TV-out when idling"); "Pass TV signal through to TV-out when idling");
static int debug = 1; int zr36067_debug = 1;
int *zr_debug = &debug; module_param_named(debug, zr36067_debug, int, 0644);
module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (0-5)");
MODULE_PARM_DESC(debug, "Debug level (0-4)");
MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver"); MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
MODULE_AUTHOR("Serguei Miridonov"); MODULE_AUTHOR("Serguei Miridonov");
...@@ -161,12 +160,6 @@ static struct pci_device_id zr36067_pci_tbl[] = { ...@@ -161,12 +160,6 @@ static struct pci_device_id zr36067_pci_tbl[] = {
}; };
MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
#define dprintk(num, format, args...) \
do { \
if (*zr_debug >= num) \
printk(format, ##args); \
} while (0)
int zoran_num; /* number of Buzs in use */ int zoran_num; /* number of Buzs in use */
struct zoran zoran[BUZ_MAX]; struct zoran zoran[BUZ_MAX];
...@@ -1075,7 +1068,7 @@ test_interrupts (struct zoran *zr) ...@@ -1075,7 +1068,7 @@ test_interrupts (struct zoran *zr)
if (timeout) { if (timeout) {
dprintk(1, ": time spent: %d\n", 1 * HZ - timeout); dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
} }
if (*zr_debug > 1) if (zr36067_debug > 1)
print_interrupts(zr); print_interrupts(zr);
btwrite(icr, ZR36057_ICR); btwrite(icr, ZR36057_ICR);
} }
...@@ -1158,7 +1151,7 @@ zr36057_init (struct zoran *zr) ...@@ -1158,7 +1151,7 @@ zr36057_init (struct zoran *zr)
goto exit_unregister; goto exit_unregister;
zoran_init_hardware(zr); zoran_init_hardware(zr);
if (*zr_debug > 2) if (zr36067_debug > 2)
detect_guest_activity(zr); detect_guest_activity(zr);
test_interrupts(zr); test_interrupts(zr);
if (!pass_through) { if (!pass_through) {
...@@ -1620,7 +1613,7 @@ init_dc10_cards (void) ...@@ -1620,7 +1613,7 @@ init_dc10_cards (void)
} }
/* random nonsense */ /* random nonsense */
dprintk(5, KERN_DEBUG "Jotti is een held!\n"); dprintk(6, KERN_DEBUG "Jotti is een held!\n");
/* some mainboards might not do PCI-PCI data transfer well */ /* some mainboards might not do PCI-PCI data transfer well */
if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) { if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) {
......
...@@ -30,6 +30,14 @@ ...@@ -30,6 +30,14 @@
#ifndef __ZORAN_CARD_H__ #ifndef __ZORAN_CARD_H__
#define __ZORAN_CARD_H__ #define __ZORAN_CARD_H__
extern int zr36067_debug;
#define dprintk(num, format, args...) \
do { \
if (zr36067_debug >= num) \
printk(format, ##args); \
} while (0)
/* Anybody who uses more than four? */ /* Anybody who uses more than four? */
#define BUZ_MAX 4 #define BUZ_MAX 4
extern int zoran_num; extern int zoran_num;
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "videocodec.h" #include "videocodec.h"
#include "zoran.h" #include "zoran.h"
#include "zoran_device.h" #include "zoran_device.h"
#include "zoran_card.h"
#define IRQ_MASK ( ZR36057_ISR_GIRQ0 | \ #define IRQ_MASK ( ZR36057_ISR_GIRQ0 | \
ZR36057_ISR_GIRQ1 | \ ZR36057_ISR_GIRQ1 | \
...@@ -59,14 +60,6 @@ ...@@ -59,14 +60,6 @@
extern const struct zoran_format zoran_formats[]; extern const struct zoran_format zoran_formats[];
extern int *zr_debug;
#define dprintk(num, format, args...) \
do { \
if (*zr_debug >= num) \
printk(format, ##args); \
} while (0)
static int lml33dpath = 0; /* 1 will use digital path in capture static int lml33dpath = 0; /* 1 will use digital path in capture
* mode instead of analog. It can be * mode instead of analog. It can be
* used for picture adjustments using * used for picture adjustments using
...@@ -174,7 +167,7 @@ post_office_read (struct zoran *zr, ...@@ -174,7 +167,7 @@ post_office_read (struct zoran *zr,
static void static void
dump_guests (struct zoran *zr) dump_guests (struct zoran *zr)
{ {
if (*zr_debug > 2) { if (zr36067_debug > 2) {
int i, guest[8]; int i, guest[8];
for (i = 1; i < 8; i++) { // Don't read jpeg codec here for (i = 1; i < 8; i++) { // Don't read jpeg codec here
...@@ -1271,7 +1264,7 @@ error_handler (struct zoran *zr, ...@@ -1271,7 +1264,7 @@ error_handler (struct zoran *zr,
zr->num_errors++; zr->num_errors++;
/* Report error */ /* Report error */
if (*zr_debug > 1 && zr->num_errors <= 8) { if (zr36067_debug > 1 && zr->num_errors <= 8) {
long frame; long frame;
frame = frame =
zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME]; zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME];
...@@ -1531,7 +1524,7 @@ zoran_irq (int irq, ...@@ -1531,7 +1524,7 @@ zoran_irq (int irq,
if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
if (*zr_debug > 1 && if (zr36067_debug > 1 &&
(!zr->frame_num || zr->JPEG_error)) { (!zr->frame_num || zr->JPEG_error)) {
printk(KERN_INFO printk(KERN_INFO
"%s: first frame ready: state=0x%08x odd_even=%d field_per_buff=%d delay=%d\n", "%s: first frame ready: state=0x%08x odd_even=%d field_per_buff=%d delay=%d\n",
...@@ -1568,7 +1561,7 @@ zoran_irq (int irq, ...@@ -1568,7 +1561,7 @@ zoran_irq (int irq,
zr->JPEG_missed; zr->JPEG_missed;
} }
if (*zr_debug > 2 && zr->frame_num < 6) { if (zr36067_debug > 2 && zr->frame_num < 6) {
int i; int i;
printk("%s: seq=%ld stat_com:", printk("%s: seq=%ld stat_com:",
ZR_DEVNAME(zr), zr->jpg_seq_num); ZR_DEVNAME(zr), zr->jpg_seq_num);
......
...@@ -200,14 +200,6 @@ const struct zoran_format zoran_formats[] = { ...@@ -200,14 +200,6 @@ const struct zoran_format zoran_formats[] = {
// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined // RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined
extern int *zr_debug;
#define dprintk(num, format, args...) \
do { \
if (*zr_debug >= num) \
printk(format, ##args); \
} while (0)
extern int v4l_nbufs; extern int v4l_nbufs;
extern int v4l_bufsize; extern int v4l_bufsize;
extern int jpg_nbufs; extern int jpg_nbufs;
...@@ -1106,12 +1098,10 @@ jpg_sync (struct file *file, ...@@ -1106,12 +1098,10 @@ jpg_sync (struct file *file,
frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME]; frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME];
/* buffer should now be in BUZ_STATE_DONE */ /* buffer should now be in BUZ_STATE_DONE */
if (*zr_debug > 0) if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE)
if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE) dprintk(2,
dprintk(2, KERN_ERR "%s: jpg_sync() - internal state error\n",
KERN_ERR ZR_DEVNAME(zr));
"%s: jpg_sync() - internal state error\n",
ZR_DEVNAME(zr));
*bs = zr->jpg_buffers.buffer[frame].bs; *bs = zr->jpg_buffers.buffer[frame].bs;
bs->frame = frame; bs->frame = frame;
...@@ -1389,7 +1379,7 @@ zoran_close (struct inode *inode, ...@@ -1389,7 +1379,7 @@ zoran_close (struct inode *inode,
/* disable interrupts */ /* disable interrupts */
btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR); btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
if (*zr_debug > 1) if (zr36067_debug > 1)
print_interrupts(zr); print_interrupts(zr);
/* Overlay off */ /* Overlay off */
......
...@@ -48,14 +48,7 @@ ...@@ -48,14 +48,7 @@
#include "videocodec.h" #include "videocodec.h"
#include "zoran.h" #include "zoran.h"
#include "zoran_procfs.h" #include "zoran_procfs.h"
#include "zoran_card.h"
extern int *zr_debug;
#define dprintk(num, format, args...) \
do { \
if (*zr_debug >= num) \
printk(format, ##args); \
} while (0)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct procfs_params_zr36067 { struct procfs_params_zr36067 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册