Ignore:
Timestamp:
Mar 18, 2021, 8:57:36 PM (5 years ago)
Author:
David Azarewicz
Message:

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/trident/trident.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for Trident 4DWave DX/NX & SiS SI7018 Audio PCI soundcard
     
    45 *  Driver was originated by Trident <audio@tridentmicro.com>
    56 *                           Fri Feb 19 15:55:28 MST 1999
    6  *
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    227 */
    238
     
    2510#include <linux/pci.h>
    2611#include <linux/time.h>
    27 #include <linux/moduleparam.h>
     12#include <linux/module.h>
    2813#include <sound/core.h>
    29 #include <sound/trident.h>
     14#include "trident.h"
    3015#include <sound/initval.h>
     16
     17#ifdef TARGET_OS2
     18#define KBUILD_MODNAME "trident"
     19#endif
    3120
    3221MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, <audio@tridentmicro.com>");
     
    4837static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4938static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    50 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable this card */
     39static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
    5140#ifndef TARGET_OS2
    5241static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
     
    6857MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
    6958
    70 static DEFINE_PCI_DEVICE_TABLE(snd_trident_ids) = {
     59static const struct pci_device_id snd_trident_ids[] = {
    7160        {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX),
    7261                PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0},
     
    7968MODULE_DEVICE_TABLE(pci, snd_trident_ids);
    8069
    81 static int __devinit snd_trident_probe(struct pci_dev *pci,
    82                                        const struct pci_device_id *pci_id)
     70static int snd_trident_probe(struct pci_dev *pci,
     71                             const struct pci_device_id *pci_id)
    8372{
    8473        static int dev;
     
    9584        }
    9685
    97         err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
     86        err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
     87                           0, &card);
    9888        if (err < 0)
    9989                return err;
     
    128118                strcpy(card->shortname, "Trident ");
    129119        }
    130         strcat(card->shortname, card->driver);
     120        strcat(card->shortname, str);
    131121        sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
    132122                card->shortname, trident->port, trident->irq);
    133123
    134         if ((err = snd_trident_pcm(trident, pcm_dev++, NULL)) < 0) {
     124        if ((err = snd_trident_pcm(trident, pcm_dev++)) < 0) {
    135125                snd_card_free(card);
    136126                return err;
     
    139129        case TRIDENT_DEVICE_ID_DX:
    140130        case TRIDENT_DEVICE_ID_NX:
    141                 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++, NULL)) < 0) {
     131                if ((err = snd_trident_foldback_pcm(trident, pcm_dev++)) < 0) {
    142132                        snd_card_free(card);
    143133                        return err;
     
    146136        }
    147137        if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
    148                 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++, NULL)) < 0) {
     138                if ((err = snd_trident_spdif_pcm(trident, pcm_dev++)) < 0) {
    149139                        snd_card_free(card);
    150140                        return err;
     
    154144            (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
    155145                                       trident->midi_port,
    156                                        MPU401_INFO_INTEGRATED,
    157                                        trident->irq, 0, &trident->rmidi)) < 0) {
     146                                       MPU401_INFO_INTEGRATED |
     147                                       MPU401_INFO_IRQ_HOOK,
     148                                       -1, &trident->rmidi)) < 0) {
    158149                snd_card_free(card);
    159150                return err;
     
    171162}
    172163
    173 static void __devexit snd_trident_remove(struct pci_dev *pci)
     164static void snd_trident_remove(struct pci_dev *pci)
    174165{
    175166        snd_card_free(pci_get_drvdata(pci));
    176         pci_set_drvdata(pci, NULL);
    177167}
    178168
    179 static struct pci_driver driver = {
    180         .name = "Trident4DWaveAudio",
     169static struct pci_driver trident_driver = {
     170        .name = KBUILD_MODNAME,
    181171        .id_table = snd_trident_ids,
    182172        .probe = snd_trident_probe,
    183         .remove = __devexit_p(snd_trident_remove),
    184 #ifdef CONFIG_PM
    185         .suspend = snd_trident_suspend,
    186         .resume = snd_trident_resume,
     173        .remove = snd_trident_remove,
     174#ifdef CONFIG_PM_SLEEP
     175        .driver = {
     176                .pm = &snd_trident_pm,
     177        },
    187178#endif
    188179};
    189180
    190 static int __init alsa_card_trident_init(void)
    191 {
    192         return pci_register_driver(&driver);
    193 }
    194 
    195 static void __exit alsa_card_trident_exit(void)
    196 {
    197         pci_unregister_driver(&driver);
    198 }
    199 
    200 module_init(alsa_card_trident_init)
    201 module_exit(alsa_card_trident_exit)
     181module_pci_driver(trident_driver);
  • GPL/trunk/alsa-kernel/pci/trident/trident_main.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Maintained by Jaroslav Kysela <perex@perex.cz>
     
    1011 *    ---
    1112 *
    12  *   This program is free software; you can redistribute it and/or modify
    13  *   it under the terms of the GNU General Public License as published by
    14  *   the Free Software Foundation; either version 2 of the License, or
    15  *   (at your option) any later version.
    16  *
    17  *   This program is distributed in the hope that it will be useful,
    18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  *   GNU General Public License for more details.
    21  *
    22  *   You should have received a copy of the GNU General Public License
    23  *   along with this program; if not, write to the Free Software
    24  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    25  *
    26  *
    2713 *  SiS7018 S/PDIF support by Thomas Winischhofer <thomas@winischhofer.net>
    2814 */
     15
     16#ifdef TARGET_OS2
     17#define KBUILD_MODNAME "trident"
     18#endif
    2919
    3020#include <linux/delay.h>
     
    3626#include <linux/gameport.h>
    3727#include <linux/dma-mapping.h>
     28#include <linux/export.h>
     29#include <linux/io.h>
    3830
    3931#include <sound/core.h>
     
    4133#include <sound/control.h>
    4234#include <sound/tlv.h>
    43 #include <sound/trident.h>
     35#include "trident.h"
    4436#include <sound/asoundef.h>
    45 
    46 #include <asm/io.h>
    4737
    4838static int snd_trident_pcm_mixer_build(struct snd_trident *trident,
     
    6959        unsigned int val, tmp;
    7060
    71         printk(KERN_DEBUG "Trident voice %i:\n", voice);
     61        dev_dbg(trident->card->dev, "Trident voice %i:\n", voice);
    7262        outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR));
    7363        val = inl(TRID_REG(trident, CH_LBA));
    74         printk(KERN_DEBUG "LBA: 0x%x\n", val);
     64        dev_dbg(trident->card->dev, "LBA: 0x%x\n", val);
    7565        val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
    76         printk(KERN_DEBUG "GVSel: %i\n", val >> 31);
    77         printk(KERN_DEBUG "Pan: 0x%x\n", (val >> 24) & 0x7f);
    78         printk(KERN_DEBUG "Vol: 0x%x\n", (val >> 16) & 0xff);
    79         printk(KERN_DEBUG "CTRL: 0x%x\n", (val >> 12) & 0x0f);
    80         printk(KERN_DEBUG "EC: 0x%x\n", val & 0x0fff);
     66        dev_dbg(trident->card->dev, "GVSel: %i\n", val >> 31);
     67        dev_dbg(trident->card->dev, "Pan: 0x%x\n", (val >> 24) & 0x7f);
     68        dev_dbg(trident->card->dev, "Vol: 0x%x\n", (val >> 16) & 0xff);
     69        dev_dbg(trident->card->dev, "CTRL: 0x%x\n", (val >> 12) & 0x0f);
     70        dev_dbg(trident->card->dev, "EC: 0x%x\n", val & 0x0fff);
    8171        if (trident->device != TRIDENT_DEVICE_ID_NX) {
    8272                val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS));
    83                 printk(KERN_DEBUG "CSO: 0x%x\n", val >> 16);
    84                 printk("Alpha: 0x%x\n", (val >> 4) & 0x0fff);
    85                 printk(KERN_DEBUG "FMS: 0x%x\n", val & 0x0f);
     73                dev_dbg(trident->card->dev, "CSO: 0x%x\n", val >> 16);
     74                dev_dbg(trident->card->dev, "Alpha: 0x%x\n", (val >> 4) & 0x0fff);
     75                dev_dbg(trident->card->dev, "FMS: 0x%x\n", val & 0x0f);
    8676                val = inl(TRID_REG(trident, CH_DX_ESO_DELTA));
    87                 printk(KERN_DEBUG "ESO: 0x%x\n", val >> 16);
    88                 printk(KERN_DEBUG "Delta: 0x%x\n", val & 0xffff);
     77                dev_dbg(trident->card->dev, "ESO: 0x%x\n", val >> 16);
     78                dev_dbg(trident->card->dev, "Delta: 0x%x\n", val & 0xffff);
    8979                val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL));
    9080        } else {                // TRIDENT_DEVICE_ID_NX
    9181                val = inl(TRID_REG(trident, CH_NX_DELTA_CSO));
    9282                tmp = (val >> 24) & 0xff;
    93                 printk(KERN_DEBUG "CSO: 0x%x\n", val & 0x00ffffff);
     83                dev_dbg(trident->card->dev, "CSO: 0x%x\n", val & 0x00ffffff);
    9484                val = inl(TRID_REG(trident, CH_NX_DELTA_ESO));
    9585                tmp |= (val >> 16) & 0xff00;
    96                 printk(KERN_DEBUG "Delta: 0x%x\n", tmp);
    97                 printk(KERN_DEBUG "ESO: 0x%x\n", val & 0x00ffffff);
     86                dev_dbg(trident->card->dev, "Delta: 0x%x\n", tmp);
     87                dev_dbg(trident->card->dev, "ESO: 0x%x\n", val & 0x00ffffff);
    9888                val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL));
    99                 printk(KERN_DEBUG "Alpha: 0x%x\n", val >> 20);
    100                 printk(KERN_DEBUG "FMS: 0x%x\n", (val >> 16) & 0x0f);
    101         }
    102         printk(KERN_DEBUG "FMC: 0x%x\n", (val >> 14) & 3);
    103         printk(KERN_DEBUG "RVol: 0x%x\n", (val >> 7) & 0x7f);
    104         printk(KERN_DEBUG "CVol: 0x%x\n", val & 0x7f);
     89                dev_dbg(trident->card->dev, "Alpha: 0x%x\n", val >> 20);
     90                dev_dbg(trident->card->dev, "FMS: 0x%x\n", (val >> 16) & 0x0f);
     91        }
     92        dev_dbg(trident->card->dev, "FMC: 0x%x\n", (val >> 14) & 3);
     93        dev_dbg(trident->card->dev, "RVol: 0x%x\n", (val >> 7) & 0x7f);
     94        dev_dbg(trident->card->dev, "CVol: 0x%x\n", val & 0x7f);
    10595}
    10696#endif
     
    156146
    157147        if (count == 0 && !trident->ac97_detect) {
    158                 snd_printk(KERN_ERR "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n",
     148                dev_err(trident->card->dev,
     149                        "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n",
    159150                           reg, data);
    160151                data = 0;
     
    497488
    498489#if 0
    499         printk(KERN_DEBUG "written %i channel:\n", voice->number);
    500         printk(KERN_DEBUG "  regs[0] = 0x%x/0x%x\n",
     490        dev_dbg(trident->card->dev, "written %i channel:\n", voice->number);
     491        dev_dbg(trident->card->dev, "  regs[0] = 0x%x/0x%x\n",
    501492               regs[0], inl(TRID_REG(trident, CH_START + 0)));
    502         printk(KERN_DEBUG "  regs[1] = 0x%x/0x%x\n",
     493        dev_dbg(trident->card->dev, "  regs[1] = 0x%x/0x%x\n",
    503494               regs[1], inl(TRID_REG(trident, CH_START + 4)));
    504         printk(KERN_DEBUG "  regs[2] = 0x%x/0x%x\n",
     495        dev_dbg(trident->card->dev, "  regs[2] = 0x%x/0x%x\n",
    505496               regs[2], inl(TRID_REG(trident, CH_START + 8)));
    506         printk(KERN_DEBUG "  regs[3] = 0x%x/0x%x\n",
     497        dev_dbg(trident->card->dev, "  regs[3] = 0x%x/0x%x\n",
    507498               regs[3], inl(TRID_REG(trident, CH_START + 12)));
    508         printk(KERN_DEBUG "  regs[4] = 0x%x/0x%x\n",
     499        dev_dbg(trident->card->dev, "  regs[4] = 0x%x/0x%x\n",
    509500               regs[4], inl(TRID_REG(trident, CH_START + 16)));
    510501#endif
     
    589580                break;
    590581        case TRIDENT_DEVICE_ID_SI7018:
    591                 /* printk(KERN_DEBUG "voice->Vol = 0x%x\n", voice->Vol); */
     582                /* dev_dbg(trident->card->dev, "voice->Vol = 0x%x\n", voice->Vol); */
    592583                outw((voice->CTRL << 12) | voice->Vol,
    593584                     TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
     
    782773
    783774/*---------------------------------------------------------------------------
    784    snd_trident_ioctl
    785  
    786    Description: Device I/O control handler for playback/capture parameters.
    787  
    788    Parameters:   substream  - PCM substream class
    789                 cmd     - what ioctl message to process
    790                 arg     - additional message infoarg     
    791  
    792    Returns:     Error status
    793  
    794   ---------------------------------------------------------------------------*/
    795 
    796 static int snd_trident_ioctl(struct snd_pcm_substream *substream,
    797                              unsigned int cmd,
    798                              void *arg)
    799 {
    800         /* FIXME: it seems that with small periods the behaviour of
    801                   trident hardware is unpredictable and interrupt generator
    802                   is broken */
    803         return snd_pcm_lib_ioctl(substream, cmd, arg);
    804 }
    805 
    806 /*---------------------------------------------------------------------------
    807775   snd_trident_allocate_pcm_mem
    808776 
     
    822790        struct snd_pcm_runtime *runtime = substream->runtime;
    823791        struct snd_trident_voice *voice = runtime->private_data;
    824         int err;
    825 
    826         if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
    827                 return err;
     792
    828793        if (trident->tlb.entries) {
    829                 if (err > 0) { /* change */
     794                if (runtime->buffer_changed) {
    830795                        if (voice->memblk)
    831796                                snd_trident_free_pages(trident, voice->memblk);
     
    925890                }
    926891        }
    927         snd_pcm_lib_free_pages(substream);
    928892        if (evoice != NULL) {
    929893                snd_trident_free_voice(trident, evoice);
     
    11421106                                                struct snd_pcm_hw_params *hw_params)
    11431107{
    1144         int err;
    1145 
    1146         if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
    1147                 return err;
    1148 
    11491108        return snd_trident_allocate_evoice(substream, hw_params);
    11501109}
     
    11681127        struct snd_trident_voice *evoice = voice ? voice->extra : NULL;
    11691128
    1170         snd_pcm_lib_free_pages(substream);
    11711129        if (evoice != NULL) {
    11721130                snd_trident_free_voice(trident, evoice);
     
    17271685 */
    17281686
    1729 static struct snd_pcm_hardware snd_trident_playback =
     1687static const struct snd_pcm_hardware snd_trident_playback =
    17301688{
    17311689        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    17521710 */
    17531711
    1754 static struct snd_pcm_hardware snd_trident_capture =
     1712static const struct snd_pcm_hardware snd_trident_capture =
    17551713{
    17561714        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    17771735 */
    17781736
    1779 static struct snd_pcm_hardware snd_trident_foldback =
     1737static const struct snd_pcm_hardware snd_trident_foldback =
    17801738{
    17811739        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    18011759 */
    18021760
    1803 static struct snd_pcm_hardware snd_trident_spdif =
     1761static const struct snd_pcm_hardware snd_trident_spdif =
    18041762{
    18051763        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    18221780};
    18231781
    1824 static struct snd_pcm_hardware snd_trident_spdif_7018 =
     1782static const struct snd_pcm_hardware snd_trident_spdif_7018 =
    18251783{
    18261784        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    20702028  ---------------------------------------------------------------------------*/
    20712029
    2072 static struct snd_pcm_ops snd_trident_playback_ops = {
     2030static const struct snd_pcm_ops snd_trident_playback_ops = {
    20732031        .open =         snd_trident_playback_open,
    20742032        .close =        snd_trident_playback_close,
    2075         .ioctl =        snd_trident_ioctl,
    20762033        .hw_params =    snd_trident_hw_params,
    20772034        .hw_free =      snd_trident_hw_free,
     
    20812038};
    20822039
    2083 static struct snd_pcm_ops snd_trident_nx_playback_ops = {
     2040static const struct snd_pcm_ops snd_trident_nx_playback_ops = {
    20842041        .open =         snd_trident_playback_open,
    20852042        .close =        snd_trident_playback_close,
    2086         .ioctl =        snd_trident_ioctl,
    20872043        .hw_params =    snd_trident_hw_params,
    20882044        .hw_free =      snd_trident_hw_free,
     
    20902046        .trigger =      snd_trident_trigger,
    20912047        .pointer =      snd_trident_playback_pointer,
    2092         .page =         snd_pcm_sgbuf_ops_page,
    20932048};
    20942049
    2095 static struct snd_pcm_ops snd_trident_capture_ops = {
     2050static const struct snd_pcm_ops snd_trident_capture_ops = {
    20962051        .open =         snd_trident_capture_open,
    20972052        .close =        snd_trident_capture_close,
    2098         .ioctl =        snd_trident_ioctl,
    20992053        .hw_params =    snd_trident_capture_hw_params,
    21002054        .hw_free =      snd_trident_hw_free,
     
    21042058};
    21052059
    2106 static struct snd_pcm_ops snd_trident_si7018_capture_ops = {
     2060static const struct snd_pcm_ops snd_trident_si7018_capture_ops = {
    21072061        .open =         snd_trident_capture_open,
    21082062        .close =        snd_trident_capture_close,
    2109         .ioctl =        snd_trident_ioctl,
    21102063        .hw_params =    snd_trident_si7018_capture_hw_params,
    21112064        .hw_free =      snd_trident_si7018_capture_hw_free,
     
    21152068};
    21162069
    2117 static struct snd_pcm_ops snd_trident_foldback_ops = {
     2070static const struct snd_pcm_ops snd_trident_foldback_ops = {
    21182071        .open =         snd_trident_foldback_open,
    21192072        .close =        snd_trident_foldback_close,
    2120         .ioctl =        snd_trident_ioctl,
    21212073        .hw_params =    snd_trident_hw_params,
    21222074        .hw_free =      snd_trident_hw_free,
     
    21262078};
    21272079
    2128 static struct snd_pcm_ops snd_trident_nx_foldback_ops = {
     2080static const struct snd_pcm_ops snd_trident_nx_foldback_ops = {
    21292081        .open =         snd_trident_foldback_open,
    21302082        .close =        snd_trident_foldback_close,
    2131         .ioctl =        snd_trident_ioctl,
    21322083        .hw_params =    snd_trident_hw_params,
    21332084        .hw_free =      snd_trident_hw_free,
     
    21352086        .trigger =      snd_trident_trigger,
    21362087        .pointer =      snd_trident_playback_pointer,
    2137         .page =         snd_pcm_sgbuf_ops_page,
    21382088};
    21392089
    2140 static struct snd_pcm_ops snd_trident_spdif_ops = {
     2090static const struct snd_pcm_ops snd_trident_spdif_ops = {
    21412091        .open =         snd_trident_spdif_open,
    21422092        .close =        snd_trident_spdif_close,
    2143         .ioctl =        snd_trident_ioctl,
    21442093        .hw_params =    snd_trident_spdif_hw_params,
    21452094        .hw_free =      snd_trident_hw_free,
     
    21492098};
    21502099
    2151 static struct snd_pcm_ops snd_trident_spdif_7018_ops = {
     2100static const struct snd_pcm_ops snd_trident_spdif_7018_ops = {
    21522101        .open =         snd_trident_spdif_open,
    21532102        .close =        snd_trident_spdif_close,
    2154         .ioctl =        snd_trident_ioctl,
    21552103        .hw_params =    snd_trident_spdif_hw_params,
    21562104        .hw_free =      snd_trident_hw_free,
     
    21712119  ---------------------------------------------------------------------------*/
    21722120
    2173 int __devinit snd_trident_pcm(struct snd_trident * trident,
    2174                               int device, struct snd_pcm ** rpcm)
     2121int snd_trident_pcm(struct snd_trident *trident, int device)
    21752122{
    21762123        struct snd_pcm *pcm;
    21772124        int err;
    21782125
    2179         if (rpcm)
    2180                 *rpcm = NULL;
    21812126        if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm)) < 0)
    21822127                return err;
     
    22022147                struct snd_pcm_substream *substream;
    22032148                for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
    2204                         snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
    2205                                                       snd_dma_pci_data(trident->pci),
    2206                                                       64*1024, 128*1024);
    2207                 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
    2208                                               SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
    2209                                               64*1024, 128*1024);
     2149                        snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV_SG,
     2150                                                   &trident->pci->dev,
     2151                                                   64*1024, 128*1024);
     2152                snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
     2153                                           SNDRV_DMA_TYPE_DEV,
     2154                                           &trident->pci->dev,
     2155                                           64*1024, 128*1024);
    22102156        } else {
    2211                 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    2212                                                       snd_dma_pci_data(trident->pci), 64*1024, 128*1024);
    2213         }
    2214 
    2215         if (rpcm)
    2216                 *rpcm = pcm;
     2157                snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
     2158                                               &trident->pci->dev,
     2159                                               64*1024, 128*1024);
     2160        }
     2161
    22172162        return 0;
    22182163}
     
    22292174  ---------------------------------------------------------------------------*/
    22302175
    2231 int __devinit snd_trident_foldback_pcm(struct snd_trident * trident,
    2232                                        int device, struct snd_pcm ** rpcm)
     2176int snd_trident_foldback_pcm(struct snd_trident *trident, int device)
    22332177{
    22342178        struct snd_pcm *foldback;
     
    22372181        struct snd_pcm_substream *substream;
    22382182
    2239         if (rpcm)
    2240                 *rpcm = NULL;
    22412183        if (trident->device == TRIDENT_DEVICE_ID_NX)
    22422184                num_chan = 4;
     
    22642206
    22652207        if (trident->tlb.entries)
    2266                 snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV_SG,
    2267                                                       snd_dma_pci_data(trident->pci), 0, 128*1024);
     2208                snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV_SG,
     2209                                               &trident->pci->dev,
     2210                                               0, 128*1024);
    22682211        else
    2269                 snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV,
    2270                                                       snd_dma_pci_data(trident->pci), 64*1024, 128*1024);
    2271 
    2272         if (rpcm)
    2273                 *rpcm = foldback;
     2212                snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV,
     2213                                               &trident->pci->dev,
     2214                                               64*1024, 128*1024);
     2215
    22742216        return 0;
    22752217}
     
    22862228  ---------------------------------------------------------------------------*/
    22872229
    2288 int __devinit snd_trident_spdif_pcm(struct snd_trident * trident,
    2289                                     int device, struct snd_pcm ** rpcm)
     2230int snd_trident_spdif_pcm(struct snd_trident *trident, int device)
    22902231{
    22912232        struct snd_pcm *spdif;
    22922233        int err;
    22932234
    2294         if (rpcm)
    2295                 *rpcm = NULL;
    22962235        if ((err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif)) < 0)
    22972236                return err;
     
    23072246        trident->spdif = spdif;
    23082247
    2309         snd_pcm_lib_preallocate_pages_for_all(spdif, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 64*1024, 128*1024);
    2310 
    2311         if (rpcm)
    2312                 *rpcm = spdif;
     2248        snd_pcm_set_managed_buffer_all(spdif, SNDRV_DMA_TYPE_DEV,
     2249                                       &trident->pci->dev, 64*1024, 128*1024);
     2250
    23132251        return 0;
    23142252}
     
    23712309}
    23722310
    2373 static struct snd_kcontrol_new snd_trident_spdif_control __devinitdata =
     2311static const struct snd_kcontrol_new snd_trident_spdif_control =
    23742312{
    23752313        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    24342372}
    24352373
    2436 static struct snd_kcontrol_new snd_trident_spdif_default __devinitdata =
     2374static const struct snd_kcontrol_new snd_trident_spdif_default =
    24372375{
    24382376        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
     
    24672405}
    24682406
    2469 static struct snd_kcontrol_new snd_trident_spdif_mask __devinitdata =
     2407static const struct snd_kcontrol_new snd_trident_spdif_mask =
    24702408{
    24712409        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
     
    25292467}
    25302468
    2531 static struct snd_kcontrol_new snd_trident_spdif_stream __devinitdata =
     2469static const struct snd_kcontrol_new snd_trident_spdif_stream =
    25322470{
    25332471        .access =       SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,
     
    25792517}
    25802518
    2581 static struct snd_kcontrol_new snd_trident_ac97_rear_control __devinitdata =
     2519static const struct snd_kcontrol_new snd_trident_ac97_rear_control =
    25822520{
    25832521        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    26372575}
    26382576
    2639 static struct snd_kcontrol_new snd_trident_vol_music_control __devinitdata =
     2577static const struct snd_kcontrol_new snd_trident_vol_music_control =
    26402578{
    26412579        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    26482586};
    26492587
    2650 static struct snd_kcontrol_new snd_trident_vol_wave_control __devinitdata =
     2588static const struct snd_kcontrol_new snd_trident_vol_wave_control =
    26512589{
    26522590        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    27152653}
    27162654
    2717 static struct snd_kcontrol_new snd_trident_pcm_vol_control __devinitdata =
     2655static const struct snd_kcontrol_new snd_trident_pcm_vol_control =
    27182656{
    27192657        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    27792717}
    27802718
    2781 static struct snd_kcontrol_new snd_trident_pcm_pan_control __devinitdata =
     2719static const struct snd_kcontrol_new snd_trident_pcm_pan_control =
    27822720{
    27832721        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    28362774static const DECLARE_TLV_DB_SCALE(db_scale_crvol, -3175, 25, 1);
    28372775
    2838 static struct snd_kcontrol_new snd_trident_pcm_rvol_control __devinitdata =
     2776static const struct snd_kcontrol_new snd_trident_pcm_rvol_control =
    28392777{
    28402778        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    28922830}
    28932831
    2894 static struct snd_kcontrol_new snd_trident_pcm_cvol_control __devinitdata =
     2832static const struct snd_kcontrol_new snd_trident_pcm_cvol_control =
    28952833{
    28962834        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     
    29722910  ---------------------------------------------------------------------------*/
    29732911
    2974 static int __devinit snd_trident_mixer(struct snd_trident * trident, int pcm_spdif_device)
     2912static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
    29752913{
    29762914        struct snd_ac97_template _ac97;
     
    29792917        struct snd_ctl_elem_value *uctl;
    29802918        int idx, err, retries = 2;
    2981         static struct snd_ac97_bus_ops ops = {
     2919        static const struct snd_ac97_bus_ops ops = {
    29822920                .write = snd_trident_codec_write,
    29832921                .read = snd_trident_codec_read,
     
    30132951                err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97_sec);
    30142952                if (err < 0)
    3015                         snd_printk(KERN_ERR "SI7018: the secondary codec - invalid access\n");
     2953                        dev_err(trident->card->dev,
     2954                                "SI7018: the secondary codec - invalid access\n");
    30162955#if 0   // only for my testing purpose --jk
    30172956                {
     
    30192958                        err = snd_ac97_modem(trident->card, &_ac97, &mc97);
    30202959                        if (err < 0)
    3021                                 snd_printk(KERN_ERR "snd_ac97_modem returned error %i\n", err);
     2960                                dev_err(trident->card->dev,
     2961                                        "snd_ac97_modem returned error %i\n", err);
    30222962                }
    30232963#endif
     
    31333073 */
    31343074
    3135 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
     3075#if IS_REACHABLE(CONFIG_GAMEPORT)
    31363076
    31373077static unsigned char snd_trident_gameport_read(struct gameport *gameport)
     
    31913131}
    31923132
    3193 int __devinit snd_trident_create_gameport(struct snd_trident *chip)
     3133int snd_trident_create_gameport(struct snd_trident *chip)
    31943134{
    31953135        struct gameport *gp;
     
    31973137        chip->gameport = gp = gameport_allocate_port();
    31983138        if (!gp) {
    3199                 printk(KERN_ERR "trident: cannot allocate memory for gameport\n");
     3139                dev_err(chip->card->dev,
     3140                        "cannot allocate memory for gameport\n");
    32003141                return -ENOMEM;
    32013142        }
     
    32253166}
    32263167#else
    3227 int __devinit snd_trident_create_gameport(struct snd_trident *chip) { return -ENOSYS; }
     3168int snd_trident_create_gameport(struct snd_trident *chip) { return -ENOSYS; }
    32283169static inline void snd_trident_free_gameport(struct snd_trident *chip) { }
    32293170#endif /* CONFIG_GAMEPORT */
     
    32703211                do_delay(trident);
    32713212        } while (time_after_eq(end_time, jiffies));
    3272         snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL)));
     3213        dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n",
     3214                inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL)));
    32733215        if (r-- > 0) {
    32743216                end_time = jiffies + HZ;
     
    33293271}
    33303272
    3331 static void __devinit snd_trident_proc_init(struct snd_trident * trident)
    3332 {
    3333         struct snd_info_entry *entry;
     3273static void snd_trident_proc_init(struct snd_trident *trident)
     3274{
    33343275        const char *s = "trident";
    33353276       
    33363277        if (trident->device == TRIDENT_DEVICE_ID_SI7018)
    33373278                s = "sis7018";
    3338         if (! snd_card_proc_new(trident->card, s, &entry))
    3339                 snd_info_set_text_ops(entry, trident, snd_trident_proc_read);
     3279        snd_card_ro_proc_new(trident->card, s, trident, snd_trident_proc_read);
    33403280}
    33413281
     
    33583298  ---------------------------------------------------------------------------*/
    33593299
    3360 static int __devinit snd_trident_tlb_alloc(struct snd_trident *trident)
     3300static int snd_trident_tlb_alloc(struct snd_trident *trident)
    33613301{
    33623302        int i;
     
    33653305           32kB region and correct offset when necessary */
    33663306
    3367         if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
     3307        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev,
    33683308                                2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) {
    3369                 snd_printk(KERN_ERR "trident: unable to allocate TLB buffer\n");
     3309                dev_err(trident->card->dev, "unable to allocate TLB buffer\n");
    33703310                return -ENOMEM;
    33713311        }
    3372         trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
     3312        trident->tlb.entries = (__le32 *)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
    33733313        trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4);
    33743314        /* allocate shadow TLB page table (virtual addresses) */
    3375         trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long));
    3376         if (trident->tlb.shadow_entries == NULL) {
    3377                 snd_printk(KERN_ERR "trident: unable to allocate shadow TLB entries\n");
     3315        trident->tlb.shadow_entries =
     3316                vmalloc(array_size(SNDRV_TRIDENT_MAX_PAGES,
     3317                                   sizeof(unsigned long)));
     3318        if (!trident->tlb.shadow_entries)
    33783319                return -ENOMEM;
    3379         }
     3320
    33803321        /* allocate and setup silent page and initialise TLB entries */
    3381         if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
     3322        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev,
    33823323                                SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) {
    3383                 snd_printk(KERN_ERR "trident: unable to allocate silent page\n");
     3324                dev_err(trident->card->dev, "unable to allocate silent page\n");
    33843325                return -ENOMEM;
    33853326        }
     
    34393380                do_delay(trident);
    34403381        } while (time_after_eq(end_time, jiffies));
    3441         snd_printk(KERN_ERR "AC'97 codec ready error\n");
     3382        dev_err(trident->card->dev, "AC'97 codec ready error\n");
    34423383        return -EIO;
    34433384
     
    34773418                do_delay(trident);
    34783419        } while (time_after_eq(end_time, jiffies));
    3479         snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT)));
     3420        dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n",
     3421                inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT)));
    34803422        return -EIO;
    34813423
     
    35393481  ---------------------------------------------------------------------------*/
    35403482
    3541 int __devinit snd_trident_create(struct snd_card *card,
     3483int snd_trident_create(struct snd_card *card,
    35423484                       struct pci_dev *pci,
    35433485                       int pcm_streams,
     
    35503492        struct snd_trident_voice *voice;
    35513493        struct snd_trident_pcm_mixer *tmix;
    3552         static struct snd_device_ops ops = {
     3494        static const struct snd_device_ops ops = {
    35533495                .dev_free =     snd_trident_dev_free,
    35543496        };
     
    35603502                return err;
    35613503        /* check, if we can restrict PCI DMA transfers to 30 bits */
    3562         if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 ||
    3563             pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
    3564                 snd_printk(KERN_ERR "architecture does not support 30bit PCI busmaster DMA\n");
     3504        if (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 ||
     3505            dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) {
     3506                dev_err(card->dev,
     3507                        "architecture does not support 30bit PCI busmaster DMA\n");
    35653508                pci_disable_device(pci);
    35663509                return -ENXIO;
     
    35993542
    36003543        if (request_irq(pci->irq, snd_trident_interrupt, IRQF_SHARED,
    3601                         "Trident Audio", trident)) {
    3602                 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
     3544                        KBUILD_MODNAME, trident)) {
     3545                dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
    36033546                snd_trident_free(trident);
    36043547                return -EBUSY;
    36053548        }
    36063549        trident->irq = pci->irq;
     3550        card->sync_irq = trident->irq;
    36073551
    36083552        /* allocate 16k-aligned TLB for NX cards */
     
    36643608
    36653609        snd_trident_proc_init(trident);
    3666         snd_card_set_dev(card, &pci->dev);
    36673610        *rtrident = trident;
    36683611        return 0;
     
    36953638        if (trident->tlb.buffer.area) {
    36963639                outl(0, TRID_REG(trident, NX_TLBC));
    3697                 if (trident->tlb.memhdr)
    3698                         snd_util_memhdr_free(trident->tlb.memhdr);
     3640                snd_util_memhdr_free(trident->tlb.memhdr);
    36993641                if (trident->tlb.silent_page.area)
    37003642                        snd_dma_free_pages(&trident->tlb.silent_page);
     
    38733815        unsigned long flags;
    38743816        void (*private_free)(struct snd_trident_voice *);
    3875         void *private_data;
    38763817
    38773818        if (voice == NULL || !voice->use)
     
    38803821        spin_lock_irqsave(&trident->voice_alloc, flags);
    38813822        private_free = voice->private_free;
    3882         private_data = voice->private_data;
    38833823        voice->private_free = NULL;
    38843824        voice->private_data = NULL;
     
    39193859}
    39203860
    3921 #ifdef CONFIG_PM
    3922 int snd_trident_suspend(struct pci_dev *pci, pm_message_t state)
    3923 {
    3924         struct snd_card *card = pci_get_drvdata(pci);
     3861#ifdef CONFIG_PM_SLEEP
     3862static int snd_trident_suspend(struct device *dev)
     3863{
     3864        struct snd_card *card = dev_get_drvdata(dev);
    39253865        struct snd_trident *trident = card->private_data;
    39263866
    39273867        trident->in_suspend = 1;
    39283868        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    3929         snd_pcm_suspend_all(trident->pcm);
    3930         snd_pcm_suspend_all(trident->foldback);
    3931         snd_pcm_suspend_all(trident->spdif);
    3932 
    39333869        snd_ac97_suspend(trident->ac97);
    39343870        snd_ac97_suspend(trident->ac97_sec);
    3935 
    3936         pci_disable_device(pci);
    3937         pci_save_state(pci);
    3938         pci_set_power_state(pci, pci_choose_state(pci, state));
    3939         return 0;
    3940 }
    3941 
    3942 int snd_trident_resume(struct pci_dev *pci)
    3943 {
    3944         struct snd_card *card = pci_get_drvdata(pci);
     3871        return 0;
     3872}
     3873
     3874static int snd_trident_resume(struct device *dev)
     3875{
     3876        struct snd_card *card = dev_get_drvdata(dev);
    39453877        struct snd_trident *trident = card->private_data;
    3946 
    3947         pci_set_power_state(pci, PCI_D0);
    3948         pci_restore_state(pci);
    3949         if (pci_enable_device(pci) < 0) {
    3950                 printk(KERN_ERR "trident: pci_enable_device failed, "
    3951                        "disabling device\n");
    3952                 snd_card_disconnect(card);
    3953                 return -EIO;
    3954         }
    3955         pci_set_master(pci);
    39563878
    39573879        switch (trident->device) {
     
    39793901        return 0;
    39803902}
    3981 #endif /* CONFIG_PM */
     3903
     3904SIMPLE_DEV_PM_OPS(snd_trident_pm, snd_trident_suspend, snd_trident_resume);
     3905#endif /* CONFIG_PM_SLEEP */
  • GPL/trunk/alsa-kernel/pci/trident/trident_memory.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    67 *  Trident 4DWave-NX memory page allocation (TLB area)
    78 *  Trident chip can handle only 16MByte of the memory at the same time.
    8  *
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    24  */
    25 
    26 #include <asm/io.h>
     9 */
     10
     11#include <linux/io.h>
    2712#include <linux/pci.h>
    2813#include <linux/time.h>
     
    3015
    3116#include <sound/core.h>
    32 #include <sound/trident.h>
     17#include "trident.h"
    3318
    3419/* page arguments of these two macros are Trident page (4096 bytes), not like
     
    140125search_empty(struct snd_util_memhdr *hdr, int size)
    141126{
    142         struct snd_util_memblk *blk, *prev;
     127        struct snd_util_memblk *blk;
    143128        int page, psize;
    144129        struct list_head *p;
    145130
    146131        psize = get_aligned_page(size + ALIGN_PAGE_SIZE -1);
    147         prev = NULL;
    148132        page = 0;
    149133        list_for_each(p, &hdr->block) {
     
    214198                return NULL;
    215199        }
    216                        
     200                           
    217201        /* set TLB entries */
    218202        idx = 0;
     
    263247                return NULL;
    264248        }
    265                        
     249                           
    266250        /* set TLB entries */
    267251        addr = runtime->dma_addr;
Note: See TracChangeset for help on using the changeset viewer.