Commit 2bea241a authored by Libin Yang's avatar Libin Yang Committed by Takashi Iwai

ALSA: hda - add hdmi_pcm to manage hdmi pcm related features

Use struct hdmi_pcm wrapper for hdmi pcm management.
All PCM related features, like jack,  will be put in this structure.
Signed-off-by: default avatarLibin Yang <libin.yang@linux.intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 463c35fb
...@@ -88,7 +88,7 @@ struct hdmi_spec_per_pin { ...@@ -88,7 +88,7 @@ struct hdmi_spec_per_pin {
struct delayed_work work; struct delayed_work work;
struct snd_kcontrol *eld_ctl; struct snd_kcontrol *eld_ctl;
struct snd_jack *acomp_jack; /* jack via audio component */ struct snd_jack *acomp_jack; /* jack via audio component */
struct hda_pcm *pcm; /* pointer to spec->pcm_rec[n] dynamically*/ struct hdmi_pcm *pcm; /* pointer to spec->pcm_rec[n] dynamically*/
int pcm_idx; /* which pcm is attached. -1 means no pcm is attached */ int pcm_idx; /* which pcm is attached. -1 means no pcm is attached */
int repoll_count; int repoll_count;
bool setup; /* the stream has been set up by prepare callback */ bool setup; /* the stream has been set up by prepare callback */
...@@ -134,6 +134,11 @@ struct hdmi_ops { ...@@ -134,6 +134,11 @@ struct hdmi_ops {
int (*chmap_validate)(int ca, int channels, unsigned char *chmap); int (*chmap_validate)(int ca, int channels, unsigned char *chmap);
}; };
struct hdmi_pcm {
struct hda_pcm *pcm;
struct snd_jack *jack;
};
struct hdmi_spec { struct hdmi_spec {
int num_cvts; int num_cvts;
struct snd_array cvts; /* struct hdmi_spec_per_cvt */ struct snd_array cvts; /* struct hdmi_spec_per_cvt */
...@@ -141,7 +146,7 @@ struct hdmi_spec { ...@@ -141,7 +146,7 @@ struct hdmi_spec {
int num_pins; int num_pins;
struct snd_array pins; /* struct hdmi_spec_per_pin */ struct snd_array pins; /* struct hdmi_spec_per_pin */
struct hda_pcm *pcm_rec[16]; struct hdmi_pcm pcm_rec[16];
struct mutex pcm_lock; struct mutex pcm_lock;
/* pcm_bitmap means which pcms have been assigned to pins*/ /* pcm_bitmap means which pcms have been assigned to pins*/
unsigned long pcm_bitmap; unsigned long pcm_bitmap;
...@@ -383,7 +388,10 @@ static struct cea_channel_speaker_allocation channel_allocations[] = { ...@@ -383,7 +388,10 @@ static struct cea_channel_speaker_allocation channel_allocations[] = {
((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx)) ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx))
#define get_cvt(spec, idx) \ #define get_cvt(spec, idx) \
((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx)) ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx))
#define get_pcm_rec(spec, idx) ((spec)->pcm_rec[idx]) /* obtain hdmi_pcm object assigned to idx */
#define get_hdmi_pcm(spec, idx) (&(spec)->pcm_rec[idx])
/* obtain hda_pcm object assigned to idx */
#define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm)
static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid) static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid)
{ {
...@@ -421,7 +429,8 @@ static int hinfo_to_pin_index(struct hda_codec *codec, ...@@ -421,7 +429,8 @@ static int hinfo_to_pin_index(struct hda_codec *codec,
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
per_pin = get_pin(spec, pin_idx); per_pin = get_pin(spec, pin_idx);
if (per_pin->pcm && per_pin->pcm->stream == hinfo) if (per_pin->pcm &&
per_pin->pcm->pcm->stream == hinfo)
return pin_idx; return pin_idx;
} }
...@@ -1723,7 +1732,7 @@ static void hdmi_attach_hda_pcm(struct hdmi_spec *spec, ...@@ -1723,7 +1732,7 @@ static void hdmi_attach_hda_pcm(struct hdmi_spec *spec,
if (idx == -ENODEV) if (idx == -ENODEV)
return; return;
per_pin->pcm_idx = idx; per_pin->pcm_idx = idx;
per_pin->pcm = spec->pcm_rec[idx]; per_pin->pcm = get_hdmi_pcm(spec, idx);
set_bit(idx, &spec->pcm_bitmap); set_bit(idx, &spec->pcm_bitmap);
} }
...@@ -1766,7 +1775,7 @@ static void hdmi_pcm_setup_pin(struct hdmi_spec *spec, ...@@ -1766,7 +1775,7 @@ static void hdmi_pcm_setup_pin(struct hdmi_spec *spec,
bool non_pcm; bool non_pcm;
if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used)
pcm = spec->pcm_rec[per_pin->pcm_idx]; pcm = get_pcm_rec(spec, per_pin->pcm_idx);
else else
return; return;
if (!test_bit(per_pin->pcm_idx, &spec->pcm_in_use)) if (!test_bit(per_pin->pcm_idx, &spec->pcm_in_use))
...@@ -2030,8 +2039,10 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) ...@@ -2030,8 +2039,10 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
per_pin->non_pcm = false; per_pin->non_pcm = false;
if (spec->dyn_pcm_assign) if (spec->dyn_pcm_assign)
per_pin->pcm_idx = -1; per_pin->pcm_idx = -1;
else else {
per_pin->pcm = get_hdmi_pcm(spec, pin_idx);
per_pin->pcm_idx = pin_idx; per_pin->pcm_idx = pin_idx;
}
per_pin->pin_nid_idx = pin_idx; per_pin->pin_nid_idx = pin_idx;
err = hdmi_read_pin_conn(codec, pin_idx); err = hdmi_read_pin_conn(codec, pin_idx);
...@@ -2441,7 +2452,6 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, ...@@ -2441,7 +2452,6 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol,
static int generic_hdmi_build_pcms(struct hda_codec *codec) static int generic_hdmi_build_pcms(struct hda_codec *codec)
{ {
struct hdmi_spec *spec = codec->spec; struct hdmi_spec *spec = codec->spec;
struct hdmi_spec_per_pin *per_pin;
int pin_idx; int pin_idx;
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
...@@ -2451,11 +2461,8 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec) ...@@ -2451,11 +2461,8 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
info = snd_hda_codec_pcm_new(codec, "HDMI %d", pin_idx); info = snd_hda_codec_pcm_new(codec, "HDMI %d", pin_idx);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
if (!spec->dyn_pcm_assign) {
per_pin = get_pin(spec, pin_idx); spec->pcm_rec[pin_idx].pcm = info;
per_pin->pcm = info;
}
spec->pcm_rec[pin_idx] = info;
spec->pcm_used++; spec->pcm_used++;
info->pcm_type = HDA_PCM_TYPE_HDMI; info->pcm_type = HDA_PCM_TYPE_HDMI;
info->own_chmap = true; info->own_chmap = true;
...@@ -2553,7 +2560,7 @@ static int generic_hdmi_build_controls(struct hda_codec *codec) ...@@ -2553,7 +2560,7 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
struct snd_kcontrol *kctl; struct snd_kcontrol *kctl;
int i; int i;
pcm = spec->pcm_rec[pin_idx]; pcm = get_pcm_rec(spec, pin_idx);
if (!pcm || !pcm->pcm) if (!pcm || !pcm->pcm)
break; break;
err = snd_pcm_add_chmap_ctls(pcm->pcm, err = snd_pcm_add_chmap_ctls(pcm->pcm,
...@@ -2859,7 +2866,7 @@ static int simple_playback_build_pcms(struct hda_codec *codec) ...@@ -2859,7 +2866,7 @@ static int simple_playback_build_pcms(struct hda_codec *codec)
info = snd_hda_codec_pcm_new(codec, "HDMI 0"); info = snd_hda_codec_pcm_new(codec, "HDMI 0");
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
spec->pcm_rec[0] = info; spec->pcm_rec[0].pcm = info;
info->pcm_type = HDA_PCM_TYPE_HDMI; info->pcm_type = HDA_PCM_TYPE_HDMI;
pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
*pstr = spec->pcm_playback; *pstr = spec->pcm_playback;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment