Skip to contentSkip to conversation

platform/x86: samsung-galaxybook: Add samsung-galaxybook driver

PATCH Applied Joshua Grisham 2 participants 3 messages Feb 1, 2025 – Feb 4, 2025

Subsystems (3)
lore
Share & tools
lore

Joshua Grisham

author maintainer
#0 lore raw

PATCH v10 1/1 platform/x86: samsung-galaxybook: Add samsung-galaxybook driver

Add a new driver for Samsung Galaxy Book series notebook devices with the following features:

- Keyboard backlight control
- Battery hook for installing power supply extension to add charge control end threshold
- Controller for Samsung's performance modes using the platform profile interface
- Adds firmware-attributes to control various system features
- Handles various hotkeys and notifications

---

v1->v2:
- Attempt to resolve all review comments from v1 as written here:
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#mbcbd8d5d9bc4496bac5486636c7d3b32bc3e5cd0

v2->v3:
- Tweak to battery attribute to closer match pattern in dell-wmi-ddv
- implement platform_profile_remove() change from 9b3bb37b44a317626464e79da8b39989b421963f
- Small tweak to Documentation page

v3->v4:
- Remove custom tracepoint (can trace via existing mechanisms)
- Remove module parameters
- Move sysfs attributes from device to firmware-attributes
- Refactor "allow_recording" to "camera_lens_cover" plus other small renames in aim to have more standardized naming that are cross-vendor
- Attempt to improve locking mechanisms
- Tweak logic for setting and getting led brightness
- More fixes for aiming to use devres/devm pattern
- Change battery charge end threshold to use 1 to 100 instead of 0 to 99
- Add swtich input event for camera_lens_cover remove all others (they will be generated as ACPI netlink events instead)
- Various other small tweaks and features as requested from feedback

v4-v5:
- Prefix all locally defined symbols with "GB_" as a namespace
- Remove extra unused out_buf from galaxybook_acpi_method
- Tighten up logic flow for setting and unsetting global pointer (now it is done directly in association with the i8042 filter init and exit)
- Rename "camera_lens_cover" to "block_recording"
- Change input device to only apply for "Camera Lens Cover", remove sparse keymap and set capabilities manually as part of block_recording init, then notify using input_report_switch when setting block_recording
- Correct firmware-attributes enumeration implementation (adding all attributes) and remove erroneous ABI fw attrs docs update
- Few small tweaks to how locks are used
- Use device_unregister instead of device_destroy for firmware attributes device
- Tighten up and clean up performance mode to profile mapping logic; now the mapping is largely "fixed" apart from "Ultra" that will map to performance while also re-mapping "Performance" to balanced-performance
- Tighten up error handling so probe will fail in more cases where it should fail
- Replace platform_profile_register with devm_platform_profile_register

v5->v6:
- A few small clean-up/fixes as requested from feedback
- Revamp performance mode profile mapping so it is more static and relies more on the facilities already built in to platform_profile, including:
- setting and using bits on profile handler choices to drive most of the behavior instead of having totally separate logic
- get_performance_mode_profile() is now a mostly static mapping that drives both setting initial profile choices and retrieving the right profile for a given performance_mode during runtime
- during init most of the mappings are hard-coded and the only things that are changed are the exception cases (override legacy values and downgrade of performance when Ultra mode is present)
- new function galaxybook_performance_mode_init() now handles initial startup performance mode in a much more simple and straight-forward way

v6->v7:
- Rebase to latest for-next and implement updates to firmware-attributes, platform_profile, and i8042 filter (including removal of global pointer).

v7->v8:
- Simplification and logic correction to platform_profile mapping and probe implementation, including renaming the internal performance modes to more closely match the internal names used by Samsung in Windows and align the logic in this driver to how it works with their Windows services.

v8->v9:
- Refactored "optional feature" init logic to return EOPNOTSUPP instead of 0 and then centralized handling of various flags in the probe function
- Re-sorted so get/show functions are always defined before set/store
- Removed manually deleting fw_attrs (kset_unregister takes care of this)
- Removed some unnecessary variable initializations
- Removed manually creating charge_control_end_threshold sysfs attribute and implemented new power supply extension framework instead
- Removed gb_pfmode() macro and instead use a local pointer in galaxybook_platform_profile_probe()

v9->v10:
- Change "not supported" error code to use a locally defined symbol GB_NOT_SUPPORTED instead of directly returning EOPNOTSUPP as it is more self-documenting and avoids checkpatch warnings which would otherwise be present when returning positive error codes
- Also brought up Thomas's and Armin's Reviewed-by tag so they do not get lost in the shuffle :)

---
 Documentation/admin-guide/laptops/index.rst   |    1 +
 .../laptops/samsung-galaxybook.rst            |  174 ++
 MAINTAINERS                                   |    7 +
 drivers/platform/x86/Kconfig                  |   17 +
 drivers/platform/x86/Makefile                 |    5 +-
 drivers/platform/x86/samsung-galaxybook.c     | 1423 +++++++++++++++++
 6 files changed, 1625 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/admin-guide/laptops/samsung-galaxybook.rst
 create mode 100644 drivers/platform/x86/samsung-galaxybook.c
Documentation/admin-guide/laptops/index.rst +1 -0
index cd9a1c2695fd..e71c8984c23e 100644
@@ -11,6 +11,7 @@ Laptop Drivers
    disk-shock-protection
    laptop-mode
    lg-laptop
+   samsung-galaxybook
    sony-laptop
    sonypi
    thinkpad-acpi
Documentation/admin-guide/laptops/samsung-galaxybook.rst new file +174 -0

174 lines not on this page · raw message

MAINTAINERS +7 -0
index 936e80f2c9ce..9d3d5359d304 100644
@@ -20913,6 +20913,13 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/video/fbdev/s3c-fb.c
 
+SAMSUNG GALAXY BOOK DRIVER
+M:	Joshua Grisham <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/admin-guide/laptops/samsung-galaxybook.rst
+F:	drivers/platform/x86/samsung-galaxybook.c
+
 SAMSUNG INTERCONNECT DRIVERS
 M:	Sylwester Nawrocki <[email protected]>
 M:	Artur Świgoń <[email protected]>
drivers/platform/x86/Kconfig +17 -0
index 0258dd879d64..c77178e2640b 100644
@@ -778,6 +778,23 @@ config BARCO_P50_GPIO
 	  To compile this driver as a module, choose M here: the module
 	  will be called barco-p50-gpio.
 
+config SAMSUNG_GALAXYBOOK
+	tristate "Samsung Galaxy Book driver"
+	depends on ACPI
+	depends on ACPI_BATTERY
+	depends on INPUT
+	depends on LEDS_CLASS
+	depends on SERIO_I8042
+	select ACPI_PLATFORM_PROFILE
+	select FW_ATTR_CLASS
+	help
+	  This is a driver for Samsung Galaxy Book series notebooks. It adds
+	  support for the keyboard backlight control, performance mode control,
+	  function keys, and various firmware attributes.
+
+	  For more information about this driver, see
+	  <file:Documentation/admin-guide/laptops/samsung-galaxybook.rst>.
+
 config SAMSUNG_LAPTOP
 	tristate "Samsung Laptop driver"
 	depends on RFKILL || RFKILL = n
drivers/platform/x86/Makefile +3 -2
index e1b142947067..32ec4cb9d902 100644
@@ -95,8 +95,9 @@ obj-$(CONFIG_PCENGINES_APU2)	+= pcengines-apuv2.o
 obj-$(CONFIG_BARCO_P50_GPIO)	+= barco-p50-gpio.o
 
 # Samsung
-obj-$(CONFIG_SAMSUNG_LAPTOP)	+= samsung-laptop.o
-obj-$(CONFIG_SAMSUNG_Q10)	+= samsung-q10.o
+obj-$(CONFIG_SAMSUNG_GALAXYBOOK)	+= samsung-galaxybook.o
+obj-$(CONFIG_SAMSUNG_LAPTOP)		+= samsung-laptop.o
+obj-$(CONFIG_SAMSUNG_Q10)		+= samsung-q10.o
 
 # Toshiba
 obj-$(CONFIG_TOSHIBA_BT_RFKILL)	+= toshiba_bluetooth.o
drivers/platform/x86/samsung-galaxybook.c new file +1423 -0

1,423 lines not on this page · raw message

Signature · 1 line
2.45.2
maintainer Applied
#1 lore raw
Quoted 11 lines · Joshua Grisham

Add a new driver for Samsung Galaxy Book series notebook devices with the following features:

- Keyboard backlight control
- Battery hook for installing power supply extension to add charge control end threshold
- Controller for Samsung's performance modes using the platform profile interface
- Adds firmware-attributes to control various system features
- Handles various hotkeys and notifications

Quoted 3 lines

I've applied this to review-ilpo-next.

Thanks a lot to all who have taken time to help in getting this into shape!

Signature · 1 line
 i.
author maintainer
#2 lore raw

Den mån 3 feb. 2025 kl 16:02 skrev Ilpo Järvinen
<[email protected]>:

Quoted 18 lines · Joshua Grisham
Quoted 12 lines

Add a new driver for Samsung Galaxy Book series notebook devices with the following features:

- Keyboard backlight control
- Battery hook for installing power supply extension to add charge control end threshold
- Controller for Samsung's performance modes using the platform profile interface
- Adds firmware-attributes to control various system features
- Handles various hotkeys and notifications

Quoted 3 lines
Quoted 7 lines

I've applied this to review-ilpo-next.

Thanks a lot to all who have taken time to help in getting this into shape!

--
i.

Thank you Ilpo!

Agreed completely and special thanks to Armin, Thomas, and Kurt for all of the extra time, help, and guidance along the way!

Best regards,
Joshua