summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>2010-05-19 08:19:26 +0200
committerJaroslav Kysela <perex@perex.cz>2010-05-19 12:39:10 +0200
commit30ad5ed04017f7e77b25cf40f18c26396903cd23 (patch)
tree8eeb5d889739602ac799966a1f318af50edab572
parent19892334499ed21ed4dc30084ad8700253f9cb2f (diff)
downloadalsa-lib-30ad5ed04017f7e77b25cf40f18c26396903cd23.tar.gz
control: tlv: Check dB range only within the control's volume range
The DB_RANGE need to be used on some HW, since the gain on volume control is not continuous, and has to be divided into several sub DB_SCALE ranges. ASoC has a feature to override the HW default volume range, and in this case when the volume range is less than the HW maximum we do not need to go through the whole DB_RANGE, but we need to stop where the kcontrol's maximum tell us. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--src/control/tlv.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/control/tlv.c b/src/control/tlv.c
index cfd9b973..0ff052ee 100644
--- a/src/control/tlv.c
+++ b/src/control/tlv.c
@@ -140,10 +140,13 @@ int snd_tlv_get_dB_range(unsigned int *tlv, long rangemin, long rangemax,
pos = 2;
while (pos + 4 <= len) {
long rmin, rmax;
- rangemin = (int)tlv[pos];
- rangemax = (int)tlv[pos + 1];
+ long submin, submax;
+ submin = (int)tlv[pos];
+ submax = (int)tlv[pos + 1];
+ if (rangemax < submax)
+ submax = rangemax;
err = snd_tlv_get_dB_range(tlv + pos + 2,
- rangemin, rangemax,
+ submin, submax,
&rmin, &rmax);
if (err < 0)
return err;
@@ -156,6 +159,8 @@ int snd_tlv_get_dB_range(unsigned int *tlv, long rangemin, long rangemax,
*min = rmin;
*max = rmax;
}
+ if (rangemax == submax)
+ return 0;
pos += int_index(tlv[pos + 3]) + 4;
}
return 0;