<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<span id="result_box" class="long_text"><span
style="background-color: rgb(255, 255, 255);"
title="He usado esta pagina para instalar los drivers alsa, ya que esta pagina es expresamente para mi portatil asus n10j.">I've
used this page to install alsa drivers: <b> </b></span></span><b><a class="moz-txt-link-freetext" href="http://n10.wikia.com/wiki/Linux_HOWTO#HDMI_Audio_.5BNVIDIA.5D">http://n10.wikia.com/wiki/Linux_HOWTO#HDMI_Audio_.5BNVIDIA.5D</a>
</b><span id="result_box" class="long_text"><span
style="background-color: rgb(255, 255, 255);"
title="He usado esta pagina para instalar los drivers alsa, ya que esta pagina es expresamente para mi portatil asus n10j.">,
as this page is specifically for my laptop Asus N10J. </span><span
style="background-color: rgb(255, 255, 255);"
title="Creo que el problema es con el parche: patch_nvhdmi.c en el que al final del codigo deberia de cambiar algo para que funcione el sonido pero no se lo que es.">I
think the problem is with the patch: patch_nvhdmi.c in which the end of
the code should change something that works for the sound but not what
it is.<br>
<br>
</span><span style="background-color: rgb(255, 255, 255);"
title="Codigo de patch_nvhdmi.c :">Patch_nvhdmi.c Code:</span></span><br>
<br>
/*<br>
* Universal Interface for Intel High Definition Audio Codec<br>
*<br>
* HD audio interface patch for NVIDIA HDMI codecs<br>
*<br>
* Copyright (c) 2008 NVIDIA Corp. All rights reserved.<br>
* Copyright (c) 2008 Wei Ni <a class="moz-txt-link-rfc2396E" href="mailto:wni@nvidia.com"><wni@nvidia.com></a><br>
*<br>
*<br>
* This driver is free software; you can redistribute it and/or modify<br>
* it under the terms of the GNU General Public License as published by<br>
* the Free Software Foundation; either version 2 of the License, or<br>
* (at your option) any later version.<br>
*<br>
* This driver is distributed in the hope that it will be useful,<br>
* but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
* GNU General Public License for more details.<br>
*<br>
* You should have received a copy of the GNU General Public License<br>
* along with this program; if not, write to the Free Software<br>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA<br>
*/<br>
<br>
#include <linux/init.h><br>
#include <linux/delay.h><br>
#include <linux/slab.h><br>
#include <sound/core.h><br>
#include "hda_codec.h"<br>
#include "hda_local.h"<br>
<br>
struct nvhdmi_spec {<br>
struct hda_multi_out multiout;<br>
<br>
struct hda_pcm pcm_rec;<br>
};<br>
<br>
#define Nv_VERB_SET_Channel_Allocation 0xF79<br>
#define Nv_VERB_SET_Info_Frame_Checksum 0xF7A<br>
#define Nv_VERB_SET_Audio_Protection_On 0xF98<br>
#define Nv_VERB_SET_Audio_Protection_Off 0xF99<br>
<br>
#define Nv_Master_Convert_nid 0x04<br>
#define Nv_Master_Pin_nid 0x05<br>
<br>
static hda_nid_t nvhdmi_convert_nids[4] = {<br>
/*front, rear, clfe, rear_surr */<br>
0x6, 0x8, 0xa, 0xc,<br>
};<br>
<br>
static struct hda_verb nvhdmi_basic_init[] = {<br>
/* set audio protect on */<br>
{ 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},<br>
/* enable digital output on pin widget */<br>
{ 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
{ 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
{ 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
{ 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
{ 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
{} /* terminator */<br>
};<br>
<br>
/*<br>
* Controls<br>
*/<br>
static int nvhdmi_build_controls(struct hda_codec *codec)<br>
{<br>
struct nvhdmi_spec *spec = codec->spec;<br>
int err;<br>
<br>
err = snd_hda_create_spdif_out_ctls(codec,
spec->multiout.dig_out_nid);<br>
if (err < 0)<br>
return err;<br>
<br>
return 0;<br>
}<br>
<br>
static int nvhdmi_init(struct hda_codec *codec)<br>
{<br>
snd_hda_sequence_write(codec, nvhdmi_basic_init);<br>
return 0;<br>
}<br>
<br>
/*<br>
* Digital out<br>
*/<br>
static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,<br>
struct hda_codec *codec,<br>
struct snd_pcm_substream *substream)<br>
{<br>
struct nvhdmi_spec *spec = codec->spec;<br>
return snd_hda_multi_out_dig_open(codec, &spec->multiout);<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_close_8ch(struct hda_pcm_stream
*hinfo,<br>
struct hda_codec *codec,<br>
struct snd_pcm_substream *substream)<br>
{<br>
struct nvhdmi_spec *spec = codec->spec;<br>
int i;<br>
<br>
snd_hda_codec_write(codec, Nv_Master_Convert_nid,<br>
0, AC_VERB_SET_CHANNEL_STREAMID, 0);<br>
for (i = 0; i < 4; i++) {<br>
/* set the stream id */<br>
snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0,<br>
AC_VERB_SET_CHANNEL_STREAMID, 0);<br>
/* set the stream format */<br>
snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0,<br>
AC_VERB_SET_STREAM_FORMAT, 0);<br>
}<br>
<br>
return snd_hda_multi_out_dig_close(codec, &spec->multiout);<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_close_2ch(struct hda_pcm_stream
*hinfo,<br>
struct hda_codec *codec,<br>
struct snd_pcm_substream *substream)<br>
{<br>
struct nvhdmi_spec *spec = codec->spec;<br>
return snd_hda_multi_out_dig_close(codec, &spec->multiout);<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream
*hinfo,<br>
struct hda_codec *codec,<br>
unsigned int stream_tag,<br>
unsigned int format,<br>
struct snd_pcm_substream *substream)<br>
{<br>
int chs;<br>
unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id;<br>
int i;<br>
<br>
mutex_lock(&codec->spdif_mutex);<br>
<br>
chs = substream->runtime->channels;<br>
chan = chs ? (chs - 1) : 1;<br>
<br>
switch (chs) {<br>
default:<br>
case 0:<br>
case 2:<br>
chanmask = 0x00;<br>
break;<br>
case 4:<br>
chanmask = 0x08;<br>
break;<br>
case 6:<br>
chanmask = 0x0b;<br>
break;<br>
case 8:<br>
chanmask = 0x13;<br>
break;<br>
}<br>
dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT;<br>
dataDCC2 = 0x2;<br>
<br>
/* set the Audio InforFrame Channel Allocation */<br>
snd_hda_codec_write(codec, 0x1, 0,<br>
Nv_VERB_SET_Channel_Allocation, chanmask);<br>
<br>
/* turn off SPDIF once; otherwise the IEC958 bits won't be updated
*/<br>
if (codec->spdif_status_reset && (codec->spdif_ctls
& AC_DIG1_ENABLE))<br>
snd_hda_codec_write(codec,<br>
Nv_Master_Convert_nid,<br>
0,<br>
AC_VERB_SET_DIGI_CONVERT_1,<br>
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);<br>
<br>
/* set the stream id */<br>
snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0,<br>
AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) |
0x0);<br>
<br>
/* set the stream format */<br>
snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0,<br>
AC_VERB_SET_STREAM_FORMAT, format);<br>
<br>
/* turn on again (if needed) */<br>
/* enable and set the channel status audio/data flag */<br>
if (codec->spdif_status_reset && (codec->spdif_ctls
& AC_DIG1_ENABLE)) {<br>
snd_hda_codec_write(codec,<br>
Nv_Master_Convert_nid,<br>
0,<br>
AC_VERB_SET_DIGI_CONVERT_1,<br>
codec->spdif_ctls & 0xff);<br>
snd_hda_codec_write(codec,<br>
Nv_Master_Convert_nid,<br>
0,<br>
AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);<br>
}<br>
<br>
for (i = 0; i < 4; i++) {<br>
if (chs == 2)<br>
channel_id = 0;<br>
else<br>
channel_id = i * 2;<br>
<br>
/* turn off SPDIF once;<br>
*otherwise the IEC958 bits won't be updated<br>
*/<br>
if (codec->spdif_status_reset &&<br>
(codec->spdif_ctls & AC_DIG1_ENABLE))<br>
snd_hda_codec_write(codec,<br>
nvhdmi_convert_nids[i],<br>
0,<br>
AC_VERB_SET_DIGI_CONVERT_1,<br>
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);<br>
/* set the stream id */<br>
snd_hda_codec_write(codec,<br>
nvhdmi_convert_nids[i],<br>
0,<br>
AC_VERB_SET_CHANNEL_STREAMID,<br>
(stream_tag << 4) | channel_id);<br>
/* set the stream format */<br>
snd_hda_codec_write(codec,<br>
nvhdmi_convert_nids[i],<br>
0,<br>
AC_VERB_SET_STREAM_FORMAT,<br>
format);<br>
/* turn on again (if needed) */<br>
/* enable and set the channel status audio/data flag */<br>
if (codec->spdif_status_reset &&<br>
(codec->spdif_ctls & AC_DIG1_ENABLE)) {<br>
snd_hda_codec_write(codec,<br>
nvhdmi_convert_nids[i],<br>
0,<br>
AC_VERB_SET_DIGI_CONVERT_1,<br>
codec->spdif_ctls & 0xff);<br>
snd_hda_codec_write(codec,<br>
nvhdmi_convert_nids[i],<br>
0,<br>
AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);<br>
}<br>
}<br>
<br>
/* set the Audio Info Frame Checksum */<br>
snd_hda_codec_write(codec, 0x1, 0,<br>
Nv_VERB_SET_Info_Frame_Checksum,<br>
(0x71 - chan - chanmask));<br>
<br>
mutex_unlock(&codec->spdif_mutex);<br>
return 0;<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream
*hinfo,<br>
struct hda_codec *codec,<br>
unsigned int stream_tag,<br>
unsigned int format,<br>
struct snd_pcm_substream *substream)<br>
{<br>
struct nvhdmi_spec *spec = codec->spec;<br>
return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
stream_tag,<br>
format, substream);<br>
}<br>
<br>
static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch = {<br>
.substreams = 1,<br>
.channels_min = 2,<br>
.channels_max = 8,<br>
.nid = Nv_Master_Convert_nid,<br>
.rates = SNDRV_PCM_RATE_48000,<br>
.maxbps = 16,<br>
.formats = SNDRV_PCM_FMTBIT_S16_LE,<br>
.ops = {<br>
.open = nvhdmi_dig_playback_pcm_open,<br>
.close = nvhdmi_dig_playback_pcm_close_8ch,<br>
.prepare = nvhdmi_dig_playback_pcm_prepare_8ch<br>
},<br>
};<br>
<br>
static struct hda_pcm_stream nvhdmi_pcm_digital_playback_2ch = {<br>
.substreams = 1,<br>
.channels_min = 2,<br>
.channels_max = 2,<br>
.nid = Nv_Master_Convert_nid,<br>
.rates = SNDRV_PCM_RATE_48000,<br>
.maxbps = 16,<br>
.formats = SNDRV_PCM_FMTBIT_S16_LE,<br>
.ops = {<br>
.open = nvhdmi_dig_playback_pcm_open,<br>
.close = nvhdmi_dig_playback_pcm_close_2ch,<br>
.prepare = nvhdmi_dig_playback_pcm_prepare_2ch<br>
},<br>
};<br>
<br>
static int nvhdmi_build_pcms_8ch(struct hda_codec *codec)<br>
{<br>
struct nvhdmi_spec *spec = codec->spec;<br>
struct hda_pcm *info = &spec->pcm_rec;<br>
<br>
codec->num_pcms = 1;<br>
codec->pcm_info = info;<br>
<br>
info->name = "NVIDIA HDMI";<br>
info->pcm_type = HDA_PCM_TYPE_HDMI;<br>
info->stream[SNDRV_PCM_STREAM_PLAYBACK]<br>
= nvhdmi_pcm_digital_playback_8ch;<br>
<br>
return 0;<br>
}<br>
<br>
static int nvhdmi_build_pcms_2ch(struct hda_codec *codec)<br>
{<br>
struct nvhdmi_spec *spec = codec->spec;<br>
struct hda_pcm *info = &spec->pcm_rec;<br>
<br>
codec->num_pcms = 1;<br>
codec->pcm_info = info;<br>
<br>
info->name = "NVIDIA HDMI";<br>
info->pcm_type = HDA_PCM_TYPE_HDMI;<br>
info->stream[SNDRV_PCM_STREAM_PLAYBACK]<br>
= nvhdmi_pcm_digital_playback_2ch;<br>
<br>
return 0;<br>
}<br>
<br>
static void nvhdmi_free(struct hda_codec *codec)<br>
{<br>
kfree(codec->spec);<br>
}<br>
<br>
static struct hda_codec_ops nvhdmi_patch_ops_8ch = {<br>
.build_controls = nvhdmi_build_controls,<br>
.build_pcms = nvhdmi_build_pcms_8ch,<br>
.init = nvhdmi_init,<br>
.free = nvhdmi_free,<br>
};<br>
<br>
static struct hda_codec_ops nvhdmi_patch_ops_2ch = {<br>
.build_controls = nvhdmi_build_controls,<br>
.build_pcms = nvhdmi_build_pcms_2ch,<br>
.init = nvhdmi_init,<br>
.free = nvhdmi_free,<br>
};<br>
<br>
static int patch_nvhdmi_8ch(struct hda_codec *codec)<br>
{<br>
struct nvhdmi_spec *spec;<br>
<br>
spec = kzalloc(sizeof(*spec), GFP_KERNEL);<br>
if (spec == NULL)<br>
return -ENOMEM;<br>
<br>
codec->spec = spec;<br>
<br>
spec->multiout.num_dacs = 0; /* no analog */<br>
spec->multiout.max_channels = 8;<br>
spec->multiout.dig_out_nid = Nv_Master_Convert_nid;<br>
<br>
codec->patch_ops = nvhdmi_patch_ops_8ch;<br>
<br>
return 0;<br>
}<br>
<br>
static int patch_nvhdmi_2ch(struct hda_codec *codec)<br>
{<br>
struct nvhdmi_spec *spec;<br>
<br>
spec = kzalloc(sizeof(*spec), GFP_KERNEL);<br>
if (spec == NULL)<br>
return -ENOMEM;<br>
<br>
codec->spec = spec;<br>
<br>
spec->multiout.num_dacs = 0; /* no analog */<br>
spec->multiout.max_channels = 2;<br>
spec->multiout.dig_out_nid = Nv_Master_Convert_nid;<br>
<br>
codec->patch_ops = nvhdmi_patch_ops_2ch;<br>
<br>
return 0;<br>
}<br>
<br>
/*<br>
* patch entries<br>
*/<br>
<b>static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {<br>
{ .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch
},<br>
{ .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch
},<br>
{ .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch
},<br>
{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch
},<br>
{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch
},<br>
{ .id = 0x10de0003, .name = "ID 3", .patch = patch_nvhdmi_8ch },<br>
{} /* terminator */<br>
};<br>
<br>
MODULE_ALIAS("snd-hda-codec-id:10de0002");<br>
MODULE_ALIAS("snd-hda-codec-id:10de0006");<br>
MODULE_ALIAS("snd-hda-codec-id:10de0007");<br>
MODULE_ALIAS("snd-hda-codec-id:10de0067");<br>
MODULE_ALIAS("snd-hda-codec-id:10de8001");<br>
MODULE_ALIAS("snd-hda-codec-id:10de0003");<br>
</b><br>
MODULE_LICENSE("GPL");<br>
MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec");<br>
<br>
static struct hda_codec_preset_list nvhdmi_list = {<br>
.preset = snd_hda_preset_nvhdmi,<br>
.owner = THIS_MODULE,<br>
};<br>
<br>
static int __init patch_nvhdmi_init(void)<br>
{<br>
return snd_hda_add_codec_preset(&nvhdmi_list);<br>
}<br>
<br>
static void __exit patch_nvhdmi_exit(void)<br>
{<br>
snd_hda_delete_codec_preset(&nvhdmi_list);<br>
}<br>
<br>
module_init(patch_nvhdmi_init)<br>
module_exit(patch_nvhdmi_exit)<br>
<br>
<br>
</body>
</html>