PATCH for OPL3-SA2/x: enable recording & 3d-effects

Peter Englmaier (ppe@mpe.mpg.de)
Wed, 29 Dec 1999 16:28:37 +0100


Dear Scott,

sound recording never worked with my yamaha opl3-sax (or sa2 ?) build into
my laptop (a winbook XL). I always got:
kernel: Sound: DMA (input) timed out - IRQ/DRQ config error?

Recently I found a posting in the kernel-list concerning
the OPL3-SA3 chip. The post mentioned the YMF715E documentation
available from the Yamaha Website. I checked this out and found
how to enable the sound recording and, since I was already
at it, added a parameter to change the 3d-mode. The sound recording
was not working, because the DMA was not allocated to the wss. This is
puzzling, because the manual states that it should be allocated by
default. Anyway, a single outb command fixed this (back to default).

The 3d-mode can now be selected with an argument for the opl3sa2
module: ymode. It can be set to any value between 0 and 3. A value of
-1 indicates that the ymode should *not* be set (default).

Cheers, Peter.

(please 'cc' to ppe@mpe.mpg.de if possible)

Patch against drivers/sound/opl3sa2.c, version included in kernel 2.2.13

--- opl3sa2.c-orig Tue Aug 10 23:56:18 1999
+++ opl3sa2.c Wed Dec 29 16:11:11 1999
@@ -32,6 +32,7 @@
* Scott Murray Simpler detection code should work all the time now
* (with thanks to Ben Hutchings for the heuristic),
* removed now unnecessary force option. (Jan 5, 1999)
+ * Peter Englmaier Fixed DMA allocation and added ymode (Dec 29, 1999)
*
*/

@@ -42,6 +43,8 @@
#include "soundmodule.h"

/* Useful control port indexes: */
+#define OPL3SA2_SYS_CONTROL 0x02
+#define OPL3SA2_DMA_CONFIG 0x06
#define OPL3SA2_MASTER_LEFT 0x07
#define OPL3SA2_MASTER_RIGHT 0x08
#define OPL3SA2_MIC 0x09
@@ -628,6 +631,7 @@
int irq = -1;
int dma = -1;
int dma2 = -1;
+int ymode = -1;

MODULE_PARM(io, "i");
MODULE_PARM_DESC(io, "Set i/o base of OPL3-SA2 or SA3 card (usually 0x370)");
@@ -647,6 +651,9 @@
MODULE_PARM(dma2, "i");
MODULE_PARM_DESC(dma2, "Set MSS (audio) second DMA channel (0, 1, 3)");

+MODULE_PARM(ymode, "i");
+MODULE_PARM_DESC(ymode, "Yamaha 3D enhancement mode (-1=off, 0=normal, 1=notebook pc (1) , 2=notebook pc (2), 3=`Hi-Fi' mode)");
+
MODULE_DESCRIPTION("Module for OPL3-SA2 and SA3 sound cards (uses AD1848 MSS driver).");
MODULE_AUTHOR("Scott Murray <scottm@interlog.com>");

@@ -665,6 +672,7 @@
int init_module(void)
{
int i;
+ unsigned char reg;

if(io == -1 || irq == -1 || dma == -1 || dma2 == -1 || mss_io == -1)
{
@@ -721,6 +729,20 @@
}
}
#endif
+
+ /* enforce default dma configuration: */
+ /* DMA-B: SB & WSS-R, DMA-A: WSS-P */
+ opl3sa2_write(devc->cfg_port, OPL3SA2_DMA_CONFIG, 0x61);
+
+ /* set YAMAHA 3D enhancement mode
+ * ymode=0: desktop, 1: notebook PC mode 1, 2: notebook PC mode 2,
+ * ymode=3: hi-fi
+ */
+ if (ymode != -1) {
+ opl3sa2_read(devc->cfg_port, OPL3SA2_SYS_CONTROL, &reg);
+ reg = (reg & 0xcf) | ((ymode&3)<<4);
+ opl3sa2_write(devc->cfg_port, OPL3SA2_SYS_CONTROL, reg);
+ }
SOUND_LOCK;
return 0;
}

----
Peter Englmaier, email: ppe@mpe.mpg.de
MPI f. extraterrestrische Physik, phone: +49 (89) 3299-3279
Postfach 1603, home: +49 (89) 2866-8653
D-85740 Garching, Germany fax: +49 (89) 3299-3390

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/