msm-audio-event-notify.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (c) 2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <dsp/msm-audio-event-notify.h>
  13. #include <linux/export.h>
  14. static ATOMIC_NOTIFIER_HEAD(msm_aud_evt_notifier_list);
  15. static BLOCKING_NOTIFIER_HEAD(msm_aud_evt_blocking_notifier_list);
  16. /**
  17. * msm_aud_evt_register_client - register a client notifier
  18. * @nb: notifier block to callback on events
  19. */
  20. int msm_aud_evt_register_client(struct notifier_block *nb)
  21. {
  22. return atomic_notifier_chain_register(&msm_aud_evt_notifier_list, nb);
  23. }
  24. EXPORT_SYMBOL(msm_aud_evt_register_client);
  25. /**
  26. * msm_aud_evt_unregister_client - unregister a client notifier
  27. * @nb: notifier block to callback on events
  28. */
  29. int msm_aud_evt_unregister_client(struct notifier_block *nb)
  30. {
  31. return atomic_notifier_chain_unregister(&msm_aud_evt_notifier_list, nb);
  32. }
  33. EXPORT_SYMBOL(msm_aud_evt_unregister_client);
  34. /**
  35. * msm_aud_evt_notifier_call_chain - notify clients of fb_events
  36. *
  37. */
  38. int msm_aud_evt_notifier_call_chain(unsigned long val, void *v)
  39. {
  40. return atomic_notifier_call_chain(&msm_aud_evt_notifier_list, val, v);
  41. }
  42. EXPORT_SYMBOL_GPL(msm_aud_evt_notifier_call_chain);
  43. /**
  44. * msm_aud_evt_blocking_register_client - register a client notifier
  45. * @nb: notifier block to callback on events
  46. */
  47. int msm_aud_evt_blocking_register_client(struct notifier_block *nb)
  48. {
  49. return blocking_notifier_chain_register(
  50. &msm_aud_evt_blocking_notifier_list, nb);
  51. }
  52. EXPORT_SYMBOL(msm_aud_evt_blocking_register_client);
  53. /**
  54. * msm_aud_evt_unregister_client - unregister a client notifier
  55. * @nb: notifier block to callback on events
  56. */
  57. int msm_aud_evt_blocking_unregister_client(struct notifier_block *nb)
  58. {
  59. return blocking_notifier_chain_unregister(
  60. &msm_aud_evt_blocking_notifier_list, nb);
  61. }
  62. EXPORT_SYMBOL(msm_aud_evt_blocking_unregister_client);
  63. /**
  64. * msm_aud_evt_notifier_call_chain - notify clients of fb_events
  65. * @val: event or enum maintained by caller
  66. * @v: private data pointer
  67. *
  68. */
  69. int msm_aud_evt_blocking_notifier_call_chain(unsigned long val, void *v)
  70. {
  71. return blocking_notifier_call_chain(
  72. &msm_aud_evt_blocking_notifier_list, val, v);
  73. }
  74. EXPORT_SYMBOL_GPL(msm_aud_evt_blocking_notifier_call_chain);