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

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/isa/sb/emu8000.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    56 *
    67 *  Routines for control of EMU8000 chip
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    218 */
    229
    2310#include <linux/wait.h>
    24 #include <linux/sched.h>
     11#include <linux/sched/signal.h>
    2512#include <linux/slab.h>
    2613#include <linux/ioport.h>
     14#include <linux/export.h>
    2715#include <linux/delay.h>
     16#include <linux/io.h>
    2817#include <sound/core.h>
    2918#include <sound/emu8000.h>
    3019#include <sound/emu8000_reg.h>
    31 #include <asm/io.h>
    32 #include <asm/uaccess.h>
     20#include <linux/uaccess.h>
    3321#include <linux/init.h>
    3422#include <sound/control.h>
     
    131119/*
    132120 */
    133 static void __devinit
     121static void
    134122snd_emu8000_read_wait(struct snd_emu8000 *emu)
    135123{
     
    143131/*
    144132 */
    145 static void __devinit
     133static void
    146134snd_emu8000_write_wait(struct snd_emu8000 *emu)
    147135{
     
    156144 * detect a card at the given port
    157145 */
    158 static int __devinit
     146static int
    159147snd_emu8000_detect(struct snd_emu8000 *emu)
    160148{
     
    182170 * intiailize audio channels
    183171 */
    184 static void __devinit
     172static void
    185173init_audio(struct snd_emu8000 *emu)
    186174{
     
    223211 * initialize DMA address
    224212 */
    225 static void __devinit
     213static void
    226214init_dma(struct snd_emu8000 *emu)
    227215{
     
    235223 * initialization arrays; from ADIP
    236224 */
    237 static unsigned short init1[128] /*__devinitdata*/ = {
     225static const unsigned short init1[128] = {
    238226        0x03ff, 0x0030,  0x07ff, 0x0130, 0x0bff, 0x0230,  0x0fff, 0x0330,
    239227        0x13ff, 0x0430,  0x17ff, 0x0530, 0x1bff, 0x0630,  0x1fff, 0x0730,
     
    257245};
    258246
    259 static unsigned short init2[128] /*__devinitdata*/ = {
     247static const unsigned short init2[128] = {
    260248        0x03ff, 0x8030, 0x07ff, 0x8130, 0x0bff, 0x8230, 0x0fff, 0x8330,
    261249        0x13ff, 0x8430, 0x17ff, 0x8530, 0x1bff, 0x8630, 0x1fff, 0x8730,
     
    279267};
    280268
    281 static unsigned short init3[128] /*__devinitdata*/ = {
     269static const unsigned short init3[128] = {
    282270        0x0C10, 0x8470, 0x14FE, 0xB488, 0x167F, 0xA470, 0x18E7, 0x84B5,
    283271        0x1B6E, 0x842A, 0x1F1D, 0x852A, 0x0DA3, 0x8F7C, 0x167E, 0xF254,
     
    301289};
    302290
    303 static unsigned short init4[128] /*__devinitdata*/ = {
     291static const unsigned short init4[128] = {
    304292        0x0C10, 0x8470, 0x14FE, 0xB488, 0x167F, 0xA470, 0x18E7, 0x84B5,
    305293        0x1B6E, 0x842A, 0x1F1D, 0x852A, 0x0DA3, 0x0F7C, 0x167E, 0x7254,
     
    327315 * is meant to work
    328316 */
    329 static void __devinit
    330 send_array(struct snd_emu8000 *emu, unsigned short *data, int size)
     317static void
     318send_array(struct snd_emu8000 *emu, const unsigned short *data, int size)
    331319{
    332320        int i;
    333         unsigned short *p;
     321        const unsigned short *p;
    334322
    335323        p = data;
     
    349337 * initialisation sequence in the adip.
    350338 */
    351 static void __devinit
     339static void
    352340init_arrays(struct snd_emu8000 *emu)
    353341{
     
    371359/*
    372360 * Size the onboard memory.
    373  * This is written so as not to need arbitary delays after the write. It
     361 * This is written so as not to need arbitrary delays after the write. It
    374362 * seems that the only way to do this is to use the one channel and keep
    375363 * reallocating between read and write.
    376364 */
    377 static void __devinit
     365static void
    378366size_dram(struct snd_emu8000 *emu)
    379367{
    380         int i, size, detected_size;
     368        int i, size;
    381369
    382370        if (emu->dram_checked)
     
    384372
    385373        size = 0;
    386         detected_size = 0;
    387374
    388375        /* write out a magic number */
     
    392379        EMU8000_SMLD_WRITE(emu, UNIQUE_ID1);
    393380        snd_emu8000_init_fm(emu); /* This must really be here and not 2 lines back even */
    394 
    395         while (size < EMU8000_MAX_DRAM) {
    396 
    397                 size += 512 * 1024;  /* increment 512kbytes */
     381        snd_emu8000_write_wait(emu);
     382
     383        /*
     384         * Detect first 512 KiB.  If a write succeeds at the beginning of a
     385         * 512 KiB page we assume that the whole page is there.
     386         */
     387        EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET);
     388        EMU8000_SMLD_READ(emu); /* discard stale data  */
     389        if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1)
     390                goto skip_detect;   /* No RAM */
     391        snd_emu8000_read_wait(emu);
     392
     393        for (size = 512 * 1024; size < EMU8000_MAX_DRAM; size += 512 * 1024) {
    398394
    399395                /* Write a unique data on the test address.
     
    417413                if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
    418414                        break; /* no memory at this address */
    419 
    420                 detected_size = size;
    421 
    422415                snd_emu8000_read_wait(emu);
    423416
     
    432425                        break; /* we must have wrapped around */
    433426                snd_emu8000_read_wait(emu);
    434         }
    435 
     427
     428                /* Otherwise, it's valid memory. */
     429        }
     430
     431skip_detect:
    436432        /* wait until FULL bit in SMAxW register is false */
    437433        for (i = 0; i < 10000; i++) {
     
    445441        snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE);
    446442
    447         snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n",
    448                     emu->port1, detected_size/1024);
    449 
    450         emu->mem_size = detected_size;
     443        pr_info("EMU8000 [0x%lx]: %d KiB on-board DRAM detected\n",
     444                    emu->port1, size/1024);
     445
     446        emu->mem_size = size;
    451447        emu->dram_checked = 1;
    452448}
     
    503499 * The main initialization routine.
    504500 */
    505 static void __devinit
     501static void
    506502snd_emu8000_init_hw(struct snd_emu8000 *emu)
    507503{
     
    553549 *----------------------------------------------------------------*/
    554550
    555 static unsigned short bass_parm[12][3] = {
     551static const unsigned short bass_parm[12][3] = {
    556552        {0xD26A, 0xD36A, 0x0000}, /* -12 dB */
    557553        {0xD25B, 0xD35B, 0x0000}, /*  -8 */
     
    568564};
    569565
    570 static unsigned short treble_parm[12][9] = {
     566static const unsigned short treble_parm[12][9] = {
    571567        {0x821E, 0xC26A, 0x031E, 0xC36A, 0x021E, 0xD208, 0x831E, 0xD308, 0x0001}, /* -12 dB */
    572568        {0x821E, 0xC25B, 0x031E, 0xC35B, 0x021E, 0xD208, 0x831E, 0xD308, 0x0001},
     
    860856}
    861857
    862 static struct snd_kcontrol_new mixer_bass_control =
     858static const struct snd_kcontrol_new mixer_bass_control =
    863859{
    864860        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    870866};
    871867
    872 static struct snd_kcontrol_new mixer_treble_control =
     868static const struct snd_kcontrol_new mixer_treble_control =
    873869{
    874870        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    927923}
    928924
    929 static struct snd_kcontrol_new mixer_chorus_mode_control =
     925static const struct snd_kcontrol_new mixer_chorus_mode_control =
    930926{
    931927        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    937933};
    938934
    939 static struct snd_kcontrol_new mixer_reverb_mode_control =
     935static const struct snd_kcontrol_new mixer_reverb_mode_control =
    940936{
    941937        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    989985}
    990986
    991 static struct snd_kcontrol_new mixer_fm_chorus_depth_control =
     987static const struct snd_kcontrol_new mixer_fm_chorus_depth_control =
    992988{
    993989        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    999995};
    1000996
    1001 static struct snd_kcontrol_new mixer_fm_reverb_depth_control =
     997static const struct snd_kcontrol_new mixer_fm_reverb_depth_control =
    1002998{
    1003999        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    10101006
    10111007
    1012 static struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = {
     1008static const struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = {
    10131009        &mixer_bass_control,
    10141010        &mixer_treble_control,
     
    10221018 * create and attach mixer elements for WaveTable treble/bass controls
    10231019 */
    1024 static int __devinit
     1020static int
    10251021snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)
    10261022{
     
    10731069 * initialize and register emu8000 synth device.
    10741070 */
    1075 int __devinit
     1071int
    10761072snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports,
    10771073                struct snd_seq_device **awe_ret)
     
    10801076        struct snd_emu8000 *hw;
    10811077        int err;
    1082         static struct snd_device_ops ops = {
     1078        static const struct snd_device_ops ops = {
    10831079                .dev_free = snd_emu8000_dev_free,
    10841080        };
     
    11301126                return err;
    11311127        }
    1132 #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
     1128#if IS_ENABLED(CONFIG_SND_SEQUENCER)
    11331129        if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000,
    11341130                               sizeof(struct snd_emu8000*), &awe) >= 0) {
Note: See TracChangeset for help on using the changeset viewer.