Skip to content

Commit 31d9227

Browse files
committed
Merge remote-tracking branch 'soundwire/next' into sound/upstream-20260528
2 parents 8935f58 + 8a7fe10 commit 31d9227

6 files changed

Lines changed: 71 additions & 64 deletions

File tree

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -299,39 +299,35 @@ static int sdw_add_element_group_count(struct sdw_group *group,
299299
int num = group->count;
300300
int i;
301301

302-
for (i = 0; i <= num; i++) {
302+
for (i = 0; i < num; i++) {
303303
if (rate == group->rates[i] && lane == group->lanes[i])
304-
break;
305-
306-
if (i != num)
307-
continue;
304+
return 0;
305+
}
308306

309-
if (group->count >= group->max_size) {
310-
unsigned int *rates;
311-
unsigned int *lanes;
307+
if (group->count >= group->max_size) {
308+
unsigned int *rates;
309+
unsigned int *lanes;
312310

313-
group->max_size += 1;
314-
rates = krealloc(group->rates,
315-
(sizeof(int) * group->max_size),
316-
GFP_KERNEL);
317-
if (!rates)
318-
return -ENOMEM;
311+
rates = krealloc_array(group->rates, group->max_size + 1,
312+
sizeof(*group->rates), GFP_KERNEL);
313+
if (!rates)
314+
return -ENOMEM;
319315

320-
group->rates = rates;
316+
group->rates = rates;
321317

322-
lanes = krealloc(group->lanes,
323-
(sizeof(int) * group->max_size),
324-
GFP_KERNEL);
325-
if (!lanes)
326-
return -ENOMEM;
318+
lanes = krealloc_array(group->lanes, group->max_size + 1,
319+
sizeof(*group->lanes), GFP_KERNEL);
320+
if (!lanes)
321+
return -ENOMEM;
327322

328-
group->lanes = lanes;
329-
}
323+
group->lanes = lanes;
330324

331-
group->rates[group->count] = rate;
332-
group->lanes[group->count++] = lane;
325+
group->max_size += 1;
333326
}
334327

328+
group->rates[group->count] = rate;
329+
group->lanes[group->count++] = lane;
330+
335331
return 0;
336332
}
337333

drivers/soundwire/intel.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -906,19 +906,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
906906
}
907907

908908
switch (cmd) {
909-
case SNDRV_PCM_TRIGGER_SUSPEND:
910-
911-
/*
912-
* The .prepare callback is used to deal with xruns and resume operations.
913-
* In the case of xruns, the DMAs and SHIM registers cannot be touched,
914-
* but for resume operations the DMAs and SHIM registers need to be initialized.
915-
* the .trigger callback is used to track the suspend case only.
916-
*/
917-
918-
dai_runtime->suspended = true;
919-
920-
break;
921-
922909
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
923910
dai_runtime->paused = true;
924911
break;
@@ -955,24 +942,20 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
955942
struct snd_soc_dai *dai;
956943

957944
/*
958-
* In the corner case where a SUSPEND happens during a PAUSE, the ALSA core
959-
* does not throw the TRIGGER_SUSPEND. This leaves the DAIs in an unbalanced state.
960-
* Since the component suspend is called last, we can trap this corner case
961-
* and force the DAIs to release their resources.
945+
* Mark all open streams as suspended.
946+
* Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
947+
* state and during prepare the DMAs and SHIM registers need to be
948+
* initialized for them.
949+
* The STOPPED state is a special corner case which can happen if audio
950+
* experiences xrun at suspend time.
962951
*/
963952
for_each_component_dais(component, dai) {
964953
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
965954
struct sdw_cdns_dai_runtime *dai_runtime;
966955

967956
dai_runtime = cdns->dai_runtime_array[dai->id];
968957

969-
if (!dai_runtime)
970-
continue;
971-
972-
if (dai_runtime->suspended)
973-
continue;
974-
975-
if (dai_runtime->paused)
958+
if (dai_runtime)
976959
dai_runtime->suspended = true;
977960
}
978961

drivers/soundwire/intel_ace2x.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ static void intel_ace2x_bpt_close_stream(struct sdw_intel *sdw, struct sdw_slave
317317
dev_err(cdns->dev, "%s: remove slave failed: %d\n",
318318
__func__, ret);
319319

320+
sdw_release_stream(cdns->bus.bpt_stream);
320321
cdns->bus.bpt_stream = NULL;
321322
}
322323

@@ -894,19 +895,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
894895
}
895896

896897
switch (cmd) {
897-
case SNDRV_PCM_TRIGGER_SUSPEND:
898-
899-
/*
900-
* The .prepare callback is used to deal with xruns and resume operations.
901-
* In the case of xruns, the DMAs and SHIM registers cannot be touched,
902-
* but for resume operations the DMAs and SHIM registers need to be initialized.
903-
* the .trigger callback is used to track the suspend case only.
904-
*/
905-
906-
dai_runtime->suspended = true;
907-
908-
break;
909-
910898
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
911899
dai_runtime->paused = true;
912900
break;
@@ -930,8 +918,34 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
930918
.get_stream = intel_get_sdw_stream,
931919
};
932920

921+
static int intel_component_dais_suspend(struct snd_soc_component *component)
922+
{
923+
struct snd_soc_dai *dai;
924+
925+
/*
926+
* Mark all open streams as suspended.
927+
* Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
928+
* state and during prepare the DMAs and SHIM registers need to be
929+
* initialized for them.
930+
* The STOPPED state is a special corner case which can happen if audio
931+
* experiences xrun at suspend time.
932+
*/
933+
for_each_component_dais(component, dai) {
934+
struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
935+
struct sdw_cdns_dai_runtime *dai_runtime;
936+
937+
dai_runtime = cdns->dai_runtime_array[dai->id];
938+
939+
if (dai_runtime)
940+
dai_runtime->suspended = true;
941+
}
942+
943+
return 0;
944+
}
945+
933946
static const struct snd_soc_component_driver dai_component = {
934947
.name = "soundwire",
948+
.suspend = intel_component_dais_suspend,
935949
};
936950

937951
/*

drivers/soundwire/intel_auxdevice.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ struct wake_capable_part {
5151
};
5252

5353
static struct wake_capable_part wake_capable_list[] = {
54+
{0x01fa, 0x2A30},
55+
{0x01fa, 0x2A3B},
5456
{0x01fa, 0x4243},
5557
{0x01fa, 0x4245},
5658
{0x01fa, 0x4249},
@@ -70,6 +72,7 @@ static struct wake_capable_part wake_capable_list[] = {
7072
{0x025d, 0x717},
7173
{0x025d, 0x721},
7274
{0x025d, 0x722},
75+
{0x04b3, 0x9356},
7376
};
7477

7578
static bool is_wake_capable(struct sdw_slave *slave)

drivers/soundwire/slave.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ int sdw_of_find_slaves(struct sdw_bus *bus)
244244
struct sdw_slave_id id;
245245
const __be32 *addr;
246246

247-
compat = of_get_property(node, "compatible", NULL);
248-
if (!compat)
247+
ret = of_property_read_string(node, "compatible", &compat);
248+
if (ret)
249249
continue;
250250

251251
ret = sscanf(compat, "sdw%01x%04hx%04hx%02hhx", &sdw_version,

drivers/soundwire/stream.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,13 @@ static int sdw_program_params(struct sdw_bus *bus, bool prepare)
697697
if (scale_index < 0)
698698
return scale_index;
699699

700+
/* Skip the unattached Peripherals */
701+
if (!completion_done(&slave->enumeration_complete)) {
702+
dev_warn(&slave->dev,
703+
"Not enumerated, skip programming BUSCLOCK_SCALE\n");
704+
continue;
705+
}
706+
700707
ret = sdw_write_no_pm(slave, addr1, scale_index);
701708
if (ret < 0) {
702709
dev_err(&slave->dev, "SDW_SCP_BUSCLOCK_SCALE register write failed\n");
@@ -2229,11 +2236,15 @@ EXPORT_SYMBOL(sdw_stream_add_slave);
22292236
* @slave: SDW Slave instance
22302237
* @stream: SoundWire stream
22312238
*
2232-
* This removes and frees port_rt and slave_rt from a stream
2239+
* This removes and frees port_rt and slave_rt from a stream.
2240+
* If stream is NULL or an ERR_PTR, do nothing and return 0.
22332241
*/
22342242
int sdw_stream_remove_slave(struct sdw_slave *slave,
22352243
struct sdw_stream_runtime *stream)
22362244
{
2245+
if (IS_ERR_OR_NULL(stream))
2246+
return 0;
2247+
22372248
mutex_lock(&slave->bus->bus_lock);
22382249

22392250
sdw_slave_port_free(slave, stream);

0 commit comments

Comments
 (0)