Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Sasha Khapyorsky <sashak@smlink.com>
Cc: unixtricks@btinternet.com, alsa-devel@lists.sourceforge.net,
	Antonis Tsolomitis <atsol@aegean.gr>,
	Jacques Goldberg <Jacques.Goldberg@cern.ch>
Subject: Re: Re: ATI IXP Modem driver
Date: Thu, 29 Jul 2004 17:11:45 +0200	[thread overview]
Message-ID: <s5hk6wmq24u.wl@alsa2.suse.de> (raw)
In-Reply-To: <s5hbri014jy.wl@alsa2.suse.de>

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

At Wed, 28 Jul 2004 18:26:25 +0200,
I wrote:
> 
> At Sun, 25 Jul 2004 18:21:54 +0300,
> Sasha Khapyorsky wrote:
> > 
> > [1  <text/plain; US-ASCII (7bit)>]
> > Hello Takashi,
> > 
> > On Mon, 12 Jul 2004 18:57:30 +0200
> > Takashi Iwai <tiwai@suse.de> wrote:
> > 
> > > 
> > > The change is already on CVS.
> > 
> > Additional 'atiixp_modem' patch (I cannot upload it to bug#0000259 - it
> > is fixed already)
> > 
> > The problem was reported at discuss@linmodems.org (and looks like one
> > that was with intel8x0m in the past) - When modem driver probes codecs
> > for mixer it mutes all sound devices.
> > 
> > Solution is same as with 'intel8x0m' - to allocate mixer only for modem
> > codec(MC). The approach is that MC is always last one. This will work
> > with one and two codecs configurations. Not sure about three codecs (are
> > there such in practice?), but if 'not' it would be simply fixed by valid
> > 'codec_num' setup.
> 
> Well, this will be still a problem when the audio driver is loaded
> after the modem driver.  We'll need a way to avoid the double reset on
> codecs.
> 
> How about adding a new flag to ac97 struct to indicate the shared chip
> type?

Ok, I changed the codes on CVS as the following patch.
Can anyone try it out?


thanks,

Takashi

[-- Attachment #2: Type: text/plain, Size: 5397 bytes --]

Index: alsa-kernel/include/ac97_codec.h
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/include/ac97_codec.h,v
retrieving revision 1.47
diff -u -r1.47 ac97_codec.h
--- alsa-kernel/include/ac97_codec.h	14 Jul 2004 15:35:01 -0000	1.47
+++ alsa-kernel/include/ac97_codec.h	29 Jul 2004 14:38:53 -0000
@@ -364,6 +364,14 @@
 #define AC97_RATES_MIC_ADC	4
 #define AC97_RATES_SPDIF	5
 
+/* shared controllers */
+enum {
+	AC97_SHARED_TYPE_NONE,
+	AC97_SHARED_TYPE_ICH,
+	AC97_SHARED_TYPE_ATIIXP,
+	AC97_SHARED_TYPES
+};
+
 /*
  *
  */
@@ -430,6 +438,7 @@
 	unsigned short used_slots[2][4]; /* actually used PCM slots */
 	unsigned short pcms_count; /* count of PCMs */
 	struct ac97_pcm *pcms;
+	unsigned int shared_type;	/* type of shared controller betwen audio and modem */
 	ac97_t *codec[4];
 	snd_info_entry_t *proc;
 };
Index: alsa-kernel/pci/atiixp.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/atiixp.c,v
retrieving revision 1.20
diff -u -r1.20 atiixp.c
--- alsa-kernel/pci/atiixp.c	15 Jul 2004 14:55:29 -0000	1.20
+++ alsa-kernel/pci/atiixp.c	29 Jul 2004 14:37:30 -0000
@@ -1361,6 +1361,7 @@
 	if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0)
 		return err;
 	pbus->clock = clock;
+	pbus->shared_type = AC97_SHARED_TYPE_ATIIXP;	/* shared with modem driver */
 	chip->ac97_bus = pbus;
 
 	codec_count = 0;
Index: alsa-kernel/pci/atiixp_modem.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/atiixp_modem.c,v
retrieving revision 1.4
diff -u -r1.4 atiixp_modem.c
--- alsa-kernel/pci/atiixp_modem.c	15 Jul 2004 14:55:29 -0000	1.4
+++ alsa-kernel/pci/atiixp_modem.c	29 Jul 2004 14:37:45 -0000
@@ -1082,6 +1082,7 @@
 	if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0)
 		return err;
 	pbus->clock = clock;
+	pbus->shared_type = AC97_SHARED_TYPE_ATIIXP;	/* shared with audio driver */
 	chip->ac97_bus = pbus;
 
 	codec_count = 0;
Index: alsa-kernel/pci/intel8x0.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/intel8x0.c,v
retrieving revision 1.150
diff -u -r1.150 intel8x0.c
--- alsa-kernel/pci/intel8x0.c	29 Jul 2004 12:17:45 -0000	1.150
+++ alsa-kernel/pci/intel8x0.c	29 Jul 2004 14:38:03 -0000
@@ -1910,6 +1910,7 @@
 	if ((err = snd_ac97_bus(chip->card, 0, ops, chip, &pbus)) < 0)
 		goto __err;
 	pbus->private_free = snd_intel8x0_mixer_free_ac97_bus;
+	pbus->shared_type = AC97_SHARED_TYPE_ICH;	/* shared with modem driver */
 	if (ac97_clock >= 8000 && ac97_clock <= 48000)
 		pbus->clock = ac97_clock;
 	/* FIXME: my test board doesn't work well with VRA... */
Index: alsa-kernel/pci/intel8x0m.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/intel8x0m.c,v
retrieving revision 1.13
diff -u -r1.13 intel8x0m.c
--- alsa-kernel/pci/intel8x0m.c	15 Jul 2004 13:16:45 -0000	1.13
+++ alsa-kernel/pci/intel8x0m.c	29 Jul 2004 14:40:10 -0000
@@ -897,6 +897,7 @@
 	if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0)
 		goto __err;
 	pbus->private_free = snd_intel8x0_mixer_free_ac97_bus;
+	pbus->shared_type = AC97_SHARED_TYPE_ICH;	/* shared with audio driver */
 	if (ac97_clock >= 8000 && ac97_clock <= 48000)
 		pbus->clock = ac97_clock;
 	chip->ac97_bus = pbus;
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.132
diff -u -r1.132 ac97_codec.c
--- alsa-kernel/pci/ac97/ac97_codec.c	5 Jul 2004 15:23:46 -0000	1.132
+++ alsa-kernel/pci/ac97/ac97_codec.c	29 Jul 2004 14:39:38 -0000
@@ -212,6 +212,13 @@
 };
 
 /*
+ * Shared AC97 controllers (ICH, ATIIXP...)
+ */
+static DECLARE_MUTEX(shared_codec_mutex);
+static ac97_t *shared_codec[AC97_SHARED_TYPES][4];
+
+
+/*
  *  I/O routines
  */
 
@@ -1056,8 +1063,14 @@
 {
 	if (ac97) {
 		snd_ac97_proc_done(ac97);
-		if (ac97->bus)
+		if (ac97->bus) {
 			ac97->bus->codec[ac97->num] = NULL;
+			if (ac97->bus->shared_type) {
+				down(&shared_codec_mutex);
+				shared_codec[ac97->bus->shared_type-1][ac97->num] = NULL;
+				up(&shared_codec_mutex);
+			}
+		}
 		if (ac97->private_free)
 			ac97->private_free(ac97);
 		kfree(ac97);
@@ -1831,6 +1844,22 @@
 	*rac97 = NULL;
 	snd_assert(bus != NULL && template != NULL, return -EINVAL);
 	snd_assert(template->num < 4 && bus->codec[template->num] == NULL, return -EINVAL);
+
+	snd_assert(bus->shared_type <= AC97_SHARED_TYPES, return -EINVAL);
+	if (bus->shared_type) {
+		/* already shared? */
+		down(&shared_codec_mutex);
+		ac97 = shared_codec[bus->shared_type-1][template->num];
+		if (ac97) {
+			if ((ac97_is_audio(ac97) && (template->scaps & AC97_SCAP_SKIP_AUDIO)) ||
+			    (ac97_is_modem(ac97) && (template->scaps & AC97_SCAP_SKIP_MODEM))) {
+				up(&shared_codec_mutex);
+				return -EACCES; /* skip this */
+			}
+		}
+		up(&shared_codec_mutex);
+	}
+
 	card = bus->card;
 	ac97 = kcalloc(1, sizeof(*ac97), GFP_KERNEL);
 	if (ac97 == NULL)
@@ -2055,6 +2084,13 @@
 		return err;
 	}
 	*rac97 = ac97;
+
+	if (bus->shared_type) {
+		down(&shared_codec_mutex);
+		shared_codec[bus->shared_type-1][ac97->num] = ac97;
+		up(&shared_codec_mutex);
+	}
+
 	return 0;
 }
 

  reply	other threads:[~2004-07-29 15:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1083465072.1639.8.camel@server.gowanlea.net>
     [not found] ` <20040503163657.668357a9@sashak.lan>
     [not found]   ` <1087962001.4844.0.camel@server.gowanlea.net>
     [not found]     ` <20040711191833.462a0b4b@sashak.lan>
     [not found]       ` <s5hr7rhcztt.wl@alsa2.suse.de>
     [not found]         ` <20040712162839.2c58e1c3@sashak.lan>
     [not found]           ` <s5hd631cq5v.wl@alsa2.suse.de>
2004-07-12 16:54             ` ATI IXP Modem driver Sasha Khapyorsky
2004-07-12 16:57               ` Takashi Iwai
2004-07-25 15:21                 ` Sasha Khapyorsky
2004-07-28 16:26                   ` Takashi Iwai
2004-07-29 15:11                     ` Takashi Iwai [this message]
2004-07-29 16:27                       ` Sasha Khapyorsky
2004-07-29 17:03                         ` Takashi Iwai
2004-07-29 15:37                     ` Sasha Khapyorsky
2004-07-29 15:43                       ` Takashi Iwai
2004-07-29 16:15                         ` Sasha Khapyorsky

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=s5hk6wmq24u.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=Jacques.Goldberg@cern.ch \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=atsol@aegean.gr \
    --cc=sashak@smlink.com \
    --cc=unixtricks@btinternet.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox