提交 64d416ec 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

[media] usbvision: frequency fixes

- setup initial radio and tv frequencies.
- set/get the correct frequency (radio vs tv).
- disable tuner/freq ioctls if there is no tuner.
- fix some tuner index checks.
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@osg.samsung.com>
上级 cbe12cc6
...@@ -608,14 +608,13 @@ static int vidioc_g_tuner(struct file *file, void *priv, ...@@ -608,14 +608,13 @@ static int vidioc_g_tuner(struct file *file, void *priv,
{ {
struct usb_usbvision *usbvision = video_drvdata(file); struct usb_usbvision *usbvision = video_drvdata(file);
if (!usbvision->have_tuner || vt->index) /* Only tuner 0 */ if (vt->index) /* Only tuner 0 */
return -EINVAL; return -EINVAL;
if (usbvision->radio) { if (vt->type == V4L2_TUNER_RADIO)
strcpy(vt->name, "Radio"); strcpy(vt->name, "Radio");
vt->type = V4L2_TUNER_RADIO; else
} else {
strcpy(vt->name, "Television"); strcpy(vt->name, "Television");
}
/* Let clients fill in the remainder of this struct */ /* Let clients fill in the remainder of this struct */
call_all(usbvision, tuner, g_tuner, vt); call_all(usbvision, tuner, g_tuner, vt);
...@@ -627,8 +626,8 @@ static int vidioc_s_tuner(struct file *file, void *priv, ...@@ -627,8 +626,8 @@ static int vidioc_s_tuner(struct file *file, void *priv,
{ {
struct usb_usbvision *usbvision = video_drvdata(file); struct usb_usbvision *usbvision = video_drvdata(file);
/* Only no or one tuner for now */ /* Only one tuner for now */
if (!usbvision->have_tuner || vt->index) if (vt->index)
return -EINVAL; return -EINVAL;
/* let clients handle this */ /* let clients handle this */
call_all(usbvision, tuner, s_tuner, vt); call_all(usbvision, tuner, s_tuner, vt);
...@@ -641,12 +640,13 @@ static int vidioc_g_frequency(struct file *file, void *priv, ...@@ -641,12 +640,13 @@ static int vidioc_g_frequency(struct file *file, void *priv,
{ {
struct usb_usbvision *usbvision = video_drvdata(file); struct usb_usbvision *usbvision = video_drvdata(file);
freq->tuner = 0; /* Only one tuner */ /* Only one tuner */
if (usbvision->radio) if (freq->tuner)
freq->type = V4L2_TUNER_RADIO; return -EINVAL;
if (freq->type == V4L2_TUNER_RADIO)
freq->frequency = usbvision->radio_freq;
else else
freq->type = V4L2_TUNER_ANALOG_TV; freq->frequency = usbvision->tv_freq;
freq->frequency = usbvision->freq;
return 0; return 0;
} }
...@@ -655,13 +655,18 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -655,13 +655,18 @@ static int vidioc_s_frequency(struct file *file, void *priv,
const struct v4l2_frequency *freq) const struct v4l2_frequency *freq)
{ {
struct usb_usbvision *usbvision = video_drvdata(file); struct usb_usbvision *usbvision = video_drvdata(file);
struct v4l2_frequency new_freq = *freq;
/* Only no or one tuner for now */ /* Only one tuner for now */
if (!usbvision->have_tuner || freq->tuner) if (freq->tuner)
return -EINVAL; return -EINVAL;
usbvision->freq = freq->frequency;
call_all(usbvision, tuner, s_frequency, freq); call_all(usbvision, tuner, s_frequency, freq);
call_all(usbvision, tuner, g_frequency, &new_freq);
if (freq->type == V4L2_TUNER_RADIO)
usbvision->radio_freq = new_freq.frequency;
else
usbvision->tv_freq = new_freq.frequency;
return 0; return 0;
} }
...@@ -1287,6 +1292,12 @@ static int usbvision_register_video(struct usb_usbvision *usbvision) ...@@ -1287,6 +1292,12 @@ static int usbvision_register_video(struct usb_usbvision *usbvision)
/* Video Device: */ /* Video Device: */
usbvision_vdev_init(usbvision, &usbvision->vdev, usbvision_vdev_init(usbvision, &usbvision->vdev,
&usbvision_video_template, "USBVision Video"); &usbvision_video_template, "USBVision Video");
if (!usbvision->have_tuner) {
v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_G_FREQUENCY);
v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_S_TUNER);
v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_G_FREQUENCY);
v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_S_TUNER);
}
if (video_register_device(&usbvision->vdev, VFL_TYPE_GRABBER, video_nr) < 0) if (video_register_device(&usbvision->vdev, VFL_TYPE_GRABBER, video_nr) < 0)
goto err_exit; goto err_exit;
printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n",
...@@ -1403,9 +1414,10 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision) ...@@ -1403,9 +1414,10 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision)
} }
usbvision->tvnorm_id = usbvision_device_data[model].video_norm; usbvision->tvnorm_id = usbvision_device_data[model].video_norm;
usbvision->video_inputs = usbvision_device_data[model].video_channels; usbvision->video_inputs = usbvision_device_data[model].video_channels;
usbvision->ctl_input = 0; usbvision->ctl_input = 0;
usbvision->radio_freq = 87.5 * 16000;
usbvision->tv_freq = 400 * 16;
/* This should be here to make i2c clients to be able to register */ /* This should be here to make i2c clients to be able to register */
/* first switch off audio */ /* first switch off audio */
......
...@@ -378,7 +378,8 @@ struct usb_usbvision { ...@@ -378,7 +378,8 @@ struct usb_usbvision {
int bridge_type; /* NT1003, NT1004, NT1005 */ int bridge_type; /* NT1003, NT1004, NT1005 */
int radio; int radio;
int video_inputs; /* # of inputs */ int video_inputs; /* # of inputs */
unsigned long freq; unsigned long radio_freq;
unsigned long tv_freq;
int audio_mute; int audio_mute;
int audio_channel; int audio_channel;
int isoc_mode; /* format of video data for the usb isoc-transfer */ int isoc_mode; /* format of video data for the usb isoc-transfer */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册