<!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:&nbsp;<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>
&nbsp;* Universal Interface for Intel High Definition Audio Codec<br>
&nbsp;*<br>
&nbsp;* HD audio interface patch for NVIDIA HDMI codecs<br>
&nbsp;*<br>
&nbsp;* Copyright (c) 2008 NVIDIA Corp.&nbsp; All rights reserved.<br>
&nbsp;* Copyright (c) 2008 Wei Ni <a class="moz-txt-link-rfc2396E" href="mailto:wni@nvidia.com">&lt;wni@nvidia.com&gt;</a><br>
&nbsp;*<br>
&nbsp;*<br>
&nbsp;*&nbsp; This driver is free software; you can redistribute it and/or modify<br>
&nbsp;*&nbsp; it under the terms of the GNU General Public License as published by<br>
&nbsp;*&nbsp; the Free Software Foundation; either version 2 of the License, or<br>
&nbsp;*&nbsp; (at your option) any later version.<br>
&nbsp;*<br>
&nbsp;*&nbsp; This driver is distributed in the hope that it will be useful,<br>
&nbsp;*&nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
&nbsp;*&nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the<br>
&nbsp;*&nbsp; GNU General Public License for more details.<br>
&nbsp;*<br>
&nbsp;*&nbsp; You should have received a copy of the GNU General Public License<br>
&nbsp;*&nbsp; along with this program; if not, write to the Free Software<br>
&nbsp;*&nbsp; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA&nbsp;
02111-1307 USA<br>
&nbsp;*/<br>
<br>
#include &lt;linux/init.h&gt;<br>
#include &lt;linux/delay.h&gt;<br>
#include &lt;linux/slab.h&gt;<br>
#include &lt;sound/core.h&gt;<br>
#include "hda_codec.h"<br>
#include "hda_local.h"<br>
<br>
struct nvhdmi_spec {<br>
&nbsp;&nbsp;&nbsp; struct hda_multi_out multiout;<br>
<br>
&nbsp;&nbsp;&nbsp; struct hda_pcm pcm_rec;<br>
};<br>
<br>
#define Nv_VERB_SET_Channel_Allocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xF79<br>
#define Nv_VERB_SET_Info_Frame_Checksum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xF7A<br>
#define Nv_VERB_SET_Audio_Protection_On&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xF98<br>
#define Nv_VERB_SET_Audio_Protection_Off&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xF99<br>
<br>
#define Nv_Master_Convert_nid&nbsp;&nbsp; 0x04<br>
#define Nv_Master_Pin_nid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x05<br>
<br>
static hda_nid_t nvhdmi_convert_nids[4] = {<br>
&nbsp;&nbsp;&nbsp; /*front, rear, clfe, rear_surr */<br>
&nbsp;&nbsp;&nbsp; 0x6, 0x8, 0xa, 0xc,<br>
};<br>
<br>
static struct hda_verb nvhdmi_basic_init[] = {<br>
&nbsp;&nbsp;&nbsp; /* set audio protect on */<br>
&nbsp;&nbsp;&nbsp; { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},<br>
&nbsp;&nbsp;&nbsp; /* enable digital output on pin widget */<br>
&nbsp;&nbsp;&nbsp; { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
&nbsp;&nbsp;&nbsp; { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
&nbsp;&nbsp;&nbsp; { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
&nbsp;&nbsp;&nbsp; { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
&nbsp;&nbsp;&nbsp; { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },<br>
&nbsp;&nbsp;&nbsp; {} /* terminator */<br>
};<br>
<br>
/*<br>
&nbsp;* Controls<br>
&nbsp;*/<br>
static int nvhdmi_build_controls(struct hda_codec *codec)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec = codec-&gt;spec;<br>
&nbsp;&nbsp;&nbsp; int err;<br>
<br>
&nbsp;&nbsp;&nbsp; err = snd_hda_create_spdif_out_ctls(codec,
spec-&gt;multiout.dig_out_nid);<br>
&nbsp;&nbsp;&nbsp; if (err &lt; 0)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return err;<br>
<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
static int nvhdmi_init(struct hda_codec *codec)<br>
{<br>
&nbsp;&nbsp;&nbsp; snd_hda_sequence_write(codec, nvhdmi_basic_init);<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
/*<br>
&nbsp;* Digital out<br>
&nbsp;*/<br>
static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct hda_codec *codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct snd_pcm_substream *substream)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec = codec-&gt;spec;<br>
&nbsp;&nbsp;&nbsp; return snd_hda_multi_out_dig_open(codec, &amp;spec-&gt;multiout);<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_close_8ch(struct hda_pcm_stream
*hinfo,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct hda_codec *codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct snd_pcm_substream *substream)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec = codec-&gt;spec;<br>
&nbsp;&nbsp;&nbsp; int i;<br>
<br>
&nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec, Nv_Master_Convert_nid,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0, AC_VERB_SET_CHANNEL_STREAMID, 0);<br>
&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; 4; i++) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* set the stream id */<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_CHANNEL_STREAMID, 0);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* set the stream format */<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_STREAM_FORMAT, 0);<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; return snd_hda_multi_out_dig_close(codec, &amp;spec-&gt;multiout);<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_close_2ch(struct hda_pcm_stream
*hinfo,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct hda_codec *codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct snd_pcm_substream *substream)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec = codec-&gt;spec;<br>
&nbsp;&nbsp;&nbsp; return snd_hda_multi_out_dig_close(codec, &amp;spec-&gt;multiout);<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream
*hinfo,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct hda_codec *codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned int stream_tag,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned int format,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct snd_pcm_substream *substream)<br>
{<br>
&nbsp;&nbsp;&nbsp; int chs;<br>
&nbsp;&nbsp;&nbsp; unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id;<br>
&nbsp;&nbsp;&nbsp; int i;<br>
<br>
&nbsp;&nbsp;&nbsp; mutex_lock(&amp;codec-&gt;spdif_mutex);<br>
<br>
&nbsp;&nbsp;&nbsp; chs = substream-&gt;runtime-&gt;channels;<br>
&nbsp;&nbsp;&nbsp; chan = chs ? (chs - 1) : 1;<br>
<br>
&nbsp;&nbsp;&nbsp; switch (chs) {<br>
&nbsp;&nbsp;&nbsp; default:<br>
&nbsp;&nbsp;&nbsp; case 0:<br>
&nbsp;&nbsp;&nbsp; case 2:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; chanmask = 0x00;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp; case 4:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; chanmask = 0x08;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp; case 6:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; chanmask = 0x0b;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp; case 8:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; chanmask = 0x13;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT;<br>
&nbsp;&nbsp;&nbsp; dataDCC2 = 0x2;<br>
<br>
&nbsp;&nbsp;&nbsp; /* set the Audio InforFrame Channel Allocation */<br>
&nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec, 0x1, 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Nv_VERB_SET_Channel_Allocation, chanmask);<br>
<br>
&nbsp;&nbsp;&nbsp; /* turn off SPDIF once; otherwise the IEC958 bits won't be updated
*/<br>
&nbsp;&nbsp;&nbsp; if (codec-&gt;spdif_status_reset &amp;&amp; (codec-&gt;spdif_ctls
&amp; AC_DIG1_ENABLE))<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Nv_Master_Convert_nid,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_DIGI_CONVERT_1,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; codec-&gt;spdif_ctls &amp; ~AC_DIG1_ENABLE &amp; 0xff);<br>
<br>
&nbsp;&nbsp;&nbsp; /* set the stream id */<br>
&nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_CHANNEL_STREAMID, (stream_tag &lt;&lt; 4) |
0x0);<br>
<br>
&nbsp;&nbsp;&nbsp; /* set the stream format */<br>
&nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_STREAM_FORMAT, format);<br>
<br>
&nbsp;&nbsp;&nbsp; /* turn on again (if needed) */<br>
&nbsp;&nbsp;&nbsp; /* enable and set the channel status audio/data flag */<br>
&nbsp;&nbsp;&nbsp; if (codec-&gt;spdif_status_reset &amp;&amp; (codec-&gt;spdif_ctls
&amp; AC_DIG1_ENABLE)) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Nv_Master_Convert_nid,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_DIGI_CONVERT_1,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; codec-&gt;spdif_ctls &amp; 0xff);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Nv_Master_Convert_nid,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; 4; i++) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (chs == 2)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; channel_id = 0;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; channel_id = i * 2;<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* turn off SPDIF once;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*otherwise the IEC958 bits won't be updated<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*/<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (codec-&gt;spdif_status_reset &amp;&amp;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (codec-&gt;spdif_ctls &amp; AC_DIG1_ENABLE))<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nvhdmi_convert_nids[i],<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_DIGI_CONVERT_1,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; codec-&gt;spdif_ctls &amp; ~AC_DIG1_ENABLE &amp; 0xff);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* set the stream id */<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nvhdmi_convert_nids[i],<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_CHANNEL_STREAMID,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (stream_tag &lt;&lt; 4) | channel_id);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* set the stream format */<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nvhdmi_convert_nids[i],<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_STREAM_FORMAT,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; format);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* turn on again (if needed) */<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* enable and set the channel status audio/data flag */<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (codec-&gt;spdif_status_reset &amp;&amp;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (codec-&gt;spdif_ctls &amp; AC_DIG1_ENABLE)) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nvhdmi_convert_nids[i],<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_DIGI_CONVERT_1,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; codec-&gt;spdif_ctls &amp; 0xff);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nvhdmi_convert_nids[i],<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; /* set the Audio Info Frame Checksum */<br>
&nbsp;&nbsp;&nbsp; snd_hda_codec_write(codec, 0x1, 0,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Nv_VERB_SET_Info_Frame_Checksum,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (0x71 - chan - chanmask));<br>
<br>
&nbsp;&nbsp;&nbsp; mutex_unlock(&amp;codec-&gt;spdif_mutex);<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream
*hinfo,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct hda_codec *codec,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned int stream_tag,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned int format,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; struct snd_pcm_substream *substream)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec = codec-&gt;spec;<br>
&nbsp;&nbsp;&nbsp; return snd_hda_multi_out_dig_prepare(codec, &amp;spec-&gt;multiout,
stream_tag,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; format, substream);<br>
}<br>
<br>
static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch = {<br>
&nbsp;&nbsp;&nbsp; .substreams = 1,<br>
&nbsp;&nbsp;&nbsp; .channels_min = 2,<br>
&nbsp;&nbsp;&nbsp; .channels_max = 8,<br>
&nbsp;&nbsp;&nbsp; .nid = Nv_Master_Convert_nid,<br>
&nbsp;&nbsp;&nbsp; .rates = SNDRV_PCM_RATE_48000,<br>
&nbsp;&nbsp;&nbsp; .maxbps = 16,<br>
&nbsp;&nbsp;&nbsp; .formats = SNDRV_PCM_FMTBIT_S16_LE,<br>
&nbsp;&nbsp;&nbsp; .ops = {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .open = nvhdmi_dig_playback_pcm_open,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .close = nvhdmi_dig_playback_pcm_close_8ch,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .prepare = nvhdmi_dig_playback_pcm_prepare_8ch<br>
&nbsp;&nbsp;&nbsp; },<br>
};<br>
<br>
static struct hda_pcm_stream nvhdmi_pcm_digital_playback_2ch = {<br>
&nbsp;&nbsp;&nbsp; .substreams = 1,<br>
&nbsp;&nbsp;&nbsp; .channels_min = 2,<br>
&nbsp;&nbsp;&nbsp; .channels_max = 2,<br>
&nbsp;&nbsp;&nbsp; .nid = Nv_Master_Convert_nid,<br>
&nbsp;&nbsp;&nbsp; .rates = SNDRV_PCM_RATE_48000,<br>
&nbsp;&nbsp;&nbsp; .maxbps = 16,<br>
&nbsp;&nbsp;&nbsp; .formats = SNDRV_PCM_FMTBIT_S16_LE,<br>
&nbsp;&nbsp;&nbsp; .ops = {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .open = nvhdmi_dig_playback_pcm_open,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .close = nvhdmi_dig_playback_pcm_close_2ch,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .prepare = nvhdmi_dig_playback_pcm_prepare_2ch<br>
&nbsp;&nbsp;&nbsp; },<br>
};<br>
<br>
static int nvhdmi_build_pcms_8ch(struct hda_codec *codec)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec = codec-&gt;spec;<br>
&nbsp;&nbsp;&nbsp; struct hda_pcm *info = &amp;spec-&gt;pcm_rec;<br>
<br>
&nbsp;&nbsp;&nbsp; codec-&gt;num_pcms = 1;<br>
&nbsp;&nbsp;&nbsp; codec-&gt;pcm_info = info;<br>
<br>
&nbsp;&nbsp;&nbsp; info-&gt;name = "NVIDIA HDMI";<br>
&nbsp;&nbsp;&nbsp; info-&gt;pcm_type = HDA_PCM_TYPE_HDMI;<br>
&nbsp;&nbsp;&nbsp; info-&gt;stream[SNDRV_PCM_STREAM_PLAYBACK]<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = nvhdmi_pcm_digital_playback_8ch;<br>
<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
static int nvhdmi_build_pcms_2ch(struct hda_codec *codec)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec = codec-&gt;spec;<br>
&nbsp;&nbsp;&nbsp; struct hda_pcm *info = &amp;spec-&gt;pcm_rec;<br>
<br>
&nbsp;&nbsp;&nbsp; codec-&gt;num_pcms = 1;<br>
&nbsp;&nbsp;&nbsp; codec-&gt;pcm_info = info;<br>
<br>
&nbsp;&nbsp;&nbsp; info-&gt;name = "NVIDIA HDMI";<br>
&nbsp;&nbsp;&nbsp; info-&gt;pcm_type = HDA_PCM_TYPE_HDMI;<br>
&nbsp;&nbsp;&nbsp; info-&gt;stream[SNDRV_PCM_STREAM_PLAYBACK]<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = nvhdmi_pcm_digital_playback_2ch;<br>
<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
static void nvhdmi_free(struct hda_codec *codec)<br>
{<br>
&nbsp;&nbsp;&nbsp; kfree(codec-&gt;spec);<br>
}<br>
<br>
static struct hda_codec_ops nvhdmi_patch_ops_8ch = {<br>
&nbsp;&nbsp;&nbsp; .build_controls = nvhdmi_build_controls,<br>
&nbsp;&nbsp;&nbsp; .build_pcms = nvhdmi_build_pcms_8ch,<br>
&nbsp;&nbsp;&nbsp; .init = nvhdmi_init,<br>
&nbsp;&nbsp;&nbsp; .free = nvhdmi_free,<br>
};<br>
<br>
static struct hda_codec_ops nvhdmi_patch_ops_2ch = {<br>
&nbsp;&nbsp;&nbsp; .build_controls = nvhdmi_build_controls,<br>
&nbsp;&nbsp;&nbsp; .build_pcms = nvhdmi_build_pcms_2ch,<br>
&nbsp;&nbsp;&nbsp; .init = nvhdmi_init,<br>
&nbsp;&nbsp;&nbsp; .free = nvhdmi_free,<br>
};<br>
<br>
static int patch_nvhdmi_8ch(struct hda_codec *codec)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec;<br>
<br>
&nbsp;&nbsp;&nbsp; spec = kzalloc(sizeof(*spec), GFP_KERNEL);<br>
&nbsp;&nbsp;&nbsp; if (spec == NULL)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -ENOMEM;<br>
<br>
&nbsp;&nbsp;&nbsp; codec-&gt;spec = spec;<br>
<br>
&nbsp;&nbsp;&nbsp; spec-&gt;multiout.num_dacs = 0;&nbsp; /* no analog */<br>
&nbsp;&nbsp;&nbsp; spec-&gt;multiout.max_channels = 8;<br>
&nbsp;&nbsp;&nbsp; spec-&gt;multiout.dig_out_nid = Nv_Master_Convert_nid;<br>
<br>
&nbsp;&nbsp;&nbsp; codec-&gt;patch_ops = nvhdmi_patch_ops_8ch;<br>
<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
static int patch_nvhdmi_2ch(struct hda_codec *codec)<br>
{<br>
&nbsp;&nbsp;&nbsp; struct nvhdmi_spec *spec;<br>
<br>
&nbsp;&nbsp;&nbsp; spec = kzalloc(sizeof(*spec), GFP_KERNEL);<br>
&nbsp;&nbsp;&nbsp; if (spec == NULL)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -ENOMEM;<br>
<br>
&nbsp;&nbsp;&nbsp; codec-&gt;spec = spec;<br>
<br>
&nbsp;&nbsp;&nbsp; spec-&gt;multiout.num_dacs = 0;&nbsp; /* no analog */<br>
&nbsp;&nbsp;&nbsp; spec-&gt;multiout.max_channels = 2;<br>
&nbsp;&nbsp;&nbsp; spec-&gt;multiout.dig_out_nid = Nv_Master_Convert_nid;<br>
<br>
&nbsp;&nbsp;&nbsp; codec-&gt;patch_ops = nvhdmi_patch_ops_2ch;<br>
<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
/*<br>
&nbsp;* patch entries<br>
&nbsp;*/<br>
<b>static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {<br>
&nbsp;&nbsp;&nbsp; { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch
},<br>
&nbsp;&nbsp;&nbsp; { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch
},<br>
&nbsp;&nbsp;&nbsp; { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch
},<br>
&nbsp;&nbsp;&nbsp; { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch
},<br>
&nbsp;&nbsp;&nbsp; { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch
},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { .id = 0x10de0003, .name = "ID 3", .patch = patch_nvhdmi_8ch },<br>
&nbsp;&nbsp;&nbsp; {} /* 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>
&nbsp;&nbsp;&nbsp; .preset = snd_hda_preset_nvhdmi,<br>
&nbsp;&nbsp;&nbsp; .owner = THIS_MODULE,<br>
};<br>
<br>
static int __init patch_nvhdmi_init(void)<br>
{<br>
&nbsp;&nbsp;&nbsp; return snd_hda_add_codec_preset(&amp;nvhdmi_list);<br>
}<br>
<br>
static void __exit patch_nvhdmi_exit(void)<br>
{<br>
&nbsp;&nbsp;&nbsp; snd_hda_delete_codec_preset(&amp;nvhdmi_list);<br>
}<br>
<br>
module_init(patch_nvhdmi_init)<br>
module_exit(patch_nvhdmi_exit)<br>
<br>
<br>
</body>
</html>