changeset 9965:e5142f0d02b1

6851831 WARNING messages on console concerning audiocs during boot
author Garrett D'Amore <gdamore@opensolaris.org>
date Wed, 24 Jun 2009 18:18:47 -0700
parents a4f88c4f7496
children d4ba9662e3c8
files usr/src/uts/sun/io/audio/drv/audiocs/audio_4231.c
diffstat 1 files changed, 26 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/sun/io/audio/drv/audiocs/audio_4231.c	Thu Jun 25 09:13:42 2009 +0800
+++ b/usr/src/uts/sun/io/audio/drv/audiocs/audio_4231.c	Wed Jun 24 18:18:47 2009 -0700
@@ -549,8 +549,11 @@
 		goto error;
 	}
 
+	mutex_enter(&state->cs_lock);
+
 	/* initialize the audio chip */
 	if ((audiocs_chip_init(state)) == DDI_FAILURE) {
+		mutex_exit(&state->cs_lock);
 		audio_dev_warn(adev, "chip_init() failed");
 		goto error;
 	}
@@ -566,8 +569,10 @@
 
 	/* we're ready, set up the interrupt handler */
 	if (CS4231_DMA_ADD_INTR(state) != DDI_SUCCESS) {
+		mutex_exit(&state->cs_lock);
 		goto error;
 	}
+	mutex_exit(&state->cs_lock);
 
 	/* finally register with framework to kick everything off */
 	if (audio_dev_register(state->cs_adev) != DDI_SUCCESS) {
@@ -617,20 +622,18 @@
 	audiocs_power_up(state);
 	state->cs_powered = B_TRUE;
 
+	mutex_enter(&state->cs_lock);
+
 	/* initialize the audio chip */
 	if ((audiocs_chip_init(state)) == DDI_FAILURE) {
+		mutex_exit(&state->cs_lock);
 		audio_dev_warn(adev, "chip_init() failed");
 		(void) pm_idle_component(state->cs_dip, CS4231_COMPONENT);
 		return (DDI_FAILURE);
 	}
 
-	mutex_enter(&state->cs_lock);
 	state->cs_suspended = B_FALSE;
 
-	/* restore mixer settings */
-	audiocs_configure_output(state);
-	audiocs_configure_input(state);
-
 	for (int i = CS4231_PLAY; i <= CS4231_REC; i++) {
 		CS_engine_t	*eng = state->cs_engines[i];
 
@@ -904,13 +907,9 @@
 	    (1U << OUTPUT_SPEAKER));
 	ADD_CTRL(inputs, CTL_INPUTS, (1U << INPUT_MIC));
 
-	mutex_enter(&state->cs_lock);
-	audiocs_configure_output(state);
-	audiocs_configure_input(state);
-	mutex_exit(&state->cs_lock);
-
 	return (DDI_SUCCESS);
 }
+
 /*
  * audiocs_del_controls
  *
@@ -956,6 +955,11 @@
 
 	CS4231_DMA_RESET(state);
 
+	/* wait for the Codec before we continue */
+	if (audiocs_poll_ready(state) == DDI_FAILURE) {
+		return (DDI_FAILURE);
+	}
+
 	/* activate registers 16 -> 31 */
 	SELIDX(state, MID_REG);
 	ddi_put8(handle, &CS4231_IDR, MID_MODE2);
@@ -993,10 +997,15 @@
 	/* program the sample rate, play and capture must be the same */
 	SELIDX(state, FSDF_REG | IAR_MCE);
 	PUTIDX(state, FS_48000 | PDF_LINEAR16NE | PDF_STEREO, FSDF_VALID_MASK);
-	SELIDX(state, FSDF_REG);
+	if (audiocs_poll_ready(state) == DDI_FAILURE) {
+		return (DDI_FAILURE);
+	}
+
 	SELIDX(state, CDF_REG | IAR_MCE);
 	PUTIDX(state, CDF_LINEAR16NE | CDF_STEREO, CDF_VALID_MASK);
-	SELIDX(state, CDF_REG);
+	if (audiocs_poll_ready(state) == DDI_FAILURE) {
+		return (DDI_FAILURE);
+	}
 
 	/*
 	 * Set up the Codec for playback and capture disabled, dual DMA, and
@@ -1004,11 +1013,6 @@
 	 */
 	SELIDX(state, (INTC_REG | IAR_MCE));
 	PUTIDX(state, INTC_DDC | INTC_PDMA | INTC_CDMA, INTC_VALID_MASK);
-
-	/* turn off the MCE bit */
-	SELIDX(state, LADCI_REG);
-
-	/* wait for the Codec before we continue XXX - do we need this? */
 	if (audiocs_poll_ready(state) == DDI_FAILURE) {
 		return (DDI_FAILURE);
 	}
@@ -1044,13 +1048,8 @@
 	SELIDX(state, MIOC_REG);
 	PUTIDX(state, MIOC_MIM, MIOC_VALID_MASK);
 
-	/* clear the mode change bit */
-	SELIDX(state, RDACO_REG);
-
-	/* wait for the Codec before we continue XXX - do we need this? */
-	if (audiocs_poll_ready(state) == DDI_FAILURE) {
-		return (DDI_FAILURE);
-	}
+	audiocs_configure_output(state);
+	audiocs_configure_input(state);
 
 	return (DDI_SUCCESS);
 }
@@ -1296,6 +1295,8 @@
 	/* reset the DMA engine(s) */
 	CS4231_DMA_RESET(state);
 
+	(void) audiocs_poll_ready(state);
+
 	/*
 	 * Reload the Codec's registers, the DMA engines will be
 	 * taken care of when play and record start up again. But
@@ -1308,7 +1309,7 @@
 		/* restore Codec registers */
 		SELIDX(state, (i | IAR_MCE));
 		ddi_put8(handle, &CS4231_IDR, state->cs_save[i]);
-		drv_usecwait(500);	/* chip bug */
+		(void) audiocs_poll_ready(state);
 	}
 	/* clear MCE bit */
 	SELIDX(state, 0);
@@ -1985,9 +1986,6 @@
 	PUTIDX(state, value, mask);
 
 	(void) audiocs_poll_ready(state);
-
-	/* clear the mode change bit */
-	SELIDX(state, reg);
 }
 
 /*