Skip to contentSkip to conversation

Gallant SC-6000 driver (3rd version)

PATCH In review Krzysztof Helt 2 participants 4 messages Sep 4, 2007 – Sep 5, 2007 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Gallant SC-6000 driver (3rd version)

From: Krzysztof Helt <[email protected]>

This is port of the Gallant SC-6000 driver from the OSS aedsp16 driver. This card was also sold as AudioExcel DSP 16 and Zoltrix AV302 (Audio Plus True 16).

---

The two issues pointed by Takashi are fixed.

sound/isa/Kconfig +13 -0
diff -urpN linux-2.6.22.old/sound/isa/Kconfig linux-2.6.22/sound/isa/Kconfig
@@ -191,6 +191,19 @@ config SND_ES18XX
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-es18xx.
 
+config SND_SC6000
+	tristate "Gallant SC-6000, Audio Excel DSP 16"
+	depends on SND
+	select SND_AD1848_LIB
+	select SND_OPL3_LIB
+	select SND_MPU401_UART
+	help
+	  Say Y here to include support for Gallant SC-6000 card and clones:
+	  Audio Excel DSP 16 and Zoltrix AV302.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-sc6000.
+
 config SND_GUS_SYNTH
 	tristate
 
sound/isa/Makefile +2 -0
diff -urpN linux-2.6.22.old/sound/isa/Makefile linux-2.6.22/sound/isa/Makefile
@@ -10,6 +10,7 @@ snd-cmi8330-objs := cmi8330.o
 snd-dt019x-objs := dt019x.o
 snd-es18xx-objs := es18xx.o
 snd-opl3sa2-objs := opl3sa2.o
+snd-sc6000-objs := sc6000.o
 snd-sgalaxy-objs := sgalaxy.o
 snd-sscape-objs := sscape.o
 
@@ -21,6 +22,7 @@ obj-$(CONFIG_SND_CMI8330) += snd-cmi8330
 obj-$(CONFIG_SND_DT019X) += snd-dt019x.o
 obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o
 obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o
+obj-$(CONFIG_SND_SC6000) += snd-sc6000.o
 obj-$(CONFIG_SND_SGALAXY) += snd-sgalaxy.o
 obj-$(CONFIG_SND_SSCAPE) += snd-sscape.o
 
sound/isa/sc6000.c +630 -0

630 lines not on this page · raw message

#1 lore raw

On 09/04/2007 09:11 PM, Krzysztof Helt wrote:

By the way -- something along the email path to you rejects my messages due to taking an SPF-neutral result from gmail as negative...

Quoted 1 line

The two issues pointed by Takashi are fixed.

[ ... ]

sound/isa/sc6000.c line 29

Quoted 4 lines
sound/isa/sc6000.c +4 -0
+#include <linux/module.h>
+#include <linux/isa.h>
+#include <asm/dma.h>
+#include <sound/driver.h>

He probably forgot to request that sound/driver.h come first. It's an issue with fixing up things for 2.4 compiles with the standalone driver package.

sound/isa/sc6000.c line 37

Quoted 8 lines
sound/isa/sc6000.c +8 -0
+#include <sound/core.h>
+#include <sound/ad1848.h>
+#include <sound/opl3.h>
+#include <sound/mpu401.h>
+#include <sound/control.h>
+#define SNDRV_LEGACY_FIND_FREE_IRQ
+#define SNDRV_LEGACY_FIND_FREE_DMA
+#include <sound/initval.h>

Personally I rather detest ISA autoprobing, so if you only included it as a "I see that the ALSA thing to do", feel free to try without as far as I'm concerned...

sound/isa/sc6000.c line 108

Quoted 6 lines
sound/isa/sc6000.c +6 -0
+#define DSP_RESET	0x06	/* offset of DSP RESET		(wo) */
+#define DSP_READ	0x0a	/* offset of DSP READ		(ro) */
+#define DSP_WRITE	0x0c	/* offset of DSP WRITE		(w-) */
+#define DSP_COMMAND	0x0c	/* offset of DSP COMMAND	(w-) */
+#define DSP_STATUS	0x0c	/* offset of DSP STATUS		(r-) */
+#define DSP_DATAVAIL	0x0e	/* offset of DSP DATA AVAILABLE	(ro) */

One of these days I'm going to stick that snd_sbdsp_reset() in the midlayer...

Quoted 46 lines
sound/isa/sc6000.c +46 -0
+
+#define PFX "sc6000: "
+
+/* hardware dependent functions */
+
+/*
+ * sc6000_irq_to_softcfg - Decode irq number into cfg code.
+ */
+static inline unsigned char sc6000_irq_to_softcfg(int irq)
+{
+	unsigned char val = 0;
+
+	switch (irq) {
+	case 5:
+		val = 0x28;
+		break;
+	case 7:
+		val = 0x8;
+		break;
+	case 9:
+		val = 0x10;
+		break;
+	case 10:
+		val = 0x18;
+		break;
+	case 11:
+		val = 0x20;
+		break;
+	default:
+		break;
+	}
+	return val;
+}
+
+/*
+ * sc6000_dma_to_softcfg - Decode dma number into cfg code.
+ */
+static inline unsigned char sc6000_dma_to_softcfg(int dma)
+{
+	unsigned char val = 0;
+
+	switch (dma) {
+	case 0:
+		val = 1;
+		break;
+	case 1:

sound/isa/sc6000.c line 164

Quoted 10 lines
sound/isa/sc6000.c +10 -0
+		val = 2;
+		break;
+	case 3:
+		val = 3;
+		break;
+	default:
+		break;
+	}
+	return val;
+}

Deja vu from sgalaxy...

But also -- please no inlines. There's no point to them. Kernel policy is basically "no inlines other than for things that would definitely be macros if we weren't fond of the typesafety inline functions give". GCC will figure things out on its own...

Quoted 12 lines
sound/isa/sc6000.c +12 -0
+static int __devinit snd_sc6000_detect(int dev, int irq, int dma)
+{
+	int err = -ENODEV;
+
+	snd_printd("Initializing BASE[0x%lx] IRQ[%d] DMA[%d] MIRQ[%d]\n",
+		   port[dev], irq, dma,
+		   mpu_irq[dev] == SND_AUTO_IRQ ? 0 : mpu_irq[dev]);
+
+/*
+ * We must request the port region because these are the I/O
+ * ports to access card's control registers.
+ */

sound/isa/sc6000.c line 412

Quoted 10 lines
sound/isa/sc6000.c +10 -0
+	if (!request_region(port[dev], 0x10, "sc-6000 (base)")) {
+		snd_printk(KERN_ERR
+			   "SC-6000 port I/O port region is already in use.\n");
+		return -EBUSY;
+	}
+
+	err = sc6000_init_board(port[dev], irq, dma,
+				mss_port[dev], mpu_irq[dev]);
+
+	release_region(port[dev], 0x10);

So what happens if now someone starts poking at port[dev]? You probably want to keep these requested no?

Quoted 20 lines
sound/isa/sc6000.c +20 -0
+static int __devinit snd_sc6000_match(struct device *devptr, unsigned int dev)
+{
+	if (!enable[dev])
+		return 0;
+	if (port[dev] == SNDRV_AUTO_PORT) {
+		printk(KERN_ERR PFX "specify IO port\n");
+		return 0;
+	}
+	if (mss_port[dev] == SNDRV_AUTO_PORT) {
+		printk(KERN_ERR PFX "specify MSS port\n");
+		return 0;
+	}
+	if (port[dev] != 0x220 && port[dev] != 0x240) {
+		printk(KERN_ERR PFX "Port must be 0x220 or 0x240\n");
+		return 0;
+	}
+	if (mss_port[dev] != 0x530 && mss_port[dev] != 0xe80) {
+		printk(KERN_ERR PFX "MSS port must be 0x530 or 0xe80\n");
+		return 0;
+	}

sound/isa/sc6000.c line 481

Quoted 10 lines
sound/isa/sc6000.c +10 -0
+	if (irq[dev] != SNDRV_AUTO_IRQ && !sc6000_irq_to_softcfg(irq[dev])) {
+		printk(KERN_ERR PFX "invalid IRQ %d\n", irq[dev]);
+		return 0;
+	}
+	if (dma[dev] != SNDRV_AUTO_DMA && !sc6000_dma_to_softcfg(dma[dev])) {
+		printk(KERN_ERR PFX "invalid DMA %d\n", dma[dev]);
+		return 0;
+	}
+	if (mpu_port[dev] != SNDRV_AUTO_PORT &&
+	    (mpu_port[dev] & ~0x30l) != 0x300) {

Eh, what?

Quoted 6 lines
sound/isa/sc6000.c +6 -0
+		printk(KERN_ERR PFX "invalid MPU-401 port %lx\n",
+			mpu_port[dev]);
+		return 0;
+	}
+	if (mpu_port[dev] != SNDRV_AUTO_PORT &&
+	    mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] != 0 &&

sound/isa/sc6000.c line 497

Quoted 10 lines
sound/isa/sc6000.c +10 -0
+	    !sc6000_mpu_irq_to_softcfg(mpu_irq[dev])) {
+		printk(KERN_ERR PFX "invalid MPU-401 IRQ %d\n", mpu_irq[dev]);
+		return 0;
+	}
+	return 1;
+}
+
+static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev)
+{
+	static int possible_irqs[] = { 7, 9, 10, 11, -1 };

In the above, IRQ 5 also seems to be allowed. This is all rather massive sgalaxy deja-vu...

Rene.

#2 lore raw
Quoted 5 lines · On Wed, 05 Sep 2007 01:04:46 +0200 Rene Herman <[email protected]> wrote:

On 09/04/2007 09:11 PM, Krzysztof Helt wrote:

By the way -- something along the email path to you rejects my messages due to taking an SPF-neutral result from gmail as negative...

I'll contact portal administrators.

Quoted 7 lines

sound/isa/sc6000.c line 37

Quoted 3 lines
sound/isa/sc6000.c +3 -0
+#define SNDRV_LEGACY_FIND_FREE_IRQ
+#define SNDRV_LEGACY_FIND_FREE_DMA
+#include <sound/initval.h>

Personally I rather detest ISA autoprobing, so if you only included it as a "I see that the ALSA thing to do", feel free to try without as far as I'm concerned...

ok.

Quoted 25 lines
Quoted 12 lines
sound/isa/sc6000.c +12 -0
+/*
+ * sc6000_dma_to_softcfg - Decode dma number into cfg code.
+ */
+static inline unsigned char sc6000_dma_to_softcfg(int dma)
+{
+	unsigned char val = 0;
+
+	switch (dma) {
+	case 0:
+		val = 1;
+		break;
+	case 1:

sound/isa/sc6000.c line 164

Quoted 10 lines
sound/isa/sc6000.c +10 -0
+		val = 2;
+		break;
+	case 3:
+		val = 3;
+		break;
+	default:
+		break;
+	}
+	return val;
+}

Deja vu from sgalaxy...

Quoted 5 lines

But also -- please no inlines. There's no point to them. Kernel policy is basically "no inlines other than for things that would definitely be macros if we weren't fond of the typesafety inline functions give". GCC will figure things out on its own...

These things were actually macros in the 2.4 driver.

Quoted 9 lines
Quoted 9 lines
sound/isa/sc6000.c +9 -0
+/*
+ * We must request the port region because these are the I/O
+ * ports to access card's control registers.
+ */
+	if (!request_region(port[dev], 0x10, "sc-6000 (base)")) {
+		snd_printk(KERN_ERR
+			   "SC-6000 port I/O port region is already in use.\n");
+		return -EBUSY;
+	}
Quoted 9 lines

sound/isa/sc6000.c line 412

Quoted 5 lines
sound/isa/sc6000.c +5 -0
+
+	err = sc6000_init_board(port[dev], irq, dma,
+				mss_port[dev], mpu_irq[dev]);
+
+	release_region(port[dev], 0x10);

So what happens if now someone starts poking at port[dev]? You probably want to keep these requested no?

Sgalaxy dejavu.

Quoted 5 lines

sound/isa/sc6000.c line 481

Quoted 2 lines
sound/isa/sc6000.c +2 -0
+	if (mpu_port[dev] != SNDRV_AUTO_PORT &&
+	    (mpu_port[dev] & ~0x30l) != 0x300) {

Eh, what?

Checking if mpu_port[dev] is one 0x3X0 where X is from 0 to 3

Quoted 11 lines
Quoted 11 lines
sound/isa/sc6000.c +11 -0
+		printk(KERN_ERR PFX "invalid MPU-401 port %lx\n",
+			mpu_port[dev]);
+		return 0;
+	}
+	if (mpu_port[dev] != SNDRV_AUTO_PORT &&
+	    mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] != 0 &&
+	    !sc6000_mpu_irq_to_softcfg(mpu_irq[dev])) {
+		printk(KERN_ERR PFX "invalid MPU-401 IRQ %d\n", mpu_irq[dev]);
+		return 0;
+	}
+	return 1;
Quoted 9 lines

sound/isa/sc6000.c line 497

Quoted 5 lines
sound/isa/sc6000.c +5 -0
+}
+
+static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev)
+{
+	static int possible_irqs[] = { 7, 9, 10, 11, -1 };

In the above, IRQ 5 also seems to be allowed. This is all rather massive sgalaxy deja-vu...

Do you think that this card can be handled by sgalaxy driver (with minimal changes to sgalaxy)?

Regards,
Krzysztof

#3 lore raw
Quoted 7 lines · Krzysztof Helt
Quoted 5 lines

But also -- please no inlines. There's no point to them. Kernel policy is basically "no inlines other than for things that would definitely be macros if we weren't fond of the typesafety inline functions give". GCC will figure things out on its own...

These things were actually macros in the 2.4 driver.

Okay, but while I myself don't terribly mind the inline keyword or anything, the kernel as a whole does -- the general meme is "inline is always wrong, unless...", where "unless" includes exceedingly trivial and on a fastpath. Opinions as to the "exceedingly" may vary, but this is one-time setup code, so dropping the inlines is suggested -- otherwise you'd just saddle up the next bunch of kernel janitors with more instances of inline removals ;-)

Quoted 5 lines
Quoted 3 lines

So what happens if now someone starts poking at port[dev]? You probably want to keep these requested no?

Sgalaxy dejavu.

Absolutely. The existing sgalaxy driver blows donkeys. In the replacement driver I have it's kept reserved (in fact, it keeps the entire SB part live, but I may want to revisit that -- I believe some testing is showing that no, the SB and WSS part really cannot be simultaneously active on any model; a forum post somewhere said they could, so I've been trying that)

Quoted 6 lines
Quoted 4 lines

sound/isa/sc6000.c line 481

Quoted 2 lines
sound/isa/sc6000.c +2 -0
+	if (mpu_port[dev] != SNDRV_AUTO_PORT &&
+	    (mpu_port[dev] & ~0x30l) != 0x300) {

Eh, what?

Checking if mpu_port[dev] is one 0x3X0 where X is from 0 to 3

That ain't working. -0x301 = 0xcff and ((foo & 0xcff) != 0x300) for all foo. I'd suggest to simply introduce another one of those switch() helpers for this -- it's again one-time code and it only pays to optimise for readability -- open-source code is read many more times that it's written.

Quoted 6 lines
Quoted 3 lines

In the above, IRQ 5 also seems to be allowed. This is all rather massive sgalaxy deja-vu...

Do you think that this card can be handled by sgalaxy driver (with minimal changes to sgalaxy)?

sgalaxy itself is on its way out as far as I'm concerned, but yes, if you can give me a bit to look at whether or not the sound galaxy driver can be handling this card, great. Generally, I don't have anything against more top-level drivers (as they're mostly just wrappers around lib functionality anyway) though, so if it gets clumsy and/or ugly the seperate driver is fine by me at least.

I'll step up getting snd-galaxy into shape...

Rene.