armbian-build/patch/kernel/archive/sm8250-6.18/0001-drm-Add-drm-notifier-support.patch
Jiali Chen e46899dff3 patch: sm8250: current: add some patches
From https://gitlab.postmarketos.org/soc/qualcomm-sm8250/linux/-/commits/6.17.0?ref_type=HEADS

Made some modifications to be compatible with the latest kernel.

Signed-off-by: CodeChenL <2540735020@qq.com>
2026-01-25 13:27:26 +01:00

139 lines
4.4 KiB
Diff

From 56330cd8650e8b60b836727156a94a67485a3c67 Mon Sep 17 00:00:00 2001
From: Jianhua Lu <lujianhua000@gmail.com>
Date: Thu, 4 Aug 2022 13:26:53 +0800
Subject: [PATCH 01/62] drm: Add drm notifier support
Signed-off-by: Jiali Chen <chenjiali@radxa.com>
---
drivers/gpu/drm/Makefile | 3 +-
drivers/gpu/drm/drm_notifier.c | 58 ++++++++++++++++++++++++++++++++++
include/drm/drm_notifier.h | 37 ++++++++++++++++++++++
3 files changed, 97 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/drm_notifier.c
create mode 100644 include/drm/drm_notifier.h
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4dafbdc8f86a..9b2434daa24f 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -72,7 +72,8 @@ drm-y := \
drm_vblank.o \
drm_vblank_work.o \
drm_vma_manager.o \
- drm_writeback.o
+ drm_writeback.o \
+ drm_notifier.o
drm-$(CONFIG_DRM_CLIENT) += \
drm_client.o \
drm_client_event.o \
diff --git a/drivers/gpu/drm/drm_notifier.c b/drivers/gpu/drm/drm_notifier.c
new file mode 100644
index 000000000000..0b90d02d8692
--- /dev/null
+++ b/drivers/gpu/drm/drm_notifier.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2021 XiaoMi, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/notifier.h>
+#include <drm/drm_notifier.h>
+
+static BLOCKING_NOTIFIER_HEAD(mi_drm_notifier_list);
+
+/**
+ * mi_drm_register_client - register a client notifier
+ * @nb: notifier block to callback on events
+ *
+ * This function registers a notifier callback function
+ * to msm_drm_notifier_list, which would be called when
+ * received unblank/power down event.
+ */
+int mi_drm_register_client(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_register(&mi_drm_notifier_list, nb);
+}
+EXPORT_SYMBOL(mi_drm_register_client);
+
+/**
+ * mi_drm_unregister_client - unregister a client notifier
+ * @nb: notifier block to callback on events
+ *
+ * This function unregisters the callback function from
+ * msm_drm_notifier_list.
+ */
+int mi_drm_unregister_client(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_unregister(&mi_drm_notifier_list, nb);
+}
+EXPORT_SYMBOL(mi_drm_unregister_client);
+
+/**
+ * mi_drm_notifier_call_chain - notify clients of drm_events
+ * @val: event MSM_DRM_EARLY_EVENT_BLANK or MSM_DRM_EVENT_BLANK
+ * @v: notifier data, inculde display id and display blank
+ * event(unblank or power down).
+ */
+int mi_drm_notifier_call_chain(unsigned long val, void *v)
+{
+ return blocking_notifier_call_chain(&mi_drm_notifier_list, val, v);
+}
+EXPORT_SYMBOL(mi_drm_notifier_call_chain);
diff --git a/include/drm/drm_notifier.h b/include/drm/drm_notifier.h
new file mode 100644
index 000000000000..fd0e976559b8
--- /dev/null
+++ b/include/drm/drm_notifier.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2021 XiaoMi, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _DRM_NOTIFIER_H_
+#define _DRM_NOTIFIER_H_
+
+#include <linux/notifier.h>
+
+/* A hardware display blank change occurred */
+#define MI_DRM_EVENT_BLANK 0x01
+/* A hardware display blank early change occurred */
+#define MI_DRM_EARLY_EVENT_BLANK 0x02
+
+enum drm_notifier_data {
+ /* panel: power on */
+ MI_DRM_BLANK_UNBLANK,
+ /* panel: power down */
+ MI_DRM_BLANK_POWERDOWN,
+};
+
+int mi_drm_register_client(struct notifier_block *nb);
+int mi_drm_unregister_client(struct notifier_block *nb);
+int mi_drm_notifier_call_chain(unsigned long val, void *v);
+
+#endif /* _DRM_NOTIFIER_H */
--
2.47.3