Skip to contentSkip to conversation

ALSA: hda - hdmi create spdif ctl based on pcm

PATCH In review [email protected] 3 participants 4 messages Jan 14, 2016 – Jan 15, 2016 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda - hdmi create spdif ctl based on pcm

From: Libin Yang <[email protected]>

SPDIF ctl should be based on pcm. Each spdif ctl controls one pcm state.

This patch creates spdif based on pcm and no longer based on pin.

---
 sound/pci/hda/patch_hdmi.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
sound/pci/hda/patch_hdmi.c +18 -9
index dfb7c26..2f949fb 100644
@@ -2255,6 +2255,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
 		hinfo->nid = 0;
 
 		mutex_lock(&spec->pcm_lock);
+		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
 		clear_bit(pcm_idx, &spec->pcm_in_use);
 		pin_idx = hinfo_to_pin_index(codec, hinfo);
 		if (spec->dyn_pcm_assign && pin_idx < 0) {
@@ -2276,8 +2277,6 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
 					    pinctl & ~PIN_OUT);
 		}
 
-		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
-
 		mutex_lock(&per_pin->lock);
 		per_pin->chmap_set = false;
 		memset(per_pin->chmap, 0, sizeof(per_pin->chmap));
@@ -2560,19 +2559,29 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
 		err = generic_hdmi_build_jack(codec, pcm_idx);
 		if (err < 0)
 			return err;
-	}
 
-	for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
-		struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
-
-		err = snd_hda_create_dig_out_ctls(codec,
+		/* create the spdif for each pcm
+		 * pin will be bound when monitor is connected
+		 */
+		if (spec->dyn_pcm_assign)
+			err = snd_hda_create_dig_out_ctls(codec,
+					  0, spec->cvt_nids[0],
+					  HDA_PCM_TYPE_HDMI);
+		else {
+			struct hdmi_spec_per_pin *per_pin =
+				get_pin(spec, pcm_idx);
+			err = snd_hda_create_dig_out_ctls(codec,
 						  per_pin->pin_nid,
 						  per_pin->mux_nids[0],
 						  HDA_PCM_TYPE_HDMI);
+		}
 		if (err < 0)
 			return err;
-		/* pin number is the same with pcm number so far */
-		snd_hda_spdif_ctls_unassign(codec, pin_idx);
+		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
+	}
+
+	for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
+		struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
 
 		/* add control for ELD Bytes */
 		err = hdmi_create_eld_ctl(codec, pin_idx,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 8 lines · On Thu, 14 Jan 2016 08:49:46 +0100, [email protected] wrote:

From: Libin Yang <[email protected]>

SPDIF ctl should be based on pcm. Each spdif ctl controls one pcm state.

This patch creates spdif based on pcm and no longer based on pin.

Which branch is this supposed to be applied to? I thought it's for MST, then this isn't for 4.5.

If it's for MST, please postpone it until the merge window is closed. If this isn't for 4.5, please clarify why this has to be applied.

thanks,

Takashi

Quoted 67 lines
---
 sound/pci/hda/patch_hdmi.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
sound/pci/hda/patch_hdmi.c +18 -9
index dfb7c26..2f949fb 100644
@@ -2255,6 +2255,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
 		hinfo->nid = 0;
 
 		mutex_lock(&spec->pcm_lock);
+		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
 		clear_bit(pcm_idx, &spec->pcm_in_use);
 		pin_idx = hinfo_to_pin_index(codec, hinfo);
 		if (spec->dyn_pcm_assign && pin_idx < 0) {
@@ -2276,8 +2277,6 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
 					    pinctl & ~PIN_OUT);
 		}
 
-		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
-
 		mutex_lock(&per_pin->lock);
 		per_pin->chmap_set = false;
 		memset(per_pin->chmap, 0, sizeof(per_pin->chmap));
@@ -2560,19 +2559,29 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
 		err = generic_hdmi_build_jack(codec, pcm_idx);
 		if (err < 0)
 			return err;
-	}
 
-	for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
-		struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
-
-		err = snd_hda_create_dig_out_ctls(codec,
+		/* create the spdif for each pcm
+		 * pin will be bound when monitor is connected
+		 */
+		if (spec->dyn_pcm_assign)
+			err = snd_hda_create_dig_out_ctls(codec,
+					  0, spec->cvt_nids[0],
+					  HDA_PCM_TYPE_HDMI);
+		else {
+			struct hdmi_spec_per_pin *per_pin =
+				get_pin(spec, pcm_idx);
+			err = snd_hda_create_dig_out_ctls(codec,
 						  per_pin->pin_nid,
 						  per_pin->mux_nids[0],
 						  HDA_PCM_TYPE_HDMI);
+		}
 		if (err < 0)
 			return err;
-		/* pin number is the same with pcm number so far */
-		snd_hda_spdif_ctls_unassign(codec, pin_idx);
+		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
+	}
+
+	for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
+		struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
 
 		/* add control for ELD Bytes */
 		err = hdmi_create_eld_ctl(codec, pin_idx,
Signature · 1 line
1.9.1
#2 lore raw
Quoted 16 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, January 14, 2016 5:09 PM
To: [email protected]
Cc: [email protected]; Lin, Mengdong; Yang, Libin
Subject: Re: [PATCH] ALSA: hda - hdmi create spdif ctl based on pcm

Quoted 6 lines · On Thu, 14 Jan 2016 08:49:46 +0100, [email protected] wrote:

From: Libin Yang <[email protected]>

SPDIF ctl should be based on pcm. Each spdif ctl controls one pcm state.

Quoted 8 lines
Quoted 2 lines

This patch creates spdif based on pcm and no longer based on pin.

Which branch is this supposed to be applied to? I thought it's for MST, then this isn't for 4.5.

If it's for MST, please postpone it until the merge window is closed. If this isn't for 4.5, please clarify why this has to be applied.

It's for MST. I will submit it later. When should I submit the patch?

Regards,
Libin

Quoted 80 lines

thanks,

Takashi

Review

Quoted 7 lines
---
 sound/pci/hda/patch_hdmi.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/sound/pci/hda/patch_hdmi.c

sound/pci/hda/patch_hdmi.c static int hdmi_pcm_close(struct

Quoted 4 lines

index dfb7c26..2f949fb 100644

sound/pci/hda/patch_hdmi.c +0 -0
@@ -2255,6 +2255,7 @@ static int hdmi_pcm_close(struct

hda_pcm_stream *hinfo,

sound/pci/hda/patch_hdmi.c static int hdmi_pcm_close(struct

Quoted 8 lines
sound/pci/hda/patch_hdmi.c +1 -0
 		hinfo->nid = 0;
 
 		mutex_lock(&spec->pcm_lock);
+		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
 		clear_bit(pcm_idx, &spec->pcm_in_use);
 		pin_idx = hinfo_to_pin_index(codec, hinfo);
 		if (spec->dyn_pcm_assign && pin_idx < 0) {
@@ -2276,8 +2277,6 @@ static int hdmi_pcm_close(struct

hda_pcm_stream *hinfo,

sound/pci/hda/patch_hdmi.c static int

Quoted 9 lines
sound/pci/hda/patch_hdmi.c +0 -2
 					    pinctl & ~PIN_OUT);
 		}
 
-		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
-
 		mutex_lock(&per_pin->lock);
 		per_pin->chmap_set = false;
 		memset(per_pin->chmap, 0, sizeof(per_pin->chmap));
@@ -2560,19 +2559,29 @@ static int

generic_hdmi_build_controls(struct hda_codec *codec)

sound/pci/hda/patch_hdmi.c static int generic_hdmi_build_controls(struct hda_codec *codec)

Quoted 7 lines
sound/pci/hda/patch_hdmi.c +0 -3
 		err = generic_hdmi_build_jack(codec, pcm_idx);
 		if (err < 0)
 			return err;
-	}
 
-	for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
-		struct hdmi_spec_per_pin *per_pin = get_pin(spec,

pin_idx);

Quoted 6 lines
sound/pci/hda/patch_hdmi.c +4 -2
-
-		err = snd_hda_create_dig_out_ctls(codec,
+		/* create the spdif for each pcm
+		 * pin will be bound when monitor is connected
+		 */
+		if (spec->dyn_pcm_assign)

sound/pci/hda/patch_hdmi.c static int generic_hdmi_build_controls(struct hda_codec *codec) · line 2585

Quoted 10 lines
sound/pci/hda/patch_hdmi.c +7 -0
+			err = snd_hda_create_dig_out_ctls(codec,
+					  0, spec->cvt_nids[0],
+					  HDA_PCM_TYPE_HDMI);
+		else {
+			struct hdmi_spec_per_pin *per_pin =
+				get_pin(spec, pcm_idx);
+			err = snd_hda_create_dig_out_ctls(codec,
 						  per_pin->pin_nid,
 						  per_pin->mux_nids[0],
 

HDA_PCM_TYPE_HDMI);

sound/pci/hda/patch_hdmi.c static int generic_hdmi_build_controls(struct hda_codec *codec)

Quoted 10 lines
sound/pci/hda/patch_hdmi.c +6 -2
+		}
 		if (err < 0)
 			return err;
-		/* pin number is the same with pcm number so far */
-		snd_hda_spdif_ctls_unassign(codec, pin_idx);
+		snd_hda_spdif_ctls_unassign(codec, pcm_idx);
+	}
+
+	for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
+		struct hdmi_spec_per_pin *per_pin = get_pin(spec,

pin_idx);

Quoted 6 lines
sound/pci/hda/patch_hdmi.c +0 -1
 		/* add control for ELD Bytes */
 		err = hdmi_create_eld_ctl(codec, pin_idx,
--

1.9.1

#3 lore raw
Quoted 20 lines · Libin
Quoted 20 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, January 14, 2016 5:09 PM
To: [email protected]
Cc: [email protected]; Lin, Mengdong; Yang, Libin
Subject: Re: [PATCH] ALSA: hda - hdmi create spdif ctl based on pcm

Quoted 8 lines · On Thu, 14 Jan 2016 08:49:46 +0100, [email protected] wrote:

From: Libin Yang <[email protected]>

SPDIF ctl should be based on pcm. Each spdif ctl controls one pcm state.

This patch creates spdif based on pcm and no longer based on pin.

Quoted 7 lines
Quoted 5 lines

Which branch is this supposed to be applied to? I thought it's for MST, then this isn't for 4.5.

If it's for MST, please postpone it until the merge window is closed. If this isn't for 4.5, please clarify why this has to be applied.

It's for MST. I will submit it later. When should I submit the patch?

After the merge window is closed.

Takashi