Commit bc81efb0 authored by Gerd Knorr's avatar Gerd Knorr Committed by Linus Torvalds

[PATCH] v4l: terratec radio update

This is the update for the terratec radio driver.
parent 75595af1
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
static int io = CONFIG_RADIO_TERRATEC_PORT; static int io = CONFIG_RADIO_TERRATEC_PORT;
static int radio_nr = -1; static int radio_nr = -1;
static int users = 0;
static spinlock_t lock; static spinlock_t lock;
struct tt_device struct tt_device
...@@ -186,89 +185,77 @@ int tt_getsigstr(struct tt_device *dev) /* TODO */ ...@@ -186,89 +185,77 @@ int tt_getsigstr(struct tt_device *dev) /* TODO */
/* implement the video4linux api */ /* implement the video4linux api */
static int tt_ioctl(struct video_device *dev, unsigned int cmd, void *arg) static int tt_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{ {
struct video_device *dev = video_devdata(file);
struct tt_device *tt=dev->priv; struct tt_device *tt=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, "ActiveRadio");
v.maxheight=0;
v.minwidth=0;
v.minheight=0;
strcpy(v.name, "ActiveRadio");
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;
strcpy(v.name, "FM"); strcpy(v->name, "FM");
v.signal=0xFFFF*tt_getsigstr(tt); v->signal=0xFFFF*tt_getsigstr(tt);
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, &tt->curfreq, sizeof(tt->curfreq))) {
return -EFAULT; unsigned long *freq = arg;
*freq = tt->curfreq;
return 0; return 0;
}
case VIDIOCSFREQ: case VIDIOCSFREQ:
if(copy_from_user(&tt->curfreq, arg,sizeof(tt->curfreq))) {
return -EFAULT; unsigned long *freq = arg;
tt->curfreq = *freq;
tt_setfreq(tt, tt->curfreq); tt_setfreq(tt, tt->curfreq);
return 0; return 0;
}
case VIDIOCGAUDIO: case VIDIOCGAUDIO:
{ {
struct video_audio v; struct video_audio *v = arg;
memset(&v,0, sizeof(v)); memset(v,0, sizeof(*v));
v.flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME;
v.volume=tt->curvol * 6554; v->volume=tt->curvol * 6554;
v.step=6554; v->step=6554;
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)
tt_mute(tt); tt_mute(tt);
else else
tt_setvol(tt,v.volume/6554); tt_setvol(tt,v->volume/6554);
return 0; return 0;
} }
default: default:
...@@ -276,30 +263,24 @@ static int tt_ioctl(struct video_device *dev, unsigned int cmd, void *arg) ...@@ -276,30 +263,24 @@ static int tt_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
} }
} }
static int tt_open(struct video_device *dev, int flags)
{
if(users)
return -EBUSY;
users++;
return 0;
}
static void tt_close(struct video_device *dev)
{
users--;
}
static struct tt_device terratec_unit; static struct tt_device terratec_unit;
static struct file_operations terratec_fops = {
owner: THIS_MODULE,
open: video_exclusive_open,
release: video_exclusive_release,
ioctl: video_generic_ioctl,
llseek: no_llseek,
};
static struct video_device terratec_radio= static struct video_device terratec_radio=
{ {
owner: THIS_MODULE, owner: THIS_MODULE,
name: "TerraTec ActiveRadio", name: "TerraTec ActiveRadio",
type: VID_TYPE_TUNER, type: VID_TYPE_TUNER,
hardware: VID_HARDWARE_TERRATEC, hardware: VID_HARDWARE_TERRATEC,
open: tt_open, fops: &terratec_fops,
close: tt_close, kernel_ioctl: tt_ioctl,
ioctl: tt_ioctl,
}; };
static int __init terratec_init(void) static int __init terratec_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