Commit e0767e39 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul

soundwire: cadence: rename sdw_cdns_dai_dma_data as sdw_cdns_dai_runtime

The existing 'struct sdw_cdns_dma_data' has really nothing to do with
DMAs. The information is stored in the dai->dma_data, but this is
really private data that should be stored in a different context.

Beyond the academic elegance discussion, using dma_data is a problem
for new Intel hardware where the dma_data structure is already used
for true DMA handling performed by other parts of the code.

This patch prepares a transition away from the use of dma_data, for
now with a rename-only change.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20221101023521.2384586-2-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent cf43cd33
...@@ -1707,40 +1707,40 @@ int cdns_set_sdw_stream(struct snd_soc_dai *dai, ...@@ -1707,40 +1707,40 @@ int cdns_set_sdw_stream(struct snd_soc_dai *dai,
void *stream, int direction) void *stream, int direction)
{ {
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_cdns_dma_data *dma; struct sdw_cdns_dai_runtime *dai_runtime;
if (stream) { if (stream) {
/* first paranoia check */ /* first paranoia check */
if (direction == SNDRV_PCM_STREAM_PLAYBACK) if (direction == SNDRV_PCM_STREAM_PLAYBACK)
dma = dai->playback_dma_data; dai_runtime = dai->playback_dma_data;
else else
dma = dai->capture_dma_data; dai_runtime = dai->capture_dma_data;
if (dma) { if (dai_runtime) {
dev_err(dai->dev, dev_err(dai->dev,
"dma_data already allocated for dai %s\n", "dai_runtime already allocated for dai %s\n",
dai->name); dai->name);
return -EINVAL; return -EINVAL;
} }
/* allocate and set dma info */ /* allocate and set dai_runtime info */
dma = kzalloc(sizeof(*dma), GFP_KERNEL); dai_runtime = kzalloc(sizeof(*dai_runtime), GFP_KERNEL);
if (!dma) if (!dai_runtime)
return -ENOMEM; return -ENOMEM;
dma->stream_type = SDW_STREAM_PCM; dai_runtime->stream_type = SDW_STREAM_PCM;
dma->bus = &cdns->bus; dai_runtime->bus = &cdns->bus;
dma->link_id = cdns->instance; dai_runtime->link_id = cdns->instance;
dma->stream = stream; dai_runtime->stream = stream;
if (direction == SNDRV_PCM_STREAM_PLAYBACK) if (direction == SNDRV_PCM_STREAM_PLAYBACK)
dai->playback_dma_data = dma; dai->playback_dma_data = dai_runtime;
else else
dai->capture_dma_data = dma; dai->capture_dma_data = dai_runtime;
} else { } else {
/* for NULL stream we release allocated dma_data */ /* for NULL stream we release allocated dai_runtime */
if (direction == SNDRV_PCM_STREAM_PLAYBACK) { if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
kfree(dai->playback_dma_data); kfree(dai->playback_dma_data);
dai->playback_dma_data = NULL; dai->playback_dma_data = NULL;
......
...@@ -70,7 +70,7 @@ struct sdw_cdns_stream_config { ...@@ -70,7 +70,7 @@ struct sdw_cdns_stream_config {
}; };
/** /**
* struct sdw_cdns_dma_data: Cadence DMA data * struct sdw_cdns_dai_runtime: Cadence DAI runtime data
* *
* @name: SoundWire stream name * @name: SoundWire stream name
* @stream: stream runtime * @stream: stream runtime
...@@ -82,7 +82,7 @@ struct sdw_cdns_stream_config { ...@@ -82,7 +82,7 @@ struct sdw_cdns_stream_config {
* @suspended: status set when suspended, to be used in .prepare * @suspended: status set when suspended, to be used in .prepare
* @paused: status set in .trigger, to be used in suspend * @paused: status set in .trigger, to be used in suspend
*/ */
struct sdw_cdns_dma_data { struct sdw_cdns_dai_runtime {
char *name; char *name;
struct sdw_stream_runtime *stream; struct sdw_stream_runtime *stream;
struct sdw_cdns_pdi *pdi; struct sdw_cdns_pdi *pdi;
......
...@@ -824,15 +824,15 @@ static int intel_hw_params(struct snd_pcm_substream *substream, ...@@ -824,15 +824,15 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
{ {
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_cdns_dma_data *dma; struct sdw_cdns_dai_runtime *dai_runtime;
struct sdw_cdns_pdi *pdi; struct sdw_cdns_pdi *pdi;
struct sdw_stream_config sconfig; struct sdw_stream_config sconfig;
struct sdw_port_config *pconfig; struct sdw_port_config *pconfig;
int ch, dir; int ch, dir;
int ret; int ret;
dma = snd_soc_dai_get_dma_data(dai, substream); dai_runtime = snd_soc_dai_get_dma_data(dai, substream);
if (!dma) if (!dai_runtime)
return -EIO; return -EIO;
ch = params_channels(params); ch = params_channels(params);
...@@ -854,10 +854,10 @@ static int intel_hw_params(struct snd_pcm_substream *substream, ...@@ -854,10 +854,10 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
sdw_cdns_config_stream(cdns, ch, dir, pdi); sdw_cdns_config_stream(cdns, ch, dir, pdi);
/* store pdi and hw_params, may be needed in prepare step */ /* store pdi and hw_params, may be needed in prepare step */
dma->paused = false; dai_runtime->paused = false;
dma->suspended = false; dai_runtime->suspended = false;
dma->pdi = pdi; dai_runtime->pdi = pdi;
dma->hw_params = params; dai_runtime->hw_params = params;
/* Inform DSP about PDI stream number */ /* Inform DSP about PDI stream number */
ret = intel_params_stream(sdw, substream->stream, dai, params, ret = intel_params_stream(sdw, substream->stream, dai, params,
...@@ -869,7 +869,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, ...@@ -869,7 +869,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
sconfig.direction = dir; sconfig.direction = dir;
sconfig.ch_count = ch; sconfig.ch_count = ch;
sconfig.frame_rate = params_rate(params); sconfig.frame_rate = params_rate(params);
sconfig.type = dma->stream_type; sconfig.type = dai_runtime->stream_type;
sconfig.bps = snd_pcm_format_width(params_format(params)); sconfig.bps = snd_pcm_format_width(params_format(params));
...@@ -884,7 +884,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream, ...@@ -884,7 +884,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
pconfig->ch_mask = (1 << ch) - 1; pconfig->ch_mask = (1 << ch) - 1;
ret = sdw_stream_add_master(&cdns->bus, &sconfig, ret = sdw_stream_add_master(&cdns->bus, &sconfig,
pconfig, 1, dma->stream); pconfig, 1, dai_runtime->stream);
if (ret) if (ret)
dev_err(cdns->dev, "add master to stream failed:%d\n", ret); dev_err(cdns->dev, "add master to stream failed:%d\n", ret);
...@@ -898,19 +898,19 @@ static int intel_prepare(struct snd_pcm_substream *substream, ...@@ -898,19 +898,19 @@ static int intel_prepare(struct snd_pcm_substream *substream,
{ {
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_cdns_dma_data *dma; struct sdw_cdns_dai_runtime *dai_runtime;
int ch, dir; int ch, dir;
int ret = 0; int ret = 0;
dma = snd_soc_dai_get_dma_data(dai, substream); dai_runtime = snd_soc_dai_get_dma_data(dai, substream);
if (!dma) { if (!dai_runtime) {
dev_err(dai->dev, "failed to get dma data in %s\n", dev_err(dai->dev, "failed to get dai runtime in %s\n",
__func__); __func__);
return -EIO; return -EIO;
} }
if (dma->suspended) { if (dai_runtime->suspended) {
dma->suspended = false; dai_runtime->suspended = false;
/* /*
* .prepare() is called after system resume, where we * .prepare() is called after system resume, where we
...@@ -921,21 +921,21 @@ static int intel_prepare(struct snd_pcm_substream *substream, ...@@ -921,21 +921,21 @@ static int intel_prepare(struct snd_pcm_substream *substream,
*/ */
/* configure stream */ /* configure stream */
ch = params_channels(dma->hw_params); ch = params_channels(dai_runtime->hw_params);
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
dir = SDW_DATA_DIR_RX; dir = SDW_DATA_DIR_RX;
else else
dir = SDW_DATA_DIR_TX; dir = SDW_DATA_DIR_TX;
intel_pdi_shim_configure(sdw, dma->pdi); intel_pdi_shim_configure(sdw, dai_runtime->pdi);
intel_pdi_alh_configure(sdw, dma->pdi); intel_pdi_alh_configure(sdw, dai_runtime->pdi);
sdw_cdns_config_stream(cdns, ch, dir, dma->pdi); sdw_cdns_config_stream(cdns, ch, dir, dai_runtime->pdi);
/* Inform DSP about PDI stream number */ /* Inform DSP about PDI stream number */
ret = intel_params_stream(sdw, substream->stream, dai, ret = intel_params_stream(sdw, substream->stream, dai,
dma->hw_params, dai_runtime->hw_params,
sdw->instance, sdw->instance,
dma->pdi->intel_alh_id); dai_runtime->pdi->intel_alh_id);
} }
return ret; return ret;
...@@ -946,11 +946,11 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) ...@@ -946,11 +946,11 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
{ {
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_cdns_dma_data *dma; struct sdw_cdns_dai_runtime *dai_runtime;
int ret; int ret;
dma = snd_soc_dai_get_dma_data(dai, substream); dai_runtime = snd_soc_dai_get_dma_data(dai, substream);
if (!dma) if (!dai_runtime)
return -EIO; return -EIO;
/* /*
...@@ -959,10 +959,10 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) ...@@ -959,10 +959,10 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
* DEPREPARED for the first cpu-dai and to RELEASED for the last * DEPREPARED for the first cpu-dai and to RELEASED for the last
* cpu-dai. * cpu-dai.
*/ */
ret = sdw_stream_remove_master(&cdns->bus, dma->stream); ret = sdw_stream_remove_master(&cdns->bus, dai_runtime->stream);
if (ret < 0) { if (ret < 0) {
dev_err(dai->dev, "remove master from stream %s failed: %d\n", dev_err(dai->dev, "remove master from stream %s failed: %d\n",
dma->stream->name, ret); dai_runtime->stream->name, ret);
return ret; return ret;
} }
...@@ -972,8 +972,8 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) ...@@ -972,8 +972,8 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
return ret; return ret;
} }
dma->hw_params = NULL; dai_runtime->hw_params = NULL;
dma->pdi = NULL; dai_runtime->pdi = NULL;
return 0; return 0;
} }
...@@ -996,17 +996,17 @@ static int intel_pcm_set_sdw_stream(struct snd_soc_dai *dai, ...@@ -996,17 +996,17 @@ static int intel_pcm_set_sdw_stream(struct snd_soc_dai *dai,
static void *intel_get_sdw_stream(struct snd_soc_dai *dai, static void *intel_get_sdw_stream(struct snd_soc_dai *dai,
int direction) int direction)
{ {
struct sdw_cdns_dma_data *dma; struct sdw_cdns_dai_runtime *dai_runtime;
if (direction == SNDRV_PCM_STREAM_PLAYBACK) if (direction == SNDRV_PCM_STREAM_PLAYBACK)
dma = dai->playback_dma_data; dai_runtime = dai->playback_dma_data;
else else
dma = dai->capture_dma_data; dai_runtime = dai->capture_dma_data;
if (!dma) if (!dai_runtime)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
return dma->stream; return dai_runtime->stream;
} }
static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai)
...@@ -1014,7 +1014,7 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn ...@@ -1014,7 +1014,7 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_intel_link_res *res = sdw->link_res; struct sdw_intel_link_res *res = sdw->link_res;
struct sdw_cdns_dma_data *dma; struct sdw_cdns_dai_runtime *dai_runtime;
int ret = 0; int ret = 0;
/* /*
...@@ -1025,9 +1025,9 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn ...@@ -1025,9 +1025,9 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
if (res->ops && res->ops->trigger) if (res->ops && res->ops->trigger)
res->ops->trigger(dai, cmd, substream->stream); res->ops->trigger(dai, cmd, substream->stream);
dma = snd_soc_dai_get_dma_data(dai, substream); dai_runtime = snd_soc_dai_get_dma_data(dai, substream);
if (!dma) { if (!dai_runtime) {
dev_err(dai->dev, "failed to get dma data in %s\n", dev_err(dai->dev, "failed to get dai runtime in %s\n",
__func__); __func__);
return -EIO; return -EIO;
} }
...@@ -1042,17 +1042,17 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn ...@@ -1042,17 +1042,17 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
* the .trigger callback is used to track the suspend case only. * the .trigger callback is used to track the suspend case only.
*/ */
dma->suspended = true; dai_runtime->suspended = true;
ret = intel_free_stream(sdw, substream->stream, dai, sdw->instance); ret = intel_free_stream(sdw, substream->stream, dai, sdw->instance);
break; break;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
dma->paused = true; dai_runtime->paused = true;
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
dma->paused = false; dai_runtime->paused = false;
break; break;
default: default:
break; break;
...@@ -1091,25 +1091,25 @@ static int intel_component_dais_suspend(struct snd_soc_component *component) ...@@ -1091,25 +1091,25 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
for_each_component_dais(component, dai) { for_each_component_dais(component, dai) {
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_cdns_dma_data *dma; struct sdw_cdns_dai_runtime *dai_runtime;
int stream; int stream;
int ret; int ret;
dma = dai->playback_dma_data; dai_runtime = dai->playback_dma_data;
stream = SNDRV_PCM_STREAM_PLAYBACK; stream = SNDRV_PCM_STREAM_PLAYBACK;
if (!dma) { if (!dai_runtime) {
dma = dai->capture_dma_data; dai_runtime = dai->capture_dma_data;
stream = SNDRV_PCM_STREAM_CAPTURE; stream = SNDRV_PCM_STREAM_CAPTURE;
} }
if (!dma) if (!dai_runtime)
continue; continue;
if (dma->suspended) if (dai_runtime->suspended)
continue; continue;
if (dma->paused) { if (dai_runtime->paused) {
dma->suspended = true; dai_runtime->suspended = true;
ret = intel_free_stream(sdw, stream, dai, sdw->instance); ret = intel_free_stream(sdw, stream, dai, sdw->instance);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment