static int wcd9xxx_dealloc_slim_sh_ch(struct slim_device *slim, u32 cnt, struct wcd9xxx_ch *channels) { int idx = 0; int ret = 0; /* slim_dealloc_ch */ for (idx = 0; idx < cnt; idx++) { ret = slim_dealloc_ch(slim, channels[idx].ch_h); if (ret < 0) { pr_err("%s: slim_dealloc_ch fail ret[%d] ch_h[%d]\n", __func__, ret, channels[idx].ch_h); } } return ret; }
static int wcd9xxx_dealloc_slim_sh_ch_tx(struct wcd9xxx *wcd9xxx) { int idx = 0; int ret = 0; struct wcd9xxx_slim_sch_tx *tx = sh_ch.tx; /* slim_dealloc_ch */ for (idx = 0; idx < SLIM_MAX_TX_PORTS; idx++) { ret = slim_dealloc_ch(wcd9xxx->slim, tx[idx].ch_h); if (ret < 0) { pr_err("%s: slim_dealloc_ch fail ret[%d] ch_h[%d]\n", __func__, ret, tx[idx].ch_h); } } memset(sh_ch.tx, 0, sizeof(sh_ch.tx)); return ret; }
static int wcd9xxx_dealloc_slim_sh_ch_rx(struct wcd9xxx *wcd9xxx) { int idx = 0; int ret = 0; struct wcd9xxx_slim_sch_rx *rx = sh_ch.rx; /* slim_dealloc_ch */ for (idx = 0; idx < sh_ch.number_of_rx_slave_dev_ports; idx++) { ret = slim_dealloc_ch(wcd9xxx->slim, rx[idx].ch_h); if (ret < 0) { pr_err("%s: slim_dealloc_ch fail ret[%d] ch_h[%d]\n", __func__, ret, rx[idx].ch_h); } } memset(sh_ch.rx, 0, sizeof(sh_ch.rx)); return ret; }
static void msm_dai_slim_shutdown(struct snd_pcm_substream *stream, struct snd_soc_dai *dai) { struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev); struct msm_slim_dma_data *dma_data = NULL; struct msm_slim_dai_data *dai_data; int i, rc = 0; dai_data = msm_slim_get_dai_data(drv_data, dai); dma_data = snd_soc_dai_get_dma_data(dai, stream); if (!dma_data || !dai_data) { dev_err(dai->dev, "%s: Invalid %s\n", __func__, (!dma_data) ? "dma_data" : "dai_data"); return; } if ((!(dai_data->status & DAI_STATE_PREPARED)) || dai_data->status & DAI_STATE_RUNNING) { dev_err(dai->dev, "%s: dai id (%d) has invalid state 0x%x\n", __func__, dai->id, dai_data->status); return; } for (i = 0; i < dai_data->ch_cnt; i++) { rc = slim_dealloc_ch(drv_data->sdev, dai_data->chan_h[i]); if (rc) { dev_err(dai->dev, "%s: dealloc_ch failed, err = %d\n", __func__, rc); } } snd_soc_dai_set_dma_data(dai, stream, NULL); /* clear prepared state for the dai */ CLR_DAI_STATE(dai_data->status, DAI_STATE_PREPARED); return; }
static int msm_dai_slim_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct msm_dai_slim_drv_data *drv_data = dev_get_drvdata(dai->dev); struct msm_slim_dma_data *dma_data; struct msm_slim_dai_data *dai_data = NULL; struct slim_ch prop; int rc; u8 i, j; dai_data = msm_slim_get_dai_data(drv_data, dai); if (!dai_data) { dev_err(dai->dev, "%s: Invalid dai_data for dai %d\n", __func__, dai->id); return -EINVAL; } if (!(dai_data->status & DAI_STATE_INITIALIZED)) { dev_err(dai->dev, "%s: dai id (%d) has invalid state 0x%x\n", __func__, dai->id, dai_data->status); return -EINVAL; } dma_data = &dai_data->dma_data; snd_soc_dai_set_dma_data(dai, substream, dma_data); for (i = 0; i < dai_data->ch_cnt; i++) { rc = slim_query_ch(drv_data->sdev, dai_data->sh_ch[i], &dai_data->chan_h[i]); if (rc) { dev_err(dai->dev, "%s:query chan handle failed rc %d\n", __func__ , rc); goto error_chan_query; } } prop.prot = SLIM_AUTO_ISO; prop.baser = SLIM_RATE_4000HZ; prop.dataf = SLIM_CH_DATAF_NOT_DEFINED; prop.auxf = SLIM_CH_AUXF_NOT_APPLICABLE; prop.ratem = (dai_data->rate/4000); prop.sampleszbits = dai_data->bits; rc = slim_define_ch(drv_data->sdev, &prop, dai_data->chan_h, dai_data->ch_cnt, true, &dai_data->grph); if (rc) { dev_err(dai->dev, "%s:define chan failed rc %d\n", __func__ , rc); goto error_define_chan; } /* Mark stream status as prepared */ SET_DAI_STATE(dai_data->status, DAI_STATE_PREPARED); return rc; error_define_chan: error_chan_query: for (j = 0; j < i; j++) slim_dealloc_ch(drv_data->sdev, dai_data->chan_h[j]); return rc; }