Re: [alsa-devel] HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
+ state = jack->button_state; + if (get_jack_plug_state(jack->pin_sense)) + state |= jack->type; + snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
On Thu, 29 Nov 2018 08:22:39 +0100, Kailang wrote:
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
state = jack->button_state;
if (get_jack_plug_state(jack->pin_sense))
state |= jack->type;
snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
As we don't receive button-release events, it makes sense to send the button clear at each time, yes.
For the one-shot button event, you can handle like below.
--- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -343,6 +343,11 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) if (get_jack_plug_state(jack->pin_sense)) state |= jack->type; snd_jack_report(jack->jack, state); + if (jack->button_state) { + snd_jack_report(jack->jack, + state & ~jack->button_state); + jack->button_state = 0; /* button released */ + } } } EXPORT_SYMBOL_GPL(snd_hda_jack_report_sync);
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
Hi Takashi,
It looks no issue now. Could I need to generate new patch for you? I will send this patch to Intel to do the test.
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 3:45 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 08:22:39 +0100, Kailang wrote:
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
state = jack->button_state;
if (get_jack_plug_state(jack->pin_sense))
state |= jack->type;
snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
As we don't receive button-release events, it makes sense to send the button clear at each time, yes.
For the one-shot button event, you can handle like below.
--- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -343,6 +343,11 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) if (get_jack_plug_state(jack->pin_sense)) state |= jack->type; snd_jack_report(jack->jack, state); + if (jack->button_state) { + snd_jack_report(jack->jack, + state & ~jack->button_state); + jack->button_state = 0; /* button released */ + } } } EXPORT_SYMBOL_GPL(snd_hda_jack_report_sync);
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
On Thu, 29 Nov 2018 09:21:51 +0100, Kailang wrote:
Hi Takashi,
It looks no issue now. Could I need to generate new patch for you?
You can fold into mine. I'll need to resubmit to ML in anyway before merging.
I will send this patch to Intel to do the test.
OK, let me know the results (and preferably tested-by tag or such).
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 3:45 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 08:22:39 +0100, Kailang wrote:
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
state = jack->button_state;
if (get_jack_plug_state(jack->pin_sense))
state |= jack->type;
snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
As we don't receive button-release events, it makes sense to send the button clear at each time, yes.
For the one-shot button event, you can handle like below.
--- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -343,6 +343,11 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) if (get_jack_plug_state(jack->pin_sense)) state |= jack->type; snd_jack_report(jack->jack, state);
if (jack->button_state) {
snd_jack_report(jack->jack,
state & ~jack->button_state);
jack->button_state = 0; /* button released */
}}
} EXPORT_SYMBOL_GPL(snd_hda_jack_report_sync);
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
Hi Takashi,
I regenerated the patch as attach. I test passed already. Waiting for test result from Intel Chrome team. Many Thanks.
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 4:28 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 09:21:51 +0100, Kailang wrote:
Hi Takashi,
It looks no issue now. Could I need to generate new patch for you?
You can fold into mine. I'll need to resubmit to ML in anyway before merging.
I will send this patch to Intel to do the test.
OK, let me know the results (and preferably tested-by tag or such).
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 3:45 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 08:22:39 +0100, Kailang wrote:
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
state = jack->button_state;
if (get_jack_plug_state(jack->pin_sense))
state |= jack->type;
snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
As we don't receive button-release events, it makes sense to send the button clear at each time, yes.
For the one-shot button event, you can handle like below.
--- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -343,6 +343,11 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) if (get_jack_plug_state(jack->pin_sense)) state |= jack->type; snd_jack_report(jack->jack, state);
if (jack->button_state) {
snd_jack_report(jack->jack,
state & ~jack->button_state);
jack->button_state = 0; /* button released */
}}
} EXPORT_SYMBOL_GPL(snd_hda_jack_report_sync);
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
Hi Takashi,
Intel say .... it was not show headset plug and unplug. Is that necessary to show headphone and MIC plug and unplug {Event type 5 (EV_SW)}?
Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 114 (KEY_VOLUMEDOWN) Event code 115 (KEY_VOLUMEUP) Event code 164 (KEY_PLAYPAUSE) Event code 582 (?) Event type 5 (EV_SW) Event code 2 (SW_HEADPHONE_INSERT) Event code 4 (SW_MICROPHONE_INSERT) Properties: Testing ... (interrupt to exit) ***Following block of events is for one single event: pressing one of the buttons on headset*** Event: time 1543528786.148227, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1 Event: time 1543528786.148227, -------------- SYN_REPORT ------------ Event: time 1543528786.148249, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0 Event: time 1543528786.148249, -------------- SYN_REPORT ------------ ***No events show on evtest when plug or unplug jack***
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 4:28 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 09:21:51 +0100, Kailang wrote:
Hi Takashi,
It looks no issue now. Could I need to generate new patch for you?
You can fold into mine. I'll need to resubmit to ML in anyway before merging.
I will send this patch to Intel to do the test.
OK, let me know the results (and preferably tested-by tag or such).
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 3:45 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 08:22:39 +0100, Kailang wrote:
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
state = jack->button_state;
if (get_jack_plug_state(jack->pin_sense))
state |= jack->type;
snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
As we don't receive button-release events, it makes sense to send the button clear at each time, yes.
For the one-shot button event, you can handle like below.
--- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -343,6 +343,11 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) if (get_jack_plug_state(jack->pin_sense)) state |= jack->type; snd_jack_report(jack->jack, state);
if (jack->button_state) {
snd_jack_report(jack->jack,
state & ~jack->button_state);
jack->button_state = 0; /* button released */
}}
} EXPORT_SYMBOL_GPL(snd_hda_jack_report_sync);
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
On Fri, 30 Nov 2018 07:45:04 +0100, Kailang wrote:
Hi Takashi,
Intel say .... it was not show headset plug and unplug. Is that necessary to show headphone and MIC plug and unplug {Event type 5 (EV_SW)}?
If so, it means that the unsol events aren't set up for the proper pins.
Takashi
Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 114 (KEY_VOLUMEDOWN) Event code 115 (KEY_VOLUMEUP) Event code 164 (KEY_PLAYPAUSE) Event code 582 (?) Event type 5 (EV_SW) Event code 2 (SW_HEADPHONE_INSERT) Event code 4 (SW_MICROPHONE_INSERT) Properties: Testing ... (interrupt to exit) ***Following block of events is for one single event: pressing one of the buttons on headset*** Event: time 1543528786.148227, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1 Event: time 1543528786.148227, -------------- SYN_REPORT ------------ Event: time 1543528786.148249, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0 Event: time 1543528786.148249, -------------- SYN_REPORT ------------ ***No events show on evtest when plug or unplug jack***
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 4:28 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 09:21:51 +0100, Kailang wrote:
Hi Takashi,
It looks no issue now. Could I need to generate new patch for you?
You can fold into mine. I'll need to resubmit to ML in anyway before merging.
I will send this patch to Intel to do the test.
OK, let me know the results (and preferably tested-by tag or such).
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 3:45 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 08:22:39 +0100, Kailang wrote:
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
state = jack->button_state;
if (get_jack_plug_state(jack->pin_sense))
state |= jack->type;
snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
As we don't receive button-release events, it makes sense to send the button clear at each time, yes.
For the one-shot button event, you can handle like below.
--- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -343,6 +343,11 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) if (get_jack_plug_state(jack->pin_sense)) state |= jack->type; snd_jack_report(jack->jack, state);
if (jack->button_state) {
snd_jack_report(jack->jack,
state & ~jack->button_state);
jack->button_state = 0; /* button released */
}}
} EXPORT_SYMBOL_GPL(snd_hda_jack_report_sync);
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
Hi Takashi,
Intel Chrome team agree the patch and test passed. I told them, it didn't need to show the headphone and MIC present event in BTN key function. Patch for patch_realtek.c that I change the COEF index 0x48's value to 0xd011. Please use attach 0003-* to apply. Thanks. So, it could apply it to upstream now.
+ case HDA_FIXUP_ACT_INIT: + switch (codec->core.vendor_id) { + case 0x10ec0225: + case 0x10ec0295: + case 0x10ec0299: + alc_write_coef_idx(codec, 0x48, 0xd011); + alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045); + alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8); + break; + case 0x10ec0236: + case 0x10ec0256: + alc_write_coef_idx(codec, 0x48, 0xd011); + alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045); + break; + } + break; + }
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Tuesday, December 4, 2018 12:34 AM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Fri, 30 Nov 2018 07:45:04 +0100, Kailang wrote:
Hi Takashi,
Intel say .... it was not show headset plug and unplug. Is that necessary to show headphone and MIC plug and unplug {Event type 5 (EV_SW)}?
If so, it means that the unsol events aren't set up for the proper pins.
Takashi
Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 114 (KEY_VOLUMEDOWN) Event code 115 (KEY_VOLUMEUP) Event code 164 (KEY_PLAYPAUSE) Event code 582 (?) Event type 5 (EV_SW) Event code 2 (SW_HEADPHONE_INSERT) Event code 4 (SW_MICROPHONE_INSERT) Properties: Testing ... (interrupt to exit) ***Following block of events is for one single event: pressing one of the buttons on headset*** Event: time 1543528786.148227, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1 Event: time 1543528786.148227, -------------- SYN_REPORT ------------ Event: time 1543528786.148249, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0 Event: time 1543528786.148249, -------------- SYN_REPORT ------------ ***No events show on evtest when plug or unplug jack***
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 4:28 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 09:21:51 +0100, Kailang wrote:
Hi Takashi,
It looks no issue now. Could I need to generate new patch for you?
You can fold into mine. I'll need to resubmit to ML in anyway before merging.
I will send this patch to Intel to do the test.
OK, let me know the results (and preferably tested-by tag or such).
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Thursday, November 29, 2018 3:45 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Thu, 29 Nov 2018 08:22:39 +0100, Kailang wrote:
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
state = jack->button_state;
if (get_jack_plug_state(jack->pin_sense))
state |= jack->type;
snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
As we don't receive button-release events, it makes sense to send the button clear at each time, yes.
For the one-shot button event, you can handle like below.
--- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -343,6 +343,11 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) if (get_jack_plug_state(jack->pin_sense)) state |= jack->type; snd_jack_report(jack->jack, state);
if (jack->button_state) {
snd_jack_report(jack->jack,
state & ~jack->button_state);
jack->button_state = 0; /* button released */
}}
} EXPORT_SYMBOL_GPL(snd_hda_jack_report_sync);
thanks,
Takashi
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
On Fri, 07 Dec 2018 08:32:43 +0100, Kailang wrote:
Hi Takashi,
Intel Chrome team agree the patch and test passed. I told them, it didn't need to show the headphone and MIC present event in BTN key function. Patch for patch_realtek.c that I change the COEF index 0x48's value to 0xd011. Please use attach 0003-* to apply. Thanks. So, it could apply it to upstream now.
OK, I applied the split two patches for the first one as my original patches, and 0003-* on top of it.
thanks,
Takashi
Hi Takashi,
Belowing was the unplug dump. [ 5184.677125] snd_hda_jack_unsol_event nid=0x21 res=0x8000020 tag=0x2 [ 5184.696467] snd_hda_jack_report_sync nid=0x55 state=0x800 jack->pin_sense=0x0 [ 5184.696477] snd_hda_jack_report_sync nid=0x21 state=0x0 jack->pin_sense=0x0 [ 5184.696481] snd_hda_jack_report_sync nid=0x19 state=0x2 jack->pin_sense=0x80000000 [ 5184.696484] snd_hda_jack_report_sync nid=0x12 state=0x2 jack->pin_sense=0x80000000 [ 5184.696486] snd_hda_jack_report_sync nid=0x14 state=0x4 jack->pin_sense=0x80000000 [ 5184.696490] snd_hda_jack_unsol_event nid=0x19 res=0xc000000 tag=0x3 [ 5184.716529] snd_hda_jack_report_sync nid=0x55 state=0x800 jack->pin_sense=0x0 [ 5184.716537] snd_hda_jack_report_sync nid=0x21 state=0x0 jack->pin_sense=0x0 [ 5184.716545] snd_hda_jack_report_sync nid=0x19 state=0x0 jack->pin_sense=0x0 [ 5184.716548] snd_hda_jack_report_sync nid=0x12 state=0x2 jack->pin_sense=0x80000000 [ 5184.716551] snd_hda_jack_report_sync nid=0x14 state=0x4 jack->pin_sense=0x80000000
[ 5184.696467] snd_hda_jack_report_sync nid=0x55 state=0x800 jack->pin_sense=0x0
If state of 0x55 keep value, plug and unplug jack will update 0x55 button sync. I test add the code to clear the jack->button_state = 0. The issue will be gone.
But why 0x14 and 0x12 had pin sens? [ 5184.716548] snd_hda_jack_report_sync nid=0x12 state=0x2 jack->pin_sense=0x80000000 [ 5184.716551] snd_hda_jack_report_sync nid=0x14 state=0x4 jack->pin_sense=0x80000000
This modify also update for all pins. When I test press the HS button, the dump show as upper list.
BR, Kailang
-----Original Message----- From: Kailang Sent: Thursday, November 29, 2018 3:03 PM To: 'Takashi Iwai' tiwai@suse.de Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: RE: HDA headset button support
Hi Takashi,
I test the patch. It will go to Max or Min volume when I press HS button up or down.
+ state = jack->button_state; + if (get_jack_plug_state(jack->pin_sense)) + state |= jack->type; + snd_jack_report(jack->jack, state); If (jack->nid == 0x55) snd_jack_report(jack->jack, 0); ==> Add this will solve keep volume up and down.
If the pin sense active, it will update Mic and Headphone state. (Upper code) But it still had chance to update 0x55 during unplug and plug state. So, Maybe need to clear the Button state. I guess.
BR, Kailang
-----Original Message----- From: Takashi Iwai tiwai@suse.de Sent: Wednesday, November 28, 2018 10:05 PM To: Kailang kailang@realtek.com Cc: (alsa-devel@alsa-project.org) alsa-devel@alsa-project.org Subject: Re: HDA headset button support
On Wed, 28 Nov 2018 13:03:58 +0100, Kailang wrote:
Hi Takashi,
I'd rather like to extend snd_hda_jack_add_kctl() with the key support (maybe adding a new function). You can pass there the combination of SND_JACK_BTN_X with KEY_XXX in an array.
Do you mean create new function like below? snd_hda_jack_add_key_kctl()
It couldn't use snd_hda_jack_add_kctl() directly. Because it had report pin state and get type from NID.
type = get_input_jack_type(codec, nid); ..... ..... state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0);
So, to create a new function in hda_jack.c was better.
Well, this seems more deeper than I thought.
Below is my quick attempt to add the infrastructure. This adds more flexibility but still easiness for other possible button implementations, hopefully.
Could you check the series below?
thanks,
Takashi
------Please consider the environment before printing this e-mail.
participants (2)
-
Kailang
-
Takashi Iwai