patch-2.2.12 linux/drivers/sound/dmasound.c

Next file: linux/drivers/sound/esssolo1.c
Previous file: linux/drivers/sound/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.11/linux/drivers/sound/dmasound.c linux/drivers/sound/dmasound.c
@@ -242,6 +242,9 @@
 static short *beep_buf;
 static volatile struct dbdma_cmd *beep_dbdma_cmd;
 static void (*orig_mksound)(unsigned int, unsigned int);
+static int is_pbook_3400;
+static int is_pbook_G3;
+static unsigned char *macio_base;
 
 /* Burgundy functions */
 static void awacs_burgundy_wcw(unsigned addr,unsigned newval);
@@ -255,9 +258,9 @@
 /*
  * Stuff for restoring after a sleep.
  */
-static int awacs_sleep_notify(struct notifier_block *, unsigned long, void *);
-struct notifier_block awacs_sleep_notifier = {
-	awacs_sleep_notify
+static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when);
+struct pmu_sleep_notifier awacs_sleep_notifier = {
+	awacs_sleep_notify, SLEEP_LEVEL_SOUND,
 };
 #endif /* CONFIG_PMAC_PBOOK */
 
@@ -3020,7 +3023,7 @@
 		kfree(beep_buf);
 	kd_mksound = orig_mksound;
 #ifdef CONFIG_PMAC_PBOOK
-	notifier_chain_unregister(&sleep_notifier_list, &awacs_sleep_notifier);
+	pmu_unregister_sleep_notifier(&awacs_sleep_notifier);
 #endif
 }
 #endif /* MODULE */
@@ -3342,14 +3345,15 @@
 /*
  * Save state when going to sleep, restore it afterwards.
  */
-static int awacs_sleep_notify(struct notifier_block *this,
-			      unsigned long code, void *x)
+static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
 {
-	switch (code) {
-	case PBOOK_SLEEP:
+	switch (when) {
+	case PBOOK_SLEEP_NOW:
 		/* XXX we should stop any dma in progress when going to sleep
 		   and restart it when we wake. */
 		PMacSilence();
+		disable_irq(awacs_irq);
+		disable_irq(awacs_tx_irq);
 		break;
 	case PBOOK_WAKE:
 		out_le32(&awacs->control, MASK_IEPC
@@ -3360,8 +3364,10 @@
 		awacs_write(awacs_reg[2] | MASK_ADDR2);
 		awacs_write(awacs_reg[4] | MASK_ADDR4);
 		out_le32(&awacs->byteswap, sound.hard.format != AFMT_S16_BE);
+		enable_irq(awacs_irq);
+		enable_irq(awacs_tx_irq);
 	}
-	return NOTIFY_DONE;
+	return PBOOK_SLEEP_OK;
 }
 #endif /* CONFIG_PMAC_PBOOK */
 
@@ -3983,7 +3989,8 @@
 
 #ifdef CONFIG_PPC
 	case DMASND_AWACS:
-		if (awacs_revision<AWACS_BURGUNDY) { /* Different IOCTLS for burgundy*/
+		/* Different IOCTLS for burgundy*/
+		if (awacs_revision < AWACS_BURGUNDY) {
 			switch (cmd) {
 			case SOUND_MIXER_INFO: {
 			    mixer_info info;
@@ -4999,9 +5006,33 @@
 			printk(KERN_WARNING "dmasound: no memory for "
 			       "beep buffer\n");
 #ifdef CONFIG_PMAC_PBOOK
-		notifier_chain_register(&sleep_notifier_list,
-					&awacs_sleep_notifier);
+		pmu_register_sleep_notifier(&awacs_sleep_notifier);
 #endif /* CONFIG_PMAC_PBOOK */
+
+		/* Powerbooks have odd ways of enabling inputs such as
+		   an expansion-bay CD or sound from an internal modem
+		   or a PC-card modem. */
+		if (machine_is_compatible("AAPL,3400/2400")) {
+			is_pbook_3400 = 1;
+			/*
+			 * Enable CD and PC-card sound inputs.
+			 * This is done by reading from address
+			 * f301a000, + 0x10 to enable the expansion-bay
+			 * CD sound input, + 0x80 to enable the PC-card
+			 * sound input.  The 0x100 seems to enable the
+			 * MESH and/or its SCSI bus drivers.
+			 */
+			in_8((unsigned char *)0xf301a190);
+		} else if (machine_is_compatible("PowerBook1,1")) {
+			np = find_devices("mac-io");
+			if (np && np->n_addrs > 0) {
+				is_pbook_G3 = 1;
+				macio_base = (unsigned char *)
+					ioremap(np->addrs[0].address, 0x40);
+				/* enable CD sound input */
+				out_8(macio_base + 0x37, 3);
+			}
+		}
 	}
 #endif /* CONFIG_PPC */
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)