162306a36Sopenharmony_ci// SPDX-License-Identifier: MIT 262306a36Sopenharmony_ci// Copyright © 2014 Intel Corporation 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _DRM_AUDIO_COMPONENT_H_ 562306a36Sopenharmony_ci#define _DRM_AUDIO_COMPONENT_H_ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/completion.h> 862306a36Sopenharmony_ci#include <linux/types.h> 962306a36Sopenharmony_ci 1062306a36Sopenharmony_cistruct drm_audio_component; 1162306a36Sopenharmony_cistruct device; 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/** 1462306a36Sopenharmony_ci * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_cistruct drm_audio_component_ops { 1762306a36Sopenharmony_ci /** 1862306a36Sopenharmony_ci * @owner: drm module to pin down 1962306a36Sopenharmony_ci */ 2062306a36Sopenharmony_ci struct module *owner; 2162306a36Sopenharmony_ci /** 2262306a36Sopenharmony_ci * @get_power: get the POWER_DOMAIN_AUDIO power well 2362306a36Sopenharmony_ci * 2462306a36Sopenharmony_ci * Request the power well to be turned on. 2562306a36Sopenharmony_ci * 2662306a36Sopenharmony_ci * Returns a wakeref cookie to be passed back to the corresponding 2762306a36Sopenharmony_ci * call to @put_power. 2862306a36Sopenharmony_ci */ 2962306a36Sopenharmony_ci unsigned long (*get_power)(struct device *); 3062306a36Sopenharmony_ci /** 3162306a36Sopenharmony_ci * @put_power: put the POWER_DOMAIN_AUDIO power well 3262306a36Sopenharmony_ci * 3362306a36Sopenharmony_ci * Allow the power well to be turned off. 3462306a36Sopenharmony_ci */ 3562306a36Sopenharmony_ci void (*put_power)(struct device *, unsigned long); 3662306a36Sopenharmony_ci /** 3762306a36Sopenharmony_ci * @codec_wake_override: Enable/disable codec wake signal 3862306a36Sopenharmony_ci */ 3962306a36Sopenharmony_ci void (*codec_wake_override)(struct device *, bool enable); 4062306a36Sopenharmony_ci /** 4162306a36Sopenharmony_ci * @get_cdclk_freq: Get the Core Display Clock in kHz 4262306a36Sopenharmony_ci */ 4362306a36Sopenharmony_ci int (*get_cdclk_freq)(struct device *); 4462306a36Sopenharmony_ci /** 4562306a36Sopenharmony_ci * @sync_audio_rate: set n/cts based on the sample rate 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * Called from audio driver. After audio driver sets the 4862306a36Sopenharmony_ci * sample rate, it will call this function to set n/cts 4962306a36Sopenharmony_ci */ 5062306a36Sopenharmony_ci int (*sync_audio_rate)(struct device *, int port, int pipe, int rate); 5162306a36Sopenharmony_ci /** 5262306a36Sopenharmony_ci * @get_eld: fill the audio state and ELD bytes for the given port 5362306a36Sopenharmony_ci * 5462306a36Sopenharmony_ci * Called from audio driver to get the HDMI/DP audio state of the given 5562306a36Sopenharmony_ci * digital port, and also fetch ELD bytes to the given pointer. 5662306a36Sopenharmony_ci * 5762306a36Sopenharmony_ci * It returns the byte size of the original ELD (not the actually 5862306a36Sopenharmony_ci * copied size), zero for an invalid ELD, or a negative error code. 5962306a36Sopenharmony_ci * 6062306a36Sopenharmony_ci * Note that the returned size may be over @max_bytes. Then it 6162306a36Sopenharmony_ci * implies that only a part of ELD has been copied to the buffer. 6262306a36Sopenharmony_ci */ 6362306a36Sopenharmony_ci int (*get_eld)(struct device *, int port, int pipe, bool *enabled, 6462306a36Sopenharmony_ci unsigned char *buf, int max_bytes); 6562306a36Sopenharmony_ci}; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/** 6862306a36Sopenharmony_ci * struct drm_audio_component_audio_ops - Ops implemented by hda driver, called by DRM driver 6962306a36Sopenharmony_ci */ 7062306a36Sopenharmony_cistruct drm_audio_component_audio_ops { 7162306a36Sopenharmony_ci /** 7262306a36Sopenharmony_ci * @audio_ptr: Pointer to be used in call to pin_eld_notify 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci void *audio_ptr; 7562306a36Sopenharmony_ci /** 7662306a36Sopenharmony_ci * @pin_eld_notify: Notify the HDA driver that pin sense and/or ELD information has changed 7762306a36Sopenharmony_ci * 7862306a36Sopenharmony_ci * Called when the DRM driver has set up audio pipeline or has just 7962306a36Sopenharmony_ci * begun to tear it down. This allows the HDA driver to update its 8062306a36Sopenharmony_ci * status accordingly (even when the HDA controller is in power save 8162306a36Sopenharmony_ci * mode). 8262306a36Sopenharmony_ci */ 8362306a36Sopenharmony_ci void (*pin_eld_notify)(void *audio_ptr, int port, int pipe); 8462306a36Sopenharmony_ci /** 8562306a36Sopenharmony_ci * @pin2port: Check and convert from pin node to port number 8662306a36Sopenharmony_ci * 8762306a36Sopenharmony_ci * Called by HDA driver to check and convert from the pin widget node 8862306a36Sopenharmony_ci * number to a port number in the graphics side. 8962306a36Sopenharmony_ci */ 9062306a36Sopenharmony_ci int (*pin2port)(void *audio_ptr, int pin); 9162306a36Sopenharmony_ci /** 9262306a36Sopenharmony_ci * @master_bind: (Optional) component master bind callback 9362306a36Sopenharmony_ci * 9462306a36Sopenharmony_ci * Called at binding master component, for HDA codec-specific 9562306a36Sopenharmony_ci * handling of dynamic binding. 9662306a36Sopenharmony_ci */ 9762306a36Sopenharmony_ci int (*master_bind)(struct device *dev, struct drm_audio_component *); 9862306a36Sopenharmony_ci /** 9962306a36Sopenharmony_ci * @master_unbind: (Optional) component master unbind callback 10062306a36Sopenharmony_ci * 10162306a36Sopenharmony_ci * Called at unbinding master component, for HDA codec-specific 10262306a36Sopenharmony_ci * handling of dynamic unbinding. 10362306a36Sopenharmony_ci */ 10462306a36Sopenharmony_ci void (*master_unbind)(struct device *dev, struct drm_audio_component *); 10562306a36Sopenharmony_ci}; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci/** 10862306a36Sopenharmony_ci * struct drm_audio_component - Used for direct communication between DRM and hda drivers 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_cistruct drm_audio_component { 11162306a36Sopenharmony_ci /** 11262306a36Sopenharmony_ci * @dev: DRM device, used as parameter for ops 11362306a36Sopenharmony_ci */ 11462306a36Sopenharmony_ci struct device *dev; 11562306a36Sopenharmony_ci /** 11662306a36Sopenharmony_ci * @ops: Ops implemented by DRM driver, called by hda driver 11762306a36Sopenharmony_ci */ 11862306a36Sopenharmony_ci const struct drm_audio_component_ops *ops; 11962306a36Sopenharmony_ci /** 12062306a36Sopenharmony_ci * @audio_ops: Ops implemented by hda driver, called by DRM driver 12162306a36Sopenharmony_ci */ 12262306a36Sopenharmony_ci const struct drm_audio_component_audio_ops *audio_ops; 12362306a36Sopenharmony_ci /** 12462306a36Sopenharmony_ci * @master_bind_complete: completion held during component master binding 12562306a36Sopenharmony_ci */ 12662306a36Sopenharmony_ci struct completion master_bind_complete; 12762306a36Sopenharmony_ci}; 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci#endif /* _DRM_AUDIO_COMPONENT_H_ */ 130