From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: ac3 now works on VIA8233 (with a tiny patch) Date: Tue, 28 Jan 2003 12:15:52 +0100 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <20030127182444.GA1974@netppl.fi> <20030128103000.GA5022@netppl.fi> Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: multipart/mixed; boundary="Multipart_Tue_Jan_28_12:15:52_2003-1" Return-path: In-Reply-To: <20030128103000.GA5022@netppl.fi> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Pekka Pietikainen Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org --Multipart_Tue_Jan_28_12:15:52_2003-1 Content-Type: text/plain; charset=US-ASCII At Tue, 28 Jan 2003 12:30:00 +0200, Pekka Pietikainen wrote: > > On Tue, Jan 28, 2003 at 10:55:42AM +0100, Takashi Iwai wrote: > > Hi it's me again, > > > > just took at your earlier posts, i found the reason. > > instead of changing the device, AC97-SPSA must be changed to 3. > > > > please try the attached patch. > I tried the patch and it seems to work fine as long as alsamixer > has AC97-SPSA set to 3 before using AC3. If it's at anything > else, the output is just some horrible noise. thanks for testing. ok, this must be fixed... could you try the one below? > The mixer setting does > change to 3 when the application starts (and goes back to 0 when it stops), > but apparently that happens too late. When the application > is running, the mixer control has no effect at all. Feature? > Bug? Application bug? (I tried mplayer and xine and both did the same) > Oh well, at least it's usable now :) it's a feature. the control is locked during the pcm is opened. Takashi --Multipart_Tue_Jan_28_12:15:52_2003-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="via-spdif.dif" Content-Transfer-Encoding: 7bit Index: alsa-kernel/pci/ac97/ac97_codec.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/ac97/ac97_codec.c,v retrieving revision 1.51 diff -u -r1.51 ac97_codec.c --- alsa-kernel/pci/ac97/ac97_codec.c 27 Jan 2003 10:36:08 -0000 1.51 +++ alsa-kernel/pci/ac97/ac97_codec.c 28 Jan 2003 11:14:25 -0000 @@ -849,6 +849,34 @@ return change; } +static int snd_ac97_put_spsa(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +{ + ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + int reg = kcontrol->private_value & 0xff; + int shift = (kcontrol->private_value >> 8) & 0xff; + int mask = (kcontrol->private_value >> 16) & 0xff; + // int invert = (kcontrol->private_value >> 24) & 0xff; + unsigned short value, old, new; + + value = (ucontrol->value.integer.value[0] & mask); + + mask <<= shift; + value <<= shift; + spin_lock(&ac97->reg_lock); + old = ac97->regs[reg]; + new = (old & ~mask) | value; + spin_unlock(&ac97->reg_lock); + + if (old != new) { + int change; + snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); + change = snd_ac97_update_bits(ac97, reg, mask, value); + snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); + return change; + } + return 0; +} + static const snd_kcontrol_new_t snd_ac97_controls_spdif[5] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, @@ -873,7 +901,15 @@ }, AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH),AC97_EXTENDED_STATUS, 2, 1, 0), - AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA",AC97_EXTENDED_STATUS, 4, 3, 0) + // AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA",AC97_EXTENDED_STATUS, 4, 3, 0) + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA", + .info = snd_ac97_info_single, + .get = snd_ac97_get_single, + .put = snd_ac97_put_spsa, + .private_value = AC97_EXTENDED_STATUS | (4 << 8) | (3 << 16) | (0 << 24), + }, }; static const snd_kcontrol_new_t snd_ac97_cirrus_controls_spdif[2] = { @@ -995,9 +1031,6 @@ /* 8: reserved */ AC97_SINGLE("Line-In As Surround", AC97_ALC650_MULTICH, 9, 1, 0), AC97_SINGLE("Mic As Center/LFE", AC97_ALC650_MULTICH, 10, 1, 0), - AC97_SINGLE("IEC958 Capture Switch", AC97_ALC650_MULTICH, 11, 1, 0), - AC97_SINGLE("Analog to IEC958 Output", AC97_ALC650_MULTICH, 12, 1, 0), - AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0), #if 0 /* always set in patch_alc650 */ AC97_SINGLE("IEC958 Input Clock Enable", AC97_ALC650_CLOCK, 0, 1, 0), AC97_SINGLE("IEC958 Input Pin Enable", AC97_ALC650_CLOCK, 1, 1, 0), @@ -1008,6 +1041,12 @@ #endif }; +static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc650[] = { + AC97_SINGLE("IEC958 Capture Switch", AC97_ALC650_MULTICH, 11, 1, 0), + AC97_SINGLE("Analog to IEC958 Output", AC97_ALC650_MULTICH, 12, 1, 0), + AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0), +}; + /* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ /* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */ @@ -1658,6 +1697,11 @@ for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_alc650); idx++) if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_alc650[idx], ac97))) < 0) return err; + if (ac97->ext_id & AC97_EI_SPDIF) { + for (idx = 0; idx < ARRAY_SIZE(snd_ac97_spdif_controls_alc650); idx++) + if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_spdif_controls_alc650[idx], ac97))) < 0) + return err; + } break; case AC97_ID_VT1616: if (snd_ac97_try_bit(ac97, 0x5a, 9)) Index: alsa-kernel/pci/ac97/ac97_patch.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/ac97/ac97_patch.c,v retrieving revision 1.7 diff -u -r1.7 ac97_patch.c --- alsa-kernel/pci/ac97/ac97_patch.c 24 Jan 2003 11:09:17 -0000 1.7 +++ alsa-kernel/pci/ac97/ac97_patch.c 28 Jan 2003 10:46:32 -0000 @@ -355,13 +355,19 @@ { unsigned short val; - /* enable spdif in */ - snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, - snd_ac97_read(ac97, AC97_ALC650_CLOCK) | 0x03); + /* check spdif */ + val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS); + if (val & AC97_EA_SPCV) { + /* enable spdif in */ + snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, + snd_ac97_read(ac97, AC97_ALC650_CLOCK) | 0x03); + } else + ac97->ext_id &= ~AC97_EI_SPDIF; /* disable extended-id */ + val = snd_ac97_read(ac97, AC97_ALC650_MULTICH); val &= ~0xc000; /* slot: 3,4,7,8,6,9 */ - snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, - val | 0x03); + snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, val | 0x03); + /* full DAC volume */ snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808); snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808); --Multipart_Tue_Jan_28_12:15:52_2003-1-- ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com