diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-01-26 08:23:44 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-01-26 08:23:44 -0200 |
commit | 0ef45ee3c01a3ceda41697593a278285008e2a5b (patch) | |
tree | e343455ebd42bc1f4fb76bca0b85c05beb08b6fc /linux/drivers/media/radio/radio-maxiradio.c | |
parent | a73c67dd5303662e84d02a4bfeaaf23f12daa0c0 (diff) | |
download | mediapointer-dvb-s2-0ef45ee3c01a3ceda41697593a278285008e2a5b.tar.gz mediapointer-dvb-s2-0ef45ee3c01a3ceda41697593a278285008e2a5b.tar.bz2 |
Add some debug info, depending on debug level
From: Mauro Carvalho Chehab <mchehab@infradead.org>
With debug>0, it will show mute/unmute and set frequency events
with debug>=4, it will show get frequency events
Also, some kernel CodingStyle fixes were done.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/radio/radio-maxiradio.c')
-rw-r--r-- | linux/drivers/media/radio/radio-maxiradio.c | 72 |
1 files changed, 56 insertions, 16 deletions
diff --git a/linux/drivers/media/radio/radio-maxiradio.c b/linux/drivers/media/radio/radio-maxiradio.c index bcb8b4d0e..b0efc8a35 100644 --- a/linux/drivers/media/radio/radio-maxiradio.c +++ b/linux/drivers/media/radio/radio-maxiradio.c @@ -49,10 +49,18 @@ #include <linux/videodev2.h> #include <media/v4l2-common.h> -#define DRIVER_VERSION "0.76" +#define DRIVER_VERSION "0.77" #include <linux/version.h> /* for KERNEL_VERSION MACRO */ -#define RADIO_VERSION KERNEL_VERSION(0,7,6) +#define RADIO_VERSION KERNEL_VERSION(0,7,7) + +static struct video_device maxiradio_radio; + +#define dprintk(num, fmt, arg...) \ + do { \ + if (maxiradio_radio.debug >= num) \ + printk(KERN_DEBUG "%s: " fmt, \ + maxiradio_radio.name, ## arg); } while (0) static struct v4l2_queryctrl radio_qctrl[] = { { @@ -87,8 +95,9 @@ module_param(radio_nr, int, 0); #define FREQ_IF 171200 /* 10.7*16000 */ #define FREQ_STEP 200 /* 12.5*16 */ -#define FREQ2BITS(x) ((( (unsigned int)(x)+FREQ_IF+(FREQ_STEP<<1))\ - /(FREQ_STEP<<2))<<2) /* (x==fmhz*16*1000) -> bits */ +/* (x==fmhz*16*1000) -> bits */ +#define FREQ2BITS(x) ((( (unsigned int)(x)+FREQ_IF+(FREQ_STEP<<1)) \ + /(FREQ_STEP<<2))<<2) #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) @@ -121,7 +130,7 @@ static struct radio_device static void outbit(unsigned long bit, __u16 io) { - if(bit != 0) + if (bit != 0) { outb( power|wren|data ,io); udelay(4); outb( power|wren|data|clk ,io); udelay(4); @@ -137,14 +146,20 @@ static void outbit(unsigned long bit, __u16 io) static void turn_power(__u16 io, int p) { - if(p != 0) outb(power, io); else outb(0,io); + if (p != 0) { + dprintk(1, "Radio powered on\n"); + outb(power, io); + } else { + dprintk(1, "Radio powered off\n"); + outb(0,io); + } } - -static void set_freq(__u16 io, __u32 data) +static void set_freq(__u16 io, __u32 freq) { unsigned long int si; int bl; + int data = FREQ2BITS(freq); /* TEA5757 shift register bits (see pdf) */ @@ -163,20 +178,31 @@ static void set_freq(__u16 io, __u32 data) outbit(0,io); // 16 search level si = 0x8000; - for(bl = 1; bl <= 16 ; bl++) { outbit(data & si,io); si >>=1; } + for (bl = 1; bl <= 16 ; bl++) { + outbit(data & si,io); + si >>=1; + } - outb(power,io); + dprintk(1, "Radio freq set to %d.%02d MHz\n", + freq / 16000, + freq % 16000 * 100 / 16000); + + turn_power(io, 1); } static int get_stereo(__u16 io) { - outb(power,io); udelay(4); + outb(power,io); + udelay(4); + return !(inb(io) & mo_st); } static int get_tune(__u16 io) { - outb(power+clk,io); udelay(4); + outb(power+clk,io); + udelay(4); + return !(inb(io) & mo_st); } @@ -242,6 +268,7 @@ static int vidioc_g_audio (struct file *file, void *priv, static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) { *i = 0; + return 0; } @@ -249,6 +276,7 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) { if (i != 0) return -EINVAL; + return 0; } @@ -268,11 +296,17 @@ static int vidioc_s_frequency (struct file *file, void *priv, struct video_device *dev = video_devdata(file); struct radio_device *card=dev->priv; - if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) + if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) { + dprintk(1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n", + f->frequency / 16000, + f->frequency % 16000 * 100 / 16000, + FREQ_LO / 16000, FREQ_HI / 16000); + return -EINVAL; + } card->freq = f->frequency; - set_freq(card->io, FREQ2BITS(card->freq)); + set_freq(card->io, card->freq); msleep(125); return 0; @@ -287,6 +321,10 @@ static int vidioc_g_frequency (struct file *file, void *priv, f->type = V4L2_TUNER_RADIO; f->frequency = card->freq; + dprintk(4, "radio freq is %d.%02d MHz", + f->frequency / 16000, + f->frequency % 16000 * 100 / 16000); + return 0; } @@ -301,6 +339,7 @@ static int vidioc_queryctrl (struct file *file, void *priv, return (0); } } + return -EINVAL; } @@ -315,6 +354,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv, ctrl->value=card->muted; return (0); } + return -EINVAL; } @@ -330,9 +370,10 @@ static int vidioc_s_ctrl (struct file *file, void *priv, if(card->muted) turn_power(card->io, 0); else - set_freq(card->io, FREQ2BITS(card->freq)); + set_freq(card->io, card->freq); return 0; } + return -EINVAL; } @@ -355,7 +396,6 @@ static struct video_device maxiradio_radio = .vidioc_queryctrl = vidioc_queryctrl, .vidioc_g_ctrl = vidioc_g_ctrl, .vidioc_s_ctrl = vidioc_s_ctrl, - }; static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |