2004-01-07 21:29:22

by Santiago Garcia Mantinan

[permalink] [raw]
Subject: ALSA in 2.6 failing to find the OPL chip of the sb cards

Hi!

I have a SB16PNP on which alsa under kernel 2.6 fails to detect the OPL
chip, I have tried the 0.9.7 version wich comes with the kernel (up to
version 2.6.1-rc2) and now even alsa 1.0.0rc2 compiled for the 2.6.1-rc2
kernel, on both I get the same result:

sb16: no OPL device at 0x388-0x38a

this is the full output on version 1.0.0rc2:

Starting ALSA (version 1.0.0rc2):pnp: Device 00:01.00 activated.
ALSA /usr/src/modules/alsa-driver/alsa-kernel/isa/sb/sb16.c:489: sb16: no
OPL device at 0x388-0x38a
sb16.

Alsa version 0.9.8 works perfectly under 2.4.X.

Don't hesitate to contact me for any other info that may be needed to track
this.

Regards...
--
Manty/BestiaTester -> http://manty.net


2004-01-08 17:21:15

by Takashi Iwai

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

At Wed, 7 Jan 2004 22:29:16 +0100,
Santiago Garcia Mantinan wrote:
>
> Hi!
>
> I have a SB16PNP on which alsa under kernel 2.6 fails to detect the OPL
> chip, I have tried the 0.9.7 version wich comes with the kernel (up to
> version 2.6.1-rc2) and now even alsa 1.0.0rc2 compiled for the 2.6.1-rc2
> kernel, on both I get the same result:
>
> sb16: no OPL device at 0x388-0x38a
>
> this is the full output on version 1.0.0rc2:
>
> Starting ALSA (version 1.0.0rc2):pnp: Device 00:01.00 activated.
> ALSA /usr/src/modules/alsa-driver/alsa-kernel/isa/sb/sb16.c:489: sb16: no
> OPL device at 0x388-0x38a
> sb16.

compile with CONFIG_SND_DEBUG and CONFIG_SND_VERBOSE_PRINTK.
if it's in snd_opl3_detect(), "OPL2/3 chip not detected at ..."
message should appear (together with other message in
snd_opl3_detect()).
if not, it must be in snd_device_new(), and quite mysterious...


--
Takashi Iwai <[email protected]> ALSA Developer - http://www.alsa-project.org

2004-01-08 22:42:44

by Santiago Garcia Mantinan

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

> compile with CONFIG_SND_DEBUG and CONFIG_SND_VERBOSE_PRINTK.
> if it's in snd_opl3_detect(), "OPL2/3 chip not detected at ..."
> message should appear (together with other message in
> snd_opl3_detect()).
> if not, it must be in snd_device_new(), and quite mysterious...

I have compiled 2.6.1rc3 this way, here is the result when loading the
kernel's alsa modules for sb16 (0.9.7):

pnp: Device 00:01.00 activated.
ALSA sound/isa/sb/sb16.c:313: pnp SB16: port=0x220, mpu port=0x330, fm port=0x388
ALSA sound/isa/sb/sb16.c:315: pnp SB16: dma1=1, dma2=5, irq=10
ALSA sound/isa/sb/sb_common.c:133: SB [0x220]: DSP chip found, version = 4.13
ALSA sound/drivers/opl3/opl3_lib.c:133: OPL3: stat1 = 0xff
ALSA sound/drivers/opl3/opl3_lib.c:444: OPL2/3 chip not detected at 0x388/0x38a
ALSA sound/isa/sb/sb16.c:484: sb16: no OPL device at 0x388-0x38a

Hope this helps a bit.

Don't hesitate to ask for anything else you may need.

Regards...
--
Manty/BestiaTester -> http://manty.net

2004-01-09 17:18:42

by Santiago Garcia Mantinan

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

> compile with CONFIG_SND_DEBUG and CONFIG_SND_VERBOSE_PRINTK.
> if it's in snd_opl3_detect(), "OPL2/3 chip not detected at ..."
> message should appear (together with other message in
> snd_opl3_detect()).

I have tested now with 2.6.1 with vanilla driver (0.9.7) and also with 1.0.1
using the patch that Jaroslav posted yesterday available at
ftp://ftp.alsa-project.org/pub/kernel-patches/alsa-bk-2004-01-08.patch.gz
and got the same result as before, these are the messages for 1.0.1:

pnp: Device 00:01.00 activated.
ALSA sound/isa/sb/sb16.c:313: pnp SB16: port=0x220, mpu port=0x330, fm port=0x388
ALSA sound/isa/sb/sb16.c:315: pnp SB16: dma1=1, dma2=5, irq=10
ALSA sound/isa/sb/sb_common.c:133: SB [0x220]: DSP chip found, version = 4.13
ALSA sound/drivers/opl3/opl3_lib.c:133: OPL3: stat1 = 0xff
ALSA sound/drivers/opl3/opl3_lib.c:444: OPL2/3 chip not detected at 0x388/0x38a
ALSA sound/isa/sb/sb16.c:489: sb16: no OPL device at 0x388-0x38a

Hope it helps.

Regards...
--
Manty/BestiaTester -> http://manty.net

2004-01-09 17:37:55

by Takashi Iwai

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

At Fri, 9 Jan 2004 18:17:15 +0100,
Santiago Garcia Mantinan wrote:
>
> > compile with CONFIG_SND_DEBUG and CONFIG_SND_VERBOSE_PRINTK.
> > if it's in snd_opl3_detect(), "OPL2/3 chip not detected at ..."
> > message should appear (together with other message in
> > snd_opl3_detect()).
>
> I have tested now with 2.6.1 with vanilla driver (0.9.7) and also with 1.0.1
> using the patch that Jaroslav posted yesterday available at
> ftp://ftp.alsa-project.org/pub/kernel-patches/alsa-bk-2004-01-08.patch.gz
> and got the same result as before, these are the messages for 1.0.1:
>
> pnp: Device 00:01.00 activated.
> ALSA sound/isa/sb/sb16.c:313: pnp SB16: port=0x220, mpu port=0x330, fm port=0x388
> ALSA sound/isa/sb/sb16.c:315: pnp SB16: dma1=1, dma2=5, irq=10
> ALSA sound/isa/sb/sb_common.c:133: SB [0x220]: DSP chip found, version = 4.13
> ALSA sound/drivers/opl3/opl3_lib.c:133: OPL3: stat1 = 0xff
> ALSA sound/drivers/opl3/opl3_lib.c:444: OPL2/3 chip not detected at 0x388/0x38a
> ALSA sound/isa/sb/sb16.c:489: sb16: no OPL device at 0x388-0x38a

then it fails in the reset sequence of opl chip, namely,
what happens if you replace the line 441
opl3->command = &snd_opl2_command;
with
opl3->command = &snd_opl3_command;
?

--
Takashi Iwai <[email protected]> ALSA Developer - http://www.alsa-project.org


2004-01-09 20:14:28

by Santiago Garcia Mantinan

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

> then it fails in the reset sequence of opl chip, namely,
> what happens if you replace the line 441
> opl3->command = &snd_opl2_command;
> with
> opl3->command = &snd_opl3_command;

Looks exactly the same thing to me:

pnp: Device 00:01.00 activated.
ALSA sound/isa/sb/sb16.c:313: pnp SB16: port=0x220, mpu port=0x330, fm port=0x388
ALSA sound/isa/sb/sb16.c:315: pnp SB16: dma1=1, dma2=5, irq=10
ALSA sound/isa/sb/sb_common.c:133: SB [0x220]: DSP chip found, version = 4.13
ALSA sound/drivers/opl3/opl3_lib.c:133: OPL3: stat1 = 0xff
ALSA sound/drivers/opl3/opl3_lib.c:444: OPL2/3 chip not detected at 0x388/0x38a
ALSA sound/isa/sb/sb16.c:484: sb16: no OPL device at 0x388-0x38a

I think I have already said that in 2.4 it works, and I have tested both
alsa in the kernel plus alsa sources downloaded from alsa-project, this last
one works in 2.4 but doesn't work in 2.6.

Regards...
--
Manty/BestiaTester -> http://manty.net

2004-01-10 07:28:20

by Rene Herman

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

Santiago Garcia Mantinan wrote:

>>then it fails in the reset sequence of opl chip, namely,
>>what happens if you replace the line 441
>> opl3->command = &snd_opl2_command;
>>with
>> opl3->command = &snd_opl3_command;
>
>
> Looks exactly the same thing to me:
>
> pnp: Device 00:01.00 activated.
> ALSA sound/isa/sb/sb16.c:313: pnp SB16: port=0x220, mpu port=0x330, fm port=0x388
> ALSA sound/isa/sb/sb16.c:315: pnp SB16: dma1=1, dma2=5, irq=10
> ALSA sound/isa/sb/sb_common.c:133: SB [0x220]: DSP chip found, version = 4.13
> ALSA sound/drivers/opl3/opl3_lib.c:133: OPL3: stat1 = 0xff
> ALSA sound/drivers/opl3/opl3_lib.c:444: OPL2/3 chip not detected at 0x388/0x38a
> ALSA sound/isa/sb/sb16.c:484: sb16: no OPL device at 0x388-0x38a
>
> I think I have already said that in 2.4 it works, and I have tested both
> alsa in the kernel plus alsa sources downloaded from alsa-project, this last
> one works in 2.4 but doesn't work in 2.6.

I'm seeing the same behaviour with a Sound Blaster AWE64 Gold. It seems
it's not an ALSA problem though, but ISA-PnP. Enabling the card from
userspace with the old isapnp tool makes the OPL chip appear:

root@7ixe4:~# dmesg -n8
root@7ixe4:~# modprobe snd-sbawe
pnp: the driver 'sb16' has been registered
pnp: match found with the PnP device '01:01.00' and the driver 'sb16'
pnp: match found with the PnP device '01:01.02' and the driver 'sb16'
pnp: Device 01:01.00 activated.
pnp: Device 01:01.02 activated.
ALSA sound/isa/sb/sb16.c:484: sbawe: no OPL device at 0x388-0x38a
root@7ixe4:~# modprobe -r snd-sbawe
pnp: Device 01:01.00 disabled.
pnp: Device 01:01.02 disabled.
pnp: the driver 'sb16' has been unregistered
root@7ixe4:~# isapnp awe64g
Board 1 has Identity 43 0f f1 94 5c 9e 00 8c 0e: CTL009e Serial No
267490396 [checksum 43]
Board 2 has Identity 2c 00 0f e4 18 02 00 94 16: ETT0002 Serial No
1041432 [checksum 2c]
root@7ixe4:~# modprobe snd-sbawe
pnp: the driver 'sb16' has been registered
pnp: match found with the PnP device '01:01.00' and the driver 'sb16'
pnp: match found with the PnP device '01:01.02' and the driver 'sb16'
pnp: Device 01:01.00 activated.
pnp: Device 01:01.02 activated.
root@7ixe4:~#

("awe64g" is just "pnpdump >awe64g", with preffered config uncommented)

That is, the driver doesn't complain anymore. Still didn't see the OPL
appear in /proc/ioports though (loading with fm_port=0x388 doesn't
change that). Haven't investigated further yet, will do.

Rene.


2004-01-11 05:37:15

by Rene Herman

[permalink] [raw]
Subject: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

--- linux-2.6.1/drivers/pnp/manager.c.orig 2004-01-11 05:32:34.000000000 +0100
+++ linux-2.6.1/drivers/pnp/manager.c 2004-01-11 05:15:36.000000000 +0100
@@ -223,25 +223,25 @@
table->irq_resource[idx].name = NULL;
table->irq_resource[idx].start = -1;
table->irq_resource[idx].end = -1;
- table->irq_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->irq_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET | IORESOURCE_IRQ;
}
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
table->dma_resource[idx].name = NULL;
table->dma_resource[idx].start = -1;
table->dma_resource[idx].end = -1;
- table->dma_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->dma_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET | IORESOURCE_DMA;
}
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
table->port_resource[idx].name = NULL;
table->port_resource[idx].start = 0;
table->port_resource[idx].end = 0;
- table->port_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->port_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET | IORESOURCE_IO;
}
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
table->mem_resource[idx].name = NULL;
table->mem_resource[idx].start = 0;
table->mem_resource[idx].end = 0;
- table->mem_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->mem_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET | IORESOURCE_MEM;
}
}


Attachments:
linux-2.6.1_pnp_resource.diff (1.42 kB)

2004-01-12 15:32:03

by Takashi Iwai

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

--- linux/sound/isa/sb/sb16.c 30 Oct 2003 14:19:30 -0000 1.31
+++ linux/sound/isa/sb/sb16.c 12 Jan 2004 15:30:04 -0000
@@ -483,7 +483,7 @@
if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
OPL3_HW_OPL3,
- fm_port[dev] == port[dev] || fm_port[dev] == 0x388,
+ acard->fm_res != NULL,
&opl3) < 0) {
snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",
fm_port[dev], fm_port[dev] + 2);

2004-01-12 15:35:23

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

At Sun, 11 Jan 2004 06:33:36 +0100,
Rene Herman wrote:
>
> [1 <text/plain; us-ascii (7bit)>]
> Rene Herman wrote:
>
> NOTE: I seem unable to contact Adam Belay; his ISP is not accepting mail
> from mine. Takashi, if you agree attached patch is a correct fix, could
> you relay it to Adam?

i forwarded it.

> It also isn't actually an OPL3 issue, but MPU401. Trouble is that sb16.c
> doesn't set mpu_port to SNDRV_DEFAULT_PORT, but hardcodes the values for
> the first two cards as 0x330 and 0x300 (Takashi: why is that, by the
> way? At least for ISA-PnP cards SNDRV_DEFAULT_PORT would seem better?).

yes, SNDRV_DEFAULT_PORT is better. the fixed values are provided for
the legacy cards without pnp. i'll fix it.


thanks,

Takashi

2004-01-12 20:55:10

by Rene Herman

[permalink] [raw]
Subject: Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

Takashi Iwai wrote:

[ OPl3 not in /proc/ioports for SB16/AWE ]

> it's a bug. the attached patch should fix it.

It does:

0388-0389 : OPL2/3 (left)
038a-038b : OPL2/3 (right)

With both patches applied, sb16 is fine again.

Rene.

2004-01-12 21:16:44

by Santiago Garcia Mantinan

[permalink] [raw]
Subject: Re: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

> The attached patch works for me:

Yes, your patch made my sb16pnp fully work again.

Thanks!

Regards...
--
Manty/BestiaTester -> http://manty.net

2004-01-14 04:43:45

by Adam Belay

[permalink] [raw]
Subject: Re: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

On Mon, Jan 12, 2004 at 04:35:13PM +0100, Takashi Iwai wrote:
> At Sun, 11 Jan 2004 06:33:36 +0100,
> Rene Herman wrote:
> >
> > [1 <text/plain; us-ascii (7bit)>]
> > Rene Herman wrote:
> >
> > NOTE: I seem unable to contact Adam Belay; his ISP is not accepting mail
> > from mine. Takashi, if you agree attached patch is a correct fix, could
> > you relay it to Adam?
>
> i forwarded it.

I agree with the overall strategy of the patch, but, during testing, I was able
to uncover a few bugs introduced by it. I'm reworking how pnp handles flags
and should have an updated patch out soon.

Thanks,
Adam

2004-01-15 00:20:55

by Adam Belay

[permalink] [raw]
Subject: Re: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

On Tue, Jan 13, 2004 at 11:29:40PM +0000, Adam Belay wrote:
> On Mon, Jan 12, 2004 at 04:35:13PM +0100, Takashi Iwai wrote:
> > At Sun, 11 Jan 2004 06:33:36 +0100,
> > Rene Herman wrote:
> > >
> > > [1 <text/plain; us-ascii (7bit)>]
> > > Rene Herman wrote:
> > >
> > > NOTE: I seem unable to contact Adam Belay; his ISP is not accepting mail
> > > from mine. Takashi, if you agree attached patch is a correct fix, could
> > > you relay it to Adam?
> >
> > i forwarded it.
>
> I agree with the overall strategy of the patch, but, during testing, I was able
> to uncover a few bugs introduced by it. I'm reworking how pnp handles flags
> and should have an updated patch out soon.


Here's the patch. Any testing would be appreciated.

Thanks,
Adam


diff -urN a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
--- a/drivers/pnp/isapnp/core.c 2003-12-31 04:47:32.000000000 +0000
+++ b/drivers/pnp/isapnp/core.c 2004-01-14 18:44:20.000000000 +0000
@@ -1039,17 +1039,17 @@

isapnp_cfg_begin(dev->card->number, dev->number);
dev->active = 1;
- for (tmp = 0; tmp < PNP_MAX_PORT && res->port_resource[tmp].flags & IORESOURCE_IO; tmp++)
+ for (tmp = 0; tmp < PNP_MAX_PORT && !(res->port_resource[tmp].flags & IORESOURCE_UNSET); tmp++)
isapnp_write_word(ISAPNP_CFG_PORT+(tmp<<1), res->port_resource[tmp].start);
- for (tmp = 0; tmp < PNP_MAX_IRQ && res->irq_resource[tmp].flags & IORESOURCE_IRQ; tmp++) {
+ for (tmp = 0; tmp < PNP_MAX_IRQ && !(res->irq_resource[tmp].flags & IORESOURCE_UNSET); tmp++) {
int irq = res->irq_resource[tmp].start;
if (irq == 2)
irq = 9;
isapnp_write_byte(ISAPNP_CFG_IRQ+(tmp<<1), irq);
}
- for (tmp = 0; tmp < PNP_MAX_DMA && res->dma_resource[tmp].flags & IORESOURCE_DMA; tmp++)
+ for (tmp = 0; tmp < PNP_MAX_DMA && !(res->dma_resource[tmp].flags & IORESOURCE_UNSET); tmp++)
isapnp_write_byte(ISAPNP_CFG_DMA+tmp, res->dma_resource[tmp].start);
- for (tmp = 0; tmp < PNP_MAX_MEM && res->mem_resource[tmp].flags & IORESOURCE_MEM; tmp++)
+ for (tmp = 0; tmp < PNP_MAX_MEM && !(res->mem_resource[tmp].flags & IORESOURCE_UNSET); tmp++)
isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<2), (res->mem_resource[tmp].start >> 8) & 0xffff);
/* FIXME: We aren't handling 32bit mems properly here */
isapnp_activate(dev->number);
diff -urN a/drivers/pnp/manager.c b/drivers/pnp/manager.c
--- a/drivers/pnp/manager.c 2003-12-31 04:48:36.000000000 +0000
+++ b/drivers/pnp/manager.c 2004-01-13 21:54:25.000000000 +0000
@@ -223,25 +223,25 @@
table->irq_resource[idx].name = NULL;
table->irq_resource[idx].start = -1;
table->irq_resource[idx].end = -1;
- table->irq_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->irq_resource[idx].flags = IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
table->dma_resource[idx].name = NULL;
table->dma_resource[idx].start = -1;
table->dma_resource[idx].end = -1;
- table->dma_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->dma_resource[idx].flags = IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
table->port_resource[idx].name = NULL;
table->port_resource[idx].start = 0;
table->port_resource[idx].end = 0;
- table->port_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->port_resource[idx].flags = IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
table->mem_resource[idx].name = NULL;
table->mem_resource[idx].start = 0;
table->mem_resource[idx].end = 0;
- table->mem_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ table->mem_resource[idx].flags = IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
}

@@ -258,28 +258,28 @@
continue;
res->irq_resource[idx].start = -1;
res->irq_resource[idx].end = -1;
- res->irq_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ res->irq_resource[idx].flags = IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
for (idx = 0; idx < PNP_MAX_DMA; idx++) {
if (!(res->dma_resource[idx].flags & IORESOURCE_AUTO))
continue;
res->dma_resource[idx].start = -1;
res->dma_resource[idx].end = -1;
- res->dma_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ res->dma_resource[idx].flags = IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
for (idx = 0; idx < PNP_MAX_PORT; idx++) {
if (!(res->port_resource[idx].flags & IORESOURCE_AUTO))
continue;
res->port_resource[idx].start = 0;
res->port_resource[idx].end = 0;
- res->port_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ res->port_resource[idx].flags = IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
for (idx = 0; idx < PNP_MAX_MEM; idx++) {
if (!(res->mem_resource[idx].flags & IORESOURCE_AUTO))
continue;
res->mem_resource[idx].start = 0;
res->mem_resource[idx].end = 0;
- res->mem_resource[idx].flags = IORESOURCE_AUTO | IORESOURCE_UNSET;
+ res->mem_resource[idx].flags = IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET;
}
}

@@ -550,7 +550,7 @@
{
if (resource == NULL)
return;
- resource->flags &= ~IORESOURCE_AUTO;
+ resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET);
resource->start = start;
resource->end = start + size - 1;
}
diff -urN a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
--- a/drivers/pnp/pnpbios/core.c 2003-12-31 04:46:24.000000000 +0000
+++ b/drivers/pnp/pnpbios/core.c 2004-01-02 18:08:02.000000000 +0000
@@ -251,7 +251,7 @@
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -1;
- if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node))
+ if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node))
return -ENODEV;
if(pnpbios_write_resources_to_node(res, node)<0) {
kfree(node);
diff -urN a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
--- a/drivers/pnp/pnpbios/rsparser.c 2003-12-31 04:47:04.000000000 +0000
+++ b/drivers/pnp/pnpbios/rsparser.c 2004-01-14 18:40:12.000000000 +0000
@@ -49,7 +49,7 @@
pnpbios_parse_allocated_irqresource(struct pnp_resource_table * res, int irq)
{
int i = 0;
- while ((res->irq_resource[i].flags & IORESOURCE_IRQ) && i < PNP_MAX_IRQ) i++;
+ while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_IRQ) i++;
if (i < PNP_MAX_IRQ) {
res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
if (irq == -1) {
@@ -65,7 +65,7 @@
pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
{
int i = 0;
- while ((res->dma_resource[i].flags & IORESOURCE_DMA) && i < PNP_MAX_DMA) i++;
+ while (!(res->dma_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_DMA) i++;
if (i < PNP_MAX_DMA) {
res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
if (dma == -1) {
@@ -81,7 +81,7 @@
pnpbios_parse_allocated_ioresource(struct pnp_resource_table * res, int io, int len)
{
int i = 0;
- while ((res->port_resource[i].flags & IORESOURCE_IO) && i < PNP_MAX_PORT) i++;
+ while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_PORT) i++;
if (i < PNP_MAX_PORT) {
res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
if (len <= 0 || (io + len -1) >= 0x10003) {
@@ -97,7 +97,7 @@
pnpbios_parse_allocated_memresource(struct pnp_resource_table * res, int mem, int len)
{
int i = 0;
- while ((res->mem_resource[i].flags & IORESOURCE_MEM) && i < PNP_MAX_MEM) i++;
+ while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_MEM) i++;
if (i < PNP_MAX_MEM) {
res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
if (len <= 0) {
diff -urN a/drivers/pnp/resource.c b/drivers/pnp/resource.c
--- a/drivers/pnp/resource.c 2003-12-31 04:47:37.000000000 +0000
+++ b/drivers/pnp/resource.c 2004-01-13 21:36:35.000000000 +0000
@@ -241,6 +241,9 @@
(*(enda) >= *(startb) && *(enda) <= *(endb)) || \
(*(starta) < *(startb) && *(enda) > *(endb)))

+#define cannot_compare(flags) \
+((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED))
+
int pnp_check_port(struct pnp_dev * dev, int idx)
{
int tmp;
@@ -250,7 +253,7 @@
end = &dev->res.port_resource[idx].end;

/* if the resource doesn't exist, don't complain about it */
- if (dev->res.port_resource[idx].flags & IORESOURCE_UNSET)
+ if (cannot_compare(dev->res.port_resource[idx].flags))
return 1;

/* check if the resource is already in use, skip if the
@@ -284,7 +287,7 @@
continue;
for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) {
if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) {
- if (pnp_port_flags(dev, tmp) & IORESOURCE_DISABLED)
+ if (cannot_compare(tdev->res.port_resource[tmp].flags))
continue;
tport = &tdev->res.port_resource[tmp].start;
tend = &tdev->res.port_resource[tmp].end;
@@ -306,7 +309,7 @@
end = &dev->res.mem_resource[idx].end;

/* if the resource doesn't exist, don't complain about it */
- if (dev->res.mem_resource[idx].flags & IORESOURCE_UNSET)
+ if (cannot_compare(dev->res.mem_resource[idx].flags))
return 1;

/* check if the resource is already in use, skip if the
@@ -340,7 +343,7 @@
continue;
for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) {
if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) {
- if (pnp_mem_flags(dev, tmp) & IORESOURCE_DISABLED)
+ if (cannot_compare(tdev->res.mem_resource[tmp].flags))
continue;
taddr = &tdev->res.mem_resource[tmp].start;
tend = &tdev->res.mem_resource[tmp].end;
@@ -365,7 +368,7 @@
unsigned long * irq = &dev->res.irq_resource[idx].start;

/* if the resource doesn't exist, don't complain about it */
- if (dev->res.irq_resource[idx].flags & IORESOURCE_UNSET)
+ if (cannot_compare(dev->res.irq_resource[idx].flags))
return 1;

/* check if the resource is valid */
@@ -411,7 +414,7 @@
continue;
for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) {
if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) {
- if (pnp_irq_flags(dev, tmp) & IORESOURCE_DISABLED)
+ if (cannot_compare(tdev->res.irq_resource[tmp].flags))
continue;
if ((tdev->res.irq_resource[tmp].start == *irq))
return 0;
@@ -429,7 +432,7 @@
unsigned long * dma = &dev->res.dma_resource[idx].start;

/* if the resource doesn't exist, don't complain about it */
- if (dev->res.dma_resource[idx].flags & IORESOURCE_UNSET)
+ if (cannot_compare(dev->res.dma_resource[idx].flags))
return 1;

/* check if the resource is valid */
@@ -464,7 +467,7 @@
continue;
for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) {
- if (pnp_dma_flags(dev, tmp) & IORESOURCE_DISABLED)
+ if (cannot_compare(tdev->res.dma_resource[tmp].flags))
continue;
if ((tdev->res.dma_resource[tmp].start == *dma))
return 0;
--- a/include/linux/pnp.h 2003-12-31 04:48:40.000000000 +0000
+++ b/include/linux/pnp.h 2004-01-13 22:37:57.000000000 +0000
@@ -33,7 +33,9 @@
#define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start)
#define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end)
#define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags)
-#define pnp_port_valid(dev,bar) (pnp_port_flags((dev),(bar)) & IORESOURCE_IO)
+#define pnp_port_valid(dev,bar) \
+ ((pnp_port_flags((dev),(bar)) & IORESOURCE_IO) && \
+ !(pnp_port_flags((dev),(bar)) & IORESOURCE_UNSET))
#define pnp_port_len(dev,bar) \
((pnp_port_start((dev),(bar)) == 0 && \
pnp_port_end((dev),(bar)) == \
@@ -45,7 +47,9 @@
#define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start)
#define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end)
#define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags)
-#define pnp_mem_valid(dev,bar) (pnp_mem_flags((dev),(bar)) & IORESOURCE_MEM)
+#define pnp_mem_valid(dev,bar) \
+ ((pnp_mem_flags((dev),(bar)) & IORESOURCE_MEM) && \
+ !(pnp_mem_flags((dev),(bar)) & IORESOURCE_UNSET))
#define pnp_mem_len(dev,bar) \
((pnp_mem_start((dev),(bar)) == 0 && \
pnp_mem_end((dev),(bar)) == \
@@ -56,11 +60,15 @@

#define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start)
#define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags)
-#define pnp_irq_valid(dev,bar) (pnp_irq_flags((dev),(bar)) & IORESOURCE_IRQ)
+#define pnp_irq_valid(dev,bar) \
+ ((pnp_irq_flags((dev),(bar)) & IORESOURCE_IRQ) && \
+ !(pnp_irq_flags((dev),(bar)) & IORESOURCE_UNSET))

#define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start)
#define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags)
-#define pnp_dma_valid(dev,bar) (pnp_dma_flags((dev),(bar)) & IORESOURCE_DMA)
+#define pnp_dma_valid(dev,bar) \
+ ((pnp_dma_flags((dev),(bar)) & IORESOURCE_DMA) && \
+ !(pnp_dma_flags((dev),(bar)) & IORESOURCE_UNSET))

#define PNP_PORT_FLAG_16BITADDR (1<<0)
#define PNP_PORT_FLAG_FIXED (1<<1)

2004-01-15 00:40:13

by Rene Herman

[permalink] [raw]
Subject: Re: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

Adam Belay wrote:

>>I agree with the overall strategy of the patch, but, during testing, I was able
>>to uncover a few bugs introduced by it. I'm reworking how pnp handles flags
>>and should have an updated patch out soon.
>
> Here's the patch. Any testing would be appreciated.

Yes, works great for the AWE64 OPL3 issue. Many thanks. I'll test this
on a few more machines with ISA PnP cards as well.

Rene.

2004-01-15 23:39:23

by Rene Herman

[permalink] [raw]
Subject: Re: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

diff -urN linux-2.6.1-pnp/drivers/pnp/isapnp/core.c linux-2.6.1-pnp-incr/drivers/pnp/isapnp/core.c
--- linux-2.6.1-pnp/drivers/pnp/isapnp/core.c 2004-01-16 00:02:40.000000000 +0100
+++ linux-2.6.1-pnp-incr/drivers/pnp/isapnp/core.c 2004-01-15 23:58:23.000000000 +0100
@@ -1039,17 +1039,17 @@

isapnp_cfg_begin(dev->card->number, dev->number);
dev->active = 1;
- for (tmp = 0; tmp < PNP_MAX_PORT && !(res->port_resource[tmp].flags & IORESOURCE_UNSET); tmp++)
+ for (tmp = 0; tmp < PNP_MAX_PORT && (res->port_resource[tmp].flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO; tmp++)
isapnp_write_word(ISAPNP_CFG_PORT+(tmp<<1), res->port_resource[tmp].start);
- for (tmp = 0; tmp < PNP_MAX_IRQ && !(res->irq_resource[tmp].flags & IORESOURCE_UNSET); tmp++) {
+ for (tmp = 0; tmp < PNP_MAX_IRQ && (res->irq_resource[tmp].flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ; tmp++) {
int irq = res->irq_resource[tmp].start;
if (irq == 2)
irq = 9;
isapnp_write_byte(ISAPNP_CFG_IRQ+(tmp<<1), irq);
}
- for (tmp = 0; tmp < PNP_MAX_DMA && !(res->dma_resource[tmp].flags & IORESOURCE_UNSET); tmp++)
+ for (tmp = 0; tmp < PNP_MAX_DMA && (res->dma_resource[tmp].flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA; tmp++)
isapnp_write_byte(ISAPNP_CFG_DMA+tmp, res->dma_resource[tmp].start);
- for (tmp = 0; tmp < PNP_MAX_MEM && !(res->mem_resource[tmp].flags & IORESOURCE_UNSET); tmp++)
+ for (tmp = 0; tmp < PNP_MAX_MEM && (res->mem_resource[tmp].flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM; tmp++)
isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<2), (res->mem_resource[tmp].start >> 8) & 0xffff);
/* FIXME: We aren't handling 32bit mems properly here */
isapnp_activate(dev->number);
diff -urN linux-2.6.1-pnp/include/linux/pnp.h linux-2.6.1-pnp-incr/include/linux/pnp.h
--- linux-2.6.1-pnp/include/linux/pnp.h 2004-01-16 00:02:40.000000000 +0100
+++ linux-2.6.1-pnp-incr/include/linux/pnp.h 2004-01-15 23:56:31.000000000 +0100
@@ -34,8 +34,8 @@
#define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end)
#define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags)
#define pnp_port_valid(dev,bar) \
- ((pnp_port_flags((dev),(bar)) & IORESOURCE_IO) && \
- !(pnp_port_flags((dev),(bar)) & IORESOURCE_UNSET))
+ ((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \
+ == IORESOURCE_IO)
#define pnp_port_len(dev,bar) \
((pnp_port_start((dev),(bar)) == 0 && \
pnp_port_end((dev),(bar)) == \
@@ -48,8 +48,8 @@
#define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end)
#define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags)
#define pnp_mem_valid(dev,bar) \
- ((pnp_mem_flags((dev),(bar)) & IORESOURCE_MEM) && \
- !(pnp_mem_flags((dev),(bar)) & IORESOURCE_UNSET))
+ ((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \
+ == IORESOURCE_MEM)
#define pnp_mem_len(dev,bar) \
((pnp_mem_start((dev),(bar)) == 0 && \
pnp_mem_end((dev),(bar)) == \
@@ -61,14 +61,14 @@
#define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start)
#define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags)
#define pnp_irq_valid(dev,bar) \
- ((pnp_irq_flags((dev),(bar)) & IORESOURCE_IRQ) && \
- !(pnp_irq_flags((dev),(bar)) & IORESOURCE_UNSET))
+ ((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \
+ == IORESOURCE_IRQ)

#define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start)
#define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags)
#define pnp_dma_valid(dev,bar) \
- ((pnp_dma_flags((dev),(bar)) & IORESOURCE_DMA) && \
- !(pnp_dma_flags((dev),(bar)) & IORESOURCE_UNSET))
+ ((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \
+ == IORESOURCE_DMA)

#define PNP_PORT_FLAG_16BITADDR (1<<0)
#define PNP_PORT_FLAG_FIXED (1<<1)


Attachments:
linux-2.6.1-pnp_incr.diff (3.76 kB)

2004-01-18 22:26:23

by Santiago Garcia Mantinan

[permalink] [raw]
Subject: Re: [PATCH] Re: ALSA in 2.6 failing to find the OPL chip of the sb cards

> Here's the patch. Any testing would be appreciated.

This new patch works well for me (SB 16PNP), no problems so far.

Regards...
--
Manty/BestiaTester -> http://manty.net