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