Changeset 92


Ignore:
Timestamp:
May 2, 2007, 9:13:43 AM (18 years ago)
Author:
Brendan Oakley
Message:

Merged 0.9.0beta6 to 0.9.0beta12. Fixed a few compilation errors.
Left include/sound/driver.h at beta9 until I figure out why it contains
so many modifications to sections that were removed in beta10.
Does not yet build. Needs more fixing.
Added a few new files that were in the copy Paul gave me to work from.

Location:
GPL/branches/alsa-resync1/alsa-kernel
Files:
4 added
60 edited

Legend:

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

    r84 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    19  *
    20  */
    21 
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     19 *
     20 */
     21
     22#define __NO_VERSION__
    2223#include <sound/driver.h>
     24#include <linux/interrupt.h>
     25#include <linux/slab.h>
     26#include <linux/vmalloc.h>
     27#include <linux/time.h>
     28#include <sound/core.h>
    2329#include <sound/minors.h>
    2430#include <sound/info.h>
     
    4349static int snd_ctl_open(struct inode *inode, struct file *file)
    4450{
    45     int cardnum = SNDRV_MINOR_CARD(MINOR(inode->i_rdev));
    46     unsigned long flags;
    47     struct snd_card *card;
    48     struct snd_ctl_file *ctl;
    49     int err;
    50 
    51     card = snd_cards[cardnum];
    52     if (!card) {
    53         err = -ENODEV;
    54         goto __error1;
    55     }
    56     err = snd_card_file_add(card, file);
    57     if (err < 0) {
    58         err = -ENODEV;
    59         goto __error1;
    60     }
    61     if (!try_module_get(card->module)) {
    62         err = -EFAULT;
    63         goto __error2;
    64     }
    65     ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL);
    66     if (ctl == NULL) {
    67         err = -ENOMEM;
    68         goto __error;
    69     }
    70     INIT_LIST_HEAD(&ctl->events);
    71     init_waitqueue_head(&ctl->change_sleep);
    72     spin_lock_init(&ctl->read_lock);
    73     ctl->card = card;
    74     ctl->pid = current->pid;
    75     file->private_data = ctl;
    76     write_lock_irqsave(&card->ctl_files_rwlock, flags);
    77     list_add_tail(&ctl->list, &card->ctl_files);
    78     write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
    79     return 0;
     51        int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
     52        unsigned long flags;
     53        struct snd_card *card;
     54        struct snd_ctl_file *ctl;
     55        int err;
     56
     57        card = snd_cards[cardnum];
     58        if (!card) {
     59                err = -ENODEV;
     60                goto __error1;
     61        }
     62        err = snd_card_file_add(card, file);
     63        if (err < 0) {
     64                err = -ENODEV;
     65                goto __error1;
     66        }
     67        if (!try_module_get(card->module)) {
     68                err = -EFAULT;
     69                goto __error2;
     70        }
     71        ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL);
     72        if (ctl == NULL) {
     73                err = -ENOMEM;
     74                goto __error;
     75        }
     76        INIT_LIST_HEAD(&ctl->events);
     77        init_waitqueue_head(&ctl->change_sleep);
     78        spin_lock_init(&ctl->read_lock);
     79        ctl->card = card;
     80        ctl->pid = current->pid;
     81        file->private_data = ctl;
     82        write_lock_irqsave(&card->ctl_files_rwlock, flags);
     83        list_add_tail(&ctl->list, &card->ctl_files);
     84        write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
     85        return 0;
    8086
    8187__error:
     
    8490    snd_card_file_remove(card, file);
    8591__error1:
    86     return err;
     92        return err;
    8793}
    8894
     
    9096{
    9197    struct snd_kctl_event *cread;
    92 
    93     spin_lock(&ctl->read_lock);
    94     while (!list_empty(&ctl->events)) {
    95         cread = snd_kctl_event(ctl->events.next);
    96         list_del(&cread->list);
    97         kfree(cread);
    98     }
    99     spin_unlock(&ctl->read_lock);
     98       
     99        spin_lock(&ctl->read_lock);
     100        while (!list_empty(&ctl->events)) {
     101                cread = snd_kctl_event(ctl->events.next);
     102                list_del(&cread->list);
     103                kfree(cread);
     104        }
     105        spin_unlock(&ctl->read_lock);
    100106}
    101107
    102108static int snd_ctl_release(struct inode *inode, struct file *file)
    103109{
    104     unsigned long flags;
    105     struct list_head *list;
    106     struct snd_card *card;
    107     struct snd_ctl_file *ctl;
    108     struct snd_kcontrol *control;
    109     unsigned int idx;
    110 
    111     ctl = file->private_data;
    112     fasync_helper(-1, file, 0, &ctl->fasync);
    113     file->private_data = NULL;
    114     card = ctl->card;
    115     write_lock_irqsave(&card->ctl_files_rwlock, flags);
    116     list_del(&ctl->list);
    117     write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
    118     down_write(&card->controls_rwsem);
    119     list_for_each(list, &card->controls) {
    120         control = snd_kcontrol(list);
    121         for (idx = 0; idx < control->count; idx++)
    122             if (control->vd[idx].owner == ctl)
    123                 control->vd[idx].owner = NULL;
    124     }
    125     up_write(&card->controls_rwsem);
    126     snd_ctl_empty_read_queue(ctl);
    127     kfree(ctl);
    128     module_put(card->module);
    129     snd_card_file_remove(card, file);
    130     return 0;
     110        unsigned long flags;
     111        struct list_head *list;
     112        struct snd_card *card;
     113        struct snd_ctl_file *ctl;
     114        struct snd_kcontrol *control;
     115        unsigned int idx;
     116
     117        ctl = file->private_data;
     118        fasync_helper(-1, file, 0, &ctl->fasync);
     119        file->private_data = NULL;
     120        card = ctl->card;
     121        write_lock_irqsave(&card->ctl_files_rwlock, flags);
     122        list_del(&ctl->list);
     123        write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
     124        down_write(&card->controls_rwsem);
     125        list_for_each(list, &card->controls) {
     126                control = snd_kcontrol(list);
     127                for (idx = 0; idx < control->count; idx++)
     128                        if (control->vd[idx].owner == ctl)
     129                                control->vd[idx].owner = NULL;
     130        }
     131        up_write(&card->controls_rwsem);
     132        snd_ctl_empty_read_queue(ctl);
     133        kfree(ctl);
     134        module_put(card->module);
     135        snd_card_file_remove(card, file);
     136        return 0;
    131137}
    132138
    133139void snd_ctl_notify(struct snd_card *card, unsigned int mask, struct snd_ctl_elem_id *id)
    134140{
    135     unsigned long flags;
    136     struct list_head *flist;
    137     struct snd_ctl_file *ctl;
    138     struct snd_kctl_event *ev;
    139 
    140     snd_runtime_check(card != NULL && id != NULL, return);
    141 
    142     control_id_changed = id->numid;
    143     card_id_changed = card->number;
    144     //        printk("ctl id %i changed\n", id->numid);
    145     read_lock(&card->ctl_files_rwlock);
     141        unsigned long flags;
     142        struct list_head *flist;
     143        struct snd_ctl_file *ctl;
     144        struct snd_kctl_event *ev;
     145       
     146        snd_runtime_check(card != NULL && id != NULL, return);
     147
     148        control_id_changed = id->numid;
     149        card_id_changed = card->number;
     150        //        printk("ctl id %i changed\n", id->numid);
     151        read_lock(&card->ctl_files_rwlock);
    146152#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
    147     card->mixer_oss_change_count++;
     153        card->mixer_oss_change_count++;
    148154#endif
    149     list_for_each(flist, &card->ctl_files) {
     155        list_for_each(flist, &card->ctl_files) {
    150156        struct list_head *elist;
    151157        ctl = snd_ctl_file(flist);
     
    166172            list_add_tail(&ev->list, &ctl->events);
    167173        } else {
    168             snd_printk("No memory available to allocate event\n");
    169         }
     174                        snd_printk(KERN_ERR "No memory available to allocate event\n");
     175                }
    170176        _found:
    171177        wake_up(&ctl->change_sleep);
     
    338344    }
    339345#endif
    340     list_add_tail(&kcontrol->list, &card->controls);
     346        list_add_tail(&kcontrol->list, &card->controls);
    341347    card->controls_count += kcontrol->count;
    342     kcontrol->id.numid = card->last_numid + 1;
    343     card->last_numid += kcontrol->count;
    344     up_write(&card->controls_rwsem);
    345     for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)
    346         snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
    347     return 0;
     348        kcontrol->id.numid = card->last_numid + 1;
     349        card->last_numid += kcontrol->count;
     350        up_write(&card->controls_rwsem);
     351        for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)
     352        snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
     353        return 0;
    348354
    349355error:
    350356    snd_ctl_free_one(kcontrol);
    351     return err;
     357        return err;
    352358}
    353359
  • GPL/branches/alsa-resync1/alsa-kernel/core/device.c

    r34 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    19  *
    20  */
    21 
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     19 *
     20 */
     21
     22#define __NO_VERSION__
    2223#include <sound/driver.h>
     24#include <linux/slab.h>
     25#include <linux/time.h>
     26#include <sound/core.h>
    2327
    2428/**
     
    8488                    dev->ops->dev_unregister) {
    8589                        if (dev->ops->dev_unregister(dev))
    86                                 snd_printk("device unregister failure\n");
     90                                snd_printk(KERN_ERR "device unregister failure\n");
    8791                } else {
    8892                        if (dev->ops->dev_free) {
    8993                                if (dev->ops->dev_free(dev))
    90                                         snd_printk("device free failure\n");
     94                                        snd_printk(KERN_ERR "device free failure\n");
    9195                        }
    9296                }
  • GPL/branches/alsa-resync1/alsa-kernel/core/info.c

    r32 r92  
    2020 */
    2121
     22#define __NO_VERSION__
    2223#include <sound/driver.h>
     24#include <linux/init.h>
     25#include <linux/vmalloc.h>
     26#include <linux/time.h>
     27#ifndef TARGET_OS2 /* Introduced in version 0.9.0beta12, not present */
     28#include <linux/smp_lock.h>
     29#endif /* TARGET_OS2 */
     30#include <sound/core.h>
    2331#include <sound/minors.h>
    2432#include <sound/info.h>
    2533#include <sound/version.h>
    26 #include <stdarg.h>
     34#include <linux/proc_fs.h>
    2735#ifdef CONFIG_DEVFS_FS
    2836#include <linux/devfs_fs_kernel.h>
    2937#endif
     38#include <stdarg.h>
    3039
    3140#define min(x,y) (x < y ? x : y )
     
    3948    static char *reserved[] =
    4049    {
     50                "dev",
    4151        "version",
    4252        "meminfo",
     
    4454        "detect",
    4555        "devices",
    46         "oss",
     56                "oss-devices",
    4757        "cards",
    4858        "timers",
     
    166176                                       data->file_private_data,
    167177                                       file, offset, orig);
    168             goto out;
    169         }
    170         break;
    171     }
    172     ret = -ENXIO;
     178                        goto out;
     179                }
     180                break;
     181        }
     182        ret = -ENXIO;
    173183out:
    174184#ifndef TARGET_OS2
    175     unlock_kernel();
    176 #endif
    177     return ret;
     185        unlock_kernel();
     186#endif
     187        return ret;
    178188}
    179189
     
    272282
    273283    down(&info_mutex);
    274     p = (struct proc_dir_entry *) inode->u.generic_ip;
     284        p = PDE(inode);
    275285    entry = p == NULL ? NULL : (snd_info_entry_t *)p->data;
    276286    if (entry == NULL) {
     
    278288        return -ENODEV;
    279289    }
    280 #ifndef LINUX_2_3
     290#ifdef LINUX_2_2
    281291    MOD_INC_USE_COUNT;
    282292#endif
     
    415425                entry->c.text.write(entry, data->wbuffer);
    416426                if (data->wbuffer->error) {
    417                     snd_printk("data write error to %s (%i)\n",
     427                                        snd_printk(KERN_WARNING "data write error to %s (%i)\n",
    418428                               entry->name,
    419429                               data->wbuffer->error);
     
    525535static struct file_operations snd_info_entry_operations =
    526536{
    527 #ifdef LINUX_2_3
     537#ifndef LINUX_2_2
    528538owner:          THIS_MODULE,
    529539#endif
     
    538548};
    539549
    540 #ifndef LINUX_2_3
     550#ifdef LINUX_2_2
    541551static struct inode_operations snd_info_entry_inode_operations =
    542552{
     
    548558    &snd_fops,          /* default sound info directory file-ops */
    549559};
    550 #endif  /* LINUX_2_3 */
     560#endif  /* LINUX_2_2 */
    551561
    552562static int snd_info_card_readlink(struct dentry *dentry,
    553563                                  char *buffer, int buflen)
    554564{
    555     char *s = ((struct proc_dir_entry *) dentry->d_inode->u.generic_ip)->data;
    556 #ifdef LINUX_2_3
     565        char *s = PDE(dentry->d_inode)->data;
     566#ifndef LINUX_2_2
    557567    return vfs_readlink(dentry, buffer, buflen, s);
    558568#else
     
    570580}
    571581
    572 #ifdef LINUX_2_3
     582#ifndef LINUX_2_2
    573583static int snd_info_card_followlink(struct dentry *dentry,
    574584                                    struct nameidata *nd)
    575585{
    576     char *s = ((struct proc_dir_entry *) dentry->d_inode->u.generic_ip)->data;
     586        char *s = PDE(dentry->d_inode)->data;
    577587    return vfs_follow_link(nd, s);
    578588}
     
    582592                                               unsigned int follow)
    583593{
    584     char *s = ((struct proc_dir_entry *) dentry->d_inode->u.generic_ip)->data;
     594        char *s = PDE(dentry->d_inode)->data;
    585595    return lookup_dentry(s, base, follow);
    586596}
    587597#endif
    588598
    589 #ifndef LINUX_2_3
     599#ifdef LINUX_2_2
    590600static struct file_operations snd_info_card_link_operations =
    591601{
     
    596606struct inode_operations snd_info_card_link_inode_operations =
    597607{
    598 #ifndef LINUX_2_3
     608#ifdef LINUX_2_2
    599609default_file_ops:       &snd_info_card_link_operations,
    600610#endif
     
    683693    snd_info_version_done();
    684694    if (snd_proc_root) {
    685 #ifdef CONFIG_SND_SEQUENCER
     695#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
    686696        if (snd_seq_root)
    687697            snd_info_unregister(snd_seq_root);
     
    10191029        return -ENOMEM;
    10201030    }
    1021 #ifdef LINUX_2_3
     1031#ifndef LINUX_2_2
    10221032    p->owner = entry->module;
    10231033#endif
     
    10251035#ifndef TARGET_OS2
    10261036    if (!S_ISDIR(entry->mode)) {
    1027 #ifdef LINUX_2_3
     1037#ifndef LINUX_2_2
    10281038        p->proc_fops = &snd_info_entry_operations;
    10291039#else
     
    10721082
    10731083    snd_iprintf(buffer,
    1074                 "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION ".\n"
     1084                    "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n"
    10751085                "Compiled on " __DATE__ " for kernel %s"
    10761086#ifdef __SMP__
  • GPL/branches/alsa-resync1/alsa-kernel/core/init.c

    r34 r92  
    102102                write_unlock(&snd_card_rwlock);
    103103                if (idx >= snd_ecards_limit)
    104                         snd_printk("card %i is out of range (0-%i)\n", idx, snd_ecards_limit-1);
     104                        snd_printk(KERN_ERR "card %i is out of range (0-%i)\n", idx, snd_ecards_limit-1);
    105105                goto __error;
    106106        }
     
    277277#endif
    278278        if (snd_device_free_all(card, SNDRV_DEV_CMD_PRE) < 0) {
    279                 snd_printk("unable to free all devices (pre)\n");
     279                snd_printk(KERN_ERR "unable to free all devices (pre)\n");
    280280                /* Fatal, but this situation should never occur */
    281281        }
    282282        if (snd_device_free_all(card, SNDRV_DEV_CMD_NORMAL) < 0) {
    283                 snd_printk("unable to free all devices (normal)\n");
     283                snd_printk(KERN_ERR "unable to free all devices (normal)\n");
    284284                /* Fatal, but this situation should never occur */
    285285        }
    286286        if (snd_ctl_unregister(card) < 0) {
    287                 snd_printk("unable to unregister control minors\n");
     287                snd_printk(KERN_ERR "unable to unregister control minors\n");
    288288                /* Not fatal error */
    289289        }
    290290        if (snd_device_free_all(card, SNDRV_DEV_CMD_POST) < 0) {
    291                 snd_printk("unable to free all devices (post)\n");
     291                snd_printk(KERN_ERR "unable to free all devices (post)\n");
    292292                /* Fatal, but this situation should never occur */
    293293        }
  • GPL/branches/alsa-resync1/alsa-kernel/core/memory.c

    r73 r92  
    2121 */
    2222
     23#define __NO_VERSION__
    2324#include <sound/driver.h>
     25#include <asm/io.h>
     26#include <asm/uaccess.h>
     27#include <linux/init.h>
     28#include <linux/slab.h>
     29#include <linux/time.h>
     30#include <sound/core.h>
    2431#include <sound/info.h>
    2532#include <sound/memalloc.h>
     
    6168void snd_memory_done(void)
    6269{
    63     struct list_head *head;
    64     struct snd_alloc_track *t;
    65     if (snd_alloc_pages > 0)
    66         snd_printk("Not freed snd_alloc_pages = %li\n", snd_alloc_pages);
    67     if (snd_alloc_kmalloc > 0)
    68         snd_printk("Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc);
    69     if (snd_alloc_vmalloc > 0)
    70         snd_printk("Not freed snd_alloc_vmalloc = %li\n", snd_alloc_vmalloc);
    71     list_for_each_prev(head, &snd_alloc_kmalloc_list) {
    72         t = list_entry(head, struct snd_alloc_track, list);
    73         if (t->magic != KMALLOC_MAGIC) {
    74             snd_printk("Corrupted kmalloc\n");
    75             break;
    76         }
    77         snd_printk("kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
    78     }
    79     list_for_each_prev(head, &snd_alloc_vmalloc_list) {
    80         t = list_entry(head, struct snd_alloc_track, list);
    81         if (t->magic != VMALLOC_MAGIC) {
    82             snd_printk("Corrupted vmalloc\n");
    83             break;
    84         }
    85         snd_printk("vmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
    86     }
     70        struct list_head *head;
     71        struct snd_alloc_track *t;
     72        if (snd_alloc_pages > 0)
     73                snd_printk(KERN_ERR "Not freed snd_alloc_pages = %li\n", snd_alloc_pages);
     74        if (snd_alloc_kmalloc > 0)
     75                snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc);
     76        if (snd_alloc_vmalloc > 0)
     77                snd_printk(KERN_ERR "Not freed snd_alloc_vmalloc = %li\n", snd_alloc_vmalloc);
     78        list_for_each_prev(head, &snd_alloc_kmalloc_list) {
     79                t = list_entry(head, struct snd_alloc_track, list);
     80                if (t->magic != KMALLOC_MAGIC) {
     81                        snd_printk(KERN_ERR "Corrupted kmalloc\n");
     82                        break;
     83                }
     84                snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
     85        }
     86        list_for_each_prev(head, &snd_alloc_vmalloc_list) {
     87                t = list_entry(head, struct snd_alloc_track, list);
     88                if (t->magic != VMALLOC_MAGIC) {
     89                        snd_printk(KERN_ERR "Corrupted vmalloc\n");
     90                        break;
     91                }
     92                snd_printk(KERN_ERR "vmalloc(%ld) from %p not freed\n", (long) t->size, t->caller);
     93        }
    8794}
    8895
    8996void *__snd_kmalloc(size_t size, int flags, void *caller)
    9097{
    91     unsigned long cpu_flags;
    92     struct snd_alloc_track *t;
    93     void *ptr;
    94 
    95     ptr = snd_wrapper_kmalloc(size + sizeof(struct snd_alloc_track), flags);
    96     if (ptr != NULL) {
    97         t = (struct snd_alloc_track *)ptr;
    98         t->magic = KMALLOC_MAGIC;
    99         t->caller = caller;
    100         spin_lock_irqsave(&snd_alloc_kmalloc_lock, cpu_flags);
    101         list_add_tail(&t->list, &snd_alloc_kmalloc_list);
    102         spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, cpu_flags);
    103         t->size = size;
    104         snd_alloc_kmalloc += size;
    105         ptr = t->data;
    106     }
    107     return ptr;
     98        unsigned long cpu_flags;
     99        struct snd_alloc_track *t;
     100        void *ptr;
     101       
     102        ptr = snd_wrapper_kmalloc(size + sizeof(struct snd_alloc_track), flags);
     103        if (ptr != NULL) {
     104                t = (struct snd_alloc_track *)ptr;
     105                t->magic = KMALLOC_MAGIC;
     106                t->caller = caller;
     107                spin_lock_irqsave(&snd_alloc_kmalloc_lock, cpu_flags);
     108                list_add_tail(&t->list, &snd_alloc_kmalloc_list);
     109                spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, cpu_flags);
     110                t->size = size;
     111                snd_alloc_kmalloc += size;
     112                ptr = t->data;
     113        }
     114        return ptr;
    108115}
    109116
     
    111118void *snd_hidden_kmalloc(size_t size, int flags)
    112119{
    113     return _snd_kmalloc(size, flags);
     120        return _snd_kmalloc(size, flags);
    114121}
    115122
     
    127134void snd_hidden_kfree(const void *obj)
    128135{
    129     unsigned long flags;
    130     struct snd_alloc_track *t;
    131     if (obj == NULL) {
    132         snd_printk("null kfree (called from %p)\n", __builtin_return_address(0));
    133         return;
    134     }
    135     t = snd_alloc_track_entry(obj);
    136     if (t->magic != KMALLOC_MAGIC) {
    137         snd_printk("bad kfree (called from %p)\n", __builtin_return_address(0));
    138         return;
    139     }
    140     spin_lock_irqsave(&snd_alloc_kmalloc_lock, flags);
    141     list_del(&t->list);
    142     spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, flags);
    143     t->magic = 0;
    144     snd_alloc_kmalloc -= t->size;
    145     obj = t;
    146     snd_wrapper_kfree(obj);
     136        unsigned long flags;
     137        struct snd_alloc_track *t;
     138        if (obj == NULL) {
     139                snd_printk(KERN_WARNING "null kfree (called from %p)\n", __builtin_return_address(0));
     140                return;
     141        }
     142        t = snd_alloc_track_entry(obj);
     143        if (t->magic != KMALLOC_MAGIC) {
     144                snd_printk(KERN_WARNING "bad kfree (called from %p)\n", __builtin_return_address(0));
     145                return;
     146        }
     147        spin_lock_irqsave(&snd_alloc_kmalloc_lock, flags);
     148        list_del(&t->list);
     149        spin_unlock_irqrestore(&snd_alloc_kmalloc_lock, flags);
     150        t->magic = 0;
     151        snd_alloc_kmalloc -= t->size;
     152        obj = t;
     153        snd_wrapper_kfree(obj);
    147154}
    148155
    149156void *snd_hidden_vmalloc(unsigned long size)
    150157{
    151     void *ptr;
    152     ptr = snd_wrapper_vmalloc(size + sizeof(struct snd_alloc_track));
    153     if (ptr) {
    154         struct snd_alloc_track *t = (struct snd_alloc_track *)ptr;
    155         t->magic = VMALLOC_MAGIC;
    156         t->caller = __builtin_return_address(0);
    157         spin_lock(&snd_alloc_vmalloc_lock);
    158         list_add_tail(&t->list, &snd_alloc_vmalloc_list);
    159         spin_unlock(&snd_alloc_vmalloc_lock);
    160         t->size = size;
    161         snd_alloc_vmalloc += size;
    162         ptr = t->data;
    163     }
    164     return ptr;
     158        void *ptr;
     159        ptr = snd_wrapper_vmalloc(size + sizeof(struct snd_alloc_track));
     160        if (ptr) {
     161                struct snd_alloc_track *t = (struct snd_alloc_track *)ptr;
     162                t->magic = VMALLOC_MAGIC;
     163                t->caller = __builtin_return_address(0);
     164                spin_lock(&snd_alloc_vmalloc_lock);
     165                list_add_tail(&t->list, &snd_alloc_vmalloc_list);
     166                spin_unlock(&snd_alloc_vmalloc_lock);
     167                t->size = size;
     168                snd_alloc_vmalloc += size;
     169                ptr = t->data;
     170        }
     171        return ptr;
    165172}
    166173
    167174void snd_hidden_vfree(void *obj)
    168175{
    169     struct snd_alloc_track *t;
    170     if (obj == NULL) {
    171         snd_printk("null vfree (called from %p)\n", __builtin_return_address(0));
    172         return;
    173     }
    174     t = snd_alloc_track_entry(obj);
    175     if (t->magic != VMALLOC_MAGIC) {
    176         snd_printk("bad vfree (called from %p)\n", __builtin_return_address(0));
    177         return;
    178     }
    179     spin_lock(&snd_alloc_vmalloc_lock);
    180     list_del(&t->list);
    181     spin_unlock(&snd_alloc_vmalloc_lock);
    182     t->magic = 0;
    183     snd_alloc_vmalloc -= t->size;
    184     obj = t;
    185     snd_wrapper_vfree(obj);
     176        struct snd_alloc_track *t;
     177        if (obj == NULL) {
     178                snd_printk(KERN_WARNING "null vfree (called from %p)\n", __builtin_return_address(0));
     179                return;
     180        }
     181        t = snd_alloc_track_entry(obj);
     182        if (t->magic != VMALLOC_MAGIC) {
     183                snd_printk(KERN_ERR "bad vfree (called from %p)\n", __builtin_return_address(0));
     184                return;
     185        }
     186        spin_lock(&snd_alloc_vmalloc_lock);
     187        list_del(&t->list);
     188        spin_unlock(&snd_alloc_vmalloc_lock);
     189        t->magic = 0;
     190        snd_alloc_vmalloc -= t->size;
     191        obj = t;
     192        snd_wrapper_vfree(obj);
    186193}
    187194
    188195static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
    189196{
    190     long pages = snd_alloc_pages >> (PAGE_SHIFT-12);
    191     snd_iprintf(buffer, "pages  : %li bytes (%li pages per %likB)\n", pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
    192     snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
    193     snd_iprintf(buffer, "vmalloc: %li bytes\n", snd_alloc_vmalloc);
     197        long pages = snd_alloc_pages >> (PAGE_SHIFT-12);
     198        snd_iprintf(buffer, "pages  : %li bytes (%li pages per %likB)\n", pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
     199        snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
     200        snd_iprintf(buffer, "vmalloc: %li bytes\n", snd_alloc_vmalloc);
    194201}
    195202
    196203int __init snd_memory_info_init(void)
    197204{
    198     snd_info_entry_t *entry;
    199 
    200     entry = snd_info_create_module_entry(THIS_MODULE, "meminfo", NULL);
    201     if (entry) {
    202         entry->content = SNDRV_INFO_CONTENT_TEXT;
    203         entry->c.text.read_size = 256;
    204         entry->c.text.read = snd_memory_info_read;
    205         if (snd_info_register(entry) < 0) {
    206             snd_info_free_entry(entry);
    207             entry = NULL;
    208         }
    209     }
    210     snd_memory_info_entry = entry;
    211     return 0;
     205        snd_info_entry_t *entry;
     206
     207        entry = snd_info_create_module_entry(THIS_MODULE, "meminfo", NULL);
     208        if (entry) {
     209                entry->content = SNDRV_INFO_CONTENT_TEXT;
     210                entry->c.text.read_size = 256;
     211                entry->c.text.read = snd_memory_info_read;
     212                if (snd_info_register(entry) < 0) {
     213                        snd_info_free_entry(entry);
     214                        entry = NULL;
     215                }
     216        }
     217        snd_memory_info_entry = entry;
     218        return 0;
    212219}
    213220
    214221int __exit snd_memory_info_done(void)
    215222{
    216     if (snd_memory_info_entry)
    217         snd_info_unregister(snd_memory_info_entry);
    218     return 0;
     223        if (snd_memory_info_entry)
     224                snd_info_unregister(snd_memory_info_entry);
     225        return 0;
    219226}
    220227#else
  • GPL/branches/alsa-resync1/alsa-kernel/core/misc.c

    r86 r92  
    2121
    2222#include <sound/driver.h>
    23 #include <sound/firmware.h>
     23#include <linux/firmware.h>
    2424int snd_task_name(struct task_struct *task, char *name, size_t size)
    2525{
     
    541541}
    542542
     543#if 0
    543544void flush_workqueue(struct workqueue_struct *wq)
    544545{
     
    561562        }
    562563}
     564#endif
    563565
    564566void destroy_workqueue(struct workqueue_struct *wq)
    565567{
     568#if 0
    566569    flush_workqueue(wq);
    567 #if 0
    568570        kill_proc(wq->task_pid, SIGKILL, 1);
    569571        if (wq->task_pid >= 0)
     
    686688}
    687689
    688 int request_firmware(const struct firmware **fw, const char *name)
     690int request_firmware(const struct firmware **fw, const char *name,
     691                     struct device *device)
    689692{
    690693        struct firmware *firmware;
  • GPL/branches/alsa-resync1/alsa-kernel/core/pcm.c

    r34 r92  
    2121
    2222#include <sound/driver.h>
     23#include <linux/init.h>
     24#include <linux/slab.h>
     25#include <linux/time.h>
     26#include <sound/core.h>
    2327#include <sound/minors.h>
    2428#include <sound/pcm.h>
     
    564568int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count)
    565569{
    566     int idx, err;
     570        int idx, err;
    567571    snd_pcm_str_t *pstr = &pcm->streams[stream];
    568572    struct snd_pcm_substream *substream, *prev;
    569573
    570574#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
    571     init_MUTEX(&pstr->oss.setup_mutex);
     575        init_MUTEX(&pstr->oss.setup_mutex);
    572576#endif
    573     pstr->stream = stream;
    574     pstr->pcm = pcm;
    575     pstr->substream_count = substream_count;
    576     pstr->reg = &snd_pcm_reg[stream];
    577     if (substream_count > 0) {
    578         err = snd_pcm_stream_proc_init(pstr);
    579         if (err < 0)
    580             return err;
    581     }
    582     prev = NULL;
    583     for (idx = 0, prev = NULL; idx < substream_count; idx++) {
    584         substream = (struct snd_pcm_substream *)kzalloc(sizeof(*substream), GFP_KERNEL);
    585         if (substream == NULL)
    586             return -ENOMEM;
    587         substream->pcm = pcm;
    588         substream->pstr = pstr;
    589         substream->number = idx;
    590         substream->stream = stream;
    591         sprintf(substream->name, "subdevice #%i", idx);
    592         substream->buffer_bytes_max = UINT_MAX;
    593         if (prev == NULL)
    594             pstr->substream = substream;
    595         else
    596             prev->next = substream;
    597         err = snd_pcm_substream_proc_init(substream);
    598         if (err < 0) {
    599             kfree(substream);
    600             return err;
    601         }
    602         substream->group = &substream->self_group;
    603         spin_lock_init(&substream->self_group.lock);
    604         INIT_LIST_HEAD(&substream->self_group.substreams);
    605         list_add_tail(&substream->link_list, &substream->self_group.substreams);
    606         spin_lock_init(&substream->timer_lock);
    607         prev = substream;
    608     }
    609     return 0;
    610 }
     577        pstr->stream = stream;
     578        pstr->pcm = pcm;
     579        pstr->substream_count = substream_count;
     580        pstr->reg = &snd_pcm_reg[stream];
     581        if (substream_count > 0) {
     582                err = snd_pcm_stream_proc_init(pstr);
     583                if (err < 0)
     584                        return err;
     585        }
     586        prev = NULL;
     587        for (idx = 0, prev = NULL; idx < substream_count; idx++) {
     588                substream = (struct snd_pcm_substream *)kzalloc(sizeof(*substream), GFP_KERNEL);
     589                if (substream == NULL)
     590                        return -ENOMEM;
     591                substream->pcm = pcm;
     592                substream->pstr = pstr;
     593                substream->number = idx;
     594                substream->stream = stream;
     595                sprintf(substream->name, "subdevice #%i", idx);
     596                substream->buffer_bytes_max = UINT_MAX;
     597                if (prev == NULL)
     598                        pstr->substream = substream;
     599                else
     600                        prev->next = substream;
     601                err = snd_pcm_substream_proc_init(substream);
     602                if (err < 0) {
     603                        kfree(substream);
     604                        return err;
     605                }
     606                substream->group = &substream->self_group;
     607                spin_lock_init(&substream->self_group.lock);
     608                INIT_LIST_HEAD(&substream->self_group.substreams);
     609                list_add_tail(&substream->link_list, &substream->self_group.substreams);
     610                spin_lock_init(&substream->timer_lock);
     611                prev = substream;
     612        }
     613        return 0;
     614}                               
    611615
    612616/**
     
    627631 */
    628632int snd_pcm_new(snd_card_t * card, char *id, int device,
    629                 int playback_count, int capture_count,
    630                 snd_pcm_t ** rpcm)
    631 {
    632     snd_pcm_t *pcm;
    633     int err;
    634     static snd_device_ops_t ops = {
    635         snd_pcm_dev_free,
    636         snd_pcm_dev_register,
    637         snd_pcm_dev_disconnect,
    638         snd_pcm_dev_unregister
    639     };
    640 
    641     snd_assert(rpcm != NULL, return -EINVAL);
    642     *rpcm = NULL;
    643     snd_assert(card != NULL, return -ENXIO);
    644     pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
    645     if (pcm == NULL)
    646         return -ENOMEM;
    647     pcm->card = card;
    648     pcm->device = device;
    649     if (id) {
    650         strlcpy(pcm->id, id, sizeof(pcm->id));
    651     }
    652     if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) {
    653         snd_pcm_free(pcm);
    654         return err;
    655     }
    656     if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count)) < 0) {
    657         snd_pcm_free(pcm);
     633                int playback_count, int capture_count,
     634                snd_pcm_t ** rpcm)
     635{
     636        snd_pcm_t *pcm;
     637        int err;
     638        static snd_device_ops_t ops = {
     639                snd_pcm_dev_free,
     640                snd_pcm_dev_register,
     641                snd_pcm_dev_disconnect,
     642                snd_pcm_dev_unregister
     643        };
     644
     645        snd_assert(rpcm != NULL, return -EINVAL);
     646        *rpcm = NULL;
     647        snd_assert(card != NULL, return -ENXIO);
     648        pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
     649        if (pcm == NULL)
     650                return -ENOMEM;
     651        pcm->card = card;
     652        pcm->device = device;
     653        if (id) {
     654                strlcpy(pcm->id, id, sizeof(pcm->id));
     655        }
     656        if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) {
     657                snd_pcm_free(pcm);
     658                return err;
     659        }
     660        if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count)) < 0) {
     661                snd_pcm_free(pcm);
    658662        return err;
    659663    }
  • GPL/branches/alsa-resync1/alsa-kernel/core/rawmidi.c

    r34 r92  
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <sound/core.h>
     24#include <linux/major.h>
     25#include <linux/init.h>
     26#include <linux/sched.h>
     27#include <linux/slab.h>
     28#include <linux/time.h>
     29#include <linux/wait.h>
    2430#include <sound/rawmidi.h>
    2531#include <sound/info.h>
     
    346352static int snd_rawmidi_open(struct inode *inode, struct file *file)
    347353{
    348     int major = MAJOR(inode->i_rdev);
     354        int maj = major(inode->i_rdev);
    349355    int cardnum;
    350356    snd_card_t *card;
     
    359365
    360366    printk("rawmidi open\n");
    361     switch (major) {
     367    switch (maj) {
    362368    case CONFIG_SND_MAJOR:
    363369        cardnum = SNDRV_MINOR_CARD(MINOR(inode->i_rdev));
     
    382388        return -ENODEV;
    383389#ifdef CONFIG_SND_OSSEMUL
    384     if (major == SOUND_MAJOR && !rmidi->ossreg)
     390        if (maj == SOUND_MAJOR && !rmidi->ossreg)
    385391        return -ENXIO;
    386392#endif
     
    392398        return -ENODEV;
    393399    fflags = snd_rawmidi_file_flags(file);
    394     if ((file->f_flags & O_APPEND) || major != CONFIG_SND_MAJOR) /* OSS emul? */
     400        if ((file->f_flags & O_APPEND) || maj != CONFIG_SND_MAJOR) /* OSS emul? */
    395401        fflags |= SNDRV_RAWMIDI_LFLG_APPEND;
    396402    fflags |= SNDRV_RAWMIDI_LFLG_NOOPENLOCK;
     
    781787#ifdef CONFIG_SND_DEBUG
    782788    default:
    783         snd_printk("rawmidi: unknown command = 0x%x\n", cmd);
     789                snd_printk(KERN_WARNING "rawmidi: unknown command = 0x%x\n", cmd);
    784790#endif
    785791    }
     
    14541460}
    14551461
    1456 #ifdef CONFIG_SND_SEQUENCER
     1462#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
    14571463static void snd_rawmidi_dev_seq_free(snd_seq_device_t *device)
    14581464{
     
    14821488                                   rmidi->card, rmidi->device,
    14831489                                   &snd_rawmidi_reg, name)) < 0) {
    1484         snd_printk("unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
     1490                snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
    14851491        snd_rawmidi_devices[idx] = NULL;
    14861492        up(&register_mutex);
     
    14991505        if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
    15001506                                    rmidi->card, 0, &snd_rawmidi_reg, name) < 0) {
    1501             snd_printk("unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
     1507                        snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
    15021508        } else {
    15031509            rmidi->ossreg++;
     
    15101516        if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
    15111517                                    rmidi->card, 1, &snd_rawmidi_reg, name) < 0) {
    1512             snd_printk("unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
     1518                        snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
    15131519        } else {
    15141520            rmidi->ossreg++;
     
    15291535    }
    15301536    rmidi->proc_entry = entry;
    1531 #ifdef CONFIG_SND_SEQUENCER
     1537#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
    15321538    if (!rmidi->ops || !rmidi->ops->dev_register) { /* own registration mechanism */
    15331539        if (snd_seq_device_new(rmidi->card, rmidi->device, SNDRV_SEQ_DEV_ID_MIDISYNTH, 0, &rmidi->seq_dev) >= 0) {
     
    15841590    snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
    15851591    up(&register_mutex);
    1586 #ifdef CONFIG_SND_SEQUENCER
     1592#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
    15871593    if (rmidi->seq_dev) {
    15881594        snd_device_free(rmidi->card, rmidi->seq_dev);
     
    16231629    { int i;
    16241630        /* check device map table */
    1625         for (i = 0; i < SNDRV_CARDS; i++) {
    1626             if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
    1627                 snd_printk(KERN_ERR "invalid midi_map[%d] = %d\n", i, midi_map[i]);
    1628                 midi_map[i] = 0;
    1629             }
    1630             if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
    1631                 snd_printk(KERN_ERR "invalid amidi_map[%d] = %d\n", i, amidi_map[i]);
    1632                 amidi_map[i] = 1;
    1633             }
     1631                for (i = 0; i < SNDRV_CARDS; i++) {
     1632                        if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
     1633                                snd_printk(KERN_ERR "invalid midi_map[%d] = %d\n", i, midi_map[i]);
     1634                                midi_map[i] = 0;
     1635                        }
     1636                        if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
     1637                                snd_printk(KERN_ERR "invalid amidi_map[%d] = %d\n", i, amidi_map[i]);
     1638                                amidi_map[i] = 1;
     1639                        }
    16341640        }
    16351641    }
  • GPL/branches/alsa-resync1/alsa-kernel/core/rtctimer.c

    r32 r92  
    1717 *   You should have received a copy of the GNU General Public License
    1818 *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2020 *
    2121 *
     
    2929 */
    3030
    31 #define SNDRV_MAIN_OBJECT_FILE
    3231#include <sound/driver.h>
     32#include <linux/init.h>
     33#include <linux/time.h>
     34#include <sound/core.h>
    3335#include <sound/timer.h>
    3436#include <sound/info.h>
     
    124126
    125127#ifdef USE_TASKLET
    126 static void rtctimer_interrupt2(void *private_data)
    127 {
    128         snd_timer_t *timer = private_data;
     128static void rtctimer_interrupt2(unsigned long private_data)
     129{
     130        snd_timer_t *timer = (snd_timer_t *)private_data;
    129131        snd_assert(timer != NULL, return);
    130132        do {
     
    151153
    152154        if (rtctimer_freq < 2 || rtctimer_freq > 8192) {
    153                 snd_printk("rtctimer: invalid frequency %d\n", rtctimer_freq);
     155                snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
    154156                return -EINVAL;
    155157        }
     
    157159                ;
    158160        if (rtctimer_freq != order) {
    159                 snd_printk("rtctimer: invalid frequency %d\n", rtctimer_freq);
     161                snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
    160162                return -EINVAL;
    161163        }
     
    167169
    168170#ifdef USE_TASKLET
    169         tasklet_init(&rtc_tq, rtctimer_interrupt2, timer);
     171        tasklet_init(&rtc_tq, rtctimer_interrupt2, (unsigned long)timer);
    170172#endif /* USE_TASKLET */
    171173
     
    213215MODULE_PARM_DESC(rtctimer_freq, "timer frequency in Hz");
    214216
     217MODULE_LICENSE("GPL");
     218
     219EXPORT_NO_SYMBOLS;
     220
    215221#endif /* CONFIG_RTC || CONFIG_RTC_MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/core/timer.c

    r34 r92  
    18731873    snd_timer_proc_entry = entry;
    18741874    if ((err = snd_timer_register_system()) < 0)
    1875         snd_printk("unable to register system timer (%i)\n", err);
     1875                snd_printk(KERN_ERR "unable to register system timer (%i)\n", err);
    18761876    if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER,
    18771877                                   NULL, 0, &snd_timer_reg, "timer"))<0)
    1878         snd_printk("unable to register timer device (%i)\n", err);
     1878                snd_printk(KERN_ERR "unable to register timer device (%i)\n", err);
    18791879    return 0;
    18801880}
  • GPL/branches/alsa-resync1/alsa-kernel/drivers/dummy.c

    r32 r92  
    1515 *   You should have received a copy of the GNU General Public License
    1616 *   along with this program; if not, write to the Free Software
    17  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     17 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1818 *
    1919 */
    2020
    21 #define SNDRV_MAIN_OBJECT_FILE
    2221#include <sound/driver.h>
     22#include <linux/init.h>
     23#include <linux/sched.h>
     24#include <linux/slab.h>
     25#include <linux/time.h>
     26#include <linux/wait.h>
     27#include <sound/core.h>
    2328#include <sound/control.h>
    2429#include <sound/pcm.h>
     
    2631#define SNDRV_GET_ID
    2732#include <sound/initval.h>
     33
     34EXPORT_NO_SYMBOLS;
    2835
    2936MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     
    609616        if (snd_card_dummy_probe(dev) < 0) {
    610617#ifdef MODULE
    611             snd_printk("Dummy soundcard #%i not found or device busy\n", dev + 1);
     618                        printk(KERN_ERR "Dummy soundcard #%i not found or device busy\n", dev + 1);
    612619#endif
    613620            break;
     
    617624    if (!cards) {
    618625#ifdef MODULE
    619         snd_printk("Dummy soundcard not found or device busy\n");
     626                printk(KERN_ERR "Dummy soundcard not found or device busy\n");
    620627#endif
    621628        return -ENODEV;
     
    637644#ifndef MODULE
    638645
    639 /* format is: snd-card-dummy=snd_enable,snd_index,snd_id,
     646/* format is: snd-dummy=snd_enable,snd_index,snd_id,
    640647 snd_pcm_devs,snd_pcm_substreams */
    641648
  • GPL/branches/alsa-resync1/alsa-kernel/drivers/mpu401/mpu401.c

    r32 r92  
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <linux/init.h>
     24#include <linux/wait.h>
     25#include <linux/sched.h>
     26#include <linux/slab.h>
     27#include <sound/core.h>
    2428#include <sound/mpu401.h>
    2529#define SNDRV_GET_ID
    2630#include <sound/initval.h>
     31#include <linux/delay.h>
     32
     33EXPORT_NO_SYMBOLS;
    2734
    2835MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     
    119126        if (!cards) {
    120127#ifdef MODULE
    121                 snd_printk("MPU-401 device not found or device busy\n");
     128                printk(KERN_ERR "MPU-401 device not found or device busy\n");
    122129#endif
    123130                return -ENODEV;
     
    139146#ifndef MODULE
    140147
    141 /* format is: snd-mpu401=enable,index,id,port,irq */
     148/* format is: snd-mpu401=snd_enable,snd_index,snd_id,snd_port,snd_irq */
    142149
    143150static int __init alsa_card_mpu401_setup(char *str)
  • GPL/branches/alsa-resync1/alsa-kernel/drivers/mtpav.c

    r32 r92  
    1717 *      You should have received a copy of the GNU General Public License
    1818 *      along with this program; if not, write to the Free Software
    19  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 *      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2020 *
    2121 *
     
    5151 */
    5252
    53 #define SNDRV_MAIN_OBJECT_FILE
    5453#include <sound/driver.h>
     54#include <asm/io.h>
     55#include <linux/init.h>
     56#include <linux/slab.h>
     57#include <sound/core.h>
    5558#define SNDRV_GET_ID
    5659#include <sound/initval.h>
    5760#include <sound/rawmidi.h>
     61#include <linux/delay.h>
    5862
    5963/*
     
    6165 */
    6266EXPORT_NO_SYMBOLS;
     67
     68MODULE_AUTHOR("Michael T. Mayers");
    6369MODULE_DESCRIPTION("MOTU MidiTimePiece AV multiport MIDI");
     70MODULE_LICENSE("GPL");
    6471MODULE_CLASSES("{sound}");
    6572MODULE_DEVICES("{{MOTU,MidiTimePiece AV multiport MIDI}}");
     
    8491MODULE_PARM(snd_port, "l");
    8592MODULE_PARM_DESC(snd_port, "Parallel port # for MotuMTPAV MIDI.");
    86 MODULE_PARM_SYNTAX(snd_port, "allows:{{0x378},{0x278}},dialog:list");
     93MODULE_PARM_SYNTAX(snd_port, SNDRV_ENABLED ",allows:{{0x378},{0x278}},dialog:list");
    8794MODULE_PARM(snd_irq, "i");
    8895MODULE_PARM_DESC(snd_irq, "Parallel IRQ # for MotuMTPAV MIDI.");
    89 MODULE_PARM_SYNTAX(snd_irq,  "allows:{{7},{5}},dialog:list");
     96MODULE_PARM_SYNTAX(snd_irq,  SNDRV_ENABLED ",allows:{{7},{5}},dialog:list");
    9097MODULE_PARM(snd_hwports, "i");
    9198MODULE_PARM_DESC(snd_hwports, "Hardware ports # for MotuMTPAV MIDI.");
    92 MODULE_PARM_SYNTAX(snd_hwports, "allows:{{1,8}},dialog:list");
     99MODULE_PARM_SYNTAX(snd_hwports, SNDRV_ENABLED ",allows:{{1,8}},dialog:list");
    93100
    94101/*
     
    721728        if (crd->irq >= 0)
    722729                free_irq(crd->irq, (void *)crd);
    723         if (crd->res_port)
     730        if (crd->res_port) {
    724731                release_resource(crd->res_port);
     732                kfree_nocheck(crd->res_port);
     733        }
    725734        if (crd != NULL)
    726735                kfree(crd);
     
    769778        snd_mtpav_portscan(mtp_card);
    770779
    771         snd_printk("Motu MidiTimePiece on parallel port irq: %d ioport: 0x%lx\n", snd_irq, snd_port);
     780        printk(KERN_INFO "Motu MidiTimePiece on parallel port irq: %d ioport: 0x%lx\n", snd_irq, snd_port);
    772781
    773782        return 0;
     
    799808#ifndef MODULE
    800809
    801 /* format is: snd-card-mtpav=snd_enable,snd_index,snd_id,
     810/* format is: snd-mtpav=snd_enable,snd_index,snd_id,
    802811                             snd_port,snd_irq,snd_hwports */
    803812
     
    815824}
    816825
    817 __setup("snd-card-mtpav=", alsa_card_mtpav_setup);
     826__setup("snd-mtpav=", alsa_card_mtpav_setup);
    818827
    819828#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/drivers/serial-u16550.c

    r34 r92  
    88 *   This code is based on the code from ALSA 0.5.9, but heavily rewritten.
    99 *
    10  * Sat Mar 31 17:27:57 PST 2001 tim.mann@compaq.com
     10 * Sat Mar 31 17:27:57 PST 2001 tim.mann@compaq.com 
    1111 *      Added support for the Midiator MS-124T and for the MS-124W in
    1212 *      Single Addressed (S/A) or Multiple Burst (M/B) mode, with
    1313 *      power derived either parasitically from the serial port or
    1414 *      from a separate power supply.
    15  *
     15 * 
    1616 *      The new snd_adaptor module parameter allows you to select
    1717 *      either the default Roland Soundcanvas support (0), which was
     
    2121 *      Midiator MS-124W, you must set the physical M-S and A-B
    2222 *      switches on the Midiator to match the driver mode you select.
    23  *
     23 * 
    2424 *      - In Roland Soundcanvas mode, multiple ALSA raw MIDI
    2525 *      substreams are supported (midiCnD0-midiCnD15).  Whenever you
     
    9999 *   You should have received a copy of the GNU General Public License
    100100 *   along with this program; if not, write to the Free Software
    101  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     101 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    102102 *
    103103 */
    104104
    105 
    106 #define SNDRV_MAIN_OBJECT_FILE
    107 
    108105#include <sound/driver.h>
     106#include <asm/io.h>
     107#include <linux/init.h>
     108#include <linux/slab.h>
     109#include <sound/core.h>
    109110#include <sound/rawmidi.h>
    110111#define SNDRV_GET_ID
     
    115116EXPORT_NO_SYMBOLS;
    116117MODULE_DESCRIPTION("MIDI serial");
     118MODULE_LICENSE("GPL");
    117119MODULE_CLASSES("{sound}");
    118120MODULE_DEVICES("{{ALSA, MIDI serial}}");
     
    769771    if (uart->irq >= 0)
    770772        free_irq(uart->irq, (void *)uart);
    771     if (uart->res_base)
     773        if (uart->res_base) {
    772774        release_resource(uart->res_base);
    773     kfree(uart);
     775                kfree_nocheck(uart->res_base);
     776        }
     777        snd_magic_kfree(uart);
    774778    return 0;
    775779};
     
    918922    if ((err = snd_uart16550_detect(snd_port[dev])) <= 0) {
    919923        snd_card_free(card);
    920         snd_printk("no UART detected at 0x%lx\n", (long)snd_port[dev]);
     924                printk(KERN_ERR "no UART detected at 0x%lx\n", (long)snd_port[dev]);
    921925        return err;
    922926    }
     
    967971    if (cards == 0) {
    968972#ifdef MODULE
    969         snd_printk("serial midi soundcard not found or device busy\n");
     973                printk(KERN_ERR "serial midi soundcard not found or device busy\n");
    970974#endif
    971975        return -ENODEV;
     
    989993#ifndef MODULE
    990994
    991 /* format is: snd-card-serial=snd_enable,snd_index,snd_id,
     995/* format is: snd-serial=snd_enable,snd_index,snd_id,
    992996 snd_port,snd_irq,snd_speed,snd_base,snd_outs */
    993997
     
    10111015}
    10121016
    1013 __setup("snd-card-serial=", alsa_card_serial_setup);
     1017__setup("snd-serial=", alsa_card_serial_setup);
    10141018
    10151019#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/drivers/virmidi.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
     
    3030 *
    3131 * Typical usage is like following:
    32  * - Load snd-card-virmidi module.
    33  *      # modprobe snd-card-virmidi snd_index=2
     32 * - Load snd-virmidi module.
     33 *      # modprobe snd-virmidi snd_index=2
    3434 *   Then, sequencer clients 72:0 to 75:0 will be created, which are
    3535 *   mapped from /dev/snd/midiC1D0 to /dev/snd/midiC1D3, respectively.
     
    4242 */
    4343
    44 #define SNDRV_MAIN_OBJECT_FILE
    4544#include <sound/driver.h>
     45#include <linux/init.h>
     46#include <linux/wait.h>
     47#include <linux/sched.h>
     48#include <sound/core.h>
    4649#include <sound/seq_kernel.h>
    4750#include <sound/seq_virmidi.h>
     
    5053
    5154EXPORT_NO_SYMBOLS;
     55
     56MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
    5257MODULE_DESCRIPTION("Dummy soundcard for virtual rawmidi devices");
     58MODULE_LICENSE("GPL");
    5359MODULE_CLASSES("{sound}");
    5460MODULE_DEVICES("{{ALSA,Virtual rawmidi device}}");
     
    136142        if (snd_card_virmidi_probe(dev) < 0) {
    137143#ifdef MODULE
    138             snd_printk("Card-VirMIDI #%i not found or device busy\n", dev + 1);
     144                        printk(KERN_ERR "Card-VirMIDI #%i not found or device busy\n", dev + 1);
    139145#endif
    140146            break;
     
    144150    if (!cards) {
    145151#ifdef MODULE
    146         snd_printk("Card-VirMIDI soundcard not found or device busy\n");
     152                printk(KERN_ERR "Card-VirMIDI soundcard not found or device busy\n");
    147153#endif
    148154        return -ENODEV;
     
    164170#ifndef MODULE
    165171
    166 /* format is: snd-card-virmidi=snd_enable,snd_index,snd_id,snd_midi_devs */
     172/* format is: snd-virmidi=snd_enable,snd_index,snd_id,snd_midi_devs */
    167173
    168174static int __init alsa_card_virmidi_setup(char *str)
     
    180186}
    181187
    182 __setup("snd-card-virmidi=", alsa_card_virmidi_setup);
     188__setup("snd-virmidi=", alsa_card_virmidi_setup);
    183189
    184190#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/driver.h

    r86 r92  
    106106#include <linux/kernel.h>
    107107#include <linux/sched.h>
     108#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 7)
    108109#include <linux/malloc.h>
     110#else
     111#include <linux/slab.h>
     112#endif
    109113#include <linux/delay.h>
     114#include <linux/bitops.h>
    110115
    111116#include <linux/ioport.h>
     
    136141#endif
    137142#include "compat_22.h"
    138 #endif
     143#endif /* LINUX_2_2 */
     144
    139145#ifdef LINUX_2_3
    140146#include <linux/init.h>
     
    166172#define pci_alloc_consistent snd_pci_hack_alloc_consistent
    167173#endif /* i386 or ppc */
     174#ifndef list_for_each_safe
     175#define list_for_each_safe(pos, n, head) \
     176        for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next)
     177#endif
    168178#endif
    169179
     
    180190#endif
    181191
     192#ifndef MODULE_LICENSE
     193#define MODULE_LICENSE(license)
    182194#ifndef PCI_D0
    183195#define PCI_D0     0
     
    227239#define schedule_work(w) snd_compat_schedule_work(w)
    228240
    229 /* Name change */
     241/* Typedef's */
    230242typedef struct timeval snd_timestamp_t;
    231243#ifndef TARGET_OS2
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/initval.h

    r32 r92  
    1 #ifndef __INITVAL_H
    2 #define __INITVAL_H
     1#ifndef __SOUND_INITVAL_H
     2#define __SOUND_INITVAL_H
    33
    44/*
     
    1818 *   You should have received a copy of the GNU General Public License
    1919 *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     20 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2121 *
    2222 */
     
    7373#define SNDRV_DEFAULT_ENABLE    { 1,1,1,1,1,1,1,1 }
    7474#define SNDRV_DEFAULT_ENABLE_PNP        SNDRV_DEFAULT_ENABLE
     75#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE_PNP
    7576#define SNDRV_DEFAULT_PORT      { REPEAT_SNDRV(-1) }
    7677#define SNDRV_DEFAULT_IRQ       { REPEAT_SNDRV(SNDRV_AUTO_IRQ) }
     
    8586#define SNDRV_DEFAULT_STR       { [0 ... (SNDRV_CARDS-1)] = NULL }
    8687#define SNDRV_DEFAULT_ENABLE    { 1, [1 ... (SNDRV_CARDS-1)] = 0 }
     88#define SNDRV_DEFAULT_ENABLE_PNP { [0 ... (SNDRV_CARDS-1)] = 1 }
     89#ifdef __ISAPNP__
     90#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE_PNP
     91#else
     92#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE
     93#endif
    8794#define SNDRV_DEFAULT_PORT      { SNDRV_AUTO_PORT, [1 ... (SNDRV_CARDS-1)] = -1 }
    8895#define SNDRV_DEFAULT_IRQ       { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_IRQ }
     
    196203#endif
    197204
    198 #endif                          /* __INITVAL_H */
     205#endif /* __SOUND_INITVAL_H */
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/pcm_params.h

    r32 r92  
    1 #ifndef __PCM_PARAMS_H
    2 #define __PCM_PARAMS_H
     1#ifndef __SOUND_PCM_PARAMS_H
     2#define __SOUND_PCM_PARAMS_H
    33
    44/*
     
    1919 *   You should have received a copy of the GNU General Public License
    2020 *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2222 *
    2323 */
     
    363363#undef assert
    364364
    365 #endif
     365#endif /* __SOUND_PCM_PARAMS_H */
     366
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/version.h

    r32 r92  
    22 *  Configuration header file for compilation of the ALSA driver
    33 */
     4#define CONFIG_SND_DATE "04-29-2007"
    45
    56#ifndef __ALSA_VERSION_H__
  • GPL/branches/alsa-resync1/alsa-kernel/isa/ad1816a/ad1816a.c

    r32 r92  
    1616    You should have received a copy of the GNU General Public License
    1717    along with this program; if not, write to the Free Software
    18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919*/
    2020
    21 #define SNDRV_MAIN_OBJECT_FILE
    2221#include <sound/driver.h>
     22#include <linux/init.h>
     23#include <linux/time.h>
     24#include <linux/wait.h>
     25#ifndef LINUX_ISAPNP_H
     26#include <linux/isapnp.h>
     27#define isapnp_card pci_bus
     28#define isapnp_dev pci_dev
     29#endif
     30#include <sound/core.h>
    2331#define SNDRV_GET_ID
    2432#include <sound/initval.h>
     
    2937#define chip_t ad1816a_t
    3038
     39#define PFX "ad1816a: "
     40
    3141EXPORT_NO_SYMBOLS;
     42MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
    3243MODULE_DESCRIPTION("AD1816A, AD1815");
     44MODULE_LICENSE("GPL");
    3345MODULE_CLASSES("{sound}");
    3446MODULE_DEVICES("{{Highscreen,Sound-Boostar 16 3D},"
     
    3648                "{Analog Devices,AD1816A},"
    3749                "{TerraTec,Base 64},"
    38                 "{Aztech/Newcom SC-16 3D}}");
     50                "{TerraTec,AudioSystem EWS64S},"
     51                "{Aztech/Newcom SC-16 3D},"
     52                "{Shark Predator ISA}}");
    3953
    4054static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 1-MAX */
    4155static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    42 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     56static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;       /* Enable this card */
    4357static long snd_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
    4458static long snd_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
     
    121135        /* Analog Devices AD1816A - Terratec Base 64 */
    122136        ISAPNP_AD1816A('T','E','R',0x1411,'A','D','S',0x7180,0x7181),
     137        /* Analog Devices AD1816A - Terratec AudioSystem EWS64S */
     138        ISAPNP_AD1816A('T','E','R',0x1112,'A','D','S',0x7180,0x7181),
    123139        /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */
    124140        ISAPNP_AD1816A('A','Z','T',0x1022,'A','Z','T',0x1018,0x2002),
     141        /* Shark Predator ISA - added by Ken Arromdee */
     142        ISAPNP_AD1816A('S','M','M',0x7180,'A','D','S',0x7180,0x7181),
    125143        { ISAPNP_CARD_END, }
    126144};
     
    170188
    171189        if (pdev->activate(pdev) < 0) {
    172                 snd_printk("AUDIO isapnp configure failure\n");
     190                printk(KERN_ERR PFX "AUDIO isapnp configure failure\n");
    173191                return -EBUSY;
    174192        }
     
    196214        if (pdev->activate(pdev) < 0) {
    197215                /* not fatal error */
    198                 snd_printk("MPU-401 isapnp configure failure\n");
     216                printk(KERN_ERR PFX "MPU-401 isapnp configure failure\n");
    199217                snd_mpu_port[dev] = -1;
    200218                acard->devmpu = NULL;
     
    251269        }
    252270#else
    253         snd_printk("you have to enable ISA PnP support.\n");
     271        printk(KERN_ERR PFX "you have to enable ISA PnP support.\n");
    254272        return -ENOSYS;
    255273#endif  /* __ISAPNP__ */
     
    278296                                        snd_mpu_port[dev], 0, snd_mpu_irq[dev], SA_INTERRUPT,
    279297                                        NULL) < 0)
    280                         snd_printk("no MPU-401 device at 0x%lx.\n", snd_mpu_port[dev]);
     298                        printk(KERN_ERR PFX "no MPU-401 device at 0x%lx.\n", snd_mpu_port[dev]);
    281299        }
    282300
     
    285303                                    snd_fm_port[dev], snd_fm_port[dev] + 2,
    286304                                    OPL3_HW_AUTO, 0, &opl3) < 0) {
    287                         snd_printk("no OPL device at 0x%lx-0x%lx.\n", snd_fm_port[dev], snd_fm_port[dev] + 2);
     305                        printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx.\n", snd_fm_port[dev], snd_fm_port[dev] + 2);
    288306                } else {
    289307                        if ((error = snd_opl3_timer_new(opl3, 1, 2)) < 0) {
     
    340358        cards += isapnp_probe_cards(snd_ad1816a_pnpids, snd_ad1816a_isapnp_detect);
    341359#else
    342         snd_printk("you have to enable ISA PnP support.\n");
     360        printk(KERN_ERR PFX "you have to enable ISA PnP support.\n");
    343361#endif
    344362#ifdef MODULE
    345363        if (!cards)
    346                 snd_printk("no AD1816A based soundcards found.\n");
     364                printk(KERN_ERR "no AD1816A based soundcards found.\n");
    347365#endif  /* MODULE */
    348366        return cards ? 0 : -ENODEV;
     
    362380#ifndef MODULE
    363381
    364 /* format is: snd-card-ad1816a=snd_enable,snd_index,snd_id,snd_port,
     382/* format is: snd-ad1816a=snd_enable,snd_index,snd_id,snd_port,
    365383                               snd_mpu_port,snd_fm_port,snd_irq,snd_mpu_irq,
    366384                               snd_dma1,snd_dma2 */
     
    386404}
    387405
    388 __setup("snd-card-ad1816a=", alsa_card_ad1816a_setup);
     406__setup("snd-ad1816a=", alsa_card_ad1816a_setup);
    389407
    390408#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/ad1816a/ad1816a_lib.c

    r32 r92  
    1616    You should have received a copy of the GNU General Public License
    1717    along with this program; if not, write to the Free Software
    18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919*/
    2020
    21 #define SNDRV_MAIN_OBJECT_FILE
    2221#include <sound/driver.h>
     22#include <asm/io.h>
     23#include <asm/dma.h>
     24#include <linux/delay.h>
     25#include <linux/init.h>
     26#include <linux/slab.h>
     27#include <sound/core.h>
    2328#include <sound/ad1816a.h>
     29
     30MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
     31MODULE_DESCRIPTION("lowlevel code for Analog Devices AD1816A chip");
     32MODULE_LICENSE("GPL");
    2433
    2534#define chip_t ad1816a_t
     
    233242                AD1816A_PLAYBACK_ENABLE | AD1816A_PLAYBACK_PIO, 0x00);
    234243
    235         snd_dma_program(chip->dma1, runtime->dma_area, size,
     244        snd_dma_program(chip->dma1, runtime->dma_addr, size,
    236245                        DMA_MODE_WRITE | DMA_AUTOINIT);
    237246
     
    262271                AD1816A_CAPTURE_ENABLE | AD1816A_CAPTURE_PIO, 0x00);
    263272
    264         snd_dma_program(chip->dma2, runtime->dma_area, size,
     273        snd_dma_program(chip->dma2, runtime->dma_addr, size,
    265274                        DMA_MODE_READ | DMA_AUTOINIT);
    266275
     
    490499        snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max);
    491500        snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max);
     501        chip->playback_substream = substream;
    492502        return 0;
    493503}
     
    505515        snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max);
    506516        snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max);
     517        chip->capture_substream = substream;
    507518        return 0;
    508519}
     
    573584static int snd_ad1816a_free(ad1816a_t *chip)
    574585{
    575         if (chip->res_port)
     586        if (chip->res_port) {
    576587                release_resource(chip->res_port);
     588                kfree_nocheck(chip->res_port);
     589        }
    577590        if (chip->irq >= 0)
    578591                free_irq(chip->irq, (void *) chip);
     
    745758        snd_ad1816a_init(chip);
    746759
    747         snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024, GFP_KERNEL|GFP_DMA);
     760        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
    748761
    749762        chip->pcm = pcm;
     
    978991static snd_kcontrol_new_t snd_ad1816a_controls[] = {
    979992AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1),
    980 AD1816A_DOUBLE("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 0),
     993AD1816A_DOUBLE("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1),
    981994AD1816A_DOUBLE("PCM Playback Switch", AD1816A_VOICE_ATT, 15, 7, 1, 1),
    982 AD1816A_DOUBLE("PCM Playback Volume", AD1816A_VOICE_ATT, 8, 0, 63, 0),
     995AD1816A_DOUBLE("PCM Playback Volume", AD1816A_VOICE_ATT, 8, 0, 63, 1),
    983996AD1816A_DOUBLE("Line Playback Switch", AD1816A_LINE_GAIN_ATT, 15, 7, 1, 1),
    984 AD1816A_DOUBLE("Line Playback Volume", AD1816A_LINE_GAIN_ATT, 8, 0, 31, 0),
     997AD1816A_DOUBLE("Line Playback Volume", AD1816A_LINE_GAIN_ATT, 8, 0, 31, 1),
    985998AD1816A_DOUBLE("CD Playback Switch", AD1816A_CD_GAIN_ATT, 15, 7, 1, 1),
    986 AD1816A_DOUBLE("CD Playback Volume", AD1816A_CD_GAIN_ATT, 8, 0, 31, 0),
     999AD1816A_DOUBLE("CD Playback Volume", AD1816A_CD_GAIN_ATT, 8, 0, 31, 1),
    9871000AD1816A_DOUBLE("Synth Playback Switch", AD1816A_SYNTH_GAIN_ATT, 15, 7, 1, 1),
    988 AD1816A_DOUBLE("Synth Playback Volume", AD1816A_SYNTH_GAIN_ATT, 8, 0, 31, 0),
     1001AD1816A_DOUBLE("Synth Playback Volume", AD1816A_SYNTH_GAIN_ATT, 8, 0, 31, 1),
    9891002AD1816A_DOUBLE("FM Playback Switch", AD1816A_FM_ATT, 15, 7, 1, 1),
    990 AD1816A_DOUBLE("FM Playback Volume", AD1816A_FM_ATT, 8, 0, 63, 0),
     1003AD1816A_DOUBLE("FM Playback Volume", AD1816A_FM_ATT, 8, 0, 63, 1),
    9911004AD1816A_SINGLE("Mic Playback Switch", AD1816A_MIC_GAIN_ATT, 15, 1, 1),
    992 AD1816A_SINGLE("Mic Playback Volume", AD1816A_MIC_GAIN_ATT, 8, 63, 0),
     1005AD1816A_SINGLE("Mic Playback Volume", AD1816A_MIC_GAIN_ATT, 8, 63, 1),
    9931006AD1816A_SINGLE("Mic Boost", AD1816A_MIC_GAIN_ATT, 14, 1, 0),
    9941007AD1816A_DOUBLE("Video Playback Switch", AD1816A_VID_GAIN_ATT, 15, 7, 1, 1),
    995 AD1816A_DOUBLE("Video Playback Volume", AD1816A_VID_GAIN_ATT, 8, 0, 31, 0),
     1008AD1816A_DOUBLE("Video Playback Volume", AD1816A_VID_GAIN_ATT, 8, 0, 31, 1),
    9961009AD1816A_SINGLE("Phone Capture Switch", AD1816A_PHONE_IN_GAIN_ATT, 15, 1, 1),
    997 AD1816A_SINGLE("Phone Capture Volume", AD1816A_PHONE_IN_GAIN_ATT, 0, 31, 0),
     1010AD1816A_SINGLE("Phone Capture Volume", AD1816A_PHONE_IN_GAIN_ATT, 0, 15, 1),
    9981011AD1816A_SINGLE("Phone Playback Switch", AD1816A_PHONE_OUT_ATT, 7, 1, 1),
    999 AD1816A_SINGLE("Phone Playback Volume", AD1816A_PHONE_OUT_ATT, 0, 31, 0),
     1012AD1816A_SINGLE("Phone Playback Volume", AD1816A_PHONE_OUT_ATT, 0, 31, 1),
    10001013{
    10011014#ifdef TARGET_OS2
  • GPL/branches/alsa-resync1/alsa-kernel/isa/ad1848/ad1848.c

    r32 r92  
    1818 *   You should have received a copy of the GNU General Public License
    1919 *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     20 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2121 *
    2222 */
    2323
    24 #define SNDRV_MAIN_OBJECT_FILE
    2524#include <sound/driver.h>
     25#include <linux/init.h>
     26#include <linux/time.h>
     27#include <linux/wait.h>
     28#include <sound/core.h>
    2629#include <sound/ad1848.h>
    2730#define SNDRV_GET_ID
     
    3134
    3235EXPORT_NO_SYMBOLS;
     36MODULE_AUTHOR("Tugrul Galatali <galatalt@stuy.edu>, Jaroslav Kysela <perex@suse.cz>");
    3337MODULE_DESCRIPTION("AD1848/AD1847/CS4248");
     38MODULE_LICENSE("GPL");
    3439MODULE_CLASSES("{sound}");
    3540MODULE_DEVICES("{{Analog Devices,AD1848},"
     
    131136        if (!cards) {
    132137#ifdef MODULE
    133                 snd_printk("AD1848 soundcard not found or device busy\n");
     138                printk(KERN_ERR "AD1848 soundcard not found or device busy\n");
    134139#endif
    135140                return -ENODEV;
     
    151156#ifndef MODULE
    152157
    153 /* format is: snd-card-ad1848=snd_enable,snd_index,snd_id,snd_port,
     158/* format is: snd-ad1848=snd_enable,snd_index,snd_id,snd_port,
    154159                              snd_irq,snd_dma1 */
    155160
     
    170175}
    171176
    172 __setup("snd-card-ad1848=", alsa_card_ad1848_setup);
     177__setup("snd-ad1848=", alsa_card_ad1848_setup);
    173178
    174179#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/ad1848/ad1848_lib.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
     
    2222#define SNDRV_MAIN_OBJECT_FILE
    2323#include <sound/driver.h>
     24#include <asm/io.h>
     25#include <asm/dma.h>
     26#include <linux/delay.h>
     27#include <linux/slab.h>
     28#include <sound/core.h>
    2429#include <sound/ad1848.h>
     30
     31MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     32MODULE_DESCRIPTION("Routines for control of AD1848/AD1847/CS4248");
     33MODULE_LICENSE("GPL");
    2534
    2635#define chip_t ad1848_t
     
    114123}
    115124
    116 static void snd_ad1848_dout(ad1848_t *chip,
     125void snd_ad1848_dout(ad1848_t *chip,
    117126                            unsigned char reg,
    118127                            unsigned char value)
     
    127136}
    128137
    129 static unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg)
     138unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg)
    130139{
    131140        int timeout;
     
    172181 */
    173182
    174 static void snd_ad1848_mce_up(ad1848_t *chip)
     183void snd_ad1848_mce_up(ad1848_t *chip)
    175184{
    176185        unsigned long flags;
     
    193202}
    194203
    195 static void snd_ad1848_mce_down(ad1848_t *chip)
     204void snd_ad1848_mce_down(ad1848_t *chip)
    196205{
    197206        unsigned long flags;
     
    292301                }
    293302                snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] |= what);
     303                chip->mode |= AD1848_MODE_RUNNING;
    294304        } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
    295305                if (!(chip->image[AD1848_IFACE_CTRL] & what)) {
     
    298308                }
    299309                snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] &= ~what);
     310                chip->mode &= ~AD1848_MODE_RUNNING;
    300311        } else {
    301312                result = -EINVAL;
     
    524535        chip->dma_size = size;
    525536        chip->image[AD1848_IFACE_CTRL] &= ~(AD1848_PLAYBACK_ENABLE | AD1848_PLAYBACK_PIO);
    526         snd_dma_program(chip->dma, runtime->dma_area, size, DMA_MODE_WRITE | DMA_AUTOINIT);
     537        snd_dma_program(chip->dma, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
    527538        count = snd_ad1848_get_count(chip->image[AD1848_DATA_FORMAT], count) - 1;
    528539        spin_lock_irqsave(&chip->reg_lock, flags);
     
    568579        chip->dma_size = size;
    569580        chip->image[AD1848_IFACE_CTRL] &= ~(AD1848_CAPTURE_ENABLE | AD1848_CAPTURE_PIO);
    570         snd_dma_program(chip->dma, runtime->dma_area, size, DMA_MODE_READ | DMA_AUTOINIT);
     581        snd_dma_program(chip->dma, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
    571582        count = snd_ad1848_get_count(chip->image[AD1848_DATA_FORMAT], count) - 1;
    572583        spin_lock_irqsave(&chip->reg_lock, flags);
     
    581592        ad1848_t *chip = snd_magic_cast(ad1848_t, dev_id, return);
    582593
    583         if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream)
     594        if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream &&
     595            (chip->mode & AD1848_MODE_RUNNING))
    584596                snd_pcm_period_elapsed(chip->playback_substream);
    585         if ((chip->mode & AD1848_MODE_CAPTURE) && chip->capture_substream)
     597        if ((chip->mode & AD1848_MODE_CAPTURE) && chip->capture_substream &&
     598            (chip->mode & AD1848_MODE_RUNNING))
    586599                snd_pcm_period_elapsed(chip->capture_substream);
    587600        outb(0, AD1848P(chip, STATUS)); /* clear global interrupt bit */
     
    821834static int snd_ad1848_free(ad1848_t *chip)
    822835{
    823         if (chip->res_port)
     836        if (chip->res_port) {
    824837                release_resource(chip->res_port);
     838                kfree_nocheck(chip->res_port);
     839        }
    825840        if (chip->irq >= 0)
    826841                free_irq(chip->irq, (void *) chip);
     
    980995        strcpy(pcm->name, snd_ad1848_chip_id(chip));
    981996
    982         snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, chip->dma > 3 ? 128*1024 : 64*1024, GFP_KERNEL|GFP_DMA);
     997        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, chip->dma > 3 ? 128*1024 : 64*1024);
    983998
    984999        chip->pcm = pcm;
     
    9951010{
    9961011        static char *texts[4] = {
    997                 "Line1", "Aux", "Line2", "Mix"
     1012                "Line", "Aux", "Mic", "Mix"
    9981013        };
    9991014
     
    11721187AD1848_DOUBLE("Aux Playback Switch", 1, AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
    11731188AD1848_DOUBLE("Aux Playback Volume", 1, AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 0, 0, 31, 1),
    1174 AD1848_DOUBLE("Capture Volume", 0, AD1848_LEFT_INPUT, AD1848_LEFT_INPUT, 0, 0, 15, 0),
     1189AD1848_DOUBLE("Capture Volume", 0, AD1848_LEFT_INPUT, AD1848_RIGHT_INPUT, 0, 0, 15, 0),
    11751190{
    11761191#ifdef TARGET_OS2
     
    12121227}
    12131228
     1229EXPORT_SYMBOL(snd_ad1848_in);
    12141230EXPORT_SYMBOL(snd_ad1848_out);
     1231EXPORT_SYMBOL(snd_ad1848_dout);
     1232EXPORT_SYMBOL(snd_ad1848_mce_up);
     1233EXPORT_SYMBOL(snd_ad1848_mce_down);
    12151234EXPORT_SYMBOL(snd_ad1848_interrupt);
    12161235EXPORT_SYMBOL(snd_ad1848_create);
  • GPL/branches/alsa-resync1/alsa-kernel/isa/als100.c

    r32 r92  
    1818    You should have received a copy of the GNU General Public License
    1919    along with this program; if not, write to the Free Software
    20     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     20    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2121*/
    2222
    2323#define SNDRV_MAIN_OBJECT_FILE
    2424#include <sound/driver.h>
     25#include <linux/init.h>
     26#include <linux/wait.h>
     27#include <linux/sched.h>
     28#include <linux/time.h>
     29#include <sound/core.h>
    2530#define SNDRV_GET_ID
    2631#include <sound/initval.h>
     
    3136#define chip_t sb_t
    3237
     38#define PFX "als100: "
     39
    3340EXPORT_NO_SYMBOLS;
     41
     42MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
    3443MODULE_DESCRIPTION("Avance Logic ALS1X0");
     44MODULE_LICENSE("GPL");
    3545MODULE_CLASSES("{sound}");
    3646MODULE_DEVICES("{{Avance Logic,ALS100 - PRO16PNP},"
    3747                "{Avance Logic,ALS110},"
     48                "{Avance Logic,ALS120},"
     49                "{Avance Logic,ALS200},"
    3850                "{3D Melody,MF1000},"
    3951                "{Digimate,3D Sound},"
     
    122134        /* ALS120 */
    123135        ISAPNP_ALS100('A','L','S',0x0120,0x2001,0x2001,0x2001),
     136        /* ALS200 */
     137        ISAPNP_ALS100('A','L','S',0x0200,0x0020,0x0020,0x0001),
    124138        /* RTL3000 */
    125139        ISAPNP_ALS100('R','T','L',0x3000,0x2001,0x2001,0x2001),
     
    173187
    174188        if (pdev->activate(pdev)<0) {
    175                 snd_printk("AUDIO isapnp configure failure\n");
     189                printk(KERN_ERR PFX "AUDIO isapnp configure failure\n");
    176190                return -EBUSY;
    177191        }
     
    196210
    197211        if (pdev->activate(pdev)<0) {
    198                 snd_printk("MPU-401 isapnp configure failure\n");
     212                printk(KERN_ERR PFX "MPU-401 isapnp configure failure\n");
    199213                snd_mpu_port[dev] = -1;
    200214                acard->devmpu = NULL;
     
    214228
    215229        if (pdev->activate(pdev)<0) {
    216                 snd_printk("OPL isapnp configure failure\n");
     230                printk(KERN_ERR PFX "OPL isapnp configure failure\n");
    217231                snd_fm_port[dev] = -1;
    218232                acard->devopl = NULL;
     
    272286        }
    273287#else
    274         snd_printk("you have to enable PnP support ...\n");
     288        printk(KERN_ERR PFX "you have to enable PnP support ...\n");
    275289        snd_card_free(card);
    276290        return -ENOSYS;
     
    302316                                        snd_mpu_irq[dev], SA_INTERRUPT,
    303317                                        NULL) < 0)
    304                         snd_printk("no MPU-401 device at 0x%lx\n", snd_mpu_port[dev]);
     318                        printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", snd_mpu_port[dev]);
    305319        }
    306320
     
    309323                                    snd_fm_port[dev], snd_fm_port[dev] + 2,
    310324                                    OPL3_HW_AUTO, 0, &opl3) < 0) {
    311                         snd_printk("no OPL device at 0x%lx-0x%lx\n",
     325                        printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",
    312326                                snd_fm_port[dev], snd_fm_port[dev] + 2);
    313327                } else {
     
    365379        cards += isapnp_probe_cards(snd_als100_pnpids, snd_als100_isapnp_detect);
    366380#else
    367         snd_printk("you have to enable ISA PnP support.\n");
     381        printk(KERN_ERR PFX "you have to enable ISA PnP support.\n");
    368382#endif
    369383#ifdef MODULE
    370384        if (!cards)
    371                 snd_printk("no ALS100 based soundcards found\n");
     385                printk(KERN_ERR "no ALS100 based soundcards found\n");
    372386#endif
    373387        return cards ? 0 : -ENODEV;
     
    387401#ifndef MODULE
    388402
    389 /* format is: snd-card-als100=snd_enable,snd_index,snd_id,snd_port,
     403/* format is: snd-als100=snd_enable,snd_index,snd_id,snd_port,
    390404                              snd_mpu_port,snd_fm_port,snd_irq,snd_mpu_irq,
    391405                              snd_dma8,snd_dma16 */
     
    411425}
    412426
    413 __setup("snd-card-als100=", alsa_card_als100_setup);
     427__setup("snd-als100=", alsa_card_als100_setup);
    414428
    415429#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/azt2320.c

    r32 r92  
    1616    You should have received a copy of the GNU General Public License
    1717    along with this program; if not, write to the Free Software
    18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919*/
    2020
     
    3131*/
    3232
    33 #define SNDRV_MAIN_OBJECT_FILE
    3433#include <sound/driver.h>
     34#include <asm/io.h>
     35#include <linux/delay.h>
     36#include <linux/init.h>
     37#include <linux/time.h>
     38#include <linux/wait.h>
     39#include <sound/core.h>
    3540#define SNDRV_GET_ID
    3641#include <sound/initval.h>
     
    4146#define chip_t cs4231_t
    4247
     48#define PFX "azt2320: "
     49
    4350EXPORT_NO_SYMBOLS;
     51
     52MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
    4453MODULE_DESCRIPTION("Aztech Systems AZT2320");
     54MODULE_LICENSE("GPL");
    4555MODULE_CLASSES("{sound}");
    4656MODULE_DEVICES("{{Aztech Systems,PRO16V},"
     
    188198
    189199        if (pdev->activate(pdev) < 0) {
    190                 snd_printk("AUDIO isapnp configure failure\n");
     200                printk(KERN_ERR PFX "AUDIO isapnp configure failure\n");
    191201                return -EBUSY;
    192202        }
     
    214224        if (pdev->activate(pdev) < 0) {
    215225                /* not fatal error */
    216                 snd_printk("MPU-401 isapnp configure failure\n");
     226                printk(KERN_ERR PFX "MPU-401 isapnp configure failure\n");
    217227                snd_mpu_port[dev] = -1;
    218228                acard->devmpu = NULL;
     
    326336                                snd_mpu_irq[dev], SA_INTERRUPT,
    327337                                NULL) < 0)
    328                         snd_printk("no MPU-401 device at 0x%lx\n",
     338                        printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n",
    329339                                snd_mpu_port[dev]);
    330340        }
     
    334344                                    snd_fm_port[dev], snd_fm_port[dev] + 2,
    335345                                    OPL3_HW_AUTO, 0, &opl3) < 0) {
    336                         snd_printk("no OPL device at 0x%lx-0x%lx\n",
     346                        printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",
    337347                                snd_fm_port[dev], snd_fm_port[dev] + 2);
    338348                } else {
     
    390400        cards += isapnp_probe_cards(snd_azt2320_pnpids, snd_azt2320_isapnp_detect);
    391401#else
    392         snd_printk("you have to enable ISA PnP support.\n");
     402        printk(KERN_ERR PFX "you have to enable ISA PnP support.\n");
    393403#endif
    394404#ifdef MODULE
    395405        if (!cards)
    396                 snd_printk("no AZT2320 based soundcards found\n");
     406                printk(KERN_ERR "no AZT2320 based soundcards found\n");
    397407#endif
    398408        return cards ? 0 : -ENODEV;
     
    412422#ifndef MODULE
    413423
    414 /* format is: snd-card-azt2320=snd_enable,snd_index,snd_id,snd_port,
     424/* format is: snd-azt2320=snd_enable,snd_index,snd_id,snd_port,
    415425                               snd_wss_port,snd_mpu_port,snd_fm_port,
    416426                               snd_irq,snd_mpu_irq,snd_dma1,snd_dma2 */
     
    436446}
    437447
    438 __setup("snd-card-azt2320=", alsa_card_azt2320_setup);
     448__setup("snd-azt2320=", alsa_card_azt2320_setup);
    439449
    440450#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/cmi8330.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
     
    4444 */
    4545
    46 #define SNDRV_MAIN_OBJECT_FILE
    47 
    4846#include <sound/driver.h>
     47#include <linux/init.h>
     48#include <linux/slab.h>
     49#include <sound/core.h>
    4950#include <sound/ad1848.h>
    5051#include <sound/sb.h>
     
    5354
    5455EXPORT_NO_SYMBOLS;
     56
     57MODULE_AUTHOR("George Talusan <gstalusan@uwaterloo.ca>");
    5558MODULE_DESCRIPTION("C-Media CMI8330");
     59MODULE_LICENSE("GPL");
    5660MODULE_CLASSES("{sound}");
    5761MODULE_DEVICES("{{C-Media,CMI8330,isapnp:{CMI0001,@@@0001,@X@0001}}}");
     
    7579static int snd_wssdma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
    7680
    77 MODULE_AUTHOR("George Talusan <gstalusan@uwaterloo.ca>");
    7881MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
    7982MODULE_PARM_DESC(snd_index, "Index value for CMI8330 soundcard.");
     
    499502        if (!cards) {
    500503#ifdef MODULE
    501                 snd_printk("CMI8330 not found or device busy\n");
     504                printk(KERN_ERR "CMI8330 not found or device busy\n");
    502505#endif
    503506                return -ENODEV;
     
    511514#ifndef MODULE
    512515
    513 /* format is: snd-card-cmi8330=snd_enable,snd_index,snd_id,snd_isapnp,
     516/* format is: snd-cmi8330=snd_enable,snd_index,snd_id,snd_isapnp,
    514517                               snd_sbport,snd_sbirq,
    515518                               snd_sbdma8,snd_sbdma16,
     
    532535               get_option(&str,&snd_sbdma8[nr_dev]) == 2 &&
    533536               get_option(&str,&snd_sbdma16[nr_dev]) == 2 &&
    534                get_option(&str,&snd_wssport[nr_dev]) == 2 &&
     537               get_option(&str,(int *)&snd_wssport[nr_dev]) == 2 &&
    535538               get_option(&str,&snd_wssirq[nr_dev]) == 2 &&
    536539               get_option(&str,&snd_wssdma[nr_dev]) == 2);
     
    543546}
    544547
    545 __setup("snd-card-cmi8330=", alsa_card_cmi8330_setup);
     548__setup("snd-cmi8330=", alsa_card_cmi8330_setup);
    546549
    547550#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/cs423x/cs4231.c

    r32 r92  
    1717 *   You should have received a copy of the GNU General Public License
    1818 *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2020 *
    2121 */
    2222
    23 #define SNDRV_MAIN_OBJECT_FILE
    2423#include <sound/driver.h>
     24#include <linux/init.h>
     25#include <linux/time.h>
     26#include <linux/wait.h>
     27#include <sound/core.h>
    2528#include <sound/cs4231.h>
    2629#include <sound/mpu401.h>
     
    3134
    3235EXPORT_NO_SYMBOLS;
     36
     37MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3338MODULE_DESCRIPTION("Generic CS4231");
     39MODULE_LICENSE("GPL");
    3440MODULE_CLASSES("{sound}");
    3541MODULE_DEVICES("{{Crystal Semiconductors,CS4231}}");
     
    130136                                        snd_mpu_irq[dev], SA_INTERRUPT,
    131137                                        NULL) < 0)
    132                         snd_printk("MPU401 not detected\n");
     138                        printk(KERN_ERR "cs4231: MPU401 not detected\n");
    133139        }
    134140        strcpy(card->driver, "CS4231");
     
    156162        if (!cards) {
    157163#ifdef MODULE
    158                 snd_printk("CS4231 soundcard not found or device busy\n");
     164                printk(KERN_ERR "CS4231 soundcard not found or device busy\n");
    159165#endif
    160166                return -ENODEV;
     
    176182#ifndef MODULE
    177183
    178 /* format is: snd-card-cs4231=snd_enable,snd_index,snd_id,
     184/* format is: snd-cs4231=snd_enable,snd_index,snd_id,
    179185                              snd_port,snd_mpu_port,snd_irq,snd_mpu_irq,
    180186                              snd_dma1,snd_dma2 */
     
    201207}
    202208
    203 __setup("snd-card-cs4231=", alsa_card_cs4231_setup);
     209__setup("snd-cs4231=", alsa_card_cs4231_setup);
    204210
    205211#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/cs423x/cs4231_lib.c

    r32 r92  
    2121 *   You should have received a copy of the GNU General Public License
    2222 *   along with this program; if not, write to the Free Software
    23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     23 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2424 *
    2525 */
    2626
    27 #define SNDRV_MAIN_OBJECT_FILE
    2827#include <sound/driver.h>
     28#include <asm/io.h>
     29#include <asm/dma.h>
     30#include <asm/irq.h>
     31#include <linux/delay.h>
     32#include <linux/pm.h>
     33#include <linux/init.h>
     34#include <linux/slab.h>
     35#include <sound/core.h>
    2936#include <sound/cs4231.h>
     37
     38MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     39MODULE_DESCRIPTION("Routines for control of CS4231(A)/CS4232/InterWave & compatible chips");
     40MODULE_LICENSE("GPL");
    3041
    3142#define chip_t cs4231_t
     
    743754        chip->image[CS4231_PIN_CTRL] &= ~CS4231_IRQ_ENABLE;
    744755        snd_cs4231_out(chip, CS4231_PIN_CTRL, chip->image[CS4231_PIN_CTRL]);
    745         spin_unlock_irqrestore(&chip->reg_lock, flags);
    746756
    747757        /* now disable record & playback */
    748758
    749         spin_lock_irqsave(&chip->reg_lock, flags);
    750759        if (chip->image[CS4231_IFACE_CTRL] & (CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO |
    751760                                               CS4231_RECORD_ENABLE | CS4231_RECORD_PIO)) {
     
    849858        unsigned int count = snd_pcm_lib_period_bytes(substream);
    850859
     860        spin_lock_irqsave(&chip->reg_lock, flags);
    851861        chip->p_dma_size = size;
    852862        chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO);
    853         snd_dma_program(chip->dma1, runtime->dma_area, size, DMA_MODE_WRITE | DMA_AUTOINIT);
     863        snd_dma_program(chip->dma1, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
    854864        count = snd_cs4231_get_count(chip->image[CS4231_PLAYBK_FORMAT], count) - 1;
    855         spin_lock_irqsave(&chip->reg_lock, flags);
    856865        snd_cs4231_out(chip, CS4231_PLY_LWR_CNT, (unsigned char) count);
    857866        snd_cs4231_out(chip, CS4231_PLY_UPR_CNT, (unsigned char) (count >> 8));
     
    891900        unsigned int count = snd_pcm_lib_period_bytes(substream);
    892901
     902        spin_lock_irqsave(&chip->reg_lock, flags);
    893903        chip->c_dma_size = size;
    894904        chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | CS4231_RECORD_PIO);
    895         snd_dma_program(chip->dma2, runtime->dma_area, size, DMA_MODE_READ | DMA_AUTOINIT);
     905        snd_dma_program(chip->dma2, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
    896906        count = snd_cs4231_get_count(chip->image[CS4231_REC_FORMAT], count) - 1;
    897         spin_lock_irqsave(&chip->reg_lock, flags);
    898907        if (chip->single_dma && chip->hardware != CS4231_HW_INTERWAVE) {
    899908                snd_cs4231_out(chip, CS4231_PLY_LWR_CNT, (unsigned char) count);
     
    13581367        }
    13591368        snd_cs4231_busy_wait(chip);
    1360         return;
     1369        spin_unlock_irqrestore(&chip->reg_lock, flags);
    13611370#endif
    13621371}
     
    13831392static int snd_cs4231_free(cs4231_t *chip)
    13841393{
    1385         if (chip->res_port)
     1394        if (chip->res_port) {
    13861395                release_resource(chip->res_port);
    1387         if (chip->res_cport)
     1396                kfree_nocheck(chip->res_port);
     1397        }
     1398        if (chip->res_cport) {
    13881399                release_resource(chip->res_cport);
     1400                kfree_nocheck(chip->res_cport);
     1401        }
    13891402        if (chip->irq >= 0) {
    13901403                disable_irq(chip->irq);
     
    16121625        strcpy(pcm->name, snd_cs4231_chip_id(chip));
    16131626
    1614         snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024, GFP_KERNEL|GFP_DMA);
     1627        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
    16151628
    16161629        chip->pcm = pcm;
  • GPL/branches/alsa-resync1/alsa-kernel/isa/cs423x/cs4236.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <linux/init.h>
     24#include <linux/slab.h>
     25#ifndef LINUX_ISAPNP_H
     26#include <linux/isapnp.h>
     27#define isapnp_card pci_bus
     28#define isapnp_dev pci_dev
     29#endif
     30#include <sound/core.h>
    2431#include <sound/cs4231.h>
    2532#include <sound/mpu401.h>
     
    3138
    3239EXPORT_NO_SYMBOLS;
     40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     41MODULE_LICENSE("GPL");
     42MODULE_CLASSES("{sound}");
    3343#ifdef CS4232
    3444MODULE_DESCRIPTION("Cirrus Logic CS4232");
    35 MODULE_CLASSES("{sound}");
    3645MODULE_DEVICES("{{Turtle Beach,TBS-2000},"
    3746                "{Turtle Beach,Tropez Plus},"
    3847                "{SIC CrystalWave 32},"
    39                 "{HP,Omnibook 5500}},"
    40                 "{TerraTec,Maestro 32/96}");
     48                "{Hewlett Packard,Omnibook 5500},"
     49                "{TerraTec,Maestro 32/96},"
     50                "{Philips,PCA70PS}}");
    4151#else
    4252MODULE_DESCRIPTION("Cirrus Logic CS4235-9");
    43 MODULE_CLASSES("{sound}");
    4453MODULE_DEVICES("{{Crystal Semiconductors,CS4235},"
    4554                "{Crystal Semiconductors,CS4236},"
     
    4756                "{Crystal Semiconductors,CS4238},"
    4857                "{Crystal Semiconductors,CS4239},"
     58                "{Acer,AW37},"
     59                "{Acer,AW35/Pro},"
     60                "{Crystal,3D},"
     61                "{Crystal Computer,TidalWave128},"
     62                "{Dell,Optiplex GX1},"
     63                "{Dell,Workstation 400 sound},"
     64                "{EliteGroup,P5TX-LA sound},"
     65                "{Gallant,SC-70P},"
     66                "{Gateway,E1000 Onboard CS4236B},"
    4967                "{Genius,Sound Maker 3DJ},"
    5068                "{Hewlett Packard,HP6330 sound},"
    51                 "{Crystal Computer,TidalWave128},"
    52                 "{Acer,AW37},"
    53                 "{EliteGroup,P5TX-LA sound},"
    54                 "{Crystal,3D},"
     69                "{IBM,PC 300PL sound},"
     70                "{IBM,Aptiva 2137 E24},"
     71                "{IBM,IntelliStation M Pro},"
     72                "{Intel,Marlin Spike Mobo CS4235},"
     73                "{Guillemot,MaxiSound 16 PnP},"
     74                "{NewClear,3D},"
     75                "{TerraTec,AudioSystem EWS64L/XL},"
    5576                "{Typhoon Soundsystem,CS4236B},"
    56                 "{TerraTec, AudioSystem EWS64XL},"
    57                 "{NewClear,3D},"
    58                 "{Dell,Optiplex GX1},"
    59                 "{Dell,Workstation 400 sound},"
    6077                "{Turtle Beach,Malibu},"
    61                 "{Crystal Semiconductors,CS4235},"
    62                 "{IBM,Adaptiva 2137 E24},"
    63                 "{Maxi Sound,16 PnP},"
    64                 "{Gallant,SC-70P},"
    65                 "{Acer,AW37/Pro},"
    66                 "{Acer,AW35/Pro},"
    67                 "{Intel, Marlin Spike Mobo CS4235},"
    68                 "{IBM,IntelliStation M Pro}}");
     78                "{Unknown,Digital PC 5000 Onboard}}");
    6979#endif
    7080
     
    7787static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    7888static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    79 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     89static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    8090#ifdef __ISAPNP__
    8191#ifdef TARGET_OS2
     
    200210#ifdef CS4232
    201211static struct isapnp_card_id snd_card_pnpids[] __devinitdata = {
     212        /* Philips PCA70PS */
     213        ISAPNP_CS4232_1('C','S','C',0x0d32,0x0000,0x0010,0xb006),
     214        /* TerraTec Maestro 32/96 (CS4232) */
     215        ISAPNP_CS4232('C','S','C',0x1a32,0x0000,0x0010,0x0003),
    202216        /* HP Omnibook 5500 onboard */
    203217        ISAPNP_CS4232('C','S','C',0x4232,0x0000,0x0002,0x0003),
     
    208222        /* SIC CrystalWave 32 (CS4232) */
    209223        ISAPNP_CS4232('C','S','C',0xf032,0x0000,0x0010,0x0003),
    210         /* TerraTec Maestro 32/96 (CS4232) */
    211         ISAPNP_CS4232('C','S','C',0x1a32,0x0000,0x0010,0x0003),
    212224        /* --- */
    213225        { ISAPNP_CARD_END, }    /* end */
     
    221233        /* Genius Sound Maker 3DJ - CS4237B */
    222234        ISAPNP_CS4232('C','S','C',0x0437,0x0000,0x0010,0x0003),
     235        /* Digital PC 5000 Onboard - CS4236B */
     236        ISAPNP_CS4232_WOMPU('C','S','C',0x0735,0x0000,0x0010),
    223237        /* some uknown CS4236B */
    224238        ISAPNP_CS4232('C','S','C',0x0b35,0x0000,0x0010,0x0003),
    225239        /* CS4235 on mainboard without MPU */
    226240        ISAPNP_CS4232_WOMPU('C','S','C',0x1425,0x0100,0x0110),
     241        /* Gateway E1000 Onboard CS4236B */
     242        ISAPNP_CS4232('C','S','C',0x1335,0x0000,0x0010,0x0003),
    227243        /* HP 6330 Onboard sound */
    228244        ISAPNP_CS4232('C','S','C',0x1525,0x0100,0x0110,0x0103),
     
    253269        /* CS4235 - onboard */
    254270        ISAPNP_CS4232('C','S','C',0x8025,0x0100,0x0110,0x0103),
     271        /* IBM PC 300PL Onboard - CS4236B */
     272        ISAPNP_CS4232_WOMPU('C','S','C',0xe836,0x0000,0x0010),
    255273        /* IBM Aptiva 2137 E24 Onboard - CS4237B */
    256274        ISAPNP_CS4232('C','S','C',0x8037,0x0000,0x0010,0x0003),
    257         /* Maxi Sound 16 PnP - CS4236B */
     275        /* IBM IntelliStation M Pro motherboard */
     276        ISAPNP_CS4232_WOMPU('C','S','C',0xc835,0x0000,0x0010),
     277        /* Guillemot MaxiSound 16 PnP - CS4236B */
    258278        ISAPNP_CS4232('C','S','C',0x9836,0x0000,0x0010,0x0003),
    259279        /* Gallant SC-70P */
    260280        ISAPNP_CS4232('C','S','C',0x9837,0x0000,0x0010,0x0003),
    261         /* IBM IntelliStation M Pro motherboard */
    262         ISAPNP_CS4232_WOMPU('C','S','C',0xc835,0x0000,0x0010),
    263281        /* ACER AW37/Pro - CS4235 */
    264282        ISAPNP_CS4232('C','S','C',0xd925,0x0000,0x0010,0x0003),
     
    319337                isapnp_resource_change(&pdev->dma_resource[1], snd_dma2[dev] < 0 ? 4 : snd_dma2[dev], 1);
    320338        if (pdev->activate(pdev)<0) {
    321                 snd_printk(IDENT " isapnp configure failed for WSS (out of resources?)\n");
     339                printk(KERN_ERR IDENT " isapnp configure failed for WSS (out of resources?)\n");
    322340                return -EBUSY;
    323341        }
     
    341359                isapnp_resource_change(&pdev->resource[0], snd_cport[dev], 8);
    342360        if (pdev->activate(pdev)<0) {
    343                 snd_printk(IDENT " isapnp configure failed for control (out of resources?)\n");
     361                printk(KERN_ERR IDENT " isapnp configure failed for control (out of resources?)\n");
    344362                acard->wss->deactivate(acard->wss);
    345363                return -EBUSY;
     
    361379                if (pdev->activate(pdev)<0) {
    362380                        snd_mpu_port[dev] = SNDRV_AUTO_PORT;
    363                         snd_printk(IDENT " isapnp configure failed for MPU (out of resources?)\n");
     381                        snd_mpu_irq[dev] = SNDRV_AUTO_IRQ;
     382                        printk(KERN_ERR IDENT " isapnp configure failed for MPU (out of resources?)\n");
    364383                } else {
    365384                        snd_mpu_port[dev] = pdev->resource[0].start;
     385                        if (pdev->irq_resource[0].flags & IORESOURCE_IRQ) {
    366386                        snd_mpu_irq[dev] = pdev->irq_resource[0].start;
     387                        } else {
     388                                snd_mpu_irq[dev] = -1;  /* disable interrupt */
     389                        }
    367390                }
    368391                snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", snd_mpu_port[dev], snd_mpu_irq[dev]);
     
    396419                snd_card_cs4236_deactivate(acard);
    397420#endif
    398                 if (acard->res_sb_port)
     421                if (acard->res_sb_port) {
    399422                        release_resource(acard->res_sb_port);
     423                        kfree_nocheck(acard->res_sb_port);
     424                }
    400425        }
    401426}
     
    432457#ifdef __ISAPNP__
    433458        if (snd_isapnp[dev] && (err = snd_card_cs4236_isapnp(dev, acard))<0) {
    434                 snd_printk("isapnp detection failed and probing for " IDENT " is not supported\n");
     459                printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n");
    435460                snd_card_free(card);
    436461                return -ENXIO;
     
    445470        if (snd_sb_port[dev] != SNDRV_AUTO_PORT)
    446471                if ((acard->res_sb_port = request_region(snd_sb_port[dev], 16, IDENT " SB")) == NULL) {
    447                         snd_printk("unable to register SB port at 0x%lx\n", snd_sb_port[dev]);
     472                        printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", snd_sb_port[dev]);
    448473                        snd_card_free(card);
    449474                        return -ENOMEM;
     
    504529                                    snd_fm_port[dev], snd_fm_port[dev] + 2,
    505530                                    OPL3_HW_OPL3_CS, 0, &opl3) < 0) {
    506                         snd_printk(IDENT ": OPL3 not detected\n");
     531                        printk(KERN_ERR IDENT ": OPL3 not detected\n");
    507532                } else {
    508533                        if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
     
    516541                if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
    517542                                        snd_mpu_port[dev], 0,
    518                                         snd_mpu_irq[dev], SA_INTERRUPT, NULL) < 0)
    519                         snd_printk(IDENT ": MPU401 not detected\n");
     543                                        snd_mpu_irq[dev],
     544                                        snd_mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0)
     545                        printk(KERN_ERR IDENT ": MPU401 not detected\n");
    520546        }
    521547        strcpy(card->driver, pcm->name);
     
    577603        if (!cards) {
    578604#ifdef MODULE
    579                 snd_printk(IDENT " soundcard not found or device busy\n");
     605                printk(KERN_ERR IDENT " soundcard not found or device busy\n");
    580606#endif
    581607                return -ENODEV;
     
    597623#ifndef MODULE
    598624
    599 /* format is: snd-card-cs4232=snd_enable,snd_index,snd_id,snd_isapnp,snd_port,
     625/* format is: snd-cs4232=snd_enable,snd_index,snd_id,snd_isapnp,snd_port,
    600626                              snd_cport,snd_mpu_port,snd_fm_port,snd_sb_port,
    601627                              snd_irq,snd_mpu_irq,snd_dma1,snd_dma1_size,
    602628                              snd_dma2,snd_dma2_size */
    603 /* format is: snd-card-cs4236=snd_enable,snd_index,snd_id,snd_isapnp,snd_port,
     629/* format is: snd-cs4236=snd_enable,snd_index,snd_id,snd_isapnp,snd_port,
    604630                              snd_cport,snd_mpu_port,snd_fm_port,snd_sb_port,
    605631                              snd_irq,snd_mpu_irq,snd_dma1,snd_dma1_size,
     
    635661
    636662#ifdef CS4232
    637 __setup("snd-card-cs4232=", alsa_card_cs423x_setup);
     663__setup("snd-cs4232=", alsa_card_cs423x_setup);
    638664#else /* CS4236 */
    639 __setup("snd-card-cs4236=", alsa_card_cs423x_setup);
     665__setup("snd-cs4236=", alsa_card_cs423x_setup);
    640666#endif
    641667
  • GPL/branches/alsa-resync1/alsa-kernel/isa/dt0197h.c

    r32 r92  
    1616    You should have received a copy of the GNU General Public License
    1717    along with this program; if not, write to the Free Software
    18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919*/
    2020
    21 #define SNDRV_MAIN_OBJECT_FILE
    2221#include <sound/driver.h>
     22#include <linux/init.h>
     23#include <linux/sched.h>
     24#include <linux/wait.h>
     25#include <sound/core.h>
    2326#define SNDRV_GET_ID
    2427#include <sound/initval.h>
     
    2932#define chip_t sb_t
    3033
     34#define PFX "dt0197h: "
     35
    3136EXPORT_NO_SYMBOLS;
     37
     38MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
    3239MODULE_DESCRIPTION("Diamond Technologies DT-0197H");
     40MODULE_LICENSE("GPL");
    3341MODULE_CLASSES("{sound}");
    3442MODULE_DEVICES("{{Diamond Technologies,DT-0197H}}");
     
    147155
    148156        if (pdev->activate(pdev)<0) {
    149                 snd_printk("AUDIO isapnp configure failure\n");
     157                printk(KERN_ERR PFX "AUDIO isapnp configure failure\n");
    150158                return -EBUSY;
    151159        }
     
    167175
    168176        if (pdev->activate(pdev)<0) {
    169                 snd_printk("MPU-401 isapnp configure failure\n");
     177                printk(KERN_ERR PFX "MPU-401 isapnp configure failure\n");
    170178                snd_mpu_port[dev] = -1;
    171179                acard->devmpu = NULL;
     
    183191
    184192        if (pdev->activate(pdev)<0) {
    185                 snd_printk("OPL isapnp configure failure\n");
     193                printk(KERN_ERR PFX "OPL isapnp configure failure\n");
    186194                snd_fm_port[dev] = -1;
    187195                acard->devopl = NULL;
     
    241249        }
    242250#else
    243         snd_printk("you have to enable PnP support ...\n");
     251        printk(KERN_ERR PFX "you have to enable PnP support ...\n");
    244252        snd_card_free(card);
    245253        return -ENOSYS;
     
    273281                                        SA_INTERRUPT,
    274282                                        NULL) < 0)
    275                         snd_printk("no MPU-401 device at 0x%lx ?\n",
     283                        printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n",
    276284                                snd_mpu_port[dev]);
    277285        }
     
    282290                                    snd_fm_port[dev] + 2,
    283291                                    OPL3_HW_AUTO, 0, &opl3) < 0) {
    284                         snd_printk("no OPL device at 0x%lx-0x%lx ?\n",
     292                        printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx ?\n",
    285293                                snd_fm_port[dev], snd_fm_port[dev] + 2);
    286294                } else {
     
    338346        cards += isapnp_probe_cards(snd_dt0197h_pnpids, snd_dt0197h_isapnp_detect);
    339347#else
    340         snd_printk("you have to enable ISA PnP support.\n");
     348        printk(KERN_ERR PFX "you have to enable ISA PnP support.\n");
    341349#endif
    342350#ifdef MODULE
    343351        if (!cards)
    344                 snd_printk("no DT-0197H based soundcards found\n");
     352                printk(KERN_ERR "no DT-0197H based soundcards found\n");
    345353#endif
    346354        return cards ? 0 : -ENODEV;
     
    360368#ifndef MODULE
    361369
    362 /* format is: snd-card-dt0197h=snd_enable,snd_index,snd_id,snd_isapnp,
     370/* format is: snd-dt0197h=snd_enable,snd_index,snd_id,snd_isapnp,
    363371                               snd_port,snd_mpu_port,snd_fm_port,
    364372                               snd_irq,snd_mpu_irq,snd_dma8,snd_dma8_size */
     
    383391}
    384392
    385 __setup("snd-card-dt0197h=", alsa_card_dt0197h_setup);
     393__setup("snd-dt0197h=", alsa_card_dt0197h_setup);
    386394
    387395#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/es1688/es1688.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <asm/dma.h>
     24#include <linux/init.h>
     25#include <linux/time.h>
     26#include <linux/wait.h>
     27#include <sound/core.h>
    2428#include <sound/es1688.h>
    2529#include <sound/mpu401.h>
     
    3438
    3539EXPORT_NO_SYMBOLS;
     40
     41MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3642MODULE_DESCRIPTION("ESS ESx688 AudioDrive");
     43MODULE_LICENSE("GPL");
    3744MODULE_CLASSES("{sound}");
    3845MODULE_DEVICES("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100},"
     
    131138
    132139        if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) {
    133                 snd_printk("opl3 not detected at 0x%lx\n", chip->port);
     140                printk(KERN_ERR "es1688: opl3 not detected at 0x%lx\n", chip->port);
    134141        } else {
    135142                if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
     
    212219#ifndef MODULE
    213220
    214 /* format is: snd-card-es1688=snd_enable,snd_index,snd_id,
     221/* format is: snd-es1688=snd_enable,snd_index,snd_id,
    215222                              snd_port,snd_mpu_port,
    216223                              snd_irq,snd_mpu_irq,
     
    235242}
    236243
    237 __setup("snd-card-es1688=", alsa_card_es1688_setup);
     244__setup("snd-es1688=", alsa_card_es1688_setup);
    238245
    239246#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/es1688/es1688_lib.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <asm/io.h>
     24#include <asm/dma.h>
     25#include <linux/init.h>
     26#include <linux/delay.h>
     27#include <linux/slab.h>
     28#include <sound/core.h>
    2429#include <sound/es1688.h>
     30#include <sound/initval.h>
     31
     32MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     33MODULE_DESCRIPTION("ESS ESx688 lowlevel module");
     34MODULE_CLASSES("{sound}");
     35MODULE_LICENSE("GPL");
    2536
    2637#define chip_t es1688_t
     
    419430        /* --- */
    420431        count = -count;
    421         snd_dma_program(chip->dma8, runtime->dma_area, size, DMA_MODE_WRITE | DMA_AUTOINIT);
     432        snd_dma_program(chip->dma8, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
    422433        spin_lock_irqsave(&chip->reg_lock, flags);
    423434        snd_es1688_write(chip, 0xa4, (unsigned char) count);
     
    476487        /* --- */
    477488        count = -count;
    478         snd_dma_program(chip->dma8, runtime->dma_area, size, DMA_MODE_READ | DMA_AUTOINIT);
     489        snd_dma_program(chip->dma8, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
    479490        spin_lock_irqsave(&chip->reg_lock, flags);
    480491        snd_es1688_write(chip, 0xa4, (unsigned char) count);
     
    656667                snd_es1688_init(chip, 0);
    657668                release_resource(chip->res_port);
     669                kfree_nocheck(chip->res_port);
    658670        }
    659671        if (chip->irq >= 0)
     
    823835        chip->pcm = pcm;
    824836
    825         snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, 64*1024, GFP_KERNEL|GFP_DMA);
     837        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, 64*1024);
    826838
    827839        if (rpcm)
    828                 *rpcm = NULL;
     840                *rpcm = pcm;
    829841        return 0;
    830842}
  • GPL/branches/alsa-resync1/alsa-kernel/isa/es18xx.c

    r32 r92  
    1717 *   You should have received a copy of the GNU General Public License
    1818 *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2020 *
    2121 */
     
    6565
    6666
    67 #define SNDRV_MAIN_OBJECT_FILE
    6867#include <sound/driver.h>
     68#include <asm/io.h>
     69#include <asm/dma.h>
     70#include <linux/init.h>
     71#include <linux/pm.h>
     72#include <linux/slab.h>
     73#ifndef LINUX_ISAPNP_H
     74#include <linux/isapnp.h>
     75#define isapnp_card pci_bus
     76#define isapnp_dev pci_dev
     77#endif
     78#include <sound/core.h>
    6979#include <sound/control.h>
    7080#include <sound/pcm.h>
     
    7686#define SNDRV_GET_ID
    7787#include <sound/initval.h>
     88
     89#define PFX "es18xx: "
    7890
    7991struct _snd_es18xx {
     
    114126        spinlock_t mixer_lock;
    115127        spinlock_t ctrl_lock;
     128#ifdef CONFIG_PM
     129        struct pm_dev *pm_dev;
     130        unsigned char pm_reg;
     131#endif
    116132};
    117133
     
    133149#define ES18XX_MUTEREC  0x0400  /* Record source can be muted */
    134150#define ES18XX_CONTROL  0x0800  /* Has control ports */
     151
     152/* Power Management */
     153#define ES18XX_PM       0x07
     154#define ES18XX_PM_GPO0  0x01
     155#define ES18XX_PM_GPO1  0x02
     156#define ES18XX_PM_PDR   0x03
     157#define ES18XX_PM_ANA   0x04
     158#define ES18XX_PM_FM    0x06
     159#define ES18XX_PM_SUS   0x08
    135160
    136161typedef struct _snd_es18xx es18xx_t;
     
    502527
    503528        /* Set DMA controller */
    504         snd_dma_program(chip->dma2, runtime->dma_area, size, DMA_MODE_WRITE | DMA_AUTOINIT);
     529        snd_dma_program(chip->dma2, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
    505530
    506531        return 0;
     
    614639
    615640        /* Set DMA controler */
    616         snd_dma_program(chip->dma1, runtime->dma_area, size, DMA_MODE_READ | DMA_AUTOINIT);
     641        snd_dma_program(chip->dma1, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
    617642
    618643        return 0;
     
    677702
    678703        /* Set DMA controler */
    679         snd_dma_program(chip->dma1, runtime->dma_area, size, DMA_MODE_WRITE | DMA_AUTOINIT);
     704        snd_dma_program(chip->dma1, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
    680705
    681706        return 0;
     
    16201645{
    16211646        if (snd_es18xx_identify(chip) < 0) {
    1622                 snd_printk("[0x%lx] ESS chip not found\n", chip->port);
     1647                printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port);
    16231648                return -ENODEV;
    16241649        }
     
    17361761        chip->pcm = pcm;
    17371762
    1738         snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024, GFP_KERNEL|GFP_DMA);
     1763        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
    17391764
    17401765        if (rpcm)
     
    17431768}
    17441769
     1770/* Power Management support functions */
     1771#ifdef CONFIG_PM
     1772static void snd_es18xx_suspend(es18xx_t *chip)
     1773{
     1774        snd_card_t *card = chip->card;
     1775
     1776        snd_power_lock(card);
     1777        if (card->power_state == SNDRV_CTL_POWER_D3hot)
     1778                goto __skip;
     1779
     1780        snd_pcm_suspend_all(chip->pcm);
     1781
     1782        /* power down */
     1783        chip->pm_reg = (unsigned char)snd_es18xx_read(chip, ES18XX_PM);
     1784        chip->pm_reg |= (ES18XX_PM_FM | ES18XX_PM_SUS);
     1785        snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg);
     1786        snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_SUS);
     1787
     1788        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
     1789      __skip:
     1790        snd_power_unlock(card);
     1791}
     1792
     1793static void snd_es18xx_resume(es18xx_t *chip)
     1794{
     1795        snd_card_t *card = chip->card;
     1796
     1797        snd_power_lock(card);
     1798        if (card->power_state == SNDRV_CTL_POWER_D0)
     1799                goto __skip;
     1800
     1801        /* restore PM register, we won't wake till (not 0x07) i/o activity though */
     1802        snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM);
     1803
     1804        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     1805      __skip:
     1806        snd_power_unlock(card);
     1807}
     1808
     1809/* callback for control API */
     1810static int snd_es18xx_set_power_state(snd_card_t *card, unsigned int power_state)
     1811{
     1812        es18xx_t *chip = (es18xx_t *) card->power_state_private_data;
     1813        switch (power_state) {
     1814        case SNDRV_CTL_POWER_D0:
     1815        case SNDRV_CTL_POWER_D1:
     1816        case SNDRV_CTL_POWER_D2:
     1817                snd_es18xx_resume(chip);
     1818                break;
     1819        case SNDRV_CTL_POWER_D3hot:
     1820        case SNDRV_CTL_POWER_D3cold:
     1821                snd_es18xx_suspend(chip);
     1822                break;
     1823        default:
     1824                return -EINVAL;
     1825        }
     1826        return 0;
     1827}
     1828
     1829static int snd_es18xx_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data)
     1830{
     1831        es18xx_t *chip = snd_magic_cast(es18xx_t, dev->data, return 0);
     1832
     1833        switch (rqst) {
     1834        case PM_SUSPEND:
     1835                snd_es18xx_suspend(chip);
     1836                break;
     1837        case PM_RESUME:
     1838                snd_es18xx_resume(chip);
     1839                break;
     1840        }
     1841        return 0;
     1842}
     1843#endif /* CONFIG_PM */
     1844
    17451845static int snd_es18xx_free(es18xx_t *chip)
    17461846{
    1747         if (chip->res_port)
     1847#ifdef CONFIG_PM
     1848        if (chip->pm_dev)
     1849                pm_unregister(chip->pm_dev);
     1850#endif
     1851        if (chip->res_port) {
    17481852                release_resource(chip->res_port);
    1749         if (chip->res_ctrl_port)
     1853                kfree_nocheck(chip->res_port);
     1854        }
     1855        if (chip->res_ctrl_port) {
    17501856                release_resource(chip->res_ctrl_port);
    1751         if (chip->res_mpu_port)
     1857                kfree_nocheck(chip->res_ctrl_port);
     1858        }
     1859        if (chip->res_mpu_port) {
    17521860                release_resource(chip->res_mpu_port);
     1861                kfree_nocheck(chip->res_mpu_port);
     1862        }
    17531863        if (chip->irq >= 0)
    17541864                free_irq(chip->irq, (void *) chip);
     
    18091919        if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) {
    18101920                snd_es18xx_free(chip);
    1811                 snd_printk("unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1);
     1921                printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1);
    18121922                return -EBUSY;
    18131923        }
     
    18211931        if (request_irq(irq, snd_es18xx_interrupt, SA_INTERRUPT, "ES18xx", (void *) chip)) {
    18221932                snd_es18xx_free(chip);
    1823                 snd_printk("unable to grap IRQ %d\n", irq);
     1933                printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq);
    18241934                return -EBUSY;
    18251935        }
     
    18281938        if (request_dma(dma1, "ES18xx DMA 1")) {
    18291939                snd_es18xx_free(chip);
    1830                 snd_printk("unable to grap DMA1 %d\n", dma1);
     1940                printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1);
    18311941                return -EBUSY;
    18321942        }
     
    18351945        if (request_dma(dma2, "ES18xx DMA 2")) {
    18361946                snd_es18xx_free(chip);
    1837                 snd_printk("unable to grap DMA2 %d\n", dma2);
     1947                printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2);
    18381948                return -EBUSY;
    18391949        }
     
    19092019                if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_es18xx_micpre1_control, chip))) < 0)
    19102020                        return err;
     2021                break;
    19112022        case 0x1869:
    19122023        case 0x1879:
    19132024                if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_es18xx_micpre2_control, chip))) < 0)
    19142025                        return err;
     2026                break;
    19152027        }
    19162028        if (chip->caps & ES18XX_SPATIALIZER) {
     
    19432055
    19442056EXPORT_NO_SYMBOLS;
     2057MODULE_AUTHOR("Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de>, Abramo Bagnara <abramo@alsa-project.org>"); 
    19452058MODULE_DESCRIPTION("ESS ES18xx AudioDrive");
     2059MODULE_LICENSE("GPL");
    19462060MODULE_CLASSES("{sound}");
    19472061MODULE_DEVICES("{{ESS,ES1868 PnP AudioDrive},"
     
    19512065                "{ESS,ES1887 PnP AudioDrive},"
    19522066                "{ESS,ES1888 PnP AudioDrive},"
    1953                 "{ESS,ES1887 AudioDrive}"
     2067                "{ESS,ES1887 AudioDrive},"
    19542068                "{ESS,ES1888 AudioDrive}}");
    19552069
    19562070static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    19572071static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    1958 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     2072static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    19592073#ifdef __ISAPNP__
    19602074#ifdef TARGET_OS2
     
    20832197                return -EAGAIN;
    20842198        if (acard->devc->activate(acard->devc)<0) {
    2085                 snd_printk("isapnp control configure failure (out of resources?)\n");
     2199                printk(KERN_ERR PFX "isapnp control configure failure (out of resources?)\n");
    20862200                return -EAGAIN;
    20872201        }
     
    21062220                isapnp_resource_change(&pdev->irq_resource[0], snd_irq[dev], 1);
    21072221        if (pdev->activate(pdev)<0) {
    2108                 snd_printk("isapnp configure failure (out of resources?)\n");
     2222                printk(KERN_ERR PFX "isapnp configure failure (out of resources?)\n");
    21092223                acard->devc->deactivate(acard->devc);
    21102224                return -EBUSY;
     
    22222336
    22232337        if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) {
    2224                 snd_printk("opl3 not detected at 0x%lx\n", chip->port);
     2338                printk(KERN_ERR PFX "opl3 not detected at 0x%lx\n", chip->port);
    22252339        } else {
    22262340                if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
     
    22302344        }
    22312345
    2232         if (snd_mpu_port[dev] > SNDRV_AUTO_PORT) {
     2346        if (snd_mpu_port[dev] != SNDRV_AUTO_PORT) {
    22332347                if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
    22342348                                               chip->mpu_port, 0,
     
    22402354                chip->rmidi = rmidi;
    22412355        }
     2356
     2357#ifdef CONFIG_PM
     2358        /* Power Management */
     2359        chip->pm_dev = pm_register(PM_ISA_DEV, 0, snd_es18xx_pm_callback);
     2360        if (chip->pm_dev) {
     2361                chip->pm_dev->data = chip;
     2362                /* set control api callback */
     2363                card->set_power_state = snd_es18xx_set_power_state;
     2364                card->power_state_private_data = chip;
     2365        }
     2366#endif
    22422367        sprintf(card->driver, "ES%x", chip->version);
    22432368        sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version);
     
    23232448        if(!cards) {
    23242449#ifdef MODULE
    2325                 snd_printk("ESS AudioDrive ES18xx soundcard not found or device busy\n");
     2450                printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n");
    23262451#endif
    23272452                return -ENODEV;
     
    23432468#ifndef MODULE
    23442469
    2345 /* format is: snd-card-es18xx=snd_enable,snd_index,snd_id,snd_isapnp,
     2470/* format is: snd-es18xx=snd_enable,snd_index,snd_id,snd_isapnp,
    23462471                              snd_port,snd_mpu_port,snd_fm_port,snd_irq,
    23472472                              snd_dma1,snd_dma2 */
     
    23722497}
    23732498
    2374 __setup("snd-card-es18xx=", alsa_card_es18xx_setup);
     2499__setup("snd-es18xx=", alsa_card_es18xx_setup);
    23752500
    23762501#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gus_pcm.c

    r32 r92  
    2222 *   You should have received a copy of the GNU General Public License
    2323 *   along with this program; if not, write to the Free Software
    24  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     24 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2525 *
    2626 */
    2727
     28#define __NO_VERSION__
    2829#include <sound/driver.h>
     30#include <asm/dma.h>
     31#include <linux/slab.h>
     32#include <sound/core.h>
    2933#include <sound/control.h>
    3034#include <sound/gus.h>
     
    9195        block.addr = addr & ~31;
    9296        block.buffer = runtime->dma_area + offset;
     97        block.buf_addr = runtime->dma_addr + offset;
    9398        block.count = count;
    9499        block.private_data = pcmp;
     
    582587        snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */
    583588        snd_gf1_i_look8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL);     /* Sampling Control Register */
    584         snd_dma_program(gus->gf1.dma2, &runtime->dma_area, gus->c_period_size, DMA_MODE_READ);
     589        snd_dma_program(gus->gf1.dma2, runtime->dma_addr, gus->c_period_size, DMA_MODE_READ);
    585590        return 0;
    586591}
     
    925930        snd_pcm_t *pcm;
    926931        snd_pcm_substream_t *substream;
    927         int err;
     932        int capture, err;
    928933
    929934        if (rpcm)
    930935                *rpcm = NULL;
    931936        card = gus->card;
     937        capture = !gus->interwave && !gus->ess_flag && !gus->ace_flag ? 1 : 0;
    932938        err = snd_pcm_new(card,
    933939                          gus->interwave ? "AMD InterWave" : "GF1",
    934940                          pcm_dev,
    935941                          gus->gf1.pcm_channels / 2,
    936                           !gus->interwave && !gus->ess_flag ? 1 : 0,
     942                          capture,
    937943                          &pcm);
    938944        if (err < 0)
     
    944950
    945951        for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
    946                 snd_pcm_lib_preallocate_pages(substream, 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024, GFP_KERNEL|GFP_DMA);
     952                snd_pcm_lib_preallocate_isa_pages(substream, 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024);
    947953       
    948954        pcm->info_flags = 0;
    949955        pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
    950         if (gus->interwave && !gus->ess_flag && !gus->ace_flag) {
    951                 /* capture setup */
     956        if (capture) {
    952957                snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_gf1_pcm_capture_ops);
    953958                if (gus->gf1.dma2 == gus->gf1.dma1)
    954959                        pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX;
    955                 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024, GFP_KERNEL|GFP_DMA);
     960                snd_pcm_lib_preallocate_isa_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024);
    956961        }
    957962        strcpy(pcm->name, pcm->id);
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gusclassic.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <asm/dma.h>
     24#include <linux/init.h>
     25#include <linux/delay.h>
     26#include <linux/time.h>
     27#include <sound/core.h>
    2428#include <sound/gus.h>
    2529#define SNDRV_LEGACY_AUTO_PROBE
     
    3034
    3135EXPORT_NO_SYMBOLS;
     36
     37MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3238MODULE_DESCRIPTION("Gravis UltraSound Classic");
     39MODULE_LICENSE("GPL");
    3340MODULE_CLASSES("{sound}");
    3441MODULE_DEVICES("{{Gravis,UltraSound Classic}}");
     
    252259        if (!cards) {
    253260#ifdef MODULE
    254                 snd_printk("GUS Classic soundcard not found or device busy\n");
     261                printk(KERN_ERR "GUS Classic soundcard not found or device busy\n");
    255262#endif
    256263                return -ENODEV;
     
    272279#ifndef MODULE
    273280
    274 /* format is: snd-card-gusclassic=snd_enable,snd_index,snd_id,
     281/* format is: snd-gusclassic=snd_enable,snd_index,snd_id,
    275282                                  snd_port,snd_irq,
    276283                                  snd_dma1,snd_dma2,
     
    298305}
    299306
    300 __setup("snd-card-gusclassic=", alsa_card_gusclassic_setup);
     307__setup("snd-gusclassic=", alsa_card_gusclassic_setup);
    301308
    302309#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gusextreme.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <asm/dma.h>
     24#include <linux/init.h>
     25#include <linux/delay.h>
     26#include <linux/time.h>
     27#include <sound/core.h>
    2428#include <sound/gus.h>
    2529#include <sound/es1688.h>
     
    3337
    3438EXPORT_NO_SYMBOLS;
     39
     40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3541MODULE_DESCRIPTION("Gravis UltraSound Extreme");
     42MODULE_LICENSE("GPL");
    3643MODULE_CLASSES("{sound}");
    3744MODULE_DEVICES("{{Gravis,UltraSound Extreme}}");
     
    322329        if (snd_opl3_create(card, es1688->port, es1688->port + 2,
    323330                            OPL3_HW_OPL3, 0, &opl3) < 0) {
    324                 snd_printk("opl3 not detected at 0x%lx\n", es1688->port);
     331                printk(KERN_ERR "gusextreme: opl3 not detected at 0x%lx\n", es1688->port);
    325332        } else {
    326333                if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) {
     
    382389        if (!cards) {
    383390#ifdef MODULE
    384                 snd_printk("GUS Extreme soundcard not found or device busy\n");
     391                printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n");
    385392#endif
    386393                return -ENODEV;
     
    409416#ifndef MODULE
    410417
    411 /* format is: snd-card-gusextreme=snd_enable,snd_index,snd_id,
     418/* format is: snd-gusextreme=snd_enable,snd_index,snd_id,
    412419                                  snd_port,snd_gf1_port,snd_mpu_port,
    413420                                  snd_irq,snd_gf1_irq,snd_mpu_irq,
     
    437444}
    438445
    439 __setup("snd-card-gusextreme=", alsa_card_gusextreme_setup);
     446__setup("snd-gusextreme=", alsa_card_gusextreme_setup);
    440447
    441448#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gusmax.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <asm/dma.h>
     24#include <linux/init.h>
     25#include <linux/delay.h>
     26#include <linux/time.h>
     27#include <sound/core.h>
    2428#include <sound/gus.h>
    2529#include <sound/cs4231.h>
     
    3135
    3236EXPORT_NO_SYMBOLS;
     37
     38MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3339MODULE_DESCRIPTION("Gravis UltraSound MAX");
     40MODULE_LICENSE("GPL");
    3441MODULE_CLASSES("{sound}");
    3542MODULE_DEVICES("{{Gravis,UltraSound MAX}}");
     
    293300        if (!gus->max_flag) {
    294301                snd_card_free(card);
    295                 snd_printk("GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port);
     302                printk(KERN_ERR "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port);
    296303                return -ENODEV;
    297304        }
     
    299306        if (request_irq(irq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) {
    300307                snd_card_free(card);
    301                 snd_printk("unable to grab IRQ %d\n", irq);
     308                printk(KERN_ERR "gusmax: unable to grab IRQ %d\n", irq);
    302309                return -EBUSY;
    303310        }
     
    388395        if (!cards) {
    389396#ifdef MODULE
    390                 snd_printk("GUS MAX soundcard not found or device busy\n");
     397                printk(KERN_ERR "GUS MAX soundcard not found or device busy\n");
    391398#endif
    392399                return -ENODEV;
     
    408415#ifndef MODULE
    409416
    410 /* format is: snd-card-gusmax=snd_enable,snd_index,snd_id,
     417/* format is: snd-gusmax=snd_enable,snd_index,snd_id,
    411418                              snd_port,snd_irq,
    412419                              snd_dma1,snd_dma2,
     
    434441}
    435442
    436 __setup("snd-card-gusmax=", alsa_card_gusmax_setup);
     443__setup("snd-gusmax=", alsa_card_gusmax_setup);
    437444
    438445#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/gus/interwave.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 *   1999/07/22         Erik Inge Bolso <knan@mo.himolde.no>
     
    2323 */
    2424
    25 #define SNDRV_MAIN_OBJECT_FILE
    2625#include <sound/driver.h>
     26#include <asm/dma.h>
     27#include <linux/delay.h>
     28#include <linux/init.h>
     29#include <linux/slab.h>
     30#ifndef LINUX_ISAPNP_H
     31#include <linux/isapnp.h>
     32#define isapnp_card pci_bus
     33#define isapnp_dev pci_dev
     34#endif
     35#include <sound/core.h>
    2736#include <sound/gus.h>
    2837#include <sound/cs4231.h>
     
    3746
    3847EXPORT_NO_SYMBOLS;
     48MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     49MODULE_CLASSES("{sound}");
     50MODULE_LICENSE("GPL");
    3951#ifndef SNDRV_STB
    4052MODULE_DESCRIPTION("AMD InterWave");
    41 MODULE_CLASSES("{sound}");
    4253MODULE_DEVICES("{{Gravis,UltraSound Plug & Play},"
    4354                "{STB,SoundRage32},"
     
    4758#else
    4859MODULE_DESCRIPTION("AMD InterWave STB with TEA6330T");
    49 MODULE_CLASSES("{sound}");
    5060MODULE_DEVICES("{{AMD,InterWave STB with TEA6330T}}");
    5161#endif
     
    5363static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    5464static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    55 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     65static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    5666#ifdef __ISAPNP__
    5767#ifdef TARGET_OS2
     
    212222}
    213223
    214 static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus)
     224static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus)
    215225{
    216226        unsigned long port = bus->private_value;
    217227        unsigned char res;
    218228
     229        res = inb(port) & 1;
     230#if 0
     231        printk("i2c_getclockline - 0x%lx -> %i\n", port, res);
     232#endif
     233        return res;
     234}
     235
     236static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack)
     237{
     238        unsigned long port = bus->private_value;
     239        unsigned char res;
     240
     241        if (ack)
     242                udelay(10);
    219243        res = (inb(port) & 2) >> 1;
    220244#if 0
     
    224248}
    225249
     250static snd_i2c_bit_ops_t snd_interwave_i2c_bit_ops = {
     251        setlines: snd_interwave_i2c_setlines,
     252        getclock: snd_interwave_i2c_getclockline,
     253        getdata:  snd_interwave_i2c_getdataline,
     254};
     255
    226256static int __init snd_interwave_detect_stb(struct snd_interwave *iwcard,
    227257                                           snd_gus_card_t * gus, int dev,
     
    231261        snd_i2c_bus_t *bus;
    232262        snd_card_t *card = iwcard->card;
    233         unsigned long flags;
    234263        char name[32];
    235264        int err;
     
    254283        }
    255284        sprintf(name, "InterWave-%i", card->number);
    256         if ((err = snd_i2c_bus_create(card, name, &bus)) < 0)
     285        if ((err = snd_i2c_bus_create(card, name, NULL, &bus)) < 0)
    257286                return err;
    258287        bus->private_value = port;
    259         bus->i2c_setlines = snd_interwave_i2c_setlines;
    260         bus->i2c_getdataline = snd_interwave_i2c_getdataline;
    261         SNDRV_LOCK_I2C_BUS(bus);
    262         snd_i2c_reset(bus);
    263 #if 0
    264         {
    265                 int idx, ack;
    266                 for (idx = 0; idx < 256; idx += 2) {
    267                         snd_i2c_start(bus);
    268                         ack = snd_i2c_sendbyte(bus, idx, 0);
    269                         snd_i2c_stop(bus);
    270                         if (!ack) {
    271                                 printk("i2c: scanning bus %s: found device at addr=0x%x\n",
    272                                        bus->name, idx);
    273                         }
    274                 }
    275         }
    276 #endif
    277         SNDRV_UNLOCK_I2C_BUS(bus);
     288        bus->hw_ops.bit = &snd_interwave_i2c_bit_ops;
    278289        if ((err = snd_tea6330t_detect(bus, 0)) < 0)
    279290                return err;
     
    707718#endif
    708719#ifdef SNDRV_STB
    709         if (iwcard->i2c_res)
     720        if (iwcard->i2c_res) {
    710721                release_resource(iwcard->i2c_res);
     722                kfree_nocheck(iwcard->i2c_res);
     723        }
    711724#endif
    712725        if (iwcard->irq >= 0)
     
    961974                }
    962975#ifdef MODULE
    963                 snd_printk("InterWave soundcard #%i not found at 0x%lx or device busy\n", dev, snd_port[dev]);
     976                printk(KERN_ERR "InterWave soundcard #%i not found at 0x%lx or device busy\n", dev, snd_port[dev]);
    964977#endif
    965978        }
     
    973986        if (!cards) {
    974987#ifdef MODULE
    975                 snd_printk("InterWave soundcard not found or device busy\n");
     988                printk(KERN_ERR "InterWave soundcard not found or device busy\n");
    976989#endif
    977990                return -ENODEV;
     
    9931006#ifndef MODULE
    9941007
    995 /* format is: snd-card-interwave=snd_enable,snd_index,snd_id,snd_isapnp,
     1008/* format is: snd-interwave=snd_enable,snd_index,snd_id,snd_isapnp,
    9961009                                 snd_port[,snd_port_tc],snd_irq,
    9971010                                 snd_dma1,snd_dma2,
     
    10301043
    10311044#ifndef SNDRV_STB
    1032 __setup("snd-card-interwave=", alsa_card_interwave_setup);
    1033 #else
    1034 __setup("snd-card-interwave-stb=", alsa_card_interwave_setup);
     1045__setup("snd-interwave=", alsa_card_interwave_setup);
     1046#else
     1047__setup("snd-interwave-stb=", alsa_card_interwave_setup);
    10351048#endif
    10361049
  • GPL/branches/alsa-resync1/alsa-kernel/isa/opl3sa2.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <asm/io.h>
     24#include <linux/init.h>
     25#include <linux/pm.h>
     26#include <linux/slab.h>
     27#ifndef LINUX_ISAPNP_H
     28#include <linux/isapnp.h>
     29#define isapnp_card pci_bus
     30#define isapnp_dev pci_dev
     31#endif
     32#include <sound/core.h>
    2433#include <sound/cs4231.h>
    2534#include <sound/mpu401.h>
     
    2938
    3039EXPORT_NO_SYMBOLS;
     40
     41MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3142MODULE_DESCRIPTION("Yamaha OPL3SA2+");
     43MODULE_LICENSE("GPL");
    3244MODULE_CLASSES("{sound}");
    3345MODULE_DEVICES("{{Yamaha,YMF719E-S},"
     
    3951static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    4052static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    41 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     53static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    4254#ifdef __ISAPNP__
    4355#ifdef TARGET_OS2
     
    101113MODULE_PARM_SYNTAX(snd_opl3sa3_ymode, SNDRV_ENABLED ",allows:{{0,3}},dialog:list");  /* SL Added */
    102114
    103 struct snd_opl3sa {
     115/* control ports */
     116#define OPL3SA2_PM_CTRL         0x01
     117#define OPL3SA2_SYS_CTRL                0x02
     118#define OPL3SA2_IRQ_CONFIG      0x03
     119#define OPL3SA2_IRQ_STATUS      0x04
     120#define OPL3SA2_DMA_CONFIG      0x06
     121#define OPL3SA2_MASTER_LEFT     0x07
     122#define OPL3SA2_MASTER_RIGHT    0x08
     123#define OPL3SA2_MIC             0x09
     124#define OPL3SA2_MISC            0x0A
     125
     126/* opl3sa3 only */
     127#define OPL3SA3_DGTL_DOWN       0x12
     128#define OPL3SA3_ANLG_DOWN       0x13
     129#define OPL3SA3_WIDE            0x14
     130#define OPL3SA3_BASS            0x15
     131#define OPL3SA3_TREBLE          0x16
     132
     133/* power management bits */
     134#define OPL3SA2_PM_ADOWN                0x20
     135#define OPL3SA2_PM_PSV          0x04           
     136#define OPL3SA2_PM_PDN          0x02
     137#define OPL3SA2_PM_PDX          0x01
     138
     139#define OPL3SA2_PM_D0   0x00
     140#define OPL3SA2_PM_D3   (OPL3SA2_PM_ADOWN|OPL3SA2_PM_PSV|OPL3SA2_PM_PDN|OPL3SA2_PM_PDX)
     141
     142typedef struct snd_opl3sa2 opl3sa2_t;
     143#define chip_t opl3sa2_t
     144
     145struct snd_opl3sa2 {
    104146        snd_card_t *card;
    105147        int version;            /* 2 or 3 */
     
    119161        snd_kcontrol_t *master_switch;
    120162        snd_kcontrol_t *master_volume;
     163#ifdef CONFIG_PM
     164        struct pm_dev *pm_dev;
     165        void (*cs4231_suspend)(cs4231_t *);
     166        void (*cs4231_resume)(cs4231_t *);
     167#endif
    121168};
    122169
    123 static snd_card_t *snd_opl3sa_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
     170static snd_card_t *snd_opl3sa2_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
    124171
    125172#ifdef __ISAPNP__
     
    159206#endif /* __ISAPNP__ */
    160207
    161 static unsigned char snd_opl3sa_read(unsigned long port, unsigned char reg)
    162 {
    163         unsigned long flags;
     208
     209/* read control port (w/o spinlock) */
     210static unsigned char __snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg)
     211{
    164212        unsigned char result;
    165 
    166         save_flags(flags);
    167         cli();
    168213#if 0
    169214        outb(0x1d, port);       /* password */
    170215        printk("read [0x%lx] = 0x%x\n", port, inb(port));
    171216#endif
    172         outb(reg, port);        /* register */
    173         result = inb(port + 1);
    174         restore_flags(flags);
     217        outb(reg, chip->port);  /* register */
     218        result = inb(chip->port + 1);
    175219#if 0
    176220        printk("read [0x%lx] = 0x%x [0x%x]\n", port, result, inb(port));
     
    179223}
    180224
    181 static void snd_opl3sa_write(unsigned long port,
    182                              unsigned char reg, unsigned char value)
     225/* read control port (with spinlock) */
     226static unsigned char snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg)
    183227{
    184228        unsigned long flags;
    185 
    186         save_flags(flags);
    187         cli();
     229        unsigned char result;
     230
     231        spin_lock_irqsave(&chip->reg_lock, flags);
     232        result = __snd_opl3sa2_read(chip, reg);
     233        spin_unlock_irqrestore(&chip->reg_lock, flags);
     234        return result;
     235}
     236
     237/* write control port (w/o spinlock) */
     238static void __snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value)
     239{
    188240#if 0
    189241        outb(0x1d, port);       /* password */
    190242#endif
    191         outb(reg, port);        /* register */
    192         outb(value, port + 1);
    193         restore_flags(flags);
    194 }
    195 
    196 static int __init snd_opl3sa_detect(struct snd_opl3sa *oplcard)
     243        outb(reg, chip->port);  /* register */
     244        outb(value, chip->port + 1);
     245        chip->ctlregs[reg] = value;
     246}
     247
     248/* write control port (with spinlock) */
     249static void snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value)
     250{
     251        unsigned long flags;
     252        spin_lock_irqsave(&chip->reg_lock, flags);
     253        __snd_opl3sa2_write(chip, reg, value);
     254        spin_unlock_irqrestore(&chip->reg_lock, flags);
     255}
     256
     257static int __init snd_opl3sa2_detect(opl3sa2_t *chip)
    197258{
    198259        snd_card_t *card;
     
    201262        char str[2];
    202263
    203         card = oplcard->card;
    204         port = oplcard->port;
    205         if ((oplcard->res_port = request_region(port, 2, "OPL3-SA control")) == NULL)
     264        card = chip->card;
     265        port = chip->port;
     266        if ((chip->res_port = request_region(port, 2, "OPL3-SA control")) == NULL)
    206267                return -EBUSY;
    207         // snd_printk("REG 0A = 0x%x\n", snd_opl3sa_read(port, 0x0a));
    208         oplcard->version = 0;
    209         tmp = snd_opl3sa_read(port, 0x0a);
     268        // snd_printk("REG 0A = 0x%x\n", snd_opl3sa2_read(chip, 0x0a));
     269        chip->version = 0;
     270        tmp = snd_opl3sa2_read(chip, OPL3SA2_MISC);
    210271        if (tmp == 0xff) {
    211272                snd_printd("OPL3-SA [0x%lx] detect = 0x%x\n", port, tmp);
     
    214275        switch (tmp & 0x07) {
    215276        case 0x01:
    216                 oplcard->version = 2;
     277                chip->version = 2; /* YMF711 */
    217278                break;
    218279        default:
    219                 oplcard->version = 3;
     280                chip->version = 3;
    220281                /* 0x02 - standard */
    221282                /* 0x03 - YM715B */
     
    224285                break;
    225286        }
    226         str[0] = oplcard->version + '0';
     287        str[0] = chip->version + '0';
    227288        str[1] = 0;
    228289        strcat(card->shortname, str);
    229         snd_opl3sa_write(port, 0x0a, tmp ^ 7);
    230         if ((tmp1 = snd_opl3sa_read(port, 0x0a)) != tmp) {
     290        snd_opl3sa2_write(chip, OPL3SA2_MISC, tmp ^ 7);
     291        if ((tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MISC)) != tmp) {
    231292                snd_printd("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n", port, tmp, tmp1);
    232293                return -ENODEV;
    233294        }
    234295        /* try if the MIC register is accesible */
    235         tmp = snd_opl3sa_read(port, 0x09);
    236         snd_opl3sa_write(port, 0x09, 0x8a);
    237         if (((tmp1 = snd_opl3sa_read(port, 0x09)) & 0x9f) != 0x8a) {
     296        tmp = snd_opl3sa2_read(chip, OPL3SA2_MIC);
     297        snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x8a);
     298        if (((tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MIC)) & 0x9f) != 0x8a) {
    238299                snd_printd("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n", port, tmp, tmp1);
    239300                return -ENODEV;
    240301        }
    241         snd_opl3sa_write(port, 0x09, 0x9f);
     302        snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x9f);
    242303        /* initialization */
    243         snd_opl3sa_write(port, 0x01, 0x00);     /* Power Management - default */
    244         if (oplcard->version > 2) {   /* SL Added */
    245                 snd_opl3sa_write(port, 0x02, (oplcard->ymode << 4)); /* SL Modified - System Control - ymode is bits 4&5 (of 0 to 7) on all but opl3sa2 versions */
    246         } else { /* SL Added */
    247                 snd_opl3sa_write(port, 0x02, 0x00);     /* SL Modified - System Control - default for opl3sa2 versions */
    248         } /* SL Added */
    249         snd_opl3sa_write(port, 0x03, 0x0d);     /* Interrupt Channel Configuration - IRQ A = OPL3 + MPU + WSS */
    250         if (oplcard->single_dma) {
    251                 snd_opl3sa_write(port, 0x06, 0x03);     /* DMA Configuration - DMA A = WSS-R + WSS-P */
     304        /* Power Management - full on */
     305        snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0);
     306        if (chip->version > 2) {
     307                /* ymode is bits 4&5 (of 0 to 7) on all but opl3sa2 versions */
     308                snd_opl3sa2_write(chip, OPL3SA2_SYS_CTRL, (chip->ymode << 4));
    252309        } else {
    253                 snd_opl3sa_write(port, 0x06, 0x21);     /* DMA Configuration - DMA B = WSS-R, DMA A = WSS-P */
    254         }
    255         snd_opl3sa_write(port, 0x0a, 0x80 | (tmp & 7)); /* Miscellaneous - default */
    256         if (oplcard->version > 2) {
    257                 snd_opl3sa_write(port, 0x12, 0x00);     /* Digital Block Partial Power Down - default */
    258                 snd_opl3sa_write(port, 0x13, 0x00);     /* Analog Block Partial Power Down - default */
    259         }
    260         return 0;
    261 }
    262 
    263 static void snd_opl3sa_interrupt(int irq, void *dev_id, struct pt_regs *regs)
     310                /* default for opl3sa2 versions */
     311                snd_opl3sa2_write(chip, OPL3SA2_SYS_CTRL, 0x00);
     312        }
     313        snd_opl3sa2_write(chip, OPL3SA2_IRQ_CONFIG, 0x0d);      /* Interrupt Channel Configuration - IRQ A = OPL3 + MPU + WSS */
     314        if (chip->single_dma) {
     315                snd_opl3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x03);      /* DMA Configuration - DMA A = WSS-R + WSS-P */
     316        } else {
     317                snd_opl3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x21);      /* DMA Configuration - DMA B = WSS-R, DMA A = WSS-P */
     318        }
     319        snd_opl3sa2_write(chip, OPL3SA2_MISC, 0x80 | (tmp & 7));        /* Miscellaneous - default */
     320        if (chip->version > 2) {
     321                snd_opl3sa2_write(chip, OPL3SA3_DGTL_DOWN, 0x00);       /* Digital Block Partial Power Down - default */
     322                snd_opl3sa2_write(chip, OPL3SA3_ANLG_DOWN, 0x00);       /* Analog Block Partial Power Down - default */
     323        }
     324        return 0;
     325}
     326
     327static void snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    264328{
    265329        unsigned short status;
    266         struct snd_opl3sa *oplcard = (struct snd_opl3sa *) dev_id;
    267 
    268         if (oplcard == NULL || oplcard->card == NULL)
     330        opl3sa2_t *chip = dev_id;
     331
     332        if (chip == NULL || chip->card == NULL)
    269333                return;
    270334
    271         spin_lock(&oplcard->reg_lock);
    272         outb(0x04, oplcard->port);      /* register - Interrupt IRQ-A status */
    273         status = inb(oplcard->port + 1);
    274         spin_unlock(&oplcard->reg_lock);
     335        status = snd_opl3sa2_read(chip, OPL3SA2_IRQ_STATUS);
    275336
    276337        if (status & 0x20)
    277                 snd_opl3_interrupt(oplcard->synth);
    278 
    279         if ((status & 0x10) && oplcard->rmidi != NULL)
    280                 snd_mpu401_uart_interrupt(irq, oplcard->rmidi->private_data, regs);
     338                snd_opl3_interrupt(chip->synth);
     339
     340        if ((status & 0x10) && chip->rmidi != NULL)
     341                snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
    281342
    282343        if (status & 0x07)      /* TI,CI,PI */
    283                 snd_cs4231_interrupt(irq, oplcard->cs4231, regs);
    284 
    285         if (status & 0x40) {
     344                snd_cs4231_interrupt(irq, chip->cs4231, regs);
     345
     346        if (status & 0x40) { /* hardware volume change */
    286347                /* reading from Master Lch register at 0x07 clears this bit */
    287                 snd_opl3sa_read(oplcard->port, 0x08);
    288                 snd_opl3sa_read(oplcard->port, 0x07);
    289                 snd_ctl_notify(oplcard->card, SNDRV_CTL_EVENT_MASK_VALUE, &oplcard->master_switch->id);
    290                 snd_ctl_notify(oplcard->card, SNDRV_CTL_EVENT_MASK_VALUE, &oplcard->master_volume->id);
     348                snd_opl3sa2_read(chip, OPL3SA2_MASTER_RIGHT);
     349                snd_opl3sa2_read(chip, OPL3SA2_MASTER_LEFT);
     350                if (chip->master_switch && chip->master_volume) {
     351                        snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id);
     352                        snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id);
     353                }
    291354        }
    292355}
    293356
    294357#ifdef TARGET_OS2
    295 #define OPL3SA_SINGLE(xname, xindex, reg, shift, mask, invert) \
     358#define OPL3SA2_SINGLE(xname, xindex, reg, shift, mask, invert) \
    296359{ SNDRV_CTL_ELEM_IFACE_MIXER, 0, 0, xname, xindex, \
    297   0, 0, snd_opl3sa_info_single, \
    298   snd_opl3sa_get_single, snd_opl3sa_put_single, \
     360  0, 0, snd_opl3sa2_info_single, \
     361  snd_opl3sa2_get_single, snd_opl3sa2_put_single, \
    299362  reg | (shift << 8) | (mask << 16) | (invert << 24) }
    300363
    301364#else
    302 #define OPL3SA_SINGLE(xname, xindex, reg, shift, mask, invert) \
     365#define OPL3SA2_SINGLE(xname, xindex, reg, shift, mask, invert) \
    303366{ iface: SNDRV_CTL_ELEM_IFACE_MIXER, name: xname, index: xindex, \
    304   info: snd_opl3sa_info_single, \
    305   get: snd_opl3sa_get_single, put: snd_opl3sa_put_single, \
     367  info: snd_opl3sa2_info_single, \
     368  get: snd_opl3sa2_get_single, put: snd_opl3sa2_put_single, \
    306369  private_value: reg | (shift << 8) | (mask << 16) | (invert << 24) }
    307370#endif
    308371
    309 static int snd_opl3sa_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     372static int snd_opl3sa2_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    310373{
    311374        int mask = (kcontrol->private_value >> 16) & 0xff;
     
    318381}
    319382
    320 int snd_opl3sa_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
    321 {
    322         struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
     383int snd_opl3sa2_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     384{
     385        opl3sa2_t *chip = snd_kcontrol_chip(kcontrol);
    323386        unsigned long flags;
    324387        int reg = kcontrol->private_value & 0xff;
     
    327390        int invert = (kcontrol->private_value >> 24) & 0xff;
    328391
    329         spin_lock_irqsave(&oplcard->reg_lock, flags);
    330         ucontrol->value.integer.value[0] = (oplcard->ctlregs[reg] >> shift) & mask;
    331         spin_unlock_irqrestore(&oplcard->reg_lock, flags);
     392        spin_lock_irqsave(&chip->reg_lock, flags);
     393        ucontrol->value.integer.value[0] = (chip->ctlregs[reg] >> shift) & mask;
     394        spin_unlock_irqrestore(&chip->reg_lock, flags);
    332395        if (invert)
    333396                ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
     
    335398}
    336399
    337 int snd_opl3sa_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
    338 {
    339         struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
     400int snd_opl3sa2_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     401{
     402        opl3sa2_t *chip = snd_kcontrol_chip(kcontrol);
    340403        unsigned long flags;
    341404        int reg = kcontrol->private_value & 0xff;
     
    350413                val = mask - val;
    351414        val <<= shift;
    352         spin_lock_irqsave(&oplcard->reg_lock, flags);
    353         oval = oplcard->ctlregs[reg];
     415        spin_lock_irqsave(&chip->reg_lock, flags);
     416        oval = chip->ctlregs[reg];
    354417        val = (oval & ~(mask << shift)) | val;
    355418        change = val != oval;
    356         snd_opl3sa_write(oplcard->port, reg, oplcard->ctlregs[reg] = val);
    357         spin_unlock_irqrestore(&oplcard->reg_lock, flags);
     419        __snd_opl3sa2_write(chip, reg, val);
     420        spin_unlock_irqrestore(&chip->reg_lock, flags);
    358421        return change;
    359422}
    360423
    361424#ifdef TARGET_OS2
    362 #define OPL3SA_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
     425#define OPL3SA2_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
    363426{ SNDRV_CTL_ELEM_IFACE_MIXER, 0, 0, xname, xindex, \
    364   0, 0, snd_opl3sa_info_double, \
    365   snd_opl3sa_get_double, snd_opl3sa_put_double, \
     427  0, 0, snd_opl3sa2_info_double, \
     428  snd_opl3sa2_get_double, snd_opl3sa2_put_double, \
    366429  left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
    367430
    368431#else
    369 #define OPL3SA_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
     432#define OPL3SA2_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
    370433{ iface: SNDRV_CTL_ELEM_IFACE_MIXER, name: xname, index: xindex, \
    371   info: snd_opl3sa_info_double, \
    372   get: snd_opl3sa_get_double, put: snd_opl3sa_put_double, \
     434  info: snd_opl3sa2_info_double, \
     435  get: snd_opl3sa2_get_double, put: snd_opl3sa2_put_double, \
    373436  private_value: left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
    374437#endif
    375438
    376 int snd_opl3sa_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     439int snd_opl3sa2_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
    377440{
    378441        int mask = (kcontrol->private_value >> 24) & 0xff;
     
    385448}
    386449
    387 int snd_opl3sa_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
    388 {
    389         struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
     450int snd_opl3sa2_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     451{
     452        opl3sa2_t *chip = snd_kcontrol_chip(kcontrol);
    390453        unsigned long flags;
    391454        int left_reg = kcontrol->private_value & 0xff;
     
    396459        int invert = (kcontrol->private_value >> 22) & 1;
    397460       
    398         spin_lock_irqsave(&oplcard->reg_lock, flags);
    399         ucontrol->value.integer.value[0] = (oplcard->ctlregs[left_reg] >> shift_left) & mask;
    400         ucontrol->value.integer.value[1] = (oplcard->ctlregs[right_reg] >> shift_right) & mask;
    401         spin_unlock_irqrestore(&oplcard->reg_lock, flags);
     461        spin_lock_irqsave(&chip->reg_lock, flags);
     462        ucontrol->value.integer.value[0] = (chip->ctlregs[left_reg] >> shift_left) & mask;
     463        ucontrol->value.integer.value[1] = (chip->ctlregs[right_reg] >> shift_right) & mask;
     464        spin_unlock_irqrestore(&chip->reg_lock, flags);
    402465        if (invert) {
    403466                ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
     
    407470}
    408471
    409 int snd_opl3sa_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
    410 {
    411         struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
     472int snd_opl3sa2_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
     473{
     474        opl3sa2_t *chip = snd_kcontrol_chip(kcontrol);
    412475        unsigned long flags;
    413476        int left_reg = kcontrol->private_value & 0xff;
     
    428491        val1 <<= shift_left;
    429492        val2 <<= shift_right;
    430         spin_lock_irqsave(&oplcard->reg_lock, flags);
     493        spin_lock_irqsave(&chip->reg_lock, flags);
    431494        if (left_reg != right_reg) {
    432                 oval1 = oplcard->ctlregs[left_reg];
    433                 oval2 = oplcard->ctlregs[right_reg];
     495                oval1 = chip->ctlregs[left_reg];
     496                oval2 = chip->ctlregs[right_reg];
    434497                val1 = (oval1 & ~(mask << shift_left)) | val1;
    435498                val2 = (oval2 & ~(mask << shift_right)) | val2;
    436499                change = val1 != oval1 || val2 != oval2;
    437                 snd_opl3sa_write(oplcard->port, left_reg, oplcard->ctlregs[left_reg] = val1);
    438                 snd_opl3sa_write(oplcard->port, right_reg, oplcard->ctlregs[right_reg] = val2);
     500                __snd_opl3sa2_write(chip, left_reg, val1);
     501                __snd_opl3sa2_write(chip, right_reg, val2);
    439502        } else {
    440                 oval1 = oplcard->ctlregs[left_reg];
     503                oval1 = chip->ctlregs[left_reg];
    441504                val1 = (oval1 & ~((mask << shift_left) | (mask << shift_right))) | val1 | val2;
    442505                change = val1 != oval1;
    443                 snd_opl3sa_write(oplcard->port, left_reg, oplcard->ctlregs[left_reg] = val1);
    444         }
    445         spin_unlock_irqrestore(&oplcard->reg_lock, flags);
     506                __snd_opl3sa2_write(chip, left_reg, val1);
     507        }
     508        spin_unlock_irqrestore(&chip->reg_lock, flags);
    446509        return change;
    447510}
    448511
    449 #define OPL3SA_CONTROLS (sizeof(snd_opl3sa_controls)/sizeof(snd_kcontrol_new_t))
    450 
    451 static snd_kcontrol_new_t snd_opl3sa_controls[] = {
    452 OPL3SA_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1),
    453 OPL3SA_DOUBLE("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1),
    454 OPL3SA_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1),
    455 OPL3SA_SINGLE("Mic Playback Volume", 0, 0x09, 0, 31, 1)
     512#define OPL3SA2_CONTROLS (sizeof(snd_opl3sa2_controls)/sizeof(snd_kcontrol_new_t))
     513
     514static snd_kcontrol_new_t snd_opl3sa2_controls[] = {
     515OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1),
     516OPL3SA2_DOUBLE("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1),
     517OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1),
     518OPL3SA2_SINGLE("Mic Playback Volume", 0, 0x09, 0, 31, 1)
    456519};
    457520
    458 #define OPL3SA_TONE_CONTROLS (sizeof(snd_opl3sa_tone_controls)/sizeof(snd_kcontrol_new_t))
    459 
    460 static snd_kcontrol_new_t snd_opl3sa_tone_controls[] = {
    461 OPL3SA_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0),
    462 OPL3SA_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0),
    463 OPL3SA_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0)
     521#define OPL3SA2_TONE_CONTROLS (sizeof(snd_opl3sa2_tone_controls)/sizeof(snd_kcontrol_new_t))
     522
     523static snd_kcontrol_new_t snd_opl3sa2_tone_controls[] = {
     524OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0),
     525OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0),
     526OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0)
    464527};
    465528
    466 static void snd_opl3sa_master_free(snd_kcontrol_t *kcontrol)
    467 {
    468         struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
    469        
    470         oplcard->master_switch = NULL;
    471         oplcard->master_volume = NULL;
    472 }
    473 
    474 static int __init snd_opl3sa_mixer(struct snd_opl3sa *oplcard)
    475 {
    476         snd_card_t *card = oplcard->card;
     529static void snd_opl3sa2_master_free(snd_kcontrol_t *kcontrol)
     530{
     531        opl3sa2_t *chip = _snd_kcontrol_chip(kcontrol);
     532        chip->master_switch = NULL;
     533        chip->master_volume = NULL;
     534}
     535
     536static int __init snd_opl3sa2_mixer(opl3sa2_t *chip)
     537{
     538        snd_card_t *card = chip->card;
    477539        snd_ctl_elem_id_t id1, id2;
    478540        snd_kcontrol_t *kctl;
     
    501563                return err;
    502564        /* add OPL3SA2 controls */
    503         for (idx = 0; idx < OPL3SA_CONTROLS; idx++) {
    504                 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa_controls[idx], oplcard))) < 0)
     565        for (idx = 0; idx < OPL3SA2_CONTROLS; idx++) {
     566                if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0)
    505567                        return err;
    506568                switch (idx) {
    507                 case 0: oplcard->master_switch = kctl; kctl->private_free = snd_opl3sa_master_free; break;
    508                 case 1: oplcard->master_volume = kctl; kctl->private_free = snd_opl3sa_master_free; break;
     569                case 0: chip->master_switch = kctl; kctl->private_free = snd_opl3sa2_master_free; break;
     570                case 1: chip->master_volume = kctl; kctl->private_free = snd_opl3sa2_master_free; break;
    509571                }
    510572        }
    511         if (oplcard->version > 2) {
    512                 for (idx = 0; idx < OPL3SA_TONE_CONTROLS; idx++)
    513                         if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_opl3sa_tone_controls[idx], oplcard))) < 0)
     573        if (chip->version > 2) {
     574                for (idx = 0; idx < OPL3SA2_TONE_CONTROLS; idx++)
     575                        if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_opl3sa2_tone_controls[idx], chip))) < 0)
    514576                                return err;
    515577        }
     
    517579}
    518580
    519 #ifdef __ISAPNP__
    520 static int __init snd_opl3sa_isapnp(int dev, struct snd_opl3sa *oplcard)
     581/* Power Management support functions */
     582#ifdef CONFIG_PM
     583static void snd_opl3sa2_suspend(opl3sa2_t *chip)
     584{
     585        snd_card_t *card = chip->card;
     586
     587        snd_power_lock(card);
     588        if (card->power_state == SNDRV_CTL_POWER_D3hot)
     589                goto __skip;
     590
     591        /* FIXME: is this order ok? */
     592        chip->cs4231_suspend(chip->cs4231);
     593        snd_pcm_suspend_all(chip->cs4231->pcm);
     594
     595        /* power down */
     596        snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3);
     597
     598        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
     599      __skip:
     600        snd_power_unlock(card);
     601}
     602
     603static void snd_opl3sa2_resume(opl3sa2_t *chip)
     604{
     605        snd_card_t *card = chip->card;
     606        int i;
     607
     608        snd_power_lock(card);
     609        if (card->power_state == SNDRV_CTL_POWER_D0)
     610                goto __skip;
     611
     612        /* power up */
     613        snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0);
     614
     615        /* restore registers */
     616        for (i = 2; i <= 0x0a; i++) {
     617                if (i != OPL3SA2_IRQ_STATUS)
     618                        snd_opl3sa2_write(chip, i, chip->ctlregs[i]);
     619        }
     620        if (chip->version > 2) {
     621                for (i = 0x12; i <= 0x16; i++)
     622                        snd_opl3sa2_write(chip, i, chip->ctlregs[i]);
     623        }
     624        /* restore cs4231 */
     625        chip->cs4231_resume(chip->cs4231);
     626
     627        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     628      __skip:
     629        snd_power_unlock(card);
     630}
     631
     632/* callback for control API */
     633static int snd_opl3sa2_set_power_state(snd_card_t *card, unsigned int power_state)
     634{
     635        opl3sa2_t *chip = (opl3sa2_t *) card->pm_private_data;
     636        switch (power_state) {
     637        case SNDRV_CTL_POWER_D0:
     638        case SNDRV_CTL_POWER_D1:
     639        case SNDRV_CTL_POWER_D2:
     640                snd_opl3sa2_resume(chip);
     641                break;
     642        case SNDRV_CTL_POWER_D3hot:
     643        case SNDRV_CTL_POWER_D3cold:
     644                snd_opl3sa2_suspend(chip);
     645                break;
     646        default:
     647                return -EINVAL;
     648        }
     649        return 0;
     650}
     651
     652static int snd_opl3sa2_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data)
     653{
     654        opl3sa2_t *chip = snd_magic_cast(opl3sa2_t, dev->data, return 0);
     655
     656        switch (rqst) {
     657        case PM_SUSPEND:
     658                snd_opl3sa2_suspend(chip);
     659                break;
     660        case PM_RESUME:
     661                snd_opl3sa2_resume(chip);
     662                break;
     663        }
     664        return 0;
     665}
     666
     667#endif /* CONFIG_PM */
     668
     669#ifdef __ISAPNP__
     670static int __init snd_opl3sa2_isapnp(int dev, opl3sa2_t *chip)
    521671{
    522672        const struct isapnp_card_id *id = snd_opl3sa2_isapnp_id[dev];
     
    524674        struct isapnp_dev *pdev;
    525675
    526         oplcard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);
    527         if (oplcard->dev->active) {
    528                 oplcard->dev = NULL;
     676        chip->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);
     677        if (chip->dev->active) {
     678                chip->dev = NULL;
    529679                return -EBUSY;
    530680        }
    531681        /* PnP initialization */
    532         pdev = oplcard->dev;
     682        pdev = chip->dev;
    533683        if (pdev->prepare(pdev)<0)
    534684                return -EAGAIN;
     
    568718}
    569719
    570 static void snd_opl3sa_deactivate(struct snd_opl3sa *oplcard)
    571 {
    572         if (oplcard->dev) {
    573                 oplcard->dev->deactivate(oplcard->dev);
    574                 oplcard->dev = NULL;
     720static void snd_opl3sa2_deactivate(opl3sa2_t *chip)
     721{
     722        if (chip->dev) {
     723                chip->dev->deactivate(chip->dev);
     724                chip->dev = NULL;
    575725        }
    576726}
    577727#endif /* __ISAPNP__ */
    578728
    579 static void snd_card_opl3sa2_free(snd_card_t *card)
    580 {
    581         struct snd_opl3sa *acard = (struct snd_opl3sa *)card->private_data;
    582 
    583         if (acard) {
    584 #ifdef __ISAPNP__
    585                 snd_opl3sa_deactivate(acard);
    586 #endif
    587                 if (acard->irq >= 0)
    588                         free_irq(acard->irq, (void *)acard);
    589                 if (acard->res_port)
    590                         release_resource(acard->res_port);
    591         }
    592 }
    593 
    594 static int __init snd_opl3sa_probe(int dev)
     729static int snd_opl3sa2_free(opl3sa2_t *chip)
     730{
     731#ifdef __ISAPNP__
     732        snd_opl3sa2_deactivate(chip);
     733#endif
     734#ifdef CONFIG_PM
     735        if (chip->pm_dev)
     736                pm_unregister(chip->pm_dev);
     737#endif
     738        if (chip->irq >= 0)
     739                free_irq(chip->irq, (void *)chip);
     740        if (chip->res_port) {
     741                release_resource(chip->res_port);
     742                kfree_nocheck(chip->res_port);
     743        }
     744        snd_magic_kfree(chip);
     745        return 0;
     746}
     747
     748static int snd_opl3sa2_dev_free(snd_device_t *device)
     749{
     750        opl3sa2_t *chip = snd_magic_cast(opl3sa2_t, device->device_data, return -ENXIO);
     751        return snd_opl3sa2_free(chip);
     752}
     753
     754static int __init snd_opl3sa2_probe(int dev)
    595755{
    596756        int irq, dma1, dma2;
    597757        snd_card_t *card;
    598         struct snd_opl3sa *oplcard;
     758        struct snd_opl3sa2 *chip;
    599759        cs4231_t *cs4231;
    600760        opl3_t *opl3;
     761        static snd_device_ops_t ops = {
     762                dev_free:       snd_opl3sa2_dev_free,
     763        };
    601764        int err;
    602765
     
    623786        }
    624787#endif
    625         card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE,
    626                             sizeof(struct snd_opl3sa));
     788        card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE, 0);
    627789        if (card == NULL)
    628790                return -ENOMEM;
    629         oplcard = (struct snd_opl3sa *)card->private_data;
    630         oplcard->irq = -1;
    631         card->private_free = snd_card_opl3sa2_free;
    632791        strcpy(card->driver, "OPL3SA2");
    633792        strcpy(card->shortname, "Yamaha OPL3-SA2");
    634 #ifdef __ISAPNP__
    635         if (snd_isapnp[dev] && snd_opl3sa_isapnp(dev, oplcard) < 0) {
    636                 snd_card_free(card);
    637                 return -EBUSY;
    638         }
    639 #endif
    640         oplcard->ymode = snd_opl3sa3_ymode[dev] & 0x03 ; /* SL Added - initialise this card from supplied (or default) parameter*/
    641         oplcard->card = card;
    642         oplcard->port = snd_port[dev];
     793        chip = snd_magic_kcalloc(opl3sa2_t, 0, GFP_KERNEL);
     794        if (chip == NULL) {
     795                err = -ENOMEM;
     796                goto __error;
     797        }
     798        chip->irq = -1;
     799        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
     800                goto __error;
     801#ifdef __ISAPNP__
     802        if (snd_isapnp[dev] && (err = snd_opl3sa2_isapnp(dev, chip)) < 0)
     803                goto __error;
     804#endif
     805        chip->ymode = snd_opl3sa3_ymode[dev] & 0x03 ; /* initialise this card from supplied (or default) parameter*/
     806        chip->card = card;
     807        chip->port = snd_port[dev];
    643808        irq = snd_irq[dev];
    644809        dma1 = snd_dma1[dev];
    645810        dma2 = snd_dma2[dev];
    646811        if (dma2 < 0)
    647                 oplcard->single_dma = 1;
    648         if ((snd_opl3sa_detect(oplcard)) < 0) {
    649                 snd_card_free(card);
    650                 return -ENODEV;
    651         }
    652         if (request_irq(irq, snd_opl3sa_interrupt, SA_INTERRUPT, "OPL3-SA2/3", (void *)oplcard)) {
    653                 snd_card_free(card);
    654                 return -ENODEV;
    655         }
    656         oplcard->irq = irq;
     812                chip->single_dma = 1;
     813        if ((err = snd_opl3sa2_detect(chip)) < 0)
     814                goto __error;
     815        if (request_irq(irq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2/3", (void *)chip)) {
     816                err = -ENODEV;
     817                goto __error;
     818        }
     819        chip->irq = irq;
    657820        if ((err = snd_cs4231_create(card,
    658821                                     snd_wss_port[dev] + 4, -1,
     
    662825                                     &cs4231)) < 0) {
    663826                snd_printd("Oops, WSS not detected at 0x%lx\n", snd_wss_port[dev] + 4);
    664                 snd_card_free(card);
    665                 return err;
    666         }
    667         oplcard->cs4231 = cs4231;
    668         if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) {
    669                 snd_card_free(card);
    670                 return err;
    671         }
    672         if ((err = snd_cs4231_mixer(cs4231)) < 0) {
    673                 snd_card_free(card);
    674                 return err;
    675         }
    676         if ((err = snd_opl3sa_mixer(oplcard)) < 0) {
    677                 snd_card_free(card);
    678                 return err;
    679         }
    680         if ((err = snd_cs4231_timer(cs4231, 0, NULL)) < 0) {
    681                 snd_card_free(card);
    682                 return err;
    683         }
     827                goto __error;
     828        }
     829        chip->cs4231 = cs4231;
     830        if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0)
     831                goto __error;
     832        if ((err = snd_cs4231_mixer(cs4231)) < 0)
     833                goto __error;
     834        if ((err = snd_opl3sa2_mixer(chip)) < 0)
     835                goto __error;
     836        if ((err = snd_cs4231_timer(cs4231, 0, NULL)) < 0)
     837                goto __error;
    684838        if (snd_fm_port[dev] >= 0x340 && snd_fm_port[dev] < 0x400) {
    685839                if ((err = snd_opl3_create(card, snd_fm_port[dev],
    686840                                           snd_fm_port[dev] + 2,
    687                                            OPL3_HW_OPL3, 0, &opl3)) < 0) {
    688                         snd_card_free(card);
    689                         return err;
    690                 }
    691                 if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0) {
    692                         snd_card_free(card);
    693                         return err;
    694                 }
    695                 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &oplcard->synth)) < 0) {
    696                         snd_card_free(card);
    697                         return err;
    698                 }
     841                                           OPL3_HW_OPL3, 0, &opl3)) < 0)
     842                        goto __error;
     843                if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0)
     844                        goto __error;
     845                if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0)
     846                        goto __error;
    699847        }
    700848        if (snd_midi_port[dev] >= 0x300 && snd_midi_port[dev] < 0x340) {
    701849                if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2,
    702850                                               snd_midi_port[dev], 0,
    703                                                irq, 0, &oplcard->rmidi)) < 0) {
    704                         snd_card_free(card);
    705                         return err;
    706                 }
    707         }
     851                                               irq, 0, &chip->rmidi)) < 0)
     852                        goto __error;
     853        }
     854#ifdef CONFIG_PM
     855        /* Power Management */
     856        chip->pm_dev = pm_register(PM_ISA_DEV, 0, snd_opl3sa2_pm_callback);
     857        if (chip->pm_dev) {
     858                chip->pm_dev->data = chip;
     859                /* remember callbacks for cs4231 - they are called inside
     860                 * opl3sa2 pm callback
     861                 */
     862                chip->cs4231_suspend = chip->cs4231->suspend;
     863                chip->cs4231_resume = chip->cs4231->resume;
     864                /* now clear callbacks for cs4231 */
     865                chip->cs4231->suspend = NULL;
     866                chip->cs4231->resume = NULL;
     867                /* set control api callback */
     868                card->set_power_state = snd_opl3sa2_set_power_state;
     869                card->pm_private_data = chip;
     870        }
     871#endif
     872
    708873        sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
    709                 card->shortname, oplcard->port, irq, dma1);
     874                card->shortname, chip->port, irq, dma1);
    710875        if (dma2 >= 0)
    711876                sprintf(card->longname + strlen(card->longname), "&%d", dma2);
    712877
    713         if ((err = snd_card_register(card)) < 0) {
    714                 snd_card_free(card);
    715                 return err;
    716         }
    717         snd_opl3sa_cards[dev] = card;
    718         return 0;
     878        if ((err = snd_card_register(card)) < 0)
     879                goto __error;
     880
     881        snd_opl3sa2_cards[dev] = card;
     882        return 0;
     883
     884 __error:
     885        snd_card_free(card);
     886        return err;
    719887}
    720888
     
    731899                snd_opl3sa2_isapnp_cards[dev] = card;
    732900                snd_opl3sa2_isapnp_id[dev] = id;
    733                 res = snd_opl3sa_probe(dev);
     901                res = snd_opl3sa2_probe(dev);
    734902                if (res < 0)
    735903                        return res;
     
    752920                        continue;
    753921#endif
    754                 if (snd_opl3sa_probe(dev) >= 0)
     922                if (snd_opl3sa2_probe(dev) >= 0)
    755923                        cards++;
    756924        }
     
    760928        if (!cards) {
    761929#ifdef MODULE
    762                 snd_printk("Yamaha OPL3-SA soundcard not found or device busy\n");
     930                printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n");
    763931#endif
    764932                return -ENODEV;
     
    772940
    773941        for (idx = 0; idx < SNDRV_CARDS; idx++)
    774                 snd_card_free(snd_opl3sa_cards[idx]);
     942                snd_card_free(snd_opl3sa2_cards[idx]);
    775943}
    776944
     
    780948#ifndef MODULE
    781949
    782 /* format is: snd-card-opl3sa2=snd_enable,snd_index,snd_id,snd_isapnp,
     950/* format is: snd-opl3sa2=snd_enable,snd_index,snd_id,snd_isapnp,
    783951                               snd_port,snd_sb_port,snd_wss_port,snd_fm_port,
    784952                               snd_midi_port,snd_irq,snd_dma1,snd_dma2,
     
    813981}
    814982
    815 __setup("snd-card-opl3sa2=", alsa_card_opl3sa2_setup);
     983__setup("snd-opl3sa2=", alsa_card_opl3sa2_setup);
    816984
    817985#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/opti9xx/opti92x-ad1848.c

    r32 r92  
    2020    You should have received a copy of the GNU General Public License
    2121    along with this program; if not, write to the Free Software
    22     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     22    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2323*/
    2424
    25 #define SNDRV_MAIN_OBJECT_FILE
     25
    2626#include <sound/driver.h>
     27#include <asm/io.h>
     28#include <asm/dma.h>
     29#include <linux/delay.h>
     30#include <linux/init.h>
     31#include <linux/slab.h>
     32#ifndef LINUX_ISAPNP_H
     33#include <linux/isapnp.h>
     34#define isapnp_card pci_bus
     35#define isapnp_dev pci_dev
     36#endif
     37#include <sound/core.h>
    2738#ifdef CS4231
    2839#include <sound/cs4231.h>
     
    4455
    4556EXPORT_NO_SYMBOLS;
     57MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
     58MODULE_CLASSES("{sound}");
     59MODULE_LICENSE("GPL");
    4660#ifdef OPTi93X
    4761MODULE_DESCRIPTION("OPTi93X");
    48 MODULE_CLASSES("{sound}");
    4962MODULE_DEVICES("{{OPTi,82C931/3}}");
    5063#else   /* OPTi93X */
    5164#ifdef CS4231
    5265MODULE_DESCRIPTION("OPTi92X - CS4231");
    53 MODULE_CLASSES("{sound}");
    5466MODULE_DEVICES("{{OPTi,82C924 (CS4231)},"
    5567                "{OPTi,82C925 (CS4231)}}");
    5668#else   /* CS4231 */
    5769MODULE_DESCRIPTION("OPTi92X - AD1848");
    58 MODULE_CLASSES("{sound}");
    5970MODULE_DEVICES("{{OPTi,82C924 (AD1848)},"
    60                 "{OPTi,82C925 (AD1848)}}");
     71                "{OPTi,82C925 (AD1848)},"
     72                "{OAK,Mozart}}");
    6173#endif  /* CS4231 */
    6274#endif  /* OPTi93X */
     
    10341046                ~(OPTi93X_PLAYBACK_ENABLE | OPTi93X_PLAYBACK_PIO));
    10351047
    1036         snd_dma_program(chip->dma1, runtime->dma_area, size,
     1048        snd_dma_program(chip->dma1, runtime->dma_addr, size,
    10371049                DMA_MODE_WRITE | DMA_AUTOINIT);
    10381050
     
    10671079                (unsigned char)~(OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO));
    10681080
    1069         snd_dma_program(chip->dma2, runtime->dma_area, size,
     1081        snd_dma_program(chip->dma2, runtime->dma_addr, size,
    10701082                DMA_MODE_READ | DMA_AUTOINIT);
    10711083
     
    12921304static int snd_opti93x_free(opti93x_t *chip)
    12931305{
    1294         if (chip->res_port)
     1306        if (chip->res_port) {
    12951307                release_resource(chip->res_port);
     1308                kfree_nocheck(chip->res_port);
     1309        }
    12961310        if (chip->dma1 >= 0) {
    12971311                disable_dma(chip->dma1);
     
    14581472        strcpy(pcm->name, snd_opti93x_chip_id(codec));
    14591473
    1460         snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, codec->dma1 > 3 || codec->dma2 > 3 ? 128*1024 : 64*1024, GFP_KERNEL|GFP_DMA);
     1474        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, codec->dma1 > 3 || codec->dma2 > 3 ? 128*1024 : 64*1024);
    14611475
    14621476        codec->pcm = pcm;
     
    17161730
    17171731        snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
     1732
    17181733        card = chip->card;
    17191734
     
    19912006                snd_card_opti9xx_deactivate(chip);
    19922007#endif  /* __ISAPNP__ */
    1993                 if (chip->res_mc_base)
     2008                if (chip->res_mc_base) {
    19942009                        release_resource(chip->res_mc_base);
     2010                        kfree_nocheck(chip->res_mc_base);
     2011                }
    19952012        }
    19962013}
     
    22492266#ifdef MODULE
    22502267#ifdef OPTi93X
    2251                 snd_printk("no OPTi 82C93x soundcard found\n");
    2252 #else
    2253                 snd_printk("no OPTi 82C92x soundcard found\n");
     2268                printk(KERN_ERR "no OPTi 82C93x soundcard found\n");
     2269#else
     2270                printk(KERN_ERR "no OPTi 82C92x soundcard found\n");
    22542271#endif  /* OPTi93X */
    22552272#endif
     
    22702287#ifndef MODULE
    22712288
    2272 /* format is: snd-card-opti9xx=snd_enable,snd_index,snd_id,snd_isapnp,
     2289/* format is: snd-opti9xx=snd_enable,snd_index,snd_id,snd_isapnp,
    22732290                               snd_port,snd_mpu_port,snd_fm_port,
    22742291                               snd_irq,snd_mpu_irq,
     
    23032320
    23042321#if defined(OPTi93X)
    2305 __setup("snd-card-opti93x=", alsa_card_opti9xx_setup);
     2322__setup("snd-opti93x=", alsa_card_opti9xx_setup);
    23062323#elif defined(CS4231)
    2307 __setup("snd-card-opti92x-cs4231=", alsa_card_opti9xx_setup);
    2308 #else
    2309 __setup("snd-card-opti92x-ad1848=", alsa_card_opti9xx_setup);
     2324__setup("snd-opti92x-cs4231=", alsa_card_opti9xx_setup);
     2325#else
     2326__setup("snd-opti92x-ad1848=", alsa_card_opti9xx_setup);
    23102327#endif
    23112328
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/es968.c

    r32 r92  
    1818 You should have received a copy of the GNU General Public License
    1919 along with this program; if not, write to the Free Software
    20  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     20    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2121 */
    2222
    23 #define SNDRV_MAIN_OBJECT_FILE
    2423#include <sound/driver.h>
     24#include <linux/init.h>
     25#include <linux/time.h>
     26#ifndef LINUX_ISAPNP_H
     27#include <linux/isapnp.h>
     28#define isapnp_card pci_bus
     29#define isapnp_dev pci_dev
     30#endif
     31#include <sound/core.h>
    2532#define SNDRV_GET_ID
    2633#include <sound/initval.h>
    2734#include <sound/sb.h>
    2835
     36#define chip_t sb_t
     37
    2938EXPORT_NO_SYMBOLS;
     39
     40MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
    3041MODULE_DESCRIPTION("ESS AudioDrive ES968");
     42MODULE_LICENSE("GPL");
    3143MODULE_CLASSES("{sound}");
    3244MODULE_DEVICES("{{ESS,AudioDrive ES968}}");
     
    3446static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    3547static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    36 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     48static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    3749static long snd_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
    3850static int snd_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;    /* Pnp setup */
     
    93105                                     struct pt_regs *regs)
    94106{
    95     sb_t *chip = dev_id;
     107        sb_t *chip = snd_magic_cast(sb_t, dev_id, return);
    96108
    97109    if (chip->open & SB_OPEN_PCM) {
     
    272284#ifndef MODULE
    273285
    274 /* format is: snd-card-es968=snd_enable,snd_index,snd_id,
     286/* format is: snd-es968=snd_enable,snd_index,snd_id,
    275287 snd_port,snd_irq,snd_dma1 */
    276288
     
    291303}
    292304
    293 __setup("snd-card-es968=", alsa_card_es968_setup);
     305__setup("snd-es968=", alsa_card_es968_setup);
    294306
    295307#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb16.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <asm/dma.h>
     24#include <linux/init.h>
     25#include <linux/slab.h>
     26#ifndef LINUX_ISAPNP_H
     27#include <linux/isapnp.h>
     28#define isapnp_card pci_bus
     29#define isapnp_dev pci_dev
     30#endif
     31#include <sound/core.h>
    2432#include <sound/sb.h>
    2533#include <sound/sb16_csp.h>
     
    3442#include <sound/initval.h>
    3543
     44#define chip_t sb_t
     45
     46#ifdef SNDRV_SBAWE
     47#define PFX "sbawe: "
     48#else
     49#define PFX "sb16: "
     50#endif
     51
     52#ifndef SNDRV_SBAWE
    3653EXPORT_NO_SYMBOLS;
     54#endif
     55
     56MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     57MODULE_LICENSE("GPL");
     58MODULE_CLASSES("{sound}");
    3759#ifndef SNDRV_SBAWE
    3860MODULE_DESCRIPTION("Sound Blaster 16");
    39 MODULE_CLASSES("{sound}");
    4061MODULE_DEVICES("{{Creative Labs,SB 16},"
    4162               "{Creative Labs,SB Vibra16S},"
     
    4566#else
    4667MODULE_DESCRIPTION("Sound Blaster AWE");
    47 MODULE_CLASSES("{sound}");
    4868MODULE_DEVICES("{{Creative Labs,SB AWE 32},"
    4969               "{Creative Labs,SB AWE 64},"
     
    5575#endif
    5676
    57 #if defined(SNDRV_SBAWE) && defined(CONFIG_SND_SEQUENCER) && defined(CONFIG_SND_SYNTH_EMU8000)
     77#if defined(SNDRV_SBAWE) && (defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE))
    5878#define SNDRV_SBAWE_EMU8000
    5979#endif
     
    6181static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    6282static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    63 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     83static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    6484#ifdef __ISAPNP__
    6585#ifdef TARGET_OS2
     
    139159MODULE_PARM(snd_mic_agc, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
    140160MODULE_PARM_DESC(snd_mic_agc, "Mic Auto-Gain-Control switch.");
    141 MODULE_PARM_SYNTAX(snd_mic_agcm, SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC);
     161MODULE_PARM_SYNTAX(snd_mic_agc, SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC);
    142162#ifdef CONFIG_SND_SB16_CSP
    143163MODULE_PARM(snd_csp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
     
    212232    ISAPNP_SB16('C','T','L',0x002b,0x0031),
    213233    /* Sound Blaster 16 PnP */
    214     ISAPNP_SB16('C','T','L',0x002c,0x0031),
     234        ISAPNP_SB16('C','T','L',0x002c,0x0031),
    215235    /* Sound Blaster Vibra16S */
    216236    ISAPNP_SB16('C','T','L',0x0051,0x0001),
     
    264284    /* Sound Blaster AWE 64 PnP */
    265285    ISAPNP_SBAWE('C','T','L',0x00e4,0x0045,0x0022),
     286        /* Sound Blaster AWE 64 PnP */
     287        ISAPNP_SBAWE('C','T','L',0x00e9,0x0045,0x0022),
    266288    /* Sound Blaster 16 PnP (AWE) */
    267289    ISAPNP_SBAWE('C','T','L',0x00ed,0x0041,0x0070),
     
    295317        return -EBUSY;
    296318    }
    297 #endif
     319#endif 
    298320    /* Audio initialization */
    299321    pdev = acard->dev;
     
    313335        isapnp_resource_change(&pdev->irq_resource[0], snd_irq[dev], 1);
    314336    if (pdev->activate(pdev) < 0) {
    315         snd_printk("isapnp configure failure (out of resources?)\n");
     337                printk(KERN_ERR PFX "isapnp configure failure (out of resources?)\n");
    316338        return -EBUSY;
    317339    }
     
    333355        return -EAGAIN;
    334356    }
    335     if (snd_awe_port[dev] != SNDRV_AUTO_PORT)
     357        if (snd_awe_port[dev] != SNDRV_AUTO_PORT) {
    336358        isapnp_resource_change(&pdev->resource[0], snd_awe_port[dev], 4);
     359                isapnp_resource_change(&pdev->resource[1], snd_awe_port[dev] + 0x400, 4);
     360                isapnp_resource_change(&pdev->resource[2], snd_awe_port[dev] + 0x800, 4);
     361        }
    337362    if (pdev->activate(pdev)<0) {
    338         snd_printk("WaveTable isapnp configure failure (out of resources?)\n");
    339         acard->dev->deactivate(acard->dev);
     363                printk(KERN_ERR PFX "WaveTable isapnp configure failure (out of resources?)\n");
     364                acard->dev->deactivate(acard->dev);             
    340365        return -EBUSY;
    341366    }
     
    368393    if (acard == NULL)
    369394        return;
    370     if (acard->fm_res)
     395        if (acard->fm_res) {
    371396        release_resource(acard->fm_res);
     397                kfree_nocheck(acard->fm_res);
     398        }
    372399#ifdef __ISAPNP__
    373400    snd_sb16_deactivate(acard);
     
    386413    opl3_t *opl3;
    387414    snd_hwdep_t *synth = NULL;
     415#ifdef CONFIG_SND_SB16_CSP
    388416    snd_hwdep_t *csp = NULL;
     417#endif
    389418    unsigned long flags;
    390419    int err;
     
    412441            if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
    413442                snd_card_free(card);
    414                 snd_printk("unable to find a free IRQ\n");
     443                        printk(KERN_ERR PFX "unable to find a free IRQ\n");
    415444                return -EBUSY;
    416445            }
     
    419448            if ((dma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) {
    420449                snd_card_free(card);
    421                 snd_printk("unable to find a free 8-bit DMA\n");
     450                        printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n");
    422451                return -EBUSY;
    423452            }
     
    426455            if ((dma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) {
    427456                snd_card_free(card);
    428                 snd_printk("unable to find a free 16-bit DMA\n");
     457                        printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n");
    429458                return -EBUSY;
    430459            }
     
    485514                                OPL3_HW_OPL3, snd_fm_port[dev] == snd_port[dev],
    486515                                &opl3) < 0) {
    487                 snd_printk("no OPL device at 0x%lx-0x%lx\n",
     516                        printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",
    488517                           snd_fm_port[dev], snd_fm_port[dev] + 2);
    489518            } else {
     
    513542                chip->hardware = SB_HW_16CSP;
    514543            } else {
    515                 snd_printk("warning - CSP chip not detected on soundcard #%i\n", dev + 1);
     544                        printk(KERN_INFO PFX "warning - CSP chip not detected on soundcard #%i\n", dev + 1);
    516545            }
    517546        }
     
    521550            if (snd_emu8000_new(card, 1, snd_awe_port[dev],
    522551                                snd_seq_ports[dev], NULL) < 0) {
    523                 snd_printk("fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", snd_awe_port[dev]);
     552                        printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", snd_awe_port[dev]);
    524553                snd_card_free(card);
    525554                return -ENXIO;
     
    535564        spin_unlock_irqrestore(&chip->mixer_lock, flags);
    536565
    537         strcpy(card->driver,
     566        strcpy(card->driver,
    538567#ifdef SNDRV_SBAWE_EMU8000
    539568               snd_awe_port[dev] > 0 ? "SB AWE" :
     
    622651            }
    623652#ifdef MODULE
    624             snd_printk("Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, snd_port[dev]);
    625 #endif
     653                printk(KERN_ERR "Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, snd_port[dev]);
     654#endif                 
    626655        }
    627656        /* legacy auto configured cards */
     
    634663        if (!cards) {
    635664#ifdef MODULE
    636             snd_printk("Sound Blaster 16 soundcard not found or device busy\n");
    637 #ifdef SNDRV_SBAWE_EMU8000
    638             snd_printk("In case, if you have non-AWE card, try snd-card-sb16 module\n");
    639 #else
    640             snd_printk("In case, if you have AWE card, try snd-card-sbawe module\n");
     665                printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n");
     666#ifdef SNDRV_SBAWE_EMU8000
     667                printk(KERN_ERR "In case, if you have non-AWE card, try snd-card-sb16 module\n");
     668#else
     669                printk(KERN_ERR "In case, if you have AWE card, try snd-card-sbawe module\n");
    641670#endif
    642671#endif
     
    659688#ifndef MODULE
    660689
    661         /* format is: snd-card-sb16=snd_enable,snd_index,snd_id,snd_isapnp,
     690/* format is: snd-sb16=snd_enable,snd_index,snd_id,snd_isapnp,
    662691         snd_port,snd_mpu_port,snd_fm_port,
    663692         snd_irq,snd_dma8,snd_dma16,
     
    683712               get_option(&str,&snd_dma8[nr_dev]) == 2 &&
    684713               get_option(&str,&snd_dma16[nr_dev]) == 2 &&
    685                get_option(&str,&snd_mic_agc[nr_dev]) == 2 &&
     714               get_option(&str,&snd_mic_agc[nr_dev]) == 2
     715#ifdef CONFIG_SND_SB16_CSP
     716               &&
    686717               get_option(&str,&snd_csp[nr_dev]) == 2
     718#endif
    687719#ifdef SNDRV_SBAWE_EMU8000
    688720               &&
     
    704736
    705737#ifndef SNDRV_SBAWE_EMU8000
    706     __setup("snd-card-sb16=", alsa_card_sb16_setup);
    707 #else
    708     __setup("snd-card-sbawe=", alsa_card_sb16_setup);
     738__setup("snd-sb16=", alsa_card_sb16_setup);
     739#else
     740__setup("snd-sbawe=", alsa_card_sb16_setup);
    709741#endif
    710742
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb16_csp.c

    r32 r92  
    2020 *   You should have received a copy of the GNU General Public License
    2121 *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     22 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2323 *
    2424 */
    2525
    26 #define SNDRV_MAIN_OBJECT_FILE
    2726#include <sound/driver.h>
     27#include <linux/delay.h>
     28#include <linux/init.h>
     29#include <linux/slab.h>
     30#include <sound/core.h>
    2831#include <sound/control.h>
    2932#include <sound/info.h>
     
    3336MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
    3437MODULE_DESCRIPTION("ALSA driver for SB16 Creative Signal Processor");
     38MODULE_LICENSE("GPL");
    3539MODULE_CLASSES("{sound}");
    3640
    3741#ifdef SNDRV_LITTLE_ENDIAN
    3842#define CSP_HDR_VALUE(a,b,c,d)  ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
    39 #define LE_SHORT(v)             (v)
    40 #define LE_INT(v)               (v)
    4143#else
    42 #include <byteswap.h>
    4344#define CSP_HDR_VALUE(a,b,c,d)  ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24))
    4445#define LE_SHORT(v)             bswap_16(v)
    4546#define LE_INT(v)               bswap_32(v)
    4647#endif
     48#define LE_SHORT(v)             le16_to_cpu(v)
     49#define LE_INT(v)               le32_to_cpu(v)
    4750
    4851#define RIFF_HEADER     CSP_HDR_VALUE('R', 'I', 'F', 'F')
     
    316319    if ((file_h.name != RIFF_HEADER) ||
    317320        (LE_INT(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) {
    318         snd_printd(__FUNCTION__ ": Invalid RIFF header\n");
     321                snd_printd("%s: Invalid RIFF header\n", __FUNCTION__);
    319322        return -EINVAL;
    320323    }
     
    325328        return -EFAULT;
    326329    if (item_type != CSP__HEADER) {
    327         snd_printd(__FUNCTION__ ": Invalid RIFF file type\n");
     330                snd_printd("%s: Invalid RIFF file type\n", __FUNCTION__);
    328331        return -EINVAL;
    329332    }
     
    380383
    381384            if (code_h.name != MAIN_HEADER) {
    382                 snd_printd(__FUNCTION__ ": Missing 'main' microcode\n");
     385                                snd_printd("%s: Missing 'main' microcode\n", __FUNCTION__);
    383386                return -EINVAL;
    384387            }
     
    424427                p->acc_format = p->acc_width = p->acc_rates = 0;
    425428                p->mode = 0;
    426                 snd_printd(__FUNCTION__ ": Unsupported CSP codec type: 0x%04x\n",
     429                                snd_printd("%s: Unsupported CSP codec type: 0x%04x\n",
     430                                           __FUNCTION__,
    427431                           LE_SHORT(funcdesc_h.VOC_type));
    428432                return -EINVAL;
     
    443447        }
    444448    }
    445     snd_printd(__FUNCTION__ ": Function #%d not found\n", info.func_req);
     449        snd_printd("%s: Function #%d not found\n", __FUNCTION__, info.func_req);
    446450    return -EINVAL;
    447451}
     
    597601{
    598602    if (p->version < 0x10 || p->version > 0x1f) {
    599         snd_printd(__FUNCTION__ ": Invalid CSP version: 0x%x\n", p->version);
     603                snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version);
    600604        return 1;
    601605    }
     
    616620    snd_sbdsp_command(p->chip, 0x01);   /* CSP download command */
    617621    if (snd_sbdsp_get_byte(p->chip)) {
    618         snd_printd(__FUNCTION__ ": Download command failed\n");
     622                snd_printd("%s: Download command failed\n", __FUNCTION__);
    619623        goto __fail;
    620624    }
     
    661665        }
    662666        if (status != 0x55) {
    663             snd_printd(__FUNCTION__ ": Microcode initialization failed\n");
     667                        snd_printd("%s: Microcode initialization failed\n", __FUNCTION__);
    664668            goto __fail;
    665669        }
     
    776780
    777781    if (!(p->running & (SNDRV_SB_CSP_ST_LOADED | SNDRV_SB_CSP_ST_AUTO))) {
    778         snd_printd(__FUNCTION__ ": Microcode not loaded\n");
     782                snd_printd("%s: Microcode not loaded\n", __FUNCTION__);
    779783        return -ENXIO;
    780784    }
    781785    if (p->running & SNDRV_SB_CSP_ST_RUNNING) {
    782         snd_printd(__FUNCTION__ ": CSP already running\n");
     786                snd_printd("%s: CSP already running\n", __FUNCTION__);
    783787        return -EBUSY;
    784788    }
    785789    if (!(sample_width & p->acc_width)) {
    786         snd_printd(__FUNCTION__ ": Unsupported PCM sample width\n");
     790                snd_printd("%s: Unsupported PCM sample width\n", __FUNCTION__);
    787791        return -EINVAL;
    788792    }
    789793    if (!(channels & p->acc_channels)) {
    790         snd_printd(__FUNCTION__ ": Invalid number of channels\n");
     794                snd_printd("%s: Invalid number of channels\n", __FUNCTION__);
    791795        return -EINVAL;
    792796    }
     
    810814
    811815    if (set_codec_parameter(p->chip, 0x81, s_type)) {
    812         snd_printd(__FUNCTION__ ": Set sample type command failed\n");
     816                snd_printd("%s: Set sample type command failed\n", __FUNCTION__);
    813817        goto __fail;
    814818    }
    815819    if (set_codec_parameter(p->chip, 0x80, 0x00)) {
    816         snd_printd(__FUNCTION__ ": Codec start command failed\n");
     820                snd_printd("%s: Codec start command failed\n", __FUNCTION__);
    817821        goto __fail;
    818822    }
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb16_main.c

    r32 r92  
    2424 *   You should have received a copy of the GNU General Public License
    2525 *   along with this program; if not, write to the Free Software
    26  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     26 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2727 *
    2828 */
    2929
    30 #define SNDRV_MAIN_OBJECT_FILE
    3130#include <sound/driver.h>
     31#include <asm/io.h>
     32#include <asm/dma.h>
     33#include <linux/init.h>
     34#include <linux/time.h>
     35#include <sound/core.h>
    3236#include <sound/sb.h>
    3337#include <sound/sb16_csp.h>
     
    3539#include <sound/control.h>
    3640#include <sound/info.h>
     41
     42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
     43MODULE_DESCRIPTION("Routines for control of 16-bit SoundBlaster cards and clones");
     44MODULE_LICENSE("GPL");
     45
     46#define chip_t sb_t
    3747
    3848#ifdef CONFIG_SND_SB16_CSP
     
    261271    size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream);
    262272    dma = (chip->mode & SB_MODE_PLAYBACK_8) ? chip->dma8 : chip->dma16;
    263     snd_dma_program(dma, runtime->dma_area, size, DMA_MODE_WRITE | DMA_AUTOINIT);
     273        snd_dma_program(dma, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
    264274
    265275    count = snd_pcm_lib_period_bytes(substream);
     
    328338    size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream);
    329339    dma = (chip->mode & SB_MODE_CAPTURE_8) ? chip->dma8 : chip->dma16;
    330     snd_dma_program(dma, runtime->dma_area, size, DMA_MODE_READ | DMA_AUTOINIT);
     340        snd_dma_program(dma, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
    331341
    332342    count = snd_pcm_lib_period_bytes(substream);
     
    932942    snd_ctl_add(card, snd_ctl_new1(&snd_sb16_dma_control, chip));
    933943
    934     snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, 128*1024, GFP_KERNEL|GFP_DMA);
     944        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, 128*1024);
    935945
    936946    if (rpcm)
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb8.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <linux/init.h>
     24#include <linux/slab.h>
     25#include <sound/core.h>
    2426#include <sound/sb.h>
    2527#include <sound/opl3.h>
     
    2830#include <sound/initval.h>
    2931
     32#define chip_t sb_t
     33
    3034EXPORT_NO_SYMBOLS;
     35
     36MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3137MODULE_DESCRIPTION("Sound Blaster 1.0/2.0/Pro");
     38MODULE_LICENSE("GPL");
    3239MODULE_CLASSES("{sound}");
    3340MODULE_DEVICES("{{Creative Labs,SB 1.0/SB 2.0/SB Pro}}");
     
    8289    if (acard == NULL)
    8390        return;
    84     if (acard->fm_res)
     91        if (acard->fm_res) {
    8592        release_resource(acard->fm_res);
     93                kfree_nocheck(acard->fm_res);
     94        }
    8695}
    8796
     
    136145                                   OPL3_HW_AUTO, 1,
    137146                                   &opl3)) < 0) {
    138             snd_printk("no OPL device at 0x%lx\n", chip->port + 8);
     147                        printk(KERN_ERR "sb8: no OPL device at 0x%lx\n", chip->port + 8);
    139148        }
    140149    } else {
     
    142151                                   OPL3_HW_AUTO, 1,
    143152                                   &opl3)) < 0) {
    144             snd_printk("no OPL device at 0x%lx-0x%lx\n",
     153                        printk(KERN_ERR "sb8: no OPL device at 0x%lx-0x%lx\n",
    145154                       chip->port, chip->port + 2);
    146155        }
     
    203212    if (!cards) {
    204213#ifdef MODULE
    205         snd_printk("Sound Blaster soundcard not found or device busy\n");
     214                printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n");
    206215#endif
    207216        return -ENODEV;
     
    223232#ifndef MODULE
    224233
    225 /* format is: snd-card-sb8=snd_enable,snd_index,snd_id,
     234/* format is: snd-sb8=snd_enable,snd_index,snd_id,
    226235 snd_port,snd_irq,snd_dma8 */
    227236
     
    242251}
    243252
    244 __setup("snd-card-sb8=", alsa_card_sb8_setup);
     253__setup("snd-sb8=", alsa_card_sb8_setup);
    245254
    246255#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb8_main.c

    r32 r92  
    1919 *   You should have received a copy of the GNU General Public License
    2020 *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2222 *
    2323 * --
     
    3131 */
    3232
    33 #define SNDRV_MAIN_OBJECT_FILE
    3433#include <sound/driver.h>
     34#include <asm/io.h>
     35#include <asm/dma.h>
     36#include <linux/init.h>
     37#include <linux/time.h>
     38#include <sound/core.h>
    3539#include <sound/sb.h>
     40
     41MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Uros Bizjak <uros@kss-loka.si>");
     42MODULE_DESCRIPTION("Routines for control of 8-bit SoundBlaster cards and clones");
     43MODULE_LICENSE("GPL");
     44
     45#define chip_t sb_t
    3646
    3747#define SB8_CLOCK       1000000
     
    172182        snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT);
    173183        runtime->dma_area[0] = 0x80;
    174         snd_dma_program(chip->dma8, runtime->dma_area, 1, DMA_MODE_WRITE);
     184                snd_dma_program(chip->dma8, runtime->dma_addr, 1, DMA_MODE_WRITE);
    175185        /* force interrupt */
    176186        chip->mode = SB_MODE_HALT;
     
    199209    }
    200210    spin_unlock_irqrestore(&chip->reg_lock, flags);
    201     snd_dma_program(chip->dma8, runtime->dma_area,
     211        snd_dma_program(chip->dma8, runtime->dma_addr,
    202212                    size, DMA_MODE_WRITE | DMA_AUTOINIT);
    203213    return 0;
     
    311321    }
    312322    spin_unlock_irqrestore(&chip->reg_lock, flags);
    313     snd_dma_program(chip->dma8, runtime->dma_area,
     323        snd_dma_program(chip->dma8, runtime->dma_addr,
    314324                    size, DMA_MODE_READ | DMA_AUTOINIT);
    315325    return 0;
     
    622632    snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops);
    623633
    624     snd_pcm_lib_preallocate_pages_for_all(pcm, 64*1024, 64*1024, GFP_KERNEL|GFP_DMA);
     634        snd_pcm_lib_preallocate_isa_pages_for_all(pcm, 64*1024, 64*1024);
    625635
    626636    if (rpcm)
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb_common.c

    r34 r92  
    1717 *   You should have received a copy of the GNU General Public License
    1818 *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2020 *
    2121 */
    2222
    23 #define SNDRV_MAIN_OBJECT_FILE
    2423#include <sound/driver.h>
     24#include <asm/io.h>
     25#include <asm/dma.h>
     26#include <linux/delay.h>
     27#include <linux/init.h>
     28#include <linux/slab.h>
     29#include <sound/core.h>
    2530#include <sound/sb.h>
    2631#include <sound/initval.h>
     
    2833MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    2934MODULE_DESCRIPTION("ALSA lowlevel driver for Sound Blaster cards");
     35MODULE_LICENSE("GPL");
    3036MODULE_CLASSES("{sound}");
    3137
     
    172178    if (chip->irq >= 0)
    173179        free_irq(chip->irq, (void *) chip);
     180#ifdef CONFIG_ISA
    174181    if (chip->dma8 >= 0) {
    175182        disable_dma(chip->dma8);
     
    180187        free_dma(chip->dma16);
    181188    }
    182     kfree(chip);
     189#endif
     190        kfree(chip);
    183191    return 0;
    184192}
     
    241249    }
    242250
     251#ifdef CONFIG_ISA
    243252    if (dma8 >= 0 && request_dma(dma8, "SoundBlaster - 8bit")) {
    244253        snd_sbdsp_free(chip);
     
    251260    }
    252261    chip->dma16 = dma16;
     262#endif
    253263
    254264__skip_allocation:
  • GPL/branches/alsa-resync1/alsa-kernel/isa/sgalaxy.c

    r32 r92  
    1818 *   You should have received a copy of the GNU General Public License
    1919 *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     20 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2121 *
    2222 */
    2323
    24 #define SNDRV_MAIN_OBJECT_FILE
    2524#include <sound/driver.h>
     25#include <asm/dma.h>
     26#include <linux/init.h>
     27#include <linux/delay.h>
     28#include <linux/time.h>
     29#include <sound/core.h>
    2630#include <sound/sb.h>
    2731#include <sound/ad1848.h>
     
    3236
    3337EXPORT_NO_SYMBOLS;
     38
     39MODULE_AUTHOR("Christopher Butler <chrisb@sandy.force9.co.uk>");
    3440MODULE_DESCRIPTION("Aztech Sound Galaxy");
     41MODULE_LICENSE("GPL");
    3542MODULE_CLASSES("{sound}");
    3643MODULE_DEVICES("{{Aztech Systems,Sound Galaxy}}");
     
    117124        if ((tmp = inb(port + 3)) == 0xff)
    118125        {
    119                 snd_printdd("I/O address dead (0x%lx)\n", tmp);
     126                snd_printdd("I/O address dead (0x%lx)\n", port);
    120127                return 0;
    121128        }
     
    299306        if (!cards) {
    300307#ifdef MODULE
    301                 snd_printk("Sound Galaxy soundcard not found or device busy\n");
     308                printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n");
    302309#endif
    303310                return -ENODEV;
     
    320327#ifndef MODULE
    321328
    322 /* format is: snd-card-sgalaxy=snd_enable,snd_index,snd_id,
     329/* format is: snd-sgalaxy=snd_enable,snd_index,snd_id,
    323330                               snd_sbport,snd_wssport,
    324331                               snd_irq,snd_dma1 */
     
    341348}
    342349
    343 __setup("snd-card-sgalaxy=", alsa_card_sgalaxy_setup);
     350__setup("snd-sgalaxy=", alsa_card_sgalaxy_setup);
    344351
    345352#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/isa/wavefront/wavefront.c

    r32 r92  
    1717 *  You should have received a copy of the GNU General Public License
    1818 *  along with this program; if not, write to the Free Software
    19  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <linux/init.h>
     24#include <linux/slab.h>
     25#ifndef LINUX_ISAPNP_H
     26#include <linux/isapnp.h>
     27#define isapnp_card pci_bus
     28#define isapnp_dev pci_dev
     29#endif
     30#include <sound/core.h>
    2431#define SNDRV_GET_ID
    2532#include <sound/initval.h>
     
    3037
    3138EXPORT_NO_SYMBOLS;
     39MODULE_AUTHOR("Paul Barton-Davis <pbd@op.net>");
    3240MODULE_DESCRIPTION("Turtle Beach Wavefront");
     41MODULE_LICENSE("GPL");
    3342MODULE_CLASSES("{sound}");
    3443MODULE_DEVICES("{{Turtle Beach,Maui/Tropez/Tropez+}}");
     
    4554static int snd_ics2115_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;    /* 2,9,11,12,15 */
    4655static long snd_fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;          /* PnP setup */
    47 static long snd_control_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
    48 static long snd_wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;         /* PnP setup */
    4956static int snd_dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* 0,1,3,5,6,7 */
    5057static int snd_dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* 0,1,3,5,6,7 */
    51 
    52 MODULE_AUTHOR("Paul Barton-Davis <pbd@op.net>");
     58static int snd_use_cs4232_midi[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
     59
    5360MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
    5461MODULE_PARM_SYNTAX(snd_index, "Index value for WaveFront soundcard.");
     
    9198MODULE_PARM_DESC(snd_fm_port, "FM port #.");
    9299MODULE_PARM_SYNTAX(snd_fm_port, SNDRV_PORT12_DESC);
    93 MODULE_PARM(snd_wss_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
    94 MODULE_PARM_DESC(snd_wss_port, "Windows Sound System port #.");
    95 MODULE_PARM_SYNTAX(snd_wss_port, SNDRV_PORT12_DESC);
     100MODULE_PARM(snd_use_cs4232_midi, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
     101MODULE_PARM_DESC(snd_use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
     102MODULE_PARM_SYNTAX(snd_use_cs4232_midi, SNDRV_ENABLED ",allows use of CS4323 MPU-401 interface");
    96103
    97104static snd_card_t *snd_wavefront_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
     
    132139        /* Check for each logical device. */
    133140
    134         /* "windows sound system" has id 0 */
     141        /* CS4232 chip (aka "windows sound system") is logical device 0 */
    135142
    136143        acard->wss = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);
     
    140147        }
    141148
    142         /* control interface has id 1 */
    143 
    144         acard->ctrl = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);
    145         if (acard->ctrl->active) {
    146                 acard->wss = acard->ctrl = NULL;
    147                 return -EBUSY;
    148         }
    149 
    150         /* synth has id 3 */
     149        /* there is a game port at logical device 1, but we ignore it completely */
     150
     151        /* the control interface is logical device 2, but we ignore it
     152           completely. in fact, nobody even seems to know what it
     153           does.
     154        */
     155
     156        /* Only configure the CS4232 MIDI interface if its been
     157           specifically requested. It is logical device 3.
     158        */
     159
     160        if (snd_use_cs4232_midi[dev]) {
     161                acard->mpu = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL);
     162                if (acard->mpu->active) {
     163                        acard->wss = acard->synth = acard->mpu = NULL;
     164                        return -EBUSY;
     165                }
     166        }
     167
     168        /* The ICS2115 synth is logical device 4 */
    151169
    152170        acard->synth = isapnp_find_dev(card, id->devs[3].vendor, id->devs[3].function, NULL);
    153171        if (acard->synth->active) {
    154                 acard->wss = acard->ctrl = acard->synth = NULL;
     172                acard->wss = acard->synth = NULL;
    155173                return -EBUSY;
    156         }
    157 
    158         /* Only configure the CS4232 MIDI interface is its been
    159            requested. It has id 2.
    160         */
    161 
    162         if (snd_cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
    163                 acard->mpu = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL);
    164                 if (acard->mpu->active) {
    165                         acard->wss = acard->ctrl = acard->synth = acard->mpu = NULL;
    166                         return -EBUSY;
    167                 }
    168174        }
    169175
     
    174180        if ((tmp = pdev->prepare (pdev)) < 0) {
    175181                if (tmp == -EBUSY) {
    176                         snd_printk ("ISA PnP configuration appears to have been "
    177                                     "done. Restart the isa-pnp module.\n");
     182                        snd_printk ("ISA PnP configuration appears to have "
     183                                    "been done. Restart the isapnp module.\n");
    178184                        return 0;
    179185                }
    180                                    
    181186                snd_printk ("isapnp WSS preparation failed\n");
    182187                return -EAGAIN;
    183188        }
     189
     190        /* An interesting note from the Tropez+ FAQ:
     191
     192           Q. [Ports] Why is the base address of the WSS I/O ports off by 4?
     193
     194           A. WSS I/O requires a block of 8 I/O addresses ("ports"). Of these, the first
     195           4 are used to identify and configure the board. With the advent of PnP,
     196           these first 4 addresses have become obsolete, and software applications
     197           only use the last 4 addresses to control the codec chip. Therefore, the
     198           base address setting "skips past" the 4 unused addresses.
     199
     200        */
    184201
    185202        if (snd_cs4232_pcm_port[dev] != SNDRV_AUTO_PORT)
     
    187204        if (snd_fm_port[dev] != SNDRV_AUTO_PORT)
    188205                isapnp_resource_change(&pdev->resource[1], snd_fm_port[dev], 4);
    189         if (snd_wss_port[dev] != SNDRV_AUTO_PORT)
    190                 isapnp_resource_change(&pdev->resource[2], snd_wss_port[dev], 4);
    191 
    192         if (snd_ics2115_port[dev] != SNDRV_AUTO_PORT)
    193                 isapnp_resource_change(&pdev->resource[3], snd_ics2115_port[dev], 8);
    194         if (snd_ics2115_irq[dev] != SNDRV_AUTO_IRQ)
    195                 isapnp_resource_change(&pdev->irq_resource[3], snd_ics2115_irq[dev], 1);
    196 
    197206        if (snd_dma1[dev] != SNDRV_AUTO_DMA)
    198207                isapnp_resource_change(&pdev->dma_resource[0], snd_dma1[dev], 1);
    199208        if (snd_dma2[dev] != SNDRV_AUTO_DMA)
    200209                isapnp_resource_change(&pdev->dma_resource[1], snd_dma2[dev], 1);
    201 
    202210        if (snd_cs4232_pcm_irq[dev] != SNDRV_AUTO_IRQ)
    203211                isapnp_resource_change(&pdev->irq_resource[0], snd_cs4232_pcm_irq[dev], 1);
     
    210218        snd_cs4232_pcm_port[dev] = pdev->resource[0].start;
    211219        snd_fm_port[dev] = pdev->resource[1].start;
    212         snd_wss_port[dev] = pdev->resource[2].start;
    213 
    214         snd_ics2115_port[dev] = pdev->resource[3].start;
    215         snd_ics2115_irq[dev] = pdev->irq_resource[3].start;
    216 
    217220        snd_dma1[dev] = pdev->dma_resource[0].start;
    218         snd_dma2[dev] = pdev->dma_resource[1].start == 4 ? -1 : pdev->dma_resource[1].start;
    219 
     221        snd_dma2[dev] = pdev->dma_resource[1].start;
    220222        snd_cs4232_pcm_irq[dev] = pdev->irq_resource[0].start;
    221223
    222         snd_printk ("CS4232: port=0x%lx, fm port=0x%lx, wss port=0x%lx\n"
    223                     "CS4232: dma1=%i, dma2=%i, irq=%i\n"
    224                     "ICS2115: port=0x%lx, irq=%i\n",
    225                     snd_cs4232_pcm_port[dev], snd_fm_port[dev], snd_wss_port[dev],
    226                     snd_dma1[dev], snd_dma2[dev], snd_cs4232_pcm_irq[dev],
    227                     snd_ics2115_port[dev],
    228                     snd_ics2115_irq[dev]);
    229        
    230         /* CTRL initialization */
    231 
    232         if (snd_control_port[dev] != SNDRV_AUTO_PORT) {
    233 
    234                 pdev = acard->ctrl;
    235 
    236                 if (pdev->prepare(pdev)<0) {
     224        /* Synth initialization */
     225
     226                pdev = acard->synth;
     227
     228        if ((tmp = pdev->prepare(pdev))<0) {
     229                if (tmp == -EBUSY) {
     230                        snd_printk ("ISA PnP configuration appears to have "
     231                                    "been done. Restart the isapnp module.\n");
     232                }
    237233                        acard->wss->deactivate(acard->wss);
    238                         snd_printk ("isapnp CTRL preparation failed\n");
    239                         return -EAGAIN;
    240                 }
    241                
    242                 if (snd_control_port[dev] != SNDRV_AUTO_PORT)
    243                         isapnp_resource_change(&pdev->resource[0], snd_control_port[dev], 8);
    244                
    245                 if (pdev->activate(pdev)<0) {
    246                         snd_printk("isapnp CTRL activation failed\n");
    247                         acard->wss->deactivate(acard->wss);
    248                         return -EBUSY;
    249                 }
    250                
    251                 snd_control_port[dev] = pdev->resource[0].start;
    252                 snd_printk ("isapnp CTRL: control port=0x%lx\n",
    253                             snd_control_port[dev]);
    254         }
    255 
    256         /* Synth initialization */
    257 
    258         if (snd_ics2115_port[dev] != SNDRV_AUTO_PORT) {
    259 
    260                 pdev = acard->synth;
    261 
    262                 if (pdev->prepare(pdev)<0) {
    263                         acard->wss->deactivate(acard->wss);
    264                         if (acard->ctrl)
    265                                 acard->ctrl->deactivate(acard->ctrl);
    266234                        snd_printk ("ICS2115 synth preparation failed\n");
    267235                        return -EAGAIN;
    268236                }
     237        if (snd_ics2115_port[dev] != SNDRV_AUTO_PORT) {
     238                isapnp_resource_change(&pdev->resource[0], snd_ics2115_port[dev], 16);
     239        }
    269240               
    270                 isapnp_resource_change(&pdev->resource[0], snd_ics2115_port[dev], 8);
    271                 if (snd_ics2115_irq[dev] != SNDRV_AUTO_IRQ)
     241        if (snd_ics2115_port[dev] != SNDRV_AUTO_IRQ) {
    272242                        isapnp_resource_change(&pdev->irq_resource[0], snd_ics2115_irq[dev], 1);
     243        }
    273244
    274245                if (pdev->activate(pdev)<0) {
    275                         snd_printk("synth configuration failed\n");
     246                snd_printk("isapnp activation for ICS2115 failed\n");
    276247                        acard->wss->deactivate(acard->wss);
    277                         if (acard->ctrl)
    278                                 acard->ctrl->deactivate(acard->ctrl);
    279248                        return -EBUSY;
    280249                }
     
    282251                snd_ics2115_port[dev] = pdev->resource[0].start;
    283252                snd_ics2115_irq[dev] = pdev->irq_resource[0].start;
    284         }
    285253
    286254        /* CS4232 MPU initialization. Configure this only if
     
    289257        */
    290258
    291         if (snd_cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
     259        if (snd_use_cs4232_midi[dev]) {
    292260
    293261                pdev = acard->mpu;
     
    295263                if (pdev->prepare(pdev)<0) {
    296264                        acard->wss->deactivate(acard->wss);
    297                         if (acard->ctrl)
    298                                 acard->ctrl->deactivate(acard->ctrl);
    299265                        if (acard->synth)
    300266                                acard->synth->deactivate(acard->synth);
     
    320286                            snd_cs4232_mpu_irq[dev]);
    321287        }
     288
     289        snd_printdd ("CS4232: pcm port=0x%lx, fm port=0x%lx, dma1=%i, dma2=%i, irq=%i\nICS2115: port=0x%lx, irq=%i\n",
     290                    snd_cs4232_pcm_port[dev],
     291                    snd_fm_port[dev],
     292                    snd_dma1[dev],
     293                    snd_dma2[dev],
     294                    snd_cs4232_pcm_irq[dev],
     295                    snd_ics2115_port[dev],
     296                    snd_ics2115_irq[dev]);
    322297
    323298        return 0;
     
    469444                snd_wavefront_deactivate(acard);
    470445#endif
    471                 if (acard->wavefront.res_base != NULL)
     446                if (acard->wavefront.res_base != NULL) {
    472447                        release_resource(acard->wavefront.res_base);
     448                        kfree_nocheck(acard->wavefront.res_base);
     449                }
    473450                if (acard->wavefront.irq > 0)
    474451                        free_irq(acard->wavefront.irq, (void *)acard);
     
    526503#ifdef __ISAPNP__
    527504        if (snd_isapnp[dev] && snd_wavefront_isapnp (dev, acard) < 0) {
    528                 if (snd_cs4232_pcm_port[dev] == SNDRV_AUTO_PORT ||
    529                     snd_control_port[dev] == SNDRV_AUTO_PORT) {
     505                if (snd_cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
    530506                        snd_printk ("isapnp detection failed\n");
    531507                        snd_card_free (card);
     
    539515        if ((err = snd_cs4231_create (card,
    540516                                      snd_cs4232_pcm_port[dev],
    541                                       snd_control_port[dev],
     517                                      -1,
    542518                                      snd_cs4232_pcm_irq[dev],
    543519                                      snd_dma1[dev],
     
    765741        if (!cards) {
    766742#ifdef MODULE
    767                 snd_printk ("No cards found or devices busy\n");
     743                printk (KERN_ERR "No WaveFront cards found or devices busy\n");
    768744#endif
    769745                return -ENODEV;
     
    785761#ifndef MODULE
    786762
    787 /* format is: snd-card-wavefront=snd_enable,snd_index,snd_id,snd_isapnp,
     763/* format is: snd-wavefront=snd_enable,snd_index,snd_id,snd_isapnp,
    788764                                 snd_cs4232_pcm_port,snd_cs4232_pcm_irq,
    789765                                 snd_cs4232_mpu_port,snd_cs4232_mpu_irq,
    790766                                 snd_ics2115_port,snd_ics2115_irq,
    791                                  snd_fm_port,snd_control_port,snd_wss_port,
    792                                  snd_dma1,snd_dma2 */
     767                            snd_fm_port,
     768                            snd_dma1,snd_dma2,
     769                            snd_use_cs4232_midi */
    793770
    794771static int __init alsa_card_wavefront_setup(char *str)
     
    809786               get_option(&str,&snd_ics2115_irq[nr_dev]) == 2 &&
    810787               get_option(&str,(int *)&snd_fm_port[nr_dev]) == 2 &&
    811                get_option(&str,(int *)&snd_control_port[nr_dev]) == 2 &&
    812                get_option(&str,(int *)&snd_wss_port[nr_dev]) == 2 &&
    813788               get_option(&str,&snd_dma1[nr_dev]) == 2 &&
    814                get_option(&str,&snd_dma2[nr_dev]) == 2);
     789               get_option(&str,&snd_dma2[nr_dev]) == 2 &&
     790               get_option(&str,&snd_use_cs4232_midi[nr_dev]) == 2);
    815791        nr_dev++;
    816792        return 1;
    817793}
    818794
    819 __setup("snd-card-wavefront=", alsa_card_wavefront_setup);
     795__setup("snd-wavefront=", alsa_card_wavefront_setup);
    820796
    821797#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ali5451/ali5451.c

    r34 r92  
    2727
    2828#define __SNDRV_OSS_COMPAT__
    29 #define SNDRV_MAIN_OBJECT_FILE
    30 
    31 #include "sound/driver.h"
    32 #include "sound/pcm.h"
    33 #include "sound/info.h"
    34 #include "sound/ac97_codec.h"
    35 #include "sound/mpu401.h"
     29
     30#include <sound/driver.h>
     31#include <asm/io.h>
     32#include <linux/delay.h>
     33#include <linux/interrupt.h>
     34#include <linux/init.h>
     35#include <linux/slab.h>
     36#include <sound/core.h>
     37#include <sound/pcm.h>
     38#include <sound/info.h>
     39#include <sound/ac97_codec.h>
     40#include <sound/mpu401.h>
    3641#define SNDRV_GET_ID
    37 #include "sound/initval.h"
     42#include <sound/initval.h>
    3843
    3944MODULE_AUTHOR("Matt Wu <Matt_Wu@acersoftech.com.cn>");
     
    23232328    if ((err = pci_module_init(&driver)) < 0) {
    23242329#ifdef MODULE
    2325         //              snd_printk("ALi pci audio not found or device busy.\n");
     2330//              snd_printk(KERN_ERR "ALi pci audio not found or device busy.\n");
    23262331#endif
    23272332        return err;
  • GPL/branches/alsa-resync1/alsa-kernel/pci/als4000.c

    r34 r92  
    731731                                   &chip->rmidi)) < 0) {
    732732        snd_card_free(card);
    733         snd_printk("no MPU-401device at 0x%lx ?\n", gcr+0x30);
     733                printk(KERN_ERR "als4000: no MPU-401device at 0x%lx ?\n", gcr+0x30);
    734734        return err;
    735735    }
     
    746746    if (snd_opl3_create(card, gcr+0x10, gcr+0x12,
    747747                        OPL3_HW_AUTO, 1, &opl3) < 0) {
    748         snd_printk("no OPL device at 0x%lx-0x%lx ?\n",
     748                printk(KERN_ERR "als4000: no OPL device at 0x%lx-0x%lx ?\n",
    749749                   gcr+0x10, gcr+0x12 );
    750750    } else {
     
    797797    if ((err = pci_module_init(&driver)) < 0) {
    798798#ifdef MODULE
    799         //              snd_printk("no ALS4000 based soundcards found or device busy\n");
     799//              snd_printk(KERN_ERR "no ALS4000 based soundcards found or device busy\n");
    800800#endif
    801801        return err;
  • GPL/branches/alsa-resync1/alsa-kernel/pci/emu10k1/emu10k1_main.c

    r84 r92  
    3939#include <sound/core.h>
    4040#include <sound/emu10k1.h>
    41 #include <sound/firmware.h>
     41#include <linux/firmware.h>
    4242#include "p16v.h"
    4343#include "tina2.h"
     
    597597    return 0;
    598598}
     599
    599600
    600601static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename)
     
    10201021    return 0;
    10211022}
    1022 
    10231023
    10241024/*
  • GPL/branches/alsa-resync1/alsa-kernel/pci/es1968.c

    r77 r92  
    16061606    es->substream = substream;
    16071607    es->mode = ESM_MODE_PLAY;
     1608        INIT_LIST_HEAD(&es->list);
    16081609
    16091610    runtime->private_data = es;
     
    16571658    es->substream = substream;
    16581659    es->mode = ESM_MODE_CAPTURE;
     1660        INIT_LIST_HEAD(&es->list);
    16591661
    16601662    /* get mixbuffer */
     
    17171719    return 0;
    17181720}
     1721
    17191722static snd_pcm_ops_t snd_es1968_playback_ops = {
    17201723    /*  open:     */    snd_es1968_playback_open,
     
    20052008
    20062009    if (event & ESM_SOUND_IRQ) {
    2007         struct list_head *p;
     2010                struct list_head *p, *n;
    20082011        spin_lock(&chip->substream_lock);
    2009         list_for_each(p, &chip->substream_list) {
     2012                /* we need to use list_for_each_safe here since the substream
     2013                 * can be deleted in period_elapsed().
     2014                 */
     2015                list_for_each_safe(p, n, &chip->substream_list) {
    20102016            esschan_t *es = list_entry(p, esschan_t, list);
    20112017            if (es->running)
     
    28412847    if ((err = pci_module_init(&driver)) < 0) {
    28422848#ifdef MODULE
    2843         //              snd_printk("ESS Maestro soundcard not found or device busy\n");
     2849//              snd_printk(KERN_ERR "ESS Maestro soundcard not found or device busy\n");
    28442850#endif
    28452851        return err;
  • GPL/branches/alsa-resync1/alsa-kernel/pci/hda/patch_analog.c

    r88 r92  
    26192619        if (is_rev2(codec))
    26202620                snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
    2621 
     2621//paul
     2622                snd_printk(KERN_INFO "patch_analog: Vendor Id: 0x%x\n", codec->vendor_id);
     2623                snd_printk(KERN_INFO "patch_analog: Subsystem Id: 0x%x\n", codec->subsystem_id);
     2624                snd_printk(KERN_INFO "patch_analog: Revision Id: 0x%x\n", codec->revision_id);
     2625                snd_printk(KERN_INFO "patch_analog: Model Name: %s\n", codec->bus->modelname);
     2626//endpaul
    26222627        board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
    26232628                                                  ad1988_models, NULL);
     
    26382643                }
    26392644        }
    2640 
     2645//paul
     2646        snd_printk(KERN_INFO "patch_analog: board_config: %d\n", board_config);
     2647        board_config = AD1988_3STACK_DIG;
     2648        snd_printk(KERN_INFO "patch_analog: kludged board_config: %d\n", board_config);
     2649//endpaul
    26412650        switch (board_config) {
    26422651        case AD1988_6STACK:
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712.c

    r32 r92  
    1616 *   You should have received a copy of the GNU General Public License
    1717 *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    1919 *
    2020 */     
     
    2222/*
    2323  NOTES:
    24   - spdif nonaudio consumer mode does not work (at least with my 
     24  - spdif nonaudio consumer mode does not work (at least with my
    2525    Sony STR-DB830)
    2626*/
    2727
    28 #define SNDRV_MAIN_OBJECT_FILE
    29 
    3028#include <sound/driver.h>
     29#include <asm/io.h>
     30#include <linux/delay.h>
     31#include <linux/interrupt.h>
     32#include <linux/init.h>
     33#include <linux/slab.h>
     34#include <sound/core.h>
    3135#include <sound/control.h>
    3236#include <sound/pcm.h>
    3337#include <sound/ac97_codec.h>
    3438#include <sound/mpu401.h>
     39#include <sound/i2c.h>
     40#include <sound/cs8427.h>
    3541#include <sound/info.h>
    3642#define SNDRV_GET_ID
    3743#include <sound/initval.h>
    3844
     45#include <sound/asoundef.h>
     46
     47#define SND_CS8403
     48#define SND_CS8404
     49#include <sound/cs8403.h>
     50
    3951EXPORT_NO_SYMBOLS;
     52
     53MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    4054MODULE_DESCRIPTION("ICEnsemble ICE1712 (Envy24)");
     55MODULE_LICENSE("GPL");
    4156MODULE_CLASSES("{sound}");
    4257MODULE_DEVICES("{{Hoontech SoundTrack DSP 24},"
     
    4964                "{TerraTec,EWS 88MT},"
    5065                "{TerraTec,EWS 88D},"
     66                "{TerraTec,DMX 6Fire},"
    5167                "{ICEnsemble,Generic ICE1712},"
    5268                "{ICEnsemble,Generic Envy24}}");
    53 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    5469
    5570static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    5671static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    57 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     72static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;          /* Enable this card */
     73static int snd_omni[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 0};       /* Delta44 & 66 Omni I/O support */
    5874
    5975MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
     
    6682MODULE_PARM_DESC(snd_enable, "Enable ICE1712 soundcard.");
    6783MODULE_PARM_SYNTAX(snd_enable, SNDRV_ENABLE_DESC);
     84MODULE_PARM(snd_omni, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
     85MODULE_PARM_DESC(snd_omni, "Enable Midiman M-Audio Delta Omni I/O support.");
     86MODULE_PARM_SYNTAX(snd_omni, SNDRV_ENABLED "," SNDRV_ENABLE_DESC);
    6887
    6988#ifndef PCI_VENDOR_ID_ICE
     
    83102#define ICE1712_SUBDEVICE_EWS88MT       0x3b151511
    84103#define ICE1712_SUBDEVICE_EWS88D        0x3b152b11
     104#define ICE1712_SUBDEVICE_DMX6FIRE      0x3b153811
    85105
    86106/*
     
    256276#define ICE1712_CFG_SPDIF_OUT   0x01    /* S/PDIF output is present */
    257277
    258 /* MidiMan Delta GPIO definitions */
    259 
    260 #define ICE1712_DELTA_DFS       0x01    /* fast/slow sample rate mode */
     278/*
     279 *  MidiMan M-Audio Delta GPIO definitions
     280 */
     281
     282/* MidiMan M-Audio Delta1010 */
     283#define ICE1712_DELTA_DFS 0x01          /* fast/slow sample rate mode */
    261284                                        /* (>48kHz must be 1) */
    262                                         /* all cards */
    263285#define ICE1712_DELTA_SPDIF_IN_STAT 0x02
    264286                                        /* S/PDIF input status */
     
    275297                                        /* all except Delta44 */
    276298                                        /* look to CS8404A datasheet */
     299/* MidiMan M-Audio DeltaDiO */
     300/* 0x01 = DFS */
     301/* 0x02 = SPDIF_IN_STAT */
     302/* 0x04 = SPDIF_OUT_STAT_CLOCK */
     303/* 0x08 = SPDIF_OUT_STAT_DATA */
    277304#define ICE1712_DELTA_SPDIF_INPUT_SELECT 0x10
    278305                                        /* coaxial (0), optical (1) */
    279306                                        /* S/PDIF input select*/
    280                                         /* DeltaDiO only */
     307
     308/* MidiMan M-Audio Delta1010 */
     309/* 0x01 = DFS */
     310/* 0x02 = SPDIF_IN_STAT */
     311/* 0x04 = SPDIF_OUT_STAT_CLOCK */
     312/* 0x08 = SPDIF_OUT_STAT_DATA */
    281313#define ICE1712_DELTA_WORD_CLOCK_SELECT 0x10
    282314                                        /* 1 - clock are taken from S/PDIF input */
    283315                                        /* 0 - clock are taken from Word Clock input */
    284                                         /* Delta1010 only (affected SPMCLKIN pin of Envy24) */
     316                                        /* affected SPMCLKIN pin of Envy24 */
     317#define ICE1712_DELTA_WORD_CLOCK_STATUS 0x20
     318                                        /* 0 = valid word clock signal is present */
     319
     320/* MidiMan M-Audio Delta66 */
     321/* 0x01 = DFS */
     322/* 0x02 = SPDIF_IN_STAT */
     323/* 0x04 = SPDIF_OUT_STAT_CLOCK */
     324/* 0x08 = SPDIF_OUT_STAT_DATA */
    285325#define ICE1712_DELTA_CODEC_SERIAL_DATA 0x10
    286326                                        /* AKM4524 serial data */
    287                                         /* Delta66 and Delta44 */
    288 #define ICE1712_DELTA_WORD_CLOCK_STATUS 0x20
    289                                         /* 0 = valid word clock signal is present */
    290                                         /* Delta1010 only */
    291327#define ICE1712_DELTA_CODEC_SERIAL_CLOCK 0x20
    292328                                        /* AKM4524 serial clock */
    293329                                        /* (writting on rising edge - 0->1 */
    294                                         /* Delta66 and Delta44 */
    295330#define ICE1712_DELTA_CODEC_CHIP_A      0x40
    296331#define ICE1712_DELTA_CODEC_CHIP_B      0x80
    297332                                        /* 1 - select chip A or B */
    298                                         /* Delta66 and Delta44 */
    299 
    300 /* M-Audio Audiophile definitions */
     333
     334/* MidiMan M-Audio Delta44 */
    301335/* 0x01 = DFS */
    302 #define ICE1712_DELTA_AP_CCLK   0x02    /* AudioPhile only */
    303                                         /* SPI clock */
     336/* 0x10 = CODEC_SERIAL_DATA */
     337/* 0x20 = CODEC_SERIAL_CLOCK */
     338/* 0x40 = CODEC_CHIP_A */
     339/* 0x80 = CODEC_CHIP_B */
     340
     341/* MidiMan M-Audio Audiophile definitions */
     342/* 0x01 = DFS */
     343#define ICE1712_DELTA_AP_CCLK   0x02    /* SPI clock */
    304344                                        /* (clocking on rising edge - 0->1) */
    305 #define ICE1712_DELTA_AP_DIN    0x04    /* AudioPhile only - data input */
    306 #define ICE1712_DELTA_AP_DOUT   0x08    /* AudioPhile only - data output */
    307 #define ICE1712_DELTA_AP_CS_DIGITAL 0x10 /* AudioPhile only - CS8427 chip select */
     345#define ICE1712_DELTA_AP_DIN    0x04    /* data input */
     346#define ICE1712_DELTA_AP_DOUT   0x08    /* data output */
     347#define ICE1712_DELTA_AP_CS_DIGITAL 0x10 /* CS8427 chip select */
    308348                                        /* low signal = select */
    309 #define ICE1712_DELTA_AP_CS_CODEC 0x20  /* AudioPhile only - AK4528 chip select */
     349#define ICE1712_DELTA_AP_CS_CODEC 0x20  /* AK4528 chip select */
    310350                                        /* low signal = select */
    311351
     
    353393/* TerraTec EWS 88MT/D configuration definitions */
    354394/* RW, SDA snd SCLK are identical with EWX24/96 */
    355 
    356395#define ICE1712_EWS88_CS8414_RATE       0x07    /* CS8414 sample rate: gpio 0-2 */
    357396#define ICE1712_EWS88_RW                0x08    /* read/write switch for i2c; high = write  */
     
    362401
    363402/* i2c address */
    364 #define ICE1712_EWS88MT_CS8404_ADDR     0x40
    365 #define ICE1712_EWS88MT_INPUT_ADDR      0x46
    366 #define ICE1712_EWS88MT_OUTPUT_ADDR     0x48
     403#define ICE1712_EWS88MT_CS8404_ADDR     (0x40>>1)
     404#define ICE1712_EWS88MT_INPUT_ADDR      (0x46>>1)
     405#define ICE1712_EWS88MT_OUTPUT_ADDR     (0x48>>1)
    367406#define ICE1712_EWS88MT_OUTPUT_SENSE    0x40    /* mask */
    368 #define ICE1712_EWS88D_PCF_ADDR         0x40
     407#define ICE1712_EWS88D_PCF_ADDR         (0x40>>1)
     408
     409/* TerraTec DMX 6Fire configuration definitions */
     410#define ICE1712_6FIRE_AK4524_CS_MASK    0x07    /* AK4524 chip select #1-#3 */
     411#define ICE1712_6FIRE_RW                0x08    /* read/write switch for i2c; high = write  */
     412#define ICE1712_6FIRE_SERIAL_DATA       0x10    /* i2c & ak4524 data */
     413#define ICE1712_6FIRE_SERIAL_CLOCK      0x20    /* i2c & ak4524 clock */
     414#define ICE1712_6FIRE_TX2               0x40    /* MIDI2 */
     415#define ICE1712_6FIRE_RX2               0x80    /* MIDI2 */
     416
     417#define ICE1712_6FIRE_CS8427_ADDR       (0x22>>1) /* ?? */
    369418
    370419/*
     
    381430
    382431typedef struct _snd_ice1712 ice1712_t;
    383 
    384 typedef struct {
    385         void (*write)(ice1712_t *ice, unsigned char reg, unsigned char data);
    386         unsigned char (*read)(ice1712_t *ice, unsigned char reg);
    387         void (*write_bytes)(ice1712_t *ice, unsigned char reg, int bytes, unsigned char *data);
    388         void (*read_bytes)(ice1712_t *ice, unsigned char reg, int bytes, unsigned char *data);
    389 } ice1712_cs8427_ops_t;
    390432
    391433typedef struct {
     
    453495
    454496        unsigned int pro_volumes[20];
    455         int num_adcs;
    456         int num_dacs;
     497        int ak4528: 1,                  /* AK4524 or AK4528 */
     498            omni: 1;                    /* Delta Omni I/O */
     499        int num_adcs;                   /* AK4524 or AK4528 ADCs */
     500        int num_dacs;                   /* AK4524 or AK4528 DACs */
     501        int num_total_dacs;             /* total DACs */
    457502        unsigned char ak4524_images[4][8];
     503        unsigned char ak4524_ipga_gain[4][2];
    458504        unsigned char hoontech_boxbits[4];
    459505        unsigned int hoontech_config;
    460506        unsigned short hoontech_boxconfig[4];
    461507
     508        snd_i2c_bus_t *i2c;             /* I2C bus */
     509        snd_i2c_device_t *cs8404;       /* CS8404A I2C device */
     510        snd_i2c_device_t *cs8427;       /* CS8427 I2C device */
     511        snd_i2c_device_t *pcf8574[2];   /* PCF8574 Output/Input (EWS88MT) */
     512        snd_i2c_device_t *pcf8575;      /* PCF8575 (EWS88D) */
     513       
    462514        unsigned char cs8403_spdif_bits;
    463515        unsigned char cs8403_spdif_stream_bits;
    464516        snd_kcontrol_t *spdif_stream_ctl;
    465 
    466         unsigned char cs8427_spdif_status[5];
    467         unsigned char cs8427_spdif_stream_status[5];
    468         ice1712_cs8427_ops_t *cs8427_ops;
    469517
    470518        unsigned char gpio_direction, gpio_write_mask;
     
    651699}
    652700
    653 static snd_kcontrol_new_t snd_ice1712_mixer_digmix_route_ac97 = {
     701static snd_kcontrol_new_t snd_ice1712_mixer_digmix_route_ac97 __devinitdata = {
    654702#ifdef TARGET_OS2
    655703        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    670718/*
    671719 */
     720
    672721static void snd_ice1712_delta_cs8403_spdif_write(ice1712_t *ice, unsigned char bits)
    673722{
     
    694743}
    695744
    696 static void snd_ice1712_decode_cs8403_spdif_bits(snd_aes_iec958_t *diga,
    697                                                  unsigned char bits)
    698 {
    699         if (bits & 0x01) {      /* consumer */
    700                 if (!(bits & 0x02))
    701                         diga->status[0] |= IEC958_AES0_NONAUDIO;
    702                 if (!(bits & 0x08))
    703                         diga->status[0] |= IEC958_AES0_CON_NOT_COPYRIGHT;
    704                 switch (bits & 0x10) {
    705                 case 0x10: diga->status[0] |= IEC958_AES0_CON_EMPHASIS_NONE; break;
    706                 case 0x00: diga->status[0] |= IEC958_AES0_CON_EMPHASIS_5015; break;
    707                 }
    708                 if (!(bits & 0x80))
    709                         diga->status[1] |= IEC958_AES1_CON_ORIGINAL;
    710                 switch (bits & 0x60) {
    711                 case 0x00: diga->status[1] |= IEC958_AES1_CON_MAGNETIC_ID; break;
    712                 case 0x20: diga->status[1] |= IEC958_AES1_CON_DIGDIGCONV_ID; break;
    713                 case 0x40: diga->status[1] |= IEC958_AES1_CON_LASEROPT_ID; break;
    714                 case 0x60: diga->status[1] |= IEC958_AES1_CON_GENERAL; break;
    715                 }
    716                 switch (bits & 0x06) {
    717                 case 0x00: diga->status[3] |= IEC958_AES3_CON_FS_44100; break;
    718                 case 0x02: diga->status[3] |= IEC958_AES3_CON_FS_48000; break;
    719                 case 0x04: diga->status[3] |= IEC958_AES3_CON_FS_32000; break;
    720                 }
    721         } else {
    722                 diga->status[0] = IEC958_AES0_PROFESSIONAL;
    723                 switch (bits & 0x18) {
    724                 case 0x00: diga->status[0] |= IEC958_AES0_PRO_FS_32000; break;
    725                 case 0x10: diga->status[0] |= IEC958_AES0_PRO_FS_44100; break;
    726                 case 0x08: diga->status[0] |= IEC958_AES0_PRO_FS_48000; break;
    727                 case 0x18: diga->status[0] |= IEC958_AES0_PRO_FS_NOTID; break;
    728                 }
    729                 switch (bits & 0x60) {
    730                 case 0x20: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_NONE; break;
    731                 case 0x40: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_5015; break;
    732                 case 0x00: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_CCITT; break;
    733                 case 0x60: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_NOTID; break;
    734                 }
    735                 if (bits & 0x80)
    736                         diga->status[1] |= IEC958_AES1_PRO_MODE_STEREOPHONIC;
    737         }
    738 }
    739 
    740 static unsigned char snd_ice1712_encode_cs8403_spdif_bits(snd_aes_iec958_t *diga)
    741 {
    742         unsigned char bits;
    743 
    744         if (!(diga->status[0] & IEC958_AES0_PROFESSIONAL)) {
    745                 bits = 0x01;    /* consumer mode */
    746                 if (diga->status[0] & IEC958_AES0_NONAUDIO)
    747                         bits &= ~0x02;
    748                 else
    749                         bits |= 0x02;
    750                 if (diga->status[0] & IEC958_AES0_CON_NOT_COPYRIGHT)
    751                         bits &= ~0x08;
    752                 else
    753                         bits |= 0x08;
    754                 switch (diga->status[0] & IEC958_AES0_CON_EMPHASIS) {
    755                 default:
    756                 case IEC958_AES0_CON_EMPHASIS_NONE: bits |= 0x10; break;
    757                 case IEC958_AES0_CON_EMPHASIS_5015: bits |= 0x00; break;
    758                 }
    759                 if (diga->status[1] & IEC958_AES1_CON_ORIGINAL)
    760                         bits &= ~0x80;
    761                 else
    762                         bits |= 0x80;
    763                 if ((diga->status[1] & IEC958_AES1_CON_CATEGORY) == IEC958_AES1_CON_GENERAL)
    764                         bits |= 0x60;
    765                 else {
    766                         switch(diga->status[1] & IEC958_AES1_CON_MAGNETIC_MASK) {
    767                         case IEC958_AES1_CON_MAGNETIC_ID:
    768                                 bits |= 0x00; break;
    769                         case IEC958_AES1_CON_DIGDIGCONV_ID:
    770                                 bits |= 0x20; break;
    771                         default:
    772                         case IEC958_AES1_CON_LASEROPT_ID:
    773                                 bits |= 0x40; break;
    774                         }
    775                 }
    776                 switch (diga->status[3] & IEC958_AES3_CON_FS) {
    777                 default:
    778                 case IEC958_AES3_CON_FS_44100: bits |= 0x00; break;
    779                 case IEC958_AES3_CON_FS_48000: bits |= 0x02; break;
    780                 case IEC958_AES3_CON_FS_32000: bits |= 0x04; break;
    781                 }
    782         } else {
    783                 bits = 0x00;    /* professional mode */
    784                 if (diga->status[0] & IEC958_AES0_NONAUDIO)
    785                         bits &= ~0x02;
    786                 else
    787                         bits |= 0x02;
    788                 /* CHECKME: I'm not sure about the bit order in val here */
    789                 switch (diga->status[0] & IEC958_AES0_PRO_FS) {
    790                 case IEC958_AES0_PRO_FS_32000:  bits |= 0x00; break;
    791                 case IEC958_AES0_PRO_FS_44100:  bits |= 0x10; break;    /* 44.1kHz */
    792                 case IEC958_AES0_PRO_FS_48000:  bits |= 0x08; break;    /* 48kHz */
    793                 default:
    794                 case IEC958_AES0_PRO_FS_NOTID: bits |= 0x18; break;
    795                 }
    796                 switch (diga->status[0] & IEC958_AES0_PRO_EMPHASIS) {
    797                 case IEC958_AES0_PRO_EMPHASIS_NONE: bits |= 0x20; break;
    798                 case IEC958_AES0_PRO_EMPHASIS_5015: bits |= 0x40; break;
    799                 case IEC958_AES0_PRO_EMPHASIS_CCITT: bits |= 0x00; break;
    800                 default:
    801                 case IEC958_AES0_PRO_EMPHASIS_NOTID: bits |= 0x60; break;
    802                 }
    803                 switch (diga->status[1] & IEC958_AES1_PRO_MODE) {
    804                 case IEC958_AES1_PRO_MODE_TWO:
    805                 case IEC958_AES1_PRO_MODE_STEREOPHONIC: bits |= 0x00; break;
    806                 default: bits |= 0x80; break;
    807                 }
    808         }
    809         return bits;
    810 }
    811 
    812745
    813746/*
     
    841774
    842775/*
    843  * CS8427 via SPI mode (for Audiophile)
     776 * CS8427 via SPI mode (for Audiophile), emulated I2C
    844777 */
    845778
     
    899832}
    900833
    901 /* write a register */
    902 static void snd_ice1712_ap_cs8427_write(ice1712_t *ice, unsigned char reg, unsigned char data)
    903 {
     834/* sequential write */
     835static int ap_cs8427_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
     836{
     837        ice1712_t *ice = snd_magic_cast(ice1712_t, device->bus->private_data, return -EIO);
     838        int res = count;
    904839        unsigned char tmp;
     840
    905841        down(&ice->gpio_mutex);
    906842        tmp = ap_cs8427_codec_select(ice);
    907         ap_cs8427_write_byte(ice, 0x20, tmp); /* address + write mode */
    908         ap_cs8427_write_byte(ice, reg, tmp);
    909         ap_cs8427_write_byte(ice, data, tmp);
     843        ap_cs8427_write_byte(ice, (device->addr << 1) | 0, tmp); /* address + write mode */
     844        while (count-- > 0)
     845                ap_cs8427_write_byte(ice, *bytes++, tmp);
    910846        ap_cs8427_codec_deassert(ice, tmp);
    911847        up(&ice->gpio_mutex);
    912 }
    913 
    914 /* read a register */
    915 static unsigned char snd_ice1712_ap_cs8427_read(ice1712_t *ice, unsigned char reg)
    916 {
    917         unsigned char tmp, data;
     848        return res;
     849}
     850
     851/* sequential read */
     852static int ap_cs8427_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
     853{
     854        ice1712_t *ice = snd_magic_cast(ice1712_t, device->bus->private_data, return -EIO);
     855        int res = count;
     856        unsigned char tmp;
    918857
    919858        down(&ice->gpio_mutex);
    920859        tmp = ap_cs8427_codec_select(ice);
    921         ap_cs8427_write_byte(ice, 0x20, tmp); /* address + write mode */
    922         ap_cs8427_write_byte(ice, reg, tmp);
    923         ap_cs8427_codec_deassert(ice, tmp);
    924         udelay(5);
    925         tmp = ap_cs8427_codec_select(ice);
    926         ap_cs8427_write_byte(ice, 0x21, tmp); /* address + read mode */
    927         data = ap_cs8427_read_byte(ice, tmp);
     860        ap_cs8427_write_byte(ice, (device->addr << 1) | 1, tmp); /* address + read mode */
     861        while (count-- > 0)
     862                *bytes++ = ap_cs8427_read_byte(ice, tmp);
    928863        ap_cs8427_codec_deassert(ice, tmp);
    929864        up(&ice->gpio_mutex);
    930         return data;
    931 }
    932 
    933 /* sequential write */
    934 static void snd_ice1712_ap_cs8427_write_bytes(ice1712_t *ice, unsigned char reg, int bytes, unsigned char *data)
    935 {
    936 #if 1
    937         unsigned char tmp;
    938         down(&ice->gpio_mutex);
    939         tmp = ap_cs8427_codec_select(ice);
    940         ap_cs8427_write_byte(ice, 0x20, tmp); /* address + write mode */
    941         ap_cs8427_write_byte(ice, reg | 0x80, tmp); /* incremental mode */
    942         while (bytes-- > 0)
    943                 ap_cs8427_write_byte(ice, *data++, tmp);
    944         ap_cs8427_codec_deassert(ice, tmp);
    945         up(&ice->gpio_mutex);
    946 #else
    947         while (bytes-- > 0)
    948                 snd_ice1712_ap_cs8427_write(ice, reg++, *data++);
    949 #endif
    950 }
    951 
    952 /* sequential read */
    953 static void snd_ice1712_ap_cs8427_read_bytes(ice1712_t *ice, unsigned char reg, int bytes, unsigned char *data)
    954 {
    955 #if 0 // is this working?  -- ti
    956         unsigned char tmp;
    957        
    958         down(&ice->gpio_mutex);
    959         tmp = ap_cs8427_codec_select(ice);
    960         ap_cs8427_write_byte(ice, 0x20, tmp); /* address + write mode */
    961         ap_cs8427_write_byte(ice, reg | 0x80, tmp); /* incremental mode */
    962         ap_cs8427_codec_deassert(ice, tmp);
    963         udelay(5);
    964         tmp = ap_cs8427_codec_select(ice);
    965         ap_cs8427_write_byte(ice, 0x21, tmp); /* address + read mode */
    966         while (bytes-- > 0)
    967                 *data++ = ap_cs8427_read_byte(ice, tmp);
    968         ap_cs8427_codec_deassert(ice, tmp);
    969         up(&ice->gpio_mutex);
    970 #else
    971         while (bytes-- > 0)
    972                 *data++ = snd_ice1712_ap_cs8427_read(ice, reg++);
    973 #endif
     865        return res;
     866}
     867
     868static int ap_cs8427_probeaddr(snd_i2c_bus_t *bus, unsigned short addr)
     869{
     870        if (addr == 0x10)
     871                return 1;
     872        return -ENOENT;
    974873}
    975874
    976875#ifdef TARGET_OS2
    977876static ice1712_cs8427_ops_t snd_ice1712_ap_cs8427_ops = {
    978         snd_ice1712_ap_cs8427_write,
    979         snd_ice1712_ap_cs8427_read,
    980         snd_ice1712_ap_cs8427_write_bytes,
    981         snd_ice1712_ap_cs8427_read_bytes
     877        ap_cs8427_sendbytes,
     878        ap_cs8427_readbytes,
     879        ap_cs8427_probeaddr,
    982880};
    983881#else
    984 static ice1712_cs8427_ops_t snd_ice1712_ap_cs8427_ops = {
    985         write: snd_ice1712_ap_cs8427_write,
    986         read: snd_ice1712_ap_cs8427_read,
    987         write_bytes: snd_ice1712_ap_cs8427_write_bytes,
    988         read_bytes: snd_ice1712_ap_cs8427_read_bytes,
     882static snd_i2c_ops_t ap_cs8427_i2c_ops = {
     883        sendbytes: ap_cs8427_sendbytes,
     884        readbytes: ap_cs8427_readbytes,
     885        probeaddr: ap_cs8427_probeaddr,
    989886};
    990887#endif
    991 
    992888
    993889/*
     
    996892
    997893/* send SDA and SCL */
    998 static void ewx_i2c_set(ice1712_t *ice, int clk, int data)
    999 {
     894static void ewx_i2c_setlines(snd_i2c_bus_t *bus, int clk, int data)
     895{
     896        ice1712_t *ice = snd_magic_cast(ice1712_t, bus->private_data, return);
    1000897        unsigned char tmp = 0;
    1001898        if (clk)
     
    1007904}
    1008905
    1009 /* send one bit */
    1010 static void ewx_i2c_send(ice1712_t *ice, int data)
    1011 {
    1012         ewx_i2c_set(ice, 0, data);
    1013         ewx_i2c_set(ice, 1, data);
    1014         ewx_i2c_set(ice, 0, data);
    1015 }
    1016 
    1017 /* start i2c */
    1018 static void ewx_i2c_start(ice1712_t *ice)
    1019 {
    1020         ewx_i2c_set(ice, 0, 1);
    1021         ewx_i2c_set(ice, 1, 1);
    1022         ewx_i2c_set(ice, 1, 0);
    1023         ewx_i2c_set(ice, 0, 0);
    1024 }
    1025 
    1026 /* stop i2c */
    1027 static void ewx_i2c_stop(ice1712_t *ice)
    1028 {
    1029         ewx_i2c_set(ice, 0, 0);
    1030         ewx_i2c_set(ice, 1, 0);
    1031         ewx_i2c_set(ice, 1, 1);
    1032 }
    1033 
    1034 /* send a byte and get ack */
    1035 static void ewx_i2c_write(ice1712_t *ice, unsigned char val)
    1036 {
    1037         int i;
    1038         for (i = 7; i >= 0; i--)
    1039                 ewx_i2c_send(ice, val & (1 << i));
    1040         ewx_i2c_send(ice, 1); /* ack */
    1041 }
    1042 
    1043 /* prepare for write and send i2c_start */
    1044 static void ewx_i2c_write_prepare(ice1712_t *ice)
    1045 {
    1046         /* set RW high */
    1047         unsigned char mask = ICE1712_EWX2496_RW;
    1048         if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_EWX2496)
    1049                 mask |= ICE1712_EWX2496_AK4524_CS; /* CS high also */
    1050         snd_ice1712_gpio_write_bits(ice, mask, mask);
    1051         /* set direction both SDA and SCL write */
    1052         ice->gpio_direction |= ICE1712_EWX2496_SERIAL_CLOCK|ICE1712_EWX2496_SERIAL_DATA;
    1053         snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, ice->gpio_direction);
    1054         snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~(ICE1712_EWX2496_SERIAL_CLOCK|ICE1712_EWX2496_SERIAL_DATA));
    1055                          
    1056         ewx_i2c_start(ice);
    1057 }
    1058 
    1059 /* read a bit from serial data;
    1060    this changes write mask
    1061    SDA direction must be set to low
    1062 */
    1063 static int ewx_i2c_read_bit(ice1712_t *ice)
    1064 {
    1065         int data;
     906static int ewx_i2c_getclock(snd_i2c_bus_t *bus)
     907{
     908        ice1712_t *ice = snd_magic_cast(ice1712_t, bus->private_data, return -EIO);
     909        return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_CLOCK ? 1 : 0;
     910}
     911
     912static int ewx_i2c_getdata(snd_i2c_bus_t *bus, int ack)
     913{
     914        ice1712_t *ice = snd_magic_cast(ice1712_t, bus->private_data, return -EIO);
     915        int bit;
    1066916        /* set RW pin to low */
    1067917        snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_RW);
    1068918        snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, 0);
    1069         data = (snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_DATA) ? 1 : 0;
     919        if (ack)
     920                udelay(5);
     921        bit = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_DATA ? 1 : 0;
    1070922        /* set RW pin to high */
    1071923        snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, ICE1712_EWX2496_RW);
    1072         return data;
    1073 }
    1074 
    1075 static void ewx_i2c_read_prepare(ice1712_t *ice)
    1076 {
    1077         /* set SCL - write, SDA - read */
    1078         ice->gpio_direction |= ICE1712_EWX2496_SERIAL_CLOCK;
    1079         ice->gpio_direction &= ~ICE1712_EWX2496_SERIAL_DATA;
     924        /* reset write mask */
     925        snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_SERIAL_CLOCK);
     926        return bit;
     927}
     928
     929static void ewx_i2c_start(snd_i2c_bus_t *bus)
     930{
     931        ice1712_t *ice = snd_magic_cast(ice1712_t, bus->private_data, return);
     932        unsigned char mask;
     933
     934        save_gpio_status(ice, (unsigned char *)&bus->private_value);
     935        /* set RW high */
     936        mask = ICE1712_EWX2496_RW;
     937        switch (ice->eeprom.subvendor) {
     938        case ICE1712_SUBDEVICE_EWX2496:
     939                mask |= ICE1712_EWX2496_AK4524_CS; /* CS high also */
     940                break;
     941        case ICE1712_SUBDEVICE_DMX6FIRE:
     942                mask |= ICE1712_6FIRE_AK4524_CS_MASK; /* CS high also */
     943                break;
     944        }
     945        snd_ice1712_gpio_write_bits(ice, mask, mask);
     946}
     947
     948static void ewx_i2c_stop(snd_i2c_bus_t *bus)
     949{
     950        ice1712_t *ice = snd_magic_cast(ice1712_t, bus->private_data, return);
     951        restore_gpio_status(ice, (unsigned char *)&bus->private_value);
     952}
     953
     954static void ewx_i2c_direction(snd_i2c_bus_t *bus, int clock, int data)
     955{
     956        ice1712_t *ice = snd_magic_cast(ice1712_t, bus->private_data, return);
     957        unsigned char mask = 0;
     958
     959        if (clock)
     960                mask |= ICE1712_EWX2496_SERIAL_CLOCK; /* write SCL */
     961        if (data)
     962                mask |= ICE1712_EWX2496_SERIAL_DATA; /* write SDA */
     963        ice->gpio_direction &= ~(ICE1712_EWX2496_SERIAL_CLOCK|ICE1712_EWX2496_SERIAL_DATA);
     964        ice->gpio_direction |= mask;
    1080965        snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, ice->gpio_direction);
    1081         /* set write mask only to SCL */
    1082         snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_SERIAL_CLOCK);
    1083 }
    1084 
    1085 static void ewx_i2c_read_post(ice1712_t *ice)
    1086 {
    1087         /* reset direction both SDA and SCL to write */
    1088         ice->gpio_direction |= ICE1712_EWX2496_SERIAL_CLOCK|ICE1712_EWX2496_SERIAL_DATA;
    1089         snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, ice->gpio_direction);
    1090         snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~(ICE1712_EWX2496_SERIAL_CLOCK|ICE1712_EWX2496_SERIAL_DATA));
    1091 }
    1092 
    1093 /* read a byte (and ack bit) */
    1094 static unsigned char ewx_i2c_read(ice1712_t *ice)
    1095 {
    1096         int i;
    1097         unsigned char data = 0;
    1098 
    1099         for (i = 7; i >= 0; i--) {
    1100                 ewx_i2c_set(ice, 1, 0);
    1101                 data |= ewx_i2c_read_bit(ice) << i;
    1102                 /* reset write mask */
    1103                 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK,
    1104                                   ~ICE1712_EWX2496_SERIAL_CLOCK);
    1105                 ewx_i2c_set(ice, 0, 0);
    1106         }
    1107         /* reset write mask */
    1108         ewx_i2c_read_post(ice);
    1109         ewx_i2c_send(ice, 1); /* ack */
    1110         return data;
    1111 }
    1112 
    1113 
    1114 /*
    1115  * CS8427 on EWX 24/96; Address 0x20
    1116  */
    1117 /* write a register */
    1118 static void snd_ice1712_ewx_cs8427_write(ice1712_t *ice, unsigned char reg, unsigned char data)
    1119 {
    1120         unsigned char saved[2];
    1121 
    1122         save_gpio_status(ice, saved);
    1123         ewx_i2c_write_prepare(ice);
    1124         ewx_i2c_write(ice, 0x20);  /* address + write */
    1125         ewx_i2c_write(ice, reg); /* MAP */
    1126         ewx_i2c_write(ice, data);
    1127         ewx_i2c_stop(ice);
    1128         restore_gpio_status(ice, saved);
    1129 }
    1130 
    1131 /* sequential write */
    1132 static void snd_ice1712_ewx_cs8427_write_bytes(ice1712_t *ice, unsigned char reg, int bytes, unsigned char *data)
    1133 {
    1134         unsigned char saved[2];
    1135 
    1136         save_gpio_status(ice, saved);
    1137         ewx_i2c_write_prepare(ice);
    1138         ewx_i2c_write(ice, 0x20);  /* address + write */
    1139         ewx_i2c_write(ice, reg | 0x80); /* MAP incremental mode */
    1140         while (bytes-- > 0)
    1141                 ewx_i2c_write(ice, *data++);
    1142         ewx_i2c_stop(ice);
    1143         restore_gpio_status(ice, saved);
    1144 }
    1145 
    1146 /* read a register */
    1147 static unsigned char snd_ice1712_ewx_cs8427_read(ice1712_t *ice, unsigned char reg)
    1148 {
    1149         unsigned char saved[2];
    1150         unsigned char data;
    1151 
    1152         save_gpio_status(ice, saved);
    1153         ewx_i2c_write_prepare(ice);
    1154         ewx_i2c_write(ice, 0x20);  /* address + write */
    1155         ewx_i2c_write(ice, reg); /* MAP */
    1156         /* we set up the address first but without data */
    1157         ewx_i2c_stop(ice);
    1158 
    1159         /* now read */
    1160         ewx_i2c_start(ice);
    1161         ewx_i2c_write(ice, 0x21);  /* address + read */
    1162         ewx_i2c_read_prepare(ice);
    1163         data = ewx_i2c_read(ice);
    1164         ewx_i2c_read_post(ice);
    1165         ewx_i2c_stop(ice);
    1166 
    1167         restore_gpio_status(ice, saved);
    1168         return data;
    1169 }
    1170 
    1171 /* sequential read  */
    1172 static void snd_ice1712_ewx_cs8427_read_bytes(ice1712_t *ice, unsigned char reg, int bytes, unsigned char *data)
    1173 {
    1174 #if 0 // the sequential read seems not working (yet)..
    1175         unsigned char saved[2];
    1176 
    1177         save_gpio_status(ice, saved);
    1178         ewx_i2c_write_prepare(ice);
    1179         ewx_i2c_write(ice, 0x20);  /* address + write */
    1180         ewx_i2c_write(ice, reg | 0x80); /* MAP incremental mode */
    1181         /* we set up the address first but without data */
    1182         ewx_i2c_stop(ice);
    1183 
    1184         /* now read */
    1185         ewx_i2c_start(ice);
    1186         ewx_i2c_write(ice, 0x21);  /* address + read */
    1187         ewx_i2c_read_prepare(ice);
    1188         while (bytes-- > 0)
    1189                 *data++ = ewx_i2c_read(ice);
    1190         ewx_i2c_read_post(ice);
    1191         ewx_i2c_stop(ice);
    1192         restore_gpio_status(ice, saved);
    1193 #else
    1194         while (bytes-- > 0)
    1195                 *data++ = snd_ice1712_ewx_cs8427_read(ice, reg++);
    1196 #endif
     966        snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~mask);
    1197967}
    1198968
    1199969#ifdef TARGET_OS2
    1200 static ice1712_cs8427_ops_t snd_ice1712_ewx_cs8427_ops = {
    1201         snd_ice1712_ewx_cs8427_write,
    1202         snd_ice1712_ewx_cs8427_read,
    1203         snd_ice1712_ewx_cs8427_write_bytes,
    1204         snd_ice1712_ewx_cs8427_read_bytes,
     970static snd_i2c_bit_ops_t snd_ice1712_ewx_cs8427_bit_ops = {
     971        ewx_i2c_start,
     972        ewx_i2c_stop,
     973        ewx_i2c_direction,
     974        ewx_i2c_setlines,
     975        ewx_i2c_getclock,
     976        ewx_i2c_getdata,
    1205977};
    1206978#else
    1207 static ice1712_cs8427_ops_t snd_ice1712_ewx_cs8427_ops = {
    1208         write: snd_ice1712_ewx_cs8427_write,
    1209         read: snd_ice1712_ewx_cs8427_read,
    1210         write_bytes: snd_ice1712_ewx_cs8427_write_bytes,
    1211         read_bytes: snd_ice1712_ewx_cs8427_read_bytes,
     979static snd_i2c_bit_ops_t snd_ice1712_ewx_cs8427_bit_ops = {
     980        start: ewx_i2c_start,
     981        stop: ewx_i2c_stop,
     982        direction: ewx_i2c_direction,
     983        setlines: ewx_i2c_setlines,
     984        getclock: ewx_i2c_getclock,
     985        getdata: ewx_i2c_getdata,
    1212986};
    1213987#endif
    1214988
    1215 /*
    1216  * PCF8574 on EWS88MT
    1217  */
    1218 static void snd_ice1712_ews88mt_pcf8574_write(ice1712_t *ice, unsigned char addr, unsigned char data)
    1219 {
    1220         ewx_i2c_write_prepare(ice);
    1221         ewx_i2c_write(ice, addr); /* address + write */
    1222         ewx_i2c_write(ice, data);
    1223         ewx_i2c_stop(ice);
    1224 }
    1225 
    1226 static unsigned char snd_ice1712_ews88mt_pcf8574_read(ice1712_t *ice, unsigned char addr)
    1227 {
    1228         unsigned char data;
    1229         ewx_i2c_write_prepare(ice);
    1230         ewx_i2c_write(ice, addr | 0x01);  /* address + read */
    1231         ewx_i2c_read_prepare(ice);
    1232         data = ewx_i2c_read(ice);
    1233         ewx_i2c_read_post(ice);
    1234         ewx_i2c_stop(ice);
    1235         return data;
    1236 }
    1237 
    1238989/* AK4524 chip select; address 0x48 bit 0-3 */
    1239990static void snd_ice1712_ews88mt_chip_select(ice1712_t *ice, int chip_mask)
     
    1242993
    1243994        snd_assert(chip_mask >= 0 && chip_mask <= 0x0f, return);
    1244         data = snd_ice1712_ews88mt_pcf8574_read(ice, ICE1712_EWS88MT_OUTPUT_ADDR);
     995        snd_i2c_lock(ice->i2c);
     996        snd_runtime_check(snd_i2c_readbytes(ice->pcf8574[1], &data, 1) == 1, snd_i2c_unlock(ice->i2c); return);
    1245997        ndata = (data & 0xf0) | chip_mask;
    1246998        if (ndata != data)
    1247                 snd_ice1712_ews88mt_pcf8574_write(ice, ICE1712_EWS88MT_OUTPUT_ADDR, ndata);
    1248 }
    1249 
    1250 
    1251 /*
    1252  * PCF8575 on EWS88D (16bit)
    1253  */
    1254 static void snd_ice1712_ews88d_pcf8575_write(ice1712_t *ice, unsigned char addr, unsigned short data)
    1255 {
    1256         ewx_i2c_write_prepare(ice);
    1257         ewx_i2c_write(ice, addr); /* address + write */
    1258         ewx_i2c_write(ice, data & 0xff);
    1259         ewx_i2c_write(ice, (data >> 8) & 0xff);
    1260         ewx_i2c_stop(ice);
    1261 }
    1262 
    1263 static unsigned short snd_ice1712_ews88d_pcf8575_read(ice1712_t *ice, unsigned char addr)
    1264 {
    1265         unsigned short data;
    1266         ewx_i2c_write_prepare(ice);
    1267         ewx_i2c_write(ice, addr | 0x01);  /* address + read */
    1268         ewx_i2c_read_prepare(ice);
    1269         data = ewx_i2c_read(ice);
    1270         data |= (unsigned short)ewx_i2c_read(ice) << 8;
    1271         //printk("pcf: read = 0x%x\n", data);
    1272         ewx_i2c_read_post(ice);
    1273         ewx_i2c_stop(ice);
    1274         return data;
     999                snd_runtime_check(snd_i2c_sendbytes(ice->pcf8574[1], &ndata, 1) == 1, snd_i2c_unlock(ice->i2c); return);
     1000        snd_i2c_unlock(ice->i2c);
    12751001}
    12761002
     
    12861012        unsigned int addrdata;
    12871013
    1288         snd_assert(chip >=0 && chip < 4, return);
     1014        snd_assert(chip >= 0 && chip < 4, return);
     1015
    12891016        if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_EWS88MT) {
    12901017                /* assert AK4524 CS */
     
    13271054                                  ~(data_mask | clk_mask |
    13281055                                    codecs_mask | ICE1712_EWS88_RW));
     1056                cif = 1; /* CIF high */
     1057                break;
     1058        case ICE1712_SUBDEVICE_DMX6FIRE:
     1059                data_mask = ICE1712_6FIRE_SERIAL_DATA;
     1060                clk_mask = ICE1712_6FIRE_SERIAL_CLOCK;
     1061                codecs_mask = (1 << chip) & ICE1712_6FIRE_AK4524_CS_MASK;
     1062                tmp |= ICE1712_6FIRE_RW; /* set rw bit high */
     1063                snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION,
     1064                                  ice->gpio_direction | data_mask | clk_mask |
     1065                                  codecs_mask | ICE1712_6FIRE_RW);
     1066                snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK,
     1067                                  ~(data_mask | clk_mask |
     1068                                    codecs_mask | ICE1712_6FIRE_RW));
    13291069                cif = 1; /* CIF high */
    13301070                break;
     
    13601100
    13611101        if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_EWS88MT) {
     1102                restore_gpio_status(ice, saved);
    13621103                //snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f);
    13631104                udelay(1);
     
    13731114                snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
    13741115                udelay(1);
    1375         }
    1376 
     1116                restore_gpio_status(ice, saved);
     1117        }
     1118
     1119        if ((addr != 0x04 && addr != 0x05) || (data & 0x80) == 0)
    13771120        ice->ak4524_images[chip][addr] = data;
    1378         restore_gpio_status(ice, saved);
    1379 }
    1380 
    1381 
    1382 /*
    1383  * decode/encode channel status bits from CS8404A on EWS88MT&D
    1384  */
    1385 static void snd_ice1712_ews_decode_cs8404_spdif_bits(snd_aes_iec958_t *diga,
    1386                                                      unsigned char bits)
    1387 {
    1388         if (bits & 0x10) {      /* consumer */
    1389                 if (!(bits & 0x20))
    1390                         diga->status[0] |= IEC958_AES0_CON_NOT_COPYRIGHT;
    1391                 if (!(bits & 0x40))
    1392                         diga->status[0] |= IEC958_AES0_CON_EMPHASIS_5015;
    1393                 if (!(bits & 0x80))
    1394                         diga->status[1] |= IEC958_AES1_CON_ORIGINAL;
    1395                 switch (bits & 0x03) {
    1396                 case 0x00: diga->status[1] |= IEC958_AES1_CON_DAT; break;
    1397                 case 0x03: diga->status[1] |= IEC958_AES1_CON_GENERAL; break;
    1398                 }
    1399                 switch (bits & 0x06) {
    1400                 case 0x02: diga->status[3] |= IEC958_AES3_CON_FS_32000; break;
    1401                 case 0x04: diga->status[3] |= IEC958_AES3_CON_FS_48000; break;
    1402                 case 0x06: diga->status[3] |= IEC958_AES3_CON_FS_44100; break;
    1403                 }
    1404         } else {
    1405                 diga->status[0] = IEC958_AES0_PROFESSIONAL;
    1406                 if (!(bits & 0x04))
    1407                         diga->status[0] |= IEC958_AES0_NONAUDIO;
    1408                 switch (bits & 0x60) {
    1409                 case 0x00: diga->status[0] |= IEC958_AES0_PRO_FS_32000; break;
    1410                 case 0x40: diga->status[0] |= IEC958_AES0_PRO_FS_44100; break;
    1411                 case 0x20: diga->status[0] |= IEC958_AES0_PRO_FS_48000; break;
    1412                 case 0x60: diga->status[0] |= IEC958_AES0_PRO_FS_NOTID; break;
    1413                 }
    1414                 switch (bits & 0x03) {
    1415                 case 0x02: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_NONE; break;
    1416                 case 0x01: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_5015; break;
    1417                 case 0x00: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_CCITT; break;
    1418                 case 0x03: diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_NOTID; break;
    1419                 }
    1420                 if (!(bits & 0x80))
    1421                         diga->status[1] |= IEC958_AES1_PRO_MODE_STEREOPHONIC;
    1422         }
    1423 }
    1424 
    1425 static unsigned char snd_ice1712_ews_encode_cs8404_spdif_bits(snd_aes_iec958_t *diga)
    1426 {
    1427         unsigned char bits;
    1428 
    1429         if (!(diga->status[0] & IEC958_AES0_PROFESSIONAL)) {
    1430                 bits = 0x10;    /* consumer mode */
    1431                 if (!(diga->status[0] & IEC958_AES0_CON_NOT_COPYRIGHT))
    1432                         bits |= 0x20;
    1433                 if ((diga->status[0] & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_NONE)
    1434                         bits |= 0x40;
    1435                 if (!(diga->status[1] & IEC958_AES1_CON_ORIGINAL))
    1436                         bits |= 0x80;
    1437                 if ((diga->status[1] & IEC958_AES1_CON_CATEGORY) == IEC958_AES1_CON_GENERAL)
    1438                         bits |= 0x03;
    1439                 switch (diga->status[3] & IEC958_AES3_CON_FS) {
    1440                 default:
    1441                 case IEC958_AES3_CON_FS_44100: bits |= 0x06; break;
    1442                 case IEC958_AES3_CON_FS_48000: bits |= 0x04; break;
    1443                 case IEC958_AES3_CON_FS_32000: bits |= 0x02; break;
    1444                 }
    1445         } else {
    1446                 bits = 0x00;    /* professional mode */
    1447                 if (!(diga->status[0] & IEC958_AES0_NONAUDIO))
    1448                         bits |= 0x04;
    1449                 switch (diga->status[0] & IEC958_AES0_PRO_FS) {
    1450                 case IEC958_AES0_PRO_FS_32000:  bits |= 0x00; break;
    1451                 case IEC958_AES0_PRO_FS_44100:  bits |= 0x40; break;    /* 44.1kHz */
    1452                 case IEC958_AES0_PRO_FS_48000:  bits |= 0x20; break;    /* 48kHz */
    1453                 default:
    1454                 case IEC958_AES0_PRO_FS_NOTID:  bits |= 0x00; break;
    1455                 }
    1456                 switch (diga->status[0] & IEC958_AES0_PRO_EMPHASIS) {
    1457                 case IEC958_AES0_PRO_EMPHASIS_NONE: bits |= 0x02; break;
    1458                 case IEC958_AES0_PRO_EMPHASIS_5015: bits |= 0x01; break;
    1459                 case IEC958_AES0_PRO_EMPHASIS_CCITT: bits |= 0x00; break;
    1460                 default:
    1461                 case IEC958_AES0_PRO_EMPHASIS_NOTID: bits |= 0x03; break;
    1462                 }
    1463                 switch (diga->status[1] & IEC958_AES1_PRO_MODE) {
    1464                 case IEC958_AES1_PRO_MODE_TWO:
    1465                 case IEC958_AES1_PRO_MODE_STEREOPHONIC: bits |= 0x00; break;
    1466                 default: bits |= 0x80; break;
    1467                 }
    1468         }
    1469         return bits;
    1470 }
    1471 
    1472 /* write on i2c address 0x40 */
     1121        else
     1122                ice->ak4524_ipga_gain[chip][addr-4] = data;
     1123}
     1124
     1125static void snd_ice1712_ak4524_reset(ice1712_t *ice, int state)
     1126{
     1127        int chip;
     1128        unsigned char reg;
     1129       
     1130        for (chip = 0; chip < ice->num_dacs/2; chip++) {
     1131                snd_ice1712_ak4524_write(ice, chip, 0x01, state ? 0x00 : 0x03);
     1132                if (state)
     1133                        continue;
     1134                for (reg = 0x04; reg < (ice->ak4528 ? 0x06 : 0x08); reg++)
     1135                        snd_ice1712_ak4524_write(ice, chip, reg, ice->ak4524_images[chip][reg]);
     1136                if (ice->ak4528)
     1137                        continue;
     1138                for (reg = 0x04; reg < 0x06; reg++)
     1139                        snd_ice1712_ak4524_write(ice, chip, reg, ice->ak4524_ipga_gain[chip][reg-4]);
     1140        }
     1141}
     1142
    14731143static void snd_ice1712_ews_cs8404_spdif_write(ice1712_t *ice, unsigned char bits)
    14741144{
    1475         unsigned short val, nval;
    1476 
     1145        unsigned char bytes[2];
     1146
     1147        snd_i2c_lock(ice->i2c);
    14771148        switch (ice->eeprom.subvendor) {
    14781149        case ICE1712_SUBDEVICE_EWS88MT:
    1479                 snd_ice1712_ews88mt_pcf8574_write(ice, ICE1712_EWS88MT_CS8404_ADDR, bits);
     1150                snd_runtime_check(snd_i2c_sendbytes(ice->cs8404, &bits, 1) == 1, snd_i2c_unlock(ice->i2c); return);
    14801151                break;
    14811152        case ICE1712_SUBDEVICE_EWS88D:
    1482                 val = snd_ice1712_ews88d_pcf8575_read(ice, ICE1712_EWS88D_PCF_ADDR);
    1483                 nval = val & 0xff;
    1484                 nval |= bits << 8;
    1485                 if (val != nval)
    1486                         snd_ice1712_ews88d_pcf8575_write(ice, ICE1712_EWS88D_PCF_ADDR, nval);
    1487                 break;
    1488         }
     1153                snd_runtime_check(snd_i2c_readbytes(ice->pcf8575, bytes, 2) == 2, snd_i2c_unlock(ice->i2c); return);
     1154                if (bits != bytes[1]) {
     1155                        bytes[1] = bits;
     1156                        snd_runtime_check(snd_i2c_readbytes(ice->pcf8575, bytes, 2) == 2, snd_i2c_unlock(ice->i2c); return);
     1157                }
     1158                break;
     1159        }
     1160        snd_i2c_unlock(ice->i2c);
    14891161}
    14901162
     
    14961168static int snd_ice1712_cs8427_set_input_clock(ice1712_t *ice, int spdif_clock)
    14971169{
     1170        unsigned char reg[2] = { 0x80 | 4, 0 };   /* CS8427 auto increment | register number 4 + data */
    14981171        unsigned char val, nval;
    1499         val = ice->cs8427_ops->read(ice, 4);
     1172        snd_i2c_lock(ice->i2c);
     1173        if (snd_i2c_sendbytes(ice->cs8427, reg, 1) != 1) {
     1174                snd_i2c_unlock(ice->i2c);
     1175                return -EREMOTE;
     1176        }
     1177        if (snd_i2c_readbytes(ice->cs8427, &val, 1) != 1) {
     1178                snd_i2c_unlock(ice->i2c);
     1179                return -EREMOTE;
     1180        }
    15001181        nval = val & 0xf0;
    15011182        if (spdif_clock)
     
    15041185                nval |= 0x04;
    15051186        if (val != nval) {
    1506                 ice->cs8427_ops->write(ice, 4, nval);
     1187                if (snd_i2c_sendbytes(ice->cs8427, reg, 2) != 2) {
     1188                        snd_i2c_unlock(ice->i2c);
     1189                        return -EREMOTE;
     1190                }
    15071191                return 1;
    15081192        }
    1509         return 0;
    1510 }
    1511 
    1512 #if 0 // we change clock selection automatically according to the ice1712 clock source
    1513 static int snd_ice1712_cs8427_clock_select_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
    1514 {
    1515         uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
    1516         uinfo->count = 1;
    1517         uinfo->value.integer.min = 0;
    1518         uinfo->value.integer.max = 1;
    1519         return 0;
    1520 }
    1521 
    1522 static int snd_ice1712_cs8427_clock_select_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
    1523 {
    1524         ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    1525         int val;
    1526         val = ice->cs8427_ops->read(ice, 4);
    1527         ucontrol->value.integer.value[0] = (val & 0x01) ? 1 : 0;
    1528         return 0;
    1529 }
    1530 
    1531 static int snd_ice1712_cs8427_clock_select_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
    1532 {
    1533         ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    1534         return snd_ice1712_cs8427_set_input_clock(ice, ucontrol->value.integer.value[0]);
    1535 }
    1536 
    1537 static snd_kcontrol_new_t snd_ice1712_cs8427_clock_select = {
    1538         iface: SNDRV_CTL_ELEM_IFACE_MIXER,
    1539         name: "CS8427 Clock Select",
    1540         info: snd_ice1712_cs8427_clock_select_info,
    1541         get: snd_ice1712_cs8427_clock_select_get,
    1542         put: snd_ice1712_cs8427_clock_select_put,
    1543 };
    1544 #endif
    1545 
    1546 
    1547 /*
    1548  */
    1549 static int snd_ice1712_cs8427_in_status_info(snd_kcontrol_t *kcontrol,
    1550                                              snd_ctl_elem_info_t *uinfo)
    1551 {
    1552         uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
    1553         uinfo->count = 1;
    1554         uinfo->value.integer.min = 0;
    1555         uinfo->value.integer.max = 255;
    1556         return 0;
    1557 }
    1558 
    1559 static int snd_ice1712_cs8427_in_status_get(snd_kcontrol_t *kcontrol,
    1560                                             snd_ctl_elem_value_t *ucontrol)
    1561 {
    1562         ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    1563         ucontrol->value.integer.value[0] = ice->cs8427_ops->read(ice, 15);
    1564         return 0;
    1565 }
    1566 
    1567 static snd_kcontrol_new_t snd_ice1712_cs8427_in_status = {
    1568 #ifdef TARGET_OS2
    1569         SNDRV_CTL_ELEM_IFACE_PCM,0,0,
    1570         "IEC958 Input Status",0,
    1571         SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
    1572         snd_ice1712_cs8427_in_status_info,
    1573         snd_ice1712_cs8427_in_status_get,0,0
    1574 #else
    1575         iface: SNDRV_CTL_ELEM_IFACE_PCM,
    1576         info: snd_ice1712_cs8427_in_status_info,
    1577         name: "IEC958 Input Status",
    1578         access: SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
    1579         get: snd_ice1712_cs8427_in_status_get,
    1580 #endif
    1581 };
    1582 
     1193        snd_i2c_unlock(ice->i2c);
     1194        return 0;
     1195}
    15831196
    15841197/*
     
    16241237        case ICE1712_SUBDEVICE_DELTA44:
    16251238        case ICE1712_SUBDEVICE_AUDIOPHILE:
    1626                 /* FIXME: we should put AK452x codecs to reset state
    1627                    when this bit is being changed */
    16281239                spin_unlock_irqrestore(&ice->reg_lock, flags);
     1240                snd_ice1712_ak4524_reset(ice, 1);
    16291241                down(&ice->gpio_mutex);
    16301242                tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
     
    16361248                snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
    16371249                up(&ice->gpio_mutex);
     1250                snd_ice1712_ak4524_reset(ice, 0);
    16381251                return;
    16391252        }
     
    21971810#endif
    21981811
    2199 static void __exit snd_ice1712_pcm_free(snd_pcm_t *pcm)
     1812static void snd_ice1712_pcm_free(snd_pcm_t *pcm)
    22001813{
    22011814        ice1712_t *ice = snd_magic_cast(ice1712_t, pcm->private_data, return);
     
    22041817}
    22051818
    2206 static int __init snd_ice1712_pcm(ice1712_t * ice, int device, snd_pcm_t ** rpcm)
     1819static int __devinit snd_ice1712_pcm(ice1712_t * ice, int device, snd_pcm_t ** rpcm)
    22071820{
    22081821        snd_pcm_t *pcm;
     
    22291842                *rpcm = pcm;
    22301843
    2231         printk("Consumer PCM code does not work well at the moment --jk\n");
    2232 
    2233         return 0;
    2234 }
    2235 
    2236 static void __exit snd_ice1712_pcm_free_ds(snd_pcm_t *pcm)
     1844        printk(KERN_WARNING "Consumer PCM code does not work well at the moment --jk\n");
     1845
     1846        return 0;
     1847}
     1848
     1849static void snd_ice1712_pcm_free_ds(snd_pcm_t *pcm)
    22371850{
    22381851        ice1712_t *ice = snd_magic_cast(ice1712_t, pcm->private_data, return);
     
    22411854}
    22421855
    2243 static int __init snd_ice1712_pcm_ds(ice1712_t * ice, int device, snd_pcm_t ** rpcm)
     1856static int __devinit snd_ice1712_pcm_ds(ice1712_t * ice, int device, snd_pcm_t ** rpcm)
    22441857{
    22451858        snd_pcm_t *pcm;
     
    23841997}
    23851998
    2386 static void snd_ice1712_cs8427_set_status(ice1712_t *ice, snd_pcm_runtime_t *runtime,
    2387                                           unsigned char *status)
    2388 {
    2389         if (status[0] & IEC958_AES0_PROFESSIONAL) {
    2390                 status[0] &= ~IEC958_AES0_PRO_FS;
    2391                 switch (runtime->rate) {
    2392                 case 32000: status[0] |= IEC958_AES0_PRO_FS_32000; break;
    2393                 case 44100: status[0] |= IEC958_AES0_PRO_FS_44100; break;
    2394                 case 48000: status[0] |= IEC958_AES0_PRO_FS_48000; break;
    2395                 default: status[0] |= IEC958_AES0_PRO_FS_NOTID; break;
    2396                 }
    2397         } else {
    2398                 status[3] &= ~IEC958_AES3_CON_FS;
    2399                 switch (runtime->rate) {
    2400                 case 32000: status[3] |= IEC958_AES3_CON_FS_32000; break;
    2401                 case 44100: status[3] |= IEC958_AES3_CON_FS_44100; break;
    2402                 case 48000: status[3] |= IEC958_AES3_CON_FS_48000; break;
    2403                 }
    2404         }
    2405 }
    2406 
    24071999static int snd_ice1712_playback_pro_prepare(snd_pcm_substream_t * substream)
    24082000{
     
    24102002        ice1712_t *ice = snd_pcm_substream_chip(substream);
    24112003        unsigned int tmp;
    2412         unsigned char tmpst[5];
    24132004        int change;
    24142005
     
    24422033        case ICE1712_SUBDEVICE_EWX2496:
    24432034        case ICE1712_SUBDEVICE_AUDIOPHILE:
    2444                 /* setup S/PDIF */
    2445                 memcpy(tmpst, ice->cs8427_spdif_stream_status, 5);
    2446                 snd_ice1712_cs8427_set_status(ice, substream->runtime, tmpst);
    2447                 change = memcmp(tmpst, ice->cs8427_spdif_stream_status, 5) != 0;
    2448                 memcpy(ice->cs8427_spdif_stream_status, tmpst, 5);
    2449                 spin_unlock_irqrestore(&ice->reg_lock, flags);
    2450                 if (change) {
    2451                         snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &ice->spdif_stream_ctl->id);
    2452                         ice->cs8427_ops->write_bytes(ice, 32, 5, tmpst);
    2453                 }
    2454                 return 0;
     2035                snd_cs8427_iec958_pcm(ice->cs8427, substream->runtime->rate);
     2036                break;
    24552037        case ICE1712_SUBDEVICE_EWS88MT:
    24562038        case ICE1712_SUBDEVICE_EWS88D:
     
    26092191
    26102192        ice->cs8403_spdif_stream_bits = ice->cs8403_spdif_bits;
    2611         memcpy(ice->cs8427_spdif_stream_status, ice->cs8427_spdif_status, 5);
    2612         if (ice->spdif_stream_ctl != NULL) {
    2613                 ice->spdif_stream_ctl->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
    2614                 snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE |
    2615                                SNDRV_CTL_EVENT_MASK_INFO, &ice->spdif_stream_ctl->id);
    2616         }
     2193        if (ice->cs8427)
     2194                snd_cs8427_iec958_active(ice->cs8427, 1);
    26172195
    26182196        return 0;
     
    26372215
    26382216        ice->playback_pro_substream = NULL;
    2639 
    2640         if (ice->spdif_stream_ctl != NULL) {
    2641                 ice->spdif_stream_ctl->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
    2642                 snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE |
    2643                                SNDRV_CTL_EVENT_MASK_INFO, &ice->spdif_stream_ctl->id);
    2644         }
     2217        if (ice->cs8427)
     2218                snd_cs8427_iec958_active(ice->cs8427, 0);
    26452219
    26462220        return 0;
     
    26552229}
    26562230
    2657 static void __exit snd_ice1712_pcm_profi_free(snd_pcm_t *pcm)
     2231static void snd_ice1712_pcm_profi_free(snd_pcm_t *pcm)
    26582232{
    26592233        ice1712_t *ice = snd_magic_cast(ice1712_t, pcm->private_data, return);
     
    27082282#endif
    27092283
    2710 static int __init snd_ice1712_pcm_profi(ice1712_t * ice, int device, snd_pcm_t ** rpcm)
     2284static int __devinit snd_ice1712_pcm_profi(ice1712_t * ice, int device, snd_pcm_t ** rpcm)
    27112285{
    27122286        snd_pcm_t *pcm;
     
    27332307                *rpcm = pcm;
    27342308       
     2309        if (ice->cs8427) {
     2310                /* assign channels to iec958 */
     2311                err = snd_cs8427_iec958_build(ice->cs8427,
     2312                                              pcm->streams[0].substream,
     2313                                              pcm->streams[1].substream);
     2314                if (err < 0)
     2315                        return err;
     2316        }
     2317
    27352318        if ((err = snd_ice1712_build_pro_mixer(ice)) < 0)
    27362319                return err;
     
    28582441        unsigned char nval = ucontrol->value.integer.value[0];
    28592442        int change = ice->ak4524_images[chip][addr] != nval;
     2443        if (change)
     2444                snd_ice1712_ak4524_write(ice, chip, addr, nval);
     2445        return change;
     2446}
     2447
     2448static int snd_ice1712_ak4524_ipga_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     2449{
     2450        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
     2451        uinfo->count = 1;
     2452        uinfo->value.integer.min = 0;
     2453        uinfo->value.integer.max = 36;
     2454        return 0;
     2455}
     2456
     2457static int snd_ice1712_ak4524_ipga_gain_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
     2458{
     2459        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
     2460        int chip = kcontrol->private_value / 8;
     2461        int addr = kcontrol->private_value % 8;
     2462        ucontrol->value.integer.value[0] = ice->ak4524_ipga_gain[chip][addr-4] & 0x7f;
     2463        return 0;
     2464}
     2465
     2466static int snd_ice1712_ak4524_ipga_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
     2467{
     2468        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
     2469        int chip = kcontrol->private_value / 8;
     2470        int addr = kcontrol->private_value % 8;
     2471        unsigned char nval = (ucontrol->value.integer.value[0] % 37) | 0x80;
     2472        int change = ice->ak4524_ipga_gain[chip][addr] != nval;
    28602473        if (change)
    28612474                snd_ice1712_ak4524_write(ice, chip, addr, nval);
     
    29602573        }
    29612574       
    2962         return 0;
    2963 }
    2964 
    2965 static void /*__init*/ snd_ice1712_ac97_init(ac97_t *ac97)
     2575        /* initialize volumes */
     2576        for (idx = 0; idx < 20; idx++) {
     2577                ice->pro_volumes[idx] = 0x80008000;     /* mute */
     2578                snd_ice1712_update_volume(ice, idx);
     2579        }
     2580        return 0;
     2581}
     2582
     2583static void snd_ice1712_ac97_init(ac97_t *ac97)
    29662584{
    29672585        // ice1712_t *ice = snd_magic_cast(ice1712_t, ac97->private_data, return);
     
    29712589}
    29722590
    2973 static void __exit snd_ice1712_mixer_free_ac97(ac97_t *ac97)
     2591static void snd_ice1712_mixer_free_ac97(ac97_t *ac97)
    29742592{
    29752593        ice1712_t *ice = snd_magic_cast(ice1712_t, ac97->private_data, return);
     
    29772595}
    29782596
    2979 static int __init snd_ice1712_ac97_mixer(ice1712_t * ice)
     2597static int __devinit snd_ice1712_ac97_mixer(ice1712_t * ice)
    29802598{
    29812599        int err;
     
    29892607                ac97.private_data = ice;
    29902608                ac97.private_free = snd_ice1712_mixer_free_ac97;
    2991                 if ((err = snd_ac97_mixer(ice->card, &ac97, &ice->ac97)) < 0)
     2609                if ((err = snd_ac97_mixer(ice->card, &ac97, &ice->ac97)) < 0) {
     2610                        printk(KERN_WARNING "ice1712: cannot initialize ac97 for consumer, skipped\n");
     2611                        // return err;
     2612                } else {
     2613                if ((err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice))) < 0)
    29922614                        return err;
     2615                }
    29932616                return 0;
    29942617        }
     
    30032626                ac97.private_free = snd_ice1712_mixer_free_ac97;
    30042627                if ((err = snd_ac97_mixer(ice->card, &ac97, &ice->ac97)) < 0)
    3005                         return err;
    3006                 if ((err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice))) < 0)
    30072628                        return err;
    30082629                return 0;
     
    30472668}
    30482669
    3049 static void __init snd_ice1712_proc_init(ice1712_t * ice)
     2670static void __devinit snd_ice1712_proc_init(ice1712_t * ice)
    30502671{
    30512672        snd_info_entry_t *entry;
     
    30922713}
    30932714
    3094 static snd_kcontrol_new_t snd_ice1712_eeprom = {
     2715static snd_kcontrol_new_t snd_ice1712_eeprom __devinitdata = {
    30952716#ifdef TARGET_OS2
    30962717        SNDRV_CTL_ELEM_IFACE_CARD,0,0,
     
    31262747        case ICE1712_SUBDEVICE_DELTADIO2496:
    31272748        case ICE1712_SUBDEVICE_DELTA66:
    3128                 snd_ice1712_decode_cs8403_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_bits);
    3129                 break;
    3130         case ICE1712_SUBDEVICE_AUDIOPHILE:
    3131         case ICE1712_SUBDEVICE_EWX2496:
    3132                 memcpy(ucontrol->value.iec958.status, ice->cs8427_spdif_status, 5);
     2749                snd_cs8403_decode_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_bits);
    31332750                break;
    31342751        case ICE1712_SUBDEVICE_EWS88MT:
    31352752        case ICE1712_SUBDEVICE_EWS88D:
    3136                 snd_ice1712_ews_decode_cs8404_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_bits);
     2753                snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_bits);
    31372754                break;
    31382755        }
     
    31522769        case ICE1712_SUBDEVICE_DELTADIO2496:
    31532770        case ICE1712_SUBDEVICE_DELTA66:
    3154                 val = snd_ice1712_encode_cs8403_spdif_bits(&ucontrol->value.iec958);
     2771                val = snd_cs8403_encode_spdif_bits(&ucontrol->value.iec958);
    31552772                spin_lock_irqsave(&ice->reg_lock, flags);
    31562773                change = ice->cs8403_spdif_bits != val;
     
    31632780                }
    31642781                break;
    3165         case ICE1712_SUBDEVICE_AUDIOPHILE:
    3166         case ICE1712_SUBDEVICE_EWX2496:
    3167                 spin_lock_irqsave(&ice->reg_lock, flags);
    3168                 change = memcmp(ucontrol->value.iec958.status, ice->cs8427_spdif_status, 5) != 0;
    3169                 memcpy(ice->cs8427_spdif_status, ucontrol->value.iec958.status, 5);
    3170                 if (change && ice->playback_pro_substream == NULL) {
    3171                         spin_unlock_irqrestore(&ice->reg_lock, flags);
    3172                         ice->cs8427_ops->write_bytes(ice, 32, 5, ice->cs8427_spdif_status);
    3173                 } else
    3174                         spin_unlock_irqrestore(&ice->reg_lock, flags);
    3175                 break;
    31762782        case ICE1712_SUBDEVICE_EWS88MT:
    31772783        case ICE1712_SUBDEVICE_EWS88D:
    3178                 val = snd_ice1712_ews_encode_cs8404_spdif_bits(&ucontrol->value.iec958);
     2784                val = snd_cs8404_encode_spdif_bits(&ucontrol->value.iec958);
    31792785                spin_lock_irqsave(&ice->reg_lock, flags);
    31802786                change = ice->cs8403_spdif_bits != val;
     
    31932799}
    31942800
    3195 static snd_kcontrol_new_t snd_ice1712_spdif_default =
     2801static snd_kcontrol_new_t snd_ice1712_spdif_default __devinitdata =
    31962802{
    31972803#ifdef TARGET_OS2
     
    32772883}
    32782884
    3279 static snd_kcontrol_new_t snd_ice1712_spdif_maskc =
     2885static snd_kcontrol_new_t snd_ice1712_spdif_maskc __devinitdata =
    32802886{
    32812887#ifdef TARGET_OS2
     
    32942900};
    32952901
    3296 static snd_kcontrol_new_t snd_ice1712_spdif_maskp =
     2902static snd_kcontrol_new_t snd_ice1712_spdif_maskp __devinitdata =
    32972903{
    32982904#ifdef TARGET_OS2
     
    33272933        case ICE1712_SUBDEVICE_DELTADIO2496:
    33282934        case ICE1712_SUBDEVICE_DELTA66:
    3329                 snd_ice1712_decode_cs8403_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_stream_bits);
    3330                 break;
    3331         case ICE1712_SUBDEVICE_AUDIOPHILE:
    3332         case ICE1712_SUBDEVICE_EWX2496:
    3333                 //ice->cs8427_ops->read_bytes(ice, 32, 5, ucontrol->value.iec958.status);
    3334                 memcpy(ucontrol->value.iec958.status, ice->cs8427_spdif_stream_status, 5);
     2935                snd_cs8403_decode_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_stream_bits);
    33352936                break;
    33362937        case ICE1712_SUBDEVICE_EWS88MT:
    33372938        case ICE1712_SUBDEVICE_EWS88D:
    3338                 snd_ice1712_ews_decode_cs8404_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_stream_bits);
     2939                snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->cs8403_spdif_stream_bits);
    33392940                break;
    33402941        }
     
    33542955        case ICE1712_SUBDEVICE_DELTADIO2496:
    33552956        case ICE1712_SUBDEVICE_DELTA66:
    3356                 val = snd_ice1712_encode_cs8403_spdif_bits(&ucontrol->value.iec958);
     2957                val = snd_cs8403_encode_spdif_bits(&ucontrol->value.iec958);
    33572958                spin_lock_irqsave(&ice->reg_lock, flags);
    33582959                change = ice->cs8403_spdif_stream_bits != val;
     
    33652966                }
    33662967                break;
    3367         case ICE1712_SUBDEVICE_AUDIOPHILE:
    3368         case ICE1712_SUBDEVICE_EWX2496:
    3369                 spin_lock_irqsave(&ice->reg_lock, flags);
    3370                 change = memcmp(ice->cs8427_spdif_stream_status,
    3371                                 ucontrol->value.iec958.status, 5) != 0;
    3372                 if (change && ice->playback_pro_substream != NULL) {
    3373                         memcpy(ice->cs8427_spdif_stream_status,
    3374                                ucontrol->value.iec958.status, 5);
    3375                         spin_unlock_irqrestore(&ice->reg_lock, flags);
    3376                         ice->cs8427_ops->write_bytes(ice, 32, 5, ucontrol->value.iec958.status);
    3377                 } else
    3378                         spin_unlock_irqrestore(&ice->reg_lock, flags);
    3379                 break;
    33802968        case ICE1712_SUBDEVICE_EWS88MT:
    33812969        case ICE1712_SUBDEVICE_EWS88D:
    3382                 val = snd_ice1712_ews_encode_cs8404_spdif_bits(&ucontrol->value.iec958);
     2970                val = snd_cs8404_encode_spdif_bits(&ucontrol->value.iec958);
    33832971                spin_lock_irqsave(&ice->reg_lock, flags);
    33842972                change = ice->cs8403_spdif_stream_bits != val;
     
    33972985}
    33982986
    3399 static snd_kcontrol_new_t snd_ice1712_spdif_stream =
     2987static snd_kcontrol_new_t snd_ice1712_spdif_stream __devinitdata =
    34002988{
    34012989#ifdef TARGET_OS2
     
    34173005
    34183006#ifdef TARGET_OS2
    3419 #define ICE1712_GPIO(xiface, xname, xindex, shift, xaccess) \
     3007#define ICE1712_GPIO(xiface, xname, xindex, mask, invert, xaccess) \
    34203008{ xiface, 0, 0, xname, 0, xaccess, snd_ice1712_gpio_info, \
    34213009  snd_ice1712_gpio_get, snd_ice1712_gpio_put, \
    3422   shift }
     3010        mask | (invert << 24) }
    34233011#else
    3424 #define ICE1712_GPIO(xiface, xname, xindex, shift, xaccess) \
     3012#define ICE1712_GPIO(xiface, xname, xindex, mask, invert, xaccess) \
    34253013{ iface: xiface, name: xname, access: xaccess, info: snd_ice1712_gpio_info, \
    34263014  get: snd_ice1712_gpio_get, put: snd_ice1712_gpio_put, \
    3427   private_value: shift }
     3015  private_value: mask | (invert << 24) }
    34283016#endif
    34293017
     
    34413029        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    34423030        unsigned char mask = kcontrol->private_value & 0xff;
     3031        int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0;
    34433032        unsigned char saved[2];
    34443033       
    34453034        save_gpio_status(ice, saved);
    3446         ucontrol->value.integer.value[0] = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & mask ? 1 : 0;
     3035        ucontrol->value.integer.value[0] = (snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & mask ? 1 : 0) ^ invert;
    34473036        restore_gpio_status(ice, saved);
    34483037        return 0;
     
    34533042        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    34543043        unsigned char mask = kcontrol->private_value & 0xff;
     3044        int invert = (kcontrol->private_value & (1<<24)) ? mask : 0;
    34553045        unsigned char saved[2];
    34563046        int val, nval;
     
    34583048        if (kcontrol->private_value & (1 << 31))
    34593049                return -EPERM;
    3460         nval = ucontrol->value.integer.value[0] ? mask : 0;
     3050        nval = (ucontrol->value.integer.value[0] ? mask : 0) ^ invert;
    34613051        save_gpio_status(ice, saved);
    34623052        val = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
     
    34673057}
    34683058
    3469 static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_select =
    3470 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 0);
    3471 static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_status =
    3472 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
    3473 static snd_kcontrol_new_t snd_ice1712_deltadio2496_spdif_in_select =
    3474 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0);
    3475 static snd_kcontrol_new_t snd_ice1712_delta_spdif_in_status =
    3476 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
     3059static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_select __devinitdata =
     3060ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0);
     3061static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_status __devinitdata =
     3062ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
     3063static snd_kcontrol_new_t snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
     3064ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0);
     3065static snd_kcontrol_new_t snd_ice1712_delta_spdif_in_status __devinitdata =
     3066ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_PCM, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
    34773067
    34783068static int snd_ice1712_pro_spdif_master_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     
    35093099        spin_unlock_irqrestore(&ice->reg_lock, flags);
    35103100
    3511         if (ice->cs8427_ops) {
     3101        if (ice->cs8427) {
    35123102                /* change CS8427 clock source too */
    35133103                snd_ice1712_cs8427_set_input_clock(ice, ucontrol->value.integer.value[0]);
     
    35173107}
    35183108
    3519 static snd_kcontrol_new_t snd_ice1712_pro_spdif_master = {
     3109static snd_kcontrol_new_t snd_ice1712_pro_spdif_master __devinitdata = {
    35203110#ifdef TARGET_OS2
    35213111        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    35633153        val >>= ((idx % 2) * 8) + ((idx / 2) * 2);
    35643154        val &= 3;
    3565         cval = inw(ICEMT(ice, ROUTE_CAPTURE));
     3155        cval = inl(ICEMT(ice, ROUTE_CAPTURE));
    35663156        cval >>= ((idx / 2) * 8) + ((idx % 2) * 4);
    35673157        if (val == 1 && idx < 2)
     
    35853175        /* update PSDOUT */
    35863176        if (ucontrol->value.enumerated.item[0] >= 11)
    3587                 nval = idx < 2 ? 1 : 0;
     3177                nval = idx < 2 ? 1 : 0; /* dig mixer (or pcm) */
    35883178        else if (ucontrol->value.enumerated.item[0] >= 9)
    3589                 nval = 3;
     3179                nval = 3; /* spdif in */
    35903180        else if (ucontrol->value.enumerated.item[0] >= 1)
    3591                 nval = 2;
     3181                nval = 2; /* analog in */
    35923182        else
    3593                 nval = 0;
     3183                nval = 0; /* pcm */
    35943184        shift = ((idx % 2) * 8) + ((idx / 2) * 2);
    35953185        val = old_val = inw(ICEMT(ice, ROUTE_PSDOUT03));
     
    35993189        if (change)
    36003190                outw(val, ICEMT(ice, ROUTE_PSDOUT03));
    3601         if (nval < 2)
     3191        if (nval < 2) /* dig mixer of pcm */
    36023192                return change;
    36033193
    36043194        /* update CAPTURE */
    3605         val = old_val = inw(ICEMT(ice, ROUTE_CAPTURE));
     3195        val = old_val = inl(ICEMT(ice, ROUTE_CAPTURE));
    36063196        shift = ((idx / 2) * 8) + ((idx % 2) * 4);
    3607         if (nval == 2) {
     3197        if (nval == 2) { /* analog in */
    36083198                nval = ucontrol->value.enumerated.item[0] - 1;
    36093199                val &= ~(0x07 << shift);
    36103200                val |= nval << shift;
    3611         } else {
     3201        } else { /* spdif in */
    36123202                nval = (ucontrol->value.enumerated.item[0] - 9) << 3;
    36133203                val &= ~(0x08 << shift);
     
    36163206        if (val != old_val) {
    36173207                change = 1;
    3618                 outw(val, ICEMT(ice, ROUTE_CAPTURE));
     3208                outl(val, ICEMT(ice, ROUTE_CAPTURE));
    36193209        }
    36203210        return change;
     
    36763266}
    36773267
    3678 static snd_kcontrol_new_t snd_ice1712_mixer_pro_analog_route = {
     3268static snd_kcontrol_new_t snd_ice1712_mixer_pro_analog_route __devinitdata = {
    36793269#ifdef TARGET_OS2
    36803270        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    36923282};
    36933283
    3694 static snd_kcontrol_new_t snd_ice1712_mixer_pro_spdif_route = {
     3284static snd_kcontrol_new_t snd_ice1712_mixer_pro_spdif_route __devinitdata = {
    36953285#ifdef TARGET_OS2
    36963286        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    37423332}
    37433333
    3744 static snd_kcontrol_new_t snd_ice1712_mixer_pro_volume_rate = {
     3334static snd_kcontrol_new_t snd_ice1712_mixer_pro_volume_rate __devinitdata = {
    37453335#ifdef TARGET_OS2
    37463336        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    37823372}
    37833373
    3784 static snd_kcontrol_new_t snd_ice1712_mixer_pro_peak = {
     3374static snd_kcontrol_new_t snd_ice1712_mixer_pro_peak __devinitdata = {
    37853375#ifdef TARGET_OS2
    37863376        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    38463436}
    38473437
    3848 static snd_kcontrol_new_t snd_ice1712_ewx_input_sense = {
     3438static snd_kcontrol_new_t snd_ice1712_ewx_input_sense __devinitdata = {
    38493439#ifdef TARGET_OS2
    38503440        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    38643454};
    38653455
    3866 static snd_kcontrol_new_t snd_ice1712_ewx_output_sense = {
     3456static snd_kcontrol_new_t snd_ice1712_ewx_output_sense __devinitdata = {
    38673457#ifdef TARGET_OS2
    38683458        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    38903480{
    38913481        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    3892         unsigned char saved[2];
    38933482        unsigned char data;
    38943483
    3895         save_gpio_status(ice, saved);
    3896         data = snd_ice1712_ews88mt_pcf8574_read(ice, ICE1712_EWS88MT_OUTPUT_ADDR);
    3897         restore_gpio_status(ice, saved);
     3484        snd_i2c_lock(ice->i2c);
     3485        if (snd_i2c_readbytes(ice->pcf8574[1], &data, 1) != 1) {
     3486                snd_i2c_unlock(ice->i2c);
     3487                return -EREMOTE;
     3488        }
     3489        snd_i2c_unlock(ice->i2c);
    38983490        ucontrol->value.enumerated.item[0] = data & ICE1712_EWS88MT_OUTPUT_SENSE ? 1 : 0; /* high = -10dBV, low = +4dBu */
    38993491        return 0;
     
    39043496{
    39053497        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    3906         unsigned char saved[2];
    39073498        unsigned char data, ndata;
    39083499
    3909         save_gpio_status(ice, saved);
    3910         data = snd_ice1712_ews88mt_pcf8574_read(ice, ICE1712_EWS88MT_OUTPUT_ADDR);
     3500        snd_i2c_lock(ice->i2c);
     3501        if (snd_i2c_readbytes(ice->pcf8574[1], &data, 1) != 1) {
     3502                snd_i2c_unlock(ice->i2c);
     3503                return -EREMOTE;
     3504        }
    39113505        ndata = (data & ~ICE1712_EWS88MT_OUTPUT_SENSE) | (ucontrol->value.enumerated.item[0] ? ICE1712_EWS88MT_OUTPUT_SENSE : 0);
    3912         if (ndata != data)
    3913                 snd_ice1712_ews88mt_pcf8574_write(ice, ICE1712_EWS88MT_OUTPUT_ADDR, ndata);
    3914         restore_gpio_status(ice, saved);
     3506        if (ndata != data && snd_i2c_sendbytes(ice->pcf8574[1], &ndata, 1) != 1) {
     3507                snd_i2c_unlock(ice->i2c);
     3508                return -EREMOTE;
     3509        }
     3510        snd_i2c_unlock(ice->i2c);
    39153511        return ndata != data;
    3916 
    39173512}
    39183513
     
    39223517        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    39233518        int channel = kcontrol->id.index;
    3924         unsigned char saved[2];
    39253519        unsigned char data;
    39263520
    39273521        snd_assert(channel >= 0 && channel <= 7, return 0);
    3928         save_gpio_status(ice, saved);
    3929         data = snd_ice1712_ews88mt_pcf8574_read(ice, ICE1712_EWS88MT_INPUT_ADDR);
    3930         restore_gpio_status(ice, saved);
     3522        snd_i2c_lock(ice->i2c);
     3523        if (snd_i2c_readbytes(ice->pcf8574[0], &data, 1) != 1) {
     3524                snd_i2c_unlock(ice->i2c);
     3525                return -EREMOTE;
     3526        }
    39313527        /* reversed; high = +4dBu, low = -10dBV */
    39323528        ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;
     
    39393535        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
    39403536        int channel = kcontrol->id.index;
    3941         unsigned char saved[2];
    39423537        unsigned char data, ndata;
    39433538
    39443539        snd_assert(channel >= 0 && channel <= 7, return 0);
    3945         save_gpio_status(ice, saved);
    3946         data = snd_ice1712_ews88mt_pcf8574_read(ice, ICE1712_EWS88MT_INPUT_ADDR);
     3540        snd_i2c_lock(ice->i2c);
     3541        if (snd_i2c_readbytes(ice->pcf8574[0], &data, 1) != 1) {
     3542                snd_i2c_unlock(ice->i2c);
     3543                return -EREMOTE;
     3544        }
    39473545        ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
    3948         if (ndata != data)
    3949                 snd_ice1712_ews88mt_pcf8574_write(ice, ICE1712_EWS88MT_INPUT_ADDR, ndata);
    3950         restore_gpio_status(ice, saved);
     3546        if (ndata != data && snd_i2c_sendbytes(ice->pcf8574[0], &ndata, 1) != 1) {
     3547                snd_i2c_unlock(ice->i2c);
     3548                return -EREMOTE;
     3549        }
     3550        snd_i2c_unlock(ice->i2c);
    39513551        return ndata != data;
    39523552}
    39533553
    3954 static snd_kcontrol_new_t snd_ice1712_ews88mt_input_sense = {
     3554static snd_kcontrol_new_t snd_ice1712_ews88mt_input_sense __devinitdata = {
    39553555#ifdef TARGET_OS2
    39563556        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    39683568};
    39693569
    3970 static snd_kcontrol_new_t snd_ice1712_ews88mt_output_sense = {
     3570static snd_kcontrol_new_t snd_ice1712_ews88mt_output_sense __devinitdata = {
    39713571#ifdef TARGET_OS2
    39723572        SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
     
    40033603        int shift = kcontrol->private_value & 0xff;
    40043604        int invert = (kcontrol->private_value >> 8) & 1;
    4005         unsigned short data;
     3605        unsigned char data[2];
    40063606       
    4007         data = snd_ice1712_ews88d_pcf8575_read(ice, ICE1712_EWS88D_PCF_ADDR);
    4008         //printk("pcf: read 0x%x\n", data);
    4009         data = (data >> shift) & 0x01;
     3607        snd_i2c_lock(ice->i2c);
     3608        if (snd_i2c_readbytes(ice->pcf8575, data, 2) != 2) {
     3609                snd_i2c_unlock(ice->i2c);
     3610                return -EREMOTE;
     3611        }
     3612        snd_i2c_unlock(ice->i2c);
     3613        data[0] = (data[shift >> 3] >> (shift & 7)) & 0x01;
    40103614        if (invert)
    4011                 data ^= 0x01;
    4012         ucontrol->value.integer.value[0] = data;
     3615                data[0] ^= 0x01;
     3616        ucontrol->value.integer.value[0] = data[0];
    40133617        return 0;
    40143618}
     
    40193623        int shift = kcontrol->private_value & 0xff;
    40203624        int invert = (kcontrol->private_value >> 8) & 1;
    4021         unsigned short data, ndata;
     3625        unsigned char data[2], ndata[2];
    40223626        int change;
    40233627
    4024         data = snd_ice1712_ews88d_pcf8575_read(ice, ICE1712_EWS88D_PCF_ADDR);
    4025         ndata = data & ~(1 << shift);
     3628        snd_i2c_lock(ice->i2c);
     3629        if (snd_i2c_readbytes(ice->pcf8575, data, 2) != 2) {
     3630                snd_i2c_unlock(ice->i2c);
     3631                return -EREMOTE;
     3632        }
     3633        ndata[shift >> 3] = data[shift >> 3] & ~(1 << (shift & 7));
    40263634        if (invert) {
    40273635                if (! ucontrol->value.integer.value[0])
    4028                         ndata |= (1 << shift);
     3636                        ndata[shift >> 3] |= (1 << (shift & 7));
    40293637        } else {
    40303638                if (ucontrol->value.integer.value[0])
    4031                         ndata |= (1 << shift);
    4032         }
    4033         change = (data != ndata);
    4034         if (change) {
    4035                 ndata &= 0xff;
    4036                 ndata |= (unsigned short)ice->cs8403_spdif_stream_bits << 8;
    4037                 snd_ice1712_ews88d_pcf8575_write(ice, ICE1712_EWS88D_PCF_ADDR, ndata);
    4038                 //printk("pcf: write 0x%x\n", ndata);
    4039         }
     3639                        ndata[shift >> 3] |= (1 << (shift & 7));
     3640        }
     3641        change = (data[shift >> 3] != ndata[shift >> 3]);
     3642        if (change && snd_i2c_sendbytes(ice->pcf8575, data, 2) != 2) {
     3643                snd_i2c_unlock(ice->i2c);
     3644                return -EREMOTE;
     3645        }
     3646        snd_i2c_unlock(ice->i2c);
    40403647        return change;
    40413648}
    40423649
    40433650#ifdef TARGET_OS2
    4044 #define EWS88D_CONTROL(xiface, xname, xindex, xshift, xinvert, xaccess) \
     3651#define EWS88D_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
    40453652{ xiface,0,0,\
    40463653  xname, 0,\
     
    40523659}
    40533660#else
    4054 #define EWS88D_CONTROL(xiface, xname, xindex, xshift, xinvert, xaccess) \
     3661#define EWS88D_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
    40553662{ iface: xiface,\
    40563663  name: xname,\
     
    40633670#endif
    40643671
    4065 static snd_kcontrol_new_t snd_ice1712_ews88d_spdif_in_opt =
    4066 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 0, 1, 0); /* inverted */
    4067 static snd_kcontrol_new_t snd_ice1712_ews88d_opt_out_adat =
    4068 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 0, 1, 0, 0);
    4069 static snd_kcontrol_new_t snd_ice1712_ews88d_master_adat =
    4070 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 0, 2, 0, 0);
    4071 static snd_kcontrol_new_t snd_ice1712_ews88d_adat_enable =
    4072 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "Enable ADAT", 0, 3, 0, 0);
    4073 static snd_kcontrol_new_t snd_ice1712_ews88d_adat_through =
    4074 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Through", 0, 4, 1, 0);
     3672static snd_kcontrol_new_t snd_ice1712_ews88d_controls[] __devinitdata = {
     3673        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
     3674        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
     3675        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
     3676        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "Enable ADAT", 3, 0, 0),
     3677        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Through", 4, 1, 0),
     3678};
     3679
     3680
     3681/*
     3682 * DMX 6Fire controls
     3683 */
     3684
     3685#if 0 // XXX not working yet
     3686static int snd_ice1712_6fire_read_pca(ice1712_t *ice)
     3687{
     3688        unsigned char byte;
     3689        snd_i2c_lock(ice->i2c);
     3690        byte = 0; /* read port */
     3691        snd_i2c_sendbytes(ice->pcf8575, &byte, 1);
     3692        if (snd_i2c_readbytes(ice->pcf8575, &byte, 1) != 1) {
     3693                snd_i2c_unlock(ice->i2c);
     3694                return -EREMOTE;
     3695        }
     3696        snd_i2c_unlock(ice->i2c);
     3697        return byte;
     3698}
     3699
     3700static int snd_ice1712_6fire_write_pca(ice1712_t *ice, unsigned char data)
     3701{
     3702        unsigned char bytes[2];
     3703        snd_i2c_lock(ice->i2c);
     3704        bytes[0] = 1; /* write port */
     3705        bytes[1] = data;
     3706        if (snd_i2c_sendbytes(ice->pcf8575, bytes, 2) != 2) {
     3707                snd_i2c_unlock(ice->i2c);
     3708                return -EREMOTE;
     3709        }
     3710        snd_i2c_unlock(ice->i2c);
     3711        return 0;
     3712}
     3713
     3714static int snd_ice1712_6fire_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
     3715{
     3716        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     3717        uinfo->count = 1;
     3718        uinfo->value.integer.min = 0;
     3719        uinfo->value.integer.max = 1;
     3720        return 0;
     3721}
     3722
     3723static int snd_ice1712_6fire_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
     3724{
     3725        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
     3726        int shift = kcontrol->private_value & 0xff;
     3727        int invert = (kcontrol->private_value >> 8) & 1;
     3728        int data;
     3729       
     3730        if ((data = snd_ice1712_6fire_read_pca(ice)) < 0)
     3731                return data;
     3732        data = (data >> shift) & 1;
     3733        if (invert)
     3734                data ^= 1;
     3735        ucontrol->value.integer.value[0] = data;
     3736        return 0;
     3737}
     3738
     3739static int snd_ice1712_6fire_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
     3740{
     3741        ice1712_t *ice = snd_kcontrol_chip(kcontrol);
     3742        int shift = kcontrol->private_value & 0xff;
     3743        int invert = (kcontrol->private_value >> 8) & 1;
     3744        int data, ndata;
     3745       
     3746        if ((data = snd_ice1712_6fire_read_pca(ice)) < 0)
     3747                return data;
     3748        ndata = data & ~(1 << shift);
     3749        if (ucontrol->value.integer.value[0])
     3750                ndata |= (1 << shift);
     3751        if (invert)
     3752                ndata ^= (1 << shift);
     3753        if (data != ndata) {
     3754                snd_ice1712_6fire_write_pca(ice, (unsigned char)ndata);
     3755                return 1;
     3756        }
     3757        return 0;
     3758}
     3759
     3760#define DMX6FIRE_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
     3761{ iface: xiface,\
     3762  name: xname,\
     3763  access: xaccess,\
     3764  info: snd_ice1712_6fire_control_info,\
     3765  get: snd_ice1712_6fire_control_get,\
     3766  put: snd_ice1712_6fire_control_put,\
     3767  private_value: xshift | (xinvert << 8),\
     3768}
     3769
     3770static snd_kcontrol_new_t snd_ice1712_6fire_led __devinitdata =
     3771DMX6FIRE_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "Breakbox LED", 6, 0, 0);
     3772
     3773#endif // XXX not working yet
    40753774
    40763775
     
    40793778 */
    40803779
    4081 static unsigned char __init snd_ice1712_read_i2c(ice1712_t *ice,
     3780static unsigned char __devinit snd_ice1712_read_i2c(ice1712_t *ice,
    40823781                                                 unsigned char dev,
    40833782                                                 unsigned char addr)
     
    40913790}
    40923791
    4093 static int __init snd_ice1712_read_eeprom(ice1712_t *ice)
     3792static int __devinit snd_ice1712_read_eeprom(ice1712_t *ice)
    40943793{
    40953794        int dev = 0xa0;         /* EEPROM device address */
     
    41373836}
    41383837
    4139 static void __init snd_ice1712_ak4524_init(ice1712_t *ice)
    4140 {
    4141         static unsigned char inits[8] = {
    4142                 0x07, /* 0: all power up */
    4143                 0x03, /* 1: ADC/DAC reset */
    4144                 0x60, /* 2: 24bit I2S */
    4145                 0x19, /* 3: deemphasis off */
    4146                 0x00, /* 4: ADC left muted */
    4147                 0x00, /* 5: ADC right muted */
    4148                 0x00, /* 6: DAC left muted */
    4149                 0x00, /* 7: DAC right muted */
     3838static void __devinit snd_ice1712_ak4524_init(ice1712_t *ice)
     3839{
     3840        static unsigned char inits[] = {
     3841                0x00, 0x07, /* 0: all power up */
     3842                0x01, 0x00, /* 1: ADC/DAC reset */
     3843                0x02, 0x60, /* 2: 24bit I2S */
     3844                0x03, 0x19, /* 3: deemphasis off */
     3845                0x01, 0x03, /* 1: ADC/DAC enable */
     3846                0x04, 0x00, /* 4: ADC left muted */
     3847                0x05, 0x00, /* 5: ADC right muted */
     3848                0x04, 0x80, /* 4: ADC IPGA gain 0dB */
     3849                0x05, 0x80, /* 5: ADC IPGA gain 0dB */
     3850                0x06, 0x00, /* 6: DAC left muted */
     3851                0x07, 0x00, /* 7: DAC right muted */
     3852                0xff, 0xff
    41503853        };
    4151         int chip;
    4152         unsigned char reg;
    4153 
    4154         for (chip = 0; chip < ice->num_dacs/2; chip++) {
    4155                 for (reg = 0; reg < 8; ++reg)
    4156                         snd_ice1712_ak4524_write(ice, chip, reg, inits[reg]);
    4157         }
    4158 }
    4159 
    4160 /* init CS8427 transciever */
    4161 static void __init snd_ice1712_cs8427_init(ice1712_t *ice)
    4162 {
    4163         static unsigned char initvals[] = {
    4164                 /* RMCK to OMCK, no validity, disable mutes, TCBL=output */
    4165                 0x80,
    4166                 /* hold last valid audio sample, RMCK=256*Fs, normal stereo operation */
    4167                 0x00,
    4168                 /* output drivers normal operation, Tx<=serial, Rx=>serial */
    4169                 0x0c,
    4170                 /* Run off, CMCK=256*Fs, output time base = OMCK, input time base =
    4171                    covered input clock, recovered input clock source is Envy24 */
    4172                 0x04,
    4173                 /* Serial audio input port data format = I2S */
    4174                 0x05, /* SIDEL=1, SILRPOL=1 */
    4175                 /* Serial audio output port data format = I2S */
    4176                 0x05,   /* SODEL=1, SOLRPOL=1 */
    4177         };
    4178         unsigned char buf[32];
    4179 
    4180         /* verify CS8427 ID */
    4181         if (ice->cs8427_ops->read(ice, 127) != 0x71) {
    4182                 snd_printk("unable to find CS8427 signature, initialization is not completed\n");
    4183                 return;
    4184         }
    4185         /* turn off run bit while making changes to configuration */
    4186         ice->cs8427_ops->write(ice, 4, 0x00);
    4187         /* send initial values */
    4188         ice->cs8427_ops->write_bytes(ice, 1, 6, initvals);
    4189         /* Turn off CS8427 interrupt stuff that is not used in hardware */
    4190         memset(buf, 0, sizeof(buf));
    4191         /* from address 9 to 15 */
    4192         ice->cs8427_ops->write_bytes(ice, 9, 7, buf);
    4193         /* unmask the input PLL clock, V, confidence, biphase, parity status bits */
    4194         //buf[0] = 0x1f;
    4195         buf[0] = 0;
    4196         /* Registers 32-55 window to CS buffer
    4197            Inhibit D->E transfers from overwriting first 5 bytes of CS data.
    4198            Allow D->E transfers (all) of CS data.
    4199            Allow E->F transfer of CS data.
    4200            One byte mode; both A/B channels get same written CB data.
    4201            A channel info is output to chip's EMPH* pin. */
    4202         buf[1] = 0x10;
    4203         /* Use internal buffer to transmit User (U) data.
    4204            Chip's U pin is an output.
    4205            Transmit all O's for user data. */
    4206         //buf[2] = 0x10;
    4207         buf[2] = 0x00;
    4208         ice->cs8427_ops->write_bytes(ice, 17, 3, buf);
    4209         /* turn on run bit and rock'n'roll */
    4210         ice->cs8427_ops->write(ice, 4, initvals[3] | 0x40);
    4211         /* write default channel status bytes */
    4212         ice->cs8427_ops->write_bytes(ice, 32, 5, ice->cs8427_spdif_status);
    4213 
    4214         /*
    4215          * add controls..
    4216          */
    4217         snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_cs8427_in_status, ice));
    4218 #if 0
    4219         snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_cs8427_clock_select, ice));
    4220 #endif
    4221 }
    4222 
    4223 static void __init snd_ice1712_stdsp24_gpio_write(ice1712_t *ice, unsigned char byte)
     3854        int chip, idx;
     3855        unsigned char *ptr, reg, data;
     3856
     3857        for (chip = idx = 0; chip < ice->num_dacs/2; chip++) {
     3858                ptr = inits;
     3859                while (*ptr != 0xff) {
     3860                        reg = *ptr++;
     3861                        data = *ptr++;
     3862                        if (ice->ak4528) {
     3863                                if (reg > 5)
     3864                                        continue;
     3865                                if (reg >= 4 && (data & 0x80))
     3866                                        continue;
     3867                        }
     3868                        if (reg == 0x03 && ice->ak4528)
     3869                                data = 0x0d;    /* deemphasis off, turn LR highpass filters on */
     3870                        snd_ice1712_ak4524_write(ice, chip, reg, data);
     3871                }
     3872        }
     3873}
     3874
     3875static void __devinit snd_ice1712_stdsp24_gpio_write(ice1712_t *ice, unsigned char byte)
    42243876{
    42253877        byte |= ICE1712_STDSP24_CLOCK_BIT;
     
    42343886}
    42353887
    4236 static void __init snd_ice1712_stdsp24_darear(ice1712_t *ice, int activate)
     3888static void __devinit snd_ice1712_stdsp24_darear(ice1712_t *ice, int activate)
    42373889{
    42383890        down(&ice->gpio_mutex);
     
    42423894}
    42433895
    4244 static void __init snd_ice1712_stdsp24_mute(ice1712_t *ice, int activate)
     3896static void __devinit snd_ice1712_stdsp24_mute(ice1712_t *ice, int activate)
    42453897{
    42463898        down(&ice->gpio_mutex);
     
    42503902}
    42513903
    4252 static void __init snd_ice1712_stdsp24_insel(ice1712_t *ice, int activate)
     3904static void __devinit snd_ice1712_stdsp24_insel(ice1712_t *ice, int activate)
    42533905{
    42543906        down(&ice->gpio_mutex);
     
    42583910}
    42593911
    4260 static void __init snd_ice1712_stdsp24_box_channel(ice1712_t *ice, int box, int chn, int activate)
     3912static void __devinit snd_ice1712_stdsp24_box_channel(ice1712_t *ice, int box, int chn, int activate)
    42613913{
    42623914        down(&ice->gpio_mutex);
     
    43053957}
    43063958
    4307 static void __init snd_ice1712_stdsp24_box_midi(ice1712_t *ice, int box, int master, int slave)
     3959static void __devinit snd_ice1712_stdsp24_box_midi(ice1712_t *ice, int box, int master, int slave)
    43083960{
    43093961        down(&ice->gpio_mutex);
     
    43363988}
    43373989
    4338 static void __init snd_ice1712_stdsp24_init(ice1712_t *ice)
     3990static void __devinit snd_ice1712_stdsp24_init(ice1712_t *ice)
    43393991{
    43403992        int box, chn;
     
    43944046}
    43954047
    4396 static int __init snd_ice1712_chip_init(ice1712_t *ice)
    4397 {
     4048static int __devinit snd_ice1712_chip_init(ice1712_t *ice)
     4049{
     4050        int err, has_i2c = 0;
     4051
    43984052        outb(ICE1712_RESET | ICE1712_NATIVE, ICEREG(ice, CONTROL));
    43994053        udelay(200);
     
    44264080        }
    44274081
     4082        /* determine I2C, DACs and ADCs */
    44284083        switch (ice->eeprom.subvendor) {
    44294084        case ICE1712_SUBDEVICE_AUDIOPHILE:
     4085                ice->ak4528 = 1;
     4086                /* follow thru */
    44304087        case ICE1712_SUBDEVICE_EWX2496:
    4431                 ice->num_adcs = ice->num_dacs = 2;
     4088                has_i2c = 1;
     4089                ice->num_adcs = ice->num_dacs = ice->num_total_dacs = 2;
    44324090                break; 
    44334091        case ICE1712_SUBDEVICE_DELTA44:
    44344092        case ICE1712_SUBDEVICE_DELTA66:
    4435                 ice->num_adcs = ice->num_dacs = 4;
     4093                ice->num_adcs = ice->num_dacs = ice->num_total_dacs = 4;
     4094                if (ice->omni)
     4095                        ice->num_total_dacs = 8;
    44364096                break;
    44374097        case ICE1712_SUBDEVICE_EWS88MT:
    4438                 ice->num_adcs = ice->num_dacs = 8;
    4439                 break;
    4440         }
    4441 
     4098                has_i2c = 1;
     4099                /* follow thru */
     4100        case ICE1712_SUBDEVICE_DELTA1010:
     4101                ice->num_adcs = ice->num_dacs = ice->num_total_dacs = 8;
     4102                break;
     4103        case ICE1712_SUBDEVICE_EWS88D:
     4104                has_i2c = 1;
     4105                break;
     4106        case ICE1712_SUBDEVICE_DMX6FIRE:
     4107                has_i2c = 1;
     4108                ice->num_adcs = ice->num_dacs = ice->num_total_dacs = 6;
     4109                break;
     4110        }
     4111
     4112        if (has_i2c) {
     4113                if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
     4114                        snd_printk("unable to create I2C bus\n");
     4115                        return err;
     4116                }
     4117                ice->i2c->private_data = ice;
     4118                switch (ice->eeprom.subvendor) {
     4119                case ICE1712_SUBDEVICE_AUDIOPHILE:
     4120                        ice->i2c->ops = &ap_cs8427_i2c_ops;
     4121                        break;
     4122                case ICE1712_SUBDEVICE_EWX2496:
     4123                case ICE1712_SUBDEVICE_EWS88MT:
     4124                case ICE1712_SUBDEVICE_EWS88D:
     4125                case ICE1712_SUBDEVICE_DMX6FIRE:
     4126                        ice->i2c->hw_ops.bit = &snd_ice1712_ewx_cs8427_bit_ops;
     4127                        break;
     4128                }
     4129                switch (ice->eeprom.subvendor) {
     4130                case ICE1712_SUBDEVICE_AUDIOPHILE:
     4131                case ICE1712_SUBDEVICE_EWX2496:
     4132                        if ((err = snd_cs8427_create(ice->i2c, CS8427_BASE_ADDR, &ice->cs8427)) < 0) {
     4133                                snd_printk("CS8427 initialization failed\n");
     4134                                return err;
     4135                        }
     4136                        break;
     4137                case ICE1712_SUBDEVICE_DMX6FIRE:
     4138#if 0 // XXX not working yet
     4139                        if ((err = snd_i2c_device_create(ice->i2c, "PCF9554", 0x40>>1, &ice->pcf8575)) < 0)
     4140                                return err;
     4141                        if ((err = snd_cs8427_create(ice->i2c, 0x11, &ice->cs8427)) < 0) {
     4142                                snd_printk("CS8427 initialization failed\n");
     4143                                return err;
     4144                        }
     4145#endif // XXX not working yet
     4146                        break;
     4147                case ICE1712_SUBDEVICE_EWS88MT:
     4148                        if ((err = snd_i2c_device_create(ice->i2c, "CS8404", ICE1712_EWS88MT_CS8404_ADDR, &ice->cs8404)) < 0)
     4149                                return err;
     4150                        if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (1st)", ICE1712_EWS88MT_INPUT_ADDR, &ice->pcf8574[0])) < 0)
     4151                                return err;
     4152                        if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (2nd)", ICE1712_EWS88MT_OUTPUT_ADDR, &ice->pcf8574[1])) < 0)
     4153                                return err;
     4154                        break;
     4155                case ICE1712_SUBDEVICE_EWS88D:
     4156                        if ((err = snd_i2c_device_create(ice->i2c, "PCF8575", ICE1712_EWS88D_PCF_ADDR, &ice->pcf8575)) < 0)
     4157                                return err;
     4158                        break;
     4159                }
     4160        }
     4161        /* second stage of initialization, analog parts and others */
    44424162        switch (ice->eeprom.subvendor) {
    44434163        case ICE1712_SUBDEVICE_DELTA66:
     
    44464166        case ICE1712_SUBDEVICE_EWX2496:
    44474167        case ICE1712_SUBDEVICE_EWS88MT:
     4168        case ICE1712_SUBDEVICE_DMX6FIRE:
    44484169                snd_ice1712_ak4524_init(ice);
    44494170                break;
     
    44674188                snd_ice1712_delta_cs8403_spdif_write(ice, ice->cs8403_spdif_bits);
    44684189                break;
     4190        }
     4191        switch (ice->eeprom.subvendor) {
    44694192        case ICE1712_SUBDEVICE_EWS88MT:
    44704193        case ICE1712_SUBDEVICE_EWS88D:
     
    44884211        if (err < 0)
    44894212                return err;
    4490         for (idx = 0; idx < ice->num_dacs; idx++) {
     4213        for (idx = 0; idx < ice->num_total_dacs; idx++) {
    44914214                kctl = snd_ctl_new1(&snd_ice1712_mixer_pro_analog_route, ice);
    44924215                if (kctl == NULL)
     
    45704293        case ICE1712_SUBDEVICE_DELTA66:
    45714294        case ICE1712_SUBDEVICE_EWS88MT:
     4295        case ICE1712_SUBDEVICE_DMX6FIRE:
    45724296                for (idx = 0; idx < ice->num_dacs; ++idx) {
    45734297                        snd_kcontrol_t ctl;
     
    45804304                        ctl.get = snd_ice1712_ak4524_volume_get;
    45814305                        ctl.put = snd_ice1712_ak4524_volume_put;
    4582                         ctl.private_value = (idx / 2) * 8 + (idx % 2) + 6; /* reigster 6 & 7 */
     4306                        if (ice->ak4528)
     4307                                ctl.private_value = (idx / 2) * 8 + (idx % 2) + 4; /* register 4 & 5 */
     4308                        else
     4309                                ctl.private_value = (idx / 2) * 8 + (idx % 2) + 6; /* register 6 & 7 */
    45834310                        ctl.private_data = ice;
    45844311                        if ((err = snd_ctl_add(ice->card, snd_ctl_new(&ctl))) < 0)
    45854312                                return err;
    45864313                }
    4587                 for (idx = 0; idx < ice->num_adcs; ++idx) {
     4314                for (idx = 0; idx < ice->num_adcs && !ice->ak4528; ++idx) {
    45884315                        snd_kcontrol_t ctl;
    45894316                        memset(&ctl, 0, sizeof(ctl));
     
    45954322                        ctl.get = snd_ice1712_ak4524_volume_get;
    45964323                        ctl.put = snd_ice1712_ak4524_volume_put;
    4597                         ctl.private_value = (idx / 2) * 8 + (idx % 2) + 4; /* reigster 4 & 5 */
     4324                        ctl.private_value = (idx / 2) * 8 + (idx % 2) + 4; /* register 4 & 5 */
     4325                        ctl.private_data = ice;
     4326                        if ((err = snd_ctl_add(ice->card, snd_ctl_new(&ctl))) < 0)
     4327                                return err;
     4328                        memset(&ctl, 0, sizeof(ctl));
     4329                        strcpy(ctl.id.name, "IPGA Analog Capture Volume");
     4330                        ctl.id.index = idx;
     4331                        ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     4332                        ctl.info = snd_ice1712_ak4524_ipga_gain_info;
     4333                        ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE;
     4334                        ctl.get = snd_ice1712_ak4524_ipga_gain_get;
     4335                        ctl.put = snd_ice1712_ak4524_ipga_gain_put;
     4336                        ctl.private_value = (idx / 2) * 8 + (idx % 2) + 4; /* register 4 & 5 */
    45984337                        ctl.private_data = ice;
    45994338                        if ((err = snd_ctl_add(ice->card, snd_ctl_new(&ctl))) < 0)
     
    46384377                break;
    46394378        case ICE1712_SUBDEVICE_EWS88D:
    4640                 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_spdif_in_opt, ice));
     4379                for (idx = 0; idx < sizeof(snd_ice1712_ews88d_controls)/sizeof(snd_ice1712_ews88d_controls[0]); idx++) {
     4380                        err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_controls[idx], ice));
    46414381                if (err < 0)
    46424382                        return err;
    4643                 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_opt_out_adat, ice));
     4383                }
     4384                break;
     4385        case ICE1712_SUBDEVICE_DMX6FIRE:
     4386#if 0 // XXX not working yet
     4387                err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_6fire_led, ice));
    46444388                if (err < 0)
    46454389                        return err;
    4646                 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_master_adat, ice));
    4647                 if (err < 0)
    4648                         return err;
    4649                 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_adat_enable, ice));
    4650                 if (err < 0)
    4651                         return err;
    4652                 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_adat_through, ice));
    4653                 if (err < 0)
    4654                         return err;
    4655                 break;
    4656         }
    4657 
    4658         return 0;
    4659 }
    4660 
    4661 static int __exit snd_ice1712_free(ice1712_t *ice)
     4390#endif
     4391                break;
     4392        }
     4393
     4394        return 0;
     4395}
     4396
     4397static int snd_ice1712_free(ice1712_t *ice)
    46624398{
    46634399        if (ice->res_port == NULL)
     
    46724408        if (ice->irq)
    46734409                free_irq(ice->irq, (void *) ice);
    4674         if (ice->res_port)
     4410        if (ice->res_port) {
    46754411                release_resource(ice->res_port);
    4676         if (ice->res_ddma_port)
     4412                kfree_nocheck(ice->res_port);
     4413        }
     4414        if (ice->res_ddma_port) {
    46774415                release_resource(ice->res_ddma_port);
    4678         if (ice->res_dmapath_port)
     4416                kfree_nocheck(ice->res_ddma_port);
     4417        }
     4418        if (ice->res_dmapath_port) {
    46794419                release_resource(ice->res_dmapath_port);
    4680         if (ice->res_profi_port)
     4420                kfree_nocheck(ice->res_dmapath_port);
     4421        }
     4422        if (ice->res_profi_port) {
    46814423                release_resource(ice->res_profi_port);
     4424                kfree_nocheck(ice->res_profi_port);
     4425        }
    46824426        snd_magic_kfree(ice);
    46834427        return 0;
    46844428}
    46854429
    4686 static int __exit snd_ice1712_dev_free(snd_device_t *device)
     4430static int snd_ice1712_dev_free(snd_device_t *device)
    46874431{
    46884432        ice1712_t *ice = snd_magic_cast(ice1712_t, device->device_data, return -ENXIO);
     
    46904434}
    46914435
    4692 static int __init snd_ice1712_create(snd_card_t * card,
     4436static int __devinit snd_ice1712_create(snd_card_t * card,
    46934437                                     struct pci_dev *pci,
     4438                                     int omni,
    46944439                                     ice1712_t ** r_ice1712)
    46954440{
     
    47054450        };
    47064451#endif
     4452
    47074453        *r_ice1712 = NULL;
    47084454
     
    47204466        if (ice == NULL)
    47214467                return -ENOMEM;
     4468        ice->omni = omni ? 1 : 0;
    47224469        spin_lock_init(&ice->reg_lock);
    47234470        init_MUTEX(&ice->gpio_mutex);
     
    47264473                                         0x10 | /* no emphasis */
    47274474                                         0x20); /* PCM encoder/decoder */
    4728         ice->cs8427_spdif_status[0] = (SNDRV_PCM_DEFAULT_CON_SPDIF >> 0) & 0xff;
    4729         ice->cs8427_spdif_status[1] = (SNDRV_PCM_DEFAULT_CON_SPDIF >> 8) & 0xff;
    4730         ice->cs8427_spdif_status[2] = (SNDRV_PCM_DEFAULT_CON_SPDIF >> 16) & 0xff;
    4731         ice->cs8427_spdif_status[3] = (SNDRV_PCM_DEFAULT_CON_SPDIF >> 24) & 0xff;
    4732         memcpy(ice->cs8427_spdif_stream_status, ice->cs8427_spdif_status, 5);
    47334475        ice->card = card;
    47344476        ice->pci = pci;
     
    47954537}
    47964538
    4797 static int __init snd_ice1712_probe(struct pci_dev *pci,
     4539static int __devinit snd_ice1712_probe(struct pci_dev *pci,
    47984540                                    const struct pci_device_id *id)
    47994541{
     
    48034545        int pcm_dev = 0, err;
    48044546
    4805         for ( ; dev < SNDRV_CARDS; dev++) {
     4547        if (dev >= SNDRV_CARDS)
     4548                return -ENODEV;
    48064549                if (!snd_enable[dev]) {
    48074550                        dev++;
    48084551                        return -ENOENT;
    48094552                }
    4810                 break;
    4811         }
    4812         if (dev >= SNDRV_CARDS)
    4813                 return -ENODEV;
    48144553
    48154554        card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE, 0);
     
    48174556                return -ENOMEM;
    48184557
    4819         if ((err = snd_ice1712_create(card, pci, &ice)) < 0) {
     4558        if ((err = snd_ice1712_create(card, pci, snd_omni[dev], &ice)) < 0) {
    48204559                snd_card_free(card);
    48214560                return err;
     
    48804619                strcpy(card->shortname, "TerraTec EWS 88D");
    48814620                break;
     4621        case ICE1712_SUBDEVICE_DMX6FIRE:
     4622                strcpy(card->shortname, "TerraTec DMX 6Fire");
     4623                break;
    48824624        }
    48834625
     
    49074649                return err;
    49084650        }
    4909         PCI_SET_DRIVER_DATA(pci, card);
     4651        pci_set_drvdata(pci, card);
    49104652        dev++;
    49114653        return 0;
    49124654}
    49134655
    4914 static void __exit snd_ice1712_remove(struct pci_dev *pci)
    4915 {
    4916         snd_card_free(PCI_GET_DRIVER_DATA(pci));
    4917         PCI_SET_DRIVER_DATA(pci, NULL);
     4656static void __devexit snd_ice1712_remove(struct pci_dev *pci)
     4657{
     4658        snd_card_free(pci_get_drvdata(pci));
     4659        pci_set_drvdata(pci, NULL);
    49184660}
    49194661
     
    49304672        id_table: snd_ice1712_ids,
    49314673        probe: snd_ice1712_probe,
    4932         remove: snd_ice1712_remove,
     4674        remove: __devexit_p(snd_ice1712_remove),
    49334675};
    49344676#endif
     
    49404682        if ((err = pci_module_init(&driver)) < 0) {
    49414683#ifdef MODULE
    4942                 snd_printk("ICE1712 soundcard not found or device busy\n");
     4684                printk(KERN_ERR "ICE1712 soundcard not found or device busy\n");
    49434685#endif
    49444686                return err;
     
    49574699#ifndef MODULE
    49584700
    4959 /* format is: snd-card-ice1712=snd_enable,snd_index,snd_id */
     4701/* format is: snd-ice1712=snd_enable,snd_index,snd_id */
    49604702
    49614703static int __init alsa_card_ice1712_setup(char *str)
     
    49724714}
    49734715
    4974 __setup("snd-card-ice1712=", alsa_card_ice1712_setup);
     4716__setup("snd-ice1712=", alsa_card_ice1712_setup);
    49754717
    49764718#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/pci/maestro3.c

    r77 r92  
    29242924    if ((err = pci_module_init(&driver)) < 0) {
    29252925#ifdef MODULE
    2926         //              snd_printk("Maestro3/Allegro soundcard not found or device busy\n");
     2926                //              snd_printk(KERN_ERR "Maestro3/Allegro soundcard not found or device busy\n");
    29272927#endif
    29282928        return err;
  • GPL/branches/alsa-resync1/alsa-kernel/pci/rme96.c

    r32 r92  
    2020 *   You should have received a copy of the GNU General Public License
    2121 *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     22 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2323 *
    2424 */     
    2525
    26 #define SNDRV_MAIN_OBJECT_FILE
    27 
    2826#include <sound/driver.h>
     27#include <asm/io.h>
     28#include <linux/delay.h>
     29#include <linux/init.h>
     30#include <linux/slab.h>
     31#include <sound/core.h>
    2932#include <sound/info.h>
    3033#include <sound/control.h>
    3134#include <sound/pcm.h>
     35#include <sound/asoundef.h>
    3236#define SNDRV_GET_ID
    3337#include <sound/initval.h>
     
    3539/* note, two last pcis should be equal, it is not a bug */
    3640EXPORT_NO_SYMBOLS;
     41
     42MODULE_AUTHOR("Anders Torger <torger@ludd.luth.se>");
    3743MODULE_DESCRIPTION("RME Digi96, Digi96/8, Digi96/8 PRO, Digi96/8 PST, "
    3844                   "Digi96/8 PAD");
     45MODULE_LICENSE("GPL");
    3946MODULE_CLASSES("{sound}");
    4047MODULE_DEVICES("{{RME,Digi96},"
     
    240247        size_t capture_periodsize; /* in bytes, zero if not used */
    241248
     249        snd_pcm_uframes_t playback_last_appl_ptr;
    242250        size_t playback_ptr;
    243251        size_t capture_ptr;
     
    693701}
    694702
    695 
    696 static int
    697 snd_rme96_playback_getrate(rme96_t *rme96)
    698 {
    699         int rate;
    700        
    701         rate = ((rme96->wcreg >> RME96_WCR_BITPOS_FREQ_0) & 1) +
    702                 (((rme96->wcreg >> RME96_WCR_BITPOS_FREQ_1) & 1) << 1);
    703         switch (rate) {
    704         case 1:
    705                 rate = 32000;
    706                 break;
    707         case 2:
    708                 rate = 44100;
    709                 break;
    710         case 3:
    711                 rate = 48000;
    712                 break;
    713         default:
    714                 return -1;
    715         }
    716         return (rme96->wcreg & RME96_WCR_DS) ? rate << 1 : rate;
    717 }
    718 
    719703static int
    720704snd_rme96_capture_getrate(rme96_t *rme96,
     
    781765
    782766static int
     767snd_rme96_playback_getrate(rme96_t *rme96)
     768{
     769        int rate, dummy;
     770
     771        if (!(rme96->wcreg & RME96_WCR_MASTER) &&
     772            (rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
     773        {
     774            /* slave clock */
     775            return rate;
     776        }
     777        rate = ((rme96->wcreg >> RME96_WCR_BITPOS_FREQ_0) & 1) +
     778                (((rme96->wcreg >> RME96_WCR_BITPOS_FREQ_1) & 1) << 1);
     779        switch (rate) {
     780        case 1:
     781                rate = 32000;
     782                break;
     783        case 2:
     784                rate = 44100;
     785                break;
     786        case 3:
     787                rate = 48000;
     788                break;
     789        default:
     790                return -1;
     791        }
     792        return (rme96->wcreg & RME96_WCR_DS) ? rate << 1 : rate;
     793}
     794
     795static int
    783796snd_rme96_playback_setrate(rme96_t *rme96,
    784797                           int rate)
     
    930943                break;
    931944        case RME96_INPUT_XLR:
    932                 if (rme96->pci->device != PCI_DEVICE_ID_DIGI96_8_PAD_OR_PST ||
    933                     rme96->pci->device != PCI_DEVICE_ID_DIGI96_8_PRO ||
     945                if ((rme96->pci->device != PCI_DEVICE_ID_DIGI96_8_PAD_OR_PST &&
     946                     rme96->pci->device != PCI_DEVICE_ID_DIGI96_8_PRO) ||
    934947                    (rme96->pci->device == PCI_DEVICE_ID_DIGI96_8_PAD_OR_PST &&
    935948                     rme96->rev > 4))
     
    11601173                         int from_pause)
    11611174{
    1162         snd_pcm_runtime_t *runtime = rme96->playback_substream->runtime;
    1163        
    11641175        if (!from_pause) {
    11651176                writel(0, rme96->iobase + RME96_IO_RESET_PLAY_POS);
    1166                 if (runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
    1167                         memcpy_toio(rme96->iobase + RME96_IO_PLAY_BUFFER,
    1168                                     runtime->dma_area,
    1169                                     rme96->playback_periodsize);
    1170                         rme96->playback_ptr = rme96->playback_periodsize;
    1171                 }
     1177                rme96->playback_last_appl_ptr = 0;
     1178                rme96->playback_ptr = 0;
    11721179        }
    11731180
     
    11821189        if (!from_pause) {
    11831190                writel(0, rme96->iobase + RME96_IO_RESET_REC_POS);
     1191                rme96->capture_ptr = 0;
    11841192        }
    11851193
     
    12201228{
    12211229        rme96_t *rme96 = (rme96_t *)dev_id;
    1222         snd_pcm_runtime_t *runtime;
    12231230
    12241231        rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER);
     
    12321239        if (rme96->rcreg & RME96_RCR_IRQ) {
    12331240                /* playback */
    1234                 runtime = rme96->playback_substream->runtime;
    1235                 if (runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
    1236                         memcpy_toio(rme96->iobase + RME96_IO_PLAY_BUFFER +
    1237                                     rme96->playback_ptr,
    1238                                     runtime->dma_area + rme96->playback_ptr,
    1239                                     rme96->playback_periodsize);
    1240                         rme96->playback_ptr += rme96->playback_periodsize;
    1241                         if (rme96->playback_ptr == RME96_BUFFER_SIZE) {
    1242                                 rme96->playback_ptr = 0;
    1243                         }
    1244                 }
    12451241                snd_pcm_period_elapsed(rme96->playback_substream);
    12461242                writel(0, rme96->iobase + RME96_IO_CONFIRM_PLAY_IRQ);
     
    12481244        if (rme96->rcreg & RME96_RCR_IRQ_2) {
    12491245                /* capture */
    1250                 runtime = rme96->capture_substream->runtime;
    1251                 if (runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
    1252                         memcpy_fromio(runtime->dma_area + rme96->capture_ptr,
    1253                                       rme96->iobase + RME96_IO_REC_BUFFER +
    1254                                       rme96->capture_ptr,
    1255                                       rme96->capture_periodsize);
    1256                         rme96->capture_ptr += rme96->capture_periodsize;
    1257                         if (rme96->capture_ptr == RME96_BUFFER_SIZE) {
    1258                                 rme96->capture_ptr = 0;
    1259                         }
    1260                 }
    12611246                snd_pcm_period_elapsed(rme96->capture_substream);               
    12621247                writel(0, rme96->iobase + RME96_IO_CONFIRM_REC_IRQ);
     
    12951280        writel(rme96->wcreg, rme96->iobase + RME96_IO_CONTROL_REGISTER);
    12961281        rme96->playback_substream = substream;
     1282        rme96->playback_last_appl_ptr = 0;
    12971283        rme96->playback_ptr = 0;
    12981284        spin_unlock_irqrestore(&rme96->lock, flags);
     
    13541340        writel(rme96->wcreg, rme96->iobase + RME96_IO_CONTROL_REGISTER);
    13551341        rme96->playback_substream = substream;
     1342        rme96->playback_last_appl_ptr = 0;
    13561343        rme96->playback_ptr = 0;
    13571344        spin_unlock_irqrestore(&rme96->lock, flags);
     
    15471534{
    15481535        rme96_t *rme96 = _snd_pcm_substream_chip(substream);
     1536        snd_pcm_runtime_t *runtime = substream->runtime;
     1537        snd_pcm_sframes_t diff;
     1538        size_t bytes;
     1539       
     1540        if (runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
     1541                diff = runtime->control->appl_ptr -
     1542                    rme96->playback_last_appl_ptr;
     1543                rme96->playback_last_appl_ptr = runtime->control->appl_ptr;
     1544                if (diff != 0 &&
     1545                    diff < -(snd_pcm_sframes_t)(runtime->boundary >> 1))
     1546                {
     1547                        diff += runtime->boundary;
     1548                }
     1549                bytes = diff << rme96->playback_frlog;
     1550               
     1551                if (bytes > RME96_BUFFER_SIZE - rme96->playback_ptr) {
     1552                        memcpy_toio(rme96->iobase + RME96_IO_PLAY_BUFFER +
     1553                                    rme96->playback_ptr,
     1554                                    runtime->dma_area + rme96->playback_ptr,
     1555                                    RME96_BUFFER_SIZE - rme96->playback_ptr);
     1556                        bytes -= RME96_BUFFER_SIZE - rme96->playback_ptr;
     1557                        if (bytes > RME96_BUFFER_SIZE) {
     1558                                bytes = RME96_BUFFER_SIZE;
     1559                        }
     1560                        memcpy_toio(rme96->iobase + RME96_IO_PLAY_BUFFER,
     1561                                    runtime->dma_area,
     1562                                    bytes);
     1563                        rme96->playback_ptr = bytes;
     1564                } else if (bytes != 0) {
     1565                        memcpy_toio(rme96->iobase + RME96_IO_PLAY_BUFFER +
     1566                                    rme96->playback_ptr,
     1567                                    runtime->dma_area + rme96->playback_ptr,
     1568                                    bytes);
     1569                        rme96->playback_ptr += bytes;
     1570                }
     1571        }
    15491572        return snd_rme96_playback_ptr(rme96);
    15501573}
     
    15541577{
    15551578        rme96_t *rme96 = _snd_pcm_substream_chip(substream);
    1556         return snd_rme96_capture_ptr(rme96);
     1579        snd_pcm_runtime_t *runtime = substream->runtime;
     1580        snd_pcm_uframes_t frameptr;
     1581        size_t ptr;
     1582
     1583        frameptr = snd_rme96_capture_ptr(rme96);
     1584        if (runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
     1585                ptr = frameptr << rme96->capture_frlog;
     1586                if (ptr > rme96->capture_ptr) {
     1587                        memcpy_fromio(runtime->dma_area + rme96->capture_ptr,
     1588                                      rme96->iobase + RME96_IO_REC_BUFFER +
     1589                                      rme96->capture_ptr,
     1590                                      ptr - rme96->capture_ptr);
     1591                        rme96->capture_ptr += ptr - rme96->capture_ptr;
     1592                } else if (ptr < rme96->capture_ptr) {
     1593                        memcpy_fromio(runtime->dma_area + rme96->capture_ptr,
     1594                                      rme96->iobase + RME96_IO_REC_BUFFER +
     1595                                      rme96->capture_ptr,
     1596                                      RME96_BUFFER_SIZE - rme96->capture_ptr);
     1597                        memcpy_fromio(runtime->dma_area,
     1598                                      rme96->iobase + RME96_IO_REC_BUFFER,
     1599                                      ptr);
     1600                        rme96->capture_ptr = ptr;
     1601                }
     1602        }
     1603        return frameptr;
    15571604}
    15581605
     
    16831730        if (rme96->res_port != NULL) {
    16841731                release_resource(rme96->res_port);
     1732                kfree_nocheck(rme96->res_port);
    16851733                rme96->res_port = NULL;
    16861734        }
     
    26142662}
    26152663
    2616 static int __init
     2664static int __devinit
    26172665snd_rme96_probe(struct pci_dev *pci,
    26182666                const struct pci_device_id *id)
     
    26242672        u8 val;
    26252673
    2626         for ( ; dev < SNDRV_CARDS; dev++) {
     2674        if (dev >= SNDRV_CARDS) {
     2675                return -ENODEV;
     2676        }
    26272677                if (!snd_enable[dev]) {
    26282678                        dev++;
    26292679                        return -ENOENT;
    2630                 }
    2631                 break;
    2632         }
    2633         if (dev >= SNDRV_CARDS) {
    2634                 return -ENODEV;
    26352680        }
    26362681        if ((card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE,
     
    26732718                return err;     
    26742719        }
    2675         PCI_SET_DRIVER_DATA(pci, card);
     2720        pci_set_drvdata(pci, card);
    26762721        dev++;
    26772722        return 0;
    26782723}
    26792724
    2680 static void __exit snd_rme96_remove(struct pci_dev *pci)
    2681 {
    2682         snd_card_free(PCI_GET_DRIVER_DATA(pci));
    2683         PCI_SET_DRIVER_DATA(pci, NULL);
     2725static void __devexit snd_rme96_remove(struct pci_dev *pci)
     2726{
     2727        snd_card_free(pci_get_drvdata(pci));
     2728        pci_set_drvdata(pci, NULL);
    26842729}
    26852730
     
    26962741        id_table: snd_rme96_ids,
    26972742        probe: snd_rme96_probe,
    2698         remove: snd_rme96_remove,
     2743        remove: __devexit_p(snd_rme96_remove),
    26992744};
    27002745#endif
     
    27062751        if ((err = pci_module_init(&driver)) < 0) {
    27072752#ifdef MODULE
    2708 //              snd_printk("No RME Digi96 cards found\n");
     2753//              snd_printk(KERN_ERR "No RME Digi96 cards found\n");
    27092754#endif
    27102755                return err;
     
    27232768#ifndef MODULE
    27242769
    2725 /* format is: snd-card-rme96=snd_enable,snd_index,snd_id */
     2770/* format is: snd-rme96=snd_enable,snd_index,snd_id */
    27262771
    27272772static int __init alsa_card_rme96_setup(char *str)
     
    27382783}
    27392784
    2740 __setup("snd-card-rme96=", alsa_card_rme96_setup);
     2785__setup("snd-rme96=", alsa_card_rme96_setup);
    27412786
    27422787#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/pci/rme9652/rme9652.c

    r32 r92  
    1717 *   You should have received a copy of the GNU General Public License
    1818 *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2020 *
    2121 */
    2222
    23 #define SNDRV_MAIN_OBJECT_FILE
    2423#include <sound/driver.h>
     24#include <asm/io.h>
     25#include <linux/delay.h>
     26#include <linux/init.h>
     27#include <linux/slab.h>
     28#include <sound/core.h>
    2529#include <sound/control.h>
    2630#include <sound/pcm.h>
    2731#include <sound/info.h>
     32#include <sound/asoundef.h>
    2833#define SNDRV_GET_ID
    2934#include <sound/initval.h>
     
    3136static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    3237static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    33 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     38static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;  /* Enable this card */
     39static int snd_precise_ptr[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* Enable precise pointer */
    3440
    3541EXPORT_NO_SYMBOLS;
     
    4349MODULE_PARM_DESC(snd_enable, "Enable/disable specific RME96{52,36} soundcards.");
    4450MODULE_PARM_SYNTAX(snd_enable, SNDRV_ENABLE_DESC);
     51MODULE_PARM(snd_precise_ptr, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
     52MODULE_PARM_DESC(snd_precise_ptr, "Enable precise pointer (doesn't work reliably).");
     53MODULE_PARM_SYNTAX(snd_precise_ptr, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
    4554MODULE_AUTHOR("Paul Davis <pbd@op.net>, Winfried Ritsch");
    4655MODULE_DESCRIPTION("RME Digi9652/Digi9636");
     56MODULE_LICENSE("GPL");
    4757MODULE_CLASSES("{sound}");
    4858MODULE_DEVICES("{{RME,Hammerfall},"
     
    206216        unsigned long iobase;
    207217
     218        int precise_ptr;
     219
    208220        u32 control_register;   /* cached value */
    209221        u32 thru_bits;          /* thru 1=on, 0=off channel 1=Bit1... channel 26= Bit26 */
     
    349361        rme9652->hw_offsetmask =
    350362                (rme9652->period_bytes * 2 - 1) & RME9652_buf_pos;
    351         rme9652->max_jitter = 16 + (rme9652->period_bytes <= 1024 ? 32 : 64);
    352 }
    353 
    354 static inline snd_pcm_uframes_t rme9652_hw_pointer(rme9652_t *rme9652)
     363        rme9652->max_jitter = 80;
     364}
     365
     366static snd_pcm_uframes_t rme9652_hw_pointer(rme9652_t *rme9652)
    355367{
    356368        int status;
     
    360372
    361373        status = rme9652_read(rme9652, RME9652_status_register);
     374        if (!rme9652->precise_ptr)
     375                return (status & RME9652_buffer_id) ? period_size : 0;
    362376        offset = status & RME9652_buf_pos;
    363377
     
    379393                if (offset > rme9652->max_jitter) {
    380394                        if (frag)
    381                                 printk("Unexpected hw_pointer position (bufid == 0): status: %x offset: %d\n", status, offset);
     395                                printk(KERN_ERR "Unexpected hw_pointer position (bufid == 0): status: %x offset: %d\n", status, offset);
    382396                } else if (!frag)
    383397                        return 0;
     
    388402                if (offset > period_size + rme9652->max_jitter) {
    389403                        if (!frag)
    390                                 printk("Unexpected hw_pointer position (bufid == 1): status: %x offset: %d\n", status, offset);
     404                                printk(KERN_ERR "Unexpected hw_pointer position (bufid == 1): status: %x offset: %d\n", status, offset);
    391405                } else if (frag)
    392406                        return period_size;
     
    17321746        snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
    17331747                    rme9652->irq, rme9652->port, rme9652->iobase);
     1748        snd_iprintf(buffer, "Control register: %x\n", rme9652->control_register);
    17341749
    17351750        snd_iprintf(buffer, "\n");
     
    19481963        if (rme9652->iobase)
    19491964                iounmap((void *) rme9652->iobase);
    1950         if (rme9652->res_port)
     1965        if (rme9652->res_port) {
    19511966                release_resource(rme9652->res_port);
     1967                kfree_nocheck(rme9652->res_port);
     1968        }
    19521969        if (rme9652->irq >= 0)
    19531970                free_irq(rme9652->irq, (void *)rme9652);
     
    19852002                }
    19862003
    1987                 snd_printk("%s: no buffers available\n",
    1988                            rme9652->card_name);
     2004                printk(KERN_ERR "%s: no buffers available\n", rme9652->card_name);
    19892005                return -ENOMEM;
    19902006        }
     
    19992015        /* Align to bus-space 64K boundary */
    20002016
    2001         cb_bus = cb_addr;
    2002         cb_bus = (cb_bus + 0xFFFF) & ~0xFFFFl;
    2003 
    2004         pb_bus = pb_addr;
    2005         pb_bus = (pb_bus + 0xFFFF) & ~0xFFFFl;
     2017        cb_bus = (cb_addr + 0xFFFF) & ~0xFFFFl;
     2018        pb_bus = (pb_addr + 0xFFFF) & ~0xFFFFl;
    20062019
    20072020        /* Tell the card where it is */
     
    20102023        rme9652_write(rme9652, RME9652_play_buffer, pb_bus);
    20112024
    2012         rme9652->capture_buffer = bus_to_virt(cb_bus);
    2013         rme9652->playback_buffer = bus_to_virt(pb_bus);
     2025        rme9652->capture_buffer = cb + (cb_bus - cb_addr);
     2026        rme9652->playback_buffer = pb + (pb_bus - pb_addr);
    20142027
    20152028        return 0;
     
    27452758
    27462759static int __init snd_rme9652_create(snd_card_t *card,
    2747                                      rme9652_t *rme9652)
     2760                                     rme9652_t *rme9652,
     2761                                     int precise_ptr)
    27482762{
    27492763        struct pci_dev *pci = rme9652->pci;
     
    27722786        rme9652->irq = pci->irq;
    27732787
    2774         rme9652->iobase = (unsigned long) ioremap(rme9652->port, RME9652_IO_EXTENT);
     2788        rme9652->iobase = (unsigned long) ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
    27752789        if (rme9652->iobase == 0) {
    27762790                snd_printk("unable to remap region 0x%lx-0x%lx\n", rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
    27772791                return -EBUSY;
    27782792        }
     2793
     2794        rme9652->precise_ptr = precise_ptr;
    27792795
    27802796        /* Determine the h/w rev level of the card. This seems like
     
    28712887}
    28722888
    2873 static int snd_rme9652_probe(struct pci_dev *pci,
     2889static int __devinit snd_rme9652_probe(struct pci_dev *pci,
    28742890                             const struct pci_device_id *id)
    28752891{
     
    28792895        int err;
    28802896
    2881         for (; dev < SNDRV_CARDS; dev++) {
     2897        if (dev >= SNDRV_CARDS)
     2898                return -ENODEV;
    28822899                if (!snd_enable[dev]) {
    28832900                        dev++;
    28842901                        return -ENOENT;
    28852902                }
    2886                 break;
    2887         }
    2888 
    2889         if (dev >= SNDRV_CARDS)
    2890                 return -ENODEV;
    28912903
    28922904        card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE,
     
    29012913        rme9652->pci = pci;
    29022914
    2903         if ((err = snd_rme9652_create(card, rme9652)) < 0) {
     2915        if ((err = snd_rme9652_create(card, rme9652, snd_precise_ptr[dev])) < 0) {
    29042916                snd_card_free(card);
    29052917                return err;
     
    29162928                return err;
    29172929        }
    2918         PCI_SET_DRIVER_DATA(pci, card);
     2930        pci_set_drvdata(pci, card);
    29192931        dev++;
    29202932        return 0;
    29212933}
    29222934
    2923 static void __exit snd_rme9652_remove(struct pci_dev *pci)
    2924 {
    2925         snd_card_free(PCI_GET_DRIVER_DATA(pci));
    2926         PCI_SET_DRIVER_DATA(pci, NULL);
     2935static void __devexit snd_rme9652_remove(struct pci_dev *pci)
     2936{
     2937        snd_card_free(pci_get_drvdata(pci));
     2938        pci_set_drvdata(pci, NULL);
    29272939}
    29282940
     
    29392951        id_table:snd_rme9652_ids,
    29402952        probe:snd_rme9652_probe,
    2941         remove:snd_rme9652_remove,
     2953        remove:__devexit_p(snd_rme9652_remove),
    29422954};
    29432955#endif
     
    29472959        if (pci_module_init(&driver) < 0) {
    29482960#ifdef MODULE
    2949                 snd_printk("RME Digi9652/Digi9636: no cards found\n");
     2961                printk(KERN_ERR "RME Digi9652/Digi9636: no cards found\n");
    29502962#endif
    29512963                return -ENODEV;
     
    29652977#ifndef MODULE
    29662978
    2967 /* format is: snd-card-rme9652=snd_enable,snd_index,snd_id */
     2979/* format is: snd-rme9652=snd_enable,snd_index,snd_id */
    29682980
    29692981static int __init alsa_card_rme9652_setup(char *str)
     
    29802992}
    29812993
    2982 __setup("snd-card-rme9652=", alsa_card_rme9652_setup);
     2994__setup("snd-rme9652=", alsa_card_rme9652_setup);
    29832995
    29842996#endif /* ifndef MODULE */
  • GPL/branches/alsa-resync1/alsa-kernel/pci/trident/trident.c

    r77 r92  
    2222 */
    2323
    24 #define SNDRV_MAIN_OBJECT_FILE
    2524#include <sound/driver.h>
     25#include <linux/init.h>
     26#include <linux/time.h>
     27#include <sound/core.h>
    2628#include <sound/trident.h>
    2729#define SNDRV_GET_ID
    2830#include <sound/initval.h>
    2931
    30 EXPORT_NO_SYMBOLS;
    3132MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, <audio@tridentmicro.com>");
    3233MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018");
     
    195196        if ((err = pci_module_init(&driver)) < 0) {
    196197#ifdef MODULE
    197 //              snd_printk("Trident 4DWave PCI soundcard not found or device busy\n");
     198//              snd_printk(KERN_ERR "Trident 4DWave PCI soundcard not found or device busy\n");
    198199#endif
    199200                return err;
     
    212213#ifndef MODULE
    213214
    214 /* format is: snd-card-trident=snd_enable,snd_index,snd_id,
     215/* format is: snd-trident=snd_enable,snd_index,snd_id,
    215216                               snd_pcm_channels,snd_wavetable_size */
    216217
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ymfpci/ymfpci.c

    r77 r92  
    2020 */
    2121
    22 #define SNDRV_MAIN_OBJECT_FILE
    2322#include <sound/driver.h>
     23#include <linux/init.h>
     24#include <linux/time.h>
     25#include <sound/core.h>
    2426#include <sound/ymfpci.h>
    2527#include <sound/mpu401.h>
     
    2931
    3032EXPORT_NO_SYMBOLS;
     33
    3134MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3235MODULE_DESCRIPTION("Yamaha DS-XG PCI");
     
    290293        if ((err = pci_module_init(&driver)) < 0) {
    291294#ifdef MODULE
    292 //              snd_printk("Yamaha DS-XG PCI soundcard not found or device busy\n");
     295//              snd_printk(KERN_ERR "Yamaha DS-XG PCI soundcard not found or device busy\n");
    293296#endif
    294297                return err;
     
    307310#ifndef MODULE
    308311
    309 /* format is: snd-card-ymfpci=snd_enable,snd_index,snd_id,
    310                               snd_fm_port,snd_mpu_port,snd_mpu_irq */
     312/* format is: snd-ymfpci=snd_enable,snd_index,snd_id,
     313                         snd_fm_port,snd_mpu_port */
    311314
    312315static int __init alsa_card_ymfpci_setup(char *str)
Note: See TracChangeset for help on using the changeset viewer.