From c14bc204989903e11d8298dc2f609b214aee2abf Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 8 Apr 2019 13:14:58 +0200 Subject: [PATCH 1/2] topology: keyword-detect: get kpb configure data from ipc We design to use bytes kcontrol to send kpb configuration data via IPC from topology, here implement it. Signed-off-by: Keyon Jie --- tools/topology/m4/kpbm.m4 | 5 ++++- tools/topology/sof/pipe-kfbm-capture.m4 | 28 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/topology/m4/kpbm.m4 b/tools/topology/m4/kpbm.m4 index 182a270aba19..8a3694dbcf60 100644 --- a/tools/topology/m4/kpbm.m4 +++ b/tools/topology/m4/kpbm.m4 @@ -5,7 +5,7 @@ dnl Define macro for Key Phrase Buffer Manager(kpbm) widget dnl kpbm Name) define(`N_KPBM', `KPBM'$2`.'$1) -dnl W_KPBM(name, format, periods_sink, periods_source, pipeline_id) +dnl W_KPBM(name, format, periods_sink, periods_source, pipeline_id, kcontrols_list) define(`W_KPBM', `SectionVendorTuples."'N_KPBM($1, $5)`_tuples_w" {' ` tokens "sof_comp_tokens"' @@ -41,6 +41,9 @@ define(`W_KPBM', ` "'N_KPBM($1, $5)`_data_w"' ` "'N_KPBM($1, $5)`_data_str"' ` ]' +` bytes [' + $6 +` ]' `}') divert(0)dnl diff --git a/tools/topology/sof/pipe-kfbm-capture.m4 b/tools/topology/sof/pipe-kfbm-capture.m4 index 56bfcb64de1a..e763c8f0bc4d 100644 --- a/tools/topology/sof/pipe-kfbm-capture.m4 +++ b/tools/topology/sof/pipe-kfbm-capture.m4 @@ -12,11 +12,37 @@ include(`buffer.m4') include(`pcm.m4') include(`dai.m4') include(`kpbm.m4') +include(`mixercontrol.m4') +include(`bytecontrol.m4') include(`pipeline.m4') dnl Soun Trigger Stream Name) define(`N_STS', `Sound Trigger Capture '$1) +# +# Controls +# + +# kpbm initial parameters, aligned with struct sof_kpb_config +CONTROLBYTES_PRIV(KPB_priv, +` bytes "0x53,0x4f,0x46,0x00,0x00,0x00,0x00,0x00,' +` 0x18,0x00,0x00,0x00,0x00,0x10,0x00,0x03,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x80,0x3e,0x00,0x00,0x10,0x00,0x00,0x00"' +) + +# KPB Bytes control with max value of 255 +C_CONTROLBYTES(KPB, PIPELINE_ID, + CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), + CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), + , , , + CONTROLBYTES_MAX(, 304), + , + KPB_priv) + # # Components and Buffers # @@ -26,7 +52,7 @@ define(`N_STS', `Sound Trigger Capture '$1) W_PCM_CAPTURE(PCM_ID, Sound Trigger Capture, 0, 2, 2) # "KPBM" has 2 source and 2 sink periods -W_KPBM(0, PIPELINE_FORMAT, 2, 2, PIPELINE_ID) +W_KPBM(0, PIPELINE_FORMAT, 2, 2, PIPELINE_ID, LIST(` ', "KPB")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, From f73d1edf6cfe7f1f46ef68ed7b3e0743af4ec92a Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 21 Mar 2019 20:14:33 +0800 Subject: [PATCH 2/2] topology: keyword-detect: add bytes control for detector Add bytes control and initial value for detector component. Signed-off-by: Keyon Jie --- tools/topology/m4/detect.m4 | 11 ++++------- tools/topology/m4/detect_test_coef.m4 | 11 +++++++++++ tools/topology/sof/pipe-detect.m4 | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 tools/topology/m4/detect_test_coef.m4 diff --git a/tools/topology/m4/detect.m4 b/tools/topology/m4/detect.m4 index f79dbcd48122..3a7b8d3d61d6 100644 --- a/tools/topology/m4/detect.m4 +++ b/tools/topology/m4/detect.m4 @@ -5,7 +5,7 @@ dnl Define macro for generic detection widget dnl Detect name) define(`N_DETECT', `DETECT'PIPELINE_ID`.'$1) -dnl W_DETECT(name, format, periods_sink, periods_source, detect_type, stream_name, mixer_list, enum_list) +dnl W_DETECT(name, format, periods_sink, periods_source, detect_type, stream_name, kcontrols_list) define(`W_DETECT', `SectionVendorTuples."'N_DETECT($1)`_tuples_w" {' ` tokens "sof_comp_tokens"' @@ -44,12 +44,9 @@ define(`W_DETECT', ` "'N_DETECT($1)`_data_w"' ` "'N_DETECT($1)`_data_str"' ` ]' -` mixer [' - $7 -` ]' -` enum [' -` $8' -` ]' +` bytes [' + $7 +` ]' `}') divert(0)dnl diff --git a/tools/topology/m4/detect_test_coef.m4 b/tools/topology/m4/detect_test_coef.m4 new file mode 100644 index 000000000000..77f027c664b2 --- /dev/null +++ b/tools/topology/m4/detect_test_coef.m4 @@ -0,0 +1,11 @@ +# initial coe params for detector, aligned with struct sof_detect_test_config +CONTROLBYTES_PRIV(DETECTOR_priv, +` bytes "0x53,0x4f,0x46,0x00,0x00,0x00,0x00,0x00,' +` 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x03,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x20,0x00,0x00,0x00,0x05,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x80,0x02,0x00,0x00,' +` 0x03,0x00,0x00,0x80,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00"' +) diff --git a/tools/topology/sof/pipe-detect.m4 b/tools/topology/sof/pipe-detect.m4 index 947661b02142..e994577c1c4a 100644 --- a/tools/topology/sof/pipe-detect.m4 +++ b/tools/topology/sof/pipe-detect.m4 @@ -40,12 +40,25 @@ C_CONTROLBYTES(SELECTOR, PIPELINE_ID, CONTROLBYTES_MAX(, 304), , SELECTOR_priv) + +# Detector initial parameters for Intel KPD. +include(`detect_test_coef.m4') + +# Detector Bytes control with max value of 255 +C_CONTROLBYTES(DETECTOR, PIPELINE_ID, + CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), + CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), + , , , + CONTROLBYTES_MAX(, 304), + , + DETECTOR_priv) + # # Components and Buffers # # "Detect 0" has 2 sink period and 0 source periods -W_DETECT(0, PIPELINE_FORMAT, 0, 2, KEYWORD, N_STS(PCM_ID)) +W_DETECT(0, PIPELINE_FORMAT, 0, 2, KEYWORD, N_STS(PCM_ID), LIST(` ', "DETECTOR")) W_SELECTOR(0, PIPELINE_FORMAT, 2, 2, LIST(` ', "SELECTOR"))