blob: 93a386be38fa1155b95fab99123ad8f1c4dc1d7b [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
Takashi Iwaia57942b2018-07-11 16:23:16 +02007struct drm_audio_component;
Ramalingam C35c02722019-02-16 10:34:59 +05308struct device;
Takashi Iwaia57942b2018-07-11 16:23:16 +02009
Takashi Iwaiae891ab2018-07-11 15:17:22 +020010/**
11 * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver
12 */
13struct drm_audio_component_ops {
14 /**
15 * @owner: drm module to pin down
16 */
17 struct module *owner;
18 /**
19 * @get_power: get the POWER_DOMAIN_AUDIO power well
20 *
21 * Request the power well to be turned on.
22 */
23 void (*get_power)(struct device *);
24 /**
25 * @put_power: put the POWER_DOMAIN_AUDIO power well
26 *
27 * Allow the power well to be turned off.
28 */
29 void (*put_power)(struct device *);
30 /**
31 * @codec_wake_override: Enable/disable codec wake signal
32 */
33 void (*codec_wake_override)(struct device *, bool enable);
34 /**
35 * @get_cdclk_freq: Get the Core Display Clock in kHz
36 */
37 int (*get_cdclk_freq)(struct device *);
38 /**
39 * @sync_audio_rate: set n/cts based on the sample rate
40 *
41 * Called from audio driver. After audio driver sets the
42 * sample rate, it will call this function to set n/cts
43 */
44 int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
45 /**
46 * @get_eld: fill the audio state and ELD bytes for the given port
47 *
48 * Called from audio driver to get the HDMI/DP audio state of the given
49 * digital port, and also fetch ELD bytes to the given pointer.
50 *
51 * It returns the byte size of the original ELD (not the actually
52 * copied size), zero for an invalid ELD, or a negative error code.
53 *
54 * Note that the returned size may be over @max_bytes. Then it
55 * implies that only a part of ELD has been copied to the buffer.
56 */
57 int (*get_eld)(struct device *, int port, int pipe, bool *enabled,
58 unsigned char *buf, int max_bytes);
59};
60
61/**
62 * struct drm_audio_component_audio_ops - Ops implemented by hda driver, called by DRM driver
63 */
64struct drm_audio_component_audio_ops {
65 /**
66 * @audio_ptr: Pointer to be used in call to pin_eld_notify
67 */
68 void *audio_ptr;
69 /**
70 * @pin_eld_notify: Notify the HDA driver that pin sense and/or ELD information has changed
71 *
72 * Called when the DRM driver has set up audio pipeline or has just
73 * begun to tear it down. This allows the HDA driver to update its
74 * status accordingly (even when the HDA controller is in power save
75 * mode).
76 */
77 void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
Takashi Iwaia57942b2018-07-11 16:23:16 +020078 /**
79 * @pin2port: Check and convert from pin node to port number
80 *
81 * Called by HDA driver to check and convert from the pin widget node
82 * number to a port number in the graphics side.
83 */
84 int (*pin2port)(void *audio_ptr, int pin);
85 /**
86 * @master_bind: (Optional) component master bind callback
87 *
88 * Called at binding master component, for HDA codec-specific
89 * handling of dynamic binding.
90 */
91 int (*master_bind)(struct device *dev, struct drm_audio_component *);
92 /**
93 * @master_unbind: (Optional) component master unbind callback
94 *
95 * Called at unbinding master component, for HDA codec-specific
96 * handling of dynamic unbinding.
97 */
98 void (*master_unbind)(struct device *dev, struct drm_audio_component *);
Takashi Iwaiae891ab2018-07-11 15:17:22 +020099};
100
101/**
102 * struct drm_audio_component - Used for direct communication between DRM and hda drivers
103 */
104struct drm_audio_component {
105 /**
106 * @dev: DRM device, used as parameter for ops
107 */
108 struct device *dev;
109 /**
110 * @ops: Ops implemented by DRM driver, called by hda driver
111 */
112 const struct drm_audio_component_ops *ops;
113 /**
114 * @audio_ops: Ops implemented by hda driver, called by DRM driver
115 */
116 const struct drm_audio_component_audio_ops *audio_ops;
117};
118
119#endif /* _DRM_AUDIO_COMPONENT_H_ */