1*41ec0267Sriastradh /* $NetBSD: drm_audio_component.h,v 1.2 2021/12/18 23:45:45 riastradh Exp $ */ 24e390cabSriastradh 34e390cabSriastradh // SPDX-License-Identifier: MIT 44e390cabSriastradh // Copyright © 2014 Intel Corporation 54e390cabSriastradh 64e390cabSriastradh #ifndef _DRM_AUDIO_COMPONENT_H_ 74e390cabSriastradh #define _DRM_AUDIO_COMPONENT_H_ 84e390cabSriastradh 94e390cabSriastradh struct drm_audio_component; 104e390cabSriastradh struct device; 114e390cabSriastradh 124e390cabSriastradh /** 134e390cabSriastradh * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver 144e390cabSriastradh */ 154e390cabSriastradh struct drm_audio_component_ops { 164e390cabSriastradh /** 174e390cabSriastradh * @owner: drm module to pin down 184e390cabSriastradh */ 194e390cabSriastradh struct module *owner; 204e390cabSriastradh /** 214e390cabSriastradh * @get_power: get the POWER_DOMAIN_AUDIO power well 224e390cabSriastradh * 234e390cabSriastradh * Request the power well to be turned on. 244e390cabSriastradh * 254e390cabSriastradh * Returns a wakeref cookie to be passed back to the corresponding 264e390cabSriastradh * call to @put_power. 274e390cabSriastradh */ 284e390cabSriastradh unsigned long (*get_power)(struct device *); 294e390cabSriastradh /** 304e390cabSriastradh * @put_power: put the POWER_DOMAIN_AUDIO power well 314e390cabSriastradh * 324e390cabSriastradh * Allow the power well to be turned off. 334e390cabSriastradh */ 344e390cabSriastradh void (*put_power)(struct device *, unsigned long); 354e390cabSriastradh /** 364e390cabSriastradh * @codec_wake_override: Enable/disable codec wake signal 374e390cabSriastradh */ 384e390cabSriastradh void (*codec_wake_override)(struct device *, bool enable); 394e390cabSriastradh /** 404e390cabSriastradh * @get_cdclk_freq: Get the Core Display Clock in kHz 414e390cabSriastradh */ 424e390cabSriastradh int (*get_cdclk_freq)(struct device *); 434e390cabSriastradh /** 444e390cabSriastradh * @sync_audio_rate: set n/cts based on the sample rate 454e390cabSriastradh * 464e390cabSriastradh * Called from audio driver. After audio driver sets the 474e390cabSriastradh * sample rate, it will call this function to set n/cts 484e390cabSriastradh */ 494e390cabSriastradh int (*sync_audio_rate)(struct device *, int port, int pipe, int rate); 504e390cabSriastradh /** 514e390cabSriastradh * @get_eld: fill the audio state and ELD bytes for the given port 524e390cabSriastradh * 534e390cabSriastradh * Called from audio driver to get the HDMI/DP audio state of the given 544e390cabSriastradh * digital port, and also fetch ELD bytes to the given pointer. 554e390cabSriastradh * 564e390cabSriastradh * It returns the byte size of the original ELD (not the actually 574e390cabSriastradh * copied size), zero for an invalid ELD, or a negative error code. 584e390cabSriastradh * 594e390cabSriastradh * Note that the returned size may be over @max_bytes. Then it 604e390cabSriastradh * implies that only a part of ELD has been copied to the buffer. 614e390cabSriastradh */ 624e390cabSriastradh int (*get_eld)(struct device *, int port, int pipe, bool *enabled, 634e390cabSriastradh unsigned char *buf, int max_bytes); 644e390cabSriastradh }; 654e390cabSriastradh 664e390cabSriastradh /** 674e390cabSriastradh * struct drm_audio_component_audio_ops - Ops implemented by hda driver, called by DRM driver 684e390cabSriastradh */ 694e390cabSriastradh struct drm_audio_component_audio_ops { 704e390cabSriastradh /** 714e390cabSriastradh * @audio_ptr: Pointer to be used in call to pin_eld_notify 724e390cabSriastradh */ 734e390cabSriastradh void *audio_ptr; 744e390cabSriastradh /** 754e390cabSriastradh * @pin_eld_notify: Notify the HDA driver that pin sense and/or ELD information has changed 764e390cabSriastradh * 774e390cabSriastradh * Called when the DRM driver has set up audio pipeline or has just 784e390cabSriastradh * begun to tear it down. This allows the HDA driver to update its 794e390cabSriastradh * status accordingly (even when the HDA controller is in power save 804e390cabSriastradh * mode). 814e390cabSriastradh */ 824e390cabSriastradh void (*pin_eld_notify)(void *audio_ptr, int port, int pipe); 834e390cabSriastradh /** 844e390cabSriastradh * @pin2port: Check and convert from pin node to port number 854e390cabSriastradh * 864e390cabSriastradh * Called by HDA driver to check and convert from the pin widget node 874e390cabSriastradh * number to a port number in the graphics side. 884e390cabSriastradh */ 894e390cabSriastradh int (*pin2port)(void *audio_ptr, int pin); 904e390cabSriastradh /** 914e390cabSriastradh * @master_bind: (Optional) component master bind callback 924e390cabSriastradh * 934e390cabSriastradh * Called at binding master component, for HDA codec-specific 944e390cabSriastradh * handling of dynamic binding. 954e390cabSriastradh */ 964e390cabSriastradh int (*master_bind)(struct device *dev, struct drm_audio_component *); 974e390cabSriastradh /** 984e390cabSriastradh * @master_unbind: (Optional) component master unbind callback 994e390cabSriastradh * 1004e390cabSriastradh * Called at unbinding master component, for HDA codec-specific 1014e390cabSriastradh * handling of dynamic unbinding. 1024e390cabSriastradh */ 1034e390cabSriastradh void (*master_unbind)(struct device *dev, struct drm_audio_component *); 1044e390cabSriastradh }; 1054e390cabSriastradh 1064e390cabSriastradh /** 1074e390cabSriastradh * struct drm_audio_component - Used for direct communication between DRM and hda drivers 1084e390cabSriastradh */ 1094e390cabSriastradh struct drm_audio_component { 1104e390cabSriastradh /** 1114e390cabSriastradh * @dev: DRM device, used as parameter for ops 1124e390cabSriastradh */ 1134e390cabSriastradh struct device *dev; 1144e390cabSriastradh /** 1154e390cabSriastradh * @ops: Ops implemented by DRM driver, called by hda driver 1164e390cabSriastradh */ 1174e390cabSriastradh const struct drm_audio_component_ops *ops; 1184e390cabSriastradh /** 1194e390cabSriastradh * @audio_ops: Ops implemented by hda driver, called by DRM driver 1204e390cabSriastradh */ 1214e390cabSriastradh const struct drm_audio_component_audio_ops *audio_ops; 1224e390cabSriastradh }; 1234e390cabSriastradh 1244e390cabSriastradh #endif /* _DRM_AUDIO_COMPONENT_H_ */ 125