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