Changeset 281


Ignore:
Timestamp:
Jan 23, 2008, 7:05:10 AM (18 years ago)
Author:
Brendan Oakley
Message:

Merged to ALSA 1.0.1

Location:
GPL/branches/alsa-resync1/alsa-kernel
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/alsa-resync1/alsa-kernel/core/init.c

    r277 r281  
    567567        entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL);
    568568        if (entry) {
    569                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    570569                entry->c.text.read_size = PAGE_SIZE;
    571570                entry->c.text.read = snd_card_module_info_read;
  • GPL/branches/alsa-resync1/alsa-kernel/core/memory.c

    r224 r281  
    203203        entry = snd_info_create_module_entry(THIS_MODULE, "meminfo", NULL);
    204204        if (entry) {
    205                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    206205                entry->c.text.read_size = 256;
    207206                entry->c.text.read = snd_memory_info_read;
  • GPL/branches/alsa-resync1/alsa-kernel/core/seq/seq_midi.c

    r207 r281  
    4141#include <sound/initval.h>
    4242
    43 MODULE_AUTHOR("Frank van de Pol <fvdpol@home.nl>, Jaroslav Kysela <perex@suse.cz>");
     43MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@suse.cz>");
    4444MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI synth.");
    4545MODULE_LICENSE("GPL");
  • GPL/branches/alsa-resync1/alsa-kernel/core/sound.c

    r277 r281  
    3333#ifndef TARGET_OS2
    3434#include <linux/devfs_fs_kernel.h>
     35#include <linux/device.h>
    3536#endif /* !TARGET_OS2 */
    3637
     
    5556MODULE_PARM_DESC(cards_limit, "Count of auto-loadable soundcards.");
    5657MODULE_PARM_SYNTAX(cards_limit, "default:8,skill:advanced");
     58MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);
    5759#ifdef CONFIG_DEVFS_FS
    5860MODULE_PARM(device_mode, "i");
  • GPL/branches/alsa-resync1/alsa-kernel/drivers/serial-u16550.c

    r277 r281  
    6464};
    6565
     66#define SNDRV_SERIAL_NORMALBUFF 0 /* Normal blocking buffer operation */
     67#define SNDRV_SERIAL_DROPBUFF   1 /* Non-blocking discard operation */
     68
    6669static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    6770static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
     
    7578static int ins[SNDRV_CARDS] = {REPEAT_SNDRV(1)};        /* 1 to 16 */
    7679static int adaptor[SNDRV_CARDS] = {REPEAT_SNDRV(SNDRV_SERIAL_SOUNDCANVAS)};
     80static int droponfull[SNDRV_CARDS] = {REPEAT_SNDRV(SNDRV_SERIAL_NORMALBUFF)};
    7781#else
    7882static int speed[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 38400}; /* 9600,19200,38400,57600,115200 */
     
    8185static int ins[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};  /* 1 to 16 */
    8286static int adaptor[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = SNDRV_SERIAL_SOUNDCANVAS};
     87static int droponfull[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS -1)] = SNDRV_SERIAL_NORMALBUFF };
    8388#endif
    8489
     
    108113MODULE_PARM(ins, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
    109114MODULE_PARM_DESC(ins, "Number of MIDI inputs.");
     115MODULE_PARM(droponfull, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
     116MODULE_PARM_DESC(droponfull, "Flag to enable drop-on-full buffer mode");
     117MODULE_PARM_SYNTAX(droponfull, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
    110118
    111119MODULE_PARM_SYNTAX(outs, SNDRV_ENABLED ",allows:{{1,16}},dialog:list");
     
    172180    int buff_in;
    173181    int buff_out;
     182        int drop_on_full;
    174183
    175184    // wait timer
     
    203212{
    204213    unsigned short buff_out = uart->buff_out;
     214        if( uart->buff_in_count > 0 ) {
    205215    outb(uart->tx_buff[buff_out], uart->base + UART_TX);
    206216    uart->fifo_count++;
     
    209219    uart->buff_out = buff_out;
    210220    uart->buff_in_count--;
     221        }
    211222}
    212223
     
    266277        /* Can't use FIFO, must send only when CTS is true */
    267278        status = inb(uart->base + UART_MSR);
    268         if (uart->fifo_count == 0 && (status & UART_MSR_CTS)
    269             && uart->buff_in_count > 0)
     279                while( (uart->fifo_count == 0) && (status & UART_MSR_CTS) &&
     280                      (uart->buff_in_count > 0) ) {
    270281            snd_uart16550_buffer_output(uart);
     282                       status = inb( uart->base + UART_MSR );
     283                }
    271284    } else {
    272285        /* Write loop */
     
    585598};
    586599
    587 inline static void snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned char byte)
     600inline static int snd_uart16550_buffer_can_write( snd_uart16550_t *uart, int Num )
     601{
     602        if( uart->buff_in_count + Num < TX_BUFF_SIZE )
     603                return 1;
     604        else
     605                return 0;
     606}
     607
     608inline static int snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned char byte)
    588609{
    589610    unsigned short buff_in = uart->buff_in;
     611        if( uart->buff_in_count < TX_BUFF_SIZE ) {
    590612    uart->tx_buff[buff_in] = byte;
    591613    buff_in++;
     
    594616    uart->buff_in_count++;
    595617    if (uart->irq < 0) /* polling mode */
    596         snd_uart16550_add_timer(uart);
    597 }
    598 
    599 static void snd_uart16550_output_byte(snd_uart16550_t *uart, snd_rawmidi_substream_t * substream, unsigned char midi_byte)
     618                        snd_uart16550_add_timer(uart);
     619                return 1;
     620        } else
     621                return 0;
     622}
     623
     624static int snd_uart16550_output_byte(snd_uart16550_t *uart, snd_rawmidi_substream_t * substream, unsigned char midi_byte)
    600625{
    601626    if (uart->buff_in_count == 0                            /* Buffer empty? */
     
    620645        }
    621646    } else {
    622         if (uart->buff_in_count >= TX_BUFF_SIZE) {
     647                if( !snd_uart16550_write_buffer(uart, midi_byte) ) {
    623648            snd_printk("%s: Buffer overrun on device at 0x%lx\n",
    624649                       uart->rmidi->name, uart->base);
    625             return;
    626         }
    627         snd_uart16550_write_buffer(uart, midi_byte);
    628     }
     650                        return 0;
     651                }
     652        }
     653
     654        return 1;
    629655}
    630656
     
    670696    } else {
    671697        first = 0;
    672         while (1) {
    673             if (snd_rawmidi_transmit(substream, &midi_byte, 1) != 1)
    674                 break;
     698                while( 1 == snd_rawmidi_transmit_peek(substream, &midi_byte, 1) ) {
    675699                        /* Also send F5 after 3 seconds with no data to handle device disconnect */
    676700                        if (first == 0 && (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS ||
     
    678702                           (uart->prev_out != substream->number || jiffies-lasttime > 3*HZ)) {
    679703
    680                                 /* We will need three bytes of data here (worst case). */
    681                                 if (uart->buff_in_count >= TX_BUFF_SIZE - 3)
    682                                         break;
    683 
     704                                if( snd_uart16550_buffer_can_write( uart, 3 ) ) {
    684705                /* Roland Soundcanvas part selection */
    685706                /* If this substream of the data is different previous
     
    693714                                if ((midi_byte < 0x80) && (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS))
    694715                    snd_uart16550_output_byte(uart, substream, uart->prev_status[uart->prev_out]);
    695             }
    696 
    697                         /* buffer full? */
    698                         if (uart->buff_in_count >= TX_BUFF_SIZE)
     716                                } else if( !uart->drop_on_full )
     717                                        break;
     718
     719                        }
     720
     721            /* send midi byte */
     722                        if( !snd_uart16550_output_byte(uart, substream, midi_byte) && !uart->drop_on_full )
    699723                                break;
    700724
    701             /* send midi byte */
    702             snd_uart16550_output_byte(uart, substream, midi_byte);
    703725            if (midi_byte >= 0x80 && midi_byte < 0xf0)
    704726                uart->prev_status[uart->prev_out] = midi_byte;
    705727            first = 1;
     728
     729                        snd_rawmidi_transmit_ack( substream, 1 );
    706730        }
    707731                lasttime = jiffies;
     
    780804                                       unsigned int base,
    781805                                       int adaptor,
     806                                       int droponfull,
    782807                                       snd_uart16550_t **ruart)
    783808{
     
    796821    uart->irq = -1;
    797822    uart->base = iobase;
     823        uart->drop_on_full = droponfull;
    798824
    799825        if ((err = snd_uart16550_detect(uart)) <= 0) {
     
    925951                                        base[dev],
    926952                                        adaptor[dev],
     953                                        droponfull[dev],
    927954                                    &uart)) < 0) {
    928955        snd_card_free(card);
     
    935962    }
    936963
    937         sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s",
     964        sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s droponfull %d",
    938965            card->shortname,
    939966            uart->base,
     
    943970                outs[dev],
    944971                ins[dev],
    945             adaptor_names[uart->adaptor]);
     972                adaptor_names[uart->adaptor],
     973                uart->drop_on_full);
    946974
    947975    if ((err = snd_card_register(card)) < 0) {
     
    9891017/* format is: snd-serial=enable,index,id,
    9901018                         port,irq,speed,base,outs,
    991                          ins,adaptor */
     1019                         ins,adaptor,droponfull */
    9921020
    9931021static int __init alsa_card_serial_setup(char *str)
     
    10061034               get_option(&str,&outs[nr_dev]) == 2 &&
    10071035               get_option(&str,&ins[nr_dev]) == 2 &&
    1008                get_option(&str,&adaptor[nr_dev]) == 2);
     1036               get_option(&str,&adaptor[nr_dev]) == 2 &&
     1037               get_option(&str,&droponfull[nr_dev]) == 2 );
    10091038    nr_dev++;
    10101039    return 1;
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/adriver.h

    r262 r281  
    241241#define schedule_work(w) snd_compat_schedule_work(w)
    242242
     243/* 2.5 new modules */
     244#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
     245#define try_module_get(x) try_inc_mod_count(x)
     246static inline void module_put(struct module *module)
     247{
     248        if (module)
     249                __MOD_DEC_USE_COUNT(module);
     250}
     251#endif /* 2.5.0 */
     252
     253/* gameport - 2.4 has different defines */
     254#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
     255#ifdef CONFIG_INPUT_GAMEPORT
     256#define CONFIG_GAMEPORT
     257#endif
     258#ifdef CONFIG_INPUT_GAMEPORT_MODULE
     259#define CONFIG_GAMEPORT_MODULE
     260#endif
     261#endif /* 2.5.0 */
     262
     263/* vmalloc_to_page wrapper */
     264#ifndef CONFIG_HAVE_VMALLOC_TO_PAGE
     265struct page *snd_compat_vmalloc_to_page(void *addr);
     266#define vmalloc_to_page(addr) snd_compat_vmalloc_to_page(addr)
     267#endif
     268
     269#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 69)
     270#include <linux/vmalloc.h>
     271static inline void *snd_compat_vmap(struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot)
     272{
     273        return vmap(pages, count);
     274}
     275#undef vmap
     276#define vmap snd_compat_vmap
     277#endif
     278
     279#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) /* correct version? */
     280#define EXPORT_NO_SYMBOLS
     281#endif
     282
     283/* MODULE_ALIAS & co. */
     284#ifndef MODULE_ALIAS
     285#define MODULE_ALIAS(x)
     286#define MODULE_ALIAS_CHARDEV_MAJOR(x)
     287#endif
     288
     289#ifndef CONFIG_HAVE_PCI_CONSISTENT_DMA_MASK
     290#define pci_set_consistent_dma_mask(p,x) pci_set_dma_mask(p,x)
     291#endif
     292
    243293#ifndef CONFIG_HAVE_MSLEEP_INTERRUPTIBLE
    244294#include <linux/delay.h>
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/asequencer.h

    r96 r281  
    11/*
    22 *  Main header file for the ALSA sequencer
    3  *  Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@home.nl>
     3 *  Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
    44 *            (c) 1998-1999 by Jaroslav Kysela <perex@suse.cz>
    55 *
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/asound.h

    r224 r281  
    277277#define SNDRV_PCM_INFO_JOINT_DUPLEX     0x00200000      /* playback and capture stream are somewhat correlated */
    278278#define SNDRV_PCM_INFO_SYNC_START       0x00400000      /* pcm support some kind of sync go */
     279#define SNDRV_PCM_INFO_NONATOMIC_OPS    0x00800000      /* non-atomic prepare callback */
    279280
    280281typedef int __bitwise snd_pcm_state_t;
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/compat_22.h

    r262 r281  
    163163#endif
    164164
    165 #define try_module_get(x) try_inc_mod_count(x)
    166 
    167 static inline void module_put(struct module *module)
    168 {
    169     if (module)
    170         do {} while(0);
    171 }
    172 
    173 #define MODULE_GENERIC_TABLE(gtype,name)       
    174 #define MODULE_DEVICE_TABLE(type,name)         
     165#define MODULE_GENERIC_TABLE(gtype,name)        \
     166static const unsigned long __module_##gtype##_size \
     167  __attribute__ ((unused)) = sizeof(struct gtype##_id); \
     168static const struct gtype##_id * __module_##gtype##_table \
     169  __attribute__ ((unused)) = name
     170#define MODULE_DEVICE_TABLE(type,name)          \
     171  MODULE_GENERIC_TABLE(type##_device,name)
    175172
    176173/**
     
    240237#undef pci_enable_device
    241238#define pci_enable_device snd_pci_compat_enable_device
     239#define pci_disable_device snd_pci_compat_disable_device
    242240#define pci_register_driver snd_pci_compat_register_driver
    243241#define pci_unregister_driver snd_pci_compat_unregister_driver
     
    273271#define pci_resource_flags(dev,bar) (snd_pci_compat_get_flags((dev),(bar)))
    274272
     273#define pci_request_region(dev,bar,name) snd_pci_compat_request_region(dev,bar,name)
     274#define pci_release_region(dev,bar) snd_pci_compat_release_region(dev,bar)
     275#define pci_request_regions(dev,name) snd_pci_compat_request_regions(dev,name)
     276#define pci_release_regions(dev) snd_pci_compat_release_regions(dev)
     277
    275278struct pci_device_id {
    276279        unsigned int vendor, device;            /* Vendor and device ID or PCI_ANY_ID */
     
    303306int snd_pci_compat_set_power_state(struct pci_dev *dev, int new_state);
    304307int snd_pci_compat_enable_device(struct pci_dev *dev);
     308void snd_pci_compat_disable_device(struct pci_dev *dev);
    305309int snd_pci_compat_find_capability(struct pci_dev *dev, int cap);
    306310void *snd_pci_compat_alloc_consistent(struct pci_dev *, long, dma_addr_t *);
     
    311315void * snd_pci_compat_get_driver_data (struct pci_dev *dev);
    312316void snd_pci_compat_set_driver_data (struct pci_dev *dev, void *driver_data);
     317int snd_pci_compat_request_region(struct pci_dev *pdev, int bar, char *res_name);
     318void snd_pci_compat_release_region(struct pci_dev *pdev, int bar);
     319int snd_pci_compat_request_regions(struct pci_dev *pdev, char *res_name);
     320void snd_pci_compat_release_regions(struct pci_dev *pdev);
     321
    313322static inline int pci_module_init(struct pci_driver *drv)
    314323{
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/config.h

    r256 r281  
    156156#define try_inc_mod_count(x)            ++(*(unsigned long *)x)
    157157#define try_module_get(x) try_inc_mod_count(x)
    158 static inline void module_put(struct module *module)
    159 {
    160     if (module)
    161         do {} while(0);
    162 }
    163158
    164159#define rwlock_init(x) *(x) = RW_LOCK_UNLOCKED;
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/hdsp.h

    r262 r281  
    2626        Multiface,
    2727        H9652,
     28        H9632,
    2829        Undefined,
    2930} HDSP_IO_Type;
     
    3233
    3334struct _snd_hdsp_peak_rms {
     35        unsigned int input_peaks[26];
    3436        unsigned int playback_peaks[26];
    35         unsigned int input_peaks[26];
    3637        unsigned int output_peaks[28];
     38        unsigned long long input_rms[26];
    3739        unsigned long long playback_rms[26];
    38         unsigned long long input_rms[26];
     40        /* These are only used for H96xx cards */
     41        unsigned long long output_rms[26];
    3942};
    4043
     
    6265        unsigned char line_out;
    6366        unsigned char passthru;
     67        unsigned char da_gain;
     68        unsigned char ad_gain;
     69        unsigned char phone_gain;
     70        unsigned char xlr_breakout_cable;
     71        unsigned char analog_extension_board;
    6472};
    6573
     
    9199#define SNDRV_HDSP_IOCTL_GET_MIXER _IOR('H', 0x44, hdsp_mixer_t)
    92100
     101typedef struct _snd_hdsp_9632_aeb hdsp_9632_aeb_t;
     102
     103struct _snd_hdsp_9632_aeb {
     104        int aebi;
     105        int aebo;
     106};
     107
     108#define SNDRV_HDSP_IOCTL_GET_9632_AEB _IOR('H', 0x45, hdsp_9632_aeb_t)
     109
    93110#endif /* __SOUND_HDSP_H */
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/i2c.h

    r96 r281  
    4444        char name[32];          /* some useful label */
    4545
    46         spinlock_t lock;
     46        struct semaphore lock_mutex;
    4747
    4848        struct list_head devices; /* attached devices */
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/initval.h

    r277 r281  
    4040#define MODULE_DEVICES(val) MODULE_GENERIC_STRING(info_devices, val)
    4141#define MODULE_PARM_SYNTAX(id, val) MODULE_GENERIC_STRING(info_parm_##id, val)
    42 
    43 #define SNDRV_MODULE_TYPE_int   "i"
    44 #define SNDRV_MODULE_TYPE_bool  "i"
    45 #define SNDRV_MODULE_TYPE_uint  "i"
    46 #define SNDRV_MODULE_TYPE_charp "s"
    47 #define SNDRV_MODULE_TYPE_long  "l"
    48 #define module_param_array(name, type, nump, perm) \
    49         MODULE_PARM(name, "1-" __MODULE_STRING(SNDRV_CARDS) SNDRV_MODULE_TYPE_##type)
    50 #define module_param(name, type, perm) \
    51         MODULE_PARM(name, SNDRV_MODULE_TYPE_##type)
    52 
    5342#endif
    5443
    55 #define SNDRV_AUTO_PORT         0xffff
     44#define SNDRV_AUTO_PORT         1
    5645#define SNDRV_AUTO_IRQ          0xffff
    5746#define SNDRV_AUTO_DMA          0xffff
     
    9281#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE
    9382#endif
    94 #define SNDRV_DEFAULT_PORT      { SNDRV_AUTO_PORT, [1 ... (SNDRV_CARDS-1)] = -1 }
     83#define SNDRV_DEFAULT_PORT      { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_PORT }
    9584#define SNDRV_DEFAULT_IRQ       { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_IRQ }
    9685#define SNDRV_DEFAULT_DMA       { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA }
     
    171160#include <linux/ctype.h>
    172161#include <linux/init.h>
     162#include <linux/bootmem.h>
    173163static int __init get_id(char **str, char **dst)
    174164{
    175         char *s, *d;
     165        char *s;
    176166
    177167        if (!(*str) || !(**str))
     
    179169        for (s = *str; isalpha(*s) || isdigit(*s) || *s == '_'; s++);
    180170        if (s != *str) {
    181                 *dst = (char *)kmalloc((s - *str) + 1, GFP_KERNEL);
    182                 s = *str; d = *dst;
    183                 while (isalpha(*s) || isdigit(*s) || *s == '_') {
    184                         if (d != NULL)
    185                                 *d++ = *s;
    186                         s++;
     171                int len = s - *str;
     172                char *d = (char *)alloc_bootmem(len + 1);
     173                if (d != NULL) {
     174                        memcpy(*dst = d, *str, len);
     175                        d[len] = '\0';
    187176                }
    188                 if (d != NULL)
    189                         *d = '\0';
     177        }
     178        if (*s == ',') {
     179                *str = s + 1;
     180                return 2;
    190181        }
    191182        *str = s;
    192         if (*s == ',') {
    193                 (*str)++;
    194                 return 2;
    195         }
    196183        return 1;
    197184}
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/minors.h

    r112 r281  
    8282#define SNDRV_OSS_DEVICE_TYPE_MUSIC     6
    8383
     84#define MODULE_ALIAS_SNDRV_MINOR(type) \
     85        MODULE_ALIAS("sound-service-?-" __stringify(type))
     86
    8487#endif
    8588
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/pcm_oss.h

    r277 r281  
    3232                     block:1,
    3333                     nonblock:1,
    34                      wholefrag:1,
     34                     partialfrag:1,
    3535                     nosilence:1;
    3636        unsigned int periods;
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/version.h

    r277 r281  
    11/* include/version.h.  Generated by configure.  */
    2 #define CONFIG_SND_VERSION "0.9.8"
     2#define CONFIG_SND_VERSION "1.0.1"
    33#define CONFIG_SND_DATE ""
  • GPL/branches/alsa-resync1/alsa-kernel/isa/ad1848/ad1848_lib.c

    r260 r281  
    737737                        rev = snd_ad1848_in(chip, AD1848_RIGHT_INPUT);
    738738                        if (rev == 0x65) {
     739                                spin_unlock_irqrestore(&chip->reg_lock, flags);
    739740                                id = 1;
    740741                                ad1847 = 1;
     
    742743                        }
    743744                        if (snd_ad1848_in(chip, AD1848_LEFT_INPUT) == 0xaa && rev == 0x45) {
     745                                spin_unlock_irqrestore(&chip->reg_lock, flags);
    744746                                id = 1;
    745747                                break;
  • GPL/branches/alsa-resync1/alsa-kernel/isa/als100.c

    r277 r281  
    250250        }
    251251
    252         if (mpu_port[dev] > 0) {
     252        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
    253253                if (snd_mpu401_uart_new(card, 0, MPU401_HW_ALS100,
    254254                                        mpu_port[dev], 0,
     
    258258        }
    259259
    260         if (fm_port[dev] > 0) {
     260        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
    261261                if (snd_opl3_create(card,
    262262                                    fm_port[dev], fm_port[dev] + 2,
  • GPL/branches/alsa-resync1/alsa-kernel/isa/azt2320.c

    r277 r281  
    284284        }
    285285
    286         if (mpu_port[dev] > 0) {
     286        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
    287287                if (snd_mpu401_uart_new(card, 0, MPU401_HW_AZT2320,
    288288                                mpu_port[dev], 0,
     
    292292        }
    293293
    294         if (fm_port[dev] > 0) {
     294        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
    295295                if (snd_opl3_create(card,
    296296                                    fm_port[dev], fm_port[dev] + 2,
  • GPL/branches/alsa-resync1/alsa-kernel/isa/cs423x/cs4231.c

    r277 r281  
    104104                return -ENOMEM;
    105105        acard = (struct snd_card_cs4231 *)card->private_data;
    106         if (mpu_port[dev] < 0)
    107                 mpu_port[dev] = SNDRV_AUTO_PORT;
    108106        if ((err = snd_cs4231_create(card, port[dev], -1,
    109107                                     irq[dev],
     
    129127        }
    130128
    131         if (mpu_irq[dev] >= 0 && mpu_irq[dev] != SNDRV_AUTO_IRQ) {
     129        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
     130                if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
     131                        mpu_irq[dev] = -1;
    132132                if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
    133133                                        mpu_port[dev], 0,
    134                                         mpu_irq[dev], SA_INTERRUPT,
     134                                        mpu_irq[dev],
     135                                        mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0,
    135136                                        NULL) < 0)
    136137                        printk(KERN_ERR "cs4231: MPU401 not detected\n");
  • GPL/branches/alsa-resync1/alsa-kernel/isa/cs423x/cs4236.c

    r277 r281  
    335335        if (port[dev] != SNDRV_AUTO_PORT)
    336336                pnp_resource_change(&cfg->port_resource[0], port[dev], 4);
    337         if (fm_port[dev] != SNDRV_AUTO_PORT && fm_port[dev] >= 0)
     337        if (fm_port[dev] != SNDRV_AUTO_PORT && fm_port[dev] > 0)
    338338                pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4);
    339339        if (sb_port[dev] != SNDRV_AUTO_PORT)
     
    355355        }
    356356        port[dev] = pnp_port_start(pdev, 0);
    357         if (fm_port[dev] >= 0)
     357        if (fm_port[dev] > 0)
    358358                fm_port[dev] = pnp_port_start(pdev, 1);
    359359        sb_port[dev] = pnp_port_start(pdev, 2);
     
    366366                        irq[dev], dma1[dev], dma2[dev]);
    367367        /* CTRL initialization */
    368         if (acard->ctrl && cport[dev] >= 0) {
     368        if (acard->ctrl && cport[dev] > 0) {
    369369        pdev = acard->ctrl;
    370370                pnp_init_resource_table(cfg);
     
    384384        }
    385385        /* MPU initialization */
    386         if (acard->mpu && mpu_port[dev] >= 0) {
     386        if (acard->mpu && mpu_port[dev] > 0) {
    387387                pdev = acard->mpu;
    388388                pnp_init_resource_table(cfg);
    389389                if (mpu_port[dev] != SNDRV_AUTO_PORT)
    390390                        pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2);
    391                 if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0)
     391                if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0 &&
     392                    pnp_irq_valid(pdev, 0))
    392393                        pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1);
    393394                err = pnp_manual_config_dev(pdev, cfg, 0);
     
    401402                } else {
    402403                        mpu_port[dev] = pnp_port_start(pdev, 0);
    403                         if (pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
     404                        if (mpu_irq[dev] >= 0 &&
     405                            pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
    404406                                mpu_irq[dev] = pnp_irq(pdev, 0);
    405407                        } else {
     
    463465        }
    464466#endif
    465         if (mpu_port[dev] < 0)
    466                 mpu_port[dev] = SNDRV_AUTO_PORT;
    467         if (fm_port[dev] < 0)
    468                 fm_port[dev] = SNDRV_AUTO_PORT;
    469         if (sb_port[dev] < 0)
    470                 sb_port[dev] = SNDRV_AUTO_PORT;
    471         if (sb_port[dev] != SNDRV_AUTO_PORT)
     467        if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT)
    472468                if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) {
    473469                        printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]);
     
    526522        }
    527523
    528         if (fm_port[dev] != SNDRV_AUTO_PORT) {
     524        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
    529525                if (snd_opl3_create(card,
    530526                                    fm_port[dev], fm_port[dev] + 2,
     
    539535        }
    540536
    541         if (mpu_port[dev] != SNDRV_AUTO_PORT) {
     537        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
     538                if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
     539                        mpu_irq[dev] = -1;
    542540                if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
    543541                                        mpu_port[dev], 0,
     
    574572
    575573        for ( ; dev < SNDRV_CARDS; dev++) {
    576                 if (!enable[dev])
     574                if (!enable[dev] || !isapnp[dev])
    577575                        continue;
    578576                res = snd_card_cs423x_probe(dev, card, id);
  • GPL/branches/alsa-resync1/alsa-kernel/isa/dt019x.c

    r277 r281  
    236236        }
    237237
    238         if (mpu_port[dev] > 0) {
     238        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
     239                if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
     240                        mpu_irq[dev] = -1;
    239241                if (snd_mpu401_uart_new(card, 0,
    240242/*                                      MPU401_HW_SB,*/
     
    242244                                        mpu_port[dev], 0,
    243245                                        mpu_irq[dev],
    244                                         SA_INTERRUPT,
     246                                        mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0,
    245247                                        NULL) < 0)
    246248                        snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n", mpu_port[dev]);
    247249        }
    248250
    249         if (fm_port[dev] > 0) {
     251        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
    250252                if (snd_opl3_create(card,
    251253                                    fm_port[dev],
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gus_irq.c

    r256 r281  
    137137
    138138        if (! snd_card_proc_new(gus->card, "gusirq", &entry))
    139                 snd_info_set_text_ops(entry, gus, snd_gus_irq_info_read);
     139                snd_info_set_text_ops(entry, gus, 1024, snd_gus_irq_info_read);
    140140}
    141141
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gus_mem.c

    r224 r281  
    266266#ifdef CONFIG_SND_DEBUG
    267267        if (! snd_card_proc_new(gus->card, "gusmem", &entry)) {
    268                 snd_info_set_text_ops(entry, gus, snd_gf1_mem_info_read);
     268                snd_info_set_text_ops(entry, gus, 1024, snd_gf1_mem_info_read);
    269269                entry->c.text.read_size = 256 * 1024;
    270270        }
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gus_pcm.c

    r224 r281  
    335335                        }
    336336                }
    337                 schedule_timeout(1);
    338                 if (signal_pending(current))
    339                         return -EAGAIN;
     337                if (count > 0 && !in_interrupt()) {
     338                        schedule_timeout(1);
     339                        if (signal_pending(current))
     340                                return -EAGAIN;
     341                }
    340342        }
    341343        return 0;
     
    814816};
    815817
     818static snd_kcontrol_new_t snd_gf1_pcm_volume_control1 =
     819{
     820        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     821        .name = "GPCM Playback Volume",
     822        .info = snd_gf1_pcm_volume_info,
     823        .get = snd_gf1_pcm_volume_get,
     824        .put = snd_gf1_pcm_volume_put
     825};
     826
    816827static snd_pcm_ops_t snd_gf1_pcm_playback_ops = {
    817828        .open =         snd_gf1_pcm_playback_open,
     
    881892        gus->pcm = pcm;
    882893
    883         if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_gf1_pcm_volume_control, gus))) < 0)
     894        if (gus->codec_flag)
     895                kctl = snd_ctl_new1(&snd_gf1_pcm_volume_control1, gus);
     896        else
     897                kctl = snd_ctl_new1(&snd_gf1_pcm_volume_control, gus);
     898        if ((err = snd_ctl_add(card, kctl)) < 0)
    884899                return err;
    885900        kctl->id.index = control_index;
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/interwave.c

    r277 r281  
    242242                        port += 0x10;
    243243                }
    244                 if (port > 0x380)
    245                         return -ENODEV;
    246244        } else {
    247                 if ((iwcard->i2c_res = request_region(port, 1, "InterWave (I2C bus)")) != NULL)
    248                         return -ENODEV;
    249         }
     245                iwcard->i2c_res = request_region(port, 1, "InterWave (I2C bus)");
     246        }
     247        if (iwcard->i2c_res == NULL)
     248                return -ENODEV;
     249
    250250        sprintf(name, "InterWave-%i", card->number);
    251251        if ((err = snd_i2c_bus_create(card, name, NULL, &bus)) < 0)
     
    639639        }
    640640        port[dev] = pnp_port_start(pdev, 0);
    641         dma1[dev] = pnp_dma(pdev, 1);
     641        dma1[dev] = pnp_dma(pdev, 0);
    642642        if (dma2[dev] >= 0)
    643643                dma2[dev] = pnp_dma(pdev, 1);
  • GPL/branches/alsa-resync1/alsa-kernel/isa/opti9xx/opti92x-ad1848.c

    r277 r281  
    544544__skip_base:
    545545        switch (chip->irq) {
    546 #ifdef OPTi93X
     546//#ifdef OPTi93X
    547547        case 5:
    548548                irq_bits = 0x05;
    549549                break;
    550 #endif  /* OPTi93X */
     550//#endif        /* OPTi93X */
    551551        case 7:
    552552                irq_bits = 0x01;
     
    605605        if (chip->hardware > OPTi9XX_HW_82C928) {
    606606                switch (chip->mpu_port) {
     607                case 0:
    607608                case -1:
    608609                        break;
     
    645646
    646647                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6),
    647                         (chip->mpu_port == -1) ? 0x00 :
     648                        (chip->mpu_port <= 0) ? 0x00 :
    648649                                0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3,
    649650                        0xf8);
     
    17351736        if (dma2 != SNDRV_AUTO_DMA)
    17361737                pnp_resource_change(&cfg->dma_resource[1], dma2, 1);
     1738#else
     1739#ifdef snd_opti9xx_fixup_dma2
     1740        snd_opti9xx_fixup_dma2(pdev);
     1741#endif
    17371742#endif  /* CS4231 || OPTi93X */
    1738         if (fm_port != SNDRV_AUTO_PORT)
     1743#ifdef OPTi93X
     1744        if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT)
    17391745                pnp_resource_change(&cfg->port_resource[1], fm_port, 4);
    1740 
     1746#else
     1747        if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT)
     1748                pnp_resource_change(&cfg->port_resource[2], fm_port, 4);
     1749#endif
    17411750        if (pnp_manual_config_dev(pdev, cfg, 0) < 0)
    17421751                snd_printk(KERN_ERR "AUDIO the requested resources are invalid, using auto config\n");
    17431752        err = pnp_activate_dev(pdev);
    17441753        if (err < 0) {
    1745                 snd_printk(KERN_ERR "AUDIO pnp configure failure\n");
     1754                snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err);
    17461755                kfree(cfg);
    17471756                return err;
     
    17631772
    17641773        pdev = chip->devmpu;
    1765         if (pdev) {
     1774        if (pdev && mpu_port > 0) {
    17661775                pnp_init_resource_table(cfg);
    17671776
     
    19861995#endif
    19871996
    1988 #ifdef CONFIG_PNP
    1989         if (!isapnp) {
    1990 #endif
    19911997        if (chip->wss_base == SNDRV_AUTO_PORT) {
    19921998                if ((chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) {
     
    19962002                }
    19972003        }
     2004#ifdef CONFIG_PNP
     2005        if (!isapnp) {
     2006#endif
    19982007        if (chip->mpu_port == SNDRV_AUTO_PORT) {
    19992008                if ((chip->mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
     
    20942103#endif
    20952104
    2096         if (chip->mpu_port <= 0)
     2105        if (chip->mpu_port <= 0 || chip->mpu_port == SNDRV_AUTO_PORT)
    20972106                rmidi = NULL;
    20982107        else
     
    21022111                        snd_printk("no MPU-401 device at 0x%lx?\n", chip->mpu_port);
    21032112
    2104         if (chip->fm_port > 0) {
     2113        if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) {
    21052114                opl3_t *opl3 = NULL;
    21062115#ifndef OPTi93X
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb16.c

    r277 r281  
    484484        }
    485485
    486         if (chip->mpu_port) {
     486        if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) {
    487487            if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB,
    488488                                           chip->mpu_port, 0,
     
    494494        }
    495495
    496         if (fm_port[dev] > 0) {
     496#ifdef SNDRV_SBAWE_EMU8000
     497        if (awe_port[dev] == SNDRV_AUTO_PORT)
     498                awe_port[dev] = 0; /* disable */
     499#endif
     500
     501        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
    497502                if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
    498503                                    OPL3_HW_OPL3,
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb16_csp.c

    r277 r281  
    11061106    sprintf(name, "cspD%d", device);
    11071107        if (! snd_card_proc_new(p->chip->card, name, &entry))
    1108                 snd_info_set_text_ops(entry, p, info_read);
     1108                snd_info_set_text_ops(entry, p, 1024, info_read);
    11091109        return 0;
    11101110}
  • GPL/branches/alsa-resync1/alsa-kernel/isa/wavefront/wavefront.c

    r277 r281  
    419419        int hw_dev = 0, midi_dev = 0, err;
    420420
    421         if (cs4232_mpu_port[dev] < 0)
    422                 cs4232_mpu_port[dev] = SNDRV_AUTO_PORT;
    423         if (fm_port[dev] < 0)
    424                 fm_port[dev] = SNDRV_AUTO_PORT;
    425         if (ics2115_port[dev] < 0)
    426                 ics2115_port[dev] = SNDRV_AUTO_PORT;
    427 
    428421#ifdef CONFIG_PNP
    429422        if (!isapnp[dev]) {
     
    491484        /* ---------- OPL3 synth --------- */
    492485
    493         if (fm_port[dev] != SNDRV_AUTO_PORT) {
     486        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
    494487                opl3_t *opl3;
    495488
     
    562555        /* ------ ICS2115 internal MIDI ------------ */
    563556
    564         if (ics2115_port[dev] >= 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
     557        if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
    565558                ics2115_internal_rmidi =
    566559                        snd_wavefront_new_midi (card,
     
    579572        /* ------ ICS2115 external MIDI ------------ */
    580573
    581         if (ics2115_port[dev] >= 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
     574        if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
    582575                ics2115_external_rmidi =
    583576                        snd_wavefront_new_midi (card,
     
    632625                sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
    633626
    634         if (cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
     627        if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
    635628                sprintf (card->longname + strlen (card->longname),
    636629                         " MPU-401 0x%lx irq %d",
  • GPL/branches/alsa-resync1/alsa-kernel/pci/als4000.c

    r277 r281  
    654654        /* disable all legacy ISA stuff except for joystick */
    655655#ifdef SUPPORT_JOYSTICK
    656         if (joystick_port[dev] > 0 &&
    657             (acard->res_joystick = request_region(joystick_port[dev], 8, "ALS4000 gameport")) != NULL)
     656        if (joystick_port[dev] == 1) {
     657                /* auto-detect */
     658                long p;
     659                for (p = 0x200; p <= 0x218; p += 8) {
     660                        if ((acard->res_joystick = request_region(p, 8, "ALS4000 gameport")) != NULL) {
     661                                joystick_port[dev] = p;
     662                                break;
     663                        }
     664                }
     665        } else if (joystick_port[dev] > 0)
     666                acard->res_joystick = request_region(joystick_port[dev], 8, "ALS4000 gameport");
     667        if (acard->res_joystick)
    658668                joystick = joystick_port[dev];
     669        else
     670                joystick = 0;
    659671#endif
    660672        snd_als4000_set_addr(gcr, 0, 0, 0, joystick);
  • GPL/branches/alsa-resync1/alsa-kernel/pci/cmipci.c

    r277 r281  
    7272MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
    7373MODULE_PARM_DESC(mpu_port, "MPU-401 port.");
    74 MODULE_PARM_SYNTAX(mpu_port, SNDRV_ENABLED ",allows:{{-1},{0x330},{0x320},{0x310},{0x300}},dialog:list");
     74MODULE_PARM_SYNTAX(mpu_port, SNDRV_ENABLED ",allows:{{0},{0x330},{0x320},{0x310},{0x300}},dialog:list");
    7575MODULE_PARM(fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
    7676MODULE_PARM_DESC(fm_port, "FM port.");
    77 MODULE_PARM_SYNTAX(fm_port, SNDRV_ENABLED ",allows:{{-1},{0x388},{0x3c8},{0x3e0},{0x3e8}},dialog:list");
     77MODULE_PARM_SYNTAX(fm_port, SNDRV_ENABLED ",allows:{{0},{0x388},{0x3c8},{0x3e0},{0x3e8}},dialog:list");
    7878#ifdef DO_SOFT_AC3
    7979MODULE_PARM(soft_ac3, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
     
    8282#endif
    8383#ifdef SUPPORT_JOYSTICK
    84 MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
    85 MODULE_PARM_DESC(joystick, "Enable joystick.");
    86 MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
     84MODULE_PARM(joystick_port, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
     85MODULE_PARM_DESC(joystick_port, "Joystick port address.");
     86MODULE_PARM_SYNTAX(joystick_port, SNDRV_ENABLED ",allows:{{0},{1},{0x200},{0x201}},dialog:list");
    8787#endif
    8888
     
    355355#define CM_EXTENT_MIDI    0x2
    356356#define CM_EXTENT_SYNTH   0x4
    357 
    358 /* fixed legacy joystick address */
    359 #define CM_JOYSTICK_ADDR        0x200
    360357 
    361358
     
    29842981
    29852982#ifdef SUPPORT_JOYSTICK
    2986         if (joystick[dev] &&
    2987             (cm->res_joystick = request_region(CM_JOYSTICK_ADDR, 8, "CMIPCI gameport")) != NULL) {
    2988                 cm->gameport.io = CM_JOYSTICK_ADDR;
     2983        if (joystick_port[dev] > 0) {
     2984                if (joystick_port[dev] == 1) { /* auto-detect */
     2985                        static int ports[] = { 0x200, 0x201, 0 };
     2986                        int i;
     2987                        for (i = 0; ports[i]; i++) {
     2988                                joystick_port[dev] = ports[i];
     2989                                cm->res_joystick = request_region(ports[i], 8, "CMIPCI gameport");
     2990                                if (cm->res_joystick)
     2991                                        break;
     2992                        }
     2993                } else {
     2994                        cm->res_joystick = request_region(joystick_port[dev], 8, "CMIPCI gameport");
     2995                }
     2996        }
     2997        if (cm->res_joystick) {
     2998                cm->gameport.io = joystick_port[dev];
    29892999                snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
    29903000                gameport_register_port(&cm->gameport);
    2991         } else
     3001        } else {
     3002                if (joystick_port[dev] > 0)
     3003                        printk(KERN_WARNING "cmipci: cannot reserve joystick ports\n");
    29923004                snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
     3005        }
    29933006#endif
    29943007    *rcmipci = cm;
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/aureon.c

    r262 r281  
    186186                        change = 0;
    187187                else
    188                         wm_put(ice, idx, nvol | 0x100);
     188                        wm_put(ice, idx, nvol | 0x180); /* update on zero detect */
    189189        }
    190190        snd_ice1712_restore_gpio_status(ice);
     
    367367{
    368368        static unsigned short wm_inits[] = {
     369                /* These come first to reduce init pop noise */
     370                0x1b, 0x000,            /* ADC Mux */
     371                0x1c, 0x009,            /* Out Mux1 */
     372                0x1d, 0x009,            /* Out Mux2 */
     373
     374                0x18, 0x000,            /* All power-up */
     375
    369376                0x16, 0x122,            /* I2S, normal polarity, 24bit */
    370377                0x17, 0x022,            /* 256fs, slave mode */
    371                 0x18, 0x000,            /* All power-up */
    372378                0x00, 0,                /* DAC1 analog mute */
    373379                0x01, 0,                /* DAC2 analog mute */
     
    394400                0x19, 0x000,            /* -12dB ADC/L */
    395401                0x1a, 0x000,            /* -12dB ADC/R */
    396                 0x1b, 0x000,            /* ADC Mux */
    397                 0x1c, 0x009,            /* Out Mux1 */
    398                 0x1d, 0x009,            /* Out Mux2 */
    399402        };
    400403        static unsigned short cs_inits[] = {
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/delta.c

    r246 r281  
    258258
    259259/*
     260 * change the DFS bit according rate for Delta1010
     261 */
     262static void delta_1010_set_rate_val(ice1712_t *ice, unsigned int rate)
     263{
     264        unsigned char tmp, tmp2;
     265
     266        if (rate == 0)  /* no hint - S/PDIF input is master, simply return */
     267                return;
     268
     269        down(&ice->gpio_mutex);
     270        tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
     271        tmp2 = tmp & ~ICE1712_DELTA_DFS;
     272        if (rate > 48000)
     273                tmp2 |= ICE1712_DELTA_DFS;
     274        if (tmp != tmp2)
     275                snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp2);
     276        up(&ice->gpio_mutex);
     277}
     278
     279/*
    260280 * change the rate of AK4524 on Delta 44/66, AP, 1010LT
    261281 */
     
    272292        tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
    273293        up(&ice->gpio_mutex);
    274         tmp2 = tmp;
    275         tmp2 &= ~ICE1712_DELTA_DFS;
     294        tmp2 = tmp & ~ICE1712_DELTA_DFS;
    276295        if (rate > 48000)
    277296                tmp2 |= ICE1712_DELTA_DFS;
     
    455474                break;
    456475        case ICE1712_SUBDEVICE_DELTA1010:
     476                ice->gpio.set_pro_rate = delta_1010_set_rate_val;
     477                break;
    457478        case ICE1712_SUBDEVICE_DELTADIO2496:
     479                ice->gpio.set_pro_rate = delta_1010_set_rate_val;
     480                /* fall thru */
    458481        case ICE1712_SUBDEVICE_DELTA66:
    459482                ice->spdif.ops.open = delta_open_spdif;
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ice1712.c

    r277 r281  
    10481048        spin_unlock_irqrestore(&ice->reg_lock, flags);
    10491049
     1050        if (ice->gpio.set_pro_rate)
     1051                ice->gpio.set_pro_rate(ice, rate);
    10501052        for (i = 0; i < ice->akm_codecs; i++) {
    10511053                if (ice->akm[i].ops.set_rate_val)
     
    14511453
    14521454        if (ice_has_con_ac97(ice)) {
     1455                ac97_bus_t bus, *pbus;
    14531456                ac97_t ac97;
     1457                memset(&bus, 0, sizeof(bus));
     1458                bus.write = snd_ice1712_ac97_write;
     1459                bus.read = snd_ice1712_ac97_read;
     1460                if ((err = snd_ac97_bus(ice->card, &bus, &pbus)) < 0)
     1461                        return err;
    14541462                memset(&ac97, 0, sizeof(ac97));
    1455                 ac97.write = snd_ice1712_ac97_write;
    1456                 ac97.read = snd_ice1712_ac97_read;
    14571463                ac97.private_data = ice;
    14581464                ac97.private_free = snd_ice1712_mixer_free_ac97;
    1459                 if ((err = snd_ac97_mixer(ice->card, &ac97, &ice->ac97)) < 0)
     1465                if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0)
    14601466                        printk(KERN_WARNING "ice1712: cannot initialize ac97 for consumer, skipped\n");
    14611467                else {
     
    14671473
    14681474        if (! (ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) {
     1475                ac97_bus_t bus, *pbus;
    14691476                ac97_t ac97;
     1477                memset(&bus, 0, sizeof(bus));
     1478                bus.write = snd_ice1712_pro_ac97_write;
     1479                bus.read = snd_ice1712_pro_ac97_read;
     1480                if ((err = snd_ac97_bus(ice->card, &bus, &pbus)) < 0)
     1481                        return err;
    14701482                memset(&ac97, 0, sizeof(ac97));
    1471                 ac97.write = snd_ice1712_pro_ac97_write;
    1472                 ac97.read = snd_ice1712_pro_ac97_read;
    14731483                ac97.private_data = ice;
    14741484                ac97.private_free = snd_ice1712_mixer_free_ac97;
    1475                 if ((err = snd_ac97_mixer(ice->card, &ac97, &ice->ac97)) < 0)
     1485                if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0)
    14761486                        printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n");
    14771487                else
     
    15341544
    15351545        if (! snd_card_proc_new(ice->card, "ice1712", &entry))
    1536                 snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
     1546                snd_info_set_text_ops(entry, ice, 1024, snd_ice1712_proc_read);
    15371547}
    15381548
     
    23582368                return -ENXIO;
    23592369        }
    2360         pci_set_dma_mask(pci, 0x0fffffff);
     2370        pci_set_consistent_dma_mask(pci, 0x0fffffff);
    23612371
    23622372        ice = snd_magic_kcalloc(ice1712_t, 0, GFP_KERNEL);
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ice1712.h

    r260 r281  
    354354                void (*set_data)(ice1712_t *ice, unsigned int data);
    355355                unsigned int (*get_data)(ice1712_t *ice);
     356                /* misc operators - move to another place? */
     357                void (*set_pro_rate)(ice1712_t *ice, unsigned int rate);
    356358        } gpio;
    357359        struct semaphore gpio_mutex;
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ice1724.c

    r262 r281  
    4444#include "revo.h"
    4545#include "aureon.h"
     46#include "prodigy.h"
     47
    4648
    4749MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     
    5355               AMP_AUDIO2000_DEVICE_DESC
    5456               AUREON_DEVICE_DESC
     57               PRODIGY_DEVICE_DESC
    5558                "{VIA,VT1724},"
    5659                "{ICEnsemble,Generic ICE1724},"
     
    909912
    910913        if (! (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) {
     914                ac97_bus_t bus, *pbus;
    911915                ac97_t ac97;
    912916                /* cold reset */
     
    915919                outb(inb(ICEMT1724(ice, AC97_CMD)) & ~0x80, ICEMT1724(ice, AC97_CMD));
    916920
     921                memset(&bus, 0, sizeof(bus));
     922                bus.write = snd_vt1724_ac97_write;
     923                bus.read = snd_vt1724_ac97_read;
     924                if ((err = snd_ac97_bus(ice->card, &bus, &pbus)) < 0)
     925                        return err;
    917926                memset(&ac97, 0, sizeof(ac97));
    918                 ac97.write = snd_vt1724_ac97_write;
    919                 ac97.read = snd_vt1724_ac97_read;
    920927                ac97.private_data = ice;
    921                 if ((err = snd_ac97_mixer(ice->card, &ac97, &ice->ac97)) < 0)
     928                if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0)
    922929                        printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n");
    923930                else
     
    976983
    977984        if (! snd_card_proc_new(ice->card, "ice1724", &entry))
    978                 snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read);
     985                snd_info_set_text_ops(entry, ice, 1024, snd_vt1724_proc_read);
    979986}
    980987
     
    15771584        snd_vt1724_amp_cards,
    15781585        snd_vt1724_aureon_cards,
     1586        snd_vt1724_prodigy_cards,
    15791587        0,
    15801588};
     
    17941802        if ((err = pci_enable_device(pci)) < 0)
    17951803                return err;
    1796         pci_set_dma_mask(pci, 0xffffffff);
     1804        pci_set_consistent_dma_mask(pci, 0xffffffff);
    17971805
    17981806        ice = snd_magic_kcalloc(ice1712_t, 0, GFP_KERNEL);
  • GPL/branches/alsa-resync1/alsa-kernel/pci/korg1212/korg1212.c

    r262 r281  
    20942094
    20952095        if (! snd_card_proc_new(korg1212->card, "korg1212", &entry))
    2096                 snd_info_set_text_ops(entry, korg1212, snd_korg1212_proc_read);
     2096                snd_info_set_text_ops(entry, korg1212, 1024, snd_korg1212_proc_read);
    20972097}
    20982098
  • GPL/branches/alsa-resync1/alsa-kernel/pci/rme96.c

    r277 r281  
    19311931
    19321932        if (! snd_card_proc_new(rme96->card, "rme96", &entry))
    1933                 snd_info_set_text_ops(entry, rme96, snd_rme96_proc_read);
     1933                snd_info_set_text_ops(entry, rme96, 1024, snd_rme96_proc_read);
    19341934}
    19351935
  • GPL/branches/alsa-resync1/alsa-kernel/pci/rme9652/hdsp.c

    r262 r281  
    7171MODULE_CLASSES("{sound}");
    7272MODULE_DEVICES("{{RME Hammerfall-DSP},"
    73                 "{RME HDSP-9652}}");
     73                "{RME HDSP-9652},"
     74                "{RME HDSP-9632}}");
    7475
    7576#define HDSP_MAX_CHANNELS        26
     77#define HDSP_MAX_DS_CHANNELS     14
     78#define HDSP_MAX_QS_CHANNELS     8
    7679#define DIGIFACE_SS_CHANNELS     26
    7780#define DIGIFACE_DS_CHANNELS     14
     
    8083#define H9652_SS_CHANNELS        26
    8184#define H9652_DS_CHANNELS        14
     85/* This does not include possible Analog Extension Boards
     86   AEBs are detected at card initialization
     87*/
     88#define H9632_SS_CHANNELS        12
     89#define H9632_DS_CHANNELS        8
     90#define H9632_QS_CHANNELS        4
    8291
    8392/* Write registers. These are defined as byte-offsets from the iobase value.
     
    123132#define HDSP_inputRmsLevel      4868  /* 26 * 64 bit values */
    124133
    125 #define HDSP_IO_EXTENT     5192
     134
     135/* This is for H9652 cards
     136   Peak values are read downward from the base
     137   Rms values are read upward
     138   There are rms values for the outputs too
     139   26*3 values are read in ss mode
     140   14*3 in ds mode, with no gap between values
     141*/
     142#define HDSP_9652_peakBase      7164   
     143#define HDSP_9652_rmsBase       4096
     144
     145/* c.f. the hdsp_9632_meters_t struct */
     146#define HDSP_9632_metersBase    4096
     147
     148#define HDSP_IO_EXTENT     7168
    126149
    127150/* control2 register bits */
     
    139162#define HDSP_RD_MULTIPLE        0x400
    140163#define HDSP_9652_ENABLE_MIXER  0x800
     164#define HDSP_TDO                0x10000000
    141165
    142166#define HDSP_S_PROGRAM          (HDSP_PROGRAM|HDSP_CONFIG_MODE_0)
     
    148172#define HDSP_Latency0             (1<<1)  /* buffer size = 2^n where n is defined by Latency{2,1,0} */
    149173#define HDSP_Latency1             (1<<2)  /* [ see above ] */
    150 #define HDSP_Latency2             (1<<3)  /* ] see above ] */
     174#define HDSP_Latency2             (1<<3)  /* [ see above ] */
    151175#define HDSP_ClockModeMaster      (1<<4)  /* 1=Master, 0=Slave/Autosync */
    152176#define HDSP_AudioInterruptEnable (1<<5)  /* what do you think ? */
    153 #define HDSP_Frequency0           (1<<6)  /* 0=44.1kHz/88.2kHz 1=48kHz/96kHz */
    154 #define HDSP_Frequency1           (1<<7)  /* 0=32kHz/64kHz */
     177#define HDSP_Frequency0           (1<<6)  /* 0=44.1kHz/88.2kHz/176.4kHz 1=48kHz/96kHz/192kHz */
     178#define HDSP_Frequency1           (1<<7)  /* 0=32kHz/64kHz/128kHz */
    155179#define HDSP_DoubleSpeed          (1<<8)  /* 0=normal speed, 1=double speed */
    156180#define HDSP_SPDIFProfessional    (1<<9)  /* 0=consumer, 1=professional */
     
    162186#define HDSP_SPDIFInputSelect1    (1<<15)
    163187#define HDSP_SyncRef0             (1<<16)
    164 #define HDSP_SyncRef1             (1<<17)
     188#define HDSP_SyncRef1             (1<<17)
     189#define HDSP_AnalogExtensionBoard (1<<18) /* For H9632 cards */
     190#define HDSP_XLRBreakoutCable     (1<<20) /* For H9632 cards */
    165191#define HDSP_Midi0InterruptEnable (1<<22)
    166192#define HDSP_Midi1InterruptEnable (1<<23)
    167193#define HDSP_LineOut              (1<<24)
     194#define HDSP_ADGain0              (1<<25) /* From here : H9632 specific */
     195#define HDSP_ADGain1              (1<<26)
     196#define HDSP_DAGain0              (1<<27)
     197#define HDSP_DAGain1              (1<<28)
     198#define HDSP_PhoneGain0           (1<<29)
     199#define HDSP_PhoneGain1           (1<<30)
     200#define HDSP_QuadSpeed            (1<<31)
     201
     202#define HDSP_ADGainMask       (HDSP_ADGain0|HDSP_ADGain1)
     203#define HDSP_ADGainMinus10dBV  HDSP_ADGainMask
     204#define HDSP_ADGainPlus4dBu   (HDSP_ADGain0)
     205#define HDSP_ADGainLowGain     0
     206
     207#define HDSP_DAGainMask         (HDSP_DAGain0|HDSP_DAGain1)
     208#define HDSP_DAGainHighGain      HDSP_DAGainMask
     209#define HDSP_DAGainPlus4dBu     (HDSP_DAGain0)
     210#define HDSP_DAGainMinus10dBV    0
     211
     212#define HDSP_PhoneGainMask      (HDSP_PhoneGain0|HDSP_PhoneGain1)
     213#define HDSP_PhoneGain0dB        HDSP_PhoneGainMask
     214#define HDSP_PhoneGainMinus6dB  (HDSP_PhoneGain0)
     215#define HDSP_PhoneGainMinus12dB  0
    168216
    169217#define HDSP_LatencyMask    (HDSP_Latency0|HDSP_Latency1|HDSP_Latency2)
    170 #define HDSP_FrequencyMask  (HDSP_Frequency0|HDSP_Frequency1|HDSP_DoubleSpeed)
     218#define HDSP_FrequencyMask  (HDSP_Frequency0|HDSP_Frequency1|HDSP_DoubleSpeed|HDSP_QuadSpeed)
    171219
    172220#define HDSP_SPDIFInputMask    (HDSP_SPDIFInputSelect0|HDSP_SPDIFInputSelect1)
    173221#define HDSP_SPDIFInputADAT1    0
    174 #define HDSP_SPDIFInputCoaxial (HDSP_SPDIFInputSelect1)
    175 #define HDSP_SPDIFInputCDROM   (HDSP_SPDIFInputSelect0|HDSP_SPDIFInputSelect1)
     222#define HDSP_SPDIFInputCoaxial (HDSP_SPDIFInputSelect0)
     223#define HDSP_SPDIFInputCdrom   (HDSP_SPDIFInputSelect1)
     224#define HDSP_SPDIFInputAES     (HDSP_SPDIFInputSelect0|HDSP_SPDIFInputSelect1)
    176225
    177226#define HDSP_SyncRefMask        (HDSP_SyncRef0|HDSP_SyncRef1|HDSP_SyncRef2)
    178 #define HDSP_SyncRef_ADAT1      0
     227#define HDSP_SyncRef_ADAT1       0
    179228#define HDSP_SyncRef_ADAT2      (HDSP_SyncRef0)
    180229#define HDSP_SyncRef_ADAT3      (HDSP_SyncRef1)
     
    185234/* Sample Clock Sources */
    186235
    187 #define HDSP_CLOCK_SOURCE_AUTOSYNC         0
    188 #define HDSP_CLOCK_SOURCE_INTERNAL_32KHZ   1
    189 #define HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ 2
    190 #define HDSP_CLOCK_SOURCE_INTERNAL_48KHZ   3
    191 #define HDSP_CLOCK_SOURCE_INTERNAL_64KHZ   4
    192 #define HDSP_CLOCK_SOURCE_INTERNAL_88_2KHZ 5
    193 #define HDSP_CLOCK_SOURCE_INTERNAL_96KHZ   6
     236#define HDSP_CLOCK_SOURCE_AUTOSYNC           0
     237#define HDSP_CLOCK_SOURCE_INTERNAL_32KHZ     1
     238#define HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ   2
     239#define HDSP_CLOCK_SOURCE_INTERNAL_48KHZ     3
     240#define HDSP_CLOCK_SOURCE_INTERNAL_64KHZ     4
     241#define HDSP_CLOCK_SOURCE_INTERNAL_88_2KHZ   5
     242#define HDSP_CLOCK_SOURCE_INTERNAL_96KHZ     6
     243#define HDSP_CLOCK_SOURCE_INTERNAL_128KHZ    7
     244#define HDSP_CLOCK_SOURCE_INTERNAL_176_4KHZ  8
     245#define HDSP_CLOCK_SOURCE_INTERNAL_192KHZ    9
    194246
    195247/* Preferred sync reference choices - used by "pref_sync_ref" control switch */
    196248
    197249#define HDSP_SYNC_FROM_WORD      0
    198 #define HDSP_SYNC_FROM_ADAT_SYNC 1
    199 #define HDSP_SYNC_FROM_SPDIF     2
    200 #define HDSP_SYNC_FROM_ADAT1    3
     250#define HDSP_SYNC_FROM_SPDIF    1
     251#define HDSP_SYNC_FROM_ADAT1     2
     252#define HDSP_SYNC_FROM_ADAT_SYNC 3
    201253#define HDSP_SYNC_FROM_ADAT2     4
    202254#define HDSP_SYNC_FROM_ADAT3     5
     
    220272/* Possible sources of S/PDIF input */
    221273
    222 #define HDSP_SPDIFIN_OPTICAL 0  /* optical  (ADAT1) */
    223 #define HDSP_SPDIFIN_COAXIAL 1  /* coaxial  (RCA) */
    224 #define HDSP_SPDIFIN_INTERN  2  /* internal (CDROM) */
     274#define HDSP_SPDIFIN_OPTICAL  0 /* optical  (ADAT1) */
     275#define HDSP_SPDIFIN_COAXIAL  1 /* coaxial (RCA) */
     276#define HDSP_SPDIFIN_INTERNAL 2 /* internal (CDROM) */
     277#define HDSP_SPDIFIN_AES      3 /* xlr for H9632 (AES)*/
    225278
    226279#define HDSP_Frequency32KHz    HDSP_Frequency0
    227280#define HDSP_Frequency44_1KHz  HDSP_Frequency1
    228 #define HDSP_Frequency48KHz   (HDSP_Frequency1|HDSP_Frequency0)
    229 #define HDSP_Frequency64KHz   (HDSP_DoubleSpeed|HDSP_Frequency0)
    230 #define HDSP_Frequency88_2KHz (HDSP_DoubleSpeed|HDSP_Frequency1)
    231 #define HDSP_Frequency96KHz   (HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0)
     281#define HDSP_Frequency48KHz    (HDSP_Frequency1|HDSP_Frequency0)
     282#define HDSP_Frequency64KHz    (HDSP_DoubleSpeed|HDSP_Frequency0)
     283#define HDSP_Frequency88_2KHz  (HDSP_DoubleSpeed|HDSP_Frequency1)
     284#define HDSP_Frequency96KHz    (HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0)
     285/* For H9632 cards */
     286#define HDSP_Frequency128KHz   (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency0)
     287#define HDSP_Frequency176_4KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1)
     288#define HDSP_Frequency192KHz   (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0)
    232289
    233290#define hdsp_encode_latency(x)       (((x)<<1) & HDSP_LatencyMask)
     
    240297
    241298#define HDSP_audioIRQPending    (1<<0)
    242 #define HDSP_Lock2              (1<<1)
     299#define HDSP_Lock2              (1<<1)     /* this is for Digiface and H9652 */
     300#define HDSP_spdifFrequency3    HDSP_Lock2 /* this is for H9632 only */
    243301#define HDSP_Lock1              (1<<2)
    244302#define HDSP_Lock0              (1<<3)
     
    258316#define HDSP_BufferID           (1<<26)
    259317#define HDSP_TimecodeSync       (1<<27)
    260 #define HDSP_CIN                (1<<28)
    261 #define HDSP_midi0IRQPending    (1<<30) /* notice the gap at bit 29 */
     318#define HDSP_AEBO               (1<<28) /* H9632 specific Analog Extension Boards */
     319#define HDSP_AEBI               (1<<29) /* 0 = present, 1 = absent */
     320#define HDSP_midi0IRQPending    (1<<30)
    262321#define HDSP_midi1IRQPending    (1<<31)
    263322
     
    271330#define HDSP_spdifFrequency88_2KHz (HDSP_spdifFrequency0|HDSP_spdifFrequency2)
    272331#define HDSP_spdifFrequency96KHz   (HDSP_spdifFrequency2|HDSP_spdifFrequency1)
     332
     333/* This is for H9632 cards */
     334#define HDSP_spdifFrequency128KHz   HDSP_spdifFrequencyMask
     335#define HDSP_spdifFrequency176_4KHz HDSP_spdifFrequency3
     336#define HDSP_spdifFrequency192KHz   (HDSP_spdifFrequency3|HDSP_spdifFrequency0)
    273337
    274338/* Status2 Register bits */
     
    295359#define HDSP_systemFrequency88_2 (HDSP_inp_freq0|HDSP_inp_freq2)
    296360#define HDSP_systemFrequency96   (HDSP_inp_freq1|HDSP_inp_freq2)
     361/* FIXME : more values for 9632 cards ? */
    297362
    298363#define HDSP_SelSyncRefMask        (HDSP_SelSyncRef0|HDSP_SelSyncRef1|HDSP_SelSyncRef2)
     
    342407#define HDSP_DMA_AREA_KILOBYTES (HDSP_DMA_AREA_BYTES/1024)
    343408
    344 typedef struct _hdsp          hdsp_t;
    345 typedef struct _hdsp_midi     hdsp_midi_t;
     409typedef struct _hdsp             hdsp_t;
     410typedef struct _hdsp_midi        hdsp_midi_t;
     411typedef struct _hdsp_9632_meters hdsp_9632_meters_t;
     412
     413struct _hdsp_9632_meters {
     414    u32 input_peak[16];
     415    u32 playback_peak[16];
     416    u32 output_peak[16];
     417    u32 xxx_peak[16];
     418    u32 padding[64];
     419    u32 input_rms_low[16];
     420    u32 playback_rms_low[16];
     421    u32 output_rms_low[16];
     422    u32 xxx_rms_low[16];
     423    u32 input_rms_high[16];
     424    u32 playback_rms_high[16];
     425    u32 output_rms_high[16];
     426    u32 xxx_rms_high[16];
     427};
    346428
    347429struct _hdsp_midi {
     
    374456        u32                   firmware_cache[24413]; /* this helps recover from accidental iobox power failure */
    375457        size_t                period_bytes;          /* guess what this is */
    376         unsigned char         ds_channels;
    377         unsigned char         ss_channels;          /* different for multiface/digiface */
     458        unsigned char         max_channels;
     459        unsigned char         qs_in_channels;        /* quad speed mode for H9632 */
     460        unsigned char         ds_in_channels;
     461        unsigned char         ss_in_channels;       /* different for multiface/digiface */
     462        unsigned char         qs_out_channels;     
     463        unsigned char         ds_out_channels;
     464        unsigned char         ss_out_channels;
    378465        void                 *capture_buffer_unaligned;  /* original buffer addresses */
    379466        void                 *playback_buffer_unaligned; /* original buffer addresses */
     
    386473        int                   running;
    387474        int                   passthru;              /* non-zero if doing pass-thru */
    388         int                   last_spdif_sample_rate;/* for information reporting */
    389         int                   last_external_sample_rate;
    390         int                   last_internal_sample_rate;
    391475        int                   system_sample_rate;
    392476        char                 *channel_map;
     
    401485        struct pci_dev       *pci;
    402486        snd_kcontrol_t       *spdif_ctl;
    403         snd_kcontrol_t       *playback_mixer_ctls[HDSP_MAX_CHANNELS];
    404487        unsigned short        mixer_matrix[HDSP_MATRIX_MIXER_SIZE];
    405488};
     
    425508        /* SPDIF */
    426509        24, 25,
    427         -1, -1, -1, -1, -1, -1, -1, -1,
     510        -1, -1, -1, -1, -1, -1, -1, -1
    428511};
    429512
     
    434517        24, 25,
    435518        /* others don't exist */
    436         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
     519        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
     520};
     521
     522static char channel_map_H9632_ss[HDSP_MAX_CHANNELS] = {
     523        /* ADAT channels */
     524        0, 1, 2, 3, 4, 5, 6, 7,
     525        /* SPDIF */
     526        8, 9,
     527        /* Analog */
     528        10, 11,
     529        /* AO4S-192 and AI4S-192 extension boards */
     530        12, 13, 14, 15,
     531        /* others don't exist */
     532        -1, -1, -1, -1, -1, -1, -1, -1,
     533        -1, -1
     534};
     535
     536static char channel_map_H9632_ds[HDSP_MAX_CHANNELS] = {
     537        /* ADAT */
     538        1, 3, 5, 7,
     539        /* SPDIF */
     540        8, 9,
     541        /* Analog */
     542        10, 11,
     543        /* AO4S-192 and AI4S-192 extension boards */
     544        12, 13, 14, 15,
     545        /* others don't exist */
     546        -1, -1, -1, -1, -1, -1, -1, -1,
     547        -1, -1, -1, -1, -1, -1
     548};
     549
     550static char channel_map_H9632_qs[HDSP_MAX_CHANNELS] = {
     551        /* ADAT is disabled in this mode */
     552        /* SPDIF */
     553        8, 9,
     554        /* Analog */
     555        10, 11,
     556        /* AO4S-192 and AI4S-192 extension boards */
     557        12, 13, 14, 15,
     558        /* others don't exist */
     559        -1, -1, -1, -1, -1, -1, -1, -1,
     560        -1, -1, -1, -1, -1, -1, -1, -1,
     561        -1, -1
    437562};
    438563
     
    494619static inline void snd_hdsp_initialize_channels (hdsp_t *hdsp);
    495620static inline int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout);
    496 static int hdsp_update_simple_mixer_controls(hdsp_t *hdsp);
    497621static int hdsp_autosync_ref(hdsp_t *hdsp);
    498622static int snd_hdsp_set_defaults(hdsp_t *hdsp);
     623static inline void snd_hdsp_9652_enable_mixer (hdsp_t *hdsp);
    499624
    500625static inline int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out)
     
    503628        case 0xa:
    504629                return (64 * out) + (32 + (in));
     630        case 0x96:
     631                return (32 * out) + (16 + (in));
    505632        default:
    506633                return (52 * out) + (26 + (in));
     
    513640        case 0xa:
    514641                return (64 * out) + in;
     642        case 0x96:
     643                return (32 * out) + in;
    515644        default:
    516645                return (52 * out) + in;
     
    531660{
    532661
    533         if (hdsp->io_type == H9652) return 0;
     662        if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
    534663        if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) {
    535664                snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n");
     
    567696                        }
    568697                }
     698
     699                if ((1000 / HZ) < 3000) {
     700                        set_current_state(TASK_UNINTERRUPTIBLE);
     701                        schedule_timeout((3000 * HZ + 999) / 1000);
     702                } else {
     703                        mdelay(3000);
     704                }
    569705               
    570706                if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
     
    581717                snd_printk ("finished firmware loading\n");
    582718               
    583                 if ((1000 / HZ) < 3000) {
    584                         set_current_state(TASK_UNINTERRUPTIBLE);
    585                         schedule_timeout((3000 * HZ + 999) / 1000);
    586                 } else {
    587                         mdelay(3000);
    588                 }
    589719        }
    590720        if (hdsp->state & HDSP_InitializationComplete) {
     
    645775static inline int hdsp_check_for_firmware (hdsp_t *hdsp)
    646776{
    647         if (hdsp->io_type == H9652) return 0;
     777        if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
    648778        if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
    649779                snd_printk("firmware not present.\n");
     
    694824        if (addr >= HDSP_MATRIX_MIXER_SIZE)
    695825                return -1;
    696                
    697         if (hdsp->io_type == H9652) {
     826       
     827        if (hdsp->io_type == H9652 || hdsp->io_type == H9632) {
    698828
    699829                /* from martin björnsen:
     
    709839                */
    710840
     841                if (hdsp->io_type == H9632 && addr >= 512) {
     842                        return 0;
     843                }
     844
     845                if (hdsp->io_type == H9652 && addr >= 1352) {
     846                        return 0;
     847                }
     848
    711849                hdsp->mixer_matrix[addr] = data;
    712850
     851               
    713852                /* `addr' addresses a 16-bit wide address, but
    714853                   the address space accessed via hdsp_write
     
    718857                   to access 0 to 2703 ...
    719858                */
    720 
    721                 hdsp_write (hdsp, 4096 + (addr*2),
     859                ad = addr/2;
     860       
     861                hdsp_write (hdsp, 4096 + (ad*4),
    722862                            (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) +
    723863                            hdsp->mixer_matrix[addr&0x7fe]);
     
    788928        case HDSP_spdifFrequency88_2KHz: return 88200;
    789929        case HDSP_spdifFrequency96KHz: return 96000;
     930        case HDSP_spdifFrequency128KHz:
     931                if (hdsp->io_type == H9632) return 128000;
     932                break;
     933        case HDSP_spdifFrequency176_4KHz:
     934                if (hdsp->io_type == H9632) return 176400;
     935                break;
     936        case HDSP_spdifFrequency192KHz:
     937                if (hdsp->io_type == H9632) return 192000;
     938                break;
    790939        default:
    791                 snd_printk ("unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status);
    792                 return 0;
    793         }
     940                break;
     941        }
     942        snd_printk ("unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status);
     943        return 0;
    794944}
    795945
     
    8691019        int rate_bits;
    8701020
    871         /* ASSUMPTION: hdsp->lock is either help, or
     1021        /* ASSUMPTION: hdsp->lock is either held, or
    8721022           there is no need for it (e.g. during module
    8731023           initialization).
     
    8861036                        if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) {
    8871037                                snd_printk("Detected ADAT in double speed mode\n");
     1038                        } else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) {
     1039                                snd_printk("Detected ADAT in quad speed mode\n");                       
    8881040                        } else if (rate != external_freq) {
    8891041                                snd_printk("No AutoSync source for requested rate\n");
     
    9051057           is to flag rate changes in the read/write routines.  */
    9061058
     1059        if (rate > 96000 && hdsp->io_type != H9632) {
     1060                return -EINVAL;
     1061        }
     1062       
    9071063        switch (rate) {
    9081064        case 32000:
     
    9251081                break;
    9261082        case 64000:
    927                 if (current_rate <= 48000) {
     1083                if (current_rate <= 48000 || current_rate > 96000) {
    9281084                        reject_if_open = 1;
    9291085                }
     
    9311087                break;
    9321088        case 88200:
    933                 if (current_rate <= 48000) {
     1089                if (current_rate <= 48000 || current_rate > 96000) {
    9341090                        reject_if_open = 1;
    9351091                }
     
    9371093                break;
    9381094        case 96000:
    939                 if (current_rate <= 48000) {
     1095                if (current_rate <= 48000 || current_rate > 96000) {
    9401096                        reject_if_open = 1;
    9411097                }
    9421098                rate_bits = HDSP_Frequency96KHz;
     1099                break;
     1100        case 128000:
     1101                if (current_rate < 128000) {
     1102                        reject_if_open = 1;
     1103                }
     1104                rate_bits = HDSP_Frequency128KHz;
     1105                break;
     1106        case 176400:
     1107                if (current_rate < 128000) {
     1108                        reject_if_open = 1;
     1109                }
     1110                rate_bits = HDSP_Frequency176_4KHz;
     1111                break;
     1112        case 192000:
     1113                if (current_rate < 128000) {
     1114                        reject_if_open = 1;
     1115                }
     1116                rate_bits = HDSP_Frequency192KHz;
    9431117                break;
    9441118        default:
     
    9471121
    9481122        if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) {
    949                 snd_printk ("cannot change between single- and double-speed mode (capture PID = %d, playback PID = %d)\n",
     1123                snd_printk ("cannot change speed mode (capture PID = %d, playback PID = %d)\n",
    9501124                            hdsp->capture_pid,
    9511125                            hdsp->playback_pid);
     
    9571131        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
    9581132
    959         if (rate > 48000) {
    960                 hdsp->channel_map = channel_map_ds;
     1133        if (rate >= 128000) {
     1134                hdsp->channel_map = channel_map_H9632_qs;
     1135        } else if (rate > 48000) {
     1136                if (hdsp->io_type == H9632) {
     1137                        hdsp->channel_map = channel_map_H9632_ds;
     1138                } else {
     1139                        hdsp->channel_map = channel_map_ds;
     1140                }
    9611141        } else {
    9621142                switch (hdsp->io_type) {
     
    9681148                        hdsp->channel_map = channel_map_df_ss;
    9691149                        break;
     1150                case H9632:
     1151                        hdsp->channel_map = channel_map_H9632_ss;
     1152                        break;
    9701153                default:
    9711154                        /* should never happen */
     
    9751158       
    9761159        hdsp->system_sample_rate = rate;
    977        
    978         if (reject_if_open) {
    979                 hdsp_update_simple_mixer_controls (hdsp);
    980         }
    9811160
    9821161        return 0;
     
    9951174
    9961175                if (enable) {
    997                         for (i = 0; i < 26; i++) {
     1176                        for (i = 0; i < hdsp->max_channels; i++) {
    9981177                                hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,i,i), UNITY_GAIN);
    9991178                        }
    10001179                } else {
    1001                         for (i = 0; i < 26; i++) {
     1180                        for (i = 0; i < hdsp->max_channels; i++) {
    10021181                                hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,i,i), MINUS_INFINITY_GAIN);
    10031182                        }
     
    10071186                int mapped_channel;
    10081187
    1009                 snd_assert(channel < HDSP_MAX_CHANNELS, return);
     1188                snd_assert(channel < hdsp->max_channels, return);
    10101189
    10111190                mapped_channel = hdsp->channel_map[channel];
     
    14651644static int snd_hdsp_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    14661645{
    1467         static char *texts[3] = {"ADAT1", "Coaxial", "Internal"};
     1646        static char *texts[4] = {"Optical", "Coaxial", "Internal", "AES"};
     1647        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
    14681648
    14691649        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    14701650        uinfo->count = 1;
    1471         uinfo->value.enumerated.items = 3;
    1472         if (uinfo->value.enumerated.item > 2)
    1473                 uinfo->value.enumerated.item = 2;
     1651        uinfo->value.enumerated.items = ((hdsp->io_type == H9632) ? 4 : 3);
     1652        if (uinfo->value.enumerated.item > ((hdsp->io_type == H9632) ? 3 : 2))
     1653                uinfo->value.enumerated.item = ((hdsp->io_type == H9632) ? 3 : 2);
    14741654        strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    14751655        return 0;
     
    14931673        if (!snd_hdsp_use_is_exclusive(hdsp))
    14941674                return -EBUSY;
    1495         val = ucontrol->value.enumerated.item[0] % 3;
     1675        val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3);
    14961676        spin_lock_irqsave(&hdsp->lock, flags);
    14971677        change = val != hdsp_spdif_in(hdsp);
     
    17061886static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    17071887{
    1708         static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None"};
     1888        static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};
     1889        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     1890
    17091891        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    17101892        uinfo->count = 1;
    1711         uinfo->value.enumerated.items = 7 ;
     1893        uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7;
    17121894        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
    17131895                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     
    17381920        case 96000:
    17391921                ucontrol->value.enumerated.item[0] = 5;
     1922                break;
     1923        case 128000:
     1924                ucontrol->value.enumerated.item[0] = 7;
     1925                break;
     1926        case 176400:
     1927                ucontrol->value.enumerated.item[0] = 8;
     1928                break;
     1929        case 192000:
     1930                ucontrol->value.enumerated.item[0] = 9;
    17401931                break;
    17411932        default:
     
    17801971static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    17811972{
    1782         static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None"}; 
     1973        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     1974        static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};   
    17831975        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    17841976        uinfo->count = 1;
    1785         uinfo->value.enumerated.items = 7 ;
     1977        uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7 ;
    17861978        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
    17871979                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     
    18132005                ucontrol->value.enumerated.item[0] = 5;
    18142006                break;
     2007        case 128000:
     2008                ucontrol->value.enumerated.item[0] = 7;
     2009                break;
     2010        case 176400:
     2011                ucontrol->value.enumerated.item[0] = 8;
     2012                break;
     2013        case 192000:
     2014                ucontrol->value.enumerated.item[0] = 9;
     2015                break; 
    18152016        default:
    18162017                ucontrol->value.enumerated.item[0] = 6;         
     
    18842085                case 96000:
    18852086                        return 6;
     2087                case 128000:
     2088                        return 7;
     2089                case 176400:
     2090                        return 8;
     2091                case 192000:
     2092                        return 9;
    18862093                default:
    18872094                        return 3;       
     
    18982105        case HDSP_CLOCK_SOURCE_AUTOSYNC:
    18992106                if (hdsp_external_sample_rate(hdsp) != 0) {
    1900                     hdsp->control_register &= ~HDSP_ClockModeMaster;           
    1901                     hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
    1902                     return 0;
     2107                    if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) {
     2108                        hdsp->control_register &= ~HDSP_ClockModeMaster;               
     2109                        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     2110                        return 0;
     2111                    }
    19032112                }
    19042113                return -1;
     
    19212130                rate = 96000;
    19222131                break;
     2132        case HDSP_CLOCK_SOURCE_INTERNAL_128KHZ:
     2133                rate = 128000;
     2134                break;
     2135        case HDSP_CLOCK_SOURCE_INTERNAL_176_4KHZ:
     2136                rate = 176400;
     2137                break;
     2138        case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ:
     2139                rate = 192000;
     2140                break;
    19232141        default:
    19242142                rate = 48000;
     
    19322150static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    19332151{
    1934         static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz" };
     2152        static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" };
     2153        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
    19352154       
    19362155        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    19372156        uinfo->count = 1;
    1938         uinfo->value.enumerated.items = 7;
     2157        if (hdsp->io_type == H9632)
     2158            uinfo->value.enumerated.items = 10;
     2159        else
     2160            uinfo->value.enumerated.items = 7; 
    19392161        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
    19402162                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     
    19622184        val = ucontrol->value.enumerated.item[0];
    19632185        if (val < 0) val = 0;
    1964         if (val > 6) val = 6;
     2186        if (hdsp->io_type == H9632) {
     2187            if (val > 9) val = 9;
     2188        } else {
     2189            if (val > 6) val = 6;
     2190        }
    19652191        spin_lock_irqsave(&hdsp->lock, flags);
    19662192        if (val != hdsp_clock_source(hdsp)) {
     
    19692195                change = 0;
    19702196        }
     2197        spin_unlock_irqrestore(&hdsp->lock, flags);
     2198        return change;
     2199}
     2200
     2201#define HDSP_DA_GAIN(xname, xindex) \
     2202{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
     2203  .name = xname, \
     2204  .index = xindex, \
     2205  .info = snd_hdsp_info_da_gain, \
     2206  .get = snd_hdsp_get_da_gain, \
     2207  .put = snd_hdsp_put_da_gain \
     2208}
     2209
     2210static int hdsp_da_gain(hdsp_t *hdsp)
     2211{
     2212        switch (hdsp->control_register & HDSP_DAGainMask) {
     2213        case HDSP_DAGainHighGain:
     2214                return 0;
     2215        case HDSP_DAGainPlus4dBu:
     2216                return 1;
     2217        case HDSP_DAGainMinus10dBV:
     2218                return 2;
     2219        default:
     2220                return 1;       
     2221        }
     2222}
     2223
     2224static int hdsp_set_da_gain(hdsp_t *hdsp, int mode)
     2225{
     2226        hdsp->control_register &= ~HDSP_DAGainMask;
     2227        switch (mode) {
     2228        case 0:
     2229                hdsp->control_register |= HDSP_DAGainHighGain;
     2230                break;
     2231        case 1:
     2232                hdsp->control_register |= HDSP_DAGainPlus4dBu;
     2233                break;
     2234        case 2:
     2235                hdsp->control_register |= HDSP_DAGainMinus10dBV;               
     2236                break;     
     2237        default:
     2238                return -1;
     2239
     2240        }
     2241        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     2242        return 0;
     2243}
     2244
     2245static int snd_hdsp_info_da_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     2246{
     2247        static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"};
     2248       
     2249        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
     2250        uinfo->count = 1;
     2251        uinfo->value.enumerated.items = 3;
     2252        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
     2253                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     2254        strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
     2255        return 0;
     2256}
     2257
     2258static int snd_hdsp_get_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2259{
     2260        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2261       
     2262        ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp);
     2263        return 0;
     2264}
     2265
     2266static int snd_hdsp_put_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2267{
     2268        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2269        unsigned long flags;
     2270        int change;
     2271        int val;
     2272       
     2273        if (!snd_hdsp_use_is_exclusive(hdsp))
     2274                return -EBUSY;
     2275        val = ucontrol->value.enumerated.item[0];
     2276        if (val < 0) val = 0;
     2277        if (val > 2) val = 2;
     2278        spin_lock_irqsave(&hdsp->lock, flags);
     2279        if (val != hdsp_da_gain(hdsp)) {
     2280                change = (hdsp_set_da_gain(hdsp, val) == 0) ? 1 : 0;
     2281        } else {
     2282                change = 0;
     2283        }
     2284        spin_unlock_irqrestore(&hdsp->lock, flags);
     2285        return change;
     2286}
     2287
     2288#define HDSP_AD_GAIN(xname, xindex) \
     2289{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
     2290  .name = xname, \
     2291  .index = xindex, \
     2292  .info = snd_hdsp_info_ad_gain, \
     2293  .get = snd_hdsp_get_ad_gain, \
     2294  .put = snd_hdsp_put_ad_gain \
     2295}
     2296
     2297static int hdsp_ad_gain(hdsp_t *hdsp)
     2298{
     2299        switch (hdsp->control_register & HDSP_ADGainMask) {
     2300        case HDSP_ADGainMinus10dBV:
     2301                return 0;
     2302        case HDSP_ADGainPlus4dBu:
     2303                return 1;
     2304        case HDSP_ADGainLowGain:
     2305                return 2;
     2306        default:
     2307                return 1;       
     2308        }
     2309}
     2310
     2311static int hdsp_set_ad_gain(hdsp_t *hdsp, int mode)
     2312{
     2313        hdsp->control_register &= ~HDSP_ADGainMask;
     2314        switch (mode) {
     2315        case 0:
     2316                hdsp->control_register |= HDSP_ADGainMinus10dBV;
     2317                break;
     2318        case 1:
     2319                hdsp->control_register |= HDSP_ADGainPlus4dBu;         
     2320                break;
     2321        case 2:
     2322                hdsp->control_register |= HDSP_ADGainLowGain;           
     2323                break;     
     2324        default:
     2325                return -1;
     2326
     2327        }
     2328        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     2329        return 0;
     2330}
     2331
     2332static int snd_hdsp_info_ad_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     2333{
     2334        static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"};
     2335       
     2336        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
     2337        uinfo->count = 1;
     2338        uinfo->value.enumerated.items = 3;
     2339        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
     2340                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     2341        strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
     2342        return 0;
     2343}
     2344
     2345static int snd_hdsp_get_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2346{
     2347        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2348       
     2349        ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp);
     2350        return 0;
     2351}
     2352
     2353static int snd_hdsp_put_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2354{
     2355        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2356        unsigned long flags;
     2357        int change;
     2358        int val;
     2359       
     2360        if (!snd_hdsp_use_is_exclusive(hdsp))
     2361                return -EBUSY;
     2362        val = ucontrol->value.enumerated.item[0];
     2363        if (val < 0) val = 0;
     2364        if (val > 2) val = 2;
     2365        spin_lock_irqsave(&hdsp->lock, flags);
     2366        if (val != hdsp_ad_gain(hdsp)) {
     2367                change = (hdsp_set_ad_gain(hdsp, val) == 0) ? 1 : 0;
     2368        } else {
     2369                change = 0;
     2370        }
     2371        spin_unlock_irqrestore(&hdsp->lock, flags);
     2372        return change;
     2373}
     2374
     2375#define HDSP_PHONE_GAIN(xname, xindex) \
     2376{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
     2377  .name = xname, \
     2378  .index = xindex, \
     2379  .info = snd_hdsp_info_phone_gain, \
     2380  .get = snd_hdsp_get_phone_gain, \
     2381  .put = snd_hdsp_put_phone_gain \
     2382}
     2383
     2384static int hdsp_phone_gain(hdsp_t *hdsp)
     2385{
     2386        switch (hdsp->control_register & HDSP_PhoneGainMask) {
     2387        case HDSP_PhoneGain0dB:
     2388                return 0;
     2389        case HDSP_PhoneGainMinus6dB:
     2390                return 1;
     2391        case HDSP_PhoneGainMinus12dB:
     2392                return 2;
     2393        default:
     2394                return 0;       
     2395        }
     2396}
     2397
     2398static int hdsp_set_phone_gain(hdsp_t *hdsp, int mode)
     2399{
     2400        hdsp->control_register &= ~HDSP_PhoneGainMask;
     2401        switch (mode) {
     2402        case 0:
     2403                hdsp->control_register |= HDSP_PhoneGain0dB;
     2404                break;
     2405        case 1:
     2406                hdsp->control_register |= HDSP_PhoneGainMinus6dB;               
     2407                break;
     2408        case 2:
     2409                hdsp->control_register |= HDSP_PhoneGainMinus12dB;             
     2410                break;     
     2411        default:
     2412                return -1;
     2413
     2414        }
     2415        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     2416        return 0;
     2417}
     2418
     2419static int snd_hdsp_info_phone_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     2420{
     2421        static char *texts[] = {"0 dB", "-6 dB", "-12 dB"};
     2422       
     2423        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
     2424        uinfo->count = 1;
     2425        uinfo->value.enumerated.items = 3;
     2426        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
     2427                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
     2428        strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
     2429        return 0;
     2430}
     2431
     2432static int snd_hdsp_get_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2433{
     2434        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2435       
     2436        ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp);
     2437        return 0;
     2438}
     2439
     2440static int snd_hdsp_put_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2441{
     2442        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2443        unsigned long flags;
     2444        int change;
     2445        int val;
     2446       
     2447        if (!snd_hdsp_use_is_exclusive(hdsp))
     2448                return -EBUSY;
     2449        val = ucontrol->value.enumerated.item[0];
     2450        if (val < 0) val = 0;
     2451        if (val > 2) val = 2;
     2452        spin_lock_irqsave(&hdsp->lock, flags);
     2453        if (val != hdsp_phone_gain(hdsp)) {
     2454                change = (hdsp_set_phone_gain(hdsp, val) == 0) ? 1 : 0;
     2455        } else {
     2456                change = 0;
     2457        }
     2458        spin_unlock_irqrestore(&hdsp->lock, flags);
     2459        return change;
     2460}
     2461
     2462#define HDSP_XLR_BREAKOUT_CABLE(xname, xindex) \
     2463{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
     2464  .name = xname, \
     2465  .index = xindex, \
     2466  .info = snd_hdsp_info_xlr_breakout_cable, \
     2467  .get = snd_hdsp_get_xlr_breakout_cable, \
     2468  .put = snd_hdsp_put_xlr_breakout_cable \
     2469}
     2470
     2471static int hdsp_xlr_breakout_cable(hdsp_t *hdsp)
     2472{
     2473        if (hdsp->control_register & HDSP_XLRBreakoutCable) {
     2474                return 1;
     2475        }
     2476        return 0;
     2477}
     2478
     2479static int hdsp_set_xlr_breakout_cable(hdsp_t *hdsp, int mode)
     2480{
     2481        if (mode) {
     2482                hdsp->control_register |= HDSP_XLRBreakoutCable;
     2483        } else {
     2484                hdsp->control_register &= ~HDSP_XLRBreakoutCable;
     2485        }
     2486        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     2487        return 0;
     2488}
     2489
     2490static int snd_hdsp_info_xlr_breakout_cable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     2491{
     2492        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     2493        uinfo->count = 1;
     2494        uinfo->value.integer.min = 0;
     2495        uinfo->value.integer.max = 1;
     2496        return 0;
     2497}
     2498
     2499static int snd_hdsp_get_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2500{
     2501        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2502       
     2503        ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp);
     2504        return 0;
     2505}
     2506
     2507static int snd_hdsp_put_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2508{
     2509        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2510        unsigned long flags;
     2511        int change;
     2512        int val;
     2513       
     2514        if (!snd_hdsp_use_is_exclusive(hdsp))
     2515                return -EBUSY;
     2516        val = ucontrol->value.integer.value[0] & 1;
     2517        spin_lock_irqsave(&hdsp->lock, flags);
     2518        change = (int)val != hdsp_xlr_breakout_cable(hdsp);
     2519        hdsp_set_xlr_breakout_cable(hdsp, val);
     2520        spin_unlock_irqrestore(&hdsp->lock, flags);
     2521        return change;
     2522}
     2523
     2524/* (De)activates old RME Analog Extension Board
     2525   These are connected to the internal ADAT connector
     2526   Switching this on desactivates external ADAT
     2527*/
     2528#define HDSP_AEB(xname, xindex) \
     2529{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
     2530  .name = xname, \
     2531  .index = xindex, \
     2532  .info = snd_hdsp_info_aeb, \
     2533  .get = snd_hdsp_get_aeb, \
     2534  .put = snd_hdsp_put_aeb \
     2535}
     2536
     2537static int hdsp_aeb(hdsp_t *hdsp)
     2538{
     2539        if (hdsp->control_register & HDSP_AnalogExtensionBoard) {
     2540                return 1;
     2541        }
     2542        return 0;
     2543}
     2544
     2545static int hdsp_set_aeb(hdsp_t *hdsp, int mode)
     2546{
     2547        if (mode) {
     2548                hdsp->control_register |= HDSP_AnalogExtensionBoard;
     2549        } else {
     2550                hdsp->control_register &= ~HDSP_AnalogExtensionBoard;
     2551        }
     2552        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     2553        return 0;
     2554}
     2555
     2556static int snd_hdsp_info_aeb(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     2557{
     2558        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     2559        uinfo->count = 1;
     2560        uinfo->value.integer.min = 0;
     2561        uinfo->value.integer.max = 1;
     2562        return 0;
     2563}
     2564
     2565static int snd_hdsp_get_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2566{
     2567        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2568       
     2569        ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp);
     2570        return 0;
     2571}
     2572
     2573static int snd_hdsp_put_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     2574{
     2575        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
     2576        unsigned long flags;
     2577        int change;
     2578        int val;
     2579       
     2580        if (!snd_hdsp_use_is_exclusive(hdsp))
     2581                return -EBUSY;
     2582        val = ucontrol->value.integer.value[0] & 1;
     2583        spin_lock_irqsave(&hdsp->lock, flags);
     2584        change = (int)val != hdsp_aeb(hdsp);
     2585        hdsp_set_aeb(hdsp, val);
    19712586        spin_unlock_irqrestore(&hdsp->lock, flags);
    19722587        return change;
     
    20382653static int snd_hdsp_info_pref_sync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    20392654{
    2040         static char *texts[] = {"Word", "ADAT Sync", "IEC958", "ADAT1", "ADAT2", "ADAT3" };
     2655        static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" };
    20412656        hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
    20422657       
     
    20512666        case Multiface:
    20522667                uinfo->value.enumerated.items = 4;
     2668                break;
     2669        case H9632:
     2670                uinfo->value.enumerated.items = 3;
     2671                break;
    20532672        default:
    20542673                uinfo->value.enumerated.items = 0;
     
    20872706        case Multiface:
    20882707                max = 4;
     2708                break;
     2709        case H9632:
     2710                max = 3;
    20892711                break;
    20902712        default:
     
    22982920        source = ucontrol->value.integer.value[0];
    22992921        destination = ucontrol->value.integer.value[1];
    2300 
    2301         if (source > 25) {
    2302                 addr = hdsp_playback_to_output_key(hdsp,source-26,destination);
     2922       
     2923        if (source >= hdsp->max_channels) {
     2924                addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination);
    23032925        } else {
    23042926                addr = hdsp_input_to_output_key(hdsp,source, destination);
     
    23272949        destination = ucontrol->value.integer.value[1];
    23282950
    2329         if (source > 25) {
    2330                 addr = hdsp_playback_to_output_key(hdsp,source-26, destination);
     2951        if (source >= hdsp->max_channels) {
     2952                addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels, destination);
    23312953        } else {
    23322954                addr = hdsp_input_to_output_key(hdsp,source, destination);
     
    23342956
    23352957        gain = ucontrol->value.integer.value[2];
    2336 
    2337         spin_lock_irqsave(&hdsp->lock, flags);
    2338         change = gain != hdsp_read_gain(hdsp, addr);
    2339         if (change)
    2340                 hdsp_write_gain(hdsp, addr, gain);
    2341         spin_unlock_irqrestore(&hdsp->lock, flags);
    2342         return change;
    2343 }
    2344 
    2345 /* The simple mixer control(s) provide gain control for the
    2346    basic 1:1 mappings of playback streams to output
    2347    streams.
    2348 */
    2349 
    2350 #define HDSP_PLAYBACK_MIXER \
    2351 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
    2352   .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_WRITE | \
    2353                  SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
    2354   .info = snd_hdsp_info_playback_mixer, \
    2355   .get = snd_hdsp_get_playback_mixer, \
    2356   .put = snd_hdsp_put_playback_mixer \
    2357 }
    2358 
    2359 static int snd_hdsp_info_playback_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    2360 {
    2361         uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
    2362         uinfo->count = 1;
    2363         uinfo->value.integer.min = 0;
    2364         uinfo->value.integer.max = 65536;
    2365         uinfo->value.integer.step = 1;
    2366         return 0;
    2367 }
    2368 
    2369 static int snd_hdsp_get_playback_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
    2370 {
    2371         hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
    2372         unsigned long flags;
    2373         int addr;
    2374         int channel;
    2375         int mapped_channel;
    2376 
    2377         channel = ucontrol->id.index - 1;
    2378 
    2379         snd_assert(channel >= 0 || channel < HDSP_MAX_CHANNELS, return -EINVAL);
    2380        
    2381         if ((mapped_channel = hdsp->channel_map[channel]) < 0) {
    2382                 return -EINVAL;
    2383         }
    2384 
    2385         addr = hdsp_playback_to_output_key(hdsp,mapped_channel, mapped_channel);
    2386 
    2387         spin_lock_irqsave(&hdsp->lock, flags);
    2388         ucontrol->value.integer.value[0] = hdsp_read_gain (hdsp, addr);
    2389         spin_unlock_irqrestore(&hdsp->lock, flags);
    2390         return 0;
    2391 }
    2392 
    2393 static int snd_hdsp_put_playback_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
    2394 {
    2395         hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);
    2396         unsigned long flags;
    2397         int change;
    2398         int addr;
    2399         int channel;
    2400         int mapped_channel;
    2401         int gain;
    2402 
    2403         if (!snd_hdsp_use_is_exclusive(hdsp))
    2404                 return -EBUSY;
    2405        
    2406         channel = ucontrol->id.index - 1;
    2407 
    2408         snd_assert(channel >= 0 || channel < HDSP_MAX_CHANNELS, return -EINVAL);
    2409        
    2410         if ((mapped_channel = hdsp->channel_map[channel]) < 0) {
    2411                 return -EINVAL;
    2412         }
    2413 
    2414         addr = hdsp_playback_to_output_key(hdsp,mapped_channel, mapped_channel);
    2415         gain = ucontrol->value.integer.value[0];
    2416 
    24172958
    24182959        spin_lock_irqsave(&hdsp->lock, flags);
     
    25683109                break;
    25693110        case Multiface:
     3111        case H9632:
    25703112                if (offset >= 1)
    25713113                        return -EINVAL;
     
    25783120        return 0;
    25793121}
     3122
     3123static snd_kcontrol_new_t snd_hdsp_9632_controls[] = {
     3124HDSP_DA_GAIN("DA Gain", 0),
     3125HDSP_AD_GAIN("AD Gain", 0),
     3126HDSP_PHONE_GAIN("Phones Gain", 0),
     3127HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0)
     3128};
    25803129
    25813130static snd_kcontrol_new_t snd_hdsp_controls[] = {
     
    26393188#define HDSP_CONTROLS (sizeof(snd_hdsp_controls)/sizeof(snd_kcontrol_new_t))
    26403189
    2641 static snd_kcontrol_new_t snd_hdsp_playback_mixer = HDSP_PLAYBACK_MIXER;
     3190#define HDSP_9632_CONTROLS (sizeof(snd_hdsp_9632_controls)/sizeof(snd_kcontrol_new_t))
     3191
     3192static snd_kcontrol_new_t snd_hdsp_96xx_aeb = HDSP_AEB("Analog Extension Board", 0);
    26423193static snd_kcontrol_new_t snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK;
    26433194
    2644 
    2645 static int hdsp_update_simple_mixer_controls(hdsp_t *hdsp)
    2646 {
    2647     int i;
    2648 
    2649     for (i = hdsp->ds_channels; i < hdsp->ss_channels; ++i) {
    2650             if (hdsp->system_sample_rate > 48000) {
    2651                     hdsp->playback_mixer_ctls[i]->vd[0].access = SNDRV_CTL_ELEM_ACCESS_INACTIVE |
    2652                                                             SNDRV_CTL_ELEM_ACCESS_READ |
    2653                                                              SNDRV_CTL_ELEM_ACCESS_VOLATILE;
    2654             } else {
    2655                     hdsp->playback_mixer_ctls[i]->vd[0].access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
    2656                                                              SNDRV_CTL_ELEM_ACCESS_VOLATILE;
    2657             }
    2658             snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE |
    2659                             SNDRV_CTL_EVENT_MASK_INFO, &hdsp->playback_mixer_ctls[i]->id);
    2660     }
    2661 
    2662     return 0;
    2663 }
    2664 
    2665 
    26663195int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp)
    26673196{
    2668         unsigned int idx, limit;
     3197        unsigned int idx;
    26693198        int err;
    26703199        snd_kcontrol_t *kctl;
     
    26783207        }
    26793208
    2680         snd_hdsp_playback_mixer.name = "Chn";
     3209        /* ADAT SyncCheck status */
    26813210        snd_hdsp_adat_sync_check.name = "ADAT Lock Status";
    2682 
    2683         switch (hdsp->io_type) {
    2684         case Digiface:
    2685                 limit = DIGIFACE_SS_CHANNELS;
    2686                 break;
    2687         case H9652:
    2688                 limit = H9652_SS_CHANNELS;
    2689                 break;
    2690         case Multiface:
    2691                 limit = MULTIFACE_SS_CHANNELS;
    2692                 break;
    2693         default:
    2694                 return -EIO;
    2695         }
    2696        
    2697         /* The index values are one greater than the channel ID so that alsamixer
    2698            will display them correctly. We want to use the index for fast lookup
    2699            of the relevant channel, but if we use it at all, most ALSA software
    2700            does the wrong thing with it ...
    2701         */
    2702 
    2703         for (idx = 0; idx < limit; ++idx) {
    2704                 snd_hdsp_playback_mixer.index = idx+1;
    2705                 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_playback_mixer, hdsp)))) {
    2706                         return err;
    2707                 }
    2708                 hdsp->playback_mixer_ctls[idx] = kctl;
    2709         }
    2710        
    2711         /* ADAT SyncCheck status */
    27123211        snd_hdsp_adat_sync_check.index = 1;
    27133212        if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) {
     
    27223221                }
    27233222        }
     3223       
     3224        /* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */
     3225        if (hdsp->io_type == H9632) {
     3226                for (idx = 0; idx < HDSP_9632_CONTROLS; idx++) {
     3227                        if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0) {
     3228                                return err;
     3229                        }
     3230                }
     3231        }
     3232
     3233        /* AEB control for H96xx card */
     3234        if (hdsp->io_type == H9632 || hdsp->io_type == H9652) {
     3235                if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0) {
     3236                                return err;
     3237                }       
     3238        }
    27243239
    27253240        return 0;
     
    28143329                clock_source = "Internal 96 kHz";
    28153330                break;
     3331        case HDSP_CLOCK_SOURCE_INTERNAL_128KHZ:
     3332                clock_source = "Internal 128 kHz";
     3333                break;
     3334        case HDSP_CLOCK_SOURCE_INTERNAL_176_4KHZ:
     3335                clock_source = "Internal 176.4 kHz";
     3336                break;
     3337                case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ:
     3338                clock_source = "Internal 192 kHz";
     3339                break; 
    28163340        default:
    28173341                clock_source = "Error";         
     
    28863410        snd_iprintf(buffer, "\n");
    28873411
    2888         switch ((hdsp->control_register & HDSP_SPDIFInputMask) >> 14) {
     3412        switch (hdsp_spdif_in(hdsp)) {
    28893413        case HDSP_SPDIFIN_OPTICAL:
    2890                 snd_iprintf(buffer, "IEC958 input: ADAT1\n");
     3414                snd_iprintf(buffer, "IEC958 input: Optical\n");
    28913415                break;
    28923416        case HDSP_SPDIFIN_COAXIAL:
    28933417                snd_iprintf(buffer, "IEC958 input: Coaxial\n");
    28943418                break;
    2895         case HDSP_SPDIFIN_INTERN:
     3419        case HDSP_SPDIFIN_INTERNAL:
    28963420                snd_iprintf(buffer, "IEC958 input: Internal\n");
     3421                break;
     3422        case HDSP_SPDIFIN_AES:
     3423                snd_iprintf(buffer, "IEC958 input: AES\n");
    28973424                break;
    28983425        default:
     
    29823509
    29833510        snd_iprintf(buffer, "\n");
    2984 
    2985 #if 0
    2986         for (x = 0; x < 26; x++) {
    2987                 unsigned int val = hdsp_read (hdsp, HDSP_inputPeakLevel + (4 * x));
    2988                 snd_iprintf (buffer, "%d: input peak = %d overs = %d\n", x, val&0xffffff00, val&0xf);
    2989         }
    2990 #endif
     3511       
     3512        /* Informations about H9632 specific controls */
     3513        if (hdsp->io_type == H9632) {
     3514                char *tmp;
     3515       
     3516                switch (hdsp_ad_gain(hdsp)) {
     3517                case 0:
     3518                        tmp = "-10 dBV";
     3519                        break;
     3520                case 1:
     3521                        tmp = "+4 dBu";
     3522                        break;
     3523                default:
     3524                        tmp = "Lo Gain";
     3525                        break;
     3526                }
     3527                snd_iprintf(buffer, "AD Gain : %s\n", tmp);
     3528
     3529                switch (hdsp_da_gain(hdsp)) {
     3530                case 0:
     3531                        tmp = "Hi Gain";
     3532                        break;
     3533                case 1:
     3534                        tmp = "+4 dBu";
     3535                        break;
     3536                default:
     3537                        tmp = "-10 dBV";
     3538                        break;
     3539                }
     3540                snd_iprintf(buffer, "DA Gain : %s\n", tmp);
     3541               
     3542                switch (hdsp_phone_gain(hdsp)) {
     3543                case 0:
     3544                        tmp = "0 dB";
     3545                        break;
     3546                case 1:
     3547                        tmp = "-6 dB";
     3548                        break;
     3549                default:
     3550                        tmp = "-12 dB";
     3551                        break;
     3552                }
     3553                snd_iprintf(buffer, "Phones Gain : %s\n", tmp);
     3554
     3555                snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no");
     3556               
     3557                if (hdsp->control_register & HDSP_AnalogExtensionBoard) {
     3558                        snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n");
     3559                } else {
     3560                        snd_iprintf(buffer, "AEB : off (ADAT1 external)\n");
     3561                }
     3562                snd_iprintf(buffer, "\n");
     3563        }
     3564
    29913565}
    29923566
     
    29963570
    29973571        if (! snd_card_proc_new(hdsp->card, "hdsp", &entry))
    2998                 snd_info_set_text_ops(entry, hdsp, snd_hdsp_proc_read);
     3572                snd_info_set_text_ops(entry, hdsp, 1024, snd_hdsp_proc_read);
    29993573}
    30003574
     
    30803654                                 hdsp_encode_latency(7) |
    30813655                                 HDSP_LineOut;
     3656       
    30823657
    30833658        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     3659
     3660#ifdef SNDRV_BIG_ENDIAN
     3661        hdsp->control2_register = HDSP_BIGENDIAN_MODE;
     3662#else
     3663        hdsp->control2_register = 0;
     3664#endif
     3665        if (hdsp->io_type == H9652) {
     3666                snd_hdsp_9652_enable_mixer (hdsp);
     3667        } else {
     3668            hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
     3669        }
     3670
    30843671        hdsp_reset_hw_pointer(hdsp);
    30853672        hdsp_compute_period_size(hdsp);
     
    30913678        }
    30923679
    3093         for (i = 0; i < (hdsp->io_type == H9652 ? 1352 : HDSP_MATRIX_MIXER_SIZE); i++) {
     3680        for (i = 0; i < ((hdsp->io_type == H9652 || hdsp->io_type == H9632) ? 1352 : HDSP_MATRIX_MIXER_SIZE); ++i) {
    30943681                if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) {
    30953682                        return -EIO;
     
    30983685       
    30993686        if ((hdsp->io_type != H9652) && line_outs_monitor[hdsp->dev]) {
     3687               
     3688                int lineouts_base;
    31003689               
    31013690                snd_printk ("sending all inputs and playback streams to line outs.\n");
     
    31043693                   odd numbered channels to right, even to left.
    31053694                */
     3695                if (hdsp->io_type == H9632) {
     3696                        /* this is the phones/analog output */
     3697                        lineouts_base = 10;
     3698                } else {
     3699                        lineouts_base = 26;
     3700                }
    31063701               
    3107                 for (i = 0; i < HDSP_MAX_CHANNELS; i++) {
     3702                for (i = 0; i < hdsp->max_channels; i++) {
    31083703                        if (i & 1) {
    3109                                 if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, 26), UNITY_GAIN) ||
    3110                                     hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, 26), UNITY_GAIN)) {
     3704                                if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, lineouts_base), UNITY_GAIN) ||
     3705                                    hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, lineouts_base), UNITY_GAIN)) {
    31113706                                    return -EIO;
    31123707                                }   
    31133708                        } else {
    3114                                 if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, 27), UNITY_GAIN) ||
    3115                                     hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, 27), UNITY_GAIN)) {
     3709                                if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, lineouts_base+1), UNITY_GAIN) ||
     3710                                    hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, lineouts_base+1), UNITY_GAIN)) {
     3711                                   
    31163712                                    return -EIO;
    31173713                                }
     
    31213717
    31223718        hdsp->passthru = 0;
     3719
     3720        /* H9632 specific defaults */
     3721        if (hdsp->io_type == H9632) {
     3722                hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB);
     3723                hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
     3724        }
    31233725
    31243726        /* set a default rate so that the channel map is set up.
     
    32103812        int mapped_channel;
    32113813
    3212         snd_assert(channel >= 0 || channel < HDSP_MAX_CHANNELS, return NULL);
     3814        snd_assert(channel >= 0 || channel < hdsp->max_channels, return NULL);
    32133815       
    32143816        if ((mapped_channel = hdsp->channel_map[channel]) < 0) {
     
    33823984        int mapped_channel;
    33833985
    3384         snd_assert(info->channel < HDSP_MAX_CHANNELS, return -EINVAL);
     3986        snd_assert(info->channel < hdsp->max_channels, return -EINVAL);
    33853987
    33863988        if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) {
     
    35714173};
    35724174
    3573 static unsigned int period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
    3574 
    3575 #define PERIOD_SIZES sizeof(period_sizes) / sizeof(period_sizes[0])
    3576 
    3577 static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = {
    3578         .count = PERIOD_SIZES,
    3579         .list = period_sizes,
     4175static unsigned int hdsp_period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
     4176
     4177#define HDSP_PERIOD_SIZES sizeof(hdsp_period_sizes) / sizeof(hdsp_period_sizes[0])
     4178
     4179static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_period_sizes = {
     4180        .count = HDSP_PERIOD_SIZES,
     4181        .list = hdsp_period_sizes,
    35804182        .mask = 0
    35814183};
    35824184
    3583 static int snd_hdsp_hw_rule_channels(snd_pcm_hw_params_t *params,
     4185static unsigned int hdsp_9632_sample_rates[] = { 32000, 44100, 48000, 64000, 88200, 96000, 128000, 176400, 192000 };
     4186
     4187#define HDSP_9632_SAMPLE_RATES sizeof(hdsp_9632_sample_rates) / sizeof(hdsp_9632_sample_rates[0])
     4188
     4189static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_9632_sample_rates = {
     4190        .count = HDSP_9632_SAMPLE_RATES,
     4191        .list = hdsp_9632_sample_rates,
     4192        .mask = 0
     4193};
     4194
     4195static int snd_hdsp_hw_rule_in_channels(snd_pcm_hw_params_t *params,
    35844196                                        snd_pcm_hw_rule_t *rule)
    35854197{
    35864198        hdsp_t *hdsp = rule->private;
    35874199        snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
    3588         unsigned int list[2] = { hdsp->ds_channels, hdsp->ss_channels };
     4200        if (hdsp->io_type == H9632) {
     4201                unsigned int list[3];
     4202                list[0] = hdsp->qs_in_channels;
     4203                list[1] = hdsp->ds_in_channels;
     4204                list[2] = hdsp->ss_in_channels;
     4205                return snd_interval_list(c, 3, list, 0);
     4206        } else {
     4207                unsigned int list[2];
     4208                list[0] = hdsp->ds_in_channels;
     4209                list[1] = hdsp->ss_in_channels;
     4210                return snd_interval_list(c, 2, list, 0);
     4211        }
     4212}
     4213
     4214static int snd_hdsp_hw_rule_out_channels(snd_pcm_hw_params_t *params,
     4215                                        snd_pcm_hw_rule_t *rule)
     4216{
     4217        unsigned int list[3];
     4218        hdsp_t *hdsp = rule->private;
     4219        snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
     4220        if (hdsp->io_type == H9632) {
     4221                list[0] = hdsp->qs_out_channels;
     4222                list[1] = hdsp->ds_out_channels;
     4223                list[2] = hdsp->ss_out_channels;
     4224                return snd_interval_list(c, 3, list, 0);
     4225        } else {
     4226                list[0] = hdsp->ds_out_channels;
     4227                list[1] = hdsp->ss_out_channels;
     4228        }
    35894229        return snd_interval_list(c, 2, list, 0);
    35904230}
    35914231
    3592 static int snd_hdsp_hw_rule_channels_rate(snd_pcm_hw_params_t *params,
     4232static int snd_hdsp_hw_rule_in_channels_rate(snd_pcm_hw_params_t *params,
    35934233                                             snd_pcm_hw_rule_t *rule)
    35944234{
     
    35964236        snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
    35974237        snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
    3598         if (r->min > 48000) {
     4238        if (r->min > 96000 && hdsp->io_type == H9632) {
    35994239                snd_interval_t t = {
    3600                         .min = hdsp->ds_channels,
    3601                         .max = hdsp->ds_channels,
     4240                        .min = hdsp->qs_in_channels,
     4241                        .max = hdsp->qs_in_channels,
     4242                        .integer = 1,
     4243                };
     4244                return snd_interval_refine(c, &t);     
     4245        } else if (r->min > 48000 && r->max <= 96000) {
     4246                snd_interval_t t = {
     4247                        .min = hdsp->ds_in_channels,
     4248                        .max = hdsp->ds_in_channels,
    36024249                        .integer = 1,
    36034250                };
     
    36054252        } else if (r->max < 64000) {
    36064253                snd_interval_t t = {
    3607                         .min = hdsp->ss_channels,
    3608                         .max = hdsp->ss_channels,
     4254                        .min = hdsp->ss_in_channels,
     4255                        .max = hdsp->ss_in_channels,
    36094256                        .integer = 1,
    36104257                };
     
    36144261}
    36154262
    3616 static int snd_hdsp_hw_rule_rate_channels(snd_pcm_hw_params_t *params,
     4263static int snd_hdsp_hw_rule_out_channels_rate(snd_pcm_hw_params_t *params,
    36174264                                             snd_pcm_hw_rule_t *rule)
    36184265{
     
    36204267        snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
    36214268        snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
    3622         if (c->min >= hdsp->ss_channels) {
     4269        if (r->min > 96000 && hdsp->io_type == H9632) {
     4270                snd_interval_t t = {
     4271                        .min = hdsp->qs_out_channels,
     4272                        .max = hdsp->qs_out_channels,
     4273                        .integer = 1,
     4274                };
     4275                return snd_interval_refine(c, &t);     
     4276        } else if (r->min > 48000 && r->max <= 96000) {
     4277                snd_interval_t t = {
     4278                        .min = hdsp->ds_out_channels,
     4279                        .max = hdsp->ds_out_channels,
     4280                        .integer = 1,
     4281                };
     4282                return snd_interval_refine(c, &t);
     4283        } else if (r->max < 64000) {
     4284                snd_interval_t t = {
     4285                        .min = hdsp->ss_out_channels,
     4286                        .max = hdsp->ss_out_channels,
     4287                        .integer = 1,
     4288                };
     4289                return snd_interval_refine(c, &t);
     4290        }
     4291        return 0;
     4292}
     4293
     4294static int snd_hdsp_hw_rule_rate_out_channels(snd_pcm_hw_params_t *params,
     4295                                             snd_pcm_hw_rule_t *rule)
     4296{
     4297        hdsp_t *hdsp = rule->private;
     4298        snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
     4299        snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
     4300        if (c->min >= hdsp->ss_out_channels) {
    36234301                snd_interval_t t = {
    36244302                        .min = 32000,
     
    36274305                };
    36284306                return snd_interval_refine(r, &t);
    3629         } else if (c->max <= hdsp->ds_channels) {
     4307        } else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) {
     4308                snd_interval_t t = {
     4309                        .min = 128000,
     4310                        .max = 192000,
     4311                        .integer = 1,
     4312                };
     4313                return snd_interval_refine(r, &t);
     4314        } else if (c->max <= hdsp->ds_out_channels) {
     4315                snd_interval_t t = {
     4316                        .min = 64000,
     4317                        .max = 96000,
     4318                        .integer = 1,
     4319                };
     4320                return snd_interval_refine(r, &t);
     4321        }
     4322        return 0;
     4323}
     4324
     4325static int snd_hdsp_hw_rule_rate_in_channels(snd_pcm_hw_params_t *params,
     4326                                             snd_pcm_hw_rule_t *rule)
     4327{
     4328        hdsp_t *hdsp = rule->private;
     4329        snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
     4330        snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
     4331        if (c->min >= hdsp->ss_in_channels) {
     4332                snd_interval_t t = {
     4333                        .min = 32000,
     4334                        .max = 48000,
     4335                        .integer = 1,
     4336                };
     4337                return snd_interval_refine(r, &t);
     4338        } else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) {
     4339                snd_interval_t t = {
     4340                        .min = 128000,
     4341                        .max = 192000,
     4342                        .integer = 1,
     4343                };
     4344                return snd_interval_refine(r, &t);
     4345        } else if (c->max <= hdsp->ds_in_channels) {
    36304346                snd_interval_t t = {
    36314347                        .min = 64000,
     
    36784394
    36794395        snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
    3680         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_period_sizes);
     4396        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
     4397        if (hdsp->io_type == H9632) {
     4398                runtime->hw.channels_min = hdsp->qs_out_channels;
     4399                runtime->hw.channels_max = hdsp->ss_out_channels;
     4400                runtime->hw.rate_max = 192000;
     4401                runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
     4402                snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates);
     4403        }
     4404       
    36814405        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
    3682                              snd_hdsp_hw_rule_channels, hdsp,
     4406                             snd_hdsp_hw_rule_out_channels, hdsp,
    36834407                             SNDRV_PCM_HW_PARAM_CHANNELS, -1);
    36844408        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
    3685                              snd_hdsp_hw_rule_channels_rate, hdsp,
     4409                             snd_hdsp_hw_rule_out_channels_rate, hdsp,
    36864410                             SNDRV_PCM_HW_PARAM_RATE, -1);
    36874411        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
    3688                              snd_hdsp_hw_rule_rate_channels, hdsp,
     4412                             snd_hdsp_hw_rule_rate_out_channels, hdsp,
    36894413                             SNDRV_PCM_HW_PARAM_CHANNELS, -1);
    36904414
     
    37554479
    37564480        snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
    3757         snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_period_sizes);
     4481        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
     4482        if (hdsp->io_type == H9632) {
     4483                runtime->hw.channels_min = hdsp->qs_in_channels;
     4484                runtime->hw.channels_max = hdsp->ss_in_channels;
     4485                runtime->hw.rate_max = 192000;
     4486                runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
     4487                snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates);
     4488        }
    37584489        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
    3759                              snd_hdsp_hw_rule_channels, hdsp,
     4490                             snd_hdsp_hw_rule_in_channels, hdsp,
    37604491                             SNDRV_PCM_HW_PARAM_CHANNELS, -1);
    37614492        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
    3762                              snd_hdsp_hw_rule_channels_rate, hdsp,
     4493                             snd_hdsp_hw_rule_in_channels_rate, hdsp,
    37634494                             SNDRV_PCM_HW_PARAM_RATE, -1);
    37644495        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
    3765                              snd_hdsp_hw_rule_rate_channels, hdsp,
     4496                             snd_hdsp_hw_rule_rate_in_channels, hdsp,
    37664497                             SNDRV_PCM_HW_PARAM_CHANNELS, -1);
    37674498        return 0;
     
    37844515static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file)
    37854516{
    3786     /* we have nothing to initialize but the call is required */
    3787     return 0;
     4517        /* we have nothing to initialize but the call is required */
     4518        return 0;
    37884519}
    37894520
     
    37924523{
    37934524        hdsp_t *hdsp = (hdsp_t *)hw->private_data;     
    3794        
     4525
    37954526        switch (cmd) {
    37964527        case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: {
    37974528                hdsp_peak_rms_t *peak_rms;
    3798 
     4529                int i;
     4530               
    37994531                if (hdsp->io_type == H9652) {
    3800                     snd_printk("hardware metering isn't supported yet for hdsp9652 cards\n");
    3801                     return -EINVAL;
     4532                        unsigned long rms_low, rms_high;
     4533                        int doublespeed = 0;
     4534                        if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
     4535                                doublespeed = 1;
     4536                        peak_rms = (hdsp_peak_rms_t *)arg;
     4537                        for (i = 0; i < 26; ++i) {
     4538                                if (!(doublespeed && (i & 4))) {
     4539                                        if (copy_to_user_fromio((void *)peak_rms->input_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-i*4, 4) != 0)
     4540                                                return -EFAULT;
     4541                                        if (copy_to_user_fromio((void *)peak_rms->playback_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
     4542                                                return -EFAULT;
     4543                                        if (copy_to_user_fromio((void *)peak_rms->output_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-2*(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
     4544                                                return -EFAULT;
     4545                                        rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8) & 0xFFFFFF00;
     4546                                        rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8+4) & 0xFFFFFF00;
     4547                                        rms_high += (rms_low >> 24);
     4548                                        rms_low <<= 8;
     4549                                        if (copy_to_user((void *)peak_rms->input_rms+i*8, &rms_low, 4) != 0)
     4550                                                return -EFAULT;
     4551                                        if (copy_to_user((void *)peak_rms->input_rms+i*8+4, &rms_high, 4) != 0)
     4552                                                return -EFAULT;                                 
     4553                                        rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
     4554                                        rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
     4555                                        rms_high += (rms_low >> 24);
     4556                                        rms_low <<= 8;
     4557                                        if (copy_to_user((void *)peak_rms->playback_rms+i*8, &rms_low, 4) != 0)
     4558                                                return -EFAULT;
     4559                                        if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, &rms_high, 4) != 0)
     4560                                                return -EFAULT;                                 
     4561                                        rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
     4562                                        rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
     4563                                        rms_high += (rms_low >> 24);
     4564                                        rms_low <<= 8;
     4565                                        if (copy_to_user((void *)peak_rms->output_rms+i*8, &rms_low, 4) != 0)
     4566                                                return -EFAULT;
     4567                                        if (copy_to_user((void *)peak_rms->output_rms+i*8+4, &rms_high, 4) != 0)
     4568                                                return -EFAULT;                                 
     4569                                }
     4570                        }
     4571                        return 0;
     4572                }
     4573                if (hdsp->io_type == H9632) {
     4574                        int j;
     4575                        hdsp_9632_meters_t *m;
     4576                        int doublespeed = 0;
     4577                        if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
     4578                                doublespeed = 1;
     4579                        m = (hdsp_9632_meters_t *)(hdsp->iobase+HDSP_9632_metersBase);
     4580                        peak_rms = (hdsp_peak_rms_t *)arg;
     4581                        for (i = 0, j = 0; i < 16; ++i, ++j) {
     4582                                if (copy_to_user((void *)peak_rms->input_peaks+i*4, &(m->input_peak[j]), 4) != 0)
     4583                                        return -EFAULT;
     4584                                if (copy_to_user((void *)peak_rms->playback_peaks+i*4, &(m->playback_peak[j]), 4) != 0)
     4585                                        return -EFAULT;
     4586                                if (copy_to_user((void *)peak_rms->output_peaks+i*4, &(m->output_peak[j]), 4) != 0)
     4587                                        return -EFAULT;
     4588                                if (copy_to_user((void *)peak_rms->input_rms+i*8, &(m->input_rms_low[j]), 4) != 0)
     4589                                        return -EFAULT;
     4590                                if (copy_to_user((void *)peak_rms->playback_rms+i*8, &(m->playback_rms_low[j]), 4) != 0)
     4591                                        return -EFAULT;
     4592                                if (copy_to_user((void *)peak_rms->output_rms+i*8, &(m->output_rms_low[j]), 4) != 0)
     4593                                        return -EFAULT;
     4594                                if (copy_to_user((void *)peak_rms->input_rms+i*8+4, &(m->input_rms_high[j]), 4) != 0)
     4595                                        return -EFAULT;
     4596                                if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, &(m->playback_rms_high[j]), 4) != 0)
     4597                                        return -EFAULT;
     4598                                if (copy_to_user((void *)peak_rms->output_rms+i*8+4, &(m->output_rms_high[j]), 4) != 0)
     4599                                        return -EFAULT;
     4600                                if (doublespeed && i == 3) i += 4;
     4601                        }
     4602                        return 0;
    38024603                }
    38034604                if (!(hdsp->state & HDSP_FirmwareLoaded)) {
     
    38064607                }
    38074608                peak_rms = (hdsp_peak_rms_t *)arg;
    3808                 if (copy_to_user_fromio((void *)peak_rms->playback_peaks, hdsp->iobase+HDSP_playbackPeakLevel, 26*4) != 0) {
    3809                         return -EFAULT;
    3810                 }
    3811                 if (copy_to_user_fromio((void *)peak_rms->input_peaks, hdsp->iobase+HDSP_inputPeakLevel, 26*4) != 0) {
    3812                         return -EFAULT;
    3813                 }
    3814                 if (copy_to_user_fromio((void *)peak_rms->output_peaks, hdsp->iobase+HDSP_outputPeakLevel, 28*4) != 0) {
    3815                         return -EFAULT;
    3816                 }
    3817                 if (copy_to_user_fromio((void *)peak_rms->playback_rms, hdsp->iobase+HDSP_playbackRmsLevel, 26*8) != 0) {
    3818                         return -EFAULT;
    3819                 }
    3820                 if (copy_to_user_fromio((void *)peak_rms->input_rms, hdsp->iobase+HDSP_inputRmsLevel, 26*8) != 0) {
    3821                         return -EFAULT;
     4609                for (i = 0; i < 26; ++i) {
     4610                    if (copy_to_user((void *)peak_rms->playback_peaks+i*4, (void *)hdsp->iobase+HDSP_playbackPeakLevel+i*4, 4) != 0)
     4611                            return -EFAULT;
     4612                    if (copy_to_user((void *)peak_rms->input_peaks+i*4, (void *)hdsp->iobase+HDSP_inputPeakLevel+i*4, 4) != 0)
     4613                            return -EFAULT;
     4614                }
     4615                for (i = 0; i < 26; ++i) {
     4616                        if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8, 4) != 0)
     4617                                return -EFAULT;
     4618                        if (copy_to_user((void *)peak_rms->playback_rms+i*8, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8+4, 4) != 0)
     4619                                return -EFAULT;
     4620                        if (copy_to_user((void *)peak_rms->input_rms+i*8+4, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8, 4) != 0)
     4621                                return -EFAULT;
     4622                        if (copy_to_user((void *)peak_rms->input_rms+i*8, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8+4, 4) != 0)
     4623                                return -EFAULT;
     4624                }
     4625                for (i = 0; i < 28; ++i) {
     4626                    if (copy_to_user((void *)peak_rms->output_peaks+i*4, (void *)hdsp->iobase+HDSP_outputPeakLevel+i*4, 4) != 0)
     4627                            return -EFAULT;
    38224628                }
    38234629                break;
     
    38274633                unsigned long flags;
    38284634                int i;
    3829 
     4635               
    38304636                if (!(hdsp->state & HDSP_FirmwareLoaded)) {
    38314637                        snd_printk("Firmware needs to be uploaded to the card.\n");     
     
    38354641                info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp);
    38364642                info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp);
    3837                 info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp);
     4643                if (hdsp->io_type != H9632) {
     4644                    info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp);
     4645                }
    38384646                info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp);
    3839                 for (i = 0; i < ((hdsp->io_type != Multiface) ? 3 : 1); ++i) {
     4647                for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != H9632) ? 3 : 1); ++i) {
    38404648                        info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i);
    38414649                }
     
    38534661                info.line_out = (unsigned char)hdsp_line_out(hdsp);
    38544662                info.passthru = (unsigned char)hdsp->passthru;
     4663                if (hdsp->io_type == H9632) {
     4664                        info.da_gain = (unsigned char)hdsp_da_gain(hdsp);
     4665                        info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp);
     4666                        info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp);
     4667                        info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp);
     4668               
     4669                }
     4670                if (hdsp->io_type == H9632 || hdsp->io_type == H9652) {
     4671                        info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp);
     4672                }
    38554673                spin_unlock_irqrestore(&hdsp->lock, flags);
    38564674                if (copy_to_user((void *)arg, &info, sizeof(info)))
     
    38584676                break;
    38594677        }
     4678        case SNDRV_HDSP_IOCTL_GET_9632_AEB: {
     4679                hdsp_9632_aeb_t h9632_aeb;
     4680               
     4681                if (hdsp->io_type != H9632) return -EINVAL;
     4682                h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
     4683                h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS;
     4684                if (copy_to_user((void *)arg, &h9632_aeb, sizeof(h9632_aeb)))
     4685                        return -EFAULT;
     4686                break;
     4687        }
    38604688        case SNDRV_HDSP_IOCTL_GET_VERSION: {
    38614689                hdsp_version_t hdsp_version;
    38624690                int err;
    3863 
    3864                 if (hdsp->io_type == H9652) return -EINVAL;
     4691               
     4692                if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
    38654693                if (hdsp->io_type == Undefined) {
    38664694                        if ((err = hdsp_get_iobox_version(hdsp)) < 0) {
     
    38794707                unsigned long *firmware_data;
    38804708                int err;
    3881 
    3882                 if (hdsp->io_type == H9652) return -EINVAL;
     4709               
     4710                if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
    38834711                /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */
    38844712                if (hdsp->io_type == Undefined) return -EINVAL;
     
    38864714                snd_printk("initializing firmware upload\n");
    38874715                firmware = (hdsp_firmware_t *)arg;
     4716
    38884717                if (get_user(firmware_data, &firmware->firmware_data)) {
    38894718                        return -EFAULT;
    38904719                }
    3891 
     4720               
    38924721                if (hdsp_check_for_iobox (hdsp)) {
    38934722                        return -EIO;
     
    39034732                        return err;
    39044733                }
    3905                
    39064734               
    39074735                if (!(hdsp->state & HDSP_InitializationComplete)) {
     
    39184746        }
    39194747        case SNDRV_HDSP_IOCTL_GET_MIXER: {
    3920                 hdsp_mixer_t    *mixer;
    3921 
     4748                hdsp_mixer_t *mixer;
     4749               
    39224750                mixer = (hdsp_mixer_t *)arg;
    39234751                if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE))
     
    40154843        }
    40164844       
    4017         for (i = 0; i < HDSP_MAX_CHANNELS; ++i) {
     4845        for (i = 0; i < hdsp->max_channels; ++i) {
    40184846                hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1);
    40194847                hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1);
     
    40254853static inline void snd_hdsp_initialize_channels(hdsp_t *hdsp)
    40264854{
     4855        int status, aebi_channels, aebo_channels;
     4856       
    40274857        switch (hdsp->io_type) {
    40284858        case Digiface:
    40294859                hdsp->card_name = "RME Hammerfall DSP + Digiface";
    4030                 hdsp->ss_channels = DIGIFACE_SS_CHANNELS;
    4031                 hdsp->ds_channels = DIGIFACE_DS_CHANNELS;
     4860                hdsp->ss_in_channels = hdsp->ss_out_channels = DIGIFACE_SS_CHANNELS;
     4861                hdsp->ds_in_channels = hdsp->ds_out_channels = DIGIFACE_DS_CHANNELS;
    40324862                break;
    40334863
    40344864        case H9652:
    40354865                hdsp->card_name = "RME Hammerfall HDSP 9652";
    4036                 hdsp->ss_channels = H9652_SS_CHANNELS;
    4037                 hdsp->ds_channels = H9652_DS_CHANNELS;
     4866                hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS;
     4867                hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS;
     4868                break;
     4869       
     4870        case H9632:
     4871                status = hdsp_read(hdsp, HDSP_statusRegister);
     4872                /* HDSP_AEBx bits are low when AEB are connected */
     4873                aebi_channels = (status & HDSP_AEBI) ? 0 : 4;
     4874                aebo_channels = (status & HDSP_AEBO) ? 0 : 4;
     4875                hdsp->card_name = "RME Hammerfall HDSP 9632";
     4876                hdsp->ss_in_channels = H9632_SS_CHANNELS+aebi_channels;
     4877                hdsp->ds_in_channels = H9632_DS_CHANNELS+aebi_channels;
     4878                hdsp->qs_in_channels = H9632_QS_CHANNELS+aebi_channels;
     4879                hdsp->ss_out_channels = H9632_SS_CHANNELS+aebo_channels;
     4880                hdsp->ds_out_channels = H9632_DS_CHANNELS+aebo_channels;
     4881                hdsp->qs_out_channels = H9632_QS_CHANNELS+aebo_channels;
    40384882                break;
    40394883
    40404884        case Multiface:
    40414885                hdsp->card_name = "RME Hammerfall DSP + Multiface";
    4042                 hdsp->ss_channels = MULTIFACE_SS_CHANNELS;
    4043                 hdsp->ds_channels = MULTIFACE_DS_CHANNELS;
    4044 
     4886                hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS;
     4887                hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS;
     4888                break;
     4889               
    40454890        default:
    40464891                /* should never get here */
     
    40604905       
    40614906        if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
     4907                snd_printk("Error creating pcm interface\n");
    40624908                return err;
    40634909        }
    40644910       
     4911
    40654912        if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
     4913                snd_printk("Error creating first midi interface\n");
    40664914                return err;
    40674915        }
    40684916
     4917
    40694918        if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) {
     4919                snd_printk("Error creating second midi interface\n");
    40704920                return err;
    40714921        }
    40724922
    40734923        if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) {
     4924                snd_printk("Error creating ctl interface\n");
    40744925                return err;
    40754926        }
     
    40774928        snd_hdsp_proc_init(hdsp);
    40784929
    4079         hdsp->last_spdif_sample_rate = -1;
    40804930        hdsp->system_sample_rate = -1;
    4081         hdsp->last_external_sample_rate = -1;
    4082         hdsp->last_internal_sample_rate = -1;
    40834931        hdsp->playback_pid = -1;
    40844932        hdsp->capture_pid = -1;
     
    40874935
    40884936        if ((err = snd_hdsp_set_defaults(hdsp)) < 0) {
     4937                snd_printk("Error setting default values\n");
    40894938                return err;
    40904939        }
    4091        
    4092         hdsp_update_simple_mixer_controls(hdsp);
    40934940       
    40944941        if (!(hdsp->state & HDSP_InitializationComplete)) {
     
    41124959        struct pci_dev *pci = hdsp->pci;
    41134960        int err;
    4114         int i;
    41154961        int is_9652 = 0;
     4962        int is_9632 = 0;
    41164963
    41174964        hdsp->irq = -1;
     
    41274974        hdsp->iobase = 0;
    41284975        hdsp->res_port = 0;
     4976        hdsp->control_register = 0;
     4977        hdsp->control2_register = 0;
    41294978        hdsp->io_type = Undefined;
    4130         for (i = 0; i < HDSP_MAX_CHANNELS; ++i)
    4131                 hdsp->playback_mixer_ctls[i] = 0;
     4979        hdsp->max_channels = 26;
    41324980
    41334981        hdsp->card = card;
     
    41545002                is_9652 = 1;
    41555003                break;
    4156 
     5004        case 0x96:
     5005                hdsp->card_name = "RME HDSP 9632";
     5006                hdsp->max_channels = 16;
     5007                is_9632 = 1;
     5008                break;
    41575009        default:
    41585010                return -ENODEV;
     
    41895041        }
    41905042       
    4191         if (!is_9652 && hdsp_check_for_iobox (hdsp)) {
     5043        if (!is_9652 && !is_9632 && hdsp_check_for_iobox (hdsp)) {
    41925044                /* no iobox connected, we defer initialization */
    41935045                snd_printk("card initialization pending : waiting for firmware\n");
     
    42205072        if (is_9652) {
    42215073                hdsp->io_type = H9652;
    4222                 snd_hdsp_9652_enable_mixer (hdsp);
     5074        }
     5075       
     5076        if (is_9632) {
     5077                hdsp->io_type = H9632;
    42235078        }
    42245079
  • GPL/branches/alsa-resync1/alsa-kernel/pci/rme9652/rme9652.c

    r262 r281  
    16181618RME9652_ADAT_SYNC("ADAT1 Sync Check", 0, 0),
    16191619RME9652_ADAT_SYNC("ADAT2 Sync Check", 0, 1),
    1620 RME9652_ADAT_SYNC("ADAT3 Sync Check", 0, 2),
    16211620RME9652_TC_VALID("Timecode Valid", 0),
    16221621RME9652_PASSTHRU("Passthru", 0)
     
    18351834
    18361835        if (! snd_card_proc_new(rme9652->card, "rme9652", &entry))
    1837                 snd_info_set_text_ops(entry, rme9652, snd_rme9652_proc_read);
     1836                snd_info_set_text_ops(entry, rme9652, 1024, snd_rme9652_proc_read);
    18381837}
    18391838
  • GPL/branches/alsa-resync1/alsa-kernel/pci/sonicvibes.c

    r262 r281  
    11821182
    11831183        if (! snd_card_proc_new(sonic->card, "sonicvibes", &entry))
    1184                 snd_info_set_text_ops(entry, sonic, snd_sonicvibes_proc_read);
     1184                snd_info_set_text_ops(entry, sonic, 1024, snd_sonicvibes_proc_read);
    11851185}
    11861186
     
    12581258                return -ENXIO;
    12591259        }
    1260         pci_set_dma_mask(pci, 0x00ffffff);
     1260        pci_set_consistent_dma_mask(pci, 0x00ffffff);
    12611261
    12621262        sonic = snd_magic_kcalloc(sonicvibes_t, 0, GFP_KERNEL);
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ymfpci/ymfpci.c

    r277 r281  
    135135
    136136        if (pci_id->device >= 0x0010) { /* YMF 744/754 */
    137                 if (fm_port[dev] <= 0) {
     137                if (fm_port[dev] == 1) {
     138                        /* auto-detect */
    138139                        fm_port[dev] = pci_resource_start(pci, 1);
    139140                }
     
    143144                        pci_write_config_word(pci, PCIR_DSXG_FMBASE, fm_port[dev]);
    144145                }
    145                 if (mpu_port[dev] <= 0) {
     146                if (mpu_port[dev] == 1) {
     147                        /* auto-detect */
    146148                        mpu_port[dev] = pci_resource_start(pci, 1) + 0x20;
    147149                }
     
    152154                }
    153155#ifdef SUPPORT_JOYSTICK
    154                 if (joystick_port[dev] < 0) {
     156                if (joystick_port[dev] == 1) {
     157                        /* auto-detect */
    155158                        joystick_port[dev] = pci_resource_start(pci, 2);
    156159                }
    157                 if (joystick_port[dev] >= 0 &&
     160                if (joystick_port[dev] > 0 &&
    158161                    (joystick_res = request_region(joystick_port[dev], 1, "YMFPCI gameport")) != NULL) {
    159162                        legacy_ctrl |= YMFPCI_LEGACY_JPEN;
     
    167170                case 0x3a0: legacy_ctrl2 |= 2; break;
    168171                case 0x3a8: legacy_ctrl2 |= 3; break;
    169                 default: fm_port[dev] = -1; break;
     172                default: fm_port[dev] = 0; break;
    170173                }
    171174                if (fm_port[dev] > 0 &&
     
    174177                } else {
    175178                        legacy_ctrl2 &= ~YMFPCI_LEGACY2_FMIO;
    176                         fm_port[dev] = -1;
     179                        fm_port[dev] = 0;
    177180                }
    178181                switch (mpu_port[dev]) {
     
    181184                case 0x332: legacy_ctrl2 |= 2 << 4; break;
    182185                case 0x334: legacy_ctrl2 |= 3 << 4; break;
    183                 default: mpu_port[dev] = -1; break;
     186                default: mpu_port[dev] = 0; break;
    184187                }
    185188                if (mpu_port[dev] > 0 &&
     
    188191                } else {
    189192                        legacy_ctrl2 &= ~YMFPCI_LEGACY2_MPUIO;
    190                         mpu_port[dev] = -1;
    191                 }
    192 #ifdef SUPPORT_JOYSTICK
     193                        mpu_port[dev] = 0;
     194                }
     195#ifdef SUPPORT_JOYSTICK
     196                if (joystick_port[dev] == 1) {
     197                        /* auto-detect */
     198                        long p;
     199                        for (p = 0x201; p <= 0x205; p++) {
     200                                if (p == 0x203) continue;
     201                                if ((joystick_res = request_region(p, 1, "YMFPCI gameport")) != NULL)
     202                                        break;
     203                        }
     204                        if (joystick_res)
     205                                joystick_port[dev] = p;
     206                }
    193207                switch (joystick_port[dev]) {
    194208                case 0x201: legacy_ctrl2 |= 0 << 6; break;
     
    196210                case 0x204: legacy_ctrl2 |= 2 << 6; break;
    197211                case 0x205: legacy_ctrl2 |= 3 << 6; break;
    198                 default: joystick_port[dev] = -1; break;
    199                 }
    200                 if (joystick_port[dev] > 0 &&
    201                     (joystick_res = request_region(joystick_port[dev], 1, "YMFPCI gameport")) != NULL) {
     212                default: joystick_port[dev] = 0; break;
     213                }
     214                if (! joystick_res && joystick_port[dev] > 0)
     215                        joystick_res = request_region(joystick_port[dev], 1, "YMFPCI gameport");
     216                if (joystick_res) {
    202217                        legacy_ctrl |= YMFPCI_LEGACY_JPEN;
    203218                } else {
    204219                        legacy_ctrl2 &= ~YMFPCI_LEGACY2_JSIO;
    205                         joystick_port[dev] = -1;
     220                        joystick_port[dev] = 0;
    206221                }
    207222#endif
Note: See TracChangeset for help on using the changeset viewer.