Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

+86 -20
+18 -2
include/uapi/sound/snd_ar_tokens.h
··· 3 3 #ifndef __SND_AR_TOKENS_H__ 4 4 #define __SND_AR_TOKENS_H__ 5 5 6 + #include <linux/types.h> 7 + 6 8 #define APM_SUB_GRAPH_PERF_MODE_LOW_POWER 0x1 7 9 #define APM_SUB_GRAPH_PERF_MODE_LOW_LATENCY 0x2 8 10 ··· 120 118 * LPAIF_WSA = 2, 121 119 * LPAIF_VA = 3, 122 120 * LPAIF_AXI = 4 121 + * Possible values for MI2S 122 + * I2S_INTF_TYPE_PRIMARY = 0, 123 + * I2S_INTF_TYPE_SECONDARY = 1, 124 + * I2S_INTF_TYPE_TERTIARY = 2, 125 + * I2S_INTF_TYPE_QUATERNARY = 3, 126 + * I2S_INTF_TYPE_QUINARY = 4, 123 127 * 124 128 * %AR_TKN_U32_MODULE_FMT_INTERLEAVE: PCM Interleaving 125 129 * PCM_INTERLEAVED = 1, ··· 192 184 #define AR_TKN_U32_MODULE_INSTANCE_ID 201 193 185 #define AR_TKN_U32_MODULE_MAX_IP_PORTS 202 194 186 #define AR_TKN_U32_MODULE_MAX_OP_PORTS 203 195 - #define AR_TKN_U32_MODULE_IN_PORTS 204 196 - #define AR_TKN_U32_MODULE_OUT_PORTS 205 187 + #define AR_TKN_U32_MODULE_IN_PORTS 204 /* deprecated */ 188 + #define AR_TKN_U32_MODULE_OUT_PORTS 205 /* deprecated */ 197 189 #define AR_TKN_U32_MODULE_SRC_OP_PORT_ID 206 198 190 #define AR_TKN_U32_MODULE_DST_IN_PORT_ID 207 199 191 #define AR_TKN_U32_MODULE_SRC_INSTANCE_ID 208 ··· 239 231 #define AR_TKN_U32_MODULE_LOG_CODE 259 240 232 #define AR_TKN_U32_MODULE_LOG_TAP_POINT_ID 260 241 233 #define AR_TKN_U32_MODULE_LOG_MODE 261 234 + 235 + #define SND_SOC_AR_TPLG_MODULE_CFG_TYPE 0x01001006 236 + struct audioreach_module_priv_data { 237 + __le32 size; /* size in bytes of the array, including all elements */ 238 + __le32 type; /* SND_SOC_AR_TPLG_MODULE_CFG_TYPE */ 239 + __le32 priv[2]; /* Private data for future expansion */ 240 + __le32 data[0]; /* config data */ 241 + }; 242 242 243 243 #endif /* __SND_AR_TOKENS_H__ */
+27
sound/soc/qcom/qdsp6/audioreach.c
··· 811 811 EARLY_EOS_DELAY_MS); 812 812 } 813 813 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 + 814 838 static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, 815 839 struct audioreach_module *module, 816 840 struct audioreach_module_config *cfg) ··· 1270 1246 break; 1271 1247 case MODULE_ID_DISPLAY_PORT_SINK: 1272 1248 rc = audioreach_display_port_set_media_format(graph, module, cfg); 1249 + break; 1250 + case MODULE_ID_SMECNS_V2: 1251 + rc = audioreach_set_module_config(graph, module, cfg); 1273 1252 break; 1274 1253 case MODULE_ID_I2S_SOURCE: 1275 1254 case MODULE_ID_I2S_SINK:
+9 -9
sound/soc/qcom/qdsp6/audioreach.h
··· 4 4 #define __AUDIOREACH_H__ 5 5 #include <linux/types.h> 6 6 #include <linux/soc/qcom/apr.h> 7 + #include <uapi/sound/snd_ar_tokens.h> 7 8 #include <sound/soc.h> 8 9 struct q6apm; 9 10 struct q6apm_graph; ··· 18 17 #define MODULE_ID_PCM_DEC 0x07001005 19 18 #define MODULE_ID_PLACEHOLDER_ENCODER 0x07001008 20 19 #define MODULE_ID_PLACEHOLDER_DECODER 0x07001009 21 - #define MODULE_ID_SAL 0x07001010 22 - #define MODULE_ID_MFC 0x07001015 23 - #define MODULE_ID_CODEC_DMA_SINK 0x07001023 24 - #define MODULE_ID_CODEC_DMA_SOURCE 0x07001024 25 20 #define MODULE_ID_I2S_SINK 0x0700100A 26 21 #define MODULE_ID_I2S_SOURCE 0x0700100B 22 + #define MODULE_ID_SAL 0x07001010 23 + #define MODULE_ID_MFC 0x07001015 27 24 #define MODULE_ID_DATA_LOGGING 0x0700101A 28 25 #define MODULE_ID_AAC_DEC 0x0700101F 26 + #define MODULE_ID_CODEC_DMA_SINK 0x07001023 27 + #define MODULE_ID_CODEC_DMA_SOURCE 0x07001024 29 28 #define MODULE_ID_FLAC_DEC 0x0700102F 29 + #define MODULE_ID_SMECNS_V2 0x07001031 30 30 #define MODULE_ID_MP3_DECODE 0x0700103B 31 31 #define MODULE_ID_GAPLESS 0x0700104D 32 32 #define MODULE_ID_DISPLAY_PORT_SINK 0x07001069 ··· 463 461 } __packed; 464 462 465 463 #define I2S_INTF_TYPE_PRIMARY 0 466 - #define I2S_INTF_TYPE_SECOINDARY 1 467 - #define I2S_INTF_TYPE_TERTINARY 2 464 + #define I2S_INTF_TYPE_SECONDARY 1 465 + #define I2S_INTF_TYPE_TERTIARY 2 468 466 #define I2S_INTF_TYPE_QUATERNARY 3 469 467 #define I2S_INTF_TYPE_QUINARY 4 470 468 #define I2S_SD0 1 ··· 709 707 uint32_t max_ip_port; 710 708 uint32_t max_op_port; 711 709 712 - uint32_t in_port; 713 - uint32_t out_port; 714 - 715 710 uint32_t num_connections; 716 711 /* Connections */ 717 712 uint32_t src_mod_inst_id; ··· 744 745 struct list_head node; 745 746 struct audioreach_container *container; 746 747 struct snd_soc_dapm_widget *widget; 748 + struct audioreach_module_priv_data *data; 747 749 }; 748 750 749 751 struct audioreach_module_config {
+32 -9
sound/soc/qcom/qdsp6/topology.c
··· 305 305 return NULL; 306 306 } 307 307 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 + 308 336 static struct audioreach_sub_graph *audioreach_parse_sg_tokens(struct q6apm *apm, 309 337 struct snd_soc_tplg_private *private) 310 338 { ··· 440 412 struct snd_soc_tplg_private *private, 441 413 struct snd_soc_dapm_widget *w) 442 414 { 443 - uint32_t max_ip_port = 0, max_op_port = 0, in_port = 0, out_port = 0; 415 + uint32_t max_ip_port = 0, max_op_port = 0; 444 416 uint32_t src_mod_op_port_id[AR_MAX_MOD_LINKS] = { 0, }; 445 417 uint32_t dst_mod_inst_id[AR_MAX_MOD_LINKS] = { 0, }; 446 418 uint32_t dst_mod_ip_port_id[AR_MAX_MOD_LINKS] = { 0, }; ··· 482 454 break; 483 455 case AR_TKN_U32_MODULE_MAX_OP_PORTS: 484 456 max_op_port = le32_to_cpu(mod_elem->value); 485 - break; 486 - case AR_TKN_U32_MODULE_IN_PORTS: 487 - in_port = le32_to_cpu(mod_elem->value); 488 - break; 489 - case AR_TKN_U32_MODULE_OUT_PORTS: 490 - out_port = le32_to_cpu(mod_elem->value); 491 457 break; 492 458 case AR_TKN_U32_MODULE_SRC_INSTANCE_ID: 493 459 src_mod_inst_id = le32_to_cpu(mod_elem->value); ··· 572 550 mod->module_id = module_id; 573 551 mod->max_ip_port = max_ip_port; 574 552 mod->max_op_port = max_op_port; 575 - mod->in_port = in_port; 576 - mod->out_port = out_port; 577 553 mod->src_mod_inst_id = src_mod_inst_id; 578 554 for (pn = 0; pn < mod->max_op_port; pn++) { 579 555 if (src_mod_op_port_id[pn] && dst_mod_inst_id[pn] && ··· 609 589 mod = audioreach_parse_common_tokens(apm, cont, &tplg_w->priv, w); 610 590 if (IS_ERR(mod)) 611 591 return PTR_ERR(mod); 592 + 593 + mod->data = audioreach_get_module_priv_data(&tplg_w->priv); 612 594 613 595 dobj = &w->dobj; 614 596 dobj->private = mod; ··· 969 947 cont->num_modules--; 970 948 971 949 list_del(&mod->node); 950 + kfree(mod->data); 972 951 kfree(mod); 973 952 /* Graph Info has N sub-graphs, sub-graph has N containers, Container has N Modules */ 974 953 if (list_empty(&cont->modules_list)) { /* if no modules in the container then remove it */