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

ASoC: rt711-sdca: add GE selected mode control #4969

Merged

Conversation

shumingfan
Copy link

@shumingfan shumingfan commented May 3, 2024

ASoC: rt711-sdca: add GE selected mode control
This patch adds the 'selected mode' control which overrides the detected_mode.

@shumingfan shumingfan force-pushed the add-ge-select-mode-ctl branch 2 times, most recently from c2bf13e to 19357b8 Compare May 3, 2024 09:01
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Thanks @shumingfan, I am afraid I don't fully understand the logic behind this patch, see comments below.

@@ -258,6 +258,8 @@ static int rt711_sdca_headset_detect(struct rt711_sdca_priv *rt711)
switch (det_mode) {
case 0x00:
rt711->jack_type = 0;
regmap_write(rt711->regmap,
SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT711_SDCA_ENT_GE49, RT711_SDCA_CTL_SELECTED_MODE, 0), 0);
Copy link
Member

Choose a reason for hiding this comment

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

i am a bit confused by this patch @shumingfan

Shouldn't the code override det_mode and change the value so that the updated selected_mode is written line 276?

Copy link
Member

Choose a reason for hiding this comment

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

I am also confused by the rest of the switch case where the jack_type would be set based on the det_mode, not selected_mode.

break;
}

return snd_soc_put_enum_double(kcontrol, ucontrol);
Copy link
Member

Choose a reason for hiding this comment

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

still not following. Even if we used a changed in selected_mode as the trigger to update the configuration, the jack_type wouldn't change.

My maybe naive proposal was that the jack detection would be set with the alsa control when the card is created, and whenever an actual jack is detected we would use the value of the alsa control to force the configuration and ignore the detected mode.

Copy link
Author

Choose a reason for hiding this comment

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

@plbossart Could we use the module parameter to force the jack type?
I updated the patch. Please take a look.

@fredoh9 fredoh9 self-requested a review May 3, 2024 18:26
@shumingfan shumingfan changed the title ASoC: rt711-sdca: add GE selected mode control ASoC: rt711-sdca: add module parameter to set jack type May 6, 2024
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Thanks @shumingfan. I had the idea of using an alsa control but the module parameter is fine to start testing.

@fredoh9 @marc-hb can you try to see if this patch improve the alsa-bat results with the option
options snd_soc_rt711_sdca detected_mode=5

det_mode = ge_mode_override;
rt711->jack_type =
(rt711->jack_type == SND_JACK_HEADPHONE) ? SND_JACK_HEADSET : SND_JACK_HEADPHONE;
rt711_sdca_ge_force_jack_type(rt711, det_mode);
Copy link
Member

Choose a reason for hiding this comment

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

optimization: I think you could move this line 297 after the if, if det_mode is zero then using rt711_sdca_ge_force_jack_type(rt711, det_mode); would work just fine.

rt711_sdca_ge_force_jack_type(rt711, det_mode);
}
if (!det_mode)
rt711_sdca_ge_force_jack_type(rt711, 0);
Copy link
Member

Choose a reason for hiding this comment

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

these two lines can be removed and replaced by rt711_sdca_ge_force_jack_type(rt711, det_mode);

@fredoh9
Copy link
Collaborator

fredoh9 commented May 6, 2024

@fredoh9 @marc-hb can you try to see if this patch improve the alsa-bat results with the option
options snd_soc_rt711_sdca detected_mode=5

I can quickly test with this today. Will update soon.

@fredoh9
Copy link
Collaborator

fredoh9 commented May 6, 2024

I was able to test with this PR and the module param.

options snd_soc_rt711_sdca detected_mode=5

Looks detected_mode is consistent throughout multiple tests, however test results have more failure than pass. Captured wave file has very low volume, not even tell whether it's sinewave. Still looking at it. i.e increasing gain. Will update.

Headset Mic Jack also stays ON.

numid=37,iface=CARD,name='Headset Mic Jack'
  ; type=BOOLEAN,access=r-------,values=1
  : values=on
$ grep detected_mode 20240506_dmesg01_pr4969_detected_mode_add_alsabat_tests.txt
[    6.041556] snd_soc_rt711_sdca:rt711_sdca_headset_detect: rt711-sdca sdw:0:0:025d:0711:01: rt711_sdca_headset_detect, detected_mode=0x0
[    6.440514] snd_soc_rt711_sdca:rt711_sdca_headset_detect: rt711-sdca sdw:0:0:025d:0711:01: rt711_sdca_headset_detect, detected_mode=0x5
[   43.739315] snd_soc_rt711_sdca:rt711_sdca_headset_detect: rt711-sdca sdw:0:0:025d:0711:01: rt711_sdca_headset_detect, detected_mode=0x5
[   43.774153] snd_soc_rt711_sdca:rt711_sdca_headset_detect: rt711-sdca sdw:0:0:025d:0711:01: rt711_sdca_headset_detect, detected_mode=0x5
[  177.001368] snd_soc_rt711_sdca:rt711_sdca_headset_detect: rt711-sdca sdw:0:0:025d:0711:01: rt711_sdca_headset_detect, detected_mode=0x5
[  204.427909] snd_soc_rt711_sdca:rt711_sdca_headset_detect: rt711-sdca sdw:0:0:025d:0711:01: rt711_sdca_headset_detect, detected_mode=0x5
[  964.759599] snd_soc_rt711_sdca:rt711_sdca_headset_detect: rt711-sdca sdw:0:0:025d:0711:01: rt711_sdca_headset_detect, detected_mode=0x5

@marc-hb
Copy link
Collaborator

marc-hb commented May 6, 2024

Headset Mic Jack also stays ON.

From the narrow perspective of this PR, this is a PASS! We can discuss and debug alsabat and other issues elsewhere.

Could you test basic, manual hotplug with a sample of headphones and headsets? evtest is the most convenient for this.

@marc-hb
Copy link
Collaborator

marc-hb commented May 6, 2024

I had the idea of using an alsa control but the module parameter is fine to start testing.

A module parameter will be less flexible and less convenient for testing automation.

@shumingfan
Copy link
Author

@marc-hb @plbossart I will update the patch, creating an alsa control to change the jack type.

@shumingfan shumingfan changed the title ASoC: rt711-sdca: add module parameter to set jack type ASoC: rt711-sdca: add GE selected mode control May 7, 2024
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Looks good to me @shumingfan, two questions below:

return -EINVAL;
val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l;
rt711->ge_mode_override = val;
return 0;
Copy link
Member

Choose a reason for hiding this comment

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

isn't there something about the return value of the 'put' that informs upper layers that the value was indeed changed?

Copy link
Author

Choose a reason for hiding this comment

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

OK, will fix

sound/soc/codecs/rt711-sdca.c Show resolved Hide resolved
This patch adds the 'selected mode' control which overrides the detected_mode.

Signed-off-by: Shuming Fan <[email protected]>
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

LGTM @shumingfan

Can you send to Mark Brown, maybe with an updated commit message such as:

The SDCA spec defines a 'selected_mode' control which can override the 'detected_mode' reported by hardware. This is useful for platform integration as well as in cases where the hardware is not able to accurately detect the jack type.

Copy link
Collaborator

@fredoh9 fredoh9 left a comment

Choose a reason for hiding this comment

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

I was able test test with LNL RVP, the overriding mode worked fine.

@shumingfan
Copy link
Author

shumingfan commented May 9, 2024

Can you send to Mark Brown, maybe with an updated commit message such as:

Sure, will send the patch soon.

@shumingfan shumingfan closed this May 9, 2024
@shumingfan shumingfan reopened this May 9, 2024
@plbossart
Copy link
Member

shared upstream, thanks @shumingfan

@plbossart plbossart closed this May 10, 2024
@marc-hb
Copy link
Collaborator

marc-hb commented May 10, 2024

@plbossart don't we need this in this branch already to unblock investigation of other capture issues?

@plbossart
Copy link
Member

good point @marc-hb. I was planning to pick it up at the next merge, but that merge might be a ways off since we have nothing to send. I'll merge it to topic/sof-dev.

@plbossart plbossart reopened this May 10, 2024
@plbossart plbossart merged commit 193bd3d into thesofproject:topic/sof-dev May 10, 2024
28 of 33 checks passed
@marc-hb
Copy link
Collaborator

marc-hb commented Jun 18, 2024

Not sure this override is enough:

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.

4 participants