linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benoit Parrot <bparrot@ti.com>
To: Hans Verkuil <hverkuil@xs4all.nl>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Rob Herring <robh+dt@kernel.org>
Cc: <linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Benoit Parrot <bparrot@ti.com>
Subject: [RESEND Patch v3 17/20] media: ti-vpe: cal: Properly calculate max resolution boundary
Date: Tue, 12 Nov 2019 08:53:44 -0600	[thread overview]
Message-ID: <20191112145347.23519-18-bparrot@ti.com> (raw)
In-Reply-To: <20191112145347.23519-1-bparrot@ti.com>

Currently we were using an arbitrarily small maximum resolution mostly
based on available sensor capabilities. However the hardware DMA limits
are much higher than the statically define maximum resolution we were
using.

There we rework the boundary check code to handle the maximum width and
height based on the maximum line width in bytes and re-calculating the
pixel width based on the given pixel format.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
---
 drivers/media/platform/ti-vpe/cal.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 5b5ff32b6120..091119bee8fc 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -34,8 +34,8 @@
 
 #define CAL_MODULE_NAME "cal"
 
-#define MAX_WIDTH 1920
-#define MAX_HEIGHT 1200
+#define MAX_WIDTH_BYTES (8192 * 8)
+#define MAX_HEIGHT_LINES 16383
 
 #define CAL_VERSION "0.1.0"
 
@@ -1330,15 +1330,21 @@ static int cal_calc_format_size(struct cal_ctx *ctx,
 				const struct cal_fmt *fmt,
 				struct v4l2_format *f)
 {
-	u32 bpl;
+	u32 bpl, max_width;
 
 	if (!fmt) {
 		ctx_dbg(3, ctx, "No cal_fmt provided!\n");
 		return -EINVAL;
 	}
 
-	v4l_bound_align_image(&f->fmt.pix.width, 48, MAX_WIDTH, 2,
-			      &f->fmt.pix.height, 32, MAX_HEIGHT, 0, 0);
+	/*
+	 * Maximum width is bound by the DMA max width in bytes.
+	 * We need to recalculate the actual maxi width depending on the
+	 * number of bytes per pixels required.
+	 */
+	max_width = MAX_WIDTH_BYTES / (ALIGN(fmt->bpp, 8) >> 3);
+	v4l_bound_align_image(&f->fmt.pix.width, 48, max_width, 2,
+			      &f->fmt.pix.height, 32, MAX_HEIGHT_LINES, 0, 0);
 
 	bpl = (f->fmt.pix.width * ALIGN(fmt->bpp, 8)) >> 3;
 	f->fmt.pix.bytesperline = ALIGN(bpl, 16);
-- 
2.17.1


  parent reply	other threads:[~2019-11-12 14:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 14:53 [RESEND Patch v3 00/20] media: ti-vpe: cal: maintenance Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 01/20] dt-bindings: media: cal: update binding to use syscon Benoit Parrot
2019-11-18 17:39   ` Rob Herring
2019-11-12 14:53 ` [RESEND Patch v3 02/20] dt-bindings: media: cal: update binding example Benoit Parrot
2019-11-18 17:40   ` Rob Herring
2019-11-12 14:53 ` [RESEND Patch v3 03/20] media: ti-vpe: cal: switch BIT_MASK to BIT Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 04/20] media: ti-vpe: cal: Add per platform data support Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 05/20] media: ti-vpe: cal: Enable DMABUF export Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 06/20] media: ti-vpe: cal: Restrict DMA to avoid memory corruption Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 07/20] dt-bindings: media: cal: update binding to add PHY LDO errata support Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 08/20] media: ti-vpe: cal: add CSI2 " Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 09/20] media: ti-vpe: cal: Fix ths_term/ths_settle parameters Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 10/20] media: ti-vpe: cal: Fix pixel processing parameters Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 11/20] media: ti-vpe: cal: Align DPHY init sequence with docs Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 12/20] dt-bindings: media: cal: update binding to add DRA76x support Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 13/20] media: ti-vpe: cal: Add " Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 14/20] dt-bindings: media: cal: update binding to add AM654 support Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 15/20] media: ti-vpe: cal: Add " Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 16/20] media: ti-vpe: cal: Add subdev s_power hooks Benoit Parrot
2019-11-12 14:53 ` Benoit Parrot [this message]
2019-11-12 14:53 ` [RESEND Patch v3 18/20] media: ti-vpe: cal: Fix a WARN issued when start streaming fails Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 19/20] media: ti-vpe: cal: fix enum_mbus_code/frame_size subdev arguments Benoit Parrot
2019-11-12 14:53 ` [RESEND Patch v3 20/20] dt-bindings: media: cal: convert binding to yaml Benoit Parrot
2019-11-18 17:47   ` Rob Herring

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=20191112145347.23519-18-bparrot@ti.com \
    --to=bparrot@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).