aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-07-17 17:29:41 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:02:57 -0400
commit18b548ca580838a2cc5813a941e6dab28660bb22 (patch)
tree58b2a76ff9108c4e458543d1965e02457843757c /drivers/media/video
parent63116febb9233743279a05be510ab8524f5f6242 (diff)
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: Jean Delvare <khali@linux-fr.org> Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Acked-by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/zoran_card.c19
-rw-r--r--drivers/media/video/zoran_card.h8
-rw-r--r--drivers/media/video/zoran_device.c17
-rw-r--r--drivers/media/video/zoran_driver.c20
-rw-r--r--drivers/media/video/zoran_procfs.c9
5 files changed, 25 insertions, 48 deletions
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 73162a3a61dd..8e12ff80550d 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -145,10 +145,9 @@ module_param(pass_through, int, 0);
145MODULE_PARM_DESC(pass_through, 145MODULE_PARM_DESC(pass_through,
146 "Pass TV signal through to TV-out when idling"); 146 "Pass TV signal through to TV-out when idling");
147 147
148static int debug = 1; 148int zr36067_debug = 1;
149int *zr_debug = &debug; 149module_param_named(debug, zr36067_debug, int, 0644);
150module_param(debug, int, 0); 150MODULE_PARM_DESC(debug, "Debug level (0-5)");
151MODULE_PARM_DESC(debug, "Debug level (0-4)");
152 151
153MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver"); 152MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
154MODULE_AUTHOR("Serguei Miridonov"); 153MODULE_AUTHOR("Serguei Miridonov");
@@ -161,12 +160,6 @@ static struct pci_device_id zr36067_pci_tbl[] = {
161}; 160};
162MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); 161MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
163 162
164#define dprintk(num, format, args...) \
165 do { \
166 if (*zr_debug >= num) \
167 printk(format, ##args); \
168 } while (0)
169
170int zoran_num; /* number of Buzs in use */ 163int zoran_num; /* number of Buzs in use */
171struct zoran zoran[BUZ_MAX]; 164struct zoran zoran[BUZ_MAX];
172 165
@@ -1075,7 +1068,7 @@ test_interrupts (struct zoran *zr)
1075 if (timeout) { 1068 if (timeout) {
1076 dprintk(1, ": time spent: %d\n", 1 * HZ - timeout); 1069 dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
1077 } 1070 }
1078 if (*zr_debug > 1) 1071 if (zr36067_debug > 1)
1079 print_interrupts(zr); 1072 print_interrupts(zr);
1080 btwrite(icr, ZR36057_ICR); 1073 btwrite(icr, ZR36057_ICR);
1081} 1074}
@@ -1158,7 +1151,7 @@ zr36057_init (struct zoran *zr)
1158 goto exit_unregister; 1151 goto exit_unregister;
1159 1152
1160 zoran_init_hardware(zr); 1153 zoran_init_hardware(zr);
1161 if (*zr_debug > 2) 1154 if (zr36067_debug > 2)
1162 detect_guest_activity(zr); 1155 detect_guest_activity(zr);
1163 test_interrupts(zr); 1156 test_interrupts(zr);
1164 if (!pass_through) { 1157 if (!pass_through) {
@@ -1620,7 +1613,7 @@ init_dc10_cards (void)
1620 } 1613 }
1621 1614
1622 /* random nonsense */ 1615 /* random nonsense */
1623 dprintk(5, KERN_DEBUG "Jotti is een held!\n"); 1616 dprintk(6, KERN_DEBUG "Jotti is een held!\n");
1624 1617
1625 /* some mainboards might not do PCI-PCI data transfer well */ 1618 /* some mainboards might not do PCI-PCI data transfer well */
1626 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) { 1619 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) {
diff --git a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
index ad997c30bee5..8444ca0a5f3f 100644
--- a/drivers/media/video/zoran_card.h
+++ b/drivers/media/video/zoran_card.h
@@ -30,6 +30,14 @@
30#ifndef __ZORAN_CARD_H__ 30#ifndef __ZORAN_CARD_H__
31#define __ZORAN_CARD_H__ 31#define __ZORAN_CARD_H__
32 32
33extern int zr36067_debug;
34
35#define dprintk(num, format, args...) \
36 do { \
37 if (zr36067_debug >= num) \
38 printk(format, ##args); \
39 } while (0)
40
33/* Anybody who uses more than four? */ 41/* Anybody who uses more than four? */
34#define BUZ_MAX 4 42#define BUZ_MAX 4
35extern int zoran_num; 43extern int zoran_num;
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index ba2f4ed29483..dc1ec20fb266 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -52,6 +52,7 @@
52#include "videocodec.h" 52#include "videocodec.h"
53#include "zoran.h" 53#include "zoran.h"
54#include "zoran_device.h" 54#include "zoran_device.h"
55#include "zoran_card.h"
55 56
56#define IRQ_MASK ( ZR36057_ISR_GIRQ0 | \ 57#define IRQ_MASK ( ZR36057_ISR_GIRQ0 | \
57 ZR36057_ISR_GIRQ1 | \ 58 ZR36057_ISR_GIRQ1 | \
@@ -59,14 +60,6 @@
59 60
60extern const struct zoran_format zoran_formats[]; 61extern const struct zoran_format zoran_formats[];
61 62
62extern int *zr_debug;
63
64#define dprintk(num, format, args...) \
65 do { \
66 if (*zr_debug >= num) \
67 printk(format, ##args); \
68 } while (0)
69
70static int lml33dpath = 0; /* 1 will use digital path in capture 63static int lml33dpath = 0; /* 1 will use digital path in capture
71 * mode instead of analog. It can be 64 * mode instead of analog. It can be
72 * used for picture adjustments using 65 * used for picture adjustments using
@@ -174,7 +167,7 @@ post_office_read (struct zoran *zr,
174static void 167static void
175dump_guests (struct zoran *zr) 168dump_guests (struct zoran *zr)
176{ 169{
177 if (*zr_debug > 2) { 170 if (zr36067_debug > 2) {
178 int i, guest[8]; 171 int i, guest[8];
179 172
180 for (i = 1; i < 8; i++) { // Don't read jpeg codec here 173 for (i = 1; i < 8; i++) { // Don't read jpeg codec here
@@ -1271,7 +1264,7 @@ error_handler (struct zoran *zr,
1271 zr->num_errors++; 1264 zr->num_errors++;
1272 1265
1273 /* Report error */ 1266 /* Report error */
1274 if (*zr_debug > 1 && zr->num_errors <= 8) { 1267 if (zr36067_debug > 1 && zr->num_errors <= 8) {
1275 long frame; 1268 long frame;
1276 frame = 1269 frame =
1277 zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME]; 1270 zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME];
@@ -1531,7 +1524,7 @@ zoran_irq (int irq,
1531 1524
1532 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || 1525 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
1533 zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { 1526 zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
1534 if (*zr_debug > 1 && 1527 if (zr36067_debug > 1 &&
1535 (!zr->frame_num || zr->JPEG_error)) { 1528 (!zr->frame_num || zr->JPEG_error)) {
1536 printk(KERN_INFO 1529 printk(KERN_INFO
1537 "%s: first frame ready: state=0x%08x odd_even=%d field_per_buff=%d delay=%d\n", 1530 "%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 zr->JPEG_missed; 1561 zr->JPEG_missed;
1569 } 1562 }
1570 1563
1571 if (*zr_debug > 2 && zr->frame_num < 6) { 1564 if (zr36067_debug > 2 && zr->frame_num < 6) {
1572 int i; 1565 int i;
1573 printk("%s: seq=%ld stat_com:", 1566 printk("%s: seq=%ld stat_com:",
1574 ZR_DEVNAME(zr), zr->jpg_seq_num); 1567 ZR_DEVNAME(zr), zr->jpg_seq_num);
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 72a037b75d63..377bb2d11ffd 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -200,14 +200,6 @@ const struct zoran_format zoran_formats[] = {
200// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined 200// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined
201 201
202 202
203extern int *zr_debug;
204
205#define dprintk(num, format, args...) \
206 do { \
207 if (*zr_debug >= num) \
208 printk(format, ##args); \
209 } while (0)
210
211extern int v4l_nbufs; 203extern int v4l_nbufs;
212extern int v4l_bufsize; 204extern int v4l_bufsize;
213extern int jpg_nbufs; 205extern int jpg_nbufs;
@@ -1106,12 +1098,10 @@ jpg_sync (struct file *file,
1106 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME]; 1098 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME];
1107 1099
1108 /* buffer should now be in BUZ_STATE_DONE */ 1100 /* buffer should now be in BUZ_STATE_DONE */
1109 if (*zr_debug > 0) 1101 if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE)
1110 if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE) 1102 dprintk(2,
1111 dprintk(2, 1103 KERN_ERR "%s: jpg_sync() - internal state error\n",
1112 KERN_ERR 1104 ZR_DEVNAME(zr));
1113 "%s: jpg_sync() - internal state error\n",
1114 ZR_DEVNAME(zr));
1115 1105
1116 *bs = zr->jpg_buffers.buffer[frame].bs; 1106 *bs = zr->jpg_buffers.buffer[frame].bs;
1117 bs->frame = frame; 1107 bs->frame = frame;
@@ -1389,7 +1379,7 @@ zoran_close (struct inode *inode,
1389 /* disable interrupts */ 1379 /* disable interrupts */
1390 btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR); 1380 btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
1391 1381
1392 if (*zr_debug > 1) 1382 if (zr36067_debug > 1)
1393 print_interrupts(zr); 1383 print_interrupts(zr);
1394 1384
1395 /* Overlay off */ 1385 /* Overlay off */
diff --git a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
index 446ae8d5c3df..328ed6e7ac6a 100644
--- a/drivers/media/video/zoran_procfs.c
+++ b/drivers/media/video/zoran_procfs.c
@@ -48,14 +48,7 @@
48#include "videocodec.h" 48#include "videocodec.h"
49#include "zoran.h" 49#include "zoran.h"
50#include "zoran_procfs.h" 50#include "zoran_procfs.h"
51 51#include "zoran_card.h"
52extern int *zr_debug;
53
54#define dprintk(num, format, args...) \
55 do { \
56 if (*zr_debug >= num) \
57 printk(format, ##args); \
58 } while (0)
59 52
60#ifdef CONFIG_PROC_FS 53#ifdef CONFIG_PROC_FS
61struct procfs_params_zr36067 { 54struct procfs_params_zr36067 {