You've already forked linux-t2-patches
mirror of
https://github.com/t2linux/linux-t2-patches.git
synced 2026-04-30 13:52:11 -07:00
Add upstreamed drm driver
This commit is contained in:
@@ -1,197 +0,0 @@
|
|||||||
From f6ab7e4580962c9d82e7dc40dd074d47b2bce034 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Hector Martin <marcan@marcan.st>
|
|
||||||
Date: Tue, 1 Feb 2022 00:40:51 +0900
|
|
||||||
Subject: [PATCH 09/12] lib/vsprintf: Add support for generic FOURCCs by
|
|
||||||
extending %p4cc
|
|
||||||
|
|
||||||
%p4cc is designed for DRM/V4L2 FOURCCs with their specific quirks, but
|
|
||||||
it's useful to be able to print generic 4-character codes formatted as
|
|
||||||
an integer. Extend it to add format specifiers for printing generic
|
|
||||||
32-bit FOURCCs with various endian semantics:
|
|
||||||
|
|
||||||
%p4ch Host-endian
|
|
||||||
%p4cl Little-endian
|
|
||||||
%p4cb Big-endian
|
|
||||||
%p4cr Reverse-endian
|
|
||||||
|
|
||||||
The endianness determines how bytes are interpreted as a u32, and the
|
|
||||||
FOURCC is then always printed MSByte-first (this is the opposite of
|
|
||||||
V4L/DRM FOURCCs). This covers most practical cases, e.g. %p4cr would
|
|
||||||
allow printing LSByte-first FOURCCs stored in host endian order
|
|
||||||
(other than the hex form being in character order, not the integer
|
|
||||||
value).
|
|
||||||
|
|
||||||
Signed-off-by: Hector Martin <marcan@marcan.st>
|
|
||||||
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
|
|
||||||
---
|
|
||||||
Documentation/core-api/printk-formats.rst | 32 ++++++++++++++++++++
|
|
||||||
lib/test_printf.c | 20 +++++++++----
|
|
||||||
lib/vsprintf.c | 36 +++++++++++++++++++----
|
|
||||||
scripts/checkpatch.pl | 2 +-
|
|
||||||
4 files changed, 77 insertions(+), 13 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
|
|
||||||
index dfe7e75a7..0ccef63e6 100644
|
|
||||||
--- a/Documentation/core-api/printk-formats.rst
|
|
||||||
+++ b/Documentation/core-api/printk-formats.rst
|
|
||||||
@@ -631,6 +631,38 @@ Examples::
|
|
||||||
%p4cc Y10 little-endian (0x20303159)
|
|
||||||
%p4cc NV12 big-endian (0xb231564e)
|
|
||||||
|
|
||||||
+Generic FourCC code
|
|
||||||
+-------------------
|
|
||||||
+
|
|
||||||
+::
|
|
||||||
+ %p4c[hnbl] gP00 (0x67503030)
|
|
||||||
+
|
|
||||||
+Print a generic FourCC code, as both ASCII characters and its numerical
|
|
||||||
+value as hexadecimal.
|
|
||||||
+
|
|
||||||
+The additional ``h``, ``r``, ``b``, and ``l`` specifiers are used to specify
|
|
||||||
+host, reversed, big or little endian order data respectively. Host endian
|
|
||||||
+order means the data is interpreted as a 32-bit integer and the most
|
|
||||||
+significant byte is printed first; that is, the character code as printed
|
|
||||||
+matches the byte order stored in memory on big-endian systems, and is reversed
|
|
||||||
+on little-endian systems.
|
|
||||||
+
|
|
||||||
+Passed by reference.
|
|
||||||
+
|
|
||||||
+Examples for a little-endian machine, given &(u32)0x67503030::
|
|
||||||
+
|
|
||||||
+ %p4ch gP00 (0x67503030)
|
|
||||||
+ %p4cl gP00 (0x67503030)
|
|
||||||
+ %p4cb 00Pg (0x30305067)
|
|
||||||
+ %p4cr 00Pg (0x30305067)
|
|
||||||
+
|
|
||||||
+Examples for a big-endian machine, given &(u32)0x67503030::
|
|
||||||
+
|
|
||||||
+ %p4ch gP00 (0x67503030)
|
|
||||||
+ %p4cl 00Pg (0x30305067)
|
|
||||||
+ %p4cb gP00 (0x67503030)
|
|
||||||
+ %p4cr 00Pg (0x30305067)
|
|
||||||
+
|
|
||||||
Rust
|
|
||||||
----
|
|
||||||
|
|
||||||
diff --git a/lib/test_printf.c b/lib/test_printf.c
|
|
||||||
index 7677ebccf..2355be36f 100644
|
|
||||||
--- a/lib/test_printf.c
|
|
||||||
+++ b/lib/test_printf.c
|
|
||||||
@@ -746,18 +746,26 @@ static void __init fwnode_pointer(void)
|
|
||||||
static void __init fourcc_pointer(void)
|
|
||||||
{
|
|
||||||
struct {
|
|
||||||
+ char type;
|
|
||||||
u32 code;
|
|
||||||
char *str;
|
|
||||||
} const try[] = {
|
|
||||||
- { 0x3231564e, "NV12 little-endian (0x3231564e)", },
|
|
||||||
- { 0xb231564e, "NV12 big-endian (0xb231564e)", },
|
|
||||||
- { 0x10111213, ".... little-endian (0x10111213)", },
|
|
||||||
- { 0x20303159, "Y10 little-endian (0x20303159)", },
|
|
||||||
+ { 'c', 0x3231564e, "NV12 little-endian (0x3231564e)", },
|
|
||||||
+ { 'c', 0xb231564e, "NV12 big-endian (0xb231564e)", },
|
|
||||||
+ { 'c', 0x10111213, ".... little-endian (0x10111213)", },
|
|
||||||
+ { 'c', 0x20303159, "Y10 little-endian (0x20303159)", },
|
|
||||||
+ { 'h', 0x67503030, "gP00 (0x67503030)", },
|
|
||||||
+ { 'r', 0x30305067, "gP00 (0x67503030)", },
|
|
||||||
+ { 'l', cpu_to_le32(0x67503030), "gP00 (0x67503030)", },
|
|
||||||
+ { 'b', cpu_to_be32(0x67503030), "gP00 (0x67503030)", },
|
|
||||||
};
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
- for (i = 0; i < ARRAY_SIZE(try); i++)
|
|
||||||
- test(try[i].str, "%p4cc", &try[i].code);
|
|
||||||
+ for (i = 0; i < ARRAY_SIZE(try); i++) {
|
|
||||||
+ char fmt[] = { '%', 'p', '4', 'c', try[i].type, '\0' };
|
|
||||||
+
|
|
||||||
+ test(try[i].str, fmt, &try[i].code);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __init
|
|
||||||
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
|
|
||||||
index 40f560959..bd9af783c 100644
|
|
||||||
--- a/lib/vsprintf.c
|
|
||||||
+++ b/lib/vsprintf.c
|
|
||||||
@@ -1758,27 +1758,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
|
|
||||||
char output[sizeof("0123 little-endian (0x01234567)")];
|
|
||||||
char *p = output;
|
|
||||||
unsigned int i;
|
|
||||||
+ bool pix_fmt = false;
|
|
||||||
u32 orig, val;
|
|
||||||
|
|
||||||
- if (fmt[1] != 'c' || fmt[2] != 'c')
|
|
||||||
+ if (fmt[1] != 'c')
|
|
||||||
return error_string(buf, end, "(%p4?)", spec);
|
|
||||||
|
|
||||||
if (check_pointer(&buf, end, fourcc, spec))
|
|
||||||
return buf;
|
|
||||||
|
|
||||||
orig = get_unaligned(fourcc);
|
|
||||||
- val = orig & ~BIT(31);
|
|
||||||
+ switch (fmt[2]) {
|
|
||||||
+ case 'h':
|
|
||||||
+ val = orig;
|
|
||||||
+ break;
|
|
||||||
+ case 'r':
|
|
||||||
+ val = orig = swab32(orig);
|
|
||||||
+ break;
|
|
||||||
+ case 'l':
|
|
||||||
+ val = orig = le32_to_cpu(orig);
|
|
||||||
+ break;
|
|
||||||
+ case 'b':
|
|
||||||
+ val = orig = be32_to_cpu(orig);
|
|
||||||
+ break;
|
|
||||||
+ case 'c':
|
|
||||||
+ /* Pixel formats are printed LSB-first */
|
|
||||||
+ val = swab32(orig & ~BIT(31));
|
|
||||||
+ pix_fmt = true;
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ return error_string(buf, end, "(%p4?)", spec);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(u32); i++) {
|
|
||||||
- unsigned char c = val >> (i * 8);
|
|
||||||
+ unsigned char c = val >> ((3 - i) * 8);
|
|
||||||
|
|
||||||
/* Print non-control ASCII characters as-is, dot otherwise */
|
|
||||||
*p++ = isascii(c) && isprint(c) ? c : '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
- *p++ = ' ';
|
|
||||||
- strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
|
|
||||||
- p += strlen(p);
|
|
||||||
+ if (pix_fmt) {
|
|
||||||
+ *p++ = ' ';
|
|
||||||
+ strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
|
|
||||||
+ p += strlen(p);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
*p++ = ' ';
|
|
||||||
*p++ = '(';
|
|
||||||
@@ -2348,6 +2371,7 @@ char *rust_fmt_argument(char *buf, char *end, void *ptr);
|
|
||||||
* read the documentation (path below) first.
|
|
||||||
* - 'NF' For a netdev_features_t
|
|
||||||
* - '4cc' V4L2 or DRM FourCC code, with endianness and raw numerical value.
|
|
||||||
+ * - '4c[hlbr]' Generic FourCC code.
|
|
||||||
* - 'h[CDN]' For a variable-length buffer, it prints it as a hex string with
|
|
||||||
* a certain separator (' ' by default):
|
|
||||||
* C colon
|
|
||||||
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
|
|
||||||
index 880fde13d..f080e33a4 100755
|
|
||||||
--- a/scripts/checkpatch.pl
|
|
||||||
+++ b/scripts/checkpatch.pl
|
|
||||||
@@ -6906,7 +6906,7 @@ sub process {
|
|
||||||
($extension eq "f" &&
|
|
||||||
defined $qualifier && $qualifier !~ /^w/) ||
|
|
||||||
($extension eq "4" &&
|
|
||||||
- defined $qualifier && $qualifier !~ /^cc/)) {
|
|
||||||
+ defined $qualifier && $qualifier !~ /^c[chlbr]/)) {
|
|
||||||
$bad_specifier = $specifier;
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.42.0
|
|
||||||
|
|
||||||
+15
-12
@@ -1,12 +1,15 @@
|
|||||||
From 337d6f6e34daaa786a0fb70d0dbd553288cd5ecd Mon Sep 17 00:00:00 2001
|
From b51f60f5c8162758c01c9019a0ca3c0776dfad25 Mon Sep 17 00:00:00 2001
|
||||||
From: Kerem Karabay <kekrby@gmail.com>
|
From: Kerem Karabay <kekrby@gmail.com>
|
||||||
Date: Fri, 4 Aug 2023 17:49:25 +0300
|
Date: Wed, 26 Feb 2025 16:03:47 +0000
|
||||||
Subject: [PATCH 11/12] drm/format-helper: add helper for BGR888 to XRGB8888
|
Subject: [PATCH 1/2] drm/format-helper: Add conversion from XRGB8888 to BGR888
|
||||||
conversion
|
|
||||||
|
|
||||||
Add XRGB8888 emulation helper for devices that only support BGR888.
|
Add XRGB8888 emulation helper for devices that only support BGR888.
|
||||||
|
|
||||||
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
|
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
|
||||||
|
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||||
|
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
|
||||||
|
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
|
||||||
|
Link: https://patchwork.freedesktop.org/patch/msgid/9A67EA95-9BC7-4D56-8F87-05EAC1C166AD@live.com
|
||||||
---
|
---
|
||||||
drivers/gpu/drm/drm_format_helper.c | 54 +++++++++++++
|
drivers/gpu/drm/drm_format_helper.c | 54 +++++++++++++
|
||||||
.../gpu/drm/tests/drm_format_helper_test.c | 81 +++++++++++++++++++
|
.../gpu/drm/tests/drm_format_helper_test.c | 81 +++++++++++++++++++
|
||||||
@@ -14,7 +17,7 @@ Signed-off-by: Kerem Karabay <kekrby@gmail.com>
|
|||||||
3 files changed, 138 insertions(+)
|
3 files changed, 138 insertions(+)
|
||||||
|
|
||||||
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
|
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
|
||||||
index b1be458ed..28c0e76a1 100644
|
index b1be458ed..4f60c8d8f 100644
|
||||||
--- a/drivers/gpu/drm/drm_format_helper.c
|
--- a/drivers/gpu/drm/drm_format_helper.c
|
||||||
+++ b/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
|
@@ -702,6 +702,57 @@ void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pi
|
||||||
@@ -31,9 +34,9 @@ index b1be458ed..28c0e76a1 100644
|
|||||||
+ for (x = 0; x < pixels; x++) {
|
+ for (x = 0; x < pixels; x++) {
|
||||||
+ pix = le32_to_cpu(sbuf32[x]);
|
+ pix = le32_to_cpu(sbuf32[x]);
|
||||||
+ /* write red-green-blue to output in little endianness */
|
+ /* write red-green-blue to output in little endianness */
|
||||||
+ *dbuf8++ = (pix & 0x00FF0000) >> 16;
|
+ *dbuf8++ = (pix & 0x00ff0000) >> 16;
|
||||||
+ *dbuf8++ = (pix & 0x0000FF00) >> 8;
|
+ *dbuf8++ = (pix & 0x0000ff00) >> 8;
|
||||||
+ *dbuf8++ = (pix & 0x000000FF) >> 0;
|
+ *dbuf8++ = (pix & 0x000000ff) >> 0;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@@ -86,7 +89,7 @@ index b1be458ed..28c0e76a1 100644
|
|||||||
drm_fb_xrgb8888_to_argb8888(dst, dst_pitch, src, fb, clip, state);
|
drm_fb_xrgb8888_to_argb8888(dst, dst_pitch, src, fb, clip, state);
|
||||||
return 0;
|
return 0;
|
||||||
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
|
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
|
||||||
index 08992636e..e54f0f6e7 100644
|
index 08992636e..35cd3405d 100644
|
||||||
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
|
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
|
||||||
+++ b/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 {
|
@@ -60,6 +60,11 @@ struct convert_to_rgb888_result {
|
||||||
@@ -227,10 +230,10 @@ index 08992636e..e54f0f6e7 100644
|
|||||||
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010, 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),
|
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
|
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
|
||||||
index f13b34e0b..b53cf85ca 100644
|
index 428d81afe..aa1604d92 100644
|
||||||
--- a/include/drm/drm_format_helper.h
|
--- a/include/drm/drm_format_helper.h
|
||||||
+++ b/include/drm/drm_format_helper.h
|
+++ b/include/drm/drm_format_helper.h
|
||||||
@@ -95,6 +95,9 @@ void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_
|
@@ -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,
|
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 iosys_map *src, const struct drm_framebuffer *fb,
|
||||||
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
||||||
@@ -241,5 +244,5 @@ index f13b34e0b..b53cf85ca 100644
|
|||||||
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
||||||
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
||||||
--
|
--
|
||||||
2.34.1
|
2.47.1
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user