From patchwork Thu Apr 11 16:12:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10896383 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80888922 for ; Thu, 11 Apr 2019 16:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69EA328D08 for ; Thu, 11 Apr 2019 16:13:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D26E28D29; Thu, 11 Apr 2019 16:13:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 DC1CB28CE2 for ; Thu, 11 Apr 2019 16:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726536AbfDKQNC (ORCPT ); Thu, 11 Apr 2019 12:13:02 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:35626 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbfDKQNC (ORCPT ); Thu, 11 Apr 2019 12:13:02 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 33BD31987; Thu, 11 Apr 2019 18:13:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1554999180; bh=KPQvMQNMlTWgebekcI6Wk/JVOuDQprHQp2ryQLCfewQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0NnIabilR+BDw6LtCm8Na7f5XrID//SK+e3VO2kNonNhqMflSjUFfdSUvx5Zy9If TBsMQVcqO3Q4d7nDC3qwL53d5sFHszK5ozZPq12YUIJEiQPVinxCsLK1lSGP43jSCB LxoGcCBLDQHw6oIxarqCr3dBiVlkaoRy51OLNVBk= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, Laurent Pinchart Cc: Kieran Bingham Subject: [PATCH v3 1/5] media: vsp1: Define partition algorithm helper Date: Thu, 11 Apr 2019 17:12:52 +0100 Message-Id: <20190411161256.19607-2-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> References: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Provide a helper to describe when the partition algorithm is in use on a given pipeline. This improves readability to the purpose of the code, rather than obtusely checking the number of partitions. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- drivers/media/platform/vsp1/vsp1_pipe.c | 8 ++++++++ drivers/media/platform/vsp1/vsp1_pipe.h | 1 + drivers/media/platform/vsp1/vsp1_rpf.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 2 +- drivers/media/platform/vsp1/vsp1_wpf.c | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c index 54ff539ffea0..f1bd21a01bcd 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.c +++ b/drivers/media/platform/vsp1/vsp1_pipe.c @@ -364,6 +364,14 @@ void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, vsp1_uds_set_alpha(pipe->uds, dlb, alpha); } +/* + * Identify if the partition algorithm is in use or not + */ +bool vsp1_pipeline_partitioned(struct vsp1_pipeline *pipe) +{ + return pipe->partitions > 1; +} + /* * Propagate the partition calculations through the pipeline * diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h index ae646c9ef337..dd8b2cdc6452 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.h +++ b/drivers/media/platform/vsp1/vsp1_pipe.h @@ -164,6 +164,7 @@ void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, struct vsp1_dl_body *dlb, unsigned int alpha); +bool vsp1_pipeline_partitioned(struct vsp1_pipeline *pipe); void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe, struct vsp1_partition *partition, unsigned int index, diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c index 616afa7e165f..ef9bf5dd55a0 100644 --- a/drivers/media/platform/vsp1/vsp1_rpf.c +++ b/drivers/media/platform/vsp1/vsp1_rpf.c @@ -269,7 +269,7 @@ static void rpf_configure_partition(struct vsp1_entity *entity, * matching the expected partition window. Only 'left' and * 'width' need to be adjusted. */ - if (pipe->partitions > 1) { + if (vsp1_pipeline_partitioned(pipe)) { crop.width = pipe->partition->rpf.width; crop.left += pipe->partition->rpf.left; } diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 7ceaf3222145..ee2fb8261a6a 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -201,7 +201,7 @@ static void vsp1_video_calculate_partition(struct vsp1_pipeline *pipe, RWPF_PAD_SINK); /* A single partition simply processes the output size in full. */ - if (pipe->partitions <= 1) { + if (!vsp1_pipeline_partitioned(pipe)) { window.left = 0; window.width = format->width; diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c index 32bb207b2007..9e8dbf99878b 100644 --- a/drivers/media/platform/vsp1/vsp1_wpf.c +++ b/drivers/media/platform/vsp1/vsp1_wpf.c @@ -376,7 +376,7 @@ static void wpf_configure_partition(struct vsp1_entity *entity, * Cropping. The partition algorithm can split the image into * multiple slices. */ - if (pipe->partitions > 1) + if (vsp1_pipeline_partitioned(pipe)) width = pipe->partition->wpf.width; vsp1_wpf_write(wpf, dlb, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN | From patchwork Thu Apr 11 16:12:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10896391 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98203922 for ; Thu, 11 Apr 2019 16:13:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 834C528AF8 for ; Thu, 11 Apr 2019 16:13:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77A3428D20; Thu, 11 Apr 2019 16:13:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 334CB28AF8 for ; Thu, 11 Apr 2019 16:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbfDKQNE (ORCPT ); Thu, 11 Apr 2019 12:13:04 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:35636 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbfDKQNE (ORCPT ); Thu, 11 Apr 2019 12:13:04 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E4321A46; Thu, 11 Apr 2019 18:13:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1554999180; bh=pVzxBQdOfPpjj22762q0So46LY7O1Lzn7r+Vt27ALNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PPmV+6FziHhLgeVRKtakQT2tbs3t848G7mxfXXtbOX2e5MLmEUGsPHbX2RJBfaaYp 4sMRTD+JIYm/EKmWV6xRaEqkiGU/nKI3IG2imRwddLK+q0/h6JF3jb821woomHMmJx HxXp5WcYl4bmyhu3vE+YIV4mA8yuZozqeQOTgQUw= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, Laurent Pinchart Cc: Kieran Bingham Subject: [PATCH v3 2/5] media: vsp1: Initialise partition windows Date: Thu, 11 Apr 2019 17:12:53 +0100 Message-Id: <20190411161256.19607-3-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> References: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure that the partition window is correctly initialised before being utilised. Signed-off-by: Kieran Bingham --- drivers/media/platform/vsp1/vsp1_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index ee2fb8261a6a..563f9a02c373 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -189,7 +189,7 @@ static void vsp1_video_calculate_partition(struct vsp1_pipeline *pipe, unsigned int index) { const struct v4l2_mbus_framefmt *format; - struct vsp1_partition_window window; + struct vsp1_partition_window window = { 0, }; unsigned int modulus; /* From patchwork Thu Apr 11 16:12:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10896395 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9CF2922 for ; Thu, 11 Apr 2019 16:13:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAD1828CF0 for ; Thu, 11 Apr 2019 16:13:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF8F328D19; Thu, 11 Apr 2019 16:13:06 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 7326E28D0D for ; Thu, 11 Apr 2019 16:13:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726794AbfDKQNE (ORCPT ); Thu, 11 Apr 2019 12:13:04 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:35638 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbfDKQNE (ORCPT ); Thu, 11 Apr 2019 12:13:04 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EEFD21A4B; Thu, 11 Apr 2019 18:13:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1554999181; bh=2c1wobSbz2WZ7agRjzEAWAPxeWgKbX1redv4gIs+v78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=syEDNl+wtirbUiWWBzIOCB/tSGODGdy2d4il7WoRk71XKoRQRQ9gC5qqFtv+1ogm5 Cf5cmjH2/l5GuPpI2R8lc8nzRs0nMyC0jFKZhLRou+v4v3XHP7WdqlI/6P9BIhquN7 67et8smmLRIYK3Eyt7wTKY8vCVuS41chtuqSAD4Y= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, Laurent Pinchart Cc: Kieran Bingham Subject: [PATCH v3 3/5] media: vsp1: Document partition algorithm in code header Date: Thu, 11 Apr 2019 17:12:54 +0100 Message-Id: <20190411161256.19607-4-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> References: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The image partition algorithm operates on the image dimensions as input into the WPF entity. Document this in the code block header. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- drivers/media/platform/vsp1/vsp1_video.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 563f9a02c373..d1ecc3d91290 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -173,6 +173,14 @@ static int __vsp1_video_try_format(struct vsp1_video *video, /* ----------------------------------------------------------------------------- * VSP1 Partition Algorithm support + * + * VSP hardware can have restrictions on image width dependent on the hardware + * configuration of the pipeline. Adapting for these restrictions is implemented + * via the partition algorithm. + * + * The partition windows and sizes are based on the output size of the WPF + * before rotation, which is represented by the input parameters to the WPF + * entity in our pipeline. */ /** From patchwork Thu Apr 11 16:12:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10896397 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 129651805 for ; Thu, 11 Apr 2019 16:13:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F19CF28BED for ; Thu, 11 Apr 2019 16:13:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFF7228D0D; Thu, 11 Apr 2019 16:13:06 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 9EAFB28BED for ; Thu, 11 Apr 2019 16:13:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726815AbfDKQNG (ORCPT ); Thu, 11 Apr 2019 12:13:06 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:35636 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbfDKQNF (ORCPT ); Thu, 11 Apr 2019 12:13:05 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5F5A41A4C; Thu, 11 Apr 2019 18:13:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1554999181; bh=jdD+5Efy+UtrEF9cneBBj3cLEPhRJLTKJSbwx+BGkfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gn1UWlMXStmDGHF7vuou8VHbiCV3+DZ/oqU9rsIR+0YBZBa/hvPhiqtauHqe0jis2 cxsmP1MPPIaCQB15U77dAlwt1Z/RFyl+uXUtymG1GxVy6/HmGWZv0aDyt9wawxvBwo rBZkhaOnj7O/c0vXgTeXdGpNTXYAiAxm3X/R77Ug= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, Laurent Pinchart Cc: Kieran Bingham Subject: [PATCH v3 4/5] media: vsp1: Split out pre-filter multiplier Date: Thu, 11 Apr 2019 17:12:55 +0100 Message-Id: <20190411161256.19607-5-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> References: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 'mp' value is used through many calculations in determining the scaling factors of the UDS. Factor this out so that it can be reused in further calculations, and also ensure that if the BLADV control is ever changed only a single function needs to be modified. Signed-off-by: Kieran Bingham --- drivers/media/platform/vsp1/vsp1_uds.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c index 27012af973b2..c71c24363d54 100644 --- a/drivers/media/platform/vsp1/vsp1_uds.c +++ b/drivers/media/platform/vsp1/vsp1_uds.c @@ -46,6 +46,18 @@ void vsp1_uds_set_alpha(struct vsp1_entity *entity, struct vsp1_dl_body *dlb, alpha << VI6_UDS_ALPVAL_VAL0_SHIFT); } +/* + * Determine the pre-filter multiplication value. + * + * This calculation assumes that the BLADV control is unset. + */ +static unsigned int uds_multiplier(int ratio) +{ + unsigned int mp = ratio / 4096; + + return mp < 4 ? 1 : (mp < 8 ? 2 : 4); +} + /* * uds_output_size - Return the output size for an input size and scaling ratio * @input: input size in pixels @@ -55,10 +67,7 @@ static unsigned int uds_output_size(unsigned int input, unsigned int ratio) { if (ratio > 4096) { /* Down-scaling */ - unsigned int mp; - - mp = ratio / 4096; - mp = mp < 4 ? 1 : (mp < 8 ? 2 : 4); + unsigned int mp = uds_multiplier(ratio); return (input - 1) / mp * mp * 4096 / ratio + 1; } else { @@ -88,10 +97,7 @@ static unsigned int uds_passband_width(unsigned int ratio) { if (ratio >= 4096) { /* Down-scaling */ - unsigned int mp; - - mp = ratio / 4096; - mp = mp < 4 ? 1 : (mp < 8 ? 2 : 4); + unsigned int mp = uds_multiplier(ratio); return 64 * 4096 * mp / ratio; } else { From patchwork Thu Apr 11 16:12:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10896401 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E7CC922 for ; Thu, 11 Apr 2019 16:13:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6479D28CCA for ; Thu, 11 Apr 2019 16:13:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58DBC28D08; Thu, 11 Apr 2019 16:13:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 3D47628D19 for ; Thu, 11 Apr 2019 16:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726827AbfDKQNH (ORCPT ); Thu, 11 Apr 2019 12:13:07 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:35638 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbfDKQNH (ORCPT ); Thu, 11 Apr 2019 12:13:07 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C0E621A4D; Thu, 11 Apr 2019 18:13:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1554999182; bh=LzOqVAj5RUGUVwEHzm3erKAt3wTqoe6iLXst0N1UAwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gydWNegcU6wjNxUel7G8IvuZ2pNdmoJV/4OC7mvY3CktUQYjn1NnG6o0mbV+v8Fmq lydIsqeedCEvkd/LIDFkHHRwrosGpxtcJeMVZfJOlEovCDeI9k5880CH/ihwvkP1i4 Ojp3gVen/6HLElwdwbWSPk2XieQ2JW7YYdukaazc= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, Laurent Pinchart Cc: Kieran Bingham Subject: [PATCH v3 5/5] media: vsp1: Provide partition overlap algorithm Date: Thu, 11 Apr 2019 17:12:56 +0100 Message-Id: <20190411161256.19607-6-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> References: <20190411161256.19607-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To improve image quality, entities involved within the image partition algorithm may extend their partition window to account for their input requirements and to take consideration of the number of taps in their filters. Extend the partition algorithm to sweep first backwards, then forwards through the entity list. Each entity is given the opportunity to expand it's window on the reverse sweep, and clip or increase the offset on the forwards sweep. Signed-off-by: Kieran Bingham --- v2: - Configure HSTP and HEDP in uds_configure_partition for single partitions - refactored to use individual functions for various phase and position calculations - squashed forwards and backwards propagation work to a single patch - Fixed a few 'off-by-ones' - considerable other changes :) v3a: - SRU comments updated - phase function parameter documentation updated - s/uds_left_src_pixel/uds_left_sink_pixel/ - s/uds_right_src_pixel/uds_right_sink_pixel/ v3b: - A full rework to the UDS overlap and phase calculations - Collapse split calculations into the single uds_partition() function - Document UDS calculations following procedure steps as per datasheet --- drivers/media/platform/vsp1/vsp1_entity.h | 2 +- drivers/media/platform/vsp1/vsp1_pipe.c | 40 +++++++- drivers/media/platform/vsp1/vsp1_pipe.h | 6 ++ drivers/media/platform/vsp1/vsp1_rpf.c | 8 +- drivers/media/platform/vsp1/vsp1_sru.c | 38 ++++++- drivers/media/platform/vsp1/vsp1_uds.c | 115 ++++++++++++++++++++-- drivers/media/platform/vsp1/vsp1_video.c | 1 + drivers/media/platform/vsp1/vsp1_wpf.c | 16 ++- 8 files changed, 207 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h index 97acb7795cf1..772492877764 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.h +++ b/drivers/media/platform/vsp1/vsp1_entity.h @@ -88,7 +88,7 @@ struct vsp1_entity_operations { unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *); void (*partition)(struct vsp1_entity *, struct vsp1_pipeline *, struct vsp1_partition *, unsigned int, - struct vsp1_partition_window *); + struct vsp1_partition_window *, bool); }; struct vsp1_entity { diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c index f1bd21a01bcd..137ebe0ecad2 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.c +++ b/drivers/media/platform/vsp1/vsp1_pipe.c @@ -375,10 +375,32 @@ bool vsp1_pipeline_partitioned(struct vsp1_pipeline *pipe) /* * Propagate the partition calculations through the pipeline * - * Work backwards through the pipe, allowing each entity to update the partition - * parameters based on its configuration, and the entity connected to its - * source. Each entity must produce the partition required for the previous - * entity in the pipeline. + * Work backwards through the pipe, allowing each entity to update the + * partition parameters based on its configuration. Each entity must produce + * the partition window required for the previous entity in the pipeline + * to generate. This window can be passed through if no changes are necessary. + * + * Entities are processed in reverse order: + * DDDD = Destination pixels + * SSSS = Source pixels + * ==== = Intermediate pixels + * ____ = Disposable pixels + * + * WPF |DDDD| WPF determines it's required partition + * SRU |====| Interconnected entities pass through + * UDS(source) |<====>| UDS Source requests overlap + * UDS(sink) |<-|======|->| UDS Sink calculates input size + * RPF |__SSSSSSSS__| RPF provides extra pixels + * + * Then work forwards through the pipe allowing entities to communicate any + * clipping required based on any overlap and expansions they may have + * generated. + * + * RPF |__SSSSSSSS__| Partition window is propagated forwards + * UDS(sink) |============| + * UDS(source) |<====>| UDS Source reports overlap + * SRU |======| Interconnected entities are updated + * WPF |_DDDD_| WPF handles clipping */ void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe, struct vsp1_partition *partition, @@ -387,10 +409,18 @@ void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe, { struct vsp1_entity *entity; + /* Move backwards through the pipeline to propagate any expansion. */ list_for_each_entry_reverse(entity, &pipe->entities, list_pipe) { if (entity->ops->partition) entity->ops->partition(entity, pipe, partition, index, - window); + window, false); + } + + /* Move forwards through the pipeline and propagate any updates. */ + list_for_each_entry(entity, &pipe->entities, list_pipe) { + if (entity->ops->partition) + entity->ops->partition(entity, pipe, partition, index, + window, true); } } diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h index dd8b2cdc6452..3e263a60f79b 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.h +++ b/drivers/media/platform/vsp1/vsp1_pipe.h @@ -58,10 +58,12 @@ enum vsp1_pipeline_state { * @left: horizontal coordinate of the partition start in pixels relative to the * left edge of the image * @width: partition width in pixels + * @offset: The number of pixels from the left edge of the window to clip */ struct vsp1_partition_window { unsigned int left; unsigned int width; + unsigned int offset; }; /* @@ -71,6 +73,8 @@ struct vsp1_partition_window { * @uds_source: The UDS output partition window configuration * @sru: The SRU partition window configuration * @wpf: The WPF partition window configuration + * @start_phase: The UDS start phase for this partition + * @end_phase: The UDS end phase for this partition */ struct vsp1_partition { struct vsp1_partition_window rpf; @@ -78,6 +82,8 @@ struct vsp1_partition { struct vsp1_partition_window uds_source; struct vsp1_partition_window sru; struct vsp1_partition_window wpf; + unsigned int start_phase; + unsigned int end_phase; }; /* diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c index ef9bf5dd55a0..46d270644fe2 100644 --- a/drivers/media/platform/vsp1/vsp1_rpf.c +++ b/drivers/media/platform/vsp1/vsp1_rpf.c @@ -324,9 +324,13 @@ static void rpf_partition(struct vsp1_entity *entity, struct vsp1_pipeline *pipe, struct vsp1_partition *partition, unsigned int partition_idx, - struct vsp1_partition_window *window) + struct vsp1_partition_window *window, + bool forwards) { - partition->rpf = *window; + if (forwards) + *window = partition->rpf; + else + partition->rpf = *window; } static const struct vsp1_entity_operations rpf_entity_ops = { diff --git a/drivers/media/platform/vsp1/vsp1_sru.c b/drivers/media/platform/vsp1/vsp1_sru.c index b1617cb1f2b9..5e6be0bbcf36 100644 --- a/drivers/media/platform/vsp1/vsp1_sru.c +++ b/drivers/media/platform/vsp1/vsp1_sru.c @@ -327,24 +327,58 @@ static void sru_partition(struct vsp1_entity *entity, struct vsp1_pipeline *pipe, struct vsp1_partition *partition, unsigned int partition_idx, - struct vsp1_partition_window *window) + struct vsp1_partition_window *window, + bool forwards) { struct vsp1_sru *sru = to_sru(&entity->subdev); struct v4l2_mbus_framefmt *input; struct v4l2_mbus_framefmt *output; + int scale_up; input = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config, SRU_PAD_SINK); output = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config, SRU_PAD_SOURCE); + scale_up = (input->width != output->width); + + if (forwards) { + /* Propagate the clipping offsets forwards. */ + window->offset += partition->sru.offset; + + if (scale_up) + window->offset *= 2; + + return; + } + /* Adapt if SRUx2 is enabled. */ - if (input->width != output->width) { + if (scale_up) { + /* Clipping offsets are not back-propagated. */ window->width /= 2; window->left /= 2; + + /* SRUx2 requires an extra pixel at the right edge. */ + window->width++; } + /* + * The partition->sru represents the SRU sink pad configuration. + * However, the SRU is a passive component in the partition algorithm. + */ partition->sru = *window; + + /* Expand to the left edge. */ + if (window->left != 0) { + window->left--; + window->width++; + partition->sru.offset = 1; + } else { + partition->sru.offset = 0; + } + + /* Expand to the right edge. */ + window->width++; } static const struct vsp1_entity_operations sru_entity_ops = { diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c index c71c24363d54..33c582aca5a5 100644 --- a/drivers/media/platform/vsp1/vsp1_uds.c +++ b/drivers/media/platform/vsp1/vsp1_uds.c @@ -270,6 +270,7 @@ static void uds_configure_stream(struct vsp1_entity *entity, const struct v4l2_mbus_framefmt *input; unsigned int hscale; unsigned int vscale; + bool manual_phase = vsp1_pipeline_partitioned(pipe); bool multitap; input = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config, @@ -294,7 +295,8 @@ static void uds_configure_stream(struct vsp1_entity *entity, vsp1_uds_write(uds, dlb, VI6_UDS_CTRL, (uds->scale_alpha ? VI6_UDS_CTRL_AON : 0) | - (multitap ? VI6_UDS_CTRL_BC : 0)); + (multitap ? VI6_UDS_CTRL_BC : 0) | + (manual_phase ? VI6_UDS_CTRL_AMDSLH : 0)); vsp1_uds_write(uds, dlb, VI6_UDS_PASS_BWIDTH, (uds_passband_width(hscale) @@ -332,6 +334,12 @@ static void uds_configure_partition(struct vsp1_entity *entity, << VI6_UDS_CLIP_SIZE_HSIZE_SHIFT) | (output->height << VI6_UDS_CLIP_SIZE_VSIZE_SHIFT)); + + vsp1_uds_write(uds, dlb, VI6_UDS_HPHASE, + (partition->start_phase + << VI6_UDS_HPHASE_HSTP_SHIFT) | + (partition->end_phase + << VI6_UDS_HPHASE_HEDP_SHIFT)); } static unsigned int uds_max_width(struct vsp1_entity *entity, @@ -374,11 +382,27 @@ static void uds_partition(struct vsp1_entity *entity, struct vsp1_pipeline *pipe, struct vsp1_partition *partition, unsigned int partition_idx, - struct vsp1_partition_window *window) + struct vsp1_partition_window *window, + bool forwards) { struct vsp1_uds *uds = to_uds(&entity->subdev); const struct v4l2_mbus_framefmt *output; const struct v4l2_mbus_framefmt *input; + unsigned int hscale; + unsigned int margin; + + unsigned int mp; + unsigned int src_left; + unsigned int src_right; + unsigned int dst_left; + unsigned int dst_right; + unsigned int remainder; + + /* For forwards propagation - simply pass on our output. */ + if (forwards) { + *window = partition->uds_source; + return; + } /* Initialise the partition state. */ partition->uds_sink = *window; @@ -389,11 +413,90 @@ static void uds_partition(struct vsp1_entity *entity, output = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config, UDS_PAD_SOURCE); - partition->uds_sink.width = window->width * input->width - / output->width; - partition->uds_sink.left = window->left * input->width - / output->width; + /* + * Quantify the margin required for discontinuous overlap, and expand + * the window no further than the limits of the image. + */ + hscale = uds_compute_ratio(input->width, output->width); + margin = hscale < 0x200 ? 32 : /* 8 < scale */ + hscale < 0x400 ? 16 : /* 4 < scale <= 8 */ + hscale < 0x800 ? 8 : /* 2 < scale <= 4 */ + 4; /* scale <= 2 */ + + dst_left = max_t(int, 0, window->left - margin); + dst_right = min_t(int, output->width - 1, + window->left + window->width - 1 + margin); + + /* + * Identify the sink positions which represent the required output + * positions. This is done in two parts, first converting destination + * to input positions, but then converting back to destination to + * account for any rounding requirements. Once adjusted, the final + * source positions are determined. + */ + + mp = uds_multiplier(hscale); + + /* Step 1: Calculate temporary src_left (src_pos0) position. */ + /* Step 2: Calculate temporary dst_left (dst_pos0_pb) position. */ + if (partition_idx == 0) { + src_left = 0; + dst_left = 0; + } else { + unsigned int sub_src = mp == 1 ? 1 : 2; + + src_left = ((dst_left * hscale) / (4096 * mp) - sub_src) * mp; + dst_left = src_left * 4096 / hscale; + } + + /* + * Step 3: Determine dst_left (dst_pos0_pb) from temporary dst_left. + * + * The output must be aligned to a multiple of the pre-filter + * multiplier. + */ + remainder = (dst_left * hscale) % mp; + if (remainder) + /* Remainder can only be two when mp == 4. */ + dst_left = round_down(dst_left, hscale % mp == 2 ? 2 : mp); + + /* Step 4: Recalculate src_left from newly adjusted dst_left. */ + src_left = DIV_ROUND_UP(dst_left * hscale, 4096 * mp) * mp; + + /* Step 5: Calculate src_right (src_pos1). */ + if (partition_idx == pipe->partitions - 1) + src_right = input->width - 1; + else + src_right = (((dst_right * hscale) / (mp * 4096)) + 2) + * mp + (mp / 2); + + /* Step 6: Calculate start phase (hstp). */ + remainder = (src_left * hscale) % (mp * 4096); + partition->start_phase = remainder ? (4096 - remainder / mp) : 0; + + /* + * Step 7: Calculate end phase (hedp). + * + * We do not currently use VI6_UDS_CTRL_AMD from VI6_UDS_CTRL. + * In the event that we enable VI6_UDS_CTRL_AMD, we must set the end + * phase for the final partition to the phase_edge. + */ + partition->end_phase = 0; + + /* + * Fill in our partition windows with the updated positions, and + * configure our output offset to allow extraneous pixels to be + * clipped by later entities. + */ + partition->uds_sink.left = src_left; + partition->uds_sink.width = src_right - src_left + 1; + + partition->uds_source.left = dst_left; + partition->uds_source.width = dst_right - dst_left + 1; + + partition->uds_source.offset = window->left - dst_left; + /* Pass a copy of our sink down to the previous entity. */ *window = partition->uds_sink; } diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index d1ecc3d91290..3638a4e9bb19 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -221,6 +221,7 @@ static void vsp1_video_calculate_partition(struct vsp1_pipeline *pipe, /* Initialise the partition with sane starting conditions. */ window.left = index * div_size; window.width = div_size; + window.offset = 0; modulus = format->width % div_size; diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c index 9e8dbf99878b..2e8cc4195c31 100644 --- a/drivers/media/platform/vsp1/vsp1_wpf.c +++ b/drivers/media/platform/vsp1/vsp1_wpf.c @@ -371,16 +371,19 @@ static void wpf_configure_partition(struct vsp1_entity *entity, RWPF_PAD_SINK); width = sink_format->width; height = sink_format->height; + offset = 0; /* * Cropping. The partition algorithm can split the image into * multiple slices. */ - if (vsp1_pipeline_partitioned(pipe)) + if (vsp1_pipeline_partitioned(pipe)) { width = pipe->partition->wpf.width; + offset = pipe->partition->wpf.offset; + } vsp1_wpf_write(wpf, dlb, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN | - (0 << VI6_WPF_SZCLIP_OFST_SHIFT) | + (offset << VI6_WPF_SZCLIP_OFST_SHIFT) | (width << VI6_WPF_SZCLIP_SIZE_SHIFT)); vsp1_wpf_write(wpf, dlb, VI6_WPF_VSZCLIP, VI6_WPF_SZCLIP_EN | (0 << VI6_WPF_SZCLIP_OFST_SHIFT) | @@ -491,8 +494,15 @@ static void wpf_partition(struct vsp1_entity *entity, struct vsp1_pipeline *pipe, struct vsp1_partition *partition, unsigned int partition_idx, - struct vsp1_partition_window *window) + struct vsp1_partition_window *window, + bool forwards) { + if (forwards) { + /* Only handle incoming cropping requirements. */ + partition->wpf.offset = window->offset; + return; + } + partition->wpf = *window; }