diff options
| author | mark <mcampbellsmith@gmail.com> | 2013-08-21 21:20:32 +1000 | 
|---|---|---|
| committer | mark <mcampbellsmith@gmail.com> | 2013-08-21 21:48:13 +1000 | 
| commit | 329915b1b5922b1c08877c8e52b89f10d576a254 (patch) | |
| tree | 0e82060c049cc03750fc7c676e78f6d9117d286a /audio | |
| parent | ee4f6f600b0f59240e4a146ba346c5e21139e4a6 (diff) | |
| download | device_samsung_i9305-329915b1b5922b1c08877c8e52b89f10d576a254.zip device_samsung_i9305-329915b1b5922b1c08877c8e52b89f10d576a254.tar.gz device_samsung_i9305-329915b1b5922b1c08877c8e52b89f10d576a254.tar.bz2  | |
revert: i9305: user configureable voice/streaming volumes
This reverts this change from 10.1, but keeps the cleaned
up parts in audio_hw.c
Change-Id: I51dc154f56b873113c36bce7dbb969ade59159f9
Diffstat (limited to 'audio')
| -rw-r--r-- | audio/audio_hw.c | 123 | ||||
| -rw-r--r-- | audio/audio_hw.h | 25 | 
2 files changed, 12 insertions, 136 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c index d515057..21d9172 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -25,7 +25,6 @@  #include <pthread.h>  #include <stdint.h>  #include <sys/time.h> -#include <sys/stat.h>  #include <stdlib.h>  #include <expat.h>  #include <dlfcn.h> @@ -197,6 +196,7 @@ struct m0_dev_cfg {  void *mCsdHandle;  int rx_dev_id, tx_dev_id, old_rx_dev; +int voice_index;  static int (*csd_client_init)();  static int (*csd_client_deinit)(); @@ -533,6 +533,7 @@ static void set_incall_device(struct m0_audio_device *adev)          case AUDIO_DEVICE_OUT_EARPIECE:              rx_dev_id = DEVICE_HANDSET_RX_ACDB_ID;              tx_dev_id = DEVICE_HANDSET_TX_ACDB_ID; +            voice_index = 5;              break;          case AUDIO_DEVICE_OUT_SPEAKER:          case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET: @@ -540,11 +541,13 @@ static void set_incall_device(struct m0_audio_device *adev)          case AUDIO_DEVICE_OUT_AUX_DIGITAL:              rx_dev_id = DEVICE_SPEAKER_MONO_RX_ACDB_ID;              tx_dev_id = DEVICE_HANDSET_TX_ACDB_ID; +            voice_index = 7;              break;          case AUDIO_DEVICE_OUT_WIRED_HEADSET:          case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:              rx_dev_id = DEVICE_HEADSET_RX_ACDB_ID;              tx_dev_id = DEVICE_HEADSET_TX_ACDB_ID; +            voice_index = 5;              break;          case AUDIO_DEVICE_OUT_BLUETOOTH_SCO:          case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET: @@ -556,10 +559,12 @@ static void set_incall_device(struct m0_audio_device *adev)                  rx_dev_id = DEVICE_BT_SCO_RX_ACDB_ID;                  tx_dev_id = DEVICE_BT_SCO_TX_ACDB_ID;              } +            voice_index = 7;              break;          default:              rx_dev_id = DEVICE_HANDSET_RX_ACDB_ID;              tx_dev_id = DEVICE_HANDSET_TX_ACDB_ID; +            voice_index = 5;              break;      } @@ -605,25 +610,8 @@ static void set_input_volumes(struct m0_audio_device *adev, int main_mic_on,  {  } -static void set_output_volumes(struct m0_audio_device *adev) +static void set_output_volumes(struct m0_audio_device *adev, bool tty_volume)  { -    int volume; - -    switch(adev->out_device) { -      case AUDIO_DEVICE_OUT_SPEAKER: -          volume = get_volume(OUT_SPEAKER); -          ALOGV("%s: SPEAKER Volume: %i", __func__, volume); -          mixer_ctl_set_value(adev->mixer_ctls.speaker_volume,0,volume); -          mixer_ctl_set_value(adev->mixer_ctls.speaker_volume,1,volume); -          break; -      case AUDIO_DEVICE_OUT_WIRED_HEADSET: -      case AUDIO_DEVICE_OUT_WIRED_HEADPHONE: -          volume = get_volume(OUT_HEADPHONE); -          ALOGV("%s: HEADPHONE Volume: %i", __func__, volume); -          mixer_ctl_set_value(adev->mixer_ctls.headphone_volume,0,volume); -          mixer_ctl_set_value(adev->mixer_ctls.headphone_volume,1,volume); -          break; -    }  }  static void force_all_standby(struct m0_audio_device *adev) @@ -754,8 +742,6 @@ static void select_output_device(struct m0_audio_device *adev)      set_eq_filter(adev); -    set_output_volumes(adev); -      if (adev->mode == AUDIO_MODE_IN_CALL) {          if (!bt_on) {              /* force tx path according to TTY mode when in call */ @@ -2741,19 +2727,16 @@ static int adev_init_check(const struct audio_hw_device *dev)  static int adev_set_voice_volume(struct audio_hw_device *dev, float volume)  {      struct m0_audio_device *adev = (struct m0_audio_device *)dev; -    int voice_index;      adev->voice_volume = volume; -    voice_index = update_voice_index(adev); -      ALOGD("%s: Voice Index: %i", __func__, voice_index);      if (adev->mode == AUDIO_MODE_IN_CALL) {          if (csd_volume_index == NULL) {              ALOGE("dlsym: Error:%s Loading csd_volume_index", dlerror());          } else { -            volume = volume * (float)voice_index; +            volume = volume * voice_index;              ALOGD("%s: calling csd_volume_index(%f)", __func__, volume);              csd_volume_index(volume);          } @@ -2761,36 +2744,6 @@ static int adev_set_voice_volume(struct audio_hw_device *dev, float volume)      return 0;  } -int update_voice_index(struct m0_audio_device *adev) -{ -      int voice_index; - -      switch(adev->out_device) { -        case AUDIO_DEVICE_OUT_EARPIECE: -            voice_index = get_volume(INCALL_EARPIECE); -            break; -        case AUDIO_DEVICE_OUT_SPEAKER: -        case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET: -        case AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET: -        case AUDIO_DEVICE_OUT_AUX_DIGITAL: -            voice_index = get_volume(INCALL_SPEAKER); -            break; -        case AUDIO_DEVICE_OUT_WIRED_HEADSET: -        case AUDIO_DEVICE_OUT_WIRED_HEADPHONE: -            voice_index = get_volume(INCALL_HEADPHONE); -            break; -        case AUDIO_DEVICE_OUT_BLUETOOTH_SCO: -        case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET: -        case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT: -            voice_index = get_volume(INCALL_BT); -            break; -        default: -            voice_index = get_volume(INCALL_EARPIECE); -            break; -    } -    return voice_index; -} -  static int adev_set_master_volume(struct audio_hw_device *dev, float volume)  {      return -ENOSYS; @@ -3210,63 +3163,11 @@ static int adev_config_parse(struct m0_audio_device *adev)      return ret;  } -static int volume_file_check() -{ -  FILE *f; -  int i; -  int default_voice_vol = 5; -  int default_stream_vol = 50; -  struct stat st = {0}; - -  if (stat(AUDIO_DIR, &st) == -1) { -    ALOGE("Directory %s does not exist, skip creating volume files\n", AUDIO_DIR); -    return -ENODEV; -  } - -  for ( i = 0; i < MAX_NUM_VOLUME_FILES; i++ ) { -    f = fopen(volume_file[i], "r"); -    if(!f){ -      ALOGW("Failed to open %s, attempting to create file\n", volume_file[i]); -      f = fopen(volume_file[i], "w"); -      if(!f){ -        ALOGE("Failed to create %s\n", volume_file[i]); -        continue; -      }else{ -        ALOGI("Successfully created %s\n", volume_file[i]); -        /* first 4 files are for incall voice, anything over that is considered streaming out */ -        if(i > 3) -           fprintf(f, "%d", default_stream_vol); -        else -           fprintf(f, "%d", default_voice_vol); -        fclose(f); -        chmod(volume_file[i], 0666); -      } -    }else{ -      chmod(volume_file[i],0666); -    } -  } - -  return 0; -} - -int get_volume(char *file) -{ -  FILE *f; -  int index = 1; - -  f = fopen(file, "r"); -  if(f) { -    fscanf(f, "%i", &index); -    fclose(f); -  } -  return index; -} -  static int adev_open(const hw_module_t* module, const char* name,                       hw_device_t** device)  {      struct m0_audio_device *adev; -    int ret, volfs; +    int ret;      if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0)          return -EINVAL; @@ -3306,16 +3207,10 @@ static int adev_open(const hw_module_t* module, const char* name,      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"); -    /* speaker/headphone volume control*/ -    adev->mixer_ctls.speaker_volume = mixer_get_ctl_by_name(adev->mixer, "Speaker Volume"); -    adev->mixer_ctls.headphone_volume = mixer_get_ctl_by_name(adev->mixer, "Headphone Volume"); -      ret = adev_config_parse(adev);      if (ret != 0)          goto err_mixer; -    volfs = volume_file_check(); -      /* Set the default route before the PCM stream is opened */      pthread_mutex_lock(&adev->lock);      adev->mode = AUDIO_MODE_NORMAL; diff --git a/audio/audio_hw.h b/audio/audio_hw.h index 33050c3..4d99bc7 100644 --- a/audio/audio_hw.h +++ b/audio/audio_hw.h @@ -64,18 +64,9 @@  /* sampling rate when using VX port for wide band */  #define VX_WB_SAMPLING_RATE 16000 -#define MAX_NUM_VOLUME_FILES 6 -#define AUDIO_DIR "/data/local/audio" - -/* in-call files */ -#define INCALL_EARPIECE "/data/local/audio/incall_earpiece" -#define INCALL_HEADPHONE "/data/local/audio/incall_headphone" -#define INCALL_SPEAKER "/data/local/audio/incall_speaker" -#define INCALL_BT "/data/local/audio/incall_bt" - -/* out stream files */ -#define OUT_HEADPHONE "/data/local/audio/out_headphone" -#define OUT_SPEAKER "/data/local/audio/out_speaker" +/* product-specific defines */ +#define PRODUCT_DEVICE_PROPERTY "ro.product.device" +#define PRODUCT_NAME_PROPERTY   "ro.product.name"  #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) @@ -113,14 +104,6 @@ enum tty_modes {      TTY_MODE_FULL  }; -char *volume_file[MAX_NUM_VOLUME_FILES] = { -    INCALL_EARPIECE, -    INCALL_HEADPHONE, -    INCALL_SPEAKER, -    INCALL_BT, -    OUT_HEADPHONE, -    OUT_SPEAKER -};  /* ACDB Device ID macros */  #define DEVICE_HANDSET_RX_ACDB_ID                       7 // HANDSET_SPKR  #define DEVICE_HANDSET_TX_ACDB_ID                       4 // HANDSET_MIC @@ -172,8 +155,6 @@ struct mixer_ctls  {      struct mixer_ctl *mixinl_in1l_volume;      struct mixer_ctl *mixinl_in2l_volume; -    struct mixer_ctl *speaker_volume; -    struct mixer_ctl *headphone_volume;  };  struct route_setting  | 
