Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 37324
b: refs/heads/master
c: 2ab6529
h: refs/heads/master
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Sep 26, 2006
1 parent c0eb329 commit 470f06d
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 60 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 30c48305ba3e785cef33ff90efcbf5d9bdc3cffe
refs/heads/master: 2ab652993623954c7bfdadeba311d15a3e1494c0
2 changes: 1 addition & 1 deletion trunk/drivers/media/radio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ config RADIO_TYPHOON_MUTEFREQ

config RADIO_ZOLTRIX
tristate "Zoltrix Radio"
depends on ISA && VIDEO_V4L1
depends on ISA && VIDEO_V4L2
---help---
Choose Y here if you have one of these FM radio cards, and then fill
in the port address below.
Expand Down
182 changes: 124 additions & 58 deletions trunk/drivers/media/radio/radio-zoltrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
* - Added unmute function
* - Reworked ioctl functions
* 2002-07-15 - Fix Stereo typo
*
* 2006-07-24 - Converted to V4L2 API
* by Mauro Carvalho Chehab <mchehab@infradead.org>
*/

#include <linux/module.h> /* Modules */
Expand All @@ -32,9 +35,31 @@
#include <linux/delay.h> /* udelay, msleep */
#include <asm/io.h> /* outb, outb_p */
#include <asm/uaccess.h> /* copy to/from user */
#include <linux/videodev.h> /* kernel radio structs */
#include <linux/videodev2.h> /* kernel radio structs */
#include <media/v4l2-common.h>

#include <linux/version.h> /* for KERNEL_VERSION MACRO */
#define RADIO_VERSION KERNEL_VERSION(0,0,2)

static struct v4l2_queryctrl radio_qctrl[] = {
{
.id = V4L2_CID_AUDIO_MUTE,
.name = "Mute",
.minimum = 0,
.maximum = 1,
.default_value = 1,
.type = V4L2_CTRL_TYPE_BOOLEAN,
},{
.id = V4L2_CID_AUDIO_VOLUME,
.name = "Volume",
.minimum = 0,
.maximum = 65535,
.step = 4096,
.default_value = 0xff,
.type = V4L2_CTRL_TYPE_INTEGER,
}
};

#ifndef CONFIG_RADIO_ZOLTRIX_PORT
#define CONFIG_RADIO_ZOLTRIX_PORT -1
#endif
Expand Down Expand Up @@ -212,78 +237,116 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
struct zol_device *zol = dev->priv;

switch (cmd) {
case VIDIOCGCAP:
case VIDIOC_QUERYCAP:
{
struct video_capability *v = arg;

struct v4l2_capability *v = arg;
memset(v,0,sizeof(*v));
v->type = VID_TYPE_TUNER;
v->channels = 1 + zol->stereo;
v->audios = 1;
strcpy(v->name, "Zoltrix Radio");
strlcpy(v->driver, "radio-zoltrix", sizeof (v->driver));
strlcpy(v->card, "Zoltrix Radio", sizeof (v->card));
sprintf(v->bus_info,"ISA");
v->version = RADIO_VERSION;
v->capabilities = V4L2_CAP_TUNER;

return 0;
}
case VIDIOCGTUNER:
case VIDIOC_G_TUNER:
{
struct video_tuner *v = arg;
if (v->tuner)
struct v4l2_tuner *v = arg;

if (v->index > 0)
return -EINVAL;

memset(v,0,sizeof(*v));
strcpy(v->name, "FM");
v->rangelow = (int) (88.0 * 16000);
v->rangehigh = (int) (108.0 * 16000);
v->flags = zol_is_stereo(zol)
? VIDEO_TUNER_STEREO_ON : 0;
v->flags |= VIDEO_TUNER_LOW;
v->mode = VIDEO_MODE_AUTO;
v->signal = 0xFFFF * zol_getsigstr(zol);
v->type = V4L2_TUNER_RADIO;

v->rangelow=(88*16000);
v->rangehigh=(108*16000);
v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
v->capability=V4L2_TUNER_CAP_LOW;
if(zol_is_stereo(zol))
v->audmode = V4L2_TUNER_MODE_STEREO;
else
v->audmode = V4L2_TUNER_MODE_MONO;
v->signal=0xFFFF*zol_getsigstr(zol);

return 0;
}
case VIDIOCSTUNER:
case VIDIOC_S_TUNER:
{
struct video_tuner *v = arg;
if (v->tuner != 0)
struct v4l2_tuner *v = arg;

if (v->index > 0)
return -EINVAL;
/* Only 1 tuner so no setting needed ! */

return 0;
}
case VIDIOCGFREQ:
{
unsigned long *freq = arg;
*freq = zol->curfreq;
return 0;
}
case VIDIOCSFREQ:
{
unsigned long *freq = arg;
zol->curfreq = *freq;
zol_setfreq(zol, zol->curfreq);
return 0;
}
case VIDIOCGAUDIO:
case VIDIOC_S_FREQUENCY:
{
struct video_audio *v = arg;
memset(v, 0, sizeof(*v));
v->flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME;
v->mode |= zol_is_stereo(zol)
? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
v->volume = zol->curvol * 4096;
v->step = 4096;
strcpy(v->name, "Zoltrix Radio");
struct v4l2_frequency *f = arg;

zol->curfreq = f->frequency;
zol_setfreq(zol, zol->curfreq);
return 0;
}
case VIDIOCSAUDIO:
case VIDIOC_G_FREQUENCY:
{
struct video_audio *v = arg;
if (v->audio)
return -EINVAL;
struct v4l2_frequency *f = arg;

if (v->flags & VIDEO_AUDIO_MUTE)
zol_mute(zol);
else {
zol_unmute(zol);
zol_setvol(zol, v->volume / 4096);
}
f->type = V4L2_TUNER_RADIO;
f->frequency = zol->curfreq;

return 0;
}
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *qc = arg;
int i;

for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
if (qc->id && qc->id == radio_qctrl[i].id) {
memcpy(qc, &(radio_qctrl[i]),
sizeof(*qc));
return (0);
}
}
return -EINVAL;
}
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl= arg;

switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
ctrl->value=zol->muted;
return (0);
case V4L2_CID_AUDIO_VOLUME:
ctrl->value=zol->curvol * 4096;
return (0);
}
return -EINVAL;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl= arg;

switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
if (ctrl->value) {
zol_mute(zol);
} else {
zol_unmute(zol);
zol_setvol(zol,zol->curvol);
}
return (0);
case V4L2_CID_AUDIO_VOLUME:
zol_setvol(zol,ctrl->value/4096);
return (0);
}
zol->stereo = 1;
zol_setfreq(zol, zol->curfreq);
#if 0
/* FIXME: Implement stereo/mono switch on V4L2 */
if (v->mode & VIDEO_SOUND_STEREO) {
zol->stereo = 1;
zol_setfreq(zol, zol->curfreq);
Expand All @@ -292,10 +355,13 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
zol->stereo = 0;
zol_setfreq(zol, zol->curfreq);
}
return 0;
#endif
return -EINVAL;
}
default:
return -ENOIOCTLCMD;

default:
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
zol_do_ioctl);
}
}

Expand All @@ -322,7 +388,7 @@ static struct video_device zoltrix_radio =
.owner = THIS_MODULE,
.name = "Zoltrix Radio Plus",
.type = VID_TYPE_TUNER,
.hardware = VID_HARDWARE_ZOLTRIX,
.hardware = 0,
.fops = &zoltrix_fops,
};

Expand Down

0 comments on commit 470f06d

Please sign in to comment.