mbox series

[v3,00/20] ASoC: qcom: Add AudioReach support

Message ID 20210803125411.28066-1-srinivas.kandagatla@linaro.org (mailing list archive)
Headers show
Series ASoC: qcom: Add AudioReach support | expand

Message

Srinivas Kandagatla Aug. 3, 2021, 12:53 p.m. UTC
This patchset adds ASoC driver support to configure signal processing
framework ("AudioReach") which is integral part of Qualcomm next
generation audio SDK and will be deployed on upcoming Qualcomm chipsets.
It makes use of ASoC Topology to load graphs on to the DSP which is then
managed by APM (Audio Processing Manager) service to prepare/start/stop.

Here is simpified high-level block diagram of AudioReach:

 ___________________________________________________________
|                 CPU (Application Processor)               |
|  +---------+          +---------+         +---------+     |
|  |  q6apm  |          |  q6apm  |         | q6apm   |     |
|  |   dais  | <------> |         | <-----> | bedais  |     |
|  +---------+          +---------+         +---------+     |
|                            ^  ^                           |
|                            |  |           +---------+     |
|  +---------+               v  +---------->|topology |     |
|  | q6prm   |          +---------+         |         |     |
|  |         |<-------->|   GPR   |         +---------+     |
|  +---------+          +---------+                         |
|                            ^                              |
|____________________________|______________________________|
                             |  
                             | RPMSG (IPC over GLINK)              
 ____________________________|______________________________
|                            |                              |
|    +-----------------------+                              |
|    |                       |                              |
|    v                       v              q6 (Audio DSP)  |
|+-----+    +----------------------------------+            |
|| PRM |    | APM (Audio Processing Manager)   |            |
|+-----+    |  . Graph Management              |            |  
|           |  . Command Handing               |            |  
|           |  . Event Management              |            |  
|           |  ...                             |            |  
|           +----------------------------------+            |  
|                            ^                              |
|____________________________|______________________________|
                             |  
                             |   LPASS AIF
 ____________________________|______________________________
|                            |            Audio I/O         |
|                            v                              |
|   +--------------------------------------------------+    |
|    |                Audio devices                     |   |
|    | CODEC | HDMI-TX | PCM  | SLIMBUS | I2S |MI2S |...|   |
|    |                                                  |   |
|    +--------------------------------------------------+   |
|___________________________________________________________|

AudioReach has constructs of sub-graph, container and modules.
Each sub-graph can have N containers and each Container can have N Modules
and connections between them can be linear or non-linear.
An audio function can be realized with one or many connected
sub-graphs. There are also control/event paths between modules that can
be wired up while building graph to achieve various control mechanism
between modules. These concepts of Sub-Graph, Containers and Modules
are represented in ASoC topology.

Here is simple I2S graph with a Write Shared Memory and a
Volume control module within a single Subgraph (1) with one Container (1)
and 5 modules.

  ____________________________________________________________
 |                        Sub-Graph [1]                       |
 |  _______________________________________________________   |
 | |                       Container [1]                   |  |
 | | [WR_SH] -> [PCM DEC] -> [PCM CONV] -> [VOL]-> [I2S-EP]|  |
 | |_______________________________________________________|  |
 |____________________________________________________________|

For now this graph is split into two subgraphs to achieve dpcm like below:
 ________________________________________________    _________________
|                Sub-Graph [1]                   |  |  Sub-Graph [2]  |
|  ____________________________________________  |  |  _____________  |
| |              Container [1]                 | |  | |Container [2]| |
| | [WR_SH] -> [PCM DEC] -> [PCM CONV] -> [VOL]| |  | |   [I2S-EP]  | |
| |____________________________________________| |  | |_____________| |
|________________________________________________|  |_________________|

                                                      _________________
                                                    |  Sub-Graph [3]  |
                                                    |  _____________  |
                                                    | |Container [3]| |
                                                    | |  [DMA-EP]   | |
                                                    | |_____________| |
                                                    |_________________|


This patchset adds very minimal support for AudioReach which includes
supporting sub-graphs containing CODEC DMA ports and simple PCM
Decoder/Encoder and Logger Modules. Additional capabilities will
be built over time to expose features offered by AudioReach. 

This patchset is Tested on SM8250 SoC based Qualcomm Robotics Platform RB5
and SM9250 MTP with WSA881X Smart Speaker Amplifiers, DMICs connected via
VA Macro and WCD938x Codec connected via TX and RX Macro and HDMI audio
via I2S.

First 10 Patches are mostly reorganization existing Old QDSP Audio
Framework code and bindings so that we could reuse them on AudioReach.

ASoC topology graphs for DragonBoard RB5 and SM8250 MTP are available at 
https://git.linaro.org/people/srinivas.kandagatla/audioreach-topology.git/

Thanks,
srini

Changes since v2:
- seperated dsp lpass ip specific bindings out of dsp bindings
- seperated audio ports and clocks code out of Q6AFE
- fixed various cppcheck warnings.
- Reuse existing code and most of the hardware specific bits
 from old drivers
- added i2s module support
- Addressed most of the comments from Pierre.
- converted most of the existing bindings to yaml format.

Srinivas Kandagatla (20):
  soc: dt-bindings: qcom: apr: convert to yaml
  soc: qcom: apr: make code more reuseable
  soc: dt-bindings: qcom: add gpr bindings
  soc: qcom: apr: Add GPR support
  ASoC: dt-bindings: replace q6afe bindings with q6dsp-audio-ports
  ASoC: dt-bindings: replace q6afe-clk with q6dsp audio clk bindings
  ASoC: dt-bindings: replace q6asm with q6dsp audio stream bindings
  ASoC: qdsp6: q6afe-dai: move lpass audio ports to common file
  ASoC: qdsp6: q6afe-clocks: move audio-clocks to common file
  ASoC: dt-bindings: q6dsp: add q6apm-dai compatible
  ASoC: dt-bindings: q6dsp: add q6apm-bedai compatible
  ASoC: dt-bindings: q6dsp-clocks: add q6prm clocks compatible
  ASoC: qdsp6: audioreach: add basic pkt alloc support
  ASoC: qdsp6: audioreach: add q6apm support
  ASoC: qdsp6: audioreach: add module configuration command helpers
  ASoC: qdsp6: audioreach: add topology support
  ASoC: qdsp6: audioreach: add q6apm-dai support
  ASoC: qdsp6: audioreach: add bedai support
  ASoC: qdsp6: audioreach: add q6prm support
  ASoC: qdsp6: audioreach: add support for q6prm-clocks

 .../devicetree/bindings/soc/qcom/qcom,apr.txt |  134 --
 .../bindings/soc/qcom/qcom,apr.yaml           |  209 +++
 .../devicetree/bindings/sound/qcom,q6afe.txt  |  201 ---
 .../devicetree/bindings/sound/qcom,q6asm.txt  |   70 -
 .../sound/qcom,q6dsp-audio-clocks.yaml        |   74 ++
 .../sound/qcom,q6dsp-audio-ports.yaml         |  202 +++
 .../sound/qcom,q6dsp-audio-stream.yaml        |  118 ++
 drivers/soc/qcom/Kconfig                      |    8 +
 drivers/soc/qcom/apr.c                        |  286 +++-
 include/dt-bindings/soc/qcom,gpr.h            |   18 +
 include/dt-bindings/sound/qcom,q6afe.h        |  204 +--
 .../sound/qcom,q6dsp-audio-ports.h            |  208 +++
 include/linux/soc/qcom/apr.h                  |   70 +-
 include/uapi/sound/snd_ar_tokens.h            |  203 +++
 sound/soc/qcom/Kconfig                        |   26 +
 sound/soc/qcom/Makefile                       |    1 +
 sound/soc/qcom/qdsp6/Makefile                 |   19 +-
 sound/soc/qcom/qdsp6/audioreach.c             | 1166 +++++++++++++++++
 sound/soc/qcom/qdsp6/audioreach.h             |  690 ++++++++++
 sound/soc/qcom/qdsp6/q6afe-clocks.c           |  187 +--
 sound/soc/qcom/qdsp6/q6afe-dai.c              |  687 +---------
 sound/soc/qcom/qdsp6/q6apm-bedai.c            |  266 ++++
 sound/soc/qcom/qdsp6/q6apm-dai.c              |  504 +++++++
 sound/soc/qcom/qdsp6/q6apm.c                  |  919 +++++++++++++
 sound/soc/qcom/qdsp6/q6apm.h                  |  155 +++
 sound/soc/qcom/qdsp6/q6dsp-audio-clocks.c     |  185 +++
 sound/soc/qcom/qdsp6/q6dsp-audio-clocks.h     |   30 +
 sound/soc/qcom/qdsp6/q6dsp-audio-ports.c      |  625 +++++++++
 sound/soc/qcom/qdsp6/q6dsp-audio-ports.h      |   22 +
 sound/soc/qcom/qdsp6/q6prm-clocks.c           |   85 ++
 sound/soc/qcom/qdsp6/q6prm.c                  |  256 ++++
 sound/soc/qcom/qdsp6/q6prm.h                  |   78 ++
 sound/soc/qcom/qdsp6/topology.c               | 1114 ++++++++++++++++
 33 files changed, 7514 insertions(+), 1506 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,apr.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/qcom,q6afe.txt
 delete mode 100644 Documentation/devicetree/bindings/sound/qcom,q6asm.txt
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,q6dsp-audio-clocks.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,q6dsp-audio-ports.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,q6dsp-audio-stream.yaml
 create mode 100644 include/dt-bindings/soc/qcom,gpr.h
 create mode 100644 include/dt-bindings/sound/qcom,q6dsp-audio-ports.h
 create mode 100644 include/uapi/sound/snd_ar_tokens.h
 create mode 100644 sound/soc/qcom/qdsp6/audioreach.c
 create mode 100644 sound/soc/qcom/qdsp6/audioreach.h
 create mode 100644 sound/soc/qcom/qdsp6/q6apm-bedai.c
 create mode 100644 sound/soc/qcom/qdsp6/q6apm-dai.c
 create mode 100644 sound/soc/qcom/qdsp6/q6apm.c
 create mode 100644 sound/soc/qcom/qdsp6/q6apm.h
 create mode 100644 sound/soc/qcom/qdsp6/q6dsp-audio-clocks.c
 create mode 100644 sound/soc/qcom/qdsp6/q6dsp-audio-clocks.h
 create mode 100644 sound/soc/qcom/qdsp6/q6dsp-audio-ports.c
 create mode 100644 sound/soc/qcom/qdsp6/q6dsp-audio-ports.h
 create mode 100644 sound/soc/qcom/qdsp6/q6prm-clocks.c
 create mode 100644 sound/soc/qcom/qdsp6/q6prm.c
 create mode 100644 sound/soc/qcom/qdsp6/q6prm.h
 create mode 100644 sound/soc/qcom/qdsp6/topology.c

Comments

Pierre-Louis Bossart Aug. 3, 2021, 3 p.m. UTC | #1
There are quite a few cppcheck warnings due to unnecessary
initializations for loop variables, see suggested patch below.

And a number of renames that were missed.

cppcheck --platform=unix64 --force --max-configs=1024 --inconclusive
--enable=all --suppress=variableScope --suppress=shiftTooManyBitsSigned
--suppress=arithOperationsOnVoidPointer --suppress=bitwiseOnBoolean
sound/soc/qcom/qdsp6/


Checking sound/soc/qcom/qdsp6/audioreach.c ...
sound/soc/qcom/qdsp6/audioreach.c:248:32: style:inconclusive: Function
'audioreach_alloc_pkt' argument 1 names different: declaration
'pkt_size' definition 'payload_size'. [funcArgNamesDifferent]
void *audioreach_alloc_pkt(int payload_size, uint32_t opcode,
                               ^
sound/soc/qcom/qdsp6/audioreach.h:657:32: note: Function
'audioreach_alloc_pkt' argument 1 names different: declaration
'pkt_size' definition 'payload_size'.
void *audioreach_alloc_pkt(int pkt_size, uint32_t opcode, uint32_t token,
                               ^
sound/soc/qcom/qdsp6/audioreach.c:248:32: note: Function
'audioreach_alloc_pkt' argument 1 names different: declaration
'pkt_size' definition 'payload_size'.
void *audioreach_alloc_pkt(int payload_size, uint32_t opcode,
                               ^
sound/soc/qcom/qdsp6/audioreach.c:265:36: style:inconclusive: Function
'audioreach_alloc_cmd_pkt' argument 1 names different: declaration
'pkt_size' definition 'payload_size'. [funcArgNamesDifferent]
void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode,
                                   ^
sound/soc/qcom/qdsp6/audioreach.h:653:36: note: Function
'audioreach_alloc_cmd_pkt' argument 1 names different: declaration
'pkt_size' definition 'payload_size'.
void *audioreach_alloc_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t
token,
                                   ^
sound/soc/qcom/qdsp6/audioreach.c:265:36: note: Function
'audioreach_alloc_cmd_pkt' argument 1 names different: declaration
'pkt_size' definition 'payload_size'.
void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode,
                                   ^
sound/soc/qcom/qdsp6/q6apm.c:326:16: style:inconclusive: Function
'q6apm_map_memory_regions' argument 4 names different: declaration
'bufsz' definition 'period_sz'. [funcArgNamesDifferent]
        size_t period_sz, unsigned int periods)
               ^
sound/soc/qcom/qdsp6/q6apm.h:137:16: note: Function
'q6apm_map_memory_regions' argument 4 names different: declaration
'bufsz' definition 'period_sz'.
        size_t bufsz, unsigned int bufcnt);
               ^
sound/soc/qcom/qdsp6/q6apm.c:326:16: note: Function
'q6apm_map_memory_regions' argument 4 names different: declaration
'bufsz' definition 'period_sz'.
        size_t period_sz, unsigned int periods)
               ^
sound/soc/qcom/qdsp6/q6apm.c:326:40: style:inconclusive: Function
'q6apm_map_memory_regions' argument 5 names different: declaration
'bufcnt' definition 'periods'. [funcArgNamesDifferent]
        size_t period_sz, unsigned int periods)
                                       ^
sound/soc/qcom/qdsp6/q6apm.h:137:36: note: Function
'q6apm_map_memory_regions' argument 5 names different: declaration
'bufcnt' definition 'periods'.
        size_t bufsz, unsigned int bufcnt);
                                   ^
sound/soc/qcom/qdsp6/q6apm.c:326:40: note: Function
'q6apm_map_memory_regions' argument 5 names different: declaration
'bufcnt' definition 'periods'.
        size_t period_sz, unsigned int periods)
                                       ^
sound/soc/qcom/qdsp6/q6apm.c:471:35: style:inconclusive: Function
'q6apm_write_async' argument 5 names different: declaration 'flags'
definition 'wflags'. [funcArgNamesDifferent]
        uint32_t lsw_ts, uint32_t wflags)
                                  ^
sound/soc/qcom/qdsp6/q6apm.h:131:36: note: Function 'q6apm_write_async'
argument 5 names different: declaration 'flags' definition 'wflags'.
         uint32_t lsw_ts, uint32_t flags);
                                   ^
sound/soc/qcom/qdsp6/q6apm.c:471:35: note: Function 'q6apm_write_async'
argument 5 names different: declaration 'flags' definition 'wflags'.
        uint32_t lsw_ts, uint32_t wflags)
                                  ^

Checking sound/soc/qcom/qdsp6/q6prm.c ...
sound/soc/qcom/qdsp6/q6prm.c:158:63: style:inconclusive: Function
'q6prm_set_lpass_clock' argument 3 names different: declaration 'attri'
definition 'clk_attr'. [funcArgNamesDifferent]
int q6prm_set_lpass_clock(struct device *dev, int clk_id, int clk_attr,
                                                              ^
sound/soc/qcom/qdsp6/q6prm.h:72:63: note: Function
'q6prm_set_lpass_clock' argument 3 names different: declaration 'attri'
definition 'clk_attr'.
int q6prm_set_lpass_clock(struct device *dev, int clk_id, int attri,
                                                              ^
sound/soc/qcom/qdsp6/q6prm.c:158:63: note: Function
'q6prm_set_lpass_clock' argument 3 names different: declaration 'attri'
definition 'clk_attr'.
int q6prm_set_lpass_clock(struct device *dev, int clk_id, int clk_attr,
                                                              ^
Srinivas Kandagatla Aug. 3, 2021, 3:03 p.m. UTC | #2
Hi Pierre,
Thanks,

I did run cppcheck --enable=all  before sending this out,


On 03/08/2021 16:00, Pierre-Louis Bossart wrote:
> There are quite a few cppcheck warnings due to unnecessary
> initializations for loop variables, see suggested patch below.
> 
> And a number of renames that were missed.
> 
> cppcheck --platform=unix64 --force --max-configs=1024 --inconclusive
> --enable=all --suppress=variableScope --suppress=shiftTooManyBitsSigned
> --suppress=arithOperationsOnVoidPointer --suppress=bitwiseOnBoolean
> sound/soc/qcom/qdsp6/

I will try these ones and fix all the warnings before next spin!

--srini
> 
> 
> Checking sound/soc/qcom/qdsp6/audioreach.c ...
> sound/soc/qcom/qdsp6/audioreach.c:248:32: style:inconclusive: Function
> 'audioreach_alloc_pkt' argument 1 names different: declaration
> 'pkt_size' definition 'payload_size'. [funcArgNamesDifferent]
> void *audioreach_alloc_pkt(int payload_size, uint32_t opcode,
>                                 ^
> sound/soc/qcom/qdsp6/audioreach.h:657:32: note: Function
> 'audioreach_alloc_pkt' argument 1 names different: declaration
> 'pkt_size' definition 'payload_size'.
> void *audioreach_alloc_pkt(int pkt_size, uint32_t opcode, uint32_t token,
>                                 ^
> sound/soc/qcom/qdsp6/audioreach.c:248:32: note: Function
> 'audioreach_alloc_pkt' argument 1 names different: declaration
> 'pkt_size' definition 'payload_size'.
> void *audioreach_alloc_pkt(int payload_size, uint32_t opcode,
>                                 ^
> sound/soc/qcom/qdsp6/audioreach.c:265:36: style:inconclusive: Function
> 'audioreach_alloc_cmd_pkt' argument 1 names different: declaration
> 'pkt_size' definition 'payload_size'. [funcArgNamesDifferent]
> void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode,
>                                     ^
> sound/soc/qcom/qdsp6/audioreach.h:653:36: note: Function
> 'audioreach_alloc_cmd_pkt' argument 1 names different: declaration
> 'pkt_size' definition 'payload_size'.
> void *audioreach_alloc_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t
> token,
>                                     ^
> sound/soc/qcom/qdsp6/audioreach.c:265:36: note: Function
> 'audioreach_alloc_cmd_pkt' argument 1 names different: declaration
> 'pkt_size' definition 'payload_size'.
> void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode,
>                                     ^
> sound/soc/qcom/qdsp6/q6apm.c:326:16: style:inconclusive: Function
> 'q6apm_map_memory_regions' argument 4 names different: declaration
> 'bufsz' definition 'period_sz'. [funcArgNamesDifferent]
>          size_t period_sz, unsigned int periods)
>                 ^
> sound/soc/qcom/qdsp6/q6apm.h:137:16: note: Function
> 'q6apm_map_memory_regions' argument 4 names different: declaration
> 'bufsz' definition 'period_sz'.
>          size_t bufsz, unsigned int bufcnt);
>                 ^
> sound/soc/qcom/qdsp6/q6apm.c:326:16: note: Function
> 'q6apm_map_memory_regions' argument 4 names different: declaration
> 'bufsz' definition 'period_sz'.
>          size_t period_sz, unsigned int periods)
>                 ^
> sound/soc/qcom/qdsp6/q6apm.c:326:40: style:inconclusive: Function
> 'q6apm_map_memory_regions' argument 5 names different: declaration
> 'bufcnt' definition 'periods'. [funcArgNamesDifferent]
>          size_t period_sz, unsigned int periods)
>                                         ^
> sound/soc/qcom/qdsp6/q6apm.h:137:36: note: Function
> 'q6apm_map_memory_regions' argument 5 names different: declaration
> 'bufcnt' definition 'periods'.
>          size_t bufsz, unsigned int bufcnt);
>                                     ^
> sound/soc/qcom/qdsp6/q6apm.c:326:40: note: Function
> 'q6apm_map_memory_regions' argument 5 names different: declaration
> 'bufcnt' definition 'periods'.
>          size_t period_sz, unsigned int periods)
>                                         ^
> sound/soc/qcom/qdsp6/q6apm.c:471:35: style:inconclusive: Function
> 'q6apm_write_async' argument 5 names different: declaration 'flags'
> definition 'wflags'. [funcArgNamesDifferent]
>          uint32_t lsw_ts, uint32_t wflags)
>                                    ^
> sound/soc/qcom/qdsp6/q6apm.h:131:36: note: Function 'q6apm_write_async'
> argument 5 names different: declaration 'flags' definition 'wflags'.
>           uint32_t lsw_ts, uint32_t flags);
>                                     ^
> sound/soc/qcom/qdsp6/q6apm.c:471:35: note: Function 'q6apm_write_async'
> argument 5 names different: declaration 'flags' definition 'wflags'.
>          uint32_t lsw_ts, uint32_t wflags)
>                                    ^
> 
> Checking sound/soc/qcom/qdsp6/q6prm.c ...
> sound/soc/qcom/qdsp6/q6prm.c:158:63: style:inconclusive: Function
> 'q6prm_set_lpass_clock' argument 3 names different: declaration 'attri'
> definition 'clk_attr'. [funcArgNamesDifferent]
> int q6prm_set_lpass_clock(struct device *dev, int clk_id, int clk_attr,
>                                                                ^
> sound/soc/qcom/qdsp6/q6prm.h:72:63: note: Function
> 'q6prm_set_lpass_clock' argument 3 names different: declaration 'attri'
> definition 'clk_attr'.
> int q6prm_set_lpass_clock(struct device *dev, int clk_id, int attri,
>                                                                ^
> sound/soc/qcom/qdsp6/q6prm.c:158:63: note: Function
> 'q6prm_set_lpass_clock' argument 3 names different: declaration 'attri'
> definition 'clk_attr'.
> int q6prm_set_lpass_clock(struct device *dev, int clk_id, int clk_attr,
>                                                                ^
>