^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/sound/soc-dai.h -- ALSA SoC Layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright: 2005-2008 Wolfson Microelectronics. PLC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Digital Audio Interface (DAI) API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef __LINUX_SND_SOC_DAI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define __LINUX_SND_SOC_DAI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <sound/asoc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct snd_pcm_substream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct snd_soc_dapm_widget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct snd_compr_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * DAI hardware audio formats.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * Describes the physical PCM data formating and clocking. Add new formats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * to the end.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define SND_SOC_DAIFMT_I2S SND_SOC_DAI_FORMAT_I2S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define SND_SOC_DAIFMT_RIGHT_J SND_SOC_DAI_FORMAT_RIGHT_J
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define SND_SOC_DAIFMT_LEFT_J SND_SOC_DAI_FORMAT_LEFT_J
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define SND_SOC_DAIFMT_DSP_A SND_SOC_DAI_FORMAT_DSP_A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define SND_SOC_DAIFMT_DSP_B SND_SOC_DAI_FORMAT_DSP_B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define SND_SOC_DAIFMT_AC97 SND_SOC_DAI_FORMAT_AC97
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define SND_SOC_DAIFMT_PDM SND_SOC_DAI_FORMAT_PDM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* left and right justified also known as MSB and LSB respectively */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * DAI Clock gating.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * DAI bit clocks can be gated (disabled) when the DAI is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * sending or receiving PCM data in a frame. This can be used to save power.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define SND_SOC_DAIFMT_CONT (1 << 4) /* continuous clock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define SND_SOC_DAIFMT_GATED (0 << 4) /* clock is gated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * DAI hardware signal polarity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Specifies whether the DAI can also support inverted clocks for the specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * BCLK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * - "normal" polarity means signal is available at rising edge of BCLK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * - "inverted" polarity means signal is available at falling edge of BCLK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * FSYNC "normal" polarity depends on the frame format:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * - I2S: frame consists of left then right channel data. Left channel starts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * with falling FSYNC edge, right channel starts with rising FSYNC edge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * - Left/Right Justified: frame consists of left then right channel data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * Left channel starts with rising FSYNC edge, right channel starts with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * falling FSYNC edge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * - DSP A/B: Frame starts with rising FSYNC edge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * - AC97: Frame starts with rising FSYNC edge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * "Negative" FSYNC polarity is the one opposite of "normal" polarity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bit clock + frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define SND_SOC_DAIFMT_NB_IF (2 << 8) /* normal BCLK + inv FRM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define SND_SOC_DAIFMT_IB_NF (3 << 8) /* invert BCLK + nor FRM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define SND_SOC_DAIFMT_IB_IF (4 << 8) /* invert BCLK + FRM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * DAI hardware clock masters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * This is wrt the codec, the inverse is true for the interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * i.e. if the codec is clk and FRM master then the interface is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * clk and frame secondary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define SND_SOC_DAIFMT_CBM_CFM (1 << 12) /* codec clk & FRM master */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define SND_SOC_DAIFMT_CBS_CFM (2 << 12) /* codec clk secondary & FRM master */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define SND_SOC_DAIFMT_CBM_CFS (3 << 12) /* codec clk master & frame secondary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define SND_SOC_DAIFMT_CBS_CFS (4 << 12) /* codec clk & FRM secondary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define SND_SOC_DAIFMT_INV_MASK 0x0f00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define SND_SOC_DAIFMT_MASTER_MASK 0xf000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * Master Clock Directions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define SND_SOC_CLOCK_IN 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define SND_SOC_CLOCK_OUT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define SND_SOC_STD_AC97_FMTS (SNDRV_PCM_FMTBIT_S8 |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) SNDRV_PCM_FMTBIT_S16_LE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) SNDRV_PCM_FMTBIT_S16_BE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) SNDRV_PCM_FMTBIT_S20_3LE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) SNDRV_PCM_FMTBIT_S20_3BE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) SNDRV_PCM_FMTBIT_S20_LE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) SNDRV_PCM_FMTBIT_S20_BE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) SNDRV_PCM_FMTBIT_S24_3LE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) SNDRV_PCM_FMTBIT_S24_3BE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) SNDRV_PCM_FMTBIT_S32_LE |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) SNDRV_PCM_FMTBIT_S32_BE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct snd_soc_dai_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct snd_soc_dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct snd_ac97_bus_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* Digital Audio Interface clocking API.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) unsigned int freq, int dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int div_id, int div);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int pll_id, int source, unsigned int freq_in, unsigned int freq_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* Digital Audio interface formatting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) unsigned int tx_num, unsigned int *tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) unsigned int rx_num, unsigned int *rx_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* Digital Audio Interface mute */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) unsigned int *tx_num, unsigned int *tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) unsigned int *rx_num, unsigned int *rx_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int snd_soc_dai_is_dummy(struct snd_soc_dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct snd_pcm_hw_params *params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct snd_pcm_substream *substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) int snd_soc_dai_startup(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct snd_pcm_substream *substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct snd_pcm_substream *substream, int rollback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct snd_pcm_substream *substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) void snd_soc_dai_suspend(struct snd_soc_dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) void snd_soc_dai_resume(struct snd_soc_dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct snd_soc_pcm_runtime *rtd, int num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void snd_soc_dai_action(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int stream, int action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static inline void snd_soc_dai_activate(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) snd_soc_dai_action(dai, stream, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static inline void snd_soc_dai_deactivate(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) int stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) snd_soc_dai_action(dai, stream, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int snd_soc_dai_active(struct snd_soc_dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct snd_compr_stream *cstream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct snd_compr_stream *cstream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct snd_compr_stream *cstream, int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct snd_compr_params *params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct snd_codec *params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) size_t bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct snd_compr_tstamp *tstamp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct snd_compr_metadata *metadata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct snd_compr_metadata *metadata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct snd_soc_dai_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * DAI clocking configuration, all optional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * Called by soc_card drivers, normally in their hw_params.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int (*set_sysclk)(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int clk_id, unsigned int freq, int dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int (*set_pll)(struct snd_soc_dai *dai, int pll_id, int source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) unsigned int freq_in, unsigned int freq_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) int (*set_bclk_ratio)(struct snd_soc_dai *dai, unsigned int ratio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * DAI format configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Called by soc_card drivers, normally in their hw_params.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) int (*xlate_tdm_slot_mask)(unsigned int slots,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) unsigned int *tx_mask, unsigned int *rx_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) int (*set_tdm_slot)(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) unsigned int tx_mask, unsigned int rx_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) int slots, int slot_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) int (*set_channel_map)(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) unsigned int tx_num, unsigned int *tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) unsigned int rx_num, unsigned int *rx_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) int (*get_channel_map)(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) unsigned int *tx_num, unsigned int *tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) unsigned int *rx_num, unsigned int *rx_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) int (*set_sdw_stream)(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) void *stream, int direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) void *(*get_sdw_stream)(struct snd_soc_dai *dai, int direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * DAI digital mute - optional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * Called by soc-core to minimise any pops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) int (*mute_stream)(struct snd_soc_dai *dai, int mute, int stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * ALSA PCM audio operations - all optional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * Called by soc-core during audio PCM operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) int (*startup)(struct snd_pcm_substream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) void (*shutdown)(struct snd_pcm_substream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) int (*hw_params)(struct snd_pcm_substream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct snd_pcm_hw_params *, struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int (*hw_free)(struct snd_pcm_substream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int (*prepare)(struct snd_pcm_substream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * NOTE: Commands passed to the trigger function are not necessarily
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * compatible with the current state of the dai. For example this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * sequence of commands is possible: START STOP STOP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * So do not unconditionally use refcounting functions in the trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * function, e.g. clk_enable/disable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int (*trigger)(struct snd_pcm_substream *, int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int (*bespoke_trigger)(struct snd_pcm_substream *, int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * For hardware based FIFO caused delay reporting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * Optional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) /* bit field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) unsigned int no_capture_mute:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct snd_soc_cdai_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * for compress ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) int (*startup)(struct snd_compr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) int (*shutdown)(struct snd_compr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) int (*set_params)(struct snd_compr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct snd_compr_params *, struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) int (*get_params)(struct snd_compr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct snd_codec *, struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) int (*set_metadata)(struct snd_compr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) struct snd_compr_metadata *, struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) int (*get_metadata)(struct snd_compr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) struct snd_compr_metadata *, struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) int (*trigger)(struct snd_compr_stream *, int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) int (*pointer)(struct snd_compr_stream *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) struct snd_compr_tstamp *, struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) int (*ack)(struct snd_compr_stream *, size_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) struct snd_soc_dai *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * Digital Audio Interface Driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * Describes the Digital Audio Interface in terms of its ALSA, DAI and AC97
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * operations and capabilities. Codec and platform drivers will register this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * structure for every DAI they have.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * This structure covers the clocking, formating and ALSA operations for each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct snd_soc_dai_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /* DAI description */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) unsigned int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) unsigned int base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct snd_soc_dobj dobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /* DAI driver callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) int (*probe)(struct snd_soc_dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) int (*remove)(struct snd_soc_dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /* compress dai */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) /* Optional Callback used at pcm creation*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) int (*pcm_new)(struct snd_soc_pcm_runtime *rtd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct snd_soc_dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) /* ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) const struct snd_soc_dai_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) const struct snd_soc_cdai_ops *cops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /* DAI capabilities */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) struct snd_soc_pcm_stream capture;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct snd_soc_pcm_stream playback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) unsigned int symmetric_rates:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) unsigned int symmetric_channels:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) unsigned int symmetric_samplebits:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) /* probe ordering - for components with runtime dependencies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) int probe_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) int remove_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * Digital Audio Interface runtime data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * Holds runtime data for a DAI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct snd_soc_dai {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) /* driver ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct snd_soc_dai_driver *driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) /* DAI runtime info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) unsigned int stream_active[SNDRV_PCM_STREAM_LAST + 1]; /* usage count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct snd_soc_dapm_widget *playback_widget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct snd_soc_dapm_widget *capture_widget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) /* DAI DMA data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) void *playback_dma_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) void *capture_dma_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /* Symmetry data - only valid if symmetry is being enforced */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) unsigned int rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) unsigned int channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) unsigned int sample_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) /* parent platform/codec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) struct snd_soc_component *component;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) /* CODEC TDM slot masks and params (for fixup) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) unsigned int tx_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) unsigned int rx_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /* function mark */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) struct snd_pcm_substream *mark_startup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) /* bit field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) unsigned int probed:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static inline struct snd_soc_pcm_stream *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) &dai->driver->playback : &dai->driver->capture;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) struct snd_soc_dapm_widget *snd_soc_dai_get_widget(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) struct snd_soc_dai *dai, int stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) dai->playback_widget : dai->capture_widget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) const struct snd_pcm_substream *ss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) return (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) dai->playback_dma_data : dai->capture_dma_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) const struct snd_pcm_substream *ss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) dai->playback_dma_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) dai->capture_dma_data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) void *playback, void *capture)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) dai->playback_dma_data = playback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) dai->capture_dma_data = capture;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) dev_set_drvdata(dai->dev, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static inline void *snd_soc_dai_get_drvdata(struct snd_soc_dai *dai)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) return dev_get_drvdata(dai->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * @stream: STREAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) * @direction: Stream direction(Playback/Capture)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * SoundWire subsystem doesn't have a notion of direction and we reuse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) * the ASoC stream direction to configure sink/source ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * Playback maps to source ports and Capture for sink ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * This should be invoked with NULL to clear the stream set previously.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * Returns 0 on success, a negative error code otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) static inline int snd_soc_dai_set_sdw_stream(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) void *stream, int direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (dai->driver->ops->set_sdw_stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) return dai->driver->ops->set_sdw_stream(dai, stream, direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * snd_soc_dai_get_sdw_stream() - Retrieves SDW stream from DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * @direction: Stream direction(Playback/Capture)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * This routine only retrieves that was previously configured
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) * with snd_soc_dai_get_sdw_stream()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * Returns pointer to stream or an ERR_PTR value, e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * ERR_PTR(-ENOTSUPP) if callback is not supported;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) static inline void *snd_soc_dai_get_sdw_stream(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) int direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (dai->driver->ops->get_sdw_stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) return dai->driver->ops->get_sdw_stream(dai, direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return ERR_PTR(-ENOTSUPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static inline unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) snd_soc_dai_stream_active(struct snd_soc_dai *dai, int stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) return dai->stream_active[stream];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) #endif