ALSA - hda: hdmi flag to stop playback when monitor is disconnected
PATCH 1/1 ALSA - hda: hdmi flag to stop playback when monitor is disconnected
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.
Besides, stopping playback when monitor is disconnected will help to save the power.
--- sound/pci/hda/patch_hdmi.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
sound/pci/hda/patch_hdmi.c +34 -0
@@ -47,6 +47,11 @@ static bool static_hdmi_pcm;module_param (static_hdmi_pcm, bool,0644 );MODULE_PARM_DESC (static_hdmi_pcm,"Don't restrict PCM parameters per ELD info" ); +static bool hdmi_pcm_stop_on_disconnect; +module_param (hdmi_pcm_stop_on_disconnect, bool,0644 ); +MODULE_PARM_DESC (hdmi_pcm_stop_on_disconnect, +"Stop PCM when monitor is disconnected" ); +#define is_haswell (codec) ((codec)->core.vendor_id == 0x80862807)#define is_broadwell (codec) ((codec)->core.vendor_id == 0x80862808)#define is_skylake (codec) ((codec)->core.vendor_id == 0x80862809)
@@ -72,6 +77,7 @@ struct hdmi_spec_per_cvt {struct hdmi_spec_per_pin {hda_nid_t pin_nid; +int pin_idx;int num_mux_nids;hda_nid_t mux_nids[HDA_MAX_CONNECTIONS ];int mux_idx;
@@ -1456,6 +1462,9 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, per_pin =get_pin (spec, pin_idx); eld = &per_pin->sink_eld; +if (hdmi_pcm_stop_on_disconnect && !eld->eld_valid) +return -ENODEV ; + err =hdmi_choose_cvt (codec, pin_idx, &cvt_idx, &mux_idx);if (err <0 )return err;
@@ -1529,6 +1538,28 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)return 0 ; } +static void hdmi_pcm_stop (struct hdmi_spec *spec, +struct hdmi_spec_per_pin *per_pin) +{ +struct hda_codec *codec = per_pin->codec; +struct snd_pcm_substream *substream; +int pin_idx = per_pin->pin_idx; + +if (!hdmi_pcm_stop_on_disconnect) +return ; + + substream =get_pcm_rec (spec, pin_idx)->pcm->streams[0 ].substream; + +snd_pcm_stream_lock_irq (substream); +if (substream && substream->runtime && +snd_pcm_running (substream)) { +codec_info (codec, +"HDMI: monitor disconnected, try to stop playback\n" ); +snd_pcm_stop (substream,SNDRV_PCM_STATE_DISCONNECTED ); + } +snd_pcm_stream_unlock_irq (substream); +} +static bool hdmi_present_sense (struct hdmi_spec_per_pin *per_pin,int repoll) {struct hda_jack_tbl *jack;
@@ -1586,6 +1617,8 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) } } +if (!eld->eld_valid) +hdmi_pcm_stop (spec, per_pin);if (pin_eld->eld_valid != eld->eld_valid) eld_changed = true;
@@ -1680,6 +1713,7 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)return -ENOMEM ; per_pin->pin_nid = pin_nid; + per_pin->pin_idx = pin_idx; per_pin->non_pcm = false; err =hdmi_read_pin_conn (codec, pin_idx);
Signature · 1 line
1.9.1
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.
Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>
Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
David, care to check in your side, too?
Quoted 9 lines
--- sound/pci/hda/patch_hdmi.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)sound/pci/hda/patch_hdmi.c +0
-0
sound/pci/hda/patch_hdmi.c static bool static_hdmi_pcm; · line 53
Quoted 7 lines
sound/pci/hda/patch_hdmi.c +4
-0@@ -47,6 +47,11 @@ static bool static_hdmi_pcm;module_param (static_hdmi_pcm, bool,0644 );MODULE_PARM_DESC (static_hdmi_pcm,"Don't restrict PCM parameters per ELD info" ); +static bool hdmi_pcm_stop_on_disconnect; +module_param (hdmi_pcm_stop_on_disconnect, bool,0644 ); +MODULE_PARM_DESC (hdmi_pcm_stop_on_disconnect, +"Stop PCM when monitor is disconnected" );
This codec driver may be used for multiple devices, e.g. an onboard GPU and a discrete GPU. Whether a single flag is best is a slight concern. Though, as a test patch, it certainly suffices.
Quoted 12 lines
sound/pci/hda/patch_hdmi.c +1
-0#define is_haswell (codec) ((codec)->core.vendor_id == 0x80862807)#define is_broadwell (codec) ((codec)->core.vendor_id == 0x80862808)#define is_skylake (codec) ((codec)->core.vendor_id == 0x80862809)@@ -72,6 +77,7 @@ struct hdmi_spec_per_cvt {struct hdmi_spec_per_pin {hda_nid_t pin_nid; +int pin_idx;int num_mux_nids;hda_nid_t mux_nids[HDA_MAX_CONNECTIONS ];int mux_idx;
sound/pci/hda/patch_hdmi.c static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, · line 1466
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +2
-0@@ -1456,6 +1462,9 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, per_pin =get_pin (spec, pin_idx); eld = &per_pin->sink_eld; +if (hdmi_pcm_stop_on_disconnect && !eld->eld_valid) +return -ENODEV ;
An error code might influence on behavior, so let's check it carefully while testing.
Quoted 12 lines
sound/pci/hda/patch_hdmi.c +5
-0err =hdmi_choose_cvt (codec, pin_idx, &cvt_idx, &mux_idx);if (err <0 )return err;@@ -1529,6 +1538,28 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)return 0 ; } +static void hdmi_pcm_stop (struct hdmi_spec *spec, +struct hdmi_spec_per_pin *per_pin) +{ +struct hda_codec *codec = per_pin->codec; +struct snd_pcm_substream *substream;
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) · line 1555
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +10
-0+int pin_idx = per_pin->pin_idx; + +if (!hdmi_pcm_stop_on_disconnect) +return ; + + substream =get_pcm_rec (spec, pin_idx)->pcm->streams[0 ].substream; + +snd_pcm_stream_lock_irq (substream); +if (substream && substream->runtime && +snd_pcm_running (substream)) {
substream NULL check has to be before the lock.
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) · line 1557
Quoted 2 lines
sound/pci/hda/patch_hdmi.c +2
-0+codec_info (codec, +"HDMI: monitor disconnected, try to stop playback\n" );
The message is good for testing, but no need to spam at each disconnect in the production state. Use codec_dbg() in the final patch.
thanks,
Takashi
Quoted 28 lines
sound/pci/hda/patch_hdmi.c +8
-0+snd_pcm_stop (substream,SNDRV_PCM_STATE_DISCONNECTED ); + } +snd_pcm_stream_unlock_irq (substream); +} +static bool hdmi_present_sense (struct hdmi_spec_per_pin *per_pin,int repoll) {struct hda_jack_tbl *jack;@@ -1586,6 +1617,8 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) } } +if (!eld->eld_valid) +hdmi_pcm_stop (spec, per_pin);if (pin_eld->eld_valid != eld->eld_valid) eld_changed = true;@@ -1680,6 +1713,7 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)return -ENOMEM ; per_pin->pin_nid = pin_nid; + per_pin->pin_idx = pin_idx; per_pin->non_pcm = false; err =hdmi_read_pin_conn (codec, pin_idx);Signature · 1 line
1.9.1
Quoted 18 lines · Takashi Iwai
Quoted 15 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Besides, stopping playback when monitor is disconnected will help to save the power.
Quoted 7 lines
Quoted 1 line
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated again
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
Takashi
Quoted 110 lines
Quoted 10 lines
--- sound/pci/hda/patch_hdmi.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)sound/pci/hda/patch_hdmi.c +0
-0sound/pci/hda/patch_hdmi.c static bool static_hdmi_pcm; · line 53
Quoted 7 lines
sound/pci/hda/patch_hdmi.c +4
-0@@ -47,6 +47,11 @@ static bool static_hdmi_pcm;module_param (static_hdmi_pcm, bool,0644 );MODULE_PARM_DESC (static_hdmi_pcm,"Don't restrict PCM parameters per ELD info" ); +static bool hdmi_pcm_stop_on_disconnect; +module_param (hdmi_pcm_stop_on_disconnect, bool,0644 ); +MODULE_PARM_DESC (hdmi_pcm_stop_on_disconnect, +"Stop PCM when monitor is disconnected" );This codec driver may be used for multiple devices, e.g. an onboard GPU and a discrete GPU. Whether a single flag is best is a slight concern. Though, as a test patch, it certainly suffices.
Quoted 12 lines
sound/pci/hda/patch_hdmi.c +1
-0#define is_haswell (codec) ((codec)->core.vendor_id == 0x80862807)#define is_broadwell (codec) ((codec)->core.vendor_id == 0x80862808)#define is_skylake (codec) ((codec)->core.vendor_id == 0x80862809)@@ -72,6 +77,7 @@ struct hdmi_spec_per_cvt {struct hdmi_spec_per_pin {hda_nid_t pin_nid; +int pin_idx;int num_mux_nids;hda_nid_t mux_nids[HDA_MAX_CONNECTIONS ];int mux_idx;sound/pci/hda/patch_hdmi.c static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, · line 1466
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +2
-0@@ -1456,6 +1462,9 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, per_pin =get_pin (spec, pin_idx); eld = &per_pin->sink_eld; +if (hdmi_pcm_stop_on_disconnect && !eld->eld_valid) +return -ENODEV ;An error code might influence on behavior, so let's check it carefully while testing.
Quoted 12 lines
sound/pci/hda/patch_hdmi.c +5
-0err =hdmi_choose_cvt (codec, pin_idx, &cvt_idx, &mux_idx);if (err <0 )return err;@@ -1529,6 +1538,28 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)return 0 ; } +static void hdmi_pcm_stop (struct hdmi_spec *spec, +struct hdmi_spec_per_pin *per_pin) +{ +struct hda_codec *codec = per_pin->codec; +struct snd_pcm_substream *substream;sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) · line 1555
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +10
-0+int pin_idx = per_pin->pin_idx; + +if (!hdmi_pcm_stop_on_disconnect) +return ; + + substream =get_pcm_rec (spec, pin_idx)->pcm->streams[0 ].substream; + +snd_pcm_stream_lock_irq (substream); +if (substream && substream->runtime && +snd_pcm_running (substream)) {substream NULL check has to be before the lock.
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) · line 1557
Quoted 2 lines
sound/pci/hda/patch_hdmi.c +2
-0+codec_info (codec, +"HDMI: monitor disconnected, try to stop playback\n" );The message is good for testing, but no need to spam at each disconnect in the production state. Use
codec_dbg()in the final patch.thanks,
Takashi
Quoted 28 lines
sound/pci/hda/patch_hdmi.c +8
-0+snd_pcm_stop (substream,SNDRV_PCM_STATE_DISCONNECTED ); + } +snd_pcm_stream_unlock_irq (substream); +} +static bool hdmi_present_sense (struct hdmi_spec_per_pin *per_pin,int repoll) {struct hda_jack_tbl *jack;@@ -1586,6 +1617,8 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) } } +if (!eld->eld_valid) +hdmi_pcm_stop (spec, per_pin);if (pin_eld->eld_valid != eld->eld_valid) eld_changed = true;@@ -1680,6 +1713,7 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)return -ENOMEM ; per_pin->pin_nid = pin_nid; + per_pin->pin_idx = pin_idx; per_pin->non_pcm = false; err =hdmi_read_pin_conn (codec, pin_idx);Signature · 1 line
1.9.1
Quoted 36 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 24 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated again
Thanks for test.
If so, should we re-write the hdmi_pcm_open() and generic_hdmi_playback_pcm_prepare() function to make the probe works? Or not support dynamic pcm assignment?
Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
Quoted 128 lines
Takashi
Quoted 3 lines
Quoted 3 lines
--- sound/pci/hda/patch_hdmi.c | 34++++++++++++++++++++++++++++++++++
Quoted 3 lines
Review
Quoted 3 lines
1 file changed, 34 insertions(+)(quoted diff) +0
-0
b/sound/pci/hda/patch_hdmi.cQuoted 6 lines
sound/pci/hda/patch_hdmi.c static bool static_hdmi_pcm; · line 48
Quoted 6 lines
index f503a88..4f5023a 100644
sound/pci/hda/patch_hdmi.c +0
-0@@ -47,6 +47,11 @@ static bool static_hdmi_pcm;module_param (static_hdmi_pcm, bool,0644 ); MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCMparameters per ELD info");
Quoted 5 lines
sound/pci/hda/patch_hdmi.c static bool static_hdmi_pcm;
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +4
-0+static bool hdmi_pcm_stop_on_disconnect; +module_param (hdmi_pcm_stop_on_disconnect, bool,0644 ); +MODULE_PARM_DESC(hdmi_pcm_stop_on_disconnect, + "Stop PCM when monitor isdisconnected");
Quoted 7 lines
This codec driver may be used for multiple devices, e.g. an onboard GPU and a discrete GPU. Whether a single flag is best is a slight concern. Though, as a test patch, it certainly suffices.
Quoted 2 lines
sound/pci/hda/patch_hdmi.c +0
-0#define is_haswell (codec) ((codec)->core.vendor_id == 0x80862807)#define is_broadwell (codec) ((codec)->core.vendor_id ==
0x80862808)Quoted 10 lines
sound/pci/hda/patch_hdmi.c static int hdmi_pcm_open(struct
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +1
-0#define is_skylake (codec) ((codec)->core.vendor_id == 0x80862809)@@ -72,6 +77,7 @@ struct hdmi_spec_per_cvt {struct hdmi_spec_per_pin {hda_nid_t pin_nid; +int pin_idx;int num_mux_nids;hda_nid_t mux_nids[HDA_MAX_CONNECTIONS ];int mux_idx;@@ -1456,6 +1462,9 @@ static int hdmi_pcm_open(struct
hda_pcm_stream*hinfo,Quoted 10 lines
sound/pci/hda/patch_hdmi.c static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, · line 1466
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +2
-0per_pin =get_pin (spec, pin_idx); eld = &per_pin->sink_eld; +if (hdmi_pcm_stop_on_disconnect && !eld->eld_valid) +return -ENODEV ;An error code might influence on behavior, so let's check it carefully while testing.
Quoted 4 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct
Quoted 4 lines
sound/pci/hda/patch_hdmi.c +0
-0err =hdmi_choose_cvt (codec, pin_idx, &cvt_idx, &mux_idx);if (err <0 )return err;@@ -1529,6 +1538,28 @@ static int hdmi_read_pin_conn(struct
hda_codec*codec, intpin_idx)Quoted 5 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +2
-0return 0 ; } +static void hdmi_pcm_stop (struct hdmi_spec *spec, + struct hdmi_spec_per_pin
*per_pin)Quoted 18 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
Quoted 9 lines
sound/pci/hda/patch_hdmi.c +9
-0+{ +struct hda_codec *codec = per_pin->codec; +struct snd_pcm_substream *substream; +int pin_idx = per_pin->pin_idx; + +if (!hdmi_pcm_stop_on_disconnect) +return ; + + substream = get_pcm_rec(spec, pin_idx)->pcm-streams[0].substream;
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) · line 1555
Quoted 4 lines
sound/pci/hda/patch_hdmi.c +4
-0+ +snd_pcm_stream_lock_irq (substream); +if (substream && substream->runtime && +snd_pcm_running (substream)) {substream NULL check has to be before the lock.
Quoted 2 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct · line 1557
Quoted 2 lines
sound/pci/hda/patch_hdmi.c +2
-0+ codec_info(codec, + "HDMI: monitor disconnected, try to stopplayback\n");
Quoted 11 lines
The message is good for testing, but no need to spam at each disconnect in the production state. Use
codec_dbg()in the final patch.thanks,
Takashi
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct · line 1558
Quoted 1 line
sound/pci/hda/patch_hdmi.c +1
-0+ snd_pcm_stop(substream,
SNDRV_PCM_STATE_DISCONNECTED);Quoted 5 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +4
-0+ } +snd_pcm_stream_unlock_irq (substream); +} + static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin,int repoll)
Quoted 3 lines
sound/pci/hda/patch_hdmi.c static bool hdmi_present_sense(struct
Quoted 3 lines
sound/pci/hda/patch_hdmi.c +0
-0{struct hda_jack_tbl *jack;@@ -1586,6 +1617,8 @@ static bool hdmi_present_sense(struct
hdmi_spec_per_pin*per_pin, int repoll)Quoted 9 lines
sound/pci/hda/patch_hdmi.c static int hdmi_add_pin(struct hda_codec
Quoted 9 lines
sound/pci/hda/patch_hdmi.c +2
-0} } +if (!eld->eld_valid) +hdmi_pcm_stop (spec, per_pin);if (pin_eld->eld_valid != eld->eld_valid) eld_changed = true;@@ -1680,6 +1713,7 @@ static int hdmi_add_pin(struct hda_codec*codec,
hda_nid_tpin_nid)Quoted 10 lines
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +1
-1return -ENOMEM ; per_pin->pin_nid = pin_nid; + per_pin->pin_idx = pin_idx; per_pin->non_pcm = false; err =hdmi_read_pin_conn (codec, pin_idx); --1.9.1
Quoted 50 lines · Libin
Quoted 37 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 24 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated againThanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?
Quoted 5 lines
Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
One obvious options is: we don't care about it. Maybe care it only when really needed, e.g. return an error only in prepare and cleanup, but not in open.
Takashi
Quoted 67 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:42 PM
To: Yang, Libin
Cc: [email protected]; David Henningsson; alsa-devel@alsa- project.org; [email protected]
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 14 lines · Libin
Quoted 14 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 1 line · Takashi Iwai
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open
PCM
Quoted 32 lines
Quoted 16 lines
Quoted 16 lines
Quoted 11 lines
if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated againThanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
Quoted 6 lines
Quoted 2 lines
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
One obvious options is: we don't care about it. Maybe care it only when really needed, e.g. return an error only in prepare and cleanup, but not in open.
Get it. I will refine the patch.
So we will not care the disconnect when playback and not stop the PCM?
If we don't stop pcm, how to handle connect a different monitor? It seems userspace must handle such scenario.
Regards,
Libin
Quoted 3 lines
Takashi
Quoted 75 lines · Libin
Quoted 68 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:42 PM
To: Yang, Libin
Cc: [email protected]; David Henningsson; alsa-devel@alsa- project.org; [email protected]
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 14 lines · Libin
Quoted 14 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 1 line · Takashi Iwai
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open
PCM
Quoted 32 lines
Quoted 16 lines
Quoted 16 lines
Quoted 11 lines
if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated againThanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
Quoted 6 lines
Quoted 2 lines
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
One obvious options is: we don't care about it. Maybe care it only when really needed, e.g. return an error only in prepare and cleanup, but not in open.
Quoted 7 lines
Get it. I will refine the patch.
So we will not care the disconnect when playback and not stop the PCM?
If we don't stop pcm, how to handle connect a different monitor? It seems userspace must handle such scenario.
Yes. The driver just wishes that user-space reacts.
Of course, you can do more complex. It's only the question about user-space interface, so you can actually stop the stream but makes it appearing as if a normal error to user-space. But I don't think it's worth to play with.
Takashi
Quoted 100 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:58 PM
To: Yang, Libin
Cc: [email protected]; David Henningsson; alsa-devel@alsa- project.org; [email protected]
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 28 lines · Libin
Quoted 28 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:42 PM
To: Yang, Libin
Cc: [email protected]; David Henningsson; alsa-devel@alsa- project.org; [email protected]
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 14 lines · Libin
Quoted 14 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 1 line · Takashi Iwai
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback
when
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
the corresponding monitor is disconnected and refuse to open
PCM
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor isconnected,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
the parameters of the 2 monitors may be different. Audio
driver
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
need handle this situation.
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA,
then
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
respin with the fixes.
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated againQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Thanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?Quoted 1 line
- PA removes the device when it's disconnected. The PCM stop
with
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
One obvious options is: we don't care about it. Maybe care it only when really needed, e.g. return an error only in prepare and cleanup, but not in open.
Quoted 7 lines
Get it. I will refine the patch.
So we will not care the disconnect when playback and not stop the PCM?
If we don't stop pcm, how to handle connect a different monitor? It seems userspace must handle such scenario.
Quoted 6 lines
Yes. The driver just wishes that user-space reacts.
Of course, you can do more complex. It's only the question about user-space interface, so you can actually stop the stream but makes it appearing as if a normal error to user-space. But I don't think it's worth to play with.
Get it. Hope gfx is OK for it :)
Quoted 3 lines
Takashi
Quoted 36 lines · Libin
Quoted 36 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 24 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated again
...and that's the expected behaviour given how PA works today. Which also means that this new parameter should not be enabled by default, unless we want to break PA 7.1 and earlier versions.
Quoted 6 lines
Thanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?
I've already suggested how we can make it work, by assigning converter nodes dynamically regardless of whether or not the PCM has a monitor connected to it.
Keeping the power well on for up to five seconds (and often much less) during boot should not be a big deal power saving wise, so the power save argument doesn't hold IMO.
Quoted 5 lines
Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
The current behavior is to keep the PCM running, which also has the benefit to be able to switch monitors on the fly (i e without stopping the stream), if both support the stream format. At least I think one can do this, I've actually never tried.
While reporting -ENODEV for a disconnected monitor seems useful to some scenarios, there are certainly other scenarios where it doesn't work.
PA should use the ELD and/or the Jack kctl to figure out when it needs to reprobe the device. This has not been implemented.
Signature · 2 lines
David Henningsson, Canonical Ltd. https://launchpad.net/~diwic
Quoted 55 lines · David Henningsson
Quoted 38 lines · Libin
Quoted 38 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 26 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first,
especially to see whether it has any significant influence on PA, then
respin with the fixes.Quoted 6 lines
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated again...and that's the expected behaviour given how PA works today. Which also means that this new parameter should not be enabled by default, unless we want to break PA 7.1 and earlier versions.
Quoted 3 lines
Thanks for test.
Quoted 7 lines
Quoted 3 lines
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?I've already suggested how we can make it work, by assigning converter nodes dynamically regardless of whether or not the PCM has a monitor connected to it.
It means the PCM will hold the converter even no monitor is connected. When will PA release the converter? If PA can't release converter in time, other PCM will not find a proper converter. Especially in probe time, will it cause probe failure?
Quoted 4 lines
Keeping the power well on for up to five seconds (and often much less) during boot should not be a big deal power saving wise, so the power save argument doesn't hold IMO.
That's fine for power saving.
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
The current behavior is to keep the PCM running, which also has the benefit to be able to switch monitors on the fly (i e without stopping the stream), if both support the stream format. At least I think one can do this, I've actually never tried.
Yes, we will keep PCM running even when monitor is disconnected.
Regards,
Libin
Quoted 8 lines
While reporting
-ENODEVfor a disconnected monitor seems useful to some scenarios, there are certainly other scenarios where it doesn't work.PA should use the ELD and/or the Jack kctl to figure out when it needs to reprobe the device. This has not been implemented.
Quoted 61 lines · Libin Yang
Quoted 59 lines · David Henningsson
Quoted 38 lines · Libin
Quoted 38 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 26 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first,
especially to see whether it has any significant influence on PA, then
respin with the fixes.Quoted 6 lines
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated again...and that's the expected behaviour given how PA works today. Which also means that this new parameter should not be enabled by default, unless we want to break PA 7.1 and earlier versions.
Quoted 6 lines
Thanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?
Quoted 5 lines
Quoted 3 lines
I've already suggested how we can make it work, by assigning converter nodes dynamically regardless of whether or not the PCM has a monitor connected to it.
It means the PCM will hold the converter even no monitor is connected.
As long as the PCM is open, yes.
Quoted 3 lines
When will PA release the converter? If PA can't release converter in time, other PCM will not find a proper converter. Especially in probe time, will it cause probe failure?
During probe, PA probes one output + one input at a time (at least by default). E g, before PA tries to open "hdmi:0,1", it closes "hdmi:0,0". And when PA calls snd_pcm_close, that should also make the driver release the converter node.
Quoted 32 lines
Quoted 3 lines
Keeping the power well on for up to five seconds (and often much less) during boot should not be a big deal power saving wise, so the power save argument doesn't hold IMO.
That's fine for power saving.
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
The current behavior is to keep the PCM running, which also has the benefit to be able to switch monitors on the fly (i e without stopping the stream), if both support the stream format. At least I think one can do this, I've actually never tried.
Yes, we will keep PCM running even when monitor is disconnected.
Regards,
LibinQuoted 8 lines
While reporting
-ENODEVfor a disconnected monitor seems useful to some scenarios, there are certainly other scenarios where it doesn't work.PA should use the ELD and/or the Jack kctl to figure out when it needs to reprobe the device. This has not been implemented.
Signature · 2 lines
David Henningsson, Canonical Ltd. https://launchpad.net/~diwic
Quoted 72 lines · David Henningsson
Quoted 61 lines · Libin Yang
Quoted 59 lines · David Henningsson
Quoted 38 lines · Libin
Quoted 38 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 26 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first,
especially to see whether it has any significant influence on PA, then
respin with the fixes.Quoted 6 lines
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated again...and that's the expected behaviour given how PA works today. Which also means that this new parameter should not be enabled by default, unless we want to break PA 7.1 and earlier versions.
Quoted 6 lines
Thanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?Quoted 5 lines
Quoted 3 lines
I've already suggested how we can make it work, by assigning converter nodes dynamically regardless of whether or not the PCM has a monitor connected to it.
It means the PCM will hold the converter even no monitor is connected.
As long as the PCM is open, yes.
Quoted 8 lines
Quoted 3 lines
When will PA release the converter? If PA can't release converter in time, other PCM will not find a proper converter. Especially in probe time, will it cause probe failure?
During probe, PA probes one output + one input at a time (at least by default). E g, before PA tries to open "hdmi:0,1", it closes "hdmi:0,0". And when PA calls
snd_pcm_close, that should also make the driver release the converter node.
That's good. I will try it if Takashi is OK.
Thanks,
Libin
Quoted 34 lines
Quoted 33 lines
Quoted 4 lines
Keeping the power well on for up to five seconds (and often much less) during boot should not be a big deal power saving wise, so the power save argument doesn't hold IMO.
That's fine for power saving.
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
The current behavior is to keep the PCM running, which also has the benefit to be able to switch monitors on the fly (i e without stopping the stream), if both support the stream format. At least I think one can do this, I've actually never tried.
Yes, we will keep PCM running even when monitor is disconnected.
Regards,
LibinQuoted 8 lines
While reporting
-ENODEVfor a disconnected monitor seems useful to some scenarios, there are certainly other scenarios where it doesn't work.PA should use the ELD and/or the Jack kctl to figure out when it needs to reprobe the device. This has not been implemented.
Quoted 59 lines
-----Original Message-----
From: Yang, Libin
Sent: Wednesday, November 11, 2015 10:24 PM
To: 'Takashi Iwai'; [email protected]
Cc: David Henningsson; [email protected]; [email protected]
Subject: RE: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 35 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 24 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated againThanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?
Quoted 5 lines
Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
BTW: I did the test on aplay. But I missed the test on PA. Where can I get the PA test cases?
Regards,
Libin
Quoted 133 lines
Quoted 21 lines
Takashi
Quoted 3 lines
Quoted 3 lines
--- sound/pci/hda/patch_hdmi.c | 34++++++++++++++++++++++++++++++++++
Quoted 3 lines
Review
Quoted 3 lines
1 file changed, 34 insertions(+)(quoted diff) +0
-0
b/sound/pci/hda/patch_hdmi.cQuoted 6 lines
sound/pci/hda/patch_hdmi.c static bool static_hdmi_pcm; · line 48
Quoted 6 lines
index f503a88..4f5023a 100644
sound/pci/hda/patch_hdmi.c +0
-0@@ -47,6 +47,11 @@ static bool static_hdmi_pcm;module_param (static_hdmi_pcm, bool,0644 ); MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCMparameters per ELD info");
Quoted 1 line
Quoted 1 line
Quoted 11 lines
Quoted 4 lines
sound/pci/hda/patch_hdmi.c static bool static_hdmi_pcm;
Quoted 4 lines
sound/pci/hda/patch_hdmi.c +4
-0+static bool hdmi_pcm_stop_on_disconnect; +module_param (hdmi_pcm_stop_on_disconnect, bool,0644 ); +MODULE_PARM_DESC(hdmi_pcm_stop_on_disconnect, + "Stop PCM when monitor isdisconnected");
Quoted 6 lines
This codec driver may be used for multiple devices, e.g. an onboard GPU and a discrete GPU. Whether a single flag is best is a slight concern. Though, as a test patch, it certainly suffices.
Quoted 1 line
#define
is_haswell(codec)((codec)->core.vendor_id ==
0x80862807)Quoted 3 lines
Quoted 1 line
Quoted 1 line
#define
is_broadwell(codec)((codec)->core.vendor_id ==
0x80862808)Quoted 1 line
Quoted 1 line
#define
is_skylake(codec)((codec)->core.vendor_id ==
0x80862809)Quoted 62 lines
Quoted 9 lines
sound/pci/hda/patch_hdmi.c static int hdmi_pcm_open(struct
Quoted 9 lines
sound/pci/hda/patch_hdmi.c +1
-0@@ -72,6 +77,7 @@ struct hdmi_spec_per_cvt {struct hdmi_spec_per_pin {hda_nid_t pin_nid; +int pin_idx;int num_mux_nids;hda_nid_t mux_nids[HDA_MAX_CONNECTIONS ];int mux_idx;@@ -1456,6 +1462,9 @@ static int hdmi_pcm_open(struct
hda_pcm_stream*hinfo,Quoted 10 lines
sound/pci/hda/patch_hdmi.c static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, · line 1466
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +2
-0per_pin =get_pin (spec, pin_idx); eld = &per_pin->sink_eld; +if (hdmi_pcm_stop_on_disconnect && !eld->eld_valid) +return -ENODEV ;An error code might influence on behavior, so let's check it carefully while testing.
Quoted 4 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct
Quoted 4 lines
sound/pci/hda/patch_hdmi.c +0
-0err =hdmi_choose_cvt (codec, pin_idx, &cvt_idx, &mux_idx);if (err <0 )return err;@@ -1529,6 +1538,28 @@ static int hdmi_read_pin_conn(struct
hda_codec*codec, intpin_idx)Quoted 5 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +2
-0return 0 ; } +static void hdmi_pcm_stop (struct hdmi_spec *spec, + struct hdmi_spec_per_pin
*per_pin)Quoted 18 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
Quoted 9 lines
sound/pci/hda/patch_hdmi.c +9
-0+{ +struct hda_codec *codec = per_pin->codec; +struct snd_pcm_substream *substream; +int pin_idx = per_pin->pin_idx; + +if (!hdmi_pcm_stop_on_disconnect) +return ; + + substream = get_pcm_rec(spec, pin_idx)->pcm-streams[0].substream;
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) · line 1555
Quoted 4 lines
sound/pci/hda/patch_hdmi.c +4
-0+ +snd_pcm_stream_lock_irq (substream); +if (substream && substream->runtime && +snd_pcm_running (substream)) {substream NULL check has to be before the lock.
Quoted 2 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct · line 1557
Quoted 2 lines
sound/pci/hda/patch_hdmi.c +2
-0+ codec_info(codec, + "HDMI: monitor disconnected, try to stopplayback\n");
Quoted 10 lines
The message is good for testing, but no need to spam at each disconnect in the production state. Use
codec_dbg()in the final patch.thanks,
Takashi
Quoted 7 lines
Quoted 1 line
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct · line 1558
Quoted 1 line
sound/pci/hda/patch_hdmi.c +1
-0+ snd_pcm_stop(substream,
SNDRV_PCM_STATE_DISCONNECTED);Quoted 5 lines
sound/pci/hda/patch_hdmi.c static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
Quoted 5 lines
sound/pci/hda/patch_hdmi.c +4
-0+ } +snd_pcm_stream_unlock_irq (substream); +} + static bool hdmi_present_sense(struct hdmi_spec_per_pin
*per_pin,Quoted 8 lines
int repoll)
Quoted 3 lines
sound/pci/hda/patch_hdmi.c static bool hdmi_present_sense(struct
Quoted 3 lines
sound/pci/hda/patch_hdmi.c +0
-0{struct hda_jack_tbl *jack;@@ -1586,6 +1617,8 @@ static bool hdmi_present_sense(struct
hdmi_spec_per_pin*per_pin, int repoll)Quoted 3 lines
Quoted 3 lines
sound/pci/hda/patch_hdmi.c +0
-0} }Quoted 6 lines
Quoted 6 lines
sound/pci/hda/patch_hdmi.c static int hdmi_add_pin(struct
Quoted 6 lines
sound/pci/hda/patch_hdmi.c +2
-0+if (!eld->eld_valid) +hdmi_pcm_stop (spec, per_pin);if (pin_eld->eld_valid != eld->eld_valid) eld_changed = true;@@ -1680,6 +1713,7 @@ static int hdmi_add_pin(struct
hda_codecQuoted 11 lines
*codec,
hda_nid_tpin_nid)Quoted 10 lines
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +1
-1return -ENOMEM ; per_pin->pin_nid = pin_nid; + per_pin->pin_idx = pin_idx; per_pin->non_pcm = false; err =hdmi_read_pin_conn (codec, pin_idx); --1.9.1
Quoted 60 lines · Libin
Quoted 60 lines
-----Original Message-----
From: Yang, Libin
Sent: Wednesday, November 11, 2015 10:24 PM
To: 'Takashi Iwai'; [email protected]
Cc: David Henningsson; [email protected]; [email protected]
Subject: RE: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 35 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 24 lines · Takashi Iwai
Quoted 12 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open PCM if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA, then respin with the fixes.
Quoted 6 lines
Quoted 1 line
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated againThanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
BTW: I did the test on aplay. But I missed the test on PA. Where can I get the PA test cases?
Just use PA on your desktop. Start PA with and without monitor plugged. Play via DP, then unplug, then watch the state change of PA.
Takashi
Quoted 80 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 11:00 PM
To: Yang, Libin
Cc: [email protected]; David Henningsson; alsa-devel@alsa- project.org; [email protected]
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 24 lines · Libin
Quoted 24 lines
-----Original Message-----
From: Yang, Libin
Sent: Wednesday, November 11, 2015 10:24 PM
To: 'Takashi Iwai'; [email protected]
Cc: David Henningsson; [email protected]; [email protected]
Subject: RE: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 12 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, November 11, 2015 10:13 PM
To: [email protected]
Cc: David Henningsson; [email protected]; [email protected]; Yang, Libin
Subject: Re: [PATCH] ALSA - hda: hdmi flag to stop playback when monitor is disconnectedQuoted 1 line · Takashi Iwai
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · On Wed, 11 Nov 2015 09:39:09 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add a flag that user can decide to stop HDMI/DP playback when the corresponding monitor is disconnected and refuse to open
PCM
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
if there is no monitor connected.
Background:
When a monitor is disconnected and a new monitor is connected, the parameters of the 2 monitors may be different. Audio driver need handle this situation.Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Besides, stopping playback when monitor is disconnected will help to save the power.
Signed-off-by Libin Yang <[email protected]>Thanks. Below are just nitpicking, so let's test this patch at first, especially to see whether it has any significant influence on PA,
then
Quoted 21 lines
Quoted 20 lines
Quoted 8 lines
Quoted 3 lines
respin with the fixes.
David, care to check in your side, too?
So I tested this with PA 7.1, and it failed, unfortunately. In short:
- PA needs the PCM access at probe. If it gets an error, the device will be never enumerated againThanks for test.
If so, should we re-write the
hdmi_pcm_open()andgeneric_hdmi_playback_pcm_prepare()function to make the probe works? Or not support dynamic pcm assignment?Quoted 2 lines
- PA removes the device when it's disconnected. The PCM stop with DISCONNECT state leads to the device disappearance.
If we can't use DISCONNECT, what else can we use? Or we can't stop PCM when monitor is disconnected?
Quoted 6 lines
Quoted 2 lines
BTW: I did the test on aplay. But I missed the test on PA. Where can I get the PA test cases?
Just use PA on your desktop. Start PA with and without monitor plugged. Play via DP, then unplug, then watch the state change of PA.
Get it. Thanks.
Regards,
Libin
Quoted 3 lines
Takashi