Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] SoundWire: add rt1308 feedback #2514

Closed

Conversation

plbossart
Copy link
Member

rough draft as an example of how to add IV feedback support

I have no idea how to add a capture dailink, might been @RanderWang's help here.

@shumingfan @bardliao comments welcome.

Comment on lines 595 to 607
capture:
direction = SDW_DATA_DIR_TX;
num_channels = 2;

stream_config.frame_rate = params_rate(params);
stream_config.ch_count = num_channels;
stream_config.bps = snd_pcm_format_width(params_format(params));
stream_config.direction = direction;

port_config_feedback[0].ch_mask = BIT(0);
port_config_feedback[0].num = 2; /* DP2 */
port_config_feedback[1].ch_mask = BIT(1);
port_config_feedback[1].num = 4; /* DP4 */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart Thanks for this commit to explain how to config the multi data ports with one DAI link.
I think something I don't explain clearly in #2513
The feedback channels are two channels for each port.
Due to RT1308 is a stereo amplifier, it will protect the left and right speakers individually.
Left IV => using DP2 to feedback ch0 (I data) and ch1 (V data) for left speaker.
Right IV => using DP4 to feedback ch0 (I data) and ch1 (V data) for right speaker.
Therefore, the total channels are four channels like below.

	num_channels = 4;

	port_config_feedback[0].ch_mask = BIT(0) | BIT(1);
	port_config_feedback[0].num = 2; /* DP2 */
	port_config_feedback[1].ch_mask = BIT(2) | BIT(3);
	port_config_feedback[1].num = 4; /* DP4 */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shumingfan waiting for your result. I also had such idea but I didn't get a answer from cadance's spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shumingfan I get the point for the case with a a single amp, we would get 4 channels. Your change makes sense. I have to see though how we would deal with 4 channels on the Intel side, I believe we would need 2 ports.

Also what happens in the case where there are two amplifiers in the system, and each of them controls a tweeter and woofer. How many feedback channels would we get from each amplifier?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart It will have 4 feedback channels from each amplifier.
Hence, there are eight feedback channels when using two amplifiers in the system.
The amp protection needs to protect each speaker whether it belongs to the tweeter or woofer.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shumingfan waiting for your result. I also had such idea but I didn't get a answer from cadance's spec.

@RanderWang I tested the feedback function with the approach of this PR.
First, I tried to record the IV data from DP2 only. I can see the ch0 and ch1 have the captured data.
Then, I tried to record the IV data from DP2/4 both. There are captured data with ch0 and ch1 only.
The ch2 and ch3 are zero.
I checked the MIPI-defined registers of DP2 and DP4 which had been configured while the test.
The DP4_ChannelEN doesn't enable. I think there is a problem there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shumingfan if the DP4 registers were configured, but only the DP4_ChannelEN is not set, this points to a missing loop in the bank switch where we only deal with a single port?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shumingfan if the DP4 registers were configured, but only the DP4_ChannelEN is not set, this points to a missing loop in the bank switch where we only deal with a single port?

@plbossart I found the root cause. The DP2/4_ChannelEn only supports channel1/2.
The driver needs to change the ch_mask to 0x3 for DP2/4 both.
Now, I could get the captured data of four channels.

num_channels = 4;

port_config_feedback[0].ch_mask = BIT(0) | BIT(1);
port_config_feedback[0].num = 2; /* DP2 */
port_config_feedback[1].ch_mask = BIT(0) | BIT(1);
port_config_feedback[1].num = 4; /* DP4 */

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @shumingfan, updated the patch and added you as co-author. please check if this is ok now.

The RT1308 can provide feedback for two speakers. Each speaker is
handled by a port, and each port transmits two channels for I and V.

The data is handled as a single 4ch stream and a single DAI.

Co-developed-by: Shuming Fan <shumingf@realtek.com>
Signed-off-by: Shuming Fan <shumingf@realtek.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
FIXME: for now there is no initialization on capture.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@shumingfan
Copy link

shumingfan commented Oct 23, 2020

@plbossart @bardliao @RanderWang Now I tried to connect two amplifiers to meet the environment of the customer's product.
The two RT1308 connect to the different SdW link. I think we will enable the aggregation feature for playback.
However, do we have the aggregation feature for capture?
I checked the topology files that there is one sof-smart-amplifier.m4 to support the smart amp which could feedback the IV to smart_amp component.
But, it seems not to support the aggregation feature.
Then, our FW team wants to combine all IV feedback data (4+4 channels) to the smart_amp component for amp protection.
I draw the topology graph below.

# PCM_P -- B0 --> smart_amp -- B1--> Demux(M) -- B2 ----> DAI
#                  ^                     |
#                  |                     pipeline n+1 --> DAI
#                  |
#                  B2
#                  |
#                  |
#                  |
# PCM_C <-- B0 <-- Demux(M) <-- B1 <--- Mux <--- B2 <-- DAI
#                                        ^
#                                        |
#                                        ------- B3 <-- DAI 
#

Sorry, I am not familiar with the topology development. Does this graph make sense or be reasonable?
Could anyone support this or give me the sample? I will try to test it if there is any suggestion or topology sample.

@RanderWang
Copy link

@plbossart @bardliao @RanderWang Now I tried to connect two amplifiers to meet the environment of the customer's product.
The two RT1308 connect to the different SdW link. I think we will enable the aggregation feature for playback.
However, do we have the aggregation feature for capture?
I checked the topology files that there is one sof-smart-amplifier.m4 to support the smart amp which could feedback the IV to smart_amp component.
But, it seems not to support the aggregation feature.
Then, our FW team wants to combine all IV feedback data (4+4 channels) to the smart_amp component for amp protection.
I draw the topology graph below.

# PCM_P -- B0 --> smart_amp -- B1--> Demux(M) -- B2 ----> DAI
#                  ^                     |
#                  |                     pipeline n+1 --> DAI
#                  |
#                  B2
#                  |
#                  |
#                  |
# PCM_C <-- B0 <-- Demux(M) <-- B1 <--- Mux <--- B2 <-- DAI
#                                        ^
#                                        |
#                                        ------- B3 <-- DAI 
#

Sorry, I am not familiar with the topology development. Does this graph make sense or be reasonable?
Could anyone support this or give me the sample? I will try to test it if there is any suggestion or topology sample.

@shumingfan please make it clear about your DAI in graph. only one BE DAI but two CPU DAIs & codec DAIs. Now as I know, we don't support capture aggregation. @bardliao do we support it ?

@plbossart
Copy link
Member Author

@shumingfan you are absolutely right that we need a mux on capture to aggregate the two links. I don't think this exists today, we need to check with @slawblauciak.

However I am not sure about the demux. The idea of inserting a demux was that we could pass an echo reference to the application for acoustic echo cancellation. It's my understanding that we use the demux only to split the stream in two.

Now in your case, the aggregated feedback stream would be made of 8 channels. That seems a bit too much to pass to the application, so we may need to combine channels or select specific ones?

Also note that if you want to develop this functionality, we will be limited by the SOF firmware signature issues. The simplest solution for development might be to use an UpExtreme board, which exposes 4 SoundWire links on its connector and allows for the community key to be used, and tie it to the 3-in-1 board.

If you want to enable the RT1308 IV feedback on devices where the Intel production key is used, we need to solve collectively the signature issues. The Realtek library will probably not go into the Intel base firmware, so we are looking at a 2-key solution similar to Windows, and Realtek releasing the firmware to users. Adding @lgirdwood to make sure this is tracked.

@shumingfan
Copy link

@plbossart Thanks for your explanation. But, it is bad news to our FW team that there is no mux on capture to aggregate the two links for now.
The main purpose is that the aggregated feedback stream could send to smart_amp component to do the amp protection.
Passing the data to the application may be an option for debugging.

We have the ICL RVP to do the test and algorithm development.
I think this environment doesn't have the SOF firmware signature issue, right?

@plbossart
Copy link
Member Author

@plbossart Thanks for your explanation. But, it is bad news to our FW team that there is no mux on capture to aggregate the two links for now.

There is no mux yet on capture, but I think this should be relatively simple to do. @bardliao could do this before breakfast :-)

The main purpose is that the aggregated feedback stream could send to smart_amp component to do the amp protection.
Passing the data to the application may be an option for debugging.

yes, the need/usage is understood.

We have the ICL RVP to do the test and algorithm development.
I think this environment doesn't have the SOF firmware signature issue, right?

RVPs shipped outside of Intel usually use the production key, not the debug key. At any rate, it's not the SOF 'community key' either way.

@bardliao
Copy link
Collaborator

@plbossart Thanks for your explanation. But, it is bad news to our FW team that there is no mux on capture to aggregate the two links for now.

There is no mux yet on capture, but I think this should be relatively simple to do. @bardliao could do this before breakfast :-)

Oh, that is not easy to me in fact.

@plbossart
Copy link
Member Author

this PR is a year old and nothing happened, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants