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) // Socionext UniPhier AIO Compress Audio driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) // Copyright (c) 2017-2018 Socionext Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/bitfield.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/circ_buf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "aio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static int uniphier_aio_compr_prepare(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 				      struct snd_compr_stream *cstream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static int uniphier_aio_compr_hw_free(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 				      struct snd_compr_stream *cstream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static int uniphier_aio_comprdma_new(struct snd_soc_pcm_runtime *rtd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct snd_compr *compr = rtd->compr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct device *dev = compr->card->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct uniphier_aio_sub *sub = &aio->sub[compr->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	size_t size = AUD_RING_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	int dma_dir = DMA_FROM_DEVICE, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(33));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	sub->compr_area = kzalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (!sub->compr_area)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	if (sub->swm->dir == PORT_DIR_OUTPUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		dma_dir = DMA_TO_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	sub->compr_addr = dma_map_single(dev, sub->compr_area, size, dma_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (dma_mapping_error(dev, sub->compr_addr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		kfree(sub->compr_area);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		sub->compr_area = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	sub->compr_bytes = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static int uniphier_aio_comprdma_free(struct snd_soc_pcm_runtime *rtd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct snd_compr *compr = rtd->compr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct device *dev = compr->card->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct uniphier_aio_sub *sub = &aio->sub[compr->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	int dma_dir = DMA_FROM_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (sub->swm->dir == PORT_DIR_OUTPUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		dma_dir = DMA_TO_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	dma_unmap_single(dev, sub->compr_addr, sub->compr_bytes, dma_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	kfree(sub->compr_area);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	sub->compr_area = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	return 0;
^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) static int uniphier_aio_compr_open(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 				   struct snd_compr_stream *cstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (sub->cstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	sub->cstream = cstream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	sub->pass_through = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	sub->use_mmap = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	ret = uniphier_aio_comprdma_new(rtd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	ret = aio_init(sub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static int uniphier_aio_compr_free(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 				   struct snd_compr_stream *cstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	ret = uniphier_aio_compr_hw_free(component, cstream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	ret = uniphier_aio_comprdma_free(rtd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	sub->cstream = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int uniphier_aio_compr_get_params(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 					 struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 					 struct snd_codec *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	*params = sub->cparams.codec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static int uniphier_aio_compr_set_params(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 					 struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 					 struct snd_compr_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct device *dev = &aio->chip->pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (params->codec.id != SND_AUDIOCODEC_IEC61937) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		dev_err(dev, "Codec ID is not supported(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			params->codec.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (params->codec.profile != SND_AUDIOPROFILE_IEC61937_SPDIF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		dev_err(dev, "Codec profile is not supported(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			params->codec.profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	/* IEC frame type will be changed after received valid data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	sub->iec_pc = IEC61937_PC_AAC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	sub->cparams = *params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	sub->setting = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	aio_port_reset(sub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	aio_src_reset(sub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	ret = uniphier_aio_compr_prepare(component, cstream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static int uniphier_aio_compr_hw_free(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 				      struct snd_compr_stream *cstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	sub->setting = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static int uniphier_aio_compr_prepare(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 				      struct snd_compr_stream *cstream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	struct snd_compr_runtime *runtime = cstream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	int bytes = runtime->fragment_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	ret = aiodma_ch_set_param(sub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	spin_lock_irqsave(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	ret = aiodma_rb_set_buffer(sub, sub->compr_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 				   sub->compr_addr + sub->compr_bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 				   bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	spin_unlock_irqrestore(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	ret = aio_port_set_param(sub, sub->pass_through, &sub->params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	ret = aio_oport_set_stream_type(sub, sub->iec_pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	aio_port_set_enable(sub, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	ret = aio_if_set_param(sub, sub->pass_through);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) static int uniphier_aio_compr_trigger(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				      struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				      int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct snd_compr_runtime *runtime = cstream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	struct device *dev = &aio->chip->pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	int bytes = runtime->fragment_size, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	spin_lock_irqsave(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	case SNDRV_PCM_TRIGGER_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		aiodma_ch_set_enable(sub, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		sub->running = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	case SNDRV_PCM_TRIGGER_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		sub->running = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		aiodma_ch_set_enable(sub, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		dev_warn(dev, "Unknown trigger(%d)\n", cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	spin_unlock_irqrestore(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static int uniphier_aio_compr_pointer(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 				      struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 				      struct snd_compr_tstamp *tstamp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	struct snd_compr_runtime *runtime = cstream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	int bytes = runtime->fragment_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	u32 pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	spin_lock_irqsave(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	if (sub->swm->dir == PORT_DIR_OUTPUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		pos = sub->rd_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		/* Size of AIO output format is double of IEC61937 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		tstamp->copied_total = sub->rd_total / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		pos = sub->wr_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		tstamp->copied_total = sub->rd_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	tstamp->byte_offset = pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	spin_unlock_irqrestore(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static int aio_compr_send_to_hw(struct uniphier_aio_sub *sub,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				char __user *buf, size_t dstsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	u32 __user *srcbuf = (u32 __user *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	u32 *dstbuf = (u32 *)(sub->compr_area + sub->wr_offs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	int src = 0, dst = 0, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	u32 frm, frm_a, frm_b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	while (dstsize > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		ret = get_user(frm, srcbuf + src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		src++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		frm_a = frm & 0xffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		frm_b = (frm >> 16) & 0xffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		if (frm == IEC61937_HEADER_SIGN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			frm_a |= 0x01000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			/* Next data is Pc and Pd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			sub->iec_header = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			u16 pc = be16_to_cpu((__be16)frm_a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			if (sub->iec_header && sub->iec_pc != pc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 				/* Force overwrite IEC frame type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 				sub->iec_pc = pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 				ret = aio_oport_set_stream_type(sub, pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 				if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 					return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			sub->iec_header = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		dstbuf[dst++] = frm_a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		dstbuf[dst++] = frm_b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		dstsize -= sizeof(u32) * 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static int uniphier_aio_compr_copy(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 				   struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 				   char __user *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	struct snd_compr_runtime *runtime = cstream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	struct device *carddev = rtd->compr->card->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	size_t cnt = min_t(size_t, count, aio_rb_space_to_end(sub) / 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	int bytes = runtime->fragment_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	size_t s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	if (cnt < sizeof(u32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if (sub->swm->dir == PORT_DIR_OUTPUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		dma_addr_t dmapos = sub->compr_addr + sub->wr_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		/* Size of AIO output format is double of IEC61937 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		s = cnt * 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		dma_sync_single_for_cpu(carddev, dmapos, s, DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		ret = aio_compr_send_to_hw(sub, buf, s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		dma_sync_single_for_device(carddev, dmapos, s, DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		dma_addr_t dmapos = sub->compr_addr + sub->rd_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		s = cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		dma_sync_single_for_cpu(carddev, dmapos, s, DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		ret = copy_to_user(buf, sub->compr_area + sub->rd_offs, s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		dma_sync_single_for_device(carddev, dmapos, s, DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	spin_lock_irqsave(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	sub->threshold = 2 * bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	aiodma_rb_set_threshold(sub, sub->compr_bytes, 2 * bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	if (sub->swm->dir == PORT_DIR_OUTPUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		sub->wr_offs += s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		if (sub->wr_offs >= sub->compr_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 			sub->wr_offs -= sub->compr_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		sub->rd_offs += s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		if (sub->rd_offs >= sub->compr_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 			sub->rd_offs -= sub->compr_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	spin_unlock_irqrestore(&sub->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	return cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) static int uniphier_aio_compr_get_caps(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 				       struct snd_compr_stream *cstream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 				       struct snd_compr_caps *caps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	caps->num_codecs = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	caps->min_fragment_size = AUD_MIN_FRAGMENT_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	caps->max_fragment_size = AUD_MAX_FRAGMENT_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	caps->min_fragments = AUD_MIN_FRAGMENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	caps->max_fragments = AUD_MAX_FRAGMENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	caps->codecs[0] = SND_AUDIOCODEC_IEC61937;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	return 0;
^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) static const struct snd_compr_codec_caps caps_iec = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	.num_descriptors = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	.descriptor[0].max_ch = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	.descriptor[0].num_sample_rates = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	.descriptor[0].num_bitrates = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	.descriptor[0].profiles = SND_AUDIOPROFILE_IEC61937_SPDIF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	.descriptor[0].modes = SND_AUDIOMODE_IEC_AC3 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 				SND_AUDIOMODE_IEC_MPEG1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 				SND_AUDIOMODE_IEC_MP3 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 				SND_AUDIOMODE_IEC_DTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	.descriptor[0].formats = 0,
^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) static int uniphier_aio_compr_get_codec_caps(struct snd_soc_component *component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 					     struct snd_compr_stream *stream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 					     struct snd_compr_codec_caps *codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	if (codec->codec == SND_AUDIOCODEC_IEC61937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		*codec = caps_iec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) const struct snd_compress_ops uniphier_aio_compress_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	.open           = uniphier_aio_compr_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	.free           = uniphier_aio_compr_free,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	.get_params     = uniphier_aio_compr_get_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	.set_params     = uniphier_aio_compr_set_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	.trigger        = uniphier_aio_compr_trigger,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	.pointer        = uniphier_aio_compr_pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	.copy           = uniphier_aio_compr_copy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	.get_caps       = uniphier_aio_compr_get_caps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	.get_codec_caps = uniphier_aio_compr_get_codec_caps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) };