18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: MIT 28c2ecf20Sopenharmony_ci// Copyright © 2014 Intel Corporation 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _DRM_AUDIO_COMPONENT_H_ 58c2ecf20Sopenharmony_ci#define _DRM_AUDIO_COMPONENT_H_ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_cistruct drm_audio_component; 88c2ecf20Sopenharmony_cistruct device; 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/** 118c2ecf20Sopenharmony_ci * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_cistruct drm_audio_component_ops { 148c2ecf20Sopenharmony_ci /** 158c2ecf20Sopenharmony_ci * @owner: drm module to pin down 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci struct module *owner; 188c2ecf20Sopenharmony_ci /** 198c2ecf20Sopenharmony_ci * @get_power: get the POWER_DOMAIN_AUDIO power well 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * Request the power well to be turned on. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Returns a wakeref cookie to be passed back to the corresponding 248c2ecf20Sopenharmony_ci * call to @put_power. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci unsigned long (*get_power)(struct device *); 278c2ecf20Sopenharmony_ci /** 288c2ecf20Sopenharmony_ci * @put_power: put the POWER_DOMAIN_AUDIO power well 298c2ecf20Sopenharmony_ci * 308c2ecf20Sopenharmony_ci * Allow the power well to be turned off. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci void (*put_power)(struct device *, unsigned long); 338c2ecf20Sopenharmony_ci /** 348c2ecf20Sopenharmony_ci * @codec_wake_override: Enable/disable codec wake signal 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci void (*codec_wake_override)(struct device *, bool enable); 378c2ecf20Sopenharmony_ci /** 388c2ecf20Sopenharmony_ci * @get_cdclk_freq: Get the Core Display Clock in kHz 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_ci int (*get_cdclk_freq)(struct device *); 418c2ecf20Sopenharmony_ci /** 428c2ecf20Sopenharmony_ci * @sync_audio_rate: set n/cts based on the sample rate 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * Called from audio driver. After audio driver sets the 458c2ecf20Sopenharmony_ci * sample rate, it will call this function to set n/cts 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ci int (*sync_audio_rate)(struct device *, int port, int pipe, int rate); 488c2ecf20Sopenharmony_ci /** 498c2ecf20Sopenharmony_ci * @get_eld: fill the audio state and ELD bytes for the given port 508c2ecf20Sopenharmony_ci * 518c2ecf20Sopenharmony_ci * Called from audio driver to get the HDMI/DP audio state of the given 528c2ecf20Sopenharmony_ci * digital port, and also fetch ELD bytes to the given pointer. 538c2ecf20Sopenharmony_ci * 548c2ecf20Sopenharmony_ci * It returns the byte size of the original ELD (not the actually 558c2ecf20Sopenharmony_ci * copied size), zero for an invalid ELD, or a negative error code. 568c2ecf20Sopenharmony_ci * 578c2ecf20Sopenharmony_ci * Note that the returned size may be over @max_bytes. Then it 588c2ecf20Sopenharmony_ci * implies that only a part of ELD has been copied to the buffer. 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci int (*get_eld)(struct device *, int port, int pipe, bool *enabled, 618c2ecf20Sopenharmony_ci unsigned char *buf, int max_bytes); 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/** 658c2ecf20Sopenharmony_ci * struct drm_audio_component_audio_ops - Ops implemented by hda driver, called by DRM driver 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_cistruct drm_audio_component_audio_ops { 688c2ecf20Sopenharmony_ci /** 698c2ecf20Sopenharmony_ci * @audio_ptr: Pointer to be used in call to pin_eld_notify 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ci void *audio_ptr; 728c2ecf20Sopenharmony_ci /** 738c2ecf20Sopenharmony_ci * @pin_eld_notify: Notify the HDA driver that pin sense and/or ELD information has changed 748c2ecf20Sopenharmony_ci * 758c2ecf20Sopenharmony_ci * Called when the DRM driver has set up audio pipeline or has just 768c2ecf20Sopenharmony_ci * begun to tear it down. This allows the HDA driver to update its 778c2ecf20Sopenharmony_ci * status accordingly (even when the HDA controller is in power save 788c2ecf20Sopenharmony_ci * mode). 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_ci void (*pin_eld_notify)(void *audio_ptr, int port, int pipe); 818c2ecf20Sopenharmony_ci /** 828c2ecf20Sopenharmony_ci * @pin2port: Check and convert from pin node to port number 838c2ecf20Sopenharmony_ci * 848c2ecf20Sopenharmony_ci * Called by HDA driver to check and convert from the pin widget node 858c2ecf20Sopenharmony_ci * number to a port number in the graphics side. 868c2ecf20Sopenharmony_ci */ 878c2ecf20Sopenharmony_ci int (*pin2port)(void *audio_ptr, int pin); 888c2ecf20Sopenharmony_ci /** 898c2ecf20Sopenharmony_ci * @master_bind: (Optional) component master bind callback 908c2ecf20Sopenharmony_ci * 918c2ecf20Sopenharmony_ci * Called at binding master component, for HDA codec-specific 928c2ecf20Sopenharmony_ci * handling of dynamic binding. 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_ci int (*master_bind)(struct device *dev, struct drm_audio_component *); 958c2ecf20Sopenharmony_ci /** 968c2ecf20Sopenharmony_ci * @master_unbind: (Optional) component master unbind callback 978c2ecf20Sopenharmony_ci * 988c2ecf20Sopenharmony_ci * Called at unbinding master component, for HDA codec-specific 998c2ecf20Sopenharmony_ci * handling of dynamic unbinding. 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_ci void (*master_unbind)(struct device *dev, struct drm_audio_component *); 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/** 1058c2ecf20Sopenharmony_ci * struct drm_audio_component - Used for direct communication between DRM and hda drivers 1068c2ecf20Sopenharmony_ci */ 1078c2ecf20Sopenharmony_cistruct drm_audio_component { 1088c2ecf20Sopenharmony_ci /** 1098c2ecf20Sopenharmony_ci * @dev: DRM device, used as parameter for ops 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_ci struct device *dev; 1128c2ecf20Sopenharmony_ci /** 1138c2ecf20Sopenharmony_ci * @ops: Ops implemented by DRM driver, called by hda driver 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_ci const struct drm_audio_component_ops *ops; 1168c2ecf20Sopenharmony_ci /** 1178c2ecf20Sopenharmony_ci * @audio_ops: Ops implemented by hda driver, called by DRM driver 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_ci const struct drm_audio_component_audio_ops *audio_ops; 1208c2ecf20Sopenharmony_ci /** 1218c2ecf20Sopenharmony_ci * @master_bind_complete: completion held during component master binding 1228c2ecf20Sopenharmony_ci */ 1238c2ecf20Sopenharmony_ci struct completion master_bind_complete; 1248c2ecf20Sopenharmony_ci}; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci#endif /* _DRM_AUDIO_COMPONENT_H_ */ 127