From patchwork Thu Dec 8 15:24:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 9466583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 132186071E for ; Thu, 8 Dec 2016 15:42:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F004F28501 for ; Thu, 8 Dec 2016 15:42:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E358C28537; Thu, 8 Dec 2016 15:42:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84BB628501 for ; Thu, 8 Dec 2016 15:42:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932371AbcLHPmD (ORCPT ); Thu, 8 Dec 2016 10:42:03 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:58807 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753013AbcLHPlx (ORCPT ); Thu, 8 Dec 2016 10:41:53 -0500 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cF0Yg-0007R6-TS; Thu, 08 Dec 2016 16:24:30 +0100 Received: from mtr by dude.hi.pengutronix.de with local (Exim 4.88) (envelope-from ) id 1cF0Yg-00076z-Mf; Thu, 08 Dec 2016 16:24:30 +0100 From: Michael Tretter To: linux-media@vger.kernel.org Cc: p.zabel@pengutronix.de, Michael Tretter Subject: [PATCH 4/9] [media] coda: correctly set capture compose rectangle Date: Thu, 8 Dec 2016 16:24:11 +0100 Message-Id: <20161208152416.16031-4-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161208152416.16031-1-m.tretter@pengutronix.de> References: <20161208152416.16031-1-m.tretter@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Philipp Zabel Correctly store the rectangle of valid video data in the destination q_data before rounding up to macroblock size. This fixes the output of VIDIOC_G_SELECTION for the capture side compose rectangle. Signed-off-by: Philipp Zabel Signed-off-by: Michael Tretter --- drivers/media/platform/coda/coda-common.c | 37 ++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index c39718a..e0184194 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -566,7 +566,8 @@ static int coda_try_fmt_vid_out(struct file *file, void *priv, return coda_try_fmt(ctx, codec, f); } -static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) +static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f, + struct v4l2_rect *r) { struct coda_q_data *q_data; struct vb2_queue *vq; @@ -589,10 +590,14 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) q_data->height = f->fmt.pix.height; q_data->bytesperline = f->fmt.pix.bytesperline; 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; + if (r) { + q_data->rect = *r; + } else { + 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; + } switch (f->fmt.pix.pixelformat) { case V4L2_PIX_FMT_NV12: @@ -621,27 +626,37 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct coda_ctx *ctx = fh_to_ctx(priv); + struct coda_q_data *q_data_src; + struct v4l2_rect r; int ret; ret = coda_try_fmt_vid_cap(file, priv, f); if (ret) return ret; - return coda_s_fmt(ctx, f); + q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + r.left = 0; + r.top = 0; + r.width = q_data_src->width; + r.height = q_data_src->height; + + return coda_s_fmt(ctx, f, &r); } static int coda_s_fmt_vid_out(struct file *file, void *priv, struct v4l2_format *f) { struct coda_ctx *ctx = fh_to_ctx(priv); + struct coda_q_data *q_data_src; struct v4l2_format f_cap; + struct v4l2_rect r; int ret; ret = coda_try_fmt_vid_out(file, priv, f); if (ret) return ret; - ret = coda_s_fmt(ctx, f); + ret = coda_s_fmt(ctx, f, NULL); if (ret) return ret; @@ -657,7 +672,13 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv, if (ret) return ret; - return coda_s_fmt(ctx, &f_cap); + q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + r.left = 0; + r.top = 0; + r.width = q_data_src->width; + r.height = q_data_src->height; + + return coda_s_fmt(ctx, &f_cap, &r); } static int coda_reqbufs(struct file *file, void *priv,