Skip to content

Commit 8ce8b40

Browse files
committed
kp: Add auto kprofiles support for MI DRM Notifier
Newer Xiaomi devices utilize their own MI DRM notifier instead of MSM DRM or FB notifier. So, they need their own custom functions for auto kprofiles to work which resemble the bits of MSM_DRM. Hence, add support for it. Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
1 parent dae8d36 commit 8ce8b40

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ config AUTO_KPROFILES_MSM_DRM
4444
mode when device screen turns off and will switch back to previously active
4545
mode when the device wakes up.
4646

47+
config AUTO_KPROFILES_MI_DRM
48+
bool "Auto Kprofiles using mi_drm_notifier"
49+
depends on !DRM_MSM
50+
select AUTO_KPROFILES
51+
help
52+
Select this to enable Kprofile's automatic mode changer via mi_drm_notifier.
53+
When this option is enabled, Kprofiles will automatically switch to battery
54+
mode when device screen turns off and will switch back to previously active
55+
mode when the device wakes up.
56+
4757
config AUTO_KPROFILES_FB
4858
bool "Auto Kprofiles using fb_notifier"
4959
depends on FB

main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <linux/moduleparam.h>
99
#ifdef CONFIG_AUTO_KPROFILES_MSM_DRM
1010
#include <linux/msm_drm_notify.h>
11+
#elif defined(CONFIG_AUTO_KPROFILES_MI_DRM)
12+
#include <drm/drm_notifier_mi.h>
1113
#elif defined(CONFIG_AUTO_KPROFILES_FB)
1214
#include <linux/fb.h>
1315
#endif
@@ -17,6 +19,10 @@
1719
#define KP_EVENT_BLANK MSM_DRM_EVENT_BLANK
1820
#define KP_BLANK_POWERDOWN MSM_DRM_BLANK_POWERDOWN
1921
#define KP_BLANK_UNBLANK MSM_DRM_BLANK_UNBLANK
22+
#elif defined(CONFIG_AUTO_KPROFILES_MI_DRM)
23+
#define KP_EVENT_BLANK MI_DRM_EVENT_BLANK
24+
#define KP_BLANK_POWERDOWN MI_DRM_BLANK_POWERDOWN
25+
#define KP_BLANK_UNBLANK MI_DRM_BLANK_UNBLANK
2026
#elif defined(CONFIG_AUTO_KPROFILES_FB)
2127
#define KP_EVENT_BLANK FB_EVENT_BLANK
2228
#define KP_BLANK_POWERDOWN FB_BLANK_POWERDOWN
@@ -126,6 +132,8 @@ static inline int kp_notifier_callback(struct notifier_block *self,
126132
{
127133
#ifdef CONFIG_AUTO_KPROFILES_MSM_DRM
128134
struct msm_drm_notifier *evdata = data;
135+
#elif defined(CONFIG_AUTO_KPROFILES_MI_DRM)
136+
struct mi_drm_notifier *evdata = data;
129137
#elif defined(CONFIG_AUTO_KPROFILES_FB)
130138
struct fb_event *evdata = data;
131139
#endif
@@ -166,6 +174,8 @@ static int kprofiles_register_notifier(void)
166174

167175
#ifdef CONFIG_AUTO_KPROFILES_MSM_DRM
168176
ret = msm_drm_register_client(&kp_notifier_block);
177+
#elif defined(CONFIG_AUTO_KPROFILES_MI_DRM)
178+
ret = mi_drm_register_client(&kp_notifier_block);
169179
#elif defined(CONFIG_AUTO_KPROFILES_FB)
170180
ret = fb_register_client(&kp_notifier_block);
171181
#endif
@@ -177,6 +187,8 @@ static void kprofiles_unregister_notifier(void)
177187
{
178188
#ifdef CONFIG_AUTO_KPROFILES_MSM_DRM
179189
msm_drm_unregister_client(&kp_notifier_block);
190+
#elif defined(CONFIG_AUTO_KPROFILES_MI_DRM)
191+
mi_drm_unregister_client(&kp_notifier_block);
180192
#elif defined(CONFIG_AUTO_KPROFILES_FB)
181193
fb_unregister_client(&kp_notifier_block);
182194
#endif

0 commit comments

Comments
 (0)