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
6.15
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
From 54a49b19e01908431a429bd136dacd30c3db0d02 Mon Sep 17 00:00:00 2001
|
||||
From f2f8fd2a8dba6f72a03d2aeb0fa66d26974ee735 Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Garg <gargaditya08@live.com>
|
||||
Date: Thu, 11 Jul 2024 10:59:04 +0000
|
||||
Date: Mon, 26 May 2025 07:08:30 +0000
|
||||
Subject: [PATCH] Add apple-bce driver
|
||||
|
||||
---
|
||||
@@ -16,20 +16,20 @@ Subject: [PATCH] Add apple-bce driver
|
||||
drivers/staging/apple-bce/audio/protocol.h | 147 ++++
|
||||
.../staging/apple-bce/audio/protocol_bce.c | 226 ++++++
|
||||
.../staging/apple-bce/audio/protocol_bce.h | 72 ++
|
||||
drivers/staging/apple-bce/mailbox.c | 151 ++++
|
||||
drivers/staging/apple-bce/mailbox.c | 155 ++++
|
||||
drivers/staging/apple-bce/mailbox.h | 53 ++
|
||||
drivers/staging/apple-bce/queue.c | 390 +++++++++
|
||||
drivers/staging/apple-bce/queue.h | 177 ++++
|
||||
drivers/staging/apple-bce/queue_dma.c | 220 +++++
|
||||
drivers/staging/apple-bce/queue_dma.h | 50 ++
|
||||
drivers/staging/apple-bce/vhci/command.h | 204 +++++
|
||||
drivers/staging/apple-bce/vhci/queue.c | 268 +++++++
|
||||
drivers/staging/apple-bce/vhci/queue.c | 268 ++++++
|
||||
drivers/staging/apple-bce/vhci/queue.h | 76 ++
|
||||
drivers/staging/apple-bce/vhci/transfer.c | 661 +++++++++++++++
|
||||
drivers/staging/apple-bce/vhci/transfer.h | 73 ++
|
||||
drivers/staging/apple-bce/vhci/vhci.c | 759 ++++++++++++++++++
|
||||
drivers/staging/apple-bce/vhci/vhci.c | 763 ++++++++++++++++++
|
||||
drivers/staging/apple-bce/vhci/vhci.h | 52 ++
|
||||
25 files changed, 5639 insertions(+)
|
||||
25 files changed, 5647 insertions(+)
|
||||
create mode 100644 drivers/staging/apple-bce/Makefile
|
||||
create mode 100644 drivers/staging/apple-bce/apple_bce.c
|
||||
create mode 100644 drivers/staging/apple-bce/apple_bce.h
|
||||
@@ -2637,13 +2637,14 @@ index 000000000..14d26c05d
|
||||
+#endif //AAUDIO_PROTOCOL_BCE_H
|
||||
diff --git a/drivers/staging/apple-bce/mailbox.c b/drivers/staging/apple-bce/mailbox.c
|
||||
new file mode 100644
|
||||
index 000000000..e24bd3521
|
||||
index 000000000..07ce11928
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/mailbox.c
|
||||
@@ -0,0 +1,151 @@
|
||||
@@ -0,0 +1,155 @@
|
||||
+#include "mailbox.h"
|
||||
+#include <linux/atomic.h>
|
||||
+#include "apple_bce.h"
|
||||
+#include <linux/version.h>
|
||||
+
|
||||
+#define REG_MBOX_OUT_BASE 0x820
|
||||
+#define REG_MBOX_REPLY_COUNTER 0x108
|
||||
@@ -2764,8 +2765,11 @@ index 000000000..e24bd3521
|
||||
+ spin_lock_irqsave(&ts->stop_sl, flags);
|
||||
+ ts->stopped = true;
|
||||
+ spin_unlock_irqrestore(&ts->stop_sl, flags);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,15,0)
|
||||
+ del_timer_sync(&ts->timer);
|
||||
+#else
|
||||
+ timer_delete_sync(&ts->timer);
|
||||
+
|
||||
+#endif
|
||||
+ iowrite32((u32) -2, regb + 2);
|
||||
+ iowrite32((u32) -1, regb);
|
||||
+}
|
||||
@@ -2792,7 +2796,6 @@ index 000000000..e24bd3521
|
||||
+ spin_unlock(&ts->stop_sl);
|
||||
+ local_irq_restore(flags);
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/drivers/staging/apple-bce/mailbox.h b/drivers/staging/apple-bce/mailbox.h
|
||||
new file mode 100644
|
||||
index 000000000..f3323f95b
|
||||
@@ -5029,10 +5032,10 @@ index 000000000..89ecad6bc
|
||||
+#endif //BCEDRIVER_TRANSFER_H
|
||||
diff --git a/drivers/staging/apple-bce/vhci/vhci.c b/drivers/staging/apple-bce/vhci/vhci.c
|
||||
new file mode 100644
|
||||
index 000000000..eb26f5500
|
||||
index 000000000..3394e0aa2
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/vhci/vhci.c
|
||||
@@ -0,0 +1,759 @@
|
||||
@@ -0,0 +1,763 @@
|
||||
+#include "vhci.h"
|
||||
+#include "../apple_bce.h"
|
||||
+#include "command.h"
|
||||
@@ -5275,7 +5278,11 @@ index 000000000..eb26f5500
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
|
||||
+static int bce_vhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
|
||||
+#else
|
||||
+static int bce_vhci_address_device(struct usb_hcd *hcd, struct usb_device *udev, unsigned int timeout_ms) //TODO: follow timeout
|
||||
+#endif
|
||||
+{
|
||||
+ /* This is the same as enable_device, but instead in the old scheme */
|
||||
+ return bce_vhci_enable_device(hcd, udev);
|
||||
@@ -5851,5 +5858,5 @@ index 000000000..6c2e22622
|
||||
+
|
||||
+#endif //BCE_VHCI_H
|
||||
--
|
||||
2.45.2
|
||||
2.49.0
|
||||
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
From 7d40e39bbd21efdb24f3ab6cb6afb57d2153c3b2 Mon Sep 17 00:00:00 2001
|
||||
From: Kerem Karabay <kekrby@gmail.com>
|
||||
Date: Sun, 5 Mar 2023 18:52:43 +0300
|
||||
Subject: [PATCH 1/2] HID: hid-appletb-bl: add driver for the backlight of
|
||||
Apple Touch Bars
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This commit adds a driver for the backlight of Apple Touch Bars on x86
|
||||
Macs. Note that currently only T2 Macs are supported.
|
||||
|
||||
This driver is based on previous work done by Ronald Tschalär
|
||||
<ronald@innovation.ch>.
|
||||
|
||||
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
|
||||
Co-developed-by: Aditya Garg <gargaditya08@live.com>
|
||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||
---
|
||||
drivers/hid/Kconfig | 10 ++
|
||||
drivers/hid/Makefile | 1 +
|
||||
drivers/hid/hid-appletb-bl.c | 204 +++++++++++++++++++++++++++++++++++
|
||||
drivers/hid/hid-quirks.c | 4 +-
|
||||
4 files changed, 218 insertions(+), 1 deletion(-)
|
||||
create mode 100644 drivers/hid/hid-appletb-bl.c
|
||||
|
||||
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
|
||||
index dfc245867..8d80a624f 100644
|
||||
--- a/drivers/hid/Kconfig
|
||||
+++ b/drivers/hid/Kconfig
|
||||
@@ -148,6 +148,16 @@ config HID_APPLEIR
|
||||
|
||||
Say Y here if you want support for Apple infrared remote control.
|
||||
|
||||
+config HID_APPLETB_BL
|
||||
+ tristate "Apple Touch Bar Backlight"
|
||||
+ depends on BACKLIGHT_CLASS_DEVICE
|
||||
+ help
|
||||
+ Say Y here if you want support for the backlight of Touch Bars on x86
|
||||
+ MacBook Pros.
|
||||
+
|
||||
+ To compile this driver as a module, choose M here: the
|
||||
+ module will be called hid-appletb-bl.
|
||||
+
|
||||
config HID_ASUS
|
||||
tristate "Asus"
|
||||
depends on USB_HID
|
||||
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
|
||||
index 482b096ee..d001c3ffd 100644
|
||||
--- a/drivers/hid/Makefile
|
||||
+++ b/drivers/hid/Makefile
|
||||
@@ -29,6 +29,7 @@ obj-$(CONFIG_HID_ALPS) += hid-alps.o
|
||||
obj-$(CONFIG_HID_ACRUX) += hid-axff.o
|
||||
obj-$(CONFIG_HID_APPLE) += hid-apple.o
|
||||
obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o
|
||||
+obj-$(CONFIG_HID_APPLETB_BL) += hid-appletb-bl.o
|
||||
obj-$(CONFIG_HID_CREATIVE_SB0540) += hid-creative-sb0540.o
|
||||
obj-$(CONFIG_HID_ASUS) += hid-asus.o
|
||||
obj-$(CONFIG_HID_AUREAL) += hid-aureal.o
|
||||
diff --git a/drivers/hid/hid-appletb-bl.c b/drivers/hid/hid-appletb-bl.c
|
||||
new file mode 100644
|
||||
index 000000000..bad2aead8
|
||||
--- /dev/null
|
||||
+++ b/drivers/hid/hid-appletb-bl.c
|
||||
@@ -0,0 +1,204 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Apple Touch Bar Backlight Driver
|
||||
+ *
|
||||
+ * Copyright (c) 2017-2018 Ronald Tschalär
|
||||
+ * Copyright (c) 2022-2023 Kerem Karabay <kekrby@gmail.com>
|
||||
+ */
|
||||
+
|
||||
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
+
|
||||
+#include <linux/hid.h>
|
||||
+#include <linux/backlight.h>
|
||||
+#include <linux/device.h>
|
||||
+
|
||||
+#include "hid-ids.h"
|
||||
+
|
||||
+#define APPLETB_BL_ON 1
|
||||
+#define APPLETB_BL_DIM 3
|
||||
+#define APPLETB_BL_OFF 4
|
||||
+
|
||||
+#define HID_UP_APPLEVENDOR_TB_BL 0xff120000
|
||||
+
|
||||
+#define HID_VD_APPLE_TB_BRIGHTNESS 0xff120001
|
||||
+#define HID_USAGE_AUX1 0xff120020
|
||||
+#define HID_USAGE_BRIGHTNESS 0xff120021
|
||||
+
|
||||
+static int appletb_bl_def_brightness = 2;
|
||||
+module_param_named(brightness, appletb_bl_def_brightness, int, 0444);
|
||||
+MODULE_PARM_DESC(brightness, "Default brightness:\n"
|
||||
+ " 0 - Touchbar is off\n"
|
||||
+ " 1 - Dim brightness\n"
|
||||
+ " [2] - Full brightness");
|
||||
+
|
||||
+struct appletb_bl {
|
||||
+ struct hid_field *aux1_field, *brightness_field;
|
||||
+ struct backlight_device *bdev;
|
||||
+
|
||||
+ bool full_on;
|
||||
+};
|
||||
+
|
||||
+static const u8 appletb_bl_brightness_map[] = {
|
||||
+ APPLETB_BL_OFF,
|
||||
+ APPLETB_BL_DIM,
|
||||
+ APPLETB_BL_ON,
|
||||
+};
|
||||
+
|
||||
+static int appletb_bl_set_brightness(struct appletb_bl *bl, u8 brightness)
|
||||
+{
|
||||
+ struct hid_report *report = bl->brightness_field->report;
|
||||
+ struct hid_device *hdev = report->device;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = hid_set_field(bl->aux1_field, 0, 1);
|
||||
+ if (ret) {
|
||||
+ hid_err(hdev, "Failed to set auxiliary field (%pe)\n", ERR_PTR(ret));
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = hid_set_field(bl->brightness_field, 0, brightness);
|
||||
+ if (ret) {
|
||||
+ hid_err(hdev, "Failed to set brightness field (%pe)\n", ERR_PTR(ret));
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ if (!bl->full_on) {
|
||||
+ ret = hid_hw_power(hdev, PM_HINT_FULLON);
|
||||
+ if (ret < 0) {
|
||||
+ hid_err(hdev, "Device didn't power on (%pe)\n", ERR_PTR(ret));
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ bl->full_on = true;
|
||||
+ }
|
||||
+
|
||||
+ hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
|
||||
+
|
||||
+ if (brightness == APPLETB_BL_OFF) {
|
||||
+ hid_hw_power(hdev, PM_HINT_NORMAL);
|
||||
+ bl->full_on = false;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int appletb_bl_update_status(struct backlight_device *bdev)
|
||||
+{
|
||||
+ struct appletb_bl *bl = bl_get_data(bdev);
|
||||
+ u8 brightness;
|
||||
+
|
||||
+ if (backlight_is_blank(bdev))
|
||||
+ brightness = APPLETB_BL_OFF;
|
||||
+ else
|
||||
+ brightness = appletb_bl_brightness_map[backlight_get_brightness(bdev)];
|
||||
+
|
||||
+ return appletb_bl_set_brightness(bl, brightness);
|
||||
+}
|
||||
+
|
||||
+static const struct backlight_ops appletb_bl_backlight_ops = {
|
||||
+ .options = BL_CORE_SUSPENDRESUME,
|
||||
+ .update_status = appletb_bl_update_status,
|
||||
+};
|
||||
+
|
||||
+static int appletb_bl_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
+{
|
||||
+ struct hid_field *aux1_field, *brightness_field;
|
||||
+ struct backlight_properties bl_props = { 0 };
|
||||
+ struct device *dev = &hdev->dev;
|
||||
+ struct appletb_bl *bl;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = hid_parse(hdev);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "HID parse failed\n");
|
||||
+
|
||||
+ aux1_field = hid_find_field(hdev, HID_FEATURE_REPORT,
|
||||
+ HID_VD_APPLE_TB_BRIGHTNESS, HID_USAGE_AUX1);
|
||||
+
|
||||
+ brightness_field = hid_find_field(hdev, HID_FEATURE_REPORT,
|
||||
+ HID_VD_APPLE_TB_BRIGHTNESS, HID_USAGE_BRIGHTNESS);
|
||||
+
|
||||
+ if (!aux1_field || !brightness_field)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ if (aux1_field->report != brightness_field->report)
|
||||
+ return dev_err_probe(dev, -ENODEV, "Encountered unexpected report structure\n");
|
||||
+
|
||||
+ bl = devm_kzalloc(dev, sizeof(*bl), GFP_KERNEL);
|
||||
+ if (!bl)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ ret = hid_hw_start(hdev, HID_CONNECT_DRIVER);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "HID hardware start failed\n");
|
||||
+
|
||||
+ ret = hid_hw_open(hdev);
|
||||
+ if (ret) {
|
||||
+ dev_err_probe(dev, ret, "HID hardware open failed\n");
|
||||
+ goto stop_hw;
|
||||
+ }
|
||||
+
|
||||
+ bl->aux1_field = aux1_field;
|
||||
+ bl->brightness_field = brightness_field;
|
||||
+
|
||||
+ ret = appletb_bl_set_brightness(bl,
|
||||
+ appletb_bl_brightness_map[(appletb_bl_def_brightness > 2) ? 2 : appletb_bl_def_brightness]);
|
||||
+
|
||||
+ if (ret) {
|
||||
+ dev_err_probe(dev, ret, "Failed to set default touch bar brightness to %d\n",
|
||||
+ appletb_bl_def_brightness);
|
||||
+ goto close_hw;
|
||||
+ }
|
||||
+
|
||||
+ bl_props.type = BACKLIGHT_RAW;
|
||||
+ bl_props.max_brightness = ARRAY_SIZE(appletb_bl_brightness_map) - 1;
|
||||
+
|
||||
+ bl->bdev = devm_backlight_device_register(dev, "appletb_backlight", dev, bl,
|
||||
+ &appletb_bl_backlight_ops, &bl_props);
|
||||
+ if (IS_ERR(bl->bdev)) {
|
||||
+ ret = PTR_ERR(bl->bdev);
|
||||
+ dev_err_probe(dev, ret, "Failed to register backlight device\n");
|
||||
+ goto close_hw;
|
||||
+ }
|
||||
+
|
||||
+ hid_set_drvdata(hdev, bl);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+close_hw:
|
||||
+ hid_hw_close(hdev);
|
||||
+stop_hw:
|
||||
+ hid_hw_stop(hdev);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void appletb_bl_remove(struct hid_device *hdev)
|
||||
+{
|
||||
+ struct appletb_bl *bl = hid_get_drvdata(hdev);
|
||||
+
|
||||
+ appletb_bl_set_brightness(bl, APPLETB_BL_OFF);
|
||||
+
|
||||
+ hid_hw_close(hdev);
|
||||
+ hid_hw_stop(hdev);
|
||||
+}
|
||||
+
|
||||
+static const struct hid_device_id appletb_bl_hid_ids[] = {
|
||||
+ /* MacBook Pro's 2018, 2019, with T2 chip: iBridge DFR Brightness */
|
||||
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(hid, appletb_bl_hid_ids);
|
||||
+
|
||||
+static struct hid_driver appletb_bl_hid_driver = {
|
||||
+ .name = "hid-appletb-bl",
|
||||
+ .id_table = appletb_bl_hid_ids,
|
||||
+ .probe = appletb_bl_probe,
|
||||
+ .remove = appletb_bl_remove,
|
||||
+};
|
||||
+module_hid_driver(appletb_bl_hid_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Ronald Tschalär");
|
||||
+MODULE_AUTHOR("Kerem Karabay <kekrby@gmail.com>");
|
||||
+MODULE_DESCRIPTION("MacBook Pro Touch Bar Backlight driver");
|
||||
+MODULE_LICENSE("GPL");
|
||||
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||
index 5d7a418cc..0e055bc73 100644
|
||||
--- a/drivers/hid/hid-quirks.c
|
||||
+++ b/drivers/hid/hid-quirks.c
|
||||
@@ -328,7 +328,6 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021) },
|
||||
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) },
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HID_APPLEIR)
|
||||
@@ -338,6 +337,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL5) },
|
||||
#endif
|
||||
+#if IS_ENABLED(CONFIG_HID_APPLETB_BL)
|
||||
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) },
|
||||
+#endif
|
||||
#if IS_ENABLED(CONFIG_HID_ASUS)
|
||||
{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD) },
|
||||
{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD) },
|
||||
--
|
||||
2.43.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
From 0af1fbc1dcf698e9facfaabd9f0dd7395a7cb849 Mon Sep 17 00:00:00 2001
|
||||
From f36469772a759d953c95719dd3a8b8c78cbf61b5 Mon Sep 17 00:00:00 2001
|
||||
From: Hector Martin <marcan@marcan.st>
|
||||
Date: Tue, 8 Apr 2025 12:17:57 +0530
|
||||
Subject: [PATCH 1/2] lib/vsprintf: Add support for generic FourCCs by extending
|
||||
%p4cc
|
||||
Subject: [PATCH 1/5] 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
|
||||
@@ -28,14 +28,16 @@ Tested-by: Petr Mladek <pmladek@suse.com>
|
||||
Signed-off-by: Hector Martin <marcan@marcan.st>
|
||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||
Reviewed-by: Kees Cook <kees@kernel.org>
|
||||
Link: https://lore.kernel.org/r/PN3PR01MB9597B01823415CB7FCD3BC27B8B52@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM
|
||||
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||
---
|
||||
Documentation/core-api/printk-formats.rst | 32 ++++++++++++++++++
|
||||
lib/vsprintf.c | 40 +++++++++++++++++++----
|
||||
Documentation/core-api/printk-formats.rst | 32 +++++++++++++++++++++
|
||||
lib/vsprintf.c | 35 +++++++++++++++++++----
|
||||
scripts/checkpatch.pl | 2 +-
|
||||
3 files changed, 67 insertions(+), 7 deletions(-)
|
||||
3 files changed, 62 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
|
||||
index ecccc0473..7379d7ba1 100644
|
||||
index 4bdc394e8..125fd0397 100644
|
||||
--- a/Documentation/core-api/printk-formats.rst
|
||||
+++ b/Documentation/core-api/printk-formats.rst
|
||||
@@ -648,6 +648,38 @@ Examples::
|
||||
@@ -46,7 +48,7 @@ index ecccc0473..7379d7ba1 100644
|
||||
+-------------------
|
||||
+
|
||||
+::
|
||||
+ %p4c[h[R]lb] gP00 (0x67503030)
|
||||
+ %p4c[hnlb] gP00 (0x67503030)
|
||||
+
|
||||
+Print a generic FourCC code, as both ASCII characters and its numerical
|
||||
+value as hexadecimal.
|
||||
@@ -54,23 +56,23 @@ index ecccc0473..7379d7ba1 100644
|
||||
+The generic FourCC code is always printed in the big-endian format,
|
||||
+the most significant byte first. This is the opposite of V4L/DRM FourCCs.
|
||||
+
|
||||
+The additional ``h``, ``hR``, ``l``, and ``b`` specifiers define what
|
||||
+The additional ``h``, ``n``, ``l``, and ``b`` specifiers define what
|
||||
+endianness is used to load the stored bytes. The data might be interpreted
|
||||
+using the host, reversed host byte order, little-endian, or big-endian.
|
||||
+using the host byte order, network byte order, little-endian, or big-endian.
|
||||
+
|
||||
+Passed by reference.
|
||||
+
|
||||
+Examples for a little-endian machine, given &(u32)0x67503030::
|
||||
+
|
||||
+ %p4ch gP00 (0x67503030)
|
||||
+ %p4chR 00Pg (0x30305067)
|
||||
+ %p4cn 00Pg (0x30305067)
|
||||
+ %p4cl gP00 (0x67503030)
|
||||
+ %p4cb 00Pg (0x30305067)
|
||||
+
|
||||
+Examples for a big-endian machine, given &(u32)0x67503030::
|
||||
+
|
||||
+ %p4ch gP00 (0x67503030)
|
||||
+ %p4chR 00Pg (0x30305067)
|
||||
+ %p4cn 00Pg (0x30305067)
|
||||
+ %p4cl 00Pg (0x30305067)
|
||||
+ %p4cb gP00 (0x67503030)
|
||||
+
|
||||
@@ -78,10 +80,10 @@ index ecccc0473..7379d7ba1 100644
|
||||
----
|
||||
|
||||
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
|
||||
index a8ac4c4ff..67cf6c542 100644
|
||||
index 01699852f..6bc64ae52 100644
|
||||
--- a/lib/vsprintf.c
|
||||
+++ b/lib/vsprintf.c
|
||||
@@ -1781,27 +1781,49 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
|
||||
@@ -1793,27 +1793,50 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
|
||||
char output[sizeof("0123 little-endian (0x01234567)")];
|
||||
char *p = output;
|
||||
unsigned int i;
|
||||
@@ -99,8 +101,9 @@ index a8ac4c4ff..67cf6c542 100644
|
||||
- val = orig & ~BIT(31);
|
||||
+ switch (fmt[2]) {
|
||||
+ case 'h':
|
||||
+ if (fmt[3] == 'R')
|
||||
+ orig = swab32(orig);
|
||||
+ break;
|
||||
+ case 'n':
|
||||
+ orig = swab32(orig);
|
||||
+ break;
|
||||
+ case 'l':
|
||||
+ orig = (__force u32)cpu_to_le32(orig);
|
||||
@@ -137,24 +140,11 @@ index a8ac4c4ff..67cf6c542 100644
|
||||
|
||||
*p++ = ' ';
|
||||
*p++ = '(';
|
||||
@@ -2365,6 +2387,12 @@ char *rust_fmt_argument(char *buf, char *end, const 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[h[R]lb]' For generic FourCC code with raw numerical value. Both are
|
||||
+ * displayed in the big-endian format. This is the opposite of V4L2 or
|
||||
+ * DRM FourCCs.
|
||||
+ * The additional specifiers define what endianness is used to load
|
||||
+ * the stored bytes. The data might be interpreted using the host,
|
||||
+ * reversed host byte order, little-endian, or big-endian.
|
||||
* - '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 7b28ad331..5595a0898 100755
|
||||
index 3d22bf863..44e233b6f 100755
|
||||
--- a/scripts/checkpatch.pl
|
||||
+++ b/scripts/checkpatch.pl
|
||||
@@ -6904,7 +6904,7 @@ sub process {
|
||||
@@ -6891,7 +6891,7 @@ sub process {
|
||||
($extension eq "f" &&
|
||||
defined $qualifier && $qualifier !~ /^w/) ||
|
||||
($extension eq "4" &&
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
From b51f60f5c8162758c01c9019a0ca3c0776dfad25 Mon Sep 17 00:00:00 2001
|
||||
From: Kerem Karabay <kekrby@gmail.com>
|
||||
Date: Wed, 26 Feb 2025 16:03:47 +0000
|
||||
Subject: [PATCH 1/2] drm/format-helper: Add conversion from XRGB8888 to BGR888
|
||||
|
||||
Add XRGB8888 emulation helper for devices that only support BGR888.
|
||||
|
||||
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 +++++++++++++
|
||||
.../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..4f60c8d8f 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);
|
||||
--
|
||||
2.47.1
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
From 459024d6769c96a110d434b0eb80580ea370c4b5 Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Garg <gargaditya08@live.com>
|
||||
Date: Tue, 8 Apr 2025 12:18:32 +0530
|
||||
Subject: [PATCH 2/5] printf: add tests for generic FourCCs
|
||||
|
||||
This patch adds support for kunit tests of generic 32-bit FourCCs added to
|
||||
vsprintf.
|
||||
|
||||
Acked-by: Tamir Duberstein <tamird@gmail.com>
|
||||
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
||||
Reviewed-by: Petr Mladek <pmladek@suse.com>
|
||||
Tested-by: Petr Mladek <pmladek@suse.com>
|
||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||
Reviewed-by: Kees Cook <kees@kernel.org>
|
||||
Link: https://lore.kernel.org/r/PN3PR01MB95973AF4F6262B2D1996FB25B8B52@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM
|
||||
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||
---
|
||||
lib/tests/printf_kunit.c | 39 ++++++++++++++++++++++++++++++++-------
|
||||
1 file changed, 32 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c
|
||||
index 2c9f6170b..b1fa0dcea 100644
|
||||
--- a/lib/tests/printf_kunit.c
|
||||
+++ b/lib/tests/printf_kunit.c
|
||||
@@ -701,21 +701,46 @@ static void fwnode_pointer(struct kunit *kunittest)
|
||||
software_node_unregister_node_group(group);
|
||||
}
|
||||
|
||||
+struct fourcc_struct {
|
||||
+ u32 code;
|
||||
+ const char *str;
|
||||
+};
|
||||
+
|
||||
+static void fourcc_pointer_test(struct kunit *kunittest, const struct fourcc_struct *fc,
|
||||
+ size_t n, const char *fmt)
|
||||
+{
|
||||
+ size_t i;
|
||||
+
|
||||
+ for (i = 0; i < n; i++)
|
||||
+ test(fc[i].str, fmt, &fc[i].code);
|
||||
+}
|
||||
+
|
||||
static void fourcc_pointer(struct kunit *kunittest)
|
||||
{
|
||||
- struct {
|
||||
- u32 code;
|
||||
- char *str;
|
||||
- } const try[] = {
|
||||
+ static const struct fourcc_struct try_cc[] = {
|
||||
{ 0x3231564e, "NV12 little-endian (0x3231564e)", },
|
||||
{ 0xb231564e, "NV12 big-endian (0xb231564e)", },
|
||||
{ 0x10111213, ".... little-endian (0x10111213)", },
|
||||
{ 0x20303159, "Y10 little-endian (0x20303159)", },
|
||||
};
|
||||
- unsigned int i;
|
||||
+ static const struct fourcc_struct try_ch[] = {
|
||||
+ { 0x41424344, "ABCD (0x41424344)", },
|
||||
+ };
|
||||
+ static const struct fourcc_struct try_cn[] = {
|
||||
+ { 0x41424344, "DCBA (0x44434241)", },
|
||||
+ };
|
||||
+ static const struct fourcc_struct try_cl[] = {
|
||||
+ { (__force u32)cpu_to_le32(0x41424344), "ABCD (0x41424344)", },
|
||||
+ };
|
||||
+ static const struct fourcc_struct try_cb[] = {
|
||||
+ { (__force u32)cpu_to_be32(0x41424344), "ABCD (0x41424344)", },
|
||||
+ };
|
||||
|
||||
- for (i = 0; i < ARRAY_SIZE(try); i++)
|
||||
- test(try[i].str, "%p4cc", &try[i].code);
|
||||
+ fourcc_pointer_test(kunittest, try_cc, ARRAY_SIZE(try_cc), "%p4cc");
|
||||
+ fourcc_pointer_test(kunittest, try_ch, ARRAY_SIZE(try_ch), "%p4ch");
|
||||
+ fourcc_pointer_test(kunittest, try_cn, ARRAY_SIZE(try_cn), "%p4cn");
|
||||
+ fourcc_pointer_test(kunittest, try_cl, ARRAY_SIZE(try_cl), "%p4cl");
|
||||
+ fourcc_pointer_test(kunittest, try_cb, ARRAY_SIZE(try_cb), "%p4cb");
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From f58df41bb14f6e1cf5cd88eb9b681ac57eaed8b0 Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Garg <gargaditya08@live.com>
|
||||
Date: Tue, 8 Apr 2025 12:19:11 +0530
|
||||
Subject: [PATCH 3/5] drm/appletbdrm: use %p4cl instead of %p4cc
|
||||
|
||||
Due to lack of a proper format specifier, %p4cc was being used instead
|
||||
of %p4cl for the purpose of printing FourCCs. But the disadvange was
|
||||
that they were being printed in a reverse order. %p4cl should correct
|
||||
this issue.
|
||||
|
||||
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||
Link: https://lore.kernel.org/r/PN3PR01MB959783DC6377C4CAB203D7ADB8B52@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM
|
||||
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||
---
|
||||
drivers/gpu/drm/tiny/appletbdrm.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/tiny/appletbdrm.c b/drivers/gpu/drm/tiny/appletbdrm.c
|
||||
index 4370ba22d..8643216ba 100644
|
||||
--- a/drivers/gpu/drm/tiny/appletbdrm.c
|
||||
+++ b/drivers/gpu/drm/tiny/appletbdrm.c
|
||||
@@ -214,7 +214,7 @@ static int appletbdrm_read_response(struct appletbdrm_device *adev,
|
||||
}
|
||||
|
||||
if (response->msg != expected_response) {
|
||||
- drm_err(drm, "Unexpected response from device (expected %p4cc found %p4cc)\n",
|
||||
+ drm_err(drm, "Unexpected response from device (expected %p4cl found %p4cl)\n",
|
||||
&expected_response, &response->msg);
|
||||
return -EIO;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ static int appletbdrm_get_information(struct appletbdrm_device *adev)
|
||||
}
|
||||
|
||||
if (pixel_format != APPLETBDRM_PIXEL_FORMAT) {
|
||||
- drm_err(drm, "Encountered unknown pixel format (%p4cc)\n", &pixel_format);
|
||||
+ drm_err(drm, "Encountered unknown pixel format (%p4cl)\n", &pixel_format);
|
||||
ret = -EINVAL;
|
||||
goto free_info;
|
||||
}
|
||||
--
|
||||
2.49.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,139 @@
|
||||
From 391f6d69ac9f0ce2f16636505c8b74025a93889b Mon Sep 17 00:00:00 2001
|
||||
From: Petr Mladek <pmladek@suse.com>
|
||||
Date: Mon, 28 Apr 2025 14:31:32 +0200
|
||||
Subject: [PATCH 4/5] vsprintf: Use %p4chR instead of %p4cn for reading data in
|
||||
reversed host ordering
|
||||
|
||||
The generic FourCC format always prints the data using the big endian
|
||||
order. It is generic because it allows to read the data using a custom
|
||||
ordering.
|
||||
|
||||
The current code uses "n" for reading data in the reverse host ordering.
|
||||
It makes the 4 variants [hnbl] consistent with the generic printing
|
||||
of IPv4 addresses.
|
||||
|
||||
Unfortunately, it creates confusion on big endian systems. For example,
|
||||
it shows the data &(u32)0x67503030 as
|
||||
|
||||
%p4cn 00Pg (0x30305067)
|
||||
|
||||
But people expect that the ordering stays the same. The network ordering
|
||||
is a big-endian ordering.
|
||||
|
||||
The problem is that the semantic is not the same. The modifiers affect
|
||||
the output ordering of IPv4 addresses while they affect the reading order
|
||||
in case of FourCC code.
|
||||
|
||||
Avoid the confusion by replacing the "n" modifier with "hR", aka
|
||||
reverse host ordering. It is inspired by the existing %p[mM]R printf
|
||||
format.
|
||||
|
||||
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
|
||||
Closes: https://lore.kernel.org/r/CAMuHMdV9tX=TG7E_CrSF=2PY206tXf+_yYRuacG48EWEtJLo-Q@mail.gmail.com
|
||||
Signed-off-by: Petr Mladek <pmladek@suse.com>
|
||||
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
|
||||
Reviewed-by: Aditya Garg <gargaditya08@live.com>
|
||||
Link: https://lore.kernel.org/r/20250428123132.578771-1-pmladek@suse.com
|
||||
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||
---
|
||||
Documentation/core-api/printk-formats.rst | 10 +++++-----
|
||||
lib/tests/printf_kunit.c | 4 ++--
|
||||
lib/vsprintf.c | 11 ++++++++---
|
||||
3 files changed, 15 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
|
||||
index 125fd0397..f531873bb 100644
|
||||
--- a/Documentation/core-api/printk-formats.rst
|
||||
+++ b/Documentation/core-api/printk-formats.rst
|
||||
@@ -652,7 +652,7 @@ Generic FourCC code
|
||||
-------------------
|
||||
|
||||
::
|
||||
- %p4c[hnlb] gP00 (0x67503030)
|
||||
+ %p4c[h[R]lb] gP00 (0x67503030)
|
||||
|
||||
Print a generic FourCC code, as both ASCII characters and its numerical
|
||||
value as hexadecimal.
|
||||
@@ -660,23 +660,23 @@ value as hexadecimal.
|
||||
The generic FourCC code is always printed in the big-endian format,
|
||||
the most significant byte first. This is the opposite of V4L/DRM FourCCs.
|
||||
|
||||
-The additional ``h``, ``n``, ``l``, and ``b`` specifiers define what
|
||||
+The additional ``h``, ``hR``, ``l``, and ``b`` specifiers define what
|
||||
endianness is used to load the stored bytes. The data might be interpreted
|
||||
-using the host byte order, network byte order, little-endian, or big-endian.
|
||||
+using the host, reversed host byte order, little-endian, or big-endian.
|
||||
|
||||
Passed by reference.
|
||||
|
||||
Examples for a little-endian machine, given &(u32)0x67503030::
|
||||
|
||||
%p4ch gP00 (0x67503030)
|
||||
- %p4cn 00Pg (0x30305067)
|
||||
+ %p4chR 00Pg (0x30305067)
|
||||
%p4cl gP00 (0x67503030)
|
||||
%p4cb 00Pg (0x30305067)
|
||||
|
||||
Examples for a big-endian machine, given &(u32)0x67503030::
|
||||
|
||||
%p4ch gP00 (0x67503030)
|
||||
- %p4cn 00Pg (0x30305067)
|
||||
+ %p4chR 00Pg (0x30305067)
|
||||
%p4cl 00Pg (0x30305067)
|
||||
%p4cb gP00 (0x67503030)
|
||||
|
||||
diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c
|
||||
index b1fa0dcea..bc54cca2d 100644
|
||||
--- a/lib/tests/printf_kunit.c
|
||||
+++ b/lib/tests/printf_kunit.c
|
||||
@@ -726,7 +726,7 @@ static void fourcc_pointer(struct kunit *kunittest)
|
||||
static const struct fourcc_struct try_ch[] = {
|
||||
{ 0x41424344, "ABCD (0x41424344)", },
|
||||
};
|
||||
- static const struct fourcc_struct try_cn[] = {
|
||||
+ static const struct fourcc_struct try_chR[] = {
|
||||
{ 0x41424344, "DCBA (0x44434241)", },
|
||||
};
|
||||
static const struct fourcc_struct try_cl[] = {
|
||||
@@ -738,7 +738,7 @@ static void fourcc_pointer(struct kunit *kunittest)
|
||||
|
||||
fourcc_pointer_test(kunittest, try_cc, ARRAY_SIZE(try_cc), "%p4cc");
|
||||
fourcc_pointer_test(kunittest, try_ch, ARRAY_SIZE(try_ch), "%p4ch");
|
||||
- fourcc_pointer_test(kunittest, try_cn, ARRAY_SIZE(try_cn), "%p4cn");
|
||||
+ fourcc_pointer_test(kunittest, try_chR, ARRAY_SIZE(try_chR), "%p4chR");
|
||||
fourcc_pointer_test(kunittest, try_cl, ARRAY_SIZE(try_cl), "%p4cl");
|
||||
fourcc_pointer_test(kunittest, try_cb, ARRAY_SIZE(try_cb), "%p4cb");
|
||||
}
|
||||
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
|
||||
index 6bc64ae52..d8a2ec083 100644
|
||||
--- a/lib/vsprintf.c
|
||||
+++ b/lib/vsprintf.c
|
||||
@@ -1805,9 +1805,8 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
|
||||
orig = get_unaligned(fourcc);
|
||||
switch (fmt[2]) {
|
||||
case 'h':
|
||||
- break;
|
||||
- case 'n':
|
||||
- orig = swab32(orig);
|
||||
+ if (fmt[3] == 'R')
|
||||
+ orig = swab32(orig);
|
||||
break;
|
||||
case 'l':
|
||||
orig = (__force u32)cpu_to_le32(orig);
|
||||
@@ -2397,6 +2396,12 @@ early_param("no_hash_pointers", no_hash_pointers_enable);
|
||||
* 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[h[R]lb]' For generic FourCC code with raw numerical value. Both are
|
||||
+ * displayed in the big-endian format. This is the opposite of V4L2 or
|
||||
+ * DRM FourCCs.
|
||||
+ * The additional specifiers define what endianness is used to load
|
||||
+ * the stored bytes. The data might be interpreted using the host,
|
||||
+ * reversed host byte order, little-endian, or big-endian.
|
||||
* - 'h[CDN]' For a variable-length buffer, it prints it as a hex string with
|
||||
* a certain separator (' ' by default):
|
||||
* C colon
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
From 1b4d677851177100a28d372838fd56a3f3c5a3e2 Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Garg <gargaditya08@live.com>
|
||||
Date: Wed, 30 Apr 2025 19:19:08 +0530
|
||||
Subject: [PATCH 5/5] checkpatch: remove %p4cn
|
||||
|
||||
%p4cn was recently removed and replaced by %p4chR in vsprintf. So,
|
||||
remove the check for %p4cn from checkpatch.pl.
|
||||
|
||||
Fixes: 37eed892cc5f ("vsprintf: Use %p4chR instead of %p4cn for reading data in reversed host ordering")
|
||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||
---
|
||||
scripts/checkpatch.pl | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
|
||||
index 44e233b6f..d5bde8322 100755
|
||||
--- a/scripts/checkpatch.pl
|
||||
+++ b/scripts/checkpatch.pl
|
||||
@@ -6891,7 +6891,7 @@ sub process {
|
||||
($extension eq "f" &&
|
||||
defined $qualifier && $qualifier !~ /^w/) ||
|
||||
($extension eq "4" &&
|
||||
- defined $qualifier && $qualifier !~ /^c[hnlbc]/)) {
|
||||
+ defined $qualifier && $qualifier !~ /^c(?:[hlbc]|hR)$/)) {
|
||||
$bad_specifier = $specifier;
|
||||
last;
|
||||
}
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -28,9 +28,9 @@ index 81edf66dbea8..8f3daf28665b 100644
|
||||
+ if (vga_switcheroo_client_probe_defer(pdev))
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
/* skip devices which are owned by radeon */
|
||||
for (i = 0; i < ARRAY_SIZE(amdgpu_unsupported_pciidlist); i++) {
|
||||
if (amdgpu_unsupported_pciidlist[i] == pdev->device)
|
||||
if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA ||
|
||||
(pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER) {
|
||||
if (drm_firmware_drivers_only() && amdgpu_modeset == -1)
|
||||
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
|
||||
index 365e6ddbe90f..cf357cd3389d 100644
|
||||
--- a/drivers/gpu/vga/vga_switcheroo.c
|
||||
|
||||
+195
-323
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user