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:
7 edited
4 copied

Legend:

Unmodified
Added
Removed
  • GPL/trunk

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

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
    34 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    4  *
    5  *
    6  *   This program is free software; you can redistribute it and/or modify
    7  *   it under the terms of the GNU General Public License as published by
    8  *   the Free Software Foundation; either version 2 of the License, or
    9  *   (at your option) any later version.
    10  *
    11  *   This program is distributed in the hope that it will be useful,
    12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  *   GNU General Public License for more details.
    15  *
    16  *   You should have received a copy of the GNU General Public License
    17  *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    19  *
    205 */
    216
     
    2611*/
    2712
     13#ifdef TARGET_OS2
     14#define KBUILD_MODNAME "cs46xx"
     15#endif
    2816#include <linux/pci.h>
    2917#include <linux/time.h>
    3018#include <linux/init.h>
    31 #include <linux/moduleparam.h>
     19#include <linux/module.h>
    3220#include <sound/core.h>
    33 #include <sound/cs46xx.h>
     21#include "cs46xx.h"
    3422#include <sound/initval.h>
    3523
     
    4735static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4836static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    49 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable this card */
    50 static int external_amp[SNDRV_CARDS];
    51 static int thinkpad[SNDRV_CARDS];
     37static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
     38static bool external_amp[SNDRV_CARDS];
     39static bool thinkpad[SNDRV_CARDS];
    5240#ifndef TARGET_OS2
    53 static int mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     41static bool mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
    5442#else
    55 static int mmap_valid[SNDRV_CARDS] = {1,1,1,1,1,1,1,1};
     43static bool mmap_valid[SNDRV_CARDS] = {1,1,1,1,1,1,1,1};
    5644#endif
     45
    5746module_param_array(index, int, NULL, 0444);
    5847MODULE_PARM_DESC(index, "Index value for the CS46xx soundcard.");
     
    6251MODULE_PARM_DESC(enable, "Enable CS46xx soundcard.");
    6352module_param_array(external_amp, bool, NULL, 0444);
    64 MODULE_PARM_DESC(external_amp, "Force to enable external amplifer.");
     53MODULE_PARM_DESC(external_amp, "Force to enable external amplifier.");
    6554module_param_array(thinkpad, bool, NULL, 0444);
    6655MODULE_PARM_DESC(thinkpad, "Force to enable Thinkpad's CLKRUN control.");
     
    6857MODULE_PARM_DESC(mmap_valid, "Support OSS mmap.");
    6958
    70 static DEFINE_PCI_DEVICE_TABLE(snd_cs46xx_ids) = {
     59static const struct pci_device_id snd_cs46xx_ids[] = {
    7160        { PCI_VDEVICE(CIRRUS, 0x6001), 0, },   /* CS4280 */
    7261        { PCI_VDEVICE(CIRRUS, 0x6003), 0, },   /* CS4612 */
     
    7766MODULE_DEVICE_TABLE(pci, snd_cs46xx_ids);
    7867
    79 static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci,
    80                                           const struct pci_device_id *pci_id)
     68static int snd_card_cs46xx_probe(struct pci_dev *pci,
     69                                const struct pci_device_id *pci_id)
    8170{
    8271        static int dev;
     
    9281        }
    9382
    94         err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
     83        err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
     84                           0, &card);
    9585        if (err < 0)
    9686                return err;
     
    10393        card->private_data = chip;
    10494        chip->accept_valid = mmap_valid[dev];
    105         if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) {
     95        if ((err = snd_cs46xx_pcm(chip, 0)) < 0) {
    10696                snd_card_free(card);
    10797                return err;
    10898        }
    10999#ifdef CONFIG_SND_CS46XX_NEW_DSP
    110         if ((err = snd_cs46xx_pcm_rear(chip,1, NULL)) < 0) {
     100        if ((err = snd_cs46xx_pcm_rear(chip, 1)) < 0) {
    111101                snd_card_free(card);
    112102                return err;
    113103        }
    114         if ((err = snd_cs46xx_pcm_iec958(chip,2,NULL)) < 0) {
     104        if ((err = snd_cs46xx_pcm_iec958(chip, 2)) < 0) {
    115105                snd_card_free(card);
    116106                return err;
     
    123113#ifdef CONFIG_SND_CS46XX_NEW_DSP
    124114        if (chip->nr_ac97_codecs ==2) {
    125                 if ((err = snd_cs46xx_pcm_center_lfe(chip,3,NULL)) < 0) {
     115                if ((err = snd_cs46xx_pcm_center_lfe(chip, 3)) < 0) {
    126116                        snd_card_free(card);
    127117                        return err;
     
    129119        }
    130120#endif
    131         if ((err = snd_cs46xx_midi(chip, 0, NULL)) < 0) {
     121        if ((err = snd_cs46xx_midi(chip, 0)) < 0) {
    132122                snd_card_free(card);
    133123                return err;
     
    159149}
    160150
    161 static void __devexit snd_card_cs46xx_remove(struct pci_dev *pci)
     151static void snd_card_cs46xx_remove(struct pci_dev *pci)
    162152{
    163153        snd_card_free(pci_get_drvdata(pci));
    164         pci_set_drvdata(pci, NULL);
    165154}
    166155
    167 static struct pci_driver driver = {
    168         .name = "Sound Fusion CS46xx",
     156static struct pci_driver cs46xx_driver = {
     157        .name = KBUILD_MODNAME,
    169158        .id_table = snd_cs46xx_ids,
    170159        .probe = snd_card_cs46xx_probe,
    171         .remove = __devexit_p(snd_card_cs46xx_remove),
    172 #ifdef CONFIG_PM
    173         .suspend = snd_cs46xx_suspend,
    174         .resume = snd_cs46xx_resume,
     160        .remove = snd_card_cs46xx_remove,
     161#ifdef CONFIG_PM_SLEEP
     162        .driver = {
     163                .pm = &snd_cs46xx_pm,
     164        },
    175165#endif
    176166};
    177167
    178 static int __init alsa_card_cs46xx_init(void)
    179 {
    180         return pci_register_driver(&driver);
    181 }
    182 
    183 static void __exit alsa_card_cs46xx_exit(void)
    184 {
    185         pci_unregister_driver(&driver);
    186 }
    187 
    188 module_init(alsa_card_cs46xx_init)
    189 module_exit(alsa_card_cs46xx_exit)
     168module_pci_driver(cs46xx_driver);
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    2930 *           supported by the cs46xx DSP's.
    3031 *           Benny <benny@hostmobility.com>
    31  *               
    32  *   This program is free software; you can redistribute it and/or modify
    33  *   it under the terms of the GNU General Public License as published by
    34  *   the Free Software Foundation; either version 2 of the License, or
    35  *   (at your option) any later version.
    36  *
    37  *   This program is distributed in the hope that it will be useful,
    38  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    39  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    40  *   GNU General Public License for more details.
    41  *
    42  *   You should have received a copy of the GNU General Public License
    43  *   along with this program; if not, write to the Free Software
    44  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    45  *
    4632 */
     33
     34#ifdef TARGET_OS2
     35#define KBUILD_MODNAME "cs46xx"
     36#endif
    4737
    4838#include <linux/delay.h>
     
    5444#include <linux/gameport.h>
    5545#include <linux/mutex.h>
    56 
     46#include <linux/export.h>
     47#include <linux/module.h>
     48#include <linux/firmware.h>
     49#include <linux/vmalloc.h>
     50#include <linux/io.h>
    5751
    5852#include <sound/core.h>
     
    6155#include <sound/pcm.h>
    6256#include <sound/pcm_params.h>
    63 #include <sound/cs46xx.h>
    64 
    65 #include <asm/io.h>
     57#include "cs46xx.h"
    6658
    6759#include "cs46xx_lib.h"
     
    7163
    7264#ifdef CONFIG_SND_CS46XX_NEW_DSP
    73 static struct snd_pcm_ops snd_cs46xx_playback_rear_ops;
    74 static struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops;
    75 static struct snd_pcm_ops snd_cs46xx_playback_clfe_ops;
    76 static struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops;
    77 static struct snd_pcm_ops snd_cs46xx_playback_iec958_ops;
    78 static struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops;
    79 #endif
    80 
    81 static struct snd_pcm_ops snd_cs46xx_playback_ops;
    82 static struct snd_pcm_ops snd_cs46xx_playback_indirect_ops;
    83 static struct snd_pcm_ops snd_cs46xx_capture_ops;
    84 static struct snd_pcm_ops snd_cs46xx_capture_indirect_ops;
     65static const struct snd_pcm_ops snd_cs46xx_playback_rear_ops;
     66static const struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops;
     67static const struct snd_pcm_ops snd_cs46xx_playback_clfe_ops;
     68static const struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops;
     69static const struct snd_pcm_ops snd_cs46xx_playback_iec958_ops;
     70static const struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops;
     71#endif
     72
     73static const struct snd_pcm_ops snd_cs46xx_playback_ops;
     74static const struct snd_pcm_ops snd_cs46xx_playback_indirect_ops;
     75static const struct snd_pcm_ops snd_cs46xx_capture_ops;
     76static const struct snd_pcm_ops snd_cs46xx_capture_indirect_ops;
    8577
    8678static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
     
    9486        if (snd_BUG_ON(codec_index != CS46XX_PRIMARY_CODEC_INDEX &&
    9587                       codec_index != CS46XX_SECONDARY_CODEC_INDEX))
    96                 return -EINVAL;
     88                return 0xffff;
    9789
    9890        chip->active_ctrl(chip, 1);
     
    114106        tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL);
    115107        if ((tmp & ACCTL_VFRM) == 0) {
    116                 snd_printk(KERN_WARNING  "cs46xx: ACCTL_VFRM not set 0x%x\n",tmp);
     108                dev_warn(chip->card->dev, "ACCTL_VFRM not set 0x%x\n", tmp);
    117109                snd_cs46xx_pokeBA0(chip, BA0_ACCTL, (tmp & (~ACCTL_ESYN)) | ACCTL_VFRM );
    118110                msleep(50);
     
    166158        }
    167159
    168         snd_printk(KERN_ERR "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
     160        dev_err(chip->card->dev,
     161                "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
    169162        result = 0xffff;
    170163        goto end;
     
    185178        }
    186179       
    187         snd_printk(KERN_ERR "AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n", codec_index, reg);
     180        dev_err(chip->card->dev,
     181                "AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n",
     182                codec_index, reg);
    188183        result = 0xffff;
    189184        goto end;
     
    195190         */
    196191#if 0
    197         printk(KERN_DEBUG "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
     192        dev_dbg(chip->card->dev,
     193                "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
    198194                        snd_cs46xx_peekBA0(chip, BA0_ACSDA),
    199195                        snd_cs46xx_peekBA0(chip, BA0_ACCAD));
     
    284280                }
    285281        }
    286         snd_printk(KERN_ERR "AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n", codec_index, reg, val);
     282        dev_err(chip->card->dev,
     283                "AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n",
     284                codec_index, reg, val);
    287285 end:
    288286        chip->active_ctrl(chip, -1);
     
    330328}
    331329
    332 #ifdef CONFIG_SND_CS46XX_NEW_DSP
    333 
    334 #include "imgs/cwc4630.h"
    335 #include "imgs/cwcasync.h"
    336 #include "imgs/cwcsnoop.h"
    337 #include "imgs/cwcbinhack.h"
    338 #include "imgs/cwcdma.h"
     330static inline void memcpy_le32(void *dst, const void *src, unsigned int len)
     331{
     332#ifdef __LITTLE_ENDIAN
     333        memcpy(dst, src, len);
     334#else
     335        u32 *_dst = dst;
     336        const __le32 *_src = src;
     337        len /= 4;
     338        while (len-- > 0)
     339                *_dst++ = le32_to_cpu(*_src++);
     340#endif
     341}
     342
     343#ifdef CONFIG_SND_CS46XX_NEW_DSP
     344
     345static const char *module_names[CS46XX_DSP_MODULES] = {
     346        "cwc4630", "cwcasync", "cwcsnoop", "cwcbinhack", "cwcdma"
     347};
     348
     349MODULE_FIRMWARE("cs46xx/cwc4630");
     350MODULE_FIRMWARE("cs46xx/cwcasync");
     351MODULE_FIRMWARE("cs46xx/cwcsnoop");
     352MODULE_FIRMWARE("cs46xx/cwcbinhack");
     353MODULE_FIRMWARE("cs46xx/cwcdma");
     354
     355static void free_module_desc(struct dsp_module_desc *module)
     356{
     357        if (!module)
     358                return;
     359        kfree(module->module_name);
     360        kfree(module->symbol_table.symbols);
     361        if (module->segments) {
     362                int i;
     363                for (i = 0; i < module->nsegments; i++)
     364                        kfree(module->segments[i].data);
     365                kfree(module->segments);
     366        }
     367        kfree(module);
     368}
     369
     370/* firmware binary format:
     371 * le32 nsymbols;
     372 * struct {
     373 *      le32 address;
     374 *      char symbol_name[DSP_MAX_SYMBOL_NAME];
     375 *      le32 symbol_type;
     376 * } symbols[nsymbols];
     377 * le32 nsegments;
     378 * struct {
     379 *      le32 segment_type;
     380 *      le32 offset;
     381 *      le32 size;
     382 *      le32 data[size];
     383 * } segments[nsegments];
     384 */
     385
     386static int load_firmware(struct snd_cs46xx *chip,
     387                         struct dsp_module_desc **module_ret,
     388                         const char *fw_name)
     389{
     390        int i, err;
     391        unsigned int nums, fwlen, fwsize;
     392        const __le32 *fwdat;
     393        struct dsp_module_desc *module = NULL;
     394        const struct firmware *fw;
     395        char fw_path[32];
     396
     397        sprintf(fw_path, "cs46xx/%s", fw_name);
     398        err = request_firmware(&fw, fw_path, &chip->pci->dev);
     399        if (err < 0)
     400                return err;
     401        fwsize = fw->size / 4;
     402        if (fwsize < 2) {
     403                err = -EINVAL;
     404                goto error;
     405        }
     406
     407        err = -ENOMEM;
     408        module = kzalloc(sizeof(*module), GFP_KERNEL);
     409        if (!module)
     410                goto error;
     411        module->module_name = kstrdup(fw_name, GFP_KERNEL);
     412        if (!module->module_name)
     413                goto error;
     414
     415        fwlen = 0;
     416        fwdat = (const __le32 *)fw->data;
     417        nums = module->symbol_table.nsymbols = le32_to_cpu(fwdat[fwlen++]);
     418        if (nums >= 40)
     419                goto error_inval;
     420        module->symbol_table.symbols =
     421                kcalloc(nums, sizeof(struct dsp_symbol_entry), GFP_KERNEL);
     422        if (!module->symbol_table.symbols)
     423                goto error;
     424        for (i = 0; i < nums; i++) {
     425                struct dsp_symbol_entry *entry =
     426                        &module->symbol_table.symbols[i];
     427                if (fwlen + 2 + DSP_MAX_SYMBOL_NAME / 4 > fwsize)
     428                        goto error_inval;
     429                entry->address = le32_to_cpu(fwdat[fwlen++]);
     430                memcpy(entry->symbol_name, &fwdat[fwlen], DSP_MAX_SYMBOL_NAME - 1);
     431                fwlen += DSP_MAX_SYMBOL_NAME / 4;
     432                entry->symbol_type = le32_to_cpu(fwdat[fwlen++]);
     433        }
     434
     435        if (fwlen >= fwsize)
     436                goto error_inval;
     437        nums = module->nsegments = le32_to_cpu(fwdat[fwlen++]);
     438        if (nums > 10)
     439                goto error_inval;
     440        module->segments =
     441                kcalloc(nums, sizeof(struct dsp_segment_desc), GFP_KERNEL);
     442        if (!module->segments)
     443                goto error;
     444        for (i = 0; i < nums; i++) {
     445                struct dsp_segment_desc *entry = &module->segments[i];
     446                if (fwlen + 3 > fwsize)
     447                        goto error_inval;
     448                entry->segment_type = le32_to_cpu(fwdat[fwlen++]);
     449                entry->offset = le32_to_cpu(fwdat[fwlen++]);
     450                entry->size = le32_to_cpu(fwdat[fwlen++]);
     451                if (fwlen + entry->size > fwsize)
     452                        goto error_inval;
     453                entry->data = kmalloc_array(entry->size, 4, GFP_KERNEL);
     454                if (!entry->data)
     455                        goto error;
     456                memcpy_le32(entry->data, &fwdat[fwlen], entry->size * 4);
     457                fwlen += entry->size;
     458        }
     459
     460        *module_ret = module;
     461        release_firmware(fw);
     462        return 0;
     463
     464 error_inval:
     465        err = -EINVAL;
     466 error:
     467        free_module_desc(module);
     468        release_firmware(fw);
     469        return err;
     470}
    339471
    340472int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip,
     
    361493#else /* old DSP image */
    362494
    363 #include "cs46xx_image.h"
     495struct ba1_struct {
     496        struct {
     497                u32 offset;
     498                u32 size;
     499        } memory[BA1_MEMORY_COUNT];
     500        u32 map[BA1_DWORD_SIZE];
     501};
     502
     503MODULE_FIRMWARE("cs46xx/ba1");
     504
     505static int load_firmware(struct snd_cs46xx *chip)
     506{
     507        const struct firmware *fw;
     508        int i, size, err;
     509
     510        err = request_firmware(&fw, "cs46xx/ba1", &chip->pci->dev);
     511        if (err < 0)
     512                return err;
     513        if (fw->size != sizeof(*chip->ba1)) {
     514                err = -EINVAL;
     515                goto error;
     516        }
     517
     518        chip->ba1 = vmalloc(sizeof(*chip->ba1));
     519        if (!chip->ba1) {
     520                err = -ENOMEM;
     521                goto error;
     522        }
     523
     524        memcpy_le32(chip->ba1, fw->data, sizeof(*chip->ba1));
     525
     526        /* sanity check */
     527        size = 0;
     528        for (i = 0; i < BA1_MEMORY_COUNT; i++)
     529                size += chip->ba1->memory[i].size;
     530        if (size > BA1_DWORD_SIZE * 4)
     531                err = -EINVAL;
     532
     533 error:
     534        release_firmware(fw);
     535        return err;
     536}
    364537
    365538int snd_cs46xx_download_image(struct snd_cs46xx *chip)
    366539{
    367540        int idx, err;
    368         unsigned long offset = 0;
     541        unsigned int offset = 0;
     542        struct ba1_struct *ba1 = chip->ba1;
    369543
    370544        for (idx = 0; idx < BA1_MEMORY_COUNT; idx++) {
    371                 if ((err = snd_cs46xx_download(chip,
    372                                                &BA1Struct.map[offset],
    373                                                BA1Struct.memory[idx].offset,
    374                                                BA1Struct.memory[idx].size)) < 0)
     545                err = snd_cs46xx_download(chip,
     546                                          &ba1->map[offset],
     547                                          ba1->memory[idx].offset,
     548                                          ba1->memory[idx].size);
     549                if (err < 0)
    375550                        return err;
    376                 offset += BA1Struct.memory[idx].size >> 2;
     551                offset += ba1->memory[idx].size >> 2;
    377552        }       
    378553        return 0;
     
    429604 
    430605        if(status & SERBST_WBSY) {
    431                 snd_printk(KERN_ERR "cs46xx: failure waiting for "
    432                            "FIFO command to complete\n");
     606                dev_err(chip->card->dev,
     607                        "failure waiting for FIFO command to complete\n");
    433608                return -EINVAL;
    434609        }
     
    467642                 */
    468643                if (cs46xx_wait_for_fifo(chip,1)) {
    469                         snd_printdd ("failed waiting for FIFO at addr (%02X)\n",idx);
     644                        dev_dbg(chip->card->dev,
     645                                "failed waiting for FIFO at addr (%02X)\n",
     646                                idx);
    470647
    471648                        if (powerdown)
     
    515692
    516693        if (snd_cs46xx_peek(chip, BA1_SPCR) & SPCR_RUNFR)
    517                 snd_printk(KERN_ERR "SPCR_RUNFR never reset\n");
     694                dev_err(chip->card->dev, "SPCR_RUNFR never reset\n");
    518695}
    519696
     
    594771
    595772        /*
    596          *  We can not capture at at rate greater than the Input Rate (48000).
     773         *  We can not capture at a rate greater than the Input Rate (48000).
    597774         *  Return an error if an attempt is made to stray outside that limit.
    598775         */
     
    701878        struct snd_pcm_runtime *runtime = substream->runtime;
    702879        struct snd_cs46xx_pcm * cpcm = runtime->private_data;
    703         snd_pcm_indirect_playback_transfer(substream, &cpcm->pcm_rec, snd_cs46xx_pb_trans_copy);
    704         return 0;
     880        return snd_pcm_indirect_playback_transfer(substream, &cpcm->pcm_rec,
     881                                                  snd_cs46xx_pb_trans_copy);
    705882}
    706883
     
    717894{
    718895        struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
    719         snd_pcm_indirect_capture_transfer(substream, &chip->capt.pcm_rec, snd_cs46xx_cp_trans_copy);
    720         return 0;
     896        return snd_pcm_indirect_capture_transfer(substream, &chip->capt.pcm_rec,
     897                                                 snd_cs46xx_cp_trans_copy);
    721898}
    722899
     
    8751052                                                                   cpcm, cpcm->hw_buf.addr,cpcm->pcm_channel_id);
    8761053                if (cpcm->pcm_channel == NULL) {
    877                         snd_printk(KERN_ERR "cs46xx: failed to create virtual PCM channel\n");
     1054                        dev_err(chip->card->dev,
     1055                                "failed to create virtual PCM channel\n");
    8781056                        return -ENOMEM;
    8791057                }
     
    8881066                                                                         cpcm->hw_buf.addr,
    8891067                                                                         cpcm->pcm_channel_id)) == NULL) {
    890                         snd_printk(KERN_ERR "cs46xx: failed to re-create virtual PCM channel\n");
     1068                        dev_err(chip->card->dev,
     1069                                "failed to re-create virtual PCM channel\n");
    8911070                        return -ENOMEM;
    8921071                }
     
    9371116         }
    9381117
    939         snd_printdd ("period_size (%d), periods (%d) buffer_size(%d)\n",
     1118        dev_dbg(chip->card->dev,
     1119                "period_size (%d), periods (%d) buffer_size(%d)\n",
    9401120                     period_size, params_periods(hw_params),
    9411121                     params_buffer_bytes(hw_params));
     
    12491429}
    12501430
    1251 static struct snd_pcm_hardware snd_cs46xx_playback =
     1431static const struct snd_pcm_hardware snd_cs46xx_playback =
    12521432{
    12531433        .info =                 (SNDRV_PCM_INFO_MMAP |
    12541434                                 SNDRV_PCM_INFO_INTERLEAVED |
    12551435                                 SNDRV_PCM_INFO_BLOCK_TRANSFER /*|*/
    1256                                  /*SNDRV_PCM_INFO_RESUME*/),
     1436                                 /*SNDRV_PCM_INFO_RESUME*/ |
     1437                                 SNDRV_PCM_INFO_SYNC_APPLPTR),
    12571438        .formats =              (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
    12581439                                 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
     
    12711452};
    12721453
    1273 static struct snd_pcm_hardware snd_cs46xx_capture =
     1454static const struct snd_pcm_hardware snd_cs46xx_capture =
    12741455{
    12751456        .info =                 (SNDRV_PCM_INFO_MMAP |
    12761457                                 SNDRV_PCM_INFO_INTERLEAVED |
    12771458                                 SNDRV_PCM_INFO_BLOCK_TRANSFER /*|*/
    1278                                  /*SNDRV_PCM_INFO_RESUME*/),
     1459                                 /*SNDRV_PCM_INFO_RESUME*/ |
     1460                                 SNDRV_PCM_INFO_SYNC_APPLPTR),
    12791461        .formats =              SNDRV_PCM_FMTBIT_S16_LE,
    12801462        .rates =                SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
     
    12931475#ifdef CONFIG_SND_CS46XX_NEW_DSP
    12941476
    1295 static unsigned int period_sizes[] = { 32, 64, 128, 256, 512, 1024, 2048 };
    1296 
    1297 static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes = {
     1477static const unsigned int period_sizes[] = { 32, 64, 128, 256, 512, 1024, 2048 };
     1478
     1479static const struct snd_pcm_hw_constraint_list hw_constraints_period_sizes = {
    12981480        .count = ARRAY_SIZE(period_sizes),
    12991481        .list = period_sizes,
     
    13171499        if (cpcm == NULL)
    13181500                return -ENOMEM;
    1319         if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
     1501        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
    13201502                                PAGE_SIZE, &cpcm->hw_buf) < 0) {
    13211503                kfree(cpcm);
     
    13521534static int snd_cs46xx_playback_open(struct snd_pcm_substream *substream)
    13531535{
    1354         snd_printdd("open front channel\n");
     1536        dev_dbg(substream->pcm->card->dev, "open front channel\n");
    13551537        return _cs46xx_playback_open_channel(substream,DSP_PCM_MAIN_CHANNEL);
    13561538}
     
    13591541static int snd_cs46xx_playback_open_rear(struct snd_pcm_substream *substream)
    13601542{
    1361         snd_printdd("open rear channel\n");
    1362 
     1543        dev_dbg(substream->pcm->card->dev, "open rear channel\n");
    13631544        return _cs46xx_playback_open_channel(substream,DSP_PCM_REAR_CHANNEL);
    13641545}
     
    13661547static int snd_cs46xx_playback_open_clfe(struct snd_pcm_substream *substream)
    13671548{
    1368         snd_printdd("open center - LFE channel\n");
    1369 
     1549        dev_dbg(substream->pcm->card->dev, "open center - LFE channel\n");
    13701550        return _cs46xx_playback_open_channel(substream,DSP_PCM_CENTER_LFE_CHANNEL);
    13711551}
     
    13751555        struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
    13761556
    1377         snd_printdd("open raw iec958 channel\n");
     1557        dev_dbg(chip->card->dev, "open raw iec958 channel\n");
    13781558
    13791559        mutex_lock(&chip->spos_mutex);
     
    13911571        struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
    13921572 
    1393         snd_printdd("close raw iec958 channel\n");
     1573        dev_dbg(chip->card->dev, "close raw iec958 channel\n");
    13941574
    13951575        err = snd_cs46xx_playback_close(substream);
     
    14071587        struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
    14081588
    1409         if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
     1589        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
    14101590                                PAGE_SIZE, &chip->capt.hw_buf) < 0)
    14111591                return -ENOMEM;
     
    14671647
    14681648#ifdef CONFIG_SND_CS46XX_NEW_DSP
    1469 static struct snd_pcm_ops snd_cs46xx_playback_rear_ops = {
     1649static const struct snd_pcm_ops snd_cs46xx_playback_rear_ops = {
    14701650        .open =                 snd_cs46xx_playback_open_rear,
    14711651        .close =                snd_cs46xx_playback_close,
    1472         .ioctl =                snd_pcm_lib_ioctl,
    14731652        .hw_params =            snd_cs46xx_playback_hw_params,
    14741653        .hw_free =              snd_cs46xx_playback_hw_free,
     
    14781657};
    14791658
    1480 static struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops = {
     1659static const struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops = {
    14811660        .open =                 snd_cs46xx_playback_open_rear,
    14821661        .close =                snd_cs46xx_playback_close,
    1483         .ioctl =                snd_pcm_lib_ioctl,
    14841662        .hw_params =            snd_cs46xx_playback_hw_params,
    14851663        .hw_free =              snd_cs46xx_playback_hw_free,
     
    14901668};
    14911669
    1492 static struct snd_pcm_ops snd_cs46xx_playback_clfe_ops = {
     1670static const struct snd_pcm_ops snd_cs46xx_playback_clfe_ops = {
    14931671        .open =                 snd_cs46xx_playback_open_clfe,
    14941672        .close =                snd_cs46xx_playback_close,
    1495         .ioctl =                snd_pcm_lib_ioctl,
    14961673        .hw_params =            snd_cs46xx_playback_hw_params,
    14971674        .hw_free =              snd_cs46xx_playback_hw_free,
     
    15011678};
    15021679
    1503 static struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops = {
     1680static const struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops = {
    15041681        .open =                 snd_cs46xx_playback_open_clfe,
    15051682        .close =                snd_cs46xx_playback_close,
    1506         .ioctl =                snd_pcm_lib_ioctl,
    15071683        .hw_params =            snd_cs46xx_playback_hw_params,
    15081684        .hw_free =              snd_cs46xx_playback_hw_free,
     
    15131689};
    15141690
    1515 static struct snd_pcm_ops snd_cs46xx_playback_iec958_ops = {
     1691static const struct snd_pcm_ops snd_cs46xx_playback_iec958_ops = {
    15161692        .open =                 snd_cs46xx_playback_open_iec958,
    15171693        .close =                snd_cs46xx_playback_close_iec958,
    1518         .ioctl =                snd_pcm_lib_ioctl,
    15191694        .hw_params =            snd_cs46xx_playback_hw_params,
    15201695        .hw_free =              snd_cs46xx_playback_hw_free,
     
    15241699};
    15251700
    1526 static struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops = {
     1701static const struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops = {
    15271702        .open =                 snd_cs46xx_playback_open_iec958,
    15281703        .close =                snd_cs46xx_playback_close_iec958,
    1529         .ioctl =                snd_pcm_lib_ioctl,
    15301704        .hw_params =            snd_cs46xx_playback_hw_params,
    15311705        .hw_free =              snd_cs46xx_playback_hw_free,
     
    15381712#endif
    15391713
    1540 static struct snd_pcm_ops snd_cs46xx_playback_ops = {
     1714static const struct snd_pcm_ops snd_cs46xx_playback_ops = {
    15411715        .open =                 snd_cs46xx_playback_open,
    15421716        .close =                snd_cs46xx_playback_close,
    1543         .ioctl =                snd_pcm_lib_ioctl,
    15441717        .hw_params =            snd_cs46xx_playback_hw_params,
    15451718        .hw_free =              snd_cs46xx_playback_hw_free,
     
    15491722};
    15501723
    1551 static struct snd_pcm_ops snd_cs46xx_playback_indirect_ops = {
     1724static const struct snd_pcm_ops snd_cs46xx_playback_indirect_ops = {
    15521725        .open =                 snd_cs46xx_playback_open,
    15531726        .close =                snd_cs46xx_playback_close,
    1554         .ioctl =                snd_pcm_lib_ioctl,
    15551727        .hw_params =            snd_cs46xx_playback_hw_params,
    15561728        .hw_free =              snd_cs46xx_playback_hw_free,
     
    15611733};
    15621734
    1563 static struct snd_pcm_ops snd_cs46xx_capture_ops = {
     1735static const struct snd_pcm_ops snd_cs46xx_capture_ops = {
    15641736        .open =                 snd_cs46xx_capture_open,
    15651737        .close =                snd_cs46xx_capture_close,
    1566         .ioctl =                snd_pcm_lib_ioctl,
    15671738        .hw_params =            snd_cs46xx_capture_hw_params,
    15681739        .hw_free =              snd_cs46xx_capture_hw_free,
     
    15721743};
    15731744
    1574 static struct snd_pcm_ops snd_cs46xx_capture_indirect_ops = {
     1745static const struct snd_pcm_ops snd_cs46xx_capture_indirect_ops = {
    15751746        .open =                 snd_cs46xx_capture_open,
    15761747        .close =                snd_cs46xx_capture_close,
    1577         .ioctl =                snd_pcm_lib_ioctl,
    15781748        .hw_params =            snd_cs46xx_capture_hw_params,
    15791749        .hw_free =              snd_cs46xx_capture_hw_free,
     
    15901760#endif
    15911761
    1592 int __devinit snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm)
     1762int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device)
    15931763{
    15941764        struct snd_pcm *pcm;
    15951765        int err;
    15961766
    1597         if (rpcm)
    1598                 *rpcm = NULL;
    15991767        if ((err = snd_pcm_new(chip->card, "CS46xx", device, MAX_PLAYBACK_CHANNELS, 1, &pcm)) < 0)
    16001768                return err;
     
    16111779
    16121780        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1613                                               snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
    1614 
    1615         if (rpcm)
    1616                 *rpcm = pcm;
    1617 
    1618         return 0;
    1619 }
    1620 
    1621 
    1622 #ifdef CONFIG_SND_CS46XX_NEW_DSP
    1623 int __devinit snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm)
     1781                                              &chip->pci->dev,
     1782                                              64*1024, 256*1024);
     1783
     1784        return 0;
     1785}
     1786
     1787
     1788#ifdef CONFIG_SND_CS46XX_NEW_DSP
     1789int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device)
    16241790{
    16251791        struct snd_pcm *pcm;
    16261792        int err;
    1627 
    1628         if (rpcm)
    1629                 *rpcm = NULL;
    16301793
    16311794        if ((err = snd_pcm_new(chip->card, "CS46xx - Rear", device, MAX_PLAYBACK_CHANNELS, 0, &pcm)) < 0)
     
    16421805
    16431806        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1644                                               snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
    1645 
    1646         if (rpcm)
    1647                 *rpcm = pcm;
    1648 
    1649         return 0;
    1650 }
    1651 
    1652 int __devinit snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm)
     1807                                              &chip->pci->dev,
     1808                                              64*1024, 256*1024);
     1809
     1810        return 0;
     1811}
     1812
     1813int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device)
    16531814{
    16541815        struct snd_pcm *pcm;
    16551816        int err;
    1656 
    1657         if (rpcm)
    1658                 *rpcm = NULL;
    16591817
    16601818        if ((err = snd_pcm_new(chip->card, "CS46xx - Center LFE", device, MAX_PLAYBACK_CHANNELS, 0, &pcm)) < 0)
     
    16711829
    16721830        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1673                                               snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
    1674 
    1675         if (rpcm)
    1676                 *rpcm = pcm;
    1677 
    1678         return 0;
    1679 }
    1680 
    1681 int __devinit snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm)
     1831                                              &chip->pci->dev,
     1832                                              64*1024, 256*1024);
     1833
     1834        return 0;
     1835}
     1836
     1837int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device)
    16821838{
    16831839        struct snd_pcm *pcm;
    16841840        int err;
    1685 
    1686         if (rpcm)
    1687                 *rpcm = NULL;
    16881841
    16891842        if ((err = snd_pcm_new(chip->card, "CS46xx - IEC958", device, 1, 0, &pcm)) < 0)
     
    16971850        pcm->info_flags = 0;
    16981851        strcpy(pcm->name, "CS46xx - IEC958");
    1699         chip->pcm_rear = pcm;
     1852        chip->pcm_iec958 = pcm;
    17001853
    17011854        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1702                                               snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
    1703 
    1704         if (rpcm)
    1705                 *rpcm = pcm;
     1855                                              &chip->pci->dev,
     1856                                              64*1024, 256*1024);
    17061857
    17071858        return 0;
     
    20922243
    20932244
    2094 static struct snd_kcontrol_new snd_cs46xx_controls[] __devinitdata = {
     2245static const struct snd_kcontrol_new snd_cs46xx_controls[] = {
    20952246{
    20962247        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    22072358}
    22082359
    2209 static struct snd_kcontrol_new snd_cs46xx_front_dup_ctl = {
     2360static const struct snd_kcontrol_new snd_cs46xx_front_dup_ctl = {
    22102361        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    22112362        .name = "Duplicate Front",
     
    22182369#ifdef CONFIG_SND_CS46XX_NEW_DSP
    22192370/* Only available on the Hercules Game Theater XP soundcard */
    2220 static struct snd_kcontrol_new snd_hercules_controls[] = {
     2371static const struct snd_kcontrol_new snd_hercules_controls[] = {
    22212372{
    22222373        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    22392390        /* set the desired CODEC mode */
    22402391        if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) {
    2241                 snd_printdd("cs46xx: CODEC1 mode %04x\n", 0x0);
     2392                dev_dbg(ac97->bus->card->dev, "CODEC1 mode %04x\n", 0x0);
    22422393                snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x0);
    22432394        } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) {
    2244                 snd_printdd("cs46xx: CODEC2 mode %04x\n", 0x3);
     2395                dev_dbg(ac97->bus->card->dev, "CODEC2 mode %04x\n", 0x3);
    22452396                snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x3);
    22462397        } else {
     
    22742425        } while (time_after_eq(end_time, jiffies));
    22752426
    2276         snd_printk(KERN_ERR "CS46xx secondary codec doesn't respond!\n"); 
    2277 }
    2278 #endif
    2279 
    2280 static int __devinit cs46xx_detect_codec(struct snd_cs46xx *chip, int codec)
     2427        dev_err(ac97->bus->card->dev,
     2428                "CS46xx secondary codec doesn't respond!\n");
     2429}
     2430#endif
     2431
     2432static int cs46xx_detect_codec(struct snd_cs46xx *chip, int codec)
    22812433{
    22822434        int idx, err;
     
    22942446                udelay(10);
    22952447                if (snd_cs46xx_codec_read(chip, AC97_RESET, codec) & 0x8000) {
    2296                         snd_printdd("snd_cs46xx: seconadry codec not present\n");
     2448                        dev_dbg(chip->card->dev,
     2449                                "secondary codec not present\n");
    22972450                        return -ENXIO;
    22982451                }
     
    23072460                msleep(10);
    23082461        }
    2309         snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec);
     2462        dev_dbg(chip->card->dev, "codec %d detection timeout\n", codec);
    23102463        return -ENXIO;
    23112464}
    23122465
    2313 int __devinit snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device)
     2466int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device)
    23142467{
    23152468        struct snd_card *card = chip->card;
     
    23172470        int err;
    23182471        unsigned int idx;
    2319         static struct snd_ac97_bus_ops ops = {
     2472        static const struct snd_ac97_bus_ops ops = {
    23202473#ifdef CONFIG_SND_CS46XX_NEW_DSP
    23212474                .reset = snd_cs46xx_codec_reset,
     
    23272480        /* detect primary codec */
    23282481        chip->nr_ac97_codecs = 0;
    2329         snd_printdd("snd_cs46xx: detecting primary codec\n");
     2482        dev_dbg(chip->card->dev, "detecting primary codec\n");
    23302483        if ((err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus)) < 0)
    23312484                return err;
     
    23372490
    23382491#ifdef CONFIG_SND_CS46XX_NEW_DSP
    2339         snd_printdd("snd_cs46xx: detecting seconadry codec\n");
     2492        dev_dbg(chip->card->dev, "detecting secondary codec\n");
    23402493        /* try detect a secondary codec */
    23412494        if (! cs46xx_detect_codec(chip, CS46XX_SECONDARY_CODEC_INDEX))
     
    23622515        if (chip->nr_ac97_codecs == 1) {
    23632516                unsigned int id2 = chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]->id & 0xffff;
    2364                 if (id2 == 0x592b || id2 == 0x592d) {
     2517                if ((id2 & 0xfff0) == 0x5920) { /* CS4294 and CS4298 */
    23652518                        err = snd_ctl_add(card, snd_ctl_new1(&snd_cs46xx_front_dup_ctl, chip));
    23662519                        if (err < 0)
     
    23722525        /* do soundcard specific mixer setup */
    23732526        if (chip->mixer_init) {
    2374                 snd_printdd ("calling chip->mixer_init(chip);\n");
     2527                dev_dbg(chip->card->dev, "calling chip->mixer_init(chip);\n");
    23752528                chip->mixer_init(chip);
    23762529        }
     
    25172670}
    25182671
    2519 static struct snd_rawmidi_ops snd_cs46xx_midi_output =
     2672static const struct snd_rawmidi_ops snd_cs46xx_midi_output =
    25202673{
    25212674        .open =         snd_cs46xx_midi_output_open,
     
    25242677};
    25252678
    2526 static struct snd_rawmidi_ops snd_cs46xx_midi_input =
     2679static const struct snd_rawmidi_ops snd_cs46xx_midi_input =
    25272680{
    25282681        .open =         snd_cs46xx_midi_input_open,
     
    25312684};
    25322685
    2533 int __devinit snd_cs46xx_midi(struct snd_cs46xx *chip, int device, struct snd_rawmidi **rrawmidi)
     2686int snd_cs46xx_midi(struct snd_cs46xx *chip, int device)
    25342687{
    25352688        struct snd_rawmidi *rmidi;
    25362689        int err;
    25372690
    2538         if (rrawmidi)
    2539                 *rrawmidi = NULL;
    25402691        if ((err = snd_rawmidi_new(chip->card, "CS46XX", device, 1, 1, &rmidi)) < 0)
    25412692                return err;
     
    25462697        rmidi->private_data = chip;
    25472698        chip->rmidi = rmidi;
    2548         if (rrawmidi)
    2549                 *rrawmidi = NULL;
    25502699        return 0;
    25512700}
     
    25562705 */
    25572706
    2558 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
     2707#if IS_REACHABLE(CONFIG_GAMEPORT)
    25592708
    25602709static void snd_cs46xx_gameport_trigger(struct gameport *gameport)
     
    26132762}
    26142763
    2615 int __devinit snd_cs46xx_gameport(struct snd_cs46xx *chip)
     2764int snd_cs46xx_gameport(struct snd_cs46xx *chip)
    26162765{
    26172766        struct gameport *gp;
     
    26192768        chip->gameport = gp = gameport_allocate_port();
    26202769        if (!gp) {
    2621                 printk(KERN_ERR "cs46xx: cannot allocate memory for gameport\n");
     2770                dev_err(chip->card->dev,
     2771                        "cannot allocate memory for gameport\n");
    26222772                return -ENOMEM;
    26232773        }
     
    26492799}
    26502800#else
    2651 int __devinit snd_cs46xx_gameport(struct snd_cs46xx *chip) { return -ENOSYS; }
     2801int snd_cs46xx_gameport(struct snd_cs46xx *chip) { return -ENOSYS; }
    26522802static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) { }
    26532803#endif /* CONFIG_GAMEPORT */
    26542804
    2655 #ifdef CONFIG_PROC_FS
     2805#ifdef CONFIG_SND_PROC_FS
    26562806/*
    26572807 *  proc interface
     
    26702820}
    26712821
    2672 static struct snd_info_entry_ops snd_cs46xx_proc_io_ops = {
     2822static const struct snd_info_entry_ops snd_cs46xx_proc_io_ops = {
    26732823        .read = snd_cs46xx_io_read,
    26742824};
    26752825
    2676 static int __devinit snd_cs46xx_proc_init(struct snd_card *card, struct snd_cs46xx *chip)
     2826static int snd_cs46xx_proc_init(struct snd_card *card, struct snd_cs46xx *chip)
    26772827{
    26782828        struct snd_info_entry *entry;
     
    26862836                        entry->c.ops = &snd_cs46xx_proc_io_ops;
    26872837                        entry->size = region->size;
    2688                         entry->mode = S_IFREG | S_IRUSR;
     2838                        entry->mode = S_IFREG | 0400;
    26892839                }
    26902840        }
     
    27022852        return 0;
    27032853}
    2704 #else /* !CONFIG_PROC_FS */
     2854#else /* !CONFIG_SND_PROC_FS */
    27052855#define snd_cs46xx_proc_init(card, chip)
    27062856#define snd_cs46xx_proc_done(chip)
     
    27852935        for (idx = 0; idx < 5; idx++) {
    27862936                struct snd_cs46xx_region *region = &chip->region.idx[idx];
    2787                 if (region->remap_addr)
    2788                         iounmap(region->remap_addr);
     2937
     2938                iounmap(region->remap_addr);
    27892939                release_and_free_resource(region->resource);
    27902940        }
     
    27952945                chip->dsp_spos_instance = NULL;
    27962946        }
     2947        for (idx = 0; idx < CS46XX_DSP_MODULES; idx++)
     2948                free_module_desc(chip->modules[idx]);
     2949#else
     2950        vfree(chip->ba1);
    27972951#endif
    27982952       
    2799 #ifdef CONFIG_PM
     2953#ifdef CONFIG_PM_SLEEP
    28002954        kfree(chip->saved_regs);
    28012955#endif
     
    29523106
    29533107
    2954         snd_printk(KERN_ERR "create - never read codec ready from AC'97\n");
    2955         snd_printk(KERN_ERR "it is not probably bug, try to use CS4236 driver\n");
     3108        dev_err(chip->card->dev,
     3109                "create - never read codec ready from AC'97\n");
     3110        dev_err(chip->card->dev,
     3111                "it is not probably bug, try to use CS4236 driver\n");
    29563112        return -EIO;
    29573113 ok1:
     
    29713127                 */
    29723128                if (!(snd_cs46xx_peekBA0(chip, BA0_ACSTS2) & ACSTS_CRDY))
    2973                         snd_printdd("cs46xx: never read card ready from secondary AC'97\n");
     3129                        dev_dbg(chip->card->dev,
     3130                                "never read card ready from secondary AC'97\n");
    29743131        }
    29753132#endif
     
    30013158
    30023159#ifndef CONFIG_SND_CS46XX_NEW_DSP
    3003         snd_printk(KERN_ERR "create - never read ISV3 & ISV4 from AC'97\n");
     3160        dev_err(chip->card->dev,
     3161                "create - never read ISV3 & ISV4 from AC'97\n");
    30043162        return -EIO;
    30053163#else
     
    30083166           with the same problem I would like to know. (Benny) */
    30093167
    3010         snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n");
    3011         snd_printk(KERN_ERR "       Try reloading the ALSA driver, if you find something\n");
    3012         snd_printk(KERN_ERR "       broken or not working on your soundcard upon\n");
    3013         snd_printk(KERN_ERR "       this message please report to alsa-devel@alsa-project.org\n");
     3168        dev_err(chip->card->dev, "never read ISV3 & ISV4 from AC'97\n");
     3169        dev_err(chip->card->dev,
     3170                "Try reloading the ALSA driver, if you find something\n");
     3171        dev_err(chip->card->dev,
     3172                "broken or not working on your soundcard upon\n");
     3173        dev_err(chip->card->dev,
     3174                "this message please report to alsa-devel@alsa-project.org\n");
    30143175
    30153176        return -EIO;
     
    30613222}
    30623223
    3063 int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
     3224int snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
    30643225{       
    30653226        unsigned int tmp;
     3227#ifdef CONFIG_SND_CS46XX_NEW_DSP
     3228        int i;
     3229#endif
     3230        int err;
     3231
    30663232        /*
    30673233         *  Reset the processor.
     
    30723238         */
    30733239#ifdef CONFIG_SND_CS46XX_NEW_DSP
    3074 #if 0
    3075         if (cs46xx_dsp_load_module(chip, &cwcemb80_module) < 0) {
    3076                 snd_printk(KERN_ERR "image download error\n");
    3077                 return -EIO;
    3078         }
    3079 #endif
    3080 
    3081         if (cs46xx_dsp_load_module(chip, &cwc4630_module) < 0) {
    3082                 snd_printk(KERN_ERR "image download error [cwc4630]\n");
    3083                 return -EIO;
    3084         }
    3085 
    3086         if (cs46xx_dsp_load_module(chip, &cwcasync_module) < 0) {
    3087                 snd_printk(KERN_ERR "image download error [cwcasync]\n");
    3088                 return -EIO;
    3089         }
    3090 
    3091         if (cs46xx_dsp_load_module(chip, &cwcsnoop_module) < 0) {
    3092                 snd_printk(KERN_ERR "image download error [cwcsnoop]\n");
    3093                 return -EIO;
    3094         }
    3095 
    3096         if (cs46xx_dsp_load_module(chip, &cwcbinhack_module) < 0) {
    3097                 snd_printk(KERN_ERR "image download error [cwcbinhack]\n");
    3098                 return -EIO;
    3099         }
    3100 
    3101         if (cs46xx_dsp_load_module(chip, &cwcdma_module) < 0) {
    3102                 snd_printk(KERN_ERR "image download error [cwcdma]\n");
    3103                 return -EIO;
     3240        for (i = 0; i < CS46XX_DSP_MODULES; i++) {
     3241                err = load_firmware(chip, &chip->modules[i], module_names[i]);
     3242                if (err < 0) {
     3243                        dev_err(chip->card->dev, "firmware load error [%s]\n",
     3244                                   module_names[i]);
     3245                        return err;
     3246                }
     3247                err = cs46xx_dsp_load_module(chip, chip->modules[i]);
     3248                if (err < 0) {
     3249                        dev_err(chip->card->dev, "image download error [%s]\n",
     3250                                   module_names[i]);
     3251                        return err;
     3252                }
    31043253        }
    31053254
     
    31073256                return -EIO;
    31083257#else
     3258        err = load_firmware(chip);
     3259        if (err < 0)
     3260                return err;
     3261
    31093262        /* old image */
    3110         if (snd_cs46xx_download_image(chip) < 0) {
    3111                 snd_printk(KERN_ERR "image download error\n");
    3112                 return -EIO;
     3263        err = snd_cs46xx_download_image(chip);
     3264        if (err < 0) {
     3265                dev_err(chip->card->dev, "image download error\n");
     3266                return err;
    31133267        }
    31143268
     
    31623316        u16 modem_power,pin_config,logic_type;
    31633317
    3164         snd_printdd ("cs46xx: cs46xx_setup_eapd_slot()+\n");
     3318        dev_dbg(chip->card->dev, "cs46xx_setup_eapd_slot()+\n");
    31653319
    31663320        /*
     
    31803334         */
    31813335        if(chip->nr_ac97_codecs != 2) {
    3182                 snd_printk (KERN_ERR "cs46xx: cs46xx_setup_eapd_slot() - no secondary codec configured\n");
     3336                dev_err(chip->card->dev,
     3337                        "cs46xx_setup_eapd_slot() - no secondary codec configured\n");
    31833338                return -EINVAL;
    31843339        }
     
    32213376
    32223377        if ( cs46xx_wait_for_fifo(chip,1) ) {
    3223           snd_printdd("FIFO is busy\n");
     3378                dev_dbg(chip->card->dev, "FIFO is busy\n");
    32243379         
    32253380          return -EINVAL;
     
    32423397                 */
    32433398                if ( cs46xx_wait_for_fifo(chip,200) ) {
    3244                         snd_printdd("failed waiting for FIFO at addr (%02X)\n",idx);
     3399                        dev_dbg(chip->card->dev,
     3400                                "failed waiting for FIFO at addr (%02X)\n",
     3401                                idx);
    32453402
    32463403                        return -EINVAL;
     
    33313488        chip->amplifier += change;
    33323489        if (chip->amplifier && !old) {
    3333                 snd_printdd ("Hercules amplifier ON\n");
     3490                dev_dbg(chip->card->dev, "Hercules amplifier ON\n");
    33343491
    33353492                snd_cs46xx_pokeBA0(chip, BA0_EGPIODR,
     
    33383495                                   EGPIOPTR_GPPT2 | val2);   /* open-drain on output */
    33393496        } else if (old && !chip->amplifier) {
    3340                 snd_printdd ("Hercules amplifier OFF\n");
     3497                dev_dbg(chip->card->dev, "Hercules amplifier OFF\n");
    33413498                snd_cs46xx_pokeBA0(chip, BA0_EGPIODR,  val1 & ~EGPIODR_GPOE2); /* disable */
    33423499                snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, val2 & ~EGPIOPTR_GPPT2); /* disable */
     
    33463503static void voyetra_mixer_init (struct snd_cs46xx *chip)
    33473504{
    3348         snd_printdd ("initializing Voyetra mixer\n");
     3505        dev_dbg(chip->card->dev, "initializing Voyetra mixer\n");
    33493506
    33503507        /* Enable SPDIF out */
     
    33643521        hercules_init(chip);
    33653522
    3366         snd_printdd ("initializing Hercules mixer\n");
     3523        dev_dbg(chip->card->dev, "initializing Hercules mixer\n");
    33673524
    33683525#ifdef CONFIG_SND_CS46XX_NEW_DSP
     
    33753532                kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip);
    33763533                if ((err = snd_ctl_add(card, kctl)) < 0) {
    3377                         printk (KERN_ERR "cs46xx: failed to initialize Hercules mixer (%d)\n",err);
     3534                        dev_err(card->dev,
     3535                                "failed to initialize Hercules mixer (%d)\n",
     3536                                err);
    33783537                        break;
    33793538                }
     
    34773636};
    34783637
    3479 static struct cs_card_type __devinitdata cards[] = {
     3638static struct cs_card_type cards[] = {
    34803639        {
    34813640                .vendor = 0x1489,
     
    35903749 * APM support
    35913750 */
    3592 #ifdef CONFIG_PM
    3593 static unsigned int saved_regs[] = {
     3751#ifdef CONFIG_PM_SLEEP
     3752static const unsigned int saved_regs[] = {
    35943753        BA0_ACOSV,
    35953754        /*BA0_ASER_FADDR,*/
     
    35993758};
    36003759
    3601 int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
    3602 {
    3603         struct snd_card *card = pci_get_drvdata(pci);
     3760static int snd_cs46xx_suspend(struct device *dev)
     3761{
     3762        struct snd_card *card = dev_get_drvdata(dev);
    36043763        struct snd_cs46xx *chip = card->private_data;
    36053764        int i, amp_saved;
     
    36073766        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    36083767        chip->in_suspend = 1;
    3609         snd_pcm_suspend_all(chip->pcm);
    36103768        // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL);
    36113769        // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE);
     
    36253783        chip->active_ctrl(chip, -chip->amplifier);
    36263784        chip->amplifier = amp_saved; /* restore the status */
    3627 
    3628         pci_disable_device(pci);
    3629         pci_save_state(pci);
    3630         pci_set_power_state(pci, pci_choose_state(pci, state));
    3631         return 0;
    3632 }
    3633 
    3634 int snd_cs46xx_resume(struct pci_dev *pci)
    3635 {
    3636         struct snd_card *card = pci_get_drvdata(pci);
     3785        return 0;
     3786}
     3787
     3788static int snd_cs46xx_resume(struct device *dev)
     3789{
     3790        struct snd_card *card = dev_get_drvdata(dev);
    36373791        struct snd_cs46xx *chip = card->private_data;
    36383792        int amp_saved;
     
    36413795#endif
    36423796        unsigned int tmp;
    3643 
    3644         pci_set_power_state(pci, PCI_D0);
    3645         pci_restore_state(pci);
    3646         if (pci_enable_device(pci) < 0) {
    3647                 printk(KERN_ERR "cs46xx: pci_enable_device failed, "
    3648                        "disabling device\n");
    3649                 snd_card_disconnect(card);
    3650                 return -EIO;
    3651         }
    3652         pci_set_master(pci);
    36533797
    36543798        amp_saved = chip->amplifier;
     
    37073851        return 0;
    37083852}
    3709 #endif /* CONFIG_PM */
     3853
     3854SIMPLE_DEV_PM_OPS(snd_cs46xx_pm, snd_cs46xx_suspend, snd_cs46xx_resume);
     3855#endif /* CONFIG_PM_SLEEP */
    37103856
    37113857
     
    37133859 */
    37143860
    3715 int __devinit snd_cs46xx_create(struct snd_card *card,
    3716                       struct pci_dev * pci,
     3861int snd_cs46xx_create(struct snd_card *card,
     3862                      struct pci_dev *pci,
    37173863                      int external_amp, int thinkpad,
    3718                       struct snd_cs46xx ** rchip)
     3864                      struct snd_cs46xx **rchip)
    37193865{
    37203866        struct snd_cs46xx *chip;
     
    37233869        struct cs_card_type *cp;
    37243870        u16 ss_card, ss_vendor;
    3725         static struct snd_device_ops ops = {
     3871        static const struct snd_device_ops ops = {
    37263872                .dev_free =     snd_cs46xx_dev_free,
    37273873        };
     
    37493895        if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 ||
    37503896            chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) {
    3751                 snd_printk(KERN_ERR "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n",
     3897                dev_err(chip->card->dev,
     3898                        "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n",
    37523899                           chip->ba0_addr, chip->ba1_addr);
    37533900                snd_cs46xx_free(chip);
     
    37863933        for (cp = &cards[0]; cp->name; cp++) {
    37873934                if (cp->vendor == ss_vendor && cp->id == ss_card) {
    3788                         snd_printdd ("hack for %s enabled\n", cp->name);
     3935                        dev_dbg(chip->card->dev, "hack for %s enabled\n",
     3936                                cp->name);
    37893937
    37903938                        chip->amplifier_ctrl = cp->amp;
     
    37993947
    38003948        if (external_amp) {
    3801                 snd_printk(KERN_INFO "Crystal EAPD support forced on.\n");
     3949                dev_info(chip->card->dev,
     3950                         "Crystal EAPD support forced on.\n");
    38023951                chip->amplifier_ctrl = amp_voyetra;
    38033952        }
    38043953
    38053954        if (thinkpad) {
    3806                 snd_printk(KERN_INFO "Activating CLKRUN hack for Thinkpad.\n");
     3955                dev_info(chip->card->dev,
     3956                         "Activating CLKRUN hack for Thinkpad.\n");
    38073957                chip->active_ctrl = clkrun_hack;
    38083958                clkrun_init(chip);
     
    38223972                if ((region->resource = request_mem_region(region->base, region->size,
    38233973                                                           region->name)) == NULL) {
    3824                         snd_printk(KERN_ERR "unable to request memory region 0x%lx-0x%lx\n",
     3974                        dev_err(chip->card->dev,
     3975                                "unable to request memory region 0x%lx-0x%lx\n",
    38253976                                   region->base, region->base + region->size - 1);
    38263977                        snd_cs46xx_free(chip);
    38273978                        return -EBUSY;
    38283979                }
    3829                 region->remap_addr = ioremap_nocache(region->base, region->size);
     3980                region->remap_addr = ioremap(region->base, region->size);
    38303981                if (region->remap_addr == NULL) {
    3831                         snd_printk(KERN_ERR "%s ioremap problem\n", region->name);
     3982                        dev_err(chip->card->dev,
     3983                                "%s ioremap problem\n", region->name);
    38323984                        snd_cs46xx_free(chip);
    38333985                        return -ENOMEM;
     
    38363988
    38373989        if (request_irq(pci->irq, snd_cs46xx_interrupt, IRQF_SHARED,
    3838                         "CS46XX", chip)) {
    3839                 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
     3990                        KBUILD_MODNAME, chip)) {
     3991                dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
    38403992                snd_cs46xx_free(chip);
    38413993                return -EBUSY;
    38423994        }
    38433995        chip->irq = pci->irq;
     3996        card->sync_irq = chip->irq;
    38443997
    38453998#ifdef CONFIG_SND_CS46XX_NEW_DSP
     
    38644017        snd_cs46xx_proc_init(card, chip);
    38654018
    3866 #ifdef CONFIG_PM
    3867         chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) *
    3868                                    ARRAY_SIZE(saved_regs), GFP_KERNEL);
     4019#ifdef CONFIG_PM_SLEEP
     4020        chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs),
     4021                                         sizeof(*chip->saved_regs),
     4022                                         GFP_KERNEL);
    38694023        if (!chip->saved_regs) {
    38704024                snd_cs46xx_free(chip);
     
    38754029        chip->active_ctrl(chip, -1); /* disable CLKRUN */
    38764030
    3877         snd_card_set_dev(card, &pci->dev);
    3878 
    38794031        *rchip = chip;
    38804032        return 0;
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
    34 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    4  *
    5  *
    6  *   This program is free software; you can redistribute it and/or modify
    7  *   it under the terms of the GNU General Public License as published by
    8  *   the Free Software Foundation; either version 2 of the License, or
    9  *   (at your option) any later version.
    10  *
    11  *   This program is distributed in the hope that it will be useful,
    12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  *   GNU General Public License for more details.
    15  *
    16  *   You should have received a copy of the GNU General Public License
    17  *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    19  *
    205 */
    216
     
    9176void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
    9277int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
    93 #ifdef CONFIG_PM
     78#ifdef CONFIG_PM_SLEEP
    9479int cs46xx_dsp_resume(struct snd_cs46xx * chip);
    9580#endif
    9681struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
    9782                                                   int symbol_type);
    98 #ifdef CONFIG_PROC_FS
     83#ifdef CONFIG_SND_PROC_FS
    9984int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
    10085int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
     
    119104struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name,
    120105                                                   u32 * scb_data, u32 dest);
    121 #ifdef CONFIG_PROC_FS
     106#ifdef CONFIG_SND_PROC_FS
    122107void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb);
    123108void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
  • GPL/trunk/alsa-kernel/pci/cs46xx/dsp_spos.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    2  *   This program is free software; you can redistribute it and/or modify
    3  *   it under the terms of the GNU General Public License as published by
    4  *   the Free Software Foundation; either version 2 of the License, or
    5  *   (at your option) any later version.
    6  *
    7  *   This program is distributed in the hope that it will be useful,
    8  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    9  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    10  *   GNU General Public License for more details.
    11  *
    12  *   You should have received a copy of the GNU General Public License
    13  *   along with this program; if not, write to the Free Software
    14  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    15  *
    163 */
    174
     
    218
    229
    23 #include <asm/io.h>
     10#include <linux/io.h>
    2411#include <linux/delay.h>
    2512#include <linux/pm.h>
     
    3320#include <sound/info.h>
    3421#include <sound/asoundef.h>
    35 #include <sound/cs46xx.h>
     22#include "cs46xx.h"
    3623
    3724#include "cs46xx_lib.h"
     
    4128                                  struct dsp_scb_descriptor * fg_entry);
    4229
    43 static enum wide_opcode wide_opcodes[] = {
     30static const enum wide_opcode wide_opcodes[] = {
    4431        WIDE_FOR_BEGIN_LOOP,
    4532        WIDE_FOR_BEGIN_LOOP2,
     
    8673                                                address |=  loval >> 15;
    8774           
    88                                                 snd_printdd("handle_wideop[1]: %05x:%05x addr %04x\n",hival,loval,address);
     75                                                dev_dbg(chip->card->dev,
     76                                                        "handle_wideop[1]: %05x:%05x addr %04x\n",
     77                                                        hival, loval, address);
    8978           
    9079                                                if ( !(address & 0x8000) ) {
    9180                                                        address += (ins->code.offset / 2) - overlay_begin_address;
    9281                                                } else {
    93                                                         snd_printdd("handle_wideop[1]: ROM symbol not reallocated\n");
     82                                                        dev_dbg(chip->card->dev,
     83                                                                "handle_wideop[1]: ROM symbol not reallocated\n");
    9484                                                }
    9585           
     
    10393                                                address |=  loval >> 15;
    10494           
    105                                                 snd_printdd("handle_wideop:[2] %05x:%05x addr %04x\n",hival,loval,address);           
    106                                                 nreallocated ++;
     95                                                dev_dbg(chip->card->dev,
     96                                                        "handle_wideop:[2] %05x:%05x addr %04x\n",
     97                                                        hival, loval, address);
     98                                                nreallocated++;
    10799                                        } /* wide_opcodes[j] == wide_op */
    108100                                } /* for */
     
    114106        }
    115107
    116         snd_printdd("dsp_spos: %d instructions reallocated\n",nreallocated);
     108        dev_dbg(chip->card->dev,
     109                "dsp_spos: %d instructions reallocated\n", nreallocated);
    117110        return nreallocated;
    118111}
     
    158151        for (i = 0;i < module->symbol_table.nsymbols; ++i) {
    159152                if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) {
    160                         snd_printk(KERN_ERR "dsp_spos: symbol table is full\n");
     153                        dev_err(chip->card->dev,
     154                                "dsp_spos: symbol table is full\n");
    161155                        return -ENOMEM;
    162156                }
     
    177171                        ins->symbol_table.nsymbols++;
    178172                } else {
    179           /* if (0) printk ("dsp_spos: symbol <%s> duplicated, probably nothing wrong with that (Cirrus?)\n",
    180                              module->symbol_table.symbols[i].symbol_name); */
     173#if 0
     174                        dev_dbg(chip->card->dev,
     175                                "dsp_spos: symbol <%s> duplicated, probably nothing wrong with that (Cirrus?)\n",
     176                                module->symbol_table.symbols[i].symbol_name); */
     177#endif
    181178                }
    182179        }
     
    193190
    194191        if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) {
    195                 snd_printk(KERN_ERR "dsp_spos: symbol table is full\n");
     192                dev_err(chip->card->dev, "dsp_spos: symbol table is full\n");
    196193                return NULL;
    197194        }
     
    200197                                     symbol_name,
    201198                                     type) != NULL) {
    202                 snd_printk(KERN_ERR "dsp_spos: symbol <%s> duplicated\n", symbol_name);
     199                dev_err(chip->card->dev,
     200                        "dsp_spos: symbol <%s> duplicated\n", symbol_name);
    203201                return NULL;
    204202        }
     
    230228
    231229        /* better to use vmalloc for this big table */
    232         ins->symbol_table.symbols = vmalloc(sizeof(struct dsp_symbol_entry) *
    233                                             DSP_MAX_SYMBOLS);
     230        ins->symbol_table.symbols =
     231                vmalloc(array_size(DSP_MAX_SYMBOLS,
     232                                   sizeof(struct dsp_symbol_entry)));
    234233        ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL);
    235         ins->modules = kmalloc(sizeof(struct dsp_module_desc) * DSP_MAX_MODULES, GFP_KERNEL);
     234        ins->modules = kmalloc_array(DSP_MAX_MODULES,
     235                                     sizeof(struct dsp_module_desc),
     236                                     GFP_KERNEL);
    236237        if (!ins->symbol_table.symbols || !ins->code.data || !ins->modules) {
    237238                cs46xx_dsp_spos_destroy(chip);
     
    288289
    289290                cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) );
    290 #ifdef CONFIG_PM
     291#ifdef CONFIG_PM_SLEEP
    291292                kfree(ins->scbs[i].data);
    292293#endif
     
    306307
    307308        if (!parameter) {
    308                 snd_printdd("dsp_spos: module got no parameter segment\n");
     309                dev_dbg(chip->card->dev,
     310                        "dsp_spos: module got no parameter segment\n");
    309311                return 0;
    310312        }
     
    313315        dsize   = parameter->size * 4;
    314316
    315         snd_printdd("dsp_spos: "
    316                     "downloading parameter data to chip (%08x-%08x)\n",
     317        dev_dbg(chip->card->dev,
     318                "dsp_spos: downloading parameter data to chip (%08x-%08x)\n",
    317319                    doffset,doffset + dsize);
    318320        if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) {
    319                 snd_printk(KERN_ERR "dsp_spos: "
    320                            "failed to download parameter data to DSP\n");
     321                dev_err(chip->card->dev,
     322                        "dsp_spos: failed to download parameter data to DSP\n");
    321323                return -EINVAL;
    322324        }
     
    330332
    331333        if (!sample) {
    332                 snd_printdd("dsp_spos: module got no sample segment\n");
     334                dev_dbg(chip->card->dev,
     335                        "dsp_spos: module got no sample segment\n");
    333336                return 0;
    334337        }
     
    337340        dsize   =  sample->size * 4;
    338341
    339         snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n",
     342        dev_dbg(chip->card->dev,
     343                "dsp_spos: downloading sample data to chip (%08x-%08x)\n",
    340344                    doffset,doffset + dsize);
    341345
    342346        if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) {
    343                 snd_printk(KERN_ERR "dsp_spos: failed to sample data to DSP\n");
     347                dev_err(chip->card->dev,
     348                        "dsp_spos: failed to sample data to DSP\n");
    344349                return -EINVAL;
    345350        }
     
    355360
    356361        if (ins->nmodules == DSP_MAX_MODULES - 1) {
    357                 snd_printk(KERN_ERR "dsp_spos: to many modules loaded into DSP\n");
     362                dev_err(chip->card->dev,
     363                        "dsp_spos: to many modules loaded into DSP\n");
    358364                return -ENOMEM;
    359365        }
    360366
    361         snd_printdd("dsp_spos: loading module %s into DSP\n", module->module_name);
     367        dev_dbg(chip->card->dev,
     368                "dsp_spos: loading module %s into DSP\n", module->module_name);
    362369 
    363370        if (ins->nmodules == 0) {
    364                 snd_printdd("dsp_spos: clearing parameter area\n");
     371                dev_dbg(chip->card->dev, "dsp_spos: clearing parameter area\n");
    365372                snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE);
    366373        }
     
    372379
    373380        if (ins->nmodules == 0) {
    374                 snd_printdd("dsp_spos: clearing sample area\n");
     381                dev_dbg(chip->card->dev, "dsp_spos: clearing sample area\n");
    375382                snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE);
    376383        }
     
    382389
    383390        if (ins->nmodules == 0) {
    384                 snd_printdd("dsp_spos: clearing code area\n");
     391                dev_dbg(chip->card->dev, "dsp_spos: clearing code area\n");
    385392                snd_cs46xx_clear_BA1(chip, DSP_CODE_BYTE_OFFSET, DSP_CODE_BYTE_SIZE);
    386393        }
    387394
    388395        if (code == NULL) {
    389                 snd_printdd("dsp_spos: module got no code segment\n");
     396                dev_dbg(chip->card->dev,
     397                        "dsp_spos: module got no code segment\n");
    390398        } else {
    391399                if (ins->code.offset + code->size > DSP_CODE_BYTE_SIZE) {
    392                         snd_printk(KERN_ERR "dsp_spos: no space available in DSP\n");
     400                        dev_err(chip->card->dev,
     401                                "dsp_spos: no space available in DSP\n");
    393402                        return -ENOMEM;
    394403                }
     
    402411                        return -ENOMEM;
    403412                if (add_symbols(chip,module)) {
    404                         snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n");
     413                        dev_err(chip->card->dev,
     414                                "dsp_spos: failed to load symbol table\n");
    405415                        return -ENOMEM;
    406416                }
     
    408418                doffset = (code->offset * 4 + ins->code.offset * 4 + DSP_CODE_BYTE_OFFSET);
    409419                dsize   = code->size * 4;
    410                 snd_printdd("dsp_spos: downloading code to chip (%08x-%08x)\n",
     420                dev_dbg(chip->card->dev,
     421                        "dsp_spos: downloading code to chip (%08x-%08x)\n",
    411422                            doffset,doffset + dsize);   
    412423
     
    414425
    415426                if (snd_cs46xx_download (chip,(ins->code.data + ins->code.offset),doffset,dsize)) {
    416                         snd_printk(KERN_ERR "dsp_spos: failed to download code to DSP\n");
     427                        dev_err(chip->card->dev,
     428                                "dsp_spos: failed to download code to DSP\n");
    417429                        return -EINVAL;
    418430                }
     
    448460
    449461#if 0
    450         printk ("dsp_spos: symbol <%s> type %02x not found\n",
     462        dev_err(chip->card->dev, "dsp_spos: symbol <%s> type %02x not found\n",
    451463                symbol_name,symbol_type);
    452464#endif
     
    456468
    457469
    458 #ifdef CONFIG_PROC_FS
     470#ifdef CONFIG_SND_PROC_FS
    459471static struct dsp_symbol_entry *
    460472cs46xx_dsp_lookup_symbol_addr (struct snd_cs46xx * chip, u32 address, int symbol_type)
     
    775787        ins->snd_card = card;
    776788
    777         if ((entry = snd_info_create_card_entry(card, "dsp", card->proc_root)) != NULL) {
    778                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    779                 entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
    780      
    781                 if (snd_info_register(entry) < 0) {
    782                         snd_info_free_entry(entry);
    783                         entry = NULL;
    784                 }
    785         }
    786 
     789        entry = snd_info_create_card_entry(card, "dsp", card->proc_root);
     790        if (entry)
     791                entry->mode = S_IFDIR | 0555;
    787792        ins->proc_dsp_dir = entry;
    788793
     
    790795                return -ENOMEM;
    791796
    792         if ((entry = snd_info_create_card_entry(card, "spos_symbols", ins->proc_dsp_dir)) != NULL) {
    793                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    794                 entry->private_data = chip;
    795                 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
    796                 entry->c.text.read = cs46xx_dsp_proc_symbol_table_read;
    797                 if (snd_info_register(entry) < 0) {
    798                         snd_info_free_entry(entry);
    799                         entry = NULL;
    800                 }
    801         }
    802         ins->proc_sym_info_entry = entry;
     797        entry = snd_info_create_card_entry(card, "spos_symbols",
     798                                           ins->proc_dsp_dir);
     799        if (entry)
     800                snd_info_set_text_ops(entry, chip,
     801                                      cs46xx_dsp_proc_symbol_table_read);
    803802   
    804         if ((entry = snd_info_create_card_entry(card, "spos_modules", ins->proc_dsp_dir)) != NULL) {
    805                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    806                 entry->private_data = chip;
    807                 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
    808                 entry->c.text.read = cs46xx_dsp_proc_modules_read;
    809                 if (snd_info_register(entry) < 0) {
    810                         snd_info_free_entry(entry);
    811                         entry = NULL;
    812                 }
    813         }
    814         ins->proc_modules_info_entry = entry;
    815 
    816         if ((entry = snd_info_create_card_entry(card, "parameter", ins->proc_dsp_dir)) != NULL) {
    817                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    818                 entry->private_data = chip;
    819                 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
    820                 entry->c.text.read = cs46xx_dsp_proc_parameter_dump_read;
    821                 if (snd_info_register(entry) < 0) {
    822                         snd_info_free_entry(entry);
    823                         entry = NULL;
    824                 }
    825         }
    826         ins->proc_parameter_dump_info_entry = entry;
    827 
    828         if ((entry = snd_info_create_card_entry(card, "sample", ins->proc_dsp_dir)) != NULL) {
    829                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    830                 entry->private_data = chip;
    831                 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
    832                 entry->c.text.read = cs46xx_dsp_proc_sample_dump_read;
    833                 if (snd_info_register(entry) < 0) {
    834                         snd_info_free_entry(entry);
    835                         entry = NULL;
    836                 }
    837         }
    838         ins->proc_sample_dump_info_entry = entry;
    839 
    840         if ((entry = snd_info_create_card_entry(card, "task_tree", ins->proc_dsp_dir)) != NULL) {
    841                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    842                 entry->private_data = chip;
    843                 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
    844                 entry->c.text.read = cs46xx_dsp_proc_task_tree_read;
    845                 if (snd_info_register(entry) < 0) {
    846                         snd_info_free_entry(entry);
    847                         entry = NULL;
    848                 }
    849         }
    850         ins->proc_task_info_entry = entry;
    851 
    852         if ((entry = snd_info_create_card_entry(card, "scb_info", ins->proc_dsp_dir)) != NULL) {
    853                 entry->content = SNDRV_INFO_CONTENT_TEXT;
    854                 entry->private_data = chip;
    855                 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
    856                 entry->c.text.read = cs46xx_dsp_proc_scb_read;
    857                 if (snd_info_register(entry) < 0) {
    858                         snd_info_free_entry(entry);
    859                         entry = NULL;
    860                 }
    861         }
    862         ins->proc_scb_info_entry = entry;
     803        entry = snd_info_create_card_entry(card, "spos_modules",
     804                                           ins->proc_dsp_dir);
     805        if (entry)
     806                snd_info_set_text_ops(entry, chip,
     807                                      cs46xx_dsp_proc_modules_read);
     808
     809        entry = snd_info_create_card_entry(card, "parameter",
     810                                           ins->proc_dsp_dir);
     811        if (entry)
     812                snd_info_set_text_ops(entry, chip,
     813                                      cs46xx_dsp_proc_parameter_dump_read);
     814
     815        entry = snd_info_create_card_entry(card, "sample",
     816                                           ins->proc_dsp_dir);
     817        if (entry)
     818                snd_info_set_text_ops(entry, chip,
     819                                      cs46xx_dsp_proc_sample_dump_read);
     820
     821        entry = snd_info_create_card_entry(card, "task_tree",
     822                                           ins->proc_dsp_dir);
     823        if (entry)
     824                snd_info_set_text_ops(entry, chip,
     825                                      cs46xx_dsp_proc_task_tree_read);
     826
     827        entry = snd_info_create_card_entry(card, "scb_info",
     828                                           ins->proc_dsp_dir);
     829        if (entry)
     830                snd_info_set_text_ops(entry, chip,
     831                                      cs46xx_dsp_proc_scb_read);
    863832
    864833        mutex_lock(&chip->spos_mutex);
     
    879848        int i;
    880849
    881         snd_info_free_entry(ins->proc_sym_info_entry);
    882         ins->proc_sym_info_entry = NULL;
    883 
    884         snd_info_free_entry(ins->proc_modules_info_entry);
    885         ins->proc_modules_info_entry = NULL;
    886 
    887         snd_info_free_entry(ins->proc_parameter_dump_info_entry);
    888         ins->proc_parameter_dump_info_entry = NULL;
    889 
    890         snd_info_free_entry(ins->proc_sample_dump_info_entry);
    891         ins->proc_sample_dump_info_entry = NULL;
    892 
    893         snd_info_free_entry(ins->proc_scb_info_entry);
    894         ins->proc_scb_info_entry = NULL;
    895 
    896         snd_info_free_entry(ins->proc_task_info_entry);
    897         ins->proc_task_info_entry = NULL;
     850        if (!ins)
     851                return 0;
    898852
    899853        mutex_lock(&chip->spos_mutex);
     
    909863        return 0;
    910864}
    911 #endif /* CONFIG_PROC_FS */
    912 
    913 static int debug_tree;
     865#endif /* CONFIG_SND_PROC_FS */
     866
    914867static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data,
    915868                                   u32  dest, int size)
     
    920873
    921874        for (i = 0; i < size; ++i) {
    922                 if (debug_tree) printk ("addr %p, val %08x\n",spdst,task_data[i]);
     875                dev_dbg(chip->card->dev, "addr %p, val %08x\n",
     876                        spdst, task_data[i]);
    923877                writel(task_data[i],spdst);
    924878                spdst += sizeof(u32);
     
    926880}
    927881
    928 static int debug_scb;
    929882static void _dsp_create_scb (struct snd_cs46xx *chip, u32 * scb_data, u32 dest)
    930883{
     
    934887
    935888        for (i = 0; i < 0x10; ++i) {
    936                 if (debug_scb) printk ("addr %p, val %08x\n",spdst,scb_data[i]);
     889                dev_dbg(chip->card->dev, "addr %p, val %08x\n",
     890                        spdst, scb_data[i]);
    937891                writel(scb_data[i],spdst);
    938892                spdst += sizeof(u32);
     
    961915
    962916        if (ins->nscb == DSP_MAX_SCB_DESC - 1) {
    963                 snd_printk(KERN_ERR "dsp_spos: got no place for other SCB\n");
     917                dev_err(chip->card->dev,
     918                        "dsp_spos: got no place for other SCB\n");
    964919                return NULL;
    965920        }
     
    992947
    993948        if (ins->ntask == DSP_MAX_TASK_DESC - 1) {
    994                 snd_printk(KERN_ERR "dsp_spos: got no place for other TASK\n");
     949                dev_err(chip->card->dev,
     950                        "dsp_spos: got no place for other TASK\n");
    995951                return NULL;
    996952        }
     
    1020976        struct dsp_scb_descriptor * desc;
    1021977
    1022 #ifdef CONFIG_PM
     978#ifdef CONFIG_PM_SLEEP
    1023979        /* copy the data for resume */
    1024980        scb_data = kmemdup(scb_data, SCB_BYTES, GFP_KERNEL);
     
    1032988                _dsp_create_scb(chip,scb_data,dest);
    1033989        } else {
    1034                 snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n");
    1035 #ifdef CONFIG_PM
     990                dev_err(chip->card->dev, "dsp_spos: failed to map SCB\n");
     991#ifdef CONFIG_PM_SLEEP
    1036992                kfree(scb_data);
    1037993#endif
     
    10531009                _dsp_create_task_tree(chip,task_data,dest,size);
    10541010        } else {
    1055                 snd_printk(KERN_ERR "dsp_spos: failed to map TASK\n");
     1011                dev_err(chip->card->dev, "dsp_spos: failed to map TASK\n");
    10561012        }
    10571013
     
    10831039        int fifo_addr, fifo_span, valid_slots;
    10841040
    1085         static struct dsp_spos_control_block sposcb = {
     1041        static const struct dsp_spos_control_block sposcb = {
    10861042                /* 0 */ HFG_TREE_SCB,HFG_STACK,
    10871043                /* 1 */ SPOSCB_ADDR,BG_TREE_SCB_ADDR,
     
    11061062        null_algorithm  = cs46xx_dsp_lookup_symbol(chip, "NULLALGORITHM", SYMBOL_CODE);
    11071063        if (null_algorithm == NULL) {
    1108                 snd_printk(KERN_ERR "dsp_spos: symbol NULLALGORITHM not found\n");
     1064                dev_err(chip->card->dev,
     1065                        "dsp_spos: symbol NULLALGORITHM not found\n");
    11091066                return -EIO;
    11101067        }
     
    11121069        fg_task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "FGTASKTREEHEADERCODE", SYMBOL_CODE); 
    11131070        if (fg_task_tree_header_code == NULL) {
    1114                 snd_printk(KERN_ERR "dsp_spos: symbol FGTASKTREEHEADERCODE not found\n");
     1071                dev_err(chip->card->dev,
     1072                        "dsp_spos: symbol FGTASKTREEHEADERCODE not found\n");
    11151073                return -EIO;
    11161074        }
     
    11181076        task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "TASKTREEHEADERCODE", SYMBOL_CODE); 
    11191077        if (task_tree_header_code == NULL) {
    1120                 snd_printk(KERN_ERR "dsp_spos: symbol TASKTREEHEADERCODE not found\n");
     1078                dev_err(chip->card->dev,
     1079                        "dsp_spos: symbol TASKTREEHEADERCODE not found\n");
    11211080                return -EIO;
    11221081        }
     
    11241083        task_tree_thread = cs46xx_dsp_lookup_symbol(chip, "TASKTREETHREAD", SYMBOL_CODE);
    11251084        if (task_tree_thread == NULL) {
    1126                 snd_printk(KERN_ERR "dsp_spos: symbol TASKTREETHREAD not found\n");
     1085                dev_err(chip->card->dev,
     1086                        "dsp_spos: symbol TASKTREETHREAD not found\n");
    11271087                return -EIO;
    11281088        }
     
    11301090        magic_snoop_task = cs46xx_dsp_lookup_symbol(chip, "MAGICSNOOPTASK", SYMBOL_CODE);
    11311091        if (magic_snoop_task == NULL) {
    1132                 snd_printk(KERN_ERR "dsp_spos: symbol MAGICSNOOPTASK not found\n");
     1092                dev_err(chip->card->dev,
     1093                        "dsp_spos: symbol MAGICSNOOPTASK not found\n");
    11331094                return -EIO;
    11341095        }
     
    14141375        if (chip->nr_ac97_codecs == 2) {
    14151376                /* create CODEC tasklet for rear Center/LFE output
    1416                    slot 6 and 9 on seconadry CODEC */
     1377                   slot 6 and 9 on secondary CODEC */
    14171378                clfe_codec_out_scb = cs46xx_dsp_create_codec_out_scb(chip,"CodecOutSCB_CLFE",0x0030,0x0030,
    14181379                                                                     CLFE_MIXER_SCB_ADDR,
     
    14771438
    14781439 _fail_end:
    1479         snd_printk(KERN_ERR "dsp_spos: failed to setup SCB's in DSP\n");
     1440        dev_err(chip->card->dev, "dsp_spos: failed to setup SCB's in DSP\n");
    14801441        return -EINVAL;
    14811442}
     
    14921453        s16_async_codec_input_task = cs46xx_dsp_lookup_symbol(chip, "S16_ASYNCCODECINPUTTASK", SYMBOL_CODE);
    14931454        if (s16_async_codec_input_task == NULL) {
    1494                 snd_printk(KERN_ERR "dsp_spos: symbol S16_ASYNCCODECINPUTTASK not found\n");
     1455                dev_err(chip->card->dev,
     1456                        "dsp_spos: symbol S16_ASYNCCODECINPUTTASK not found\n");
    14951457                return -EIO;
    14961458        }
    14971459        spdifo_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFOTASK", SYMBOL_CODE);
    14981460        if (spdifo_task == NULL) {
    1499                 snd_printk(KERN_ERR "dsp_spos: symbol SPDIFOTASK not found\n");
     1461                dev_err(chip->card->dev,
     1462                        "dsp_spos: symbol SPDIFOTASK not found\n");
    15001463                return -EIO;
    15011464        }
     
    15031466        spdifi_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFITASK", SYMBOL_CODE);
    15041467        if (spdifi_task == NULL) {
    1505                 snd_printk(KERN_ERR "dsp_spos: symbol SPDIFITASK not found\n");
     1468                dev_err(chip->card->dev,
     1469                        "dsp_spos: symbol SPDIFITASK not found\n");
    15061470                return -EIO;
    15071471        }
     
    18841848
    18851849        if (i == 25) {
    1886                 snd_printk(KERN_ERR "dsp_spos: SPIOWriteTask not responding\n");
     1850                dev_err(chip->card->dev,
     1851                        "dsp_spos: SPIOWriteTask not responding\n");
    18871852                return -EBUSY;
    18881853        }
     
    19381903}
    19391904
    1940 #ifdef CONFIG_PM
     1905#ifdef CONFIG_PM_SLEEP
    19411906int cs46xx_dsp_resume(struct snd_cs46xx * chip)
    19421907{
  • GPL/trunk/alsa-kernel/pci/cs46xx/dsp_spos.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
    34 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    4  *
    5  *
    6  *   This program is free software; you can redistribute it and/or modify
    7  *   it under the terms of the GNU General Public License as published by
    8  *   the Free Software Foundation; either version 2 of the License, or
    9  *   (at your option) any later version.
    10  *
    11  *   This program is distributed in the hope that it will be useful,
    12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  *   GNU General Public License for more details.
    15  *
    16  *   You should have received a copy of the GNU General Public License
    17  *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    19  *
    205 */
    216
  • GPL/trunk/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    2  *
    3  *   This program is free software; you can redistribute it and/or modify
    4  *   it under the terms of the GNU General Public License as published by
    5  *   the Free Software Foundation; either version 2 of the License, or
    6  *   (at your option) any later version.
    7  *
    8  *   This program is distributed in the hope that it will be useful,
    9  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  *   GNU General Public License for more details.
    12  *
    13  *   You should have received a copy of the GNU General Public License
    14  *   along with this program; if not, write to the Free Software
    15  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    16  *
    173 */
    184
     
    228
    239
    24 #include <asm/io.h>
     10#include <linux/io.h>
    2511#include <linux/delay.h>
    2612#include <linux/pm.h>
     
    3218#include <sound/control.h>
    3319#include <sound/info.h>
    34 #include <sound/cs46xx.h>
     20#include "cs46xx.h"
    3521
    3622#include "cs46xx_lib.h"
     
    6854}
    6955
    70 #ifdef CONFIG_PROC_FS
     56#ifdef CONFIG_SND_PROC_FS
    7157static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry,
    7258                                           struct snd_info_buffer *buffer)
     
    7460        struct proc_scb_info * scb_info  = entry->private_data;
    7561        struct dsp_scb_descriptor * scb = scb_info->scb_desc;
    76         struct dsp_spos_instance * ins;
    7762        struct snd_cs46xx *chip = scb_info->chip;
    7863        int j,col;
    7964        void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
    80 
    81         ins = chip->dsp_spos_instance;
    8265
    8366        mutex_lock(&chip->spos_mutex);
     
    204187
    205188        ins->scbs[scb->index].deleted = 1;
    206 #ifdef CONFIG_PM
     189#ifdef CONFIG_PM_SLEEP
    207190        kfree(ins->scbs[scb->index].data);
    208191        ins->scbs[scb->index].data = NULL;
     
    229212
    230213
    231 #ifdef CONFIG_PROC_FS
     214#ifdef CONFIG_SND_PROC_FS
    232215void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb)
    233216{
    234217        if (scb->proc_info) {
    235218                struct proc_scb_info * scb_info = scb->proc_info->private_data;
    236 
    237                 snd_printdd("cs46xx_dsp_proc_free_scb_desc: freeing %s\n",scb->scb_name);
     219                struct snd_cs46xx *chip = scb_info->chip;
     220
     221                dev_dbg(chip->card->dev,
     222                        "cs46xx_dsp_proc_free_scb_desc: freeing %s\n",
     223                        scb->scb_name);
    238224
    239225                snd_info_free_entry(scb->proc_info);
     
    255241            scb->proc_info == NULL) {
    256242 
    257                 if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
    258                                                         ins->proc_dsp_dir)) != NULL) {
     243                entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
     244                                                   ins->proc_dsp_dir);
     245                if (entry) {
    259246                        scb_info = kmalloc(sizeof(struct proc_scb_info), GFP_KERNEL);
    260247                        if (!scb_info) {
     
    266253                        scb_info->chip = chip;
    267254                        scb_info->scb_desc = scb;
    268      
    269                         entry->content = SNDRV_INFO_CONTENT_TEXT;
    270                         entry->private_data = scb_info;
    271                         entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
    272      
    273                         entry->c.text.read = cs46xx_dsp_proc_scb_info_read;
    274      
    275                         if (snd_info_register(entry) < 0) {
    276                                 snd_info_free_entry(entry);
    277                                 kfree (scb_info);
    278                                 entry = NULL;
    279                         }
     255                        snd_info_set_text_ops(entry, scb_info,
     256                                              cs46xx_dsp_proc_scb_info_read);
    280257                }
    281258out:
     
    283260        }
    284261}
    285 #endif /* CONFIG_PROC_FS */
     262#endif /* CONFIG_SND_PROC_FS */
    286263
    287264static struct dsp_scb_descriptor *
     
    306283        scb_data[SCBfuncEntryPtr] |= task_entry->address;
    307284
    308         snd_printdd("dsp_spos: creating SCB <%s>\n",name);
     285        dev_dbg(chip->card->dev, "dsp_spos: creating SCB <%s>\n", name);
    309286
    310287        scb = cs46xx_dsp_create_scb(chip,name,scb_data,dest);
     
    321298        if (scb->parent_scb_ptr) {
    322299#if 0
    323                 printk ("scb->parent_scb_ptr = %s\n",scb->parent_scb_ptr->scb_name);
    324                 printk ("scb->parent_scb_ptr->next_scb_ptr = %s\n",scb->parent_scb_ptr->next_scb_ptr->scb_name);
    325                 printk ("scb->parent_scb_ptr->sub_list_ptr = %s\n",scb->parent_scb_ptr->sub_list_ptr->scb_name);
     300                dev_dbg(chip->card->dev,
     301                        "scb->parent_scb_ptr = %s\n",
     302                        scb->parent_scb_ptr->scb_name);
     303                dev_dbg(chip->card->dev,
     304                        "scb->parent_scb_ptr->next_scb_ptr = %s\n",
     305                        scb->parent_scb_ptr->next_scb_ptr->scb_name);
     306                dev_dbg(chip->card->dev,
     307                        "scb->parent_scb_ptr->sub_list_ptr = %s\n",
     308                        scb->parent_scb_ptr->sub_list_ptr->scb_name);
    326309#endif
    327310                /* link to  parent SCB */
     
    369352 
    370353        if (task_entry == NULL) {
    371                 snd_printk (KERN_ERR "dsp_spos: symbol %s not found\n",task_entry_name);
     354                dev_err(chip->card->dev,
     355                        "dsp_spos: symbol %s not found\n", task_entry_name);
    372356                return NULL;
    373357        }
     
    583567   
    584568                if (ins->null_algorithm == NULL) {
    585                         snd_printk (KERN_ERR "dsp_spos: symbol NULLALGORITHM not found\n");
     569                        dev_err(chip->card->dev,
     570                                "dsp_spos: symbol NULLALGORITHM not found\n");
    586571                        return NULL;
    587572                }   
     
    613598        unsigned int correctionPerGOF, correctionPerSec;
    614599
    615         snd_printdd( "dsp_spos: setting %s rate to %u\n",scb_name,rate);
     600        dev_dbg(chip->card->dev, "dsp_spos: setting %s rate to %u\n",
     601                scb_name, rate);
    616602
    617603        /*
     
    671657                       
    672658                        if (ins->s16_up == NULL) {
    673                                 snd_printk (KERN_ERR "dsp_spos: symbol S16_UPSRC not found\n");
     659                                dev_err(chip->card->dev,
     660                                        "dsp_spos: symbol S16_UPSRC not found\n");
    674661                                return NULL;
    675662                        }   
     
    11591146}
    11601147
    1161 static u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = {
     1148static const u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = {
    11621149        0x0600, /* 1 */
    11631150        0x1500, /* 2 */
     
    11941181};
    11951182
    1196 static u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = {
     1183static const u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = {
    11971184        0x2B80,
    11981185        0x2BA0,
     
    12111198};
    12121199
    1213 static u32 src_delay_buffer_addr[DSP_MAX_SRC_NR] = {
     1200static const u32 src_delay_buffer_addr[DSP_MAX_SRC_NR] = {
    12141201        0x2480,
    12151202        0x2500,
     
    12661253                   alter the raw data stream ...) */
    12671254                if (sample_rate == 48000) {
    1268                         snd_printdd ("IEC958 pass through\n");
     1255                        dev_dbg(chip->card->dev, "IEC958 pass through\n");
    12691256                        /* Hack to bypass creating a new SRC */
    12701257                        pass_through = 1;
     
    13001287
    13011288        if (pcm_index == -1) {
    1302                 snd_printk (KERN_ERR "dsp_spos: no free PCM channel\n");
     1289                dev_err(chip->card->dev, "dsp_spos: no free PCM channel\n");
    13031290                return NULL;
    13041291        }
     
    13061293        if (src_scb == NULL) {
    13071294                if (ins->nsrc_scb >= DSP_MAX_SRC_NR) {
    1308                         snd_printk(KERN_ERR "dsp_spos: to many SRC instances\n!");
     1295                        dev_err(chip->card->dev,
     1296                                "dsp_spos: too many SRC instances\n!");
    13091297                        return NULL;
    13101298                }
     
    13321320                snprintf (scb_name,DSP_MAX_SCB_NAME,"SrcTask_SCB%d",src_index);
    13331321               
    1334                 snd_printdd( "dsp_spos: creating SRC \"%s\"\n",scb_name);
     1322                dev_dbg(chip->card->dev,
     1323                        "dsp_spos: creating SRC \"%s\"\n", scb_name);
    13351324                src_scb = cs46xx_dsp_create_src_task_scb(chip,scb_name,
    13361325                                                         sample_rate,
     
    13441333
    13451334                if (!src_scb) {
    1346                         snd_printk (KERN_ERR "dsp_spos: failed to create SRCtaskSCB\n");
     1335                        dev_err(chip->card->dev,
     1336                                "dsp_spos: failed to create SRCtaskSCB\n");
    13471337                        return NULL;
    13481338                }
     
    13561346        snprintf (scb_name,DSP_MAX_SCB_NAME,"PCMReader_SCB%d",pcm_index);
    13571347
    1358         snd_printdd( "dsp_spos: creating PCM \"%s\" (%d)\n",scb_name,
    1359                 pcm_channel_id);
     1348        dev_dbg(chip->card->dev, "dsp_spos: creating PCM \"%s\" (%d)\n",
     1349                scb_name, pcm_channel_id);
    13601350
    13611351        pcm_scb = cs46xx_dsp_create_pcm_reader_scb(chip,scb_name,
     
    13701360
    13711361        if (!pcm_scb) {
    1372                 snd_printk (KERN_ERR "dsp_spos: failed to create PCMreaderSCB\n");
     1362                dev_err(chip->card->dev,
     1363                        "dsp_spos: failed to create PCMreaderSCB\n");
    13731364                return NULL;
    13741365        }
     
    14201411                break;
    14211412        default:
    1422                 snd_printdd ("period size (%d) not supported by HW\n", period_size);
     1413                dev_dbg(chip->card->dev,
     1414                        "period size (%d) not supported by HW\n", period_size);
    14231415                return -EINVAL;
    14241416        }
     
    14581450                break;
    14591451        default:
    1460                 snd_printdd ("period size (%d) not supported by HW\n", period_size);
     1452                dev_dbg(chip->card->dev,
     1453                        "period size (%d) not supported by HW\n", period_size);
    14611454                return -EINVAL;
    14621455        }
     
    17241717
    17251718        if ( ins->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED ) {
    1726                 /* remove AsynchFGTxSCB and and PCMSerialInput_II */
     1719                /* remove AsynchFGTxSCB and PCMSerialInput_II */
    17271720                cs46xx_dsp_disable_spdif_out (chip);
    17281721
Note: See TracChangeset for help on using the changeset viewer.