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

[PATCH] v4l: aztech radio update

Here comes the aztech radio driver update.
parent 70d72c8a
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
static int io = CONFIG_RADIO_AZTECH_PORT; static int io = CONFIG_RADIO_AZTECH_PORT;
static int radio_nr = -1; static int radio_nr = -1;
static int radio_wait_time = 1000; static int radio_wait_time = 1000;
static int users = 0;
static struct semaphore lock; static struct semaphore lock;
struct az_device struct az_device
...@@ -158,93 +157,82 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency) ...@@ -158,93 +157,82 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
return 0; return 0;
} }
static int az_ioctl(struct video_device *dev, unsigned int cmd, void *arg) static int az_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{ {
struct az_device *az=dev->priv; struct video_device *dev = video_devdata(file);
struct az_device *az = 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, "Aztech Radio");
v.maxheight=0;
v.minwidth=0;
v.minheight=0;
strcpy(v.name, "Aztech Radio");
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*az_getsigstr(az); v->signal=0xFFFF*az_getsigstr(az);
if(az_getstereo(az)) if(az_getstereo(az))
v.flags|=VIDEO_TUNER_STEREO_ON; v->flags|=VIDEO_TUNER_STEREO_ON;
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 ! */
return 0; return 0;
} }
case VIDIOCGFREQ: case VIDIOCGFREQ:
if(copy_to_user(arg, &az->curfreq, sizeof(az->curfreq))) {
return -EFAULT; unsigned long *freq = arg;
*freq = az->curfreq;
return 0; return 0;
}
case VIDIOCSFREQ: case VIDIOCSFREQ:
if(copy_from_user(&az->curfreq, arg,sizeof(az->curfreq))) {
return -EFAULT; unsigned long *freq = arg;
az->curfreq = *freq;
az_setfreq(az, az->curfreq); az_setfreq(az, az->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;
if(az->stereo) if(az->stereo)
v.mode=VIDEO_SOUND_STEREO; v->mode=VIDEO_SOUND_STEREO;
else else
v.mode=VIDEO_SOUND_MONO; v->mode=VIDEO_SOUND_MONO;
v.volume=az->curvol; v->volume=az->curvol;
v.step=16384; v->step=16384;
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;
az->curvol=v.volume; az->curvol=v->volume;
az->stereo=(v.mode&VIDEO_SOUND_STEREO)?1:0; az->stereo=(v->mode&VIDEO_SOUND_STEREO)?1:0;
if(v.flags&VIDEO_AUDIO_MUTE) if(v->flags&VIDEO_AUDIO_MUTE)
az_setvol(az,0); az_setvol(az,0);
else else
az_setvol(az,az->curvol); az_setvol(az,az->curvol);
...@@ -255,30 +243,24 @@ static int az_ioctl(struct video_device *dev, unsigned int cmd, void *arg) ...@@ -255,30 +243,24 @@ static int az_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
} }
} }
static int az_open(struct video_device *dev, int flags)
{
if(users)
return -EBUSY;
users++;
return 0;
}
static void az_close(struct video_device *dev)
{
users--;
}
static struct az_device aztech_unit; static struct az_device aztech_unit;
static struct file_operations aztech_fops = {
owner: THIS_MODULE,
open: video_exclusive_open,
release: video_exclusive_release,
ioctl: video_generic_ioctl,
llseek: no_llseek,
};
static struct video_device aztech_radio= static struct video_device aztech_radio=
{ {
owner: THIS_MODULE, owner: THIS_MODULE,
name: "Aztech radio", name: "Aztech radio",
type: VID_TYPE_TUNER, type: VID_TYPE_TUNER,
hardware: VID_HARDWARE_AZTECH, hardware: VID_HARDWARE_AZTECH,
open: az_open, fops: &aztech_fops,
close: az_close, kernel_ioctl: az_ioctl,
ioctl: az_ioctl,
}; };
static int __init aztech_init(void) static int __init aztech_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