Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcibios_enable_memmap_set_master_all, fix PCI command register width #74

Merged
merged 3 commits into from
Jan 18, 2024

Conversation

jiyunomegami
Copy link
Contributor

Is it OK to change all byte reads/writes to 16 bit word read/writes?
Maybe there is some hardware that doesn't work one byte at a time?

Also, I think pcibios_enable_memmap_set_master_all (new function) is needed for some cards like YMF7xx.

@crazii
Copy link
Owner

crazii commented Jan 18, 2024

The PCI configuration space allow byte IO, so it's OK, only some devices doesn't support byte/word IO, but only dwords.
It's OK to change it to words, we got nothing to lose.

@crazii crazii merged commit 6327014 into crazii:main Jan 18, 2024
1 check passed
@crazii
Copy link
Owner

crazii commented Jan 21, 2024

Does the YMF7x4 driver (SETUPDS.EXE and DSDMA.EXE) work?
if it doesn't work, you can try this one out: https://www.vogons.org/viewtopic.php?p=903972#p903972 that's the one I used for my desktop rig, and Toshiba 2805.

And if it still doesn't work perfectly, I think we can add ymf driver support.

@jiyunomegami
Copy link
Contributor Author

jiyunomegami commented Jan 21, 2024

Thanks. I know about the Yamaha drivers and use them for my core 2 duo machine with win98.
Since Sandy Bridge (i7-2600K etc) you need PCI support or a PCIe-to-PCI bridge that supports "subtractive decode" in order for the YMF card to handle the legacy I/O ports.
Also it seems that the BIOS must properly support this.
I tested some motherboards:
MA3-79GDG COMBO AMD SB750 chipset: setupds and dsdma run, but there is no sound at all.
Asus B75M-PLUS Ivy Bridge: everything works OK. B75 has proper PCI support.
Asus H81M-C Haswell w/ASM1083 bridge IC: dsdma only works if you limit memory with himemx /MAX=32768.
ECS Z77 Ivy Bridge: running setupds or dsma causes the system to reset.
MSI P67A-S40 Sandy Bridge w/ASM1083 bridge IC: running setupds or dsma results in a system freeze with a Jemm exception message shown.

One other thing, setupds and dsdma will freeze if you have QPIEMU.DLL loaded!
And you can't load QPIEMU.DLL after running dsdma.

@volkertb
Copy link
Collaborator

volkertb commented Jan 21, 2024

Thanks. I know about the Yamaha drivers and use them for my core 2 duo machine with win98. Since Sandy Bridge (i7-2600K etc) you need PCI support or a PCIe-to-PCI bridge that supports "subtractive decode" in order for the YMF card to handle the legacy I/O ports.

Do such newer motherboard at least make those resources available on higher (non-legacy) ports? Because if so, it would be nice if SBEMU could redirect the OPL3 legacy port I/O to the ports on the YMF7x4 cards, instead of emulating OPL3 completely in software. That would save quite a few CPU cycles and also it would be cool to actually be using that functionality in the card, even in newer motherboards that lack support for subtractive decode. 🙂

@jiyunomegami
Copy link
Contributor Author

I made a YMF744 version because Kamerat asked a similar question on Vogons.
FM and MPU-401 is handled by the YMF card, and sound blaster PCM is handled by HDA or whatever other card you have in your system.
https://www.vogons.org/viewtopic.php?f=62&t=98071

It only works with YMF744 or YMF754, since YMF724/YMF740 only support the legacy addresses.
The source code is in my fork. I am not sure if it is OK to merge now, since the YMF driver doesn't handle PCM yet.
I think you can do the same thing with CMI8738.

@crazii
Copy link
Owner

crazii commented Jan 22, 2024

I think you can do the same thing with CMI8738.

Yes, it can be done, but it will be the last solution.

FM and MPU-401 is handled by the YMF card, and sound blaster PCM is handled by HDA or whatever other card you have in your system.

Is it done by one cmdline opt, or automatically use FM if the YMF744/754 is detected?

Are you planning to add PCM support to YMF754? I think it'll be great if you add PCM. :)

@jiyunomegami
Copy link
Contributor Author

It automatically detects and uses YMF744/754 if detected, and you can use both the serial port and YMF gameport for MIDI.
It will use a NULL driver for the other card if none is detected.

I am trying to add PCM. I probably would have finished it over the weekend, but I got sidetracked verifying S/PDIF output, checking status bits with a logic analyzer etc.

@jiyunomegami
Copy link
Contributor Author

I finished the PCM driver, but it might not be stable. I have some weird problem where mTCP's ftp server hangs when receiving a file, after running Doom or Duke 3D. Also the volume is fixed at maximum.
I don't think it works with YMF724 yet, the other day when i tried it, it couldn't find the I/O registers and just skipped the card.

When I make a pull request later, is it OK to add the HW port remapping and the NULL driver?
the NULL driver is only selectable when a driver explicitly asks for it by setting au_cards_fallback_to_null.

For HW port remapping, see main_hw_fmport and main_hw_mpuport in main.c:
main...jiyunomegami:SBEMU:main
There might be a few things left to cleanup, for instance the CMI changes are not needed.

@crazii
Copy link
Owner

crazii commented Jan 23, 2024

OK I check it later.
It's really good to have ymf support.😃

@crazii
Copy link
Owner

crazii commented Jan 23, 2024

Theoretically It's OK to redirect to hardware FM, but the problem is that the PCM is needed to feed muted samples to keep interrupts happening, otherwise there'll be no interrupts and SBEMU will stop working, or if the sound cards uses LOOP mode, it will play the last samples repeatedly. I was planning to remove the muted samples and then trigger AU_start on SB playback, but never did that.
So currently it might have problem.

BTW, did it work on YMF753 (AC-XG aka ac97 without dos support)? I have a Toshiba laptop win YMF753, I could test with it.
Although it lacks dos support, the WDM driver provides SB emulation and the XG MIDI is way better than the MS GS wavetable. So I can still play DOS games in win98, but the SB emulation on win98 is not compatible to all games.

@crazii
Copy link
Owner

crazii commented Jan 23, 2024

Btw I have 2 piece of Yamaha waveforce 192xg which is 724 with midi, but the midi is not available in dos, maybe I can test it with dsxg driver and SBEMU, with only p330 remapped.

@jiyunomegami
Copy link
Contributor Author

The way that FM/MPU/SB ports are setup on the 724 is different, so it won't work yet.
And you can't use dsdma or setupds at the same time as QPIEMU.DLL, they will freeze.

YMF753 is just a tiny AC97 IC, like the Realtek AC97 ICs you can see on some motherboards.
It doesn't have an OPL chip, MIDI, or sound blaster compatibility.
Maybe the ICH AC97 driver works with it?

Does the ICH driver work? I tried it on a Pentium 4 motherboard. SBEMU and games run, but there is no sound at all.
It is detected as ICH : Intel ICH found on port E200 irq:11 (type:ICH4, bits:16,20)

The PCI device is 8086:24D5
Subsystem ID 82121565 (vendor id 1565 is Biostar)
The AC97 IC is a Realtek ALC655.

@crazii
Copy link
Owner

crazii commented Jan 24, 2024

I haven't tested sbemu on 753, maybe it needs special handling, what about the midi of 753, can it work?

@jiyunomegami
Copy link
Contributor Author

I think that the WDM drivers use a software synth, like S-YXG50, and send PCM data to the 753.

@jiyunomegami
Copy link
Contributor Author

I added YMF724 support and made a pull request.
If you use it with your YMF724, make sure it says YMF: OPL3 detected on startup.
If PCI subtractive decode is not supported, it will fallback to SBEMU's OPL3 emulation.
There is a master volume mixer, so /vol works.
I tested it with 3 types, 724, 744, and 754.

There is a big problem with the 754. Maybe you can help?
No interrupts are generated when you trigger PCM playback by setting the playback control address.
And if you unmute PCM (by setting the register YDSXGR_NATIVEDACOUTVOL) there is a very loud buzzing noise. Maybe it is playing some junk data using DMA from the wrong address.
The playback pointer does not get updated.
I added a workaround using the card's timer interrupt. It only unmutes PCM once the playback pointer is non zero.

Now, the weird thing is, if you boot Linux and then immediately reboot into DOS, it works perfectly!
You don't even need to load the Linux ymfpci driver. You can just use a bootable USB drive with Linux on it and ctrl-alt-del once init runs.
Is there something special that Linux does to setup PCI/DMA?
I checked the PCI registers and the YMF card's registers, but the only difference was in the status bits of 2 PCI to PCI bridges, they had the "Received Master Abort" bit set after running Linux.

@crazii
Copy link
Owner

crazii commented Jan 27, 2024

Cool, I'll review the code in a day or two.
I only have one 754 laptop, the unicorn Toshiba2805 with GeForce 2 Go, I'm cautious to debug using it LOL, may be I can pick another 754 for my desktop. :)

There's a possibility Linux touched some registers that you missed, (not for the YMF but the PCI config space registers) I haven't check the code yet, it's all blind guess that might not help.

@jiyunomegami
Copy link
Contributor Author

Take your time.
I see from your posts on vogons that your 754 works in Windows 98 or DOS.
For me, sound blaster sound effects do not work with DSDMA.
I took out the 724 from my Windows 98 box and put in the 754, and now there is no sound in at all in Windows.

BTW, it appears that setupds will run with QPIEMU.DLL loaded, but not with HDPMI32i enabled.
I was using HDPMI32i -r -x but if you do something like:
HDPMI32i
SBEMU /SCL
HDPMI32i -d
then setupds will run. I dumped the registers while setupds was playing the wav file this way.

@crazii
Copy link
Owner

crazii commented Jan 27, 2024

Yes that laptop's board has SBLINK and it's wired to the 754, so the DS-XG works in PCPCI mode not DSDMA.
You may need use ymfirq to detect the IRQ of your 754, as setupds may not detect it well.

Interesting that setupds won't work with hdpmi32i, I'll check my desktop on it after merging your code.

My desktop board has SBLINK too and I connected it with the 724 (All the 724 I bought have PCPCI connector except the waveforce 192xgs but they also work in DSDMA), so it works in PCPCI mode. I tested when SBLINK not connected and it also works.

EDIT: I don't know whether DSDMA needs motherboard support, you can check that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants