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