Skip to content

Commit cf6e9a5

Browse files
committed
ASoC: SOF: Use input/output pin consistently
Currently we use input/output and sink/source pins interchangeably. Remove the references to sink/source pins and replace with input/output pins everywhere for consistency and clarity. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 26d542d commit cf6e9a5

File tree

4 files changed

+86
-86
lines changed

4 files changed

+86
-86
lines changed

include/uapi/sound/sof/tokens.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@
8989
#define SOF_TKN_COMP_CPC 406
9090
#define SOF_TKN_COMP_IS_PAGES 409
9191
#define SOF_TKN_COMP_NUM_AUDIO_FORMATS 410
92-
#define SOF_TKN_COMP_NUM_SINK_PINS 411
93-
#define SOF_TKN_COMP_NUM_SOURCE_PINS 412
92+
#define SOF_TKN_COMP_NUM_INPUT_PINS 411
93+
#define SOF_TKN_COMP_NUM_OUTPUT_PINS 412
9494
/*
95-
* The token for sink/source pin binding, it specifies the widget
96-
* name that the sink/source pin is connected from/to.
95+
* The token for input/output pin binding, it specifies the widget
96+
* name that the input/output pin is connected from/to.
9797
*/
98-
#define SOF_TKN_COMP_SINK_PIN_BINDING_WNAME 413
99-
#define SOF_TKN_COMP_SRC_PIN_BINDING_WNAME 414
98+
#define SOF_TKN_COMP_INPUT_PIN_BINDING_WNAME 413
99+
#define SOF_TKN_COMP_OUTPUT_PIN_BINDING_WNAME 414
100100

101101
/* SSP */
102102
#define SOF_TKN_INTEL_SSP_CLKS_CONTROL 500

sound/soc/sof/ipc4-topology.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,30 +1966,30 @@ static int sof_ipc4_get_queue_id(struct snd_sof_widget *src_widget,
19661966
u32 num_pins;
19671967
int i;
19681968

1969-
if (pin_type == SOF_PIN_TYPE_SOURCE) {
1969+
if (pin_type == SOF_PIN_TYPE_OUTPUT) {
19701970
current_swidget = src_widget;
1971-
pin_binding = src_widget->src_pin_binding;
1972-
queue_ida = &src_widget->src_queue_ida;
1973-
num_pins = src_widget->num_source_pins;
1971+
pin_binding = src_widget->output_pin_binding;
1972+
queue_ida = &src_widget->output_queue_ida;
1973+
num_pins = src_widget->num_output_pins;
19741974
buddy_name = sink_widget->widget->name;
19751975
} else {
19761976
current_swidget = sink_widget;
1977-
pin_binding = sink_widget->sink_pin_binding;
1978-
queue_ida = &sink_widget->sink_queue_ida;
1979-
num_pins = sink_widget->num_sink_pins;
1977+
pin_binding = sink_widget->input_pin_binding;
1978+
queue_ida = &sink_widget->input_queue_ida;
1979+
num_pins = sink_widget->num_input_pins;
19801980
buddy_name = src_widget->widget->name;
19811981
}
19821982

19831983
scomp = current_swidget->scomp;
19841984

19851985
if (num_pins < 1) {
19861986
dev_err(scomp->dev, "invalid %s num_pins: %d for queue allocation for %s\n",
1987-
(pin_type == SOF_PIN_TYPE_SOURCE ? "source" : "sink"),
1987+
(pin_type == SOF_PIN_TYPE_OUTPUT ? "output" : "input"),
19881988
num_pins, current_swidget->widget->name);
19891989
return -EINVAL;
19901990
}
19911991

1992-
/* If there is only one sink/source pin, queue id must be 0 */
1992+
/* If there is only one input/output pin, queue id must be 0 */
19931993
if (num_pins == 1)
19941994
return 0;
19951995

@@ -2004,7 +2004,7 @@ static int sof_ipc4_get_queue_id(struct snd_sof_widget *src_widget,
20042004
* mixed use pin binding array and ida for queue ID allocation.
20052005
*/
20062006
dev_err(scomp->dev, "no %s queue id found from pin binding array for %s\n",
2007-
(pin_type == SOF_PIN_TYPE_SOURCE ? "source" : "sink"),
2007+
(pin_type == SOF_PIN_TYPE_OUTPUT ? "output" : "input"),
20082008
current_swidget->widget->name);
20092009
return -EINVAL;
20102010
}
@@ -2020,14 +2020,14 @@ static void sof_ipc4_put_queue_id(struct snd_sof_widget *swidget, int queue_id,
20202020
char **pin_binding;
20212021
int num_pins;
20222022

2023-
if (pin_type == SOF_PIN_TYPE_SOURCE) {
2024-
pin_binding = swidget->src_pin_binding;
2025-
queue_ida = &swidget->src_queue_ida;
2026-
num_pins = swidget->num_source_pins;
2023+
if (pin_type == SOF_PIN_TYPE_OUTPUT) {
2024+
pin_binding = swidget->output_pin_binding;
2025+
queue_ida = &swidget->output_queue_ida;
2026+
num_pins = swidget->num_output_pins;
20272027
} else {
2028-
pin_binding = swidget->sink_pin_binding;
2029-
queue_ida = &swidget->sink_queue_ida;
2030-
num_pins = swidget->num_sink_pins;
2028+
pin_binding = swidget->input_pin_binding;
2029+
queue_ida = &swidget->input_queue_ida;
2030+
num_pins = swidget->num_input_pins;
20312031
}
20322032

20332033
/* Nothing to free if queue ID is not allocated with ida. */
@@ -2120,20 +2120,20 @@ static int sof_ipc4_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *
21202120
}
21212121

21222122
sroute->src_queue_id = sof_ipc4_get_queue_id(src_widget, sink_widget,
2123-
SOF_PIN_TYPE_SOURCE);
2123+
SOF_PIN_TYPE_OUTPUT);
21242124
if (sroute->src_queue_id < 0) {
21252125
dev_err(sdev->dev, "failed to get queue ID for source widget: %s\n",
21262126
src_widget->widget->name);
21272127
return sroute->src_queue_id;
21282128
}
21292129

21302130
sroute->dst_queue_id = sof_ipc4_get_queue_id(src_widget, sink_widget,
2131-
SOF_PIN_TYPE_SINK);
2131+
SOF_PIN_TYPE_INPUT);
21322132
if (sroute->dst_queue_id < 0) {
21332133
dev_err(sdev->dev, "failed to get queue ID for sink widget: %s\n",
21342134
sink_widget->widget->name);
21352135
sof_ipc4_put_queue_id(src_widget, sroute->src_queue_id,
2136-
SOF_PIN_TYPE_SOURCE);
2136+
SOF_PIN_TYPE_OUTPUT);
21372137
return sroute->dst_queue_id;
21382138
}
21392139

@@ -2177,8 +2177,8 @@ static int sof_ipc4_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *
21772177
return ret;
21782178

21792179
out:
2180-
sof_ipc4_put_queue_id(src_widget, sroute->src_queue_id, SOF_PIN_TYPE_SOURCE);
2181-
sof_ipc4_put_queue_id(sink_widget, sroute->dst_queue_id, SOF_PIN_TYPE_SINK);
2180+
sof_ipc4_put_queue_id(src_widget, sroute->src_queue_id, SOF_PIN_TYPE_OUTPUT);
2181+
sof_ipc4_put_queue_id(sink_widget, sroute->dst_queue_id, SOF_PIN_TYPE_INPUT);
21822182
return ret;
21832183
}
21842184

@@ -2231,8 +2231,8 @@ static int sof_ipc4_route_free(struct snd_sof_dev *sdev, struct snd_sof_route *s
22312231
src_widget->widget->name, sroute->src_queue_id,
22322232
sink_widget->widget->name, sroute->dst_queue_id);
22332233
out:
2234-
sof_ipc4_put_queue_id(sink_widget, sroute->dst_queue_id, SOF_PIN_TYPE_SINK);
2235-
sof_ipc4_put_queue_id(src_widget, sroute->src_queue_id, SOF_PIN_TYPE_SOURCE);
2234+
sof_ipc4_put_queue_id(sink_widget, sroute->dst_queue_id, SOF_PIN_TYPE_INPUT);
2235+
sof_ipc4_put_queue_id(src_widget, sroute->src_queue_id, SOF_PIN_TYPE_OUTPUT);
22362236

22372237
return ret;
22382238
}

sound/soc/sof/sof-audio.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
*/
3131
#define SOF_WIDGET_MAX_NUM_PINS 8
3232

33-
/* The type of a widget pin is either sink or source */
34-
#define SOF_PIN_TYPE_SINK 0
35-
#define SOF_PIN_TYPE_SOURCE 1
33+
/* Widget pin type */
34+
#define SOF_PIN_TYPE_INPUT 0
35+
#define SOF_PIN_TYPE_OUTPUT 1
3636

3737
/* max number of FE PCMs before BEs */
3838
#define SOF_BE_PCM_BASE 16
@@ -433,31 +433,31 @@ struct snd_sof_widget {
433433
struct snd_sof_tuple *tuples;
434434

435435
/*
436-
* The allowed range for num_sink/source_pins is [0, SOF_WIDGET_MAX_NUM_PINS].
437-
* Widgets may have zero sink or source pins, for example the tone widget has
438-
* zero sink pins.
436+
* The allowed range for num_input/output_pins is [0, SOF_WIDGET_MAX_NUM_PINS].
437+
* Widgets may have zero input or output pins, for example the tone widget has
438+
* zero input pins.
439439
*/
440-
u32 num_sink_pins;
441-
u32 num_source_pins;
440+
u32 num_input_pins;
441+
u32 num_output_pins;
442442

443443
/*
444-
* The sink/source pin binding array, it takes the form of
444+
* The input/output pin binding array, it takes the form of
445445
* [widget_name_connected_to_pin0, widget_name_connected_to_pin1, ...],
446446
* with the index as the queue ID.
447447
*
448448
* The array is used for special pin binding. Note that even if there
449-
* is only one sink/source pin requires special pin binding, pin binding
450-
* should be defined for all sink/source pins in topology, for pin(s) that
449+
* is only one input/output pin requires special pin binding, pin binding
450+
* should be defined for all input/output pins in topology, for pin(s) that
451451
* are not used, give the value "NotConnected".
452452
*
453453
* If pin binding is not defined in topology, nothing to parse in the kernel,
454-
* sink_pin_binding and src_pin_binding shall be NULL.
454+
* input_pin_binding and output_pin_binding shall be NULL.
455455
*/
456-
char **sink_pin_binding;
457-
char **src_pin_binding;
456+
char **input_pin_binding;
457+
char **output_pin_binding;
458458

459-
struct ida src_queue_ida;
460-
struct ida sink_queue_ida;
459+
struct ida output_queue_ida;
460+
struct ida input_queue_ida;
461461

462462
void *private; /* core does not touch this */
463463
};

sound/soc/sof/topology.c

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -416,19 +416,19 @@ static const struct sof_topology_token led_tokens[] = {
416416
};
417417

418418
static const struct sof_topology_token comp_pin_tokens[] = {
419-
{SOF_TKN_COMP_NUM_SINK_PINS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
420-
offsetof(struct snd_sof_widget, num_sink_pins)},
421-
{SOF_TKN_COMP_NUM_SOURCE_PINS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
422-
offsetof(struct snd_sof_widget, num_source_pins)},
419+
{SOF_TKN_COMP_NUM_INPUT_PINS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
420+
offsetof(struct snd_sof_widget, num_input_pins)},
421+
{SOF_TKN_COMP_NUM_OUTPUT_PINS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
422+
offsetof(struct snd_sof_widget, num_output_pins)},
423423
};
424424

425-
static const struct sof_topology_token comp_sink_pin_binding_tokens[] = {
426-
{SOF_TKN_COMP_SINK_PIN_BINDING_WNAME, SND_SOC_TPLG_TUPLE_TYPE_STRING,
425+
static const struct sof_topology_token comp_input_pin_binding_tokens[] = {
426+
{SOF_TKN_COMP_INPUT_PIN_BINDING_WNAME, SND_SOC_TPLG_TUPLE_TYPE_STRING,
427427
get_token_string, 0},
428428
};
429429

430-
static const struct sof_topology_token comp_src_pin_binding_tokens[] = {
431-
{SOF_TKN_COMP_SRC_PIN_BINDING_WNAME, SND_SOC_TPLG_TUPLE_TYPE_STRING,
430+
static const struct sof_topology_token comp_output_pin_binding_tokens[] = {
431+
{SOF_TKN_COMP_OUTPUT_PIN_BINDING_WNAME, SND_SOC_TPLG_TUPLE_TYPE_STRING,
432432
get_token_string, 0},
433433
};
434434

@@ -1318,12 +1318,12 @@ static void sof_free_pin_binding(struct snd_sof_widget *swidget,
13181318
u32 num_pins;
13191319
int i;
13201320

1321-
if (pin_type == SOF_PIN_TYPE_SINK) {
1322-
pin_binding = swidget->sink_pin_binding;
1323-
num_pins = swidget->num_sink_pins;
1321+
if (pin_type == SOF_PIN_TYPE_INPUT) {
1322+
pin_binding = swidget->input_pin_binding;
1323+
num_pins = swidget->num_input_pins;
13241324
} else {
1325-
pin_binding = swidget->src_pin_binding;
1326-
num_pins = swidget->num_source_pins;
1325+
pin_binding = swidget->output_pin_binding;
1326+
num_pins = swidget->num_output_pins;
13271327
}
13281328

13291329
if (pin_binding) {
@@ -1345,14 +1345,14 @@ static int sof_parse_pin_binding(struct snd_sof_widget *swidget,
13451345
int ret;
13461346
int i;
13471347

1348-
if (pin_type == SOF_PIN_TYPE_SINK) {
1349-
num_pins = swidget->num_sink_pins;
1350-
pin_binding_token = comp_sink_pin_binding_tokens;
1351-
token_count = ARRAY_SIZE(comp_sink_pin_binding_tokens);
1348+
if (pin_type == SOF_PIN_TYPE_INPUT) {
1349+
num_pins = swidget->num_input_pins;
1350+
pin_binding_token = comp_input_pin_binding_tokens;
1351+
token_count = ARRAY_SIZE(comp_input_pin_binding_tokens);
13521352
} else {
1353-
num_pins = swidget->num_source_pins;
1354-
pin_binding_token = comp_src_pin_binding_tokens;
1355-
token_count = ARRAY_SIZE(comp_src_pin_binding_tokens);
1353+
num_pins = swidget->num_output_pins;
1354+
pin_binding_token = comp_output_pin_binding_tokens;
1355+
token_count = ARRAY_SIZE(comp_output_pin_binding_tokens);
13561356
}
13571357

13581358
memset(pin_binding, 0, SOF_WIDGET_MAX_NUM_PINS * sizeof(char *));
@@ -1369,10 +1369,10 @@ static int sof_parse_pin_binding(struct snd_sof_widget *swidget,
13691369
ret = -ENOMEM;
13701370
goto err;
13711371
}
1372-
if (pin_type == SOF_PIN_TYPE_SINK)
1373-
swidget->sink_pin_binding = pb;
1372+
if (pin_type == SOF_PIN_TYPE_INPUT)
1373+
swidget->input_pin_binding = pb;
13741374
else
1375-
swidget->src_pin_binding = pb;
1375+
swidget->output_pin_binding = pb;
13761376
}
13771377

13781378
return 0;
@@ -1411,8 +1411,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
14111411
swidget->private = NULL;
14121412
mutex_init(&swidget->setup_mutex);
14131413

1414-
ida_init(&swidget->src_queue_ida);
1415-
ida_init(&swidget->sink_queue_ida);
1414+
ida_init(&swidget->output_queue_ida);
1415+
ida_init(&swidget->input_queue_ida);
14161416

14171417
ret = sof_parse_tokens(scomp, swidget, comp_pin_tokens,
14181418
ARRAY_SIZE(comp_pin_tokens), priv->array,
@@ -1423,29 +1423,29 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
14231423
goto widget_free;
14241424
}
14251425

1426-
if (swidget->num_sink_pins > SOF_WIDGET_MAX_NUM_PINS ||
1427-
swidget->num_source_pins > SOF_WIDGET_MAX_NUM_PINS) {
1428-
dev_err(scomp->dev, "invalid pins for %s: [sink: %d, src: %d]\n",
1429-
swidget->widget->name, swidget->num_sink_pins, swidget->num_source_pins);
1426+
if (swidget->num_input_pins > SOF_WIDGET_MAX_NUM_PINS ||
1427+
swidget->num_output_pins > SOF_WIDGET_MAX_NUM_PINS) {
1428+
dev_err(scomp->dev, "invalid pins for %s: [input: %d, output: %d]\n",
1429+
swidget->widget->name, swidget->num_input_pins, swidget->num_output_pins);
14301430
ret = -EINVAL;
14311431
goto widget_free;
14321432
}
14331433

1434-
if (swidget->num_sink_pins > 1) {
1435-
ret = sof_parse_pin_binding(swidget, priv, SOF_PIN_TYPE_SINK);
1434+
if (swidget->num_input_pins > 1) {
1435+
ret = sof_parse_pin_binding(swidget, priv, SOF_PIN_TYPE_INPUT);
14361436
/* on parsing error, pin binding is not allocated, nothing to free. */
14371437
if (ret < 0) {
1438-
dev_err(scomp->dev, "failed to parse sink pin binding for %s\n",
1438+
dev_err(scomp->dev, "failed to parse input pin binding for %s\n",
14391439
w->name);
14401440
goto widget_free;
14411441
}
14421442
}
14431443

1444-
if (swidget->num_source_pins > 1) {
1445-
ret = sof_parse_pin_binding(swidget, priv, SOF_PIN_TYPE_SOURCE);
1444+
if (swidget->num_output_pins > 1) {
1445+
ret = sof_parse_pin_binding(swidget, priv, SOF_PIN_TYPE_OUTPUT);
14461446
/* on parsing error, pin binding is not allocated, nothing to free. */
14471447
if (ret < 0) {
1448-
dev_err(scomp->dev, "failed to parse source pin binding for %s\n",
1448+
dev_err(scomp->dev, "failed to parse output pin binding for %s\n",
14491449
w->name);
14501450
goto widget_free;
14511451
}
@@ -1454,7 +1454,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
14541454
dev_dbg(scomp->dev,
14551455
"tplg: widget %d (%s) is ready [type: %d, pipe: %d, pins: %d / %d, stream: %s]\n",
14561456
swidget->comp_id, w->name, swidget->id, index,
1457-
swidget->num_sink_pins, swidget->num_source_pins,
1457+
swidget->num_input_pins, swidget->num_output_pins,
14581458
strnlen(w->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0 ? w->sname : "none");
14591459

14601460
widget_ops = tplg_ops ? tplg_ops->widget : NULL;
@@ -1675,11 +1675,11 @@ static int sof_widget_unload(struct snd_soc_component *scomp,
16751675
if (widget_ops && widget_ops[swidget->id].ipc_free)
16761676
widget_ops[swidget->id].ipc_free(swidget);
16771677

1678-
ida_destroy(&swidget->src_queue_ida);
1679-
ida_destroy(&swidget->sink_queue_ida);
1678+
ida_destroy(&swidget->output_queue_ida);
1679+
ida_destroy(&swidget->input_queue_ida);
16801680

1681-
sof_free_pin_binding(swidget, SOF_PIN_TYPE_SINK);
1682-
sof_free_pin_binding(swidget, SOF_PIN_TYPE_SOURCE);
1681+
sof_free_pin_binding(swidget, SOF_PIN_TYPE_INPUT);
1682+
sof_free_pin_binding(swidget, SOF_PIN_TYPE_OUTPUT);
16831683

16841684
kfree(swidget->tuples);
16851685

0 commit comments

Comments
 (0)