thinkpad_helper.c 891 B

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Helper functions for Thinkpad LED control;
  3. * to be included from codec driver
  4. */
  5. #if IS_ENABLED(CONFIG_THINKPAD_ACPI)
  6. #include <linux/acpi.h>
  7. #include <linux/leds.h>
  8. static bool is_thinkpad(struct hda_codec *codec)
  9. {
  10. return (codec->core.subsystem_id >> 16 == 0x17aa) &&
  11. (acpi_dev_found("LEN0068") || acpi_dev_found("LEN0268") ||
  12. acpi_dev_found("IBM0068"));
  13. }
  14. static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
  15. const struct hda_fixup *fix, int action)
  16. {
  17. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  18. if (!is_thinkpad(codec))
  19. return;
  20. snd_hda_gen_add_mute_led_cdev(codec, NULL);
  21. snd_hda_gen_add_micmute_led_cdev(codec, NULL);
  22. }
  23. }
  24. #else /* CONFIG_THINKPAD_ACPI */
  25. static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
  26. const struct hda_fixup *fix, int action)
  27. {
  28. }
  29. #endif /* CONFIG_THINKPAD_ACPI */