All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH v14 10/33] rcar-vin: all Gen2 boards can scale simplify logic
Date: Sat, 14 Apr 2018 13:57:03 +0200	[thread overview]
Message-ID: <20180414115726.5075-11-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20180414115726.5075-1-niklas.soderlund+renesas@ragnatech.se>

The logic to preserve the requested format width and height are too
complex and come from a premature optimization for Gen3. All Gen2 SoC
can scale and the Gen3 implementation will not use these functions at
all so simply preserve the width and height when interacting with the
subdevice much like the field is preserved simplifies the logic quite a
bit.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/platform/rcar-vin/rcar-dma.c  |  8 --------
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 25 +++++++++++--------------
 drivers/media/platform/rcar-vin/rcar-vin.h  |  2 --
 3 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index 23120901b0a062ed..4f48575f2008fe34 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -585,14 +585,6 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
 		0, 0);
 }
 
-void rvin_scale_try(struct rvin_dev *vin, struct v4l2_pix_format *pix,
-		    u32 width, u32 height)
-{
-	/* All VIN channels on Gen2 have scalers */
-	pix->width = width;
-	pix->height = height;
-}
-
 /* -----------------------------------------------------------------------------
  * Hardware setup
  */
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 8805d7911a761019..c2265324c7c96308 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -166,6 +166,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 		.which = which,
 	};
 	enum v4l2_field field;
+	u32 width, height;
 	int ret;
 
 	sd = vin_to_source(vin);
@@ -178,7 +179,10 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 
 	format.pad = vin->digital->source_pad;
 
+	/* Allow the video device to override field and to scale */
 	field = pix->field;
+	width = pix->width;
+	height = pix->height;
 
 	ret = v4l2_subdev_call(sd, pad, set_fmt, pad_cfg, &format);
 	if (ret < 0 && ret != -ENOIOCTLCMD)
@@ -186,11 +190,13 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 
 	v4l2_fill_pix_format(pix, &format.format);
 
-	pix->field = field;
-
 	source->width = pix->width;
 	source->height = pix->height;
 
+	pix->field = field;
+	pix->width = width;
+	pix->height = height;
+
 	vin_dbg(vin, "Source resolution: %ux%u\n", source->width,
 		source->height);
 
@@ -204,13 +210,9 @@ static int __rvin_try_format(struct rvin_dev *vin,
 			     struct v4l2_pix_format *pix,
 			     struct rvin_source_fmt *source)
 {
-	u32 rwidth, rheight, walign;
+	u32 walign;
 	int ret;
 
-	/* Requested */
-	rwidth = pix->width;
-	rheight = pix->height;
-
 	/* Keep current field if no specific one is asked for */
 	if (pix->field == V4L2_FIELD_ANY)
 		pix->field = vin->format.field;
@@ -248,10 +250,6 @@ static int __rvin_try_format(struct rvin_dev *vin,
 		break;
 	}
 
-	/* If source can't match format try if VIN can scale */
-	if (source->width != rwidth || source->height != rheight)
-		rvin_scale_try(vin, pix, rwidth, rheight);
-
 	/* HW limit width to a multiple of 32 (2^5) for NV16 else 2 (2^1) */
 	walign = vin->format.pixelformat == V4L2_PIX_FMT_NV16 ? 5 : 1;
 
@@ -270,9 +268,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
 		return -EINVAL;
 	}
 
-	vin_dbg(vin, "Requested %ux%u Got %ux%u bpl: %d size: %d\n",
-		rwidth, rheight, pix->width, pix->height,
-		pix->bytesperline, pix->sizeimage);
+	vin_dbg(vin, "Format %ux%u bpl: %d size: %d\n",
+		pix->width, pix->height, pix->bytesperline, pix->sizeimage);
 
 	return 0;
 }
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h
index 8d135ed3f7abd855..1c91b774205a7750 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -175,8 +175,6 @@ void rvin_v4l2_unregister(struct rvin_dev *vin);
 const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat);
 
 /* Cropping, composing and scaling */
-void rvin_scale_try(struct rvin_dev *vin, struct v4l2_pix_format *pix,
-		    u32 width, u32 height);
 void rvin_crop_scale_comp(struct rvin_dev *vin);
 
 #endif
-- 
2.16.2

  parent reply	other threads:[~2018-04-14 11:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-14 11:56 [PATCH v14 00/33] rcar-vin: Add Gen3 with media controller Niklas Söderlund
2018-04-14 11:56 ` [PATCH v14 01/33] dt-bindings: media: rcar_vin: Reverse SoC part number list Niklas Söderlund
2018-04-14 11:56 ` [PATCH v14 02/33] dt-bindings: media: rcar_vin: add device tree support for r8a774[35] Niklas Söderlund
2018-04-14 11:56 ` [PATCH v14 03/33] rcar-vin: add Gen3 devicetree bindings documentation Niklas Söderlund
2018-05-02 13:10   ` Geert Uytterhoeven
2018-04-14 11:56 ` [PATCH v14 04/33] rcar-vin: rename poorly named initialize and cleanup functions Niklas Söderlund
2018-04-14 11:56 ` [PATCH v14 05/33] rcar-vin: unregister video device on driver removal Niklas Söderlund
2018-04-14 11:56 ` [PATCH v14 06/33] rcar-vin: move subdevice handling to async callbacks Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 07/33] rcar-vin: move model information to own struct Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 08/33] rcar-vin: move max width and height information to chip information Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 09/33] rcar-vin: move functions regarding scaling Niklas Söderlund
2018-04-14 11:57 ` Niklas Söderlund [this message]
2018-04-14 11:57 ` [PATCH v14 11/33] rcar-vin: set a default field to fallback on Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 12/33] rcar-vin: fix handling of single field frames (top, bottom and alternate fields) Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 13/33] rcar-vin: update bytesperline and sizeimage calculation Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 14/33] rcar-vin: align pixelformat check Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 15/33] rcar-vin: break out format alignment and checking Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 16/33] rcar-vin: simplify how formats are set and reset Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 17/33] rcar-vin: cache video standard Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 18/33] rcar-vin: move media bus configuration to struct rvin_dev Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 19/33] rcar-vin: enable Gen3 hardware configuration Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 20/33] rcar-vin: add function to manipulate Gen3 chsel value Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 21/33] rcar-vin: add flag to switch to media controller mode Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 22/33] rcar-vin: use different v4l2 operations in " Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 23/33] rcar-vin: force default colorspace for media centric mode Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 24/33] rcar-vin: prepare for media controller mode initialization Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 25/33] rcar-vin: add group allocator functions Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 26/33] rcar-vin: change name of video device Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 27/33] rcar-vin: add chsel information to rvin_info Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 28/33] rcar-vin: parse Gen3 OF and setup media graph Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 29/33] rcar-vin: add link notify for Gen3 Niklas Söderlund
2019-04-05 14:17   ` [PATCH v14,29/33] " Eugeniu Rosca
2019-04-05 14:34     ` Niklas Söderlund
2019-04-05 14:45       ` Eugeniu Rosca
2018-04-14 11:57 ` [PATCH v14 30/33] rcar-vin: extend {start,stop}_streaming to work with media controller Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 31/33] rcar-vin: enable support for r8a7795 Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 32/33] rcar-vin: enable support for r8a7796 Niklas Söderlund
2018-04-14 11:57 ` [PATCH v14 33/33] rcar-vin: enable support for r8a77970 Niklas Söderlund

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=20180414115726.5075-11-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=hverkuil@xs4all.nl \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@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.