Subject: About CS4231 sound driver output control
To: None <martin@duskware.de>
From: Sung-Won Chung <swchung7@hotmail.com>
List: tech-kern
Date: 08/23/2002 02:47:51
Hi,

AD1848 driver used by CS4231 driver controls
the output volume with AD1848_DAC_CHANNEL.
For Ultra 1, there are three outputs --- line, built-in
speaker, and headphone.

I think the author of CS4231 intended to make the
built-in the speaker mutable by CSAUDIO_MONITOR_MUTE.
However, CSAUDIO_MONITOR_MUTE doesn't work for the
internal speaker of Ultra 1. I think it is natural
for later revision of cs4231 chip, as indicated in
driver code.

Therefore, to control built-in speaker mutability,
I think there need to be additional parts of mixer,
not to break compatibility with other platforms than Ultra 1.

With the attached fix, 'mixerctl -a -v' will show additionally,

	monitor.master.mute=off  [ off on ].

The built-in speaker can be turned on or off with this.

However, I think, for elaborate implementation, mutability control function
not only for built-in speaker, but also headphone and line output
needs to be implemented.

Welcome to any comments,

Sung-Won


Index: cs4231.c
===================================================================
RCS file: /usr/local/cvsroot/nunbora/src/syssrc/sys/dev/ic/cs4231.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cs4231.c
--- cs4231.c	2002/08/16 14:50:45	1.1.1.1
+++ cs4231.c	2002/08/22 17:19:58
@@ -71,14 +71,15 @@
#define CSAUDIO_CD_MUTE		8
#define CSAUDIO_MONO_MUTE	9
#define CSAUDIO_MONITOR_MUTE	10
-#define CSAUDIO_REC_LVL		11
-#define CSAUDIO_RECORD_SOURCE	12
+#define CSAUDIO_OUT_MUTE	11
+#define CSAUDIO_REC_LVL		12
+#define CSAUDIO_RECORD_SOURCE	13
+
+#define CSAUDIO_INPUT_CLASS	14
+#define CSAUDIO_OUTPUT_CLASS	15
+#define CSAUDIO_RECORD_CLASS	16
+#define CSAUDIO_MONITOR_CLASS	17

-#define CSAUDIO_INPUT_CLASS	13
-#define CSAUDIO_OUTPUT_CLASS	14
-#define CSAUDIO_RECORD_CLASS	15
-#define CSAUDIO_MONITOR_CLASS	16
-
#ifdef AUDIO_DEBUG
int     cs4231_debug = 0;
#define DPRINTF(x)      if (cs4231_debug) printf x
@@ -442,6 +443,7 @@
	{ CSAUDIO_MONO_MUTE, AD1848_KIND_MUTE, AD1848_MONO_CHANNEL },
	{ CSAUDIO_CD_MUTE, AD1848_KIND_MUTE, AD1848_AUX2_CHANNEL },
	{ CSAUDIO_MONITOR_MUTE, AD1848_KIND_MUTE, AD1848_MONITOR_CHANNEL },
+	{ CSAUDIO_OUT_MUTE, AD1848_KIND_MUTE, AD1848_OUT_CHANNEL },
	{ CSAUDIO_REC_LVL, AD1848_KIND_RECORDGAIN, -1 },
	{ CSAUDIO_RECORD_SOURCE, AD1848_KIND_RECORDSOURCE, -1 }
};
@@ -541,8 +543,9 @@
	case CSAUDIO_OUT_LVL:		/* cs4231 output volume: not useful? */
		dip->type = AUDIO_MIXER_VALUE;
		dip->mixer_class = CSAUDIO_MONITOR_CLASS;
-		dip->prev = dip->next = AUDIO_MIXER_LAST;
-		strcpy(dip->label.name, AudioNoutput);
+		dip->next = CSAUDIO_OUT_MUTE;
+		dip->prev = AUDIO_MIXER_LAST;
+		strcpy(dip->label.name, AudioNmaster);
		dip->un.v.num_channels = 2;
		strcpy(dip->un.v.units.name, AudioNvolume);
		break;
@@ -579,6 +582,13 @@
		dip->mixer_class = CSAUDIO_MONITOR_CLASS;
		dip->type = AUDIO_MIXER_ENUM;
		dip->prev = CSAUDIO_MONITOR_LVL;
+		dip->next = AUDIO_MIXER_LAST;
+		goto mute;
+
+	case CSAUDIO_OUT_MUTE: /* mute built-in speaker */
+		dip->mixer_class = CSAUDIO_MONITOR_CLASS;
+		dip->type = AUDIO_MIXER_ENUM;
+		dip->prev = CSAUDIO_OUT_LVL;
		dip->next = AUDIO_MIXER_LAST;
	mute:
		strcpy(dip->label.name, AudioNmute);
Index: ad1848.c
===================================================================
RCS file: /usr/local/cvsroot/nunbora/src/syssrc/sys/dev/ic/ad1848.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ad1848.c
--- ad1848.c	2002/08/16 14:50:41	1.1.1.1
+++ ad1848.c	2002/08/22 17:19:58
@@ -464,6 +464,7 @@
   { CS_LEFT_LINE_CONTROL, CS_RIGHT_LINE_CONTROL, LINE_INPUT_ATTEN_BITS,
     LINE_INPUT_ATTEN_MASK },
   { CS_MONO_IO_CONTROL, 0, MONO_INPUT_ATTEN_BITS, MONO_INPUT_ATTEN_MASK },
+  { CS_MONO_IO_CONTROL, 0, 0, 0 },
   { SP_DIGITAL_MIX, 0, OUTPUT_ATTEN_BITS, MIX_ATTEN_MASK }
};

@@ -490,8 +491,11 @@
				ad1848_mute_wave_output(sc, WAVE_UNMUTE1, 0);
			ad_write(sc, mixer_channel_info[device].left_reg,
				 reg & ~DIGITAL_MIX1_ENABLE);
-		} else
+		} else if (device == AD1848_OUT_CHANNEL)
			ad_write(sc, mixer_channel_info[device].left_reg,
+				 reg | MONO_OUTPUT_MUTE);
+		else
+			ad_write(sc, mixer_channel_info[device].left_reg,
				 reg | 0x80);
	} else if (!(sc->mute[device] & MUTE_LEFT)) {
		if (device == AD1848_MONITOR_CHANNEL) {
@@ -499,7 +503,10 @@
				 reg | DIGITAL_MIX1_ENABLE);
			if (sc->open_mode & FREAD)
				ad1848_mute_wave_output(sc, WAVE_UNMUTE1, 1);
-		} else
+		} else if (device == AD1848_OUT_CHANNEL)
+			ad_write(sc, mixer_channel_info[device].left_reg,
+				 reg & ~MONO_OUTPUT_MUTE);
+		else
			ad_write(sc, mixer_channel_info[device].left_reg,
				 reg & ~0x80);
	}
Index: ad1848var.h
===================================================================
RCS file: /usr/local/cvsroot/nunbora/src/syssrc/sys/dev/ic/ad1848var.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ad1848var.h
--- ad1848var.h	2002/08/16 14:50:41	1.1.1.1
+++ ad1848var.h	2002/08/22 17:19:58
@@ -134,7 +134,8 @@
#define AD1848_DAC_CHANNEL	2
#define AD1848_LINE_CHANNEL	3
#define AD1848_MONO_CHANNEL	4
-#define AD1848_MONITOR_CHANNEL	5 /* Doesn't seem to be on all later chips 
*/
+#define AD1848_OUT_CHANNEL	5
+#define AD1848_MONITOR_CHANNEL	6 /* Doesn't seem to be on all later chips 
*/

/*
  * Ad1848 registers.



_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com