All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Philipp Zabel <p.zabel@pengutronix.de>, linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Kamil Debski <k.debski@samsung.com>,
	Fabio Estevam <fabio.estevam@freescale.com>,
	kernel@pengutronix.de
Subject: Re: [PATCH v2 08/29] [media] coda: add selection API support for h.264 decoder
Date: Fri, 27 Jun 2014 10:58:19 +0200	[thread overview]
Message-ID: <53AD322B.8030201@xs4all.nl> (raw)
In-Reply-To: <1403621771-11636-9-git-send-email-p.zabel@pengutronix.de>

Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

On 06/24/2014 04:55 PM, Philipp Zabel wrote:
> The h.264 decoder produces capture frames that are a multiple of the macroblock
> size (16 pixels). To inform userspace about invalid pixel data at the edges,
> use the active and padded composing rectangles on the capture queue.
> The cropping information is obtained from the h.264 sequence parameter set.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> Changes since v1:
>   - Rewrote g_selection to only allow CROP target on OUTPUT and
>     COMPOSE target on CAPTURE buffers.
> ---
>   drivers/media/platform/coda.c | 94 +++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 94 insertions(+)
>
> diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
> index f00b2aa..965b0d9 100644
> --- a/drivers/media/platform/coda.c
> +++ b/drivers/media/platform/coda.c
> @@ -119,6 +119,7 @@ struct coda_q_data {
>   	unsigned int		height;
>   	unsigned int		sizeimage;
>   	unsigned int		fourcc;
> +	struct v4l2_rect	rect;
>   };
>
>   struct coda_aux_buf {
> @@ -735,6 +736,10 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f)
>   	q_data->width = f->fmt.pix.width;
>   	q_data->height = f->fmt.pix.height;
>   	q_data->sizeimage = f->fmt.pix.sizeimage;
> +	q_data->rect.left = 0;
> +	q_data->rect.top = 0;
> +	q_data->rect.width = f->fmt.pix.width;
> +	q_data->rect.height = f->fmt.pix.height;
>
>   	v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
>   		"Setting format for type %d, wxh: %dx%d, fmt: %d\n",
> @@ -871,6 +876,50 @@ static int coda_streamoff(struct file *file, void *priv,
>   	return ret;
>   }
>
> +static int coda_g_selection(struct file *file, void *fh,
> +			    struct v4l2_selection *s)
> +{
> +	struct coda_ctx *ctx = fh_to_ctx(fh);
> +	struct coda_q_data *q_data;
> +	struct v4l2_rect r, *rsel;
> +
> +	q_data = get_q_data(ctx, s->type);
> +	if (!q_data)
> +		return -EINVAL;
> +
> +	r.left = 0;
> +	r.top = 0;
> +	r.width = q_data->width;
> +	r.height = q_data->height;
> +	rsel = &q_data->rect;
> +
> +	switch (s->target) {
> +	case V4L2_SEL_TGT_CROP_DEFAULT:
> +	case V4L2_SEL_TGT_CROP_BOUNDS:
> +		rsel = &r;
> +		/* fallthrough */
> +	case V4L2_SEL_TGT_CROP:
> +		if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
> +			return -EINVAL;
> +		break;
> +	case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> +	case V4L2_SEL_TGT_COMPOSE_PADDED:
> +		rsel = &r;
> +		/* fallthrough */
> +	case V4L2_SEL_TGT_COMPOSE:
> +	case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> +		if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +			return -EINVAL;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	s->r = *rsel;
> +
> +	return 0;
> +}
> +
>   static int coda_try_decoder_cmd(struct file *file, void *fh,
>   				struct v4l2_decoder_cmd *dc)
>   {
> @@ -949,6 +998,8 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
>   	.vidioc_streamon	= coda_streamon,
>   	.vidioc_streamoff	= coda_streamoff,
>
> +	.vidioc_g_selection	= coda_g_selection,
> +
>   	.vidioc_try_decoder_cmd	= coda_try_decoder_cmd,
>   	.vidioc_decoder_cmd	= coda_decoder_cmd,
>
> @@ -1504,6 +1555,10 @@ static void set_default_params(struct coda_ctx *ctx)
>   	ctx->q_data[V4L2_M2M_DST].width = max_w;
>   	ctx->q_data[V4L2_M2M_DST].height = max_h;
>   	ctx->q_data[V4L2_M2M_DST].sizeimage = CODA_MAX_FRAME_SIZE;
> +	ctx->q_data[V4L2_M2M_SRC].rect.width = max_w;
> +	ctx->q_data[V4L2_M2M_SRC].rect.height = max_h;
> +	ctx->q_data[V4L2_M2M_DST].rect.width = max_w;
> +	ctx->q_data[V4L2_M2M_DST].rect.height = max_h;
>
>   	if (ctx->dev->devtype->product == CODA_960)
>   		coda_set_tiled_map_type(ctx, GDI_LINEAR_FRAME_MAP);
> @@ -2031,6 +2086,21 @@ static int coda_start_decoding(struct coda_ctx *ctx)
>   		return -EINVAL;
>   	}
>
> +	if (src_fourcc == V4L2_PIX_FMT_H264) {
> +		u32 left_right;
> +		u32 top_bottom;
> +
> +		left_right = coda_read(dev, CODA_RET_DEC_SEQ_CROP_LEFT_RIGHT);
> +		top_bottom = coda_read(dev, CODA_RET_DEC_SEQ_CROP_TOP_BOTTOM);
> +
> +		q_data_dst->rect.left = (left_right >> 10) & 0x3ff;
> +		q_data_dst->rect.top = (top_bottom >> 10) & 0x3ff;
> +		q_data_dst->rect.width = width - q_data_dst->rect.left -
> +					 (left_right & 0x3ff);
> +		q_data_dst->rect.height = height - q_data_dst->rect.top -
> +					  (top_bottom & 0x3ff);
> +	}
> +
>   	ret = coda_alloc_framebuffers(ctx, q_data_dst, src_fourcc);
>   	if (ret < 0)
>   		return ret;
> @@ -2937,6 +3007,30 @@ static void coda_finish_decode(struct coda_ctx *ctx)
>
>   	q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
>
> +	/* frame crop information */
> +	if (src_fourcc == V4L2_PIX_FMT_H264) {
> +		u32 left_right;
> +		u32 top_bottom;
> +
> +		left_right = coda_read(dev, CODA_RET_DEC_PIC_CROP_LEFT_RIGHT);
> +		top_bottom = coda_read(dev, CODA_RET_DEC_PIC_CROP_TOP_BOTTOM);
> +
> +		if (left_right == 0xffffffff && top_bottom == 0xffffffff) {
> +			/* Keep current crop information */
> +		} else {
> +			struct v4l2_rect *rect = &q_data_dst->rect;
> +
> +			rect->left = left_right >> 16 & 0xffff;
> +			rect->top = top_bottom >> 16 & 0xffff;
> +			rect->width = width - rect->left -
> +				      (left_right & 0xffff);
> +			rect->height = height - rect->top -
> +				       (top_bottom & 0xffff);
> +		}
> +	} else {
> +		/* no cropping */
> +	}
> +
>   	val = coda_read(dev, CODA_RET_DEC_PIC_ERR_MB);
>   	if (val > 0)
>   		v4l2_err(&dev->v4l2_dev,
>

  reply	other threads:[~2014-06-27  8:58 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24 14:55 [PATCH v2 00/29] Initial CODA960 (i.MX6 VPU) support Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 01/29] [media] coda: fix decoder I/P/B frame detection Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 02/29] [media] coda: fix readback of CODA_RET_DEC_SEQ_FRAME_NEED Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 03/29] [media] coda: fix h.264 quantization parameter range Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 04/29] [media] coda: fix internal framebuffer allocation size Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 05/29] [media] coda: simplify IRAM setup Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 06/29] [media] coda: Add encoder/decoder support for CODA960 Philipp Zabel
2014-06-24 16:16   ` Nicolas Dufresne
2014-07-01 17:53     ` Philipp Zabel
2014-07-02 13:37       ` Kamil Debski
2014-07-02 19:16         ` Robert Schwebel
2014-07-11 12:33           ` Robert Schwebel
2014-07-11 12:53             ` Fabio Estevam
2014-07-21  7:07             ` Robert Schwebel
2014-07-25 12:27               ` Fabio Estevam
2014-08-14  7:15               ` Robert Schwebel
2014-06-24 14:55 ` [PATCH v2 07/29] [media] coda: remove BUG() in get_q_data Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 08/29] [media] coda: add selection API support for h.264 decoder Philipp Zabel
2014-06-27  8:58   ` Hans Verkuil [this message]
2014-06-24 14:55 ` [PATCH v2 09/29] [media] coda: add workqueue to serialize hardware commands Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 10/29] [media] coda: Use mem-to-mem ioctl helpers Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 11/29] [media] coda: use ctx->fh.m2m_ctx instead of ctx->m2m_ctx Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 12/29] [media] coda: Add runtime pm support Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 13/29] [media] coda: split firmware version check out of coda_hw_init Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 14/29] [media] coda: select GENERIC_ALLOCATOR Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 15/29] [media] coda: add h.264 min/max qp controls Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 16/29] [media] coda: add h.264 deblocking filter controls Philipp Zabel
2014-06-24 14:55 ` [PATCH v2 17/29] [media] coda: add cyclic intra refresh control Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 18/29] [media] v4l2-mem2mem: export v4l2_m2m_try_schedule Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 19/29] [media] coda: try to schedule a decode run after a stop command Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 20/29] [media] coda: add decoder timestamp queue Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 21/29] [media] coda: alert userspace about macroblock errors Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 22/29] [media] coda: add sequence counter offset Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 23/29] [media] coda: use prescan_failed variable to stop stream after a timeout Philipp Zabel
2014-07-02 12:58   ` Kamil Debski
2014-07-02 13:43     ` Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 24/29] [media] coda: add reset control support Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 25/29] [media] coda: add bytesperline to queue data Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 26/29] [media] coda: allow odd width, but still round up bytesperline Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 27/29] [media] coda: round up internal frames to multiples of macroblock size for h.264 Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 28/29] [media] coda: increase frame stride to 16 " Philipp Zabel
2014-06-24 14:56 ` [PATCH v2 29/29] [media] coda: export auxiliary buffers via debugfs Philipp Zabel

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=53AD322B.8030201@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=fabio.estevam@freescale.com \
    --cc=k.debski@samsung.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=p.zabel@pengutronix.de \
    /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.