-
Notifications
You must be signed in to change notification settings - Fork 133
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
ASoC: rt711-sdca: add GE selected mode control #4969
Conversation
c2bf13e
to
19357b8
Compare
There was a problem hiding this 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.
sound/soc/codecs/rt711-sdca.c
Outdated
@@ -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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
sound/soc/codecs/rt711-sdca.c
Outdated
break; | ||
} | ||
|
||
return snd_soc_put_enum_double(kcontrol, ucontrol); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
19357b8
to
e9cfe95
Compare
There was a problem hiding this 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
sound/soc/codecs/rt711-sdca.c
Outdated
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); |
There was a problem hiding this comment.
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.
sound/soc/codecs/rt711-sdca.c
Outdated
rt711_sdca_ge_force_jack_type(rt711, det_mode); | ||
} | ||
if (!det_mode) | ||
rt711_sdca_ge_force_jack_type(rt711, 0); |
There was a problem hiding this comment.
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);
I was able to test with this PR and the module param.
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.
|
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? |
A module parameter will be less flexible and less convenient for testing automation. |
@marc-hb @plbossart I will update the patch, creating an alsa control to change the jack type. |
e9cfe95
to
c568b60
Compare
c568b60
to
ff0b669
Compare
There was a problem hiding this 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:
sound/soc/codecs/rt711-sdca.c
Outdated
return -EINVAL; | ||
val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; | ||
rt711->ge_mode_override = val; | ||
return 0; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will fix
This patch adds the 'selected mode' control which overrides the detected_mode. Signed-off-by: Shuming Fan <[email protected]>
ff0b669
to
b81cf53
Compare
There was a problem hiding this 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.
There was a problem hiding this 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.
Sure, will send the patch soon. |
shared upstream, thanks @shumingfan |
@plbossart don't we need this in this branch already to unblock investigation of other capture issues? |
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. |
193bd3d
into
thesofproject:topic/sof-dev
Not sure this override is enough: |
ASoC: rt711-sdca: add GE selected mode control
This patch adds the 'selected mode' control which overrides the detected_mode.