Skip to content

Commit 132e098

Browse files
committed
ASoC: qcom: audioreach: cleanup and calibration
Merge series from srinivas.kandagatla@oss.qualcomm.com: Sorry to resend this series once again, as some of the patches seems to be dropped/rejected by email client from previous send. This patchset: - cleans up some of the audioreach tokens which are unused - adds missing documentation - add support for static calibration support which is required for ECNS an speaker protection support. Tested this with Single Mic ECNS on SM8450 platform.
2 parents 9963b1f + da9881d commit 132e098

4 files changed

Lines changed: 86 additions & 20 deletions

File tree

include/uapi/sound/snd_ar_tokens.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#ifndef __SND_AR_TOKENS_H__
44
#define __SND_AR_TOKENS_H__
55

6+
#include <linux/types.h>
7+
68
#define APM_SUB_GRAPH_PERF_MODE_LOW_POWER 0x1
79
#define APM_SUB_GRAPH_PERF_MODE_LOW_LATENCY 0x2
810

@@ -118,6 +120,12 @@ enum ar_event_types {
118120
* LPAIF_WSA = 2,
119121
* LPAIF_VA = 3,
120122
* LPAIF_AXI = 4
123+
* Possible values for MI2S
124+
* I2S_INTF_TYPE_PRIMARY = 0,
125+
* I2S_INTF_TYPE_SECONDARY = 1,
126+
* I2S_INTF_TYPE_TERTIARY = 2,
127+
* I2S_INTF_TYPE_QUATERNARY = 3,
128+
* I2S_INTF_TYPE_QUINARY = 4,
121129
*
122130
* %AR_TKN_U32_MODULE_FMT_INTERLEAVE: PCM Interleaving
123131
* PCM_INTERLEAVED = 1,
@@ -184,8 +192,8 @@ enum ar_event_types {
184192
#define AR_TKN_U32_MODULE_INSTANCE_ID 201
185193
#define AR_TKN_U32_MODULE_MAX_IP_PORTS 202
186194
#define AR_TKN_U32_MODULE_MAX_OP_PORTS 203
187-
#define AR_TKN_U32_MODULE_IN_PORTS 204
188-
#define AR_TKN_U32_MODULE_OUT_PORTS 205
195+
#define AR_TKN_U32_MODULE_IN_PORTS 204 /* deprecated */
196+
#define AR_TKN_U32_MODULE_OUT_PORTS 205 /* deprecated */
189197
#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID 206
190198
#define AR_TKN_U32_MODULE_DST_IN_PORT_ID 207
191199
#define AR_TKN_U32_MODULE_SRC_INSTANCE_ID 208
@@ -232,4 +240,12 @@ enum ar_event_types {
232240
#define AR_TKN_U32_MODULE_LOG_TAP_POINT_ID 260
233241
#define AR_TKN_U32_MODULE_LOG_MODE 261
234242

243+
#define SND_SOC_AR_TPLG_MODULE_CFG_TYPE 0x01001006
244+
struct audioreach_module_priv_data {
245+
__le32 size; /* size in bytes of the array, including all elements */
246+
__le32 type; /* SND_SOC_AR_TPLG_MODULE_CFG_TYPE */
247+
__le32 priv[2]; /* Private data for future expansion */
248+
__le32 data[0]; /* config data */
249+
};
250+
235251
#endif /* __SND_AR_TOKENS_H__ */

sound/soc/qcom/qdsp6/audioreach.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,30 @@ static int audioreach_gapless_set_media_format(struct q6apm_graph *graph,
811811
EARLY_EOS_DELAY_MS);
812812
}
813813

814+
static int audioreach_set_module_config(struct q6apm_graph *graph,
815+
struct audioreach_module *module,
816+
struct audioreach_module_config *cfg)
817+
{
818+
int payload_size = module->data->size;
819+
struct gpr_pkt *pkt;
820+
int rc;
821+
void *p;
822+
823+
pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
824+
if (IS_ERR(pkt))
825+
return PTR_ERR(pkt);
826+
827+
p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
828+
829+
memcpy(p, module->data->data, payload_size);
830+
831+
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
832+
833+
kfree(pkt);
834+
835+
return rc;
836+
}
837+
814838
static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
815839
struct audioreach_module *module,
816840
struct audioreach_module_config *cfg)
@@ -1247,6 +1271,9 @@ int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_mod
12471271
case MODULE_ID_DISPLAY_PORT_SINK:
12481272
rc = audioreach_display_port_set_media_format(graph, module, cfg);
12491273
break;
1274+
case MODULE_ID_SMECNS_V2:
1275+
rc = audioreach_set_module_config(graph, module, cfg);
1276+
break;
12501277
case MODULE_ID_I2S_SOURCE:
12511278
case MODULE_ID_I2S_SINK:
12521279
rc = audioreach_i2s_set_media_format(graph, module, cfg);

sound/soc/qcom/qdsp6/audioreach.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define __AUDIOREACH_H__
55
#include <linux/types.h>
66
#include <linux/soc/qcom/apr.h>
7+
#include <uapi/sound/snd_ar_tokens.h>
78
#include <sound/soc.h>
89
struct q6apm;
910
struct q6apm_graph;
@@ -17,15 +18,16 @@ struct q6apm_graph;
1718
#define MODULE_ID_PCM_DEC 0x07001005
1819
#define MODULE_ID_PLACEHOLDER_ENCODER 0x07001008
1920
#define MODULE_ID_PLACEHOLDER_DECODER 0x07001009
20-
#define MODULE_ID_SAL 0x07001010
21-
#define MODULE_ID_MFC 0x07001015
22-
#define MODULE_ID_CODEC_DMA_SINK 0x07001023
23-
#define MODULE_ID_CODEC_DMA_SOURCE 0x07001024
2421
#define MODULE_ID_I2S_SINK 0x0700100A
2522
#define MODULE_ID_I2S_SOURCE 0x0700100B
23+
#define MODULE_ID_SAL 0x07001010
24+
#define MODULE_ID_MFC 0x07001015
2625
#define MODULE_ID_DATA_LOGGING 0x0700101A
2726
#define MODULE_ID_AAC_DEC 0x0700101F
27+
#define MODULE_ID_CODEC_DMA_SINK 0x07001023
28+
#define MODULE_ID_CODEC_DMA_SOURCE 0x07001024
2829
#define MODULE_ID_FLAC_DEC 0x0700102F
30+
#define MODULE_ID_SMECNS_V2 0x07001031
2931
#define MODULE_ID_MP3_DECODE 0x0700103B
3032
#define MODULE_ID_GAPLESS 0x0700104D
3133
#define MODULE_ID_DISPLAY_PORT_SINK 0x07001069
@@ -461,8 +463,8 @@ struct param_id_i2s_intf_cfg {
461463
} __packed;
462464

463465
#define I2S_INTF_TYPE_PRIMARY 0
464-
#define I2S_INTF_TYPE_SECOINDARY 1
465-
#define I2S_INTF_TYPE_TERTINARY 2
466+
#define I2S_INTF_TYPE_SECONDARY 1
467+
#define I2S_INTF_TYPE_TERTIARY 2
466468
#define I2S_INTF_TYPE_QUATERNARY 3
467469
#define I2S_INTF_TYPE_QUINARY 4
468470
#define I2S_SD0 1
@@ -707,9 +709,6 @@ struct audioreach_module {
707709
uint32_t max_ip_port;
708710
uint32_t max_op_port;
709711

710-
uint32_t in_port;
711-
uint32_t out_port;
712-
713712
uint32_t num_connections;
714713
/* Connections */
715714
uint32_t src_mod_inst_id;
@@ -745,6 +744,7 @@ struct audioreach_module {
745744
struct list_head node;
746745
struct audioreach_container *container;
747746
struct snd_soc_dapm_widget *widget;
747+
struct audioreach_module_priv_data *data;
748748
};
749749

750750
struct audioreach_module_config {

sound/soc/qcom/qdsp6/topology.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,34 @@ static struct snd_soc_tplg_vendor_array *audioreach_get_module_array(
305305
return NULL;
306306
}
307307

308+
static struct audioreach_module_priv_data *audioreach_get_module_priv_data(
309+
struct snd_soc_tplg_private *private)
310+
{
311+
int sz;
312+
313+
for (sz = 0; sz < le32_to_cpu(private->size); ) {
314+
struct snd_soc_tplg_vendor_array *mod_array;
315+
316+
mod_array = (struct snd_soc_tplg_vendor_array *)((u8 *)private->array + sz);
317+
if (mod_array->type == SND_SOC_AR_TPLG_MODULE_CFG_TYPE) {
318+
struct audioreach_module_priv_data *pdata;
319+
320+
pdata = kzalloc(struct_size(pdata, data, le32_to_cpu(mod_array->size)),
321+
GFP_KERNEL);
322+
if (!pdata)
323+
return ERR_PTR(-ENOMEM);
324+
325+
memcpy(pdata, ((u8 *)private->data + sz), struct_size(pdata, data,
326+
le32_to_cpu(mod_array->size)));
327+
return pdata;
328+
}
329+
330+
sz = sz + le32_to_cpu(mod_array->size);
331+
}
332+
333+
return NULL;
334+
}
335+
308336
static struct audioreach_sub_graph *audioreach_parse_sg_tokens(struct q6apm *apm,
309337
struct snd_soc_tplg_private *private)
310338
{
@@ -412,7 +440,7 @@ static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *ap
412440
struct snd_soc_tplg_private *private,
413441
struct snd_soc_dapm_widget *w)
414442
{
415-
uint32_t max_ip_port = 0, max_op_port = 0, in_port = 0, out_port = 0;
443+
uint32_t max_ip_port = 0, max_op_port = 0;
416444
uint32_t src_mod_op_port_id[AR_MAX_MOD_LINKS] = { 0, };
417445
uint32_t dst_mod_inst_id[AR_MAX_MOD_LINKS] = { 0, };
418446
uint32_t dst_mod_ip_port_id[AR_MAX_MOD_LINKS] = { 0, };
@@ -455,12 +483,6 @@ static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *ap
455483
case AR_TKN_U32_MODULE_MAX_OP_PORTS:
456484
max_op_port = le32_to_cpu(mod_elem->value);
457485
break;
458-
case AR_TKN_U32_MODULE_IN_PORTS:
459-
in_port = le32_to_cpu(mod_elem->value);
460-
break;
461-
case AR_TKN_U32_MODULE_OUT_PORTS:
462-
out_port = le32_to_cpu(mod_elem->value);
463-
break;
464486
case AR_TKN_U32_MODULE_SRC_INSTANCE_ID:
465487
src_mod_inst_id = le32_to_cpu(mod_elem->value);
466488
break;
@@ -550,8 +572,6 @@ static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *ap
550572
mod->module_id = module_id;
551573
mod->max_ip_port = max_ip_port;
552574
mod->max_op_port = max_op_port;
553-
mod->in_port = in_port;
554-
mod->out_port = out_port;
555575
mod->src_mod_inst_id = src_mod_inst_id;
556576
for (pn = 0; pn < mod->max_op_port; pn++) {
557577
if (src_mod_op_port_id[pn] && dst_mod_inst_id[pn] &&
@@ -590,6 +610,8 @@ static int audioreach_widget_load_module_common(struct snd_soc_component *compon
590610
if (IS_ERR(mod))
591611
return PTR_ERR(mod);
592612

613+
mod->data = audioreach_get_module_priv_data(&tplg_w->priv);
614+
593615
dobj = &w->dobj;
594616
dobj->private = mod;
595617

@@ -947,6 +969,7 @@ static int audioreach_widget_unload(struct snd_soc_component *scomp,
947969
cont->num_modules--;
948970

949971
list_del(&mod->node);
972+
kfree(mod->data);
950973
kfree(mod);
951974
/* Graph Info has N sub-graphs, sub-graph has N containers, Container has N Modules */
952975
if (list_empty(&cont->modules_list)) { /* if no modules in the container then remove it */

0 commit comments

Comments
 (0)