From: Anssi Hannula <anssi.hannula@iki.fi>
To: Takashi Iwai <tiwai@suse.de>
Cc: "Olivier Langlois" <olivier@trillion01.com>,
alsa-devel@alsa-project.org, "Rafał Miłecki" <zajec5@gmail.com>,
linux-kernel@vger.kernel.org,
"Peter Frühberger" <fritsch@xbmc.org>
Subject: [PATCH 3/4] ALSA: hda - hdmi: Add HBR bitstreaming support for ATI/AMD HDMI codecs
Date: Tue, 1 Oct 2013 23:30:55 +0300 [thread overview]
Message-ID: <1380659456-3746-4-git-send-email-anssi.hannula@iki.fi> (raw)
In-Reply-To: <1380659456-3746-1-git-send-email-anssi.hannula@iki.fi>
ATI/AMD HDMI codecs do not include standard HDA HDMI HBR support (which
is required for bitstreaming DTS-HD and Dolby TrueHD), instead they have
custom verbs for checking and enabling it.
Add support for the ATI/AMD HDMI HBR verbs.
The specification is available at:
http://www.x.org/docs/AMD/AMD_HDA_verbs_v2.pdf
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Tested-by: Peter Frühberger <fritsch@xbmc.org>
---
sound/pci/hda/patch_hdmi.c | 65 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 64 insertions(+), 1 deletion(-)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 19adb01..c0cd4ca 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1140,7 +1140,7 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
new_pinctl);
}
- if (is_hbr_format(format) && !new_pinctl) {
+ if (is_hbr_format(format) && !new_pinctl && !is_atihdmi(codec)) {
snd_printdd("hdmi_setup_stream: HBR is not supported\n");
return -EINVAL;
}
@@ -2654,6 +2654,7 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
#define ATI_VERB_SET_MULTICHANNEL_23 0x778
#define ATI_VERB_SET_MULTICHANNEL_45 0x779
#define ATI_VERB_SET_MULTICHANNEL_67 0x77a
+#define ATI_VERB_SET_HBR_CONTROL 0x77c
#define ATI_VERB_SET_MULTICHANNEL_1 0x785
#define ATI_VERB_SET_MULTICHANNEL_3 0x786
#define ATI_VERB_SET_MULTICHANNEL_5 0x787
@@ -2665,6 +2666,7 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
#define ATI_VERB_GET_MULTICHANNEL_23 0xf78
#define ATI_VERB_GET_MULTICHANNEL_45 0xf79
#define ATI_VERB_GET_MULTICHANNEL_67 0xf7a
+#define ATI_VERB_GET_HBR_CONTROL 0xf7c
#define ATI_VERB_GET_MULTICHANNEL_1 0xf85
#define ATI_VERB_GET_MULTICHANNEL_3 0xf86
#define ATI_VERB_GET_MULTICHANNEL_5 0xf87
@@ -2673,6 +2675,9 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
#define ATI_OUT_ENABLE 0x1
+#define ATI_HBR_CAPABLE 0x01
+#define ATI_HBR_ENABLE 0x10
+
static void atihdmi_set_ca(struct hda_codec *codec, hda_nid_t pin_nid, int ca)
{
printk("ATI: setting ca %d\n", ca);
@@ -2813,6 +2818,63 @@ static int atihdmi_get_chan_slot(struct hda_codec *codec, hda_nid_t pin_nid, int
}
#endif
+static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+ struct hda_codec *codec,
+ unsigned int stream_tag,
+ unsigned int format,
+ struct snd_pcm_substream *substream)
+{
+ struct hdmi_spec *spec = codec->spec;
+ int pin_idx = hinfo_to_pin_index(spec, hinfo);
+ struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
+ hda_nid_t pin_nid = per_pin->pin_nid;
+ int hbr_ctl, hbr_ctl_new;
+
+ hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0);
+ if (hbr_ctl & ATI_HBR_CAPABLE) {
+ if (is_hbr_format(format))
+ hbr_ctl_new = hbr_ctl | ATI_HBR_ENABLE;
+ else
+ hbr_ctl_new = hbr_ctl & ~ATI_HBR_ENABLE;
+
+ snd_printdd("atihdmi_playback_pcm_prepare: "
+ "NID=0x%x, %shbr-ctl=0x%x\n",
+ pin_nid,
+ hbr_ctl == hbr_ctl_new ? "" : "new-",
+ hbr_ctl_new);
+
+ if (hbr_ctl != hbr_ctl_new)
+ snd_hda_codec_write(codec, pin_nid, 0,
+ ATI_VERB_SET_HBR_CONTROL,
+ hbr_ctl_new);
+
+ } else if (is_hbr_format(format)) {
+ snd_printdd("atihdmi_playback_pcm_prepare: HBR is not supported\n");
+ return -EINVAL;
+ }
+
+ return generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, format, substream);
+}
+
+static int atihdmi_build_pcms(struct hda_codec *codec)
+{
+ struct hdmi_spec *spec = codec->spec;
+ int err, pin_idx;
+
+ err = generic_hdmi_build_pcms(codec);
+
+ if (err)
+ return err;
+
+ for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
+ struct hda_pcm *info = get_pcm_rec(spec, pin_idx);
+
+ info->stream[SNDRV_PCM_STREAM_PLAYBACK].ops.prepare = atihdmi_playback_pcm_prepare;
+ }
+
+ return 0;
+}
+
static int atihdmi_init(struct hda_codec *codec)
{
struct hdmi_spec *spec = codec->spec;
@@ -2849,6 +2911,7 @@ static int patch_atihdmi(struct hda_codec *codec)
return err;
codec->patch_ops.init = atihdmi_init;
+ codec->patch_ops.build_pcms = atihdmi_build_pcms;
/* ATI/AMD converters do not advertise all of their capabilities */
spec = codec->spec;
--
1.8.1.5
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2013-10-01 20:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-01 20:30 [RFC/RFT v2 0/4] ALSA: hda - hdmi: ATI/AMD multi-channel and HBR support Anssi Hannula
2013-10-01 20:30 ` [PATCH 1/4] ALSA: hda - hdmi: Add ATI/AMD multi-channel audio support Anssi Hannula
2013-10-30 15:35 ` Rafał Miłecki
2013-10-30 15:59 ` Anssi Hannula
2013-10-31 16:22 ` Rafał Miłecki
2013-10-31 20:26 ` Anssi Hannula
2013-10-31 23:25 ` Rafał Miłecki
2013-10-31 23:34 ` Anssi Hannula
2013-10-31 23:51 ` Rafał Miłecki
2013-10-31 23:58 ` Anssi Hannula
2013-11-01 11:29 ` Rafał Miłecki
2013-11-01 12:15 ` Anssi Hannula
2013-11-01 13:22 ` Rafał Miłecki
2013-11-01 13:43 ` Rafał Miłecki
2013-10-01 20:30 ` [PATCH 2/4] ALSA: hda - hdmi: Add ELD emulation for ATI/AMD codecs Anssi Hannula
2013-10-01 20:30 ` Anssi Hannula [this message]
2013-10-01 20:30 ` [PATCH 4/4] ALSA: hda - hdmi: Disable ramp-up/down for non-PCM on AMD codecs Anssi Hannula
2013-10-02 14:34 ` [RFC/RFT v2 0/4] ALSA: hda - hdmi: ATI/AMD multi-channel and HBR support Takashi Iwai
2013-10-02 16:42 ` Anssi Hannula
2013-10-07 7:33 ` Takashi Iwai
2013-10-04 7:06 ` Olivier Langlois
2013-10-04 23:39 ` Anssi Hannula
2013-10-06 3:48 ` Olivier Langlois
2013-10-06 12:07 ` [alsa-devel] " Anssi Hannula
2013-10-09 4:32 ` Olivier Langlois
2013-10-24 19:06 ` Anssi Hannula
2013-11-07 21:20 ` Olivier Langlois
2013-11-08 10:18 ` Anssi Hannula
2013-11-08 16:44 ` Olivier Langlois
2013-11-08 22:13 ` Anssi Hannula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380659456-3746-4-git-send-email-anssi.hannula@iki.fi \
--to=anssi.hannula@iki.fi \
--cc=alsa-devel@alsa-project.org \
--cc=fritsch@xbmc.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olivier@trillion01.com \
--cc=tiwai@suse.de \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).