Commit 7b6b283a authored by Gerd Knorr's avatar Gerd Knorr Committed by Linus Torvalds

[PATCH] v4l: gemtek radio update

This patch updates the gemtek and gemtek pci radio drivers.
parent 0f752d9d
...@@ -90,24 +90,6 @@ static const char rcsid[] = "$Id: radio-gemtek-pci.c,v 1.1 2001/07/23 08:08:16 t ...@@ -90,24 +90,6 @@ static const char rcsid[] = "$Id: radio-gemtek-pci.c,v 1.1 2001/07/23 08:08:16 t
static int nr_radio = -1; static int nr_radio = -1;
static int gemtek_pci_open( struct video_device *dev, int flags)
{
struct gemtek_pci_card *card = dev->priv;
/* Paranoid check */
if ( !card )
return -ENODEV;
return 0;
}
static void gemtek_pci_close( struct video_device *dev )
{
/*
* The module usage is managed by 'videodev'
*/
}
static inline u8 gemtek_pci_out( u16 value, u32 port ) static inline u8 gemtek_pci_out( u16 value, u32 port )
{ {
outw( value, port ); outw( value, port );
...@@ -195,80 +177,65 @@ static inline unsigned int gemtek_pci_getsignal( struct gemtek_pci_card *card ) ...@@ -195,80 +177,65 @@ static inline unsigned int gemtek_pci_getsignal( struct gemtek_pci_card *card )
return ( inb( card->iobase ) & 0x08 ) ? 0 : 1; return ( inb( card->iobase ) & 0x08 ) ? 0 : 1;
} }
static int gemtek_pci_ioctl( struct video_device *dev, unsigned int cmd, void *arg) static int gemtek_pci_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{ {
struct video_device *dev = video_devdata(file);
struct gemtek_pci_card *card = dev->priv; struct gemtek_pci_card *card = dev->priv;
switch ( cmd ) { switch ( cmd ) {
case VIDIOCGCAP: case VIDIOCGCAP:
{ {
struct video_capability c; struct video_capability *c = arg;
c.type = VID_TYPE_TUNER;
c.channels = 1;
c.audios = 1;
c.maxwidth = 0;
c.maxheight = 0;
c.minwidth = 0;
c.minheight = 0;
strcpy( c.name, "Gemtek PCI Radio" );
if ( copy_to_user( arg, &c, sizeof( c ) ) )
return -EFAULT;
memset(c,0,sizeof(*c));
c->type = VID_TYPE_TUNER;
c->channels = 1;
c->audios = 1;
strcpy( c->name, "Gemtek PCI Radio" );
return 0; return 0;
} }
case VIDIOCGTUNER: case VIDIOCGTUNER:
{ {
struct video_tuner t; struct video_tuner *t = arg;
if ( copy_from_user( &t, arg, sizeof( struct video_tuner ) ) ) if ( t->tuner )
return -EFAULT;
if ( t.tuner )
return -EINVAL; return -EINVAL;
t.rangelow = GEMTEK_PCI_RANGE_LOW; t->rangelow = GEMTEK_PCI_RANGE_LOW;
t.rangehigh = GEMTEK_PCI_RANGE_HIGH; t->rangehigh = GEMTEK_PCI_RANGE_HIGH;
t.flags = VIDEO_TUNER_LOW; t->flags = VIDEO_TUNER_LOW;
t.mode = VIDEO_MODE_AUTO; t->mode = VIDEO_MODE_AUTO;
t.signal = 0xFFFF * gemtek_pci_getsignal( card ); t->signal = 0xFFFF * gemtek_pci_getsignal( card );
strcpy( t.name, "FM" ); strcpy( t->name, "FM" );
if ( copy_to_user( arg, &t, sizeof( struct video_tuner ) ) )
return -EFAULT;
return 0; return 0;
} }
case VIDIOCSTUNER: case VIDIOCSTUNER:
{ {
struct video_tuner t; struct video_tuner *t = arg;
if ( t->tuner )
if ( copy_from_user( &t, arg, sizeof( struct video_tuner ) ) )
return -EFAULT;
if ( t.tuner )
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
case VIDIOCGFREQ: case VIDIOCGFREQ:
return put_user( card->current_frequency, (u32 *)arg ); {
unsigned long *freq = arg;
*freq = card->current_frequency;
return 0;
}
case VIDIOCSFREQ: case VIDIOCSFREQ:
{ {
u32 frequency; unsigned long *freq = arg;
if ( get_user( frequency, (u32 *)arg ) ) if ( (*freq < GEMTEK_PCI_RANGE_LOW) ||
return -EFAULT; (*freq > GEMTEK_PCI_RANGE_HIGH) )
if ( (frequency < GEMTEK_PCI_RANGE_LOW) || (frequency > GEMTEK_PCI_RANGE_HIGH) )
return -EINVAL; return -EINVAL;
gemtek_pci_setfrequency( card, frequency ); gemtek_pci_setfrequency( card, *freq );
card->current_frequency = frequency; card->current_frequency = *freq;
card->mute = FALSE; card->mute = FALSE;
return 0; return 0;
...@@ -276,36 +243,27 @@ static int gemtek_pci_ioctl( struct video_device *dev, unsigned int cmd, void *a ...@@ -276,36 +243,27 @@ static int gemtek_pci_ioctl( struct video_device *dev, unsigned int cmd, void *a
case VIDIOCGAUDIO: case VIDIOCGAUDIO:
{ {
struct video_audio a; struct video_audio *a = arg;
memset( &a, 0, sizeof( a ) );
a.flags |= VIDEO_AUDIO_MUTABLE;
a.volume = 1;
a.step = 65535;
strcpy( a.name, "Radio" );
if ( copy_to_user( arg, &a, sizeof( struct video_audio ) ) )
return -EFAULT;
memset( a, 0, sizeof( *a ) );
a->flags |= VIDEO_AUDIO_MUTABLE;
a->volume = 1;
a->step = 65535;
strcpy( a->name, "Radio" );
return 0; return 0;
} }
case VIDIOCSAUDIO: case VIDIOCSAUDIO:
{ {
struct video_audio a; struct video_audio *a = arg;
if ( copy_from_user( &a, arg, sizeof( struct video_audio ) ) )
return -EFAULT;
if ( a.audio ) if ( a->audio )
return -EINVAL; return -EINVAL;
if ( a.flags & VIDEO_AUDIO_MUTE ) if ( a->flags & VIDEO_AUDIO_MUTE )
gemtek_pci_mute( card ); gemtek_pci_mute( card );
else else
gemtek_pci_unmute( card ); gemtek_pci_unmute( card );
return 0; return 0;
} }
...@@ -333,19 +291,22 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id ); ...@@ -333,19 +291,22 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id );
static u8 mx = 1; static u8 mx = 1;
static char gemtek_pci_videodev_name[] = "Gemtek PCI Radio"; static struct file_operations gemtek_pci_fops = {
owner: THIS_MODULE,
open: video_exclusive_open,
release: video_exclusive_release,
ioctl: video_generic_ioctl,
llseek: no_llseek,
};
static inline void gemtek_pci_init_struct( struct video_device *dev ) static struct video_device vdev_template = {
{ owner: THIS_MODULE,
memset( dev, 0, sizeof( struct video_device ) ); name: "Gemtek PCI Radio",
dev->owner = THIS_MODULE; type: VID_TYPE_TUNER,
strcpy( dev->name , gemtek_pci_videodev_name ); hardware: VID_HARDWARE_GEMTEK,
dev->type = VID_TYPE_TUNER; fops: &gemtek_pci_fops,
dev->hardware = VID_HARDWARE_GEMTEK; kernel_ioctl: gemtek_pci_ioctl,
dev->open = gemtek_pci_open; };
dev->close = gemtek_pci_close;
dev->ioctl = gemtek_pci_ioctl;
}
static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci_device_id *pci_id ) static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci_device_id *pci_id )
{ {
...@@ -378,7 +339,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci ...@@ -378,7 +339,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
printk( KERN_ERR "gemtek_pci: out of memory\n" ); printk( KERN_ERR "gemtek_pci: out of memory\n" );
goto err_video; goto err_video;
} }
gemtek_pci_init_struct( devradio ); *devradio = vdev_template;
if ( video_register_device( devradio, VFL_TYPE_RADIO , nr_radio) == -1 ) { if ( video_register_device( devradio, VFL_TYPE_RADIO , nr_radio) == -1 ) {
kfree( devradio ); kfree( devradio );
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
static int io = CONFIG_RADIO_GEMTEK_PORT; static int io = CONFIG_RADIO_GEMTEK_PORT;
static int radio_nr = -1; static int radio_nr = -1;
static int users = 0;
static spinlock_t lock; static spinlock_t lock;
struct gemtek_device struct gemtek_device
...@@ -139,87 +138,77 @@ int gemtek_getsigstr(struct gemtek_device *dev) ...@@ -139,87 +138,77 @@ int gemtek_getsigstr(struct gemtek_device *dev)
return 1; /* signal present */ return 1; /* signal present */
} }
static int gemtek_ioctl(struct video_device *dev, unsigned int cmd, void *arg) static int gemtek_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{ {
struct video_device *dev = video_devdata(file);
struct gemtek_device *rt=dev->priv; struct gemtek_device *rt=dev->priv;
switch(cmd) switch(cmd)
{ {
case VIDIOCGCAP: case VIDIOCGCAP:
{ {
struct video_capability v; struct video_capability *v = arg;
v.type=VID_TYPE_TUNER; memset(v,0,sizeof(*v));
v.channels=1; v->type=VID_TYPE_TUNER;
v.audios=1; v->channels=1;
/* No we don't do pictures */ v->audios=1;
v.maxwidth=0; strcpy(v->name, "GemTek");
v.maxheight=0;
v.minwidth=0;
v.minheight=0;
strcpy(v.name, "GemTek");
if(copy_to_user(arg,&v,sizeof(v)))
return -EFAULT;
return 0; return 0;
} }
case VIDIOCGTUNER: case VIDIOCGTUNER:
{ {
struct video_tuner v; struct video_tuner *v = arg;
if(copy_from_user(&v, arg,sizeof(v))!=0) if(v->tuner) /* Only 1 tuner */
return -EFAULT;
if(v.tuner) /* Only 1 tuner */
return -EINVAL; return -EINVAL;
v.rangelow=87*16000; v->rangelow=87*16000;
v.rangehigh=108*16000; v->rangehigh=108*16000;
v.flags=VIDEO_TUNER_LOW; v->flags=VIDEO_TUNER_LOW;
v.mode=VIDEO_MODE_AUTO; v->mode=VIDEO_MODE_AUTO;
v.signal=0xFFFF*gemtek_getsigstr(rt); v->signal=0xFFFF*gemtek_getsigstr(rt);
strcpy(v.name, "FM"); strcpy(v->name, "FM");
if(copy_to_user(arg,&v, sizeof(v)))
return -EFAULT;
return 0; return 0;
} }
case VIDIOCSTUNER: case VIDIOCSTUNER:
{ {
struct video_tuner v; struct video_tuner *v = arg;
if(copy_from_user(&v, arg, sizeof(v))) if(v->tuner!=0)
return -EFAULT;
if(v.tuner!=0)
return -EINVAL; return -EINVAL;
/* Only 1 tuner so no setting needed ! */ /* Only 1 tuner so no setting needed ! */
return 0; return 0;
} }
case VIDIOCGFREQ: case VIDIOCGFREQ:
if(copy_to_user(arg, &rt->curfreq, sizeof(rt->curfreq))) {
return -EFAULT; unsigned long *freq = arg;
*freq = rt->curfreq;
return 0; return 0;
}
case VIDIOCSFREQ: case VIDIOCSFREQ:
if(copy_from_user(&rt->curfreq, arg,sizeof(rt->curfreq))) {
return -EFAULT; unsigned long *freq = arg;
rt->curfreq = *freq;
/* needs to be called twice in order for getsigstr to work */ /* needs to be called twice in order for getsigstr to work */
gemtek_setfreq(rt, rt->curfreq); gemtek_setfreq(rt, rt->curfreq);
gemtek_setfreq(rt, rt->curfreq); gemtek_setfreq(rt, rt->curfreq);
return 0; return 0;
}
case VIDIOCGAUDIO: case VIDIOCGAUDIO:
{ {
struct video_audio v; struct video_audio *v = 0;
memset(&v,0, sizeof(v)); memset(v,0, sizeof(*v));
v.flags|=VIDEO_AUDIO_MUTABLE; v->flags|=VIDEO_AUDIO_MUTABLE;
v.volume=1; v->volume=1;
v.step=65535; v->step=65535;
strcpy(v.name, "Radio"); strcpy(v->name, "Radio");
if(copy_to_user(arg,&v, sizeof(v)))
return -EFAULT;
return 0; return 0;
} }
case VIDIOCSAUDIO: case VIDIOCSAUDIO:
{ {
struct video_audio v; struct video_audio *v = arg;
if(copy_from_user(&v, arg, sizeof(v))) if(v->audio)
return -EFAULT;
if(v.audio)
return -EINVAL; return -EINVAL;
if(v.flags&VIDEO_AUDIO_MUTE) if(v->flags&VIDEO_AUDIO_MUTE)
gemtek_mute(rt); gemtek_mute(rt);
else else
gemtek_unmute(rt); gemtek_unmute(rt);
...@@ -231,30 +220,24 @@ static int gemtek_ioctl(struct video_device *dev, unsigned int cmd, void *arg) ...@@ -231,30 +220,24 @@ static int gemtek_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
} }
} }
static int gemtek_open(struct video_device *dev, int flags)
{
if(users)
return -EBUSY;
users++;
return 0;
}
static void gemtek_close(struct video_device *dev)
{
users--;
}
static struct gemtek_device gemtek_unit; static struct gemtek_device gemtek_unit;
static struct file_operations gemtek_fops = {
owner: THIS_MODULE,
open: video_exclusive_open,
release: video_exclusive_release,
ioctl: video_generic_ioctl,
llseek: no_llseek,
};
static struct video_device gemtek_radio= static struct video_device gemtek_radio=
{ {
owner: THIS_MODULE, owner: THIS_MODULE,
name: "GemTek radio", name: "GemTek radio",
type: VID_TYPE_TUNER, type: VID_TYPE_TUNER,
hardware: VID_HARDWARE_GEMTEK, hardware: VID_HARDWARE_GEMTEK,
open: gemtek_open, fops: &gemtek_fops,
close: gemtek_close, kernel_ioctl: gemtek_ioctl,
ioctl: gemtek_ioctl,
}; };
static int __init gemtek_init(void) static int __init gemtek_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment