All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Antti Palosaari <crope@iki.fi>
Cc: linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <m.chehab@samsung.com>
Subject: Re: [PATCH RFC v3 5/7] v4l: enable some IOCTLs for SDR receiver
Date: Tue, 17 Dec 2013 08:34:59 +0100	[thread overview]
Message-ID: <52AFFEA3.7010200@xs4all.nl> (raw)
In-Reply-To: <1387231688-8647-6-git-send-email-crope@iki.fi>

On 12/16/2013 11:08 PM, Antti Palosaari wrote:
> Enable stream format (FMT) IOCTLs for SDR use. These are used for negotiate
> used data stream format.
> 
> Enable input IOCTLs, VIDIOC_ENUMINPUT, VIDIOC_G_INPUT, VIDIOC_S_INPUT.
> These are used to select possible antenna connector.
> 
> Reorganise some some IOCTL selection logic.
> 
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> ---
>  drivers/media/v4l2-core/v4l2-dev.c   | 27 ++++++++++++++++++++++++---
>  drivers/media/v4l2-core/v4l2-ioctl.c | 35 +++++++++++++++++++++++++++++++++++
>  2 files changed, 59 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index 6a1e6a8..5795e8d 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -562,7 +562,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
>  	const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;
>  	bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER;
>  	bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI;
> -	bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO;
> +	bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR;
>  	bool is_rx = vdev->vfl_dir != VFL_DIR_TX;
>  	bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
>  
> @@ -671,9 +671,26 @@ static void determine_valid_ioctls(struct video_device *vdev)
>  			       ops->vidioc_try_fmt_sliced_vbi_out)))
>  			set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
>  		SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap);
> +	} else if (is_sdr) {
> +		/* SDR specific ioctls */
> +		if (ops->vidioc_enum_fmt_sdr_cap)
> +			set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
> +		if (ops->vidioc_g_fmt_sdr_cap)
> +			set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
> +		if (ops->vidioc_s_fmt_sdr_cap)
> +			set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
> +		if (ops->vidioc_try_fmt_sdr_cap)
> +			set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
> +
> +		if (is_rx) {
> +			SET_VALID_IOCTL(ops, VIDIOC_ENUMINPUT, vidioc_enum_input);
> +			SET_VALID_IOCTL(ops, VIDIOC_G_INPUT, vidioc_g_input);
> +			SET_VALID_IOCTL(ops, VIDIOC_S_INPUT, vidioc_s_input);

Why would you want to enable these? Normal radio devices should never use
these, so why would sdr devices?

Regards,

	Hans

> +		}
>  	}
> -	if (!is_radio) {
> -		/* ioctls valid for video or vbi */
> +
> +	if (is_vid || is_vbi || is_sdr) {
> +		/* ioctls valid for video, vbi or sdr */
>  		SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
>  		SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
>  		SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
> @@ -681,6 +698,10 @@ static void determine_valid_ioctls(struct video_device *vdev)
>  		SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
>  		SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs);
>  		SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf);
> +	}
> +
> +	if (is_vid || is_vbi) {
> +		/* ioctls valid for video or vbi */
>  		if (ops->vidioc_s_std)
>  			set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls);
>  		SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std);
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index da197e1..d0777bd 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -243,6 +243,7 @@ static void v4l_print_format(const void *arg, bool write_only)
>  	const struct v4l2_vbi_format *vbi;
>  	const struct v4l2_sliced_vbi_format *sliced;
>  	const struct v4l2_window *win;
> +	const struct v4l2_format_sdr *sdr;
>  	unsigned i;
>  
>  	pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
> @@ -316,6 +317,14 @@ static void v4l_print_format(const void *arg, bool write_only)
>  				sliced->service_lines[0][i],
>  				sliced->service_lines[1][i]);
>  		break;
> +	case V4L2_BUF_TYPE_SDR_CAPTURE:
> +		sdr = &p->fmt.sdr;
> +		pr_cont(", pixelformat=%c%c%c%c\n",
> +			(sdr->pixelformat >>  0) & 0xff,
> +			(sdr->pixelformat >>  8) & 0xff,
> +			(sdr->pixelformat >> 16) & 0xff,
> +			(sdr->pixelformat >> 24) & 0xff);
> +		break;
>  	}
>  }
>  
> @@ -879,6 +888,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
>  	const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
>  	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
>  	bool is_vbi = vfd->vfl_type == VFL_TYPE_VBI;
> +	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
>  	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
>  	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
>  
> @@ -928,6 +938,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
>  		if (is_vbi && is_tx && ops->vidioc_g_fmt_sliced_vbi_out)
>  			return 0;
>  		break;
> +	case V4L2_BUF_TYPE_SDR_CAPTURE:
> +		if (is_sdr && is_rx && ops->vidioc_g_fmt_sdr_cap)
> +			return 0;
> +		break;
>  	default:
>  		break;
>  	}
> @@ -1047,6 +1061,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
>  		if (unlikely(!is_tx || !ops->vidioc_enum_fmt_vid_out_mplane))
>  			break;
>  		return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg);
> +	case V4L2_BUF_TYPE_SDR_CAPTURE:
> +		if (unlikely(!is_rx || !ops->vidioc_enum_fmt_sdr_cap))
> +			break;
> +		return ops->vidioc_enum_fmt_sdr_cap(file, fh, arg);
>  	}
>  	return -EINVAL;
>  }
> @@ -1057,6 +1075,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
>  	struct v4l2_format *p = arg;
>  	struct video_device *vfd = video_devdata(file);
>  	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
> +	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
>  	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
>  	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
>  
> @@ -1101,6 +1120,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
>  		if (unlikely(!is_tx || is_vid || !ops->vidioc_g_fmt_sliced_vbi_out))
>  			break;
>  		return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg);
> +	case V4L2_BUF_TYPE_SDR_CAPTURE:
> +		if (unlikely(!is_rx || !is_sdr || !ops->vidioc_g_fmt_sdr_cap))
> +			break;
> +		return ops->vidioc_g_fmt_sdr_cap(file, fh, arg);
>  	}
>  	return -EINVAL;
>  }
> @@ -1111,6 +1134,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
>  	struct v4l2_format *p = arg;
>  	struct video_device *vfd = video_devdata(file);
>  	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
> +	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
>  	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
>  	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
>  
> @@ -1165,6 +1189,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
>  			break;
>  		CLEAR_AFTER_FIELD(p, fmt.sliced);
>  		return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg);
> +	case V4L2_BUF_TYPE_SDR_CAPTURE:
> +		if (unlikely(!is_rx || !is_sdr || !ops->vidioc_s_fmt_sdr_cap))
> +			break;
> +		CLEAR_AFTER_FIELD(p, fmt.sdr);
> +		return ops->vidioc_s_fmt_sdr_cap(file, fh, arg);
>  	}
>  	return -EINVAL;
>  }
> @@ -1175,6 +1204,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
>  	struct v4l2_format *p = arg;
>  	struct video_device *vfd = video_devdata(file);
>  	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
> +	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
>  	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
>  	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
>  
> @@ -1229,6 +1259,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
>  			break;
>  		CLEAR_AFTER_FIELD(p, fmt.sliced);
>  		return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg);
> +	case V4L2_BUF_TYPE_SDR_CAPTURE:
> +		if (unlikely(!is_rx || !is_sdr || !ops->vidioc_try_fmt_sdr_cap))
> +			break;
> +		CLEAR_AFTER_FIELD(p, fmt.sdr);
> +		return ops->vidioc_try_fmt_sdr_cap(file, fh, arg);
>  	}
>  	return -EINVAL;
>  }
> 


  reply	other threads:[~2013-12-17  7:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16 22:08 [PATCH RFC v3 0/7] SDR API Antti Palosaari
2013-12-16 22:08 ` [PATCH RFC v3 1/7] v4l: add new tuner types for SDR Antti Palosaari
2013-12-17  7:31   ` Hans Verkuil
2013-12-16 22:08 ` [PATCH RFC v3 2/7] v4l: 1 Hz resolution flag for tuners Antti Palosaari
2013-12-17  7:31   ` Hans Verkuil
2013-12-16 22:08 ` [PATCH RFC v3 3/7] v4l: add stream format for SDR receiver Antti Palosaari
2013-12-17  7:32   ` Hans Verkuil
2013-12-16 22:08 ` [PATCH RFC v3 4/7] v4l: define own IOCTL ops for SDR FMT Antti Palosaari
2013-12-17  7:32   ` Hans Verkuil
2013-12-16 22:08 ` [PATCH RFC v3 5/7] v4l: enable some IOCTLs for SDR receiver Antti Palosaari
2013-12-17  7:34   ` Hans Verkuil [this message]
2013-12-17 16:40     ` Antti Palosaari
2013-12-18  7:32       ` Hans Verkuil
2013-12-16 22:08 ` [PATCH RFC v3 6/7] rtl2832_sdr: convert to SDR API Antti Palosaari
2013-12-17  7:45   ` Hans Verkuil
2013-12-19  9:21   ` Hans Verkuil
2013-12-19 16:50     ` Antti Palosaari
2013-12-19 16:59       ` Devin Heitmueller
2013-12-19 18:38         ` Antti Palosaari
2013-12-19 19:12           ` Devin Heitmueller
2013-12-16 22:08 ` [PATCH RFC v3 7/7] msi3101: " Antti Palosaari
2013-12-17  7:36 ` [PATCH RFC v3 0/7] " Hans Verkuil
2013-12-17 16:46   ` 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=52AFFEA3.7010200@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=crope@iki.fi \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.