Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: MIT
0002 // Copyright © 2014 Intel Corporation
0003 
0004 #ifndef _DRM_AUDIO_COMPONENT_H_
0005 #define _DRM_AUDIO_COMPONENT_H_
0006 
0007 struct drm_audio_component;
0008 struct device;
0009 
0010 /**
0011  * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver
0012  */
0013 struct drm_audio_component_ops {
0014     /**
0015      * @owner: drm module to pin down
0016      */
0017     struct module *owner;
0018     /**
0019      * @get_power: get the POWER_DOMAIN_AUDIO power well
0020      *
0021      * Request the power well to be turned on.
0022      *
0023      * Returns a wakeref cookie to be passed back to the corresponding
0024      * call to @put_power.
0025      */
0026     unsigned long (*get_power)(struct device *);
0027     /**
0028      * @put_power: put the POWER_DOMAIN_AUDIO power well
0029      *
0030      * Allow the power well to be turned off.
0031      */
0032     void (*put_power)(struct device *, unsigned long);
0033     /**
0034      * @codec_wake_override: Enable/disable codec wake signal
0035      */
0036     void (*codec_wake_override)(struct device *, bool enable);
0037     /**
0038      * @get_cdclk_freq: Get the Core Display Clock in kHz
0039      */
0040     int (*get_cdclk_freq)(struct device *);
0041     /**
0042      * @sync_audio_rate: set n/cts based on the sample rate
0043      *
0044      * Called from audio driver. After audio driver sets the
0045      * sample rate, it will call this function to set n/cts
0046      */
0047     int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
0048     /**
0049      * @get_eld: fill the audio state and ELD bytes for the given port
0050      *
0051      * Called from audio driver to get the HDMI/DP audio state of the given
0052      * digital port, and also fetch ELD bytes to the given pointer.
0053      *
0054      * It returns the byte size of the original ELD (not the actually
0055      * copied size), zero for an invalid ELD, or a negative error code.
0056      *
0057      * Note that the returned size may be over @max_bytes.  Then it
0058      * implies that only a part of ELD has been copied to the buffer.
0059      */
0060     int (*get_eld)(struct device *, int port, int pipe, bool *enabled,
0061                unsigned char *buf, int max_bytes);
0062 };
0063 
0064 /**
0065  * struct drm_audio_component_audio_ops - Ops implemented by hda driver, called by DRM driver
0066  */
0067 struct drm_audio_component_audio_ops {
0068     /**
0069      * @audio_ptr: Pointer to be used in call to pin_eld_notify
0070      */
0071     void *audio_ptr;
0072     /**
0073      * @pin_eld_notify: Notify the HDA driver that pin sense and/or ELD information has changed
0074      *
0075      * Called when the DRM driver has set up audio pipeline or has just
0076      * begun to tear it down. This allows the HDA driver to update its
0077      * status accordingly (even when the HDA controller is in power save
0078      * mode).
0079      */
0080     void (*pin_eld_notify)(void *audio_ptr, int port, int pipe);
0081     /**
0082      * @pin2port: Check and convert from pin node to port number
0083      *
0084      * Called by HDA driver to check and convert from the pin widget node
0085      * number to a port number in the graphics side.
0086      */
0087     int (*pin2port)(void *audio_ptr, int pin);
0088     /**
0089      * @master_bind: (Optional) component master bind callback
0090      *
0091      * Called at binding master component, for HDA codec-specific
0092      * handling of dynamic binding.
0093      */
0094     int (*master_bind)(struct device *dev, struct drm_audio_component *);
0095     /**
0096      * @master_unbind: (Optional) component master unbind callback
0097      *
0098      * Called at unbinding master component, for HDA codec-specific
0099      * handling of dynamic unbinding.
0100      */
0101     void (*master_unbind)(struct device *dev, struct drm_audio_component *);
0102 };
0103 
0104 /**
0105  * struct drm_audio_component - Used for direct communication between DRM and hda drivers
0106  */
0107 struct drm_audio_component {
0108     /**
0109      * @dev: DRM device, used as parameter for ops
0110      */
0111     struct device *dev;
0112     /**
0113      * @ops: Ops implemented by DRM driver, called by hda driver
0114      */
0115     const struct drm_audio_component_ops *ops;
0116     /**
0117      * @audio_ops: Ops implemented by hda driver, called by DRM driver
0118      */
0119     const struct drm_audio_component_audio_ops *audio_ops;
0120     /**
0121      * @master_bind_complete: completion held during component master binding
0122      */
0123     struct completion master_bind_complete;
0124 };
0125 
0126 #endif /* _DRM_AUDIO_COMPONENT_H_ */