summaryrefslogtreecommitdiff
path: root/cras/src/server/config/cras_card_config.c
diff options
context:
space:
mode:
authorAndrew Walbran <qwandor@google.com>2021-08-03 14:20:19 +0000
committerAndrew Walbran <qwandor@google.com>2021-08-03 14:20:19 +0000
commit8dce65084f73d40bb081312769a24b4bd533f667 (patch)
treee2118ad5dbee0370c6ab114bb3974cd9f09a2251 /cras/src/server/config/cras_card_config.c
parentbcf1f249f11b6865cff3f0d3f0ae5801e67e0e7e (diff)
downloadadhd-android-t-preview-1.tar.gz
This repository will be removed from the manifest change, but Treehugger seems unable to test the manifest change, so this change first removes all files so we can test that instead. Bug: 190503456 Test: m crosvm Change-Id: I133ef3bd8b39035a68113c4da8fe4c637a40daac
Diffstat (limited to 'cras/src/server/config/cras_card_config.c')
-rw-r--r--cras/src/server/config/cras_card_config.c110
1 files changed, 0 insertions, 110 deletions
diff --git a/cras/src/server/config/cras_card_config.c b/cras/src/server/config/cras_card_config.c
deleted file mode 100644
index ae36565d..00000000
--- a/cras/src/server/config/cras_card_config.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <syslog.h>
-
-#include "cras_util.h"
-#include "cras_volume_curve.h"
-#include "iniparser_wrapper.h"
-#include "utlist.h"
-
-struct cras_card_config {
- dictionary *ini;
-};
-
-static struct cras_volume_curve *
-create_simple_step_curve(const struct cras_card_config *card_config,
- const char *control_name)
-{
- char ini_key[MAX_INI_KEY_LENGTH + 1];
- int max_volume;
- int volume_step;
-
- snprintf(ini_key, MAX_INI_KEY_LENGTH, "%s:max_volume", control_name);
- ini_key[MAX_INI_KEY_LENGTH] = 0;
- max_volume = iniparser_getint(card_config->ini, ini_key, 0);
- snprintf(ini_key, MAX_INI_KEY_LENGTH, "%s:volume_step", control_name);
- ini_key[MAX_INI_KEY_LENGTH] = 0;
- volume_step = iniparser_getint(card_config->ini, ini_key, 300);
- syslog(LOG_INFO, "Configure curve found for %s.", control_name);
- return cras_volume_curve_create_simple_step(max_volume, volume_step);
-}
-
-static struct cras_volume_curve *
-create_explicit_curve(const struct cras_card_config *card_config,
- const char *control_name)
-{
- unsigned int i;
- char ini_key[MAX_INI_KEY_LENGTH + 1];
- long dB_values[101];
-
- for (i = 0; i < 101; i++) {
- snprintf(ini_key, MAX_INI_KEY_LENGTH, "%s:dB_at_%u",
- control_name, i);
- ini_key[MAX_INI_KEY_LENGTH] = 0;
- dB_values[i] = iniparser_getint(card_config->ini, ini_key, 0);
- }
- syslog(LOG_INFO, "Explicit volume curve found for %s.", control_name);
- return cras_volume_curve_create_explicit(dB_values);
-}
-
-/*
- * Exported interface.
- */
-
-struct cras_card_config *cras_card_config_create(const char *config_path,
- const char *card_name)
-{
- struct cras_card_config *card_config = NULL;
- char ini_name[MAX_INI_NAME_LENGTH + 1];
- dictionary *ini;
-
- snprintf(ini_name, MAX_INI_NAME_LENGTH, "%s/%s", config_path,
- card_name);
- ini_name[MAX_INI_NAME_LENGTH] = '\0';
- ini = iniparser_load_wrapper(ini_name);
- if (ini == NULL) {
- syslog(LOG_DEBUG, "No ini file %s", ini_name);
- return NULL;
- }
-
- card_config = calloc(1, sizeof(*card_config));
- if (card_config == NULL) {
- iniparser_freedict(ini);
- return NULL;
- }
-
- card_config->ini = ini;
- syslog(LOG_DEBUG, "Loaded ini file %s", ini_name);
- return card_config;
-}
-
-void cras_card_config_destroy(struct cras_card_config *card_config)
-{
- assert(card_config);
- iniparser_freedict(card_config->ini);
- free(card_config);
-}
-
-struct cras_volume_curve *cras_card_config_get_volume_curve_for_control(
- const struct cras_card_config *card_config, const char *control_name)
-{
- char ini_key[MAX_INI_KEY_LENGTH + 1];
- const char *curve_type;
-
- if (card_config == NULL || control_name == NULL)
- return NULL;
-
- snprintf(ini_key, MAX_INI_KEY_LENGTH, "%s:volume_curve", control_name);
- ini_key[MAX_INI_KEY_LENGTH] = 0;
- curve_type = iniparser_getstring(card_config->ini, ini_key, NULL);
-
- if (curve_type && strcmp(curve_type, "simple_step") == 0)
- return create_simple_step_curve(card_config, control_name);
- if (curve_type && strcmp(curve_type, "explicit") == 0)
- return create_explicit_curve(card_config, control_name);
- syslog(LOG_DEBUG, "No configure curve found for %s.", control_name);
- return NULL;
-}