diff options
Diffstat (limited to 'audio')
| -rw-r--r--[-rwxr-xr-x] | audio/audio_hw.c | 250 | ||||
| -rw-r--r-- | audio/audio_hw.h | 82 | ||||
| -rwxr-xr-x | audio/ril_interface.c | 10 | ||||
| -rwxr-xr-x | audio/ril_interface.h | 6 | 
4 files changed, 186 insertions, 162 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c index a322386..283fb30 100755..100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -73,7 +73,7 @@ struct pcm_config pcm_config_capture = {  struct pcm_config pcm_config_vx = {      .channels = 2, -    .rate = VX_NB_SAMPLING_RATE, +    .rate = VX_WB_SAMPLING_RATE,      .period_size = 160,      .period_count = 2,      .format = PCM_FORMAT_S16_LE, @@ -88,7 +88,6 @@ struct m0_audio_device {      struct m0_dev_cfg *dev_cfgs;      int num_dev_cfgs;      struct mixer *mixer; -    struct mixer_ctls mixer_ctls;      audio_mode_t mode;      int active_out_device;      int out_device; @@ -96,12 +95,13 @@ struct m0_audio_device {      int in_device;      struct pcm *pcm_modem_dl;      struct pcm *pcm_modem_ul; +    struct pcm *pcm_bt_dl; +    struct pcm *pcm_bt_ul;      int in_call;      float voice_volume;      struct m0_stream_in *active_input;      struct m0_stream_out *outputs[OUTPUT_TOTAL];      bool mic_mute; -    int tty_mode;      struct echo_reference_itfe *echo_reference;      bool bluetooth_nrec;      int wb_amr; @@ -200,6 +200,7 @@ struct m0_dev_cfg {  static void select_output_device(struct m0_audio_device *adev);  static void select_input_device(struct m0_audio_device *adev); +static void set_noise_supression(struct m0_audio_device *adev, int enable);  static int adev_set_voice_volume(struct audio_hw_device *dev, float volume);  static int do_input_standby(struct m0_stream_in *in);  static int do_output_standby(struct m0_stream_out *out); @@ -312,7 +313,6 @@ static int set_route_by_array(struct mixer *mixer, struct route_setting *route,  void select_devices(struct m0_audio_device *adev)  {      int i; -      if (adev->active_out_device == adev->out_device && adev->active_in_device == adev->in_device)      return; @@ -322,26 +322,30 @@ void select_devices(struct m0_audio_device *adev)      /* Turn on new devices first so we don't glitch due to powerdown... */      for (i = 0; i < adev->num_dev_cfgs; i++)      if ((adev->out_device & adev->dev_cfgs[i].mask) && -        !(adev->active_out_device & adev->dev_cfgs[i].mask)) +        !(adev->active_out_device & adev->dev_cfgs[i].mask) && +        !(adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN))          set_route_by_array(adev->mixer, adev->dev_cfgs[i].on,                     adev->dev_cfgs[i].on_len);      for (i = 0; i < adev->num_dev_cfgs; i++)      if ((adev->in_device & adev->dev_cfgs[i].mask) && -        !(adev->active_in_device & adev->dev_cfgs[i].mask)) +        !(adev->active_in_device & adev->dev_cfgs[i].mask) && +        (adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN))          set_route_by_array(adev->mixer, adev->dev_cfgs[i].on,                     adev->dev_cfgs[i].on_len);      /* ...then disable old ones. */      for (i = 0; i < adev->num_dev_cfgs; i++)      if (!(adev->out_device & adev->dev_cfgs[i].mask) && -        (adev->active_out_device & adev->dev_cfgs[i].mask)) +        (adev->active_out_device & adev->dev_cfgs[i].mask) && +        !(adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN))          set_route_by_array(adev->mixer, adev->dev_cfgs[i].off,                     adev->dev_cfgs[i].off_len);      for (i = 0; i < adev->num_dev_cfgs; i++)      if (!(adev->in_device & adev->dev_cfgs[i].mask) && -        (adev->active_in_device & adev->dev_cfgs[i].mask)) +        (adev->active_in_device & adev->dev_cfgs[i].mask) && +        (adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN))          set_route_by_array(adev->mixer, adev->dev_cfgs[i].off,                     adev->dev_cfgs[i].off_len); @@ -351,17 +355,21 @@ void select_devices(struct m0_audio_device *adev)  static int start_call(struct m0_audio_device *adev)  { -    ALOGE("Opening modem PCMs"); +    ALOGV("Opening modem PCMs");      int bt_on;      bt_on = adev->out_device & AUDIO_DEVICE_OUT_ALL_SCO; -    pcm_config_vx.rate = adev->wb_amr ? VX_WB_SAMPLING_RATE : VX_NB_SAMPLING_RATE; + +    if (bt_on) { +       /* use amr-nb for bluetooth */ +       pcm_config_vx.rate = VX_NB_SAMPLING_RATE; +    } else { +       pcm_config_vx.rate = adev->wb_amr ? VX_WB_SAMPLING_RATE : VX_NB_SAMPLING_RATE; +    }      /* Open modem PCM channels */      if (adev->pcm_modem_dl == NULL) { -        if (bt_on) -            adev->pcm_modem_dl = pcm_open(CARD_DEFAULT, PORT_BT, PCM_OUT, &pcm_config_vx); -        else +        ALOGD("Opening PCM modem DL stream");              adev->pcm_modem_dl = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_OUT, &pcm_config_vx);          if (!pcm_is_ready(adev->pcm_modem_dl)) {              ALOGE("cannot open PCM modem DL stream: %s", pcm_get_error(adev->pcm_modem_dl)); @@ -370,6 +378,7 @@ static int start_call(struct m0_audio_device *adev)      }      if (adev->pcm_modem_ul == NULL) { +        ALOGD("Opening PCM modem UL stream");          adev->pcm_modem_ul = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_IN, &pcm_config_vx);          if (!pcm_is_ready(adev->pcm_modem_ul)) {              ALOGE("cannot open PCM modem UL stream: %s", pcm_get_error(adev->pcm_modem_ul)); @@ -377,34 +386,88 @@ static int start_call(struct m0_audio_device *adev)          }      } +    ALOGD("Starting PCM modem streams");      pcm_start(adev->pcm_modem_dl);      pcm_start(adev->pcm_modem_ul); +    /* Open bluetooth PCM channels */ +    if (bt_on) { +        ALOGV("Opening bluetooth PCMs"); + +        if (adev->pcm_bt_dl == NULL) { +            ALOGD("Opening PCM bluetooth DL stream"); +            adev->pcm_bt_dl = pcm_open(CARD_DEFAULT, PORT_BT, PCM_OUT, &pcm_config_vx); +            if (!pcm_is_ready(adev->pcm_bt_dl)) { +                ALOGE("cannot open PCM bluetooth DL stream: %s", pcm_get_error(adev->pcm_bt_dl)); +                goto err_open_dl; +            } +        } + +        if (adev->pcm_bt_ul == NULL) { +            ALOGD("Opening PCM bluetooth UL stream"); +            adev->pcm_bt_ul = pcm_open(CARD_DEFAULT, PORT_BT, PCM_IN, &pcm_config_vx); +            if (!pcm_is_ready(adev->pcm_bt_ul)) { +                ALOGE("cannot open PCM bluetooth UL stream: %s", pcm_get_error(adev->pcm_bt_ul)); +                goto err_open_ul; +            } +        } +        ALOGD("Starting PCM bluetooth streams"); +        pcm_start(adev->pcm_bt_dl); +        pcm_start(adev->pcm_bt_ul); +    } +      return 0;  err_open_ul:      pcm_close(adev->pcm_modem_ul);      adev->pcm_modem_ul = NULL; +    pcm_close(adev->pcm_bt_ul); +    adev->pcm_bt_ul = NULL;  err_open_dl:      pcm_close(adev->pcm_modem_dl);      adev->pcm_modem_dl = NULL; +    pcm_close(adev->pcm_bt_dl); +    adev->pcm_bt_dl = NULL;      return -ENOMEM;  }  static void end_call(struct m0_audio_device *adev)  { -    ALOGE("Closing modem PCMs"); -    pcm_stop(adev->pcm_modem_dl); -    pcm_stop(adev->pcm_modem_ul); -    pcm_close(adev->pcm_modem_dl); -    pcm_close(adev->pcm_modem_ul); +    int bt_on; +    bt_on = adev->out_device & AUDIO_DEVICE_OUT_ALL_SCO; + +    if (adev->pcm_modem_dl != NULL) { +        ALOGD("Stopping modem DL PCM"); +        pcm_stop(adev->pcm_modem_dl); +        ALOGV("Closing modem DL PCM"); +        pcm_close(adev->pcm_modem_dl); +    } +    if (adev->pcm_modem_ul != NULL) { +        ALOGD("Stopping modem UL PCM"); +        pcm_stop(adev->pcm_modem_ul); +        ALOGV("Closing modem UL PCM"); +        pcm_close(adev->pcm_modem_ul); +    }      adev->pcm_modem_dl = NULL;      adev->pcm_modem_ul = NULL; -    /* re-enable +30db boost on mics */ -    mixer_ctl_set_value(adev->mixer_ctls.mixinl_in1l_volume, 0, 1); -    mixer_ctl_set_value(adev->mixer_ctls.mixinl_in2l_volume, 0, 1); +    if (bt_on) { +        if (adev->pcm_bt_dl != NULL) { +            ALOGD("Stopping bluetooth DL PCM"); +            pcm_stop(adev->pcm_bt_dl); +            ALOGV("Closing bluetooth DL PCM"); +            pcm_close(adev->pcm_bt_dl); +        } +        if (adev->pcm_bt_ul != NULL) { +            ALOGD("Stopping bluetooth UL PCM"); +            pcm_stop(adev->pcm_bt_ul); +            ALOGV("Closing bluetooth UL PCM"); +            pcm_close(adev->pcm_bt_ul); +        } +    } +    adev->pcm_bt_dl = NULL; +    adev->pcm_bt_ul = NULL;  }  static void set_eq_filter(struct m0_audio_device *adev) @@ -438,7 +501,7 @@ static void set_incall_device(struct m0_audio_device *adev)              device_type = SOUND_AUDIO_PATH_HANDSET;              break;          case AUDIO_DEVICE_OUT_SPEAKER: -        case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET:  +        case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET:          case AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET:          case AUDIO_DEVICE_OUT_AUX_DIGITAL:              device_type = SOUND_AUDIO_PATH_SPEAKER; @@ -468,15 +531,6 @@ static void set_incall_device(struct m0_audio_device *adev)      ril_set_call_audio_path(&adev->ril, device_type);  } -static void set_input_volumes(struct m0_audio_device *adev, int main_mic_on, -                              int headset_mic_on, int sub_mic_on) -{ -} - -static void set_output_volumes(struct m0_audio_device *adev, bool tty_volume) -{ -} -  static void force_all_standby(struct m0_audio_device *adev)  {      struct m0_stream_in *in; @@ -532,9 +586,23 @@ static void select_mode(struct m0_audio_device *adev)               adev->in_call, adev->mode);          if (adev->in_call) {              adev->in_call = 0; +            ril_set_call_clock_sync(&adev->ril, SOUND_CLOCK_STOP);              end_call(adev);              force_all_standby(adev); + +            ALOGD("%s: set voicecall route: voicecall_default_disable", __func__); +            set_bigroute_by_array(adev->mixer, voicecall_default_disable, 1); +            ALOGD("%s: set voicecall route: default_input_disable", __func__); +            set_bigroute_by_array(adev->mixer, default_input_disable, 1); +            set_noise_supression(adev, 0); +            ALOGD("%s: set voicecall route: headset_input_disable", __func__); +            set_bigroute_by_array(adev->mixer, headset_input_disable, 1); +            ALOGD("%s: set voicecall route: bt_disable", __func__); +            set_bigroute_by_array(adev->mixer, bt_disable, 1); +              select_output_device(adev); +            //Force Input Standby +            adev->in_device = AUDIO_DEVICE_NONE;              select_input_device(adev);          }      } @@ -547,7 +615,6 @@ static void select_output_device(struct m0_audio_device *adev)      int speaker_on;      int earpiece_on;      int bt_on; -    bool tty_volume = false;      unsigned int channel;      headset_on = adev->out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET; @@ -594,29 +661,6 @@ static void select_output_device(struct m0_audio_device *adev)      set_eq_filter(adev);      if (adev->mode == AUDIO_MODE_IN_CALL) { -        if (!bt_on) { -            /* force tx path according to TTY mode when in call */ -            switch(adev->tty_mode) { -                case TTY_MODE_FULL: -                case TTY_MODE_HCO: -                    /* tx path from headset mic */ -                    headphone_on = 0; -                    headset_on = 1; -                    speaker_on = 0; -                    earpiece_on = 0; -                    break; -                case TTY_MODE_VCO: -                    /* tx path from device sub mic */ -                    headphone_on = 0; -                    headset_on = 0; -                    speaker_on = 1; -                    earpiece_on = 0; -                    break; -                case TTY_MODE_OFF: -                default: -                    break; -            } -        }          if (headset_on || headphone_on || speaker_on || earpiece_on) {              ALOGD("%s: set voicecall route: voicecall_default", __func__); @@ -629,9 +673,11 @@ static void select_output_device(struct m0_audio_device *adev)          if (speaker_on || earpiece_on || headphone_on) {              ALOGD("%s: set voicecall route: default_input", __func__);              set_bigroute_by_array(adev->mixer, default_input, 1); +            set_noise_supression(adev, 1);          } else {              ALOGD("%s: set voicecall route: default_input_disable", __func__);              set_bigroute_by_array(adev->mixer, default_input_disable, 1); +            set_noise_supression(adev, 0);          }          if (headset_on) { @@ -643,9 +689,6 @@ static void select_output_device(struct m0_audio_device *adev)          }          if (bt_on) { -            // bt uses a different port (PORT_BT) for playback, reopen the pcms -            end_call(adev); -            start_call(adev);              ALOGD("%s: set voicecall route: bt_input", __func__);              set_bigroute_by_array(adev->mixer, bt_input, 1);              ALOGD("%s: set voicecall route: bt_output", __func__); @@ -654,7 +697,6 @@ static void select_output_device(struct m0_audio_device *adev)              ALOGD("%s: set voicecall route: bt_disable", __func__);              set_bigroute_by_array(adev->mixer, bt_disable, 1);          } -          set_incall_device(adev);      }  } @@ -668,9 +710,9 @@ static void select_input_device(struct m0_audio_device *adev)              ALOGD("%s: AUDIO_DEVICE_IN_BUILTIN_MIC", __func__);              break;          case AUDIO_DEVICE_IN_BACK_MIC: -            ALOGD("%s: AUDIO_DEVICE_IN_BACK_MIC | AUDIO_DEVICE_IN_BUILTIN_MIC", __func__);              // Force use both mics for video recording              adev->in_device = (AUDIO_DEVICE_IN_BACK_MIC | AUDIO_DEVICE_IN_BUILTIN_MIC) & ~AUDIO_DEVICE_BIT_IN; +            ALOGD("%s: AUDIO_DEVICE_IN_BACK_MIC and AUDIO_DEVICE_IN_BUILTIN_MIC", __func__);              break;          case AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET:              ALOGD("%s: AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET", __func__); @@ -685,6 +727,21 @@ static void select_input_device(struct m0_audio_device *adev)      select_devices(adev);  } +static void set_noise_supression(struct m0_audio_device *adev, int enable) +{ +    if (enable) { +        // Enable Noise suppression for builtin microphone +        ALOGE("%s: enabling two mic control", __func__); +        ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_ON); +        set_bigroute_by_array(adev->mixer, noise_suppression, 1); +    } else { +        // Disable Noise suppression for builtin microphone +        ALOGE("%s: disabling two mic control", __func__); +        ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_OFF); +        set_bigroute_by_array(adev->mixer, noise_suppression_disable, 1); +    } +} +  /* must be called with hw device and output stream mutexes locked */  static int start_output_stream_low_latency(struct m0_stream_out *out)  { @@ -730,7 +787,7 @@ static int start_output_stream_low_latency(struct m0_stream_out *out)      if (success) {          out->buffer_frames = pcm_config_tones.period_size * 2;          if (out->buffer == NULL) -            out->buffer = malloc(out->buffer_frames * audio_stream_frame_size(&out->stream.common)); +            out->buffer = malloc(out->buffer_frames * audio_stream_out_frame_size(&out->stream.common));          if (adev->echo_reference != NULL)              out->echo_reference = adev->echo_reference; @@ -930,7 +987,7 @@ static size_t out_get_buffer_size_low_latency(const struct audio_stream *stream)      from pcm_config_tones.rate. */      size_t size = (SHORT_PERIOD_SIZE * DEFAULT_OUT_SAMPLING_RATE) / pcm_config_tones.rate;      size = ((size + 15) / 16) * 16; -    return size * audio_stream_frame_size((struct audio_stream *)stream); +    return size * audio_stream_out_frame_size((struct audio_stream *)stream);  }  static size_t out_get_buffer_size_deep_buffer(const struct audio_stream *stream) @@ -944,7 +1001,7 @@ static size_t out_get_buffer_size_deep_buffer(const struct audio_stream *stream)      size_t size = (DEEP_BUFFER_SHORT_PERIOD_SIZE * DEFAULT_OUT_SAMPLING_RATE) /                          pcm_config_mm.rate;      size = ((size + 15) / 16) * 16; -    return size * audio_stream_frame_size((struct audio_stream *)stream); +    return size * audio_stream_out_frame_size((struct audio_stream *)stream);  }  static audio_channel_mask_t out_get_channels(const struct audio_stream *stream) @@ -1168,7 +1225,7 @@ static ssize_t out_write_low_latency(struct audio_stream_out *stream, const void      int ret;      struct m0_stream_out *out = (struct m0_stream_out *)stream;      struct m0_audio_device *adev = out->dev; -    size_t frame_size = audio_stream_frame_size(&out->stream.common); +    size_t frame_size = audio_stream_out_frame_size(&out->stream.common);      size_t in_frames = bytes / frame_size;      size_t out_frames = in_frames;      bool force_input_standby = false; @@ -1236,7 +1293,7 @@ exit:      pthread_mutex_unlock(&out->lock);      if (ret != 0) { -        usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) / +        usleep(bytes * 1000000 / audio_stream_out_frame_size(&stream->common) /                 out_get_sample_rate(&stream->common));      } @@ -1260,7 +1317,7 @@ static ssize_t out_write_deep_buffer(struct audio_stream_out *stream, const void      int ret;      struct m0_stream_out *out = (struct m0_stream_out *)stream;      struct m0_audio_device *adev = out->dev; -    size_t frame_size = audio_stream_frame_size(&out->stream.common); +    size_t frame_size = audio_stream_out_frame_size(&out->stream.common);      size_t in_frames = bytes / frame_size;      size_t out_frames;      bool use_long_periods; @@ -1339,7 +1396,7 @@ exit:      pthread_mutex_unlock(&out->lock);      if (ret != 0) { -        usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) / +        usleep(bytes * 1000000 / audio_stream_out_frame_size(&stream->common) /                 out_get_sample_rate(&stream->common));      } @@ -1951,7 +2008,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,      int ret = 0;      struct m0_stream_in *in = (struct m0_stream_in *)stream;      struct m0_audio_device *adev = in->dev; -    size_t frames_rq = bytes / audio_stream_frame_size(&stream->common); +    size_t frames_rq = bytes / audio_stream_in_frame_size(&stream->common);      /* acquiring hw device mutex systematically is useful if a low priority thread is waiting       * on the input stream mutex - e.g. executing select_mode() while holding the hw device @@ -1984,7 +2041,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,  exit:      if (ret < 0) -        usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) / +        usleep(bytes * 1000000 / audio_stream_in_frame_size(&stream->common) /                 in_get_sample_rate(&stream->common));      pthread_mutex_unlock(&in->lock); @@ -2486,30 +2543,6 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)      int ret;      parms = str_parms_create_str(kvpairs); -    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value)); -    if (ret >= 0) { -        int tty_mode; - -        if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_OFF) == 0) -            tty_mode = TTY_MODE_OFF; -        else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_VCO) == 0) -            tty_mode = TTY_MODE_VCO; -        else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_HCO) == 0) -            tty_mode = TTY_MODE_HCO; -        else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_FULL) == 0) -            tty_mode = TTY_MODE_FULL; -        else -            return -EINVAL; - -        pthread_mutex_lock(&adev->lock); -        if (tty_mode != adev->tty_mode) { -            adev->tty_mode = tty_mode; -            if (adev->mode == AUDIO_MODE_IN_CALL) -                select_output_device(adev); -        } -        pthread_mutex_unlock(&adev->lock); -    } -      ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));      if (ret >= 0) {          if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0) @@ -2526,21 +2559,6 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)              adev->screen_off = true;      } -    ret = str_parms_get_str(parms, "noise_suppression", value, sizeof(value)); -    if (ret >= 0) { -        if (strcmp(value, "true") == 0) { -            ALOGE("%s: enabling two mic control", __func__); -            ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_ON); -            /* sub mic */ -            set_bigroute_by_array(adev->mixer, noise_suppression, 1); -        } else { -            ALOGE("%s: disabling two mic control", __func__); -            ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_OFF); -            /* sub mic */ -            set_bigroute_by_array(adev->mixer, noise_suppression_disable, 1); -        } -    } -      str_parms_destroy(parms);      return ret;  } @@ -2591,6 +2609,9 @@ static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)  {      struct m0_audio_device *adev = (struct m0_audio_device *)dev; +    if (adev->mode == AUDIO_MODE_IN_CALL) +            ril_set_mic_mute(&adev->ril, state); +      adev->mic_mute = state;      return 0; @@ -2760,8 +2781,8 @@ static const struct {      { AUDIO_DEVICE_OUT_SPEAKER, "speaker" },      { AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE, "headphone" },      { AUDIO_DEVICE_OUT_EARPIECE, "earpiece" }, -    { AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, "dock" }, -    { AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, "dock" }, +    { AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, "analogue-dock" }, +    { AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, "digital-dock" },      { AUDIO_DEVICE_OUT_ALL_SCO, "sco-out" },      { AUDIO_DEVICE_OUT_AUX_DIGITAL, "aux-digital" }, @@ -3009,10 +3030,6 @@ static int adev_open(const hw_module_t* module, const char* name,          return -EINVAL;      } -    /* +30db boost for mics */ -    adev->mixer_ctls.mixinl_in1l_volume = mixer_get_ctl_by_name(adev->mixer, "MIXINL IN1L Volume"); -    adev->mixer_ctls.mixinl_in2l_volume = mixer_get_ctl_by_name(adev->mixer, "MIXINL IN2L Volume"); -      ret = adev_config_parse(adev);      if (ret != 0)          goto err_mixer; @@ -3021,13 +3038,14 @@ static int adev_open(const hw_module_t* module, const char* name,      pthread_mutex_lock(&adev->lock);      adev->mode = AUDIO_MODE_NORMAL;      adev->out_device = AUDIO_DEVICE_OUT_SPEAKER; -    adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN; +    adev->in_device = AUDIO_DEVICE_NONE;      select_devices(adev);      adev->pcm_modem_dl = NULL;      adev->pcm_modem_ul = NULL; +    adev->pcm_bt_dl = NULL; +    adev->pcm_bt_ul = NULL;      adev->voice_volume = 1.0f; -    adev->tty_mode = TTY_MODE_OFF;      adev->bluetooth_nrec = true;      adev->wb_amr = 0; diff --git a/audio/audio_hw.h b/audio/audio_hw.h index 49842ca..7da52bc 100644 --- a/audio/audio_hw.h +++ b/audio/audio_hw.h @@ -97,19 +97,6 @@ enum output_type {      OUTPUT_TOTAL  }; -enum tty_modes { -    TTY_MODE_OFF, -    TTY_MODE_VCO, -    TTY_MODE_HCO, -    TTY_MODE_FULL -}; - -struct mixer_ctls -{ -    struct mixer_ctl *mixinl_in1l_volume; -    struct mixer_ctl *mixinl_in2l_volume; -}; -  struct route_setting  {      char *ctl_name; @@ -118,6 +105,9 @@ struct route_setting  };  struct route_setting voicecall_default[] = { +    { .ctl_name = "DAC1L Mixer AIF1.1 Switch", .intval = 1, }, +    { .ctl_name = "DAC1R Mixer AIF1.1 Switch", .intval = 1, }, +    { .ctl_name = "AIF2ADCL DRC Switch", .intval = 0, },      { .ctl_name = "AIF2DACL Source", .intval = 0, },      { .ctl_name = "AIF2DACR Source", .intval = 0, },      { .ctl_name = "AIF2 Mode", .intval = 0, }, @@ -130,34 +120,28 @@ struct route_setting voicecall_default[] = {  };  struct route_setting voicecall_default_disable[] = { -    { .ctl_name = "AIF2DACL Source", .intval = 0, }, -    { .ctl_name = "AIF2DACR Source", .intval = 1, }, -    { .ctl_name = "AIF2 Mode", .intval = 0, },      { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 0, },      { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 0, },      { .ctl_name = "AIF2DAC Mux", .strval = "AIF3DACDAT", }, -    { .ctl_name = "Main Mic Switch", .intval = 0, }, -    { .ctl_name = "MIXINL IN1L Switch", .intval = 0, }, -    { .ctl_name = "Sub Mic Switch", .intval = 0, }, -    { .ctl_name = "MIXINR IN1R Switch", .intval = 0, }, +    { .ctl_name = "AIF2 Mode", .intval = 1, },      { .ctl_name = NULL, },  };  struct route_setting default_input[] = {      { .ctl_name = "Main Mic Switch", .intval = 1, }, -    { .ctl_name = "IN1L Volume", .intval = 30, }, +    { .ctl_name = "AIF1ADCL Source", .intval = 0, }, +    { .ctl_name = "AIF2ADCL Source", .intval = 0, },      { .ctl_name = "MIXINL IN1L Switch", .intval = 1, }, +    { .ctl_name = "IN1L Volume", .intval = 25, },      { .ctl_name = "MIXINL IN1L Volume", .intval = 0, }, -    { .ctl_name = "AIF1ADC1 HPF Mode", .intval = 0, }, -    { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 1, }, +    { .ctl_name = "AIF2ADC Volume", .intval = 96, }, +    { .ctl_name = "AIF2ADCL DRC Switch", .intval = 0, },      { .ctl_name = NULL, },  };  struct route_setting default_input_disable[] = {      { .ctl_name = "Main Mic Switch", .intval = 0, }, -    { .ctl_name = "IN1L Volume", .intval = 22, },      { .ctl_name = "MIXINL IN1L Switch", .intval = 0, }, -    { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 0, },      { .ctl_name = NULL, },  }; @@ -167,61 +151,65 @@ struct route_setting noise_suppression[] = {      { .ctl_name = "MIXINR IN1R Switch", .intval = 1, },      { .ctl_name = "MIXINR IN1R Volume", .intval = 0, },      { .ctl_name = "AIF1ADCR Source", .intval = 1, }, -    { .ctl_name = "AIF2ADCR Source", .intval = 1, },      { .ctl_name = NULL, },  };  struct route_setting noise_suppression_disable[] = {      { .ctl_name = "Sub Mic Switch", .intval = 0, }, -    { .ctl_name = "IN1R Volume", .intval = 7, },      { .ctl_name = "MIXINR IN1R Switch", .intval = 0, },      { .ctl_name = "MIXINR IN1R Volume", .intval = 0, },      { .ctl_name = NULL, },  };  struct route_setting headset_input[] = { +    { .ctl_name = "AIF2DAC2L Mixer AIF2 Switch", .intval = 0, }, +    { .ctl_name = "AIF2DAC2R Mixer AIF2 Switch", .intval = 0, }, +    { .ctl_name = "Headphone ZC Switch", .intval = 0, }, +    { .ctl_name = "AIF1DAC1 Volume", .intval = 96, }, +    { .ctl_name = "AIF2DAC Volume", .intval = 96, }, +    { .ctl_name = "AIF1 Boost Volume", .intval = 0, }, +    { .ctl_name = "AIF2 Boost Volume", .intval = 0, }, +    { .ctl_name = "DAC1 Volume", .intval = 96, }, +    { .ctl_name = "Headphone Volume", .intval = 49, },      { .ctl_name = "MIXINL IN1L Switch", .intval = 0, },      { .ctl_name = "MIXINR IN1R Switch", .intval = 0, },      { .ctl_name = "Headset Mic Switch", .intval = 1, }, -    { .ctl_name = "IN2L Volume", .intval = 30, }, -    { .ctl_name = "MIXINL IN2L Switch", .intval = 1, }, -    { .ctl_name = "MIXINL IN2L Volume", .intval = 0, }, -    { .ctl_name = "AIF1ADC1 HPF Mode", .intval = 0, }, -    { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 1, }, -    { .ctl_name = "AIF1ADC1 Volume", .intval = 96, },      { .ctl_name = "AIF1ADCL Source", .intval = 0, },      { .ctl_name = "AIF1ADCR Source", .intval = 0, },      { .ctl_name = "AIF2ADCL Source", .intval = 0, }, +    { .ctl_name = "MIXINL IN2L Switch", .intval = 1, }, +    { .ctl_name = "IN2L Volume", .intval = 28, }, +    { .ctl_name = "MIXINL IN2L Volume", .intval = 0, }, +    { .ctl_name = "DAC2 Left Sidetone Volume", .intval = 12, }, +    { .ctl_name = "AIF2ADC Volume", .intval = 96, }, +    { .ctl_name = "AIF2ADCL DRC Switch", .intval = 0, },      { .ctl_name = NULL, },  };  struct route_setting headset_input_disable[] = {      { .ctl_name = "Headset Mic Switch", .intval = 0, },      { .ctl_name = "MIXINL IN2L Switch", .intval = 0, }, -    { .ctl_name = "AIF1ADC1 HPF Mode", .intval = 0, }, -    { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 0, },      { .ctl_name = NULL, },  };  struct route_setting bt_output[] = { +    { .ctl_name = "AIF1DAC1 Volume", .intval = 96, }, +    { .ctl_name = "AIF1 Boost Volume", .intval = 0, }, +    { .ctl_name = "DAC2 Volume", .intval = 96, }, +    { .ctl_name = "AIF2ADC Volume", .intval = 96, },      { .ctl_name = "DAC1L Mixer AIF1.1 Switch", .intval = 1, },      { .ctl_name = "DAC1R Mixer AIF1.1 Switch", .intval = 1, },      { .ctl_name = "AIF3ADC Mux", .intval = 1, },      { .ctl_name = "AIF2DAC2L Mixer AIF1.1 Switch", .intval = 1, },      { .ctl_name = "AIF2DAC2R Mixer AIF1.1 Switch", .intval = 1, },      { .ctl_name = "AIF2DAC Volume", .intval = 96, }, -    { .ctl_name = "DAC2 Volume", .intval = 96, }, -    { .ctl_name = "AIF2ADC Volume", .intval = 96, }, -    { .ctl_name = "Speaker Mixer Volume", .intval = 1, }, -    { .ctl_name = "MIXINL IN2L Volume", .intval = 1, }, -    { .ctl_name = "IN1L Volume", .intval = 25, }, -    { .ctl_name = "IN1R Volume", .intval = 25, }, -    { .ctl_name = "Speaker Boost Volume", .intval = 4, }, +    { .ctl_name = "MIXINL IN1L Volume", .intval = 1, }, +    { .ctl_name = "IN1L Volume", .intval = 28, }, +    { .ctl_name = "IN1R Volume", .intval = 28, },      { .ctl_name = "LINEOUT1N Switch", .intval = 0, },      { .ctl_name = "LINEOUT1P Switch", .intval = 0, }, -    { .ctl_name = "AIF2DACR Source", .intval = 0, },      { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 0, }, -    { .ctl_name = "AIF2ADC HPF Mode", .intval = 1, }, +    { .ctl_name = "AIF2ADC HPF Mode", .intval = 3, },      { .ctl_name = "AIF2ADC HPF Switch", .intval = 1, },      { .ctl_name = "AIF2DAC Mux", .strval = "AIF2DACDAT", },      { .ctl_name = "AIF2DAC2R Mixer AIF2 Switch", .intval = 1, }, @@ -233,8 +221,6 @@ struct route_setting bt_input[] = {      { .ctl_name = "AIF2ADC Mux", .intval = 1, },      { .ctl_name = "AIF1ADCL Source", .intval = 0, },      { .ctl_name = "AIF1ADCR Source", .intval = 1, }, -    { .ctl_name = "AIF2ADCL Source", .intval = 0, }, -    { .ctl_name = "AIF2ADCR Source", .intval = 1, },      { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 1, },      { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 1, },      { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 1, }, @@ -245,6 +231,10 @@ struct route_setting bt_input[] = {  };  struct route_setting bt_disable[] = { +    { .ctl_name = "AIF1DAC1 Volume", .intval = 96, }, +    { .ctl_name = "AIF1 Boost Volume", .intval = 0, }, +    { .ctl_name = "DAC2 Volume", .intval = 96, }, +    { .ctl_name = "AIF2ADC Volume", .intval = 96, },      { .ctl_name = "AIF2ADC Mux", .intval = 0, },      { .ctl_name = "MIXINL IN2L Volume", .intval = 0, },      { .ctl_name = "LINEOUT1N Switch", .intval = 1, }, diff --git a/audio/ril_interface.c b/audio/ril_interface.c index a77efc0..78e60b2 100755 --- a/audio/ril_interface.c +++ b/audio/ril_interface.c @@ -38,6 +38,7 @@ int (*_ril_set_call_volume)(void *, enum ril_sound_type, int);  int (*_ril_set_call_audio_path)(void *, enum ril_audio_path);  int (*_ril_set_call_clock_sync)(void *, enum ril_clock_state);  int (*_ril_set_two_mic_control)(void *, enum ril_two_mic_device, enum ril_two_mic_state); +int (*_ril_set_mic_mute)(void *, enum ril_mic_mute);  int (*_ril_register_unsolicited_handler)(void *, int, void *);  int (*_ril_get_wb_amr)(void *, void *); @@ -108,6 +109,7 @@ int ril_open(struct ril_handle *ril)      _ril_set_call_audio_path = dlsym(ril->handle, "SetCallAudioPath");      _ril_set_call_clock_sync = dlsym(ril->handle, "SetCallClockSync");      _ril_set_two_mic_control = dlsym(ril->handle, "SetTwoMicControl"); +    _ril_set_mic_mute = dlsym(ril->handle, "SetMute");      _ril_register_unsolicited_handler = dlsym(ril->handle,                                                "RegisterUnsolicitedHandler");      /* since this function is not supported in all RILs, don't require it */ @@ -191,3 +193,11 @@ int ril_set_two_mic_control(struct ril_handle *ril, enum ril_two_mic_device devi      return _ril_set_two_mic_control(ril->client, device, state);  } + +int ril_set_mic_mute(struct ril_handle *ril, enum ril_mic_mute state) +{ +    if (ril_connect_if_required(ril)) +        return 0; + +    return _ril_set_mic_mute(ril->client, state); +} diff --git a/audio/ril_interface.h b/audio/ril_interface.h index 3d99d8d..a5bf480 100755 --- a/audio/ril_interface.h +++ b/audio/ril_interface.h @@ -70,6 +70,11 @@ enum ril_two_mic_state {      TWO_MIC_SOLUTION_ON  }; +enum ril_mic_mute { +    MIC_UNMUTE, +    MIC_MUTE +}; +  /* Function prototypes */  int ril_open(struct ril_handle *ril);  int ril_close(struct ril_handle *ril); @@ -79,5 +84,6 @@ int ril_set_call_audio_path(struct ril_handle *ril, enum ril_audio_path path);  int ril_set_call_clock_sync(struct ril_handle *ril, enum ril_clock_state state);  void ril_register_set_wb_amr_callback(void *function, void *data);  int ril_set_two_mic_control(struct ril_handle *ril, enum ril_two_mic_device device, enum ril_two_mic_state state); +int ril_set_mic_mute(struct ril_handle *ril, enum ril_mic_mute state);  #endif  | 
