Jump to content

ATI AC 97 Sounds (SB400) effort


  • This topic is locked This topic is locked
695 replies to this topic

#181
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
Using my code, I've compiled a version that appears to be minimally functional - "minimally" defined as, it plays something resembling correct sound eventually. I suspect some of the remaining problems are in the getDMAHardwarePointer() function (I don't know what it's actually supposed to return), as well as the DMA engine never stopping. I'm attaching the complete archive in the .zip file; the compiled kext is found in build/Development and is named AppleAC97Audio.kext.

Using my code, I've compiled a version that appears to be minimally functional - "minimally" defined as, it plays something resembling correct sound eventually. I suspect some of the remaining problems are in the getDMAHardwarePointer() function (I don't know what it's actually supposed to return), as well as the DMA engine never stopping. I'm attaching the complete archive in the .zip file; the compiled kext is found in build/Development and is named AppleAC97Audio.kext.

Attached Files



#182
lazyilmaz

lazyilmaz

    InsanelyMac Protégé

  • Members
  • Pip
  • 29 posts
  • Location:Netherlands
Maybe you guys don't know yet. The newest version of FreeBSD, v. 6.1, supports ATI sound. Maybe it will be more usefull then the Linux drivers.

#183
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
Mac OS X kernel drivers are unlike any other mainstream OS drivers on the market. As such, it's usually easier for us to start with something we're familiar with. I've been using and hacking Linux for probably ten years now, so I perfer to start with Linux kernel drivers, figure out how they work, and apply that functionality to the Mac OS driver model. Thank you for the information, though. :P

#184
EdFlyer

EdFlyer

    Computer Lackey

  • Members
  • PipPipPip
  • 159 posts
is it possible that the playing for a while and then looping is caused by the buffer not being flushed so it leaves some data in there and then fills up and then starts looping?

sounds like we've got a memory leak or something like that.
-ed

#185
chrs2021

chrs2021

    InsanelyMac Protégé

  • Members
  • PipPip
  • 69 posts
i was thinking the same thing, i discovered it when i thought it was a buffer issue. also is there anyway to reset the driver without rebooting

#186
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
chrs: Not that I know of, I've tried.

Ed: Quite likely, the flush() method is called during the stopDMAEngine, but that never seems to get called.

#187
EdFlyer

EdFlyer

    Computer Lackey

  • Members
  • PipPipPip
  • 159 posts
what's the condition necessary for the stopDMAEngine to be called?

It probably has something to do with the getDMAPointer that we are now incrementing, but maybe not incrememting the right way.

Yeha, so I'll be home from work in about 2 hours, then I'll be able to really dive into the code 100%

#188
Elv13

Elv13

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 318 posts
the kext dont load, in my sys info it say no integrated audio (probably bad traduction)
i got an ATIIXP and use the linux atiixp.ko module, any idea why it dont load?
*i repared permission manually

#189
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
That was my thought, Ed. I don't know what get DMAPointer should return, which is confusing enough. And I do think that stopDMAEngine is probably called once the system determines that the DMA hardware pointer has incremented past end-of-stream.

#190
EdFlyer

EdFlyer

    Computer Lackey

  • Members
  • PipPipPip
  • 159 posts
the DMAPointer is supposed to return an IOByteCount.

From the other AC97 codes (intel, via) it seems they return how many bytes are left in the stream. It is entirely possible we are returning the wrong number and that's why it loops out on us.

#191
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
It returns how many bytes are *left*? Hmm... I'm returning (supposedly) how many bytes we've sent. That would explain, probably, why it loops out on us. I'll take a look-see to find out how to calculate bytes remaining.

#192
EdFlyer

EdFlyer

    Computer Lackey

  • Members
  • PipPipPip
  • 159 posts
total bytes left = total bytes - bytes sent

that may be more useful than it would originally seem

you access the total length of the stream, see how many we've sent, and then subtract that out to get the bytes left and send that number...


or i could be entirely wrong. (standard oops i messed up, sorry kthnx disclaimer)

#193
chrs2021

chrs2021

    InsanelyMac Protégé

  • Members
  • PipPip
  • 69 posts
@dopefish
the reason i thought (past tense) there was a buffering issue was the fact that it'd take a few seconds to load something then it would stutter but that was using your old code before you uploaded your project. now it takes a while to play and like 10 minutes with the Kext loaded it speeds up or atleast thats what i think its doing. also i think it is the way we increment the pointer because i looked at the other code from amd and intel and i noticed that after stopped DMA there was IOSleep() and for me it stopped the looping, but now after awhile the audio gets choppy and the latency is still up there and here is what i wrote
if (!(dma->flags & ATI_ENGINE_RUNNING))
	{
		IOLog("%s::%s: Redundant DMA stop\n", getName(), __FUNCTION__);
		return;
	}

	dma->run_dma(regs, false);
	dma->flush_dma(regs);
	regs->update(ATI_REG_IER, ATI_REG_IER_SET_BUS_BUSY, 0);
	IOSleep(50);
	dma->interruptReady = false;
	dma->flags &= ~ATI_ENGINE_RUNNING;


#194
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
Ed, I dunno how to access the length of the stream.

#195
chrs2021

chrs2021

    InsanelyMac Protégé

  • Members
  • PipPip
  • 69 posts
i think i figured out here is the source code peice i changed
IOByteCount CLASS::getDMAEngineHardwarePointer(IOAC97DMAEngineID engine)
{
	UInt32 curptr;
	UInt32 timeout = 1000;
	CHECK_DMA_ENGINE_ID(engine, 0);
	ATIIXPDMADesc *dma = dma_channels[engine];
	UInt32 tmp;
	IOPhysicalAddress buf_addr = dma->sampleMemory->getPhysicalSegment(0, &tmp);
	IOByteCount position;
	/*while (timeout--)
	{
		curptr = regs->read(dma->currentPointerOffset);
		DebugLog("%s::%s: DMA hardware pointer value 0x%lx\n", getName(), __FUNCTION__, curptr);
		if (curptr < buf_addr)
			continue;
		curptr -= buf_addr;
		DebugLog("%s::%s: Hardware pointer > sample buffer addr, offset 0x%lx\n", getName(), __FUNCTION__, curptr);
		if (curptr >= dma->sampleMemory->getCapacity())
		{
			DebugLog("%s::%s: Current buffer size 0x%lx\n", dma->sampleMemory->getCapacity());
			continue;
		}
		DebugLog("%s::%s: Hardware pointer < buffer size, returning to user\n", getName(), __FUNCTION__);
		return (IOByteCount)curptr;
	} */
	position = regs->read(ATI_REG_SPDF_DMA_DT_SIZE + (engine * 4));
	IOLog("%s::%s: Timeout getting DMA hardware pointer\n", getName(), __FUNCTION__);
	IOLog("Current codec mask: 0x%x\n", codecsNotReady);
	return (position - dma->currentPointerOffset);
}

*never mind causes kernel panic :) *

#196
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
dma->currentPointerOffset is a register offset in memory-mapped space. :) ATI_REG_SPDF_DMA_DT_SIZE is an SPDIF register, which doesn't make much sense.

#197
chrs2021

chrs2021

    InsanelyMac Protégé

  • Members
  • PipPip
  • 69 posts
OH {censored} lol sorry i was basing it off the AMD source haha no wonder why it paniked out on me. but i must have the right idea to create ed's equation

#198
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
Hehe, yeah, that doesn't work too well. What's in the code is a similar idea to what's in the AMD source, which is why I believe it's supposed to calculate the current position in the stream, i.e. how many bytes we've read/written so far.

#199
chrs2021

chrs2021

    InsanelyMac Protégé

  • Members
  • PipPip
  • 69 posts
its weird i i got it to the point where it doesn't stutter but now i am having big ass latency issues of about 6 seconds

#200
thedopefishlives

thedopefishlives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 205 posts
Latency issues, I assume, are due to something about the DMA engine, which all goes back to the hardware pointer. If we can figure out this one function, I think we'll have working sound.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2017 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy