Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * hdmi-codec.h - HDMI Codec driver API
0004  *
0005  * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com
0006  *
0007  * Author: Jyri Sarha <jsarha@ti.com>
0008  */
0009 
0010 #ifndef __HDMI_CODEC_H__
0011 #define __HDMI_CODEC_H__
0012 
0013 #include <linux/of_graph.h>
0014 #include <linux/hdmi.h>
0015 #include <drm/drm_edid.h>
0016 #include <sound/asoundef.h>
0017 #include <sound/soc.h>
0018 #include <uapi/sound/asound.h>
0019 
0020 /*
0021  * Protocol between ASoC cpu-dai and HDMI-encoder
0022  */
0023 struct hdmi_codec_daifmt {
0024     enum {
0025         HDMI_I2S,
0026         HDMI_RIGHT_J,
0027         HDMI_LEFT_J,
0028         HDMI_DSP_A,
0029         HDMI_DSP_B,
0030         HDMI_AC97,
0031         HDMI_SPDIF,
0032     } fmt;
0033     unsigned int bit_clk_inv:1;
0034     unsigned int frame_clk_inv:1;
0035     unsigned int bit_clk_provider:1;
0036     unsigned int frame_clk_provider:1;
0037     /* bit_fmt could be standard PCM format or
0038      * IEC958 encoded format. ALSA IEC958 plugin will pass
0039      * IEC958_SUBFRAME format to the underneath driver.
0040      */
0041     snd_pcm_format_t bit_fmt;
0042 };
0043 
0044 /*
0045  * HDMI audio parameters
0046  */
0047 struct hdmi_codec_params {
0048     struct hdmi_audio_infoframe cea;
0049     struct snd_aes_iec958 iec;
0050     int sample_rate;
0051     int sample_width;
0052     int channels;
0053 };
0054 
0055 typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
0056                       bool plugged);
0057 
0058 struct hdmi_codec_pdata;
0059 struct hdmi_codec_ops {
0060     /*
0061      * Called when ASoC starts an audio stream setup.
0062      * Optional
0063      */
0064     int (*audio_startup)(struct device *dev, void *data);
0065 
0066     /*
0067      * Configures HDMI-encoder for audio stream.
0068      * Having either prepare or hw_params is mandatory.
0069      */
0070     int (*hw_params)(struct device *dev, void *data,
0071              struct hdmi_codec_daifmt *fmt,
0072              struct hdmi_codec_params *hparms);
0073 
0074     /*
0075      * Configures HDMI-encoder for audio stream. Can be called
0076      * multiple times for each setup.
0077      *
0078      * Having either prepare or hw_params is mandatory.
0079      */
0080     int (*prepare)(struct device *dev, void *data,
0081                struct hdmi_codec_daifmt *fmt,
0082                struct hdmi_codec_params *hparms);
0083 
0084     /*
0085      * Shuts down the audio stream.
0086      * Mandatory
0087      */
0088     void (*audio_shutdown)(struct device *dev, void *data);
0089 
0090     /*
0091      * Mute/unmute HDMI audio stream.
0092      * Optional
0093      */
0094     int (*mute_stream)(struct device *dev, void *data,
0095                bool enable, int direction);
0096 
0097     /*
0098      * Provides EDID-Like-Data from connected HDMI device.
0099      * Optional
0100      */
0101     int (*get_eld)(struct device *dev, void *data,
0102                uint8_t *buf, size_t len);
0103 
0104     /*
0105      * Getting DAI ID
0106      * Optional
0107      */
0108     int (*get_dai_id)(struct snd_soc_component *comment,
0109               struct device_node *endpoint);
0110 
0111     /*
0112      * Hook callback function to handle connector plug event.
0113      * Optional
0114      */
0115     int (*hook_plugged_cb)(struct device *dev, void *data,
0116                    hdmi_codec_plugged_cb fn,
0117                    struct device *codec_dev);
0118 
0119     /* bit field */
0120     unsigned int no_capture_mute:1;
0121 };
0122 
0123 /* HDMI codec initalization data */
0124 struct hdmi_codec_pdata {
0125     const struct hdmi_codec_ops *ops;
0126     uint i2s:1;
0127     uint spdif:1;
0128     int max_i2s_channels;
0129     void *data;
0130 };
0131 
0132 struct snd_soc_component;
0133 struct snd_soc_jack;
0134 
0135 #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"
0136 
0137 #endif /* __HDMI_CODEC_H__ */