Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

PMIC_STATUS pmic_audio_reset_all ( void   ) 

Reset all audio hardware control registers to their power on state.

This resets all of the audio hardware control registers back to their power on states. Use this function with care since it also invalidates (i.e., automatically closes) all currently opened device handles.

Return values:
PMIC_SUCCESS If the reset operation was successful.
PMIC_ERROR If the reset was unsuccessful.

Definition at line 1438 of file pmic_audio.c.

References PMIC_MICROPHONE_STATE::ampMode, PMIC_AUDIO_AUDIO_OUTPUT_STATE::balanceLeftGain, PMIC_AUDIO_AUDIO_OUTPUT_STATE::balanceRightGain, PMIC_AUDIO_VCODEC_STATE::busID, PMIC_AUDIO_STDAC_STATE::busID, PMIC_AUDIO_VCODEC_STATE::clockFreq, PMIC_AUDIO_STDAC_STATE::clockFreq, PMIC_AUDIO_VCODEC_STATE::clockIn, PMIC_AUDIO_STDAC_STATE::clockIn, PMIC_AUDIO_AUDIO_OUTPUT_STATE::config, PMIC_AUDIO_VCODEC_STATE::config, PMIC_AUDIO_STDAC_STATE::config, PMIC_AUDIO_AUDIO_OUTPUT_STATE::extStereooutputPGAGain, PMIC_MICROPHONE_STATE::gain, PMIC_AUDIO_EXT_STEREO_IN_STATE::handle, PMIC_AUDIO_VCODEC_STATE::handle, PMIC_AUDIO_STDAC_STATE::handle, PMIC_AUDIO_VCODEC_STATE::invert, PMIC_AUDIO_STDAC_STATE::invert, PMIC_AUDIO_VCODEC_STATE::leftChannelMic, PMIC_AUDIO_VCODEC_STATE::masterSlave, PMIC_AUDIO_STDAC_STATE::masterSlave, PMIC_MICROPHONE_STATE::mic, PMIC_MICROPHONE_STATE::micOnOff, PMIC_AUDIO_AUDIO_OUTPUT_STATE::monoAdderGain, NO_HEADSET, PMIC_AUDIO_VCODEC_STATE::numSlots, PMIC_AUDIO_STDAC_STATE::numSlots, PMIC_AUDIO_AUDIO_OUTPUT_STATE::outputPort, pmic_audio_close_handle(), pmic_write_reg(), PMIC_AUDIO_VCODEC_STATE::protocol, PMIC_AUDIO_STDAC_STATE::protocol, PMIC_AUDIO_VCODEC_STATE::protocol_set, PMIC_AUDIO_STDAC_STATE::protocol_set, RESET_AUD_CODEC, RESET_AUDIO_RX_0, RESET_AUDIO_RX_1, RESET_AUDIO_TX, RESET_SSI_NETWORK, RESET_ST_DAC, PMIC_AUDIO_VCODEC_STATE::rightChannelMic, PMIC_AUDIO_VCODEC_STATE::samplingRate, PMIC_AUDIO_STDAC_STATE::samplingRate, PMIC_AUDIO_AUDIO_OUTPUT_STATE::stDacoutputPGAGain, PMIC_AUDIO_VCODEC_STATE::timeslot, PMIC_AUDIO_STDAC_STATE::timeslot, VCODEC_DIRECT_OUT, PMIC_AUDIO_AUDIO_OUTPUT_STATE::vCodecOut, and PMIC_AUDIO_AUDIO_OUTPUT_STATE::vCodecoutputPGAGain.

{
      PMIC_STATUS rc = PMIC_SUCCESS;
      unsigned int audio_ssi_reset = 0;
      unsigned int audio_rx1_reset = 0;
      /* We need a critical section here to maintain a consistent state. */
      if (down_interruptible(&mutex))
            return PMIC_SYSTEM_ERROR_EINTR;

      /* First close all opened device handles, also deregisters callbacks. */
      pmic_audio_close_handle(stDAC.handle);
      pmic_audio_close_handle(vCodec.handle);
      pmic_audio_close_handle(extStereoIn.handle);

      if (pmic_write_reg(REG_AUDIO_RX_1, RESET_AUDIO_RX_1,
                     PMIC_ALL_BITS) != PMIC_SUCCESS) {
            rc = PMIC_ERROR;
      } else {
            audio_rx1_reset = 1;
      }
      if (pmic_write_reg(REG_AUDIO_SSI_NETWORK, RESET_SSI_NETWORK,
                     PMIC_ALL_BITS) != PMIC_SUCCESS) {
            rc = PMIC_ERROR;
      } else {
            audio_ssi_reset = 1;
      }
      if (pmic_write_reg
          (REG_AUDIO_STEREO_DAC, RESET_ST_DAC,
           PMIC_ALL_BITS) != PMIC_SUCCESS) {
            rc = PMIC_ERROR;
      } else {
            /* Also reset the driver state information to match. Note that we
             * keep the device handle and event callback settings unchanged
             * since these don't affect the actual hardware and we rely on
             * the user to explicitly close the handle or deregister callbacks
             */
            if (audio_ssi_reset) {
                  /* better to check if SSI is also reset as some fields are represennted in SSI reg */
                  stDAC.busID = AUDIO_DATA_BUS_1;
                  stDAC.protocol = NORMAL_MSB_JUSTIFIED_MODE;
                  stDAC.masterSlave = BUS_MASTER_MODE;
                  stDAC.protocol_set = false;
                  stDAC.numSlots = USE_2_TIMESLOTS;
                  stDAC.clockIn = CLOCK_IN_CLIA;
                  stDAC.samplingRate = STDAC_RATE_44_1_KHZ;
                  stDAC.clockFreq = STDAC_CLI_13MHZ;
                  stDAC.invert = NO_INVERT;
                  stDAC.timeslot = USE_TS0_TS1;
                  stDAC.config = (PMIC_AUDIO_STDAC_CONFIG) 0;
            }
      }

      if (pmic_write_reg(REG_AUDIO_CODEC, RESET_AUD_CODEC,
                     PMIC_ALL_BITS) != PMIC_SUCCESS) {
            rc = PMIC_ERROR;
      } else {
            /* Also reset the driver state information to match. Note that we
             * keep the device handle and event callback settings unchanged
             * since these don't affect the actual hardware and we rely on
             * the user to explicitly close the handle or deregister callbacks
             */
            if (audio_ssi_reset) {
                  vCodec.busID = AUDIO_DATA_BUS_2;
                  vCodec.protocol = NETWORK_MODE;
                  vCodec.masterSlave = BUS_SLAVE_MODE;
                  vCodec.protocol_set = false;
                  vCodec.numSlots = USE_4_TIMESLOTS;
                  vCodec.clockIn = CLOCK_IN_CLIB;
                  vCodec.samplingRate = VCODEC_RATE_8_KHZ;
                  vCodec.clockFreq = VCODEC_CLI_13MHZ;
                  vCodec.invert = NO_INVERT;
                  vCodec.timeslot = USE_TS0;
                  vCodec.config =
                      INPUT_HIGHPASS_FILTER | OUTPUT_HIGHPASS_FILTER;
            }
      }

      if (pmic_write_reg(REG_AUDIO_RX_0, RESET_AUDIO_RX_0,
                     PMIC_ALL_BITS) != PMIC_SUCCESS) {
            rc = PMIC_ERROR;
      } else {
            /* Also reset the driver state information to match. */
            audioOutput.outputPort = (PMIC_AUDIO_OUTPUT_PORT) NULL;
            audioOutput.vCodecoutputPGAGain = OUTPGA_GAIN_0DB;
            audioOutput.stDacoutputPGAGain = OUTPGA_GAIN_0DB;
            audioOutput.extStereooutputPGAGain = OUTPGA_GAIN_0DB;
            audioOutput.balanceLeftGain = BAL_GAIN_0DB;
            audioOutput.balanceRightGain = BAL_GAIN_0DB;
            audioOutput.monoAdderGain = MONOADD_GAIN_0DB;
            audioOutput.config = (PMIC_AUDIO_OUTPUT_CONFIG) 0;
            audioOutput.vCodecOut = VCODEC_DIRECT_OUT;
      }

      if (pmic_write_reg(REG_AUDIO_TX, RESET_AUDIO_TX,
                     PMIC_ALL_BITS) != PMIC_SUCCESS) {
            rc = PMIC_ERROR;
      } else {
            /* Also reset the driver state information to match. Note that we
             * reset the vCodec fields since all of the input/recording
             * devices are only connected to the Voice CODEC and are managed
             * as part of the Voice CODEC state.
             */
            if (audio_rx1_reset) {
                  vCodec.leftChannelMic.mic = NO_MIC;
                  vCodec.leftChannelMic.micOnOff = MICROPHONE_OFF;
                  vCodec.leftChannelMic.ampMode = CURRENT_TO_VOLTAGE;
                  vCodec.leftChannelMic.gain = MIC_GAIN_0DB;
                  vCodec.rightChannelMic.mic = NO_MIC;
                  vCodec.rightChannelMic.micOnOff = MICROPHONE_OFF;
                  vCodec.rightChannelMic.ampMode = AMP_OFF;
                  vCodec.rightChannelMic.gain = MIC_GAIN_0DB;
            }
      }
      /* Finally, also reset any global state variables. */
      headsetState = NO_HEADSET;
      /* Exit the critical section. */
      up(&mutex);
      return rc;
}


Generated by  Doxygen 1.6.0   Back to index