public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <m.chehab@samsung.com>
To: Antti Palosaari <crope@iki.fi>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [PATCH 23/52] v4l: add new tuner types for SDR
Date: Fri, 07 Feb 2014 12:03:53 -0200	[thread overview]
Message-ID: <20140207120353.26d71842@samsung.com> (raw)
In-Reply-To: <1390669846-8131-24-git-send-email-crope@iki.fi>

Em Sat, 25 Jan 2014 19:10:17 +0200
Antti Palosaari <crope@iki.fi> escreveu:

> 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 <hverkuil@xs4all.nl>
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  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;

A minor issue: return code here is IMHO wrong. It should be -ENOTTY.

It makes sense to add a printk_once() to warn about it, as, if we ever
need it for SDR, people could lose hours debugging why this is not work
until finally discovering that the Kernel is blocking such call.

In any case, I'll apply this patch. Please send a fix on a next series.

> +
>  	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 {


-- 

Cheers,
Mauro

  reply	other threads:[~2014-02-07 14:03 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-25 17:09 [PATCH 00/52] SDR devel tree Antti Palosaari
2014-01-25 17:09 ` [PATCH 01/52] rtl2832_sdr: Realtek RTL2832 SDR driver module Antti Palosaari
2014-01-25 17:09 ` [PATCH 02/52] rtl28xxu: attach SDR extension module Antti Palosaari
2014-01-25 17:09 ` [PATCH 03/52] rtl2832_sdr: use config struct from rtl2832 module Antti Palosaari
2014-01-25 17:09 ` [PATCH 04/52] rtl2832_sdr: initial support for R820T tuner Antti Palosaari
2014-01-25 17:09 ` [PATCH 05/52] rtl2832_sdr: use get_if_frequency() Antti Palosaari
2014-01-25 17:10 ` [PATCH 06/52] rtl2832_sdr: implement sampling rate Antti Palosaari
2014-01-25 17:10 ` [PATCH 07/52] rtl2832_sdr: initial support for FC0012 tuner Antti Palosaari
2014-01-25 17:10 ` [PATCH 08/52] rtl2832_sdr: initial support for FC0013 tuner Antti Palosaari
2014-01-25 17:10 ` [PATCH 09/52] rtl28xxu: constify demod config structs Antti Palosaari
2014-01-25 17:10 ` [PATCH 10/52] rtl2832: remove unused if_dvbt config parameter Antti Palosaari
2014-01-25 17:10 ` [PATCH 11/52] rtl2832: style changes and minor cleanup Antti Palosaari
2014-01-25 17:10 ` [PATCH 12/52] rtl2832_sdr: pixel format for SDR Antti Palosaari
2014-01-25 17:10 ` [PATCH 13/52] rtl2832_sdr: implement FMT IOCTLs Antti Palosaari
2014-01-25 17:10 ` [PATCH 14/52] msi3101: add signed 8-bit pixel format for SDR Antti Palosaari
2014-01-25 17:10 ` [PATCH 15/52] msi3101: implement FMT IOCTLs Antti Palosaari
2014-01-25 17:10 ` [PATCH 16/52] msi3101: move format 384 conversion to libv4lconvert Antti Palosaari
2014-01-25 17:10 ` [PATCH 17/52] msi3101: move format 336 " Antti Palosaari
2014-01-25 17:10 ` [PATCH 18/52] msi3101: move format 252 " Antti Palosaari
2014-01-25 17:10 ` [PATCH 19/52] rtl28xxu: add module parameter to disable IR Antti Palosaari
2014-01-25 17:10 ` [PATCH 20/52] rtl2832_sdr: increase USB buffers Antti Palosaari
2014-01-25 17:10 ` [PATCH 21/52] DocBook: fix wait.c location Antti Palosaari
2014-01-25 17:10 ` [PATCH 22/52] v4l: add device type for Software Defined Radio Antti Palosaari
2014-01-25 17:10 ` [PATCH 23/52] v4l: add new tuner types for SDR Antti Palosaari
2014-02-07 14:03   ` Mauro Carvalho Chehab [this message]
2014-01-25 17:10 ` [PATCH 24/52] v4l: 1 Hz resolution flag for tuners Antti Palosaari
2014-01-25 17:10 ` [PATCH 25/52] v4l: add stream format for SDR receiver Antti Palosaari
2014-01-25 17:10 ` [PATCH 26/52] v4l: define own IOCTL ops for SDR FMT Antti Palosaari
2014-01-25 17:10 ` [PATCH 27/52] v4l: enable some IOCTLs for SDR receiver Antti Palosaari
2014-01-25 17:10 ` [PATCH 28/52] v4l: add device capability flag " Antti Palosaari
2014-01-25 17:10 ` [PATCH 29/52] v4l: do not allow modulator ioctls for non-radio devices Antti Palosaari
2014-01-25 17:10 ` [PATCH 30/52] DocBook: document 1 Hz flag Antti Palosaari
2014-01-25 17:10 ` [PATCH 31/52] DocBook: Software Defined Radio Interface Antti Palosaari
2014-01-25 17:10 ` [PATCH 32/52] DocBook: mark SDR API as Experimental Antti Palosaari
2014-01-25 17:10 ` [PATCH 33/52] v4l2-framework.txt: add SDR device type Antti Palosaari
2014-01-25 17:10 ` [PATCH 34/52] devices.txt: add video4linux device for Software Defined Radio Antti Palosaari
2014-01-25 17:10 ` [PATCH 35/52] rtl2832_sdr: convert to SDR API Antti Palosaari
2014-01-25 17:10 ` [PATCH 36/52] msi3101: " Antti Palosaari
2014-01-25 17:10 ` [PATCH 37/52] msi3101: add u8 sample format Antti Palosaari
2014-01-25 17:10 ` [PATCH 38/52] msi3101: add u16 LE " Antti Palosaari
2014-01-25 17:10 ` [PATCH 39/52] msi3101: tons of small changes Antti Palosaari
2014-01-25 17:10 ` [PATCH 40/52] v4l: disable lockdep on vb2_fop_mmap() Antti Palosaari
2014-01-25 17:10 ` [PATCH 41/52] rtl2832_sdr: return NULL on rtl2832_sdr_attach failure Antti Palosaari
2014-01-25 17:10 ` [PATCH 42/52] rtl2832_sdr: calculate bandwidth if not set by user Antti Palosaari
2014-01-25 17:10 ` [PATCH 43/52] rtl2832_sdr: clamp ADC frequency to valid range always Antti Palosaari
2014-01-25 17:10 ` [PATCH 44/52] rtl2832_sdr: improve ADC device programming logic Antti Palosaari
2014-01-25 17:10 ` [PATCH 45/52] rtl2832_sdr: remove FMT buffer type checks Antti Palosaari
2014-01-25 17:10 ` [PATCH 46/52] rtl2832_sdr: switch FM to DAB mode Antti Palosaari
2014-01-25 17:10 ` [PATCH 47/52] msi3101: calculate tuner filters Antti Palosaari
2014-01-25 17:10 ` [PATCH 48/52] msi3101: remove FMT buffer type checks Antti Palosaari
2014-01-25 17:10 ` [PATCH 49/52] msi3101: improve ADC config stream format selection Antti Palosaari
2014-01-25 17:10 ` [PATCH 50/52] msi3101: clamp ADC and RF to valid range Antti Palosaari
2014-01-25 17:10 ` [PATCH 51/52] msi3101: disable all but u8 and u16le formats Antti Palosaari
2014-01-25 17:10 ` [PATCH 52/52] v4l: add RF tuner gain controls Antti Palosaari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140207120353.26d71842@samsung.com \
    --to=m.chehab@samsung.com \
    --cc=crope@iki.fi \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox