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