X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fau88x0%2Fau88x0_eq.c;h=c8280f82eb5ad4edde8141b3bea1b430683a8c23;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=f8f52638ccaa4ad0a411ef39601dbb531d796db5;hpb=ec9397bab20a628530ce3051167d3d0fcc2c1af7;p=linux-2.6.git diff --git a/sound/pci/au88x0/au88x0_eq.c b/sound/pci/au88x0/au88x0_eq.c index f8f52638c..c8280f82e 100644 --- a/sound/pci/au88x0/au88x0_eq.c +++ b/sound/pci/au88x0/au88x0_eq.c @@ -45,6 +45,8 @@ #define VORTEX_EQ_SOURCE (VORTEX_EQ_BASE + 0x430) #define VORTEX_EQ_CTRL (VORTEX_EQ_BASE + 0x440) +#define VORTEX_BAND_COEFF_SIZE 0x30 + /* CEqHw.s */ static void vortex_EqHw_SetTimeConsts(vortex_t * vortex, u16 gain, u16 level) { @@ -52,10 +54,19 @@ static void vortex_EqHw_SetTimeConsts(vortex_t * vortex, u16 gain, u16 level) hwwrite(vortex->mmio, 0x2b3c8, level); } +static inline u16 sign_invert(u16 a) +{ + /* -(-32768) -> -32768 so we do -(-32768) -> 32767 to make the result positive */ + if (a == (u16)-32768) + return 32767; + else + return -a; +} + static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 coefs[]) { eqhw_t *eqhw = &(vortex->eq.this04); - int eax, i = 0, n /*esp2c */; + int i = 0, n /*esp2c */; for (n = 0; n < eqhw->this04; n++) { hwwrite(vortex->mmio, 0x2b000 + n * 0x30, coefs[i + 0]); @@ -64,25 +75,12 @@ static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 coefs[]) if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b008 + n * 0x30, coefs[i + 2]); hwwrite(vortex->mmio, 0x2b00c + n * 0x30, coefs[i + 3]); - eax = coefs[i + 4]; //esp24; + hwwrite(vortex->mmio, 0x2b010 + n * 0x30, coefs[i + 4]); } else { - if (coefs[2 + i] == 0x8000) - eax = 0x7fff; - else - eax = ~coefs[2 + i]; - hwwrite(vortex->mmio, 0x2b008 + n * 0x30, eax & 0xffff); - if (coefs[3 + i] == 0x8000) - eax = 0x7fff; - else - eax = ~coefs[3 + i]; - hwwrite(vortex->mmio, 0x2b00c + n * 0x30, eax & 0xffff); - if (coefs[4 + i] == 0x8000) - eax = 0x7fff; - else - eax = ~coefs[4 + i]; + hwwrite(vortex->mmio, 0x2b008 + n * 0x30, sign_invert(coefs[2 + i])); + hwwrite(vortex->mmio, 0x2b00c + n * 0x30, sign_invert(coefs[3 + i])); + hwwrite(vortex->mmio, 0x2b010 + n * 0x30, sign_invert(coefs[4 + i])); } - hwwrite(vortex->mmio, 0x2b010 + n * 0x30, eax); - i += 5; } } @@ -90,7 +88,7 @@ static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 coefs[]) static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 coefs[]) { eqhw_t *eqhw = &(vortex->eq.this04); - int i = 0, n /*esp2c */, eax; + int i = 0, n /*esp2c */; for (n = 0; n < eqhw->this04; n++) { hwwrite(vortex->mmio, 0x2b1e0 + n * 0x30, coefs[0 + i]); @@ -99,24 +97,12 @@ static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 coefs[]) if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, coefs[2 + i]); hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, coefs[3 + i]); - eax = coefs[4 + i]; //*esp24; + hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, coefs[4 + i]); } else { - if (coefs[2 + i] == 0x8000) - eax = 0x7fff; - else - eax = ~(coefs[2 + i]); - hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, eax & 0xffff); - if (coefs[3 + i] == 0x8000) - eax = 0x7fff; - else - eax = ~coefs[3 + i]; - hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, eax & 0xffff); - if (coefs[4 + i] == 0x8000) - eax = 0x7fff; - else - eax = ~coefs[4 + i]; + hwwrite(vortex->mmio, 0x2b1e8 + n * 0x30, sign_invert(coefs[2 + i])); + hwwrite(vortex->mmio, 0x2b1ec + n * 0x30, sign_invert(coefs[3 + i])); + hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, sign_invert(coefs[4 + i])); } - hwwrite(vortex->mmio, 0x2b1f0 + n * 0x30, eax); i += 5; } @@ -188,22 +174,12 @@ static void vortex_EqHw_GetRightStates(vortex_t * vortex, u16 * a, u16 b[]) static void vortex_EqHw_SetBypassGain(vortex_t * vortex, u16 a, u16 b) { eqhw_t *eqhw = &(vortex->eq.this04); - int eax; - if (eqhw->this08 == 0) { hwwrite(vortex->mmio, 0x2b3d4, a); hwwrite(vortex->mmio, 0x2b3ec, b); } else { - if (a == 0x8000) - eax = 0x7fff; - else - eax = ~a; - hwwrite(vortex->mmio, 0x2b3d4, eax & 0xffff); - if (b == 0x8000) - eax = 0x7fff; - else - eax = ~b; - hwwrite(vortex->mmio, 0x2b3ec, eax & 0xffff); + hwwrite(vortex->mmio, 0x2b3d4, sign_invert(a)); + hwwrite(vortex->mmio, 0x2b3ec, sign_invert(b)); } } @@ -345,25 +321,27 @@ static void vortex_EqHw_GetRightGainsCurrent(vortex_t * vortex, u16 a[]) #endif /* EQ band levels settings */ -static void vortex_EqHw_SetLevels(vortex_t * vortex, u16 a[]) +static void vortex_EqHw_SetLevels(vortex_t * vortex, u16 peaks[]) { eqhw_t *eqhw = &(vortex->eq.this04); - int ebx; + int i; - for (ebx = 0; ebx < eqhw->this04; ebx++) { - hwwrite(vortex->mmio, 0x2b024 + ebx * 0x30, a[ebx]); + /* set left peaks */ + for (i = 0; i < eqhw->this04; i++) { + hwwrite(vortex->mmio, 0x2b024 + i * VORTEX_BAND_COEFF_SIZE, peaks[i]); } - hwwrite(vortex->mmio, 0x2b3cc, a[eqhw->this04]); - hwwrite(vortex->mmio, 0x2b3d8, a[eqhw->this04 + 1]); + hwwrite(vortex->mmio, 0x2b3cc, peaks[eqhw->this04]); + hwwrite(vortex->mmio, 0x2b3d8, peaks[eqhw->this04 + 1]); - for (ebx = 0; ebx < eqhw->this04; ebx++) { - hwwrite(vortex->mmio, 0x2b204 + ebx * 0x30, - a[ebx + (eqhw->this04 + 2)]); + /* set right peaks */ + for (i = 0; i < eqhw->this04; i++) { + hwwrite(vortex->mmio, 0x2b204 + i * VORTEX_BAND_COEFF_SIZE, + peaks[i + (eqhw->this04 + 2)]); } - hwwrite(vortex->mmio, 0x2b3e4, a[2 + (eqhw->this04 * 2)]); - hwwrite(vortex->mmio, 0x2b3f0, a[3 + (eqhw->this04 * 2)]); + hwwrite(vortex->mmio, 0x2b3e4, peaks[2 + (eqhw->this04 * 2)]); + hwwrite(vortex->mmio, 0x2b3f0, peaks[3 + (eqhw->this04 * 2)]); } #if 0 @@ -752,7 +730,7 @@ static void vortex_Eqlzr_shutdown(vortex_t * vortex) /* Control interface */ static int -snd_vortex_eqtoggle_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_eqtoggle_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -762,8 +740,8 @@ snd_vortex_eqtoggle_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) } static int -snd_vortex_eqtoggle_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_vortex_eqtoggle_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); eqlzr_t *eq = &(vortex->eq); @@ -775,8 +753,8 @@ snd_vortex_eqtoggle_get(snd_kcontrol_t * kcontrol, } static int -snd_vortex_eqtoggle_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_vortex_eqtoggle_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); eqlzr_t *eq = &(vortex->eq); @@ -788,7 +766,7 @@ snd_vortex_eqtoggle_put(snd_kcontrol_t * kcontrol, return 1; /* Allways changes */ } -static snd_kcontrol_new_t vortex_eqtoggle_kcontrol __devinitdata = { +static struct snd_kcontrol_new vortex_eqtoggle_kcontrol __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "EQ Enable", .index = 0, @@ -800,7 +778,7 @@ static snd_kcontrol_new_t vortex_eqtoggle_kcontrol __devinitdata = { }; static int -snd_vortex_eq_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_eq_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -810,7 +788,7 @@ snd_vortex_eq_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) } static int -snd_vortex_eq_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); int i = kcontrol->private_value; @@ -824,7 +802,7 @@ snd_vortex_eq_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) } static int -snd_vortex_eq_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); int changed = 0, i = kcontrol->private_value; @@ -846,7 +824,7 @@ snd_vortex_eq_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) return changed; } -static snd_kcontrol_new_t vortex_eq_kcontrol __devinitdata = { +static struct snd_kcontrol_new vortex_eq_kcontrol __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = " .", .index = 0, @@ -858,7 +836,7 @@ static snd_kcontrol_new_t vortex_eq_kcontrol __devinitdata = { }; static int -snd_vortex_peaks_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_peaks_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 20; @@ -868,15 +846,15 @@ snd_vortex_peaks_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) } static int -snd_vortex_peaks_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_peaks_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); - int i, count; + int i, count = 0; u16 peaks[20]; vortex_Eqlzr_GetAllPeaks(vortex, peaks, &count); if (count != 20) { - printk("vortex: peak count error 20 != %d \n", count); + printk(KERN_ERR "vortex: peak count error 20 != %d \n", count); return -1; } for (i = 0; i < 20; i++) @@ -885,7 +863,7 @@ snd_vortex_peaks_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) return 0; } -static snd_kcontrol_new_t vortex_levels_kcontrol __devinitdata = { +static struct snd_kcontrol_new vortex_levels_kcontrol __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "EQ Peaks", .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, @@ -910,7 +888,7 @@ static char *EqBandLabels[10] __devinitdata = { /* ALSA driver entry points. Init and exit. */ static int vortex_eq_init(vortex_t * vortex) { - snd_kcontrol_t *kcontrol; + struct snd_kcontrol *kcontrol; int err, i; vortex_Eqlzr_init(vortex);