From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Re: ATI IXP Modem driver Date: Thu, 29 Jul 2004 17:11:45 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <1083465072.1639.8.camel@server.gowanlea.net> <20040503163657.668357a9@sashak.lan> <1087962001.4844.0.camel@server.gowanlea.net> <20040711191833.462a0b4b@sashak.lan> <20040712162839.2c58e1c3@sashak.lan> <20040712195450.04494434@sashak.lan> <20040725182154.3317e5d8@sashak.lan> Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: multipart/mixed; boundary="Multipart_Thu_Jul_29_17:11:45_2004-1" Return-path: In-Reply-To: Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Sasha Khapyorsky Cc: unixtricks@btinternet.com, alsa-devel@lists.sourceforge.net, Antonis Tsolomitis , Jacques Goldberg List-Id: alsa-devel@alsa-project.org --Multipart_Thu_Jul_29_17:11:45_2004-1 Content-Type: text/plain; charset=US-ASCII At Wed, 28 Jul 2004 18:26:25 +0200, I wrote: > > At Sun, 25 Jul 2004 18:21:54 +0300, > Sasha Khapyorsky wrote: > > > > [1 ] > > Hello Takashi, > > > > On Mon, 12 Jul 2004 18:57:30 +0200 > > Takashi Iwai 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 --Multipart_Thu_Jul_29_17:11:45_2004-1 Content-Type: text/plain; charset=US-ASCII 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; } --Multipart_Thu_Jul_29_17:11:45_2004-1-- ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click