Sat 24 Apr 2004 09:17:06 AM UTC, comment #2:
static int
snd_vortex_peaks_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 20;
uinfo->value.integer.min = 0x0000;
uinfo->value.integer.max = 0x7fff;
return 0;
}
snd_ctl_elem_value_get_integer = 0 167713136 12970489
snd_ctl_elem_value_get_integer = 1 1 167758360
snd_ctl_elem_value_get_integer = 2 -536870890 80
snd_ctl_elem_value_get_integer = 3 0 0
snd_ctl_elem_value_get_integer = 4 1 13121220
snd_ctl_elem_value_get_integer = 5 167598340 0
snd_ctl_elem_value_get_integer = 6 13121220 0
snd_ctl_elem_value_get_integer = 7 167758360 4
snd_ctl_elem_value_get_integer = 8 12972384 13121220
snd_ctl_elem_value_get_integer = 9 -1075173944 13121220
Why do I get negative peak value when
long snd_ctl_elem_info_get_min (const snd_ctl_elem_info_t *obj) return 0
long snd_ctl_elem_info_get_min (const snd_ctl_elem_info_t *obj) return 32767 ?
Is there any sample code to obtain 20 EQ Peak values using alsa-lib ?
|
Sat 24 Apr 2004 08:49:32 AM UTC, comment #1:
Are EQ Peaks 16-bit or 32-bit ?
>amixer contents
numid=12,iface=MIXER,name='EQ Peaks'
; type=INTEGER,access=r----,values=20,min=0,max=32767,step=0
: values=1,1,0,1,1,0,1,0,0,0,1,1,0,1,1,0,0,0,0,0
long snd_ctl_elem_value_get_integer (const snd_ctl_elem_value_t *obj, unsigned int idx)
#define hwread(x,y) readl((x)+((y)>>2))
static void vortex_EqHw_GetTenBandLevels(vortex_t * vortex, u16 peaks[])
{
eqhw_t *eqhw = &(vortex->eq.this04);
int i;
if (eqhw->this04 <= 0)
return;
for (i = 0; i < eqhw->this04; i++)
peaks[i] = hwread(vortex->mmio, 0x2B024 + i * 0x30);
for (i = 0; i < eqhw->this04; i++)
peaks[i + eqhw->this04] =
hwread(vortex->mmio, 0x2B204 + i * 0x30);
}
static int vortex_Eqlzr_GetAllPeaks(vortex_t * vortex, u16 * peaks, int *count)
{
eqlzr_t *eq = &(vortex->eq);
if (eq->this10 == 0)
return 1;
count = eq->this10 2;
vortex_EqHw_GetTenBandLevels(vortex, peaks);
return 0;
}
static int
snd_vortex_peaks_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
{
vortex_t *vortex = snd_kcontrol_chip(kcontrol);
int i, count;
u16 peaks[20];
vortex_Eqlzr_GetAllPeaks(vortex, peaks, &count);
if (count != 20) {
printk("vortex: peak count error 20 != %d \n", count);
return -1;
}
for (i = 0; i < 20; i++)
ucontrol->value.integer.value[i] = peaks[i];
return 0;
}
|