Repository navigation
Expand file tree
/
Copy pathpcm.c
More file actions
66 lines (55 loc) · 1.79 KB
/
Copy pathpcm.c
File metadata and controls
66 lines (55 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2023 Intel Corporation. All rights reserved.
//
// Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
/* FE DAI or PCM parser */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <errno.h>
#include <string.h>
#include <ipc/topology.h>
#include <sof/list.h>
#include <sof/ipc/topology.h>
#include <kernel/header.h>
#include <tplg_parser/topology.h>
/* parse and save the PCM information */
int tplg_parse_pcm(struct tplg_context *ctx, struct list_item *widget_list,
struct list_item *pcm_list)
{
struct tplg_pcm_info *pcm_info;
struct snd_soc_tplg_pcm *pcm;
struct list_item *item;
pcm_info = calloc(sizeof(struct tplg_pcm_info), 1);
if (!pcm_info)
return -ENOMEM;
pcm = tplg_get_pcm(ctx);
pcm_info->name = strdup(pcm->pcm_name);
if (!pcm_info->name) {
free(pcm_info);
return -ENOMEM;
}
pcm_info->id = pcm->pcm_id;
/* look up from the widget list and populate the PCM info */
list_for_item(item, widget_list) {
struct tplg_comp_info *comp_info = container_of(item, struct tplg_comp_info, item);
if (!strcmp(pcm->caps[0].name, comp_info->stream_name) &&
(comp_info->type == SND_SOC_TPLG_DAPM_AIF_IN ||
comp_info->type == SND_SOC_TPLG_DAPM_AIF_OUT)) {
pcm_info->playback_host = comp_info;
tplg_debug("PCM: '%s' ID: %d Host name: %s\n", pcm_info->name,
pcm_info->id, comp_info->name);
}
if (!strcmp(pcm->caps[1].name, comp_info->stream_name) &&
(comp_info->type == SND_SOC_TPLG_DAPM_AIF_IN ||
comp_info->type == SND_SOC_TPLG_DAPM_AIF_OUT)) {
pcm_info->capture_host = comp_info;
tplg_debug("PCM: '%s' ID: %d Host name: %s\n", pcm_info->name,
pcm_info->id, comp_info->name);
}
}
list_item_append(&pcm_info->item, pcm_list);
return 0;
}