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