#include <linux/module.h>
#include <sound/core.h>
#include <sound/jack.h>
+#include <sound/asoundef.h>
#include "hda_codec.h"
#include "hda_local.h"
#include "hda_jack.h"
u32 rates;
u64 formats;
unsigned int maxbps;
+ bool non_pcm;
};
struct hdmi_spec_per_pin {
static void hdmi_setup_channel_mapping(struct hda_codec *codec,
hda_nid_t pin_nid,
+ hda_nid_t cvt_nid,
+ bool non_pcm,
int ca)
{
int i;
int err;
int order;
+ int non_pcm_mapping[8];
order = get_channel_allocation_order(ca);
+
if (hdmi_channel_mapping[ca][1] == 0) {
for (i = 0; i < channel_allocations[order].channels; i++)
hdmi_channel_mapping[ca][i] = i | (i << 4);
hdmi_channel_mapping[ca][i] = 0xf | (i << 4);
}
+ if (non_pcm) {
+ for (i = 0; i < channel_allocations[order].channels; i++)
+ non_pcm_mapping[i] = i | (i << 4);
+ for (; i < 8; i++)
+ non_pcm_mapping[i] = 0xf | (i << 4);
+ }
+
for (i = 0; i < 8; i++) {
err = snd_hda_codec_write(codec, pin_nid, 0,
AC_VERB_SET_HDMI_CHAN_SLOT,
- hdmi_channel_mapping[ca][i]);
+ non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]);
if (err) {
snd_printdd(KERN_NOTICE
"HDMI: channel mapping failed\n");
}
static void hdmi_setup_audio_infoframe(struct hda_codec *codec, int pin_idx,
- struct snd_pcm_substream *substream)
+ hda_nid_t cvt_nid, struct snd_pcm_substream *substream)
{
struct hdmi_spec *spec = codec->spec;
struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
+ struct hdmi_spec_per_cvt *per_cvt;
+ struct hda_spdif_out *spdif;
hda_nid_t pin_nid = per_pin->pin_nid;
int channels = substream->runtime->channels;
struct hdmi_eld *eld;
int ca;
+ int cvt_idx;
union audio_infoframe ai;
+ bool non_pcm = false;
+
+ cvt_idx = cvt_nid_to_cvt_index(spec, cvt_nid);
+ per_cvt = &spec->cvts[cvt_idx];
+
+ mutex_lock(&codec->spdif_mutex);
+ spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid);
+ non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO);
+ mutex_unlock(&codec->spdif_mutex);
eld = &spec->pins[pin_idx].sink_eld;
if (!eld->monitor_present)
"pin=%d channels=%d\n",
pin_nid,
channels);
- hdmi_setup_channel_mapping(codec, pin_nid, ca);
+ hdmi_setup_channel_mapping(codec, pin_nid, cvt_nid, non_pcm, ca);
hdmi_stop_infoframe_trans(codec, pin_nid);
hdmi_fill_audio_infoframe(codec, pin_nid,
ai.bytes, sizeof(ai));
hdmi_start_infoframe_trans(codec, pin_nid);
}
+
+ per_cvt->non_pcm = non_pcm;
}
per_cvt->cvt_nid = cvt_nid;
per_cvt->channels_min = 2;
+ per_cvt->non_pcm = false;
if (chans <= 16)
per_cvt->channels_max = chans;
hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels);
- hdmi_setup_audio_infoframe(codec, pin_idx, substream);
+ hdmi_setup_audio_infoframe(codec, pin_idx, cvt_nid, substream);
pinctl = snd_hda_codec_read(codec, pin_nid, 0,
AC_VERB_GET_PIN_WIDGET_CONTROL, 0);