[media] radio-cadet: upgrade to latest frameworks
- add control framework - use core locking - use V4L2_TUNER_CAP_LOW - remove volume support: there is no hardware volume control Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
50121317c2
commit
b54c97db7f
|
@ -41,6 +41,9 @@
|
||||||
#include <linux/io.h> /* outb, outb_p */
|
#include <linux/io.h> /* outb, outb_p */
|
||||||
#include <media/v4l2-device.h>
|
#include <media/v4l2-device.h>
|
||||||
#include <media/v4l2-ioctl.h>
|
#include <media/v4l2-ioctl.h>
|
||||||
|
#include <media/v4l2-ctrls.h>
|
||||||
|
#include <media/v4l2-fh.h>
|
||||||
|
#include <media/v4l2-event.h>
|
||||||
|
|
||||||
MODULE_AUTHOR("Fred Gleason, Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath");
|
MODULE_AUTHOR("Fred Gleason, Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath");
|
||||||
MODULE_DESCRIPTION("A driver for the ADS Cadet AM/FM/RDS radio card.");
|
MODULE_DESCRIPTION("A driver for the ADS Cadet AM/FM/RDS radio card.");
|
||||||
|
@ -61,8 +64,8 @@ module_param(radio_nr, int, 0);
|
||||||
struct cadet {
|
struct cadet {
|
||||||
struct v4l2_device v4l2_dev;
|
struct v4l2_device v4l2_dev;
|
||||||
struct video_device vdev;
|
struct video_device vdev;
|
||||||
|
struct v4l2_ctrl_handler ctrl_handler;
|
||||||
int io;
|
int io;
|
||||||
int users;
|
|
||||||
int curtuner;
|
int curtuner;
|
||||||
int tunestat;
|
int tunestat;
|
||||||
int sigstrength;
|
int sigstrength;
|
||||||
|
@ -94,11 +97,9 @@ static int cadet_getstereo(struct cadet *dev)
|
||||||
if (dev->curtuner != 0) /* Only FM has stereo capability! */
|
if (dev->curtuner != 0) /* Only FM has stereo capability! */
|
||||||
return V4L2_TUNER_SUB_MONO;
|
return V4L2_TUNER_SUB_MONO;
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
outb(7, dev->io); /* Select tuner control */
|
outb(7, dev->io); /* Select tuner control */
|
||||||
if ((inb(dev->io + 1) & 0x40) == 0)
|
if ((inb(dev->io + 1) & 0x40) == 0)
|
||||||
ret = V4L2_TUNER_SUB_STEREO;
|
ret = V4L2_TUNER_SUB_STEREO;
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +112,6 @@ static unsigned cadet_gettune(struct cadet *dev)
|
||||||
* Prepare for read
|
* Prepare for read
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
|
|
||||||
outb(7, dev->io); /* Select tuner control */
|
outb(7, dev->io); /* Select tuner control */
|
||||||
curvol = inb(dev->io + 1); /* Save current volume/mute setting */
|
curvol = inb(dev->io + 1); /* Save current volume/mute setting */
|
||||||
outb(0x00, dev->io + 1); /* Ensure WRITE-ENABLE is LOW */
|
outb(0x00, dev->io + 1); /* Ensure WRITE-ENABLE is LOW */
|
||||||
|
@ -134,8 +133,6 @@ static unsigned cadet_gettune(struct cadet *dev)
|
||||||
* Restore volume/mute setting
|
* Restore volume/mute setting
|
||||||
*/
|
*/
|
||||||
outb(curvol, dev->io + 1);
|
outb(curvol, dev->io + 1);
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
|
|
||||||
return fifo;
|
return fifo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +158,7 @@ static unsigned cadet_getfreq(struct cadet *dev)
|
||||||
fifo = fifo >> 1;
|
fifo = fifo >> 1;
|
||||||
}
|
}
|
||||||
freq -= 10700000; /* IF frequency is 10.7 MHz */
|
freq -= 10700000; /* IF frequency is 10.7 MHz */
|
||||||
freq = (freq * 16) / 1000000; /* Make it 1/16 MHz */
|
freq = (freq * 16) / 1000; /* Make it 1/16 kHz */
|
||||||
}
|
}
|
||||||
if (dev->curtuner == 1) /* AM */
|
if (dev->curtuner == 1) /* AM */
|
||||||
freq = ((fifo & 0x7fff) - 2010) * 16;
|
freq = ((fifo & 0x7fff) - 2010) * 16;
|
||||||
|
@ -174,8 +171,6 @@ static void cadet_settune(struct cadet *dev, unsigned fifo)
|
||||||
int i;
|
int i;
|
||||||
unsigned test;
|
unsigned test;
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
|
|
||||||
outb(7, dev->io); /* Select tuner control */
|
outb(7, dev->io); /* Select tuner control */
|
||||||
/*
|
/*
|
||||||
* Write the shift register
|
* Write the shift register
|
||||||
|
@ -194,7 +189,6 @@ static void cadet_settune(struct cadet *dev, unsigned fifo)
|
||||||
test = 0x1c | ((fifo >> 23) & 0x02);
|
test = 0x1c | ((fifo >> 23) & 0x02);
|
||||||
outb(test, dev->io + 1);
|
outb(test, dev->io + 1);
|
||||||
}
|
}
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cadet_setfreq(struct cadet *dev, unsigned freq)
|
static void cadet_setfreq(struct cadet *dev, unsigned freq)
|
||||||
|
@ -209,7 +203,7 @@ static void cadet_setfreq(struct cadet *dev, unsigned freq)
|
||||||
fifo = 0;
|
fifo = 0;
|
||||||
if (dev->curtuner == 0) { /* FM */
|
if (dev->curtuner == 0) { /* FM */
|
||||||
test = 102400;
|
test = 102400;
|
||||||
freq = (freq * 1000) / 16; /* Make it kHz */
|
freq = freq / 16; /* Make it kHz */
|
||||||
freq += 10700; /* IF is 10700 kHz */
|
freq += 10700; /* IF is 10700 kHz */
|
||||||
for (i = 0; i < 14; i++) {
|
for (i = 0; i < 14; i++) {
|
||||||
fifo = fifo << 1;
|
fifo = fifo << 1;
|
||||||
|
@ -229,10 +223,8 @@ static void cadet_setfreq(struct cadet *dev, unsigned freq)
|
||||||
* Save current volume/mute setting
|
* Save current volume/mute setting
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
outb(7, dev->io); /* Select tuner control */
|
outb(7, dev->io); /* Select tuner control */
|
||||||
curvol = inb(dev->io + 1);
|
curvol = inb(dev->io + 1);
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tune the card
|
* Tune the card
|
||||||
|
@ -240,10 +232,8 @@ static void cadet_setfreq(struct cadet *dev, unsigned freq)
|
||||||
for (j = 3; j > -1; j--) {
|
for (j = 3; j > -1; j--) {
|
||||||
cadet_settune(dev, fifo | (j << 16));
|
cadet_settune(dev, fifo | (j << 16));
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
outb(7, dev->io); /* Select tuner control */
|
outb(7, dev->io); /* Select tuner control */
|
||||||
outb(curvol, dev->io + 1);
|
outb(curvol, dev->io + 1);
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
|
|
||||||
msleep(100);
|
msleep(100);
|
||||||
|
|
||||||
|
@ -257,32 +247,6 @@ static void cadet_setfreq(struct cadet *dev, unsigned freq)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int cadet_getvol(struct cadet *dev)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
|
|
||||||
outb(7, dev->io); /* Select tuner control */
|
|
||||||
if ((inb(dev->io + 1) & 0x20) != 0)
|
|
||||||
ret = 0xffff;
|
|
||||||
|
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void cadet_setvol(struct cadet *dev, int vol)
|
|
||||||
{
|
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
outb(7, dev->io); /* Select tuner control */
|
|
||||||
if (vol > 0)
|
|
||||||
outb(0x20, dev->io + 1);
|
|
||||||
else
|
|
||||||
outb(0x00, dev->io + 1);
|
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cadet_handler(unsigned long data)
|
static void cadet_handler(unsigned long data)
|
||||||
{
|
{
|
||||||
struct cadet *dev = (void *)data;
|
struct cadet *dev = (void *)data;
|
||||||
|
@ -337,18 +301,19 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
|
||||||
add_timer(&dev->readtimer);
|
add_timer(&dev->readtimer);
|
||||||
}
|
}
|
||||||
if (dev->rdsin == dev->rdsout) {
|
if (dev->rdsin == dev->rdsout) {
|
||||||
mutex_unlock(&dev->lock);
|
if (file->f_flags & O_NONBLOCK) {
|
||||||
if (file->f_flags & O_NONBLOCK)
|
i = -EWOULDBLOCK;
|
||||||
return -EWOULDBLOCK;
|
goto unlock;
|
||||||
|
}
|
||||||
interruptible_sleep_on(&dev->read_queue);
|
interruptible_sleep_on(&dev->read_queue);
|
||||||
mutex_lock(&dev->lock);
|
|
||||||
}
|
}
|
||||||
while (i < count && dev->rdsin != dev->rdsout)
|
while (i < count && dev->rdsin != dev->rdsout)
|
||||||
readbuf[i++] = dev->rdsbuf[dev->rdsout++];
|
readbuf[i++] = dev->rdsbuf[dev->rdsout++];
|
||||||
mutex_unlock(&dev->lock);
|
|
||||||
|
|
||||||
if (copy_to_user(data, readbuf, i))
|
if (copy_to_user(data, readbuf, i))
|
||||||
return -EFAULT;
|
i = -EFAULT;
|
||||||
|
unlock:
|
||||||
|
mutex_unlock(&dev->lock);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,8 +324,9 @@ static int vidioc_querycap(struct file *file, void *priv,
|
||||||
strlcpy(v->driver, "ADS Cadet", sizeof(v->driver));
|
strlcpy(v->driver, "ADS Cadet", sizeof(v->driver));
|
||||||
strlcpy(v->card, "ADS Cadet", sizeof(v->card));
|
strlcpy(v->card, "ADS Cadet", sizeof(v->card));
|
||||||
strlcpy(v->bus_info, "ISA", sizeof(v->bus_info));
|
strlcpy(v->bus_info, "ISA", sizeof(v->bus_info));
|
||||||
v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO |
|
v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO |
|
||||||
V4L2_CAP_READWRITE | V4L2_CAP_RDS_CAPTURE;
|
V4L2_CAP_READWRITE | V4L2_CAP_RDS_CAPTURE;
|
||||||
|
v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,20 +340,11 @@ static int vidioc_g_tuner(struct file *file, void *priv,
|
||||||
case 0:
|
case 0:
|
||||||
strlcpy(v->name, "FM", sizeof(v->name));
|
strlcpy(v->name, "FM", sizeof(v->name));
|
||||||
v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS |
|
v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS |
|
||||||
V4L2_TUNER_CAP_RDS_BLOCK_IO;
|
V4L2_TUNER_CAP_RDS_BLOCK_IO | V4L2_TUNER_CAP_LOW;
|
||||||
v->rangelow = 1400; /* 87.5 MHz */
|
v->rangelow = 1400000; /* 87.5 MHz */
|
||||||
v->rangehigh = 1728; /* 108.0 MHz */
|
v->rangehigh = 1728000; /* 108.0 MHz */
|
||||||
v->rxsubchans = cadet_getstereo(dev);
|
v->rxsubchans = cadet_getstereo(dev);
|
||||||
switch (v->rxsubchans) {
|
v->audmode = V4L2_TUNER_MODE_STEREO;
|
||||||
case V4L2_TUNER_SUB_MONO:
|
|
||||||
v->audmode = V4L2_TUNER_MODE_MONO;
|
|
||||||
break;
|
|
||||||
case V4L2_TUNER_SUB_STEREO:
|
|
||||||
v->audmode = V4L2_TUNER_MODE_STEREO;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
v->rxsubchans |= V4L2_TUNER_SUB_RDS;
|
v->rxsubchans |= V4L2_TUNER_SUB_RDS;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -408,11 +365,8 @@ static int vidioc_g_tuner(struct file *file, void *priv,
|
||||||
static int vidioc_s_tuner(struct file *file, void *priv,
|
static int vidioc_s_tuner(struct file *file, void *priv,
|
||||||
struct v4l2_tuner *v)
|
struct v4l2_tuner *v)
|
||||||
{
|
{
|
||||||
struct cadet *dev = video_drvdata(file);
|
|
||||||
|
|
||||||
if (v->index != 0 && v->index != 1)
|
if (v->index != 0 && v->index != 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
dev->curtuner = v->index;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +375,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
|
||||||
{
|
{
|
||||||
struct cadet *dev = video_drvdata(file);
|
struct cadet *dev = video_drvdata(file);
|
||||||
|
|
||||||
f->tuner = dev->curtuner;
|
if (f->tuner > 1)
|
||||||
|
return -EINVAL;
|
||||||
f->type = V4L2_TUNER_RADIO;
|
f->type = V4L2_TUNER_RADIO;
|
||||||
f->frequency = cadet_getfreq(dev);
|
f->frequency = cadet_getfreq(dev);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -435,101 +390,52 @@ static int vidioc_s_frequency(struct file *file, void *priv,
|
||||||
|
|
||||||
if (f->type != V4L2_TUNER_RADIO)
|
if (f->type != V4L2_TUNER_RADIO)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (dev->curtuner == 0 && (f->frequency < 1400 || f->frequency > 1728))
|
if (f->tuner == 0) {
|
||||||
return -EINVAL;
|
if (f->frequency < 1400000)
|
||||||
if (dev->curtuner == 1 && (f->frequency < 8320 || f->frequency > 26400))
|
f->frequency = 1400000;
|
||||||
|
else if (f->frequency > 1728000)
|
||||||
|
f->frequency = 1728000;
|
||||||
|
} else if (f->tuner == 1) {
|
||||||
|
if (f->frequency < 8320)
|
||||||
|
f->frequency = 8320;
|
||||||
|
else if (f->frequency > 26400)
|
||||||
|
f->frequency = 26400;
|
||||||
|
} else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
cadet_setfreq(dev, f->frequency);
|
cadet_setfreq(dev, f->frequency);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vidioc_queryctrl(struct file *file, void *priv,
|
static int cadet_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
struct v4l2_queryctrl *qc)
|
|
||||||
{
|
{
|
||||||
switch (qc->id) {
|
struct cadet *dev = container_of(ctrl->handler, struct cadet, ctrl_handler);
|
||||||
case V4L2_CID_AUDIO_MUTE:
|
|
||||||
return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
|
|
||||||
case V4L2_CID_AUDIO_VOLUME:
|
|
||||||
return v4l2_ctrl_query_fill(qc, 0, 0xff, 1, 0xff);
|
|
||||||
}
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vidioc_g_ctrl(struct file *file, void *priv,
|
|
||||||
struct v4l2_control *ctrl)
|
|
||||||
{
|
|
||||||
struct cadet *dev = video_drvdata(file);
|
|
||||||
|
|
||||||
switch (ctrl->id) {
|
switch (ctrl->id) {
|
||||||
case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
|
case V4L2_CID_AUDIO_MUTE:
|
||||||
ctrl->value = (cadet_getvol(dev) == 0);
|
outb(7, dev->io); /* Select tuner control */
|
||||||
break;
|
if (ctrl->val)
|
||||||
case V4L2_CID_AUDIO_VOLUME:
|
outb(0x00, dev->io + 1);
|
||||||
ctrl->value = cadet_getvol(dev);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vidioc_s_ctrl(struct file *file, void *priv,
|
|
||||||
struct v4l2_control *ctrl)
|
|
||||||
{
|
|
||||||
struct cadet *dev = video_drvdata(file);
|
|
||||||
|
|
||||||
switch (ctrl->id){
|
|
||||||
case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
|
|
||||||
if (ctrl->value)
|
|
||||||
cadet_setvol(dev, 0);
|
|
||||||
else
|
else
|
||||||
cadet_setvol(dev, 0xffff);
|
outb(0x20, dev->io + 1);
|
||||||
break;
|
return 0;
|
||||||
case V4L2_CID_AUDIO_VOLUME:
|
|
||||||
cadet_setvol(dev, ctrl->value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return -EINVAL;
|
||||||
}
|
|
||||||
|
|
||||||
static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
|
|
||||||
{
|
|
||||||
*i = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
|
|
||||||
{
|
|
||||||
return i ? -EINVAL : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vidioc_g_audio(struct file *file, void *priv,
|
|
||||||
struct v4l2_audio *a)
|
|
||||||
{
|
|
||||||
a->index = 0;
|
|
||||||
strlcpy(a->name, "Radio", sizeof(a->name));
|
|
||||||
a->capability = V4L2_AUDCAP_STEREO;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vidioc_s_audio(struct file *file, void *priv,
|
|
||||||
struct v4l2_audio *a)
|
|
||||||
{
|
|
||||||
return a->index ? -EINVAL : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cadet_open(struct file *file)
|
static int cadet_open(struct file *file)
|
||||||
{
|
{
|
||||||
struct cadet *dev = video_drvdata(file);
|
struct cadet *dev = video_drvdata(file);
|
||||||
|
int err;
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
mutex_lock(&dev->lock);
|
||||||
dev->users++;
|
err = v4l2_fh_open(file);
|
||||||
if (1 == dev->users)
|
if (err)
|
||||||
|
goto fail;
|
||||||
|
if (v4l2_fh_is_singular_file(file))
|
||||||
init_waitqueue_head(&dev->read_queue);
|
init_waitqueue_head(&dev->read_queue);
|
||||||
|
fail:
|
||||||
mutex_unlock(&dev->lock);
|
mutex_unlock(&dev->lock);
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cadet_release(struct file *file)
|
static int cadet_release(struct file *file)
|
||||||
|
@ -537,11 +443,11 @@ static int cadet_release(struct file *file)
|
||||||
struct cadet *dev = video_drvdata(file);
|
struct cadet *dev = video_drvdata(file);
|
||||||
|
|
||||||
mutex_lock(&dev->lock);
|
mutex_lock(&dev->lock);
|
||||||
dev->users--;
|
if (v4l2_fh_is_singular_file(file) && dev->rdsstat) {
|
||||||
if (0 == dev->users) {
|
|
||||||
del_timer_sync(&dev->readtimer);
|
del_timer_sync(&dev->readtimer);
|
||||||
dev->rdsstat = 0;
|
dev->rdsstat = 0;
|
||||||
}
|
}
|
||||||
|
v4l2_fh_release(file);
|
||||||
mutex_unlock(&dev->lock);
|
mutex_unlock(&dev->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -549,11 +455,12 @@ static int cadet_release(struct file *file)
|
||||||
static unsigned int cadet_poll(struct file *file, struct poll_table_struct *wait)
|
static unsigned int cadet_poll(struct file *file, struct poll_table_struct *wait)
|
||||||
{
|
{
|
||||||
struct cadet *dev = video_drvdata(file);
|
struct cadet *dev = video_drvdata(file);
|
||||||
|
unsigned int res = v4l2_ctrl_poll(file, wait);
|
||||||
|
|
||||||
poll_wait(file, &dev->read_queue, wait);
|
poll_wait(file, &dev->read_queue, wait);
|
||||||
if (dev->rdsin != dev->rdsout)
|
if (dev->rdsin != dev->rdsout)
|
||||||
return POLLIN | POLLRDNORM;
|
res |= POLLIN | POLLRDNORM;
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -572,13 +479,13 @@ static const struct v4l2_ioctl_ops cadet_ioctl_ops = {
|
||||||
.vidioc_s_tuner = vidioc_s_tuner,
|
.vidioc_s_tuner = vidioc_s_tuner,
|
||||||
.vidioc_g_frequency = vidioc_g_frequency,
|
.vidioc_g_frequency = vidioc_g_frequency,
|
||||||
.vidioc_s_frequency = vidioc_s_frequency,
|
.vidioc_s_frequency = vidioc_s_frequency,
|
||||||
.vidioc_queryctrl = vidioc_queryctrl,
|
.vidioc_log_status = v4l2_ctrl_log_status,
|
||||||
.vidioc_g_ctrl = vidioc_g_ctrl,
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
||||||
.vidioc_s_ctrl = vidioc_s_ctrl,
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
||||||
.vidioc_g_audio = vidioc_g_audio,
|
};
|
||||||
.vidioc_s_audio = vidioc_s_audio,
|
|
||||||
.vidioc_g_input = vidioc_g_input,
|
static const struct v4l2_ctrl_ops cadet_ctrl_ops = {
|
||||||
.vidioc_s_input = vidioc_s_input,
|
.s_ctrl = cadet_s_ctrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PNP
|
#ifdef CONFIG_PNP
|
||||||
|
@ -648,7 +555,8 @@ static int __init cadet_init(void)
|
||||||
{
|
{
|
||||||
struct cadet *dev = &cadet_card;
|
struct cadet *dev = &cadet_card;
|
||||||
struct v4l2_device *v4l2_dev = &dev->v4l2_dev;
|
struct v4l2_device *v4l2_dev = &dev->v4l2_dev;
|
||||||
int res;
|
struct v4l2_ctrl_handler *hdl;
|
||||||
|
int res = -ENODEV;
|
||||||
|
|
||||||
strlcpy(v4l2_dev->name, "cadet", sizeof(v4l2_dev->name));
|
strlcpy(v4l2_dev->name, "cadet", sizeof(v4l2_dev->name));
|
||||||
mutex_init(&dev->lock);
|
mutex_init(&dev->lock);
|
||||||
|
@ -680,23 +588,37 @@ static int __init cadet_init(void)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hdl = &dev->ctrl_handler;
|
||||||
|
v4l2_ctrl_handler_init(hdl, 2);
|
||||||
|
v4l2_ctrl_new_std(hdl, &cadet_ctrl_ops,
|
||||||
|
V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
|
||||||
|
v4l2_dev->ctrl_handler = hdl;
|
||||||
|
if (hdl->error) {
|
||||||
|
res = hdl->error;
|
||||||
|
v4l2_err(v4l2_dev, "Could not register controls\n");
|
||||||
|
goto err_hdl;
|
||||||
|
}
|
||||||
|
|
||||||
strlcpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name));
|
strlcpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name));
|
||||||
dev->vdev.v4l2_dev = v4l2_dev;
|
dev->vdev.v4l2_dev = v4l2_dev;
|
||||||
dev->vdev.fops = &cadet_fops;
|
dev->vdev.fops = &cadet_fops;
|
||||||
dev->vdev.ioctl_ops = &cadet_ioctl_ops;
|
dev->vdev.ioctl_ops = &cadet_ioctl_ops;
|
||||||
dev->vdev.release = video_device_release_empty;
|
dev->vdev.release = video_device_release_empty;
|
||||||
|
dev->vdev.lock = &dev->lock;
|
||||||
|
set_bit(V4L2_FL_USE_FH_PRIO, &dev->vdev.flags);
|
||||||
video_set_drvdata(&dev->vdev, dev);
|
video_set_drvdata(&dev->vdev, dev);
|
||||||
|
|
||||||
if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
|
if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0)
|
||||||
v4l2_device_unregister(v4l2_dev);
|
goto err_hdl;
|
||||||
release_region(dev->io, 2);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
v4l2_info(v4l2_dev, "ADS Cadet Radio Card at 0x%x\n", dev->io);
|
v4l2_info(v4l2_dev, "ADS Cadet Radio Card at 0x%x\n", dev->io);
|
||||||
return 0;
|
return 0;
|
||||||
|
err_hdl:
|
||||||
|
v4l2_ctrl_handler_free(hdl);
|
||||||
|
v4l2_device_unregister(v4l2_dev);
|
||||||
|
release_region(dev->io, 2);
|
||||||
fail:
|
fail:
|
||||||
pnp_unregister_driver(&cadet_pnp_driver);
|
pnp_unregister_driver(&cadet_pnp_driver);
|
||||||
return -ENODEV;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit cadet_exit(void)
|
static void __exit cadet_exit(void)
|
||||||
|
@ -704,6 +626,7 @@ static void __exit cadet_exit(void)
|
||||||
struct cadet *dev = &cadet_card;
|
struct cadet *dev = &cadet_card;
|
||||||
|
|
||||||
video_unregister_device(&dev->vdev);
|
video_unregister_device(&dev->vdev);
|
||||||
|
v4l2_ctrl_handler_free(&dev->ctrl_handler);
|
||||||
v4l2_device_unregister(&dev->v4l2_dev);
|
v4l2_device_unregister(&dev->v4l2_dev);
|
||||||
release_region(dev->io, 2);
|
release_region(dev->io, 2);
|
||||||
pnp_unregister_driver(&cadet_pnp_driver);
|
pnp_unregister_driver(&cadet_pnp_driver);
|
||||||
|
|
Loading…
Reference in New Issue