All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCH 3/3] ivtv: setup per-device caps.
Date: Fri, 25 Nov 2011 09:00:31 -0200	[thread overview]
Message-ID: <4ECF754F.3090207@redhat.com> (raw)
In-Reply-To: <a74598d6964e8582de02d3cfbc22d52fc000d033.1321956058.git.hans.verkuil@cisco.com>

Em 22-11-2011 08:05, Hans Verkuil escreveu:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/video/ivtv/ivtv-driver.h  |    1 +
>  drivers/media/video/ivtv/ivtv-ioctl.c   |    7 +++++--
>  drivers/media/video/ivtv/ivtv-streams.c |   14 ++++++++++++++
>  3 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
> index 8f9cc17..06b9efd 100644
> --- a/drivers/media/video/ivtv/ivtv-driver.h
> +++ b/drivers/media/video/ivtv/ivtv-driver.h
> @@ -331,6 +331,7 @@ struct ivtv_stream {
>  	struct ivtv *itv; 		/* for ease of use */
>  	const char *name;		/* name of the stream */
>  	int type;			/* stream type */
> +	u32 caps;			/* V4L2 capabilities */
>  
>  	u32 id;
>  	spinlock_t qlock; 		/* locks access to the queues */
> diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
> index ecafa69..6be63e9 100644
> --- a/drivers/media/video/ivtv/ivtv-ioctl.c
> +++ b/drivers/media/video/ivtv/ivtv-ioctl.c
> @@ -752,12 +752,15 @@ static int ivtv_s_register(struct file *file, void *fh, struct v4l2_dbg_register
>  
>  static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vcap)
>  {
> -	struct ivtv *itv = fh2id(fh)->itv;
> +	struct ivtv_open_id *id = fh2id(file->private_data);
> +	struct ivtv *itv = id->itv;
> +	struct ivtv_stream *s = &itv->streams[id->type];
>  
>  	strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
>  	strlcpy(vcap->card, itv->card_name, sizeof(vcap->card));
>  	snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(itv->pdev));
> -	vcap->capabilities = itv->v4l2_cap; 	    /* capabilities */
> +	vcap->capabilities = itv->v4l2_cap | V4L2_CAP_DEVICE_CAPS;

IMO, the right thing to do here would be:

	vcap->capabilities = V4L2_CAP_DEVICE_CAPS;
	for (i = 0; i < ARRAY_SIZE(ivtv_stream_info); i++)
		vcap->capabilities |= ivtv_stream_info[v4l2_caps];

This avoids the risk of future patches adding new device_caps at the devices, but
forgetting to update the physical device capabilities.

Also, as the initial patches will be used as implementation reference by others,
such implementation will be more effective than a "magic" set of features that
may or may not match the union of all device capabilities.

> +	vcap->device_caps = s->caps;
>  	return 0;
>  }
>  
> diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
> index e7794dc..4d4ae6e 100644
> --- a/drivers/media/video/ivtv/ivtv-streams.c
> +++ b/drivers/media/video/ivtv/ivtv-streams.c
> @@ -78,60 +78,73 @@ static struct {
>  	int num_offset;
>  	int dma, pio;
>  	enum v4l2_buf_type buf_type;
> +	u32 v4l2_caps;
>  	const struct v4l2_file_operations *fops;
>  } ivtv_stream_info[] = {
>  	{	/* IVTV_ENC_STREAM_TYPE_MPG */
>  		"encoder MPG",
>  		VFL_TYPE_GRABBER, 0,
>  		PCI_DMA_FROMDEVICE, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE,
> +		V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER |
> +			V4L2_CAP_AUDIO | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_enc_fops
>  	},
>  	{	/* IVTV_ENC_STREAM_TYPE_YUV */
>  		"encoder YUV",
>  		VFL_TYPE_GRABBER, IVTV_V4L2_ENC_YUV_OFFSET,
>  		PCI_DMA_FROMDEVICE, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE,
> +		V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER |
> +			V4L2_CAP_AUDIO | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_enc_fops
>  	},
>  	{	/* IVTV_ENC_STREAM_TYPE_VBI */
>  		"encoder VBI",
>  		VFL_TYPE_VBI, 0,
>  		PCI_DMA_FROMDEVICE, 0, V4L2_BUF_TYPE_VBI_CAPTURE,
> +		V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_TUNER |
> +			V4L2_CAP_AUDIO | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_enc_fops
>  	},
>  	{	/* IVTV_ENC_STREAM_TYPE_PCM */
>  		"encoder PCM",
>  		VFL_TYPE_GRABBER, IVTV_V4L2_ENC_PCM_OFFSET,
>  		PCI_DMA_FROMDEVICE, 0, V4L2_BUF_TYPE_PRIVATE,
> +		V4L2_CAP_TUNER | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_enc_fops
>  	},
>  	{	/* IVTV_ENC_STREAM_TYPE_RAD */
>  		"encoder radio",
>  		VFL_TYPE_RADIO, 0,
>  		PCI_DMA_NONE, 1, V4L2_BUF_TYPE_PRIVATE,
> +		V4L2_CAP_RADIO | V4L2_CAP_TUNER,
>  		&ivtv_v4l2_enc_fops
>  	},
>  	{	/* IVTV_DEC_STREAM_TYPE_MPG */
>  		"decoder MPG",
>  		VFL_TYPE_GRABBER, IVTV_V4L2_DEC_MPG_OFFSET,
>  		PCI_DMA_TODEVICE, 0, V4L2_BUF_TYPE_VIDEO_OUTPUT,
> +		V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_dec_fops
>  	},
>  	{	/* IVTV_DEC_STREAM_TYPE_VBI */
>  		"decoder VBI",
>  		VFL_TYPE_VBI, IVTV_V4L2_DEC_VBI_OFFSET,
>  		PCI_DMA_NONE, 1, V4L2_BUF_TYPE_VBI_CAPTURE,
> +		V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_enc_fops
>  	},
>  	{	/* IVTV_DEC_STREAM_TYPE_VOUT */
>  		"decoder VOUT",
>  		VFL_TYPE_VBI, IVTV_V4L2_DEC_VOUT_OFFSET,
>  		PCI_DMA_NONE, 1, V4L2_BUF_TYPE_VBI_OUTPUT,
> +		V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_dec_fops
>  	},
>  	{	/* IVTV_DEC_STREAM_TYPE_YUV */
>  		"decoder YUV",
>  		VFL_TYPE_GRABBER, IVTV_V4L2_DEC_YUV_OFFSET,
>  		PCI_DMA_TODEVICE, 0, V4L2_BUF_TYPE_VIDEO_OUTPUT,
> +		V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE,
>  		&ivtv_v4l2_dec_fops
>  	}
>  };
> @@ -149,6 +162,7 @@ static void ivtv_stream_init(struct ivtv *itv, int type)
>  	s->itv = itv;
>  	s->type = type;
>  	s->name = ivtv_stream_info[type].name;
> +	s->caps = ivtv_stream_info[type].v4l2_caps;
>  
>  	if (ivtv_stream_info[type].pio)
>  		s->dma = PCI_DMA_NONE;


  reply	other threads:[~2011-11-25 11:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 10:05 [PATCH 0/3] Add per-device-node capabilities Hans Verkuil
2011-11-22 10:05 ` [PATCH 1/3] V4L2: " Hans Verkuil
2011-11-22 10:05   ` [PATCH 2/3] vivi: set device_caps Hans Verkuil
2011-11-25 10:53     ` Mauro Carvalho Chehab
2011-11-25 11:18       ` Hans Verkuil
2011-11-22 10:05   ` [PATCH 3/3] ivtv: setup per-device caps Hans Verkuil
2011-11-25 11:00     ` Mauro Carvalho Chehab [this message]
2011-11-25 11:29       ` Hans Verkuil
2011-11-25 11:55         ` Mauro Carvalho Chehab
2011-11-25 10:51   ` [PATCH 1/3] V4L2: Add per-device-node capabilities Mauro Carvalho Chehab
2011-11-25 11:14     ` Hans Verkuil

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=4ECF754F.3090207@redhat.com \
    --to=mchehab@redhat.com \
    --cc=hans.verkuil@cisco.com \
    --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 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.