diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-01-26 05:23:44 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:35:06 -0500 |
commit | f1557cebc8c5714fd463ffeb5f424dc56dd61bdf (patch) | |
tree | ffe1751b838b1d199319da2a3c6afc8a92caa8a0 /drivers/media/radio | |
parent | b61f8d695c02dbcd3391b3409eafcf182451f10f (diff) |
V4L/DVB (5154): Add some debug info, depending on debug level
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 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/radio-maxiradio.c | 72 |
1 files changed, 56 insertions, 16 deletions
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index 82a2f83fe2e2..e5bfbd15820c 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
@@ -45,10 +45,18 @@ | |||
45 | #include <linux/videodev2.h> | 45 | #include <linux/videodev2.h> |
46 | #include <media/v4l2-common.h> | 46 | #include <media/v4l2-common.h> |
47 | 47 | ||
48 | #define DRIVER_VERSION "0.76" | 48 | #define DRIVER_VERSION "0.77" |
49 | 49 | ||
50 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | 50 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ |
51 | #define RADIO_VERSION KERNEL_VERSION(0,7,6) | 51 | #define RADIO_VERSION KERNEL_VERSION(0,7,7) |
52 | |||
53 | static struct video_device maxiradio_radio; | ||
54 | |||
55 | #define dprintk(num, fmt, arg...) \ | ||
56 | do { \ | ||
57 | if (maxiradio_radio.debug >= num) \ | ||
58 | printk(KERN_DEBUG "%s: " fmt, \ | ||
59 | maxiradio_radio.name, ## arg); } while (0) | ||
52 | 60 | ||
53 | static struct v4l2_queryctrl radio_qctrl[] = { | 61 | static struct v4l2_queryctrl radio_qctrl[] = { |
54 | { | 62 | { |
@@ -83,8 +91,9 @@ module_param(radio_nr, int, 0); | |||
83 | #define FREQ_IF 171200 /* 10.7*16000 */ | 91 | #define FREQ_IF 171200 /* 10.7*16000 */ |
84 | #define FREQ_STEP 200 /* 12.5*16 */ | 92 | #define FREQ_STEP 200 /* 12.5*16 */ |
85 | 93 | ||
86 | #define FREQ2BITS(x) ((( (unsigned int)(x)+FREQ_IF+(FREQ_STEP<<1))\ | 94 | /* (x==fmhz*16*1000) -> bits */ |
87 | /(FREQ_STEP<<2))<<2) /* (x==fmhz*16*1000) -> bits */ | 95 | #define FREQ2BITS(x) ((( (unsigned int)(x)+FREQ_IF+(FREQ_STEP<<1)) \ |
96 | /(FREQ_STEP<<2))<<2) | ||
88 | 97 | ||
89 | #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) | 98 | #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) |
90 | 99 | ||
@@ -113,7 +122,7 @@ static struct radio_device | |||
113 | 122 | ||
114 | static void outbit(unsigned long bit, __u16 io) | 123 | static void outbit(unsigned long bit, __u16 io) |
115 | { | 124 | { |
116 | if(bit != 0) | 125 | if (bit != 0) |
117 | { | 126 | { |
118 | outb( power|wren|data ,io); udelay(4); | 127 | outb( power|wren|data ,io); udelay(4); |
119 | outb( power|wren|data|clk ,io); udelay(4); | 128 | outb( power|wren|data|clk ,io); udelay(4); |
@@ -129,14 +138,20 @@ static void outbit(unsigned long bit, __u16 io) | |||
129 | 138 | ||
130 | static void turn_power(__u16 io, int p) | 139 | static void turn_power(__u16 io, int p) |
131 | { | 140 | { |
132 | if(p != 0) outb(power, io); else outb(0,io); | 141 | if (p != 0) { |
142 | dprintk(1, "Radio powered on\n"); | ||
143 | outb(power, io); | ||
144 | } else { | ||
145 | dprintk(1, "Radio powered off\n"); | ||
146 | outb(0,io); | ||
147 | } | ||
133 | } | 148 | } |
134 | 149 | ||
135 | 150 | static void set_freq(__u16 io, __u32 freq) | |
136 | static void set_freq(__u16 io, __u32 data) | ||
137 | { | 151 | { |
138 | unsigned long int si; | 152 | unsigned long int si; |
139 | int bl; | 153 | int bl; |
154 | int data = FREQ2BITS(freq); | ||
140 | 155 | ||
141 | /* TEA5757 shift register bits (see pdf) */ | 156 | /* TEA5757 shift register bits (see pdf) */ |
142 | 157 | ||
@@ -155,20 +170,31 @@ static void set_freq(__u16 io, __u32 data) | |||
155 | outbit(0,io); // 16 search level | 170 | outbit(0,io); // 16 search level |
156 | 171 | ||
157 | si = 0x8000; | 172 | si = 0x8000; |
158 | for(bl = 1; bl <= 16 ; bl++) { outbit(data & si,io); si >>=1; } | 173 | for (bl = 1; bl <= 16 ; bl++) { |
174 | outbit(data & si,io); | ||
175 | si >>=1; | ||
176 | } | ||
159 | 177 | ||
160 | outb(power,io); | 178 | dprintk(1, "Radio freq set to %d.%02d MHz\n", |
179 | freq / 16000, | ||
180 | freq % 16000 * 100 / 16000); | ||
181 | |||
182 | turn_power(io, 1); | ||
161 | } | 183 | } |
162 | 184 | ||
163 | static int get_stereo(__u16 io) | 185 | static int get_stereo(__u16 io) |
164 | { | 186 | { |
165 | outb(power,io); udelay(4); | 187 | outb(power,io); |
188 | udelay(4); | ||
189 | |||
166 | return !(inb(io) & mo_st); | 190 | return !(inb(io) & mo_st); |
167 | } | 191 | } |
168 | 192 | ||
169 | static int get_tune(__u16 io) | 193 | static int get_tune(__u16 io) |
170 | { | 194 | { |
171 | outb(power+clk,io); udelay(4); | 195 | outb(power+clk,io); |
196 | udelay(4); | ||
197 | |||
172 | return !(inb(io) & mo_st); | 198 | return !(inb(io) & mo_st); |
173 | } | 199 | } |
174 | 200 | ||
@@ -234,6 +260,7 @@ static int vidioc_g_audio (struct file *file, void *priv, | |||
234 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) | 260 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) |
235 | { | 261 | { |
236 | *i = 0; | 262 | *i = 0; |
263 | |||
237 | return 0; | 264 | return 0; |
238 | } | 265 | } |
239 | 266 | ||
@@ -241,6 +268,7 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | |||
241 | { | 268 | { |
242 | if (i != 0) | 269 | if (i != 0) |
243 | return -EINVAL; | 270 | return -EINVAL; |
271 | |||
244 | return 0; | 272 | return 0; |
245 | } | 273 | } |
246 | 274 | ||
@@ -260,11 +288,17 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
260 | struct video_device *dev = video_devdata(file); | 288 | struct video_device *dev = video_devdata(file); |
261 | struct radio_device *card=dev->priv; | 289 | struct radio_device *card=dev->priv; |
262 | 290 | ||
263 | if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) | 291 | if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) { |
292 | dprintk(1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n", | ||
293 | f->frequency / 16000, | ||
294 | f->frequency % 16000 * 100 / 16000, | ||
295 | FREQ_LO / 16000, FREQ_HI / 16000); | ||
296 | |||
264 | return -EINVAL; | 297 | return -EINVAL; |
298 | } | ||
265 | 299 | ||
266 | card->freq = f->frequency; | 300 | card->freq = f->frequency; |
267 | set_freq(card->io, FREQ2BITS(card->freq)); | 301 | set_freq(card->io, card->freq); |
268 | msleep(125); | 302 | msleep(125); |
269 | 303 | ||
270 | return 0; | 304 | return 0; |
@@ -279,6 +313,10 @@ static int vidioc_g_frequency (struct file *file, void *priv, | |||
279 | f->type = V4L2_TUNER_RADIO; | 313 | f->type = V4L2_TUNER_RADIO; |
280 | f->frequency = card->freq; | 314 | f->frequency = card->freq; |
281 | 315 | ||
316 | dprintk(4, "radio freq is %d.%02d MHz", | ||
317 | f->frequency / 16000, | ||
318 | f->frequency % 16000 * 100 / 16000); | ||
319 | |||
282 | return 0; | 320 | return 0; |
283 | } | 321 | } |
284 | 322 | ||
@@ -293,6 +331,7 @@ static int vidioc_queryctrl (struct file *file, void *priv, | |||
293 | return (0); | 331 | return (0); |
294 | } | 332 | } |
295 | } | 333 | } |
334 | |||
296 | return -EINVAL; | 335 | return -EINVAL; |
297 | } | 336 | } |
298 | 337 | ||
@@ -307,6 +346,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv, | |||
307 | ctrl->value=card->muted; | 346 | ctrl->value=card->muted; |
308 | return (0); | 347 | return (0); |
309 | } | 348 | } |
349 | |||
310 | return -EINVAL; | 350 | return -EINVAL; |
311 | } | 351 | } |
312 | 352 | ||
@@ -322,9 +362,10 @@ static int vidioc_s_ctrl (struct file *file, void *priv, | |||
322 | if(card->muted) | 362 | if(card->muted) |
323 | turn_power(card->io, 0); | 363 | turn_power(card->io, 0); |
324 | else | 364 | else |
325 | set_freq(card->io, FREQ2BITS(card->freq)); | 365 | set_freq(card->io, card->freq); |
326 | return 0; | 366 | return 0; |
327 | } | 367 | } |
368 | |||
328 | return -EINVAL; | 369 | return -EINVAL; |
329 | } | 370 | } |
330 | 371 | ||
@@ -347,7 +388,6 @@ static struct video_device maxiradio_radio = | |||
347 | .vidioc_queryctrl = vidioc_queryctrl, | 388 | .vidioc_queryctrl = vidioc_queryctrl, |
348 | .vidioc_g_ctrl = vidioc_g_ctrl, | 389 | .vidioc_g_ctrl = vidioc_g_ctrl, |
349 | .vidioc_s_ctrl = vidioc_s_ctrl, | 390 | .vidioc_s_ctrl = vidioc_s_ctrl, |
350 | |||
351 | }; | 391 | }; |
352 | 392 | ||
353 | static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 393 | static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |