Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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) // soc-dai.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) // Copyright (C) 2019 Renesas Electronics Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <sound/soc-dai.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <sound/soc-link.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) static inline int _soc_dai_ret(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 			       const char *func, int ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	/* Positive, Zero values are not errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	if (ret >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	/* Negative values might be errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	case -EPROBE_DEFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	case -ENOTSUPP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		dev_err(dai->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 			"ASoC: error at %s on %s: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			func, dai->name, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * We might want to check substream by using list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * In such case, we can update these macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define soc_dai_mark_push(dai, substream, tgt)	((dai)->mark_##tgt = substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define soc_dai_mark_pop(dai, substream, tgt)	((dai)->mark_##tgt = NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define soc_dai_mark_match(dai, substream, tgt)	((dai)->mark_##tgt == substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * snd_soc_dai_set_sysclk - configure DAI system or master clock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * @clk_id: DAI specific clock ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * @freq: new clock frequency in Hz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * @dir: new clock direction - input/output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * Configures the DAI master (MCLK) or system (SYSCLK) clocking.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			   unsigned int freq, int dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	    dai->driver->ops->set_sysclk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		ret = dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		ret = snd_soc_component_set_sysclk(dai->component, clk_id, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 						   freq, dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * @div_id: DAI specific clock divider ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @div: new clock divisor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * Configures the clock dividers. This is used to derive the best DAI bit and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * frame clocks from the system or master clock. It's best to set the DAI bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * and frame clocks as low as possible to save system power.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			   int div_id, int div)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	    dai->driver->ops->set_clkdiv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		ret = dai->driver->ops->set_clkdiv(dai, div_id, div);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
^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)  * snd_soc_dai_set_pll - configure DAI PLL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  * @pll_id: DAI specific PLL ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * @source: DAI specific source for the PLL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  * @freq_in: PLL input clock frequency in Hz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * @freq_out: requested PLL output clock frequency in Hz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * Configures and enables PLL to generate output clock based on input clock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			unsigned int freq_in, unsigned int freq_out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	    dai->driver->ops->set_pll)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		ret = dai->driver->ops->set_pll(dai, pll_id, source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 						freq_in, freq_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		ret = snd_soc_component_set_pll(dai->component, pll_id, source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 						freq_in, freq_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * @ratio: Ratio of BCLK to Sample rate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * Configures the DAI for a preset BCLK to sample rate ratio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	    dai->driver->ops->set_bclk_ratio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		ret = dai->driver->ops->set_bclk_ratio(dai, ratio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * snd_soc_dai_set_fmt - configure DAI hardware audio format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * @fmt: SND_SOC_DAIFMT_* format value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * Configures the DAI hardware format and clocking.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	int ret = -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	    dai->driver->ops->set_fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		ret = dai->driver->ops->set_fmt(dai, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * snd_soc_xlate_tdm_slot - generate tx/rx slot mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * @slots: Number of slots in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * @tx_mask: bitmask representing active TX slots.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * @rx_mask: bitmask representing active RX slots.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * Generates the TDM tx and rx slot default masks for DAI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int snd_soc_xlate_tdm_slot_mask(unsigned int slots,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				       unsigned int *tx_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 				       unsigned int *rx_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	if (*tx_mask || *rx_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	if (!slots)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	*tx_mask = (1 << slots) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	*rx_mask = (1 << slots) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * snd_soc_dai_set_tdm_slot() - Configures a DAI for TDM operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * @dai: The DAI to configure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * @tx_mask: bitmask representing active TX slots.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  * @rx_mask: bitmask representing active RX slots.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  * @slots: Number of slots in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * @slot_width: Width in bits for each slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * This function configures the specified DAI for TDM operation. @slot contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  * the total number of slots of the TDM stream and @slot_with the width of each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * slot in bit clock cycles. @tx_mask and @rx_mask are bitmasks specifying the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * active slots of the TDM stream for the specified DAI, i.e. which slots the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * DAI should write to or read from. If a bit is set the corresponding slot is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * active, if a bit is cleared the corresponding slot is inactive. Bit 0 maps to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  * the first slot, bit 1 to the second slot and so on. The first active slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * maps to the first channel of the DAI, the second active slot to the second
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  * channel and so on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * TDM mode can be disabled by passing 0 for @slots. In this case @tx_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  * @rx_mask and @slot_width will be ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  * Returns 0 on success, a negative error code otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			     unsigned int tx_mask, unsigned int rx_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			     int slots, int slot_width)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	int ret = -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	    dai->driver->ops->xlate_tdm_slot_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		dai->driver->ops->xlate_tdm_slot_mask(slots,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 						      &tx_mask, &rx_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	dai->tx_mask = tx_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	dai->rx_mask = rx_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	    dai->driver->ops->set_tdm_slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		ret = dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 						      slots, slot_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  * snd_soc_dai_set_channel_map - configure DAI audio channel map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  * @tx_num: how many TX channels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * @tx_slot: pointer to an array which imply the TX slot number channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  *           0~num-1 uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  * @rx_num: how many RX channels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * @rx_slot: pointer to an array which imply the RX slot number channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  *           0~num-1 uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * configure the relationship between channel number and TDM slot number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 				unsigned int tx_num, unsigned int *tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 				unsigned int rx_num, unsigned int *rx_slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	int ret = -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	    dai->driver->ops->set_channel_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		ret = dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 							rx_num, rx_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  * snd_soc_dai_get_channel_map - Get DAI audio channel map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  * @tx_num: how many TX channels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  * @tx_slot: pointer to an array which imply the TX slot number channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)  *           0~num-1 uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)  * @rx_num: how many RX channels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)  * @rx_slot: pointer to an array which imply the RX slot number channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  *           0~num-1 uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 				unsigned int *tx_num, unsigned int *tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 				unsigned int *rx_num, unsigned int *rx_slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	int ret = -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	    dai->driver->ops->get_channel_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		ret = dai->driver->ops->get_channel_map(dai, tx_num, tx_slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 							rx_num, rx_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) EXPORT_SYMBOL_GPL(snd_soc_dai_get_channel_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * snd_soc_dai_set_tristate - configure DAI system or master clock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  * @tristate: tristate enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  * Tristates the DAI so that others can use it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	    dai->driver->ops->set_tristate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		ret = dai->driver->ops->set_tristate(dai, tristate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)  * snd_soc_dai_digital_mute - configure DAI system or master clock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)  * @dai: DAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)  * @mute: mute enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)  * @direction: stream to mute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  * Mutes the DAI DAC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			     int direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	int ret = -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	 * ignore if direction was CAPTURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	 * and it had .no_capture_mute flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	    dai->driver->ops->mute_stream &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	    (direction == SNDRV_PCM_STREAM_PLAYBACK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	     !dai->driver->ops->no_capture_mute))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		ret = dai->driver->ops->mute_stream(dai, mute, direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 			  struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 			  struct snd_pcm_hw_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	/* perform any topology hw_params fixups before DAI  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	ret = snd_soc_link_be_hw_params_fixup(rtd, params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	    dai->driver->ops->hw_params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		ret = dai->driver->ops->hw_params(substream, params, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 			 struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	    dai->driver->ops->hw_free)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		dai->driver->ops->hw_free(substream, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) int snd_soc_dai_startup(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 			struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	    dai->driver->ops->startup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		ret = dai->driver->ops->startup(substream, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	/* mark substream if succeeded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	if (ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		soc_dai_mark_push(dai, substream, startup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			  struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 			  int rollback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	if (rollback && !soc_dai_mark_match(dai, substream, startup))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	    dai->driver->ops->shutdown)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		dai->driver->ops->shutdown(substream, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	/* remove marked substream */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	soc_dai_mark_pop(dai, substream, startup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 				    struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	int delay = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	    dai->driver->ops->delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		delay = dai->driver->ops->delay(substream, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	return delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			     struct snd_soc_pcm_runtime *rtd, int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	int ret = -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	if (dai->driver->compress_new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		ret = dai->driver->compress_new(rtd, num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  * snd_soc_dai_stream_valid() - check if a DAI supports the given stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  * Returns true if the DAI supports the indicated stream type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	struct snd_soc_pcm_stream *stream = snd_soc_dai_get_pcm_stream(dai, dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	/* If the codec specifies any channels at all, it supports the stream */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	return stream->channels_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)  * snd_soc_dai_link_set_capabilities() - set dai_link properties based on its DAIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	struct snd_soc_dai_link_component *cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	struct snd_soc_dai_link_component *codec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	struct snd_soc_dai *dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	bool supported[SNDRV_PCM_STREAM_LAST + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	bool supported_cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	bool supported_codec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	int direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	for_each_pcm_streams(direction) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		supported_cpu = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		supported_codec = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		for_each_link_cpus(dai_link, i, cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 			dai = snd_soc_find_dai_with_mutex(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 			if (dai && snd_soc_dai_stream_valid(dai, direction)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 				supported_cpu = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		for_each_link_codecs(dai_link, i, codec) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 			dai = snd_soc_find_dai_with_mutex(codec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 			if (dai && snd_soc_dai_stream_valid(dai, direction)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 				supported_codec = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		supported[direction] = supported_cpu && supported_codec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	dai_link->dpcm_capture  = supported[SNDRV_PCM_STREAM_CAPTURE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) EXPORT_SYMBOL_GPL(snd_soc_dai_link_set_capabilities);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) void snd_soc_dai_action(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 			int stream, int action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	/* see snd_soc_dai_stream_active() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	dai->stream_active[stream]	+= action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	/* see snd_soc_component_active() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	dai->component->active		+= action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) EXPORT_SYMBOL_GPL(snd_soc_dai_action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) int snd_soc_dai_active(struct snd_soc_dai *dai)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	int stream, active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	active = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	for_each_pcm_streams(stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		active += dai->stream_active[stream];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	return active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) EXPORT_SYMBOL_GPL(snd_soc_dai_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	struct snd_soc_dai *dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	for_each_rtd_dais(rtd, i, dai) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		if (dai->driver->probe_order != order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 		if (dai->driver->probe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 			int ret = dai->driver->probe(dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 				return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		dai->probed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	struct snd_soc_dai *dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	int i, r, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	for_each_rtd_dais(rtd, i, dai) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		if (dai->driver->remove_order != order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		if (dai->probed &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		    dai->driver->remove) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 			r = dai->driver->remove(dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 			if (r < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 				ret = r; /* use last error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		dai->probed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	struct snd_soc_dai *dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	int i, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	for_each_rtd_dais(rtd, i, dai) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		if (dai->driver->pcm_new) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 			ret = dai->driver->pcm_new(rtd, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 				return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	struct snd_soc_dai *dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	for_each_rtd_dais(rtd, i, dai) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 		if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		    dai->driver->ops->prepare) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 			ret = dai->driver->ops->prepare(substream, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 				return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 			    int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	struct snd_soc_dai *dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	for_each_rtd_dais(rtd, i, dai) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 		if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 		    dai->driver->ops->trigger) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 			ret = dai->driver->ops->trigger(substream, cmd, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 				return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 				    int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	struct snd_soc_dai *dai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	for_each_rtd_dais(rtd, i, dai) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 		if (dai->driver->ops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 		    dai->driver->ops->bespoke_trigger) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 			ret = dai->driver->ops->bespoke_trigger(substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 								cmd, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 				return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 			      struct snd_compr_stream *cstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	    dai->driver->cops->startup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 		ret = dai->driver->cops->startup(cstream, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_startup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 				struct snd_compr_stream *cstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	    dai->driver->cops->shutdown)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 		dai->driver->cops->shutdown(cstream, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_shutdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 			      struct snd_compr_stream *cstream, int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	    dai->driver->cops->trigger)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		ret = dai->driver->cops->trigger(cstream, cmd, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_trigger);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 				 struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 				 struct snd_compr_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	    dai->driver->cops->set_params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 		ret = dai->driver->cops->set_params(cstream, params, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_set_params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 				 struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 				 struct snd_codec *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	    dai->driver->cops->get_params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 		ret = dai->driver->cops->get_params(cstream, params, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_get_params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 			  struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 			  size_t bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	    dai->driver->cops->ack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 		ret = dai->driver->cops->ack(cstream, bytes, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 			      struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 			      struct snd_compr_tstamp *tstamp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 	    dai->driver->cops->pointer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		ret = dai->driver->cops->pointer(cstream, tstamp, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 				   struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 				   struct snd_compr_metadata *metadata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 	    dai->driver->cops->set_metadata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 		ret = dai->driver->cops->set_metadata(cstream, metadata, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_set_metadata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 				   struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 				   struct snd_compr_metadata *metadata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 	if (dai->driver->cops &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 	    dai->driver->cops->get_metadata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 		ret = dai->driver->cops->get_metadata(cstream, metadata, dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 	return soc_dai_ret(dai, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) EXPORT_SYMBOL_GPL(snd_soc_dai_compr_get_metadata);