Skip to content

Commit aab9f50

Browse files
committed
Add upstream changes to drm
1 parent aeafa73 commit aab9f50

2 files changed

+164
-8
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
From 4870ca09f6de64bb971ba649fc5b65b116b1d851 Mon Sep 17 00:00:00 2001
2+
From: Hector Martin <[email protected]>
3+
Date: Tue, 8 Apr 2025 12:17:57 +0530
4+
Subject: [PATCH 1/2] lib/vsprintf: Add support for generic FourCCs by
5+
extending %p4cc
6+
7+
%p4cc is designed for DRM/V4L2 FourCCs with their specific quirks, but
8+
it's useful to be able to print generic 4-character codes formatted as
9+
an integer. Extend it to add format specifiers for printing generic
10+
32-bit FourCCs with various endian semantics:
11+
12+
%p4ch Host byte order
13+
%p4cn Network byte order
14+
%p4cl Little-endian
15+
%p4cb Big-endian
16+
17+
The endianness determines how bytes are interpreted as a u32, and the
18+
FourCC is then always printed MSByte-first (this is the opposite of
19+
V4L/DRM FourCCs). This covers most practical cases, e.g. %p4cn would
20+
allow printing LSByte-first FourCCs stored in host endian order
21+
(other than the hex form being in character order, not the integer
22+
value).
23+
24+
Acked-by: Rasmus Villemoes <[email protected]>
25+
Reviewed-by: Andy Shevchenko <[email protected]>
26+
Reviewed-by: Petr Mladek <[email protected]>
27+
Tested-by: Petr Mladek <[email protected]>
28+
Signed-off-by: Hector Martin <[email protected]>
29+
Signed-off-by: Aditya Garg <[email protected]>
30+
Reviewed-by: Kees Cook <[email protected]>
31+
---
32+
Documentation/core-api/printk-formats.rst | 32 +++++++++++++++++++++
33+
lib/vsprintf.c | 35 +++++++++++++++++++----
34+
scripts/checkpatch.pl | 2 +-
35+
3 files changed, 62 insertions(+), 7 deletions(-)
36+
37+
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
38+
index ecccc0473..bd420e8aa 100644
39+
--- a/Documentation/core-api/printk-formats.rst
40+
+++ b/Documentation/core-api/printk-formats.rst
41+
@@ -648,6 +648,38 @@ Examples::
42+
%p4cc Y10 little-endian (0x20303159)
43+
%p4cc NV12 big-endian (0xb231564e)
44+
45+
+Generic FourCC code
46+
+-------------------
47+
+
48+
+::
49+
+ %p4c[hnlb] gP00 (0x67503030)
50+
+
51+
+Print a generic FourCC code, as both ASCII characters and its numerical
52+
+value as hexadecimal.
53+
+
54+
+The generic FourCC code is always printed in the big-endian format,
55+
+the most significant byte first. This is the opposite of V4L/DRM FourCCs.
56+
+
57+
+The additional ``h``, ``n``, ``l``, and ``b`` specifiers define what
58+
+endianness is used to load the stored bytes. The data might be interpreted
59+
+using the host byte order, network byte order, little-endian, or big-endian.
60+
+
61+
+Passed by reference.
62+
+
63+
+Examples for a little-endian machine, given &(u32)0x67503030::
64+
+
65+
+ %p4ch gP00 (0x67503030)
66+
+ %p4cn 00Pg (0x30305067)
67+
+ %p4cl gP00 (0x67503030)
68+
+ %p4cb 00Pg (0x30305067)
69+
+
70+
+Examples for a big-endian machine, given &(u32)0x67503030::
71+
+
72+
+ %p4ch gP00 (0x67503030)
73+
+ %p4cn 00Pg (0x30305067)
74+
+ %p4cl 00Pg (0x30305067)
75+
+ %p4cb gP00 (0x67503030)
76+
+
77+
Rust
78+
----
79+
80+
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
81+
index a8ac4c4ff..a434b58e8 100644
82+
--- a/lib/vsprintf.c
83+
+++ b/lib/vsprintf.c
84+
@@ -1781,27 +1781,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
85+
char output[sizeof("0123 little-endian (0x01234567)")];
86+
char *p = output;
87+
unsigned int i;
88+
+ bool pixel_fmt = false;
89+
u32 orig, val;
90+
91+
- if (fmt[1] != 'c' || fmt[2] != 'c')
92+
+ if (fmt[1] != 'c')
93+
return error_string(buf, end, "(%p4?)", spec);
94+
95+
if (check_pointer(&buf, end, fourcc, spec))
96+
return buf;
97+
98+
orig = get_unaligned(fourcc);
99+
- val = orig & ~BIT(31);
100+
+ switch (fmt[2]) {
101+
+ case 'h':
102+
+ break;
103+
+ case 'n':
104+
+ orig = swab32(orig);
105+
+ break;
106+
+ case 'l':
107+
+ orig = (__force u32)cpu_to_le32(orig);
108+
+ break;
109+
+ case 'b':
110+
+ orig = (__force u32)cpu_to_be32(orig);
111+
+ break;
112+
+ case 'c':
113+
+ /* Pixel formats are printed LSB-first */
114+
+ pixel_fmt = true;
115+
+ break;
116+
+ default:
117+
+ return error_string(buf, end, "(%p4?)", spec);
118+
+ }
119+
+
120+
+ val = pixel_fmt ? swab32(orig & ~BIT(31)) : orig;
121+
122+
for (i = 0; i < sizeof(u32); i++) {
123+
- unsigned char c = val >> (i * 8);
124+
+ unsigned char c = val >> ((3 - i) * 8);
125+
126+
/* Print non-control ASCII characters as-is, dot otherwise */
127+
*p++ = isascii(c) && isprint(c) ? c : '.';
128+
}
129+
130+
- *p++ = ' ';
131+
- strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
132+
- p += strlen(p);
133+
+ if (pixel_fmt) {
134+
+ *p++ = ' ';
135+
+ strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
136+
+ p += strlen(p);
137+
+ }
138+
139+
*p++ = ' ';
140+
*p++ = '(';
141+
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
142+
index 7b28ad331..5595a0898 100755
143+
--- a/scripts/checkpatch.pl
144+
+++ b/scripts/checkpatch.pl
145+
@@ -6904,7 +6904,7 @@ sub process {
146+
($extension eq "f" &&
147+
defined $qualifier && $qualifier !~ /^w/) ||
148+
($extension eq "4" &&
149+
- defined $qualifier && $qualifier !~ /^cc/)) {
150+
+ defined $qualifier && $qualifier !~ /^c[hnlbc]/)) {
151+
$bad_specifier = $specifier;
152+
last;
153+
}
154+
--
155+
2.49.0
156+

1015-drm-tiny-add-driver-for-Apple-Touch-Bars-in-x86-Macs.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 0773051dff8f9bb8ef4c21a017a907f078cba80a Mon Sep 17 00:00:00 2001
1+
From 08dec01da405ecf1c24d1d3c38b19b7654580b26 Mon Sep 17 00:00:00 2001
22
From: Kerem Karabay <[email protected]>
33
Date: Wed, 26 Feb 2025 16:04:36 +0000
44
Subject: [PATCH 2/2] drm/tiny: add driver for Apple Touch Bars in x86 Macs
@@ -53,10 +53,10 @@ Link: https://patchwork.freedesktop.org/patch/msgid/FCAC702C-F84A-47F9-8C78-BBBB
5353
create mode 100644 drivers/gpu/drm/tiny/appletbdrm.c
5454

5555
diff --git a/MAINTAINERS b/MAINTAINERS
56-
index 0fa7c5728..bce57e844 100644
56+
index 00e94bec4..2c70390fc 100644
5757
--- a/MAINTAINERS
5858
+++ b/MAINTAINERS
59-
@@ -7066,6 +7066,14 @@ S: Supported
59+
@@ -7163,6 +7163,14 @@ S: Supported
6060
T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
6161
F: drivers/gpu/drm/sun4i/sun8i*
6262

@@ -94,7 +94,7 @@ index 94cbdb133..54c84c980 100644
9494
tristate "ARC PGU"
9595
depends on DRM && OF
9696
diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
97-
index 4aaf56f87..d9add9c3e 100644
97+
index 60816d2eb..0a3a7837a 100644
9898
--- a/drivers/gpu/drm/tiny/Makefile
9999
+++ b/drivers/gpu/drm/tiny/Makefile
100100
@@ -1,5 +1,6 @@
@@ -106,7 +106,7 @@ index 4aaf56f87..d9add9c3e 100644
106106
obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus-qemu.o
107107
diff --git a/drivers/gpu/drm/tiny/appletbdrm.c b/drivers/gpu/drm/tiny/appletbdrm.c
108108
new file mode 100644
109-
index 000000000..4370ba22d
109+
index 000000000..8643216ba
110110
--- /dev/null
111111
+++ b/drivers/gpu/drm/tiny/appletbdrm.c
112112
@@ -0,0 +1,840 @@
@@ -326,7 +326,7 @@ index 000000000..4370ba22d
326326
+ }
327327
+
328328
+ if (response->msg != expected_response) {
329-
+ drm_err(drm, "Unexpected response from device (expected %p4cc found %p4cc)\n",
329+
+ drm_err(drm, "Unexpected response from device (expected %p4cl found %p4cl)\n",
330330
+ &expected_response, &response->msg);
331331
+ return -EIO;
332332
+ }
@@ -400,7 +400,7 @@ index 000000000..4370ba22d
400400
+ }
401401
+
402402
+ if (pixel_format != APPLETBDRM_PIXEL_FORMAT) {
403-
+ drm_err(drm, "Encountered unknown pixel format (%p4cc)\n", &pixel_format);
403+
+ drm_err(drm, "Encountered unknown pixel format (%p4cl)\n", &pixel_format);
404404
+ ret = -EINVAL;
405405
+ goto free_info;
406406
+ }
@@ -951,5 +951,5 @@ index 000000000..4370ba22d
951951
+MODULE_DESCRIPTION("Apple Touch Bar DRM Driver");
952952
+MODULE_LICENSE("GPL");
953953
--
954-
2.47.1
954+
2.49.0
955955

0 commit comments

Comments
 (0)