From patchwork Thu Jan 23 21:08:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 3531911 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E96B89F39B for ; Thu, 23 Jan 2014 21:09:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4CC9201BB for ; Thu, 23 Jan 2014 21:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DA5C2012E for ; Thu, 23 Jan 2014 21:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbaAWVJM (ORCPT ); Thu, 23 Jan 2014 16:09:12 -0500 Received: from mail.kapsi.fi ([217.30.184.167]:46459 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbaAWVJL (ORCPT ); Thu, 23 Jan 2014 16:09:11 -0500 Received: from [82.128.187.60] (helo=localhost.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1W6RWP-00012d-U4; Thu, 23 Jan 2014 23:09:10 +0200 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari , Hans Verkuil Subject: [REVIEW PATCH 02/13] v4l: add new tuner types for SDR Date: Thu, 23 Jan 2014 23:08:42 +0200 Message-Id: <1390511333-25837-3-git-send-email-crope@iki.fi> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1390511333-25837-1-git-send-email-crope@iki.fi> References: <1390511333-25837-1-git-send-email-crope@iki.fi> X-SA-Exim-Connect-IP: 82.128.187.60 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define tuner types V4L2_TUNER_ADC and V4L2_TUNER_RF for SDR usage. ADC is used for setting sampling rate (sampling frequency) to SDR device. Another tuner type, named as V4L2_TUNER_RF, is possible RF tuner. Is is used to down-convert RF frequency to range ADC could sample. Having RF tuner is optional, whilst in practice it is almost always there. Also add checks to VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY and VIDIOC_ENUM_FREQ_BANDS only allow these two tuner types when device type is SDR (VFL_TYPE_SDR). For VIDIOC_G_FREQUENCY we do not check tuner type, instead override type with V4L2_TUNER_ADC in every case (requested by Hans in order to keep functionality in line with existing tuners and existing API does not specify it). Prohibit VIDIOC_S_HW_FREQ_SEEK explicitly when device type is SDR, as device cannot do hardware seek without a hardware demodulator. Cc: Hans Verkuil Signed-off-by: Antti Palosaari Acked-by: Hans Verkuil --- drivers/media/v4l2-core/v4l2-ioctl.c | 39 ++++++++++++++++++++++++++---------- include/uapi/linux/videodev2.h | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 707aef7..15ab349 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1291,8 +1291,11 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops, struct video_device *vfd = video_devdata(file); struct v4l2_frequency *p = arg; - p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + if (vfd->vfl_type == VFL_TYPE_SDR) + p->type = V4L2_TUNER_ADC; + else + p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; return ops->vidioc_g_frequency(file, fh, p); } @@ -1303,10 +1306,15 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops, const struct v4l2_frequency *p = arg; enum v4l2_tuner_type type; - type = (vfd->vfl_type == VFL_TYPE_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; - if (p->type != type) - return -EINVAL; + if (vfd->vfl_type == VFL_TYPE_SDR) { + if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF) + return -EINVAL; + } else { + type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + if (type != p->type) + return -EINVAL; + } return ops->vidioc_s_frequency(file, fh, p); } @@ -1386,6 +1394,10 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, struct v4l2_hw_freq_seek *p = arg; enum v4l2_tuner_type type; + /* s_hw_freq_seek is not supported for SDR for now */ + if (vfd->vfl_type == VFL_TYPE_SDR) + return -EINVAL; + type = (vfd->vfl_type == VFL_TYPE_RADIO) ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; if (p->type != type) @@ -1885,11 +1897,16 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops, enum v4l2_tuner_type type; int err; - type = (vfd->vfl_type == VFL_TYPE_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; - - if (type != p->type) - return -EINVAL; + if (vfd->vfl_type == VFL_TYPE_SDR) { + if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF) + return -EINVAL; + type = p->type; + } else { + type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + if (type != p->type) + return -EINVAL; + } if (ops->vidioc_enum_freq_bands) return ops->vidioc_enum_freq_bands(file, fh, p); if (is_valid_ioctl(vfd, VIDIOC_G_TUNER)) { diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 6ae7bbe..9dc79d1 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -159,6 +159,8 @@ enum v4l2_tuner_type { V4L2_TUNER_RADIO = 1, V4L2_TUNER_ANALOG_TV = 2, V4L2_TUNER_DIGITAL_TV = 3, + V4L2_TUNER_ADC = 4, + V4L2_TUNER_RF = 5, }; enum v4l2_memory {