Commit 52003ba3 authored by Gerd Knorr's avatar Gerd Knorr Committed by Linus Torvalds

[PATCH] v4l: cadet radio update

This is the cadet radio driver update.
parent 7b6b283a
...@@ -351,8 +351,8 @@ void cadet_handler(unsigned long data) ...@@ -351,8 +351,8 @@ void cadet_handler(unsigned long data)
static long cadet_read(struct video_device *v,char *buf,unsigned long count, static ssize_t cadet_read(struct file *file, char *data,
int nonblock) size_t count, loff_t *ppos)
{ {
int i=0; int i=0;
unsigned char readbuf[RDS_BUFFER]; unsigned char readbuf[RDS_BUFFER];
...@@ -369,7 +369,7 @@ static long cadet_read(struct video_device *v,char *buf,unsigned long count, ...@@ -369,7 +369,7 @@ static long cadet_read(struct video_device *v,char *buf,unsigned long count,
add_timer(&readtimer); add_timer(&readtimer);
} }
if(rdsin==rdsout) { if(rdsin==rdsout) {
if(nonblock) { if (file->f_flags & O_NONBLOCK) {
return -EWOULDBLOCK; return -EWOULDBLOCK;
} }
interruptible_sleep_on(&readq); interruptible_sleep_on(&readq);
...@@ -377,70 +377,60 @@ static long cadet_read(struct video_device *v,char *buf,unsigned long count, ...@@ -377,70 +377,60 @@ static long cadet_read(struct video_device *v,char *buf,unsigned long count,
while((i<count)&&(rdsin!=rdsout)) { while((i<count)&&(rdsin!=rdsout)) {
readbuf[i++]=rdsbuf[rdsout++]; readbuf[i++]=rdsbuf[rdsout++];
} }
if(copy_to_user(buf,readbuf,i)) { if (copy_to_user(data,readbuf,i))
return -EFAULT; return -EFAULT;
}
return i; return i;
} }
static int cadet_ioctl(struct video_device *dev, unsigned int cmd, void *arg) static int cadet_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{ {
unsigned freq;
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=2; v->type=VID_TYPE_TUNER;
v.audios=1; v->channels=2;
/* No we don't do pictures */ v->audios=1;
v.maxwidth=0; strcpy(v->name, "ADS Cadet");
v.maxheight=0;
v.minwidth=0;
v.minheight=0;
strcpy(v.name, "ADS Cadet");
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<0)||(v->tuner>1)) {
return -EFAULT;
}
if((v.tuner<0)||(v.tuner>1)) {
return -EINVAL; return -EINVAL;
} }
switch(v.tuner) { switch(v->tuner) {
case 0: case 0:
strcpy(v.name,"FM"); strcpy(v->name,"FM");
v.rangelow=1400; /* 87.5 MHz */ v->rangelow=1400; /* 87.5 MHz */
v.rangehigh=1728; /* 108.0 MHz */ v->rangehigh=1728; /* 108.0 MHz */
v.flags=0; v->flags=0;
v.mode=0; v->mode=0;
v.mode|=VIDEO_MODE_AUTO; v->mode|=VIDEO_MODE_AUTO;
v.signal=sigstrength; v->signal=sigstrength;
if(cadet_getstereo()==1) { if(cadet_getstereo()==1) {
v.flags|=VIDEO_TUNER_STEREO_ON; v->flags|=VIDEO_TUNER_STEREO_ON;
} }
v.flags|=cadet_getrds(); v->flags|=cadet_getrds();
if(copy_to_user(arg,&v, sizeof(v))) { if(copy_to_user(arg,&v, sizeof(v))) {
return -EFAULT; return -EFAULT;
} }
break; break;
case 1: case 1:
strcpy(v.name,"AM"); strcpy(v->name,"AM");
v.rangelow=8320; /* 520 kHz */ v->rangelow=8320; /* 520 kHz */
v.rangehigh=26400; /* 1650 kHz */ v->rangehigh=26400; /* 1650 kHz */
v.flags=0; v->flags=0;
v.flags|=VIDEO_TUNER_LOW; v->flags|=VIDEO_TUNER_LOW;
v.mode=0; v->mode=0;
v.mode|=VIDEO_MODE_AUTO; v->mode|=VIDEO_MODE_AUTO;
v.signal=sigstrength; v->signal=sigstrength;
if(copy_to_user(arg,&v, sizeof(v))) { if(copy_to_user(arg,&v, sizeof(v))) {
return -EFAULT; return -EFAULT;
} }
...@@ -450,59 +440,53 @@ static int cadet_ioctl(struct video_device *dev, unsigned int cmd, void *arg) ...@@ -450,59 +440,53 @@ static int cadet_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
} }
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)||(v->tuner>1)) {
return -EFAULT;
}
if((v.tuner<0)||(v.tuner>1)) {
return -EINVAL; return -EINVAL;
} }
curtuner=v.tuner; curtuner=v->tuner;
return 0; return 0;
} }
case VIDIOCGFREQ: case VIDIOCGFREQ:
freq=cadet_getfreq(); {
if(copy_to_user(arg, &freq, sizeof(freq))) unsigned long *freq = arg;
return -EFAULT; *freq = cadet_getfreq();
return 0; return 0;
}
case VIDIOCSFREQ: case VIDIOCSFREQ:
if(copy_from_user(&freq, arg,sizeof(freq))) {
return -EFAULT; unsigned long *freq = arg;
if((curtuner==0)&&((freq<1400)||(freq>1728))) { if((curtuner==0)&&((*freq<1400)||(*freq>1728))) {
return -EINVAL; return -EINVAL;
} }
if((curtuner==1)&&((freq<8320)||(freq>26400))) { if((curtuner==1)&&((*freq<8320)||(*freq>26400))) {
return -EINVAL; return -EINVAL;
} }
cadet_setfreq(freq); cadet_setfreq(*freq);
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(cadet_getstereo()==0) { if(cadet_getstereo()==0) {
v.mode=VIDEO_SOUND_MONO; v->mode=VIDEO_SOUND_MONO;
} } else {
else { v->mode=VIDEO_SOUND_STEREO;
v.mode=VIDEO_SOUND_STEREO;
} }
v.volume=cadet_getvol(); v->volume=cadet_getvol();
v.step=0xffff; v->step=0xffff;
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;
cadet_setvol(v.volume); cadet_setvol(v->volume);
if(v.flags&VIDEO_AUDIO_MUTE) if(v->flags&VIDEO_AUDIO_MUTE)
cadet_setvol(0); cadet_setvol(0);
else else
cadet_setvol(0xffff); cadet_setvol(0xffff);
...@@ -514,7 +498,7 @@ static int cadet_ioctl(struct video_device *dev, unsigned int cmd, void *arg) ...@@ -514,7 +498,7 @@ static int cadet_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
} }
static int cadet_open(struct video_device *dev, int flags) static int cadet_open(struct inode *inode, struct file *file)
{ {
if(users) if(users)
return -EBUSY; return -EBUSY;
...@@ -523,26 +507,34 @@ static int cadet_open(struct video_device *dev, int flags) ...@@ -523,26 +507,34 @@ static int cadet_open(struct video_device *dev, int flags)
return 0; return 0;
} }
static void cadet_close(struct video_device *dev) static int cadet_release(struct inode *inode, struct file *file)
{ {
if(rdsstat==1) { if(rdsstat==1) {
del_timer(&readtimer); del_timer(&readtimer);
rdsstat=0; rdsstat=0;
} }
users--; users--;
return 0;
} }
static struct file_operations cadet_fops = {
owner: THIS_MODULE,
open: cadet_open,
release: cadet_release,
read: cadet_read,
ioctl: video_generic_ioctl,
llseek: no_llseek,
};
static struct video_device cadet_radio= static struct video_device cadet_radio=
{ {
owner: THIS_MODULE, owner: THIS_MODULE,
name: "Cadet radio", name: "Cadet radio",
type: VID_TYPE_TUNER, type: VID_TYPE_TUNER,
hardware: VID_HARDWARE_CADET, hardware: VID_HARDWARE_CADET,
open: cadet_open, fops: &cadet_fops,
close: cadet_close, kernel_ioctl: cadet_ioctl,
read: cadet_read,
ioctl: cadet_ioctl,
}; };
static int isapnp_cadet_probe(void) static int isapnp_cadet_probe(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