2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ATI HDMI codecs
6 * Copyright (c) 2006 ATI Technologies Inc.
9 * This driver is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sound/driver.h>
25 #include <linux/init.h>
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28 #include <linux/pci.h>
29 #include <sound/core.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 struct hda_multi_out multiout;
36 struct hda_pcm pcm_rec;
39 static struct hda_verb atihdmi_basic_init[] = {
40 /* enable digital output on pin widget */
41 { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
48 static int atihdmi_build_controls(struct hda_codec *codec)
50 struct atihdmi_spec *spec = codec->spec;
53 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
60 static int atihdmi_init(struct hda_codec *codec)
62 snd_hda_sequence_write(codec, atihdmi_basic_init);
70 static int atihdmi_resume(struct hda_codec *codec)
73 snd_hda_resume_spdif_out(codec);
82 static int atihdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
83 struct hda_codec *codec,
84 struct snd_pcm_substream *substream)
86 struct atihdmi_spec *spec = codec->spec;
87 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
90 static int atihdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
91 struct hda_codec *codec,
92 struct snd_pcm_substream *substream)
94 struct atihdmi_spec *spec = codec->spec;
95 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
98 static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
102 .nid = 0x2, /* NID to query formats and rates and setup streams */
104 .open = atihdmi_dig_playback_pcm_open,
105 .close = atihdmi_dig_playback_pcm_close
109 static int atihdmi_build_pcms(struct hda_codec *codec)
111 struct atihdmi_spec *spec = codec->spec;
112 struct hda_pcm *info = &spec->pcm_rec;
115 codec->pcm_info = info;
117 info->name = "ATI HDMI";
118 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback;
123 static void atihdmi_free(struct hda_codec *codec)
128 static struct hda_codec_ops atihdmi_patch_ops = {
129 .build_controls = atihdmi_build_controls,
130 .build_pcms = atihdmi_build_pcms,
131 .init = atihdmi_init,
132 .free = atihdmi_free,
134 .resume = atihdmi_resume,
138 static int patch_atihdmi(struct hda_codec *codec)
140 struct atihdmi_spec *spec;
142 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
148 spec->multiout.num_dacs = 0; /* no analog */
149 spec->multiout.max_channels = 2;
150 spec->multiout.dig_out_nid = 0x2; /* NID for copying analog to digital,
151 * seems to be unused in pure-digital
154 codec->patch_ops = atihdmi_patch_ops;
162 struct hda_codec_preset snd_hda_preset_atihdmi[] = {
163 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
164 { .id = 0x1002791a, .name = "ATI RS690 HDMI", .patch = patch_atihdmi },