Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  Common functions for kernel modules using Dell SMBIOS
0004  *
0005  *  Copyright (c) Red Hat <mjg@redhat.com>
0006  *  Copyright (c) 2014 Gabriele Mazzotta <gabriele.mzt@gmail.com>
0007  *  Copyright (c) 2014 Pali Rohár <pali@kernel.org>
0008  *
0009  *  Based on documentation in the libsmbios package:
0010  *  Copyright (C) 2005-2014 Dell Inc.
0011  */
0012 
0013 #ifndef _DELL_SMBIOS_H_
0014 #define _DELL_SMBIOS_H_
0015 
0016 #include <linux/device.h>
0017 #include <uapi/linux/wmi.h>
0018 
0019 /* Classes and selects used only in kernel drivers */
0020 #define CLASS_KBD_BACKLIGHT 4
0021 #define SELECT_KBD_BACKLIGHT 11
0022 
0023 /* Tokens used in kernel drivers, any of these
0024  * should be filtered from userspace access
0025  */
0026 #define BRIGHTNESS_TOKEN    0x007d
0027 #define KBD_LED_AC_TOKEN    0x0451
0028 #define KBD_LED_OFF_TOKEN   0x01E1
0029 #define KBD_LED_ON_TOKEN    0x01E2
0030 #define KBD_LED_AUTO_TOKEN  0x01E3
0031 #define KBD_LED_AUTO_25_TOKEN   0x02EA
0032 #define KBD_LED_AUTO_50_TOKEN   0x02EB
0033 #define KBD_LED_AUTO_75_TOKEN   0x02EC
0034 #define KBD_LED_AUTO_100_TOKEN  0x02F6
0035 #define GLOBAL_MIC_MUTE_ENABLE  0x0364
0036 #define GLOBAL_MIC_MUTE_DISABLE 0x0365
0037 
0038 struct notifier_block;
0039 
0040 struct calling_interface_token {
0041     u16 tokenID;
0042     u16 location;
0043     union {
0044         u16 value;
0045         u16 stringlength;
0046     };
0047 };
0048 
0049 struct calling_interface_structure {
0050     struct dmi_header header;
0051     u16 cmdIOAddress;
0052     u8 cmdIOCode;
0053     u32 supportedCmds;
0054     struct calling_interface_token tokens[];
0055 } __packed;
0056 
0057 int dell_smbios_register_device(struct device *d, void *call_fn);
0058 void dell_smbios_unregister_device(struct device *d);
0059 
0060 int dell_smbios_error(int value);
0061 int dell_smbios_call_filter(struct device *d,
0062     struct calling_interface_buffer *buffer);
0063 int dell_smbios_call(struct calling_interface_buffer *buffer);
0064 
0065 struct calling_interface_token *dell_smbios_find_token(int tokenid);
0066 
0067 enum dell_laptop_notifier_actions {
0068     DELL_LAPTOP_KBD_BACKLIGHT_BRIGHTNESS_CHANGED,
0069 };
0070 
0071 int dell_laptop_register_notifier(struct notifier_block *nb);
0072 int dell_laptop_unregister_notifier(struct notifier_block *nb);
0073 void dell_laptop_call_notifier(unsigned long action, void *data);
0074 
0075 /* for the supported backends */
0076 #ifdef CONFIG_DELL_SMBIOS_WMI
0077 int init_dell_smbios_wmi(void);
0078 void exit_dell_smbios_wmi(void);
0079 #else /* CONFIG_DELL_SMBIOS_WMI */
0080 static inline int init_dell_smbios_wmi(void)
0081 {
0082     return -ENODEV;
0083 }
0084 static inline void exit_dell_smbios_wmi(void)
0085 {}
0086 #endif /* CONFIG_DELL_SMBIOS_WMI */
0087 
0088 #ifdef CONFIG_DELL_SMBIOS_SMM
0089 int init_dell_smbios_smm(void);
0090 void exit_dell_smbios_smm(void);
0091 #else /* CONFIG_DELL_SMBIOS_SMM */
0092 static inline int init_dell_smbios_smm(void)
0093 {
0094     return -ENODEV;
0095 }
0096 static inline void exit_dell_smbios_smm(void)
0097 {}
0098 #endif /* CONFIG_DELL_SMBIOS_SMM */
0099 
0100 #endif /* _DELL_SMBIOS_H_ */