Skip to contentSkip to conversation

Dreamcast AICA driver

DISCUSSION Lee Revell 5 participants 14 messages Mar 12, 2006 – Mar 13, 2006 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Lee Revell

author
#1 lore raw
Quoted 9 lines · Adrian McMenamin

After a mere three years in development I now have a working (mono only for now) ALSA driver for the Dreamcast driver to test.

Sources are available for browsing at:

http://newgolddream.dyndns.info/cgi-bin/cvsweb

If there are any testers out there please let me know!

Cool, what did you have to do to get it working?

Lee

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#2 lore raw
Quoted 4 lines · Lee Revell
Quoted 3 lines · Adrian McMenamin

After a mere three years in development I now have a working (mono only for now) ALSA driver for the Dreamcast driver to test.

Quoted 8 lines
Quoted 6 lines

Sources are available for browsing at:

http://newgolddream.dyndns.info/cgi-bin/cvsweb

If there are any testers out there please let me know!

Cool, what did you have to do to get it working?

Key point was to switch to timer polling. It turned out there were issues with the ARM7 firmware and interrupts that meant it behaved in odd ways and essentially didn't work :)

So I still use DMA to transfer the samples, but I use timer polling to test how much has been played

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

author
#3 lore raw
Quoted 15 lines · Adrian McMenamin
Quoted 4 lines · Lee Revell
Quoted 3 lines · Adrian McMenamin

After a mere three years in development I now have a working (mono only for now) ALSA driver for the Dreamcast driver to test.

Quoted 8 lines
Quoted 6 lines

Sources are available for browsing at:

http://newgolddream.dyndns.info/cgi-bin/cvsweb

If there are any testers out there please let me know!

Cool, what did you have to do to get it working?

Quoted 7 lines

Key point was to switch to timer polling. It turned out there were issues with the ARM7 firmware and interrupts that meant it behaved in odd ways and essentially didn't work :)

So I still use DMA to transfer the samples, but I use timer polling to test how much has been played

Great!!! I am really glad you finally got this to work - your plight reminded me of trying to develop the emu10k1 multichannel support, when I knew nothing about ALSA drivers, and only had existing driver and reverse engineered hardware docs...

You should submit this to ALSA now, as a patch against CVS...

Lee

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

author
#4 lore raw
Quoted 1 line · Lee Revell

You should submit this to ALSA now, as a patch against CVS...

static int snd_aicapcm_free(snd_card_aica_t *dreamcastcard)

{
	release_mem_region(0xa0702c00, 0x4);
	release_mem_region(0xa0800000, 0x200000);
	return 0;
}

Actually this driver still has way too many magic numbers - if you're not exactly sure what a constant does then document it with comments in the header file.

It looks like many of these will be trivial to document:

	if (request_mem_region(0xa0702c00, 4, "AICA ARM control")== NULL) return -ENOMEM;
	if (request_mem_region(0xa0800000, 0x200000, "AICA Sound RAM") == NULL)

Lee

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#5 lore raw
Quoted 11 lines · Lee Revell
Quoted 1 line · Lee Revell

You should submit this to ALSA now, as a patch against CVS...

static int snd_aicapcm_free(snd_card_aica_t *dreamcastcard)

{
	release_mem_region(0xa0702c00, 0x4);
	release_mem_region(0xa0800000, 0x200000);
	return 0;
}
Quoted 4 lines

Actually this driver still has way too many magic numbers - if you're not exactly sure what a constant does then document it with comments in the header file.

I know what these are - they can be turned into constants - they are either references to the ARM7 register bank or the ARM7 memory space.

Quoted 9 lines

It looks like many of these will be trivial to document:

	if (request_mem_region(0xa0702c00, 4, "AICA ARM control")== NULL) return -ENOMEM;
	if (request_mem_region(0xa0800000, 0x200000, "AICA Sound RAM") == NULL)

Lee

Quoted 9 lines

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 13 lines · Adrian McMenamin

I know what these are - they can be turned into constants - they are either references to the ARM7 register bank or the ARM7 memory space.

Quoted 8 lines

It looks like many of these will be trivial to document:

	if (request_mem_region(0xa0702c00, 4, "AICA ARM control")== NULL) return -ENOMEM;
	if (request_mem_region(0xa0800000, 0x200000, "AICA Sound RAM") == NULL)

Lee

Adrian,

It was good to talk to you on IRC. Now, as you have the source code for the ARM7 firmware as well as the SH4 driver code, it might be sensible to highlight the dependencies between them, by maybe using the same human readable constant name in both bits of code. It also makes things easier to understand if the hex addresses are given as offsets from some sort of base.

if (request_mem_region(0xa0702c00, 4, "AICA ARM control")== NULL) return -ENOMEM;

then becomes in a .h file:
#define ARM7_BASE_MEM 0xa0700000
#define ARM7_AICA_CONTROL 0x2c00

During driver init:
base_mem = ARM7_BASE_MEM

if (request_mem_region(base_mem + ARM7_AICA_CONTROL, 4, "AICA ARM control")== NULL) return -ENOMEM;

This would then allow movement of the base_mem without much modification to the driver code, if for example the ARM7 firmware required the change.

James

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#8 lore raw
Quoted 15 lines · James Courtier-Dutton

Adrian,

It was good to talk to you on IRC. Now, as you have the source code for the ARM7 firmware as well as the SH4 driver code, it might be sensible to highlight the dependencies between them, by maybe using the same human readable constant name in both bits of code. It also makes things easier to understand if the hex addresses are given as offsets from some sort of base.

if (request_mem_region(0xa0702c00, 4, "AICA ARM control")== NULL) return -ENOMEM;

then becomes in a .h file:
#define ARM7_BASE_MEM 0xa0700000
#define ARM7_AICA_CONTROL 0x2c00

Quoted 6 lines

During driver init:
base_mem = ARM7_BASE_MEM

if (request_mem_region(base_mem + ARM7_AICA_CONTROL, 4, "AICA ARM control")== NULL) return -ENOMEM;

This would then allow movement of the base_mem without much modification to the driver code, if for example the ARM7 firmware required the change.

Sure. I understand the point of course

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#9 lore raw
In reply to Lee Revell
Quoted 4 lines · Lee Revell

You should submit this to ALSA now, as a patch against CVS...

Lee

A bit more tidying to be done as you say

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

author
#10 lore raw
In reply to Adrian McMenamin
Quoted 1 line · Adrian McMenamin

http://newgolddream.dyndns.info/cgi-bin/cvsweb

You should split this into a .c and .h file

/* AICA channels stuff */

/* Command values */
#define AICA_CMD_KICK 0x80000000
#define AICA_CMD_NONE 0
#define AICA_CMD_START 1
#define AICA_CMD_STOP 2
#define AICA_CMD_VOL 3

/* Sound modes */
#define SM_8BIT 1
#define SM_16BIT 0
#define SM_ADPCM 2

etc

Lee

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

author
#11 lore raw
In reply to Adrian McMenamin
Quoted 6 lines · Adrian McMenamin
Quoted 2 lines
Quoted 2 lines

http://newgolddream.dyndns.info/cgi-bin/cvsweb

	dreamcastcard->clicks++;
	if (dreamcastcard->clicks == 8) dreamcastcard->clicks = 0;

dreamcastcard->clicks %= 8

;-)

Quoted 2 lines
	/* reschedule the timer */
	dreamcastcard->timer.expires = jiffies + 2;

What exactly do you mean to do here - I suspect there's an unintended dependency on HZ. Do you intend to delay for $FOO ms?

Lee

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#12 lore raw
Quoted 10 lines · Lee Revell
Quoted 6 lines · Adrian McMenamin
Quoted 2 lines
Quoted 2 lines

http://newgolddream.dyndns.info/cgi-bin/cvsweb

	dreamcastcard->clicks++;
	if (dreamcastcard->clicks == 8) dreamcastcard->clicks = 0;

dreamcastcard->clicks %= 8

Quoted 7 lines

;-)

Quoted 2 lines
	/* reschedule the timer */
	dreamcastcard->timer.expires = jiffies + 2;

What exactly do you mean to do here - I suspect there's an unintended dependency on HZ. Do you intend to delay for $FOO ms?

Just copied that off the dummy driver in the kernel but yes it's just an arbitrary delay

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#13 lore raw
In reply to Lee Revell

Hi,

Quoted 9 lines · Lee Revell
Quoted 6 lines · Adrian McMenamin
Quoted 2 lines
Quoted 2 lines

http://newgolddream.dyndns.info/cgi-bin/cvsweb

	dreamcastcard->clicks++;
	if (dreamcastcard->clicks == 8) dreamcastcard->clicks = 0;

dreamcastcard->clicks %= 8;

Watch out. The ARM7 does not support this in direct assembler. If the compiler is not smart enough it would require a division, and that is really realy slow on a any ARM processor.
Helping the compiler by using

dreamcastcard->clicks &= 0x00000003;

... would be a much faster option.

Best Regards,
Manuel.

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#14 lore raw
Quoted 13 lines · Manuel Jander

Hi,

Quoted 9 lines · Lee Revell
Quoted 6 lines · Adrian McMenamin
Quoted 2 lines
Quoted 2 lines

http://newgolddream.dyndns.info/cgi-bin/cvsweb

	dreamcastcard->clicks++;
	if (dreamcastcard->clicks == 8) dreamcastcard->clicks = 0;

dreamcastcard->clicks %= 8;

Quoted 9 lines

Watch out. The ARM7 does not support this in direct assembler. If the compiler is not smart enough it would require a division, and that is really realy slow on a any ARM processor.
Helping the compiler by using

dreamcastcard->clicks &= 0x00000003;

... would be a much faster option.

This was actually in SH4 code rather than ARM7, though I did have some fun and games with the ARM7 code - seemingly with division :)

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#15 lore raw
In reply to Manuel Jander

At Sun, 12 Mar 2006 21:35:36 +0100,

Quoted 12 lines · Manuel Jander

Hi,

Quoted 8 lines · Lee Revell
Quoted 6 lines · Adrian McMenamin
Quoted 2 lines
Quoted 2 lines

http://newgolddream.dyndns.info/cgi-bin/cvsweb

	dreamcastcard->clicks++;
	if (dreamcastcard->clicks == 8) dreamcastcard->clicks = 0;
Quoted 8 lines
Quoted 1 line

dreamcastcard->clicks %= 8;

Watch out. The ARM7 does not support this in direct assembler. If the compiler is not smart enough it would require a division, and that is really realy slow on a any ARM processor.
Helping the compiler by using

dreamcastcard->clicks &= 0x00000003;

Should be 7 instead of 3 :)

BTW, you don't have to restrict the buffer size and period size as long as you have double-buffer, i.e. a buffer on CPU side and transfer to the h/w buffer. The only restricted parameter is the period size. For example, a buffer with 13 periods can be mapped like:

BUF  0 ... 7 8 9 10 11 12 | 0 1 2 3 4 ...
H/W  0 ... 7 0 1 2  3  4  | 5 6 7 0 1 ...

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642