2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for NVIDIA HDMI codecs
6 * Copyright (c) 2008 NVIDIA Corp. All rights reserved.
7 * Copyright (c) 2008 Wei Ni <wni@nvidia.com>
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.
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.
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
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"
33 struct hda_multi_out multiout
;
35 struct hda_pcm pcm_rec
;
38 static struct hda_verb nvhdmi_basic_init
[] = {
39 /* enable digital output on pin widget */
40 { 0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
47 static int nvhdmi_build_controls(struct hda_codec
*codec
)
49 struct nvhdmi_spec
*spec
= codec
->spec
;
52 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
59 static int nvhdmi_init(struct hda_codec
*codec
)
61 snd_hda_sequence_write(codec
, nvhdmi_basic_init
);
68 static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
69 struct hda_codec
*codec
,
70 struct snd_pcm_substream
*substream
)
72 struct nvhdmi_spec
*spec
= codec
->spec
;
73 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
76 static int nvhdmi_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
77 struct hda_codec
*codec
,
78 struct snd_pcm_substream
*substream
)
80 struct nvhdmi_spec
*spec
= codec
->spec
;
81 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
84 static int nvhdmi_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
85 struct hda_codec
*codec
,
86 unsigned int stream_tag
,
88 struct snd_pcm_substream
*substream
)
90 struct nvhdmi_spec
*spec
= codec
->spec
;
91 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
, stream_tag
,
95 static struct hda_pcm_stream nvhdmi_pcm_digital_playback
= {
99 .nid
= 0x4, /* NID to query formats and rates and setup streams */
100 .rates
= SNDRV_PCM_RATE_48000
,
102 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
104 .open
= nvhdmi_dig_playback_pcm_open
,
105 .close
= nvhdmi_dig_playback_pcm_close
,
106 .prepare
= nvhdmi_dig_playback_pcm_prepare
110 static int nvhdmi_build_pcms(struct hda_codec
*codec
)
112 struct nvhdmi_spec
*spec
= codec
->spec
;
113 struct hda_pcm
*info
= &spec
->pcm_rec
;
116 codec
->pcm_info
= info
;
118 info
->name
= "NVIDIA HDMI";
119 info
->pcm_type
= HDA_PCM_TYPE_HDMI
;
120 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = nvhdmi_pcm_digital_playback
;
125 static void nvhdmi_free(struct hda_codec
*codec
)
130 static struct hda_codec_ops nvhdmi_patch_ops
= {
131 .build_controls
= nvhdmi_build_controls
,
132 .build_pcms
= nvhdmi_build_pcms
,
137 static int patch_nvhdmi(struct hda_codec
*codec
)
139 struct nvhdmi_spec
*spec
;
141 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
147 spec
->multiout
.num_dacs
= 0; /* no analog */
148 spec
->multiout
.max_channels
= 2;
149 spec
->multiout
.dig_out_nid
= 0x4; /* NID for copying analog to digital,
150 * seems to be unused in pure-digital
153 codec
->patch_ops
= nvhdmi_patch_ops
;
161 static struct hda_codec_preset snd_hda_preset_nvhdmi
[] = {
162 { .id
= 0x10de0002, .name
= "MCP78 HDMI", .patch
= patch_nvhdmi
},
163 { .id
= 0x10de0006, .name
= "MCP78 HDMI", .patch
= patch_nvhdmi
},
164 { .id
= 0x10de0007, .name
= "MCP7A HDMI", .patch
= patch_nvhdmi
},
165 { .id
= 0x10de0067, .name
= "MCP67 HDMI", .patch
= patch_nvhdmi
},
166 { .id
= 0x10de8001, .name
= "MCP73 HDMI", .patch
= patch_nvhdmi
},
170 MODULE_ALIAS("snd-hda-codec-id:10de0002");
171 MODULE_ALIAS("snd-hda-codec-id:10de0006");
172 MODULE_ALIAS("snd-hda-codec-id:10de0007");
173 MODULE_ALIAS("snd-hda-codec-id:10de0067");
174 MODULE_ALIAS("snd-hda-codec-id:10de8001");
176 MODULE_LICENSE("GPL");
177 MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec");
179 static struct hda_codec_preset_list nvhdmi_list
= {
180 .preset
= snd_hda_preset_nvhdmi
,
181 .owner
= THIS_MODULE
,
184 static int __init
patch_nvhdmi_init(void)
186 return snd_hda_add_codec_preset(&nvhdmi_list
);
189 static void __exit
patch_nvhdmi_exit(void)
191 snd_hda_delete_codec_preset(&nvhdmi_list
);
194 module_init(patch_nvhdmi_init
)
195 module_exit(patch_nvhdmi_exit
)