Skip to contentSkip to conversation

Volume and mute buttons on PowerBook G3

PATCH Alvin Brattli 1 participant 1 message Mar 4, 1999 Sound

lore
Share & tools
lore
#0 lore raw

Below, you will find a patch that adds support for the volume and mute buttons on the PowerBook G3 series. A pre-compiled kernel can be found
here: <ftp://xenu.phys.uit.no/pub/vmlinux-2.2.1>. The kernel was built using the 2.2.1 .config from samba, and should work with these modules. Can people test it, and report problems and general feedback to me?

The patch implements the following:

Pressing the mute button toggles the muting of the internal speakers on the PowerBook G3. Changing the volume via xmixer, kmix, etc. does not unmute the speakers, as this implementation gives precedence to the user's choice of muting via the button. However, the volume *can* be changed this way, but this does not go into effect until the speakers are unmuted again.

The volume buttons work as expected; they change the speaker volume. If the speakers are muted, they will be unmuted, and the volume will be increased/decreased from the level set before muting (or from the level set by xmixer/kmix while muted).

Pressing shift-mute or shift-volume up/down does the same thing with the headphones.

The patch (relative to 2.2.1 from samba):

macintosh/mac_keyb.c renamed from macintosh/mac_keyb.c.orig +18 -2
@@ -243,6 +243,9 @@
 
 static int adb_mouse_kinds[16];
 
+/* code in buttons_input() needs to know if shift key is down */
+static int shift_down;
+
 struct mackbd_state {
 	int	adb_id;
 	void	*kbd_id;
@@ -326,6 +329,10 @@
 	if (keycode == 0x3f)
 		keycode = 0x48;
 
+	/* code in buttons_input() needs to know if shift key is down */
+	shift_down  = !up_flag && (keycode == 0x38 || keycode == 0x7b);
+
+
 #ifdef CONFIG_ADBMOUSE
 	/*
 	 * XXX: Add mouse button 2+3 fake codes here if mouse open.
@@ -517,6 +524,9 @@
 /* XXX Needs to get rid of this, see comments in pmu.c */
 extern int backlight_level;
 
+extern int pmac_togglemute(int);
+extern int pmac_addto_volume(int, int);
+
 static void
 buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll)
 {
@@ -535,18 +545,24 @@
 		case 0x8:
 			/* down event */
 			if ( data[1] == (data[1]&0xf) ) {
+				if (pmu_get_model() == PMU_HEATHROW_BASED)
+					pmac_togglemute(shift_down? 2:4);
 			}
 			break;
-		/* contrast decrease */
+		/* contrast decrease (volume decrease on PB G3) */
 		case 0x7:
 			/* down event */
 			if ( data[1] == (data[1]&0xf) ) {
+				if (pmu_get_model() == PMU_HEATHROW_BASED)
+					pmac_addto_volume(shift_down? 2:4, -7);
 			}
 			break;
-		/* contrast increase */
+		/* contrast increase (volume increase on PB G3) */
 		case 0x6:
 			/* down event */
 			if ( data[1] == (data[1]&0xf) ) {
+				if (pmu_get_model() == PMU_HEATHROW_BASED)
+					pmac_addto_volume(shift_down? 2:4, 7);
 			}
 			break;
 		/* brightness decrease */
sound/dmasound.c renamed from sound/dmasound.c.orig +58 -0

76 lines not on this page · raw message

aLViN

Signature · 6 lines
:r .signature

[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to  Cc linuxppc-dev  if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to [email protected] ]]