From patchwork Wed Apr 9 00:47:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043887 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 667FA4C80 for ; Wed, 9 Apr 2025 00:48:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159709; cv=none; b=qyiVDgiEzSvnGnuXVb0iIhMVzy3CjZhCSgNNF5NgWPVPbUDP2TFNXA9UbzVsl3OSfZVPVKiQSYo4p9RyGO4SU8jDHilQLagENvVM2gbOrK1rSUtgudZVdZqwmjPtydCPXsxP+bB5MxATlXGJPLFtf32/6KuVqKxZbC06H4mqBPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159709; c=relaxed/simple; bh=R8K/2v2kmOdNSN3bjDCEgDtnK7X4aLzqbLS+KDdvCJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HXNXKPSkVir4ckxRjyanVRgAkQpT7maz0rwLU/LiAg8zCXer7N4+2vCjzZrO1pyypbxqX7zjxlgrIGuzEkHNsk+YQ/hGTC7PaqRFLFxichqbAyTqAm1IZ5rtQoxmTUASY/ZdtiCO2egKtnr/xpQyQ8cu/6X1HznWfJl5vLtCQsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=G0ti2c/k; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="G0ti2c/k" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B342C83D; Wed, 9 Apr 2025 02:46:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159587; bh=R8K/2v2kmOdNSN3bjDCEgDtnK7X4aLzqbLS+KDdvCJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0ti2c/k6DTCU0M/ohszQKFF8MtkFjP3g5YYCs9csbbFIUouZRDvY/bC7XeDLBoIR 4M55xxetM5qBTYjoEnpiP5jAoYSPlvQdxOs+sI8Ho5slfBNhXhRfb4ojf3VHDvdOg2 6yLVlzpJ7cxs3YvENSCIk/ImmPHRrpXaDK6eE8uI= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 01/16] gen-lut.py: Replace tabs with spaces Date: Wed, 9 Apr 2025 03:47:43 +0300 Message-ID: <20250409004758.11014-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Python source code is typically indented with 4 spaces instead of tabs. Update gen-lut.py accordingly. Signed-off-by: Laurent Pinchart --- data/frames/gen-lut.py | 100 ++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/data/frames/gen-lut.py b/data/frames/gen-lut.py index 335b9f1613bc..c3591f90c2d3 100755 --- a/data/frames/gen-lut.py +++ b/data/frames/gen-lut.py @@ -6,79 +6,79 @@ import math import sys clu_configs = ( - ('zero', { - 'scale': 0.0, - 'a': 0.0, - 'freq': 1.0, - 'weights': (1.0, 1.0, 1.0) - } ), - ('identity', { - 'scale': 1.0, - 'a': 0.0, - 'freq': 1.0, - 'weights': (1.0, 1.0, 1.0) - } ), - # Keep the three weights different to generate an anisothropic - # look up table. - ('wave', { - 'scale': 1.0, - 'a': 0.1, - 'freq': 3.0, - 'weights': (1.0, 2.0, 3.0) - } ), + ('zero', { + 'scale': 0.0, + 'a': 0.0, + 'freq': 1.0, + 'weights': (1.0, 1.0, 1.0) + } ), + ('identity', { + 'scale': 1.0, + 'a': 0.0, + 'freq': 1.0, + 'weights': (1.0, 1.0, 1.0) + } ), + # Keep the three weights different to generate an anisothropic + # look up table. + ('wave', { + 'scale': 1.0, + 'a': 0.1, + 'freq': 3.0, + 'weights': (1.0, 2.0, 3.0) + } ), ) lut_configs = ( - ('zero', 0.0, 1.0, 1.0, 1.0), - ('identity', 1.0, 1.0, 1.0, 1.0), - ('gamma', 1.0, 0.5, 1.0, 2.0), + ('zero', 0.0, 1.0, 1.0, 1.0), + ('identity', 1.0, 1.0, 1.0, 1.0), + ('gamma', 1.0, 0.5, 1.0, 2.0), ) def clu_value(x, y, z, scale, a, freq, weights): - x = x / 16. - y = y / 16. - z = z / 16. + x = x / 16. + y = y / 16. + z = z / 16. - dist = math.sqrt((x*x*weights[0] + y*y*weights[1] + z*z*weights[2]) / 3. / sum(weights)) - offset = a * math.sin(dist * freq * 2 * math.pi) + dist = math.sqrt((x*x*weights[0] + y*y*weights[1] + z*z*weights[2]) / 3. / sum(weights)) + offset = a * math.sin(dist * freq * 2 * math.pi) - x = max(0, min(255, int((x*scale + offset) * 256))) - y = max(0, min(255, int((y*scale + offset) * 256))) - z = max(0, min(255, int((z*scale + offset) * 256))) + x = max(0, min(255, int((x*scale + offset) * 256))) + y = max(0, min(255, int((y*scale + offset) * 256))) + z = max(0, min(255, int((z*scale + offset) * 256))) - return (z, y, x, 0) + return (z, y, x, 0) def generate_clu(config): - clu = bytearray() + clu = bytearray() - for z in range(17): - for y in range(17): - for x in range(17): - clu.extend(clu_value(x, y, z, **config[1])) + for z in range(17): + for y in range(17): + for x in range(17): + clu.extend(clu_value(x, y, z, **config[1])) - open('clu-%s.bin' % config[0], 'wb').write(clu) + open('clu-%s.bin' % config[0], 'wb').write(clu) def gamma(vin, gamma, scale): - return int(255 * scale * math.pow(vin / 255., gamma)) + return int(255 * scale * math.pow(vin / 255., gamma)) def generate_lut(config): - lut = bytearray() - for i in range(256): - lut.extend([gamma(i, g, config[1]) for g in config[2:]]) - lut.append(0) + lut = bytearray() + for i in range(256): + lut.extend([gamma(i, g, config[1]) for g in config[2:]]) + lut.append(0) - open('lut-%s.bin' % config[0], 'wb').write(lut) + open('lut-%s.bin' % config[0], 'wb').write(lut) def main(argv): - for config in clu_configs: - generate_clu(config) + for config in clu_configs: + generate_clu(config) - for config in lut_configs: - generate_lut(config) + for config in lut_configs: + generate_lut(config) - return 0 + return 0 if __name__ == '__main__': - sys.exit(main(sys.argv)) + sys.exit(main(sys.argv)) From patchwork Wed Apr 9 00:47:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043888 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44D954C80 for ; Wed, 9 Apr 2025 00:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159711; cv=none; b=RYSwVspVnbmeK6WqeRWMhDKRodSddWu5G67Z/yMn/CdfUmTODNA4sDUTLZHur+3myfmKzwV0WL4s2togu4hR3etPEk2DFtKA2B7RdBizxHWMbu/nKwhxKxEMpw1zXZjqCy1hWy6pnW27kl8XzvcKUVJYioSlpPndum+BcOOtiYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159711; c=relaxed/simple; bh=Q3gGfKPEzJ+TUo2dOUVWjv1STFaeURFs0JSF/A1gPxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KM8JrQM3MKG8JRiQNZHD7pBPg/TozmcXo8vpkq1aEa06pVBkQ8oTKiUaQRteBOrm4UG/N6EZFbI/kQxIDdrBQvtItcfb1L+E0mG40WbQKW+RZ3K3cyEA1Ha9VralcOXfDUA065SmZfQ5BsqGbfWL6W5tRF8yWp1O+GF/YTEnpi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=QlECgrwR; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QlECgrwR" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0FA7799F; Wed, 9 Apr 2025 02:46:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159589; bh=Q3gGfKPEzJ+TUo2dOUVWjv1STFaeURFs0JSF/A1gPxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QlECgrwRGjGosh0pUReC8IqxLpST7ektRRzaNhUInuDx3qyMLbaxwK5gkCQWtH4QN ztg2G5dcSY3SDEzaLJSvXIMYWESyONhM6PA8W92IEVYTZtejxD5OtEPccmVIlEB3z1 T7mtV2Qcxapt/S4b8iilT1K3OSeiFKaGiAezuJ2o= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 02/16] Convert from make to meson Date: Wed, 9 Apr 2025 03:47:44 +0300 Message-ID: <20250409004758.11014-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Meson makes cross compilation easier. Replace the make-based build system with meson. Signed-off-by: Laurent Pinchart --- data/frames/.gitignore => .gitignore | 2 +- Makefile | 14 ------- README | 8 ++-- data/Makefile | 14 ------- data/frames/Makefile | 17 --------- data/frames/gen-lut.py | 56 +++++++++++++++++----------- data/frames/meson.build | 28 ++++++++++++++ src/.gitignore => data/meson.build | 4 +- meson.build | 36 ++++++++++++++++++ scripts/Makefile | 10 ----- scripts/meson.build | 11 ++++++ src/Makefile | 29 -------------- src/meson.build | 21 +++++++++++ tests/Makefile | 10 ----- tests/meson.build | 34 +++++++++++++++++ 15 files changed, 172 insertions(+), 122 deletions(-) rename data/frames/.gitignore => .gitignore (81%) delete mode 100644 Makefile delete mode 100644 data/Makefile delete mode 100644 data/frames/Makefile create mode 100644 data/frames/meson.build rename src/.gitignore => data/meson.build (57%) create mode 100644 meson.build delete mode 100644 scripts/Makefile create mode 100644 scripts/meson.build delete mode 100644 src/Makefile create mode 100644 src/meson.build delete mode 100644 tests/Makefile create mode 100644 tests/meson.build diff --git a/data/frames/.gitignore b/.gitignore similarity index 81% rename from data/frames/.gitignore rename to .gitignore index 2c0a1ff3d654..e06192977743 100644 --- a/data/frames/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: CC0-1.0 -*.bin +/build/ diff --git a/Makefile b/Makefile deleted file mode 100644 index 4d311e1b84a9..000000000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 - -SUBDIRS=data scripts src tests - -recursive=all clean install - -all: - -$(recursive): - @target=$@ ; \ - for subdir in $(SUBDIRS); do \ - echo "Making $$target in $$subdir" ; \ - $(MAKE) -C $$subdir $$target; \ - done diff --git a/README b/README index e45d03a0e944..d4211d742afa 100644 --- a/README +++ b/README @@ -20,16 +20,18 @@ The vsp-tests suite requires the following tools to be installed on the host to generate the test scripts, applications and data. * gcc -* make +* meson +* ninja * python After installing the needed packages, you can build the test suite by running - make + meson setup build/ + meson compile -C build/ in the vsp-tests root directory. Then, to install the test suite, run - make install INSTALL_DIR=/path/to/target/directory + meson install -C build/ --destdir=/path/to/target/directory This will copy the test scripts and applications to the target directory to be copied or exported to the host. diff --git a/data/Makefile b/data/Makefile deleted file mode 100644 index a65b5bcdc4e4..000000000000 --- a/data/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 - -SUBDIRS=frames - -recursive=all clean install - -all: - -$(recursive): - @target=$@ ; \ - for subdir in $(SUBDIRS); do \ - echo "Making $$target in $$subdir" ; \ - $(MAKE) -C $$subdir $$target; \ - done diff --git a/data/frames/Makefile b/data/frames/Makefile deleted file mode 100644 index 026cbdd53eed..000000000000 --- a/data/frames/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 - -frames=$(patsubst %.pnm.gz,%.pnm,$(wildcard *.pnm.gz)) - -all: - ./gen-lut.py - -clean: - @rm -f *.bin - -%.pnm: %.pnm.gz - gzip -dk $< - -install: $(frames) - mkdir -p $(INSTALL_DIR)/frames/ - mv $(frames) $(INSTALL_DIR)/frames/ - cp *.bin $(INSTALL_DIR)/frames/ diff --git a/data/frames/gen-lut.py b/data/frames/gen-lut.py index c3591f90c2d3..bd371a483c05 100755 --- a/data/frames/gen-lut.py +++ b/data/frames/gen-lut.py @@ -2,37 +2,38 @@ # SPDX-License-Identifier: GPL-2.0-or-later # SPDX-FileCopyrightText: 2016 Renesas Electronics Corporation +import argparse import math import sys -clu_configs = ( - ('zero', { +clu_configs = { + 'zero': { 'scale': 0.0, 'a': 0.0, 'freq': 1.0, 'weights': (1.0, 1.0, 1.0) - } ), - ('identity', { + }, + 'identity': { 'scale': 1.0, 'a': 0.0, 'freq': 1.0, 'weights': (1.0, 1.0, 1.0) - } ), + }, # Keep the three weights different to generate an anisothropic # look up table. - ('wave', { + 'wave': { 'scale': 1.0, 'a': 0.1, 'freq': 3.0, 'weights': (1.0, 2.0, 3.0) - } ), -) + }, +} -lut_configs = ( - ('zero', 0.0, 1.0, 1.0, 1.0), - ('identity', 1.0, 1.0, 1.0, 1.0), - ('gamma', 1.0, 0.5, 1.0, 2.0), -) +lut_configs = { + 'zero': (0.0, 1.0, 1.0, 1.0), + 'identity': (1.0, 1.0, 1.0, 1.0), + 'gamma': (1.0, 0.5, 1.0, 2.0), +} def clu_value(x, y, z, scale, a, freq, weights): x = x / 16. @@ -54,9 +55,9 @@ def generate_clu(config): for z in range(17): for y in range(17): for x in range(17): - clu.extend(clu_value(x, y, z, **config[1])) + clu.extend(clu_value(x, y, z, **config)) - open('clu-%s.bin' % config[0], 'wb').write(clu) + return clu def gamma(vin, gamma, scale): @@ -65,18 +66,31 @@ def gamma(vin, gamma, scale): def generate_lut(config): lut = bytearray() for i in range(256): - lut.extend([gamma(i, g, config[1]) for g in config[2:]]) + lut.extend([gamma(i, g, config[0]) for g in config[1:]]) lut.append(0) - open('lut-%s.bin' % config[0], 'wb').write(lut) + return lut def main(argv): - for config in clu_configs: - generate_clu(config) + # Parse command line arguments + parser = argparse.ArgumentParser() + parser.add_argument('--output', '-o', metavar='file', type=str, + help='Output file name. Defaults to standard output if not specified.') + parser.add_argument('--type', '-t', dest='table_type', type=str, required=True, + choices=['clu', 'lut'], help='Select the look up table type.') + parser.add_argument('table', type=str, + help='Table contents') + args = parser.parse_args(argv[1:]) - for config in lut_configs: - generate_lut(config) + out = open(args.output, 'wb') + + if args.table_type == 'clu': + table = generate_clu(clu_configs[args.table]) + else: + table = generate_lut(lut_configs[args.table]) + + out.write(table) return 0 diff --git a/data/frames/meson.build b/data/frames/meson.build new file mode 100644 index 000000000000..f4ec8e30bdac --- /dev/null +++ b/data/frames/meson.build @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: CC0-1.0 + +gen_lut = find_program('./gen-lut.py') +gzip = find_program('gzip') + +tables = [ + ['clu', 'identity'], + ['clu', 'wave'], + ['clu', 'zero'], + ['lut', 'gamma'], + ['lut', 'identity'], + ['lut', 'zero'], +] + +foreach table : tables + name = '@0@-@1@.bin'.format(table[0], table[1]) + custom_target(output : name, + command : [gen_lut, '-o', '@OUTPUT@', '-t', table[0], table[1]], + install : true, + install_dir : 'frames') +endforeach + +custom_target(input : files('frame-reference-1024x768.pnm.gz'), + output : 'frame-reference-1024x768.pnm', + capture : true, + command : [gzip, '-cd', '@INPUT@'], + install : true, + install_dir : 'frames') diff --git a/src/.gitignore b/data/meson.build similarity index 57% rename from src/.gitignore rename to data/meson.build index 817142c8a3e8..2171e041a8cb 100644 --- a/src/.gitignore +++ b/data/meson.build @@ -1,5 +1,3 @@ # SPDX-License-Identifier: CC0-1.0 -*.o -gen-image -monotonic-ts +subdir('frames') diff --git a/meson.build b/meson.build new file mode 100644 index 000000000000..026bc0d29187 --- /dev/null +++ b/meson.build @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: CC0-1.0 + +project('vsp-tests', 'c', + meson_version : '>= 0.60', + version : '0.0.0', + default_options : [ + 'werror=true', + 'warning_level=2', + ], + license : 'GPL 2.0+') + +# +# Configure the build environment +# +cc = meson.get_compiler('c') + +cc_arguments = [ + '-Wno-unused-parameter', +] + +if cc.get_id() == 'clang' + # Turn _FORTIFY_SOURCE by default on optimised builds (as it requires -O1 + # or higher). This is needed on clang only as gcc enables it by default. + if get_option('optimization') != '0' + cc_arguments += [ + '-D_FORTIFY_SOURCE=2', + ] + endif +endif + +add_project_arguments(cc_arguments, language : 'c') + +subdir('data') +subdir('scripts') +subdir('src') +subdir('tests') diff --git a/scripts/Makefile b/scripts/Makefile deleted file mode 100644 index 6511c3c61ebf..000000000000 --- a/scripts/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 - -SCRIPTS=$(wildcard *.sh) - -all: - -clean: - -install: - cp $(SCRIPTS) $(INSTALL_DIR)/ diff --git a/scripts/meson.build b/scripts/meson.build new file mode 100644 index 000000000000..a86f1a568f6b --- /dev/null +++ b/scripts/meson.build @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: CC0-1.0 + +scripts = files([ + 'bin2png.sh', + 'histo2png.py', + 'logger.sh', + 'vsp-lib.sh', + 'vsp-tests.sh', +]) + +install_data(scripts, install_dir : get_option('prefix')) diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index c40e95afca50..000000000000 --- a/src/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 - -CROSS_COMPILE ?= - -CC := $(CROSS_COMPILE)gcc -CFLAGS ?= -O0 -g -W -Wall -Wno-unused-parameter -Iinclude -LDFLAGS ?= -LIBS := -lm -GEN-IMAGE := gen-image -MONOTONIC-TS := monotonic-ts - -%.o : %.c - $(CC) $(CFLAGS) -c -o $@ $< - -all: $(GEN-IMAGE) $(MONOTONIC-TS) - -$(GEN-IMAGE): gen-image.o - $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) - -$(MONOTONIC-TS): monotonic-ts.o - $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) - -clean: - -rm -f *.o - -rm -f $(GEN-IMAGE) $(MONOTONIC_TS) - -install: - cp $(GEN-IMAGE) $(INSTALL_DIR)/ - cp $(MONOTONIC-TS) $(INSTALL_DIR)/ diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000000..3a6118bd3ea8 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: CC0-1.0 + +gen_image_sources = files([ + 'gen-image.c', +]) + +monotonic_ts_sources = files([ + 'monotonic-ts.c', +]) + +m_dep = cc.find_library('m', required : false) + +executable('gen-image', gen_image_sources, + dependencies : [m_dep], + install : true, + install_dir : '') + +executable('monotonic-ts', monotonic_ts_sources, + dependencies : [m_dep], + install : true, + install_dir : '') diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 6511c3c61ebf..000000000000 --- a/tests/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: CC0-1.0 - -SCRIPTS=$(wildcard *.sh) - -all: - -clean: - -install: - cp $(SCRIPTS) $(INSTALL_DIR)/ diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 000000000000..e5396cc0a132 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: CC0-1.0 + +tests = files([ + 'vsp-unit-test-0000.sh', + 'vsp-unit-test-0001.sh', + 'vsp-unit-test-0002.sh', + 'vsp-unit-test-0003.sh', + 'vsp-unit-test-0004.sh', + 'vsp-unit-test-0005.sh', + 'vsp-unit-test-0006.sh', + 'vsp-unit-test-0007.sh', + 'vsp-unit-test-0008.sh', + 'vsp-unit-test-0009.sh', + 'vsp-unit-test-0010.sh', + 'vsp-unit-test-0011.sh', + 'vsp-unit-test-0012.sh', + 'vsp-unit-test-0013.sh', + 'vsp-unit-test-0014.sh', + 'vsp-unit-test-0015.sh', + 'vsp-unit-test-0016.sh', + 'vsp-unit-test-0017.sh', + 'vsp-unit-test-0018.sh', + 'vsp-unit-test-0019.sh', + 'vsp-unit-test-0020.sh', + 'vsp-unit-test-0021.sh', + 'vsp-unit-test-0022.sh', + 'vsp-unit-test-0023.sh', + 'vsp-unit-test-0024.sh', + 'vsp-unit-test-0025.sh', + 'vsp-unit-test-0026.sh', + 'vsp-unit-test-0027.sh', +]) + +install_data(tests, install_dir : get_option('prefix')) From patchwork Wed Apr 9 00:47:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043889 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0A163595C for ; Wed, 9 Apr 2025 00:48:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159712; cv=none; b=EG5gIu2FarOT2n1dLiC4eX7Co3d58ZBVs/pkQvgG6fmOgaL5YVyV6YNGE1e4VLf0Jw6gxqilMfoRbIsTDwmJbLkZJkvDqsWiQ/3OjfWveR40gLjXxPZJXDPY6tVxHobiNCTKQUsUQXaF/JUDJATf3RSpBBd/vyXs8WZugh3134k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159712; c=relaxed/simple; bh=x24Hb95DOle7mCiLoNQD0yOncyC59IPEGKYsCu+Mb8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bEs+fdIhiCTjTjUvcX38XqGLIkQGzUXyycsx8Trfqk+X4TuBI4RaPoelk6cYAm8JpJySc2bzNiVkpuqqa3rI6CFNiXwvJ5RIascVIRvV6zURTMv5Z4qJQESKWcHPQCnlIEpRm7n0Od3cHCbDVba/ogWDIquoQXMJaRPeprRzVDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=PN/LzKae; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PN/LzKae" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 61B32A98; Wed, 9 Apr 2025 02:46:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159590; bh=x24Hb95DOle7mCiLoNQD0yOncyC59IPEGKYsCu+Mb8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PN/LzKaejYid0jGaOHKKw+rrArlANIiDlEu/R4JkftHGcUsEmxC0ZnidyufSsH/i0 ejfYXh5J7oU0jRPVAd6goxLhvR8WtLfFjLsM9NWlL3z/wTgcoxuMm2wVa2xQuafqDw /AbP9LQYJudsQH/ZFDkSQTP020jUeTZG0D2LLQGA= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 03/16] Use correct .ppm extension for PPM images Date: Wed, 9 Apr 2025 03:47:45 +0300 Message-ID: <20250409004758.11014-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The reference images used by the test scripts are in PPM format, not PNM. Use the correct file extension. Signed-off-by: Laurent Pinchart --- ...pnm.gz => frame-reference-1024x768.ppm.gz} | Bin data/frames/meson.build | 4 ++-- scripts/bin2png.sh | 8 +++---- scripts/vsp-lib.sh | 22 +++++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-) rename data/frames/{frame-reference-1024x768.pnm.gz => frame-reference-1024x768.ppm.gz} (100%) diff --git a/data/frames/frame-reference-1024x768.pnm.gz b/data/frames/frame-reference-1024x768.ppm.gz similarity index 100% rename from data/frames/frame-reference-1024x768.pnm.gz rename to data/frames/frame-reference-1024x768.ppm.gz diff --git a/data/frames/meson.build b/data/frames/meson.build index f4ec8e30bdac..a9d79f29cde3 100644 --- a/data/frames/meson.build +++ b/data/frames/meson.build @@ -20,8 +20,8 @@ foreach table : tables install_dir : 'frames') endforeach -custom_target(input : files('frame-reference-1024x768.pnm.gz'), - output : 'frame-reference-1024x768.pnm', +custom_target(input : files('frame-reference-1024x768.ppm.gz'), + output : 'frame-reference-1024x768.ppm', capture : true, command : [gzip, '-cd', '@INPUT@'], install : true, diff --git a/scripts/bin2png.sh b/scripts/bin2png.sh index d231d192e772..e7b16ee6288b 100755 --- a/scripts/bin2png.sh +++ b/scripts/bin2png.sh @@ -6,7 +6,7 @@ FILE=${1:-.} convert_image() { local file=$1 - local pnm=${file%bin}pnm + local ppm=${file%bin}ppm local png=${file%bin}png local format=$(echo $file | sed -e 's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\1|' | tr '[:lower:]' '[:upper:]') @@ -24,9 +24,9 @@ convert_image() { ;; esac - raw2rgbpnm -f $format -s $size $file $pnm && \ - convert $pnm $png - rm $pnm + raw2rgbpnm -f $format -s $size $file $ppm && \ + convert $ppm $png + rm $ppm } if [ -d $FILE ] ; then diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index 114bc7200e6e..92a9121337f1 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -196,7 +196,7 @@ reference_frame() { [ x$__vsp_brx_inputs != x ] && options="$options -c $__vsp_brx_inputs" $genimage -i $in_format -f $out_format -s $size -a $alpha $options -o $file \ - frames/frame-reference-1024x768.pnm + frames/frame-reference-1024x768.ppm } reference_histogram() { @@ -210,7 +210,7 @@ reference_histogram() { [[ "x$hgt_hue_areas" != x ]] && hue="--histogram-areas $hgt_hue_areas" $genimage -i $format -f $format -s $size -H $file --histogram-type $type $hue \ - frames/frame-reference-1024x768.pnm + frames/frame-reference-1024x768.ppm } # ------------------------------------------------------------------------------ @@ -247,17 +247,17 @@ compare_frame_fuzzy() { local img_a=$3 local img_b=$4 - local pnm_a=${img_a/bin/pnm} - local pnm_b=${img_b/bin/pnm} + local ppm_a=${img_a/bin/ppm} + local ppm_b=${img_b/bin/ppm} - raw2rgbpnm -f $fmt -s $size $img_a $pnm_a > /dev/null - raw2rgbpnm -f $fmt -s $size $img_b $pnm_b > /dev/null + raw2rgbpnm -f $fmt -s $size $img_a $ppm_a > /dev/null + raw2rgbpnm -f $fmt -s $size $img_b $ppm_b > /dev/null - local ae=$(compare -metric ae $pnm_a $pnm_b /dev/null 2>&1) - local mae=$(compare -metric mae $pnm_a $pnm_b /dev/null 2>&1 | sed 's/.*(\(.*\))/\1/') + local ae=$(compare -metric ae $ppm_a $ppm_b /dev/null 2>&1) + local mae=$(compare -metric mae $ppm_a $ppm_b /dev/null 2>&1 | sed 's/.*(\(.*\))/\1/') - rm $pnm_a - rm $pnm_b + rm $ppm_a + rm $ppm_b local width=$(echo $size | cut -d 'x' -f 1) local height=$(echo $size | cut -d 'x' -f 2) @@ -892,7 +892,7 @@ generate_input_frame() { $(format_v4l2_is_yuv $format) && options="$options -C -i YUV444M" $genimage -f $format -s $size -a $alpha $options -o $file \ - frames/frame-reference-1024x768.pnm + frames/frame-reference-1024x768.ppm } vsp_runner() { From patchwork Wed Apr 9 00:47:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043890 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF79D26AF5 for ; Wed, 9 Apr 2025 00:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159714; cv=none; b=PVmy0pazNjZ3Poz5TPttoQUoRR9iAk7wxOx3301hcDEOoLwvGZ/Hgtzm/wc0QrGXlv1fbgcmRxbXCRs0cA5xst4LIC6f4+LIk/p2jz3YF3s3EkQiJFrKz5HLqBGaIRkQ7UpxZKKNoWm3okdXf3Dck4LakiLTnrHsWabL4Ij6iYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159714; c=relaxed/simple; bh=Osp7ePEDyWXlzUoHrlUeH6qEhfpofxYFl2poW3nb+YE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H/qU8Duo3K9/2WR6M6S65nazzCY9ovO9MKsHlwxAcWpdO3SSO7BT7KWJK9MGvO/w10Am8cvXMp/Fqg5W2C4THHzXU06OfMXm0Die5W61tPRktZyEzMuAaRIIHJrfHDg63+w7ClGpLmFrN5DRrlLl6FCdFBuaSgP2sI2x7OvIogU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=f0XnV15P; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f0XnV15P" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A9F0D82E; Wed, 9 Apr 2025 02:46:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159591; bh=Osp7ePEDyWXlzUoHrlUeH6qEhfpofxYFl2poW3nb+YE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0XnV15P7bpmTmzQSofkZ00t9wSj3kQAQ5n/B9UMXeYSRGkFiTvDP47AKfbU5O4rH G6wGLirNnAadbv+EDFcZt0nJQ6H0pWnjOIGpoQybz5VYIK+W2wkjOehMnFkAKcWBjg xWtHdpDv9gOeWd4mEpBUz7yTP++PSnpJavB/yK4U= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 04/16] gen-image: Round sub-sampled chroma towards zero Date: Wed, 9 Apr 2025 03:47:46 +0300 Message-ID: <20250409004758.11014-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Based on tests, the VSP1 hardware seems to round averaged chroma values towards 0 when subsampling YUV formats. Replicate the same calculation in gen-image. Signed-off-by: Laurent Pinchart --- src/gen-image.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gen-image.c b/src/gen-image.c index 170d69490399..d053d7906159 100644 --- a/src/gen-image.c +++ b/src/gen-image.c @@ -618,8 +618,15 @@ static void image_format_yuv_packed(const struct image *input, struct image *out o_c[2*x + u_offset] = idata[3*x + 1]; o_c[2*x + v_offset] = idata[3*x + 2]; } else { - o_c[2*x + u_offset] = (idata[3*x + 1] + idata[3*x + 4]) / 2; - o_c[2*x + v_offset] = (idata[3*x + 2] + idata[3*x + 5]) / 2; + unsigned int u = idata[3*x + 1] + idata[3*x + 4]; + unsigned int v = idata[3*x + 2] + idata[3*x + 5]; + + /* Round towards the middle value. */ + u += u < 0x100 ? 1 : 0; + v += v < 0x100 ? 1 : 0; + + o_c[2*x + u_offset] = u / 2; + o_c[2*x + v_offset] = v / 2; } } @@ -674,8 +681,15 @@ static void image_format_yuv_planar(const struct image *input, struct image *out } } else { for (x = 0; x < output->width; x += xsub) { - o_u[x*c_stride/xsub] = (idata[3*x + 1] + idata[3*x + 4]) / 2; - o_v[x*c_stride/xsub] = (idata[3*x + 2] + idata[3*x + 5]) / 2; + unsigned int u = idata[3*x + 1] + idata[3*x + 4]; + unsigned int v = idata[3*x + 2] + idata[3*x + 5]; + + /* Round towards the middle value. */ + u += u < 0x100 ? 1 : 0; + v += v < 0x100 ? 1 : 0; + + o_u[x*c_stride/xsub] = u / 2; + o_v[x*c_stride/xsub] = v / 2; } } From patchwork Wed Apr 9 00:47:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043891 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4D572C190 for ; Wed, 9 Apr 2025 00:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159715; cv=none; b=OZHhXpnq1r+4WP1cUTNEqOx6/TCr1jiq8tE2OKBQfMw2CkymBs68sX89tDjq2RU8oVGhnNo/jIGLV6ZAAt6o0yEgy76WhvX04e+733/KVE37alsea9X2llFMkAwLhmozIH0POQpJzPdzFhWhp263frDDZWHKoQmlR6V6yhTT530= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159715; c=relaxed/simple; bh=WRAH/Ti6Mv+ZMPeZY3PjoPgvXAmUGgJqv4ICKncEb8M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KRkRgc0hMhUCfCMbpDaA44hN/7YsYE+IssfetnTHtzaila54DV6CuvOc6giPgAaV4jCIuzKCmg7gDtq2CAgbb8Mb+JFJ8h9Jw9wzFK85TIBMJFEjZIKi19TZ9kK1tn6zTVKe9oczP8lXb+eVVJ+7bbD7wO7REZTQD8yd/Hrj+Xk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=vP0Jhhuy; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vP0Jhhuy" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 05A9783D; Wed, 9 Apr 2025 02:46:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159593; bh=WRAH/Ti6Mv+ZMPeZY3PjoPgvXAmUGgJqv4ICKncEb8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vP0JhhuyAQZBCext7Vz0I4VZ/ovHVORts1xBiLauRQQ80EpPEM/sMCffEr0NrfG3T C/28Q6QP0OaG2wNm7e92JZDwN688MvPmRKoaOVofeH24vOrxyQAnz8RaOxnQ0Yl/JD bRyAQjpYeZ6urluk1wg6BBDco+H1MDN67kK9pP8Y= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 05/16] gen-image: Update the RGB to YCbCr conversion to match VSP hardware Date: Wed, 9 Apr 2025 03:47:47 +0300 Message-ID: <20250409004758.11014-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 RGB to YCbCr conversion is only used at the moment to generate images for test cases that run fully YUV pipelines. The exact value of the RGB to YCbCr conversion matrices hasn't mattered much so far. However, this will change with introduction of tests that perform RGB to YCbCr conversion. To achieve pixel-perfect match between the reference and hardware frames, reference images need to be generated with the exact method used by the VSP. Replace the current coefficients by values obtained from reverse-engineering of the RGB to YCbCr conversion performed by the VSP1. Remove support for SMPTE240 and BT.2020, as the VSP hardware supports BT.601 and BT.709 only. Signed-off-by: Laurent Pinchart --- src/gen-image.c | 114 +++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 64 deletions(-) diff --git a/src/gen-image.c b/src/gen-image.c index d053d7906159..50c10109289b 100644 --- a/src/gen-image.c +++ b/src/gen-image.c @@ -700,56 +700,51 @@ static void image_format_yuv_planar(const struct image *input, struct image *out } /* ----------------------------------------------------------------------------- - * Colorspace handling - * - * The code is inspired by the v4l2-tpg Linux kernel driver. + * Format conversion (as performed by the Renesas VSP HST, HSI, RPF and WPF) */ static void colorspace_matrix(enum v4l2_ycbcr_encoding encoding, enum v4l2_quantization quantization, int (*matrix)[3][3]) { -#define COEFF(v, r) ((int)(0.5 + (v) * (r) * 256.0)) - + /* + * The value of the coefficients has been reverse-engineered by + * analyzing the VSP1 YUV output values for carefully crafted input RGB + * data. The hardware precision of the coefficients appears to be Q1.11. + * + * The exact way to derive those fixed-point coefficients from the + * BT.601 and BT.709 standard values is not know, none of the tested + * rounding methods (rounding down, rounding up, rounding to the closest + * integer, or rounding to minimum the error on the sum of each line) + * produce the fixed-point values used by the hardware. + * + * While the coefficients for BT.601 in both ranges, and BT.709 in + * limited range, differ from the values listed in the respective + * standards by at most a single unit, some of the BT.709 full range + * coefficients differ more significantly. The first line of the matrix + * matches the standard, but the second and third lines seem to be + * multiplied a factor approximately equal to 1.072. The reason is not + * currently understood. + */ static const int bt601[3][3] = { - { COEFF(0.299, 219), COEFF(0.587, 219), COEFF(0.114, 219) }, - { COEFF(-0.169, 224), COEFF(-0.331, 224), COEFF(0.5, 224) }, - { COEFF(0.5, 224), COEFF(-0.419, 224), COEFF(-0.081, 224) }, + { 526, 1033, 201 }, + { -304, -596, 900 }, + { 900, -753, -146 }, }; static const int bt601_full[3][3] = { - { COEFF(0.299, 255), COEFF(0.587, 255), COEFF(0.114, 255) }, - { COEFF(-0.169, 255), COEFF(-0.331, 255), COEFF(0.5, 255) }, - { COEFF(0.5, 255), COEFF(-0.419, 255), COEFF(-0.081, 255) }, + { 612, 1202, 233 }, + { -346, -678, 1024 }, + { 1024, -857, -167 }, }; static const int rec709[3][3] = { - { COEFF(0.2126, 219), COEFF(0.7152, 219), COEFF(0.0722, 219) }, - { COEFF(-0.1146, 224), COEFF(-0.3854, 224), COEFF(0.5, 224) }, - { COEFF(0.5, 224), COEFF(-0.4542, 224), COEFF(-0.0458, 224) }, + { 374, 1258, 127 }, + { -206, -693, 899 }, + { 899, -817, -83 }, }; static const int rec709_full[3][3] = { - { COEFF(0.2126, 255), COEFF(0.7152, 255), COEFF(0.0722, 255) }, - { COEFF(-0.1146, 255), COEFF(-0.3854, 255), COEFF(0.5, 255) }, - { COEFF(0.5, 255), COEFF(-0.4542, 255), COEFF(-0.0458, 255) }, - }; - static const int smpte240m[3][3] = { - { COEFF(0.212, 219), COEFF(0.701, 219), COEFF(0.087, 219) }, - { COEFF(-0.116, 224), COEFF(-0.384, 224), COEFF(0.5, 224) }, - { COEFF(0.5, 224), COEFF(-0.445, 224), COEFF(-0.055, 224) }, - }; - static const int smpte240m_full[3][3] = { - { COEFF(0.212, 255), COEFF(0.701, 255), COEFF(0.087, 255) }, - { COEFF(-0.116, 255), COEFF(-0.384, 255), COEFF(0.5, 255) }, - { COEFF(0.5, 255), COEFF(-0.445, 255), COEFF(-0.055, 255) }, - }; - static const int bt2020[3][3] = { - { COEFF(0.2627, 219), COEFF(0.6780, 219), COEFF(0.0593, 219) }, - { COEFF(-0.1396, 224), COEFF(-0.3604, 224), COEFF(0.5, 224) }, - { COEFF(0.5, 224), COEFF(-0.4598, 224), COEFF(-0.0402, 224) }, - }; - static const int bt2020_full[3][3] = { - { COEFF(0.2627, 255), COEFF(0.6780, 255), COEFF(0.0593, 255) }, - { COEFF(-0.1396, 255), COEFF(-0.3604, 255), COEFF(0.5, 255) }, - { COEFF(0.5, 255), COEFF(-0.4698, 255), COEFF(-0.0402, 255) }, + { 435, 1465, 148 }, + { -240, -807, 1047 }, + { 1047, -951, -96 }, }; bool full = quantization == V4L2_QUANTIZATION_FULL_RANGE; @@ -764,12 +759,6 @@ static void colorspace_matrix(enum v4l2_ycbcr_encoding encoding, case V4L2_YCBCR_ENC_709: m = full ? &rec709_full : &rec709; break; - case V4L2_YCBCR_ENC_BT2020: - m = full ? &bt2020_full : &bt2020; - break; - case V4L2_YCBCR_ENC_SMPTE240M: - m = full ? &smpte240m_full : &smpte240m; - break; } for (i = 0; i < ARRAY_SIZE(*m); ++i) @@ -781,23 +770,28 @@ static void colorspace_rgb2ycbcr(int m[3][3], const uint8_t rgb[3], uint8_t ycbcr[3]) { bool full = quantization == V4L2_QUANTIZATION_FULL_RANGE; - unsigned int y_offset = full ? 0 : 16; + int y_min = full ? 0 : 16; + int y_max = full ? 255 : 235; + int cbcr_min = full ? 0 : 16; + int cbcr_max = full ? 255 : 240; + int div = 1 << 11; int r, g, b; int y, cb, cr; - int div; - r = rgb[0] << 4; - g = rgb[1] << 4; - b = rgb[2] << 4; + r = rgb[0]; + g = rgb[1]; + b = rgb[2]; - div = (1 << (8 + 4)) * 255; - y = (m[0][0] * r + m[0][1] * g + m[0][2] * b + y_offset * div) / div; - cb = (m[1][0] * r + m[1][1] * g + m[1][2] * b + 128 * div) / div; - cr = (m[2][0] * r + m[2][1] * g + m[2][2] * b + 128 * div) / div; + y = (m[0][0] * r + m[0][1] * g + m[0][2] * b + y_min * div + div / 2) / div; + cb = (m[1][0] * r + m[1][1] * g + m[1][2] * b + 128 * div + div / 2) / div; + cr = (m[2][0] * r + m[2][1] * g + m[2][2] * b + 128 * div + div / 2) / div; - ycbcr[0] = y; - ycbcr[1] = cb; - ycbcr[2] = cr; +#define CLAMP(x, low, high) \ + ((x) < (low) ? (low) : ( (x) > (high) ? (high) : (x) )) + + ycbcr[0] = CLAMP(y, y_min, y_max); + ycbcr[1] = CLAMP(cb, cbcr_min, cbcr_max); + ycbcr[2] = CLAMP(cr, cbcr_min, cbcr_max); } static void image_colorspace_rgb_to_yuv(const struct image *input, @@ -851,10 +845,6 @@ static void image_convert_rgb_to_rgb(const struct image *input, } } -/* ----------------------------------------------------------------------------- - * RGB to HSV conversion (as performed by the Renesas VSP HST) - */ - #define K 4 static uint8_t hst_calc_h(uint8_t r, uint8_t g, uint8_t b) { @@ -1828,7 +1818,7 @@ static void usage(const char *argv0) printf("-C, --no-chroma-average Disable chroma averaging for odd pixels on output\n"); printf(" --crop (X,Y)/WxH Crop the input image\n"); printf("-e, --encoding enc Set the YCbCr encoding method. Valid values are\n"); - printf(" BT.601, REC.709, BT.2020 and SMPTE240M\n"); + printf(" BT.601 and REC.709\n"); printf("-f, --format format Set the output image format\n"); printf(" Defaults to RGB24 if not specified\n"); printf(" Use -f help to list the supported formats\n"); @@ -2062,10 +2052,6 @@ static int parse_args(struct options *options, int argc, char *argv[]) options->params.encoding = V4L2_YCBCR_ENC_601; } else if (!strcmp(optarg, "REC.709")) { options->params.encoding = V4L2_YCBCR_ENC_709; - } else if (!strcmp(optarg, "BT.2020")) { - options->params.encoding = V4L2_YCBCR_ENC_BT2020; - } else if (!strcmp(optarg, "SMPTE240M")) { - options->params.encoding = V4L2_YCBCR_ENC_SMPTE240M; } else { printf("Invalid encoding value '%s'\n", optarg); return 1; From patchwork Wed Apr 9 00:47:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043892 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA00926AF5 for ; Wed, 9 Apr 2025 00:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159717; cv=none; b=X/012D0RfrPAaBgQujNdxMRHiDu0Vp1jjl9lat3T8sQfmXYVa26WTEMmBCymK+z4vvokctqhy95RprwTdYRu+Q8q4Tk611uR3C6atZupLlTruSUHZxeaS+2rH943XJT9FvDfHHO7ehpS/Rqaf2PyNt8hi7o7qv+vT4p0JRemtjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159717; c=relaxed/simple; bh=RhQjDP9NiMlgxkk8SJAQurEn/dAQxRcm7sDcvdDOlZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nVXyz59EsoDxQK+oCFBYqREIQERCuSrvKGt97CXx/v1SM5w9LsoHDizaPsG4tOiDzD8a1v6tXl+Qe4Y/RAgGPTQi/r0Y9IfbdESZKwSvC3TD/l7SGJQ0m4jMHom3hOI6WERq3v4+RJreIbRXvUiETb29VX+Ifc4HrLpV3mh0Gok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=tilxT1P6; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tilxT1P6" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C7C0EF2; Wed, 9 Apr 2025 02:46:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159594; bh=RhQjDP9NiMlgxkk8SJAQurEn/dAQxRcm7sDcvdDOlZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tilxT1P6p/ZVZAWOyT0m5xI/p7uup+S+2tsL04pfsHZK6STmITL/qJG5U7A9eER2d 61YXX2qH1OVnjVttt5OcwPI4RSd9ZH7QAKyUnvwhqJCmfyt+rJ4DsGj/BRp+cDVjcQ Ny0qnkb4L50TOzXlJv8g5cyVxvOTBaZ9j8qSI02c= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 06/16] gen-image: Split struct params into CSC and packing parameters Date: Wed, 9 Apr 2025 03:47:48 +0300 Message-ID: <20250409004758.11014-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To prepare for improvements to the format conversion code, split the struct params into CSC parameters and packing parameters. Signed-off-by: Laurent Pinchart --- src/gen-image.c | 75 +++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/src/gen-image.c b/src/gen-image.c index 50c10109289b..40773c8ef967 100644 --- a/src/gen-image.c +++ b/src/gen-image.c @@ -106,10 +106,13 @@ struct image { void *data; }; -struct params { - unsigned int alpha; +struct csc_params { enum v4l2_ycbcr_encoding encoding; enum v4l2_quantization quantization; +}; + +struct pack_params { + unsigned int alpha; bool no_chroma_average; }; @@ -134,7 +137,8 @@ struct options { bool vflip; bool rotate; unsigned int compose; - struct params params; + struct csc_params csc_params; + struct pack_params pack_params; bool crop; struct image_rect inputcrop; enum histogram_type histo_type; @@ -461,7 +465,7 @@ static int image_write(const struct image *image, const char *filename) */ static void image_format_rgb8(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { const uint8_t *idata = input->data; uint8_t *odata = output->data; @@ -484,7 +488,7 @@ static void image_format_rgb8(const struct image *input, struct image *output, } static void image_format_rgb16(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { const struct format_info *format = output->format; const uint8_t *idata = input->data; @@ -508,7 +512,7 @@ static void image_format_rgb16(const struct image *input, struct image *output, } static void image_format_rgb24(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { struct color_rgb24 { unsigned int value:24; @@ -540,7 +544,7 @@ static void image_format_rgb24(const struct image *input, struct image *output, } static void image_format_rgb32(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { const struct format_info *format = output->format; const uint8_t *idata = input->data; @@ -564,13 +568,13 @@ static void image_format_rgb32(const struct image *input, struct image *output, } static void image_format_hsv24(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { memcpy(output->data, input->data, input->width * input->height * 3); } static void image_format_hsv32(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { const struct format_info *format = output->format; const uint8_t *idata = input->data; @@ -598,7 +602,7 @@ static void image_format_hsv32(const struct image *input, struct image *output, * chroma components of the two pixels to match the hardware behaviour. */ static void image_format_yuv_packed(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { const struct format_info *format = output->format; const uint8_t *idata = input->data; @@ -637,7 +641,7 @@ static void image_format_yuv_packed(const struct image *input, struct image *out } static void image_format_yuv_planar(const struct image *input, struct image *output, - const struct params *params) + const struct pack_params *params) { const struct format_info *format = output->format; const uint8_t *idata; @@ -797,7 +801,7 @@ static void colorspace_rgb2ycbcr(int m[3][3], static void image_colorspace_rgb_to_yuv(const struct image *input, struct image *output, const struct format_info *format, - const struct params *params) + const struct csc_params *params) { int matrix[3][3]; const uint8_t *idata = input->data; @@ -942,7 +946,7 @@ static void hst_rgb_to_hsv(const uint8_t rgb[3], uint8_t hsv[3]) static void image_rgb_to_hsv(const struct image *input, struct image *output, - const struct params *params) + const struct csc_params *params) { const uint8_t *idata = input->data; uint8_t *odata = output->data; @@ -999,8 +1003,7 @@ static void image_scale_bilinear(const struct image *input, struct image *output #undef _C2 } -static void image_scale(const struct image *input, struct image *output, - const struct params *params) +static void image_scale(const struct image *input, struct image *output) { image_scale_bilinear(input, output); } @@ -1564,7 +1567,7 @@ static int process(const struct options *options) } image_colorspace_rgb_to_yuv(input, yuv, options->input_format, - &options->params); + &options->csc_params); image_delete(input); input = yuv; } else if (options->input_format->rgb.bpp < 24) { @@ -1604,7 +1607,7 @@ static int process(const struct options *options) goto done; } - image_scale(input, scaled, &options->params); + image_scale(input, scaled); image_delete(input); input = scaled; } @@ -1715,9 +1718,9 @@ static int process(const struct options *options) if (options->output_format->type == FORMAT_YUV) image_colorspace_rgb_to_yuv(input, converted, format, - &options->params); + &options->csc_params); else - image_rgb_to_hsv(input, converted, &options->params); + image_rgb_to_hsv(input, converted, &options->csc_params); image_delete(input); input = converted; @@ -1733,16 +1736,16 @@ static int process(const struct options *options) case FORMAT_RGB: switch (output->format->rgb.bpp) { case 8: - image_format_rgb8(input, output, &options->params); + image_format_rgb8(input, output, &options->pack_params); break; case 16: - image_format_rgb16(input, output, &options->params); + image_format_rgb16(input, output, &options->pack_params); break; case 24: - image_format_rgb24(input, output, &options->params); + image_format_rgb24(input, output, &options->pack_params); break; case 32: - image_format_rgb32(input, output, &options->params); + image_format_rgb32(input, output, &options->pack_params); break; default: ret = -EINVAL; @@ -1753,10 +1756,10 @@ static int process(const struct options *options) case FORMAT_HSV: switch (output->format->hsv.bpp) { case 24: - image_format_hsv24(input, output, &options->params); + image_format_hsv24(input, output, &options->pack_params); break; case 32: - image_format_hsv32(input, output, &options->params); + image_format_hsv32(input, output, &options->pack_params); break; default: ret = -EINVAL; @@ -1767,11 +1770,11 @@ static int process(const struct options *options) case FORMAT_YUV: switch (output->format->yuv.num_planes) { case 1: - image_format_yuv_packed(input, output, &options->params); + image_format_yuv_packed(input, output, &options->pack_params); break; case 2: case 3: - image_format_yuv_planar(input, output, &options->params); + image_format_yuv_planar(input, output, &options->pack_params); break; default: ret = -EINVAL; @@ -2002,9 +2005,9 @@ static int parse_args(struct options *options, int argc, char *argv[]) memset(options, 0, sizeof(*options)); options->input_format = format_by_name("RGB24"); options->output_format = format_by_name("RGB24"); - options->params.alpha = 255; - options->params.encoding = V4L2_YCBCR_ENC_601; - options->params.quantization = V4L2_QUANTIZATION_LIM_RANGE; + options->pack_params.alpha = 255; + options->csc_params.encoding = V4L2_YCBCR_ENC_601; + options->csc_params.quantization = V4L2_QUANTIZATION_LIM_RANGE; options->histo_type = HISTOGRAM_HGO; opterr = 0; @@ -2031,7 +2034,7 @@ static int parse_args(struct options *options, int argc, char *argv[]) return 1; } - options->params.alpha = alpha; + options->pack_params.alpha = alpha; break; } @@ -2044,14 +2047,14 @@ static int parse_args(struct options *options, int argc, char *argv[]) break; case 'C': - options->params.no_chroma_average = true; + options->pack_params.no_chroma_average = true; break; case 'e': if (!strcmp(optarg, "BT.601")) { - options->params.encoding = V4L2_YCBCR_ENC_601; + options->csc_params.encoding = V4L2_YCBCR_ENC_601; } else if (!strcmp(optarg, "REC.709")) { - options->params.encoding = V4L2_YCBCR_ENC_709; + options->csc_params.encoding = V4L2_YCBCR_ENC_709; } else { printf("Invalid encoding value '%s'\n", optarg); return 1; @@ -2108,9 +2111,9 @@ static int parse_args(struct options *options, int argc, char *argv[]) case 'q': if (!strcmp(optarg, "limited")) { - options->params.quantization = V4L2_QUANTIZATION_LIM_RANGE; + options->csc_params.quantization = V4L2_QUANTIZATION_LIM_RANGE; } else if (!strcmp(optarg, "full")) { - options->params.quantization = V4L2_QUANTIZATION_FULL_RANGE; + options->csc_params.quantization = V4L2_QUANTIZATION_FULL_RANGE; } else { printf("Invalid quantization value '%s'\n", optarg); return 1; From patchwork Wed Apr 9 00:47:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043893 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC5662C190 for ; Wed, 9 Apr 2025 00:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159719; cv=none; b=KHd8XduqeNsWhJsQuZenV0NeXEHWAPBV5P4EXy3Ot8LL2N7vNisNQ98Di1vbLzU8rVzqszrV+YT5zoJ4nxHlJxJvx1JFbtrraNk4aqbyXWT/PnAzp5wXTJg/Uw8VEwyG4UU20HIlCSOD8XDmDFNz7WNhE0DalOPymuRH7R7h9CA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159719; c=relaxed/simple; bh=qtoMHXiEcJsgwwhTsFOSHqVpcGAbgCFPg/mPWpfQRGU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=umckCpcLErdjw/zmmqVjYqCcrma/bH8fK7A4YRvDkq4dch/S+Di+6ctxvvlDxERY4Dk8VfFF7bByTnLYQ1H+GXsSEYzYkn/pNGDJPqm9LketI9XRqNSgo3/aPfUMW/YR/OShwtUEjs0kt681E7ogG/6WiNDZzOXySdFzKoP1pGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=BO93LKRH; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BO93LKRH" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B85ECA98; Wed, 9 Apr 2025 02:46:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159595; bh=qtoMHXiEcJsgwwhTsFOSHqVpcGAbgCFPg/mPWpfQRGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BO93LKRH+OWsNEG48RXBmjJrDSLoFFVdtsU8Bb3k66/h1c4AnIp5gRTqoZwPSdoiG 0THf0WjH/fHTXHj2pTzc4oTB+Koel+kIRsFaFlFWLnzqPc5YOz4/wezdJOyCg8++NZ oOJgbptfvC0Fj+5Ywj3lXWJ2rpBt3OEATiMZum0U= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 07/16] gen-image: Centralize format conversion code Date: Wed, 9 Apr 2025 03:47:49 +0300 Message-ID: <20250409004758.11014-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Create an image_convert() function that encapsulates all format conversion, and use it to replace direct calls to other converter functions. This prepares for extending the supported conversions. Signed-off-by: Laurent Pinchart --- src/gen-image.c | 241 ++++++++++++++++++++++++++++++------------------ 1 file changed, 149 insertions(+), 92 deletions(-) diff --git a/src/gen-image.c b/src/gen-image.c index 40773c8ef967..d2d4870a699a 100644 --- a/src/gen-image.c +++ b/src/gen-image.c @@ -205,6 +205,25 @@ static const struct format_info *format_by_name(const char *name) return NULL; } +static const struct format_info *format_by_type(enum format_type type) +{ + const char *name = ""; + + switch (type) { + case FORMAT_RGB: + name = "RGB24"; + break; + case FORMAT_YUV: + name = "YUV24"; + break; + case FORMAT_HSV: + name = "HSV24"; + break; + } + + return format_by_name(name); +} + /* ----------------------------------------------------------------------------- * File I/O */ @@ -309,6 +328,13 @@ static void image_delete(struct image *image) free(image); } +static void image_move(struct image *src, struct image *dst) +{ + free(dst->data); + *dst = *src; + free(src); +} + /* ----------------------------------------------------------------------------- * Image read and write */ @@ -707,9 +733,34 @@ static void image_format_yuv_planar(const struct image *input, struct image *out * Format conversion (as performed by the Renesas VSP HST, HSI, RPF and WPF) */ -static void colorspace_matrix(enum v4l2_ycbcr_encoding encoding, - enum v4l2_quantization quantization, - int (*matrix)[3][3]) +/* RGB to RGB (downsampling only) */ +static void image_convert_rgb_to_rgb(const struct image *input, + struct image *output, + const struct format_info *format, + const struct csc_params *params) +{ + const uint8_t *idata = input->data; + uint8_t *odata = output->data; + unsigned int x; + unsigned int y; + uint8_t r, g, b; + + for (y = 0; y < output->height; ++y) { + for (x = 0; x < output->width; ++x) { + r = *idata++ & (0xff << (8 - format->rgb.red.length)); + g = *idata++ & (0xff << (8 - format->rgb.green.length)); + b = *idata++ & (0xff << (8 - format->rgb.blue.length)); + *odata++ = r; + *odata++ = g; + *odata++ = b; + } + } +} + +/* RGB to YUV */ +static void csc_matrix(enum v4l2_ycbcr_encoding encoding, + enum v4l2_quantization quantization, + int (*matrix)[3][3]) { /* * The value of the coefficients has been reverse-engineered by @@ -769,9 +820,8 @@ static void colorspace_matrix(enum v4l2_ycbcr_encoding encoding, memcpy((*matrix)[i], (*m)[i], sizeof((*m)[i])); } -static void colorspace_rgb2ycbcr(int m[3][3], - enum v4l2_quantization quantization, - const uint8_t rgb[3], uint8_t ycbcr[3]) +static void csc_rgb_to_yuv(int m[3][3], enum v4l2_quantization quantization, + const uint8_t rgb[3], uint8_t ycbcr[3]) { bool full = quantization == V4L2_QUANTIZATION_FULL_RANGE; int y_min = full ? 0 : 16; @@ -798,10 +848,10 @@ static void colorspace_rgb2ycbcr(int m[3][3], ycbcr[2] = CLAMP(cr, cbcr_min, cbcr_max); } -static void image_colorspace_rgb_to_yuv(const struct image *input, - struct image *output, - const struct format_info *format, - const struct csc_params *params) +static void image_convert_rgb_to_yuv(const struct image *input, + struct image *output, + const struct format_info *format, + const struct csc_params *params) { int matrix[3][3]; const uint8_t *idata = input->data; @@ -809,12 +859,12 @@ static void image_colorspace_rgb_to_yuv(const struct image *input, unsigned int x; unsigned int y; - colorspace_matrix(params->encoding, params->quantization, &matrix); + csc_matrix(params->encoding, params->quantization, &matrix); for (y = 0; y < output->height; ++y) { for (x = 0; x < output->width; ++x) { - colorspace_rgb2ycbcr(matrix, params->quantization, - &idata[3*x], &odata[3*x]); + csc_rgb_to_yuv(matrix, params->quantization, + &idata[3*x], &odata[3*x]); } if (format->yuv.xsub == 2) { for (x = 1; x < output->width - 1; x += 2) { @@ -827,28 +877,7 @@ static void image_colorspace_rgb_to_yuv(const struct image *input, } } -static void image_convert_rgb_to_rgb(const struct image *input, - struct image *output, - const struct format_info *format) -{ - const uint8_t *idata = input->data; - uint8_t *odata = output->data; - unsigned int x; - unsigned int y; - uint8_t r, g, b; - - for (y = 0; y < output->height; ++y) { - for (x = 0; x < output->width; ++x) { - r = *idata++ & (0xff << (8 - format->rgb.red.length)); - g = *idata++ & (0xff << (8 - format->rgb.green.length)); - b = *idata++ & (0xff << (8 - format->rgb.blue.length)); - *odata++ = r; - *odata++ = g; - *odata++ = b; - } - } -} - +/* RGB to HSV */ #define K 4 static uint8_t hst_calc_h(uint8_t r, uint8_t g, uint8_t b) { @@ -944,9 +973,10 @@ static void hst_rgb_to_hsv(const uint8_t rgb[3], uint8_t hsv[3]) hsv[2] = hst_calc_v(rgb[0], rgb[1], rgb[2]); } -static void image_rgb_to_hsv(const struct image *input, - struct image *output, - const struct csc_params *params) +static void image_convert_rgb_to_hsv(const struct image *input, + struct image *output, + const struct format_info *format, + const struct csc_params *params) { const uint8_t *idata = input->data; uint8_t *odata = output->data; @@ -962,6 +992,78 @@ static void image_rgb_to_hsv(const struct image *input, } } +typedef void (*image_convert_func)(const struct image *input, + struct image *output, + const struct format_info *format, + const struct csc_params *params); + +struct image_converter { + enum format_type input; + enum format_type output; + image_convert_func convert; +}; + +static const struct image_converter image_converters[] = { + { FORMAT_RGB, FORMAT_HSV, image_convert_rgb_to_hsv }, + { FORMAT_RGB, FORMAT_RGB, image_convert_rgb_to_rgb }, + { FORMAT_RGB, FORMAT_YUV, image_convert_rgb_to_yuv }, +}; + +static int image_convert(struct image *input, const struct format_info *format, + const struct csc_params *params) +{ + const struct image_converter *converter; + const struct format_info *image_format; + struct image *output; + unsigned int i; + + /* + * Converters combines two tasks: they convert between 24-bit RGB, YUV + * and HSV formats (as done by the VSP RPF and WPF CSC blocks for RGB + * <-> YUV conversion, and the HSI and HST blocks for RGB <-> HSV + * conversion), and they emulate the effects of reading downsampled + * formats (RGB with less than 24bpp, or subsampled YUV). Combining + * those operations makes the converter suitable to efficiently emulate + * + * - RPF unpacking + * - RPF color space conversion + * - HST and HSI + * - WPF color space conversion + * + * The input image must be in a 24-bit format. The output format + * parameter can be either a 24-bit format (when emulating RPF/WPF CSC, + * HST or HSI), or a downsampled RGB or YUV format (when emulating RPF + * unpacking). In all cases, the converter image will be in a 24-bit + * format. + */ + image_format = format_by_type(format->type); + + /* Find an appropriate converter. */ + for (i = 0; i < ARRAY_SIZE(image_converters); ++i) { + converter = &image_converters[i]; + + if (converter->input == input->format->type && + converter->output == format->type) + break; + } + + if (i == ARRAY_SIZE(image_converters)) { + printf("Conversion from %s to %s is not supported\n", + input->format->name, format->name); + return -EINVAL; + } + + output = image_new(image_format, input->width, input->height); + if (!output) + return -ENOMEM; + + converter->convert(input, output, format, params); + + image_move(output, input); + + return 0; +} + /* ----------------------------------------------------------------------------- * Image scaling */ @@ -1555,34 +1657,12 @@ static int process(const struct options *options) input = cropped; } - /* Convert colorspace */ - if (options->input_format->type == FORMAT_YUV) { - struct image *yuv; - - yuv = image_new(format_by_name("YUV24"), input->width, - input->height); - if (!yuv) { - ret = -ENOMEM; + /* Convert to the input format */ + if (options->input_format != input->format) { + ret = image_convert(input, options->input_format, + &options->csc_params); + if (ret) goto done; - } - - image_colorspace_rgb_to_yuv(input, yuv, options->input_format, - &options->csc_params); - image_delete(input); - input = yuv; - } else if (options->input_format->rgb.bpp < 24) { - struct image *rgb; - - rgb = image_new(format_by_name("RGB24"), input->width, - input->height); - if (!rgb) { - ret = -ENOMEM; - goto done; - } - - image_convert_rgb_to_rgb(input, rgb, options->input_format); - image_delete(input); - input = rgb; } /* Scale */ @@ -1694,36 +1774,13 @@ static int process(const struct options *options) } /* Format the output */ - if (input->format->type != options->output_format->type && - input->format->type != FORMAT_RGB) { - printf("Format conversion with non-RGB input not supported\n"); - ret = -EINVAL; - goto done; - } - if (input->format->type != options->output_format->type) { - const struct format_info *format; - struct image *converted; + const struct format_info *format = + format_by_type(options->output_format->type); - if (options->output_format->type == FORMAT_YUV) - format = format_by_name("YUV24"); - else - format = format_by_name("HSV24"); - - converted = image_new(format, input->width, input->height); - if (!converted) { - ret = -ENOMEM; + ret = image_convert(input, format, &options->csc_params); + if (ret) goto done; - } - - if (options->output_format->type == FORMAT_YUV) - image_colorspace_rgb_to_yuv(input, converted, format, - &options->csc_params); - else - image_rgb_to_hsv(input, converted, &options->csc_params); - - image_delete(input); - input = converted; } output = image_new(options->output_format, input->width, input->height); From patchwork Wed Apr 9 00:47:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043894 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45A9A26AF5 for ; Wed, 9 Apr 2025 00:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159720; cv=none; b=F4g6xo/uLcqXMQXjnTlpQxEFUTvgQIeNQQv0hoKdk/IdFIhzxxWmstMrC5gkYkGCWKk0uetrS0A4T37v9AX6DvTvE8PAxNVL6uIScHwLV5TQVJ61PkUG5lT3t2ocO/2GG7PZei7RFIT2e30Ha5qTESnqR09EmMvnDuJZcuJJ1tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159720; c=relaxed/simple; bh=fXrQJESh0K1WyDnVjt0ZMYwQo6P5Vo7ptj4muMpf00U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VXb6b2i3AOrfO0/T5VitCNVYIgQJ+Zzznq2MJjMMy1L6IMR0e8zn4h7vODqAK+fekdMtMQ8lTRw3erDOZ2vVRXH4y9G4jtcoRdc3eO0yALgTJ2lXbZoUhDrFUnEjPY/w2a6TetmwYpdyUiFSiY1mooc3NJXqIRxFTy0ebdhViBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=KgDXntyw; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KgDXntyw" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6BCB118E5; Wed, 9 Apr 2025 02:46:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159597; bh=fXrQJESh0K1WyDnVjt0ZMYwQo6P5Vo7ptj4muMpf00U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KgDXntywvWPDY7UPqSV1Cr7buS6+bTSiEruHNN74RSYNvOOUrt+CrFtxsCqqLxixq KZ9Qwz8vf1slg4FbwBvrkk2yDFV9R+cTfciF8keoSOEjdXO/VeuMwX4RSOKl833FAY RBOtJ2Qb+eZ3Juy5KAiL7gWqHLyNVrZh8U3aat7U= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 08/16] gen-image: Don't copy CSC conversion matrix Date: Wed, 9 Apr 2025 03:47:50 +0300 Message-ID: <20250409004758.11014-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Merge the csc_matrix() function into image_convert_rgb_to_yuv() to avoid unnecessary copies of the matrix. Signed-off-by: Laurent Pinchart --- src/gen-image.c | 105 +++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/src/gen-image.c b/src/gen-image.c index d2d4870a699a..2f854634a986 100644 --- a/src/gen-image.c +++ b/src/gen-image.c @@ -758,9 +758,37 @@ static void image_convert_rgb_to_rgb(const struct image *input, } /* RGB to YUV */ -static void csc_matrix(enum v4l2_ycbcr_encoding encoding, - enum v4l2_quantization quantization, - int (*matrix)[3][3]) +static void csc_rgb_to_yuv(const int ccm[3][3], bool full_range, + const uint8_t rgb[3], uint8_t ycbcr[3]) +{ + int y_min = full_range ? 0 : 16; + int y_max = full_range ? 255 : 235; + int cbcr_min = full_range ? 0 : 16; + int cbcr_max = full_range ? 255 : 240; + int div = 1 << 11; + int r, g, b; + int y, cb, cr; + + r = rgb[0]; + g = rgb[1]; + b = rgb[2]; + + y = (ccm[0][0] * r + ccm[0][1] * g + ccm[0][2] * b + y_min * div + div / 2) / div; + cb = (ccm[1][0] * r + ccm[1][1] * g + ccm[1][2] * b + 128 * div + div / 2) / div; + cr = (ccm[2][0] * r + ccm[2][1] * g + ccm[2][2] * b + 128 * div + div / 2) / div; + +#define CLAMP(x, low, high) \ + ((x) < (low) ? (low) : ( (x) > (high) ? (high) : (x) )) + + ycbcr[0] = CLAMP(y, y_min, y_max); + ycbcr[1] = CLAMP(cb, cbcr_min, cbcr_max); + ycbcr[2] = CLAMP(cr, cbcr_min, cbcr_max); +} + +static void image_convert_rgb_to_yuv(const struct image *input, + struct image *output, + const struct format_info *format, + const struct csc_params *params) { /* * The value of the coefficients has been reverse-engineered by @@ -802,76 +830,35 @@ static void csc_matrix(enum v4l2_ycbcr_encoding encoding, { 1047, -951, -96 }, }; - bool full = quantization == V4L2_QUANTIZATION_FULL_RANGE; - unsigned int i; - const int (*m)[3][3]; - - switch (encoding) { - case V4L2_YCBCR_ENC_601: - default: - m = full ? &bt601_full : &bt601; - break; - case V4L2_YCBCR_ENC_709: - m = full ? &rec709_full : &rec709; - break; - } - - for (i = 0; i < ARRAY_SIZE(*m); ++i) - memcpy((*matrix)[i], (*m)[i], sizeof((*m)[i])); -} - -static void csc_rgb_to_yuv(int m[3][3], enum v4l2_quantization quantization, - const uint8_t rgb[3], uint8_t ycbcr[3]) -{ - bool full = quantization == V4L2_QUANTIZATION_FULL_RANGE; - int y_min = full ? 0 : 16; - int y_max = full ? 255 : 235; - int cbcr_min = full ? 0 : 16; - int cbcr_max = full ? 255 : 240; - int div = 1 << 11; - int r, g, b; - int y, cb, cr; - - r = rgb[0]; - g = rgb[1]; - b = rgb[2]; - - y = (m[0][0] * r + m[0][1] * g + m[0][2] * b + y_min * div + div / 2) / div; - cb = (m[1][0] * r + m[1][1] * g + m[1][2] * b + 128 * div + div / 2) / div; - cr = (m[2][0] * r + m[2][1] * g + m[2][2] * b + 128 * div + div / 2) / div; - -#define CLAMP(x, low, high) \ - ((x) < (low) ? (low) : ( (x) > (high) ? (high) : (x) )) - - ycbcr[0] = CLAMP(y, y_min, y_max); - ycbcr[1] = CLAMP(cb, cbcr_min, cbcr_max); - ycbcr[2] = CLAMP(cr, cbcr_min, cbcr_max); -} - -static void image_convert_rgb_to_yuv(const struct image *input, - struct image *output, - const struct format_info *format, - const struct csc_params *params) -{ - int matrix[3][3]; + bool full_range = params->quantization == V4L2_QUANTIZATION_FULL_RANGE; + const int (*matrix)[3][3]; const uint8_t *idata = input->data; uint8_t *odata = output->data; unsigned int x; unsigned int y; - csc_matrix(params->encoding, params->quantization, &matrix); + switch (params->encoding) { + case V4L2_YCBCR_ENC_601: + default: + matrix = full_range ? &bt601_full : &bt601; + break; + case V4L2_YCBCR_ENC_709: + matrix = full_range ? &rec709_full : &rec709; + break; + } for (y = 0; y < output->height; ++y) { - for (x = 0; x < output->width; ++x) { - csc_rgb_to_yuv(matrix, params->quantization, + for (x = 0; x < output->width; ++x) + csc_rgb_to_yuv(*matrix, full_range, &idata[3*x], &odata[3*x]); - } + if (format->yuv.xsub == 2) { for (x = 1; x < output->width - 1; x += 2) { odata[3*x + 1] = (odata[3*(x-1) + 1] + odata[3*(x+1) + 1]) / 2; odata[3*x + 2] = (odata[3*(x-1) + 2] + odata[3*(x+1) + 2]) / 2; } } + idata += 3 * output->width; odata += 3 * output->width; } From patchwork Wed Apr 9 00:47:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043895 X-Patchwork-Delegate: geert@linux-m68k.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9EC12C190 for ; Wed, 9 Apr 2025 00:48:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159722; cv=none; b=B8+PxIVOhC+Hnti1Cjvas5S+2yDj/b1+dxE8iDB4f++2Tpv/KIj8eeuy3h8xGOkBby1FvtSpdnGQP3wPirBIgjXHbSJIzdrw2op3HRpKadA25bBbJY13G+t55RQe7qYwTH1LmQLzQxrcdVrIpr/n3+XKwzStJkG9bAiIk5NmjJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159722; c=relaxed/simple; bh=PunNaulOMfclCNJB8h43c1bNp7/SXbVo+cgAyOTyhdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cg5lXk6u+t9wmWN8rnTdmnzib6s6+ZFSBeZudAxSq7uRkBitepvG1RrDHR3m5nW0Z6K/N8VBjHE3DU7Wl2k0YPJVyTgbPRIe5FjSEgggLAVeMUJgReSByKmHppIP3i/V2qH/vy35AvV0c1YzwD5wVlhf5NpAurIHRz/IXpEO1zs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=AKpeRDNL; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AKpeRDNL" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CD31982E; Wed, 9 Apr 2025 02:46:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159598; bh=PunNaulOMfclCNJB8h43c1bNp7/SXbVo+cgAyOTyhdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKpeRDNLzogzXGwPq9hFW+jCxq0mtx+fdxr3jNouxpxq7J58TquSezpLpCI22HCCP JSyHSjV9gsR/2NQ6CpJXEVPNh7RTfX+g5a/ROFLLlPoT18xm8IEci9JJvvs8WSAFit keLWffl/c3FzoElJy0b7CAFerZ12nMMUXZh5YS4I= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 09/16] gen-image: Add support for YUV to RGB conversion Date: Wed, 9 Apr 2025 03:47:51 +0300 Message-ID: <20250409004758.11014-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support YUV to RGB conversion, to emulate the RPF and WPF CSC. As for RGB to YUV conversion, the coefficients have been reverse-engineered. Signed-off-by: Laurent Pinchart --- src/gen-image.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/src/gen-image.c b/src/gen-image.c index 2f854634a986..cf6b6bc48745 100644 --- a/src/gen-image.c +++ b/src/gen-image.c @@ -979,6 +979,101 @@ static void image_convert_rgb_to_hsv(const struct image *input, } } +/* YUV ro RGB */ +static void csc_yuv_to_rgb(const int ccm[3][3], bool full_range, + const uint8_t ycbcr[3], uint8_t rgb[3]) +{ + int y_min = full_range ? 0 : 16; + int div = 1 << 11; + int y, cb, cr; + int r, g, b; + + y = ycbcr[0] - y_min; + cb = ycbcr[1] - 128; + cr = ycbcr[2] - 128; + + r = (ccm[0][0] * y + ccm[0][1] * cb + ccm[0][2] * cr + div / 2) / div; + g = (ccm[1][0] * y + ccm[1][1] * cb + ccm[1][2] * cr + div / 2) / div; + b = (ccm[2][0] * y + ccm[2][1] * cb + ccm[2][2] * cr + div / 2) / div; + + rgb[0] = CLAMP(r, 0, 255); + rgb[1] = CLAMP(g, 0, 255); + rgb[2] = CLAMP(b, 0, 255); +} + +static void image_convert_yuv_to_rgb(const struct image *input, + struct image *output, + const struct format_info *format, + const struct csc_params *params) +{ + /* + * The value of the coefficients has been reverse-engineered by + * analyzing the VSP1 RGB output values for carefully crafted input YUV + * data. The hardware precision of the coefficients appears to be Q1.11. + * + * The exact way to derive those fixed-point coefficients from the + * BT.601 and BT.709 standard values is not know, none of the tested + * rounding methods (rounding down, rounding up, rounding to the closest + * integer, or rounding to minimum the error on the sum of each line) + * produce the fixed-point values used by the hardware. + * + * While the coefficients for BT.601 in both ranges, and BT.709 in + * limited range, differ from the values listed in the respective + * standards by at most a single unit, some of the BT.709 full range + * coefficients differ more significantly. The first column of the + * matrix matches the standard, but the second and third columns seem to + * be divided by a factor equal to (240-16)/(235-16). The reason is not + * currently understood, but the value of the factor strongly hints that + * this isn't a random difference. + */ + static const int bt601[3][3] = { + { 2384, 0, 3269 }, + { 2384, -803, -1665 }, + { 2384, 4131, 0 }, + }; + static const int bt601_full[3][3] = { + { 2048, 0, 2871 }, + { 2048, -705, -1463 }, + { 2048, 3629, 0 }, + }; + static const int rec709[3][3] = { + { 2385, 0, 3672 }, + { 2385, -437, -1092 }, + { 2385, 4326, 0 }, + }; + static const int rec709_full[3][3] = { + { 2048, 0, 3153 }, + { 2048, -375, -937 }, + { 2048, 3715, 0 }, + }; + + bool full_range = params->quantization == V4L2_QUANTIZATION_FULL_RANGE; + const int (*matrix)[3][3]; + const uint8_t *idata = input->data; + uint8_t *odata = output->data; + unsigned int x; + unsigned int y; + + switch (params->encoding) { + case V4L2_YCBCR_ENC_601: + default: + matrix = full_range ? &bt601_full : &bt601; + break; + case V4L2_YCBCR_ENC_709: + matrix = full_range ? &rec709_full : &rec709; + break; + } + + for (y = 0; y < output->height; ++y) { + for (x = 0; x < output->width; ++x) + csc_yuv_to_rgb(*matrix, full_range, + &idata[3*x], &odata[3*x]); + + idata += 3 * output->width; + odata += 3 * output->width; + } +} + typedef void (*image_convert_func)(const struct image *input, struct image *output, const struct format_info *format, @@ -994,6 +1089,7 @@ static const struct image_converter image_converters[] = { { FORMAT_RGB, FORMAT_HSV, image_convert_rgb_to_hsv }, { FORMAT_RGB, FORMAT_RGB, image_convert_rgb_to_rgb }, { FORMAT_RGB, FORMAT_YUV, image_convert_rgb_to_yuv }, + { FORMAT_YUV, FORMAT_RGB, image_convert_yuv_to_rgb }, }; static int image_convert(struct image *input, const struct format_info *format, From patchwork Wed Apr 9 00:47:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043896 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A86126AF5 for ; Wed, 9 Apr 2025 00:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159723; cv=none; b=tpTm53TKdb41rNDxmR98axBEayobwz5oBDbWQGG/I1dQK6Bb4P3Ec8P3xzR07BPrzxcW6vWLgD0QNB/21UWDRjTmjaT8JcPhErfJplCpsGDc32/V/FVZMvZ4eAjotkAaUu91Ua1oobMfX8HECvRaAVWTReSb5qYfZ4tgPlOEF9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159723; c=relaxed/simple; bh=Xqz4Ptp6xRR4FQY3m8E0fnjrACpBg/HjJaoLWnrqaTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cVxZctsANLcFnLXF5kFuZstCm77vH75Hq+QpqQisrnLwkJmx+uAvudARzezRuQXEI+W5Jevc6UdNR4K9lslAf2rmgqOeoEM/lmK1GgK3KL3SabKhOPaLr1aV+sF7JrCy7p+PhSbSgTwj19pQaRDd8Q6hI8hMUNrP8x1yQVNafyk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=c6M6M30M; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="c6M6M30M" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4213399F; Wed, 9 Apr 2025 02:46:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159600; bh=Xqz4Ptp6xRR4FQY3m8E0fnjrACpBg/HjJaoLWnrqaTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c6M6M30MoIqG1bv5pvq18swUt1qrIPiq3KizUtGzjDxJtWymoylhRpOrn/YtYtkgK ddEB0dYCGJNA4cB0L1oI5EntWXoRpeAQZLpnn8Y1FKCNPu1N82kflIWWavbS21tLwM 0IcS7dMEXOozB1N+IWU473OeebsrdEE3aGPaxgEQ= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 10/16] vsp-lib: Save RPF input frames upon error Date: Wed, 9 Apr 2025 03:47:52 +0300 Message-ID: <20250409004758.11014-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When a test fail, it can be useful to inspect the frames input to the RPFs. Save them along the frames output by the WPFs and the reference frames. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index 92a9121337f1..ba87de5af954 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -316,9 +316,13 @@ compare_frames() { if [ x$VSP_KEEP_FRAMES = x1 -o $result = "fail" ] ; then mv ${frames_dir}ref-frame.bin ${0/.sh/}-$params-ref-frame.bin + for frame in ${frames_dir}rpf.*.bin ; do + mv $frame ${0/.sh/}-$params-$(basename ${frame}) + done else rm -f ${frames_dir}ref-frame.bin rm -f ${frames_dir}frame-*.bin + rm -f ${frames_dir}rpf.*.bin fi echo $result From patchwork Wed Apr 9 00:47:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043897 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01BA23595C for ; Wed, 9 Apr 2025 00:48:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159725; cv=none; b=ZZyqvm8CIJuWaWAaOagiwyzzPAYH3uKKBrmhAIZilX9irwolL3zUhEE78CjkcMvrqptCz2mZdlaMsMjryYkYHLaOfTrqeI+qPOcwsnSwBUHZjqIfomhmvziOU0wrj3va9SlvsHWnqprMvnn/IyIlshz2aCm890QJL8LR5lSNTBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159725; c=relaxed/simple; bh=INDIGiCQGrUsxyMEHtK/+J98aRwHa3L8EQVmkR3yduM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H4Xn2YMqn7mPmCTtS5weo8I0yteTwh0PYEwHbcTquPTvXHdrxCtJLIrichUGEs5F+t4BUOWzyoehEsIODl2eWbTfY+M3M0eXY7DiYq/3oDfaIHotl4ArYVIhbXgFuWziClK5NLIKDW0Skjop4yMEMzsNo6v6c7B6ljmEQ1dgRpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=JbX+sy3k; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JbX+sy3k" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A092F90; Wed, 9 Apr 2025 02:46:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159601; bh=INDIGiCQGrUsxyMEHtK/+J98aRwHa3L8EQVmkR3yduM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbX+sy3kcTNdkZiUG3q0T1I3K6m/yR7BX52yE5Vo/JgbMW5FbUbEfF3Ai4xvCW5HT 7rQ6hzf8Rpi4/AI5hDTAY1Ik+caJqUjOJqkf9FDeQ7VEYgHPLB7j0AUsKt0jfkBL1y syqonB3ATn7lAHDZRmYFzoLj+6SYXKwc9Qjx+5Xw= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 11/16] vsp-lib: Support specifying pipeline internal format for RPF -> WPF Date: Wed, 9 Apr 2025 03:47:53 +0300 Message-ID: <20250409004758.11014-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The RPF can perform color space conversion, converting between RGB and YUV formats. Testing this feature requires specifying different formats on the RPF input and output. Add a --midfmt argument to the format_rpf_wpf() function to specify the RPF output format, and propagate it through the pipeline up to the WPF input. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index ba87de5af954..d8722905cdc9 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -789,6 +789,7 @@ format_rpf_wpf() { local infmt=$(format_v4l2_to_mbus $3) local size=$4 local outfmt=$(format_v4l2_to_mbus $5) + local midfmt=$infmt local rpfcrop= local wpfcrop= local rpfoutsize= @@ -802,6 +803,9 @@ format_rpf_wpf() { for option in $* ; do case $option in + --midfmt=*) + midfmt=$(format_v4l2_to_mbus ${option/--midfmt=/}) + ;; --rpfcrop=*) rpfcrop=${option/--rpfcrop=/} ;; @@ -831,8 +835,8 @@ format_rpf_wpf() { fi $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size $rpfcrop]" - $mediactl -d $mdev -V "'$dev rpf.$rpf':1 [fmt:$infmt/$rpfoutsize]" - $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$rpfoutsize $wpfcrop]" + $mediactl -d $mdev -V "'$dev rpf.$rpf':1 [fmt:$midfmt/$rpfoutsize]" + $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$midfmt/$rpfoutsize $wpfcrop]" $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]" } From patchwork Wed Apr 9 00:47:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043898 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F28026AF5 for ; Wed, 9 Apr 2025 00:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159727; cv=none; b=BhiV65E2orywXqhCoNNIkc4Xvar6QtlPG6CwPdGWdXJrXzltJ/xKcAKh8uE2oYCuRdFUp3yDk8FptckXhYfelPyCC0tKnqj1tlKJVWmS2HAlEle0XCPx06y2LsINTa68ivrocdIu6Vu9uvgvoDfGpqmtib7KgNjS3+yVxNt80OU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159727; c=relaxed/simple; bh=kNHVw+b833L018HUNn9P11uSm9o66ENvrIDCFt44OsY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jy92gKpFcMbbi+8/CIUFy9BCcZWfY4M2IMa6vZasaY+lCxq0eir47TEHLObNJYdAGxx4cYJ3kg7KbhWli8NKTy2H+QEaLnzRMgpom/o6R79ZLsRyh7h0f1LWQOsZImUnbGuADv22K9sYMRHFo5XLTHacOoDNsSGTpYGi99Ee5I4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=UcEz+Oux; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UcEz+Oux" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 05052A98; Wed, 9 Apr 2025 02:46:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159603; bh=kNHVw+b833L018HUNn9P11uSm9o66ENvrIDCFt44OsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UcEz+OuxDy4s7T+ZvJzYezAotLM2ZVJzPAQbBygGYzOcDK6sNS8A/kBfFtkZlm0MR uBe6PydYNm6z9Bi+50Isu5dBVkvI9ya3ubcFSZZFWpiaTZF3E2tflNam/FCIJm41wR 7M2VErAXkQ0Iip6KgdjivqDkKt8uZSp+zxJPLoQE= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 12/16] vsp-lib: Centralize pad format setting in function Date: Wed, 9 Apr 2025 03:47:54 +0300 Message-ID: <20250409004758.11014-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Create a new vsp1_entity_set_format() function to set a pad format, and use it through the code. This prepares for automating configuration of colour space parameters. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 161 ++++++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 75 deletions(-) diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index d8722905cdc9..2e1980d5debb 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -77,6 +77,17 @@ vsp1_entity_get_size() { sed 's/.*\/\([0-9x]*\).*/\1/' } +vsp1_entity_set_format() { + local entity=$1 + local pad=$2 + local format=$3 + local size=$4 + shift 4 + local options="$*" + + $mediactl -d $mdev -V "'$dev $entity':$pad [fmt:$format/$size $options]" +} + vsp1_has_control() { local subdev=$(vsp1_entity_subdev $1) local control_name=$(echo $2 | tr '+' ' ') @@ -555,7 +566,7 @@ format_rpf() { local size=$2 local rpf=$3 - $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$format/$size]" + vsp1_entity_set_format rpf.$rpf 0 $format $size __vsp_rpf_format=$1 } @@ -571,13 +582,13 @@ __format_rpf_brx() { for input in `seq 0 1 $((ninputs-1))` ; do offset=$((offset+50)) - $mediactl -d $mdev -V "'$dev rpf.$input':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev $name':$input [fmt:$format/$size compose:($offset,$offset)/$size]" + vsp1_entity_set_format rpf.$input 0 $format $size + vsp1_entity_set_format $name $input $format $size "compose:($offset,$offset)/$size" done - $mediactl -d $mdev -V "'$dev $name':$output [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]" + vsp1_entity_set_format $name $output $format $size + vsp1_entity_set_format wpf.0 0 $format $size + vsp1_entity_set_format wpf.0 1 $format $size __vsp_rpf_format=$2 __vsp_wpf_format=$2 @@ -599,13 +610,13 @@ format_rpf_bru_uds() { local bru_output=$(vsp1_count_bru_inputs) - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev bru':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]" + vsp1_entity_set_format rpf.0 0 $infmt $insize + vsp1_entity_set_format bru 0 $infmt $insize + vsp1_entity_set_format bru $bru_output $infmt $insize + vsp1_entity_set_format uds.0 0 $infmt $insize + vsp1_entity_set_format uds.0 1 $infmt $outsize + vsp1_entity_set_format wpf.0 0 $infmt $outsize + vsp1_entity_set_format wpf.0 1 $outfmt $outsize [ $insize != $outsize ] && __vsp_pixel_perfect=false __vsp_rpf_format=$1 @@ -616,11 +627,11 @@ format_rpf_clu() { local format=$(format_v4l2_to_mbus $1) local size=$2 - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev clu':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev clu':1 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]" + vsp1_entity_set_format rpf.0 0 $format $size + vsp1_entity_set_format clu 0 $format $size + vsp1_entity_set_format clu 1 $format $size + vsp1_entity_set_format wpf.0 0 $format $size + vsp1_entity_set_format wpf.0 1 $format $size __vsp_rpf_format=$1 __vsp_wpf_format=$1 @@ -630,11 +641,11 @@ format_rpf_hst() { local format=$(format_v4l2_to_mbus $1) local size=$2 - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev hst':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev hst':1 [fmt:AHSV8888_1X32/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:AHSV8888_1X32/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:AHSV8888_1X32/$size]" + vsp1_entity_set_format rpf.0 0 $format $size + vsp1_entity_set_format hst 0 $format $size + vsp1_entity_set_format hst 1 AHSV8888_1X32 $size + vsp1_entity_set_format wpf.0 0 AHSV8888_1X32 $size + vsp1_entity_set_format wpf.0 1 AHSV8888_1X32 $size __vsp_rpf_format=$1 __vsp_wpf_format=$3 @@ -646,10 +657,10 @@ format_rpf_hgo() { local crop=${3:+crop:$3} local compose=${4:+compose:$4} - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev hgo':0 [fmt:$format/$size $crop $compose]" + vsp1_entity_set_format rpf.0 0 $format $size + vsp1_entity_set_format wpf.0 0 $format $size + vsp1_entity_set_format wpf.0 1 $format $size + vsp1_entity_set_format hgo 0 $format $size $crop $compose __vsp_histo_type=hgo __vsp_rpf_format=$1 @@ -662,12 +673,12 @@ format_rpf_hgt() { local crop=${3:+crop:$3} local compose=${4:+compose:$4} - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev hst':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev hgt':0 [fmt:$format/$size $crop $compose]" - $mediactl -d $mdev -V "'$dev hsi':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]" + vsp1_entity_set_format rpf.0 0 $format $size + vsp1_entity_set_format hst 0 $format $size + vsp1_entity_set_format hgt 0 $format $size $crop $compose + vsp1_entity_set_format hsi 0 $format $size + vsp1_entity_set_format wpf.0 0 $format $size + vsp1_entity_set_format wpf.0 1 $format $size __vsp_histo_type=hgt __vsp_rpf_format=$1 @@ -678,11 +689,11 @@ format_rpf_lut() { local format=$(format_v4l2_to_mbus $1) local size=$2 - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev lut':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev lut':1 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]" + vsp1_entity_set_format rpf.0 0 $format $size + vsp1_entity_set_format lut 0 $format $size + vsp1_entity_set_format lut 1 $format $size + vsp1_entity_set_format wpf.0 0 $format $size + vsp1_entity_set_format wpf.0 1 $format $size __vsp_rpf_format=$1 __vsp_wpf_format=$1 @@ -694,11 +705,11 @@ format_rpf_uds() { local outfmt=$(format_v4l2_to_mbus $3) local outsize=$4 - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]" + vsp1_entity_set_format rpf.0 0 $infmt $insize + vsp1_entity_set_format uds.0 0 $infmt $insize + vsp1_entity_set_format uds.0 1 $infmt $outsize + vsp1_entity_set_format wpf.0 0 $infmt $outsize + vsp1_entity_set_format wpf.0 1 $outfmt $outsize [ $insize != $outsize ] && __vsp_pixel_perfect=false __vsp_rpf_format=$1 @@ -713,13 +724,13 @@ format_rpf_uds_bru() { local bru_output=$(vsp1_count_bru_inputs) - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev bru':0 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]" + vsp1_entity_set_format rpf.0 0 $infmt $insize + vsp1_entity_set_format uds.0 0 $infmt $insize + vsp1_entity_set_format uds.0 1 $infmt $outsize + vsp1_entity_set_format bru 0 $infmt $outsize + vsp1_entity_set_format bru $bru_output $infmt $outsize + vsp1_entity_set_format wpf.0 0 $infmt $outsize + vsp1_entity_set_format wpf.0 1 $outfmt $outsize [ $insize != $outsize ] && __vsp_pixel_perfect=false __vsp_rpf_format=$1 @@ -733,13 +744,13 @@ format_rpf_uds_sru() { local outfmt=$(format_v4l2_to_mbus $4) local outsize=$5 - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$midsize]" - $mediactl -d $mdev -V "'$dev sru':0 [fmt:$infmt/$midsize]" - $mediactl -d $mdev -V "'$dev sru':1 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]" + vsp1_entity_set_format rpf.0 0 $infmt $insize + vsp1_entity_set_format uds.0 0 $infmt $insize + vsp1_entity_set_format uds.0 1 $infmt $midsize + vsp1_entity_set_format sru 0 $infmt $midsize + vsp1_entity_set_format sru 1 $infmt $outsize + vsp1_entity_set_format wpf.0 0 $infmt $outsize + vsp1_entity_set_format wpf.0 1 $outfmt $outsize __vsp_pixel_perfect=false __vsp_rpf_format=$1 @@ -752,11 +763,11 @@ format_rpf_sru() { local outfmt=$(format_v4l2_to_mbus $3) local outsize=$4 - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev sru':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev sru':1 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]" + vsp1_entity_set_format rpf.0 0 $infmt $insize + vsp1_entity_set_format sru 0 $infmt $insize + vsp1_entity_set_format sru 1 $infmt $outsize + vsp1_entity_set_format wpf.0 0 $infmt $outsize + vsp1_entity_set_format wpf.0 1 $outfmt $outsize __vsp_pixel_perfect=false __vsp_rpf_format=$1 @@ -770,13 +781,13 @@ format_rpf_sru_uds() { local outfmt=$(format_v4l2_to_mbus $4) local outsize=$5 - $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev sru':0 [fmt:$infmt/$insize]" - $mediactl -d $mdev -V "'$dev sru':1 [fmt:$infmt/$midsize]" - $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$midsize]" - $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]" - $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]" + vsp1_entity_set_format rpf.0 0 $infmt $insize + vsp1_entity_set_format sru 0 $infmt $insize + vsp1_entity_set_format sru 1 $infmt $midsize + vsp1_entity_set_format uds.0 0 $infmt $midsize + vsp1_entity_set_format uds.0 1 $infmt $outsize + vsp1_entity_set_format wpf.0 0 $infmt $outsize + vsp1_entity_set_format wpf.0 1 $outfmt $outsize __vsp_pixel_perfect=false __vsp_rpf_format=$1 @@ -834,10 +845,10 @@ format_rpf_wpf() { outsize=$rpfoutsize fi - $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size $rpfcrop]" - $mediactl -d $mdev -V "'$dev rpf.$rpf':1 [fmt:$midfmt/$rpfoutsize]" - $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$midfmt/$rpfoutsize $wpfcrop]" - $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]" + vsp1_entity_set_format rpf.$rpf 0 $infmt $size $rpfcrop + vsp1_entity_set_format rpf.$rpf 1 $midfmt $rpfoutsize + vsp1_entity_set_format wpf.$wpf 0 $midfmt $rpfoutsize $wpfcrop + vsp1_entity_set_format wpf.$wpf 1 $outfmt $outsize } format_wpf() { @@ -845,8 +856,8 @@ format_wpf() { local size=$2 local wpf=$3 - $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$format/$size]" - $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$format/$size]" + vsp1_entity_set_format wpf.$wpf 0 $format $size + vsp1_entity_set_format wpf.$wpf 1 $format $size __vsp_wpf_format=$1 } From patchwork Wed Apr 9 00:47:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043899 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1116A2C190 for ; Wed, 9 Apr 2025 00:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159728; cv=none; b=O97UgD2TS2vw1rWU9AdYaT4xiEdH3joJUotcPGbIGSDHnVeLbc/nSWqR+If1BXvO2jC26BHKf4ThcWeHWcHa6+qnZCD3gnEjh7WBdbLbzatXVqhY/bWp5gi6LLDpNve4sJO1IiE7eSUu/roe7rWnJrzhNiw7OTlakSONe30Pcy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159728; c=relaxed/simple; bh=qQWb81AfXXSMd9QPZvHWF4BO92V8i1WPOWYL8mOifNI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oRKSE66OdT5qXAAqkksSQigfFHELqcRrUObE02jfE05eVRyFd8nqasRvO+hrTN1MpP9/ip6Of9cNebbMv439kSg+z7jn+scxaT8n58LedrxXZMglX1kj04qo4q6A/sB+8hUSGAmSDDpZyEIw1QiSAfzGrhMG7bjR5D8+onRCgaM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=HCLPwdqq; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HCLPwdqq" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 623C71440; Wed, 9 Apr 2025 02:46:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159604; bh=qQWb81AfXXSMd9QPZvHWF4BO92V8i1WPOWYL8mOifNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HCLPwdqq5CeJPWuXKKneJ82aLPfFE2Pzbm6zp6Z63JxLe9a7tdQh425r6VxL6UCnM WLtNy5B0cnj+DqStBI/h1lLLtNgVEUrNF/dYFiPyCF1hw+VKLiIxo4UwAQJulLcBPM ZQZ7rZpi+v7kne/Xbu4ni78zQtTDX1tb8xHUMZkQ= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 13/16] vsp-lib: Use canonical media bus code names Date: Wed, 9 Apr 2025 03:47:55 +0300 Message-ID: <20250409004758.11014-14-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The media-ctl utility names media bus codes by stripping the MEDIA_BUS_FMT_ prefix from the kernel macro name. For a small set of formats, alternative names are supported for historical reasons. Their usage is discouraged, so use the canonical names in the tests. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index 2e1980d5debb..85f3fdef69d1 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -532,7 +532,7 @@ pipe_configure() { format_v4l2_to_mbus() { case $1 in RGB332 | ARGB555 | XRGB555 | RGB565 | BGR24 | RGB24 | XBGR32 | XRGB32 | ABGR32 | ARGB32) - echo "ARGB32"; + echo "ARGB8888_1X32"; ;; HSV24 | HSV32) @@ -540,7 +540,7 @@ format_v4l2_to_mbus() { ;; UYVY | VYUY | YUYV | YVYU | NV12M | NV16M | NV21M | NV61M | YUV420M | YUV422M | YUV444M | YVU420M | YVU422M | YVU444M) - echo "AYUV32" + echo "AYUV8_1X32" ;; *) @@ -558,7 +558,7 @@ format_v4l2_to_mbus() { format_v4l2_is_yuv() { local format=$(format_v4l2_to_mbus $1) - [ $format = 'AYUV32' ] + [ $format = 'AYUV8_1X32' ] } format_rpf() { From patchwork Wed Apr 9 00:47:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043900 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BD2A2C190 for ; Wed, 9 Apr 2025 00:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159730; cv=none; b=DvY/NjlOExYlMjCWH2ZMXmr7R/my2kZC7bZ3i1nPrIcRSmqu5MLLbIFuw7OBSyNRg46h/T+KFbgd2xWl+kaUkI+piqYyMGEcg5frljh1LFIbFoCjCgW9ZhHVxfoI6ivSUM6tiQJujpp4GZVG4mjWHfF1rom1WJtQDXKawGiPF34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159730; c=relaxed/simple; bh=KD+GGB+AMbGefdpwqsz5hyPsEY1mFzHDsohPBHOsJZs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mnV59Mczqt+KvMePSOvIFd44+E1bztXq9T6fpfxeCoReqdu7eSPBucP1lt95+Uu15+qZk9DH5iyPaMzPqOBv7JT/Esk+vjTB4jbNtGkqvqXDRpiaIr9ZvYOaUsg1XtCdaSE2PAV6TKdP4vbJwib9WEzTWbx+GsyqMMA+oLm4nHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=SqtQJ21W; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SqtQJ21W" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B9AA183D; Wed, 9 Apr 2025 02:46:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159605; bh=KD+GGB+AMbGefdpwqsz5hyPsEY1mFzHDsohPBHOsJZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SqtQJ21WM0Q/6BQ4Jn6sMx5Gak1m+KrV2x4y91GsHXH0ktibXFmphDgxmRGDeE6Tz P24begfdF0yr3E9q+cXoARl4dVjGetw+F85+IaTijkmt58BD8vjuzzSG8GoEiPN/dM JjYWumrqYFMb4Bc/IzGi8ZbH7eC5SOo5tu3Sd+bg= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 14/16] vsp-lib: Add support for color space Date: Wed, 9 Apr 2025 03:47:56 +0300 Message-ID: <20250409004758.11014-15-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support configuring the color space when setting formats on subdev pads and on video devices. As the VSP only cares about the encoding and quantization, the colorspace and transfer function parameters are not handled. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 82 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index 85f3fdef69d1..47828296285e 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -85,6 +85,12 @@ vsp1_entity_set_format() { shift 4 local options="$*" + if [ $format = 'AYUV8_1X32' ] ; then + options="$options ycbcr:$__vsp_encoding quantization:$__vsp_quantization" + else + options="$options ycbcr:601 quantization:full-range" + fi + $mediactl -d $mdev -V "'$dev $entity':$pad [fmt:$format/$size $options]" } @@ -115,6 +121,30 @@ vsp1_reset_controls() { $yavta --no-query --reset-controls $subdev | ./logger.sh "$entity" >> $logfile } +gen_image_csc_options() { + local options= + + case $__vsp_encoding in + 601) + options="$options -e BT.601" + ;; + 709) + options="$options -e REC.709" + ;; + esac + + case $__vsp_quantization in + lim-range) + options="$options -q limited" + ;; + full-range) + options="$options -q full" + ;; + esac + + echo "$options" +} + # ----------------------------------------------------------------------------- # Reference frame generation # @@ -206,6 +236,11 @@ reference_frame() { [ x$__vsp_brx_inputs != x ] && options="$options -c $__vsp_brx_inputs" + options="$options $(gen_image_csc_options)" + + echo "Generating reference frame with $genimage -i $in_format -f $out_format -s $size -a $alpha $options" | \ + ./logger.sh check >> $logfile + $genimage -i $in_format -f $out_format -s $size -a $alpha $options -o $file \ frames/frame-reference-1024x768.ppm } @@ -512,6 +547,8 @@ pipe_reset() { __vsp_rpf_format= __vsp_wpf_index=0 __vsp_wpf_format= + __vsp_encoding=601 + __vsp_quantization=lim-range __vsp_pixel_perfect=true } @@ -866,7 +903,23 @@ format_configure() { local pipe=${1//-/_} shift 1 - format_$pipe $* + local options + local arg + + for arg in $* ; do + case $arg in + --encoding=*) + local encoding=${arg/--encoding=/} + __vsp_encoding=${encoding%:*} + __vsp_quantization=${encoding#*:} + ;; + *) + options="$options $arg" + ;; + esac + done + + format_$pipe $options } # ------------------------------------------------------------------------------ @@ -886,9 +939,10 @@ hgt_configure() { # generate_input_frame() { - local file=$1 - local format=$2 - local size=$3 + local entity=$1 + local file=$2 + local format=$3 + local size=$4 local alpha= local options= @@ -910,6 +964,11 @@ generate_input_frame() { $(format_v4l2_is_yuv $format) && options="$options -C -i YUV444M" + options="$options $(gen_image_csc_options)" + + echo "Generating input frame with $genimage -f $format -s $size -a $alpha $options" | \ + ./logger.sh $entity >> $logfile + $genimage -f $format -s $size -a $alpha $options -o $file \ frames/frame-reference-1024x768.ppm } @@ -952,6 +1011,7 @@ vsp_runner() { local videodev local format local size + local csc case $entity in hgo) @@ -971,7 +1031,7 @@ vsp_runner() { format=$__vsp_rpf_format size=$(vsp1_entity_get_size $entity 0) file=${frames_dir}${entity}.bin - generate_input_frame $file $format $size + generate_input_frame $entity $file $format $size ;; wpf.*) @@ -982,7 +1042,17 @@ vsp_runner() { ;; esac - $yavta -c$count -n $buffers ${format:+-f $format} ${size:+-s $size} \ + if [ x$format != 'x' ] ; then + if [ $(format_v4l2_to_mbus $format) = 'AYUV8_1X32' ] ; then + local encoding=$(echo $__vsp_encoding | tr '[:lower:]-' '[:upper:]_') + local quantization=$(echo $__vsp_quantization | tr '[:lower:]-' '[:upper:]_') + csc="--encoding $encoding --quantization $quantization" + else + csc="--encoding 601 --quantization FULL_RANGE" + fi + fi + + $yavta -c$count -n $buffers ${format:+-f $format} ${size:+-s $size} $csc \ ${skip:+--skip $skip} ${file:+--file=$file} ${pause:+-p$pause} \ $videodev | ./logger.sh $entity >> $logfile } From patchwork Wed Apr 9 00:47:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043901 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 241553E47B for ; Wed, 9 Apr 2025 00:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159731; cv=none; b=jJn1RdVzAe2IbRlegh08XArJ+NCqrjXQ4A0h7p4xfROUQzjtHuiLPc8G2T/LFjevZdH3cwONOscnSmQ5sALRzTMfeC98yTfOge1rDeKzF6QRQIcJpuPBZOYrMrfYob1Rzy8wh2g5UihvRiKJqPy5l6WY8RZcqV/I8YHAyJ7AWaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159731; c=relaxed/simple; bh=iG6bbHir4U+SlquzrIuANlxmJUEL/YGfgDPY7mCCzc0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aSHLt4hChBVvMfnJYs3UlRwH7dfBkSph3zAApS4BjUxS/9J5OpuEoK8jHyFj+LgaU/wau1BXMeN53DHVU7H0BNbdcK5c4/v7/BLx8TDhl5h0I7wvlY1AIp2YQB4Hcrp6EkgbNfTlnI8L9njyxPntyJINHONa9sFi6+dTplfs4mw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=ItphXU+r; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ItphXU+r" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0AD94EF2; Wed, 9 Apr 2025 02:46:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159607; bh=iG6bbHir4U+SlquzrIuANlxmJUEL/YGfgDPY7mCCzc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItphXU+rh2o5FiEMQ5MKbHLurOPjytnGIzUqey4lUg7WrpFawDR+Suhx/DEGQDaD2 7qAhJtRHB8M4kisBPfGIqQgLFXaC4KhUmfsLgwJliBfFC3d2KRj51JSe9Rjpccxnq+ JxfrTUsBdNOkX3fInXPE0wfVekPYDXN3/3fRr7Hc= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 15/16] tests: Add WPF RGB to YUV conversion test Date: Wed, 9 Apr 2025 03:47:57 +0300 Message-ID: <20250409004758.11014-16-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a test case to validate RGB <-> YUV conversion in the RPF and WPF. Signed-off-by: Laurent Pinchart --- tests/meson.build | 1 + tests/vsp-unit-test-0028.sh | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 tests/vsp-unit-test-0028.sh diff --git a/tests/meson.build b/tests/meson.build index e5396cc0a132..6c3ebd28095f 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -29,6 +29,7 @@ tests = files([ 'vsp-unit-test-0025.sh', 'vsp-unit-test-0026.sh', 'vsp-unit-test-0027.sh', + 'vsp-unit-test-0028.sh', ]) install_data(tests, install_dir : get_option('prefix')) diff --git a/tests/vsp-unit-test-0028.sh b/tests/vsp-unit-test-0028.sh new file mode 100755 index 000000000000..23a4f411e863 --- /dev/null +++ b/tests/vsp-unit-test-0028.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2025 Renesas Electronics Corporation + +# +# Test RGB to YUV conversion in RPF and WPF. +# + +. ./vsp-lib.sh + +features="rpf.0 wpf.0" +formats="RGB24-YUV444M YUV444M-RGB24" + +test_rwpf_csc() { + local rwpf=$1 + local format=$2 + local infmt=${format%-*} + local outfmt=${format#*-} + local midfmt + + test_start "$rwpf CSC $infmt -> $outfmt" + + if [ $rwpf = 'RPF' ] ; then + midfmt=$outfmt + else + midfmt=$infmt + fi + + pipe_configure rpf-wpf 0 0 + format_configure rpf-wpf 0 0 $infmt 1024x768 $outfmt --midfmt=$midfmt + + vsp_runner rpf.0 & + vsp_runner wpf.0 + + local result=$(compare_frames) + + test_complete $result +} + +test_main() { + local format + + for rwpf in RPF WPF ; do + for format in $formats ; do + test_rwpf_csc $rwpf $format + done + done +} + +test_init $0 "$features" +test_run From patchwork Wed Apr 9 00:47:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14043902 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 020812C190 for ; Wed, 9 Apr 2025 00:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159733; cv=none; b=mJqusVc1dU/o2tbOisEuno39KBRSD8vEg9yZeSXHvFIJQluPZJKsKSTJUcd7rzcOJx9zMjGGdNFX3eAHUsVqMMV6va+fT4H2qkVZSfdgmPcbJR1JcM8yg27rlKIRJm/XhsMvwYH4wfAGUAujdSUfeHXZ4AS+dYGQNSjuFPBAxr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744159733; c=relaxed/simple; bh=yydOIbzrQK0HysdALPaTgH1T1ytoNpw9dTgj75L/HzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KKq1ZAnoSNxCw77XzBsPTtqR4Qvxi8+DbQe365n8vsykFZsTL/XbdVop+4mAG3ngm3WJDPP1my7Sp65SU7Ez2ISsY8aK0V7SnBLdfLfnOhBsAOPw3aRbulnd+njSjrri7qI/Pr+g8j/0pyEnkVbm8Sng85L+LTNfcA+DJvgpMDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=RAzrx6/1; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RAzrx6/1" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6DA6399F; Wed, 9 Apr 2025 02:46:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744159608; bh=yydOIbzrQK0HysdALPaTgH1T1ytoNpw9dTgj75L/HzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RAzrx6/1mInL+5WJ7x3hkuiKa/fJSPbAUwIRseh7Ayi5CHww3wAe03EVdjCcZJ0+D CJpNXlYjdmQc0eX2rGhkZW7Doj4WrUIFy+z6YYW0QytFkv6d07Q5ow7GXDbtY0IsEi NyJMfYPfwnM/VXFb/WesJ0cks2wJqwwg396JITHc= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jacopo Mondi Subject: [vsp-tests] [PATCH 16/16] tests: Add color space support to RGB <-> YUV conversion test Date: Wed, 9 Apr 2025 03:47:58 +0300 Message-ID: <20250409004758.11014-17-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> References: <20250409004758.11014-1-laurent.pinchart@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Run the YUV <-> RGB conversion test with all four color spaces supported by the VSP. Signed-off-by: Laurent Pinchart --- tests/vsp-unit-test-0028.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/vsp-unit-test-0028.sh b/tests/vsp-unit-test-0028.sh index 23a4f411e863..5016e65cb865 100755 --- a/tests/vsp-unit-test-0028.sh +++ b/tests/vsp-unit-test-0028.sh @@ -16,9 +16,10 @@ test_rwpf_csc() { local format=$2 local infmt=${format%-*} local outfmt=${format#*-} + local encoding=$3 local midfmt - test_start "$rwpf CSC $infmt -> $outfmt" + test_start "$rwpf CSC $infmt -> $outfmt ($encoding)" if [ $rwpf = 'RPF' ] ; then midfmt=$outfmt @@ -27,12 +28,12 @@ test_rwpf_csc() { fi pipe_configure rpf-wpf 0 0 - format_configure rpf-wpf 0 0 $infmt 1024x768 $outfmt --midfmt=$midfmt + format_configure rpf-wpf 0 0 $infmt 1024x768 $outfmt --midfmt=$midfmt --encoding=$encoding vsp_runner rpf.0 & vsp_runner wpf.0 - local result=$(compare_frames) + local result=$(compare_frames $rwpf-$encoding) test_complete $result } @@ -42,7 +43,9 @@ test_main() { for rwpf in RPF WPF ; do for format in $formats ; do - test_rwpf_csc $rwpf $format + for encoding in 601:lim-range 601:full-range 709:lim-range 709:full-range ; do + test_rwpf_csc $rwpf $format $encoding + done done done }