alsactl init - add ATTR{dBmin} and ATTR{dBmax}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2008-08-18 12:39:26 +02:00
parent 5dda875b85
commit 0c02a4e3d2
3 changed files with 53 additions and 1 deletions

View file

@ -239,6 +239,18 @@
<para>Value range - step value</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>dBmin</option></term>
<listitem>
<para>Value range - minimum dB value</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>dBmax</option></term>
<listitem>
<para>Value range - maximum dB value</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>items</option></term>
<listitem>

View file

@ -76,6 +76,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
CTL{search}="mixer", CTL{name}="*", PROGRAM!="__ctl_search 1", GOTO="skip_first_ten_search"
@ -93,6 +95,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
CTL{search}="mixer", CTL{name}="*", PROGRAM!="__ctl_search 2", GOTO="skip_first_ten_search"
@ -110,6 +114,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
LABEL="skip_first_ten_search"
@ -127,6 +133,8 @@ PRINT=" CTL{owner}=\"$ctl{owner}\"\n"
PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
@ -146,6 +154,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
LABEL="skip_first_ten_search"
@ -164,6 +174,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
LABEL="skip_first_ten_search"
@ -182,6 +194,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
LABEL="skip_first_ten_search"
@ -200,6 +214,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
LABEL="skip_first_ten_search"
@ -218,6 +234,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
LABEL="skip_first_ten_search"
@ -236,6 +254,8 @@ PRINT=" CTL{count}=\"$ctl{count}\"\n"
PRINT=" CTL{min}=\"$ctl{min}\"\n"
PRINT=" CTL{max}=\"$ctl{max}\"\n"
PRINT=" CTL{step}=\"$ctl{step}\"\n"
PRINT=" CTL{dBmin}=\"$ctl{dBmin}\"\n"
PRINT=" CTL{dBmax}=\"$ctl{dBmax}\"\n"
PRINT=" CTL{items}=\"$ctl{items}\"\n"
PRINT=" CTL{value}=\"$ctl{value}\"\n"
LABEL="skip_first_ten_search"

View file

@ -478,7 +478,7 @@ static const char *elemid_get(struct space *space, const char *attr)
{
long long val;
snd_ctl_elem_type_t type;
static char res[16];
static char res[32];
if (strncasecmp(attr, "numid", 5) == 0) {
val = snd_ctl_elem_id_get_numid(space->ctl_id);
@ -597,6 +597,26 @@ static const char *elemid_get(struct space *space, const char *attr)
return NULL;
return get_ctl_value(space);
}
if (strncasecmp(attr, "dBmin", 5) == 0) {
long min, max;
if (check_id_changed(space, 1))
return NULL;
if (snd_ctl_get_dB_range(snd_hctl_ctl(space->ctl_handle), space->ctl_id, &min, &max) < 0)
goto empty;
val = min;
dbvalue:
sprintf(res, "%li.%02idB", (long)(val / 100), (int)abs(val % 100));
return res;
}
if (strncasecmp(attr, "dBmax", 5) == 0) {
long min, max;
if (check_id_changed(space, 1))
return NULL;
if (snd_ctl_get_dB_range(snd_hctl_ctl(space->ctl_handle), space->ctl_id, &min, &max) < 0)
goto empty;
val = max;
goto dbvalue;
}
Perror(space, "unknown ctl{} attribute '%s'", attr);
return NULL;
value: