Skip to content

Commit 6590faa

Browse files
libinyangtiwai
authored andcommitted
ALSA: hda - hdmi begin to support dynamic PCM assignment
Begin to support dynamic PCM assignment to pin in hdmi audio driver. This means PCM will not be statically bound with pin. When there is a monitor connected, the corresponding pin will try to find a proper PCM to bind. When the monitor is disconnected, the corresponding pin will unbind the PCM. This helps to reduce the PCM number when there are many pins (device entries in DP MST mode) and only a few of them work at the same time. This patch adds the pcm member in struct hdmi_spec_per_pin. When PCM is dynamically bound to the pin, the member pcm will pointer to the corresponding pcm_rec[] in hdmi_spec, which means the hda_pcm is bound to the pin. Signed-off-by: Libin Yang <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 92e963f commit 6590faa

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

sound/pci/hda/patch_hdmi.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct hdmi_spec_per_pin {
8686
struct delayed_work work;
8787
struct snd_kcontrol *eld_ctl;
8888
struct snd_jack *acomp_jack; /* jack via audio component */
89+
struct hda_pcm *pcm; /* pointer to spec->pcm_rec[n] dynamically*/
8990
int repoll_count;
9091
bool setup; /* the stream has been set up by prepare callback */
9192
int channels; /* current number of channels */
@@ -144,7 +145,7 @@ struct hdmi_spec {
144145
struct hdmi_ops ops;
145146

146147
bool dyn_pin_out;
147-
148+
bool dyn_pcm_assign;
148149
/*
149150
* Non-generic VIA/NVIDIA specific
150151
*/
@@ -389,13 +390,16 @@ static int hinfo_to_pin_index(struct hda_codec *codec,
389390
struct hda_pcm_stream *hinfo)
390391
{
391392
struct hdmi_spec *spec = codec->spec;
393+
struct hdmi_spec_per_pin *per_pin;
392394
int pin_idx;
393395

394-
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
395-
if (get_pcm_rec(spec, pin_idx)->stream == hinfo)
396+
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
397+
per_pin = get_pin(spec, pin_idx);
398+
if (per_pin->pcm && per_pin->pcm->stream == hinfo)
396399
return pin_idx;
400+
}
397401

398-
codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo);
402+
codec_dbg(codec, "HDMI: hinfo %p not registered\n", hinfo);
399403
return -EINVAL;
400404
}
401405

@@ -2116,6 +2120,7 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol,
21162120
static int generic_hdmi_build_pcms(struct hda_codec *codec)
21172121
{
21182122
struct hdmi_spec *spec = codec->spec;
2123+
struct hdmi_spec_per_pin *per_pin;
21192124
int pin_idx;
21202125

21212126
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
@@ -2125,6 +2130,10 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
21252130
info = snd_hda_codec_pcm_new(codec, "HDMI %d", pin_idx);
21262131
if (!info)
21272132
return -ENOMEM;
2133+
if (!spec->dyn_pcm_assign) {
2134+
per_pin = get_pin(spec, pin_idx);
2135+
per_pin->pcm = info;
2136+
}
21282137
spec->pcm_rec[pin_idx] = info;
21292138
info->pcm_type = HDA_PCM_TYPE_HDMI;
21302139
info->own_chmap = true;

0 commit comments

Comments
 (0)