drm_audio_component.h 3.5 KB

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