dell_wmi_helper.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Helper functions for Dell Mic Mute LED control;
  3. * to be included from codec driver
  4. */
  5. #if IS_ENABLED(CONFIG_DELL_LAPTOP)
  6. #include <linux/dell-led.h>
  7. static int (*dell_micmute_led_set_func)(int);
  8. static void dell_micmute_update(struct hda_codec *codec)
  9. {
  10. struct hda_gen_spec *spec = codec->spec;
  11. dell_micmute_led_set_func(spec->micmute_led.led_value);
  12. }
  13. static void alc_fixup_dell_wmi(struct hda_codec *codec,
  14. const struct hda_fixup *fix, int action)
  15. {
  16. bool removefunc = false;
  17. if (action == HDA_FIXUP_ACT_PROBE) {
  18. if (!dell_micmute_led_set_func)
  19. dell_micmute_led_set_func = symbol_request(dell_micmute_led_set);
  20. if (!dell_micmute_led_set_func) {
  21. codec_warn(codec, "Failed to find dell wmi symbol dell_micmute_led_set\n");
  22. return;
  23. }
  24. removefunc = (dell_micmute_led_set_func(false) < 0) ||
  25. (snd_hda_gen_add_micmute_led(codec,
  26. dell_micmute_update) < 0);
  27. }
  28. if (dell_micmute_led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) {
  29. symbol_put(dell_micmute_led_set);
  30. dell_micmute_led_set_func = NULL;
  31. }
  32. }
  33. #else /* CONFIG_DELL_LAPTOP */
  34. static void alc_fixup_dell_wmi(struct hda_codec *codec,
  35. const struct hda_fixup *fix, int action)
  36. {
  37. }
  38. #endif /* CONFIG_DELL_LAPTOP */