Ejemplo n.º 1
0
void cpcap_audio_set_audio_state(struct cpcap_audio_state *state)
{
	struct cpcap_audio_state *previous_state = &previous_state_struct;

	if (state->codec_mute == CPCAP_AUDIO_CODEC_BYPASS_LOOP)
		state->codec_mode = CPCAP_AUDIO_CODEC_ON;

	if (state->codec_mode == CPCAP_AUDIO_CODEC_OFF ||
	    state->codec_mode == CPCAP_AUDIO_CODEC_CLOCK_ONLY ||
		state->rat_type == CPCAP_AUDIO_RAT_CDMA)
		state->codec_mute = CPCAP_AUDIO_CODEC_MUTE;
	else
		state->codec_mute = CPCAP_AUDIO_CODEC_UNMUTE;

	if (state->stdac_mode != CPCAP_AUDIO_STDAC_ON)
		state->stdac_mute = CPCAP_AUDIO_STDAC_MUTE;
	else
		state->stdac_mute = CPCAP_AUDIO_STDAC_UNMUTE;

	if (state->stdac_mode == CPCAP_AUDIO_STDAC_CLOCK_ONLY)
		state->stdac_mode = CPCAP_AUDIO_STDAC_ON;

	if ((state->codec_mode != CPCAP_AUDIO_CODEC_OFF  &&
	     state->codec_mode != CPCAP_AUDIO_CODEC_CLOCK_ONLY) ||
	    state->stdac_mode != CPCAP_AUDIO_STDAC_OFF ||
	    (state->codec_primary_speaker != CPCAP_AUDIO_OUT_NONE  &&
	     state->codec_primary_speaker != CPCAP_AUDIO_OUT_BT_MONO) ||
	    state->stdac_primary_speaker != CPCAP_AUDIO_OUT_NONE ||
	    state->ext_primary_speaker != CPCAP_AUDIO_OUT_NONE ||
	    (state->microphone != CPCAP_AUDIO_IN_NONE &&
	     state->microphone != CPCAP_AUDIO_IN_BT_MONO))
		cpcap_audio_configure_power(1);

	if (is_speaker_turning_off(state, previous_state))
		cpcap_audio_configure_output(state, previous_state);

	if (is_codec_changed(state, previous_state)) {
		int codec_mute = state->codec_mute;

		state->codec_mute = CPCAP_AUDIO_CODEC_MUTE;

		cpcap_audio_configure_aud_mute(state, previous_state);

		previous_state->codec_mute = state->codec_mute;

		state->codec_mute = codec_mute;

		cpcap_audio_configure_codec(state, previous_state);
	}
	if (is_stdac_changed(state, previous_state)) {
		int stdac_mute = state->stdac_mute;

		state->stdac_mute = CPCAP_AUDIO_STDAC_MUTE;

		cpcap_audio_configure_aud_mute(state, previous_state);

		previous_state->stdac_mute = state->stdac_mute;

		state->stdac_mute = stdac_mute;

		cpcap_audio_configure_stdac(state, previous_state);
	}

	cpcap_audio_configure_analog_source(state, previous_state);

	cpcap_audio_configure_input(state, previous_state);

	cpcap_audio_configure_input_gains(state, previous_state);

	cpcap_audio_configure_output(state, previous_state);

	cpcap_audio_configure_output_gains(state, previous_state);

	cpcap_audio_configure_aud_mute(state, previous_state);

	if ((state->codec_mode == CPCAP_AUDIO_CODEC_OFF ||
	     state->codec_mode == CPCAP_AUDIO_CODEC_CLOCK_ONLY) &&
	    state->stdac_mode == CPCAP_AUDIO_STDAC_OFF &&
	    (state->codec_primary_speaker == CPCAP_AUDIO_OUT_NONE ||
	     state->codec_primary_speaker == CPCAP_AUDIO_OUT_BT_MONO) &&
	    state->stdac_primary_speaker == CPCAP_AUDIO_OUT_NONE &&
	    state->ext_primary_speaker == CPCAP_AUDIO_OUT_NONE &&
	    (state->microphone == CPCAP_AUDIO_IN_NONE ||
	     state->microphone == CPCAP_AUDIO_IN_BT_MONO))
		cpcap_audio_configure_power(0);

	previous_state_struct = *state;

	cpcap_audio_register_dump(state);
}
Ejemplo n.º 2
0
void cpcap_audio_set_audio_state(struct cpcap_audio_state *state)
{
    struct cpcap_audio_state *previous_state = &previous_state_struct;

    if (state->codec_mute == CPCAP_AUDIO_CODEC_BYPASS_LOOP)
        state->codec_mode = CPCAP_AUDIO_CODEC_ON;

    if (state->codec_mode == CPCAP_AUDIO_CODEC_OFF ||
            state->codec_mode == CPCAP_AUDIO_CODEC_CLOCK_ONLY)
        state->codec_mute = CPCAP_AUDIO_CODEC_MUTE;
    else
        state->codec_mute = CPCAP_AUDIO_CODEC_UNMUTE;

    if (state->stdac_mode != CPCAP_AUDIO_STDAC_ON)
        state->stdac_mute = CPCAP_AUDIO_STDAC_MUTE;
    else
        state->stdac_mute = CPCAP_AUDIO_STDAC_UNMUTE;

    /* @TODO: STDAC_CLOCK_ONLY can be used when AUX_I2S is the
     * only speaker to save some current.  AUX_I2S is to stdac
     * as BT_MONO is to phone codec.
     */
    if (state->stdac_mode == CPCAP_AUDIO_STDAC_CLOCK_ONLY)
        state->stdac_mode = CPCAP_AUDIO_STDAC_ON;

    if ((state->codec_mode != CPCAP_AUDIO_CODEC_OFF &&
            state->codec_mode != CPCAP_AUDIO_CODEC_CLOCK_ONLY) ||
            state->stdac_mode != CPCAP_AUDIO_STDAC_OFF ||
            (state->codec_primary_speaker != CPCAP_AUDIO_OUT_NONE &&
             state->codec_primary_speaker != CPCAP_AUDIO_OUT_BT_MONO) ||
            state->stdac_primary_speaker != CPCAP_AUDIO_OUT_NONE ||
            state->ext_primary_speaker != CPCAP_AUDIO_OUT_NONE ||
            (state->microphone != CPCAP_AUDIO_IN_NONE &&
             state->microphone != CPCAP_AUDIO_IN_BT_MONO))
        cpcap_audio_configure_power(1);

    if (is_speaker_turning_off(state, previous_state))
        cpcap_audio_configure_output(state, previous_state);

    if (is_codec_changed(state, previous_state)) {
        int codec_mute = state->codec_mute;

        state->codec_mute = CPCAP_AUDIO_CODEC_MUTE;

        cpcap_audio_configure_aud_mute(state, previous_state);

        previous_state->codec_mute = state->codec_mute;

        state->codec_mute = codec_mute;

        cpcap_audio_configure_codec(state, previous_state);
    }
    if (is_stdac_changed(state, previous_state)) {
        int stdac_mute = state->stdac_mute;

        state->stdac_mute = CPCAP_AUDIO_STDAC_MUTE;

        cpcap_audio_configure_aud_mute(state, previous_state);

        previous_state->stdac_mute = state->stdac_mute;

        state->stdac_mute = stdac_mute;

        cpcap_audio_configure_stdac(state, previous_state);
    }


    cpcap_audio_configure_analog_source(state, previous_state);

    cpcap_audio_configure_input(state, previous_state);

    cpcap_audio_configure_input_gains(state, previous_state);

    cpcap_audio_configure_output(state, previous_state);

    cpcap_audio_configure_output_gains(state, previous_state);

    cpcap_audio_configure_aud_mute(state, previous_state);

    if ((state->codec_mode == CPCAP_AUDIO_CODEC_OFF ||
            state->codec_mode == CPCAP_AUDIO_CODEC_CLOCK_ONLY) &&
            state->stdac_mode == CPCAP_AUDIO_STDAC_OFF &&
            (state->codec_primary_speaker == CPCAP_AUDIO_OUT_NONE ||
             state->codec_primary_speaker == CPCAP_AUDIO_OUT_BT_MONO) &&
            state->stdac_primary_speaker == CPCAP_AUDIO_OUT_NONE &&
            state->ext_primary_speaker == CPCAP_AUDIO_OUT_NONE &&
            (state->microphone == CPCAP_AUDIO_IN_NONE ||
             state->microphone == CPCAP_AUDIO_IN_BT_MONO))
        cpcap_audio_configure_power(0);

    previous_state_struct = *state;

    cpcap_audio_reguister_dump(state);
}