audio_notifier.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __AUDIO_NOTIFIER_H_
  6. #define __AUDIO_NOTIFIER_H_
  7. /* State of the notifier domain */
  8. enum {
  9. AUDIO_NOTIFIER_SERVICE_DOWN,
  10. AUDIO_NOTIFIER_SERVICE_UP
  11. };
  12. /* Service order determines connection priority
  13. * Highest number connected first
  14. */
  15. enum {
  16. AUDIO_NOTIFIER_SSR_SERVICE,
  17. AUDIO_NOTIFIER_PDR_SERVICE,
  18. AUDIO_NOTIFIER_MAX_SERVICES
  19. };
  20. enum {
  21. AUDIO_NOTIFIER_ADSP_DOMAIN,
  22. AUDIO_NOTIFIER_MODEM_DOMAIN,
  23. AUDIO_NOTIFIER_MAX_DOMAINS
  24. };
  25. /* Structure populated in void *data of nb function
  26. * callback used for audio_notifier_register
  27. */
  28. struct audio_notifier_cb_data {
  29. int service;
  30. int domain;
  31. };
  32. #if IS_ENABLED(CONFIG_MSM_QDSP6_NOTIFIER)
  33. /*
  34. * Use audio_notifier_register to register any audio
  35. * clients who need to be notified of a remote process.
  36. * This API will determine and register the client with
  37. * the best available subsystem (SSR or PDR) for that
  38. * domain (Adsp or Modem). When an event is sent from that
  39. * domain the notifier block callback function will be called.
  40. *
  41. * client_name - A unique user name defined by the client.
  42. * If the same name is used for multiple calls each will
  43. * be tracked & called back separately and a single call
  44. * to deregister will delete them all.
  45. * domain - Domain the client wants to get events from.
  46. * AUDIO_NOTIFIER_ADSP_DOMAIN
  47. * AUDIO_NOTIFIER_MODEM_DOMAIN
  48. * *nb - Pointer to a notifier block. Provide a callback function
  49. * to be notified of an even on that domain.
  50. *
  51. * nb_func(struct notifier_block *this, unsigned long opcode, void *data)
  52. * this - pointer to own nb
  53. * opcode - event from registered domain
  54. * AUDIO_NOTIFIER_SERVICE_DOWN
  55. * AUDIO_NOTIFIER_SERVICE_UP
  56. * *data - pointer to struct audio_notifier_cb_data
  57. *
  58. * Returns: Success: 0
  59. * Error: -#
  60. */
  61. int audio_notifier_register(char *client_name, int domain,
  62. struct notifier_block *nb);
  63. /*
  64. * Use audio_notifier_deregister to deregister the clients from
  65. * all domains registered using audio_notifier_register that
  66. * match the client name.
  67. *
  68. * client_name - Unique user name used in audio_notifier_register.
  69. * Returns: Success: 0
  70. * Error: -#
  71. */
  72. int audio_notifier_deregister(char *client_name);
  73. bool audio_notifier_probe_status(void);
  74. #else
  75. static inline int audio_notifier_register(char *client_name, int domain,
  76. struct notifier_block *nb)
  77. {
  78. return 0;
  79. }
  80. static inline int audio_notifier_deregister(char *client_name)
  81. {
  82. return 0;
  83. }
  84. static inline bool audio_notifier_probe_status(void)
  85. {
  86. return 0;
  87. }
  88. #endif /* CONFIG_MSM_QDSP6_NOTIFIER */
  89. #endif