Ignore:
Timestamp:
Oct 23, 2006, 11:07:11 PM (19 years ago)
Author:
vladest
Message:

SB code update
HDA code update
Some other updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/alsa-kernel/pci/emu10k1/emufx.c

    r34 r84  
    33 *                   Creative Labs, Inc.
    44 *  Routines for effect processor FX8010
     5 *
     6 *  Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
     7 *      Added EMU 1010 support.
    58 *
    69 *  BUGS:
     
    2932#include <linux/delay.h>
    3033#include <linux/slab.h>
     34
    3135#include <sound/core.h>
     36#include <sound/tlv.h>
    3237#include <sound/emu10k1.h>
    33 
    3438
    3539#if 0           /* for testing purposes - digital out -> capture */
     
    262266};
    263267
     268/* dB gain = (float) 20 * log10( float(db_table_value) / 0x8000000 ) */
    264269static const u32 db_table[101] = {
    265270    0x00000000, 0x01571f82, 0x01674b41, 0x01783a1b, 0x0189f540,
     
    286291};
    287292
     293/* EMU10k1/EMU10k2 DSP control db gain */
     294static DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1);
     295
    288296static const u32 onoff_table[2] = {
    289297    0x00000000, 0x00000001
     
    310318 */
    311319
    312 static int snd_emu10k1_gpr_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    313 {
    314     struct snd_emu10k1_fx8010_ctl *ctl = (struct snd_emu10k1_fx8010_ctl *)kcontrol->private_value;
     320static int snd_emu10k1_gpr_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
     321{
     322    struct snd_emu10k1_fx8010_ctl *ctl =
     323        (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value;
    315324
    316325    if (ctl->min == 0 && ctl->max == 1)
     
    324333}
    325334
    326 static int snd_emu10k1_gpr_ctl_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     335static int snd_emu10k1_gpr_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    327336{
    328337    struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
    329     struct snd_emu10k1_fx8010_ctl *ctl = (struct snd_emu10k1_fx8010_ctl *)kcontrol->private_value;
     338    struct snd_emu10k1_fx8010_ctl *ctl =
     339        (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value;
    330340    unsigned long flags;
    331341    unsigned int i;
     
    338348}
    339349
    340 static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     350static int snd_emu10k1_gpr_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    341351{
    342352    struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
    343     struct snd_emu10k1_fx8010_ctl *ctl = (struct snd_emu10k1_fx8010_ctl *)kcontrol->private_value;
     353    struct snd_emu10k1_fx8010_ctl *ctl =
     354        (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value;
    344355    unsigned long flags;
    345356    unsigned int nval, val;
     
    365376            break;
    366377        case EMU10K1_GPR_TRANSLATION_BASS:
    367             snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error);
     378            if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
     379                change = -EIO;
     380                goto __error;
     381            }
    368382            for (j = 0; j < 5; j++)
    369383                snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]);
    370384            break;
    371385        case EMU10K1_GPR_TRANSLATION_TREBLE:
    372             snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error);
     386            if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
     387                change = -EIO;
     388                goto __error;
     389            }
    373390            for (j = 0; j < 5; j++)
    374391                snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]);
     
    413430    unsigned long flags;
    414431
    415     snd_runtime_check(emu, return -EINVAL);
    416     snd_runtime_check(handler, return -EINVAL);
    417432    irq = kmalloc(sizeof(*irq), GFP_ATOMIC);
    418433    if (irq == NULL)
     
    443458    unsigned long flags;
    444459
    445     snd_runtime_check(irq, return -EINVAL);
    446460    spin_lock_irqsave(&emu->fx8010.irq_lock, flags);
    447461    if ((tmp = emu->fx8010.irq_handlers) == irq) {
     
    466480 *************************************************************************/
    467481
    468 static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr,
    469                                 u32 op, u32 r, u32 a, u32 x, u32 y)
     482static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode,
     483                                 unsigned int *ptr,
     484                                 u32 op, u32 r, u32 a, u32 x, u32 y)
    470485{
    471486    u_int32_t *code;
    472487    snd_assert(*ptr < 512, return);
    473     code = (u_int32_t *)icode->code + (*ptr) * 2;
     488    code = (u_int32_t __force *)icode->code + (*ptr) * 2;
    474489    set_bit(*ptr, icode->code_valid);
    475490    code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
     
    481496    snd_emu10k1_write_op(icode, ptr, op, r, a, x, y)
    482497
    483 static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr,
    484                                        u32 op, u32 r, u32 a, u32 x, u32 y)
     498static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode,
     499                                        unsigned int *ptr,
     500                                        u32 op, u32 r, u32 a, u32 x, u32 y)
    485501{
    486502    u_int32_t *code;
    487503    snd_assert(*ptr < 1024, return);
    488     code = (u_int32_t *)icode->code + (*ptr) * 2;
     504    code = (u_int32_t __force *)icode->code + (*ptr) * 2;
    489505    set_bit(*ptr, icode->code_valid);
    490506    code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
     
    496512    snd_emu10k1_audigy_write_op(icode, ptr, op, r, a, x, y)
    497513
    498 void snd_emu10k1_efx_write(struct snd_emu10k1 *emu, unsigned int pc, unsigned int data)
     514static void snd_emu10k1_efx_write(struct snd_emu10k1 *emu, unsigned int pc, unsigned int data)
    499515{
    500516    pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
     
    508524}
    509525
    510 static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     526static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu,
     527                                struct snd_emu10k1_fx8010_code *icode)
    511528{
    512529    int gpr;
     
    523540}
    524541
    525 static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     542static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu,
     543                                struct snd_emu10k1_fx8010_code *icode)
    526544{
    527545    int gpr;
     
    537555}
    538556
    539 static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     557static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu,
     558                                 struct snd_emu10k1_fx8010_code *icode)
    540559{
    541560    int tram;
     
    559578}
    560579
    561 static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     580static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu,
     581                                 struct snd_emu10k1_fx8010_code *icode)
    562582{
    563583    int tram;
     
    581601}
    582602
    583 static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     603static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu,
     604                                 struct snd_emu10k1_fx8010_code *icode)
    584605{
    585606    u32 pc, lo, hi;
     
    597618}
    598619
    599 static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     620static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu,
     621                                 struct snd_emu10k1_fx8010_code *icode)
    600622{
    601623    u32 pc;
     
    612634}
    613635
    614 static struct snd_emu10k1_fx8010_ctl *snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, snd_ctl_elem_id_t *id)
     636static struct snd_emu10k1_fx8010_ctl *
     637snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id)
    615638{
    616639    struct snd_emu10k1_fx8010_ctl *ctl;
    617     snd_kcontrol_t *kcontrol;
     640    struct snd_kcontrol *kcontrol;
    618641    struct list_head *list;
    619642
     
    629652}
    630653
    631 static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     654static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
     655                                       struct snd_emu10k1_fx8010_code *icode)
    632656{
    633657    unsigned int i;
    634     snd_ctl_elem_id_t *_id, id;
    635     emu10k1_fx8010_control_gpr_t *_gctl;
    636     emu10k1_fx8010_control_gpr_t *gctl;
     658    struct snd_ctl_elem_id __user *_id;
     659    struct snd_ctl_elem_id id;
     660    struct snd_emu10k1_fx8010_control_gpr __user *_gctl;
     661    struct snd_emu10k1_fx8010_control_gpr *gctl;
    637662    int err;
    638663
     
    682707}
    683708
    684 static void snd_emu10k1_ctl_private_free(snd_kcontrol_t *kctl)
     709static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl)
    685710{
    686711    struct snd_emu10k1_fx8010_ctl *ctl;
     
    692717}
    693718
    694 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     719static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
     720                                    struct snd_emu10k1_fx8010_code *icode)
    695721{
    696722    unsigned int i, j;
    697     emu10k1_fx8010_control_gpr_t *_gctl;
    698     emu10k1_fx8010_control_gpr_t *gctl;
     723    struct snd_emu10k1_fx8010_control_gpr __user *_gctl;
     724    struct snd_emu10k1_fx8010_control_gpr *gctl;
    699725    struct snd_emu10k1_fx8010_ctl *ctl, *nctl;
    700     snd_kcontrol_new_t knew;
    701     snd_kcontrol_t *kctl;
    702     snd_ctl_elem_value_t *val;
     726    struct snd_kcontrol_new knew;
     727    struct snd_kcontrol *kctl;
     728    struct snd_ctl_elem_value *val;
    703729    int err = 0;
    704730
    705     val = (snd_ctl_elem_value_t *)kmalloc(sizeof(*val), GFP_KERNEL);
     731    val = kmalloc(sizeof(*val), GFP_KERNEL);
    706732    gctl = kmalloc(sizeof(*gctl), GFP_KERNEL);
    707733    nctl = kmalloc(sizeof(*nctl), GFP_KERNEL);
     
    717743            goto __error;
    718744        }
    719         snd_runtime_check(gctl->id.iface == SNDRV_CTL_ELEM_IFACE_MIXER ||
    720                           gctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM, err = -EINVAL; goto __error);
    721         snd_runtime_check(gctl->id.name[0] != '\0', err = -EINVAL; goto __error);
     745        if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
     746            gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) {
     747            err = -EINVAL;
     748            goto __error;
     749        }
     750        if (! gctl->id.name[0]) {
     751            err = -EINVAL;
     752            goto __error;
     753        }
    722754        ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id);
    723755        memset(&knew, 0, sizeof(knew));
     
    728760        knew.subdevice = gctl->id.subdevice;
    729761        knew.info = snd_emu10k1_gpr_ctl_info;
     762        if (gctl->tlv.p) {
     763            knew.tlv.p = gctl->tlv.p;
     764            knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
     765                SNDRV_CTL_ELEM_ACCESS_TLV_READ;
     766        }
    730767        knew.get = snd_emu10k1_gpr_ctl_get;
    731768        knew.put = snd_emu10k1_gpr_ctl_put;
     
    742779        nctl->translation = gctl->translation;
    743780        if (ctl == NULL) {
    744             ctl = (struct snd_emu10k1_fx8010_ctl *)kmalloc(sizeof(*ctl), GFP_KERNEL);
     781            ctl = kmalloc(sizeof(*ctl), GFP_KERNEL);
    745782            if (ctl == NULL) {
    746783                err = -ENOMEM;
     
    773810}
    774811
    775 static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     812static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu,
     813                                    struct snd_emu10k1_fx8010_code *icode)
    776814{
    777815    unsigned int i;
    778     snd_ctl_elem_id_t *_id, id;
     816    struct snd_ctl_elem_id id;
     817    struct snd_ctl_elem_id __user *_id;
    779818    struct snd_emu10k1_fx8010_ctl *ctl;
    780     snd_card_t *card = emu->card;
     819    struct snd_card *card = emu->card;
    781820
    782821    for (i = 0, _id = icode->gpr_del_controls;
    783822         i < icode->gpr_del_control_count; i++, _id++) {
    784         snd_runtime_check(copy_from_user(&id, _id, sizeof(id)) == 0, return -EFAULT);
     823        if (copy_from_user(&id, _id, sizeof(id)))
     824            return -EFAULT;
    785825        down_write(&card->controls_rwsem);
    786826        ctl = snd_emu10k1_look_for_ctl(emu, &id);
     
    792832}
    793833
    794 static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     834static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu,
     835                                     struct snd_emu10k1_fx8010_code *icode)
    795836{
    796837    unsigned int i = 0, j;
    797838    unsigned int total = 0;
    798     emu10k1_fx8010_control_gpr_t *gctl;
    799     emu10k1_fx8010_control_gpr_t *_gctl;
     839    struct snd_emu10k1_fx8010_control_gpr *gctl;
     840    struct snd_emu10k1_fx8010_control_gpr __user *_gctl;
    800841    struct snd_emu10k1_fx8010_ctl *ctl;
    801     snd_ctl_elem_id_t *id;
     842    struct snd_ctl_elem_id *id;
    802843    struct list_head *list;
    803844
     
    840881}
    841882
    842 static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     883static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu,
     884                                  struct snd_emu10k1_fx8010_code *icode)
    843885{
    844886    int err = 0;
     
    871913}
    872914
    873 static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode)
     915static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu,
     916                                  struct snd_emu10k1_fx8010_code *icode)
    874917{
    875918    int err;
     
    889932}
    890933
    891 static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_pcm_t *ipcm)
     934static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu,
     935                                 struct snd_emu10k1_fx8010_pcm_rec *ipcm)
    892936{
    893937    unsigned int i;
     
    934978}
    935979
    936 static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_pcm_t *ipcm)
     980static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu,
     981                                 struct snd_emu10k1_fx8010_pcm_rec *ipcm)
    937982{
    938983    unsigned int i;
     
    9681013#define SND_EMU10K1_CAPTURE_CHANNELS    4
    9691014
    970 static void __devinit snd_emu10k1_init_mono_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval)
     1015static void __devinit
     1016snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
     1017                              const char *name, int gpr, int defval)
    9711018{
    9721019    ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     
    9761023    ctl->min = 0;
    9771024    ctl->max = 100;
     1025    ctl->tlv.p = snd_emu10k1_db_scale1;
    9781026    ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
    9791027}
    9801028
    981 static void __devinit snd_emu10k1_init_stereo_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval)
     1029static void __devinit
     1030snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
     1031                                const char *name, int gpr, int defval)
    9821032{
    9831033    ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     
    9881038    ctl->min = 0;
    9891039    ctl->max = 100;
     1040    ctl->tlv.p = snd_emu10k1_db_scale1;
    9901041    ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
    9911042}
    9921043
    993 static void __devinit snd_emu10k1_init_mono_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval)
     1044static void __devinit
     1045snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
     1046                                    const char *name, int gpr, int defval)
    9941047{
    9951048    ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     
    10021055}
    10031056
    1004 static void __devinit snd_emu10k1_init_stereo_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval)
     1057static void __devinit
     1058snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
     1059                                      const char *name, int gpr, int defval)
    10051060{
    10061061    ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     
    10141069}
    10151070
     1071static int snd_emu10k1_audigy_dsp_convert_32_to_2x16(
     1072                                                     struct snd_emu10k1_fx8010_code *icode,
     1073                                                     u32 *ptr, int tmp, int bit_shifter16,
     1074                                                     int reg_in, int reg_out)
     1075{
     1076    A_OP(icode, ptr, iACC3, A_GPR(tmp + 1), reg_in, A_C_00000000, A_C_00000000);
     1077    A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp + 1), A_GPR(bit_shifter16 - 1), A_C_00000000);
     1078    A_OP(icode, ptr, iTSTNEG, A_GPR(tmp + 2), A_GPR(tmp), A_C_80000000, A_GPR(bit_shifter16 - 2));
     1079    A_OP(icode, ptr, iANDXOR, A_GPR(tmp + 2), A_GPR(tmp + 2), A_C_80000000, A_C_00000000);
     1080    A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp), A_GPR(bit_shifter16 - 3), A_C_00000000);
     1081    A_OP(icode, ptr, iMACINT0, A_GPR(tmp), A_C_00000000, A_GPR(tmp), A_C_00010000);
     1082    A_OP(icode, ptr, iANDXOR, reg_out, A_GPR(tmp), A_C_ffffffff, A_GPR(tmp + 2));
     1083    A_OP(icode, ptr, iACC3, reg_out + 1, A_GPR(tmp + 1), A_C_00000000, A_C_00000000);
     1084    return 1;
     1085}
    10161086
    10171087/*
     
    10221092{
    10231093    int err, i, z, gpr, nctl;
     1094    int bit_shifter16;
    10241095    const int playback = 10;
    10251096    const int capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we reserve 10 voices */
     
    10271098    const int tmp = 0x88;
    10281099    u32 ptr;
    1029     emu10k1_fx8010_code_t *icode = NULL;
    1030     emu10k1_fx8010_control_gpr_t *controls = NULL, *ctl;
     1100    struct snd_emu10k1_fx8010_code *icode = NULL;
     1101    struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl;
    10311102    u32 *gpr_map;
    10321103    mm_segment_t seg;
    10331104
    1034     spin_lock_init(&emu->fx8010.irq_lock);
    1035     INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);
    1036 
    1037     if ((icode = (emu10k1_fx8010_code_t *)kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
    1038         (icode->gpr_map = (u_int32_t __user *)kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
    1039         (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(*controls), GFP_KERNEL)) == NULL) {
     1105    if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
     1106        (icode->gpr_map = (u_int32_t __user *)
     1107         kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
     1108                GFP_KERNEL)) == NULL ||
     1109        (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
     1110                            sizeof(*controls), GFP_KERNEL)) == NULL) {
    10401111        err = -ENOMEM;
    10411112        goto __err;
    10421113    }
    1043     gpr_map = (u32 *)icode->gpr_map;
     1114    gpr_map = (u32 __force *)icode->gpr_map;
    10441115
    10451116    icode->tram_data_map = icode->gpr_map + 512;
     
    10591130    nctl = 0;
    10601131    gpr = stereo_mix + 10;
     1132    gpr_map[gpr++] = 0x00007fff;
     1133    gpr_map[gpr++] = 0x00008000;
     1134    gpr_map[gpr++] = 0x0000ffff;
     1135    bit_shifter16 = gpr;
    10611136
    10621137    /* stop FX processor */
    10631138    snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP);
    10641139
     1140#if 1
    10651141    /* PCM front Playback Volume (independent from stereo mix) */
    10661142    A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT));
     
    11021178    gpr += 2;
    11031179
    1104     /* Music Playback */
     1180    /* Synth Playback */
    11051181    A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix+0), A_GPR(stereo_mix+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT));
    11061182    A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix+1), A_GPR(stereo_mix+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT));
    1107     snd_emu10k1_init_stereo_control(&controls[nctl++], "Music Playback Volume", gpr, 100);
     1183    snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Playback Volume", gpr, 100);
    11081184    gpr += 2;
    11091185
     
    11141190    gpr += 2;
    11151191
    1116     /* Music Capture */
     1192    /* Synth Capture */
    11171193    A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT));
    11181194    A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT));
    1119     snd_emu10k1_init_stereo_control(&controls[nctl++], "Music Capture Volume", gpr, 0);
     1195    snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0);
    11201196    gpr += 2;
    11211197
     
    11261202    A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
    11271203
    1128     /* AC'97 Playback Volume - used only for mic */
     1204    /* emu1212 DSP 0 and DSP 1 Capture */
     1205    if (emu->card_capabilities->emu1010) {
     1206        A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_P16VIN(0x0));
     1207        A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_P16VIN(0x1));
     1208        snd_emu10k1_init_stereo_control(&controls[nctl++], "EMU Capture Volume", gpr, 0);
     1209        gpr += 2;
     1210    }
     1211    /* AC'97 Playback Volume - used only for mic (renamed later) */
    11291212    A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AC97_L);
    11301213    A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AC97_R);
     
    11581241    A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_OPT_SPDIF_L);
    11591242    A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_OPT_SPDIF_R);
    1160     snd_emu10k1_init_stereo_control(&controls[nctl++], "IEC958 Optical Playback Volume", gpr, 0);
     1243    snd_emu10k1_init_stereo_control(&controls[nctl++], SNDRV_CTL_NAME_IEC958("Optical ",PLAYBACK,VOLUME), gpr, 0);
    11611244    gpr += 2;
    11621245    /* Optical SPDIF Capture Volume */
    11631246    A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_OPT_SPDIF_L);
    11641247    A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_OPT_SPDIF_R);
    1165     snd_emu10k1_init_stereo_control(&controls[nctl++], "IEC958 Optical Capture Volume", gpr, 0);
     1248    snd_emu10k1_init_stereo_control(&controls[nctl++], SNDRV_CTL_NAME_IEC958("Optical ",CAPTURE,VOLUME), gpr, 0);
    11661249    gpr += 2;
    11671250
     
    12651348    A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 4), A_GPR(playback + 4), A_C_00000000, A_C_00000000); /* center */
    12661349    A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), A_GPR(playback + 5), A_C_00000000, A_C_00000000); /* LFE */
    1267 
    12681350    if (emu->card_capabilities->spk71) {
    12691351        A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 6), A_GPR(playback + 6), A_C_00000000, A_C_00000000); /* side left */
    12701352        A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 7), A_GPR(playback + 7), A_C_00000000, A_C_00000000); /* side right */
    12711353    }
     1354
    12721355
    12731356    ctl = &controls[nctl + 0];
     
    13501433    A_OP(icode, &ptr, iMAC0, A_GPR(playback+6+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+6+SND_EMU10K1_PLAYBACK_CHANNELS));
    13511434    A_OP(icode, &ptr, iMAC0, A_GPR(playback+7+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+7+SND_EMU10K1_PLAYBACK_CHANNELS));
    1352     snd_emu10k1_init_stereo_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0);
    1353     //snd_emu10k1_init_mono_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0);
     1435    snd_emu10k1_init_mono_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0);
    13541436    gpr += 2;
    13551437
     
    13591441    A_PUT_OUTPUT(A_EXTOUT_ACENTER, playback+4 + SND_EMU10K1_PLAYBACK_CHANNELS);
    13601442    A_PUT_OUTPUT(A_EXTOUT_ALFE, playback+5 + SND_EMU10K1_PLAYBACK_CHANNELS);
    1361 
    13621443    if (emu->card_capabilities->spk71)
    13631444        A_PUT_STEREO_OUTPUT(A_EXTOUT_ASIDE_L, A_EXTOUT_ASIDE_R, playback+6 + SND_EMU10K1_PLAYBACK_CHANNELS);
     
    13681449    /* digital outputs */
    13691450    /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */
     1451    if (emu->card_capabilities->emu1010) {
     1452        /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */
     1453        snd_printk("EMU outputs on\n");
     1454        for (z = 0; z < 8; z++) {
     1455            A_OP(icode, &ptr, iACC3, A_EMU32OUTL(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000);
     1456        }
     1457    }
    13701458
    13711459    /* IEC958 Optical Raw Playback Switch */
     
    13901478        }
    13911479    }
    1392     snd_emu10k1_init_stereo_onoff_control(controls + nctl++, "IEC958 Optical Raw Playback Switch", gpr, 0);
     1480    snd_emu10k1_init_stereo_onoff_control(controls + nctl++, SNDRV_CTL_NAME_IEC958("Optical Raw ",PLAYBACK,SWITCH), gpr, 0);
    13931481    gpr += 2;
    13941482
     
    13981486
    13991487    /* ADC buffer */
     1488#ifdef EMU10K1_CAPTURE_DIGITAL_OUT
     1489    A_PUT_STEREO_OUTPUT(A_EXTOUT_ADC_CAP_L, A_EXTOUT_ADC_CAP_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS);
     1490#else
    14001491    A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_L, capture);
    14011492    A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_R, capture+1);
    1402 
    1403     /* EFX capture - capture the 16 EXTINs */
    1404     for (z = 0; z < 16; z++) {
    1405         A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z));
    1406     }
    1407 
     1493#endif
     1494
     1495    if (emu->card_capabilities->emu1010) {
     1496        snd_printk("EMU inputs on\n");
     1497        /* Capture 8 channels of S32_LE sound */
     1498
     1499        /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */
     1500        /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
     1501        /* A_P16VIN(0) is delayed by one sample,
     1502         * so all other A_P16VIN channels will need to also be delayed
     1503         */
     1504        /* Left ADC in. 1 of 2 */
     1505        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) );
     1506        /* Right ADC in 1 of 2 */
     1507        gpr_map[gpr++] = 0x00000000;
     1508        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) );
     1509        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000);
     1510        gpr_map[gpr++] = 0x00000000;
     1511        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(4) );
     1512        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x2), A_C_00000000, A_C_00000000);
     1513        gpr_map[gpr++] = 0x00000000;
     1514        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(6) );
     1515        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x3), A_C_00000000, A_C_00000000);
     1516        /* For 96kHz mode */
     1517        /* Left ADC in. 2 of 2 */
     1518        gpr_map[gpr++] = 0x00000000;
     1519        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0x8) );
     1520        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x4), A_C_00000000, A_C_00000000);
     1521        /* Right ADC in 2 of 2 */
     1522        gpr_map[gpr++] = 0x00000000;
     1523        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xa) );
     1524        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x5), A_C_00000000, A_C_00000000);
     1525        gpr_map[gpr++] = 0x00000000;
     1526        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xc) );
     1527        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x6), A_C_00000000, A_C_00000000);
     1528        gpr_map[gpr++] = 0x00000000;
     1529        snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) );
     1530        A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000);
     1531
     1532#if 0
     1533        for (z = 4; z < 8; z++) {
     1534            A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000);
     1535        }
     1536        for (z = 0xc; z < 0x10; z++) {
     1537            A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000);
     1538        }
     1539#endif
     1540    } else {
     1541
     1542        /* EFX capture - capture the 16 EXTINs */
     1543        /* Capture 16 channels of S16_LE sound */
     1544        for (z = 0; z < 16; z++) {
     1545            A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z));
     1546        }
     1547    }
     1548
     1549#endif /* JCD test */
    14081550    /*
    14091551     * ok, set up done..
     
    14211563    seg = snd_enter_user();
    14221564    icode->gpr_add_control_count = nctl;
    1423     icode->gpr_add_controls = (emu10k1_fx8010_control_gpr_t __user *)controls;
     1565    icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;
    14241566    err = snd_emu10k1_icode_poke(emu, icode);
    14251567    snd_leave_user(seg);
     
    14281570    kfree(controls);
    14291571    if (icode != NULL) {
    1430         kfree((void *)icode->gpr_map);
     1572        kfree((void __force *)icode->gpr_map);
    14311573        kfree(icode);
    14321574    }
     
    14411583/* when volume = max, then copy only to avoid volume modification */
    14421584/* with iMAC0 (negative values) */
    1443 static void __devinit _volume(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
     1585static void __devinit _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
    14441586{
    14451587    OP(icode, ptr, iMAC0, dst, C_00000000, src, vol);
     
    14481590    OP(icode, ptr, iACC3, dst, src, C_00000000, C_00000000);
    14491591}
    1450 static void __devinit _volume_add(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
     1592static void __devinit _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
    14511593{
    14521594    OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff);
     
    14561598    OP(icode, ptr, iMAC0, dst, dst, src, vol);
    14571599}
    1458 static void __devinit _volume_out(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
     1600static void __devinit _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
    14591601{
    14601602    OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff);
     
    14911633    int err, i, z, gpr, tmp, playback, capture;
    14921634    u32 ptr;
    1493     emu10k1_fx8010_code_t *icode;
    1494     emu10k1_fx8010_pcm_t *ipcm = NULL;
    1495     emu10k1_fx8010_control_gpr_t *controls = NULL, *ctl;
     1635    struct snd_emu10k1_fx8010_code *icode;
     1636    struct snd_emu10k1_fx8010_pcm_rec *ipcm = NULL;
     1637    struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl;
    14961638    u32 *gpr_map;
    14971639    mm_segment_t seg;
    14981640
    1499     spin_lock_init(&emu->fx8010.irq_lock);
    1500     INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);
    1501 
    1502     if ((icode = (emu10k1_fx8010_code_t *)kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
     1641    if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
    15031642        return -ENOMEM;
    1504     if ((icode->gpr_map = (u_int32_t __user *)kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
    1505         (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL ||
    1506         (ipcm = (emu10k1_fx8010_pcm_t *)kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
     1643    if ((icode->gpr_map = (u_int32_t __user *)
     1644         kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
     1645                 GFP_KERNEL)) == NULL ||
     1646        (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
     1647                            sizeof(struct snd_emu10k1_fx8010_control_gpr),
     1648                            GFP_KERNEL)) == NULL ||
     1649        (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
    15071650        err = -ENOMEM;
    15081651        goto __err;
    15091652    }
    1510     gpr_map = (u32 *)icode->gpr_map;
     1653    gpr_map = (u32 __force *)icode->gpr_map;
    15111654
    15121655    icode->tram_data_map = icode->gpr_map + 256;
     
    15651708    ipcm->etram[1] = 1;
    15661709
    1567         gpr_map[gpr + 0] = 0xfffff000;
    1568         gpr_map[gpr + 1] = 0xffff0000;
    1569         gpr_map[gpr + 2] = 0x70000000;
    1570         gpr_map[gpr + 3] = 0x00000007;
    1571         gpr_map[gpr + 4] = 0x001f << 11;
    1572         gpr_map[gpr + 5] = 0x001c << 11;
    1573         gpr_map[gpr + 6] = (0x22  - 0x01) - 1;  /* skip at 01 to 22 */
    1574         gpr_map[gpr + 7] = (0x22  - 0x06) - 1;  /* skip at 06 to 22 */
    1575         gpr_map[gpr + 8] = 0x2000000 + (2<<11);
    1576         gpr_map[gpr + 9] = 0x4000000 + (2<<11);
    1577         gpr_map[gpr + 10] = 1<<11;
    1578         gpr_map[gpr + 11] = (0x24 - 0x0a) - 1;  /* skip at 0a to 24 */
    1579         gpr_map[gpr + 12] = 0;
     1710    gpr_map[gpr + 0] = 0xfffff000;
     1711    gpr_map[gpr + 1] = 0xffff0000;
     1712    gpr_map[gpr + 2] = 0x70000000;
     1713    gpr_map[gpr + 3] = 0x00000007;
     1714    gpr_map[gpr + 4] = 0x001f << 11;
     1715    gpr_map[gpr + 5] = 0x001c << 11;
     1716    gpr_map[gpr + 6] = (0x22  - 0x01) - 1;      /* skip at 01 to 22 */
     1717    gpr_map[gpr + 7] = (0x22  - 0x06) - 1;      /* skip at 06 to 22 */
     1718    gpr_map[gpr + 8] = 0x2000000 + (2<<11);
     1719    gpr_map[gpr + 9] = 0x4000000 + (2<<11);
     1720    gpr_map[gpr + 10] = 1<<11;
     1721    gpr_map[gpr + 11] = (0x24 - 0x0a) - 1;      /* skip at 0a to 24 */
     1722    gpr_map[gpr + 12] = 0;
    15801723
    15811724    /* if the trigger flag is not set, skip */
     
    16581801    gpr += 4;
    16591802
    1660     /* Music Playback Volume */
     1803    /* Synth Playback Volume */
    16611804    for (z = 0; z < 2; z++)
    16621805        VOLUME_ADD(icode, &ptr, playback + z, 2 + z, gpr + z);
    1663     snd_emu10k1_init_stereo_control(controls + i++, "Music Playback Volume", gpr, 100);
    1664     gpr += 2;
    1665 
    1666     /* Music Capture Volume + Switch */
     1806    snd_emu10k1_init_stereo_control(controls + i++, "Synth Playback Volume", gpr, 100);
     1807    gpr += 2;
     1808
     1809    /* Synth Capture Volume + Switch */
    16671810    for (z = 0; z < 2; z++) {
    16681811        SWITCH(icode, &ptr, tmp + 0, 2 + z, gpr + 2 + z);
    16691812        VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
    16701813    }
    1671     snd_emu10k1_init_stereo_control(controls + i++, "Music Capture Volume", gpr, 0);
    1672     snd_emu10k1_init_stereo_onoff_control(controls + i++, "Music Capture Switch", gpr + 2, 0);
     1814    snd_emu10k1_init_stereo_control(controls + i++, "Synth Capture Volume", gpr, 0);
     1815    snd_emu10k1_init_stereo_onoff_control(controls + i++, "Synth Capture Switch", gpr + 2, 0);
    16731816    gpr += 4;
    16741817
     
    17301873        for (z = 0; z < 2; z++)
    17311874            VOLUME_ADDIN(icode, &ptr, playback + z, EXTIN_SPDIF_CD_L + z, gpr + z);
    1732         snd_emu10k1_init_stereo_control(controls + i++, "IEC958 TTL Playback Volume", gpr, 0);
     1875        snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",PLAYBACK,VOLUME), gpr, 0);
    17331876        gpr += 2;
    17341877
     
    17381881            VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
    17391882        }
    1740         snd_emu10k1_init_stereo_control(controls + i++, "IEC958 TTL Capture Volume", gpr, 0);
    1741         snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 TTL Capture Switch", gpr + 2, 0);
     1883        snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",CAPTURE,VOLUME), gpr, 0);
     1884        snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",CAPTURE,SWITCH), gpr + 2, 0);
    17421885        gpr += 4;
    17431886    }
     
    17641907        for (z = 0; z < 2; z++)
    17651908            VOLUME_ADDIN(icode, &ptr, playback + z, EXTIN_TOSLINK_L + z, gpr + z);
    1766         snd_emu10k1_init_stereo_control(controls + i++, "IEC958 LiveDrive Playback Volume", gpr, 0);
     1909        snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",PLAYBACK,VOLUME), gpr, 0);
    17671910        gpr += 2;
    17681911
     
    17721915            VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
    17731916        }
    1774         snd_emu10k1_init_stereo_control(controls + i++, "IEC958 LiveDrive Capture Volume", gpr, 0);
    1775         snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 LiveDrive Capture Switch", gpr + 2, 0);
     1917        snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",CAPTURE,VOLUME), gpr, 0);
     1918        snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",CAPTURE,SWITCH), gpr + 2, 0);
    17761919        gpr += 4;
    17771920    }
     
    17981941        for (z = 0; z < 2; z++)
    17991942            VOLUME_ADDIN(icode, &ptr, playback + z, EXTIN_COAX_SPDIF_L + z, gpr + z);
    1800         snd_emu10k1_init_stereo_control(controls + i++, "IEC958 Coaxial Playback Volume", gpr, 0);
     1943        snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",PLAYBACK,VOLUME), gpr, 0);
    18011944        gpr += 2;
    18021945
     
    18061949            VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z);
    18071950        }
    1808         snd_emu10k1_init_stereo_control(controls + i++, "IEC958 Coaxial Capture Volume", gpr, 0);
    1809         snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 Coaxial Capture Switch", gpr + 2, 0);
     1951        snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",CAPTURE,VOLUME), gpr, 0);
     1952        snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",CAPTURE,SWITCH), gpr + 2, 0);
    18101953        gpr += 4;
    18111954    }
     
    19342077        }
    19352078
    1936         snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 Optical Raw Playback Switch", gpr, 0);
     2079        snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("Optical Raw ",PLAYBACK,SWITCH), gpr, 0);
    19372080        gpr += 2;
    19382081    }
     
    20352178    seg = snd_enter_user();
    20362179    icode->gpr_add_control_count = i;
    2037     icode->gpr_add_controls = (emu10k1_fx8010_control_gpr_t __user *)controls;
     2180    icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;
    20382181    err = snd_emu10k1_icode_poke(emu, icode);
    20392182    snd_leave_user(seg);
     
    20442187    kfree(controls);
    20452188    if (icode != NULL) {
    2046         kfree((void *)icode->gpr_map);
     2189        kfree((void __force *)icode->gpr_map);
    20472190        kfree(icode);
    20482191    }
     
    20522195int __devinit snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
    20532196{
     2197    spin_lock_init(&emu->fx8010.irq_lock);
     2198    INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);
    20542199    if (emu->audigy)
    20552200        return _snd_emu10k1_audigy_init_efx(emu);
     
    20672212}
    20682213
    2069 #if 0 // FIXME: who use them?
     2214#if 0 /* FIXME: who use them? */
    20702215int snd_emu10k1_fx8010_tone_control_activate(struct snd_emu10k1 *emu, int output)
    20712216{
    2072     snd_runtime_check(output >= 0 && output < 6, return -EINVAL);
     2217    if (output < 0 || output >= 6)
     2218        return -EINVAL;
    20732219    snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1);
    20742220    return 0;
     
    20772223int snd_emu10k1_fx8010_tone_control_deactivate(struct snd_emu10k1 *emu, int output)
    20782224{
    2079     snd_runtime_check(output >= 0 && output < 6, return -EINVAL);
     2225    if (output < 0 || output >= 6)
     2226        return -EINVAL;
    20802227    snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0);
    20812228    return 0;
     
    20972244        size = 0x2000 << size_reg;
    20982245    }
    2099     if (emu->fx8010.etram_pages.bytes == size)
     2246    if ((emu->fx8010.etram_pages.bytes / 2) == size)
    21002247        return 0;
    21012248    spin_lock_irq(&emu->emu_lock);
     
    21252272}
    21262273
    2127 static int snd_emu10k1_fx8010_open(snd_hwdep_t * hw, struct file *file)
     2274static int snd_emu10k1_fx8010_open(struct snd_hwdep * hw, struct file *file)
    21282275{
    21292276    return 0;
     
    21382285}
    21392286
    2140 static int snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu, emu10k1_fx8010_info_t *info)
     2287static int snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu,
     2288                                   struct snd_emu10k1_fx8010_info *info)
    21412289{
    21422290    char **fxbus, **extin, **extout;
     
    21642312}
    21652313
    2166 static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg)
     2314static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg)
    21672315{
    21682316    struct snd_emu10k1 *emu = hw->private_data;
    2169     emu10k1_fx8010_info_t *info;
    2170     emu10k1_fx8010_code_t *icode;
    2171     emu10k1_fx8010_pcm_t *ipcm;
     2317    struct snd_emu10k1_fx8010_info *info;
     2318    struct snd_emu10k1_fx8010_code *icode;
     2319    struct snd_emu10k1_fx8010_pcm_rec *ipcm;
    21722320    unsigned int addr;
     2321    void __user *argp = (void __user *)arg;
    21732322    int res;
    21742323
    21752324    switch (cmd) {
    21762325    case SNDRV_EMU10K1_IOCTL_INFO:
    2177         info = (emu10k1_fx8010_info_t *)kmalloc(sizeof(*info), GFP_KERNEL);
     2326        info = kmalloc(sizeof(*info), GFP_KERNEL);
    21782327        if (!info)
    21792328            return -ENOMEM;
     
    21822331            return res;
    21832332        }
    2184         if (copy_to_user((void *)arg, info, sizeof(*info))) {
     2333        if (copy_to_user(argp, info, sizeof(*info))) {
    21852334            kfree(info);
    21862335            return -EFAULT;
     
    21912340        if (!capable(CAP_SYS_ADMIN))
    21922341            return -EPERM;
    2193         icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL);
     2342        icode = kmalloc(sizeof(*icode), GFP_KERNEL);
    21942343        if (icode == NULL)
    21952344            return -ENOMEM;
    2196         if (copy_from_user(icode, (void *)arg, sizeof(*icode))) {
     2345        if (copy_from_user(icode, argp, sizeof(*icode))) {
    21972346            kfree(icode);
    21982347            return -EFAULT;
     
    22022351        return res;
    22032352    case SNDRV_EMU10K1_IOCTL_CODE_PEEK:
    2204         icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL);
     2353        icode = kmalloc(sizeof(*icode), GFP_KERNEL);
    22052354        if (icode == NULL)
    22062355            return -ENOMEM;
    2207         if (copy_from_user(icode, (void *)arg, sizeof(*icode))) {
     2356        if (copy_from_user(icode, argp, sizeof(*icode))) {
    22082357            kfree(icode);
    22092358            return -EFAULT;
    22102359        }
    22112360        res = snd_emu10k1_icode_peek(emu, icode);
    2212         if (res == 0 && copy_to_user((void *)arg, icode, sizeof(*icode))) {
     2361        if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) {
    22132362            kfree(icode);
    22142363            return -EFAULT;
     
    22172366        return res;
    22182367    case SNDRV_EMU10K1_IOCTL_PCM_POKE:
    2219         ipcm = (emu10k1_fx8010_pcm_t *)kmalloc(sizeof(*ipcm), GFP_KERNEL);
     2368        ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL);
    22202369        if (ipcm == NULL)
    22212370            return -ENOMEM;
    2222         if (copy_from_user(ipcm, (void *)arg, sizeof(*ipcm))) {
     2371        if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
    22232372            kfree(ipcm);
    22242373            return -EFAULT;
     
    22282377        return res;
    22292378    case SNDRV_EMU10K1_IOCTL_PCM_PEEK:
    2230         ipcm = (emu10k1_fx8010_pcm_t *)kzalloc(sizeof(*ipcm), GFP_KERNEL);
     2379        ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
    22312380        if (ipcm == NULL)
    22322381            return -ENOMEM;
    2233         if (copy_from_user(ipcm, (void *)arg, sizeof(*ipcm))) {
     2382        if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
    22342383            kfree(ipcm);
    22352384            return -EFAULT;
    22362385        }
    22372386        res = snd_emu10k1_ipcm_peek(emu, ipcm);
    2238         if (res == 0 && copy_to_user((void *)arg, ipcm, sizeof(*ipcm))) {
     2387        if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) {
    22392388            kfree(ipcm);
    22402389            return -EFAULT;
     
    22452394        if (!capable(CAP_SYS_ADMIN))
    22462395            return -EPERM;
    2247         if (get_user(addr, (unsigned int *)arg))
     2396        if (get_user(addr, (unsigned int __user *)argp))
    22482397            return -EFAULT;
    22492398        down(&emu->fx8010.lock);
     
    22832432        if (!capable(CAP_SYS_ADMIN))
    22842433            return -EPERM;
    2285         if (get_user(addr, (unsigned int *)arg))
     2434        if (get_user(addr, (unsigned int __user *)argp))
    22862435            return -EFAULT;
    22872436        if (addr > 0x1ff)
     
    23022451        else
    23032452            addr = snd_emu10k1_ptr_read(emu, DBG, 0);
    2304         if (put_user(addr, (unsigned int *)arg))
     2453        if (put_user(addr, (unsigned int __user *)argp))
    23052454            return -EFAULT;
    23062455        return 0;
     
    23092458}
    23102459
    2311 static int snd_emu10k1_fx8010_release(snd_hwdep_t * hw, struct file *file)
     2460static int snd_emu10k1_fx8010_release(struct snd_hwdep * hw, struct file *file)
    23122461{
    23132462    return 0;
    23142463}
    23152464
    2316 int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, snd_hwdep_t ** rhwdep)
    2317 {
    2318     snd_hwdep_t *hw;
     2465int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep)
     2466{
     2467    struct snd_hwdep *hw;
    23192468    int err;
    23202469
     
    23332482    return 0;
    23342483}
     2484
     2485#ifdef CONFIG_PM
     2486int __devinit snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu)
     2487{
     2488    int len;
     2489
     2490    len = emu->audigy ? 0x200 : 0x100;
     2491    emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL);
     2492    if (! emu->saved_gpr)
     2493        return -ENOMEM;
     2494    len = emu->audigy ? 0x100 : 0xa0;
     2495    emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL);
     2496    emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL);
     2497    if (! emu->tram_val_saved || ! emu->tram_addr_saved)
     2498        return -ENOMEM;
     2499    len = emu->audigy ? 2 * 1024 : 2 * 512;
     2500    emu->saved_icode = vmalloc(len * 4);
     2501    if (! emu->saved_icode)
     2502        return -ENOMEM;
     2503    return 0;
     2504}
     2505
     2506void snd_emu10k1_efx_free_pm_buffer(struct snd_emu10k1 *emu)
     2507{
     2508    kfree(emu->saved_gpr);
     2509    kfree(emu->tram_val_saved);
     2510    kfree(emu->tram_addr_saved);
     2511    vfree(emu->saved_icode);
     2512}
     2513
     2514/*
     2515 * save/restore GPR, TRAM and codes
     2516 */
     2517void snd_emu10k1_efx_suspend(struct snd_emu10k1 *emu)
     2518{
     2519    int i, len;
     2520
     2521    len = emu->audigy ? 0x200 : 0x100;
     2522    for (i = 0; i < len; i++)
     2523        emu->saved_gpr[i] = snd_emu10k1_ptr_read(emu, emu->gpr_base + i, 0);
     2524
     2525    len = emu->audigy ? 0x100 : 0xa0;
     2526    for (i = 0; i < len; i++) {
     2527        emu->tram_val_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMDATAREGBASE + i, 0);
     2528        emu->tram_addr_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + i, 0);
     2529        if (emu->audigy) {
     2530            emu->tram_addr_saved[i] >>= 12;
     2531            emu->tram_addr_saved[i] |=
     2532                snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + i, 0) << 20;
     2533        }
     2534    }
     2535
     2536    len = emu->audigy ? 2 * 1024 : 2 * 512;
     2537    for (i = 0; i < len; i++)
     2538        emu->saved_icode[i] = snd_emu10k1_efx_read(emu, i);
     2539}
     2540
     2541void snd_emu10k1_efx_resume(struct snd_emu10k1 *emu)
     2542{
     2543    int i, len;
     2544
     2545    /* set up TRAM */
     2546    if (emu->fx8010.etram_pages.bytes > 0) {
     2547        unsigned size, size_reg = 0;
     2548        size = emu->fx8010.etram_pages.bytes / 2;
     2549        size = (size - 1) >> 13;
     2550        while (size) {
     2551            size >>= 1;
     2552            size_reg++;
     2553        }
     2554        outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG);
     2555        snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr);
     2556        snd_emu10k1_ptr_write(emu, TCBS, 0, size_reg);
     2557        outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG);
     2558    }
     2559
     2560    if (emu->audigy)
     2561        snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP);
     2562    else
     2563        snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP);
     2564
     2565    len = emu->audigy ? 0x200 : 0x100;
     2566    for (i = 0; i < len; i++)
     2567        snd_emu10k1_ptr_write(emu, emu->gpr_base + i, 0, emu->saved_gpr[i]);
     2568
     2569    len = emu->audigy ? 0x100 : 0xa0;
     2570    for (i = 0; i < len; i++) {
     2571        snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + i, 0,
     2572                              emu->tram_val_saved[i]);
     2573        if (! emu->audigy)
     2574            snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0,
     2575                                  emu->tram_addr_saved[i]);
     2576        else {
     2577            snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0,
     2578                                  emu->tram_addr_saved[i] << 12);
     2579            snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0,
     2580                                  emu->tram_addr_saved[i] >> 20);
     2581        }
     2582    }
     2583
     2584    len = emu->audigy ? 2 * 1024 : 2 * 512;
     2585    for (i = 0; i < len; i++)
     2586        snd_emu10k1_efx_write(emu, i, emu->saved_icode[i]);
     2587
     2588    /* start FX processor when the DSP code is updated */
     2589    if (emu->audigy)
     2590        snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg);
     2591    else
     2592        snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg);
     2593}
     2594#endif
Note: See TracChangeset for help on using the changeset viewer.