Skip to content

[FEATURE] connect multi-DAIs with one SdW link in one SdW device driver #2513

Closed

Description

@shumingfan

Hi @plbossart @RanderWang @bardliao

I want to add the IV feedback feature in rt1308-sdw driver now. But, I encounter the problem of how to connect multi-DAIs in the m/c driver.

Due to the hardware design of rt1308-sdw, it needs two data ports (DP2 & DP4) to feedback the left IV and right IV separately.
To implement the amp protection, it will need to feedback data ports both.
I try to add two DAIs for DP2 and DP4 like below.

@@ -635,6 +668,28 @@ static struct snd_soc_dai_driver rt1308_sdw_dai[] = {
                },
                .ops = &rt1308_aif_dai_ops,
        },
+       {
+               .name = "rt1308-aif-fb1",
+               .capture = {
+                       .stream_name = "DP2 Capture",
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = RT1308_STEREO_RATES,
+                       .formats = RT1308_FORMATS,
+               },
+               .ops = &rt1308_aif_dai_ops,
+       },
+       {
+               .name = "rt1308-aif-fb2",
+               .capture = {
+                       .stream_name = "DP4 Capture",
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = RT1308_STEREO_RATES,
+                       .formats = RT1308_FORMATS,
+               },
+               .ops = &rt1308_aif_dai_ops,
+       }
};

Based on my understanding of the m/c driver (sof_sdw.c), it can't connect and select the different DAI name with this condition.
I think the correct connections are similar to below. (assume using SdW link3)
"SDW3 Pin2" connects to "rt1308-aif" : DP1 Playback
"SDW3 Pin3" connects to "rt1308-aif-fb1" : DP2 Capture for Left IV
"SDW3 Pin4" connects to "rt1308-aif-fb2" : DP4 Capture for Right IV

Is it possible to do this with the current m/c driver? Or any suggestions to support this feature?

Activity

  1. plbossart commented on Oct 16, 2020

    @plbossart
    Member

    @shumingfan I am not sure if it's necessary to have two DAIs, one for each port. IIRC a stream can use two ports on the same device. Will look into this later today, it's an interesting point.

    Likewise, on the master side you could use a single port for the feedback, with the left and right channels written in different slots by the RT1308 ports. The bus allows for the master to combine data if they are written in the right places (configured by the bit allocation algorithm).

    Keep in mind though that the Intel firmware does not support this yet, so I am not sure how we would test this anyways if there's nothing to, we may need an experimental topology where we add a PCM capture stream visible all the way to the OS, until the firmware has the ability to deal with feedback.

    How we add the Realtek-specific processing is another issue from a firmware signature standpoint, we don't have a mechanism yet to add third party libraries signed with an OEM key. @lgirdwood FYI.

  2. plbossart commented on Oct 16, 2020

    @plbossart
    Member

    @shumingfan see your code below

    static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
    				struct snd_pcm_hw_params *params,
    				struct snd_soc_dai *dai)
    {
    	struct snd_soc_component *component = dai->component;
    	struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);
    	struct sdw_stream_config stream_config;
    	struct sdw_port_config port_config;
    	enum sdw_data_direction direction;
    	struct sdw_stream_data *stream;
    	int retval, port, num_channels;
    	unsigned int val = 0;
    
    	dev_dbg(dai->dev, "%s %s", __func__, dai->name);
    	stream = snd_soc_dai_get_dma_data(dai, substream);
    
    	if (!stream)
    		return -EINVAL;
    
    	if (!rt711->slave)
    		return -EINVAL;
    
    	/* SoundWire specific configuration */
    	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
    		direction = SDW_DATA_DIR_RX;
    		port = 3;
    	} else {
    		direction = SDW_DATA_DIR_TX;
    		if (dai->id == RT711_AIF1)
    			port = 4;
    		else if (dai->id == RT711_AIF2)
    			port = 2;
    		else
    			return -EINVAL;
    	}
    
    	stream_config.frame_rate = params_rate(params);
    	stream_config.ch_count = params_channels(params);
    	stream_config.bps = snd_pcm_format_width(params_format(params));
    	stream_config.direction = direction;
    
    	num_channels = params_channels(params);
    	port_config.ch_mask = (1 << (num_channels)) - 1;
    	port_config.num = port;
    
    	retval = sdw_stream_add_slave(rt711->slave, &stream_config,
    					&port_config, 1, stream->sdw_stream);

    You could have an port_config array with 2 ports used by your DAI. the ch_mask and num would be different for the [0] and [1] case, and correspond to the left and right feedback. I really don't see why you would need multiple DAIs here on the codec side, all you need is a DAI with has two ports.

    Of course this is completely untested, but from an API perspective we have the hooks needed.

  3. shumingfan commented on Oct 19, 2020

    @shumingfan
    Author

    You could have an port_config array with 2 ports used by your DAI. the ch_mask and num would be different for the [0] and [1] case, and correspond to the left and right feedback. I really don't see why you would need multiple DAIs here on the codec side, all you need is a DAI with has two ports.

    Of course this is completely untested, but from an API perspective we have the hooks needed.

    @plbossart Oh, I didn't expect I could use this to set the multi data ports. Now I know. Thanks.
    I also checked the PR #2514 . I left one comment to fix the channel number.

  4. added
    SDWApplies to SoundWire bus for codec connection
    on Oct 19, 2020
  5. shumingfan commented on Oct 22, 2020

    @shumingfan
    Author

    PR #2514 could meet my requirement. This issue could close now.
    @plbossart Thanks.

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

    SDWApplies to SoundWire bus for codec connectionenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions