All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randy Cushman <rcushman_linux@earthlink.net>
To: Alsa-devel@lists.sourceforge.net
Subject: Re: Patch for AD1985 AC97 CODEC
Date: Mon, 04 Dec 2006 16:56:32 -0500	[thread overview]
Message-ID: <45749990.1080900@earthlink.net> (raw)
In-Reply-To: <456F9B57.5020107@earthlink.net>

[-- Attachment #1: Type: text/plain, Size: 2485 bytes --]

Attached please find my revision 2 patch of improvements to the AD1985 
CODEC driver.  This supersedes the patch I submitted on 30-Nov-2006, and 
patches the latest Mercurial source.

At this time I am figuring that I may be able to reduce the amount of 
work I create for the ALSA-Project team if I combine my work into a 
smaller number of patches.  This combined patch includes all of the 
modifications I have planned for the AD1985 CODEC driver.  I am 
continuing work on a patch to create separate AD1986/AD1986A CODEC 
driver code.

In this revised, combined patch I have included my "fix microphone and 
line_in selection logic" patch that should help users of the AD1985, 
along with many other multichannel CODECs.  I have also decided to 
provide an enhanced V_REFOUT control, rather than simply remove the 
faulty control, as I had done in my previous revision.

Again, any feedback regarding my work is welcome.

Randy Cushman


Randy Cushman wrote:
> (This message references ALSA bugtracking issue ID 2655.
> https://bugtrack.alsa-project.org/alsa-bug/view.php?id=2655)
>
> I am researching issues I am having with the audio chipsets onboard my
> ASUS A8S-X Motherboard, which has an AD1986A CODEC, using its AC'97
> interface.
>
> $ cat /proc/asound/cards
>  0 [SI7012 ]: ICH - SiS SI7012
>                       SiS SI7012 with AD1986 at 0x8000, irq 50
>
> The attached patch file removes the "V_REFOUT Enable" mixer control that
> recently was added to the driver for the AD1888 CODEC, and was inherited
> by the driver for the AD1985 CODEC.  The AD1986/AD1986A CODECs currently
> utilize the AD1985 driver.
>
> I am preparing additional patches that will provide improved support for
> these CODECs.  Please let me know if my work thus far is satisfactory.
>
> Randy Cushman
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/alsa-devel
>   


[-- Attachment #2: ac97_ad1985_2.patch --]
[-- Type: text/plain, Size: 6128 bytes --]

Summary: fix microphone and line_in selection logic

This patch fixes the Microphone and LINE_IN select logic for
surround codecs with shared jacks.  This issue appears to apply
to most, if not all AC'97 surround codecs.  The existing code
can never utilize the shared jacks for Microphone and LINE_IN
due to the reversed jack selection logic.  The patched code
correctly selects the shared jack for input if the "Channel Mode"
selector does not specify that the jack is to be used for output.

Specifically, in "2ch" mode the Center/LFE jack is used for
microphone input and the Surround jack is used for LINE_IN,
in "4ch" mode the Center/LFE jack is used for microphone input
and the Surround jack is used for output, and in "6ch" mode
both jacks are used for output.

Signed-off-by: Randy Cushman <rcushman_linux@earthlink.net>


Summary: replace malfunctioning mixer control for AD1985

This patch replacing the "V_REFOUT Enable" mixer switch control
with a listbox control for the AD1985 CODEC.

Previous patch "AD1888 mixer controls for DC mode" added
controls that were propogated to multiple codecs.  For the
AD1985 codec, the bits VREFH and VREFD function differently,
preventing the "V_REFOUT Enable" control from setting V_REFOUT
to Hi-Z.

Signed-off-by: Randy Cushman <rcushman_linux@earthlink.net>

--- ./a/alsa-kernel/pci/ac97/ac97_patch.c	2006-11-30 17:34:01.000000000 -0500
+++ ./b/alsa-kernel/pci/ac97/ac97_patch.c	2006-12-04 12:05:58.000000000 -0500
@@ -192,12 +192,12 @@
 
 static inline int is_shared_linein(struct snd_ac97 *ac97)
 {
-	return ! ac97->indep_surround && is_surround_on(ac97);
+	return ! ac97->indep_surround && ! is_surround_on(ac97);
 }
 
 static inline int is_shared_micin(struct snd_ac97 *ac97)
 {
-	return ! ac97->indep_surround && is_clfe_on(ac97);
+	return ! ac97->indep_surround && ! is_clfe_on(ac97);
 }
 
 
@@ -1615,8 +1615,10 @@
 #define AC97_AD198X_MBC_10	0x0001	/* +10dB */
 #define AC97_AD198X_MBC_30	0x0002	/* +30dB */
 #define AC97_AD198X_VREFD	0x0004	/* VREF high-Z */
-#define AC97_AD198X_VREFH	0x0008	/* 2.25V, 3.7V */
-#define AC97_AD198X_VREF_0	0x000c	/* 0V */
+#define AC97_AD198X_VREFH	0x0008	/* 0=2.25V, 1=3.7V */
+#define AC97_AD198X_VREF_0	0x000c	/* 0V (AD1985 only) */
+#define AC97_AD198X_VREF_MASK	(AC97_AD198X_VREFH | AC97_AD198X_VREFD)
+#define AC97_AD198X_VREF_OFFSET 2
 #define AC97_AD198X_SRU		0x0010	/* sample rate unlock */
 #define AC97_AD198X_LOSEL	0x0020	/* LINE_OUT amplifiers input select */
 #define AC97_AD198X_2MIC	0x0040	/* 2-channel mic select */
@@ -1952,8 +1954,75 @@
 	return 0;
 }
 
+static int snd_ac97_ad1985_vrefout_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
+{
+	static char *texts[4] = {"High-Z", "3.7 V", "2.25 V", "0 V"};
+
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+	uinfo->count = 1;
+	uinfo->value.enumerated.items = 4;
+	if (uinfo->value.enumerated.item > 3)
+		uinfo->value.enumerated.item = 3;
+	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
+	return 0;
+}
+
+static int snd_ac97_ad1985_vrefout_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+	static const int reg2ctrl[4] = {2, 0, 1, 3};
+	struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+	unsigned short val;
+	val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
+	      >> AC97_AD198X_VREF_OFFSET;
+	ucontrol->value.enumerated.item[0] = reg2ctrl[val];
+	return 0;
+}
+
+static int snd_ac97_ad1985_vrefout_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+	static const int ctrl2reg[4] = {1, 2, 0, 3};
+	struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+	unsigned short val;
+
+	if (ucontrol->value.enumerated.item[0] > 3
+	    || ucontrol->value.enumerated.item[0] < 0)
+		return -EINVAL;
+	val = ctrl2reg[ucontrol->value.enumerated.item[0]]
+	      << AC97_AD198X_VREF_OFFSET;
+	return snd_ac97_update_bits(ac97, AC97_AD_MISC,
+				    AC97_AD198X_VREF_MASK, val);
+}
+
 static const struct snd_kcontrol_new snd_ac97_ad1985_controls[] = {
-	AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0)
+	AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0),
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Exchange Front/Surround",
+		.info = snd_ac97_ad1888_lohpsel_info,
+		.get = snd_ac97_ad1888_lohpsel_get,
+		.put = snd_ac97_ad1888_lohpsel_put
+	},
+	AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1),
+	AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0),
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "Downmix",
+		.info = snd_ac97_ad1888_downmix_info,
+		.get = snd_ac97_ad1888_downmix_get,
+		.put = snd_ac97_ad1888_downmix_put
+	},
+	{
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+		.name = "V_REFOUT",
+		.info = snd_ac97_ad1985_vrefout_info,
+		.get = snd_ac97_ad1985_vrefout_get,
+		.put = snd_ac97_ad1985_vrefout_put
+	},
+	AC97_SURROUND_JACK_MODE_CTL,
+	AC97_CHANNEL_MODE_CTL,
+
+	AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0),
+	AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0),
 };
 
 static void ad1985_update_jacks(struct snd_ac97 *ac97)
@@ -1967,8 +2036,13 @@
 {
 	int err;
 
-	if ((err = patch_ad1980_specific(ac97)) < 0)
+	/* rename 0x04 as "Master" and 0x02 as "Master Surround" */
+	snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Master Surround Playback");
+	snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
+
+	if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
 		return err;
+
 	return patch_build_controls(ac97, snd_ac97_ad1985_controls, ARRAY_SIZE(snd_ac97_ad1985_controls));
 }
 
@@ -1989,12 +2063,11 @@
 	ac97->build_ops = &patch_ad1985_build_ops;
 	misc = snd_ac97_read(ac97, AC97_AD_MISC);
 	/* switch front/surround line-out/hp-out */
-	/* center/LFE, mic in 3.75V mode */
+	/* center/LFE */
 	/* AD-compatible mode */
 	/* Stereo mutes enabled */
 	/* in accordance with ADI driver: misc | 0x5c28 */
 	snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
-			     AC97_AD198X_VREFH |
 			     AC97_AD198X_LOSEL |
 			     AC97_AD198X_HPSEL |
 			     AC97_AD198X_CLDIS |

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

  reply	other threads:[~2006-12-04 21:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-01  3:02 Patch for AD1985 AC97 CODEC Randy Cushman
2006-12-04 21:56 ` Randy Cushman [this message]
2006-12-13  0:31   ` Randy Cushman
2006-12-19  9:43     ` Takashi Iwai
     [not found]       ` <45881891.5030101@earthlink.net>
2006-12-19 17:06         ` Patch for AC97 AD CODEC shared jacks Takashi Iwai
2006-12-19 17:37           ` Randy Cushman
2006-12-19 17:43             ` Takashi Iwai
2006-12-19 18:40       ` Patch for AD1985 AC97 CODEC Randy Cushman
2006-12-20 18:47         ` Takashi Iwai
2006-12-20  1:40       ` Randy Cushman
2006-12-21 16:17         ` Randy Cushman
2006-12-21 18:18           ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45749990.1080900@earthlink.net \
    --to=rcushman_linux@earthlink.net \
    --cc=Alsa-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.