From patchwork Fri Dec 2 13:16:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13062737 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 148A9C4167B for ; Fri, 2 Dec 2022 13:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232966AbiLBNR2 (ORCPT ); Fri, 2 Dec 2022 08:17:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232873AbiLBNR1 (ORCPT ); Fri, 2 Dec 2022 08:17:27 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF843D11EB for ; Fri, 2 Dec 2022 05:17:25 -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 A8228151A; Fri, 2 Dec 2022 14:17:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669987044; bh=L+/4y0Ua/KqkzQDKv6gUlR2Gp2tUoQ4VfYnyEM5M9LE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXEbBDmsuJX9bwj9UjK5rH1jaoTCFd5BrXNSyJl+byq4IS+zvF3bdYVU1MGILmbnO 4Q80iukC/M8/oKzvti9zQclvBsrbZJyPxtF2pTx1rHDhZ7+WDtTX6I3LeX/iRkdGzC VxO9ANfvNeV88khOrffFS87WFeWklQk12HoZZMxc= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ 1/4] kms++: PixelFormats: Fix formatting Date: Fri, 2 Dec 2022 15:16:55 +0200 Message-Id: <20221202131658.434114-2-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221202131658.434114-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221202131658.434114-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 | 60 +++++++------------------------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp index d739efd..7afbf09 100644 --- a/kms++/src/pixelformats.cpp +++ b/kms++/src/pixelformats.cpp @@ -32,107 +32,67 @@ static const map format_info_array = { { PixelFormat::NV12, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 2, 2 } }, } }, { PixelFormat::NV21, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 2, 2 } }, } }, { PixelFormat::NV16, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 2, 1 } }, } }, { PixelFormat::NV61, { PixelColorType::YUV, 2, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 2, 1 } }, } }, /* YUV planar */ { PixelFormat::YUV420, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 2, 2 }, { 8, 2, 2 } }, } }, { PixelFormat::YVU420, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 2, 2 }, { 8, 2, 2 } }, } }, { PixelFormat::YUV422, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 2, 1 }, { 8, 2, 1 } }, } }, { PixelFormat::YVU422, { PixelColorType::YUV, 3, - { { - 8, - 1, - 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 } }, } }, { PixelFormat::YVU444, { PixelColorType::YUV, 3, - { { - 8, - 1, - 1, - }, + { { 8, 1, 1 }, { 8, 1, 1 }, { 8, 1, 1 } }, } }, From patchwork Fri Dec 2 13:16:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13062738 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 42F4FC47089 for ; Fri, 2 Dec 2022 13:17:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233143AbiLBNR3 (ORCPT ); Fri, 2 Dec 2022 08:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232011AbiLBNR2 (ORCPT ); Fri, 2 Dec 2022 08:17:28 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02ACDD0391 for ; Fri, 2 Dec 2022 05:17:28 -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 33FB2158D; Fri, 2 Dec 2022 14:17:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669987044; bh=Njv56V9L49c5sQ3FG5DlqfUC69eMZkcsCMS7VJwV4FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NSyWbjYOQ5lpwqZdzvWBMDAH8VLQVRbxdV9FSVnvO8l8lqWFM1rkpVriqdnpPQSug 03kABvomh7tRFXT+0JpbT3Czlw/GOfgSse3IVwkVcJnULcD38B0ZqYuiOMIcaL1G5Z 5IU2YFVZsBKPIksr6xPvCsnpGSBPyBkWyTkPqGLw= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ 2/4] kms++: PixelFormats: Add Y210 format Date: Fri, 2 Dec 2022 15:16:56 +0200 Message-Id: <20221202131658.434114-3-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221202131658.434114-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221202131658.434114-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 pixel format. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- kms++/inc/kms++/pixelformats.h | 2 ++ kms++/src/pixelformats.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h index 6f2671b..35261a9 100644 --- a/kms++/inc/kms++/pixelformats.h +++ b/kms++/inc/kms++/pixelformats.h @@ -31,6 +31,8 @@ enum class PixelFormat : uint32_t { YVYU = MakeFourCC("YVYU"), VYUY = MakeFourCC("VYUY"), + Y210 = MakeFourCC("Y210"), + XRGB8888 = MakeFourCC("XR24"), XBGR8888 = MakeFourCC("XB24"), RGBX8888 = MakeFourCC("RX24"), diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp index 7afbf09..89eece4 100644 --- a/kms++/src/pixelformats.cpp +++ b/kms++/src/pixelformats.cpp @@ -28,6 +28,12 @@ static const map format_info_array = { 1, { { 16, 2, 1 } }, } }, + { PixelFormat::Y210, { + PixelColorType::YUV, + 1, + { { 32, 2, 1 } }, + } }, + /* YUV semi-planar */ { PixelFormat::NV12, { PixelColorType::YUV, From patchwork Fri Dec 2 13:16:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13062739 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 9E0F8C4321E for ; Fri, 2 Dec 2022 13:17:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232011AbiLBNRa (ORCPT ); Fri, 2 Dec 2022 08:17:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232873AbiLBNR2 (ORCPT ); Fri, 2 Dec 2022 08:17:28 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D8FAD11EB for ; Fri, 2 Dec 2022 05:17:28 -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 A338E16B6; Fri, 2 Dec 2022 14:17:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669987044; bh=ZtkycX0MxCw8BpLMiZsfPY7Z6dley9TNj4JeQxc11P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mzjxas9ccMLXzEGjg1xWwJbVF6VzpVOLP8Wpzs4aHHpZeUJ1IYu4FLe306D5WdsA7 MBHeWWXzSDNvf+mCQFAKXgKJR+hqURD9XLVZANcLHutfKPlJFuYkMsYr+K/KklA+H/ uiDC7p3VVNIhEKbMHk0OjJCNl6O1Mfuf7jJoGvLQ= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ 3/4] kms++util: Add endian.h Date: Fri, 2 Dec 2022 15:16:57 +0200 Message-Id: <20221202131658.434114-4-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221202131658.434114-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221202131658.434114-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..ea09065 --- /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 val, T* dst) +{ + if constexpr (E != endian::native) + val = byteswap(val); + + *dst = val; +} + +[[maybe_unused]] +static void write16le(uint16_t val, uint16_t* dst) +{ + write_endian(val, dst); +} From patchwork Fri Dec 2 13:16:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13062740 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 A8CE9C47088 for ; Fri, 2 Dec 2022 13:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233182AbiLBNRb (ORCPT ); Fri, 2 Dec 2022 08:17:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232873AbiLBNRa (ORCPT ); Fri, 2 Dec 2022 08:17:30 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8AAAD0391 for ; Fri, 2 Dec 2022 05:17:29 -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 25C9016C4; Fri, 2 Dec 2022 14:17:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669987045; bh=YnxGlYAV8mV1R7AK/9SpjDzziSeonFLwYY+ZQAtaZw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qr1AhCSLzbHP15LBwTxCqppNmtEr8PM2jsJFd/MsSVMU5K15MPb7UeNsiLvQPDMOF s9GmaIu3cwz1oqP5RFviQrV+iERbU8lLGMryKWG+UsFh6gI1pKrPcz36fY8s4B7IVU F1MJaPd6aOsrGEHT6Wf38eCgKG8q+0nA1yXs+n2g= From: Tomi Valkeinen To: linux-renesas-soc@vger.kernel.org, Laurent Pinchart , Kieran Bingham Cc: Tomi Valkeinen Subject: [PATCH kms++ 4/4] kms++util: Add Y210 drawing support Date: Fri, 2 Dec 2022 15:16:58 +0200 Message-Id: <20221202131658.434114-5-tomi.valkeinen+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221202131658.434114-1-tomi.valkeinen+renesas@ideasonboard.com> References: <20221202131658.434114-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 pixels. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- kms++util/src/drawing.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp index 79e0d90..7e1b40b 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,32 @@ 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 shift left, 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; + + write16le(y0, &p[0]); + write16le(cb, &p[1]); + write16le(y1, &p[2]); + write16le(cr, &p[3]); + 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 +284,10 @@ 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: + 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);