mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Helen Koike <helen.koike@collabora.com>
To: "André Almeida" <andrealmeid@collabora.com>, linux-media@vger.kernel.org
Cc: mchehab@kernel.org, hverkuil@xs4all.nl, lucmaga@gmail.com,
	linux-kernel@vger.kernel.org, kernel@collabora.com,
	lkcamp@lists.libreplanetbr.org
Subject: Re: [PATCH v2 08/15] media: vimc: cap: Add multiplanar default format
Date: Fri, 12 Apr 2019 19:49:31 -0300	[thread overview]
Message-ID: <9f3290ab-c0d0-a56a-c6dc-64b1b791fa6c@collabora.com> (raw)
In-Reply-To: <20190327151743.18528-9-andrealmeid@collabora.com>



On 3/27/19 12:17 PM, André Almeida wrote:
> vimc already have a default single planar default format.

The word "default" is repeated twice.

> Add a multiplanar default pixel format to perform those
> same actions. Change where the default pixelformat is set to make sure
> that the vcap is with the right capabilities.
> 
> Signed-off-by: André Almeida <andrealmeid@collabora.com>
> ---
> Change in v2:
> - Move here the default format is set to verify if the device have a
> multiplanar capability before assign the default format
> 
>  drivers/media/platform/vimc/vimc-capture.c | 38 +++++++++++++++++-----
>  1 file changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c
> index a65611be63bb..c344d04ed8ea 100644
> --- a/drivers/media/platform/vimc/vimc-capture.c
> +++ b/drivers/media/platform/vimc/vimc-capture.c
> @@ -104,6 +104,15 @@ static const struct v4l2_format fmt_default = {
>  	.fmt.pix.colorspace = V4L2_COLORSPACE_DEFAULT,
>  };
>  
> +static const struct v4l2_format fmt_default_mp = {

I would just add a "_sp" sufix to the sp version to make it consistent
with previous patches.

> +	.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
> +	.fmt.pix_mp.width = 640,
> +	.fmt.pix_mp.height = 480,
> +	.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_YVU420M,
> +	.fmt.pix_mp.field = V4L2_FIELD_NONE,
> +	.fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT,
> +};
> +
>  struct vimc_cap_buffer {
>  	/*
>  	 * struct vb2_v4l2_buffer must be the first element
> @@ -153,6 +162,7 @@ static int _vimc_cap_try_fmt_vid_cap_mp(struct file *file, void *priv,
>  				    struct v4l2_format *f)
>  {
>  	struct v4l2_pix_format_mplane *format = &f->fmt.pix_mp;
> +	struct vimc_cap_device *vcap = video_drvdata(file);
>  
>  	format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH,
>  				VIMC_FRAME_MAX_WIDTH) & ~1;
> @@ -168,7 +178,9 @@ static int _vimc_cap_try_fmt_vid_cap_mp(struct file *file, void *priv,
>  
>  	/* Don't accept a pixelformat that is not on the table */
>  	if (!v4l2_format_info(format->pixelformat))
> -		format->pixelformat = fmt_default.fmt.pix.pixelformat;
> +		format->pixelformat = IS_MULTIPLANAR(vcap) ?
> +				fmt_default_mp.fmt.pix_mp.pixelformat :
> +				fmt_default.fmt.pix.pixelformat;
>  
>  	return v4l2_fill_pixfmt_mp(format, format->pixelformat,
>  				   format->width, format->height);
> @@ -651,13 +663,6 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master,
>  	INIT_LIST_HEAD(&vcap->buf_list);
>  	spin_lock_init(&vcap->qlock);
>  
> -	/* Set default frame format */
> -	vcap->format = fmt_default;
> -	v4l2_fill_pixfmt(&vcap->format.fmt.pix,
> -			 vcap->format.fmt.pix.pixelformat,
> -			 vcap->format.fmt.pix.width,
> -			 vcap->format.fmt.pix.height);
> -
>  	/* Fill the vimc_ent_device struct */
>  	vcap->ved.ent = &vcap->vdev.entity;
>  	vcap->ved.process_frame = vimc_cap_process_frame;
> @@ -679,6 +684,23 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master,
>  	strscpy(vdev->name, pdata->entity_name, sizeof(vdev->name));
>  	video_set_drvdata(vdev, &vcap->ved);
>  
> +	dev_dbg(vcap->dev, "vimc-capture is in %s mode", IS_MULTIPLANAR(vcap) ?
> +		"multiplanar" : "singleplanar");

I think if you put the check in the second line it would be better:

IS_MULTIPLANAR(vcap) ? "multiplanar" : "singleplanar"

(this is just a suggestion, feel free to take it or not).

Helen

> +
> +	if (IS_MULTIPLANAR(vcap)) {
> +		vcap->format = fmt_default_mp;
> +		v4l2_fill_pixfmt_mp(&vcap->format.fmt.pix_mp,
> +				vcap->format.fmt.pix_mp.pixelformat,
> +				vcap->format.fmt.pix_mp.width,
> +				vcap->format.fmt.pix_mp.height);
> +	} else {
> +		vcap->format = fmt_default;
> +		v4l2_fill_pixfmt(&vcap->format.fmt.pix,
> +				vcap->format.fmt.pix.pixelformat,
> +				vcap->format.fmt.pix.width,
> +				vcap->format.fmt.pix.height);
> +	}
> +
>  	/* Register the video_device with the v4l2 and the media framework */
>  	ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
>  	if (ret) {
> 

  reply	other threads:[~2019-04-12 22:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27 15:17 [PATCH v2 00/15] media: vimc: Add support for multiplanar formats André Almeida
2019-03-27 15:17 ` [PATCH v2 01/15] media: Move sp2mp functions to v4l2-common André Almeida
2019-04-12 22:48   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 02/15] media: vimc: Remove unnecessary stream checks André Almeida
2019-04-12 22:48   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 03/15] media: vimc: cap: Change vimc_cap_device.format type André Almeida
2019-04-12 22:48   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 04/15] media: vimc: cap: Dynamically define stream pixelformat André Almeida
2019-04-12 22:48   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 05/15] media: vimc: cap: Add handler for singleplanar fmt ioctls André Almeida
2019-04-12 22:48   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 06/15] media: vimc: cap: Add handler for multiplanar " André Almeida
2019-03-27 15:17 ` [PATCH v2 07/15] media: vimc: cap: Add multiplanar formats André Almeida
2019-04-12 22:49   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 08/15] media: vimc: cap: Add multiplanar default format André Almeida
2019-04-12 22:49   ` Helen Koike [this message]
2019-03-27 15:17 ` [PATCH v2 09/15] media: vimc: cap: Allocate and verify mplanar buffers André Almeida
2019-04-12 22:49   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 10/15] media: vimc: Propagate multiplanar state in the stream André Almeida
2019-04-12 22:50   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 11/15] media: vimc: Add and use new struct vimc_frame André Almeida
2019-04-16 15:17   ` Helen Koike
2019-03-27 15:17 ` [PATCH v2 12/15] media: vimc: sen: Add support for multiplanar formats André Almeida
2019-03-27 15:17 ` [PATCH v2 13/15] media: vimc: sca: " André Almeida
2019-03-27 15:17 ` [PATCH v2 14/15] media: vimc: cap: " André Almeida
2019-03-27 15:17 ` [PATCH v2 15/15] media: vimc: Create multiplanar parameter André Almeida
2019-04-12 22:50   ` Helen Koike

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=9f3290ab-c0d0-a56a-c6dc-64b1b791fa6c@collabora.com \
    --to=helen.koike@collabora.com \
    --cc=andrealmeid@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=lkcamp@lists.libreplanetbr.org \
    --cc=lucmaga@gmail.com \
    --cc=mchehab@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

all inboxes | Powered by JetHome®