audio(9) has two different methods for managing DMA transfers. the
original method is essentially a callback that gives the low level
driver the current kernel audio buffer position and block size
when each block is to be moved. the newer (well, at least 12 yrs
old) method just gives the low level driver the blocksize and
kernel audio buffer start and end addresses when DMA is started.
the old method is useful in some circumstances, but is unnecessary
for most devices. the drivers that use the AD1848 DMA engine
directly do not need to use the older method, but they were never
changed to the new method (in OpenBSD, NetBSD did change them 11
years ago).
so, this diff changes the ad1848 ISA drivers to use the newer method.
the CS4231 is very similar to the AD1848, and the CS4231 is also
supported by these drivers. the biggest difference is that the
AD1848 only supports a single DMA channel, while the CS4231 supports
two DMA channels. this means the AD1848 is not capable of full-
duplex but the CS4231 is. single channel DMA operations is referred
to as Mode 1 and two channel DMA operation is referred to as
Mode 2. currently, CS4231 chips are forced into Mode 2, even if
there is only one DMA channel available. this makes recording
not work if there is only one DMA channel available. so I also
made it so CS4231 can be used in Mode 1, and both playback and
recording work. and in mode 2, full-duplex currently doesn't work
because of a couple reasons, but mainly because only one of the
capture or playback (instead of both) interrupt callbacks gets
called. this diff fixes full-duplex mode for Mode 2 capable
devices as well. but, there is a bandwidth limit. for full-duplex
to work, you need to use either 8-bit samples, mono, or a sample
rate = 24000.
and finally, the AD1848 and CS4231 recalibrate their sample clock
after mode changes. the tests to check if calibration has ended are
currently wrong, causing busy loops in the driver. when starting
audio playback, my machine is noticibly stuck for a second or two.
this diff fixes that issue as well.
what I'm mostly looking for are tests that this doesn't break any
current setup. I imagine these devices probably aren't used much
these days, but maybe I'm wrong.
--
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Index: ic/cs4231reg.h
===
RCS file: /cvs/src/sys/dev/ic/cs4231reg.h,v
retrieving revision 1.6
diff -u -p ic/cs4231reg.h
--- ic/cs4231reg.h 26 Jun 2008 05:42:15 - 1.6
+++ ic/cs4231reg.h 3 Jun 2010 07:42:30 -
@@ -77,26 +77,32 @@
#define CS_ALT_FEATURE20x11
#define CS_LEFT_LINE_CONTROL 0x12
#define CS_RIGHT_LINE_CONTROL 0x13
+#defineLINE_INPUT_ATTEN_BITS 0x1f
+#defineLINE_INPUT_ATTEN_MASK 0xe0
+#defineLINE_INPUT_MUTE 0x80
+#defineLINE_INPUT_MUTE_MASK0x7f
#define CS_TIMER_LOW 0x14
#define CS_TIMER_HIGH 0x15
#define CS_UPPER_FREQUENCY_SEL 0x16
#define CS_LOWER_FREQUENCY_SEL 0x17
#define CS_IRQ_STATUS 0x18
+#defineCS_IRQ_PU 0x01/* Playback Underrun */
+#defineCS_IRQ_PO 0x02/* Playback Overrun */
+#defineCS_IRQ_CO 0x04/* Capture Overrrun */
+#defineCS_IRQ_CU 0x08/* Capture Underrun */
+#defineCS_IRQ_PI 0x10/* Playback Interrupt */
+#defineCS_IRQ_CI 0x20/* Capture Interrupt */
+#defineCS_IRQ_TI 0x40/* Timer Interrupt */
+#defineCS_IRQ_RES 0x80/* reserved */
#define CS_VERSION_ID 0x19
#define CS_MONO_IO_CONTROL 0x1A
+#defineMONO_INPUT_ATTEN_BITS 0x0f
+#defineMONO_INPUT_ATTEN_MASK 0xf0
+#defineMONO_OUTPUT_MUTE0x40
+#defineMONO_INPUT_MUTE 0x80
+#defineMONO_INPUT_MUTE_MASK0x7f
#define CS_POWERDOWN_CONTROL 0x1B
#define CS_REC_FORMAT 0x1C
#define CS_XTAL_SELECT 0x1D
#define CS_UPPER_REC_CNT 0x1E
#define CS_LOWER_REC_CNT 0x1F
-
-#define MONO_INPUT_ATTEN_BITS 0x0f
-#define MONO_INPUT_ATTEN_MASK 0xf0
-#define MONO_OUTPUT_MUTE 0x40
-#define MONO_INPUT_MUTE0x80
-#define MONO_INPUT_MUTE_MASK 0x7f
-
-#define LINE_INPUT_ATTEN_BITS 0x1f
-#define LINE_INPUT_ATTEN_MASK 0xe0
-#define LINE_INPUT_MUTE0x80
-#define LINE_INPUT_MUTE_MASK 0x7f
Index: isa/ad1848.c
===
RCS file: /cvs/src/sys/dev/isa/ad1848.c,v
retrieving revision 1.33
diff -u -p isa/ad1848.c
--- isa/ad1848.c5 Nov 2007 00:17:28 - 1.33
+++ isa/ad1848.c3 Jun 2010 07:42:30 -
@@ -92,9 +92,11 @@
#include