mbox series

[v1,0/4] Add static channel mapping between soundwire master and slave

Message ID 20240909105547.2691015-1-quic_mohs@quicinc.com (mailing list archive)
Headers show
Series Add static channel mapping between soundwire master and slave | expand

Message

Mohammad Rafi Shaik Sept. 9, 2024, 10:55 a.m. UTC
Add static channel map support between soundwire master and slave.
This patch series will resolve channel mask mismatch between master and slave.

Scenario: wcd937x AMIC2 usecase

                          Master                 Slave (wcd937x)
                     +--------------+           +--------------+
                     |  +--------+  |           |  +--------+  |
         AMIC1 ----->|  | PORT1  |  |           |  |   TX1  |  |<-----------AMIC1
         AMIC2 ----->|  |        |  |           |  |        |  |
                     |  +--------+  |           |  +--------+  |
                     |              |           |              |
         AMIC3 ----->|  +--------+  |           |  +--------+  |
                     |  |  PORT2 |  |           |  |   TX2  |  |<-----------AMIC2
                     |  |        |  |           |  |        |  |<-----------AMIC3
                     |  +--------+  |           |  +--------+  |
                     |              |           |              |
                     |  +--------+  |           |  +--------+  |
 DMIC0...DMIC3------>|  |  PORT3 |  |           |  |   TX3  |  |<-----------DMIC0...DMIC3
                     |  |        |  |           |  |        |  |<-----------MBHC
                     |  +--------+  |           |  +--------+  |
                     |              |           |              |
                     |  +--------+  |           |  +--------+  |
 DMIC4...DMIC37----->|  |  PORT4 |  |           |  |   TX4  |  |<-----------DMIC4...DMIC7
                     |  |        |  |           |  |        |  |
                     |  +--------+  |           |  +--------+  |
                     |              |           |              |
                     +------------- +           +--------------+

For AMIC2 usecase, The Slave need to configure TX2 Port with channel mask 1 and
for Master required PORT1 with channel mask 2,

In existing design master and slave configured with same channel mask, it will fail
AMIC2 usecase.

The New design will help to configure channel mapping between master and slave from
device tree.

Mohammad Rafi Shaik (4):
  ASoC: dt-bindings: wcd938x-sdw: Add static channel mapping support
  soundwire: stream: Add set_master_channel_map() to set static channel
    mapping
  soundwire: qcom: Add static channel mapping support in soundwire
    master
  ASoC: codecs: wcd937x: Add static channel mapping support in
    wcd937x-sdw

 .../bindings/sound/qcom,wcd937x-sdw.yaml      | 28 ++++++++++
 drivers/soundwire/qcom.c                      | 18 +++++++
 drivers/soundwire/stream.c                    | 16 ++++++
 include/linux/soundwire/sdw.h                 |  5 ++
 sound/soc/codecs/wcd937x-sdw.c                | 52 ++++++++++++++++---
 sound/soc/codecs/wcd937x.c                    | 12 ++++-
 sound/soc/codecs/wcd937x.h                    |  6 ++-
 7 files changed, 126 insertions(+), 11 deletions(-)


base-commit: 9aaeb87ce1e966169a57f53a02ba05b30880ffb8

Comments

Charles Keepax Sept. 9, 2024, 2:49 p.m. UTC | #1
On Mon, Sep 09, 2024 at 04:25:43PM +0530, Mohammad Rafi Shaik wrote:
> Add static channel map support between soundwire master and slave.
> This patch series will resolve channel mask mismatch between master and slave.
> 
> Scenario: wcd937x AMIC2 usecase
> 
>                           Master                 Slave (wcd937x)
>                      +--------------+           +--------------+
>                      |  +--------+  |           |  +--------+  |
>          AMIC1 ----->|  | PORT1  |  |           |  |   TX1  |  |<-----------AMIC1
>          AMIC2 ----->|  |        |  |           |  |        |  |
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>          AMIC3 ----->|  +--------+  |           |  +--------+  |
>                      |  |  PORT2 |  |           |  |   TX2  |  |<-----------AMIC2
>                      |  |        |  |           |  |        |  |<-----------AMIC3
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>                      |  +--------+  |           |  +--------+  |
>  DMIC0...DMIC3------>|  |  PORT3 |  |           |  |   TX3  |  |<-----------DMIC0...DMIC3
>                      |  |        |  |           |  |        |  |<-----------MBHC
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>                      |  +--------+  |           |  +--------+  |
>  DMIC4...DMIC37----->|  |  PORT4 |  |           |  |   TX4  |  |<-----------DMIC4...DMIC7
>                      |  |        |  |           |  |        |  |
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>                      +------------- +           +--------------+
> 
> For AMIC2 usecase, The Slave need to configure TX2 Port with channel mask 1 and
> for Master required PORT1 with channel mask 2,
> 
> In existing design master and slave configured with same channel mask, it will fail
> AMIC2 usecase.

Apologies but I am not really following what exactly the issue is
here? How do these ports map to DAI links? It looks like you are
attempting to have AMIC2 produced by one DAI link, but consumed
by another?

Thanks,
Charles
Mark Brown Sept. 9, 2024, 3:10 p.m. UTC | #2
On Mon, Sep 09, 2024 at 03:49:47PM +0100, Charles Keepax wrote:
> On Mon, Sep 09, 2024 at 04:25:43PM +0530, Mohammad Rafi Shaik wrote:

> > Add static channel map support between soundwire master and slave.
> > This patch series will resolve channel mask mismatch between master and slave.

...

> > For AMIC2 usecase, The Slave need to configure TX2 Port with channel mask 1 and
> > for Master required PORT1 with channel mask 2,
> > 
> > In existing design master and slave configured with same channel mask, it will fail
> > AMIC2 usecase.

> Apologies but I am not really following what exactly the issue is
> here? How do these ports map to DAI links? It looks like you are
> attempting to have AMIC2 produced by one DAI link, but consumed
> by another?

Yes, and it's also not clear to me why this is device specific.
Pierre-Louis Bossart Sept. 9, 2024, 4:03 p.m. UTC | #3
On 9/9/24 12:55, Mohammad Rafi Shaik wrote:
> Add static channel map support between soundwire master and slave.
> This patch series will resolve channel mask mismatch between master and slave.
> 
> Scenario: wcd937x AMIC2 usecase
> 
>                           Master                 Slave (wcd937x)
>                      +--------------+           +--------------+
>                      |  +--------+  |           |  +--------+  |
>          AMIC1 ----->|  | PORT1  |  |           |  |   TX1  |  |<-----------AMIC1
>          AMIC2 ----->|  |        |  |           |  |        |  |
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>          AMIC3 ----->|  +--------+  |           |  +--------+  |
>                      |  |  PORT2 |  |           |  |   TX2  |  |<-----------AMIC2
>                      |  |        |  |           |  |        |  |<-----------AMIC3
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>                      |  +--------+  |           |  +--------+  |
>  DMIC0...DMIC3------>|  |  PORT3 |  |           |  |   TX3  |  |<-----------DMIC0...DMIC3
>                      |  |        |  |           |  |        |  |<-----------MBHC
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>                      |  +--------+  |           |  +--------+  |
>  DMIC4...DMIC37----->|  |  PORT4 |  |           |  |   TX4  |  |<-----------DMIC4...DMIC7
>                      |  |        |  |           |  |        |  |
>                      |  +--------+  |           |  +--------+  |
>                      |              |           |              |
>                      +------------- +           +--------------+
> 
> For AMIC2 usecase, The Slave need to configure TX2 Port with channel mask 1 and
> for Master required PORT1 with channel mask 2,
> 
> In existing design master and slave configured with same channel mask, it will fail
> AMIC2 usecase.
> 
> The New design will help to configure channel mapping between master and slave from
> device tree.

That's rather controversial...

In theory you already have the means to deal with a different channel
mapping in the hw_params callback for your manager and peripheral
devices. That's how we e.g. send a 2ch stream on the manager to two
separate amplifiers and program which channel is used by what amplifier.

The common part between manager and peripheral is the notion of
'stream', and you can add a different port/stream configuration for
manager and peripheral with sdw_stream_add_master() and
sdw_stream_add_slave() respectively.

Port1 and TX2 can be used by just setting the relevant port_config.num
value.

Likewise the port_config.ch_mask can be programmed at will to select the
relevant mappings. See e.g. rt1308_sdw_hw_params() in rt1308-sdw.c, the
mapping were handled with a set_tdm_slot() callback before.

In short, please re-visit your hw_params() implementation first and use
the existing 'stream' APIs.