aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-gemtek-pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-gemtek-pci.c')
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 8e499b8f64c..9f249e7e60c 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -1,6 +1,6 @@
1/* 1/*
2 *************************************************************************** 2 ***************************************************************************
3 * 3 *
4 * radio-gemtek-pci.c - Gemtek PCI Radio driver 4 * radio-gemtek-pci.c - Gemtek PCI Radio driver
5 * (C) 2001 Vladimir Shebordaev <vshebordaev@mail.ru> 5 * (C) 2001 Vladimir Shebordaev <vshebordaev@mail.ru>
6 * 6 *
@@ -31,7 +31,7 @@
31 * radio device driver. 31 * radio device driver.
32 * 32 *
33 * Please, let me know if this piece of code was useful :) 33 * Please, let me know if this piece of code was useful :)
34 * 34 *
35 * TODO: multiple device support and portability were not tested 35 * TODO: multiple device support and portability were not tested
36 * 36 *
37 *************************************************************************** 37 ***************************************************************************
@@ -44,6 +44,7 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/videodev.h> 46#include <linux/videodev.h>
47#include <media/v4l2-common.h>
47#include <linux/errno.h> 48#include <linux/errno.h>
48 49
49#include <asm/io.h> 50#include <asm/io.h>
@@ -69,18 +70,18 @@
69#define TRUE (1) 70#define TRUE (1)
70#endif 71#endif
71 72
72#ifndef FALSE 73#ifndef FALSE
73#define FALSE (0) 74#define FALSE (0)
74#endif 75#endif
75 76
76struct gemtek_pci_card { 77struct gemtek_pci_card {
77 struct video_device *videodev; 78 struct video_device *videodev;
78 79
79 u32 iobase; 80 u32 iobase;
80 u32 length; 81 u32 length;
81 u8 chiprev; 82 u8 chiprev;
82 u16 model; 83 u16 model;
83 84
84 u32 current_frequency; 85 u32 current_frequency;
85 u8 mute; 86 u8 mute;
86}; 87};
@@ -96,7 +97,7 @@ static inline u8 gemtek_pci_out( u16 value, u32 port )
96 return (u8)value; 97 return (u8)value;
97} 98}
98 99
99#define _b0( v ) *((u8 *)&v) 100#define _b0( v ) *((u8 *)&v)
100static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep ) 101static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep )
101{ 102{
102 register u8 byte = *last_byte; 103 register u8 byte = *last_byte;
@@ -104,7 +105,7 @@ static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep )
104 if ( !value ) { 105 if ( !value ) {
105 if ( !keep ) 106 if ( !keep )
106 value = (u16)port; 107 value = (u16)port;
107 byte &= 0xfd; 108 byte &= 0xfd;
108 } else 109 } else
109 byte |= 2; 110 byte |= 2;
110 111
@@ -116,7 +117,7 @@ static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep )
116 byte &= 0xfe; 117 byte &= 0xfe;
117 _b0( value ) = byte; 118 _b0( value ) = byte;
118 outw( value, port ); 119 outw( value, port );
119 120
120 *last_byte = byte; 121 *last_byte = byte;
121} 122}
122 123
@@ -193,13 +194,13 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
193 c->audios = 1; 194 c->audios = 1;
194 strcpy( c->name, "Gemtek PCI Radio" ); 195 strcpy( c->name, "Gemtek PCI Radio" );
195 return 0; 196 return 0;
196 } 197 }
197 198
198 case VIDIOCGTUNER: 199 case VIDIOCGTUNER:
199 { 200 {
200 struct video_tuner *t = arg; 201 struct video_tuner *t = arg;
201 202
202 if ( t->tuner ) 203 if ( t->tuner )
203 return -EINVAL; 204 return -EINVAL;
204 205
205 t->rangelow = GEMTEK_PCI_RANGE_LOW; 206 t->rangelow = GEMTEK_PCI_RANGE_LOW;
@@ -228,7 +229,7 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
228 case VIDIOCSFREQ: 229 case VIDIOCSFREQ:
229 { 230 {
230 unsigned long *freq = arg; 231 unsigned long *freq = arg;
231 232
232 if ( (*freq < GEMTEK_PCI_RANGE_LOW) || 233 if ( (*freq < GEMTEK_PCI_RANGE_LOW) ||
233 (*freq > GEMTEK_PCI_RANGE_HIGH) ) 234 (*freq > GEMTEK_PCI_RANGE_HIGH) )
234 return -EINVAL; 235 return -EINVAL;
@@ -239,9 +240,9 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
239 240
240 return 0; 241 return 0;
241 } 242 }
242 243
243 case VIDIOCGAUDIO: 244 case VIDIOCGAUDIO:
244 { 245 {
245 struct video_audio *a = arg; 246 struct video_audio *a = arg;
246 247
247 memset( a, 0, sizeof( *a ) ); 248 memset( a, 0, sizeof( *a ) );
@@ -249,17 +250,17 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
249 a->volume = 1; 250 a->volume = 1;
250 a->step = 65535; 251 a->step = 65535;
251 strcpy( a->name, "Radio" ); 252 strcpy( a->name, "Radio" );
252 return 0; 253 return 0;
253 } 254 }
254 255
255 case VIDIOCSAUDIO: 256 case VIDIOCSAUDIO:
256 { 257 {
257 struct video_audio *a = arg; 258 struct video_audio *a = arg;
258 259
259 if ( a->audio ) 260 if ( a->audio )
260 return -EINVAL; 261 return -EINVAL;
261 262
262 if ( a->flags & VIDEO_AUDIO_MUTE ) 263 if ( a->flags & VIDEO_AUDIO_MUTE )
263 gemtek_pci_mute( card ); 264 gemtek_pci_mute( card );
264 else 265 else
265 gemtek_pci_unmute( card ); 266 gemtek_pci_unmute( card );
@@ -323,9 +324,9 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
323 return -ENOMEM; 324 return -ENOMEM;
324 } 325 }
325 326
326 if ( pci_enable_device( pci_dev ) ) 327 if ( pci_enable_device( pci_dev ) )
327 goto err_pci; 328 goto err_pci;
328 329
329 card->iobase = pci_resource_start( pci_dev, 0 ); 330 card->iobase = pci_resource_start( pci_dev, 0 );
330 card->length = pci_resource_len( pci_dev, 0 ); 331 card->length = pci_resource_len( pci_dev, 0 );
331 332
@@ -338,7 +339,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
338 pci_read_config_word( pci_dev, PCI_SUBSYSTEM_ID, &card->model ); 339 pci_read_config_word( pci_dev, PCI_SUBSYSTEM_ID, &card->model );
339 340
340 pci_set_drvdata( pci_dev, card ); 341 pci_set_drvdata( pci_dev, card );
341 342
342 if ( (devradio = kmalloc( sizeof( struct video_device ), GFP_KERNEL )) == NULL ) { 343 if ( (devradio = kmalloc( sizeof( struct video_device ), GFP_KERNEL )) == NULL ) {
343 printk( KERN_ERR "gemtek_pci: out of memory\n" ); 344 printk( KERN_ERR "gemtek_pci: out of memory\n" );
344 goto err_video; 345 goto err_video;
@@ -354,7 +355,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
354 devradio->priv = card; 355 devradio->priv = card;
355 gemtek_pci_mute( card ); 356 gemtek_pci_mute( card );
356 357
357 printk( KERN_INFO "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n", 358 printk( KERN_INFO "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n",
358 card->chiprev, card->iobase, card->iobase + card->length - 1 ); 359 card->chiprev, card->iobase, card->iobase + card->length - 1 );
359 360
360 return 0; 361 return 0;
@@ -364,7 +365,7 @@ err_video:
364 365
365err_pci: 366err_pci:
366 kfree( card ); 367 kfree( card );
367 return -ENODEV; 368 return -ENODEV;
368} 369}
369 370
370static void __devexit gemtek_pci_remove( struct pci_dev *pci_dev ) 371static void __devexit gemtek_pci_remove( struct pci_dev *pci_dev )
@@ -375,12 +376,12 @@ static void __devexit gemtek_pci_remove( struct pci_dev *pci_dev )
375 kfree( card->videodev ); 376 kfree( card->videodev );
376 377
377 release_region( card->iobase, card->length ); 378 release_region( card->iobase, card->length );
378 379
379 if ( mx ) 380 if ( mx )
380 gemtek_pci_mute( card ); 381 gemtek_pci_mute( card );
381 382
382 kfree( card ); 383 kfree( card );
383 384
384 pci_set_drvdata( pci_dev, NULL ); 385 pci_set_drvdata( pci_dev, NULL );
385} 386}
386 387