Skip to content

Commit 0741361

Browse files
authored
Merge pull request #4231 from plbossart/sdw/cleanup-free-trigger
SoundWire: cleanup free, trigger and hw_params callbacks
2 parents a477636 + 4b0b5f7 commit 0741361

File tree

3 files changed

+7
-65
lines changed

3 files changed

+7
-65
lines changed

drivers/soundwire/intel.c

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,15 @@ intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
643643
}
644644

645645
static int intel_params_stream(struct sdw_intel *sdw,
646-
int stream,
646+
struct snd_pcm_substream *substream,
647647
struct snd_soc_dai *dai,
648648
struct snd_pcm_hw_params *hw_params,
649649
int link_id, int alh_stream_id)
650650
{
651651
struct sdw_intel_link_res *res = sdw->link_res;
652652
struct sdw_intel_stream_params_data params_data;
653653

654-
params_data.stream = stream; /* direction */
654+
params_data.substream = substream;
655655
params_data.dai = dai;
656656
params_data.hw_params = hw_params;
657657
params_data.link_id = link_id;
@@ -663,25 +663,6 @@ static int intel_params_stream(struct sdw_intel *sdw,
663663
return -EIO;
664664
}
665665

666-
static int intel_free_stream(struct sdw_intel *sdw,
667-
int stream,
668-
struct snd_soc_dai *dai,
669-
int link_id)
670-
{
671-
struct sdw_intel_link_res *res = sdw->link_res;
672-
struct sdw_intel_stream_free_data free_data;
673-
674-
free_data.stream = stream; /* direction */
675-
free_data.dai = dai;
676-
free_data.link_id = link_id;
677-
678-
if (res->ops && res->ops->free_stream && res->dev)
679-
return res->ops->free_stream(res->dev,
680-
&free_data);
681-
682-
return 0;
683-
}
684-
685666
/*
686667
* DAI routines
687668
*/
@@ -728,7 +709,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
728709
dai_runtime->hw_params = params;
729710

730711
/* Inform DSP about PDI stream number */
731-
ret = intel_params_stream(sdw, substream->stream, dai, params,
712+
ret = intel_params_stream(sdw, substream, dai, params,
732713
sdw->instance,
733714
pdi->intel_alh_id);
734715
if (ret)
@@ -800,7 +781,7 @@ static int intel_prepare(struct snd_pcm_substream *substream,
800781
sdw_cdns_config_stream(cdns, ch, dir, dai_runtime->pdi);
801782

802783
/* Inform DSP about PDI stream number */
803-
ret = intel_params_stream(sdw, substream->stream, dai,
784+
ret = intel_params_stream(sdw, substream, dai,
804785
dai_runtime->hw_params,
805786
sdw->instance,
806787
dai_runtime->pdi->intel_alh_id);
@@ -813,7 +794,6 @@ static int
813794
intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
814795
{
815796
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
816-
struct sdw_intel *sdw = cdns_to_intel(cdns);
817797
struct sdw_cdns_dai_runtime *dai_runtime;
818798
int ret;
819799

@@ -834,12 +814,6 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
834814
return ret;
835815
}
836816

837-
ret = intel_free_stream(sdw, substream->stream, dai, sdw->instance);
838-
if (ret < 0) {
839-
dev_err(dai->dev, "intel_free_stream: failed %d\n", ret);
840-
return ret;
841-
}
842-
843817
dai_runtime->hw_params = NULL;
844818
dai_runtime->pdi = NULL;
845819

@@ -868,19 +842,9 @@ static void *intel_get_sdw_stream(struct snd_soc_dai *dai,
868842
static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai)
869843
{
870844
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
871-
struct sdw_intel *sdw = cdns_to_intel(cdns);
872-
struct sdw_intel_link_res *res = sdw->link_res;
873845
struct sdw_cdns_dai_runtime *dai_runtime;
874846
int ret = 0;
875847

876-
/*
877-
* The .trigger callback is used to send required IPC to audio
878-
* firmware. The .free_stream callback will still be called
879-
* by intel_free_stream() in the TRIGGER_SUSPEND case.
880-
*/
881-
if (res->ops && res->ops->trigger)
882-
res->ops->trigger(dai, cmd, substream->stream);
883-
884848
dai_runtime = cdns->dai_runtime_array[dai->id];
885849
if (!dai_runtime) {
886850
dev_err(dai->dev, "failed to get dai runtime in %s\n",
@@ -900,7 +864,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
900864

901865
dai_runtime->suspended = true;
902866

903-
ret = intel_free_stream(sdw, substream->stream, dai, sdw->instance);
904867
break;
905868

906869
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
@@ -946,9 +909,7 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
946909
*/
947910
for_each_component_dais(component, dai) {
948911
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
949-
struct sdw_intel *sdw = cdns_to_intel(cdns);
950912
struct sdw_cdns_dai_runtime *dai_runtime;
951-
int ret;
952913

953914
dai_runtime = cdns->dai_runtime_array[dai->id];
954915

@@ -958,13 +919,8 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
958919
if (dai_runtime->suspended)
959920
continue;
960921

961-
if (dai_runtime->paused) {
922+
if (dai_runtime->paused)
962923
dai_runtime->suspended = true;
963-
964-
ret = intel_free_stream(sdw, dai_runtime->direction, dai, sdw->instance);
965-
if (ret < 0)
966-
return ret;
967-
}
968924
}
969925

970926
return 0;

include/linux/soundwire/sdw_intel.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,34 +182,20 @@
182182
* firmware.
183183
*/
184184
struct sdw_intel_stream_params_data {
185-
int stream;
185+
struct snd_pcm_substream *substream;
186186
struct snd_soc_dai *dai;
187187
struct snd_pcm_hw_params *hw_params;
188188
int link_id;
189189
int alh_stream_id;
190190
};
191191

192-
/**
193-
* struct sdw_intel_stream_free_data: configuration passed during
194-
* the @free_stream callback, e.g. for interaction with DSP
195-
* firmware.
196-
*/
197-
struct sdw_intel_stream_free_data {
198-
int stream;
199-
struct snd_soc_dai *dai;
200-
int link_id;
201-
};
202-
203192
/**
204193
* struct sdw_intel_ops: Intel audio driver callback ops
205194
*
206195
*/
207196
struct sdw_intel_ops {
208197
int (*params_stream)(struct device *dev,
209198
struct sdw_intel_stream_params_data *params_data);
210-
int (*free_stream)(struct device *dev,
211-
struct sdw_intel_stream_free_data *free_data);
212-
int (*trigger)(struct snd_soc_dai *dai, int cmd, int stream);
213199
};
214200

215201
/**

sound/soc/sof/intel/hda.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int sdw_params_stream(struct device *dev,
9999
struct sdw_intel_stream_params_data *params_data)
100100
{
101101
struct snd_soc_dai *d = params_data->dai;
102-
struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->stream);
102+
struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->substream->stream);
103103
struct snd_sof_dai_config_data data = { 0 };
104104

105105
data.dai_index = (params_data->link_id << 8) | d->id;

0 commit comments

Comments
 (0)