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

PMIC_STATUS pmic_audio_vcodec_set_mic_on_off ( const PMIC_AUDIO_HANDLE  handle,
const PMIC_AUDIO_INPUT_MIC_STATE  leftChannel,
const PMIC_AUDIO_INPUT_MIC_STATE  rightChannel 
)

Enable/disable the microphone input.

This function enables/disables the current microphone input channel. The input amplifier is automatically turned off when the microphone input is disabled.

Parameters:
handle Device handle from pmic_audio_open() call.
leftChannel The left microphone input channel state.
rightChannel the right microphone input channel state.
Return values:
PMIC_SUCCESS If the microphone input channels were successfully reconfigured.
PMIC_PARAMETER_ERROR If the handle or microphone input states were invalid.
PMIC_ERROR If the microphone input channels could not be reconfigured.

Definition at line 3352 of file pmic_audio.c.

References PMIC_AUDIO_VCODEC_STATE::handle, HANDLE_IN_USE, PMIC_AUDIO_VCODEC_STATE::handleState, PMIC_AUDIO_VCODEC_STATE::leftChannelMic, PMIC_MICROPHONE_STATE::mic, PMIC_MICROPHONE_STATE::micOnOff, pmic_write_reg(), PMIC_AUDIO_VCODEC_STATE::rightChannelMic, and SET_BITS.

Referenced by set_mixer_input_device().

{
      PMIC_STATUS rc = PMIC_PARAMETER_ERROR;
      unsigned int reg_write = 0;
      unsigned int reg_mask = 0;
      unsigned int curr_left = 0;
      unsigned int curr_right = 0;

      /* Use a critical section to ensure a consistent hardware state. */
      if (down_interruptible(&mutex))
            return PMIC_SYSTEM_ERROR_EINTR;

      if ((handle == vCodec.handle) && (vCodec.handleState == HANDLE_IN_USE)) {
            curr_left = vCodec.leftChannelMic.mic;
            curr_right = vCodec.rightChannelMic.mic;
            if ((curr_left == NO_MIC) && (curr_right == NO_MIC)) {
                  rc = PMIC_PARAMETER_ERROR;
            } else {
                  if (curr_left == MIC1_LEFT) {
                        if ((leftChannel == MICROPHONE_ON) &&
                            (vCodec.leftChannelMic.micOnOff ==
                             MICROPHONE_OFF)) {
                              /* Enable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1LEN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1LEN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC, 0);

                        } else if ((leftChannel == MICROPHONE_OFF) &&
                                 (vCodec.leftChannelMic.micOnOff ==
                                  MICROPHONE_ON)) {
                              /* Disable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1LEN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1LEN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   RXINREC, 0);

                        } else {
                              /* Both are in same state . Nothing to be done */
                        }

                  }
                  if (curr_right == MIC1_RIGHT_MIC_MONO) {
                        if ((rightChannel == MICROPHONE_ON) &&
                            (vCodec.leftChannelMic.micOnOff ==
                             MICROPHONE_OFF)) {
                              /* Enable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   1) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   0) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 0);
                        } else if ((rightChannel == MICROPHONE_OFF)
                                 && (vCodec.leftChannelMic.micOnOff ==
                                     MICROPHONE_ON)) {
                              /* Disable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   1) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   0) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 0);
                        } else {
                              /* Both are in same state . Nothing to be done */
                        }
                  } else if (curr_right == MIC2_AUX) {
                        if ((rightChannel == MICROPHONE_ON)
                            && (vCodec.leftChannelMic.micOnOff ==
                              MICROPHONE_OFF)) {
                              /* Enable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   1) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   0) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 0);
                        } else if ((rightChannel == MICROPHONE_OFF)
                                 && (vCodec.leftChannelMic.micOnOff ==
                                     MICROPHONE_ON)) {
                              /* Disable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   1) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   0) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 0);
                        } else {
                              /* Both are in same state . Nothing to be done */
                        }
                  } else if (curr_right == TXIN_EXT) {
                        if ((rightChannel == MICROPHONE_ON)
                            && (vCodec.leftChannelMic.micOnOff ==
                              MICROPHONE_OFF)) {
                              /* Enable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   1) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   0) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 1);
                        } else if ((rightChannel == MICROPHONE_OFF)
                                 && (vCodec.leftChannelMic.micOnOff ==
                                     MICROPHONE_ON)) {
                              /* Disable the microphone */
                              reg_mask |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   1) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         1) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 1);
                              reg_write |=
                                  SET_BITS(regAUDIO_TX, AMC1REN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   RXINREC,
                                                   0) |
                                  SET_BITS(regAUDIO_TX, AMC2EN,
                                         0) | SET_BITS(regAUDIO_TX,
                                                   ATXINEN, 0);
                        } else {
                              /* Both are in same state . Nothing to be done */
                        }
                  }
                  if (reg_mask == 0) {
                  } else {
                        rc = pmic_write_reg(REG_AUDIO_TX,
                                        reg_write, reg_mask);

                        if (rc == PMIC_SUCCESS) {
                              pr_debug
                                  ("MIC states configured successfully\n");
                              vCodec.leftChannelMic.micOnOff =
                                  leftChannel;
                              vCodec.rightChannelMic.micOnOff =
                                  rightChannel;
                        }
                  }
            }

      }

      /* Exit the critical section. */
      up(&mutex);

      return rc;
}


Generated by  Doxygen 1.6.0   Back to index