summaryrefslogtreecommitdiff
path: root/src/control/hcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/hcontrol.c')
-rw-r--r--src/control/hcontrol.c111
1 files changed, 1 insertions, 110 deletions
diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c
index 761df411..ede08870 100644
--- a/src/control/hcontrol.c
+++ b/src/control/hcontrol.c
@@ -239,6 +239,7 @@ static int get_compare_weight(const snd_ctl_elem_id_t *id)
"Tone Control",
"3D Control",
"PCM",
+ "Front",
"Surround",
"Center",
"LFE",
@@ -787,116 +788,6 @@ int snd_hctl_handle_events(snd_hctl_t *hctl)
return count;
}
-static int snd_hctl_elem_decode_tlv_db_gain(unsigned int *tlv, unsigned int tlv_size, long volume, long *db_gain)
-{
- unsigned int type;
- unsigned int size;
- unsigned int idx = 0;
- int err = 0;
-
- type = tlv[idx++];
- size = tlv[idx++];
- tlv_size -= 2 * sizeof(unsigned int);
- if (size > tlv_size) {
- err = -EINVAL;
- goto __exit_decode_db_gain;
- }
- switch (type) {
- case SND_CTL_TLVT_CONTAINER:
- size += sizeof(unsigned int) - 1;
- size /= sizeof(unsigned int);
- while (idx < size) {
- if (tlv[idx+1] > (size - idx) * sizeof(unsigned int)) {
- err = -EINVAL;
- goto __exit_decode_db_gain;
- }
- err = snd_hctl_elem_decode_tlv_db_gain(tlv + idx, tlv[idx+1], volume, db_gain);
- if (!err)
- break; /* db_gain obtained */
- idx += 2 + (tlv[1] + sizeof(unsigned int) - 1) / sizeof(unsigned int);
- }
- break;
- case SND_CTL_TLVT_DB_SCALE:
- if (size != 2 * sizeof(unsigned int)) {
-#if 0
- while (size > 0) {
- printf("0x%x", tlv[idx++]);
- size -= sizeof(unsigned int);
- }
- printf("\n");
-#endif
- } else {
- int min,step,mute;
- min = tlv[2];
- step = (tlv[3] & 0xffff);
- mute = (tlv[3] >> 16) & 1;
- *db_gain = (volume * step) + min;
- if (mute && (volume == 0))
- *db_gain = -9999999;
- }
- break;
- default:
-#if 0
- printf("unk-%i-", type);
- while (size > 0) {
- printf("0x%x", tlv[idx++]);
- size -= sizeof(unsigned int);
- }
- printf("\n");
-#endif
- break;
- }
-
- __exit_decode_db_gain:
- return err;
-}
-
-/**
- * \brief Get db_gain information for an HCTL element
- * \param elem HCTL element
- * \param volume The current control volume
- * \param db_gain The return value in db_gain scale
- * \return 0 otherwise a negative error code on failure
- */
-int snd_hctl_elem_get_db_gain(snd_hctl_elem_t *elem, long volume, long *db_gain)
-{
- snd_ctl_elem_info_t *info;
- unsigned int *tlv;
- unsigned int tlv_size = 4096;
- int err;
-
- snd_ctl_elem_info_alloca(&info);
- err = snd_hctl_elem_info(elem, info);
- if (err < 0)
- return err;
-
- if (tlv_size < 2 * sizeof(unsigned int)) {
- err = -EINVAL;
- goto __exit_db_gain;
- }
- if (!snd_ctl_elem_info_is_tlv_readable(info)) {
- err = -EINVAL;
- goto __exit_db_gain;
- }
- tlv = malloc(tlv_size);
- if (tlv == NULL) {
- err = -ENOMEM;
- goto __exit_db_gain;
- }
- if ((err = snd_hctl_elem_tlv_read(elem, tlv, tlv_size)) < 0)
- goto __free_exit_db_gain;
- err = snd_hctl_elem_decode_tlv_db_gain(tlv, tlv_size, volume, db_gain);
- __free_exit_db_gain:
- free(tlv);
- __exit_db_gain:
- return err;
-}
-
-
-
-
-
-
/**
* \brief Get information for an HCTL element
* \param elem HCTL element