summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEn-Shuo Hsu <enshuo@chromium.org>2020-01-04 17:20:42 +0800
committerCommit Bot <commit-bot@chromium.org>2020-02-21 14:41:19 +0000
commit088f5d46996ff4a9815bb30dc2311cd32ab4e2ab (patch)
tree40baff64ad5cb19c5343e59e5de168555c2419f9
parent5b5ffcb661ec685c7c115cf0c0fc549cf90b8248 (diff)
downloadadhd-088f5d46996ff4a9815bb30dc2311cd32ab4e2ab.tar.gz
CRAS: Deprecate system gain related API
The CL deprecates the API used to change system gain on CRAS and cleans up codes used for supporting it. The main purpose for this change is to simplify the logic related to capture gain so it becomes easier for partner to tune and for us to maintain. BUG=b:147080207 TEST=Build,deploy and test on DUT Cq-Depend: chromium:2007029, chrome-internal:2531574, chrome-internal:2534153, chromium:2049923 Change-Id: Id03b296c4c9d52f584d36214277965316958ca79 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2006931 Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org> Reviewed-by: Curtis Malainey <cujomalainey@chromium.org> Tested-by: En-Shuo Hsu <enshuo@chromium.org> Commit-Queue: En-Shuo Hsu <enshuo@chromium.org>
-rw-r--r--cras/README.dbus-api7
-rw-r--r--cras/src/alsa_plugin/ctl_cras.c78
-rw-r--r--cras/src/common/cras_messages.h16
-rw-r--r--cras/src/common/cras_types.h11
-rw-r--r--cras/src/libcras/cras_client.c39
-rw-r--r--cras/src/libcras/cras_client.h47
-rw-r--r--cras/src/server/cras_alsa_io.c118
-rw-r--r--cras/src/server/cras_alsa_ucm.c41
-rw-r--r--cras/src/server/cras_alsa_ucm.h26
-rw-r--r--cras/src/server/cras_bt_io.c2
-rw-r--r--cras/src/server/cras_control_rclient.c8
-rw-r--r--cras/src/server/cras_dbus_control.c27
-rw-r--r--cras/src/server/cras_iodev.c15
-rw-r--r--cras/src/server/cras_iodev.h49
-rw-r--r--cras/src/server/cras_iodev_list.c13
-rw-r--r--cras/src/server/cras_loopback_iodev.c1
-rw-r--r--cras/src/server/cras_system_state.c37
-rw-r--r--cras/src/server/cras_system_state.h18
-rw-r--r--cras/src/server/test_iodev.c1
-rw-r--r--cras/src/tests/alsa_io_unittest.cc214
-rw-r--r--cras/src/tests/alsa_ucm_unittest.cc50
-rw-r--r--cras/src/tests/control_rclient_unittest.cc39
-rw-r--r--cras/src/tests/iodev_unittest.cc14
-rw-r--r--cras/src/tests/system_state_unittest.cc47
-rw-r--r--cras/src/tools/cras_monitor/cras_monitor.c7
-rw-r--r--cras/src/tools/cras_test_client/cras_test_client.c35
-rw-r--r--ucm-config/for_all_boards/HD Pro Webcam C920/HiFi.conf2
27 files changed, 69 insertions, 893 deletions
diff --git a/cras/README.dbus-api b/cras/README.dbus-api
index 2c2da67a..2204f813 100644
--- a/cras/README.dbus-api
+++ b/cras/README.dbus-api
@@ -30,13 +30,6 @@ Methods void SetOutputVolume(int32 volume)
Sets the system output mute from user action.
- void SetInputGain(int32 gain)
-
- Sets the capture gain of the system. Gain is specified
- in dBFS * 100. For example 5dB of gain would be
- specified with an argument of 500, while -10 would be
- specified with -1000, and 11.5 maps to 1150.
-
void SetInputNodeGain(uint64 node_id, int32 gain)
Sets the capture gain of the node. Gain is specified
diff --git a/cras/src/alsa_plugin/ctl_cras.c b/cras/src/alsa_plugin/ctl_cras.c
index 822b63ab..76b0c039 100644
--- a/cras/src/alsa_plugin/ctl_cras.c
+++ b/cras/src/alsa_plugin/ctl_cras.c
@@ -14,8 +14,6 @@ static const size_t MAX_IONODES = 20; /* Max ionodes to print out. */
enum CTL_CRAS_MIXER_CONTROLS {
CTL_CRAS_MIXER_PLAYBACK_SWITCH,
CTL_CRAS_MIXER_PLAYBACK_VOLUME,
- CTL_CRAS_MIXER_CAPTURE_SWITCH,
- CTL_CRAS_MIXER_CAPTURE_VOLUME,
NUM_CTL_CRAS_MIXER_ELEMS
};
@@ -33,10 +31,6 @@ static const struct cras_mixer_control cras_elems[NUM_CTL_CRAS_MIXER_ELEMS] = {
SND_CTL_EXT_ACCESS_READWRITE, 1 },
{ "Master Playback Volume", SND_CTL_ELEM_TYPE_INTEGER,
SND_CTL_EXT_ACCESS_READWRITE, 1 },
- { "Capture Switch", SND_CTL_ELEM_TYPE_BOOLEAN,
- SND_CTL_EXT_ACCESS_READWRITE, 1 },
- { "Capture Volume", SND_CTL_ELEM_TYPE_INTEGER,
- SND_CTL_EXT_ACCESS_READWRITE, 1 },
};
/* Holds the client and ctl plugin pointers. */
@@ -119,46 +113,6 @@ static int ctl_cras_get_integer_info(snd_ctl_ext_t *ext_ctl,
return 0;
}
-static long capture_index_to_gain(struct cras_client *client, long index)
-{
- long min;
- long max;
- long dB_step;
-
- min = cras_client_get_system_min_capture_gain(client);
- max = cras_client_get_system_max_capture_gain(client);
- if (min >= max)
- return min;
-
- dB_step = (max - min) / 100;
-
- if (index <= 0)
- return min;
- if (index >= 100)
- return max;
- return index * dB_step + min;
-}
-
-static long capture_gain_to_index(struct cras_client *client, long gain)
-{
- long min;
- long max;
- long dB_step;
-
- min = cras_client_get_system_min_capture_gain(client);
- max = cras_client_get_system_max_capture_gain(client);
- if (min >= max)
- return 0;
-
- dB_step = (max - min) / 100;
-
- if (gain <= min)
- return 0;
- if (gain >= max)
- return 100;
- return (gain - min) / dB_step;
-}
-
static int get_nodes(struct cras_client *client, enum CRAS_STREAM_DIRECTION dir,
struct cras_ionode_info *nodes, size_t num_nodes)
{
@@ -199,20 +153,6 @@ static int ctl_cras_read_integer(snd_ctl_ext_t *ext_ctl, snd_ctl_ext_key_t key,
break;
}
break;
- case CTL_CRAS_MIXER_CAPTURE_SWITCH:
- *value = !cras_client_get_system_capture_muted(cras->client);
- break;
- case CTL_CRAS_MIXER_CAPTURE_VOLUME:
- num_nodes = get_nodes(cras->client, CRAS_STREAM_INPUT, nodes,
- MAX_IONODES);
- for (i = 0; i < num_nodes; i++) {
- if (!nodes[i].active)
- continue;
- *value = capture_gain_to_index(cras->client,
- nodes[i].capture_gain);
- break;
- }
- break;
default:
return -EINVAL;
}
@@ -227,7 +167,6 @@ static int ctl_cras_write_integer(snd_ctl_ext_t *ext_ctl, snd_ctl_ext_key_t key,
struct ctl_cras *cras = (struct ctl_cras *)ext_ctl->private_data;
struct cras_ionode_info nodes[MAX_IONODES];
int num_nodes, i;
- long gain;
switch (key) {
case CTL_CRAS_MIXER_PLAYBACK_SWITCH:
@@ -246,23 +185,6 @@ static int ctl_cras_write_integer(snd_ctl_ext_t *ext_ctl, snd_ctl_ext_key_t key,
*value);
}
break;
- case CTL_CRAS_MIXER_CAPTURE_SWITCH:
- cras_client_set_system_capture_mute(cras->client, !(*value));
- break;
- case CTL_CRAS_MIXER_CAPTURE_VOLUME:
- gain = capture_index_to_gain(cras->client, *value);
- num_nodes = get_nodes(cras->client, CRAS_STREAM_INPUT, nodes,
- MAX_IONODES);
- for (i = 0; i < num_nodes; i++) {
- if (!nodes[i].active)
- continue;
- cras_client_set_node_capture_gain(
- cras->client,
- cras_make_node_id(nodes[i].iodev_idx,
- nodes[i].ionode_idx),
- gain);
- }
- break;
default:
return -EINVAL;
}
diff --git a/cras/src/common/cras_messages.h b/cras/src/common/cras_messages.h
index 1965d3c1..4b8d42b6 100644
--- a/cras/src/common/cras_messages.h
+++ b/cras/src/common/cras_messages.h
@@ -34,7 +34,7 @@ enum CRAS_SERVER_MESSAGE_ID {
CRAS_SERVER_SET_SYSTEM_MUTE,
CRAS_SERVER_SET_USER_MUTE,
CRAS_SERVER_SET_SYSTEM_MUTE_LOCKED,
- CRAS_SERVER_SET_SYSTEM_CAPTURE_GAIN,
+ CRAS_SERVER_SET_SYSTEM_CAPTURE_GAIN, /* Deprecated */
CRAS_SERVER_SET_SYSTEM_CAPTURE_MUTE,
CRAS_SERVER_SET_SYSTEM_CAPTURE_MUTE_LOCKED,
CRAS_SERVER_SET_NODE_ATTR,
@@ -200,20 +200,6 @@ static inline void cras_fill_set_system_volume(struct cras_set_system_volume *m,
m->header.length = sizeof(*m);
}
-/* Sets the capture gain. */
-struct __attribute__((__packed__)) cras_set_system_capture_gain {
- struct cras_server_message header;
- int32_t gain;
-};
-static inline void
-cras_fill_set_system_capture_gain(struct cras_set_system_capture_gain *m,
- long gain)
-{
- m->gain = gain;
- m->header.id = CRAS_SERVER_SET_SYSTEM_CAPTURE_GAIN;
- m->header.length = sizeof(*m);
-}
-
/* Set the system mute state. */
struct __attribute__((__packed__)) cras_set_system_mute {
struct cras_server_message header;
diff --git a/cras/src/common/cras_types.h b/cras/src/common/cras_types.h
index 499a9c09..04cb1058 100644
--- a/cras/src/common/cras_types.h
+++ b/cras/src/common/cras_types.h
@@ -452,16 +452,8 @@ struct __attribute__((__packed__)) cras_audio_thread_snapshot_buffer {
* mute_locked - 0 = unlocked, 1 = locked.
* suspended - 1 = suspended, 0 = resumed.
* capture_gain - Capture gain in dBFS * 100.
- * capture_gain_target - Target capture gain in dBFS * 100. The actual
- * capture gain will be subjected to current
- * supported range. When active device/node changes,
- * supported range changes accordingly. System state
- * should try to re-apply target gain subjected to new
- * range.
* capture_mute - 0 = unmuted, 1 = muted.
* capture_mute_locked - 0 = unlocked, 1 = locked.
- * min_capture_gain - Min allowed capture gain in dBFS * 100.
- * max_capture_gain - Max allowed capture gain in dBFS * 100.
* num_streams_attached - Total number of streams since server started.
* num_output_devs - Number of available output devices.
* num_input_devs - Number of available input devices.
@@ -503,11 +495,8 @@ struct __attribute__((packed, aligned(4))) cras_server_state {
int32_t mute_locked;
int32_t suspended;
int32_t capture_gain;
- int32_t capture_gain_target;
int32_t capture_mute;
int32_t capture_mute_locked;
- int32_t min_capture_gain;
- int32_t max_capture_gain;
uint32_t num_streams_attached;
uint32_t num_output_devs;
uint32_t num_input_devs;
diff --git a/cras/src/libcras/cras_client.c b/cras/src/libcras/cras_client.c
index 37f25224..7a71b91b 100644
--- a/cras/src/libcras/cras_client.c
+++ b/cras/src/libcras/cras_client.c
@@ -2448,17 +2448,6 @@ int cras_client_set_system_volume(struct cras_client *client, size_t volume)
return write_message_to_server(client, &msg.header);
}
-int cras_client_set_system_capture_gain(struct cras_client *client, long gain)
-{
- struct cras_set_system_capture_gain msg;
-
- if (client == NULL)
- return -EINVAL;
-
- cras_fill_set_system_capture_gain(&msg, gain);
- return write_message_to_server(client, &msg.header);
-}
-
int cras_client_set_system_mute(struct cras_client *client, int mute)
{
struct cras_set_system_mute msg;
@@ -2613,34 +2602,6 @@ long cras_client_get_system_max_volume(const struct cras_client *client)
return max_volume;
}
-long cras_client_get_system_min_capture_gain(const struct cras_client *client)
-{
- long min_gain;
- int lock_rc;
-
- lock_rc = server_state_rdlock(client);
- if (lock_rc)
- return 0;
-
- min_gain = client->server_state->min_capture_gain;
- server_state_unlock(client, lock_rc);
- return min_gain;
-}
-
-long cras_client_get_system_max_capture_gain(const struct cras_client *client)
-{
- long max_gain;
- int lock_rc;
-
- lock_rc = server_state_rdlock(client);
- if (lock_rc)
- return 0;
-
- max_gain = client->server_state->max_capture_gain;
- server_state_unlock(client, lock_rc);
- return max_gain;
-}
-
const struct audio_debug_info *
cras_client_get_audio_debug_info(const struct cras_client *client)
{
diff --git a/cras/src/libcras/cras_client.h b/cras/src/libcras/cras_client.h
index 7aba374f..13fbd0ee 100644
--- a/cras/src/libcras/cras_client.h
+++ b/cras/src/libcras/cras_client.h
@@ -682,20 +682,6 @@ int cras_client_set_stream_volume(struct cras_client *client,
*/
int cras_client_set_system_volume(struct cras_client *client, size_t volume);
-/* Sets the capture gain of the system.
- *
- * Gain is specified in dBFS * 100. For example 5dB of gain would be specified
- * with an argument of 500, while -10 would be specified with -1000.
- *
- * Args:
- * client - The client from cras_client_create.
- * gain - The gain in dBFS * 100.
- * Returns:
- * 0 for success, -EPIPE if there is an I/O error talking to the server, or
- * -EINVAL if 'client' is invalid.
- */
-int cras_client_set_system_capture_gain(struct cras_client *client, long gain);
-
/* Sets the mute state of the system.
*
* Args:
@@ -771,17 +757,6 @@ int cras_client_set_system_capture_mute_locked(struct cras_client *client,
*/
size_t cras_client_get_system_volume(const struct cras_client *client);
-/* Gets the current system capture gain.
- *
- * Requires that the connection to the server has been established.
- *
- * Args:
- * client - The client from cras_client_create.
- * Returns:
- * The current system capture volume in dB * 100.
- */
-long cras_client_get_system_capture_gain(const struct cras_client *client);
-
/* Gets the current system mute state.
*
* Requires that the connection to the server has been established.
@@ -833,28 +808,6 @@ long cras_client_get_system_min_volume(const struct cras_client *client);
*/
long cras_client_get_system_max_volume(const struct cras_client *client);
-/* Gets the current minimum system capture gain.
- *
- * Requires that the connection to the server has been established.
- *
- * Args:
- * client - The client from cras_client_create.
- * Returns:
- * The minimum capture gain for the current input device in dBFS * 100.
- */
-long cras_client_get_system_min_capture_gain(const struct cras_client *client);
-
-/* Gets the current maximum system capture gain.
- *
- * Requires that the connection to the server has been established.
- *
- * Args:
- * client - The client from cras_client_create.
- * Returns:
- * The maximum capture gain for the current input device in dBFS * 100.
- */
-long cras_client_get_system_max_capture_gain(const struct cras_client *client);
-
/* Gets audio debug info.
*
* Requires that the connection to the server has been established.
diff --git a/cras/src/server/cras_alsa_io.c b/cras/src/server/cras_alsa_io.c
index 41446629..24e03dce 100644
--- a/cras/src/server/cras_alsa_io.c
+++ b/cras/src/server/cras_alsa_io.c
@@ -768,8 +768,7 @@ static void set_alsa_capture_gain(struct cras_iodev *iodev)
{
const struct alsa_io *aio = (const struct alsa_io *)iodev;
struct alsa_input_node *ain;
- long gain;
-
+ long min_capture_gain, max_capture_gain, gain;
assert(aio);
if (aio->mixer == NULL)
return;
@@ -778,14 +777,19 @@ static void set_alsa_capture_gain(struct cras_iodev *iodev)
if (!has_handle(aio))
return;
+ ain = get_active_input(aio);
+
/* Set hardware gain to 0dB if software gain is needed. */
if (cras_iodev_software_volume_needed(iodev))
gain = 0;
- else
- gain = cras_iodev_adjust_active_node_gain(
- iodev, cras_system_get_capture_gain());
-
- ain = get_active_input(aio);
+ else {
+ min_capture_gain = cras_alsa_mixer_get_minimum_capture_gain(
+ aio->mixer, ain ? ain->mixer_input : NULL);
+ max_capture_gain = cras_alsa_mixer_get_maximum_capture_gain(
+ aio->mixer, ain ? ain->mixer_input : NULL);
+ gain = MAX(iodev->active_node->capture_gain, min_capture_gain);
+ gain = MIN(gain, max_capture_gain);
+ }
cras_alsa_mixer_set_capture_dBFS(aio->mixer, gain,
ain ? ain->mixer_input : NULL);
@@ -819,28 +823,6 @@ static void init_device_settings(struct alsa_io *aio)
set_alsa_volume(&aio->base);
set_alsa_mute(&aio->base);
} else {
- struct mixer_control *mixer_input = NULL;
- struct alsa_input_node *ain = get_active_input(aio);
- long min_capture_gain, max_capture_gain;
-
- if (ain)
- mixer_input = ain->mixer_input;
-
- if (cras_iodev_software_volume_needed(&aio->base)) {
- min_capture_gain =
- cras_iodev_minimum_software_gain(&aio->base);
- max_capture_gain =
- cras_iodev_maximum_software_gain(&aio->base);
- } else {
- min_capture_gain =
- cras_alsa_mixer_get_minimum_capture_gain(
- aio->mixer, mixer_input);
- max_capture_gain =
- cras_alsa_mixer_get_maximum_capture_gain(
- aio->mixer, mixer_input);
- }
- cras_system_set_capture_gain_limits(min_capture_gain,
- max_capture_gain);
set_alsa_capture_gain(&aio->base);
}
}
@@ -1092,80 +1074,24 @@ set_output_node_software_volume_needed(struct alsa_output_node *output,
output->base.name);
}
-static void set_input_node_software_volume_needed(struct alsa_input_node *input,
- struct alsa_io *aio)
-{
- long min_software_gain;
- long max_software_gain;
- int rc;
-
- input->base.software_volume_needed = 0;
- input->base.min_software_gain = DEFAULT_MIN_CAPTURE_GAIN;
- input->base.max_software_gain = 0;
-
- /* TODO(enshuo): Deprecate the max and min software gain when intrinsic
- * sensitivity is done. */
-
- /* Enable software gain if max software gain is specified in UCM. */
- if (!aio->ucm)
- return;
-
- rc = ucm_get_max_software_gain(aio->ucm, input->base.name,
- &max_software_gain);
-
- /* If max software gain doesn't exist, skip min software gain setting. */
- if (rc)
- return;
-
- input->base.software_volume_needed = 1;
- input->base.max_software_gain = max_software_gain;
- syslog(LOG_INFO,
- "Use software gain for %s with max %ld because it is specified"
- " in UCM",
- input->base.name, max_software_gain);
-
- /* Enable min software gain if it is specified in UCM. */
- rc = ucm_get_min_software_gain(aio->ucm, input->base.name,
- &min_software_gain);
- if (rc)
- return;
-
- if (min_software_gain > max_software_gain) {
- syslog(LOG_ERR,
- "Ignore MinSoftwareGain %ld because it is larger than "
- "MaxSoftwareGain %ld",
- min_software_gain, max_software_gain);
- return;
- }
-
- syslog(LOG_INFO,
- "Use software gain for %s with min %ld because it is specified"
- " in UCM",
- input->base.name, min_software_gain);
- input->base.min_software_gain = min_software_gain;
-}
-
static void set_input_default_node_gain(struct alsa_input_node *input,
struct alsa_io *aio)
{
- long default_node_gain;
- int rc;
+ long gain;
- if (!aio->ucm)
- return;
+ input->base.capture_gain = DEFAULT_CAPTURE_GAIN;
- rc = ucm_get_default_node_gain(aio->ucm, input->base.name,
- &default_node_gain);
- if (rc)
+ if (!aio->ucm)
return;
- input->base.capture_gain = default_node_gain;
+ if (ucm_get_default_node_gain(aio->ucm, input->base.name, &gain) == 0)
+ input->base.capture_gain = gain;
}
static void set_input_node_intrinsic_sensitivity(struct alsa_input_node *input,
struct alsa_io *aio)
{
- long volume;
+ long sensitivity;
int rc;
input->base.intrinsic_sensitivity = 0;
@@ -1173,16 +1099,17 @@ static void set_input_node_intrinsic_sensitivity(struct alsa_input_node *input,
if (!aio->ucm)
return;
- rc = ucm_get_intrinsic_sensitivity(aio->ucm, input->base.name, &volume);
+ rc = ucm_get_intrinsic_sensitivity(aio->ucm, input->base.name,
+ &sensitivity);
if (rc)
return;
- input->base.intrinsic_sensitivity = volume;
- input->base.capture_gain = DEFAULT_CAPTURE_VOLUME_DBFS - volume;
+ input->base.intrinsic_sensitivity = sensitivity;
+ input->base.capture_gain = DEFAULT_CAPTURE_VOLUME_DBFS - sensitivity;
syslog(LOG_INFO,
"Use software gain %ld for %s because IntrinsicSensitivity %ld is"
" specified in UCM",
- input->base.capture_gain, input->base.name, volume);
+ input->base.capture_gain, input->base.name, sensitivity);
}
static void check_auto_unplug_output_node(struct alsa_io *aio,
@@ -1317,7 +1244,6 @@ static struct alsa_input_node *new_input(struct alsa_io *aio,
input->mixer_input = cras_input;
strncpy(input->base.name, name, sizeof(input->base.name) - 1);
set_node_initial_state(&input->base, aio->card_type);
- set_input_node_software_volume_needed(input, aio);
set_input_default_node_gain(input, aio);
set_input_node_intrinsic_sensitivity(input, aio);
diff --git a/cras/src/server/cras_alsa_ucm.c b/cras/src/server/cras_alsa_ucm.c
index 125b7efb..66bd1b67 100644
--- a/cras/src/server/cras_alsa_ucm.c
+++ b/cras/src/server/cras_alsa_ucm.c
@@ -50,17 +50,6 @@ static const char echo_reference_dev_name_var[] = "EchoReferenceDev";
static const char intrinsic_sensitivity_var[] = "IntrinsicSensitivity";
/*
- * Set this value in a SectionDevice to specify the minimum software gain in
- * 0.01 dB and enable software gain on this node. It must be used with
- * MaxSoftwareGain. If not, the value will be ignored.
- */
-static const char min_software_gain[] = "MinSoftwareGain";
-/*
- * Set this value in a SectionDevice to specify the maximum software gain in
- * 0.01 dB and enable software gain on this node.
- */
-static const char max_software_gain[] = "MaxSoftwareGain";
-/*
* Set this value in a SectionDevice to specify the default node gain in
* 0.01 dB.
*/
@@ -682,32 +671,6 @@ unsigned int ucm_get_disable_software_volume(struct cras_use_case_mgr *mgr)
return value;
}
-int ucm_get_min_software_gain(struct cras_use_case_mgr *mgr, const char *dev,
- long *gain)
-{
- int value;
- int rc;
-
- rc = get_int(mgr, min_software_gain, dev, uc_verb(mgr), &value);
- if (rc)
- return rc;
- *gain = value;
- return 0;
-}
-
-int ucm_get_max_software_gain(struct cras_use_case_mgr *mgr, const char *dev,
- long *gain)
-{
- int value;
- int rc;
-
- rc = get_int(mgr, max_software_gain, dev, uc_verb(mgr), &value);
- if (rc)
- return rc;
- *gain = value;
- return 0;
-}
-
int ucm_get_default_node_gain(struct cras_use_case_mgr *mgr, const char *dev,
long *gain)
{
@@ -722,7 +685,7 @@ int ucm_get_default_node_gain(struct cras_use_case_mgr *mgr, const char *dev,
}
int ucm_get_intrinsic_sensitivity(struct cras_use_case_mgr *mgr,
- const char *dev, long *vol)
+ const char *dev, long *sensitivity)
{
int value;
int rc;
@@ -730,7 +693,7 @@ int ucm_get_intrinsic_sensitivity(struct cras_use_case_mgr *mgr,
rc = get_int(mgr, intrinsic_sensitivity_var, dev, uc_verb(mgr), &value);
if (rc)
return rc;
- *vol = value;
+ *sensitivity = value;
return 0;
}
diff --git a/cras/src/server/cras_alsa_ucm.h b/cras/src/server/cras_alsa_ucm.h
index b9b36a78..b8d72c41 100644
--- a/cras/src/server/cras_alsa_ucm.h
+++ b/cras/src/server/cras_alsa_ucm.h
@@ -185,28 +185,6 @@ int ucm_get_min_buffer_level(struct cras_use_case_mgr *mgr,
*/
unsigned int ucm_get_disable_software_volume(struct cras_use_case_mgr *mgr);
-/* Gets the value for minimum software gain.
- * Args:
- * mgr - The cras_use_case_mgr pointer returned from alsa_ucm_create.
- * dev - The device to check for minimum software gain.
- * gain - The pointer to the returned value.
- * Returns:
- * 0 on success, other error codes on failure.
- */
-int ucm_get_min_software_gain(struct cras_use_case_mgr *mgr, const char *dev,
- long *gain);
-
-/* Gets the value for maximum software gain.
- * Args:
- * mgr - The cras_use_case_mgr pointer returned from alsa_ucm_create.
- * dev - The device to check for maximum software gain.
- * gain - The pointer to the returned value.
- * Returns:
- * 0 on success, other error codes on failure.
- */
-int ucm_get_max_software_gain(struct cras_use_case_mgr *mgr, const char *dev,
- long *gain);
-
/* Gets the value for default node gain.
* Args:
* mgr - The cras_use_case_mgr pointer returned from alsa_ucm_create.
@@ -222,12 +200,12 @@ int ucm_get_default_node_gain(struct cras_use_case_mgr *mgr, const char *dev,
* Args:
* mgr - The cras_use_case_mgr pointer returned from alsa_ucm_create.
* dev - The device to query for intrinsic volume.
- * vol - The pointer to the returned value.
+ * sensitivity - The pointer to the returned value.
* Returns:
* 0 on success, other error codes on failure.
*/
int ucm_get_intrinsic_sensitivity(struct cras_use_case_mgr *mgr,
- const char *dev, long *vol);
+ const char *dev, long *sensitivity);
/* Gets the flag if an input device can preempt hotword recording.
* Args:
diff --git a/cras/src/server/cras_bt_io.c b/cras/src/server/cras_bt_io.c
index 8f3c3e2e..27ec15e4 100644
--- a/cras/src/server/cras_bt_io.c
+++ b/cras/src/server/cras_bt_io.c
@@ -70,7 +70,7 @@ static struct cras_ionode *add_profile_dev(struct cras_iodev *bt_iodev,
n->base.type = CRAS_NODE_TYPE_BLUETOOTH;
n->base.volume = 100;
n->base.stable_id = dev->info.stable_id;
- n->base.max_software_gain = 0;
+ n->base.capture_gain = 0;
gettimeofday(&n->base.plugged_time, NULL);
strcpy(n->base.name, dev->info.name);
diff --git a/cras/src/server/cras_control_rclient.c b/cras/src/server/cras_control_rclient.c
index c0eea5d6..209762da 100644
--- a/cras/src/server/cras_control_rclient.c
+++ b/cras/src/server/cras_control_rclient.c
@@ -335,14 +335,6 @@ static int ccr_handle_message_from_client(struct cras_rclient *client,
cras_system_set_mute_locked(
((const struct cras_set_system_mute *)msg)->mute);
break;
- case CRAS_SERVER_SET_SYSTEM_CAPTURE_GAIN: {
- const struct cras_set_system_capture_gain *m =
- (const struct cras_set_system_capture_gain *)msg;
- if (!MSG_LEN_VALID(msg, struct cras_set_system_capture_gain))
- return -EINVAL;
- cras_system_set_capture_gain(m->gain);
- break;
- }
case CRAS_SERVER_SET_SYSTEM_CAPTURE_MUTE:
if (!MSG_LEN_VALID(msg, struct cras_set_system_mute))
return -EINVAL;
diff --git a/cras/src/server/cras_dbus_control.c b/cras/src/server/cras_dbus_control.c
index 173e6984..a5b4618b 100644
--- a/cras/src/server/cras_dbus_control.c
+++ b/cras/src/server/cras_dbus_control.c
@@ -47,9 +47,6 @@
" <method name=\"SetSuspendAudio\">\n" \
" <arg name=\"suspend\" type=\"b\" direction=\"in\"/>\n" \
" </method>\n" \
- " <method name=\"SetInputGain\">\n" \
- " <arg name=\"gain\" type=\"i\" direction=\"in\"/>\n" \
- " </method>\n" \
" <method name=\"SetInputNodeGain\">\n" \
" <arg name=\"node_id\" type=\"t\" direction=\"in\"/>\n" \
" <arg name=\"gain\" type=\"i\" direction=\"in\"/>\n" \
@@ -60,7 +57,6 @@
" <method name=\"GetVolumeState\">\n" \
" <arg name=\"output_volume\" type=\"i\" direction=\"out\"/>\n" \
" <arg name=\"output_mute\" type=\"b\" direction=\"out\"/>\n" \
- " <arg name=\"input_gain\" type=\"i\" direction=\"out\"/>\n" \
" <arg name=\"input_mute\" type=\"b\" direction=\"out\"/>\n" \
" <arg name=\"output_user_mute\" type=\"b\" direction=\"out\"/>\n" \
" </method>\n" \
@@ -302,23 +298,6 @@ handle_set_suspend_audio(DBusConnection *conn, DBusMessage *message, void *arg)
return DBUS_HANDLER_RESULT_HANDLED;
}
-static DBusHandlerResult handle_set_input_gain(DBusConnection *conn,
- DBusMessage *message, void *arg)
-{
- int rc;
- dbus_int32_t new_gain;
-
- rc = get_single_arg(message, DBUS_TYPE_INT32, &new_gain);
- if (rc)
- return rc;
-
- cras_system_set_capture_gain(new_gain);
-
- send_empty_reply(conn, message);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
static DBusHandlerResult handle_set_input_node_gain(DBusConnection *conn,
DBusMessage *message,
void *arg)
@@ -370,7 +349,6 @@ handle_get_volume_state(DBusConnection *conn, DBusMessage *message, void *arg)
dbus_int32_t volume;
dbus_bool_t system_muted;
dbus_bool_t user_muted;
- dbus_int32_t capture_gain;
dbus_bool_t capture_muted;
reply = dbus_message_new_method_return(message);
@@ -378,12 +356,10 @@ handle_get_volume_state(DBusConnection *conn, DBusMessage *message, void *arg)
volume = cras_system_get_volume();
system_muted = cras_system_get_system_mute();
user_muted = cras_system_get_user_mute();
- capture_gain = cras_system_get_capture_gain();
capture_muted = cras_system_get_capture_mute();
dbus_message_append_args(reply, DBUS_TYPE_INT32, &volume,
DBUS_TYPE_BOOLEAN, &system_muted,
- DBUS_TYPE_INT32, &capture_gain,
DBUS_TYPE_BOOLEAN, &capture_muted,
DBUS_TYPE_BOOLEAN, &user_muted,
DBUS_TYPE_INVALID);
@@ -835,9 +811,6 @@ static DBusHandlerResult handle_control_message(DBusConnection *conn,
"SetSuspendAudio")) {
return handle_set_suspend_audio(conn, message, arg);
} else if (dbus_message_is_method_call(message, CRAS_CONTROL_INTERFACE,
- "SetInputGain")) {
- return handle_set_input_gain(conn, message, arg);
- } else if (dbus_message_is_method_call(message, CRAS_CONTROL_INTERFACE,
"SetInputNodeGain")) {
return handle_set_input_node_gain(conn, message, arg);
} else if (dbus_message_is_method_call(message, CRAS_CONTROL_INTERFACE,
diff --git a/cras/src/server/cras_iodev.c b/cras/src/server/cras_iodev.c
index 63686d0e..b115137f 100644
--- a/cras/src/server/cras_iodev.c
+++ b/cras/src/server/cras_iodev.c
@@ -741,13 +741,10 @@ float cras_iodev_get_software_volume_scaler(struct cras_iodev *iodev)
float cras_iodev_get_software_gain_scaler(const struct cras_iodev *iodev)
{
- float scaler = 1.0f;
- if (cras_iodev_software_volume_needed(iodev)) {
- long gain = cras_iodev_adjust_active_node_gain(
- iodev, cras_system_get_capture_gain());
- scaler = convert_softvol_scaler_from_dB(gain);
- }
- return scaler;
+ if (cras_iodev_software_volume_needed(iodev))
+ return convert_softvol_scaler_from_dB(
+ iodev->active_node->capture_gain);
+ return 1.0f;
}
int cras_iodev_get_valid_frames(struct cras_iodev *odev,
@@ -975,8 +972,8 @@ int cras_iodev_open(struct cras_iodev *iodev, unsigned int cb_level,
/*
* The device specific gain scaler to be used in audio thread.
* It's expected to stick to 1.0f if device has hardware gain
- * control. For alsa device, this gain value can be configured
- * through UCM labels DefaultNodeGain.
+ * control. For alsa device, this gain value will be configured
+ * based on UCM labels IntrinsicSensitivity.
*/
iodev->software_gain_scaler =
cras_iodev_get_software_gain_scaler(iodev);
diff --git a/cras/src/server/cras_iodev.h b/cras/src/server/cras_iodev.h
index bdd6216a..e09d7e85 100644
--- a/cras/src/server/cras_iodev.h
+++ b/cras/src/server/cras_iodev.h
@@ -110,8 +110,6 @@ enum CRAS_IODEV_STATE {
* software_volume_needed - For output: True if the volume range of the node
* is smaller than desired. For input: True if this node needs software
* gain.
- * min_software_gain - The minimum software gain in 0.01 dB if needed.
- * max_software_gain - The maximum software gain in 0.01 dB if needed.
* intrinsic_sensitivity - The "IntrinsicSensitivity" in 0.01 dBFS/Pa
* specified in the ucm config.
* stable_id - id for node that doesn't change after unplug/plug.
@@ -133,8 +131,6 @@ struct cras_ionode {
char active_hotword_model[CRAS_NODE_HOTWORD_MODEL_BUFFER_SIZE];
float *softvol_scalers;
int software_volume_needed;
- long min_software_gain;
- long max_software_gain;
long intrinsic_sensitivity;
unsigned int stable_id;
int is_sco_pcm;
@@ -143,8 +139,8 @@ struct cras_ionode {
/* An input or output device, that can have audio routed to/from it.
* set_volume - Function to call if the system volume changes.
+ * set_capture_gain - Function to call if active node's capture_gain changes.
* set_mute - Function to call if the system mute state changes.
- * set_capture_gain - Function to call if the system capture_gain changes.
* set_capture_mute - Function to call if the system capture mute state changes.
* set_swap_mode_for_node - Function to call to set swap mode for the node.
* open_dev - Opens the device.
@@ -478,17 +474,6 @@ cras_iodev_adjust_active_node_volume(struct cras_iodev *iodev,
return cras_iodev_adjust_node_volume(iodev->active_node, system_volume);
}
-/* Get the gain adjusted based on system for the active node. */
-static inline long
-cras_iodev_adjust_active_node_gain(const struct cras_iodev *iodev,
- long system_gain)
-{
- if (!iodev->active_node)
- return system_gain;
-
- return iodev->active_node->capture_gain + system_gain;
-}
-
/* Returns true if the active node of the iodev needs software volume. */
static inline int
cras_iodev_software_volume_needed(const struct cras_iodev *iodev)
@@ -505,38 +490,6 @@ cras_iodev_software_volume_needed(const struct cras_iodev *iodev)
return iodev->active_node->software_volume_needed;
}
-/* Returns minimum software gain for the iodev.
- * Args:
- * iodev - The device.
- * Returs:
- * 0 if software gain is not needed, or if there is no active node.
- * Returns min_software_gain on active node if there is one. */
-static inline long
-cras_iodev_minimum_software_gain(const struct cras_iodev *iodev)
-{
- if (!cras_iodev_software_volume_needed(iodev))
- return 0;
- if (!iodev->active_node)
- return 0;
- return iodev->active_node->min_software_gain;
-}
-
-/* Returns maximum software gain for the iodev.
- * Args:
- * iodev - The device.
- * Returs:
- * 0 if software gain is not needed, or if there is no active node.
- * Returns max_software_gain on active node if there is one. */
-static inline long
-cras_iodev_maximum_software_gain(const struct cras_iodev *iodev)
-{
- if (!cras_iodev_software_volume_needed(iodev))
- return 0;
- if (!iodev->active_node)
- return 0;
- return iodev->active_node->max_software_gain;
-}
-
/* Gets the software gain scaler should be applied on the deivce.
* Args:
* iodev - The device.
diff --git a/cras/src/server/cras_iodev_list.c b/cras/src/server/cras_iodev_list.c
index 99d6e11c..5e00e414 100644
--- a/cras/src/server/cras_iodev_list.c
+++ b/cras/src/server/cras_iodev_list.c
@@ -555,18 +555,6 @@ void sys_suspend_change(void *arg, int suspended)
resume_devs();
}
-/* Called when the system capture gain changes. Pass the current capture_gain
- * setting to the default input if it is active. */
-void sys_cap_gain_change(void *context, int32_t gain)
-{
- struct cras_iodev *dev;
-
- DL_FOREACH (devs[CRAS_STREAM_INPUT].iodevs, dev) {
- if (dev->set_capture_gain && cras_iodev_is_open(dev))
- dev->set_capture_gain(dev);
- }
-}
-
/* Called when the system capture mute state changes. Pass the current capture
* mute setting to the default input if it is active. */
static void sys_cap_mute_change(void *context, int muted, int mute_locked)
@@ -1035,7 +1023,6 @@ void cras_iodev_list_init()
memset(&observer_ops, 0, sizeof(observer_ops));
observer_ops.output_volume_changed = sys_vol_change;
observer_ops.output_mute_changed = sys_mute_change;
- observer_ops.capture_gain_changed = sys_cap_gain_change;
observer_ops.capture_mute_changed = sys_cap_mute_change;
observer_ops.suspend_changed = sys_suspend_change;
list_observer = cras_observer_add(&observer_ops, NULL);
diff --git a/cras/src/server/cras_loopback_iodev.c b/cras/src/server/cras_loopback_iodev.c
index dea96169..8077fdcb 100644
--- a/cras/src/server/cras_loopback_iodev.c
+++ b/cras/src/server/cras_loopback_iodev.c
@@ -317,7 +317,6 @@ struct cras_iodev *loopback_iodev_create(enum CRAS_LOOPBACK_TYPE type)
node->volume = 100;
node->stable_id = iodev->info.stable_id;
node->software_volume_needed = 0;
- node->max_software_gain = 0;
strcpy(node->name, loopdev_names[type]);
cras_iodev_add_node(iodev, node);
cras_iodev_set_active_node(iodev, node);
diff --git a/cras/src/server/cras_system_state.c b/cras/src/server/cras_system_state.c
index 7a4a5c22..8648072d 100644
--- a/cras/src/server/cras_system_state.c
+++ b/cras/src/server/cras_system_state.c
@@ -103,14 +103,10 @@ void cras_system_state_init(const char *device_config_dir, const char *shm_name,
exp_state->mute = 0;
exp_state->mute_locked = 0;
exp_state->suspended = 0;
- exp_state->capture_gain = DEFAULT_CAPTURE_GAIN;
- exp_state->capture_gain_target = DEFAULT_CAPTURE_GAIN;
exp_state->capture_mute = 0;
exp_state->capture_mute_locked = 0;
exp_state->min_volume_dBFS = DEFAULT_MIN_VOLUME_DBFS;
exp_state->max_volume_dBFS = DEFAULT_MAX_VOLUME_DBFS;
- exp_state->min_capture_gain = DEFAULT_MIN_CAPTURE_GAIN;
- exp_state->max_capture_gain = DEFAULT_MAX_CAPTURE_GAIN;
exp_state->num_streams_attached = 0;
exp_state->default_output_buffer_size =
board_config.default_output_buffer_size;
@@ -187,21 +183,6 @@ size_t cras_system_get_volume()
return state.exp_state->volume;
}
-void cras_system_set_capture_gain(long gain)
-{
- /* Adjust targeted gain to be in supported range. */
- state.exp_state->capture_gain_target = gain;
- gain = MAX(gain, state.exp_state->min_capture_gain);
- gain = MIN(gain, state.exp_state->max_capture_gain);
- state.exp_state->capture_gain = gain;
- cras_observer_notify_capture_gain(state.exp_state->capture_gain);
-}
-
-long cras_system_get_capture_gain()
-{
- return state.exp_state->capture_gain;
-}
-
void cras_system_notify_mute(void)
{
cras_observer_notify_output_mute(state.exp_state->mute,
@@ -328,24 +309,6 @@ long cras_system_get_max_volume()
return state.exp_state->max_volume_dBFS;
}
-void cras_system_set_capture_gain_limits(long min, long max)
-{
- state.exp_state->min_capture_gain = MAX(min, DEFAULT_MIN_CAPTURE_GAIN);
- state.exp_state->max_capture_gain = max;
- /* Re-apply target gain subjected to the new supported range. */
- cras_system_set_capture_gain(state.exp_state->capture_gain_target);
-}
-
-long cras_system_get_min_capture_gain()
-{
- return state.exp_state->min_capture_gain;
-}
-
-long cras_system_get_max_capture_gain()
-{
- return state.exp_state->max_capture_gain;
-}
-
int cras_system_get_default_output_buffer_size()
{
return state.exp_state->default_output_buffer_size;
diff --git a/cras/src/server/cras_system_state.h b/cras/src/server/cras_system_state.h
index 553c8456..3311c314 100644
--- a/cras/src/server/cras_system_state.h
+++ b/cras/src/server/cras_system_state.h
@@ -57,9 +57,8 @@ void cras_system_set_volume(size_t volume);
/* Gets the current system volume. */
size_t cras_system_get_volume();
-/* Sets the system capture volume. Will be applied by the active device. */
-void cras_system_set_capture_gain(long gain);
-/* Gets the current system capture volume. */
+/* Gets the current system capture volume. As we remove the support of setting
+ * system capture gain, it should always be DEFAULT_CAPTURE_GAIN now. */
long cras_system_get_capture_gain();
/* Sets if the system is muted by the user. */
@@ -108,19 +107,6 @@ long cras_system_get_min_volume();
/* Returns the dB value when volume = CRAS_MAX_SYSTEM_VOLUME, in dB * 100. */
long cras_system_get_max_volume();
-/* Sets the limits in dB * 100 of the MAX and MIN capture gain. This will allow
- * clients to query what range of control is available. Both arguments are
- * specified as dB * 100.
- * Args:
- * min - minimum allowed capture gain.
- * max - maximum allowed capture gaax.
- */
-void cras_system_set_capture_gain_limits(long min, long max);
-/* Returns the max value allowed for capture gain in dB * 100. */
-long cras_system_get_min_capture_gain();
-/* Returns the min value allowed for capture gain in dB * 100. */
-long cras_system_get_max_capture_gain();
-
/* Returns the default value of output buffer size in frames. */
int cras_system_get_default_output_buffer_size();
diff --git a/cras/src/server/test_iodev.c b/cras/src/server/test_iodev.c
index 47ff3363..19e65228 100644
--- a/cras/src/server/test_iodev.c
+++ b/cras/src/server/test_iodev.c
@@ -204,7 +204,6 @@ struct cras_iodev *test_iodev_create(enum CRAS_STREAM_DIRECTION direction,
node->type = CRAS_NODE_TYPE_UNKNOWN;
node->volume = 100;
node->software_volume_needed = 0;
- node->max_software_gain = 0;
strcpy(node->name, "(default)");
cras_iodev_add_node(iodev, node);
cras_iodev_set_active_node(iodev, node);
diff --git a/cras/src/tests/alsa_io_unittest.cc b/cras/src/tests/alsa_io_unittest.cc
index a44354f6..4363bec4 100644
--- a/cras/src/tests/alsa_io_unittest.cc
+++ b/cras/src/tests/alsa_io_unittest.cc
@@ -49,8 +49,6 @@ static struct mixer_control*
cras_alsa_mixer_get_control_for_section_return_value;
static size_t sys_get_volume_called;
static size_t sys_get_volume_return_value;
-static size_t sys_get_capture_gain_called;
-static long sys_get_capture_gain_return_value;
static size_t alsa_mixer_set_mute_called;
static int alsa_mixer_set_mute_value;
static size_t alsa_mixer_get_dB_range_called;
@@ -77,7 +75,6 @@ static std::vector<struct mixer_control*>
static std::vector<int> cras_alsa_mixer_set_output_active_state_values;
static cras_audio_format* fake_format;
static size_t sys_set_volume_limits_called;
-static size_t sys_set_capture_gain_limits_called;
static size_t cras_alsa_mixer_get_minimum_capture_gain_called;
static size_t cras_alsa_mixer_get_maximum_capture_gain_called;
static struct mixer_control* cras_alsa_jack_get_mixer_output_ret;
@@ -121,13 +118,6 @@ static const char* cras_alsa_jack_get_name_ret_value = 0;
static char default_jack_name[] = "Something Jack";
static int auto_unplug_input_node_ret = 0;
static int auto_unplug_output_node_ret = 0;
-static int ucm_get_min_software_gain_called;
-static int ucm_get_min_software_gain_ret_value;
-static long ucm_get_min_software_gain_value;
-static int ucm_get_max_software_gain_called;
-static int ucm_get_max_software_gain_ret_value;
-static long ucm_get_max_software_gain_value;
-static long cras_system_set_capture_gain_limits_set_value[2];
static long cras_alsa_mixer_get_minimum_capture_gain_ret_value;
static long cras_alsa_mixer_get_maximum_capture_gain_ret_value;
static snd_pcm_state_t snd_pcm_state_ret;
@@ -163,7 +153,6 @@ void ResetStubData() {
cras_alsa_start_called = 0;
cras_alsa_fill_properties_called = 0;
sys_get_volume_called = 0;
- sys_get_capture_gain_called = 0;
alsa_mixer_set_dBFS_called = 0;
alsa_mixer_set_capture_dBFS_called = 0;
sys_get_mute_called = 0;
@@ -182,8 +171,6 @@ void ResetStubData() {
cras_alsa_mixer_set_output_active_state_outputs.clear();
cras_alsa_mixer_set_output_active_state_values.clear();
sys_set_volume_limits_called = 0;
- sys_set_capture_gain_limits_called = 0;
- sys_get_capture_gain_return_value = 0;
cras_alsa_mixer_get_minimum_capture_gain_called = 0;
cras_alsa_mixer_get_maximum_capture_gain_called = 0;
cras_alsa_mixer_get_output_volume_curve_called = 0;
@@ -214,16 +201,8 @@ void ResetStubData() {
cras_alsa_jack_get_name_called = 0;
cras_alsa_jack_get_name_ret_value = default_jack_name;
cras_alsa_jack_update_monitor_fake_name = 0;
- ucm_get_min_software_gain_called = 0;
- ucm_get_min_software_gain_ret_value = -1;
- ucm_get_min_software_gain_value = 0;
- ucm_get_max_software_gain_called = 0;
- ucm_get_max_software_gain_ret_value = -1;
- ucm_get_max_software_gain_value = 0;
cras_card_config_get_volume_curve_for_control_called = 0;
cras_card_config_get_volume_curve_vals.clear();
- cras_system_set_capture_gain_limits_set_value[0] = -1;
- cras_system_set_capture_gain_limits_set_value[1] = -1;
cras_alsa_mixer_get_minimum_capture_gain_ret_value = 0;
cras_alsa_mixer_get_maximum_capture_gain_ret_value = 0;
snd_pcm_state_ret = SND_PCM_STATE_RUNNING;
@@ -480,124 +459,6 @@ TEST(AlsaIoInit, UsbCardUseSoftwareVolume) {
alsa_iodev_destroy(iodev);
}
-TEST(AlsaIoInit, UseSoftwareGain) {
- struct cras_iodev* iodev;
- struct cras_use_case_mgr* const fake_ucm = (struct cras_use_case_mgr*)3;
-
- /* MaxSoftwareGain is specified in UCM */
- ResetStubData();
- ucm_get_min_software_gain_ret_value = 1;
- ucm_get_min_software_gain_value = 1;
- ucm_get_max_software_gain_ret_value = 0;
- ucm_get_max_software_gain_value = 2000;
- iodev = alsa_iodev_create_with_default_parameters(
- 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_config, fake_ucm,
- CRAS_STREAM_INPUT);
- ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
- EXPECT_EQ(1, iodev->active_node->software_volume_needed);
- EXPECT_EQ(DEFAULT_MIN_CAPTURE_GAIN, iodev->active_node->min_software_gain);
- EXPECT_EQ(2000, iodev->active_node->max_software_gain);
- ASSERT_EQ(1, sys_set_capture_gain_limits_called);
- /* The gain range is [DEFAULT_MIN_CAPTURE_GAIN, maximum software gain]. */
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[0],
- DEFAULT_MIN_CAPTURE_GAIN);
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[1], 2000);
-
- alsa_iodev_destroy(iodev);
-
- /* MaxSoftwareGain and MinSoftwareGain are specified in UCM. */
- ResetStubData();
- ucm_get_min_software_gain_ret_value = 0;
- ucm_get_min_software_gain_value = 1000;
- ucm_get_max_software_gain_ret_value = 0;
- ucm_get_max_software_gain_value = 2000;
- iodev = alsa_iodev_create_with_default_parameters(
- 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_config, fake_ucm,
- CRAS_STREAM_INPUT);
- ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
- EXPECT_EQ(1, iodev->active_node->software_volume_needed);
- EXPECT_EQ(1000, iodev->active_node->min_software_gain);
- EXPECT_EQ(2000, iodev->active_node->max_software_gain);
- ASSERT_EQ(1, sys_set_capture_gain_limits_called);
- /* The gain range is [minimum software gain, maximum software gain]. */
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[0], 1000);
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[1], 2000);
-
- alsa_iodev_destroy(iodev);
-
- /* MinSoftwareGain is larger than MaxSoftwareGain in UCM. */
- ResetStubData();
- ucm_get_min_software_gain_ret_value = 0;
- ucm_get_min_software_gain_value = 3000;
- ucm_get_max_software_gain_ret_value = 0;
- ucm_get_max_software_gain_value = 2000;
- iodev = alsa_iodev_create_with_default_parameters(
- 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_config, fake_ucm,
- CRAS_STREAM_INPUT);
- ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
- EXPECT_EQ(1, iodev->active_node->software_volume_needed);
- EXPECT_EQ(DEFAULT_MIN_CAPTURE_GAIN, iodev->active_node->min_software_gain);
- EXPECT_EQ(2000, iodev->active_node->max_software_gain);
- ASSERT_EQ(1, sys_set_capture_gain_limits_called);
- /* The gain range is [DEFAULT_MIN_CAPTURE_GAIN, maximum software gain]. */
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[0],
- DEFAULT_MIN_CAPTURE_GAIN);
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[1], 2000);
-
- alsa_iodev_destroy(iodev);
-
- /* MaxSoftwareGain is not specified in UCM. */
- ResetStubData();
- ucm_get_max_software_gain_ret_value = 1;
- ucm_get_max_software_gain_value = 1;
- cras_alsa_mixer_get_minimum_capture_gain_ret_value = -500;
- cras_alsa_mixer_get_maximum_capture_gain_ret_value = 500;
- iodev = alsa_iodev_create_with_default_parameters(
- 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_config, fake_ucm,
- CRAS_STREAM_INPUT);
- ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
- EXPECT_EQ(0, iodev->active_node->software_volume_needed);
- EXPECT_EQ(0, iodev->active_node->max_software_gain);
- ASSERT_EQ(1, sys_set_capture_gain_limits_called);
- /* The gain range is reported by controls. */
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[0], -500);
- ASSERT_EQ(cras_system_set_capture_gain_limits_set_value[1], 500);
-
- alsa_iodev_destroy(iodev);
-}
-
-TEST(AlsaIoInit, SoftwareGainWithDefaultNodeGain) {
- struct cras_iodev* iodev;
- struct cras_use_case_mgr* const fake_ucm = (struct cras_use_case_mgr*)3;
- long system_gain = 500;
- long default_node_gain = -1000;
-
- ResetStubData();
-
- // Use software gain.
- ucm_get_max_software_gain_ret_value = 0;
- ucm_get_max_software_gain_value = 2000;
-
- // Set default node gain to -1000 * 0.01 dB.
- ucm_get_default_node_gain_values[INTERNAL_MICROPHONE] = default_node_gain;
-
- // Assume this is the first device so it gets internal mic node name.
- iodev = alsa_iodev_create_with_default_parameters(
- 0, NULL, ALSA_CARD_TYPE_INTERNAL, 1, fake_mixer, fake_config, fake_ucm,
- CRAS_STREAM_INPUT);
- ASSERT_EQ(0, alsa_iodev_legacy_complete_init(iodev));
-
- // Gain on node is 300 * 0.01 dB.
- iodev->active_node->capture_gain = default_node_gain;
-
- // cras_iodev will call cras_iodev_adjust_active_node_gain to get gain for
- // software gain.
- ASSERT_EQ(system_gain + default_node_gain,
- cras_iodev_adjust_active_node_gain(iodev, system_gain));
-
- alsa_iodev_destroy(iodev);
-}
-
TEST(AlsaIoInit, SoftwareGainIntrinsicSensitivity) {
struct cras_iodev* iodev;
struct cras_use_case_mgr* const fake_ucm = (struct cras_use_case_mgr*)3;
@@ -605,7 +466,7 @@ TEST(AlsaIoInit, SoftwareGainIntrinsicSensitivity) {
ResetStubData();
- // Set intrinsic volume to -2700 * 0.01 dBFS.
+ // Set intrinsic sensitivity to -2700 * 0.01 dBFS/Pa.
ucm_get_intrinsic_sensitivity_values[INTERNAL_MICROPHONE] =
intrinsic_sensitivity;
@@ -717,8 +578,6 @@ TEST(AlsaIoInit, OpenCapture) {
EXPECT_EQ(1, cras_alsa_open_called);
EXPECT_EQ(1, cras_alsa_mixer_get_minimum_capture_gain_called);
EXPECT_EQ(1, cras_alsa_mixer_get_maximum_capture_gain_called);
- EXPECT_EQ(1, sys_set_capture_gain_limits_called);
- EXPECT_EQ(1, sys_get_capture_gain_called);
EXPECT_EQ(1, alsa_mixer_set_capture_dBFS_called);
EXPECT_EQ(1, sys_get_capture_mute_called);
EXPECT_EQ(1, alsa_mixer_set_capture_mute_called);
@@ -734,8 +593,7 @@ TEST(AlsaIoInit, OpenCaptureSetCaptureGainWithDefaultNodeGain) {
struct cras_iodev* iodev;
struct cras_audio_format format;
struct cras_use_case_mgr* const fake_ucm = (struct cras_use_case_mgr*)3;
- long system_gain = 2000;
- long default_node_gain = -1000;
+ long default_node_gain = 1000;
ResetStubData();
// Set default node gain to -1000 * 0.01 dB.
@@ -751,15 +609,24 @@ TEST(AlsaIoInit, OpenCaptureSetCaptureGainWithDefaultNodeGain) {
// Check the default node gain is the same as what specified in UCM.
EXPECT_EQ(default_node_gain, iodev->active_node->capture_gain);
- // System gain is set to 2000 * 0.01 dB.
- sys_get_capture_gain_return_value = system_gain;
+ cras_alsa_mixer_get_minimum_capture_gain_ret_value = 0;
+ cras_alsa_mixer_get_maximum_capture_gain_ret_value = 2000;
+
+ iodev->open_dev(iodev);
+ iodev->configure_dev(iodev);
+ iodev->close_dev(iodev);
+
+ // Hardware gain is in the hardware gain range and set to 1000 * 0.01 dB.
+ EXPECT_EQ(default_node_gain, alsa_mixer_set_capture_dBFS_value);
+
+ // Check we do respect the hardware maximum capture gain.
+ cras_alsa_mixer_get_maximum_capture_gain_ret_value = 500;
iodev->open_dev(iodev);
iodev->configure_dev(iodev);
iodev->close_dev(iodev);
- // Hardware gain is set to (2000 - 1000) * 0.01 dB.
- EXPECT_EQ(system_gain + default_node_gain, alsa_mixer_set_capture_dBFS_value);
+ EXPECT_EQ(500, alsa_mixer_set_capture_dBFS_value);
alsa_iodev_destroy(iodev);
free(fake_format);
@@ -772,8 +639,6 @@ TEST(AlsaIoInit, OpenCaptureSetCaptureGainWithSoftwareGain) {
/* Meet the requirements of using software gain. */
ResetStubData();
- ucm_get_max_software_gain_ret_value = 0;
- ucm_get_max_software_gain_value = 2000;
iodev = alsa_iodev_create_with_default_parameters(
0, NULL, ALSA_CARD_TYPE_INTERNAL, 0, fake_mixer, fake_config, fake_ucm,
@@ -784,9 +649,6 @@ TEST(AlsaIoInit, OpenCaptureSetCaptureGainWithSoftwareGain) {
format.num_channels = 1;
cras_iodev_set_format(iodev, &format);
- /* System gain is set to 1000 * 0.01 dB */
- sys_get_capture_gain_return_value = 1000;
-
iodev->open_dev(iodev);
iodev->configure_dev(iodev);
iodev->close_dev(iodev);
@@ -796,12 +658,13 @@ TEST(AlsaIoInit, OpenCaptureSetCaptureGainWithSoftwareGain) {
/* Test the case where software gain is not needed. */
iodev->active_node->software_volume_needed = 0;
+ iodev->active_node->capture_gain = 1000;
iodev->open_dev(iodev);
iodev->configure_dev(iodev);
iodev->close_dev(iodev);
- /* Hardware gain is set to 1000 * 0.01 dB as got from system capture gain.*/
- EXPECT_EQ(1000, alsa_mixer_set_capture_dBFS_value);
+ /* Hardware gain is set to 1000 * 0.01 dB as got from catpure_gain.*/
+ EXPECT_EQ(0, alsa_mixer_set_capture_dBFS_value);
alsa_iodev_destroy(iodev);
free(fake_format);
@@ -1320,6 +1183,7 @@ TEST(AlsaOutputNode, InputsFromUCM) {
static const char* jack_name = "TestCard - Headset Jack";
int rc;
struct ucm_section* section;
+ long intrinsic_sensitivity = -2700;
ResetStubData();
inputs[0] = reinterpret_cast<struct mixer_control*>(3);
@@ -1338,7 +1202,6 @@ TEST(AlsaOutputNode, InputsFromUCM) {
// First node.
cras_alsa_mixer_get_control_for_section_return_value = inputs[0];
- ucm_get_max_software_gain_ret_value = -1;
section = ucm_section_create(INTERNAL_MICROPHONE, "hw:0,1", 0, -1,
CRAS_STREAM_INPUT, NULL, NULL);
ucm_section_add_coupled(section, "MIC-L", MIXER_NAME_VOLUME);
@@ -1348,8 +1211,8 @@ TEST(AlsaOutputNode, InputsFromUCM) {
// Add a second node (will use the same iodev).
cras_alsa_mixer_get_control_name_called = 0;
- ucm_get_max_software_gain_ret_value = 0;
- ucm_get_max_software_gain_value = 2000;
+ // Set intrinsic sensitivity to enable software gain.
+ ucm_get_intrinsic_sensitivity_values[MIC] = intrinsic_sensitivity;
cras_alsa_jack_list_add_jack_for_section_result_jack =
reinterpret_cast<struct cras_alsa_jack*>(1);
cras_alsa_mixer_get_control_for_section_return_value = inputs[1];
@@ -1359,7 +1222,7 @@ TEST(AlsaOutputNode, InputsFromUCM) {
ASSERT_EQ(0, alsa_iodev_ucm_add_nodes_and_jacks(iodev, section));
ucm_section_free_list(section);
- // Jack plug of an unkonwn device should do nothing.
+ // Jack plug of an unknown device should do nothing.
cras_alsa_jack_get_mixer_input_ret = NULL;
cras_alsa_jack_get_name_ret_value = "Some other jack";
jack_input_plug_event(reinterpret_cast<struct cras_alsa_jack*>(4), 0, aio);
@@ -1377,7 +1240,6 @@ TEST(AlsaOutputNode, InputsFromUCM) {
EXPECT_EQ(2, cras_alsa_jack_list_add_jack_for_section_called);
EXPECT_EQ(2, cras_alsa_mixer_get_control_for_section_called);
EXPECT_EQ(1, cras_alsa_mixer_get_control_name_called);
- EXPECT_EQ(1, sys_set_capture_gain_limits_called);
EXPECT_EQ(2, cras_iodev_add_node_called);
EXPECT_EQ(2, ucm_get_dma_period_for_dev_called);
EXPECT_EQ(0, aio->dma_period_set_microsecs);
@@ -1393,10 +1255,9 @@ TEST(AlsaOutputNode, InputsFromUCM) {
EXPECT_EQ(1, cras_iodev_update_dsp_called);
EXPECT_EQ(1, cras_alsa_jack_enable_ucm_called);
EXPECT_EQ(1, ucm_set_enabled_called);
- EXPECT_EQ(1, sys_set_capture_gain_limits_called);
EXPECT_EQ(1, alsa_mixer_set_capture_mute_called);
- EXPECT_EQ(1, iodev->active_node->software_volume_needed);
- EXPECT_EQ(2000, iodev->active_node->max_software_gain);
+ ASSERT_EQ(DEFAULT_CAPTURE_VOLUME_DBFS - intrinsic_sensitivity,
+ iodev->active_node->capture_gain);
alsa_iodev_destroy(iodev);
}
@@ -2476,11 +2337,6 @@ size_t cras_system_get_volume() {
return sys_get_volume_return_value;
}
-long cras_system_get_capture_gain() {
- sys_get_capture_gain_called++;
- return sys_get_capture_gain_return_value;
-}
-
int cras_system_get_mute() {
sys_get_mute_called++;
return sys_get_mute_return_value;
@@ -2495,12 +2351,6 @@ void cras_system_set_volume_limits(long min, long max) {
sys_set_volume_limits_called++;
}
-void cras_system_set_capture_gain_limits(long min, long max) {
- cras_system_set_capture_gain_limits_set_value[0] = min;
- cras_system_set_capture_gain_limits_set_value[1] = max;
- sys_set_capture_gain_limits_called++;
-}
-
// From cras_alsa_mixer.
void cras_alsa_mixer_set_dBFS(struct cras_alsa_mixer* m,
long dB_level,
@@ -2720,22 +2570,6 @@ unsigned int ucm_get_disable_software_volume(struct cras_use_case_mgr* mgr) {
return 0;
}
-int ucm_get_min_software_gain(struct cras_use_case_mgr* mgr,
- const char* dev,
- long* gain) {
- ucm_get_min_software_gain_called++;
- *gain = ucm_get_min_software_gain_value;
- return ucm_get_min_software_gain_ret_value;
-}
-
-int ucm_get_max_software_gain(struct cras_use_case_mgr* mgr,
- const char* dev,
- long* gain) {
- ucm_get_max_software_gain_called++;
- *gain = ucm_get_max_software_gain_value;
- return ucm_get_max_software_gain_ret_value;
-}
-
char* ucm_get_hotword_models(struct cras_use_case_mgr* mgr) {
return NULL;
}
diff --git a/cras/src/tests/alsa_ucm_unittest.cc b/cras/src/tests/alsa_ucm_unittest.cc
index 6976cd65..b8ec286a 100644
--- a/cras/src/tests/alsa_ucm_unittest.cc
+++ b/cras/src/tests/alsa_ucm_unittest.cc
@@ -758,56 +758,6 @@ TEST(AlsaUcm, FreeMixerNames) {
mixer_name_free(mixer_names_1);
}
-TEST(AlsaUcm, MaxSoftwareGain) {
- struct cras_use_case_mgr* mgr = &cras_ucm_mgr;
- long max_software_gain;
- int ret;
- std::string id = "=MaxSoftwareGain/Internal Mic/HiFi";
- std::string value = "2000";
-
- ResetStubData();
-
- /* Value can be found in UCM. */
- snd_use_case_get_value[id] = value;
-
- ret = ucm_get_max_software_gain(mgr, "Internal Mic", &max_software_gain);
-
- EXPECT_EQ(0, ret);
- EXPECT_EQ(2000, max_software_gain);
-
- ResetStubData();
-
- /* Value can not be found in UCM. */
- ret = ucm_get_max_software_gain(mgr, "Internal Mic", &max_software_gain);
-
- ASSERT_TRUE(ret);
-}
-
-TEST(AlsaUcm, MinSoftwareGain) {
- struct cras_use_case_mgr* mgr = &cras_ucm_mgr;
- long min_software_gain;
- int ret;
- std::string id = "=MinSoftwareGain/Internal Mic/HiFi";
- std::string value = "2000";
-
- ResetStubData();
-
- /* Value can be found in UCM. */
- snd_use_case_get_value[id] = value;
-
- ret = ucm_get_min_software_gain(mgr, "Internal Mic", &min_software_gain);
-
- EXPECT_EQ(0, ret);
- EXPECT_EQ(2000, min_software_gain);
-
- ResetStubData();
-
- /* Value can not be found in UCM. */
- ret = ucm_get_min_software_gain(mgr, "Internal Mic", &min_software_gain);
-
- ASSERT_TRUE(ret);
-}
-
TEST(AlsaUcm, DefaultNodeGain) {
struct cras_use_case_mgr* mgr = &cras_ucm_mgr;
long default_node_gain;
diff --git a/cras/src/tests/control_rclient_unittest.cc b/cras/src/tests/control_rclient_unittest.cc
index e8cb9e88..eca2580f 100644
--- a/cras/src/tests/control_rclient_unittest.cc
+++ b/cras/src/tests/control_rclient_unittest.cc
@@ -25,8 +25,6 @@ static struct cras_rstream* cras_rstream_create_stream_out;
static int cras_iodev_attach_stream_retval;
static size_t cras_system_set_volume_value;
static int cras_system_set_volume_called;
-static size_t cras_system_set_capture_gain_value;
-static int cras_system_set_capture_gain_called;
static size_t cras_system_set_mute_value;
static int cras_system_set_mute_called;
static size_t cras_system_set_user_mute_value;
@@ -65,8 +63,6 @@ void ResetStubData() {
cras_iodev_attach_stream_retval = 0;
cras_system_set_volume_value = 0;
cras_system_set_volume_called = 0;
- cras_system_set_capture_gain_value = 0;
- cras_system_set_capture_gain_called = 0;
cras_system_set_mute_value = 0;
cras_system_set_mute_called = 0;
cras_system_set_user_mute_value = 0;
@@ -368,21 +364,6 @@ TEST_F(RClientMessagesSuite, SetVolume) {
EXPECT_EQ(66, cras_system_set_volume_value);
}
-TEST_F(RClientMessagesSuite, SetCaptureVolume) {
- struct cras_set_system_volume msg;
- int rc;
-
- msg.header.id = CRAS_SERVER_SET_SYSTEM_CAPTURE_GAIN;
- msg.header.length = sizeof(msg);
- msg.volume = 66;
-
- rc =
- rclient_->ops->handle_message_from_client(rclient_, &msg.header, NULL, 0);
- EXPECT_EQ(0, rc);
- EXPECT_EQ(1, cras_system_set_capture_gain_called);
- EXPECT_EQ(66, cras_system_set_capture_gain_value);
-}
-
TEST_F(RClientMessagesSuite, SetMute) {
struct cras_set_system_mute msg;
int rc;
@@ -605,21 +586,6 @@ TEST_F(RClientMessagesSuite, SendOutputMuteChanged) {
EXPECT_EQ(msg->mute_locked, mute_locked);
}
-TEST_F(RClientMessagesSuite, SendCaptureGainChanged) {
- void* void_client = reinterpret_cast<void*>(rclient_);
- char buf[1024];
- ssize_t rc;
- struct cras_client_volume_changed* msg =
- (struct cras_client_volume_changed*)buf;
- const int32_t gain = 90;
-
- send_capture_gain_changed(void_client, gain);
- rc = read(pipe_fds_[0], buf, sizeof(buf));
- ASSERT_EQ(rc, (ssize_t)sizeof(*msg));
- EXPECT_EQ(msg->header.id, CRAS_CLIENT_CAPTURE_GAIN_CHANGED);
- EXPECT_EQ(msg->volume, gain);
-}
-
TEST_F(RClientMessagesSuite, SendCaptureMuteChanged) {
void* void_client = reinterpret_cast<void*>(rclient_);
char buf[1024];
@@ -845,11 +811,6 @@ void cras_system_set_volume(size_t volume) {
cras_system_set_volume_called++;
}
-void cras_system_set_capture_gain(long gain) {
- cras_system_set_capture_gain_value = gain;
- cras_system_set_capture_gain_called++;
-}
-
// From system_state.
void cras_system_set_mute(int mute) {
cras_system_set_mute_value = mute;
diff --git a/cras/src/tests/iodev_unittest.cc b/cras/src/tests/iodev_unittest.cc
index e3efa224..a42023bf 100644
--- a/cras/src/tests/iodev_unittest.cc
+++ b/cras/src/tests/iodev_unittest.cc
@@ -73,7 +73,6 @@ static unsigned int post_dsp_hook_called;
static const uint8_t* post_dsp_hook_frames;
static void* post_dsp_hook_cb_data;
static int iodev_buffer_size;
-static long cras_system_get_capture_gain_ret_value;
static uint8_t audio_buffer[BUFFER_SIZE];
static struct cras_audio_area* audio_area;
static unsigned int put_buffer_nframes;
@@ -159,7 +158,6 @@ void ResetStubData() {
post_dsp_hook_called = 0;
post_dsp_hook_frames = NULL;
iodev_buffer_size = 0;
- cras_system_get_capture_gain_ret_value = 0;
// Assume there is some data in audio buffer.
memset(audio_buffer, 0xff, sizeof(audio_buffer));
if (audio_area) {
@@ -1169,21 +1167,15 @@ TEST(IoDev, SoftwareGain) {
iodev.active_node = &ionode;
iodev.active_node->dev = &iodev;
- ionode.capture_gain = 400;
+ ionode.capture_gain = 2400;
ionode.software_volume_needed = 1;
- ionode.max_software_gain = 3000;
- // Check that system volume changes software volume if needed.
- cras_system_get_capture_gain_ret_value = 2000;
- // system_gain + node_gain = 2000 + 400 = 2400
// 2400 * 0.01 dB is 15.848931
EXPECT_FLOAT_EQ(15.848931, cras_iodev_get_software_gain_scaler(&iodev));
- EXPECT_FLOAT_EQ(3000, cras_iodev_maximum_software_gain(&iodev));
// Software gain scaler should be 1.0 if software gain is not needed.
ionode.software_volume_needed = 0;
EXPECT_FLOAT_EQ(1.0, cras_iodev_get_software_gain_scaler(&iodev));
- EXPECT_FLOAT_EQ(0, cras_iodev_maximum_software_gain(&iodev));
}
// This get_buffer implementation set returned frames larger than requested
@@ -2568,10 +2560,6 @@ size_t cras_system_get_volume() {
return cras_system_get_volume_return;
}
-long cras_system_get_capture_gain() {
- return cras_system_get_capture_gain_ret_value;
-}
-
int cras_system_get_mute() {
return cras_system_get_mute_return;
}
diff --git a/cras/src/tests/system_state_unittest.cc b/cras/src/tests/system_state_unittest.cc
index 9e7ecc8b..c1db9749 100644
--- a/cras/src/tests/system_state_unittest.cc
+++ b/cras/src/tests/system_state_unittest.cc
@@ -33,7 +33,6 @@ static char* device_config_dir;
static const char* cras_alsa_card_config_dir;
static size_t cras_observer_notify_output_volume_called;
static size_t cras_observer_notify_output_mute_called;
-static size_t cras_observer_notify_capture_gain_called;
static size_t cras_observer_notify_capture_mute_called;
static size_t cras_observer_notify_suspend_changed_called;
static size_t cras_observer_notify_num_active_streams_called;
@@ -53,7 +52,6 @@ static void ResetStubData() {
cras_alsa_card_config_dir = NULL;
cras_observer_notify_output_volume_called = 0;
cras_observer_notify_output_mute_called = 0;
- cras_observer_notify_capture_gain_called = 0;
cras_observer_notify_capture_mute_called = 0;
cras_observer_notify_suspend_changed_called = 0;
cras_observer_notify_num_active_streams_called = 0;
@@ -103,7 +101,6 @@ static void do_sys_init() {
TEST(SystemStateSuite, DefaultVolume) {
do_sys_init();
EXPECT_EQ(100, cras_system_get_volume());
- EXPECT_EQ(2000, cras_system_get_capture_gain());
EXPECT_EQ(0, cras_system_get_mute());
EXPECT_EQ(0, cras_system_get_capture_mute());
cras_system_state_deinit();
@@ -131,46 +128,6 @@ TEST(SystemStateSuite, SetMinMaxVolume) {
cras_system_state_deinit();
}
-TEST(SystemStateSuite, SetCaptureVolume) {
- do_sys_init();
- cras_system_set_capture_gain(0);
- EXPECT_EQ(0, cras_system_get_capture_gain());
- cras_system_set_capture_gain(3000);
- EXPECT_EQ(3000, cras_system_get_capture_gain());
- // Check that it is limited to the minimum allowed gain.
- cras_system_set_capture_gain(-10000);
- EXPECT_EQ(-5000, cras_system_get_capture_gain());
- cras_system_state_deinit();
- EXPECT_EQ(3, cras_observer_notify_capture_gain_called);
-}
-
-TEST(SystemStateSuite, SetCaptureVolumeStoreTarget) {
- do_sys_init();
- cras_system_set_capture_gain_limits(-2000, 2000);
- cras_system_set_capture_gain(3000);
- // Gain is within the limit.
- EXPECT_EQ(2000, cras_system_get_capture_gain());
-
- // Assume the range is changed.
- cras_system_set_capture_gain_limits(-4000, 4000);
-
- // Gain is also changed because target gain is re-applied.
- EXPECT_EQ(3000, cras_system_get_capture_gain());
-
- cras_system_state_deinit();
-}
-
-TEST(SystemStateSuite, SetMinMaxCaptureGain) {
- do_sys_init();
- cras_system_set_capture_gain(3000);
- cras_system_set_capture_gain_limits(-2000, 2000);
- EXPECT_EQ(-2000, cras_system_get_min_capture_gain());
- EXPECT_EQ(2000, cras_system_get_max_capture_gain());
- // Current gain is adjusted for range.
- EXPECT_EQ(2000, cras_system_get_capture_gain());
- cras_system_state_deinit();
-}
-
TEST(SystemStateSuite, SetUserMute) {
ResetStubData();
do_sys_init();
@@ -521,10 +478,6 @@ void cras_observer_notify_output_mute(int muted,
cras_observer_notify_output_mute_called++;
}
-void cras_observer_notify_capture_gain(int32_t gain) {
- cras_observer_notify_capture_gain_called++;
-}
-
void cras_observer_notify_capture_mute(int muted, int mute_locked) {
cras_observer_notify_capture_mute_called++;
}
diff --git a/cras/src/tools/cras_monitor/cras_monitor.c b/cras/src/tools/cras_monitor/cras_monitor.c
index d021669a..19252773 100644
--- a/cras/src/tools/cras_monitor/cras_monitor.c
+++ b/cras/src/tools/cras_monitor/cras_monitor.c
@@ -31,11 +31,6 @@ static void output_mute_changed(void *context, int muted, int user_muted,
muted, user_muted, mute_locked);
}
-static void capture_gain_changed(void *context, int32_t gain)
-{
- printf("capture gain: %d\n", gain);
-}
-
static void capture_mute_changed(void *context, int muted, int mute_locked)
{
printf("capture mute: muted: %d, mute_locked: %d\n", muted,
@@ -271,8 +266,6 @@ int main(int argc, char **argv)
output_volume_changed);
cras_client_set_output_mute_changed_callback(client,
output_mute_changed);
- cras_client_set_capture_gain_changed_callback(client,
- capture_gain_changed);
cras_client_set_capture_mute_changed_callback(client,
capture_mute_changed);
cras_client_set_nodes_changed_callback(client, nodes_changed);
diff --git a/cras/src/tools/cras_test_client/cras_test_client.c b/cras/src/tools/cras_test_client/cras_test_client.c
index bc1c2b23..b290837f 100644
--- a/cras/src/tools/cras_test_client/cras_test_client.c
+++ b/cras/src/tools/cras_test_client/cras_test_client.c
@@ -440,13 +440,11 @@ static void print_active_stream_info(struct cras_client *client)
static void print_system_volumes(struct cras_client *client)
{
printf("System Volume (0-100): %zu %s\n"
- "Capture Gain (%.2f - %.2f): %.2fdB %s\n",
+ "Capture Muted : %s\n",
cras_client_get_system_volume(client),
cras_client_get_system_muted(client) ? "(Muted)" : "",
- cras_client_get_system_min_capture_gain(client) / 100.0,
- cras_client_get_system_max_capture_gain(client) / 100.0,
- cras_client_get_system_capture_gain(client) / 100.0,
- cras_client_get_system_capture_muted(client) ? "(Muted)" : "");
+ cras_client_get_system_capture_muted(client) ? "Muted" :
+ "Not muted");
}
static void print_user_muted(struct cras_client *client)
@@ -1074,7 +1072,6 @@ static int run_file_io_stream(struct cras_client *client, int fd,
struct timespec sleep_ts;
float volume_scaler = 1.0;
size_t sys_volume = 100;
- long cap_gain = 0;
int mute = 0;
int8_t layout[CRAS_CH_MAX];
@@ -1223,14 +1220,6 @@ static int run_file_io_stream(struct cras_client *client, int fd,
sys_volume = sys_volume == 0 ? 0 : sys_volume - 1;
cras_client_set_system_volume(client, sys_volume);
break;
- case 'K':
- cap_gain = MIN(cap_gain + 100, 5000);
- cras_client_set_system_capture_gain(client, cap_gain);
- break;
- case 'J':
- cap_gain = cap_gain == -5000 ? -5000 : cap_gain - 100;
- cras_client_set_system_capture_gain(client, cap_gain);
- break;
case 'm':
mute = !mute;
cras_client_set_system_mute(client, mute);
@@ -1243,19 +1232,16 @@ static int run_file_io_stream(struct cras_client *client, int fd,
break;
case 'v':
printf("Volume: %zu%s Min dB: %ld Max dB: %ld\n"
- "Capture: %ld%s Min dB: %ld Max dB: %ld\n",
+ "Capture: %s\n",
cras_client_get_system_volume(client),
cras_client_get_system_muted(client) ?
"(Muted)" :
"",
cras_client_get_system_min_volume(client),
cras_client_get_system_max_volume(client),
- cras_client_get_system_capture_gain(client),
cras_client_get_system_capture_muted(client) ?
- "(Muted)" :
- "",
- cras_client_get_system_min_capture_gain(client),
- cras_client_get_system_max_capture_gain(client));
+ "Muted" :
+ "Not muted");
break;
case '\'':
play_short_sound_periods_left =
@@ -1795,15 +1781,6 @@ int main(int argc, char **argv)
}
break;
}
- case 'g': {
- long gain = atol(optarg);
- rc = cras_client_set_system_capture_gain(client, gain);
- if (rc < 0) {
- fprintf(stderr, "problem setting capture\n");
- goto destroy_exit;
- }
- break;
- }
case 'h':
show_usage();
break;
diff --git a/ucm-config/for_all_boards/HD Pro Webcam C920/HiFi.conf b/ucm-config/for_all_boards/HD Pro Webcam C920/HiFi.conf
index 4aca0e38..e90fa8c4 100644
--- a/ucm-config/for_all_boards/HD Pro Webcam C920/HiFi.conf
+++ b/ucm-config/for_all_boards/HD Pro Webcam C920/HiFi.conf
@@ -16,7 +16,7 @@ SectionVerb {
SectionDevice."Mic" {
Value {
CapturePCM "hw:C920,0"
- MaxSoftwareGain "2000"
+ IntrinsicSensitivity "-2600"
}
EnableSequence [