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