drm_audio_component.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // SPDX-License-Identifier: MIT
  2. // Copyright © 2014 Intel Corporation
  3. #ifndef _DRM_AUDIO_COMPONENT_H_
  4. #define _DRM_AUDIO_COMPONENT_H_
  5. #include <linux/completion.h>
  6. #include <linux/types.h>
  7. struct drm_audio_component;
  8. struct device;
  9. /**
  10. * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver
  11. */
  12. struct drm_audio_component_ops {
  13. /**
  14. * @owner: drm module to pin down
  15. */
  16. struct module *owner;
  17. /**
  18. * @get_power: get the POWER_DOMAIN_AUDIO power well
  19. *
  20. * Request the power well to be turned on.
  21. *
  22. * Returns a wakeref cookie to be passed back to the corresponding
  23. * call to @put_power.
  24. */
  25. unsigned long (*get_power)(struct device *);
  26. /**
  27. * @put_power: put the POWER_DOMAIN_AUDIO power well
  28. *
  29. * Allow the power well to be turned off.
  30. */
  31. void (*put_power)(struct device *, unsigned long);
  32. /**
  33. * @codec_wake_override: Enable/disable codec wake signal
  34. */
  35. void (*codec_wake_override)(struct device *, bool enable);
  36. /**
  37. * @get_cdclk_freq: Get the Core Display Clock in kHz
  38. */
  39. int (*get_cdclk_freq)(struct device *);
  40. /**
  41. * @sync_audio_rate: set n/cts based on the sample rate
  42. *
  43. * Called from audio driver. After audio driver sets the
  44. * sample rate, it will call this function to set n/cts
  45. */
  46. int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
  47. /**
  48. * @get_eld: fill the audio state and ELD bytes for the given port
  49. *
  50. * Called from audio driver to get the HDMI/DP audio state of the given
  51. * digital port, and also fetch ELD bytes to the given pointer.
  52. *
  53. * It returns the byte size of the original ELD (not the actually
  54. * copied size), zero for an invalid ELD, or a negative error code.
  55. *
  56. * Note that the returned size may be over @max_bytes. Then it
  57. * implies that only a part of ELD has been copied to the buffer.
  58. */
  59. int (*get_eld)(struct device *, int port, int pipe, bool *enabled,
  60. unsigned char *buf, int max_bytes);
  61. };
  62. /**
  63. * struct drm_audio_component_audio_ops - Ops implemented by hda driver, called by DRM driver
  64. */
  65. struct drm_audio_component_audio_ops {
  66. /**
  67. * @audio_ptr: Pointer to be used in call to pin_eld_notify
  68. */
  69. void *audio_ptr;
  70. /**
  71. * @pin_eld_notify: Notify the HDA driver that pin sense and/or ELD information has changed
  72. *
  73. * Called when the DRM driver has set up audio pipeline or has just
  74. * begun to tear it down. This allows the HDA driver to update its
  75. * status accordingly (even when the HDA controller is in power save
  76. * mode).
  77. */
  78. void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
  79. /**
  80. * @pin2port: Check and convert from pin node to port number
  81. *
  82. * Called by HDA driver to check and convert from the pin widget node
  83. * number to a port number in the graphics side.
  84. */
  85. int (*pin2port)(void *audio_ptr, int pin);
  86. /**
  87. * @master_bind: (Optional) component master bind callback
  88. *
  89. * Called at binding master component, for HDA codec-specific
  90. * handling of dynamic binding.
  91. */
  92. int (*master_bind)(struct device *dev, struct drm_audio_component *);
  93. /**
  94. * @master_unbind: (Optional) component master unbind callback
  95. *
  96. * Called at unbinding master component, for HDA codec-specific
  97. * handling of dynamic unbinding.
  98. */
  99. void (*master_unbind)(struct device *dev, struct drm_audio_component *);
  100. };
  101. /**
  102. * struct drm_audio_component - Used for direct communication between DRM and hda drivers
  103. */
  104. struct drm_audio_component {
  105. /**
  106. * @dev: DRM device, used as parameter for ops
  107. */
  108. struct device *dev;
  109. /**
  110. * @ops: Ops implemented by DRM driver, called by hda driver
  111. */
  112. const struct drm_audio_component_ops *ops;
  113. /**
  114. * @audio_ops: Ops implemented by hda driver, called by DRM driver
  115. */
  116. const struct drm_audio_component_audio_ops *audio_ops;
  117. /**
  118. * @master_bind_complete: completion held during component master binding
  119. */
  120. struct completion master_bind_complete;
  121. };
  122. #endif /* _DRM_AUDIO_COMPONENT_H_ */