ASoC: sun8i-codec: Fix build with CONFIG_SND_JACK_INPUT_DEV disabled
Subsystems (3)
PATCH 1/1 ASoC: sun8i-codec: Fix build with CONFIG_SND_JACK_INPUT_DEV disabled
From: Ondrej Jirman <[email protected]>
When CONFIG_SND_JACK_INPUT_DEV is disabled, struct snd_jack doesn't have 'type' field. We can't rely on this field being always present, so store the jack_type in the codec driver itself.
---
This is a followup for https://lore.kernel.org/lkml/2vhd45kylttgonosdcfn7ugwyy2vx56gijwf3ealz4tel65iqr@cs3kxrl6d2hh/
sound/soc/sunxi/sun8i-codec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/sunxi/sun8i-codec.c +7 -7
@@ -232,6 +232,7 @@ struct sun8i_codec {struct delayed_work jack_work;int jack_irq;int jack_status; +int jack_type;int jack_last_sample;ktime_t jack_hbias_ready;struct mutex jack_mutex;
@@ -1352,7 +1353,6 @@ static void sun8i_codec_jack_work(struct work_struct *work) struct sun8i_codec *scodec = container_of(work, struct sun8i_codec, jack_work.work);unsigned int mdata; -int type_mask = scodec->jack->jack->type;int type;guard (mutex)(&scodec->jack_mutex);
@@ -1363,7 +1363,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) scodec->jack_last_sample =-1 ; -if (type_mask &SND_JACK_MICROPHONE ) { +if (scodec->jack_type &SND_JACK_MICROPHONE ) {/* * If we were in disconnected state, we enable HBIAS and * wait 600ms before reading initial HDATA value.
@@ -1376,7 +1376,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) scodec->jack_status =SUN8I_JACK_STATUS_WAITING_HBIAS ; }else {snd_soc_jack_report (scodec->jack,SND_JACK_HEADPHONE , - type_mask); + scodec->jack_type); scodec->jack_status =SUN8I_JACK_STATUS_CONNECTED ; } }else if (scodec->jack_status ==SUN8I_JACK_STATUS_WAITING_HBIAS ) {
@@ -1417,17 +1417,17 @@ static void sun8i_codec_jack_work(struct work_struct *work)if (type ==SND_JACK_HEADPHONE )sun8i_codec_set_hmic_bias (scodec, false); -snd_soc_jack_report (scodec->jack, type, type_mask); +snd_soc_jack_report (scodec->jack, type, scodec->jack_type); scodec->jack_status =SUN8I_JACK_STATUS_CONNECTED ; }else if (scodec->jack_status ==SUN8I_JACK_STATUS_CONNECTED ) {if (scodec->last_hmic_irq !=SUN8I_HMIC_STS_JACK_OUT_IRQ_ST )return ; scodec->jack_status =SUN8I_JACK_STATUS_DISCONNECTED ; -if (type_mask &SND_JACK_MICROPHONE ) +if (scodec->jack_type &SND_JACK_MICROPHONE )sun8i_codec_set_hmic_bias (scodec, false); -snd_soc_jack_report (scodec->jack,0 , type_mask); +snd_soc_jack_report (scodec->jack,0 , scodec->jack_type); } }
@@ -1491,7 +1491,7 @@ static irqreturn_t sun8i_codec_jack_irq(int irq, void *dev_id)if (scodec->jack_last_sample >=0 && scodec->jack_last_sample == value)snd_soc_jack_report (scodec->jack, type, - scodec->jack->jack->type); + scodec->jack_type); scodec->jack_last_sample = value; }
Signature · 1 line
2.44.0
Jernej Škrabec
maintainerDne sreda, 27. marec 2024 ob 09:05:34 CET je Ondřej Jirman napisal(a):
Quoted 20 lines
From: Ondrej Jirman <[email protected]>
When
CONFIG_SND_JACK_INPUT_DEVis disabled, structsnd_jackdoesn't have 'type' field. We can't rely on this field being always present, so store thejack_typein the codec driver itself.Signed-off-by Ondrej Jirman <[email protected]>Reported-by kernel test robot <[email protected]>---
This is a followup for https://lore.kernel.org/lkml/2vhd45kylttgonosdcfn7ugwyy2vx56gijwf3ealz4tel65iqr@cs3kxrl6d2hh/sound/soc/sunxi/sun8i-codec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)sound/soc/sunxi/sun8i-codec.c +0
-0
sound/soc/sunxi/sun8i-codec.c struct sun8i_codec { · line 235
Quoted 4 lines
sound/soc/sunxi/sun8i-codec.c +1
-0@@ -232,6 +232,7 @@ struct sun8i_codec {struct delayed_work jack_work;int jack_irq;int jack_status; +int jack_type;
Where is this variable set? Below I see just usage of its value.
Best regards,
Jernej
Quoted 60 lines
sound/soc/sunxi/sun8i-codec.c +6
-7int jack_last_sample;ktime_t jack_hbias_ready;struct mutex jack_mutex;@@ -1352,7 +1353,6 @@ static void sun8i_codec_jack_work(struct work_struct *work) struct sun8i_codec *scodec = container_of(work, struct sun8i_codec, jack_work.work);unsigned int mdata; -int type_mask = scodec->jack->jack->type;int type;guard (mutex)(&scodec->jack_mutex);@@ -1363,7 +1363,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) scodec->jack_last_sample =-1 ; -if (type_mask &SND_JACK_MICROPHONE ) { +if (scodec->jack_type &SND_JACK_MICROPHONE ) {/* * If we were in disconnected state, we enable HBIAS and * wait 600ms before reading initial HDATA value. @@ -1376,7 +1376,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) scodec->jack_status =SUN8I_JACK_STATUS_WAITING_HBIAS ; }else {snd_soc_jack_report (scodec->jack,SND_JACK_HEADPHONE , - type_mask); + scodec->jack_type); scodec->jack_status =SUN8I_JACK_STATUS_CONNECTED ; } }else if (scodec->jack_status ==SUN8I_JACK_STATUS_WAITING_HBIAS ) {@@ -1417,17 +1417,17 @@ static void sun8i_codec_jack_work(struct work_struct *work)if (type ==SND_JACK_HEADPHONE )sun8i_codec_set_hmic_bias (scodec, false); -snd_soc_jack_report (scodec->jack, type, type_mask); +snd_soc_jack_report (scodec->jack, type, scodec->jack_type); scodec->jack_status =SUN8I_JACK_STATUS_CONNECTED ; }else if (scodec->jack_status ==SUN8I_JACK_STATUS_CONNECTED ) {if (scodec->last_hmic_irq !=SUN8I_HMIC_STS_JACK_OUT_IRQ_ST )return ; scodec->jack_status =SUN8I_JACK_STATUS_DISCONNECTED ; -if (type_mask &SND_JACK_MICROPHONE ) +if (scodec->jack_type &SND_JACK_MICROPHONE )sun8i_codec_set_hmic_bias (scodec, false); -snd_soc_jack_report (scodec->jack,0 , type_mask); +snd_soc_jack_report (scodec->jack,0 , scodec->jack_type); } }@@ -1491,7 +1491,7 @@ static irqreturn_t sun8i_codec_jack_irq(int irq, void *dev_id)if (scodec->jack_last_sample >=0 && scodec->jack_last_sample == value)snd_soc_jack_report (scodec->jack, type, - scodec->jack->jack->type); + scodec->jack_type); scodec->jack_last_sample = value; }
Hello Jernej,
Quoted 16 lines · Jernej Škrabec
Dne sreda, 27. marec 2024 ob 09:05:34 CET je Ondřej Jirman napisal(a):
Quoted 15 lines
From: Ondrej Jirman <[email protected]>
When
CONFIG_SND_JACK_INPUT_DEVis disabled, structsnd_jackdoesn't have 'type' field. We can't rely on this field being always present, so store thejack_typein the codec driver itself.Signed-off-by Ondrej Jirman <[email protected]>Reported-by kernel test robot <[email protected]>---
This is a followup for https://lore.kernel.org/lkml/2vhd45kylttgonosdcfn7ugwyy2vx56gijwf3ealz4tel65iqr@cs3kxrl6d2hh/sound/soc/sunxi/sun8i-codec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Quoted 11 lines
sound/soc/sunxi/sun8i-codec.c struct sun8i_codec { · line 235
Quoted 9 lines
sound/soc/sunxi/sun8i-codec.c +1
-0@@ -232,6 +232,7 @@ struct sun8i_codec {struct delayed_work jack_work;int jack_irq;int jack_status; +int jack_type;Where is this variable set? Below I see just usage of its value.
It's going to be set in probe function, once generic DT bindings for jack-type are figured out. This is mentioned in the v3 cover letter for
https://lore.kernel.org/lkml/[email protected]/
I plan on sending support for generic property mentioned here
https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-component.c#L288
but it may need several iterations, and fail to get merged for various reasons and I may need to fall back to vendor DT property, then.
If you want to test/use the jack detection on some A64 board now, what's needed to enable this is to add:
scodec->jack_type = SND_JACK_HEADSET | SUN8I_CODEC_BUTTONS;
(or just SND_JACK_HEADPHONE, depednding on jack type)
to probe function and add get_jack_type callback to sun8i_soc_component:
static int sun8i_codec_component_get_jack_type(struct snd_soc_component *component)
{
struct sun8i_codec *scodec = snd_soc_component_get_drvdata(component);
return scodec->jack_type;}
Then detection will get enabled on A64 SoC based boards that use simple-audio-card. (if codec is in simple-audio-card,aux-devs)
Simple card iterates through aux devices and adds jacks for the ones that return something from component's get_jack_type() callback:
https://elixir.bootlin.com/linux/latest/source/sound/soc/generic/simple-card-utils.c#L822
kind regards,
o.
Quoted 67 lines
Best regards,
JernejQuoted 60 lines
sound/soc/sunxi/sun8i-codec.c +6
-7int jack_last_sample;ktime_t jack_hbias_ready;struct mutex jack_mutex;@@ -1352,7 +1353,6 @@ static void sun8i_codec_jack_work(struct work_struct *work) struct sun8i_codec *scodec = container_of(work, struct sun8i_codec, jack_work.work);unsigned int mdata; -int type_mask = scodec->jack->jack->type;int type;guard (mutex)(&scodec->jack_mutex);@@ -1363,7 +1363,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) scodec->jack_last_sample =-1 ; -if (type_mask &SND_JACK_MICROPHONE ) { +if (scodec->jack_type &SND_JACK_MICROPHONE ) {/* * If we were in disconnected state, we enable HBIAS and * wait 600ms before reading initial HDATA value. @@ -1376,7 +1376,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) scodec->jack_status =SUN8I_JACK_STATUS_WAITING_HBIAS ; }else {snd_soc_jack_report (scodec->jack,SND_JACK_HEADPHONE , - type_mask); + scodec->jack_type); scodec->jack_status =SUN8I_JACK_STATUS_CONNECTED ; } }else if (scodec->jack_status ==SUN8I_JACK_STATUS_WAITING_HBIAS ) {@@ -1417,17 +1417,17 @@ static void sun8i_codec_jack_work(struct work_struct *work)if (type ==SND_JACK_HEADPHONE )sun8i_codec_set_hmic_bias (scodec, false); -snd_soc_jack_report (scodec->jack, type, type_mask); +snd_soc_jack_report (scodec->jack, type, scodec->jack_type); scodec->jack_status =SUN8I_JACK_STATUS_CONNECTED ; }else if (scodec->jack_status ==SUN8I_JACK_STATUS_CONNECTED ) {if (scodec->last_hmic_irq !=SUN8I_HMIC_STS_JACK_OUT_IRQ_ST )return ; scodec->jack_status =SUN8I_JACK_STATUS_DISCONNECTED ; -if (type_mask &SND_JACK_MICROPHONE ) +if (scodec->jack_type &SND_JACK_MICROPHONE )sun8i_codec_set_hmic_bias (scodec, false); -snd_soc_jack_report (scodec->jack,0 , type_mask); +snd_soc_jack_report (scodec->jack,0 , scodec->jack_type); } }@@ -1491,7 +1491,7 @@ static irqreturn_t sun8i_codec_jack_irq(int irq, void *dev_id)if (scodec->jack_last_sample >=0 && scodec->jack_last_sample == value)snd_soc_jack_report (scodec->jack, type, - scodec->jack->jack->type); + scodec->jack_type); scodec->jack_last_sample = value; }
Mark Brown
maintainerQuoted 5 lines · Ondřej Jirman
When
CONFIG_SND_JACK_INPUT_DEVis disabled, structsnd_jackdoesn't have 'type' field. We can't rely on this field being always present, so store thejack_typein the codec driver itself.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: sun8i-codec: Fix build with CONFIG_SND_JACK_INPUT_DEV disabled
commit: 559aebe45a054a479fdbd2a3dfba999ffd73cc9d
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