PATCH - via82xx vt1618 7.1 Audio Support
Makes Audio > 2.0 work on the VIA vt1618 7.1 Channel AC97 Codec
Patched against ALSA-GIT Fri Aug 22 16:24:52 PDT 2008
pci/ac97/ac97_codec.c +0 -0
@@ -168,7 +168,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[]
= {
{ 0x54584e20, 0xffffffff, "TLC320AD9xC", NULL, NULL },
{ 0x56494161, 0xffffffff, "VIA1612A", NULL, NULL }, // modified ICE1232
with S/PDIF
{ 0x56494170, 0xffffffff, "VIA1617A", patch_vt1617a, NULL }, // modified
VT1616 with S/PDIF
-{ 0x56494182, 0xffffffff, "VIA1618", NULL, NULL },
+{ 0x56494182, 0xffffffff, "VIA1618", patch_vt1618, NULL },
{ 0x57454301, 0xffffffff, "W83971D", NULL, NULL },
{ 0x574d4c00, 0xffffffff, "WM9701,WM9701A", NULL, NULL },
{ 0x574d4C03, 0xffffffff, "WM9703,WM9707,WM9708,WM9717", patch_wolfson03,
NULL},
@@ -609,7 +609,6 @@ AC97_SINGLE("PC Speaker Playback Volume", AC97_PC_BEEP, 1, 15, 1)
static const struct snd_kcontrol_new snd_ac97_controls_mic_boost =
AC97_SINGLE("Mic Boost (+20dB)", AC97_MIC, 6, 1, 0);
-
static const char* std_rec_sel[] = {"Mic", "CD", "Video", "Aux", "Line",
"Mix", "Mix Mono", "Phone"};
static const char* std_3d_path[] = {"pre 3D", "post 3D"}; static const char* std_mix[] = {"Mix", "Mic"};
pci/ac97/ac97_patch.c +1 -1
@@ -3465,7 +3465,7 @@ static int patch_vt1616(struct snd_ac97 * ac97)/* * unfortunately, the vt1617a stashes the twiddlers required for -* nooding the i/o jacks on 2 different regs. * thameans that we cant +* noodling the i/o jacks on 2 different regs. that means that we cant * use the easy way provided by AC97_ENUM_DOUBLE() we have to write * are own funcs. *
@@ -3498,7 +3498,7 @@ static int snd_ac97_vt1617a_smart51_get(struct
snd_kcontrol *kcontrol,
pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
- /* grab our desirec bits, then mash them together in a manner
+ /* grab our desired bits, then mash them together in a manner
* consistent with Table 6 on page 17 in the 1617a docs */
usSM51 = snd_ac97_read(pac97, 0x7a) >> 14;
@@ -3576,6 +3576,200 @@ int patch_vt1617a(struct snd_ac97 * ac97)
return err;
}
+/* VIA VT1618 8 CHANNEL AC97 CODEC */
+
+/* config aux in jack - not found on 3 jack motherboards or soundcards */ +
+static int snd_ac97_vt1618_aux_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ static const char *acTxtAux[] = {"Aux In", "Back Surr Out"};
+
+ return ac97_enum_text_info(kcontrol, uinfo, acTxtAux, 2);
+}
+
+static int snd_ac97_vt1618_aux_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ ucontrol->value.enumerated.item[0] =
+ (snd_ac97_read(snd_kcontrol_chip(kcontrol), 0x5c) & 0x0008)>>3;
+ return 0;
+}
+
+static int snd_ac97_vt1618_aux_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ /* toggle surround rear dac power */
+
+ snd_ac97_update_bits(snd_kcontrol_chip(kcontrol), 0x5c, 0x0008,
+ ucontrol->value.enumerated.item[0] << 3);
+
+ /* toggle aux in surround rear out jack */
+
+ return snd_ac97_update_bits(snd_kcontrol_chip(kcontrol), 0x76, 0x0008,
+ ucontrol->value.enumerated.item[0] << 3);
+}
+
+
+/*
+ * VIA implements 'Smart 5.1' completely differently on the 1618 than
+ * it does on the 1617a. awesome! They seem to have sourced this
+ * particular revision of the technology from somebody else, it's
+ * called Universal Audio Jack and it shows up on some other folk's chips
+ * as well.
+ *
+ * ordering in this list reflects vt1618 docs for Reg 60h and
+ * the block diagram, DACs are as follows:
+ *
+ * OUT_O -> Front,
+ * OUT_1 -> Surround,
+ * OUT_2 -> C/LFE
+ *
+ * Unlike the 1617a, each OUT has a consistent set of mappings
+ * for all bitpatterns other than 00:
+ *
+ * 01 Unmixed Output + * 10 Line In + * 11 Mic In + * + * Special Case of 00: + * + * OUT_0 Mixed Output + * OUT_1 Reserved + * OUT_2 Reserved
+ *
+ * I have no idea what the hell Reserved does, but on an MSI
+ * CN700T, i have to set it to get surround output - YMMV, bad
+ * shit may happen.
+ *
+ * If other chips use Universal Audio Jack, then this code might be
+ * applicable to them.
+ */
+
+static int snd_ac97_vt1618_UAJ_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ /* cribbed from ac97_surround_jack_mode_info() ordering in these lists
+ * reflects vt1618 docs for Vendor Defined Register 0x60 */
+
+ static const char *acTxtUAJ0[] =
+ { "Speaker Out", "DAC Unmixed Out", "Line In", "Mic In"};
+
+ static const char *acTxtUAJ1[] =
+ { "Surround Out", "DAC Unmixed Out", "Line In", "Mic In"};
+
+ static const char *acTxtUAJ2[] =
+ { "Center LFE Out", "DAC Unmixed Out", "Line In", "Mic In"};
+
+ const char **ppacTxt = acTxtUAJ0;
+
+ if (0x000C == kcontrol->private_value)
+ ppacTxt = acTxtUAJ1;
+
+ if (0x0030 == kcontrol->private_value)
+ ppacTxt = acTxtUAJ2;
+
+ return ac97_enum_text_info(kcontrol, uinfo, ppacTxt, 4);
+}
+
+/* All of the vt1618 Universal Audio Jack twiddlers are on
+ Vendor Defined Register 0x60, page 0. The bits, and thus
+ the mask, are the only thing that changes */
+
+static int snd_ac97_vt1618_UAJ_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ unsigned short usDatPag, usUAJ, usShift = 0;
+ struct snd_ac97 *pac97 = snd_kcontrol_chip(kcontrol);
+
+ if (0x000C == kcontrol->private_value)
+ usShift = 2;
+
+ if (0x0030 == kcontrol->private_value)
+ usShift = 4;
+
+ mutex_lock(&pac97->page_mutex);
+
+ usDatPag = snd_ac97_read(pac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
+ snd_ac97_update_bits(pac97, AC97_INT_PAGING, AC97_PAGE_MASK, 0);
+
+ usUAJ = snd_ac97_read(pac97, 0x60) & kcontrol->private_value;
+
+ snd_ac97_update_bits(pac97, AC97_INT_PAGING, AC97_PAGE_MASK, usDatPag);
+ mutex_unlock(&pac97->page_mutex);
+
+ ucontrol->value.enumerated.item[0] = usUAJ >> usShift;
+
+ return 0;
+}
+
+static int snd_ac97_vt1618_UAJ_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ unsigned short usSft = 0;
+
+ if (0x000C == kcontrol->private_value)
+ usSft = 2;
+
+ if (0x0030 == kcontrol->private_value)
+ usSft = 4;
+
+ /* UAJ1 and UAJ2 are not supposed to have 00 written to them?? i
+ * dunno, because thats something that i have to do to get 5.1 out to
+ * work. */
+
+ return ac97_update_bits_page(snd_kcontrol_chip(kcontrol),
+ 0x60, kcontrol->private_value,
+ ucontrol->value.enumerated.item[0]<<usSft,
+ 0);
+}
+
+static const struct snd_kcontrol_new snd_ac97_controls_vt1618[] = {
+ AC97_SINGLE("Exchange Center/LFE", 0x5a, 8, 1, 0),
+ AC97_SINGLE("DC Offset", 0x5a, 10, 1, 0),
+ AC97_SINGLE("Soft Mute", 0x5c, 0, 1, 1),
+ AC97_SINGLE("Headphone Amp", 0x5c, 5, 1, 1),
+ AC97_DOUBLE("Back Surr Volume", 0x5e, 8, 0, 31, 1),
+ AC97_SINGLE("Back Surr Switch", 0x5e, 15, 1, 1),
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Aux Jack",
+ .info = snd_ac97_vt1618_aux_info,
+ .get = snd_ac97_vt1618_aux_get,
+ .put = snd_ac97_vt1618_aux_put,
+ },
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Speaker Jack",
+ .info = snd_ac97_vt1618_UAJ_info,
+ .get = snd_ac97_vt1618_UAJ_get,
+ .put = snd_ac97_vt1618_UAJ_put,
+ .private_value = 0x0003
+ },
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Line Jack",
+ .info = snd_ac97_vt1618_UAJ_info,
+ .get = snd_ac97_vt1618_UAJ_get,
+ .put = snd_ac97_vt1618_UAJ_put,
+ .private_value = 0x000C
+ },
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Mic Jack",
+ .info = snd_ac97_vt1618_UAJ_info,
+ .get = snd_ac97_vt1618_UAJ_get,
+ .put = snd_ac97_vt1618_UAJ_put,+ .private_value = 0x0030
+ },
+};
+
+int patch_vt1618(struct snd_ac97 *ac97)
+{
+ return patch_build_controls(ac97, snd_ac97_controls_vt1618,
+ ARRAY_SIZE(snd_ac97_controls_vt1618));
+}
+
/*
*/
static void it2646_update_jacks(struct snd_ac97 *ac97)
At Fri, 22 Aug 2008 16:26:59 -0700,
Quoted 6 lines · John L. Utz III
Makes Audio > 2.0 work on the VIA vt1618 7.1 Channel AC97 Codec
Patched against ALSA-GIT Fri Aug 22 16:24:52 PDT 2008
Authored-by John L. Utz III [email protected]
It's taken from "From:" tag. If you need a different address for the patch, put "From:" tag with that address before the patch description.
Quoted 1 line
Signed-off-by John L. Utz III [email protected]
Put the address with <> please.
Review
Quoted 8 lines
(quoted diff) +8
-0+/* VIA VT1618 8 CHANNEL AC97 CODEC */ + +/* config aux in jack - not found on 3 jack motherboards or soundcards */ + +static int snd_ac97_vt1618_aux_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static const char *acTxtAux[] = {"Aux In", "Back Surr Out"};
As mentioned earlier, the Hungarian notation should be avoided (unless it must be so). In this case, use a plain variable name like "text_aux".
Quoted 12 lines
(quoted diff) +12
-0+static int snd_ac97_vt1618_UAJ_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + /* cribbed from ac97_surround_jack_mode_info() ordering in these lists + * reflects vt1618 docs for Vendor Defined Register 0x60 */ + + static const char *acTxtUAJ0[] = + { "Speaker Out", "DAC Unmixed Out", "Line In", "Mic In"}; + + static const char *acTxtUAJ1[] = + { "Surround Out", "DAC Unmixed Out", "Line In", "Mic In"}; +
Review
Quoted 10 lines
(quoted diff) +10
-0+ static const char *acTxtUAJ2[] = + { "Center LFE Out", "DAC Unmixed Out", "Line In", "Mic In"}; + + const char **ppacTxt = acTxtUAJ0; + + if (0x000C == kcontrol->private_value) + ppacTxt = acTxtUAJ1; + + if (0x0030 == kcontrol->private_value) + ppacTxt = acTxtUAJ2;
Maybe it's cleaner to define the code like the following:
struct vt1618_uaj_item {
unsigned short reg;
unsigned short shift;
const char *items[4];
};static struct vt1618_uaj *vt1618_uaj[3] = {
{
/* speaker jack */
.reg = 0x03,
.shift = 0,
.items = {
"Speaker Out", "DAC Unmixed Out", "Line In", "Mic In"
},
},
{
/* line jack */
.reg = 0x0c,
.shift = 2,
.items = {
"Surround Out", "DAC Unmixed Out", "Line In", "Mic In"
},
},
{
/* mic jack */
.reg = 0x30,
.shift = 4,
.items = {
"Center LFE Out", "DAC Unmixed Out", "Line In",
"Mic In"
},
},
};And pass the array index to private_value field.
Then you can avoid if's in each callback.
Review
Quoted 10 lines
(quoted diff) +10
-0+static const struct snd_kcontrol_new snd_ac97_controls_vt1618[] = { + AC97_SINGLE("Exchange Center/LFE", 0x5a, 8, 1, 0), + AC97_SINGLE("DC Offset", 0x5a, 10, 1, 0), + AC97_SINGLE("Soft Mute", 0x5c, 0, 1, 1), + AC97_SINGLE("Headphone Amp", 0x5c, 5, 1, 1), + AC97_DOUBLE("Back Surr Volume", 0x5e, 8, 0, 31, 1), + AC97_SINGLE("Back Surr Switch", 0x5e, 15, 1, 1), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Aux Jack",
Better to be "Aux Jack Mode" or such.
Could you fix these issues and repost?
thanks,
Takashi