[PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC

Ondřej Jirman posted 4 patches 1 year, 11 months ago
sound/soc/sunxi/sun50i-codec-analog.c |  73 +++++-
sound/soc/sunxi/sun8i-codec.c         | 346 +++++++++++++++++++++++++-
2 files changed, 399 insertions(+), 20 deletions(-)
[PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC
Posted by Ondřej Jirman 1 year, 11 months ago
From: Ondrej Jirman <megi@xff.cz>

This series adds support for jack detection to this codec. I used
and tested this on Pinephone. It works quite nicely. I tested it
against Android headset mic button resistor specification.

The patches are a rewritten and debugged version of the original
ones from Arnaud Ferraris and Samuel Holland, improved to better
handle headset button presses and with more robust plug-in/out
event debouncing, and to use set_jack API instead of sniffing
the sound card widget names, to detect the type of jack connector.

Please take a look. :)

v3:
- removed all device-tree related code
  (it's not necessary for core functionality, it only helps make the jack detect
  functionality of the codec be usable from simple-sound-card driver, and I'll
  send it spearately, because it will apparently need several more rounds
  of review)

v2:
- use set_jack/get_jack_type
- get rid of some custom poking inside card internals to figure
  out what kind of jack port we should setup the codec for
- read jack-type from OF as suggested here: 
  https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-component.c#L288
- add DT bindings

Thank you very much,
	Ondřej Jirman

Arnaud Ferraris (2):
  ASoC: sun50i-codec-analog: Enable jack detection on startup
  ASoC: sun8i-codec: Implement jack and accessory detection

Samuel Holland (2):
  ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level
  ASoC: sun8i-codec: Enable bus clock at STANDBY and higher bias

 sound/soc/sunxi/sun50i-codec-analog.c |  73 +++++-
 sound/soc/sunxi/sun8i-codec.c         | 346 +++++++++++++++++++++++++-
 2 files changed, 399 insertions(+), 20 deletions(-)

-- 
2.44.0

Re: [PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC
Posted by Vasily Khoruzhick 1 year, 1 month ago
On Sat, Mar 2, 2024 at 6:02 AM Ondřej Jirman <megi@xff.cz> wrote:
>
> From: Ondrej Jirman <megi@xff.cz>
>
> This series adds support for jack detection to this codec. I used
> and tested this on Pinephone. It works quite nicely. I tested it
> against Android headset mic button resistor specification.
>
> The patches are a rewritten and debugged version of the original
> ones from Arnaud Ferraris and Samuel Holland, improved to better
> handle headset button presses and with more robust plug-in/out
> event debouncing, and to use set_jack API instead of sniffing
> the sound card widget names, to detect the type of jack connector.
>
> Please take a look. :)
>
> v3:
> - removed all device-tree related code
>   (it's not necessary for core functionality, it only helps make the jack detect
>   functionality of the codec be usable from simple-sound-card driver, and I'll
>   send it spearately, because it will apparently need several more rounds
>   of review)

Hey Ondrej,

Has it ever materialized? As far as I can tell, this code has been
sitting dead due to missing dt-related code.

Regards,
Vasily

> v2:
> - use set_jack/get_jack_type
> - get rid of some custom poking inside card internals to figure
>   out what kind of jack port we should setup the codec for
> - read jack-type from OF as suggested here:
>   https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-component.c#L288
> - add DT bindings
>
> Thank you very much,
>         Ondřej Jirman
>
> Arnaud Ferraris (2):
>   ASoC: sun50i-codec-analog: Enable jack detection on startup
>   ASoC: sun8i-codec: Implement jack and accessory detection
>
> Samuel Holland (2):
>   ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level
>   ASoC: sun8i-codec: Enable bus clock at STANDBY and higher bias
>
>  sound/soc/sunxi/sun50i-codec-analog.c |  73 +++++-
>  sound/soc/sunxi/sun8i-codec.c         | 346 +++++++++++++++++++++++++-
>  2 files changed, 399 insertions(+), 20 deletions(-)
>
> --
> 2.44.0
>
>
Re: [PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC
Posted by Ondřej Jirman 1 year, 1 month ago
Hi Vasily,

On Fri, Dec 27, 2024 at 03:58:44PM -0800, Vasily Khoruzhick wrote:
> On Sat, Mar 2, 2024 at 6:02 AM Ondřej Jirman <megi@xff.cz> wrote:
> >
> > From: Ondrej Jirman <megi@xff.cz>
> >
> > This series adds support for jack detection to this codec. I used
> > and tested this on Pinephone. It works quite nicely. I tested it
> > against Android headset mic button resistor specification.
> >
> > The patches are a rewritten and debugged version of the original
> > ones from Arnaud Ferraris and Samuel Holland, improved to better
> > handle headset button presses and with more robust plug-in/out
> > event debouncing, and to use set_jack API instead of sniffing
> > the sound card widget names, to detect the type of jack connector.
> >
> > Please take a look. :)
> >
> > v3:
> > - removed all device-tree related code
> >   (it's not necessary for core functionality, it only helps make the jack detect
> >   functionality of the codec be usable from simple-sound-card driver, and I'll
> >   send it spearately, because it will apparently need several more rounds
> >   of review)
> 
> Hey Ondrej,
> 
> Has it ever materialized? As far as I can tell, this code has been
> sitting dead due to missing dt-related code.

The code is used with some non-mainline patches. There was a bit of
a problem with simple-sound-card not being flexible enough for complete
functionality of audio jack on Pinephone, so I had to extend it a bit:

https://codeberg.org/megi/linux/commit/afbe7688083cd1e3ab98c37e0fe0c28d530829e1
https://codeberg.org/megi/linux/commit/95552b66a269c2da434edd3880f9819c0bd5602f
https://codeberg.org/megi/linux/commit/c15070c220e7425dd0d0445ae0eacdb4a4872ad7

Here's a bunch of patches that I use currently for complete audio
jack detection functionality:

  https://codeberg.org/megi/linux/commits/branch/audio-6.13

But no, complete upstream support did not materialize, yet.

I'm not sure about the direction. Whether to push more features to DT or
just write a sound card driver for Pinephone, that would be able to handle all
this without extending simple-sound-card or DT changes to codec driver.

Kind regards,
	o.

> Regards,
> Vasily
> 
> > v2:
> > - use set_jack/get_jack_type
> > - get rid of some custom poking inside card internals to figure
> >   out what kind of jack port we should setup the codec for
> > - read jack-type from OF as suggested here:
> >   https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-component.c#L288
> > - add DT bindings
> >
> > Thank you very much,
> >         Ondřej Jirman
> >
> > Arnaud Ferraris (2):
> >   ASoC: sun50i-codec-analog: Enable jack detection on startup
> >   ASoC: sun8i-codec: Implement jack and accessory detection
> >
> > Samuel Holland (2):
> >   ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level
> >   ASoC: sun8i-codec: Enable bus clock at STANDBY and higher bias
> >
> >  sound/soc/sunxi/sun50i-codec-analog.c |  73 +++++-
> >  sound/soc/sunxi/sun8i-codec.c         | 346 +++++++++++++++++++++++++-
> >  2 files changed, 399 insertions(+), 20 deletions(-)
> >
> > --
> > 2.44.0
> >
> >
Re: [PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC
Posted by Vasily Khoruzhick 1 year, 1 month ago
On Tue, Jan 7, 2025 at 11:23 AM Ondřej Jirman <megi@xff.cz> wrote:

> > Has it ever materialized? As far as I can tell, this code has been
> > sitting dead due to missing dt-related code.
>
> The code is used with some non-mainline patches. There was a bit of
> a problem with simple-sound-card not being flexible enough for complete
> functionality of audio jack on Pinephone, so I had to extend it a bit:

So maybe it's time to respin the discussion? :)

> https://codeberg.org/megi/linux/commit/afbe7688083cd1e3ab98c37e0fe0c28d530829e1
> https://codeberg.org/megi/linux/commit/95552b66a269c2da434edd3880f9819c0bd5602f

I think the only fishy-looking part is using device name instead of
device node here, i.e. something like this would look cleaner in my
opinion:

simple-audio-card,jack-pins =
<&codec>, "Headphone Jack",
<&codec>, "Headset Microphone";

However, I'd like to hear the opinion of ASoC maintainers. Mark, Liam,
what would be the best approach here?

> https://codeberg.org/megi/linux/commit/c15070c220e7425dd0d0445ae0eacdb4a4872ad7
>
> Here's a bunch of patches that I use currently for complete audio
> jack detection functionality:
>
>   https://codeberg.org/megi/linux/commits/branch/audio-6.13
>
> But no, complete upstream support did not materialize, yet.
>
> I'm not sure about the direction. Whether to push more features to DT or
> just write a sound card driver for Pinephone, that would be able to handle all
> this without extending simple-sound-card or DT changes to codec driver.

It's not really Pinephone-specific, all A64 (and probably other
Allwinner-based) devices can benefit from generic code, so I think
extending simple-card driver is appropriate.

Regards,
Vasily
Re: [PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC
Posted by Mark Brown 1 year, 10 months ago
On Sat, 02 Mar 2024 15:00:34 +0100, Ondřej Jirman wrote:
> This series adds support for jack detection to this codec. I used
> and tested this on Pinephone. It works quite nicely. I tested it
> against Android headset mic button resistor specification.
> 
> The patches are a rewritten and debugged version of the original
> ones from Arnaud Ferraris and Samuel Holland, improved to better
> handle headset button presses and with more robust plug-in/out
> event debouncing, and to use set_jack API instead of sniffing
> the sound card widget names, to detect the type of jack connector.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/4] ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level
      commit: c0454d31e05062b1c7df7eef21855ba1f56c5158
[2/4] ASoC: sun8i-codec: Enable bus clock at STANDBY and higher bias
      commit: c556814b926c3f16fdca3d18cac793ccf0d14c44
[3/4] ASoC: sun50i-codec-analog: Enable jack detection on startup
      commit: d5961e43b28668088087befbf4f7a043bd0ae65c
[4/4] ASoC: sun8i-codec: Implement jack and accessory detection
      commit: 21fa98f4197bb3365dda1417708b318f403c13c1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

Re: [PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC
Posted by Ondřej Jirman 1 year, 10 months ago
Hello Mark,

On Tue, Mar 26, 2024 at 03:27:41PM +0000, Mark Brown wrote:
> On Sat, 02 Mar 2024 15:00:34 +0100, Ondřej Jirman wrote:
> > This series adds support for jack detection to this codec. I used
> > and tested this on Pinephone. It works quite nicely. I tested it
> > against Android headset mic button resistor specification.
> > 
> > The patches are a rewritten and debugged version of the original
> > ones from Arnaud Ferraris and Samuel Holland, improved to better
> > handle headset button presses and with more robust plug-in/out
> > event debouncing, and to use set_jack API instead of sniffing
> > the sound card widget names, to detect the type of jack connector.
> > 
> > [...]
> 
> Applied to
> 
>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thank you.

Coincidentally, Intel kernel test bot found an issue today that this fails to
build with CONFIG_SND_JACK_INPUT_DEV disabled. Should I send a followup fix or
should I send v5 with the fix integrated into the patch that breaks?

Kind regards,
	o.

> Thanks!
> 
> [1/4] ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level
>       commit: c0454d31e05062b1c7df7eef21855ba1f56c5158
> [2/4] ASoC: sun8i-codec: Enable bus clock at STANDBY and higher bias
>       commit: c556814b926c3f16fdca3d18cac793ccf0d14c44
> [3/4] ASoC: sun50i-codec-analog: Enable jack detection on startup
>       commit: d5961e43b28668088087befbf4f7a043bd0ae65c
> [4/4] ASoC: sun8i-codec: Implement jack and accessory detection
>       commit: 21fa98f4197bb3365dda1417708b318f403c13c1
> 
> All being well this means that it will be integrated into the linux-next
> tree (usually sometime in the next 24 hours) and sent to Linus during
> the next merge window (or sooner if it is a bug fix), however if
> problems are discovered then the patch may be dropped or reverted.
> 
> You may get further e-mails resulting from automated or manual testing
> and review of the tree, please engage with people reporting problems and
> send followup patches addressing any issues that are reported if needed.
> 
> If any updates are required or you are submitting further changes they
> should be sent as incremental updates against current git, existing
> patches will not be replaced.
> 
> Please add any relevant lists and maintainers to the CCs when replying
> to this mail.
> 
> Thanks,
> Mark
> 
Re: [PATCH v3 0/4] Add support for jack detection to codec present in A64 SoC
Posted by Mark Brown 1 year, 10 months ago
On Tue, Mar 26, 2024 at 05:33:14PM +0100, Ondřej Jirman wrote:

> Coincidentally, Intel kernel test bot found an issue today that this fails to
> build with CONFIG_SND_JACK_INPUT_DEV disabled. Should I send a followup fix or
> should I send v5 with the fix integrated into the patch that breaks?

Please send a followup.