Skip to content

[SOF CODEC]how can i use sof/cadence decoder or encoder? #5381

Open

Description

@bawanqin1987

i wannna use cadence encoder and decoder,how can i open the cadence codec with my sof?

i check the source support,there are cadence codec supportting,
i now,use the pipe-passthrough-playback.m4 had already test the audio ok
so ,how can i open the cadence codec with my pipeline?

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Activity

  1. hlleng commented on Feb 17, 2022

    @hlleng
    Contributor
  2. bawanqin1987 commented on Feb 17, 2022

    @bawanqin1987
    Author

    Kernel: {zephyr}
    SOF: {1.5.0}
    Name of the topology file
    Topology: {pipe-passthrough-playback.m4}
    Name of the platform(s) on which the bug is observed.
    Platform: {CSK6} our new add ,more sames to nxp

  3. dbaluta commented on Feb 17, 2022

    @dbaluta
    Collaborator

    @bawanqin1987 Have a look at the pipeline we have for supporting MP3 with i.MX8QXP/i.MX8QM here:

    https://github.com/thesofproject/sof/blob/main/tools/topology/topology1/development/sof-imx8-compr-mp3-wm8960.m4

    You will also need to have the cadence binary libraries: (these are provided by Cadence!!). Once you got them, you need to set some config options:

    CONFIG_CADENCE_CODEC_MP3_DEC=y
    CONFIG_CADENCE_CODEC_MP3_DEC_LIB="path/to/cadence/library/xa_mp3_dec.a"
    

    This works and it is tested for NXP platforms. I can assist you with that. For Intel platforms maybe @ranj063 can help you.

  4. hlleng commented on Feb 17, 2022

    @hlleng
    Contributor

    @bawanqin1987 Have a look at the pipeline we have for supporting MP3 with i.MX8QXP/i.MX8QM here:

    https://github.com/thesofproject/sof/blob/main/tools/topology/topology1/development/sof-imx8-compr-mp3-wm8960.m4

    You will also need to have the cadence binary libraries: (these are provided by Cadence!!). Once you got them, you need to set some config options:

    CONFIG_CADENCE_CODEC_MP3_DEC=y
    CONFIG_CADENCE_CODEC_MP3_DEC_LIB="path/to/cadence/library/xa_mp3_dec.a"
    

    This works and it is tested for NXP platforms. I can assist you with that. For Intel platforms maybe @ranj063 can help you.

    https://github.com/thesofproject/sof/blob/main/zephyr/CMakeLists.txt this file not support CONFIG_COMP_CODEC_ADAPTER

  5. bawanqin1987 commented on Feb 17, 2022

    @bawanqin1987
    Author

    1.CONFIG_CADENCE_CODEC_MP3_DEC_LIB="path/to/cadence/library/xa_mp3_dec.a" where i cp this .a ?Where should I maintain the codec library on the file system?
    2.cadence .a need Do all these. A need to be rebuilt?

  6. dbaluta commented on Feb 17, 2022

    @dbaluta
    Collaborator

    https://github.com/thesofproject/sof/blob/main/zephyr/CMakeLists.txt this file not support CONFIG_COMP_CODEC_ADAPTER

    We will add this to zephyr in the next few weeks. Anyhow, @bawanqin1987 can try this with proper SOF without Zephyr.

  7. dbaluta commented on Feb 17, 2022

    @dbaluta
    Collaborator

    1.CONFIG_CADENCE_CODEC_MP3_DEC_LIB="path/to/cadence/library/xa_mp3_dec.a" where i cp this .a ?Where should I maintain the codec library on the file system?
    2.cadence .a need Do all these. A need to be rebuilt?

    You can add Cadence library anywhere on your filestem and provide the correct path to CONFIG_CADENCE_CODEC_MP3_DEC_LIB config option.

    Here is on my machine:

    CONFIG_CADENCE_CODEC_MP3_DEC_LIB="/home/daniel/work/repos/imx-audio-codec/core_lib/pilibxa_mp3_dec/lib/xa_mp3_dec.a"
    
    1. I don't think I understand your question. You need to get the library from Cadence (are you a cadence customer?!), I think there are some fees involved. You will need to rebuild just the firmware and link it with Cadence library.

    The cadence library it is just a binary. No need to modify it. Use it as it is.

    What platforms are you trying to enable?

  8. bawanqin1987 commented on Feb 17, 2022

    @bawanqin1987
    Author

    i wanns test with my target board,so i think the .a will be Put on file system,Then the SOF on the AP side delivers the playback service, and calls. A to play after hifi4 starts?

  9. bawanqin1987 commented on Feb 17, 2022

    @bawanqin1987
    Author

    then ,i test the sof cadence codec with zpehyr os..and it's does not work? it's not support with zpehyr?

  10. dbaluta commented on Feb 17, 2022

    @dbaluta
    Collaborator

    @bawanqin1987 Yes, currently codec_adapter is not supported with zephyr. I have added a first PR to add this support.

    Please have a look at:

    #5384

    The next thing that needs to be done is to find a way to link the cadence libraries with zepyr firmware. @lgirdwood any idea? We need a function similar with SOF - > sof_add_static_library

    Meanhwile, @bawanqin1987 you can use codec_adapter's passhthrough codec type, to get you started.

  11. bawanqin1987 commented on Feb 18, 2022

    @bawanqin1987
    Author

    and some updates for me?
    passthrough codec type is not necessary. We're mainly stereo...

  12. lgirdwood commented on Feb 21, 2022

    @lgirdwood
    Member

    Zephyr builds SOF as a module and imports it's cmake and Kconfig. We should be able to link Zephyr + SOF module to the Cadence archive with a regular Cmake library inclusion.

  13. bawanqin1987 commented on Feb 21, 2022

    @bawanqin1987
    Author

    When will this feature be completed?we can merge it by my platform.

  14. dbaluta commented on Feb 21, 2022

    @dbaluta
    Collaborator

    @bawanqin1987 i don't have a date when this is to be completed, hopefully in under 1 month. Patches are welcomed. Can you please let us know what platform are you using and if you have an NDA with Cadence (otherwise you wont be able to use cadence libs.)

  15. 3 remaining items

  16. hlleng commented on Feb 28, 2022

    @hlleng
    Contributor

    this CONFIG option must be set on SOF firmware side:

    See: https://github.com/thesofproject/sof/blob/main/src/audio/Kconfig#L441

    Besides this depending on what codec you want to enable you will also need to look inside:

    https://github.com/thesofproject/sof/blob/main/src/audio/codec_adapter/Kconfig

    Yes, but this is sof side , i wanna know how to let host send CODEC_ADAPTOR ipc cmd to dsp. i don't find this part code.

  17. dbaluta commented on Feb 28, 2022

    @dbaluta
    Collaborator

    The command to create the CODEC_ADAPTER component is already sent, as you see in your screenshot. And it fails.

    What I think you want on the kernel side is to have the SND_SOC_SOF_COMPRESS config option enabled so that you can use the compress interface.

    This needs that you must have this Compress patch in your tree: https://lkml.org/lkml/2022/1/20/527

    One question: what decoder do you want to use: compress one (like MP3) or uncrompressed one like for example (Dolby Audio Processing?).

    For DAP there is no need for compress interface as it is PCM based stream.

  18. hlleng commented on Feb 28, 2022

    @hlleng
    Contributor

    The command to create the CODEC_ADAPTER component is already sent, as you see in your screenshot. And it fails.

    What I think you want on the kernel side is to have the SND_SOC_SOF_COMPRESS config option enabled so that you can use the compress interface.

    This needs that you must have this Compress patch in your tree: https://lkml.org/lkml/2022/1/20/527

    Thanks , I try to find SND_SOC_SOF_COMPRESS this part code.

    Why don't use SOF_COMP_CODEC_ADAPTOR like create SOF_COMP_DAI

    One question: what decoder do you want to use: compress one (like MP3) or uncrompressed one like for example (Dolby Audio Processing?).

    Yes, MP3

  19. dbaluta commented on Feb 28, 2022

    @dbaluta
    Collaborator

    Why don't use SOF_COMP_CODEC_ADAPTOR like create SOF_COMP_DAI

    I don't know how to answer this question. Could be that DAI is a special component.

  20. hlleng commented on Feb 28, 2022

    @hlleng
    Contributor

    Why don't use SOF_COMP_CODEC_ADAPTOR like create SOF_COMP_DAI

    I don't know how to answer this question. Could be that DAI is a special component.

    Thanks a bundle

  21. lgirdwood commented on Feb 28, 2022

    @lgirdwood
    Member

    @lenghonglin all the components are being aligned along a single interface being done by @ranj063 and @jxstelter. This is WIP but will converge at some point before SOF 2.4 (Q4 2022)

  22. hlleng commented on Mar 17, 2022

    @hlleng
    Contributor

    @dbaluta @lgirdwood hello, i can load mp3 decode lib in sof now.

    now i have a question, i see

    uint32_t api_id = CODEC_GET_API_ID(DEFAULT_CODEC_ID);
    this link setup DEFAULT_CODEC_ID,

    2ca2977
    this commit say If needed, this can be overwritten from userspace at runtime.

    how can i change codec_id in runtime ?

    i wanna let codec_adapter support both mp3 decode and aac decodec.

  23. paulstelian97 commented on Mar 17, 2022

    @paulstelian97
    Collaborator

    @lenghonglin That's a good point, with the current state of affairs the codec ID cannot be overwritten. It is a task actively being worked on (since MP3 doesn't work with the current code without changing the default). See #5245 .

  24. hlleng commented on Mar 17, 2022

    @hlleng
    Contributor

    @lenghonglin That's a good point, with the current state of affairs the codec ID cannot be overwritten. It is a task actively being worked on (since MP3 doesn't work with the current code without changing the default). See #5245 .

    So there two way to support both mp3 and aac decode.

    1. creat mp3 decode pipeline and aac decode pipeline. but this maybe coumse more ram.
    2. dynamically setup codec_id. The codec_id will be sent by the Linux kernel running on Host. like RFC: Preparation to dynamically setup codec_id for codec_adapter #5245 .
      Right ?
  25. hlleng commented on Mar 17, 2022

    @hlleng
    Contributor

    @lenghonglin That's a good point, with the current state of affairs the codec ID cannot be overwritten. It is a task actively being worked on (since MP3 doesn't work with the current code without changing the default). See #5245 .

    and It seem this #5245 is not continuing @dbaluta

  26. dbaluta commented on Mar 17, 2022

    @dbaluta
    Collaborator
    • creat mp3 decode pipeline and aac decode pipeline. but this maybe coumse more ram.

    This is no longer true with latest sources of SOF as we removed the codec_id from topology.

    • dynamically setup codec_id. The codec_id will be sent by the Linux kernel running on Host. like

    This is the way we are working now to upstream. Actually, I got back to look at this. Hope to have a solution in 1 week.

    For now, just for testing you can replace at compile time DEFAULT_CODEC_ID with MP3 so that you can test it.

  27. hlleng commented on Mar 17, 2022

    @hlleng
    Contributor
    • creat mp3 decode pipeline and aac decode pipeline. but this maybe coumse more ram.

    This is no longer true with latest sources of SOF as we removed the codec_id from topology.

    • dynamically setup codec_id. The codec_id will be sent by the Linux kernel running on Host. like

    This is the way we are working now to upstream. Actually, I got back to look at this. Hope to have a solution in 1 week.

    For now, just for testing you can replace at compile time DEFAULT_CODEC_ID with MP3 so that you can test it.

    Thanks for you reply. DEFAULT_CODEC_ID with MP3 so that you can test it.
    Yes, i am dothing like this , and it work fine now.

    I got back to look at this. Hope to have a solution in 1 week.

    What can i do for you? I've been needing that lately.

  28. dbaluta commented on Mar 17, 2022

    @dbaluta
    Collaborator

    What kernel are you using? What SOF version are you using.

    Not sure if you can help, unless you have some ideas on how can we dinamically set the codec id as discussed in #5245

    You can help me test this change applied on SOF main, with MP3 and tell me if it still works. Thus we can spare me some cycles.

    #5559

  29. hlleng commented on Mar 17, 2022

    @hlleng
    Contributor

    What kernel are you using? What SOF version are you using.

    The sof version is v1.5, but i update codec_apater part files to latest.

    Not sure if you can help, unless you have some ideas on how can we dinamically set the codec id as discussed in #5245

    OK

    You can help me test this change applied on SOF main, with MP3 and tell me if it still works. Thus we can spare me some cycles.

    #5559

    OK, i will test later.

  30. lgirdwood commented on Mar 18, 2022

    @lgirdwood
    Member

    @lenghonglin please also see that @ranj063 is doing updates to the codec adapter to align the interface to what's used on Windows. Some PRs have been merged, some are in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions