aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorWei Ni <wni@nvidia.com>2008-09-26 01:45:46 -0400
committerJaroslav Kysela <perex@perex.cz>2008-10-10 07:41:35 -0400
commit9a10eb21e1e1c389a8cea3016157a7f471512645 (patch)
tree4bf44292f3547aa2add9d8a930aa9a4b690e6a8d /sound/pci
parent2f72853ca1ee1571377996471d05db51eb7c54c4 (diff)
ALSA: Support NVIDIA MCP78/7A HDMI audio
Add NVIDIA HDMI HD-audio codec support in snd-hda-intel driver, include NVIDIA MCP78/7A HDMI. Signed-off-by: Wei Ni <wni@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/Kconfig8
-rw-r--r--sound/pci/hda/Makefile1
-rw-r--r--sound/pci/hda/hda_codec.c3
-rw-r--r--sound/pci/hda/hda_patch.h2
-rw-r--r--sound/pci/hda/patch_nvhdmi.c164
5 files changed, 178 insertions, 0 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1f8b7966a839..7003711f4fcc 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -565,6 +565,14 @@ config SND_HDA_CODEC_ATIHDMI
565 Say Y here to include ATI HDMI HD-audio codec support in 565 Say Y here to include ATI HDMI HD-audio codec support in
566 snd-hda-intel driver, such as ATI RS600 HDMI. 566 snd-hda-intel driver, such as ATI RS600 HDMI.
567 567
568config SND_HDA_CODEC_NVHDMI
569 bool "Build NVIDIA HDMI HD-audio codec support"
570 depends on SND_HDA_INTEL
571 default y
572 help
573 Say Y here to include NVIDIA HDMI HD-audio codec support in
574 snd-hda-intel driver, such as NVIDIA MCP78 HDMI.
575
568config SND_HDA_CODEC_CONEXANT 576config SND_HDA_CODEC_CONEXANT
569 bool "Build Conexant HD-audio codec support" 577 bool "Build Conexant HD-audio codec support"
570 depends on SND_HDA_INTEL 578 depends on SND_HDA_INTEL
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 6db92fd954d9..1980c6d207e7 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -15,5 +15,6 @@ snd-hda-intel-$(CONFIG_SND_HDA_CODEC_SI3054) += patch_si3054.o
15snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATIHDMI) += patch_atihdmi.o 15snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATIHDMI) += patch_atihdmi.o
16snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CONEXANT) += patch_conexant.o 16snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CONEXANT) += patch_conexant.o
17snd-hda-intel-$(CONFIG_SND_HDA_CODEC_VIA) += patch_via.o 17snd-hda-intel-$(CONFIG_SND_HDA_CODEC_VIA) += patch_via.o
18snd-hda-intel-$(CONFIG_SND_HDA_CODEC_NVHDMI) += patch_nvhdmi.o
18 19
19obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o 20obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 94ea6543440e..fdb6d559f5dd 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -94,6 +94,9 @@ static const struct hda_codec_preset *hda_preset_tables[] = {
94#ifdef CONFIG_SND_HDA_CODEC_VIA 94#ifdef CONFIG_SND_HDA_CODEC_VIA
95 snd_hda_preset_via, 95 snd_hda_preset_via,
96#endif 96#endif
97#ifdef CONFIG_SND_HDA_CODEC_NVHDMI
98 snd_hda_preset_nvhdmi,
99#endif
97 NULL 100 NULL
98}; 101};
99 102
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h
index 2fdf2358dbc2..dfbcfa88da44 100644
--- a/sound/pci/hda/hda_patch.h
+++ b/sound/pci/hda/hda_patch.h
@@ -18,3 +18,5 @@ extern struct hda_codec_preset snd_hda_preset_atihdmi[];
18extern struct hda_codec_preset snd_hda_preset_conexant[]; 18extern struct hda_codec_preset snd_hda_preset_conexant[];
19/* VIA codecs */ 19/* VIA codecs */
20extern struct hda_codec_preset snd_hda_preset_via[]; 20extern struct hda_codec_preset snd_hda_preset_via[];
21/* NVIDIA HDMI codecs */
22extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c
new file mode 100644
index 000000000000..1a65775d28e1
--- /dev/null
+++ b/sound/pci/hda/patch_nvhdmi.c
@@ -0,0 +1,164 @@
1/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for NVIDIA HDMI codecs
5 *
6 * Copyright (c) 2008 NVIDIA Corp. All rights reserved.
7 * Copyright (c) 2008 Wei Ni <wni@nvidia.com>
8 *
9 *
10 * This driver is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This driver is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/init.h>
26#include <linux/delay.h>
27#include <linux/slab.h>
28#include <sound/core.h>
29#include "hda_codec.h"
30#include "hda_local.h"
31
32struct nvhdmi_spec {
33 struct hda_multi_out multiout;
34
35 struct hda_pcm pcm_rec;
36};
37
38static struct hda_verb nvhdmi_basic_init[] = {
39 /* enable digital output on pin widget */
40 { 0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
41 {} /* terminator */
42};
43
44/*
45 * Controls
46 */
47static int nvhdmi_build_controls(struct hda_codec *codec)
48{
49 struct nvhdmi_spec *spec = codec->spec;
50 int err;
51
52 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
53 if (err < 0)
54 return err;
55
56 return 0;
57}
58
59static int nvhdmi_init(struct hda_codec *codec)
60{
61 snd_hda_sequence_write(codec, nvhdmi_basic_init);
62 return 0;
63}
64
65/*
66 * Digital out
67 */
68static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
69 struct hda_codec *codec,
70 struct snd_pcm_substream *substream)
71{
72 struct nvhdmi_spec *spec = codec->spec;
73 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
74}
75
76static int nvhdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
77 struct hda_codec *codec,
78 struct snd_pcm_substream *substream)
79{
80 struct nvhdmi_spec *spec = codec->spec;
81 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
82}
83
84static int nvhdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
85 struct hda_codec *codec,
86 unsigned int stream_tag,
87 unsigned int format,
88 struct snd_pcm_substream *substream)
89{
90 struct nvhdmi_spec *spec = codec->spec;
91 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
92 format, substream);
93}
94
95static struct hda_pcm_stream nvhdmi_pcm_digital_playback = {
96 .substreams = 1,
97 .channels_min = 2,
98 .channels_max = 2,
99 .nid = 0x4, /* NID to query formats and rates and setup streams */
100 .rates = SNDRV_PCM_RATE_48000,
101 .maxbps = 16,
102 .formats = SNDRV_PCM_FMTBIT_S16_LE,
103 .ops = {
104 .open = nvhdmi_dig_playback_pcm_open,
105 .close = nvhdmi_dig_playback_pcm_close,
106 .prepare = nvhdmi_dig_playback_pcm_prepare
107 },
108};
109
110static int nvhdmi_build_pcms(struct hda_codec *codec)
111{
112 struct nvhdmi_spec *spec = codec->spec;
113 struct hda_pcm *info = &spec->pcm_rec;
114
115 codec->num_pcms = 1;
116 codec->pcm_info = info;
117
118 info->name = "NVIDIA HDMI";
119 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = nvhdmi_pcm_digital_playback;
120
121 return 0;
122}
123
124static void nvhdmi_free(struct hda_codec *codec)
125{
126 kfree(codec->spec);
127}
128
129static struct hda_codec_ops nvhdmi_patch_ops = {
130 .build_controls = nvhdmi_build_controls,
131 .build_pcms = nvhdmi_build_pcms,
132 .init = nvhdmi_init,
133 .free = nvhdmi_free,
134};
135
136static int patch_nvhdmi(struct hda_codec *codec)
137{
138 struct nvhdmi_spec *spec;
139
140 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
141 if (spec == NULL)
142 return -ENOMEM;
143
144 codec->spec = spec;
145
146 spec->multiout.num_dacs = 0; /* no analog */
147 spec->multiout.max_channels = 2;
148 spec->multiout.dig_out_nid = 0x4; /* NID for copying analog to digital,
149 * seems to be unused in pure-digital
150 * case. */
151
152 codec->patch_ops = nvhdmi_patch_ops;
153
154 return 0;
155}
156
157/*
158 * patch entries
159 */
160struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
161 { .id = 0x10de0002, .name = "NVIDIA MCP78 HDMI", .patch = patch_nvhdmi },
162 { .id = 0x10de0007, .name = "NVIDIA MCP7A HDMI", .patch = patch_nvhdmi },
163 {} /* terminator */
164};