Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
64d416ec cbe12cc6

+30 -17
+28 -16
drivers/media/usb/usbvision/usbvision-video.c
··· 608 608 { 609 609 struct usb_usbvision *usbvision = video_drvdata(file); 610 610 611 - if (!usbvision->have_tuner || vt->index) /* Only tuner 0 */ 611 + if (vt->index) /* Only tuner 0 */ 612 612 return -EINVAL; 613 - if (usbvision->radio) { 613 + if (vt->type == V4L2_TUNER_RADIO) 614 614 strcpy(vt->name, "Radio"); 615 - vt->type = V4L2_TUNER_RADIO; 616 - } else { 615 + else 617 616 strcpy(vt->name, "Television"); 618 - } 617 + 619 618 /* Let clients fill in the remainder of this struct */ 620 619 call_all(usbvision, tuner, g_tuner, vt); 621 620 ··· 626 627 { 627 628 struct usb_usbvision *usbvision = video_drvdata(file); 628 629 629 - /* Only no or one tuner for now */ 630 - if (!usbvision->have_tuner || vt->index) 630 + /* Only one tuner for now */ 631 + if (vt->index) 631 632 return -EINVAL; 632 633 /* let clients handle this */ 633 634 call_all(usbvision, tuner, s_tuner, vt); ··· 640 641 { 641 642 struct usb_usbvision *usbvision = video_drvdata(file); 642 643 643 - freq->tuner = 0; /* Only one tuner */ 644 - if (usbvision->radio) 645 - freq->type = V4L2_TUNER_RADIO; 644 + /* Only one tuner */ 645 + if (freq->tuner) 646 + return -EINVAL; 647 + if (freq->type == V4L2_TUNER_RADIO) 648 + freq->frequency = usbvision->radio_freq; 646 649 else 647 - freq->type = V4L2_TUNER_ANALOG_TV; 648 - freq->frequency = usbvision->freq; 650 + freq->frequency = usbvision->tv_freq; 649 651 650 652 return 0; 651 653 } ··· 655 655 const struct v4l2_frequency *freq) 656 656 { 657 657 struct usb_usbvision *usbvision = video_drvdata(file); 658 + struct v4l2_frequency new_freq = *freq; 658 659 659 - /* Only no or one tuner for now */ 660 - if (!usbvision->have_tuner || freq->tuner) 660 + /* Only one tuner for now */ 661 + if (freq->tuner) 661 662 return -EINVAL; 662 663 663 - usbvision->freq = freq->frequency; 664 664 call_all(usbvision, tuner, s_frequency, freq); 665 + call_all(usbvision, tuner, g_frequency, &new_freq); 666 + if (freq->type == V4L2_TUNER_RADIO) 667 + usbvision->radio_freq = new_freq.frequency; 668 + else 669 + usbvision->tv_freq = new_freq.frequency; 665 670 666 671 return 0; 667 672 } ··· 1292 1287 /* Video Device: */ 1293 1288 usbvision_vdev_init(usbvision, &usbvision->vdev, 1294 1289 &usbvision_video_template, "USBVision Video"); 1290 + if (!usbvision->have_tuner) { 1291 + v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_G_FREQUENCY); 1292 + v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_S_TUNER); 1293 + v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_G_FREQUENCY); 1294 + v4l2_disable_ioctl(&usbvision->vdev, VIDIOC_S_TUNER); 1295 + } 1295 1296 if (video_register_device(&usbvision->vdev, VFL_TYPE_GRABBER, video_nr) < 0) 1296 1297 goto err_exit; 1297 1298 printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", ··· 1414 1403 } 1415 1404 1416 1405 usbvision->tvnorm_id = usbvision_device_data[model].video_norm; 1417 - 1418 1406 usbvision->video_inputs = usbvision_device_data[model].video_channels; 1419 1407 usbvision->ctl_input = 0; 1408 + usbvision->radio_freq = 87.5 * 16000; 1409 + usbvision->tv_freq = 400 * 16; 1420 1410 1421 1411 /* This should be here to make i2c clients to be able to register */ 1422 1412 /* first switch off audio */
+2 -1
drivers/media/usb/usbvision/usbvision.h
··· 378 378 int bridge_type; /* NT1003, NT1004, NT1005 */ 379 379 int radio; 380 380 int video_inputs; /* # of inputs */ 381 - unsigned long freq; 381 + unsigned long radio_freq; 382 + unsigned long tv_freq; 382 383 int audio_mute; 383 384 int audio_channel; 384 385 int isoc_mode; /* format of video data for the usb isoc-transfer */