Loading drivers/media/radio/radio-cadet.c +179 −118 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,25 @@ #define CADET_VERSION KERNEL_VERSION(0,3,3) #define CADET_VERSION KERNEL_VERSION(0,3,3) 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 = 0xff, .step = 1, .default_value = 0xff, .type = V4L2_CTRL_TYPE_INTEGER, } }; static int io=-1; /* default to isapnp activation */ static int io=-1; /* default to isapnp activation */ static int radio_nr = -1; static int radio_nr = -1; static int users=0; static int users=0; Loading Loading @@ -347,118 +366,129 @@ cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos) } } static int vidioc_querycap(struct file *file, void *priv, static int cadet_do_ioctl(struct inode *inode, struct file *file, struct v4l2_capability *v) unsigned int cmd, void *arg) { switch(cmd) { { case VIDIOC_QUERYCAP: v->capabilities = { struct v4l2_capability *cap = arg; memset(cap,0,sizeof(*cap)); cap->capabilities = V4L2_CAP_TUNER | V4L2_CAP_TUNER | V4L2_CAP_READWRITE; V4L2_CAP_READWRITE; cap->version = CADET_VERSION; v->version = CADET_VERSION; strcpy(cap->driver, "ADS Cadet"); strcpy(v->driver, "ADS Cadet"); strcpy(cap->card, "ADS Cadet"); strcpy(v->card, "ADS Cadet"); return 0; return 0; } } case VIDIOC_G_TUNER: { static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t = arg; struct v4l2_tuner *v) memset(t,0,sizeof(*t)); t->type = V4L2_TUNER_RADIO; switch (t->index) { { case 0: strcpy(t->name, "FM"); v->type = V4L2_TUNER_RADIO; t->capability = V4L2_TUNER_CAP_STEREO; switch (v->index) { t->rangelow = 1400; /* 87.5 MHz */ case 0: t->rangehigh = 1728; /* 108.0 MHz */ strcpy(v->name, "FM"); t->rxsubchans=cadet_getstereo(); v->capability = V4L2_TUNER_CAP_STEREO; switch (t->rxsubchans){ v->rangelow = 1400; /* 87.5 MHz */ v->rangehigh = 1728; /* 108.0 MHz */ v->rxsubchans=cadet_getstereo(); switch (v->rxsubchans){ case V4L2_TUNER_SUB_MONO: case V4L2_TUNER_SUB_MONO: t->audmode = V4L2_TUNER_MODE_MONO; v->audmode = V4L2_TUNER_MODE_MONO; break; break; case V4L2_TUNER_SUB_STEREO: case V4L2_TUNER_SUB_STEREO: t->audmode = V4L2_TUNER_MODE_STEREO; v->audmode = V4L2_TUNER_MODE_STEREO; break; break; default: ; default: ; } } break; break; case 1: strcpy(t->name, "AM"); case 1: t->capability = V4L2_TUNER_CAP_LOW; strcpy(v->name, "AM"); t->rangelow = 8320; /* 520 kHz */ v->capability = V4L2_TUNER_CAP_LOW; t->rangehigh = 26400; /* 1650 kHz */ v->rangelow = 8320; /* 520 kHz */ t->rxsubchans = V4L2_TUNER_SUB_MONO; v->rangehigh = 26400; /* 1650 kHz */ t->audmode = V4L2_TUNER_MODE_MONO; v->rxsubchans = V4L2_TUNER_SUB_MONO; v->audmode = V4L2_TUNER_MODE_MONO; break; break; default: default: return -EINVAL; return -EINVAL; } } v->signal = sigstrength; /* We might need to modify scaling of this */ t->signal = sigstrength; /* We might need to modify scaling of this */ return 0; return 0; } } case VIDIOC_S_TUNER: static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { { struct v4l2_tuner *t = arg; if((v->index != 0)&&(v->index != 1)) if((t->index != 0)&&(t->index != 1)) return -EINVAL; return -EINVAL; curtuner = v->index; curtuner = t->index; return 0; return 0; } } case VIDIOC_G_FREQUENCY: static int vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { { struct v4l2_frequency *f = arg; memset(f,0,sizeof(*f)); f->tuner = curtuner; f->tuner = curtuner; f->type = V4L2_TUNER_RADIO; f->type = V4L2_TUNER_RADIO; f->frequency = cadet_getfreq(); f->frequency = cadet_getfreq(); return 0; return 0; } } case VIDIOC_S_FREQUENCY: static int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { { struct v4l2_frequency *f = arg; if (f->type != V4L2_TUNER_RADIO) if (f->type != V4L2_TUNER_RADIO){ return -EINVAL; return -EINVAL; } if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) { return -EINVAL; return -EINVAL; } if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) { return -EINVAL; return -EINVAL; } cadet_setfreq(f->frequency); cadet_setfreq(f->frequency); return 0; return 0; } } case VIDIOC_G_CTRL: static int vidioc_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *qc) { { struct v4l2_control *c = arg; int i; switch (c->id){ 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; } static int vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { switch (ctrl->id){ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ c->value = (cadet_getvol() == 0); ctrl->value = (cadet_getvol() == 0); break; break; case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME: c->value = cadet_getvol(); ctrl->value = cadet_getvol(); break; break; default: default: return -EINVAL; return -EINVAL; } } return 0; return 0; } } case VIDIOC_S_CTRL: static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { { struct v4l2_control *c = arg; switch (ctrl->id){ switch (c->id){ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ if (c->value) cadet_setvol(0); if (ctrl->value) else cadet_setvol(0xffff); cadet_setvol(0); else cadet_setvol(0xffff); break; break; case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME: cadet_setvol(c->value); cadet_setvol(ctrl->value); break; break; default: default: return -EINVAL; return -EINVAL; Loading @@ -466,16 +496,35 @@ static int cadet_do_ioctl(struct inode *inode, struct file *file, return 0; return 0; } } default: static int vidioc_g_audio(struct file *file, void *priv, return -ENOIOCTLCMD; struct v4l2_audio *a) { if (a->index > 1) return -EINVAL; strcpy(a->name, "Radio"); a->capability = V4L2_AUDCAP_STEREO; return 0; } } static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) { *i = 0; return 0; } } static int static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) cadet_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { { return video_usercopy(inode, file, cmd, arg, cadet_do_ioctl); if (i != 0) return -EINVAL; return 0; } static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) { if (a->index != 0) return -EINVAL; return 0; } } static int static int Loading Loading @@ -512,7 +561,7 @@ static const struct file_operations cadet_fops = { .open = cadet_open, .open = cadet_open, .release = cadet_release, .release = cadet_release, .read = cadet_read, .read = cadet_read, .ioctl = cadet_ioctl, .ioctl = video_ioctl2, .poll = cadet_poll, .poll = cadet_poll, .compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32, .llseek = no_llseek, .llseek = no_llseek, Loading @@ -524,6 +573,18 @@ static struct video_device cadet_radio= .name = "Cadet radio", .name = "Cadet radio", .type = VID_TYPE_TUNER, .type = VID_TYPE_TUNER, .fops = &cadet_fops, .fops = &cadet_fops, .vidioc_querycap = vidioc_querycap, .vidioc_g_tuner = vidioc_g_tuner, .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, .vidioc_queryctrl = vidioc_queryctrl, .vidioc_g_ctrl = vidioc_g_ctrl, .vidioc_s_ctrl = vidioc_s_ctrl, .vidioc_g_audio = vidioc_g_audio, .vidioc_s_audio = vidioc_s_audio, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, }; }; static struct pnp_device_id cadet_pnp_devices[] = { static struct pnp_device_id cadet_pnp_devices[] = { Loading Loading
drivers/media/radio/radio-cadet.c +179 −118 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,25 @@ #define CADET_VERSION KERNEL_VERSION(0,3,3) #define CADET_VERSION KERNEL_VERSION(0,3,3) 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 = 0xff, .step = 1, .default_value = 0xff, .type = V4L2_CTRL_TYPE_INTEGER, } }; static int io=-1; /* default to isapnp activation */ static int io=-1; /* default to isapnp activation */ static int radio_nr = -1; static int radio_nr = -1; static int users=0; static int users=0; Loading Loading @@ -347,118 +366,129 @@ cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos) } } static int vidioc_querycap(struct file *file, void *priv, static int cadet_do_ioctl(struct inode *inode, struct file *file, struct v4l2_capability *v) unsigned int cmd, void *arg) { switch(cmd) { { case VIDIOC_QUERYCAP: v->capabilities = { struct v4l2_capability *cap = arg; memset(cap,0,sizeof(*cap)); cap->capabilities = V4L2_CAP_TUNER | V4L2_CAP_TUNER | V4L2_CAP_READWRITE; V4L2_CAP_READWRITE; cap->version = CADET_VERSION; v->version = CADET_VERSION; strcpy(cap->driver, "ADS Cadet"); strcpy(v->driver, "ADS Cadet"); strcpy(cap->card, "ADS Cadet"); strcpy(v->card, "ADS Cadet"); return 0; return 0; } } case VIDIOC_G_TUNER: { static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t = arg; struct v4l2_tuner *v) memset(t,0,sizeof(*t)); t->type = V4L2_TUNER_RADIO; switch (t->index) { { case 0: strcpy(t->name, "FM"); v->type = V4L2_TUNER_RADIO; t->capability = V4L2_TUNER_CAP_STEREO; switch (v->index) { t->rangelow = 1400; /* 87.5 MHz */ case 0: t->rangehigh = 1728; /* 108.0 MHz */ strcpy(v->name, "FM"); t->rxsubchans=cadet_getstereo(); v->capability = V4L2_TUNER_CAP_STEREO; switch (t->rxsubchans){ v->rangelow = 1400; /* 87.5 MHz */ v->rangehigh = 1728; /* 108.0 MHz */ v->rxsubchans=cadet_getstereo(); switch (v->rxsubchans){ case V4L2_TUNER_SUB_MONO: case V4L2_TUNER_SUB_MONO: t->audmode = V4L2_TUNER_MODE_MONO; v->audmode = V4L2_TUNER_MODE_MONO; break; break; case V4L2_TUNER_SUB_STEREO: case V4L2_TUNER_SUB_STEREO: t->audmode = V4L2_TUNER_MODE_STEREO; v->audmode = V4L2_TUNER_MODE_STEREO; break; break; default: ; default: ; } } break; break; case 1: strcpy(t->name, "AM"); case 1: t->capability = V4L2_TUNER_CAP_LOW; strcpy(v->name, "AM"); t->rangelow = 8320; /* 520 kHz */ v->capability = V4L2_TUNER_CAP_LOW; t->rangehigh = 26400; /* 1650 kHz */ v->rangelow = 8320; /* 520 kHz */ t->rxsubchans = V4L2_TUNER_SUB_MONO; v->rangehigh = 26400; /* 1650 kHz */ t->audmode = V4L2_TUNER_MODE_MONO; v->rxsubchans = V4L2_TUNER_SUB_MONO; v->audmode = V4L2_TUNER_MODE_MONO; break; break; default: default: return -EINVAL; return -EINVAL; } } v->signal = sigstrength; /* We might need to modify scaling of this */ t->signal = sigstrength; /* We might need to modify scaling of this */ return 0; return 0; } } case VIDIOC_S_TUNER: static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { { struct v4l2_tuner *t = arg; if((v->index != 0)&&(v->index != 1)) if((t->index != 0)&&(t->index != 1)) return -EINVAL; return -EINVAL; curtuner = v->index; curtuner = t->index; return 0; return 0; } } case VIDIOC_G_FREQUENCY: static int vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { { struct v4l2_frequency *f = arg; memset(f,0,sizeof(*f)); f->tuner = curtuner; f->tuner = curtuner; f->type = V4L2_TUNER_RADIO; f->type = V4L2_TUNER_RADIO; f->frequency = cadet_getfreq(); f->frequency = cadet_getfreq(); return 0; return 0; } } case VIDIOC_S_FREQUENCY: static int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { { struct v4l2_frequency *f = arg; if (f->type != V4L2_TUNER_RADIO) if (f->type != V4L2_TUNER_RADIO){ return -EINVAL; return -EINVAL; } if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) { return -EINVAL; return -EINVAL; } if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) { return -EINVAL; return -EINVAL; } cadet_setfreq(f->frequency); cadet_setfreq(f->frequency); return 0; return 0; } } case VIDIOC_G_CTRL: static int vidioc_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *qc) { { struct v4l2_control *c = arg; int i; switch (c->id){ 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; } static int vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { switch (ctrl->id){ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ c->value = (cadet_getvol() == 0); ctrl->value = (cadet_getvol() == 0); break; break; case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME: c->value = cadet_getvol(); ctrl->value = cadet_getvol(); break; break; default: default: return -EINVAL; return -EINVAL; } } return 0; return 0; } } case VIDIOC_S_CTRL: static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { { struct v4l2_control *c = arg; switch (ctrl->id){ switch (c->id){ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ if (c->value) cadet_setvol(0); if (ctrl->value) else cadet_setvol(0xffff); cadet_setvol(0); else cadet_setvol(0xffff); break; break; case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME: cadet_setvol(c->value); cadet_setvol(ctrl->value); break; break; default: default: return -EINVAL; return -EINVAL; Loading @@ -466,16 +496,35 @@ static int cadet_do_ioctl(struct inode *inode, struct file *file, return 0; return 0; } } default: static int vidioc_g_audio(struct file *file, void *priv, return -ENOIOCTLCMD; struct v4l2_audio *a) { if (a->index > 1) return -EINVAL; strcpy(a->name, "Radio"); a->capability = V4L2_AUDCAP_STEREO; return 0; } } static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) { *i = 0; return 0; } } static int static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) cadet_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { { return video_usercopy(inode, file, cmd, arg, cadet_do_ioctl); if (i != 0) return -EINVAL; return 0; } static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) { if (a->index != 0) return -EINVAL; return 0; } } static int static int Loading Loading @@ -512,7 +561,7 @@ static const struct file_operations cadet_fops = { .open = cadet_open, .open = cadet_open, .release = cadet_release, .release = cadet_release, .read = cadet_read, .read = cadet_read, .ioctl = cadet_ioctl, .ioctl = video_ioctl2, .poll = cadet_poll, .poll = cadet_poll, .compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32, .llseek = no_llseek, .llseek = no_llseek, Loading @@ -524,6 +573,18 @@ static struct video_device cadet_radio= .name = "Cadet radio", .name = "Cadet radio", .type = VID_TYPE_TUNER, .type = VID_TYPE_TUNER, .fops = &cadet_fops, .fops = &cadet_fops, .vidioc_querycap = vidioc_querycap, .vidioc_g_tuner = vidioc_g_tuner, .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, .vidioc_queryctrl = vidioc_queryctrl, .vidioc_g_ctrl = vidioc_g_ctrl, .vidioc_s_ctrl = vidioc_s_ctrl, .vidioc_g_audio = vidioc_g_audio, .vidioc_s_audio = vidioc_s_audio, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, }; }; static struct pnp_device_id cadet_pnp_devices[] = { static struct pnp_device_id cadet_pnp_devices[] = { Loading