xref: /dflybsd-src/sys/dev/drm/include/drm/i915_component.h (revision aee94f86171368465eaa15d649743f13cea3363a)
12c9916cdSFrançois Tigeot /*
22c9916cdSFrançois Tigeot  * Copyright © 2014 Intel Corporation
32c9916cdSFrançois Tigeot  *
42c9916cdSFrançois Tigeot  * Permission is hereby granted, free of charge, to any person obtaining a
52c9916cdSFrançois Tigeot  * copy of this software and associated documentation files (the "Software"),
62c9916cdSFrançois Tigeot  * to deal in the Software without restriction, including without limitation
72c9916cdSFrançois Tigeot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
82c9916cdSFrançois Tigeot  * and/or sell copies of the Software, and to permit persons to whom the
92c9916cdSFrançois Tigeot  * Software is furnished to do so, subject to the following conditions:
102c9916cdSFrançois Tigeot  *
112c9916cdSFrançois Tigeot  * The above copyright notice and this permission notice (including the next
122c9916cdSFrançois Tigeot  * paragraph) shall be included in all copies or substantial portions of the
132c9916cdSFrançois Tigeot  * Software.
142c9916cdSFrançois Tigeot  *
152c9916cdSFrançois Tigeot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
162c9916cdSFrançois Tigeot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
172c9916cdSFrançois Tigeot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
182c9916cdSFrançois Tigeot  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
192c9916cdSFrançois Tigeot  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
202c9916cdSFrançois Tigeot  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
212c9916cdSFrançois Tigeot  * IN THE SOFTWARE.
222c9916cdSFrançois Tigeot  */
232c9916cdSFrançois Tigeot 
242c9916cdSFrançois Tigeot #ifndef _I915_COMPONENT_H_
252c9916cdSFrançois Tigeot #define _I915_COMPONENT_H_
262c9916cdSFrançois Tigeot 
27*aee94f86SFrançois Tigeot #include <linux/device.h>
28*aee94f86SFrançois Tigeot 
29352ff8bdSFrançois Tigeot /* MAX_PORT is the number of port
30352ff8bdSFrançois Tigeot  * It must be sync with I915_MAX_PORTS defined i915_drv.h
31352ff8bdSFrançois Tigeot  * 5 should be enough as only HSW, BDW, SKL need such fix.
32352ff8bdSFrançois Tigeot  */
33352ff8bdSFrançois Tigeot #define MAX_PORTS 5
34352ff8bdSFrançois Tigeot 
35352ff8bdSFrançois Tigeot /**
36*aee94f86SFrançois Tigeot  * struct i915_audio_component_ops - Ops implemented by i915 driver, called by hda driver
37352ff8bdSFrançois Tigeot  */
38*aee94f86SFrançois Tigeot struct i915_audio_component_ops {
39*aee94f86SFrançois Tigeot 	/**
40*aee94f86SFrançois Tigeot 	 * @owner: i915 module
41*aee94f86SFrançois Tigeot 	 */
422c9916cdSFrançois Tigeot 	struct module *owner;
43*aee94f86SFrançois Tigeot 	/**
44*aee94f86SFrançois Tigeot 	 * @get_power: get the POWER_DOMAIN_AUDIO power well
45*aee94f86SFrançois Tigeot 	 *
46*aee94f86SFrançois Tigeot 	 * Request the power well to be turned on.
47*aee94f86SFrançois Tigeot 	 */
482c9916cdSFrançois Tigeot 	void (*get_power)(struct device *);
49*aee94f86SFrançois Tigeot 	/**
50*aee94f86SFrançois Tigeot 	 * @put_power: put the POWER_DOMAIN_AUDIO power well
51*aee94f86SFrançois Tigeot 	 *
52*aee94f86SFrançois Tigeot 	 * Allow the power well to be turned off.
53*aee94f86SFrançois Tigeot 	 */
542c9916cdSFrançois Tigeot 	void (*put_power)(struct device *);
55*aee94f86SFrançois Tigeot 	/**
56*aee94f86SFrançois Tigeot 	 * @codec_wake_override: Enable/disable codec wake signal
57*aee94f86SFrançois Tigeot 	 */
5819c468b4SFrançois Tigeot 	void (*codec_wake_override)(struct device *, bool enable);
59*aee94f86SFrançois Tigeot 	/**
60*aee94f86SFrançois Tigeot 	 * @get_cdclk_freq: Get the Core Display Clock in kHz
61*aee94f86SFrançois Tigeot 	 */
622c9916cdSFrançois Tigeot 	int (*get_cdclk_freq)(struct device *);
63352ff8bdSFrançois Tigeot 	/**
64352ff8bdSFrançois Tigeot 	 * @sync_audio_rate: set n/cts based on the sample rate
65352ff8bdSFrançois Tigeot 	 *
66352ff8bdSFrançois Tigeot 	 * Called from audio driver. After audio driver sets the
67352ff8bdSFrançois Tigeot 	 * sample rate, it will call this function to set n/cts
68352ff8bdSFrançois Tigeot 	 */
69352ff8bdSFrançois Tigeot 	int (*sync_audio_rate)(struct device *, int port, int rate);
70*aee94f86SFrançois Tigeot 	/**
71*aee94f86SFrançois Tigeot 	 * @get_eld: fill the audio state and ELD bytes for the given port
72*aee94f86SFrançois Tigeot 	 *
73*aee94f86SFrançois Tigeot 	 * Called from audio driver to get the HDMI/DP audio state of the given
74*aee94f86SFrançois Tigeot 	 * digital port, and also fetch ELD bytes to the given pointer.
75*aee94f86SFrançois Tigeot 	 *
76*aee94f86SFrançois Tigeot 	 * It returns the byte size of the original ELD (not the actually
77*aee94f86SFrançois Tigeot 	 * copied size), zero for an invalid ELD, or a negative error code.
78*aee94f86SFrançois Tigeot 	 *
79*aee94f86SFrançois Tigeot 	 * Note that the returned size may be over @max_bytes.  Then it
80*aee94f86SFrançois Tigeot 	 * implies that only a part of ELD has been copied to the buffer.
81*aee94f86SFrançois Tigeot 	 */
82*aee94f86SFrançois Tigeot 	int (*get_eld)(struct device *, int port, bool *enabled,
83*aee94f86SFrançois Tigeot 		       unsigned char *buf, int max_bytes);
84*aee94f86SFrançois Tigeot };
85a05eeebfSFrançois Tigeot 
86*aee94f86SFrançois Tigeot /**
87*aee94f86SFrançois Tigeot  * struct i915_audio_component_audio_ops - Ops implemented by hda driver, called by i915 driver
88*aee94f86SFrançois Tigeot  */
89*aee94f86SFrançois Tigeot struct i915_audio_component_audio_ops {
90*aee94f86SFrançois Tigeot 	/**
91*aee94f86SFrançois Tigeot 	 * @audio_ptr: Pointer to be used in call to pin_eld_notify
92*aee94f86SFrançois Tigeot 	 */
93a05eeebfSFrançois Tigeot 	void *audio_ptr;
94a05eeebfSFrançois Tigeot 	/**
95*aee94f86SFrançois Tigeot 	 * @pin_eld_notify: Notify the HDA driver that pin sense and/or ELD information has changed
96*aee94f86SFrançois Tigeot 	 *
97*aee94f86SFrançois Tigeot 	 * Called when the i915 driver has set up audio pipeline or has just
98*aee94f86SFrançois Tigeot 	 * begun to tear it down. This allows the HDA driver to update its
99*aee94f86SFrançois Tigeot 	 * status accordingly (even when the HDA controller is in power save
100*aee94f86SFrançois Tigeot 	 * mode).
101a05eeebfSFrançois Tigeot 	 */
102a05eeebfSFrançois Tigeot 	void (*pin_eld_notify)(void *audio_ptr, int port);
103*aee94f86SFrançois Tigeot };
104*aee94f86SFrançois Tigeot 
105*aee94f86SFrançois Tigeot /**
106*aee94f86SFrançois Tigeot  * struct i915_audio_component - Used for direct communication between i915 and hda drivers
107*aee94f86SFrançois Tigeot  */
108*aee94f86SFrançois Tigeot struct i915_audio_component {
109*aee94f86SFrançois Tigeot 	/**
110*aee94f86SFrançois Tigeot 	 * @dev: i915 device, used as parameter for ops
111*aee94f86SFrançois Tigeot 	 */
112*aee94f86SFrançois Tigeot 	struct device *dev;
113*aee94f86SFrançois Tigeot 	/**
114*aee94f86SFrançois Tigeot 	 * @aud_sample_rate: the array of audio sample rate per port
115*aee94f86SFrançois Tigeot 	 */
116*aee94f86SFrançois Tigeot 	int aud_sample_rate[MAX_PORTS];
117*aee94f86SFrançois Tigeot 	/**
118*aee94f86SFrançois Tigeot 	 * @ops: Ops implemented by i915 driver, called by hda driver
119*aee94f86SFrançois Tigeot 	 */
120*aee94f86SFrançois Tigeot 	const struct i915_audio_component_ops *ops;
121*aee94f86SFrançois Tigeot 	/**
122*aee94f86SFrançois Tigeot 	 * @audio_ops: Ops implemented by hda driver, called by i915 driver
123*aee94f86SFrançois Tigeot 	 */
124*aee94f86SFrançois Tigeot 	const struct i915_audio_component_audio_ops *audio_ops;
1252c9916cdSFrançois Tigeot };
1262c9916cdSFrançois Tigeot 
1272c9916cdSFrançois Tigeot #endif /* _I915_COMPONENT_H_ */
128