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