+ if (v->index != 0 && v->index != 1)
+ return -EINVAL;
+ dev->curtuner = v->index;
+ return 0;
+}
+
+static int vidioc_g_frequency(struct file *file, void *priv,
+ struct v4l2_frequency *f)
+{
+ struct cadet *dev = video_drvdata(file);
+
+ f->tuner = dev->curtuner;
+ f->type = V4L2_TUNER_RADIO;
+ f->frequency = cadet_getfreq(dev);
+ return 0;
+}
+
+
+static int vidioc_s_frequency(struct file *file, void *priv,
+ struct v4l2_frequency *f)
+{
+ struct cadet *dev = video_drvdata(file);
+
+ if (f->type != V4L2_TUNER_RADIO)
+ return -EINVAL;
+ if (dev->curtuner == 0 && (f->frequency < 1400 || f->frequency > 1728))
+ return -EINVAL;
+ if (dev->curtuner == 1 && (f->frequency < 8320 || f->frequency > 26400))
+ return -EINVAL;
+ cadet_setfreq(dev, f->frequency);
+ return 0;
+}
+
+static int vidioc_queryctrl(struct file *file, void *priv,
+ struct v4l2_queryctrl *qc)
+{
+ switch (qc->id) {
+ 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) {
+ case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
+ ctrl->value = (cadet_getvol(dev) == 0);
+ break;
+ case V4L2_CID_AUDIO_VOLUME:
+ 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
+ cadet_setvol(dev, 0xffff);
+ break;
+ case V4L2_CID_AUDIO_VOLUME:
+ cadet_setvol(dev, ctrl->value);
+ break;
+ default:
+ return -EINVAL;