From patchwork Mon Dec 5 08:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13064241 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55E2DC47089 for ; Mon, 5 Dec 2022 08:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231757AbiLEIEW (ORCPT ); Mon, 5 Dec 2022 03:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231890AbiLEIEA (ORCPT ); Mon, 5 Dec 2022 03:04:00 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 989E4140CA for ; Mon, 5 Dec 2022 00:03:57 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 88B25327; Mon, 5 Dec 2022 09:03:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1670227435; bh=RJSk9Ao0qd6V7FXWv0DRYRkusTmCqnEJ4tMuqhfM5/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tYWuavNtqiYxt4bCfcKPDXfevILxky9baK1OYnd1QSxo+ww7mcJLv8rFRcdQ+1PeA HF+2Nu4NTe0CK0d/+ezsH/24xxRAg1C1iG9Rt/OzjA5KN7+b6+ZYbBt+TQF0afVCln ew4dB6FVdUpVTHcEaLXTz1uF+ORhstOEFlcBipr8= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ v2 1/4] kms++: PixelFormats: Fix formatting Date: Mon, 5 Dec 2022 10:03:36 +0200 Message-Id: <20221205080339.12801-2-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Fix formatting for some pixel formats. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- kms++/src/pixelformats.cpp | 76 +++++--------------------------------- 1 file changed, 10 insertions(+), 66 deletions(-) diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp index d739efd..1f10f3a 100644 --- a/kms++/src/pixelformats.cpp +++ b/kms++/src/pixelformats.cpp @@ -32,109 +32,53 @@ static const map format_info_array = { { PixelFormat::NV12, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, - { 8, 2, 2 } }, + { { 8, 1, 1 }, { 8, 2, 2 } }, } }, { PixelFormat::NV21, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, - { 8, 2, 2 } }, + { { 8, 1, 1 }, { 8, 2, 2 } }, } }, { PixelFormat::NV16, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, - { 8, 2, 1 } }, + { { 8, 1, 1 }, { 8, 2, 1 } }, } }, { PixelFormat::NV61, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, - { 8, 2, 1 } }, + { { 8, 1, 1 }, { 8, 2, 1 } }, } }, /* YUV planar */ { PixelFormat::YUV420, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, - { 8, 2, 2 }, - { 8, 2, 2 } }, + { { 8, 1, 1 }, { 8, 2, 2 }, { 8, 2, 2 } }, } }, { PixelFormat::YVU420, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, - { 8, 2, 2 }, - { 8, 2, 2 } }, + { { 8, 1, 1 }, { 8, 2, 2 }, { 8, 2, 2 } }, } }, { PixelFormat::YUV422, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, - { 8, 2, 1 }, - { 8, 2, 1 } }, + { { 8, 1, 1 }, { 8, 2, 1 }, { 8, 2, 1 } }, } }, { PixelFormat::YVU422, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, - { 8, 2, 1 }, - { 8, 2, 1 } }, + { { 8, 1, 1 }, { 8, 2, 1 }, { 8, 2, 1 } }, } }, { PixelFormat::YUV444, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, - { 8, 1, 1 }, - { 8, 1, 1 } }, + { { 8, 1, 1 }, { 8, 1, 1 }, { 8, 1, 1 } }, } }, { PixelFormat::YVU444, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, - { 8, 1, 1 }, - { 8, 1, 1 } }, + { { 8, 1, 1 }, { 8, 1, 1 }, { 8, 1, 1 } }, } }, /* RGB8 */ { PixelFormat::RGB332, { From patchwork Mon Dec 5 08:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13064242 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32CFBC4321E for ; Mon, 5 Dec 2022 08:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231843AbiLEIE0 (ORCPT ); Mon, 5 Dec 2022 03:04:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231932AbiLEIEE (ORCPT ); Mon, 5 Dec 2022 03:04:04 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A76A2653 for ; Mon, 5 Dec 2022 00:04:01 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 07357CCE; Mon, 5 Dec 2022 09:03:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1670227436; bh=cwFqxegfDkPxigOFKjnREtiv0SOZI+2rLLBZOCEaVx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ShKzfsQgcp6Ln4CEZjVFJ7wXqxRLrMWL55WhK/RNp7gJ8YgNTjt0tDyldTdwnDtZI yrKDWO6fw56XdVrz8Dxxn6fjJBob/z3gZDIitsUORP6SeNoyPrCz1q3zv642bLWkSv d09i0HC+h2/GspLVaxoL3QPlaoe4T2/NABEbAj3Y= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ v2 2/4] kms++: PixelFormats: Add Y21x formats Date: Mon, 5 Dec 2022 10:03:37 +0200 Message-Id: <20221205080339.12801-3-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add Y210, Y212, Y216 pixel formats. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- kms++/inc/kms++/pixelformats.h | 4 ++++ kms++/src/pixelformats.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h index 8ebb76b..e334ee6 100644 --- a/kms++/inc/kms++/pixelformats.h +++ b/kms++/inc/kms++/pixelformats.h @@ -31,6 +31,10 @@ enum class PixelFormat : uint32_t { YVYU = MakeFourCC("YVYU"), VYUY = MakeFourCC("VYUY"), + Y210 = MakeFourCC("Y210"), + Y212 = MakeFourCC("Y212"), + Y216 = MakeFourCC("Y216"), + XRGB8888 = MakeFourCC("XR24"), XBGR8888 = MakeFourCC("XB24"), RGBX8888 = MakeFourCC("RX24"), diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp index 1f10f3a..5f13ef4 100644 --- a/kms++/src/pixelformats.cpp +++ b/kms++/src/pixelformats.cpp @@ -28,6 +28,22 @@ static const map format_info_array = { 1, { { 16, 2, 1 } }, } }, + { PixelFormat::Y210, { + PixelColorType::YUV, + 1, + { { 32, 2, 1 } }, + } }, + { PixelFormat::Y212, { + PixelColorType::YUV, + 1, + { { 32, 2, 1 } }, + } }, + { PixelFormat::Y216, { + PixelColorType::YUV, + 1, + { { 32, 2, 1 } }, + } }, + /* YUV semi-planar */ { PixelFormat::NV12, { PixelColorType::YUV, From patchwork Mon Dec 5 08:03:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13064243 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E60C47088 for ; Mon, 5 Dec 2022 08:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbiLEIE0 (ORCPT ); Mon, 5 Dec 2022 03:04:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbiLEIEE (ORCPT ); Mon, 5 Dec 2022 03:04:04 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D5712AD4 for ; Mon, 5 Dec 2022 00:04:01 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 76975E51; Mon, 5 Dec 2022 09:03:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1670227436; bh=UQRXNGAhA4L/hnszM6rDUJW4RAZJYClnRti4JR4Py3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dzu0Uqotshvc3mm1TH/jXsI3OxGmR4TShv+mYyxgv3lZsoIqrHyfLtstfrgksekNj zsUR63uI8rqK7J4n3vzkLeYBcraxH24bn1LfBJVwZIRht4lW4KVuV3QT8RwIyz9cos 1jaP0cQuB/gDgwLKUOmZuR0QKbaquoS5WoSqAipg= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ v2 3/4] kms++util: Add endian.h Date: Mon, 5 Dec 2022 10:03:38 +0200 Message-Id: <20221205080339.12801-4-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add simple endianness supporting write function, and, for now, only one shortcut helper, write16le(). Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- kms++util/inc/kms++util/endian.h | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 kms++util/inc/kms++util/endian.h diff --git a/kms++util/inc/kms++util/endian.h b/kms++util/inc/kms++util/endian.h new file mode 100644 index 0000000..0f7aecd --- /dev/null +++ b/kms++util/inc/kms++util/endian.h @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include + +static_assert((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || + (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__), + "Unable to detect endianness"); + +enum class endian { + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__ +}; + +template +constexpr T byteswap(T value) noexcept +{ + static_assert(std::is_integral(), "Type is not integral"); + static_assert(sizeof(T) == 2 || + sizeof(T) == 4 || + sizeof(T) == 8, + "Illegal value size"); + + switch (sizeof(T)) { + case 2: return bswap_16(value); + case 4: return bswap_32(value); + case 8: return bswap_64(value); + } +} + +template +static void write_endian(T* dst, T val) +{ + if constexpr (E != endian::native) + val = byteswap(val); + + *dst = val; +} + +[[maybe_unused]] +static void write16le(uint16_t* dst, uint16_t val) +{ + write_endian(dst, val); +} From patchwork Mon Dec 5 08:03:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13064244 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55CC7C4321E for ; Mon, 5 Dec 2022 08:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231842AbiLEIE3 (ORCPT ); Mon, 5 Dec 2022 03:04:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231898AbiLEIEJ (ORCPT ); Mon, 5 Dec 2022 03:04:09 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8608814D29 for ; Mon, 5 Dec 2022 00:04:05 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ED611E61; Mon, 5 Dec 2022 09:03:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1670227437; bh=6wJnjausWa0Z2FuTFMYU+22uYsRViu0qKKBsV1hwgQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mfjgt+y5PmRxMMQ/vFv19iLbbp/Tr7Q3qLQr4FlPwtPDENApjt4uj9sonP1dk6lkb junQ8lFD9tfMqPn2Ye1K9CYZvt2ziuvLhoNQ6W709DEhpLUr2nGFwr48mL+lXHEE8V zu2e0vQRT+SppLZmJ0czfOA15UiTRNYrvpf6FdOk= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ v2 4/4] kms++util: Add Y21x drawing support Date: Mon, 5 Dec 2022 10:03:39 +0200 Message-Id: <20221205080339.12801-5-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221205080339.12801-1-tomi.valkeinen+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add support for drawing Y210, Y212, Y216 pixels. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- kms++util/src/drawing.cpp | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp index 79e0d90..5764b08 100644 --- a/kms++util/src/drawing.cpp +++ b/kms++util/src/drawing.cpp @@ -3,6 +3,7 @@ #include #include +#include using namespace std; @@ -179,6 +180,62 @@ static void draw_yuv422_packed_macropixel(IFramebuffer& buf, unsigned x, unsigne } } +static void draw_y2xx_packed_macropixel(IFramebuffer& buf, unsigned x, unsigned y, + YUV yuv1, YUV yuv2) +{ + const uint32_t macro_size = 4; + uint16_t* p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * macro_size); + + switch (buf.format()) { + case PixelFormat::Y210: { + // XXX naive expansion to 10 bits, similar to 10-bit funcs in class RGB + uint16_t y0 = yuv1.y << 2; + uint16_t y1 = yuv2.y << 2; + uint16_t cb = ((yuv1.u << 2) + (yuv2.u << 2)) / 2; + uint16_t cr = ((yuv1.v << 2) + (yuv2.v << 2)) / 2; + + // The 10 bits occupy the msb, so we shift left by 16-10 = 6 + write16le(&p[0], y0 << 6); + write16le(&p[1], cb << 6); + write16le(&p[2], y1 << 6); + write16le(&p[3], cr << 6); + break; + } + + case PixelFormat::Y212: { + // XXX naive expansion to 12 bits + uint16_t y0 = yuv1.y << 4; + uint16_t y1 = yuv2.y << 4; + uint16_t cb = ((yuv1.u << 4) + (yuv2.u << 4)) / 2; + uint16_t cr = ((yuv1.v << 4) + (yuv2.v << 4)) / 2; + + // The 10 bits occupy the msb, so we shift left by 16-12 = 4 + write16le(&p[0], y0 << 4); + write16le(&p[1], cb << 4); + write16le(&p[2], y1 << 4); + write16le(&p[3], cr << 4); + break; + } + + case PixelFormat::Y216: { + // XXX naive expansion to 16 bits + uint16_t y0 = yuv1.y << 8; + uint16_t y1 = yuv2.y << 8; + uint16_t cb = ((yuv1.u << 8) + (yuv2.u << 8)) / 8; + uint16_t cr = ((yuv1.v << 8) + (yuv2.v << 8)) / 8; + + write16le(&p[0], y0); + write16le(&p[1], cb); + write16le(&p[2], y1); + write16le(&p[3], cr); + break; + } + + default: + throw std::invalid_argument("invalid pixelformat"); + } +} + static void draw_yuv422_semiplanar_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2) { @@ -257,6 +314,12 @@ void draw_yuv422_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, draw_yuv422_packed_macropixel(buf, x, y, yuv1, yuv2); break; + case PixelFormat::Y210: + case PixelFormat::Y212: + case PixelFormat::Y216: + draw_y2xx_packed_macropixel(buf, x, y, yuv1, yuv2); + break; + case PixelFormat::NV16: case PixelFormat::NV61: draw_yuv422_semiplanar_macropixel(buf, x, y, yuv1, yuv2);