From patchwork Mon Feb 28 11:28:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12763037 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BD2EC433F5 for ; Mon, 28 Feb 2022 11:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbiB1L36 (ORCPT ); Mon, 28 Feb 2022 06:29:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbiB1L35 (ORCPT ); Mon, 28 Feb 2022 06:29:57 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A0C4889E for ; Mon, 28 Feb 2022 03:29:19 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 47F1C478; Mon, 28 Feb 2022 12:29:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1646047756; bh=A12Awla9mAwZyn65Ew655XVtPW6OJJRb9obRl53wovs=; h=From:To:Cc:Subject:Date:From; b=mqKaUD1yW+Dz8vRRD5XzytL4z9IgTF3oLwGv+ZSpKND2hp9SegzIBkMSfYLpsyrrO 6/vlAAVk5AbGg0lgbP+Wj2Fe9zycigaG9GaGH4JFxxVUTP4Ibs0No/67okSSFFIPPg FHrbNiZcmt/Ib7GR2u/kHX3v0uXS7aKEELHLP44c= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham Subject: [PATCH 1/3] tests: Add SPDX headers to vsp-unit-test-0026.sh Date: Mon, 28 Feb 2022 13:28:59 +0200 Message-Id: <20220228112901.21289-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org vsp-unit-test-0026.sh is missing SPDX headers. Add them. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- tests/vsp-unit-test-0026.sh | 2 ++ 1 file changed, 2 insertions(+) base-commit: 2e98a1bf774bc8516aa8027411a2fd511e52561c diff --git a/tests/vsp-unit-test-0026.sh b/tests/vsp-unit-test-0026.sh index 0e013cec881b..36ed0b03469b 100755 --- a/tests/vsp-unit-test-0026.sh +++ b/tests/vsp-unit-test-0026.sh @@ -1,4 +1,6 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2020 Renesas Electronics Corporation # # Test unbinding and binding all VSP1 devices, performing a simple From patchwork Mon Feb 28 11:29:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12763038 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A451AC433FE for ; Mon, 28 Feb 2022 11:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbiB1L36 (ORCPT ); Mon, 28 Feb 2022 06:29:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbiB1L36 (ORCPT ); Mon, 28 Feb 2022 06:29:58 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41BF74889F for ; Mon, 28 Feb 2022 03:29:19 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 020CF486; Mon, 28 Feb 2022 12:29:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1646047757; bh=OUGD9ggTa2f/Ra39FQdgedH7he+PcLGql8gvuMySD3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YpOyzso6jaT3OhsfvnzEYnDqDoS0gCuD645x0qfV3If/0eG1e40h4ZUe9SdwYJTjO 3haC2wF7NymB08Q2x+82hsqyRFw+CCYb9pkk0g8wKaSAsYf8N6pEQ+HM0Afzwiu/b1 CeooIh9i3/FjZMxc8ZvYFU2729ejm7UjgeuqM+yg= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham Subject: [PATCH 2/3] gen-image: Crop input image before format conversion to YUV Date: Mon, 28 Feb 2022 13:29:00 +0200 Message-Id: <20220228112901.21289-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220228112901.21289-1-laurent.pinchart@ideasonboard.com> References: <20220228112901.21289-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org When converting the input image to a subsampled YUV format, chroma components are averaged horizontally to emulate the VSP internal conversion to YUV444. If the image is subsequently cropped to emulate the RPF cropping, the edge chroma values end up effectively taking into account pixels outside of the crop rectangle. This doesn't match the hardware mode of operation which crops the image when reading it through DMA, before performing any other operation. Fix this by cropping the image just after reading it, before format conversion. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/gen-image.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/gen-image.c b/src/gen-image.c index d9f92253af46..170d69490399 100644 --- a/src/gen-image.c +++ b/src/gen-image.c @@ -1531,6 +1531,23 @@ static int process(const struct options *options) goto done; } + /* Crop */ + if (options->crop) { + struct image *cropped; + + cropped = image_new(format_by_name("RGB24"), + options->inputcrop.width, + options->inputcrop.height); + if (!cropped) { + ret = -ENOMEM; + goto done; + } + + image_crop(input, cropped, &options->inputcrop); + image_delete(input); + input = cropped; + } + /* Convert colorspace */ if (options->input_format->type == FORMAT_YUV) { struct image *yuv; @@ -1561,22 +1578,6 @@ static int process(const struct options *options) input = rgb; } - /* Crop */ - if (options->crop) { - struct image *cropped; - - cropped = image_new(input->format, options->inputcrop.width, - options->inputcrop.height); - if (!cropped) { - ret = -ENOMEM; - goto done; - } - - image_crop(input, cropped, &options->inputcrop); - image_delete(input); - input = cropped; - } - /* Scale */ if (options->output_width && options->output_height) { output_width = options->output_width; From patchwork Mon Feb 28 11:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12763039 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBA61C433F5 for ; Mon, 28 Feb 2022 11:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbiB1LaB (ORCPT ); Mon, 28 Feb 2022 06:30:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbiB1LaA (ORCPT ); Mon, 28 Feb 2022 06:30:00 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBC4A49270 for ; Mon, 28 Feb 2022 03:29:21 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 743D5A67; Mon, 28 Feb 2022 12:29:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1646047757; bh=gxRu9R+pUzKq+Yi0XgfngHHUGhm5bjhN6VHzTBg0n/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oJ+pyC4B4wjcZ2xiToGp+9Jtp7c4ZKEgOQH4CIFgKbk38ji65wPeS7gPzVprDkIxb iCnxfgiw5ia4175uM/lZ0HknwBobETl+5XeIN9jpBbb5C9dnNf/ZLlbn1II505cdy8 IMWnHpreBcYDeKf7S//7ZUOKoVQQ0CSp/ny0mEnk= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham Subject: [PATCH 3/3] tests: Add RPF cropping test for YUV formats Date: Mon, 28 Feb 2022 13:29:01 +0200 Message-Id: <20220228112901.21289-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220228112901.21289-1-laurent.pinchart@ideasonboard.com> References: <20220228112901.21289-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org YUV formats can be subsampled, which interact with cropping. Add a test to verify that the VSP driver handles this correctly. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- tests/vsp-unit-test-0027.sh | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 tests/vsp-unit-test-0027.sh diff --git a/tests/vsp-unit-test-0027.sh b/tests/vsp-unit-test-0027.sh new file mode 100755 index 000000000000..8be8ae736375 --- /dev/null +++ b/tests/vsp-unit-test-0027.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2017-2022 Renesas Electronics Corporation + +# +# Test RPF crop using multiplanar YUV formats, test buffer offset calculation +# with subsampling. Use a RPF -> WPF pipeline, passing a selection of cropping +# windows. +# + +. ./vsp-lib.sh + +features="rpf.0 wpf.0" +crops="(0,0)/512x384 (32,32)/512x384 (32,64)/512x384 (64,32)/512x384" +formats="NV12M NV16M YUV420M YUV422M YUV444M" + +test_rpf_cropping() { + local format=$1 + local crop=$2 + + test_start "RPF crop from $crop in $format" + + pipe_configure rpf-wpf 0 0 + format_configure rpf-wpf 0 0 $format 1024x768 YUV444M --rpfcrop=$crop + + vsp_runner rpf.0 & + vsp_runner wpf.0 + + local result=$(compare_frames crop=${crop}) + + test_complete $result +} + +test_main() { + local crop + local format + + for format in $formats ; do + for crop in $crops ; do + test_rpf_cropping $format $crop + done + done +} + +test_init $0 "$features" +test_run