summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangchul Lee <sc11.lee@samsung.com>2019-07-11 10:28:55 +0900
committerSangchul Lee <sc11.lee@samsung.com>2019-07-11 14:29:24 +0900
commit958c83f2a5ef336e54285f332c58720eaff714ba (patch)
tree82d3f593f5bf54f309d0581ca504936e203214a0
parent0786984f147fa2c41c6c55e7f9edc0339d634aaf (diff)
downloadaudio-hal-sc7727-958c83f2a5ef336e54285f332c58720eaff714ba.tar.gz
audio-hal-sc7727-958c83f2a5ef336e54285f332c58720eaff714ba.tar.bz2
audio-hal-sc7727-958c83f2a5ef336e54285f332c58720eaff714ba.zip
Add support for radio volumesubmit/tizen/20190715.061154
The operation of radio volume is moved from radio HAL. [Version] 0.1.30 [Issue Type] Improvement Change-Id: Ie35ca5cfb9c56a4130d9db5e03e1b108822b2982 Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
-rw-r--r--packaging/audio-hal-sc7727.spec2
-rw-r--r--tizen-audio-impl.h2
-rw-r--r--tizen-audio-internal.h2
-rw-r--r--tizen-audio-volume.c90
4 files changed, 56 insertions, 40 deletions
diff --git a/packaging/audio-hal-sc7727.spec b/packaging/audio-hal-sc7727.spec
index 3eaddec..ffa9242 100644
--- a/packaging/audio-hal-sc7727.spec
+++ b/packaging/audio-hal-sc7727.spec
@@ -1,6 +1,6 @@
Name: audio-hal-sc7727
Summary: TIZEN Audio HAL for SC7727
-Version: 0.1.29
+Version: 0.1.30
Release: 0
Group: System/Libraries
License: Apache-2.0
diff --git a/tizen-audio-impl.h b/tizen-audio-impl.h
index c3f8e85..b1879b2 100644
--- a/tizen-audio-impl.h
+++ b/tizen-audio-impl.h
@@ -58,6 +58,8 @@ audio_return_t _pcm_set_hw_params(snd_pcm_t *pcm, audio_pcm_sample_spec_t *sampl
#define MIXER_FMRADIO_L_VOLUME "VBC STR DG Set"
#define MIXER_FMRADIO_R_VOLUME "VBC STL DG Set"
#define MIXER_FMRADIO_MUTE "Digital FM Function"
+#define FMRADIO_MUTE_ON 0
+#define FMRADIO_MUTE_OFF 1
audio_return_t _mixer_control_init(audio_hal_t *ah);
audio_return_t _mixer_control_deinit(audio_hal_t *ah);
audio_return_t _mixer_control_set_param(audio_hal_t *ah, const char* ctl_name, snd_ctl_elem_value_t* value, int size);
diff --git a/tizen-audio-internal.h b/tizen-audio-internal.h
index f4b3ff2..1d595a6 100644
--- a/tizen-audio-internal.h
+++ b/tizen-audio-internal.h
@@ -241,6 +241,7 @@ typedef struct audio_hal_volume {
uint32_t volume_level[AUDIO_VOLUME_TYPE_MAX];
audio_volume_value_table_t *volume_value_table;
int32_t radio_volume_value_table[RADIO_VOLUME_LEVEL_MAX];
+ int32_t radio_volume_num_of_levels;
} audio_hal_volume_t;
/* UCM */
@@ -336,7 +337,6 @@ audio_return_t _audio_comm_deinit(audio_hal_t *ah);
audio_return_t _audio_update_route_voicecall(audio_hal_t *ah, device_info_t *devices, int32_t num_of_devices);
int _audio_modem_is_call_connected(audio_hal_t *ah);
audio_return_t _audio_comm_send_message(audio_hal_t *ah, const char *name, int value);
-audio_return_t _audio_volume_set_level_radio(audio_hal_t *ah, uint32_t level);
typedef struct _dump_data {
char *strbuf;
diff --git a/tizen-audio-volume.c b/tizen-audio-volume.c
index 9fca5cc..97e445c 100644
--- a/tizen-audio-volume.c
+++ b/tizen-audio-volume.c
@@ -339,49 +339,63 @@ error:
return ret;
}
-audio_return_t _audio_volume_set_level_radio(audio_hal_t *ah, uint32_t level)
+static audio_return_t _audio_volume_set_ratio_radio(audio_hal_t *ah, double ratio)
{
audio_return_t audio_ret = AUDIO_RET_OK;
- int volume = 0;
+ int new_value = 0;
+ int prev_value = -1;
int mute = -1;
+ int max_value;
+ int min_value;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
/* Applying mute at volume zero */
- if (level == 0) {
- if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_MUTE, 0)))
- AUDIO_LOG_ERROR("set mixer(%s) failed", MIXER_FMRADIO_MUTE);
+ if (ratio == 0) {
+ if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_MUTE, FMRADIO_MUTE_ON))) {
+ AUDIO_LOG_ERROR("[mute on] set mixer(%s) failed", MIXER_FMRADIO_MUTE);
+ return AUDIO_ERR_INTERNAL;
+ }
+ new_value = 0;
+ goto set_volume;
+ }
- } else {
- if ((audio_ret = _mixer_control_get_value(ah, MIXER_FMRADIO_MUTE, &mute))) {
- AUDIO_LOG_ERROR("get mixer(%s) failed", MIXER_FMRADIO_MUTE);
+ /* Unmute if muted */
+ if ((audio_ret = _mixer_control_get_value(ah, MIXER_FMRADIO_MUTE, &mute))) {
+ AUDIO_LOG_ERROR("[mute get] get mixer(%s) failed", MIXER_FMRADIO_MUTE);
+ return audio_ret;
+ }
+ if (mute == FMRADIO_MUTE_ON) {
+ if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_MUTE, FMRADIO_MUTE_OFF))) {
+ AUDIO_LOG_ERROR("[mute off] set mixer(%s) failed", MIXER_FMRADIO_MUTE);
return audio_ret;
}
- if (mute == 0) {
- if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_MUTE, 1))) {
- AUDIO_LOG_ERROR("set mixer(%s) failed", MIXER_FMRADIO_MUTE);
- return audio_ret;
- }
- }
}
- if ((_mixer_control_get_value(ah, MIXER_FMRADIO_L_VOLUME, &volume)))
- AUDIO_LOG_ERROR("get mixer(%s) failed", MIXER_FMRADIO_L_VOLUME);
- else {
- if (volume != ah->volume.radio_volume_value_table[level]) {
- if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_L_VOLUME, ah->volume.radio_volume_value_table[level]))) {
- AUDIO_LOG_ERROR("set mixer(%s) failed", MIXER_FMRADIO_L_VOLUME);
- return audio_ret;
- }
+ max_value = ah->volume.radio_volume_value_table[ah->volume.radio_volume_num_of_levels - 1];
+ min_value = ah->volume.radio_volume_value_table[0];
+ new_value = (int) (ratio * (max_value - min_value) + min_value);
+
+set_volume:
+ /* Left volume */
+ if ((_mixer_control_get_value(ah, MIXER_FMRADIO_L_VOLUME, &prev_value)))
+ AUDIO_LOG_ERROR("[volume get] get mixer(%s) failed", MIXER_FMRADIO_L_VOLUME);
+ if (new_value != prev_value) {
+ AUDIO_LOG_INFO("[volume set] set mixer(%s), %d", MIXER_FMRADIO_L_VOLUME, new_value);
+ if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_L_VOLUME, new_value))) {
+ AUDIO_LOG_ERROR("[volume set] set mixer(%s) failed", MIXER_FMRADIO_L_VOLUME);
+ return audio_ret;
}
}
- if ((_mixer_control_get_value(ah, MIXER_FMRADIO_R_VOLUME, &volume)))
- AUDIO_LOG_ERROR("get mixer(%s) failed", MIXER_FMRADIO_R_VOLUME);
- else {
- if (volume != ah->volume.radio_volume_value_table[level]) {
- if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_R_VOLUME, ah->volume.radio_volume_value_table[level])))
- AUDIO_LOG_ERROR("set mixer(%s) failed", MIXER_FMRADIO_R_VOLUME);
+ /* Right volume */
+ if ((_mixer_control_get_value(ah, MIXER_FMRADIO_R_VOLUME, &prev_value)))
+ AUDIO_LOG_ERROR("[volume get] get mixer(%s) failed", MIXER_FMRADIO_R_VOLUME);
+ if (new_value != prev_value) {
+ AUDIO_LOG_INFO("[volume set] set mixer(%s), %d", MIXER_FMRADIO_R_VOLUME, new_value);
+ if ((audio_ret = _mixer_control_set_value(ah, MIXER_FMRADIO_R_VOLUME, new_value))) {
+ AUDIO_LOG_ERROR("[volume set] set mixer(%s) failed", MIXER_FMRADIO_R_VOLUME);
+ return audio_ret;
}
}
@@ -395,7 +409,6 @@ audio_return_t _audio_volume_init(audio_hal_t *ah)
audio_return_t audio_ret = AUDIO_RET_OK;
int init_value[AUDIO_VOLUME_TYPE_MAX] = { 9, 11, 7, 11, 7, 4, 4, 7 };
int* fm_table = NULL;
- int number_of_steps = 0;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
@@ -426,13 +439,13 @@ audio_return_t _audio_volume_init(audio_hal_t *ah)
}
/* radio volume table */
- __load_radio_volume_table(&fm_table, &number_of_steps);
+ __load_radio_volume_table(&fm_table, &ah->volume.radio_volume_num_of_levels);
if (fm_table) {
- AUDIO_LOG_DEBUG("number of steps -> %d", number_of_steps);
+ AUDIO_LOG_DEBUG("number of levels -> %d", ah->volume.radio_volume_num_of_levels);
/*copy from temp structure to main strcture*/
- for (i = 0; i < number_of_steps; i++) {
+ for (i = 0; i < ah->volume.radio_volume_num_of_levels; i++)
ah->volume.radio_volume_value_table[i] = fm_table[i];
- }
+
free(fm_table);
fm_table = NULL;
}
@@ -529,10 +542,6 @@ audio_return_t audio_set_volume_level(void *audio_handle, audio_volume_info_t *i
ah->volume.volume_level[__get_volume_idx_by_string_type(info->type)] = level;
AUDIO_LOG_INFO("set [%s] volume_level: %d, direction(%d)", info->type, level, info->direction);
- /* set mixer related to H/W volume if needed */
- if ((__get_volume_idx_by_string_type(info->type) == AUDIO_VOLUME_TYPE_MEDIA) && ah->device.is_radio_on)
- audio_ret = _audio_volume_set_level_radio(ah, level);
-
return audio_ret;
}
@@ -573,5 +582,10 @@ audio_return_t audio_set_volume_ratio(void *audio_handle, audio_stream_info_t *i
AUDIO_LOG_INFO("set [%s] volume_ratio: %f, direction(%u), index(%u)", info->role, ratio, info->direction, info->idx);
+ if (!strncmp(info->role, "radio", strlen(info->role))) {
+ AUDIO_LOG_INFO("set radio volume according to the ratio[%f]", ratio);
+ audio_ret = _audio_volume_set_ratio_radio(ah, ratio);
+ }
+
return audio_ret;
-} \ No newline at end of file
+}