From ec73719ec6a7d4ccdd71c32de585217f31a99fb3 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 14 Aug 2008 14:57:19 +0200 Subject: [PATCH] amixer - fixed TLV dBscale and added dBrange parsing Signed-off-by: Jaroslav Kysela --- amixer/amixer.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/amixer/amixer.c b/amixer/amixer.c index 61259f6..f93fa9e 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -456,7 +456,7 @@ static void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_ unsigned int type = tlv[0]; unsigned int size; unsigned int idx = 0; - + if (tlv_size < 2 * sizeof(unsigned int)) { printf("TLV size error!\n"); return; @@ -487,12 +487,12 @@ static void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_ printf("dBscale-"); if (size != 2 * sizeof(unsigned int)) { while (size > 0) { - printf("0x%x", tlv[idx++]); + printf("0x%08x,", tlv[idx++]); size -= sizeof(unsigned int); } } else { printf("min="); - print_dB(tlv[2]); + print_dB((int)tlv[2]); printf(",step="); print_dB(tlv[3] & 0xffff); printf(",mute=%i", (tlv[3] >> 16) & 1); @@ -503,7 +503,7 @@ static void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_ printf("dBlinear-"); if (size != 2 * sizeof(unsigned int)) { while (size > 0) { - printf("0x%x", tlv[idx++]); + printf("0x%08x,", tlv[idx++]); size -= sizeof(unsigned int); } } else { @@ -513,11 +513,31 @@ static void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_ print_dB(tlv[3]); } break; +#endif +#ifdef SND_CTL_TLVT_DB_RANGE + case SND_CTL_TLVT_DB_RANGE: + printf("dBrange-\n"); + if ((size / (6 * sizeof(unsigned int))) != 0) { + while (size > 0) { + printf("0x%08x,", tlv[idx++]); + size -= sizeof(unsigned int); + } + break; + } + idx = 0; + while (idx < size) { + print_spaces(spaces + 2); + printf("rangemin=%i,", tlv[0]); + printf(",rangemax=%i\n", tlv[1]); + decode_tlv(spaces + 4, tlv + 2, 6 * sizeof(unsigned int)); + idx += 6 * sizeof(unsigned int); + } + break; #endif default: printf("unk-%i-", type); while (size > 0) { - printf("0x%x", tlv[idx++]); + printf("0x%08x,", tlv[idx++]); size -= sizeof(unsigned int); } break;