From patchwork Thu Aug 8 12:13:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 817793 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2010.outbound.protection.outlook.com [40.92.103.10]) (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 6263918A956; Thu, 8 Aug 2024 12:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.103.10 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723119201; cv=fail; b=mQrlnNJPsM/dbSyok4WP8xovjQJhjcQJPwWS5Gph9vgMyQyKgKdoLHQj66vuljHPbrANr2S4rEBUFpQmmPaphgTOYA4ZiRr8uWdEhUGAzoXyry/Wg3TuJ+D+oACg3gvNEkXZzxOSxoSGkS95TG3kp99cuG1qV5YyAAiaRD9WB8o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723119201; c=relaxed/simple; bh=k2qTvJJuKQ9yjna5tCPRpIpR+Mhe7F9Wvq5AaQD3p4o=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=Xi06Rqf9VlIl4E1gMsP2rAEhpgHZ9BLU5EeFGQwJ/cDknbtAh10UOR6EsHbgCaQHBQoX1cEDI9WHCWV7SPAIxw4ZTg0FiC0V3T0G+Ss01lzYRwzDzPtvJDoIzbQMLQKV7i91eXCwkzHN/Lv59RlfQ1eZT639AaUoflSBxtF4gLo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=Kp2BFGt+; arc=fail smtp.client-ip=40.92.103.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="Kp2BFGt+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VaS7CIuUqsgsvdFlSly2s5mQOokWhHD2qYsE2L5KyB34OSmidsFOFnnOemIp839inAgJBHOeYNotD8uUYMNfuQqffsMIxbGQSmYidf/K9qmbYZvKulTvr9Bv0tHAdcO85DTMH6c460zYgrDS86g6DQ2EoWF+0t7pUYmmgtBuyZnzWFQc+G1W/jBakyXQT4/jyRTb87OiO3zldgT6jguHJi/d/exIvPDNbG7PtB3yyxkUDURSbq+MqfB/41zDPaMb+msuJDRSPZWyjPy101tYlNdwR4i6UKlHjPa3+Q8AJ1jvMMbzCAqfNejco5v+dfrcUmndau5+1uGFab14grVsUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OtdQ3/r+0UdrKlCuSHzXkJk1YWEEi4Wt1GXubHNHEfc=; b=cH/bdha/X6Ds49K2JONPB4GsjgabJZFYsVGJXs0SYPPIjmk9VWPbh3GLpPUlZXUVFBkb/QevXBIUDKmZcXXG39IWnaUruh1bLosy/LdjxzT+zu9sHg/v787ok5OwHyCb1f6L3OaI3ZnsNigSAthrXcv8gdA00R7ZLVFEpiluDuc8r2nc6bUXaP5J0nAcwc5zQkcZSfa2J9eNIlFCBH336x2mh1FgNRqwsiKwJNvitA88N1oMS42hu9bNKwKy1v6cGpCBcVbMhmo7oICOcFOB38Z/47aFu91Vyr3C1/R/M//OjcnMcZcfDmXcadWdimxvfi+1vZSDJp2kUWqFR5ifIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OtdQ3/r+0UdrKlCuSHzXkJk1YWEEi4Wt1GXubHNHEfc=; b=Kp2BFGt+6K3aDhsw8wjKURZZ6fkpcmvkgWDwBPQd45m/rMPH1CbucjJplPvJeYeoDeg/vOLUNuFwUALPOdfMp4Bdog1RQUE0VI1r9Hk0S57uV6Y+J7kEdhNG5xD2H/d/KTNzCYFlJb51meyWGVRp3BwFMIScoexS570B34L470MU0m/bH/PrFPM4MqboZODvAiFsVJ8kWHM3zL2Iup8D4blCG0ULVxcfP3qKtce9/sQcX1wV9MoeMIQ5jhIiG1c1J42YwZHp9YANshqMbqnC1/7vBZCuQdYdyH2LpsMCSyxRYVquzVncwaKaFiFPZiaRPJy5lNJ9w1Y0c2Q5lLgCAA== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by PN2P287MB2144.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:1c5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13; Thu, 8 Aug 2024 12:13:10 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 12:13:10 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH RESEND v2 8/9] drm/format-helper: Add conversion from XRGB8888 to BGR888 Thread-Topic: [PATCH RESEND v2 8/9] drm/format-helper: Add conversion from XRGB8888 to BGR888 Thread-Index: AQHa6YxVlajliY3BmUmFXaQEzoUoow== Date: Thu, 8 Aug 2024 12:13:10 +0000 Message-ID: References: <752D8EEA-EE3B-4854-9B5E-F412AFA20048@live.com> In-Reply-To: <752D8EEA-EE3B-4854-9B5E-F412AFA20048@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [UeTAULfIFEQ45uuhlBBtcqYHGJOhzlOrWc2cdcNz2qrLsZN06MQTm7L7r7B7/Bd8njuN8jO6+Fw=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|PN2P287MB2144:EE_ x-ms-office365-filtering-correlation-id: b873eca1-6da0-4086-a5db-08dcb7a37824 x-microsoft-antispam: BCL:0; ARA:14566002|461199028|15080799003|19110799003|8060799006|102099032|3412199025|440099028; x-microsoft-antispam-message-info: VRgWMOV6UKEebcoMBjROchWKDslqvT1MT1FXNAVqTuzNpJMAKqbOI/keUAhr1ll8qEUfldgnkH3hqezR5nbZ2ARDyW8kazA+NQJZ3jUSaqZsD04Fhk3ixmq7zo4zsnsbaxnV5ZzDrijmhd0KjYka6KcfR/N8/i2nBWc2NVJDafwzyX2Z5wsYAihRIXP0uJt6YhGVQ9O0qT4E+aijul3LiC3KIzVS3N69kmoZvlyJxQ5cDpwu0R7Z4spMn/CsXDSO4JElo2tx7TB/crxgPzUQc35b82fHV1nj94nuMXagIViBndWNkfrHGGlvO9GYW5NbAZ4h9Na6Rvel8jvXOOAYt1gEJokGacIaY6gXTaqiOejTL3+hedM2mwZQsrBWmiTEq8jM43wELFD+FpTwUPImOd7Bin7kR1OCG8rUihCjRStEOivPH3bYBbpaHRSINApMY2FyXQhCaQOjlNNNYu/ynvpwvIKWJC58Qals3V5QQNkbxOOXVUGjgkopNsMvMKHqNs6gErxt0VxdzZqtS4SKV22XrF8Js1QZGeKwM/oIDjheLgQd9VUDWHGNEIeJQdsfxd7FYixatXTS11mvHe6agy3js0qkMeq5e5KUwsHntLX6pGIxlLj/ViG5zeBCQ0cbCH3tRqMDFpZXHXIQDmW1WZsvh/Wlb4mFo8pxlVFgDk0= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: iCrwHF6JEoV8jV2BShdvU6A4n+rqJKZNEMMO+0PtU0SP5D8YuGPRQCXW7LXsO+7/wHVQ//O8e1vvPtI88l/sdQk+RICop826qo/IMxHEiDiV3aKlh6ypK4/Bn5o4JsCGf80CxYfV52eDCjnxAmRBM0srwQ5vM/+BH0iQYBL31cfrHRR+H40mAWMo3mT5u0rohPDfaraJ4RskIDmqyxPYDl7Tp7O68w8bqU+QgHscRZIksTa4LYvblpS2q/SG4q8a5XQP7U9XP+QppjfG47fuhsD9K7O1n9d9Yd5JFuDvi45usSqnVWDuvkPgGrQpIYTl6/h9loiLPJmQkdVPgAk4vk3vCY1+oU/dIKWVu0I7+kwVtQR+kMHFHy3WtFNC/+FEhk0v8lsGplnG7ihZVt4KvflwTWfT8WYixVj/m3UeqS8H++EeJiWwo96r/PpbrL3OqYVo9XxeFTFIwvWZbcUmF+m/9cmOHuB3Oif+ynAWA/fm3vExRAUuFW85CrHvI1v/ynpoNglAlzQNjZqOJmzv7dOkRRT5SPJJApv0vfjQqcDQKIoxlr57wLgAoxnZZBTgKNXidMbWDQ7e+hkb+qKMHGusLOBNFskwzV6iff2tk3pj8asvw4P3GuX0d3YHRZ4eB6yYdkgZcOOEfIcFainoYjqEo1qxfSCMEKYv6v0Hx6x0/UJcQ81kLeUVK54DPPjEXphob4aq0VMYT20e3fhEc6kvGgdGVBWicE8WwnJiIDFQp04qNIE6ijmGtvqvtuZAg84zaaNQdZBthDX6NYoP7S7nShRnqqm8TeFGxOq63uXdAVjHttvfUljgMLcjF+G0XNr4q4cNqFNhAsjSEdER3R4e6ilD+LIkS/+0lupV4I3wo0QTa3Xv0MFD2YMTEpBffQsXI4OiJGqFXTkUkfM2ny0jpUvbprBXT5DkjJqKSkvDfkaprhybGNvbugkxXvVb6uOqOYPN5HdZXW1NpoARfGlbiY5sLTAUHfi0fKJ6XAlsdGotxb939/ZxSDEwQGtoyioJMY0/gD3sbwn7vZ0FiCU3jLOeY1n8YGZ7sqZiHvgg+uU4Up/SQIPSW/ml7Z1r0iqlRWmnYQeCr38MLDEV5Ei9FcTHxzR9yA20OXBW09NjaLZA4x/Og8jcKHiMLf+aT49tmC4xGMrbop+GFb6cQ5Wm12x2CmFBZyHxwDpS+63FHywPv8l7JkdfKF7EAMMekeJeYrBNr5UItmP/o4HEzeLn1CHBFmoP7EUcUMWquzcHnQzCVnlW6mL0J5IgXZTosuMyp2UKPBYlr+JAX0Xu/GIfpSO8q9QMEuDWa3DfNe2BOLaQhiIAopVBiukm6NBO Content-ID: Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: b873eca1-6da0-4086-a5db-08dcb7a37824 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 12:13:10.2607 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB2144 From: Kerem Karabay Add XRGB8888 emulation helper for devices that only support BGR888. Signed-off-by: Kerem Karabay Signed-off-by: Aditya Garg --- drivers/gpu/drm/drm_format_helper.c | 54 +++++++++++++ .../gpu/drm/tests/drm_format_helper_test.c | 81 +++++++++++++++++++ include/drm/drm_format_helper.h | 3 + 3 files changed, 138 insertions(+) diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c index b1be458ed..28c0e76a1 100644 --- a/drivers/gpu/drm/drm_format_helper.c +++ b/drivers/gpu/drm/drm_format_helper.c @@ -702,6 +702,57 @@ void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pi } EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888); +static void drm_fb_xrgb8888_to_bgr888_line(void *dbuf, const void *sbuf, unsigned int pixels) +{ + u8 *dbuf8 = dbuf; + const __le32 *sbuf32 = sbuf; + unsigned int x; + u32 pix; + + for (x = 0; x < pixels; x++) { + pix = le32_to_cpu(sbuf32[x]); + /* write red-green-blue to output in little endianness */ + *dbuf8++ = (pix & 0x00FF0000) >> 16; + *dbuf8++ = (pix & 0x0000FF00) >> 8; + *dbuf8++ = (pix & 0x000000FF) >> 0; + } +} + +/** + * drm_fb_xrgb8888_to_bgr888 - Convert XRGB8888 to BGR888 clip buffer + * @dst: Array of BGR888 destination buffers + * @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines + * within @dst; can be NULL if scanlines are stored next to each other. + * @src: Array of XRGB8888 source buffers + * @fb: DRM framebuffer + * @clip: Clip rectangle area to copy + * @state: Transform and conversion state + * + * This function copies parts of a framebuffer to display memory and converts the + * color format during the process. Destination and framebuffer formats must match. The + * parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at + * least as many entries as there are planes in @fb's format. Each entry stores the + * value for the format's respective color plane at the same index. + * + * This function does not apply clipping on @dst (i.e. the destination is at the + * top-left corner). + * + * Drivers can use this function for BGR888 devices that don't natively + * support XRGB8888. + */ +void drm_fb_xrgb8888_to_bgr888(struct iosys_map *dst, const unsigned int *dst_pitch, + const struct iosys_map *src, const struct drm_framebuffer *fb, + const struct drm_rect *clip, struct drm_format_conv_state *state) +{ + static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = { + 3, + }; + + drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false, state, + drm_fb_xrgb8888_to_bgr888_line); +} +EXPORT_SYMBOL(drm_fb_xrgb8888_to_bgr888); + static void drm_fb_xrgb8888_to_argb8888_line(void *dbuf, const void *sbuf, unsigned int pixels) { __le32 *dbuf32 = dbuf; @@ -1035,6 +1086,9 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d } else if (dst_format == DRM_FORMAT_RGB888) { drm_fb_xrgb8888_to_rgb888(dst, dst_pitch, src, fb, clip, state); return 0; + } else if (dst_format == DRM_FORMAT_BGR888) { + drm_fb_xrgb8888_to_bgr888(dst, dst_pitch, src, fb, clip, state); + return 0; } else if (dst_format == DRM_FORMAT_ARGB8888) { drm_fb_xrgb8888_to_argb8888(dst, dst_pitch, src, fb, clip, state); return 0; diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 08992636e..35cd3405d 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -60,6 +60,11 @@ struct convert_to_rgb888_result { const u8 expected[TEST_BUF_SIZE]; }; +struct convert_to_bgr888_result { + unsigned int dst_pitch; + const u8 expected[TEST_BUF_SIZE]; +}; + struct convert_to_argb8888_result { unsigned int dst_pitch; const u32 expected[TEST_BUF_SIZE]; @@ -107,6 +112,7 @@ struct convert_xrgb8888_case { struct convert_to_argb1555_result argb1555_result; struct convert_to_rgba5551_result rgba5551_result; struct convert_to_rgb888_result rgb888_result; + struct convert_to_bgr888_result bgr888_result; struct convert_to_argb8888_result argb8888_result; struct convert_to_xrgb2101010_result xrgb2101010_result; struct convert_to_argb2101010_result argb2101010_result; @@ -151,6 +157,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = TEST_USE_DEFAULT_PITCH, .expected = { 0x00, 0x00, 0xFF }, }, + .bgr888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { 0xFF, 0x00, 0x00 }, + }, .argb8888_result = { .dst_pitch = TEST_USE_DEFAULT_PITCH, .expected = { 0xFFFF0000 }, @@ -217,6 +227,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = TEST_USE_DEFAULT_PITCH, .expected = { 0x00, 0x00, 0xFF }, }, + .bgr888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { 0xFF, 0x00, 0x00 }, + }, .argb8888_result = { .dst_pitch = TEST_USE_DEFAULT_PITCH, .expected = { 0xFFFF0000 }, @@ -330,6 +344,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, }, }, + .bgr888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, + 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + }, + }, .argb8888_result = { .dst_pitch = TEST_USE_DEFAULT_PITCH, .expected = { @@ -468,6 +491,17 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, }, + .bgr888_result = { + .dst_pitch = 15, + .expected = { + 0x0E, 0x44, 0x9C, 0x11, 0x4D, 0x05, 0xA8, 0xF3, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6C, 0xF0, 0x73, 0x0E, 0x44, 0x9C, 0x11, 0x4D, 0x05, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xA8, 0x03, 0x03, 0x6C, 0xF0, 0x73, 0x0E, 0x44, 0x9C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + }, .argb8888_result = { .dst_pitch = 20, .expected = { @@ -914,6 +948,52 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } +static void drm_test_fb_xrgb8888_to_bgr888(struct kunit *test) +{ + const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_bgr888_result *result = ¶ms->bgr888_result; + size_t dst_size; + u8 *buf = NULL; + __le32 *xrgb8888 = NULL; + struct iosys_map dst, src; + + struct drm_framebuffer fb = { + .format = drm_format_info(DRM_FORMAT_XRGB8888), + .pitches = { params->pitch, 0, 0 }, + }; + + dst_size = conversion_buf_size(DRM_FORMAT_BGR888, result->dst_pitch, + ¶ms->clip, 0); + KUNIT_ASSERT_GT(test, dst_size, 0); + + buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf); + iosys_map_set_vaddr(&dst, buf); + + xrgb8888 = cpubuf_to_le32(test, params->xrgb8888, TEST_BUF_SIZE); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888); + iosys_map_set_vaddr(&src, xrgb8888); + + /* + * BGR888 expected results are already in little-endian + * order, so there's no need to convert the test output. + */ + drm_fb_xrgb8888_to_bgr888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, + &fmtcnv_state); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, dst_size); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, &result->dst_pitch, DRM_FORMAT_BGR888, &src, &fb, ¶ms->clip, + &fmtcnv_state); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); +} + static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) { const struct convert_xrgb8888_case *params = test->param_value; @@ -1851,6 +1931,7 @@ static struct kunit_case drm_format_helper_test_cases[] = { KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb1555, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgba5551, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888, convert_xrgb8888_gen_params), + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_bgr888, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb8888, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb2101010, convert_xrgb8888_gen_params), diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h index 428d81afe..aa1604d92 100644 --- a/include/drm/drm_format_helper.h +++ b/include/drm/drm_format_helper.h @@ -96,6 +96,9 @@ void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_ void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch, const struct iosys_map *src, const struct drm_framebuffer *fb, const struct drm_rect *clip, struct drm_format_conv_state *state); +void drm_fb_xrgb8888_to_bgr888(struct iosys_map *dst, const unsigned int *dst_pitch, + const struct iosys_map *src, const struct drm_framebuffer *fb, + const struct drm_rect *clip, struct drm_format_conv_state *state); void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch, const struct iosys_map *src, const struct drm_framebuffer *fb, const struct drm_rect *clip, struct drm_format_conv_state *state);