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

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
4 deleted
64 edited
109 copied

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/include/sound/ac97_codec.h

    r598 r679  
    1 #ifndef __SOUND_AC97_CODEC_H
    2 #define __SOUND_AC97_CODEC_H
    3 
    4 /*
     1/* SPDX-License-Identifier: GPL-2.0+
     2 *
    53 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    64 *  Universal interface for Audio Codec '97
     
    86 *  For more details look to AC '97 component specification revision 2.1
    97 *  by Intel Corporation (http://developer.intel.com).
    10  *
    11  *
    12  *   This program is free software; you can redistribute it and/or modify
    13  *   it under the terms of the GNU General Public License as published by
    14  *   the Free Software Foundation; either version 2 of the License, or
    15  *   (at your option) any later version.
    16  *
    17  *   This program is distributed in the hope that it will be useful,
    18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  *   GNU General Public License for more details.
    21  *
    22  *   You should have received a copy of the GNU General Public License
    23  *   along with this program; if not, write to the Free Software
    24  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    25  *
    268 */
     9
     10#ifndef __SOUND_AC97_CODEC_H
     11#define __SOUND_AC97_CODEC_H
    2712
    2813#include <linux/bitops.h>
    2914#include <linux/device.h>
    3015#include <linux/workqueue.h>
    31 #include "pcm.h"
    32 #include "control.h"
    33 #include "info.h"
     16#include <sound/ac97/regs.h>
     17#include <sound/pcm.h>
     18#include <sound/control.h>
     19#include <sound/info.h>
    3420
    3521/* maximum number of devices on the AC97 bus */
    3622#define AC97_BUS_MAX_DEVICES    4
    37 
    38 /*
    39  *  AC'97 codec registers
    40  */
    41 
    42 #define AC97_RESET              0x00    /* Reset */
    43 #define AC97_MASTER             0x02    /* Master Volume */
    44 #define AC97_HEADPHONE          0x04    /* Headphone Volume (optional) */
    45 #define AC97_MASTER_MONO        0x06    /* Master Volume Mono (optional) */
    46 #define AC97_MASTER_TONE        0x08    /* Master Tone (Bass & Treble) (optional) */
    47 #define AC97_PC_BEEP            0x0a    /* PC Beep Volume (optinal) */
    48 #define AC97_PHONE              0x0c    /* Phone Volume (optional) */
    49 #define AC97_MIC                0x0e    /* MIC Volume */
    50 #define AC97_LINE               0x10    /* Line In Volume */
    51 #define AC97_CD                 0x12    /* CD Volume */
    52 #define AC97_VIDEO              0x14    /* Video Volume (optional) */
    53 #define AC97_AUX                0x16    /* AUX Volume (optional) */
    54 #define AC97_PCM                0x18    /* PCM Volume */
    55 #define AC97_REC_SEL            0x1a    /* Record Select */
    56 #define AC97_REC_GAIN           0x1c    /* Record Gain */
    57 #define AC97_REC_GAIN_MIC       0x1e    /* Record Gain MIC (optional) */
    58 #define AC97_GENERAL_PURPOSE    0x20    /* General Purpose (optional) */
    59 #define AC97_3D_CONTROL         0x22    /* 3D Control (optional) */
    60 #define AC97_INT_PAGING         0x24    /* Audio Interrupt & Paging (AC'97 2.3) */
    61 #define AC97_POWERDOWN          0x26    /* Powerdown control / status */
    62 /* range 0x28-0x3a - AUDIO AC'97 2.0 extensions */
    63 #define AC97_EXTENDED_ID        0x28    /* Extended Audio ID */
    64 #define AC97_EXTENDED_STATUS    0x2a    /* Extended Audio Status and Control */
    65 #define AC97_PCM_FRONT_DAC_RATE 0x2c    /* PCM Front DAC Rate */
    66 #define AC97_PCM_SURR_DAC_RATE  0x2e    /* PCM Surround DAC Rate */
    67 #define AC97_PCM_LFE_DAC_RATE   0x30    /* PCM LFE DAC Rate */
    68 #define AC97_PCM_LR_ADC_RATE    0x32    /* PCM LR ADC Rate */
    69 #define AC97_PCM_MIC_ADC_RATE   0x34    /* PCM MIC ADC Rate */
    70 #define AC97_CENTER_LFE_MASTER  0x36    /* Center + LFE Master Volume */
    71 #define AC97_SURROUND_MASTER    0x38    /* Surround (Rear) Master Volume */
    72 #define AC97_SPDIF              0x3a    /* S/PDIF control */
    73 /* range 0x3c-0x58 - MODEM */
    74 #define AC97_EXTENDED_MID       0x3c    /* Extended Modem ID */
    75 #define AC97_EXTENDED_MSTATUS   0x3e    /* Extended Modem Status and Control */
    76 #define AC97_LINE1_RATE         0x40    /* Line1 DAC/ADC Rate */
    77 #define AC97_LINE2_RATE         0x42    /* Line2 DAC/ADC Rate */
    78 #define AC97_HANDSET_RATE       0x44    /* Handset DAC/ADC Rate */
    79 #define AC97_LINE1_LEVEL        0x46    /* Line1 DAC/ADC Level */
    80 #define AC97_LINE2_LEVEL        0x48    /* Line2 DAC/ADC Level */
    81 #define AC97_HANDSET_LEVEL      0x4a    /* Handset DAC/ADC Level */
    82 #define AC97_GPIO_CFG           0x4c    /* GPIO Configuration */
    83 #define AC97_GPIO_POLARITY      0x4e    /* GPIO Pin Polarity/Type, 0=low, 1=high active */
    84 #define AC97_GPIO_STICKY        0x50    /* GPIO Pin Sticky, 0=not, 1=sticky */
    85 #define AC97_GPIO_WAKEUP        0x52    /* GPIO Pin Wakeup, 0=no int, 1=yes int */
    86 #define AC97_GPIO_STATUS        0x54    /* GPIO Pin Status, slot 12 */
    87 #define AC97_MISC_AFE           0x56    /* Miscellaneous Modem AFE Status and Control */
    88 /* range 0x5a-0x7b - Vendor Specific */
    89 #define AC97_VENDOR_ID1         0x7c    /* Vendor ID1 */
    90 #define AC97_VENDOR_ID2         0x7e    /* Vendor ID2 / revision */
    91 /* range 0x60-0x6f (page 1) - extended codec registers */
    92 #define AC97_CODEC_CLASS_REV    0x60    /* Codec Class/Revision */
    93 #define AC97_PCI_SVID           0x62    /* PCI Subsystem Vendor ID */
    94 #define AC97_PCI_SID            0x64    /* PCI Subsystem ID */
    95 #define AC97_FUNC_SELECT        0x66    /* Function Select */
    96 #define AC97_FUNC_INFO          0x68    /* Function Information */
    97 #define AC97_SENSE_INFO         0x6a    /* Sense Details */
    98 
    99 /* slot allocation */
    100 #define AC97_SLOT_TAG           0
    101 #define AC97_SLOT_CMD_ADDR      1
    102 #define AC97_SLOT_CMD_DATA      2
    103 #define AC97_SLOT_PCM_LEFT      3
    104 #define AC97_SLOT_PCM_RIGHT     4
    105 #define AC97_SLOT_MODEM_LINE1   5
    106 #define AC97_SLOT_PCM_CENTER    6
    107 #define AC97_SLOT_MIC           6       /* input */
    108 #define AC97_SLOT_SPDIF_LEFT1   6
    109 #define AC97_SLOT_PCM_SLEFT     7       /* surround left */
    110 #define AC97_SLOT_PCM_LEFT_0    7       /* double rate operation */
    111 #define AC97_SLOT_SPDIF_LEFT    7
    112 #define AC97_SLOT_PCM_SRIGHT    8       /* surround right */
    113 #define AC97_SLOT_PCM_RIGHT_0   8       /* double rate operation */
    114 #define AC97_SLOT_SPDIF_RIGHT   8
    115 #define AC97_SLOT_LFE           9
    116 #define AC97_SLOT_SPDIF_RIGHT1  9
    117 #define AC97_SLOT_MODEM_LINE2   10
    118 #define AC97_SLOT_PCM_LEFT_1    10      /* double rate operation */
    119 #define AC97_SLOT_SPDIF_LEFT2   10
    120 #define AC97_SLOT_HANDSET       11      /* output */
    121 #define AC97_SLOT_PCM_RIGHT_1   11      /* double rate operation */
    122 #define AC97_SLOT_SPDIF_RIGHT2  11
    123 #define AC97_SLOT_MODEM_GPIO    12      /* modem GPIO */
    124 #define AC97_SLOT_PCM_CENTER_1  12      /* double rate operation */
    125 
    126 /* basic capabilities (reset register) */
    127 #define AC97_BC_DEDICATED_MIC   0x0001  /* Dedicated Mic PCM In Channel */
    128 #define AC97_BC_RESERVED1       0x0002  /* Reserved (was Modem Line Codec support) */
    129 #define AC97_BC_BASS_TREBLE     0x0004  /* Bass & Treble Control */
    130 #define AC97_BC_SIM_STEREO      0x0008  /* Simulated stereo */
    131 #define AC97_BC_HEADPHONE       0x0010  /* Headphone Out Support */
    132 #define AC97_BC_LOUDNESS        0x0020  /* Loudness (bass boost) Support */
    133 #define AC97_BC_16BIT_DAC       0x0000  /* 16-bit DAC resolution */
    134 #define AC97_BC_18BIT_DAC       0x0040  /* 18-bit DAC resolution */
    135 #define AC97_BC_20BIT_DAC       0x0080  /* 20-bit DAC resolution */
    136 #define AC97_BC_DAC_MASK        0x00c0
    137 #define AC97_BC_16BIT_ADC       0x0000  /* 16-bit ADC resolution */
    138 #define AC97_BC_18BIT_ADC       0x0100  /* 18-bit ADC resolution */
    139 #define AC97_BC_20BIT_ADC       0x0200  /* 20-bit ADC resolution */
    140 #define AC97_BC_ADC_MASK        0x0300
    141 
    142 /* general purpose */
    143 #define AC97_GP_DRSS_MASK       0x0c00  /* double rate slot select */
    144 #define AC97_GP_DRSS_1011       0x0000  /* LR(C) 10+11(+12) */
    145 #define AC97_GP_DRSS_78         0x0400  /* LR 7+8 */
    146 
    147 /* powerdown bits */
    148 #define AC97_PD_ADC_STATUS      0x0001  /* ADC status (RO) */
    149 #define AC97_PD_DAC_STATUS      0x0002  /* DAC status (RO) */
    150 #define AC97_PD_MIXER_STATUS    0x0004  /* Analog mixer status (RO) */
    151 #define AC97_PD_VREF_STATUS     0x0008  /* Vref status (RO) */
    152 #define AC97_PD_PR0             0x0100  /* Power down PCM ADCs and input MUX */
    153 #define AC97_PD_PR1             0x0200  /* Power down PCM front DAC */
    154 #define AC97_PD_PR2             0x0400  /* Power down Mixer (Vref still on) */
    155 #define AC97_PD_PR3             0x0800  /* Power down Mixer (Vref off) */
    156 #define AC97_PD_PR4             0x1000  /* Power down AC-Link */
    157 #define AC97_PD_PR5             0x2000  /* Disable internal clock usage */
    158 #define AC97_PD_PR6             0x4000  /* Headphone amplifier */
    159 #define AC97_PD_EAPD            0x8000  /* External Amplifer Power Down (EAPD) */
    160 
    161 /* extended audio ID bit defines */
    162 #define AC97_EI_VRA             0x0001  /* Variable bit rate supported */
    163 #define AC97_EI_DRA             0x0002  /* Double rate supported */
    164 #define AC97_EI_SPDIF           0x0004  /* S/PDIF out supported */
    165 #define AC97_EI_VRM             0x0008  /* Variable bit rate supported for MIC */
    166 #define AC97_EI_DACS_SLOT_MASK  0x0030  /* DACs slot assignment */
    167 #define AC97_EI_DACS_SLOT_SHIFT 4
    168 #define AC97_EI_CDAC            0x0040  /* PCM Center DAC available */
    169 #define AC97_EI_SDAC            0x0080  /* PCM Surround DACs available */
    170 #define AC97_EI_LDAC            0x0100  /* PCM LFE DAC available */
    171 #define AC97_EI_AMAP            0x0200  /* indicates optional slot/DAC mapping based on codec ID */
    172 #define AC97_EI_REV_MASK        0x0c00  /* AC'97 revision mask */
    173 #define AC97_EI_REV_22          0x0400  /* AC'97 revision 2.2 */
    174 #define AC97_EI_REV_23          0x0800  /* AC'97 revision 2.3 */
    175 #define AC97_EI_REV_SHIFT       10
    176 #define AC97_EI_ADDR_MASK       0xc000  /* physical codec ID (address) */
    177 #define AC97_EI_ADDR_SHIFT      14
    178 
    179 /* extended audio status and control bit defines */
    180 #define AC97_EA_VRA             0x0001  /* Variable bit rate enable bit */
    181 #define AC97_EA_DRA             0x0002  /* Double-rate audio enable bit */
    182 #define AC97_EA_SPDIF           0x0004  /* S/PDIF out enable bit */
    183 #define AC97_EA_VRM             0x0008  /* Variable bit rate for MIC enable bit */
    184 #define AC97_EA_SPSA_SLOT_MASK  0x0030  /* Mask for slot assignment bits */
    185 #define AC97_EA_SPSA_SLOT_SHIFT 4
    186 #define AC97_EA_SPSA_3_4        0x0000  /* Slot assigned to 3 & 4 */
    187 #define AC97_EA_SPSA_7_8        0x0010  /* Slot assigned to 7 & 8 */
    188 #define AC97_EA_SPSA_6_9        0x0020  /* Slot assigned to 6 & 9 */
    189 #define AC97_EA_SPSA_10_11      0x0030  /* Slot assigned to 10 & 11 */
    190 #define AC97_EA_CDAC            0x0040  /* PCM Center DAC is ready (Read only) */
    191 #define AC97_EA_SDAC            0x0080  /* PCM Surround DACs are ready (Read only) */
    192 #define AC97_EA_LDAC            0x0100  /* PCM LFE DAC is ready (Read only) */
    193 #define AC97_EA_MDAC            0x0200  /* MIC ADC is ready (Read only) */
    194 #define AC97_EA_SPCV            0x0400  /* S/PDIF configuration valid (Read only) */
    195 #define AC97_EA_PRI             0x0800  /* Turns the PCM Center DAC off */
    196 #define AC97_EA_PRJ             0x1000  /* Turns the PCM Surround DACs off */
    197 #define AC97_EA_PRK             0x2000  /* Turns the PCM LFE DAC off */
    198 #define AC97_EA_PRL             0x4000  /* Turns the MIC ADC off */
    199 
    200 /* S/PDIF control bit defines */
    201 #define AC97_SC_PRO             0x0001  /* Professional status */
    202 #define AC97_SC_NAUDIO          0x0002  /* Non audio stream */
    203 #define AC97_SC_COPY            0x0004  /* Copyright status */
    204 #define AC97_SC_PRE             0x0008  /* Preemphasis status */
    205 #define AC97_SC_CC_MASK         0x07f0  /* Category Code mask */
    206 #define AC97_SC_CC_SHIFT        4
    207 #define AC97_SC_L               0x0800  /* Generation Level status */
    208 #define AC97_SC_SPSR_MASK       0x3000  /* S/PDIF Sample Rate bits */
    209 #define AC97_SC_SPSR_SHIFT      12
    210 #define AC97_SC_SPSR_44K        0x0000  /* Use 44.1kHz Sample rate */
    211 #define AC97_SC_SPSR_48K        0x2000  /* Use 48kHz Sample rate */
    212 #define AC97_SC_SPSR_32K        0x3000  /* Use 32kHz Sample rate */
    213 #define AC97_SC_DRS             0x4000  /* Double Rate S/PDIF */
    214 #define AC97_SC_V               0x8000  /* Validity status */
    215 
    216 /* Interrupt and Paging bit defines (AC'97 2.3) */
    217 #define AC97_PAGE_MASK          0x000f  /* Page Selector */
    218 #define AC97_PAGE_VENDOR        0       /* Vendor-specific registers */
    219 #define AC97_PAGE_1             1       /* Extended Codec Registers page 1 */
    220 #define AC97_INT_ENABLE         0x0800  /* Interrupt Enable */
    221 #define AC97_INT_SENSE          0x1000  /* Sense Cycle */
    222 #define AC97_INT_CAUSE_SENSE    0x2000  /* Sense Cycle Completed (RO) */
    223 #define AC97_INT_CAUSE_GPIO     0x4000  /* GPIO bits changed (RO) */
    224 #define AC97_INT_STATUS         0x8000  /* Interrupt Status */
    225 
    226 /* extended modem ID bit defines */
    227 #define AC97_MEI_LINE1          0x0001  /* Line1 present */
    228 #define AC97_MEI_LINE2          0x0002  /* Line2 present */
    229 #define AC97_MEI_HANDSET        0x0004  /* Handset present */
    230 #define AC97_MEI_CID1           0x0008  /* caller ID decode for Line1 is supported */
    231 #define AC97_MEI_CID2           0x0010  /* caller ID decode for Line2 is supported */
    232 #define AC97_MEI_ADDR_MASK      0xc000  /* physical codec ID (address) */
    233 #define AC97_MEI_ADDR_SHIFT     14
    234 
    235 /* extended modem status and control bit defines */
    236 #define AC97_MEA_GPIO           0x0001  /* GPIO is ready (ro) */
    237 #define AC97_MEA_MREF           0x0002  /* Vref is up to nominal level (ro) */
    238 #define AC97_MEA_ADC1           0x0004  /* ADC1 operational (ro) */
    239 #define AC97_MEA_DAC1           0x0008  /* DAC1 operational (ro) */
    240 #define AC97_MEA_ADC2           0x0010  /* ADC2 operational (ro) */
    241 #define AC97_MEA_DAC2           0x0020  /* DAC2 operational (ro) */
    242 #define AC97_MEA_HADC           0x0040  /* HADC operational (ro) */
    243 #define AC97_MEA_HDAC           0x0080  /* HDAC operational (ro) */
    244 #define AC97_MEA_PRA            0x0100  /* GPIO power down (high) */
    245 #define AC97_MEA_PRB            0x0200  /* reserved */
    246 #define AC97_MEA_PRC            0x0400  /* ADC1 power down (high) */
    247 #define AC97_MEA_PRD            0x0800  /* DAC1 power down (high) */
    248 #define AC97_MEA_PRE            0x1000  /* ADC2 power down (high) */
    249 #define AC97_MEA_PRF            0x2000  /* DAC2 power down (high) */
    250 #define AC97_MEA_PRG            0x4000  /* HADC power down (high) */
    251 #define AC97_MEA_PRH            0x8000  /* HDAC power down (high) */
    252 
    253 /* modem gpio status defines */
    254 #define AC97_GPIO_LINE1_OH      0x0001  /* Off Hook Line1 */
    255 #define AC97_GPIO_LINE1_RI      0x0002  /* Ring Detect Line1 */
    256 #define AC97_GPIO_LINE1_CID     0x0004  /* Caller ID path enable Line1 */
    257 #define AC97_GPIO_LINE1_LCS     0x0008  /* Loop Current Sense Line1 */
    258 #define AC97_GPIO_LINE1_PULSE   0x0010  /* Opt./ Pulse Dial Line1 (out) */
    259 #define AC97_GPIO_LINE1_HL1R    0x0020  /* Opt./ Handset to Line1 relay control (out) */
    260 #define AC97_GPIO_LINE1_HOHD    0x0040  /* Opt./ Handset off hook detect Line1 (in) */
    261 #define AC97_GPIO_LINE12_AC     0x0080  /* Opt./ Int.bit 1 / Line1/2 AC (out) */
    262 #define AC97_GPIO_LINE12_DC     0x0100  /* Opt./ Int.bit 2 / Line1/2 DC (out) */
    263 #define AC97_GPIO_LINE12_RS     0x0200  /* Opt./ Int.bit 3 / Line1/2 RS (out) */
    264 #define AC97_GPIO_LINE2_OH      0x0400  /* Off Hook Line2 */
    265 #define AC97_GPIO_LINE2_RI      0x0800  /* Ring Detect Line2 */
    266 #define AC97_GPIO_LINE2_CID     0x1000  /* Caller ID path enable Line2 */
    267 #define AC97_GPIO_LINE2_LCS     0x2000  /* Loop Current Sense Line2 */
    268 #define AC97_GPIO_LINE2_PULSE   0x4000  /* Opt./ Pulse Dial Line2 (out) */
    269 #define AC97_GPIO_LINE2_HL1R    0x8000  /* Opt./ Handset to Line2 relay control (out) */
    27023
    27124/* specific - SigmaTel */
     
    381134#define AC97_SCAP_NO_SPDIF      (1<<9)  /* don't build SPDIF controls */
    382135#define AC97_SCAP_EAPD_LED      (1<<10) /* EAPD as mute LED */
    383 #define AC97_SCAP_POWER_SAVE    (1<<11) /* capable for aggresive power-saving */
     136#define AC97_SCAP_POWER_SAVE    (1<<11) /* capable for aggressive power-saving */
    384137
    385138/* ac97->flags */
     
    413166#define AC97_RATES_SPDIF        5
    414167
     168#define AC97_NUM_GPIOS          16
    415169/*
    416170 *
     
    418172
    419173struct snd_ac97;
     174struct snd_ac97_gpio_priv;
     175struct snd_pcm_chmap;
    420176
    421177struct snd_ac97_build_ops {
     
    442198struct snd_ac97_bus {
    443199        /* -- lowlevel (hardware) driver specific -- */
    444         struct snd_ac97_bus_ops *ops;
     200        const struct snd_ac97_bus_ops *ops;
    445201        void *private_data;
    446202        void (*private_free) (struct snd_ac97_bus *bus);
     
    524280#endif
    525281        struct device dev;
     282        struct snd_ac97_gpio_priv *gpio_priv;
     283
     284        struct snd_pcm_chmap *chmaps[2]; /* channel-maps (optional) */
    526285};
    527286
     
    552311/* functions */
    553312/* create new AC97 bus */
    554 int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
     313int snd_ac97_bus(struct snd_card *card, int num,
     314                 const struct snd_ac97_bus_ops *ops,
    555315                 void *private_data, struct snd_ac97_bus **rbus);
    556316/* create mixer controls */
     
    577337void snd_ac97_resume(struct snd_ac97 *ac97);
    578338#endif
     339int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
     340        unsigned int id_mask);
    579341
    580342/* quirk types */
     
    601363};
    602364
    603 int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, const char *override);
     365int snd_ac97_tune_hardware(struct snd_ac97 *ac97,
     366                           const struct ac97_quirk *quirk,
     367                           const char *override);
    604368int snd_ac97_set_rate(struct snd_ac97 *ac97, int reg, unsigned int rate);
    605369
  • GPL/trunk/alsa-kernel/include/sound/ad1816a.h

    r426 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_AD1816A_H
    23#define __SOUND_AD1816A_H
     
    67    Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it>
    78
    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
    219*/
    2210
    23 #include "control.h"
    24 #include "pcm.h"
    25 #include "timer.h"
     11#include <sound/control.h>
     12#include <sound/pcm.h>
     13#include <sound/timer.h>
    2614
    2715#define AD1816A_REG(r)                  (chip->port + r)
     
    148136
    149137        struct snd_timer *timer;
     138#ifdef CONFIG_PM
     139        unsigned short image[48];
     140#endif
    150141};
    151142
     
    166157extern int snd_ad1816a_create(struct snd_card *card, unsigned long port,
    167158                              int irq, int dma1, int dma2,
    168                               struct snd_ad1816a **chip);
     159                              struct snd_ad1816a *chip);
    169160
    170 extern int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm);
     161extern int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device);
    171162extern int snd_ad1816a_mixer(struct snd_ad1816a *chip);
    172 extern int snd_ad1816a_timer(struct snd_ad1816a *chip, int device,
    173                              struct snd_timer **rtimer);
     163extern int snd_ad1816a_timer(struct snd_ad1816a *chip, int device);
     164#ifdef CONFIG_PM
     165extern void snd_ad1816a_suspend(struct snd_ad1816a *chip);
     166extern void snd_ad1816a_resume(struct snd_ad1816a *chip);
     167#endif
    174168
    175169#endif  /* __SOUND_AD1816A_H */
  • GPL/trunk/alsa-kernel/include/sound/ak4114.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_AK4114_H
    23#define __SOUND_AK4114_H
     
    56 *  Routines for Asahi Kasei AK4114
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     
    164149typedef unsigned char (ak4114_read_t)(void *private_data, unsigned char addr);
    165150
     151enum {
     152        AK4114_PARITY_ERRORS,
     153        AK4114_V_BIT_ERRORS,
     154        AK4114_QCRC_ERRORS,
     155        AK4114_CCRC_ERRORS,
     156        AK4114_NUM_ERRORS
     157};
     158
    166159struct ak4114 {
    167160        struct snd_card *card;
     
    169162        ak4114_read_t * read;
    170163        void * private_data;
    171         unsigned int init: 1;
     164        atomic_t wq_processing;
     165        struct mutex reinit_mutex;
    172166        spinlock_t lock;
    173         unsigned char regmap[7];
     167        unsigned char regmap[6];
    174168        unsigned char txcsb[5];
    175169        struct snd_kcontrol *kctls[AK4114_CONTROLS];
    176170        struct snd_pcm_substream *playback_substream;
    177171        struct snd_pcm_substream *capture_substream;
    178         unsigned long parity_errors;
    179         unsigned long v_bit_errors;
    180         unsigned long qcrc_errors;
    181         unsigned long ccrc_errors;
     172        unsigned long errors[AK4114_NUM_ERRORS];
    182173        unsigned char rcs0;
    183174        unsigned char rcs1;
     
    190181int snd_ak4114_create(struct snd_card *card,
    191182                      ak4114_read_t *read, ak4114_write_t *write,
    192                       const unsigned char pgm[7], const unsigned char txcsb[5],
     183                      const unsigned char pgm[6], const unsigned char txcsb[5],
    193184                      void *private_data, struct ak4114 **r_ak4114);
    194185void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val);
     
    200191int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags);
    201192
     193#ifdef CONFIG_PM
     194void snd_ak4114_suspend(struct ak4114 *chip);
     195void snd_ak4114_resume(struct ak4114 *chip);
     196#else
     197static inline void snd_ak4114_suspend(struct ak4114 *chip) {}
     198static inline void snd_ak4114_resume(struct ak4114 *chip) {}
     199#endif
     200
    202201#endif /* __SOUND_AK4114_H */
    203202
  • GPL/trunk/alsa-kernel/include/sound/ak4117.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_AK4117_H
    23#define __SOUND_AK4117_H
     
    56 *  Routines for Asahi Kasei AK4117
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     
    156141typedef unsigned char (ak4117_read_t)(void *private_data, unsigned char addr);
    157142
     143enum {
     144        AK4117_PARITY_ERRORS,
     145        AK4117_V_BIT_ERRORS,
     146        AK4117_QCRC_ERRORS,
     147        AK4117_CCRC_ERRORS,
     148        AK4117_NUM_ERRORS
     149};
     150
    158151struct ak4117 {
    159152        struct snd_card *card;
     
    166159        struct snd_kcontrol *kctls[AK4117_CONTROLS];
    167160        struct snd_pcm_substream *substream;
    168         unsigned long parity_errors;
    169         unsigned long v_bit_errors;
    170         unsigned long qcrc_errors;
    171         unsigned long ccrc_errors;
     161        unsigned long errors[AK4117_NUM_ERRORS];
    172162        unsigned char rcs0;
    173163        unsigned char rcs1;
  • GPL/trunk/alsa-kernel/include/sound/ak4531_codec.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_AK4531_CODEC_H
    23#define __SOUND_AK4531_CODEC_H
     
    89 *  For more details look to AC '97 component specification revision 2.1
    910 *  by Intel Corporation (http://developer.intel.com).
    10  *
    11  *
    12  *   This program is free software; you can redistribute it and/or modify
    13  *   it under the terms of the GNU General Public License as published by
    14  *   the Free Software Foundation; either version 2 of the License, or
    15  *   (at your option) any later version.
    16  *
    17  *   This program is distributed in the hope that it will be useful,
    18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  *   GNU General Public License for more details.
    21  *
    22  *   You should have received a copy of the GNU General Public License
    23  *   along with this program; if not, write to the Free Software
    24  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    25  *
    2611 */
    2712
    28 #include "info.h"
    29 #include "control.h"
     13#include <sound/info.h>
     14#include <sound/control.h>
    3015
    3116/*
  • GPL/trunk/alsa-kernel/include/sound/ak4xxx-adda.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_AK4XXX_ADDA_H
    23#define __SOUND_AK4XXX_ADDA_H
     
    78 *
    89 *      Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    2410 */     
    2511
  • GPL/trunk/alsa-kernel/include/sound/asequencer.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 *  Main header file for the ALSA sequencer
    34 *  Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
    45 *            (c) 1998-1999 by Jaroslav Kysela <perex@perex.cz>
    5  *
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    20  *
    216 */
    227#ifndef __SOUND_ASEQUENCER_H
    238#define __SOUND_ASEQUENCER_H
    249
    25 #ifdef __KERNEL__
    2610#include <linux/ioctl.h>
    2711#include <sound/asound.h>
    28 #endif
    29 
    30 /** version of the sequencer */
    31 #define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION (1, 0, 1)
    32 
    33 /**
    34  * definition of sequencer event types
    35  */
    36 
    37 /** system messages
    38  * event data type = #snd_seq_result
    39  */
    40 #define SNDRV_SEQ_EVENT_SYSTEM          0
    41 #define SNDRV_SEQ_EVENT_RESULT          1
    42 
    43 /** note messages (channel specific)
    44  * event data type = #snd_seq_ev_note
    45  */
    46 #define SNDRV_SEQ_EVENT_NOTE            5
    47 #define SNDRV_SEQ_EVENT_NOTEON          6
    48 #define SNDRV_SEQ_EVENT_NOTEOFF         7
    49 #define SNDRV_SEQ_EVENT_KEYPRESS        8
    50        
    51 /** control messages (channel specific)
    52  * event data type = #snd_seq_ev_ctrl
    53  */
    54 #define SNDRV_SEQ_EVENT_CONTROLLER      10
    55 #define SNDRV_SEQ_EVENT_PGMCHANGE       11
    56 #define SNDRV_SEQ_EVENT_CHANPRESS       12
    57 #define SNDRV_SEQ_EVENT_PITCHBEND       13      /**< from -8192 to 8191 */
    58 #define SNDRV_SEQ_EVENT_CONTROL14       14      /**< 14 bit controller value */
    59 #define SNDRV_SEQ_EVENT_NONREGPARAM     15      /**< 14 bit NRPN address + 14 bit unsigned value */
    60 #define SNDRV_SEQ_EVENT_REGPARAM        16      /**< 14 bit RPN address + 14 bit unsigned value */
    61 
    62 /** synchronisation messages
    63  * event data type = #snd_seq_ev_ctrl
    64  */
    65 #define SNDRV_SEQ_EVENT_SONGPOS         20      /* Song Position Pointer with LSB and MSB values */
    66 #define SNDRV_SEQ_EVENT_SONGSEL         21      /* Song Select with song ID number */
    67 #define SNDRV_SEQ_EVENT_QFRAME          22      /* midi time code quarter frame */
    68 #define SNDRV_SEQ_EVENT_TIMESIGN        23      /* SMF Time Signature event */
    69 #define SNDRV_SEQ_EVENT_KEYSIGN         24      /* SMF Key Signature event */
    70                
    71 /** timer messages
    72  * event data type = snd_seq_ev_queue_control
    73  */
    74 #define SNDRV_SEQ_EVENT_START           30      /* midi Real Time Start message */
    75 #define SNDRV_SEQ_EVENT_CONTINUE        31      /* midi Real Time Continue message */
    76 #define SNDRV_SEQ_EVENT_STOP            32      /* midi Real Time Stop message */       
    77 #define SNDRV_SEQ_EVENT_SETPOS_TICK     33      /* set tick queue position */
    78 #define SNDRV_SEQ_EVENT_SETPOS_TIME     34      /* set realtime queue position */
    79 #define SNDRV_SEQ_EVENT_TEMPO           35      /* (SMF) Tempo event */
    80 #define SNDRV_SEQ_EVENT_CLOCK           36      /* midi Real Time Clock message */
    81 #define SNDRV_SEQ_EVENT_TICK            37      /* midi Real Time Tick message */
    82 #define SNDRV_SEQ_EVENT_QUEUE_SKEW      38      /* skew queue tempo */
    83 
    84 /** others
    85  * event data type = none
    86  */
    87 #define SNDRV_SEQ_EVENT_TUNE_REQUEST    40      /* tune request */
    88 #define SNDRV_SEQ_EVENT_RESET           41      /* reset to power-on state */
    89 #define SNDRV_SEQ_EVENT_SENSING         42      /* "active sensing" event */
    90 
    91 /** echo back, kernel private messages
    92  * event data type = any type
    93  */
    94 #define SNDRV_SEQ_EVENT_ECHO            50      /* echo event */
    95 #define SNDRV_SEQ_EVENT_OSS             51      /* OSS raw event */
    96 
    97 /** system status messages (broadcast for subscribers)
    98  * event data type = snd_seq_addr
    99  */
    100 #define SNDRV_SEQ_EVENT_CLIENT_START    60      /* new client has connected */
    101 #define SNDRV_SEQ_EVENT_CLIENT_EXIT     61      /* client has left the system */
    102 #define SNDRV_SEQ_EVENT_CLIENT_CHANGE   62      /* client status/info has changed */
    103 #define SNDRV_SEQ_EVENT_PORT_START      63      /* new port was created */
    104 #define SNDRV_SEQ_EVENT_PORT_EXIT       64      /* port was deleted from system */
    105 #define SNDRV_SEQ_EVENT_PORT_CHANGE     65      /* port status/info has changed */
    106 
    107 /** port connection changes
    108  * event data type = snd_seq_connect
    109  */
    110 #define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66      /* ports connected */
    111 #define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67    /* ports disconnected */
    112 
    113 /* 70-89:  synthesizer events - obsoleted */
    114 
    115 /** user-defined events with fixed length
    116  * event data type = any
    117  */
    118 #define SNDRV_SEQ_EVENT_USR0            90
    119 #define SNDRV_SEQ_EVENT_USR1            91
    120 #define SNDRV_SEQ_EVENT_USR2            92
    121 #define SNDRV_SEQ_EVENT_USR3            93
    122 #define SNDRV_SEQ_EVENT_USR4            94
    123 #define SNDRV_SEQ_EVENT_USR5            95
    124 #define SNDRV_SEQ_EVENT_USR6            96
    125 #define SNDRV_SEQ_EVENT_USR7            97
    126 #define SNDRV_SEQ_EVENT_USR8            98
    127 #define SNDRV_SEQ_EVENT_USR9            99
    128 
    129 /* 100-118: instrument layer - obsoleted */
    130 /* 119-129: reserved */
    131 
    132 /* 130-139: variable length events
    133  * event data type = snd_seq_ev_ext
    134  * (SNDRV_SEQ_EVENT_LENGTH_VARIABLE must be set)
    135  */
    136 #define SNDRV_SEQ_EVENT_SYSEX           130     /* system exclusive data (variable length) */
    137 #define SNDRV_SEQ_EVENT_BOUNCE          131     /* error event */
    138 /* 132-134: reserved */
    139 #define SNDRV_SEQ_EVENT_USR_VAR0        135
    140 #define SNDRV_SEQ_EVENT_USR_VAR1        136
    141 #define SNDRV_SEQ_EVENT_USR_VAR2        137
    142 #define SNDRV_SEQ_EVENT_USR_VAR3        138
    143 #define SNDRV_SEQ_EVENT_USR_VAR4        139
    144 
    145 /* 150-151: kernel events with quote - DO NOT use in user clients */
    146 #define SNDRV_SEQ_EVENT_KERNEL_ERROR    150
    147 #define SNDRV_SEQ_EVENT_KERNEL_QUOTE    151     /* obsolete */
    148 
    149 /* 152-191: reserved */
    150 
    151 /* 192-254: hardware specific events */
    152 
    153 /* 255: special event */
    154 #define SNDRV_SEQ_EVENT_NONE            255
    155 
    156 
    157 typedef unsigned char snd_seq_event_type_t;
    158 
    159 /** event address */
    160 struct snd_seq_addr {
    161         unsigned char client;   /**< Client number:         0..255, 255 = broadcast to all clients */
    162         unsigned char port;     /**< Port within client:    0..255, 255 = broadcast to all ports */
    163 };
    164 
    165 /** port connection */
    166 struct snd_seq_connect {
    167         struct snd_seq_addr sender;
    168         struct snd_seq_addr dest;
    169 };
    170 
    171 
    172 #define SNDRV_SEQ_ADDRESS_UNKNOWN       253     /* unknown source */
    173 #define SNDRV_SEQ_ADDRESS_SUBSCRIBERS   254     /* send event to all subscribed ports */
    174 #define SNDRV_SEQ_ADDRESS_BROADCAST     255     /* send event to all queues/clients/ports/channels */
    175 #define SNDRV_SEQ_QUEUE_DIRECT          253     /* direct dispatch */
    176 
    177         /* event mode flag - NOTE: only 8 bits available! */
    178 #define SNDRV_SEQ_TIME_STAMP_TICK       (0<<0) /* timestamp in clock ticks */
    179 #define SNDRV_SEQ_TIME_STAMP_REAL       (1<<0) /* timestamp in real time */
    180 #define SNDRV_SEQ_TIME_STAMP_MASK       (1<<0)
    181 
    182 #define SNDRV_SEQ_TIME_MODE_ABS         (0<<1)  /* absolute timestamp */
    183 #define SNDRV_SEQ_TIME_MODE_REL         (1<<1)  /* relative to current time */
    184 #define SNDRV_SEQ_TIME_MODE_MASK        (1<<1)
    185 
    186 #define SNDRV_SEQ_EVENT_LENGTH_FIXED    (0<<2)  /* fixed event size */
    187 #define SNDRV_SEQ_EVENT_LENGTH_VARIABLE (1<<2)  /* variable event size */
    188 #define SNDRV_SEQ_EVENT_LENGTH_VARUSR   (2<<2)  /* variable event size - user memory space */
    189 #define SNDRV_SEQ_EVENT_LENGTH_MASK     (3<<2)
    190 
    191 #define SNDRV_SEQ_PRIORITY_NORMAL       (0<<4)  /* normal priority */
    192 #define SNDRV_SEQ_PRIORITY_HIGH         (1<<4)  /* event should be processed before others */
    193 #define SNDRV_SEQ_PRIORITY_MASK         (1<<4)
    194 
    195 
    196         /* note event */
    197 struct snd_seq_ev_note {
    198         unsigned char channel;
    199         unsigned char note;
    200         unsigned char velocity;
    201         unsigned char off_velocity;     /* only for SNDRV_SEQ_EVENT_NOTE */
    202         unsigned int duration;          /* only for SNDRV_SEQ_EVENT_NOTE */
    203 };
    204 
    205         /* controller event */
    206 struct snd_seq_ev_ctrl {
    207         unsigned char channel;
    208         unsigned char unused1, unused2, unused3;        /* pad */
    209         unsigned int param;
    210         signed int value;
    211 };
    212 
    213         /* generic set of bytes (12x8 bit) */
    214 struct snd_seq_ev_raw8 {
    215         unsigned char d[12];    /* 8 bit value */
    216 };
    217 
    218         /* generic set of integers (3x32 bit) */
    219 struct snd_seq_ev_raw32 {
    220         unsigned int d[3];      /* 32 bit value */
    221 };
    222 
    223         /* external stored data */
    224 #ifndef TARGET_OS2
    225 struct snd_seq_ev_ext {
    226         unsigned int len;       /* length of data */
    227         void *ptr;              /* pointer to data (note: maybe 64-bit) */
    228 } __attribute__((packed));
    229 #else
    230 #pragma pack(1)
    231 struct snd_seq_ev_ext {
    232         unsigned int len;       /* length of data */
    233         void *ptr;              /* pointer to data (note: maybe 64-bit) */
    234 };
    235 #pragma pack()
    236 #endif
    237 struct snd_seq_result {
    238         int event;              /* processed event type */
    239         int result;
    240 };
    241 
    242 
    243 struct snd_seq_real_time {
    244         unsigned int tv_sec;    /* seconds */
    245         unsigned int tv_nsec;   /* nanoseconds */
    246 };
    247 
    248 typedef unsigned int snd_seq_tick_time_t;       /* midi ticks */
    249 
    250 union snd_seq_timestamp {
    251         snd_seq_tick_time_t tick;
    252         struct snd_seq_real_time time;
    253 };
    254 
    255 struct snd_seq_queue_skew {
    256         unsigned int value;
    257         unsigned int base;
    258 };
    259 
    260         /* queue timer control */
    261 struct snd_seq_ev_queue_control {
    262         unsigned char queue;                    /* affected queue */
    263         unsigned char pad[3];                   /* reserved */
    264         union {
    265                 signed int value;               /* affected value (e.g. tempo) */
    266                 union snd_seq_timestamp time;   /* time */
    267                 unsigned int position;          /* sync position */
    268                 struct snd_seq_queue_skew skew;
    269                 unsigned int d32[2];
    270                 unsigned char d8[8];
    271         } param;
    272 };
    273 
    274         /* quoted event - inside the kernel only */
    275 #ifndef TARGET_OS2
    276 struct snd_seq_ev_quote {
    277         struct snd_seq_addr origin;             /* original sender */
    278         unsigned short value;           /* optional data */
    279         struct snd_seq_event *event;            /* quoted event */
    280 } __attribute__((packed));
    281 #else
    282 #pragma pack(1)
    283 struct snd_seq_ev_quote {
    284         struct snd_seq_addr origin;             /* original sender */
    285         unsigned short value;           /* optional data */
    286         struct snd_seq_event *event;            /* quoted event */
    287 };
    288 #pragma pack()
    289 #endif
    290 
    291         /* sequencer event */
    292 struct snd_seq_event {
    293         snd_seq_event_type_t type;      /* event type */
    294         unsigned char flags;            /* event flags */
    295         char tag;
    296        
    297         unsigned char queue;            /* schedule queue */
    298         union snd_seq_timestamp time;   /* schedule time */
    299 
    300 
    301         struct snd_seq_addr source;     /* source address */
    302         struct snd_seq_addr dest;       /* destination address */
    303 
    304         union {                         /* event data... */
    305                 struct snd_seq_ev_note note;
    306                 struct snd_seq_ev_ctrl control;
    307                 struct snd_seq_ev_raw8 raw8;
    308                 struct snd_seq_ev_raw32 raw32;
    309                 struct snd_seq_ev_ext ext;
    310                 struct snd_seq_ev_queue_control queue;
    311                 union snd_seq_timestamp time;
    312                 struct snd_seq_addr addr;
    313                 struct snd_seq_connect connect;
    314                 struct snd_seq_result result;
    315                 struct snd_seq_ev_quote quote;
    316         } data;
    317 };
    318 
    319 
    320 /*
    321  * bounce event - stored as variable size data
    322  */
    323 struct snd_seq_event_bounce {
    324         int err;
    325         struct snd_seq_event event;
    326         /* external data follows here. */
    327 };
    328 
    329 #ifdef __KERNEL__
     12#include <uapi/sound/asequencer.h>
    33013
    33114/* helper macro */
     
    38669#define snd_seq_queue_sync_port(q)      ((q) + 16)
    38770
    388 #endif /* __KERNEL__ */
    389 
    390         /* system information */
    391 struct snd_seq_system_info {
    392         int queues;                     /* maximum queues count */
    393         int clients;                    /* maximum clients count */
    394         int ports;                      /* maximum ports per client */
    395         int channels;                   /* maximum channels per port */
    396         int cur_clients;                /* current clients */
    397         int cur_queues;                 /* current queues */
    398         char reserved[24];
    399 };
    400 
    401 
    402         /* system running information */
    403 struct snd_seq_running_info {
    404         unsigned char client;           /* client id */
    405         unsigned char big_endian;       /* 1 = big-endian */
    406         unsigned char cpu_mode;         /* 4 = 32bit, 8 = 64bit */
    407         unsigned char pad;              /* reserved */
    408         unsigned char reserved[12];
    409 };
    410 
    411 
    412         /* known client numbers */
    413 #define SNDRV_SEQ_CLIENT_SYSTEM         0
    414         /* internal client numbers */
    415 #define SNDRV_SEQ_CLIENT_DUMMY          14      /* midi through */
    416 #define SNDRV_SEQ_CLIENT_OSS            15      /* oss sequencer emulator */
    417 
    418 
    419         /* client types */
    420 typedef int __bitwise snd_seq_client_type_t;
    421 #define NO_CLIENT       ((__force snd_seq_client_type_t) 0)
    422 #define USER_CLIENT     ((__force snd_seq_client_type_t) 1)
    423 #define KERNEL_CLIENT   ((__force snd_seq_client_type_t) 2)
    424                        
    425         /* event filter flags */
    426 #define SNDRV_SEQ_FILTER_BROADCAST      (1<<0)  /* accept broadcast messages */
    427 #define SNDRV_SEQ_FILTER_MULTICAST      (1<<1)  /* accept multicast messages */
    428 #define SNDRV_SEQ_FILTER_BOUNCE         (1<<2)  /* accept bounce event in error */
    429 #define SNDRV_SEQ_FILTER_USE_EVENT      (1<<31) /* use event filter */
    430 
    431 struct snd_seq_client_info {
    432         int client;                     /* client number to inquire */
    433         snd_seq_client_type_t type;     /* client type */
    434         char name[64];                  /* client name */
    435         unsigned int filter;            /* filter flags */
    436         unsigned char multicast_filter[8]; /* multicast filter bitmap */
    437         unsigned char event_filter[32]; /* event filter bitmap */
    438         int num_ports;                  /* RO: number of ports */
    439         int event_lost;                 /* number of lost events */
    440         char reserved[64];              /* for future use */
    441 };
    442 
    443 
    444 /* client pool size */
    445 struct snd_seq_client_pool {
    446         int client;                     /* client number to inquire */
    447         int output_pool;                /* outgoing (write) pool size */
    448         int input_pool;                 /* incoming (read) pool size */
    449         int output_room;                /* minimum free pool size for select/blocking mode */
    450         int output_free;                /* unused size */
    451         int input_free;                 /* unused size */
    452         char reserved[64];
    453 };
    454 
    455 
    456 /* Remove events by specified criteria */
    457 
    458 #define SNDRV_SEQ_REMOVE_INPUT          (1<<0)  /* Flush input queues */
    459 #define SNDRV_SEQ_REMOVE_OUTPUT         (1<<1)  /* Flush output queues */
    460 #define SNDRV_SEQ_REMOVE_DEST           (1<<2)  /* Restrict by destination q:client:port */
    461 #define SNDRV_SEQ_REMOVE_DEST_CHANNEL   (1<<3)  /* Restrict by channel */
    462 #define SNDRV_SEQ_REMOVE_TIME_BEFORE    (1<<4)  /* Restrict to before time */
    463 #define SNDRV_SEQ_REMOVE_TIME_AFTER     (1<<5)  /* Restrict to time or after */
    464 #define SNDRV_SEQ_REMOVE_TIME_TICK      (1<<6)  /* Time is in ticks */
    465 #define SNDRV_SEQ_REMOVE_EVENT_TYPE     (1<<7)  /* Restrict to event type */
    466 #define SNDRV_SEQ_REMOVE_IGNORE_OFF     (1<<8)  /* Do not flush off events */
    467 #define SNDRV_SEQ_REMOVE_TAG_MATCH      (1<<9)  /* Restrict to events with given tag */
    468 
    469 struct snd_seq_remove_events {
    470         unsigned int  remove_mode;      /* Flags that determine what gets removed */
    471 
    472         union snd_seq_timestamp time;
    473 
    474         unsigned char queue;    /* Queue for REMOVE_DEST */
    475         struct snd_seq_addr dest;       /* Address for REMOVE_DEST */
    476         unsigned char channel;  /* Channel for REMOVE_DEST */
    477 
    478         int  type;      /* For REMOVE_EVENT_TYPE */
    479         char  tag;      /* Tag for REMOVE_TAG */
    480 
    481         int  reserved[10];      /* To allow for future binary compatibility */
    482 
    483 };
    484 
    485 
    486         /* known port numbers */
    487 #define SNDRV_SEQ_PORT_SYSTEM_TIMER     0
    488 #define SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE  1
    489 
    490         /* port capabilities (32 bits) */
    491 #define SNDRV_SEQ_PORT_CAP_READ         (1<<0)  /* readable from this port */
    492 #define SNDRV_SEQ_PORT_CAP_WRITE        (1<<1)  /* writable to this port */
    493 
    494 #define SNDRV_SEQ_PORT_CAP_SYNC_READ    (1<<2)
    495 #define SNDRV_SEQ_PORT_CAP_SYNC_WRITE   (1<<3)
    496 
    497 #define SNDRV_SEQ_PORT_CAP_DUPLEX       (1<<4)
    498 
    499 #define SNDRV_SEQ_PORT_CAP_SUBS_READ    (1<<5)  /* allow read subscription */
    500 #define SNDRV_SEQ_PORT_CAP_SUBS_WRITE   (1<<6)  /* allow write subscription */
    501 #define SNDRV_SEQ_PORT_CAP_NO_EXPORT    (1<<7)  /* routing not allowed */
    502 
    503         /* port type */
    504 #define SNDRV_SEQ_PORT_TYPE_SPECIFIC    (1<<0)  /* hardware specific */
    505 #define SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /* generic MIDI device */
    506 #define SNDRV_SEQ_PORT_TYPE_MIDI_GM     (1<<2)  /* General MIDI compatible device */
    507 #define SNDRV_SEQ_PORT_TYPE_MIDI_GS     (1<<3)  /* GS compatible device */
    508 #define SNDRV_SEQ_PORT_TYPE_MIDI_XG     (1<<4)  /* XG compatible device */
    509 #define SNDRV_SEQ_PORT_TYPE_MIDI_MT32   (1<<5)  /* MT-32 compatible device */
    510 #define SNDRV_SEQ_PORT_TYPE_MIDI_GM2    (1<<6)  /* General MIDI 2 compatible device */
    511 
    512 /* other standards...*/
    513 #define SNDRV_SEQ_PORT_TYPE_SYNTH       (1<<10) /* Synth device (no MIDI compatible - direct wavetable) */
    514 #define SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11)       /* Sampling device (support sample download) */
    515 #define SNDRV_SEQ_PORT_TYPE_SAMPLE      (1<<12) /* Sampling device (sample can be downloaded at any time) */
    516 /*...*/
    517 #define SNDRV_SEQ_PORT_TYPE_HARDWARE    (1<<16) /* driver for a hardware device */
    518 #define SNDRV_SEQ_PORT_TYPE_SOFTWARE    (1<<17) /* implemented in software */
    519 #define SNDRV_SEQ_PORT_TYPE_SYNTHESIZER (1<<18) /* generates sound */
    520 #define SNDRV_SEQ_PORT_TYPE_PORT        (1<<19) /* connects to other device(s) */
    521 #define SNDRV_SEQ_PORT_TYPE_APPLICATION (1<<20) /* application (sequencer/editor) */
    522 
    523 /* misc. conditioning flags */
    524 #define SNDRV_SEQ_PORT_FLG_GIVEN_PORT   (1<<0)
    525 #define SNDRV_SEQ_PORT_FLG_TIMESTAMP    (1<<1)
    526 #define SNDRV_SEQ_PORT_FLG_TIME_REAL    (1<<2)
    527 
    528 struct snd_seq_port_info {
    529         struct snd_seq_addr addr;       /* client/port numbers */
    530         char name[64];                  /* port name */
    531 
    532         unsigned int capability;        /* port capability bits */
    533         unsigned int type;              /* port type bits */
    534         int midi_channels;              /* channels per MIDI port */
    535         int midi_voices;                /* voices per MIDI port */
    536         int synth_voices;               /* voices per SYNTH port */
    537 
    538         int read_use;                   /* R/O: subscribers for output (from this port) */
    539         int write_use;                  /* R/O: subscribers for input (to this port) */
    540 
    541         void *kernel;                   /* reserved for kernel use (must be NULL) */
    542         unsigned int flags;             /* misc. conditioning */
    543         unsigned char time_queue;       /* queue # for timestamping */
    544         char reserved[59];              /* for future use */
    545 };
    546 
    547 
    548 /* queue flags */
    549 #define SNDRV_SEQ_QUEUE_FLG_SYNC        (1<<0)  /* sync enabled */
    550 
    551 /* queue information */
    552 struct snd_seq_queue_info {
    553         int queue;              /* queue id */
    554 
    555         /*
    556          *  security settings, only owner of this queue can start/stop timer
    557          *  etc. if the queue is locked for other clients
    558          */
    559         int owner;              /* client id for owner of the queue */
    560         unsigned locked:1;      /* timing queue locked for other queues */
    561         char name[64];          /* name of this queue */
    562         unsigned int flags;     /* flags */
    563         char reserved[60];      /* for future use */
    564 
    565 };
    566 
    567 /* queue info/status */
    568 struct snd_seq_queue_status {
    569         int queue;                      /* queue id */
    570         int events;                     /* read-only - queue size */
    571         snd_seq_tick_time_t tick;       /* current tick */
    572         struct snd_seq_real_time time;  /* current time */
    573         int running;                    /* running state of queue */
    574         int flags;                      /* various flags */
    575         char reserved[64];              /* for the future */
    576 };
    577 
    578 
    579 /* queue tempo */
    580 struct snd_seq_queue_tempo {
    581         int queue;                      /* sequencer queue */
    582         unsigned int tempo;             /* current tempo, us/tick */
    583         int ppq;                        /* time resolution, ticks/quarter */
    584         unsigned int skew_value;        /* queue skew */
    585         unsigned int skew_base;         /* queue skew base */
    586         char reserved[24];              /* for the future */
    587 };
    588 
    589 
    590 /* sequencer timer sources */
    591 #define SNDRV_SEQ_TIMER_ALSA            0       /* ALSA timer */
    592 #define SNDRV_SEQ_TIMER_MIDI_CLOCK      1       /* Midi Clock (CLOCK event) */
    593 #define SNDRV_SEQ_TIMER_MIDI_TICK       2       /* Midi Timer Tick (TICK event) */
    594 
    595 /* queue timer info */
    596 struct snd_seq_queue_timer {
    597         int queue;                      /* sequencer queue */
    598         int type;                       /* source timer type */
    599         union {
    600                 struct {
    601                         struct snd_timer_id id; /* ALSA's timer ID */
    602                         unsigned int resolution;        /* resolution in Hz */
    603                 } alsa;
    604         } u;
    605         char reserved[64];              /* for the future use */
    606 };
    607 
    608 
    609 struct snd_seq_queue_client {
    610         int queue;              /* sequencer queue */
    611         int client;             /* sequencer client */
    612         int used;               /* queue is used with this client
    613                                    (must be set for accepting events) */
    614         /* per client watermarks */
    615         char reserved[64];      /* for future use */
    616 };
    617 
    618 
    619 #define SNDRV_SEQ_PORT_SUBS_EXCLUSIVE   (1<<0)  /* exclusive connection */
    620 #define SNDRV_SEQ_PORT_SUBS_TIMESTAMP   (1<<1)
    621 #define SNDRV_SEQ_PORT_SUBS_TIME_REAL   (1<<2)
    622 
    623 struct snd_seq_port_subscribe {
    624         struct snd_seq_addr sender;     /* sender address */
    625         struct snd_seq_addr dest;       /* destination address */
    626         unsigned int voices;            /* number of voices to be allocated (0 = don't care) */
    627         unsigned int flags;             /* modes */
    628         unsigned char queue;            /* input time-stamp queue (optional) */
    629         unsigned char pad[3];           /* reserved */
    630         char reserved[64];
    631 };
    632 
    633 /* type of query subscription */
    634 #define SNDRV_SEQ_QUERY_SUBS_READ       0
    635 #define SNDRV_SEQ_QUERY_SUBS_WRITE      1
    636 
    637 struct snd_seq_query_subs {
    638         struct snd_seq_addr root;       /* client/port id to be searched */
    639         int type;               /* READ or WRITE */
    640         int index;              /* 0..N-1 */
    641         int num_subs;           /* R/O: number of subscriptions on this port */
    642         struct snd_seq_addr addr;       /* R/O: result */
    643         unsigned char queue;    /* R/O: result */
    644         unsigned int flags;     /* R/O: result */
    645         char reserved[64];      /* for future use */
    646 };
    647 
    648 
    649 /*
    650  *  IOCTL commands
    651  */
    652 
    653 #define SNDRV_SEQ_IOCTL_PVERSION        _IOR ('S', 0x00, int)
    654 #define SNDRV_SEQ_IOCTL_CLIENT_ID       _IOR ('S', 0x01, int)
    655 #define SNDRV_SEQ_IOCTL_SYSTEM_INFO     _IOWR('S', 0x02, struct snd_seq_system_info)
    656 #define SNDRV_SEQ_IOCTL_RUNNING_MODE    _IOWR('S', 0x03, struct snd_seq_running_info)
    657 
    658 #define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO _IOWR('S', 0x10, struct snd_seq_client_info)
    659 #define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO _IOW ('S', 0x11, struct snd_seq_client_info)
    660 
    661 #define SNDRV_SEQ_IOCTL_CREATE_PORT     _IOWR('S', 0x20, struct snd_seq_port_info)
    662 #define SNDRV_SEQ_IOCTL_DELETE_PORT     _IOW ('S', 0x21, struct snd_seq_port_info)
    663 #define SNDRV_SEQ_IOCTL_GET_PORT_INFO   _IOWR('S', 0x22, struct snd_seq_port_info)
    664 #define SNDRV_SEQ_IOCTL_SET_PORT_INFO   _IOW ('S', 0x23, struct snd_seq_port_info)
    665 
    666 #define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT  _IOW ('S', 0x30, struct snd_seq_port_subscribe)
    667 #define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct snd_seq_port_subscribe)
    668 
    669 #define SNDRV_SEQ_IOCTL_CREATE_QUEUE    _IOWR('S', 0x32, struct snd_seq_queue_info)
    670 #define SNDRV_SEQ_IOCTL_DELETE_QUEUE    _IOW ('S', 0x33, struct snd_seq_queue_info)
    671 #define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO  _IOWR('S', 0x34, struct snd_seq_queue_info)
    672 #define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO  _IOWR('S', 0x35, struct snd_seq_queue_info)
    673 #define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE _IOWR('S', 0x36, struct snd_seq_queue_info)
    674 #define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct snd_seq_queue_status)
    675 #define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO _IOWR('S', 0x41, struct snd_seq_queue_tempo)
    676 #define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO _IOW ('S', 0x42, struct snd_seq_queue_tempo)
    677 #define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER _IOWR('S', 0x43, struct snd_seq_queue_owner)
    678 #define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER _IOW ('S', 0x44, struct snd_seq_queue_owner)
    679 #define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER _IOWR('S', 0x45, struct snd_seq_queue_timer)
    680 #define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER _IOW ('S', 0x46, struct snd_seq_queue_timer)
    681 /* XXX
    682 #define SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC  _IOWR('S', 0x53, struct snd_seq_queue_sync)
    683 #define SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC  _IOW ('S', 0x54, struct snd_seq_queue_sync)
    684 */
    685 #define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT        _IOWR('S', 0x49, struct snd_seq_queue_client)
    686 #define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT        _IOW ('S', 0x4a, struct snd_seq_queue_client)
    687 #define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL _IOWR('S', 0x4b, struct snd_seq_client_pool)
    688 #define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL _IOW ('S', 0x4c, struct snd_seq_client_pool)
    689 #define SNDRV_SEQ_IOCTL_REMOVE_EVENTS   _IOW ('S', 0x4e, struct snd_seq_remove_events)
    690 #define SNDRV_SEQ_IOCTL_QUERY_SUBS      _IOWR('S', 0x4f, struct snd_seq_query_subs)
    691 #define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION        _IOWR('S', 0x50, struct snd_seq_port_subscribe)
    692 #define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT       _IOWR('S', 0x51, struct snd_seq_client_info)
    693 #define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT _IOWR('S', 0x52, struct snd_seq_port_info)
    694 
    69571#endif /* __SOUND_ASEQUENCER_H */
  • GPL/trunk/alsa-kernel/include/sound/asound.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 *  Advanced Linux Sound Architecture - ALSA - Driver
    34 *  Copyright (c) 1994-2003 by Jaroslav Kysela <perex@perex.cz>,
    45 *                             Abramo Bagnara <abramo@alsa-project.org>
    5  *
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    20  *
    216 */
    22 
    237#ifndef __SOUND_ASOUND_H
    248#define __SOUND_ASOUND_H
    259
    26 #include <linux/types.h>
    27 
    28 #ifdef __KERNEL__
    2910#include <linux/ioctl.h>
    3011#include <linux/time.h>
    3112#include <asm/byteorder.h>
     13
    3214#ifdef  __LITTLE_ENDIAN
    3315#define SNDRV_LITTLE_ENDIAN
     
    4022#endif
    4123
    42 #endif /* __KERNEL__ **/
    43 
    44 #ifndef __force
    45 #define __force
    46 #endif
    47 
    48 #ifndef __bitwise
    49 #define __bitwise
    50 #endif
    51 
    52 #ifdef TARGET_OS2
    53 #define SNDRV_PCM_VOL_FRONT_LEFT        0
    54 #define SNDRV_PCM_VOL_FRONT_RIGHT       1
    55 #define SNDRV_PCM_VOL_REAR_LEFT         2
    56 #define SNDRV_PCM_VOL_REAR_RIGHT        3
    57 #define SNDRV_PCM_VOL_CENTER            4
    58 #define SNDRV_PCM_VOL_LFE               5
    59 
    60 #define SNDRV_PCM_VOL_MAX               100
    61 
    62 struct snd_pcm_volume {
    63         int nrchannels;
    64         int volume[6];
    65 };
    66 #endif
    67 
    68 /*
    69  *  protocol version
    70  */
    71 
    72 #define SNDRV_PROTOCOL_VERSION(major, minor, subminor) (((major)<<16)|((minor)<<8)|(subminor))
    73 #define SNDRV_PROTOCOL_MAJOR(version) (((version)>>16)&0xffff)
    74 #define SNDRV_PROTOCOL_MINOR(version) (((version)>>8)&0xff)
    75 #define SNDRV_PROTOCOL_MICRO(version) ((version)&0xff)
    76 #define SNDRV_PROTOCOL_INCOMPATIBLE(kversion, uversion) \
    77         (SNDRV_PROTOCOL_MAJOR(kversion) != SNDRV_PROTOCOL_MAJOR(uversion) || \
    78          (SNDRV_PROTOCOL_MAJOR(kversion) == SNDRV_PROTOCOL_MAJOR(uversion) && \
    79            SNDRV_PROTOCOL_MINOR(kversion) != SNDRV_PROTOCOL_MINOR(uversion)))
    80 
    81 /****************************************************************************
    82  *                                                                          *
    83  *        Digital audio interface                                           *
    84  *                                                                          *
    85  ****************************************************************************/
    86 
    87 struct snd_aes_iec958 {
    88         unsigned char status[24];       /* AES/IEC958 channel status bits */
    89         unsigned char subcode[147];     /* AES/IEC958 subcode bits */
    90         unsigned char pad;              /* nothing */
    91         unsigned char dig_subframe[4];  /* AES/IEC958 subframe bits */
    92 };
    93 
    94 /****************************************************************************
    95  *                                                                          *
    96  *      Section for driver hardware dependent interface - /dev/snd/hw?      *
    97  *                                                                          *
    98  ****************************************************************************/
    99 
    100 #define SNDRV_HWDEP_VERSION             SNDRV_PROTOCOL_VERSION(1, 0, 1)
    101 
    102 enum {
    103         SNDRV_HWDEP_IFACE_OPL2 = 0,
    104         SNDRV_HWDEP_IFACE_OPL3,
    105         SNDRV_HWDEP_IFACE_OPL4,
    106         SNDRV_HWDEP_IFACE_SB16CSP,      /* Creative Signal Processor */
    107         SNDRV_HWDEP_IFACE_EMU10K1,      /* FX8010 processor in EMU10K1 chip */
    108         SNDRV_HWDEP_IFACE_YSS225,       /* Yamaha FX processor */
    109         SNDRV_HWDEP_IFACE_ICS2115,      /* Wavetable synth */
    110         SNDRV_HWDEP_IFACE_SSCAPE,       /* Ensoniq SoundScape ISA card (MC68EC000) */
    111         SNDRV_HWDEP_IFACE_VX,           /* Digigram VX cards */
    112         SNDRV_HWDEP_IFACE_MIXART,       /* Digigram miXart cards */
    113         SNDRV_HWDEP_IFACE_USX2Y,        /* Tascam US122, US224 & US428 usb */
    114         SNDRV_HWDEP_IFACE_EMUX_WAVETABLE, /* EmuX wavetable */ 
    115         SNDRV_HWDEP_IFACE_BLUETOOTH,    /* Bluetooth audio */
    116         SNDRV_HWDEP_IFACE_USX2Y_PCM,    /* Tascam US122, US224 & US428 rawusb pcm */
    117         SNDRV_HWDEP_IFACE_PCXHR,        /* Digigram PCXHR */
    118         SNDRV_HWDEP_IFACE_SB_RC,        /* SB Extigy/Audigy2NX remote control */
    119         SNDRV_HWDEP_IFACE_HDA,          /* HD-audio */
    120         SNDRV_HWDEP_IFACE_USB_STREAM,   /* direct access to usb stream */
    121 
    122         /* Don't forget to change the following: */
    123         SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USB_STREAM
    124 };
    125 
    126 struct snd_hwdep_info {
    127         unsigned int device;            /* WR: device number */
    128         int card;                       /* R: card number */
    129         unsigned char id[64];           /* ID (user selectable) */
    130         unsigned char name[80];         /* hwdep name */
    131         int iface;                      /* hwdep interface */
    132         unsigned char reserved[64];     /* reserved for future */
    133 };
    134 
    135 /* generic DSP loader */
    136 struct snd_hwdep_dsp_status {
    137         unsigned int version;           /* R: driver-specific version */
    138         unsigned char id[32];           /* R: driver-specific ID string */
    139         unsigned int num_dsps;          /* R: number of DSP images to transfer */
    140         unsigned int dsp_loaded;        /* R: bit flags indicating the loaded DSPs */
    141         unsigned int chip_ready;        /* R: 1 = initialization finished */
    142         unsigned char reserved[16];     /* reserved for future use */
    143 };
    144 
    145 struct snd_hwdep_dsp_image {
    146         unsigned int index;             /* W: DSP index */
    147         unsigned char name[64];         /* W: ID (e.g. file name) */
    148         unsigned char __user *image;    /* W: binary image */
    149         size_t length;                  /* W: size of image in bytes */
    150         unsigned long driver_data;      /* W: driver-specific data */
    151 };
    152 
    153 #define SNDRV_HWDEP_IOCTL_PVERSION      _IOR ('H', 0x00, int)
    154 #define SNDRV_HWDEP_IOCTL_INFO          _IOR ('H', 0x01, struct snd_hwdep_info)
    155 #define SNDRV_HWDEP_IOCTL_DSP_STATUS    _IOR('H', 0x02, struct snd_hwdep_dsp_status)
    156 #define SNDRV_HWDEP_IOCTL_DSP_LOAD      _IOW('H', 0x03, struct snd_hwdep_dsp_image)
    157 
    158 /*****************************************************************************
    159  *                                                                           *
    160  *             Digital Audio (PCM) interface - /dev/snd/pcm??                *
    161  *                                                                           *
    162  *****************************************************************************/
    163 
    164 #define SNDRV_PCM_VERSION               SNDRV_PROTOCOL_VERSION(2, 0, 10)
    165 
    166 typedef unsigned long snd_pcm_uframes_t;
    167 typedef signed long snd_pcm_sframes_t;
    168 
    169 enum {
    170         SNDRV_PCM_CLASS_GENERIC = 0,    /* standard mono or stereo device */
    171         SNDRV_PCM_CLASS_MULTI,          /* multichannel device */
    172         SNDRV_PCM_CLASS_MODEM,          /* software modem class */
    173         SNDRV_PCM_CLASS_DIGITIZER,      /* digitizer class */
    174         /* Don't forget to change the following: */
    175         SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER,
    176 };
    177 
    178 enum {
    179         SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, /* mono or stereo subdevices are mixed together */
    180         SNDRV_PCM_SUBCLASS_MULTI_MIX,   /* multichannel subdevices are mixed together */
    181         /* Don't forget to change the following: */
    182         SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX,
    183 };
    184 
    185 enum {
    186         SNDRV_PCM_STREAM_PLAYBACK = 0,
    187         SNDRV_PCM_STREAM_CAPTURE,
    188         SNDRV_PCM_STREAM_LAST = SNDRV_PCM_STREAM_CAPTURE,
    189 };
    190 
    191 typedef int __bitwise snd_pcm_access_t;
    192 #define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED       ((__force snd_pcm_access_t) 0) /* interleaved mmap */
    193 #define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED    ((__force snd_pcm_access_t) 1) /* noninterleaved mmap */
    194 #define SNDRV_PCM_ACCESS_MMAP_COMPLEX           ((__force snd_pcm_access_t) 2) /* complex mmap */
    195 #define SNDRV_PCM_ACCESS_RW_INTERLEAVED         ((__force snd_pcm_access_t) 3) /* readi/writei */
    196 #define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED      ((__force snd_pcm_access_t) 4) /* readn/writen */
    197 #define SNDRV_PCM_ACCESS_LAST           SNDRV_PCM_ACCESS_RW_NONINTERLEAVED
    198 
    199 typedef int __bitwise snd_pcm_format_t;
    200 #define SNDRV_PCM_FORMAT_S8     ((__force snd_pcm_format_t) 0)
    201 #define SNDRV_PCM_FORMAT_U8     ((__force snd_pcm_format_t) 1)
    202 #define SNDRV_PCM_FORMAT_S16_LE ((__force snd_pcm_format_t) 2)
    203 #define SNDRV_PCM_FORMAT_S16_BE ((__force snd_pcm_format_t) 3)
    204 #define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4)
    205 #define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5)
    206 #define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6) /* low three bytes */
    207 #define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) /* low three bytes */
    208 #define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) /* low three bytes */
    209 #define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) /* low three bytes */
    210 #define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10)
    211 #define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11)
    212 #define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12)
    213 #define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13)
    214 #define SNDRV_PCM_FORMAT_FLOAT_LE       ((__force snd_pcm_format_t) 14) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
    215 #define SNDRV_PCM_FORMAT_FLOAT_BE       ((__force snd_pcm_format_t) 15) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
    216 #define SNDRV_PCM_FORMAT_FLOAT64_LE     ((__force snd_pcm_format_t) 16) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
    217 #define SNDRV_PCM_FORMAT_FLOAT64_BE     ((__force snd_pcm_format_t) 17) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
    218 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18) /* IEC-958 subframe, Little Endian */
    219 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19) /* IEC-958 subframe, Big Endian */
    220 #define SNDRV_PCM_FORMAT_MU_LAW         ((__force snd_pcm_format_t) 20)
    221 #define SNDRV_PCM_FORMAT_A_LAW          ((__force snd_pcm_format_t) 21)
    222 #define SNDRV_PCM_FORMAT_IMA_ADPCM      ((__force snd_pcm_format_t) 22)
    223 #define SNDRV_PCM_FORMAT_MPEG           ((__force snd_pcm_format_t) 23)
    224 #define SNDRV_PCM_FORMAT_GSM            ((__force snd_pcm_format_t) 24)
    225 #define SNDRV_PCM_FORMAT_SPECIAL        ((__force snd_pcm_format_t) 31)
    226 #define SNDRV_PCM_FORMAT_S24_3LE        ((__force snd_pcm_format_t) 32) /* in three bytes */
    227 #define SNDRV_PCM_FORMAT_S24_3BE        ((__force snd_pcm_format_t) 33) /* in three bytes */
    228 #define SNDRV_PCM_FORMAT_U24_3LE        ((__force snd_pcm_format_t) 34) /* in three bytes */
    229 #define SNDRV_PCM_FORMAT_U24_3BE        ((__force snd_pcm_format_t) 35) /* in three bytes */
    230 #define SNDRV_PCM_FORMAT_S20_3LE        ((__force snd_pcm_format_t) 36) /* in three bytes */
    231 #define SNDRV_PCM_FORMAT_S20_3BE        ((__force snd_pcm_format_t) 37) /* in three bytes */
    232 #define SNDRV_PCM_FORMAT_U20_3LE        ((__force snd_pcm_format_t) 38) /* in three bytes */
    233 #define SNDRV_PCM_FORMAT_U20_3BE        ((__force snd_pcm_format_t) 39) /* in three bytes */
    234 #define SNDRV_PCM_FORMAT_S18_3LE        ((__force snd_pcm_format_t) 40) /* in three bytes */
    235 #define SNDRV_PCM_FORMAT_S18_3BE        ((__force snd_pcm_format_t) 41) /* in three bytes */
    236 #define SNDRV_PCM_FORMAT_U18_3LE        ((__force snd_pcm_format_t) 42) /* in three bytes */
    237 #define SNDRV_PCM_FORMAT_U18_3BE        ((__force snd_pcm_format_t) 43) /* in three bytes */
    238 #define SNDRV_PCM_FORMAT_G723_24        ((__force snd_pcm_format_t) 44) /* 8 samples in 3 bytes */
    239 #define SNDRV_PCM_FORMAT_G723_24_1B     ((__force snd_pcm_format_t) 45) /* 1 sample in 1 byte */
    240 #define SNDRV_PCM_FORMAT_G723_40        ((__force snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */
    241 #define SNDRV_PCM_FORMAT_G723_40_1B     ((__force snd_pcm_format_t) 47) /* 1 sample in 1 byte */
    242 #define SNDRV_PCM_FORMAT_LAST           SNDRV_PCM_FORMAT_G723_40_1B
    243 
    244 #ifdef SNDRV_LITTLE_ENDIAN
    245 #define SNDRV_PCM_FORMAT_S16            SNDRV_PCM_FORMAT_S16_LE
    246 #define SNDRV_PCM_FORMAT_U16            SNDRV_PCM_FORMAT_U16_LE
    247 #define SNDRV_PCM_FORMAT_S24            SNDRV_PCM_FORMAT_S24_LE
    248 #define SNDRV_PCM_FORMAT_U24            SNDRV_PCM_FORMAT_U24_LE
    249 #define SNDRV_PCM_FORMAT_S32            SNDRV_PCM_FORMAT_S32_LE
    250 #define SNDRV_PCM_FORMAT_U32            SNDRV_PCM_FORMAT_U32_LE
    251 #define SNDRV_PCM_FORMAT_FLOAT          SNDRV_PCM_FORMAT_FLOAT_LE
    252 #define SNDRV_PCM_FORMAT_FLOAT64        SNDRV_PCM_FORMAT_FLOAT64_LE
    253 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
    254 #endif
    255 #ifdef SNDRV_BIG_ENDIAN
    256 #define SNDRV_PCM_FORMAT_S16            SNDRV_PCM_FORMAT_S16_BE
    257 #define SNDRV_PCM_FORMAT_U16            SNDRV_PCM_FORMAT_U16_BE
    258 #define SNDRV_PCM_FORMAT_S24            SNDRV_PCM_FORMAT_S24_BE
    259 #define SNDRV_PCM_FORMAT_U24            SNDRV_PCM_FORMAT_U24_BE
    260 #define SNDRV_PCM_FORMAT_S32            SNDRV_PCM_FORMAT_S32_BE
    261 #define SNDRV_PCM_FORMAT_U32            SNDRV_PCM_FORMAT_U32_BE
    262 #define SNDRV_PCM_FORMAT_FLOAT          SNDRV_PCM_FORMAT_FLOAT_BE
    263 #define SNDRV_PCM_FORMAT_FLOAT64        SNDRV_PCM_FORMAT_FLOAT64_BE
    264 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE
    265 #endif
    266 
    267 typedef int __bitwise snd_pcm_subformat_t;
    268 #define SNDRV_PCM_SUBFORMAT_STD         ((__force snd_pcm_subformat_t) 0)
    269 #define SNDRV_PCM_SUBFORMAT_LAST        SNDRV_PCM_SUBFORMAT_STD
    270 
    271 #define SNDRV_PCM_INFO_MMAP             0x00000001      /* hardware supports mmap */
    272 #define SNDRV_PCM_INFO_MMAP_VALID       0x00000002      /* period data are valid during transfer */
    273 #define SNDRV_PCM_INFO_DOUBLE           0x00000004      /* Double buffering needed for PCM start/stop */
    274 #define SNDRV_PCM_INFO_BATCH            0x00000010      /* double buffering */
    275 #define SNDRV_PCM_INFO_INTERLEAVED      0x00000100      /* channels are interleaved */
    276 #define SNDRV_PCM_INFO_NONINTERLEAVED   0x00000200      /* channels are not interleaved */
    277 #define SNDRV_PCM_INFO_COMPLEX          0x00000400      /* complex frame organization (mmap only) */
    278 #define SNDRV_PCM_INFO_BLOCK_TRANSFER   0x00010000      /* hardware transfer block of samples */
    279 #define SNDRV_PCM_INFO_OVERRANGE        0x00020000      /* hardware supports ADC (capture) overrange detection */
    280 #define SNDRV_PCM_INFO_RESUME           0x00040000      /* hardware supports stream resume after suspend */
    281 #define SNDRV_PCM_INFO_PAUSE            0x00080000      /* pause ioctl is supported */
    282 #define SNDRV_PCM_INFO_HALF_DUPLEX      0x00100000      /* only half duplex */
    283 #define SNDRV_PCM_INFO_JOINT_DUPLEX     0x00200000      /* playback and capture stream are somewhat correlated */
    284 #define SNDRV_PCM_INFO_SYNC_START       0x00400000      /* pcm support some kind of sync go */
    285 #define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000      /* period wakeup can be disabled */
    286 #define SNDRV_PCM_INFO_FIFO_IN_FRAMES   0x80000000      /* internal kernel flag - FIFO size is in frames */
    287 
    288 typedef int __bitwise snd_pcm_state_t;
    289 #define SNDRV_PCM_STATE_OPEN            ((__force snd_pcm_state_t) 0) /* stream is open */
    290 #define SNDRV_PCM_STATE_SETUP           ((__force snd_pcm_state_t) 1) /* stream has a setup */
    291 #define SNDRV_PCM_STATE_PREPARED        ((__force snd_pcm_state_t) 2) /* stream is ready to start */
    292 #define SNDRV_PCM_STATE_RUNNING         ((__force snd_pcm_state_t) 3) /* stream is running */
    293 #define SNDRV_PCM_STATE_XRUN            ((__force snd_pcm_state_t) 4) /* stream reached an xrun */
    294 #define SNDRV_PCM_STATE_DRAINING        ((__force snd_pcm_state_t) 5) /* stream is draining */
    295 #define SNDRV_PCM_STATE_PAUSED          ((__force snd_pcm_state_t) 6) /* stream is paused */
    296 #define SNDRV_PCM_STATE_SUSPENDED       ((__force snd_pcm_state_t) 7) /* hardware is suspended */
    297 #define SNDRV_PCM_STATE_DISCONNECTED    ((__force snd_pcm_state_t) 8) /* hardware is disconnected */
    298 #define SNDRV_PCM_STATE_LAST            SNDRV_PCM_STATE_DISCONNECTED
    299 
    300 enum {
    301         SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
    302         SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000,
    303         SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000,
    304 };
    305 
    306 union snd_pcm_sync_id {
    307         unsigned char id[16];
    308         unsigned short id16[8];
    309         unsigned int id32[4];
    310 };
    311 
    312 struct snd_pcm_info {
    313         unsigned int device;            /* RO/WR (control): device number */
    314         unsigned int subdevice;         /* RO/WR (control): subdevice number */
    315         int stream;                     /* RO/WR (control): stream direction */
    316         int card;                       /* R: card number */
    317         unsigned char id[64];           /* ID (user selectable) */
    318         unsigned char name[80];         /* name of this device */
    319         unsigned char subname[32];      /* subdevice name */
    320         int dev_class;                  /* SNDRV_PCM_CLASS_* */
    321         int dev_subclass;               /* SNDRV_PCM_SUBCLASS_* */
    322         unsigned int subdevices_count;
    323         unsigned int subdevices_avail;
    324         union snd_pcm_sync_id sync;     /* hardware synchronization ID */
    325         unsigned char reserved[64];     /* reserved for future... */
    326 };
    327 
    328 typedef int snd_pcm_hw_param_t;
    329 #define SNDRV_PCM_HW_PARAM_ACCESS       0       /* Access type */
    330 #ifdef TARGET_OS2
    331 #define SNDRV_PCM_HW_PARAM_RATE_MASK    1 /* Format */
    332 #endif
    333 #define SNDRV_PCM_HW_PARAM_FORMAT       2       /* Format */
    334 #define SNDRV_PCM_HW_PARAM_SUBFORMAT    3       /* Subformat */
    335 #define SNDRV_PCM_HW_PARAM_FIRST_MASK   SNDRV_PCM_HW_PARAM_ACCESS
    336 #define SNDRV_PCM_HW_PARAM_LAST_MASK    SNDRV_PCM_HW_PARAM_SUBFORMAT
    337 
    338 #define SNDRV_PCM_HW_PARAM_SAMPLE_BITS  8       /* Bits per sample */
    339 #define SNDRV_PCM_HW_PARAM_FRAME_BITS   9       /* Bits per frame */
    340 #define SNDRV_PCM_HW_PARAM_CHANNELS     10      /* Channels */
    341 #define SNDRV_PCM_HW_PARAM_RATE         11      /* Approx rate */
    342 #define SNDRV_PCM_HW_PARAM_PERIOD_TIME  12      /* Approx distance between
    343                                                  * interrupts in us
    344                                                  */
    345 #define SNDRV_PCM_HW_PARAM_PERIOD_SIZE  13      /* Approx frames between
    346                                                  * interrupts
    347                                                  */
    348 #define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14      /* Approx bytes between
    349                                                  * interrupts
    350                                                  */
    351 #define SNDRV_PCM_HW_PARAM_PERIODS      15      /* Approx interrupts per
    352                                                  * buffer
    353                                                  */
    354 #define SNDRV_PCM_HW_PARAM_BUFFER_TIME  16      /* Approx duration of buffer
    355                                                  * in us
    356                                                  */
    357 #define SNDRV_PCM_HW_PARAM_BUFFER_SIZE  17      /* Size of buffer in frames */
    358 #define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18      /* Size of buffer in bytes */
    359 #define SNDRV_PCM_HW_PARAM_TICK_TIME    19      /* Approx tick duration in us */
    360 #define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL       SNDRV_PCM_HW_PARAM_SAMPLE_BITS
    361 #define SNDRV_PCM_HW_PARAM_LAST_INTERVAL        SNDRV_PCM_HW_PARAM_TICK_TIME
    362 
    363 #define SNDRV_PCM_HW_PARAMS_NORESAMPLE  (1<<0)  /* avoid rate resampling */
    364 #define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER       (1<<1)  /* export buffer */
    365 #define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP    (1<<2)  /* disable period wakeups */
    366 
    367 struct snd_interval {
    368         unsigned int min, max;
    369         unsigned int openmin:1,
    370                      openmax:1,
    371                      integer:1,
    372                      empty:1;
    373 };
    374 
    375 #define SNDRV_MASK_MAX  256
    376 
    377 struct snd_mask {
    378         __u32 bits[(SNDRV_MASK_MAX+31)/32];
    379 };
    380 
    381 struct snd_pcm_hw_params {
    382         unsigned int flags;
    383         struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
    384                                SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
    385         struct snd_mask mres[5];        /* reserved masks */
    386         struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
    387                                         SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
    388         struct snd_interval ires[9];    /* reserved intervals */
    389         unsigned int rmask;             /* W: requested masks */
    390         unsigned int cmask;             /* R: changed masks */
    391         unsigned int info;              /* R: Info flags for returned setup */
    392         unsigned int msbits;            /* R: used most significant bits */
    393         unsigned int rate_num;          /* R: rate numerator */
    394         unsigned int rate_den;          /* R: rate denominator */
    395         snd_pcm_uframes_t fifo_size;    /* R: chip FIFO size in frames */
    396         unsigned char reserved[64];     /* reserved for future */
    397 };
    398 
    399 enum {
    400         SNDRV_PCM_TSTAMP_NONE = 0,
    401         SNDRV_PCM_TSTAMP_ENABLE,
    402         SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE,
    403 };
    404 
    405 struct snd_pcm_sw_params {
    406         int tstamp_mode;                        /* timestamp mode */
    407         unsigned int period_step;
    408         unsigned int sleep_min;                 /* min ticks to sleep */
    409         snd_pcm_uframes_t avail_min;            /* min avail frames for wakeup */
    410         snd_pcm_uframes_t xfer_align;           /* obsolete: xfer size need to be a multiple */
    411         snd_pcm_uframes_t start_threshold;      /* min hw_avail frames for automatic start */
    412         snd_pcm_uframes_t stop_threshold;       /* min avail frames for automatic stop */
    413         snd_pcm_uframes_t silence_threshold;    /* min distance from noise for silence filling */
    414         snd_pcm_uframes_t silence_size;         /* silence block size */
    415         snd_pcm_uframes_t boundary;             /* pointers wrap point */
    416         unsigned char reserved[64];             /* reserved for future */
    417 };
    418 
    419 struct snd_pcm_channel_info {
    420         unsigned int channel;
    421         __kernel_off_t offset;          /* mmap offset */
    422         unsigned int first;             /* offset to first sample in bits */
    423         unsigned int step;              /* samples distance in bits */
    424 };
    425 
    426 struct snd_pcm_status {
    427         snd_pcm_state_t state;          /* stream state */
    428         struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */
    429         struct timespec tstamp;         /* reference timestamp */
    430         snd_pcm_uframes_t appl_ptr;     /* appl ptr */
    431         snd_pcm_uframes_t hw_ptr;       /* hw ptr */
    432         snd_pcm_sframes_t delay;        /* current delay in frames */
    433         snd_pcm_uframes_t avail;        /* number of frames available */
    434         snd_pcm_uframes_t avail_max;    /* max frames available on hw since last status */
    435         snd_pcm_uframes_t overrange;    /* count of ADC (capture) overrange detections from last status */
    436         snd_pcm_state_t suspended_state; /* suspended stream state */
    437         unsigned char reserved[60];     /* must be filled with zero */
    438 };
    439 
    440 struct snd_pcm_mmap_status {
    441         snd_pcm_state_t state;          /* RO: state - SNDRV_PCM_STATE_XXXX */
    442         int pad1;                       /* Needed for 64 bit alignment */
    443         snd_pcm_uframes_t hw_ptr;       /* RO: hw ptr (0...boundary-1) */
    444         struct timespec tstamp;         /* Timestamp */
    445         snd_pcm_state_t suspended_state; /* RO: suspended stream state */
    446 };
    447 
    448 struct snd_pcm_mmap_control {
    449         snd_pcm_uframes_t appl_ptr;     /* RW: appl ptr (0...boundary-1) */
    450         snd_pcm_uframes_t avail_min;    /* RW: min available frames for wakeup */
    451 };
    452 
    453 #define SNDRV_PCM_SYNC_PTR_HWSYNC       (1<<0)  /* execute hwsync */
    454 #define SNDRV_PCM_SYNC_PTR_APPL         (1<<1)  /* get appl_ptr from driver (r/w op) */
    455 #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN    (1<<2)  /* get avail_min from driver */
    456 
    457 struct snd_pcm_sync_ptr {
    458         unsigned int flags;
    459         union {
    460                 struct snd_pcm_mmap_status status;
    461                 unsigned char reserved[64];
    462         } s;
    463         union {
    464                 struct snd_pcm_mmap_control control;
    465                 unsigned char reserved[64];
    466         } c;
    467 };
    468 
    469 struct snd_xferi {
    470         snd_pcm_sframes_t result;
    471         void __user *buf;
    472         snd_pcm_uframes_t frames;
    473 };
    474 
    475 struct snd_xfern {
    476         snd_pcm_sframes_t result;
    477         void __user * __user *bufs;
    478         snd_pcm_uframes_t frames;
    479 };
    480 
    481 enum {
    482         SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /* gettimeofday equivalent */
    483         SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,        /* posix_clock_monotonic equivalent */
    484         SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,
    485 };
    486 
    487 #define SNDRV_PCM_IOCTL_PVERSION        _IOR('A', 0x00, int)
    488 #define SNDRV_PCM_IOCTL_INFO            _IOR('A', 0x01, struct snd_pcm_info)
    489 #define SNDRV_PCM_IOCTL_TSTAMP          _IOW('A', 0x02, int)
    490 #define SNDRV_PCM_IOCTL_TTSTAMP         _IOW('A', 0x03, int)
    491 #define SNDRV_PCM_IOCTL_HW_REFINE       _IOWR('A', 0x10, struct snd_pcm_hw_params)
    492 #define SNDRV_PCM_IOCTL_HW_PARAMS       _IOWR('A', 0x11, struct snd_pcm_hw_params)
    493 #define SNDRV_PCM_IOCTL_HW_FREE         _IO('A', 0x12)
    494 #define SNDRV_PCM_IOCTL_SW_PARAMS       _IOWR('A', 0x13, struct snd_pcm_sw_params)
    495 #define SNDRV_PCM_IOCTL_STATUS          _IOR('A', 0x20, struct snd_pcm_status)
    496 #define SNDRV_PCM_IOCTL_DELAY           _IOR('A', 0x21, snd_pcm_sframes_t)
    497 #define SNDRV_PCM_IOCTL_HWSYNC          _IO('A', 0x22)
    498 #define SNDRV_PCM_IOCTL_SYNC_PTR        _IOWR('A', 0x23, struct snd_pcm_sync_ptr)
    499 #define SNDRV_PCM_IOCTL_CHANNEL_INFO    _IOR('A', 0x32, struct snd_pcm_channel_info)
    500 #define SNDRV_PCM_IOCTL_PREPARE         _IO('A', 0x40)
    501 #define SNDRV_PCM_IOCTL_RESET           _IO('A', 0x41)
    502 #define SNDRV_PCM_IOCTL_START           _IO('A', 0x42)
    503 #define SNDRV_PCM_IOCTL_DROP            _IO('A', 0x43)
    504 #define SNDRV_PCM_IOCTL_DRAIN           _IO('A', 0x44)
    505 #define SNDRV_PCM_IOCTL_PAUSE           _IOW('A', 0x45, int)
    506 #define SNDRV_PCM_IOCTL_REWIND          _IOW('A', 0x46, snd_pcm_uframes_t)
    507 #define SNDRV_PCM_IOCTL_RESUME          _IO('A', 0x47)
    508 #define SNDRV_PCM_IOCTL_XRUN            _IO('A', 0x48)
    509 #define SNDRV_PCM_IOCTL_FORWARD         _IOW('A', 0x49, snd_pcm_uframes_t)
    510 #define SNDRV_PCM_IOCTL_WRITEI_FRAMES   _IOW('A', 0x50, struct snd_xferi)
    511 #define SNDRV_PCM_IOCTL_READI_FRAMES    _IOR('A', 0x51, struct snd_xferi)
    512 #define SNDRV_PCM_IOCTL_WRITEN_FRAMES   _IOW('A', 0x52, struct snd_xfern)
    513 #define SNDRV_PCM_IOCTL_READN_FRAMES    _IOR('A', 0x53, struct snd_xfern)
    514 #define SNDRV_PCM_IOCTL_LINK            _IOW('A', 0x60, int)
    515 #define SNDRV_PCM_IOCTL_UNLINK          _IO('A', 0x61)
    516 
    517 /*****************************************************************************
    518  *                                                                           *
    519  *                            MIDI v1.0 interface                            *
    520  *                                                                           *
    521  *****************************************************************************/
    522 
    523 /*
    524  *  Raw MIDI section - /dev/snd/midi??
    525  */
    526 
    527 #define SNDRV_RAWMIDI_VERSION           SNDRV_PROTOCOL_VERSION(2, 0, 0)
    528 
    529 enum {
    530         SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
    531         SNDRV_RAWMIDI_STREAM_INPUT,
    532         SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT,
    533 };
    534 
    535 #define SNDRV_RAWMIDI_INFO_OUTPUT               0x00000001
    536 #define SNDRV_RAWMIDI_INFO_INPUT                0x00000002
    537 #define SNDRV_RAWMIDI_INFO_DUPLEX               0x00000004
    538 
    539 struct snd_rawmidi_info {
    540         unsigned int device;            /* RO/WR (control): device number */
    541         unsigned int subdevice;         /* RO/WR (control): subdevice number */
    542         int stream;                     /* WR: stream */
    543         int card;                       /* R: card number */
    544         unsigned int flags;             /* SNDRV_RAWMIDI_INFO_XXXX */
    545         unsigned char id[64];           /* ID (user selectable) */
    546         unsigned char name[80];         /* name of device */
    547         unsigned char subname[32];      /* name of active or selected subdevice */
    548         unsigned int subdevices_count;
    549         unsigned int subdevices_avail;
    550         unsigned char reserved[64];     /* reserved for future use */
    551 };
    552 
    553 struct snd_rawmidi_params {
    554         int stream;
    555         size_t buffer_size;             /* queue size in bytes */
    556         size_t avail_min;               /* minimum avail bytes for wakeup */
    557         unsigned int no_active_sensing: 1; /* do not send active sensing byte in close() */
    558         unsigned char reserved[16];     /* reserved for future use */
    559 };
    560 
    561 struct snd_rawmidi_status {
    562         int stream;
    563         struct timespec tstamp;         /* Timestamp */
    564         size_t avail;                   /* available bytes */
    565         size_t xruns;                   /* count of overruns since last status (in bytes) */
    566         unsigned char reserved[16];     /* reserved for future use */
    567 };
    568 
    569 #define SNDRV_RAWMIDI_IOCTL_PVERSION    _IOR('W', 0x00, int)
    570 #define SNDRV_RAWMIDI_IOCTL_INFO        _IOR('W', 0x01, struct snd_rawmidi_info)
    571 #define SNDRV_RAWMIDI_IOCTL_PARAMS      _IOWR('W', 0x10, struct snd_rawmidi_params)
    572 #define SNDRV_RAWMIDI_IOCTL_STATUS      _IOWR('W', 0x20, struct snd_rawmidi_status)
    573 #define SNDRV_RAWMIDI_IOCTL_DROP        _IOW('W', 0x30, int)
    574 #define SNDRV_RAWMIDI_IOCTL_DRAIN       _IOW('W', 0x31, int)
    575 
    576 /*
    577  *  Timer section - /dev/snd/timer
    578  */
    579 
    580 #define SNDRV_TIMER_VERSION             SNDRV_PROTOCOL_VERSION(2, 0, 6)
    581 
    582 enum {
    583         SNDRV_TIMER_CLASS_NONE = -1,
    584         SNDRV_TIMER_CLASS_SLAVE = 0,
    585         SNDRV_TIMER_CLASS_GLOBAL,
    586         SNDRV_TIMER_CLASS_CARD,
    587         SNDRV_TIMER_CLASS_PCM,
    588         SNDRV_TIMER_CLASS_LAST = SNDRV_TIMER_CLASS_PCM,
    589 };
    590 
    591 /* slave timer classes */
    592 enum {
    593         SNDRV_TIMER_SCLASS_NONE = 0,
    594         SNDRV_TIMER_SCLASS_APPLICATION,
    595         SNDRV_TIMER_SCLASS_SEQUENCER,           /* alias */
    596         SNDRV_TIMER_SCLASS_OSS_SEQUENCER,       /* alias */
    597         SNDRV_TIMER_SCLASS_LAST = SNDRV_TIMER_SCLASS_OSS_SEQUENCER,
    598 };
    599 
    600 /* global timers (device member) */
    601 #define SNDRV_TIMER_GLOBAL_SYSTEM       0
    602 #define SNDRV_TIMER_GLOBAL_RTC          1
    603 #define SNDRV_TIMER_GLOBAL_HPET         2
    604 #define SNDRV_TIMER_GLOBAL_HRTIMER      3
    605 
    606 /* info flags */
    607 #define SNDRV_TIMER_FLG_SLAVE           (1<<0)  /* cannot be controlled */
    608 
    609 struct snd_timer_id {
    610         int dev_class;
    611         int dev_sclass;
    612         int card;
    613         int device;
    614         int subdevice;
    615 };
    616 
    617 struct snd_timer_ginfo {
    618         struct snd_timer_id tid;        /* requested timer ID */
    619         unsigned int flags;             /* timer flags - SNDRV_TIMER_FLG_* */
    620         int card;                       /* card number */
    621         unsigned char id[64];           /* timer identification */
    622         unsigned char name[80];         /* timer name */
    623         unsigned long reserved0;        /* reserved for future use */
    624         unsigned long resolution;       /* average period resolution in ns */
    625         unsigned long resolution_min;   /* minimal period resolution in ns */
    626         unsigned long resolution_max;   /* maximal period resolution in ns */
    627         unsigned int clients;           /* active timer clients */
    628         unsigned char reserved[32];
    629 };
    630 
    631 struct snd_timer_gparams {
    632         struct snd_timer_id tid;        /* requested timer ID */
    633         unsigned long period_num;       /* requested precise period duration (in seconds) - numerator */
    634         unsigned long period_den;       /* requested precise period duration (in seconds) - denominator */
    635         unsigned char reserved[32];
    636 };
    637 
    638 struct snd_timer_gstatus {
    639         struct snd_timer_id tid;        /* requested timer ID */
    640         unsigned long resolution;       /* current period resolution in ns */
    641         unsigned long resolution_num;   /* precise current period resolution (in seconds) - numerator */
    642         unsigned long resolution_den;   /* precise current period resolution (in seconds) - denominator */
    643         unsigned char reserved[32];
    644 };
    645 
    646 struct snd_timer_select {
    647         struct snd_timer_id id; /* bind to timer ID */
    648         unsigned char reserved[32];     /* reserved */
    649 };
    650 
    651 struct snd_timer_info {
    652         unsigned int flags;             /* timer flags - SNDRV_TIMER_FLG_* */
    653         int card;                       /* card number */
    654         unsigned char id[64];           /* timer identificator */
    655         unsigned char name[80];         /* timer name */
    656         unsigned long reserved0;        /* reserved for future use */
    657         unsigned long resolution;       /* average period resolution in ns */
    658         unsigned char reserved[64];     /* reserved */
    659 };
    660 
    661 #define SNDRV_TIMER_PSFLG_AUTO          (1<<0)  /* auto start, otherwise one-shot */
    662 #define SNDRV_TIMER_PSFLG_EXCLUSIVE     (1<<1)  /* exclusive use, precise start/stop/pause/continue */
    663 #define SNDRV_TIMER_PSFLG_EARLY_EVENT   (1<<2)  /* write early event to the poll queue */
    664 
    665 struct snd_timer_params {
    666         unsigned int flags;             /* flags - SNDRV_MIXER_PSFLG_* */
    667         unsigned int ticks;             /* requested resolution in ticks */
    668         unsigned int queue_size;        /* total size of queue (32-1024) */
    669         unsigned int reserved0;         /* reserved, was: failure locations */
    670         unsigned int filter;            /* event filter (bitmask of SNDRV_TIMER_EVENT_*) */
    671         unsigned char reserved[60];     /* reserved */
    672 };
    673 
    674 struct snd_timer_status {
    675         struct timespec tstamp;         /* Timestamp - last update */
    676         unsigned int resolution;        /* current period resolution in ns */
    677         unsigned int lost;              /* counter of master tick lost */
    678         unsigned int overrun;           /* count of read queue overruns */
    679         unsigned int queue;             /* used queue size */
    680         unsigned char reserved[64];     /* reserved */
    681 };
    682 
    683 #define SNDRV_TIMER_IOCTL_PVERSION      _IOR('T', 0x00, int)
    684 #define SNDRV_TIMER_IOCTL_NEXT_DEVICE   _IOWR('T', 0x01, struct snd_timer_id)
    685 #define SNDRV_TIMER_IOCTL_TREAD         _IOW('T', 0x02, int)
    686 #define SNDRV_TIMER_IOCTL_GINFO         _IOWR('T', 0x03, struct snd_timer_ginfo)
    687 #define SNDRV_TIMER_IOCTL_GPARAMS       _IOW('T', 0x04, struct snd_timer_gparams)
    688 #define SNDRV_TIMER_IOCTL_GSTATUS       _IOWR('T', 0x05, struct snd_timer_gstatus)
    689 #define SNDRV_TIMER_IOCTL_SELECT        _IOW('T', 0x10, struct snd_timer_select)
    690 #define SNDRV_TIMER_IOCTL_INFO          _IOR('T', 0x11, struct snd_timer_info)
    691 #define SNDRV_TIMER_IOCTL_PARAMS        _IOW('T', 0x12, struct snd_timer_params)
    692 #define SNDRV_TIMER_IOCTL_STATUS        _IOR('T', 0x14, struct snd_timer_status)
    693 /* The following four ioctls are changed since 1.0.9 due to confliction */
    694 #define SNDRV_TIMER_IOCTL_START         _IO('T', 0xa0)
    695 #define SNDRV_TIMER_IOCTL_STOP          _IO('T', 0xa1)
    696 #define SNDRV_TIMER_IOCTL_CONTINUE      _IO('T', 0xa2)
    697 #define SNDRV_TIMER_IOCTL_PAUSE         _IO('T', 0xa3)
    698 
    699 struct snd_timer_read {
    700         unsigned int resolution;
    701         unsigned int ticks;
    702 };
    703 
    704 enum {
    705         SNDRV_TIMER_EVENT_RESOLUTION = 0,       /* val = resolution in ns */
    706         SNDRV_TIMER_EVENT_TICK,                 /* val = ticks */
    707         SNDRV_TIMER_EVENT_START,                /* val = resolution in ns */
    708         SNDRV_TIMER_EVENT_STOP,                 /* val = 0 */
    709         SNDRV_TIMER_EVENT_CONTINUE,             /* val = resolution in ns */
    710         SNDRV_TIMER_EVENT_PAUSE,                /* val = 0 */
    711         SNDRV_TIMER_EVENT_EARLY,                /* val = 0, early event */
    712         SNDRV_TIMER_EVENT_SUSPEND,              /* val = 0 */
    713         SNDRV_TIMER_EVENT_RESUME,               /* val = resolution in ns */
    714         /* master timer events for slave timer instances */
    715         SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
    716         SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10,
    717         SNDRV_TIMER_EVENT_MCONTINUE = SNDRV_TIMER_EVENT_CONTINUE + 10,
    718         SNDRV_TIMER_EVENT_MPAUSE = SNDRV_TIMER_EVENT_PAUSE + 10,
    719         SNDRV_TIMER_EVENT_MSUSPEND = SNDRV_TIMER_EVENT_SUSPEND + 10,
    720         SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10,
    721 };
    722 
    723 struct snd_timer_tread {
    724         int event;
    725         struct timespec tstamp;
    726         unsigned int val;
    727 };
    728 
    729 /****************************************************************************
    730  *                                                                          *
    731  *        Section for driver control interface - /dev/snd/control?          *
    732  *                                                                          *
    733  ****************************************************************************/
    734 
    735 #define SNDRV_CTL_VERSION               SNDRV_PROTOCOL_VERSION(2, 0, 6)
    736 
    737 /******************** This section used in uniaud.dll interface *********************/
    738 struct snd_ctl_card_info {
    739         int card;                       /* card number */
    740         int pad;                        /* reserved for future (was type) */
    741         unsigned char id[16];           /* ID of card (user selectable) */
    742         unsigned char driver[16];       /* Driver name */
    743         unsigned char name[32];         /* Short name of soundcard */
    744         unsigned char longname[80];     /* name + info text about soundcard */
    745         unsigned char reserved_[16];    /* reserved for future (was ID of mixer) */
    746         unsigned char mixername[80];    /* visual mixer identification */
    747         unsigned char components[128];  /* card components / fine identification, delimited with one space (AC97 etc..) */
    748 };
    749 
    750 typedef int __bitwise snd_ctl_elem_type_t;
    751 #define SNDRV_CTL_ELEM_TYPE_NONE        ((__force snd_ctl_elem_type_t) 0) /* invalid */
    752 #define SNDRV_CTL_ELEM_TYPE_BOOLEAN     ((__force snd_ctl_elem_type_t) 1) /* boolean type */
    753 #define SNDRV_CTL_ELEM_TYPE_INTEGER     ((__force snd_ctl_elem_type_t) 2) /* integer type */
    754 #define SNDRV_CTL_ELEM_TYPE_ENUMERATED  ((__force snd_ctl_elem_type_t) 3) /* enumerated type */
    755 #define SNDRV_CTL_ELEM_TYPE_BYTES       ((__force snd_ctl_elem_type_t) 4) /* byte array */
    756 #define SNDRV_CTL_ELEM_TYPE_IEC958      ((__force snd_ctl_elem_type_t) 5) /* IEC958 (S/PDIF) setup */
    757 #define SNDRV_CTL_ELEM_TYPE_INTEGER64   ((__force snd_ctl_elem_type_t) 6) /* 64-bit integer type */
    758 #define SNDRV_CTL_ELEM_TYPE_LAST        SNDRV_CTL_ELEM_TYPE_INTEGER64
    759 
    760 typedef int __bitwise snd_ctl_elem_iface_t;
    761 #define SNDRV_CTL_ELEM_IFACE_CARD       ((__force snd_ctl_elem_iface_t) 0) /* global control */
    762 #define SNDRV_CTL_ELEM_IFACE_HWDEP      ((__force snd_ctl_elem_iface_t) 1) /* hardware dependent device */
    763 #define SNDRV_CTL_ELEM_IFACE_MIXER      ((__force snd_ctl_elem_iface_t) 2) /* virtual mixer device */
    764 #define SNDRV_CTL_ELEM_IFACE_PCM        ((__force snd_ctl_elem_iface_t) 3) /* PCM device */
    765 #define SNDRV_CTL_ELEM_IFACE_RAWMIDI    ((__force snd_ctl_elem_iface_t) 4) /* RawMidi device */
    766 #define SNDRV_CTL_ELEM_IFACE_TIMER      ((__force snd_ctl_elem_iface_t) 5) /* timer device */
    767 #define SNDRV_CTL_ELEM_IFACE_SEQUENCER  ((__force snd_ctl_elem_iface_t) 6) /* sequencer client */
    768 #define SNDRV_CTL_ELEM_IFACE_LAST       SNDRV_CTL_ELEM_IFACE_SEQUENCER
    769 
    770 #define SNDRV_CTL_ELEM_ACCESS_READ              (1<<0)
    771 #define SNDRV_CTL_ELEM_ACCESS_WRITE             (1<<1)
    772 #define SNDRV_CTL_ELEM_ACCESS_READWRITE         (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE)
    773 #define SNDRV_CTL_ELEM_ACCESS_VOLATILE          (1<<2)  /* control value may be changed without a notification */
    774 #define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP         (1<<3)  /* when was control changed */
    775 #define SNDRV_CTL_ELEM_ACCESS_TLV_READ          (1<<4)  /* TLV read is possible */
    776 #define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE         (1<<5)  /* TLV write is possible */
    777 #define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE     (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE)
    778 #define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND       (1<<6)  /* TLV command is possible */
    779 #define SNDRV_CTL_ELEM_ACCESS_INACTIVE          (1<<8)  /* control does actually nothing, but may be updated */
    780 #define SNDRV_CTL_ELEM_ACCESS_LOCK              (1<<9)  /* write lock */
    781 #define SNDRV_CTL_ELEM_ACCESS_OWNER             (1<<10) /* write lock owner */
    782 #define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK      (1<<28) /* kernel use a TLV callback */
    783 #define SNDRV_CTL_ELEM_ACCESS_USER              (1<<29) /* user space element */
    784 /* bits 30 and 31 are obsoleted (for indirect access) */
    785 
    786 /* for further details see the ACPI and PCI power management specification */
    787 #define SNDRV_CTL_POWER_D0              0x0000  /* full On */
    788 #define SNDRV_CTL_POWER_D1              0x0100  /* partial On */
    789 #define SNDRV_CTL_POWER_D2              0x0200  /* partial On */
    790 #define SNDRV_CTL_POWER_D3              0x0300  /* Off */
    791 #define SNDRV_CTL_POWER_D3hot           (SNDRV_CTL_POWER_D3|0x0000)     /* Off, with power */
    792 #define SNDRV_CTL_POWER_D3cold          (SNDRV_CTL_POWER_D3|0x0001)     /* Off, without power */
    793 
    794 struct snd_ctl_elem_id {
    795         unsigned int numid;             /* numeric identifier, zero = invalid */
    796         snd_ctl_elem_iface_t iface;     /* interface identifier */
    797         unsigned int device;            /* device/client number */
    798         unsigned int subdevice;         /* subdevice (substream) number */
    799         unsigned char name[44];         /* ASCII name of item */
    800         unsigned int index;             /* index of item */
    801 };
    802 
    803 struct snd_ctl_elem_list {
    804         unsigned int offset;            /* W: first element ID to get */
    805         unsigned int space;             /* W: count of element IDs to get */
    806         unsigned int used;              /* R: count of element IDs set */
    807         unsigned int count;             /* R: count of all elements */
    808         struct snd_ctl_elem_id __user *pids; /* R: IDs */
    809         unsigned char reserved[50];
    810 };
    811 
    812 struct snd_ctl_elem_info {
    813         struct snd_ctl_elem_id id;      /* W: element ID */
    814         snd_ctl_elem_type_t type;       /* R: value type - SNDRV_CTL_ELEM_TYPE_* */
    815         unsigned int access;            /* R: value access (bitmask) - SNDRV_CTL_ELEM_ACCESS_* */
    816         unsigned int count;             /* count of values */
    817         __kernel_pid_t owner;           /* owner's PID of this control */
    818         union {
    819                 struct {
    820                         long min;               /* R: minimum value */
    821                         long max;               /* R: maximum value */
    822                         long step;              /* R: step (0 variable) */
    823                 } integer;
    824                 struct {
    825                         long long min;          /* R: minimum value */
    826                         long long max;          /* R: maximum value */
    827                         long long step;         /* R: step (0 variable) */
    828                 } integer64;
    829                 struct {
    830                         unsigned int items;     /* R: number of items */
    831                         unsigned int item;      /* W: item number */
    832                         char name[64];          /* R: value name */
    833                 } enumerated;
    834                 unsigned char reserved[128];
    835         } value;
    836         union {
    837                 unsigned short d[4];            /* dimensions */
    838                 unsigned short *d_ptr;          /* indirect - obsoleted */
    839         } dimen;
    840         unsigned char reserved[64-4*sizeof(unsigned short)];
    841 };
    842 
    843 struct snd_ctl_elem_value {
    844         struct snd_ctl_elem_id id;      /* W: element ID */
    845         unsigned int indirect: 1;       /* W: indirect access - obsoleted */
    846         union {
    847                 union {
    848                         long value[128];
    849                         long *value_ptr;        /* obsoleted */
    850                 } integer;
    851                 union {
    852                         long long value[64];
    853                         long long *value_ptr;   /* obsoleted */
    854                 } integer64;
    855                 union {
    856                         unsigned int item[128];
    857                         unsigned int *item_ptr; /* obsoleted */
    858                 } enumerated;
    859                 union {
    860                         unsigned char data[512];
    861                         unsigned char *data_ptr;        /* obsoleted */
    862                 } bytes;
    863                 struct snd_aes_iec958 iec958;
    864         } value;                /* RO */
    865         struct timespec tstamp;
    866         unsigned char reserved[128-sizeof(struct timespec)];
    867 };
    868 
    869 struct snd_ctl_tlv {
    870         unsigned int numid;     /* control element numeric identification */
    871         unsigned int length;    /* in bytes aligned to 4 */
    872 #ifndef TARGET_OS2
    873         unsigned int tlv[0];    /* first TLV */
    874 #else
    875         unsigned int tlv[1];    /* first TLV */
    876 #endif
    877 };
    878 
    879 #define SNDRV_CTL_IOCTL_PVERSION        _IOR('U', 0x00, int)
    880 #define SNDRV_CTL_IOCTL_CARD_INFO       _IOR('U', 0x01, struct snd_ctl_card_info)
    881 #define SNDRV_CTL_IOCTL_ELEM_LIST       _IOWR('U', 0x10, struct snd_ctl_elem_list)
    882 #define SNDRV_CTL_IOCTL_ELEM_INFO       _IOWR('U', 0x11, struct snd_ctl_elem_info)
    883 #define SNDRV_CTL_IOCTL_ELEM_READ       _IOWR('U', 0x12, struct snd_ctl_elem_value)
    884 #define SNDRV_CTL_IOCTL_ELEM_WRITE      _IOWR('U', 0x13, struct snd_ctl_elem_value)
    885 #define SNDRV_CTL_IOCTL_ELEM_LOCK       _IOW('U', 0x14, struct snd_ctl_elem_id)
    886 #define SNDRV_CTL_IOCTL_ELEM_UNLOCK     _IOW('U', 0x15, struct snd_ctl_elem_id)
    887 #define SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS _IOWR('U', 0x16, int)
    888 #define SNDRV_CTL_IOCTL_ELEM_ADD        _IOWR('U', 0x17, struct snd_ctl_elem_info)
    889 #define SNDRV_CTL_IOCTL_ELEM_REPLACE    _IOWR('U', 0x18, struct snd_ctl_elem_info)
    890 #define SNDRV_CTL_IOCTL_ELEM_REMOVE     _IOWR('U', 0x19, struct snd_ctl_elem_id)
    891 #define SNDRV_CTL_IOCTL_TLV_READ        _IOWR('U', 0x1a, struct snd_ctl_tlv)
    892 #define SNDRV_CTL_IOCTL_TLV_WRITE       _IOWR('U', 0x1b, struct snd_ctl_tlv)
    893 #define SNDRV_CTL_IOCTL_TLV_COMMAND     _IOWR('U', 0x1c, struct snd_ctl_tlv)
    894 #define SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE _IOWR('U', 0x20, int)
    895 #define SNDRV_CTL_IOCTL_HWDEP_INFO      _IOR('U', 0x21, struct snd_hwdep_info)
    896 #define SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE _IOR('U', 0x30, int)
    897 #define SNDRV_CTL_IOCTL_PCM_INFO        _IOWR('U', 0x31, struct snd_pcm_info)
    898 #define SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE _IOW('U', 0x32, int)
    899 #define SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE _IOWR('U', 0x40, int)
    900 #define SNDRV_CTL_IOCTL_RAWMIDI_INFO    _IOWR('U', 0x41, struct snd_rawmidi_info)
    901 #define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int)
    902 #define SNDRV_CTL_IOCTL_POWER           _IOWR('U', 0xd0, int)
    903 #define SNDRV_CTL_IOCTL_POWER_STATE     _IOR('U', 0xd1, int)
    904 #ifdef TARGET_OS2
    905 #define SNDRV_PCM_IOCTL_SETVOLUME       _IOW('A', 0x62, struct snd_pcm_volume)
    906 #define SNDRV_PCM_IOCTL_GETVOLUME       _IOR('A', 0x63, struct snd_pcm_volume)
    907 #endif
    908 
    909 /*
    910  *  Read interface.
    911  */
    912 
    913 enum sndrv_ctl_event_type {
    914         SNDRV_CTL_EVENT_ELEM = 0,
    915         SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM,
    916 };
    917 
    918 #define SNDRV_CTL_EVENT_MASK_VALUE      (1<<0)  /* element value was changed */
    919 #define SNDRV_CTL_EVENT_MASK_INFO       (1<<1)  /* element info was changed */
    920 #define SNDRV_CTL_EVENT_MASK_ADD        (1<<2)  /* element was added */
    921 #define SNDRV_CTL_EVENT_MASK_TLV        (1<<3)  /* element TLV tree was changed */
    922 #define SNDRV_CTL_EVENT_MASK_REMOVE     (~0U)   /* element was removed */
    923 
    924 struct snd_ctl_event {
    925         int type;       /* event type - SNDRV_CTL_EVENT_* */
    926         union {
    927                 struct {
    928                         unsigned int mask;
    929                         struct snd_ctl_elem_id id;
    930                 } elem;
    931                 unsigned char data8[60];
    932         } data;
    933 };
    934 
    935 /*
    936  *  Control names
    937  */
    938 
    939 #define SNDRV_CTL_NAME_NONE                             ""
    940 #define SNDRV_CTL_NAME_PLAYBACK                         "Playback "
    941 #define SNDRV_CTL_NAME_CAPTURE                          "Capture "
    942 
    943 #define SNDRV_CTL_NAME_IEC958_NONE                      ""
    944 #define SNDRV_CTL_NAME_IEC958_SWITCH                    "Switch"
    945 #define SNDRV_CTL_NAME_IEC958_VOLUME                    "Volume"
    946 #define SNDRV_CTL_NAME_IEC958_DEFAULT                   "Default"
    947 #define SNDRV_CTL_NAME_IEC958_MASK                      "Mask"
    948 #define SNDRV_CTL_NAME_IEC958_CON_MASK                  "Con Mask"
    949 #define SNDRV_CTL_NAME_IEC958_PRO_MASK                  "Pro Mask"
    950 #define SNDRV_CTL_NAME_IEC958_PCM_STREAM                "PCM Stream"
    951 #define SNDRV_CTL_NAME_IEC958(expl,direction,what)      "IEC958 " expl SNDRV_CTL_NAME_##direction SNDRV_CTL_NAME_IEC958_##what
    952 
     24#include <uapi/sound/asound.h>
    95325#endif /* __SOUND_ASOUND_H */
  • GPL/trunk/alsa-kernel/include/sound/asoundef.h

    r399 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_ASOUNDEF_H
    23#define __SOUND_ASOUNDEF_H
     
    56 *  Advanced Linux Sound Architecture - ALSA - Driver
    67 *  Copyright (c) 1994-2000 by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     
    171156#define IEC958_AES5_CON_CGMSA_COPYNEVER (3<<0)  /* no copying is permitted */
    172157
     158/****************************************************************************
     159 *                                                                          *
     160 *        CEA-861 Audio InfoFrame. Used in HDMI and DisplayPort             *
     161 *                                                                          *
     162 ****************************************************************************/
     163#define CEA861_AUDIO_INFOFRAME_DB1CC            (7<<0) /* mask - channel count */
     164#define CEA861_AUDIO_INFOFRAME_DB1CT            (0xf<<4) /* mask - coding type */
     165#define CEA861_AUDIO_INFOFRAME_DB1CT_FROM_STREAM (0<<4) /* refer to stream */
     166#define CEA861_AUDIO_INFOFRAME_DB1CT_IEC60958   (1<<4) /* IEC-60958 L-PCM */
     167#define CEA861_AUDIO_INFOFRAME_DB1CT_AC3        (2<<4) /* AC-3 */
     168#define CEA861_AUDIO_INFOFRAME_DB1CT_MPEG1      (3<<4) /* MPEG1 Layers 1 & 2 */
     169#define CEA861_AUDIO_INFOFRAME_DB1CT_MP3        (4<<4) /* MPEG1 Layer 3 */
     170#define CEA861_AUDIO_INFOFRAME_DB1CT_MPEG2_MULTICH (5<<4) /* MPEG2 Multichannel */
     171#define CEA861_AUDIO_INFOFRAME_DB1CT_AAC        (6<<4) /* AAC */
     172#define CEA861_AUDIO_INFOFRAME_DB1CT_DTS        (7<<4) /* DTS */
     173#define CEA861_AUDIO_INFOFRAME_DB1CT_ATRAC      (8<<4) /* ATRAC */
     174#define CEA861_AUDIO_INFOFRAME_DB1CT_ONEBIT     (9<<4) /* One Bit Audio */
     175#define CEA861_AUDIO_INFOFRAME_DB1CT_DOLBY_DIG_PLUS (10<<4) /* Dolby Digital + */
     176#define CEA861_AUDIO_INFOFRAME_DB1CT_DTS_HD     (11<<4) /* DTS-HD */
     177#define CEA861_AUDIO_INFOFRAME_DB1CT_MAT        (12<<4) /* MAT (MLP) */
     178#define CEA861_AUDIO_INFOFRAME_DB1CT_DST        (13<<4) /* DST */
     179#define CEA861_AUDIO_INFOFRAME_DB1CT_WMA_PRO    (14<<4) /* WMA Pro */
     180#define CEA861_AUDIO_INFOFRAME_DB2SF            (7<<2) /* mask - sample frequency */
     181#define CEA861_AUDIO_INFOFRAME_DB2SF_FROM_STREAM (0<<2) /* refer to stream */
     182#define CEA861_AUDIO_INFOFRAME_DB2SF_32000      (1<<2) /* 32kHz */
     183#define CEA861_AUDIO_INFOFRAME_DB2SF_44100      (2<<2) /* 44.1kHz */
     184#define CEA861_AUDIO_INFOFRAME_DB2SF_48000      (3<<2) /* 48kHz */
     185#define CEA861_AUDIO_INFOFRAME_DB2SF_88200      (4<<2) /* 88.2kHz */
     186#define CEA861_AUDIO_INFOFRAME_DB2SF_96000      (5<<2) /* 96kHz */
     187#define CEA861_AUDIO_INFOFRAME_DB2SF_176400     (6<<2) /* 176.4kHz */
     188#define CEA861_AUDIO_INFOFRAME_DB2SF_192000     (7<<2) /* 192kHz */
     189#define CEA861_AUDIO_INFOFRAME_DB2SS            (3<<0) /* mask - sample size */
     190#define CEA861_AUDIO_INFOFRAME_DB2SS_FROM_STREAM (0<<0) /* refer to stream */
     191#define CEA861_AUDIO_INFOFRAME_DB2SS_16BIT      (1<<0) /* 16 bits */
     192#define CEA861_AUDIO_INFOFRAME_DB2SS_20BIT      (2<<0) /* 20 bits */
     193#define CEA861_AUDIO_INFOFRAME_DB2SS_24BIT      (3<<0) /* 24 bits */
     194#define CEA861_AUDIO_INFOFRAME_DB5_DM_INH       (1<<7) /* mask - inhibit downmixing */
     195#define CEA861_AUDIO_INFOFRAME_DB5_DM_INH_PERMITTED (0<<7) /* stereo downmix permitted */
     196#define CEA861_AUDIO_INFOFRAME_DB5_DM_INH_PROHIBITED (1<<7) /* stereo downmis prohibited */
     197#define CEA861_AUDIO_INFOFRAME_DB5_LSV          (0xf<<3) /* mask - level-shift values */
     198
    173199/*****************************************************************************
    174200 *                                                                           *
  • GPL/trunk/alsa-kernel/include/sound/config.h

    r598 r679  
    88
    99#include <linux/version.h>
    10 #include <linux/types.h>
    11 #include <linux/fcntl.h>
    12 #include <linux/signal.h>
    13 #include <linux/kdev_t.h>
    14 #include <linux/wait.h>
    15 #include <linux/list.h>
    16 #include <linux/init.h>
    17 #include <linux/dcache.h>
    18 #include <linux/vmalloc.h>
    19 #include <linux/tqueue.h>
    20 #include <linux/time.h>
    21 #include <linux/timer.h>
    22 #include <linux/stat.h>
    23 #include <linux/major.h>
    24 #include <linux/fs.h>
    25 #include <linux/pid.h>
    26 #include <linux/err.h>
    27 #include <linux/gfp.h>
    28 #include <linux/workqueue.h>
    29 #include <linux/byteorder/little_endian.h>
    30 #include <linux/lockdep.h>
    31 #include <linux/string.h>
    32 #include <asm/ioctl.h>
    33 #include <asm/hardirq.h>
    34 #include <asm/processor.h>
    35 #include <asm/siginfo.h>
    36 #include <dbgos2.h>
    37 #include <limits.h>
    38 #include <sys/cdefs.h>
    39 #include <stdio.h>
    40 #include <linux/config.h>
    41 #include <linux/module.h>
    42 #include <linux/utsname.h>
    43 #include <linux/errno.h>
    44 #include <linux/kernel.h>
    45 #include <linux/sched.h>
    46 #include <linux/malloc.h>
    47 #include <linux/delay.h>
    48 #include <linux/ioport.h>
    49 #include <asm/io.h>
    50 #include <asm/irq.h>
    51 #include <asm/segment.h>
    52 #include <asm/uaccess.h>
    53 #include <asm/system.h>
    54 #include <asm/string.h>
    55 #include <linux/pci.h>
    56 #include <linux/interrupt.h>
    57 #include <linux/pagemap.h>
    58 #include <linux/fs.h>
    59 #include <linux/fcntl.h>
    60 #include <linux/vmalloc.h>
    61 #include <linux/poll.h>
    62 #include <linux/reboot.h>
    63 #include <linux/init.h>
    64 #include <linux/lockdep.h>
    65 #include <linux/smp_lock.h>
    66 #include <linux/dma-mapping.h>
    67 #include "compat_22.h"
    68 
    69 #include <sound/asound.h>
    70 #include <sound/asoundef.h>
    7110
    7211/*
     
    8322#define CONFIG_PCI
    8423#define CONFIG_PM
    85 #define CONFIG_PROC_FS
     24#define CONFIG_PM_SLEEP
    8625#ifdef DEBUG
    8726#define CONFIG_SND_DEBUG_DETECT
     27#endif
    8828#define CONFIG_SND_DEBUG_VERBOSE
    89 #endif
    9029#define CONFIG_SND_DMA_SGBUF
    9130#define CONFIG_SND_HDA_CODEC_ANALOG
     
    9837#define CONFIG_SND_HDA_GENERIC
    9938#define CONFIG_SND_HDA_HWDEP
     39#define CONFIG_SND_HDA_PREALLOC_SIZE  64
    10040#define CONFIG_SND_OSSEMUL
    101 #define CONFIG_SND_PCM_OSS
    10241#define CONFIG_SND_SEQUENCER
    10342#define CONFIG_SOUND
    10443#define CONFIG_SYSFS_DEPRECATED
     44#define CONFIG_SND_PROC_FS
     45#define CONFIG_SND_JACK
     46//#define CONFIG_SND_DYNAMIC_MINORS //new 2020-12-26
     47//#define CONFIG_SND_MAX_CARDS 8 //new 2020-12-26
    10548#define PCI_NEW_SUSPEND
    10649#define SNDRV_LITTLE_ENDIAN
    107 
     50#define CONFIG_SND_HDA_POWER_SAVE_DEFAULT 1
     51#define CONFIG_SND_PCM_TIMER 1
     52#define CONFIG_PROC_FS 1 /* new oct 2020 */
     53#define CONFIG_SND_PCM_OSS 1
    10854
    10955/* Still need to work out where the following really belong */
    11056#undef interrupt
    111 #define __builtin_return_address(a)     0
    112 #define __builtin_expect(x, expected_value) (x)
    113 #define BUG_ON(x) /* nothing */
    11457#define assert(a)
    11558#define no_llseek       NULL
    11659#define noop_llseek     NULL
    117 
    118 struct class;
    119 struct class_device;
    120 struct class_device_attribute {int x; }; /* dummy */
    121 #define __ATTR(cls,perm,read,write) {0 } /* dummy */
    12260
    12361#define min_t(type, x, y) ({                    \
  • GPL/trunk/alsa-kernel/include/sound/control.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_CONTROL_H
    23#define __SOUND_CONTROL_H
     
    56 *  Header file for control interface
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    23  */
    24 
     8 */
     9
     10#include <linux/wait.h>
     11#include <linux/nospec.h>
    2512#include <sound/asound.h>
    2613
     
    3219typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
    3320typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol,
    34                                     int op_flag, /* 0=read,1=write,-1=command */
     21                                    int op_flag, /* SNDRV_CTL_TLV_OP_XXX */
    3522                                    unsigned int size,
    3623                                    unsigned int __user *tlv);
    3724
     25/* internal flag for skipping validations */
     26#ifdef CONFIG_SND_CTL_VALIDATION
     27#define SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK        (1 << 27)
     28#define snd_ctl_skip_validation(info) \
     29        ((info)->access & SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK)
     30#else
     31#define SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK        0
     32#define snd_ctl_skip_validation(info)           true
     33#endif
     34
     35enum {
     36        SNDRV_CTL_TLV_OP_READ = 0,
     37        SNDRV_CTL_TLV_OP_WRITE = 1,
     38        SNDRV_CTL_TLV_OP_CMD = -1,
     39};
    3840
    3941struct snd_kcontrol_new {
     
    4143        unsigned int device;            /* device/client number */
    4244        unsigned int subdevice;         /* subdevice (substream) number */
    43         unsigned char *name;            /* ASCII name of item */
     45        const char *name;               /* ASCII name of item */
    4446        unsigned int index;             /* index of item */
    4547        unsigned int access;            /* access rights */
     
    7274        } tlv;
    7375        unsigned long private_value;
    74 #ifdef TARGET_OS2
    75         void *private_ptr;
    76 #endif
    7776        void *private_data;
    7877        void (*private_free)(struct snd_kcontrol *kcontrol);
    79 #ifndef TARGET_OS2
    80         struct snd_kcontrol_volatile vd[0];     /* volatile data */
    81 #else
    82         struct snd_kcontrol_volatile vd[1];     /* volatile data */
    83 #endif
     78        struct snd_kcontrol_volatile vd[];      /* volatile data */
    8479};
    8580
     
    9691struct pid;
    9792
     93enum {
     94        SND_CTL_SUBDEV_PCM,
     95        SND_CTL_SUBDEV_RAWMIDI,
     96        SND_CTL_SUBDEV_ITEMS,
     97};
     98
    9899struct snd_ctl_file {
    99100        struct list_head list;          /* list of all control files */
    100101        struct snd_card *card;
    101102        struct pid *pid;
    102         int prefer_pcm_subdevice;
    103         int prefer_rawmidi_subdevice;
     103        int preferred_subdevice[SND_CTL_SUBDEV_ITEMS];
    104104        wait_queue_head_t change_sleep;
    105105        spinlock_t read_lock;
     
    121121int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
    122122int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
     123int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace);
    123124int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
    124125int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
     126int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
     127                        int active);
    125128struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
    126129struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
     
    138141#endif
    139142
     143int snd_ctl_get_preferred_subdevice(struct snd_card *card, int type);
     144
    140145static inline unsigned int snd_ctl_get_ioffnum(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
    141146{
    142         return id->numid - kctl->id.numid;
     147        unsigned int ioff = id->numid - kctl->id.numid;
     148        return array_index_nospec(ioff, kctl->count);
    143149}
    144150
    145151static inline unsigned int snd_ctl_get_ioffidx(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
    146152{
    147         return id->index - kctl->id.index;
     153        unsigned int ioff = id->index - kctl->id.index;
     154        return array_index_nospec(ioff, kctl->count);
    148155}
    149156
     
    182189struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
    183190                                                 const unsigned int *tlv);
    184 int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
    185                        unsigned int flags);
    186 /* optional flags for slave */
    187 #define SND_CTL_SLAVE_NEED_UPDATE       (1 << 0)
     191int _snd_ctl_add_follower(struct snd_kcontrol *master,
     192                          struct snd_kcontrol *follower,
     193                          unsigned int flags);
     194/* optional flags for follower */
     195#define SND_CTL_FOLLOWER_NEED_UPDATE    (1 << 0)
    188196
    189197/**
    190  * snd_ctl_add_slave - Add a virtual slave control
     198 * snd_ctl_add_follower - Add a virtual follower control
    191199 * @master: vmaster element
    192  * @slave: slave element to add
    193  *
    194  * Add a virtual slave control to the given master element created via
     200 * @follower: follower element to add
     201 *
     202 * Add a virtual follower control to the given master element created via
    195203 * snd_ctl_create_virtual_master() beforehand.
    196  * Returns zero if successful or a negative error code.
    197  *
    198  * All slaves must be the same type (returning the same information
    199  * via info callback).  The fucntion doesn't check it, so it's your
     204 *
     205 * All followers must be the same type (returning the same information
     206 * via info callback).  The function doesn't check it, so it's your
    200207 * responsibility.
    201208 *
     
    204211 * logarithmic volume control (dB level) thus no linear volume,
    205212 * master can only attenuate the volume without gain
     213 *
     214 * Return: Zero if successful or a negative error code.
    206215 */
    207216static inline int
    208 snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave)
    209 {
    210         return _snd_ctl_add_slave(master, slave, 0);
     217snd_ctl_add_follower(struct snd_kcontrol *master, struct snd_kcontrol *follower)
     218{
     219        return _snd_ctl_add_follower(master, follower, 0);
    211220}
    212221
    213222/**
    214  * snd_ctl_add_slave_uncached - Add a virtual slave control
     223 * snd_ctl_add_follower_uncached - Add a virtual follower control
    215224 * @master: vmaster element
    216  * @slave: slave element to add
    217  *
    218  * Add a virtual slave control to the given master.
    219  * Unlike snd_ctl_add_slave(), the element added via this function
     225 * @follower: follower element to add
     226 *
     227 * Add a virtual follower control to the given master.
     228 * Unlike snd_ctl_add_follower(), the element added via this function
    220229 * is supposed to have volatile values, and get callback is called
    221  * at each time quried from the master.
     230 * at each time queried from the master.
    222231 *
    223232 * When the control peeks the hardware values directly and the value
    224233 * can be changed by other means than the put callback of the element,
    225234 * this function should be used to keep the value always up-to-date.
     235 *
     236 * Return: Zero if successful or a negative error code.
    226237 */
    227238static inline int
    228 snd_ctl_add_slave_uncached(struct snd_kcontrol *master,
    229                            struct snd_kcontrol *slave)
    230 {
    231         return _snd_ctl_add_slave(master, slave, SND_CTL_SLAVE_NEED_UPDATE);
    232 }
     239snd_ctl_add_follower_uncached(struct snd_kcontrol *master,
     240                              struct snd_kcontrol *follower)
     241{
     242        return _snd_ctl_add_follower(master, follower, SND_CTL_FOLLOWER_NEED_UPDATE);
     243}
     244
     245int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kctl,
     246                             void (*hook)(void *private_data, int),
     247                             void *private_data);
     248void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only);
     249#define snd_ctl_sync_vmaster_hook(kctl) snd_ctl_sync_vmaster(kctl, true)
     250int snd_ctl_apply_vmaster_followers(struct snd_kcontrol *kctl,
     251                                    int (*func)(struct snd_kcontrol *vfollower,
     252                                                struct snd_kcontrol *follower,
     253                                                void *arg),
     254                                    void *arg);
     255
     256/*
     257 * Helper functions for jack-detection controls
     258 */
     259struct snd_kcontrol *
     260snd_kctl_jack_new(const char *name, struct snd_card *card);
     261void snd_kctl_jack_report(struct snd_card *card,
     262                          struct snd_kcontrol *kctl, bool status);
    233263
    234264#endif  /* __SOUND_CONTROL_H */
  • GPL/trunk/alsa-kernel/include/sound/core.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_CORE_H
    23#define __SOUND_CORE_H
     
    56 *  Main header file for the ALSA driver
    67 *  Copyright (c) 1994-2001 by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249#ifdef TARGET_OS2
     
    2611#endif
    2712
    28 #include <linux/module.h>
     13#include <linux/device.h>
    2914#include <linux/sched.h>                /* wake_up() */
    3015#include <linux/mutex.h>                /* struct mutex */
    3116#include <linux/rwsem.h>                /* struct rw_semaphore */
    3217#include <linux/pm.h>                   /* pm_message_t */
    33 #include <linux/device.h>
    3418#include <linux/stringify.h>
     19#include <linux/printk.h>
    3520
    3621/* number of supported soundcards */
    3722#ifdef CONFIG_SND_DYNAMIC_MINORS
    38 #define SNDRV_CARDS 32
     23#define SNDRV_CARDS CONFIG_SND_MAX_CARDS
    3924#else
    4025#define SNDRV_CARDS 8           /* don't change - minor numbers */
     
    4429
    4530/* forward declarations */
    46 #ifdef CONFIG_PCI
    4731struct pci_dev;
    48 #endif
     32struct module;
     33struct completion;
    4934
    5035/* device allocation stuff */
    5136
    52 #define SNDRV_DEV_TYPE_RANGE_SIZE               0x1000
    53 
    54 typedef int __bitwise snd_device_type_t;
    55 #define SNDRV_DEV_TOPLEVEL      ((__force snd_device_type_t) 0)
    56 #define SNDRV_DEV_CONTROL       ((__force snd_device_type_t) 1)
    57 #define SNDRV_DEV_LOWLEVEL_PRE  ((__force snd_device_type_t) 2)
    58 #define SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000)
    59 #define SNDRV_DEV_PCM           ((__force snd_device_type_t) 0x1001)
    60 #define SNDRV_DEV_RAWMIDI       ((__force snd_device_type_t) 0x1002)
    61 #define SNDRV_DEV_TIMER         ((__force snd_device_type_t) 0x1003)
    62 #define SNDRV_DEV_SEQUENCER     ((__force snd_device_type_t) 0x1004)
    63 #define SNDRV_DEV_HWDEP         ((__force snd_device_type_t) 0x1005)
    64 #define SNDRV_DEV_INFO          ((__force snd_device_type_t) 0x1006)
    65 #define SNDRV_DEV_BUS           ((__force snd_device_type_t) 0x1007)
    66 #define SNDRV_DEV_CODEC         ((__force snd_device_type_t) 0x1008)
    67 #define SNDRV_DEV_JACK          ((__force snd_device_type_t) 0x1009)
    68 #define SNDRV_DEV_LOWLEVEL      ((__force snd_device_type_t) 0x2000)
    69 
    70 typedef int __bitwise snd_device_state_t;
    71 #define SNDRV_DEV_BUILD         ((__force snd_device_state_t) 0)
    72 #define SNDRV_DEV_REGISTERED    ((__force snd_device_state_t) 1)
    73 #define SNDRV_DEV_DISCONNECTED  ((__force snd_device_state_t) 2)
    74 
    75 typedef int __bitwise snd_device_cmd_t;
    76 #define SNDRV_DEV_CMD_PRE       ((__force snd_device_cmd_t) 0)
    77 #define SNDRV_DEV_CMD_NORMAL    ((__force snd_device_cmd_t) 1) 
    78 #define SNDRV_DEV_CMD_POST      ((__force snd_device_cmd_t) 2)
     37/* type of the object used in snd_device_*()
     38 * this also defines the calling order
     39 */
     40enum snd_device_type {
     41        SNDRV_DEV_LOWLEVEL,
     42        SNDRV_DEV_INFO,
     43        SNDRV_DEV_BUS,
     44        SNDRV_DEV_CODEC,
     45        SNDRV_DEV_PCM,
     46        SNDRV_DEV_COMPRESS,
     47        SNDRV_DEV_RAWMIDI,
     48        SNDRV_DEV_TIMER,
     49        SNDRV_DEV_SEQUENCER,
     50        SNDRV_DEV_HWDEP,
     51        SNDRV_DEV_JACK,
     52        SNDRV_DEV_CONTROL,      /* NOTE: this must be the last one */
     53};
     54
     55enum snd_device_state {
     56        SNDRV_DEV_BUILD,
     57        SNDRV_DEV_REGISTERED,
     58        SNDRV_DEV_DISCONNECTED,
     59};
    7960
    8061struct snd_device;
     
    8970        struct list_head list;          /* list of registered devices */
    9071        struct snd_card *card;          /* card which holds this device */
    91         snd_device_state_t state;       /* state of the device */
    92         snd_device_type_t type;         /* device type */
     72        enum snd_device_state state;    /* state of the device */
     73        enum snd_device_type type;      /* device type */
    9374        void *device_data;              /* device structure */
    94         struct snd_device_ops *ops;     /* operations */
     75        const struct snd_device_ops *ops;       /* operations */
    9576};
    9677
     
    10788        char shortname[32];             /* short name of this soundcard */
    10889        char longname[80];              /* name of this soundcard */
     90        char irq_descr[32];             /* Interrupt description */
    10991        char mixername[80];             /* mixer name */
    11092        char components[128];           /* card components delimited with
     
    11799        struct list_head devices;       /* devices */
    118100
     101        struct device ctl_dev;          /* control device */
    119102        unsigned int last_numid;        /* last used numeric ID */
    120103        struct rw_semaphore controls_rwsem;     /* controls list lock */
     
    126109
    127110        struct snd_info_entry *proc_root;       /* root for soundcard specific files */
    128         struct snd_info_entry *proc_id; /* the card id */
    129111        struct proc_dir_entry *proc_root_link;  /* number link to real id */
    130112
     
    134116        spinlock_t files_lock;          /* lock the files for this card */
    135117        int shutdown;                   /* this card is going down */
    136         int free_on_last_close;         /* free in context of file_release */
    137         wait_queue_head_t shutdown_sleep;
     118        struct completion *release_completion;
    138119        struct device *dev;             /* device assigned to this card */
    139         struct device *card_dev;        /* cardX object for sysfs */
     120        struct device card_dev;         /* cardX object for sysfs */
     121        const struct attribute_group *dev_groups[4]; /* assigned sysfs attr */
     122        bool registered;                /* card_dev is registered? */
     123        int sync_irq;                   /* assigned irq, used for PCM sync */
     124        wait_queue_head_t remove_sleep;
     125
     126        size_t total_pcm_alloc_bytes;   /* total amount of allocated buffers */
     127        struct mutex memory_mutex;      /* protection for the above */
    140128
    141129#ifdef CONFIG_PM
    142130        unsigned int power_state;       /* power state */
    143         struct mutex power_lock;        /* power lock */
    144131        wait_queue_head_t power_sleep;
    145132#endif
    146133
    147 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
     134#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
    148135        struct snd_mixer_oss *mixer_oss;
    149136        int mixer_oss_change_count;
     
    151138};
    152139
     140#define dev_to_snd_card(p)      container_of(p, struct snd_card, card_dev)
     141
    153142#ifdef CONFIG_PM
    154 static inline void snd_power_lock(struct snd_card *card)
    155 {
    156         mutex_lock(&card->power_lock);
    157 }
    158 
    159 static inline void snd_power_unlock(struct snd_card *card)
    160 {
    161         mutex_unlock(&card->power_lock);
    162 }
    163 
    164143static inline unsigned int snd_power_get_state(struct snd_card *card)
    165144{
     
    178157#else /* ! CONFIG_PM */
    179158
    180 #define snd_power_lock(card)            do { (void)(card); } while (0)
    181 #define snd_power_unlock(card)          do { (void)(card); } while (0)
    182159static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; }
    183160#define snd_power_get_state(card)       ({ (void)(card); SNDRV_CTL_POWER_D0; })
     
    190167        int card;                       /* card number */
    191168        int device;                     /* device number */
    192 #ifndef TARGET_OS2
    193169        const struct file_operations *f_ops;    /* file operations */
    194 #else
    195         struct file_operations *f_ops;  /* file operations */
    196 #endif
    197170        void *private_data;             /* private data for f_ops->open */
    198171        struct device *dev;             /* device for sysfs */
     172        struct snd_card *card_ptr;      /* assigned card instance */
    199173};
    200174
     
    202176static inline struct device *snd_card_get_device_link(struct snd_card *card)
    203177{
    204         return card ? card->card_dev : NULL;
     178        return card ? &card->card_dev : NULL;
    205179}
    206180
     
    213187void snd_request_card(int card);
    214188
    215 int snd_register_device_for_dev(int type, struct snd_card *card,
    216                                 int dev,
    217 #ifndef TARGET_OS2
    218                                 const struct file_operations *f_ops,
    219 #else
    220                                 struct file_operations *f_ops,
    221 #endif
    222                                 void *private_data,
    223                                 const char *name,
    224                                 struct device *device);
    225 
    226 /**
    227  * snd_register_device - Register the ALSA device file for the card
    228  * @type: the device type, SNDRV_DEVICE_TYPE_XXX
    229  * @card: the card instance
    230  * @dev: the device index
    231  * @f_ops: the file operations
    232  * @private_data: user pointer for f_ops->open()
    233  * @name: the device file name
    234  *
    235  * Registers an ALSA device file for the given card.
    236  * The operators have to be set in reg parameter.
    237  *
    238  * This function uses the card's device pointer to link to the
    239  * correct &struct device.
    240  *
    241  * Returns zero if successful, or a negative error code on failure.
    242  */
    243 static inline int snd_register_device(int type, struct snd_card *card, int dev,
    244 #ifndef TARGET_OS2
    245                                       const struct file_operations *f_ops,
    246 #else
    247                                       struct file_operations *f_ops,
    248 #endif
    249                                       void *private_data,
    250                                       const char *name)
    251 {
    252         return snd_register_device_for_dev(type, card, dev, f_ops,
    253                                            private_data, name,
    254                                            snd_card_get_device_link(card));
    255 }
    256 
    257 int snd_unregister_device(int type, struct snd_card *card, int dev);
     189void snd_device_initialize(struct device *dev, struct snd_card *card);
     190
     191int snd_register_device(int type, struct snd_card *card, int dev,
     192                        const struct file_operations *f_ops,
     193                        void *private_data, struct device *device);
     194int snd_unregister_device(struct device *dev);
    258195void *snd_lookup_minor_data(unsigned int minor, int type);
    259 int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
    260                               struct device_attribute *attr);
    261196
    262197#ifdef CONFIG_SND_OSSEMUL
    263198int snd_register_oss_device(int type, struct snd_card *card, int dev,
    264 #ifndef TARGET_OS2
    265                             const struct file_operations *f_ops, void *private_data,
    266 #else
    267                             struct file_operations *f_ops, void *private_data,
    268 #endif
    269                             const char *name);
     199                            const struct file_operations *f_ops, void *private_data);
    270200int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
    271201void *snd_lookup_oss_minor_data(unsigned int minor, int type);
     
    273203
    274204int snd_minor_info_init(void);
    275 int snd_minor_info_done(void);
    276205
    277206/* sound_oss.c */
     
    279208#ifdef CONFIG_SND_OSSEMUL
    280209int snd_minor_info_oss_init(void);
    281 int snd_minor_info_oss_done(void);
    282210#else
    283211static inline int snd_minor_info_oss_init(void) { return 0; }
    284 static inline int snd_minor_info_oss_done(void) { return 0; }
    285212#endif
    286213
     
    292219/* init.c */
    293220
    294 extern struct snd_card *snd_cards[SNDRV_CARDS];
    295221int snd_card_locked(int card);
    296 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
     222#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
    297223#define SND_MIXER_OSS_NOTIFY_REGISTER   0
    298224#define SND_MIXER_OSS_NOTIFY_DISCONNECT 1
     
    301227#endif
    302228
    303 int snd_card_create(int idx, const char *id,
    304                     struct module *module, int extra_size,
    305                     struct snd_card **card_ret);
     229int snd_card_new(struct device *parent, int idx, const char *xid,
     230                 struct module *module, int extra_size,
     231                 struct snd_card **card_ret);
    306232
    307233int snd_card_disconnect(struct snd_card *card);
     234void snd_card_disconnect_sync(struct snd_card *card);
    308235int snd_card_free(struct snd_card *card);
    309236int snd_card_free_when_closed(struct snd_card *card);
     
    311238int snd_card_register(struct snd_card *card);
    312239int snd_card_info_init(void);
    313 int snd_card_info_done(void);
     240int snd_card_add_dev_attr(struct snd_card *card,
     241                          const struct attribute_group *group);
    314242int snd_component_add(struct snd_card *card, const char *component);
    315243int snd_card_file_add(struct snd_card *card, struct file *file);
    316244int snd_card_file_remove(struct snd_card *card, struct file *file);
    317245
     246struct snd_card *snd_card_ref(int card);
     247
     248/**
     249 * snd_card_unref - Unreference the card object
     250 * @card: the card object to unreference
     251 *
     252 * Call this function for the card object that was obtained via snd_card_ref()
     253 * or snd_lookup_minor_data().
     254 */
     255static inline void snd_card_unref(struct snd_card *card)
     256{
     257        put_device(&card->card_dev);
     258}
     259
    318260#define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
    319261
    320262/* device.c */
    321263
    322 int snd_device_new(struct snd_card *card, snd_device_type_t type,
    323                    void *device_data, struct snd_device_ops *ops);
     264int snd_device_new(struct snd_card *card, enum snd_device_type type,
     265                   void *device_data, const struct snd_device_ops *ops);
    324266int snd_device_register(struct snd_card *card, void *device_data);
    325267int snd_device_register_all(struct snd_card *card);
    326 int snd_device_disconnect(struct snd_card *card, void *device_data);
    327 int snd_device_disconnect_all(struct snd_card *card);
    328 int snd_device_free(struct snd_card *card, void *device_data);
    329 int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd);
     268void snd_device_disconnect(struct snd_card *card, void *device_data);
     269void snd_device_disconnect_all(struct snd_card *card);
     270void snd_device_free(struct snd_card *card, void *device_data);
     271void snd_device_free_all(struct snd_card *card);
     272int snd_device_get_state(struct snd_card *card, void *device_data);
    330273
    331274/* isadma.c */
     
    345288/* --- */
    346289
     290/* sound printk debug levels */
     291enum {
     292        SND_PR_ALWAYS,
     293        SND_PR_DEBUG,
     294        SND_PR_VERBOSE,
     295};
     296
    347297#if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK)
    348 void __snd_printk(unsigned int level, const char *file, int line,
    349                   const char *format, ...)
    350      __attribute__ ((format (printf, 4, 5)));
    351 #else
    352 #ifndef TARGET_OS2
    353 #define __snd_printk(level, file, line, format, args...) \
    354         printk(format, ##args)
     298#error "Not valid for OS/2"
     299__printf(4, 5)
     300void __snd_printk(unsigned int level, const char *file, int line, const char *format, ...);
     301#else
     302#ifndef TARGET_OS2
     303#define __snd_printk(level, file, line, format, ...) \
     304 printk(format, ##__VA_ARGS__)
    355305#else
    356306#define __snd_printk printk
    357 #endif /* nothing */
    358 #endif
     307#endif /* TARGET_OS2 */
     308#endif /* defined(...) */
    359309
    360310/**
     
    366316 */
    367317#ifndef TARGET_OS2
    368 #define snd_printk(fmt, args...) \
    369         __snd_printk(0, __FILE__, __LINE__, fmt, ##args)
    370 #else
    371 #define snd_printk printk
    372 #endif
     318#define snd_printk(fmt, ...) \
     319        __snd_printk(0, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
     320#else
     321#define snd_printk __snd_printk
     322#endif 
    373323
    374324#ifdef CONFIG_SND_DEBUG
     
    380330 * Ignored when CONFIG_SND_DEBUG is not set.
    381331 */
    382 #define snd_printd(fmt, args...) \
    383         __snd_printk(1, __FILE__, __LINE__, fmt, ##args)
     332#ifndef TARGET_OS2
     333#define snd_printd(fmt, ...) \
     334 __snd_printk(1, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
     335#define _snd_printd(level, fmt, ...) \
     336        __snd_printk(level, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
     337#else /* TARGET_OS2 */
     338#define snd_printd printk
     339#endif /* TARGET_OS2 */
    384340
    385341/**
     
    389345 * Ignored when CONFIG_SND_DEBUG is not set.
    390346 */
     347#ifndef TARGET_OS2
    391348#define snd_BUG()               WARN(1, "BUG?\n")
     349#else
     350#define snd_BUG()
     351#endif
     352
     353/**
     354 * snd_printd_ratelimit - Suppress high rates of output when
     355 *                        CONFIG_SND_DEBUG is enabled.
     356 */
     357#define snd_printd_ratelimit() printk_ratelimit()
    392358
    393359/**
     
    395361 * @cond: condition to evaluate
    396362 *
    397  * When CONFIG_SND_DEBUG is set, this macro evaluates the given condition,
    398  * and call WARN() and returns the value if it's non-zero.
    399  *
    400  * When CONFIG_SND_DEBUG is not set, this just returns zero, and the given
    401  * condition is ignored.
    402  *
    403  * NOTE: the argument won't be evaluated at all when CONFIG_SND_DEBUG=n.
    404  * Thus, don't put any statement that influences on the code behavior,
    405  * such as pre/post increment, to the argument of this macro.
    406  * If you want to evaluate and give a warning, use standard WARN_ON().
    407  */
    408 
    409 #define snd_BUG_ON(cond)        WARN((cond), "BUG? (%s)\n", __stringify(cond))
     363 * Has the same behavior as WARN_ON when CONFIG_SND_DEBUG is set,
     364 * otherwise just evaluates the conditional and returns the value.
     365 */
     366#ifndef TARGET_OS2
     367#define snd_BUG_ON(cond)        WARN_ON((cond))
     368#else
     369#define snd_BUG_ON(cond)
     370#endif
    410371
    411372#else /* !CONFIG_SND_DEBUG */
    412373
    413374#ifndef TARGET_OS2
    414 #define snd_printd(fmt, args...)        do { } while (0)
     375__printf(1, 2)
     376static inline void snd_printd(const char *format, ...) {}
     377__printf(2, 3)
     378static inline void _snd_printd(int level, const char *format, ...) {}
     379
    415380#define snd_BUG()                       do { } while (0)
    416 static inline int __snd_bug_on(int cond)
    417 {
    418         return 0;
    419 }
    420 #define snd_BUG_ON(cond)        __snd_bug_on(0 && (cond))  /* always false */
     381
     382#define snd_BUG_ON(condition) ({ \
     383        int __ret_warn_on = !!(condition); \
     384        unlikely(__ret_warn_on); \
     385})
    421386#else
    422387#define snd_printd snd_printk
     
    429394#endif
    430395
     396static inline bool snd_printd_ratelimit(void) { return false; }
    431397
    432398#endif /* CONFIG_SND_DEBUG */
     
    441407 */
    442408#ifndef TARGET_OS2
    443 #define snd_printdd(format, args...) \
    444         __snd_printk(2, __FILE__, __LINE__, format, ##args)
     409#define snd_printdd(format, ...) \
     410 __snd_printk(2, __FILE__, __LINE__, format, ##__VA_ARGS__)
    445411#else
    446412#define snd_printdd snd_printk
    447 #endif
    448 #else
    449 #ifndef TARGET_OS2
    450 #define snd_printdd(format, args...)    do { } while (0)
    451 #else
    452 #define snd_printdd 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
    453 #endif
    454 #endif
     413#endif /* TARGET_OS2 */
     414#else /* CONFIG_SND_DEBUG_VERBIOSE */
     415#ifndef TARGET_OS2
     416__printf(1, 2)
     417static inline void snd_printdd(const char *format, ...) {}
     418#else
     419#define snd_printdd snd_printk
     420#endif /* TARGET_OS2 */
     421#endif /* CONFIG_SND_DEBUG_VERBIOSE */
    455422
    456423
     
    458425
    459426/* for easier backward-porting */
    460 #if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE)
     427#if IS_ENABLED(CONFIG_GAMEPORT)
    461428#define gameport_set_dev_parent(gp,xdev) ((gp)->dev.parent = (xdev))
    462429#define gameport_set_port_data(gp,r) ((gp)->port_data = (r))
     
    488455        {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev),                       \
    489456                        .value = (val), .name = (xname)}
     457#define snd_pci_quirk_name(q)   ((q)->name)
    490458#else
    491459#define SND_PCI_QUIRK(vend,dev,xname,val) \
     
    495463#define SND_PCI_QUIRK_VENDOR(vend, xname, val)                  \
    496464        {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val)}
    497 #endif
    498 
     465#define snd_pci_quirk_name(q)   ""
     466#endif
     467
     468#ifdef CONFIG_PCI
    499469const struct snd_pci_quirk *
    500470snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list);
     
    503473snd_pci_quirk_lookup_id(u16 vendor, u16 device,
    504474                        const struct snd_pci_quirk *list);
     475#else
     476static inline const struct snd_pci_quirk *
     477snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
     478{
     479        return NULL;
     480}
     481
     482static inline const struct snd_pci_quirk *
     483snd_pci_quirk_lookup_id(u16 vendor, u16 device,
     484                        const struct snd_pci_quirk *list)
     485{
     486        return NULL;
     487}
     488#endif
    505489
    506490#endif /* __SOUND_CORE_H */
  • GPL/trunk/alsa-kernel/include/sound/cs4231-regs.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_CS4231_REGS_H
    23#define __SOUND_CS4231_REGS_H
     
    56 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    67 *  Definitions for CS4231 & InterWave chips & compatible chips registers
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
  • GPL/trunk/alsa-kernel/include/sound/cs46xx_dsp_spos.h

    r598 r679  
    148148
    149149struct dsp_spos_instance {
    150         struct dsp_symbol_desc symbol_table; /* currently availble loaded symbols in SP */
     150        struct dsp_symbol_desc symbol_table; /* currently available loaded symbols in SP */
    151151
    152152        int nmodules;
  • GPL/trunk/alsa-kernel/include/sound/cs8403.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_CS8403_H
    23#define __SOUND_CS8403_H
     
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
    78 *                   Takashi Iwai <tiwai@suse.de>
    8  *
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    249 */
    2510
  • GPL/trunk/alsa-kernel/include/sound/cs8427.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_CS8427_H
    23#define __SOUND_CS8427_H
     
    56 *  Routines for Cirrus Logic CS8427
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     
    189174struct snd_pcm_substream;
    190175
     176int snd_cs8427_init(struct snd_i2c_bus *bus, struct snd_i2c_device *device);
    191177int snd_cs8427_create(struct snd_i2c_bus *bus, unsigned char addr,
    192178                      unsigned int reset_timeout, struct snd_i2c_device **r_cs8427);
  • GPL/trunk/alsa-kernel/include/sound/emu10k1.h

    r598 r679  
    1 #ifndef __SOUND_EMU10K1_H
    2 #define __SOUND_EMU10K1_H
    3 
    4 #include <linux/types.h>
    5 
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    62/*
    73 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
    84 *                   Creative Labs, Inc.
    95 *  Definitions for EMU10K1 (SB Live!) chips
    10  *
    11  *
    12  *   This program is free software; you can redistribute it and/or modify
    13  *   it under the terms of the GNU General Public License as published by
    14  *   the Free Software Foundation; either version 2 of the License, or
    15  *   (at your option) any later version.
    16  *
    17  *   This program is distributed in the hope that it will be useful,
    18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  *   GNU General Public License for more details.
    21  *
    22  *   You should have received a copy of the GNU General Public License
    23  *   along with this program; if not, write to the Free Software
    24  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    25  *
    266 */
    27 
    28 #ifdef __KERNEL__
     7#ifndef __SOUND_EMU10K1_H
     8#define __SOUND_EMU10K1_H
     9
    2910
    3011#include <sound/pcm.h>
     
    3718#include <linux/interrupt.h>
    3819#include <linux/mutex.h>
    39 
    40 #include <asm/io.h>
     20#include <linux/firmware.h>
     21#include <linux/io.h>
     22
     23#include <uapi/sound/emu10k1.h>
    4124
    4225/* ------------------- DEFINES -------------------- */
     
    4427#define EMUPAGESIZE     4096
    4528#define MAXREQVOICES    8
    46 #define MAXPAGES        8192
     29#define MAXPAGES0       4096    /* 32 bit mode */
     30#define MAXPAGES1       8192    /* 31 bit mode */
    4731#define RESERVED        0
    4832#define NUM_MIDI        16
     
    5337/* FIXME? - according to the OSS driver the EMU10K1 needs a 29 bit DMA mask */
    5438#define EMU10K1_DMA_MASK        0x7fffffffUL    /* 31bit */
    55 #define AUDIGY_DMA_MASK         0x7fffffffUL    /* 31bit FIXME - 32 should work? */
    56                                                 /* See ALSA bug #1276 - rlrevell */
     39#define AUDIGY_DMA_MASK         0xffffffffUL    /* 32bit mode */
    5740
    5841#define TMEMSIZE        256*1024
     
    439422#define CCCA_CURRADDR           0x18000008
    440423
    441 /* undefine CCR to avoid conflict with the definition for SH */
    442 #undef CCR
    443424#define CCR                     0x09            /* Cache control register                               */
    444425#define CCR_CACHEINVALIDSIZE    0x07190009
     
    471452#define MAPB                    0x0d            /* Cache map B                                          */
    472453
    473 #define MAP_PTE_MASK            0xffffe000      /* The 19 MSBs of the PTE indexed by the PTI            */
    474 #define MAP_PTI_MASK            0x00001fff      /* The 13 bit index to one of the 8192 PTE dwords       */
     454#define MAP_PTE_MASK0           0xfffff000      /* The 20 MSBs of the PTE indexed by the PTI            */
     455#define MAP_PTI_MASK0           0x00000fff      /* The 12 bit index to one of the 4096 PTE dwords       */
     456
     457#define MAP_PTE_MASK1           0xffffe000      /* The 19 MSBs of the PTE indexed by the PTI            */
     458#define MAP_PTI_MASK1           0x00001fff      /* The 13 bit index to one of the 8192 PTE dwords       */
    475459
    476460/* 0x0e, 0x0f: Not used */
     
    16121596        unsigned int tram_pos;
    16131597        unsigned int tram_shift;
    1614         struct snd_emu10k1_fx8010_irq *irq;
     1598        struct snd_emu10k1_fx8010_irq irq;
    16151599};
    16161600
     
    16901674        unsigned int optical_in; /* 0:SPDIF, 1:ADAT */
    16911675        unsigned int optical_out; /* 0:SPDIF, 1:ADAT */
    1692         struct task_struct *firmware_thread;
     1676        struct delayed_work firmware_work;
     1677        u32 last_reg;
    16931678};
    16941679
     
    17091694        unsigned int card_type;                 /* EMU10K1_CARD_* */
    17101695        unsigned int ecard_ctrl;                /* ecard control bits */
     1696        unsigned int address_mode;              /* address mode */
    17111697        unsigned long dma_mask;                 /* PCI DMA mask */
     1698        bool iommu_workaround;                  /* IOMMU workaround needed */
    17121699        unsigned int delay_pcm_irq;             /* in samples */
    17131700        int max_cache_pages;                    /* max memory size / PAGE_SIZE */
     
    17181705
    17191706        struct snd_util_memhdr *memhdr;         /* page allocation list */
    1720         struct snd_emu10k1_memblk *reserved_page;       /* reserved page */
    17211707
    17221708        struct list_head mapped_link_head;
     
    17891775        unsigned int next_free_voice;
    17901776
    1791 #ifdef CONFIG_PM
     1777        const struct firmware *firmware;
     1778        const struct firmware *dock_fw;
     1779
     1780#ifdef CONFIG_PM_SLEEP
    17921781        unsigned int *saved_ptr;
    17931782        unsigned int *saved_gpr;
     
    17971786        unsigned int *p16v_saved;
    17981787        unsigned int saved_a_iocfg, saved_hcfg;
     1788        bool suspend;
    17991789#endif
    18001790
     
    18101800                       struct snd_emu10k1 ** remu);
    18111801
    1812 int snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm);
    1813 int snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm);
    1814 int snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm);
    1815 int snd_p16v_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm);
     1802int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device);
     1803int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device);
     1804int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device);
     1805int snd_p16v_pcm(struct snd_emu10k1 *emu, int device);
    18161806int snd_p16v_free(struct snd_emu10k1 * emu);
    18171807int snd_p16v_mixer(struct snd_emu10k1 * emu);
    1818 int snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm);
    1819 int snd_emu10k1_fx8010_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm);
     1808int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device);
     1809int snd_emu10k1_fx8010_pcm(struct snd_emu10k1 *emu, int device);
    18201810int snd_emu10k1_mixer(struct snd_emu10k1 * emu, int pcm_device, int multi_device);
    18211811int snd_emu10k1_timer(struct snd_emu10k1 * emu, int device);
    1822 int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep);
     1812int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device);
    18231813
    18241814irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id);
     
    18571847unsigned int snd_emu10k1_rate_to_pitch(unsigned int rate);
    18581848
    1859 #ifdef CONFIG_PM
     1849#ifdef CONFIG_PM_SLEEP
    18601850void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu);
    18611851void snd_emu10k1_resume_init(struct snd_emu10k1 *emu);
     
    18741864struct snd_util_memblk *snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream);
    18751865int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk);
     1866int snd_emu10k1_alloc_pages_maybe_wider(struct snd_emu10k1 *emu, size_t size,
     1867                                        struct snd_dma_buffer *dmab);
    18761868struct snd_util_memblk *snd_emu10k1_synth_alloc(struct snd_emu10k1 *emu, unsigned int size);
    18771869int snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *blk);
     
    18961888                                            unsigned char gpr_running,
    18971889                                            void *private_data,
    1898                                             struct snd_emu10k1_fx8010_irq **r_irq);
     1890                                            struct snd_emu10k1_fx8010_irq *irq);
    18991891int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu,
    19001892                                              struct snd_emu10k1_fx8010_irq *irq);
    19011893
    1902 #endif /* __KERNEL__ */
    1903 
    1904 /*
    1905  * ---- FX8010 ----
    1906  */
    1907 
    1908 #define EMU10K1_CARD_CREATIVE                   0x00000000
    1909 #define EMU10K1_CARD_EMUAPS                     0x00000001
    1910 
    1911 #define EMU10K1_FX8010_PCM_COUNT                8
    1912 
    1913 /* instruction set */
    1914 #define iMAC0    0x00   /* R = A + (X * Y >> 31)   ; saturation */
    1915 #define iMAC1    0x01   /* R = A + (-X * Y >> 31)  ; saturation */
    1916 #define iMAC2    0x02   /* R = A + (X * Y >> 31)   ; wraparound */
    1917 #define iMAC3    0x03   /* R = A + (-X * Y >> 31)  ; wraparound */
    1918 #define iMACINT0 0x04   /* R = A + X * Y           ; saturation */
    1919 #define iMACINT1 0x05   /* R = A + X * Y           ; wraparound (31-bit) */
    1920 #define iACC3    0x06   /* R = A + X + Y           ; saturation */
    1921 #define iMACMV   0x07   /* R = A, acc += X * Y >> 31 */
    1922 #define iANDXOR  0x08   /* R = (A & X) ^ Y */
    1923 #define iTSTNEG  0x09   /* R = (A >= Y) ? X : ~X */
    1924 #define iLIMITGE 0x0a   /* R = (A >= Y) ? X : Y */
    1925 #define iLIMITLT 0x0b   /* R = (A < Y) ? X : Y */
    1926 #define iLOG     0x0c   /* R = linear_data, A (log_data), X (max_exp), Y (format_word) */
    1927 #define iEXP     0x0d   /* R = log_data, A (linear_data), X (max_exp), Y (format_word) */
    1928 #define iINTERP  0x0e   /* R = A + (X * (Y - A) >> 31)  ; saturation */
    1929 #define iSKIP    0x0f   /* R = A (cc_reg), X (count), Y (cc_test) */
    1930 
    1931 /* GPRs */
    1932 #define FXBUS(x)        (0x00 + (x))    /* x = 0x00 - 0x0f */
    1933 #define EXTIN(x)        (0x10 + (x))    /* x = 0x00 - 0x0f */
    1934 #define EXTOUT(x)       (0x20 + (x))    /* x = 0x00 - 0x0f physical outs -> FXWC low 16 bits */
    1935 #define FXBUS2(x)       (0x30 + (x))    /* x = 0x00 - 0x0f copies of fx buses for capture -> FXWC high 16 bits */
    1936                                         /* NB: 0x31 and 0x32 are shared with Center/LFE on SB live 5.1 */
    1937 
    1938 #define C_00000000      0x40
    1939 #define C_00000001      0x41
    1940 #define C_00000002      0x42
    1941 #define C_00000003      0x43
    1942 #define C_00000004      0x44
    1943 #define C_00000008      0x45
    1944 #define C_00000010      0x46
    1945 #define C_00000020      0x47
    1946 #define C_00000100      0x48
    1947 #define C_00010000      0x49
    1948 #define C_00080000      0x4a
    1949 #define C_10000000      0x4b
    1950 #define C_20000000      0x4c
    1951 #define C_40000000      0x4d
    1952 #define C_80000000      0x4e
    1953 #define C_7fffffff      0x4f
    1954 #define C_ffffffff      0x50
    1955 #define C_fffffffe      0x51
    1956 #define C_c0000000      0x52
    1957 #define C_4f1bbcdc      0x53
    1958 #define C_5a7ef9db      0x54
    1959 #define C_00100000      0x55            /* ?? */
    1960 #define GPR_ACCU        0x56            /* ACCUM, accumulator */
    1961 #define GPR_COND        0x57            /* CCR, condition register */
    1962 #define GPR_NOISE0      0x58            /* noise source */
    1963 #define GPR_NOISE1      0x59            /* noise source */
    1964 #define GPR_IRQ         0x5a            /* IRQ register */
    1965 #define GPR_DBAC        0x5b            /* TRAM Delay Base Address Counter */
    1966 #define GPR(x)          (FXGPREGBASE + (x)) /* free GPRs: x = 0x00 - 0xff */
    1967 #define ITRAM_DATA(x)   (TANKMEMDATAREGBASE + 0x00 + (x)) /* x = 0x00 - 0x7f */
    1968 #define ETRAM_DATA(x)   (TANKMEMDATAREGBASE + 0x80 + (x)) /* x = 0x00 - 0x1f */
    1969 #define ITRAM_ADDR(x)   (TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0x7f */
    1970 #define ETRAM_ADDR(x)   (TANKMEMADDRREGBASE + 0x80 + (x)) /* x = 0x00 - 0x1f */
    1971 
    1972 #define A_ITRAM_DATA(x) (TANKMEMDATAREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
    1973 #define A_ETRAM_DATA(x) (TANKMEMDATAREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
    1974 #define A_ITRAM_ADDR(x) (TANKMEMADDRREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
    1975 #define A_ETRAM_ADDR(x) (TANKMEMADDRREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
    1976 #define A_ITRAM_CTL(x)  (A_TANKMEMCTLREGBASE + 0x00 + (x)) /* x = 0x00 - 0xbf */
    1977 #define A_ETRAM_CTL(x)  (A_TANKMEMCTLREGBASE + 0xc0 + (x)) /* x = 0x00 - 0x3f */
    1978 
    1979 #define A_FXBUS(x)      (0x00 + (x))    /* x = 0x00 - 0x3f FX buses */
    1980 #define A_EXTIN(x)      (0x40 + (x))    /* x = 0x00 - 0x0f physical ins */
    1981 #define A_P16VIN(x)     (0x50 + (x))    /* x = 0x00 - 0x0f p16v ins (A2 only) "EMU32 inputs" */
    1982 #define A_EXTOUT(x)     (0x60 + (x))    /* x = 0x00 - 0x1f physical outs -> A_FXWC1 0x79-7f unknown   */
    1983 #define A_FXBUS2(x)     (0x80 + (x))    /* x = 0x00 - 0x1f extra outs used for EFX capture -> A_FXWC2 */
    1984 #define A_EMU32OUTH(x)  (0xa0 + (x))    /* x = 0x00 - 0x0f "EMU32_OUT_10 - _1F" - ??? */
    1985 #define A_EMU32OUTL(x)  (0xb0 + (x))    /* x = 0x00 - 0x0f "EMU32_OUT_1 - _F" - ??? */
    1986 #define A3_EMU32IN(x)   (0x160 + (x))   /* x = 0x00 - 0x3f "EMU32_IN_00 - _3F" - Only when .device = 0x0008 */
    1987 #define A3_EMU32OUT(x)  (0x1E0 + (x))   /* x = 0x00 - 0x0f "EMU32_OUT_00 - _3F" - Only when .device = 0x0008 */
    1988 #define A_GPR(x)        (A_FXGPREGBASE + (x))
    1989 
    1990 /* cc_reg constants */
    1991 #define CC_REG_NORMALIZED C_00000001
    1992 #define CC_REG_BORROW   C_00000002
    1993 #define CC_REG_MINUS    C_00000004
    1994 #define CC_REG_ZERO     C_00000008
    1995 #define CC_REG_SATURATE C_00000010
    1996 #define CC_REG_NONZERO  C_00000100
    1997 
    1998 /* FX buses */
    1999 #define FXBUS_PCM_LEFT          0x00
    2000 #define FXBUS_PCM_RIGHT         0x01
    2001 #define FXBUS_PCM_LEFT_REAR     0x02
    2002 #define FXBUS_PCM_RIGHT_REAR    0x03
    2003 #define FXBUS_MIDI_LEFT         0x04
    2004 #define FXBUS_MIDI_RIGHT        0x05
    2005 #define FXBUS_PCM_CENTER        0x06
    2006 #define FXBUS_PCM_LFE           0x07
    2007 #define FXBUS_PCM_LEFT_FRONT    0x08
    2008 #define FXBUS_PCM_RIGHT_FRONT   0x09
    2009 #define FXBUS_MIDI_REVERB       0x0c
    2010 #define FXBUS_MIDI_CHORUS       0x0d
    2011 #define FXBUS_PCM_LEFT_SIDE     0x0e
    2012 #define FXBUS_PCM_RIGHT_SIDE    0x0f
    2013 #define FXBUS_PT_LEFT           0x14
    2014 #define FXBUS_PT_RIGHT          0x15
    2015 
    2016 /* Inputs */
    2017 #define EXTIN_AC97_L       0x00 /* AC'97 capture channel - left */
    2018 #define EXTIN_AC97_R       0x01 /* AC'97 capture channel - right */
    2019 #define EXTIN_SPDIF_CD_L   0x02 /* internal S/PDIF CD - onboard - left */
    2020 #define EXTIN_SPDIF_CD_R   0x03 /* internal S/PDIF CD - onboard - right */
    2021 #define EXTIN_ZOOM_L       0x04 /* Zoom Video I2S - left */
    2022 #define EXTIN_ZOOM_R       0x05 /* Zoom Video I2S - right */
    2023 #define EXTIN_TOSLINK_L    0x06 /* LiveDrive - TOSLink Optical - left */
    2024 #define EXTIN_TOSLINK_R    0x07 /* LiveDrive - TOSLink Optical - right */
    2025 #define EXTIN_LINE1_L      0x08 /* LiveDrive - Line/Mic 1 - left */
    2026 #define EXTIN_LINE1_R      0x09 /* LiveDrive - Line/Mic 1 - right */
    2027 #define EXTIN_COAX_SPDIF_L 0x0a /* LiveDrive - Coaxial S/PDIF - left */
    2028 #define EXTIN_COAX_SPDIF_R 0x0b /* LiveDrive - Coaxial S/PDIF - right */
    2029 #define EXTIN_LINE2_L      0x0c /* LiveDrive - Line/Mic 2 - left */
    2030 #define EXTIN_LINE2_R      0x0d /* LiveDrive - Line/Mic 2 - right */
    2031 
    2032 /* Outputs */
    2033 #define EXTOUT_AC97_L      0x00 /* AC'97 playback channel - left */
    2034 #define EXTOUT_AC97_R      0x01 /* AC'97 playback channel - right */
    2035 #define EXTOUT_TOSLINK_L   0x02 /* LiveDrive - TOSLink Optical - left */
    2036 #define EXTOUT_TOSLINK_R   0x03 /* LiveDrive - TOSLink Optical - right */
    2037 #define EXTOUT_AC97_CENTER 0x04 /* SB Live 5.1 - center */
    2038 #define EXTOUT_AC97_LFE    0x05 /* SB Live 5.1 - LFE */
    2039 #define EXTOUT_HEADPHONE_L 0x06 /* LiveDrive - Headphone - left */
    2040 #define EXTOUT_HEADPHONE_R 0x07 /* LiveDrive - Headphone - right */
    2041 #define EXTOUT_REAR_L      0x08 /* Rear channel - left */
    2042 #define EXTOUT_REAR_R      0x09 /* Rear channel - right */
    2043 #define EXTOUT_ADC_CAP_L   0x0a /* ADC Capture buffer - left */
    2044 #define EXTOUT_ADC_CAP_R   0x0b /* ADC Capture buffer - right */
    2045 #define EXTOUT_MIC_CAP     0x0c /* MIC Capture buffer */
    2046 #define EXTOUT_AC97_REAR_L 0x0d /* SB Live 5.1 (c) 2003 - Rear Left */
    2047 #define EXTOUT_AC97_REAR_R 0x0e /* SB Live 5.1 (c) 2003 - Rear Right */
    2048 #define EXTOUT_ACENTER     0x11 /* Analog Center */
    2049 #define EXTOUT_ALFE        0x12 /* Analog LFE */
    2050 
    2051 /* Audigy Inputs */
    2052 #define A_EXTIN_AC97_L          0x00    /* AC'97 capture channel - left */
    2053 #define A_EXTIN_AC97_R          0x01    /* AC'97 capture channel - right */
    2054 #define A_EXTIN_SPDIF_CD_L      0x02    /* digital CD left */
    2055 #define A_EXTIN_SPDIF_CD_R      0x03    /* digital CD left */
    2056 #define A_EXTIN_OPT_SPDIF_L     0x04    /* audigy drive Optical SPDIF - left */
    2057 #define A_EXTIN_OPT_SPDIF_R     0x05    /*                              right */
    2058 #define A_EXTIN_LINE2_L         0x08    /* audigy drive line2/mic2 - left */
    2059 #define A_EXTIN_LINE2_R         0x09    /*                           right */
    2060 #define A_EXTIN_ADC_L           0x0a    /* Philips ADC - left */
    2061 #define A_EXTIN_ADC_R           0x0b    /*               right */
    2062 #define A_EXTIN_AUX2_L          0x0c    /* audigy drive aux2 - left */
    2063 #define A_EXTIN_AUX2_R          0x0d    /*                   - right */
    2064 
    2065 /* Audigiy Outputs */
    2066 #define A_EXTOUT_FRONT_L        0x00    /* digital front left */
    2067 #define A_EXTOUT_FRONT_R        0x01    /*               right */
    2068 #define A_EXTOUT_CENTER         0x02    /* digital front center */
    2069 #define A_EXTOUT_LFE            0x03    /* digital front lfe */
    2070 #define A_EXTOUT_HEADPHONE_L    0x04    /* headphone audigy drive left */
    2071 #define A_EXTOUT_HEADPHONE_R    0x05    /*                        right */
    2072 #define A_EXTOUT_REAR_L         0x06    /* digital rear left */
    2073 #define A_EXTOUT_REAR_R         0x07    /*              right */
    2074 #define A_EXTOUT_AFRONT_L       0x08    /* analog front left */
    2075 #define A_EXTOUT_AFRONT_R       0x09    /*              right */
    2076 #define A_EXTOUT_ACENTER        0x0a    /* analog center */
    2077 #define A_EXTOUT_ALFE           0x0b    /* analog LFE */
    2078 #define A_EXTOUT_ASIDE_L        0x0c    /* analog side left  - Audigy 2 ZS */
    2079 #define A_EXTOUT_ASIDE_R        0x0d    /*             right - Audigy 2 ZS */
    2080 #define A_EXTOUT_AREAR_L        0x0e    /* analog rear left */
    2081 #define A_EXTOUT_AREAR_R        0x0f    /*             right */
    2082 #define A_EXTOUT_AC97_L         0x10    /* AC97 left (front) */
    2083 #define A_EXTOUT_AC97_R         0x11    /*      right */
    2084 #define A_EXTOUT_ADC_CAP_L      0x16    /* ADC capture buffer left */
    2085 #define A_EXTOUT_ADC_CAP_R      0x17    /*                    right */
    2086 #define A_EXTOUT_MIC_CAP        0x18    /* Mic capture buffer */
    2087 
    2088 /* Audigy constants */
    2089 #define A_C_00000000    0xc0
    2090 #define A_C_00000001    0xc1
    2091 #define A_C_00000002    0xc2
    2092 #define A_C_00000003    0xc3
    2093 #define A_C_00000004    0xc4
    2094 #define A_C_00000008    0xc5
    2095 #define A_C_00000010    0xc6
    2096 #define A_C_00000020    0xc7
    2097 #define A_C_00000100    0xc8
    2098 #define A_C_00010000    0xc9
    2099 #define A_C_00000800    0xca
    2100 #define A_C_10000000    0xcb
    2101 #define A_C_20000000    0xcc
    2102 #define A_C_40000000    0xcd
    2103 #define A_C_80000000    0xce
    2104 #define A_C_7fffffff    0xcf
    2105 #define A_C_ffffffff    0xd0
    2106 #define A_C_fffffffe    0xd1
    2107 #define A_C_c0000000    0xd2
    2108 #define A_C_4f1bbcdc    0xd3
    2109 #define A_C_5a7ef9db    0xd4
    2110 #define A_C_00100000    0xd5
    2111 #define A_GPR_ACCU      0xd6            /* ACCUM, accumulator */
    2112 #define A_GPR_COND      0xd7            /* CCR, condition register */
    2113 #define A_GPR_NOISE0    0xd8            /* noise source */
    2114 #define A_GPR_NOISE1    0xd9            /* noise source */
    2115 #define A_GPR_IRQ       0xda            /* IRQ register */
    2116 #define A_GPR_DBAC      0xdb            /* TRAM Delay Base Address Counter - internal */
    2117 #define A_GPR_DBACE     0xde            /* TRAM Delay Base Address Counter - external */
    2118 
    2119 /* definitions for debug register */
    2120 #define EMU10K1_DBG_ZC                  0x80000000      /* zero tram counter */
    2121 #define EMU10K1_DBG_SATURATION_OCCURED  0x02000000      /* saturation control */
    2122 #define EMU10K1_DBG_SATURATION_ADDR     0x01ff0000      /* saturation address */
    2123 #define EMU10K1_DBG_SINGLE_STEP         0x00008000      /* single step mode */
    2124 #define EMU10K1_DBG_STEP                0x00004000      /* start single step */
    2125 #define EMU10K1_DBG_CONDITION_CODE      0x00003e00      /* condition code */
    2126 #define EMU10K1_DBG_SINGLE_STEP_ADDR    0x000001ff      /* single step address */
    2127 
    2128 /* tank memory address line */
    2129 #ifndef __KERNEL__
    2130 #define TANKMEMADDRREG_ADDR_MASK 0x000fffff     /* 20 bit tank address field                    */
    2131 #define TANKMEMADDRREG_CLEAR     0x00800000     /* Clear tank memory                            */
    2132 #define TANKMEMADDRREG_ALIGN     0x00400000     /* Align read or write relative to tank access  */
    2133 #define TANKMEMADDRREG_WRITE     0x00200000     /* Write to tank memory                         */
    2134 #define TANKMEMADDRREG_READ      0x00100000     /* Read from tank memory                        */
    2135 #endif
    2136 
    2137 struct snd_emu10k1_fx8010_info {
    2138         unsigned int internal_tram_size;        /* in samples */
    2139         unsigned int external_tram_size;        /* in samples */
    2140         char fxbus_names[16][32];               /* names of FXBUSes */
    2141         char extin_names[16][32];               /* names of external inputs */
    2142         char extout_names[32][32];              /* names of external outputs */
    2143         unsigned int gpr_controls;              /* count of GPR controls */
    2144 };
    2145 
    2146 #define EMU10K1_GPR_TRANSLATION_NONE            0
    2147 #define EMU10K1_GPR_TRANSLATION_TABLE100        1
    2148 #define EMU10K1_GPR_TRANSLATION_BASS            2
    2149 #define EMU10K1_GPR_TRANSLATION_TREBLE          3
    2150 #define EMU10K1_GPR_TRANSLATION_ONOFF           4
    2151 
    2152 struct snd_emu10k1_fx8010_control_gpr {
    2153         struct snd_ctl_elem_id id;              /* full control ID definition */
    2154         unsigned int vcount;            /* visible count */
    2155         unsigned int count;             /* count of GPR (1..16) */
    2156         unsigned short gpr[32];         /* GPR number(s) */
    2157         unsigned int value[32];         /* initial values */
    2158         unsigned int min;               /* minimum range */
    2159         unsigned int max;               /* maximum range */
    2160         unsigned int translation;       /* translation type (EMU10K1_GPR_TRANSLATION*) */
    2161         const unsigned int *tlv;
    2162 };
    2163 
    2164 /* old ABI without TLV support */
    2165 struct snd_emu10k1_fx8010_control_old_gpr {
    2166         struct snd_ctl_elem_id id;
    2167         unsigned int vcount;
    2168         unsigned int count;
    2169         unsigned short gpr[32];
    2170         unsigned int value[32];
    2171         unsigned int min;
    2172         unsigned int max;
    2173         unsigned int translation;
    2174 };
    2175 
    2176 struct snd_emu10k1_fx8010_code {
    2177         char name[128];
    2178 
    2179         DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */
    2180         __u32 __user *gpr_map;          /* initializers */
    2181 
    2182         unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */
    2183         struct snd_emu10k1_fx8010_control_gpr __user *gpr_add_controls; /* GPR controls to add/replace */
    2184 
    2185         unsigned int gpr_del_control_count; /* count of GPR controls to remove */
    2186         struct snd_ctl_elem_id __user *gpr_del_controls; /* IDs of GPR controls to remove */
    2187 
    2188         unsigned int gpr_list_control_count; /* count of GPR controls to list */
    2189         unsigned int gpr_list_control_total; /* total count of GPR controls */
    2190         struct snd_emu10k1_fx8010_control_gpr __user *gpr_list_controls; /* listed GPR controls */
    2191 
    2192         DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */
    2193         __u32 __user *tram_data_map;      /* data initializers */
    2194         __u32 __user *tram_addr_map;      /* map initializers */
    2195 
    2196         DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */
    2197         __u32 __user *code;               /* one instruction - 64 bits */
    2198 };
    2199 
    2200 struct snd_emu10k1_fx8010_tram {
    2201         unsigned int address;           /* 31.bit == 1 -> external TRAM */
    2202         unsigned int size;              /* size in samples (4 bytes) */
    2203         unsigned int *samples;          /* pointer to samples (20-bit) */
    2204                                         /* NULL->clear memory */
    2205 };
    2206 
    2207 struct snd_emu10k1_fx8010_pcm_rec {
    2208         unsigned int substream;         /* substream number */
    2209         unsigned int res1;              /* reserved */
    2210         unsigned int channels;          /* 16-bit channels count, zero = remove this substream */
    2211         unsigned int tram_start;        /* ring buffer position in TRAM (in samples) */
    2212         unsigned int buffer_size;       /* count of buffered samples */
    2213         unsigned short gpr_size;                /* GPR containing size of ringbuffer in samples (host) */
    2214         unsigned short gpr_ptr;         /* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
    2215         unsigned short gpr_count;       /* GPR containing count of samples between two interrupts (host) */
    2216         unsigned short gpr_tmpcount;    /* GPR containing current count of samples to interrupt (host = set, FX8010) */
    2217         unsigned short gpr_trigger;     /* GPR containing trigger (activate) information (host) */
    2218         unsigned short gpr_running;     /* GPR containing info if PCM is running (FX8010) */
    2219         unsigned char pad;              /* reserved */
    2220         unsigned char etram[32];        /* external TRAM address & data (one per channel) */
    2221         unsigned int res2;              /* reserved */
    2222 };
    2223 
    2224 #define SNDRV_EMU10K1_VERSION           SNDRV_PROTOCOL_VERSION(1, 0, 1)
    2225 
    2226 #define SNDRV_EMU10K1_IOCTL_INFO        _IOR ('H', 0x10, struct snd_emu10k1_fx8010_info)
    2227 #define SNDRV_EMU10K1_IOCTL_CODE_POKE   _IOW ('H', 0x11, struct snd_emu10k1_fx8010_code)
    2228 #define SNDRV_EMU10K1_IOCTL_CODE_PEEK   _IOWR('H', 0x12, struct snd_emu10k1_fx8010_code)
    2229 #define SNDRV_EMU10K1_IOCTL_TRAM_SETUP  _IOW ('H', 0x20, int)
    2230 #define SNDRV_EMU10K1_IOCTL_TRAM_POKE   _IOW ('H', 0x21, struct snd_emu10k1_fx8010_tram)
    2231 #define SNDRV_EMU10K1_IOCTL_TRAM_PEEK   _IOWR('H', 0x22, struct snd_emu10k1_fx8010_tram)
    2232 #define SNDRV_EMU10K1_IOCTL_PCM_POKE    _IOW ('H', 0x30, struct snd_emu10k1_fx8010_pcm_rec)
    2233 #define SNDRV_EMU10K1_IOCTL_PCM_PEEK    _IOWR('H', 0x31, struct snd_emu10k1_fx8010_pcm_rec)
    2234 #define SNDRV_EMU10K1_IOCTL_PVERSION    _IOR ('H', 0x40, int)
    2235 #define SNDRV_EMU10K1_IOCTL_STOP        _IO  ('H', 0x80)
    2236 #define SNDRV_EMU10K1_IOCTL_CONTINUE    _IO  ('H', 0x81)
    2237 #define SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER _IO ('H', 0x82)
    2238 #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int)
    2239 #define SNDRV_EMU10K1_IOCTL_DBG_READ    _IOR ('H', 0x84, int)
    2240 
    2241 /* typedefs for compatibility to user-space */
    2242 typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t;
    2243 typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t;
    2244 typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t;
    2245 typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t;
    2246 typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t;
    2247 
    22481894#endif  /* __SOUND_EMU10K1_H */
  • GPL/trunk/alsa-kernel/include/sound/emu10k1_synth.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __EMU10K1_SYNTH_H
    23#define __EMU10K1_SYNTH_H
     
    56 *
    67 *  Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
    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
    23 #include "emu10k1.h"
    24 #include "emux_synth.h"
     10#include <sound/emu10k1.h>
     11#include <sound/emux_synth.h>
    2512
    2613/* sequencer device id */
  • GPL/trunk/alsa-kernel/include/sound/emu8000.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_EMU8000_H
    23#define __SOUND_EMU8000_H
     
    67 *  Copyright (C) 1999 Steve Ratcliffe
    78 *  Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    229 */
    2310
    24 #include "emux_synth.h"
    25 #include "seq_kernel.h"
     11#include <sound/emux_synth.h>
     12#include <sound/seq_kernel.h>
    2613
    2714/*
  • GPL/trunk/alsa-kernel/include/sound/emu8000_reg.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_EMU8000_REG_H
    23#define __SOUND_EMU8000_REG_H
     
    78 *
    89 *  Based on awe_wave.c by Takashi Iwai
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    2410 */
    2511
  • GPL/trunk/alsa-kernel/include/sound/emux_legacy.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_EMUX_LEGACY_H
    23#define __SOUND_EMUX_LEGACY_H
     
    67 *
    78 *  Definitions of OSS compatible headers for Emu8000 device informations
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    239 */
    2410
    25 #include "seq_oss_legacy.h"
     11#include <sound/seq_oss_legacy.h>
    2612
    2713/*
  • GPL/trunk/alsa-kernel/include/sound/emux_synth.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_EMUX_SYNTH_H
    23#define __SOUND_EMUX_SYNTH_H
     
    67 *
    78 *  Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  */
    23 
    24 #include "seq_kernel.h"
    25 #include "seq_device.h"
    26 #include "soundfont.h"
    27 #include "seq_midi_emul.h"
    28 #ifdef CONFIG_SND_SEQUENCER_OSS
    29 #include "seq_oss.h"
    30 #endif
    31 #include "emux_legacy.h"
    32 #include "seq_virmidi.h"
     9 */
     10
     11#include <sound/seq_kernel.h>
     12#include <sound/seq_device.h>
     13#include <sound/soundfont.h>
     14#include <sound/seq_midi_emul.h>
     15#include <sound/seq_oss.h>
     16#include <sound/emux_legacy.h>
     17#include <sound/seq_virmidi.h>
    3318
    3419/*
     
    6752        void (*sysex)(struct snd_emux *emu, char *buf, int len, int parsed,
    6853                      struct snd_midi_channel_set *chset);
    69 #ifdef CONFIG_SND_SEQUENCER_OSS
     54#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
    7055        int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2);
    7156#endif
     
    126111        struct snd_util_memhdr *memhdr; /* memory chunk information */
    127112
    128 #ifdef CONFIG_PROC_FS
     113#ifdef CONFIG_SND_PROC_FS
    129114        struct snd_info_entry *proc;
    130115#endif
    131116
    132 #ifdef CONFIG_SND_SEQUENCER_OSS
     117#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
    133118        struct snd_seq_device *oss_synth;
    134119#endif
     
    151136        struct snd_emux_effect_table *effect;
    152137#endif
    153 #ifdef CONFIG_SND_SEQUENCER_OSS
     138#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
    154139        struct snd_seq_oss_arg *oss_arg;
    155140#endif
  • GPL/trunk/alsa-kernel/include/sound/es1688.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_ES1688_H
    23#define __SOUND_ES1688_H
     
    56 *  Header file for ES488/ES1688
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
    25 #include "control.h"
    26 #include "pcm.h"
     10#include <sound/control.h>
     11#include <sound/pcm.h>
    2712#include <linux/interrupt.h>
    2813
     
    3015#define ES1688_HW_688           0x0001
    3116#define ES1688_HW_1688          0x0002
     17#define ES1688_HW_UNDEF 0x0003
    3218
    3319struct snd_es1688 {
     
    115101                      int dma8,
    116102                      unsigned short hardware);
    117 int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device,
    118                    struct snd_pcm **rpcm);
     103int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device);
    119104int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip);
    120105int snd_es1688_reset(struct snd_es1688 *chip);
  • GPL/trunk/alsa-kernel/include/sound/gus.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_GUS_H
    23#define __SOUND_GUS_H
     
    56 *  Global structures used for GUS part of ALSA driver
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
    25 #include "pcm.h"
    26 #include "rawmidi.h"
    27 #include "timer.h"
    28 #include "seq_midi_emul.h"
    29 #include "seq_device.h"
    30 #include <asm/io.h>
     10#include <sound/pcm.h>
     11#include <sound/rawmidi.h>
     12#include <sound/timer.h>
     13#include <sound/seq_midi_emul.h>
     14#include <sound/seq_device.h>
     15#include <linux/io.h>
    3116
    3217/* IO ports */
     
    592577/* gus_pcm.c */
    593578
    594 int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm);
     579int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index);
    595580
    596581#ifdef CONFIG_SND_DEBUG
     
    621606/* gus_uart.c */
    622607
    623 int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi **rrawmidi);
     608int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device);
    624609
    625610/* gus_dram.c */
     
    629614                      unsigned int addr, unsigned int size, int rom);
    630615
     616/* gus_timer.c */
     617void snd_gf1_timers_init(struct snd_gus_card *gus);
     618void snd_gf1_timers_done(struct snd_gus_card *gus);
     619
    631620#endif /* __SOUND_GUS_H */
  • GPL/trunk/alsa-kernel/include/sound/hda_hwdep.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 * HWDEP Interface for HD-audio codec
    34 *
    45 * Copyright (c) 2007 Takashi Iwai <tiwai@suse.de>
    5  *
    6  *  This driver 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 driver 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
    196 */
    207
  • GPL/trunk/alsa-kernel/include/sound/hwdep.h

    r426 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_HWDEP_H
    23#define __SOUND_HWDEP_H
     
    56 *  Hardware dependent layer
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     
    3823        int (*open)(struct snd_hwdep *hw, struct file * file);
    3924        int (*release)(struct snd_hwdep *hw, struct file * file);
    40         unsigned int (*poll)(struct snd_hwdep *hw, struct file *file,
     25        __poll_t (*poll)(struct snd_hwdep *hw, struct file *file,
    4126                             poll_table *wait);
    4227        int (*ioctl)(struct snd_hwdep *hw, struct file *file,
     
    6146
    6247#ifdef CONFIG_SND_OSSEMUL
    63         char oss_dev[32];
    6448        int oss_type;
    6549        int ossreg;
     
    7054        void *private_data;
    7155        void (*private_free) (struct snd_hwdep *hwdep);
     56        struct device dev;
    7257
    7358        struct mutex open_mutex;
  • GPL/trunk/alsa-kernel/include/sound/i2c.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_I2C_H
    23#define __SOUND_I2C_H
    34
    45/*
    5  *
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    20  *
    21  *
    226 */
    237
     
    6751                void *ops;
    6852        } hw_ops;               /* lowlevel operations */
    69         struct snd_i2c_ops *ops;        /* midlevel operations */
     53        const struct snd_i2c_ops *ops;  /* midlevel operations */
    7054
    7155        unsigned long private_value;
  • GPL/trunk/alsa-kernel/include/sound/info.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_INFO_H
    23#define __SOUND_INFO_H
     
    56 *  Header file for info interface
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
    2510#include <linux/poll.h>
     11#include <linux/seq_file.h>
     12#include <sound/core.h>
    2613
    2714/* buffer for information */
     
    6148                         void *file_private_data, struct file *file,
    6249                         loff_t offset, int orig);
    63         unsigned int (*poll)(struct snd_info_entry *entry,
     50        __poll_t (*poll)(struct snd_info_entry *entry,
    6451                             void *file_private_data, struct file *file,
    6552                             poll_table *wait);
     
    7360struct snd_info_entry {
    7461        const char *name;
    75         mode_t mode;
     62        umode_t mode;
    7663        long size;
    7764        unsigned short content;
    7865        union {
    7966                struct snd_info_entry_text text;
    80                 struct snd_info_entry_ops *ops;
     67                const struct snd_info_entry_ops *ops;
    8168        } c;
    8269        struct snd_info_entry *parent;
    83         struct snd_card *card;
    8470        struct module *module;
    8571        void *private_data;
     
    9177};
    9278
    93 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
     79#if (defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)) || defined(TARGET_OS2)
    9480int snd_info_minor_register(void);
    95 int snd_info_minor_unregister(void);
    96 #else
    97 #define snd_info_minor_register() /* NOP */
    98 #define snd_info_minor_unregister() /* NOP */
    99 #endif
    100 
    101 
    102 #ifdef CONFIG_PROC_FS
     81#else
     82#define snd_info_minor_register()       0
     83#endif
     84
     85
     86#if defined(CONFIG_SND_PROC_FS)
    10387
    10488extern struct snd_info_entry *snd_seq_root;
     
    11195#endif
    11296
     97/**
     98 * snd_iprintf - printf on the procfs buffer
     99 * @buf: the procfs buffer
     100 * @fmt: the printf format
     101 *
     102 * Outputs the string on the procfs buffer just like printf().
     103 *
     104 * Return: zero for success, or a negative error code.
     105 */
    113106#ifndef TARGET_OS2
    114 int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) \
    115                                 __attribute__ ((format (printf, 2, 3)));
    116 #else
    117 int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...);
    118 #endif
     107#define snd_iprintf(buf, fmt, args...) \
     108        seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
     109#else
     110static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
     111#endif
     112
    119113int snd_info_init(void);
    120114int snd_info_done(void);
     
    140134
    141135/* for card drivers */
    142 int snd_card_proc_new(struct snd_card *card, const char *name,
    143                       struct snd_info_entry **entryp);
     136static inline int snd_card_proc_new(struct snd_card *card, const char *name,
     137                                    struct snd_info_entry **entryp)
     138{
     139        *entryp = snd_info_create_card_entry(card, name, card->proc_root);
     140        return *entryp ? 0 : -ENOMEM;
     141}
    144142
    145143static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
     
    150148        entry->c.text.read = read;
    151149}
     150
     151int snd_card_rw_proc_new(struct snd_card *card, const char *name,
     152                         void *private_data,
     153                         void (*read)(struct snd_info_entry *,
     154                                      struct snd_info_buffer *),
     155                         void (*write)(struct snd_info_entry *entry,
     156                                       struct snd_info_buffer *buffer));
    152157
    153158int snd_info_check_reserved_words(const char *str);
     
    177182static inline int snd_card_proc_new(struct snd_card *card, const char *name,
    178183                                    struct snd_info_entry **entryp) { return -EINVAL; }
    179 static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
     184static inline void snd_info_set_text_ops(struct snd_info_entry *entry /*__attribute__((unused))*/,
    180185                                         void *private_data,
    181186                                         void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
    182 
     187static inline int snd_card_rw_proc_new(struct snd_card *card, const char *name,
     188                                       void *private_data,
     189                                       void (*read)(struct snd_info_entry *,
     190                                                    struct snd_info_buffer *),
     191                                       void (*write)(struct snd_info_entry *entry,
     192                                                     struct snd_info_buffer *buffer))
     193{
     194        return 0;
     195}
    183196static inline int snd_info_check_reserved_words(const char *str) { return 1; }
    184197
    185198#endif
     199
     200/**
     201 * snd_card_ro_proc_new - Create a read-only text proc file entry for the card
     202 * @card: the card instance
     203 * @name: the file name
     204 * @private_data: the arbitrary private data
     205 * @read: the read callback
     206 *
     207 * This proc file entry will be registered via snd_card_register() call, and
     208 * it will be removed automatically at the card removal, too.
     209 */
     210static inline int
     211snd_card_ro_proc_new(struct snd_card *card, const char *name,
     212                     void *private_data,
     213                     void (*read)(struct snd_info_entry *,
     214                                  struct snd_info_buffer *))
     215{
     216        return snd_card_rw_proc_new(card, name, private_data, read, NULL);
     217}
    186218
    187219/*
     
    189221 */
    190222
    191 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
     223#if (defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)) || defined(TARGET_OS2)
    192224
    193225#define SNDRV_OSS_INFO_DEV_AUDIO        0
     
    202234#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
    203235
    204 #endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */
     236#endif /* CONFIG_SND_OSSEMUL && CONFIG_SND_PROC_FS */
    205237
    206238#endif /* __SOUND_INFO_H */
  • GPL/trunk/alsa-kernel/include/sound/initval.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_INITVAL_H
    23#define __SOUND_INITVAL_H
     
    56 *  Init values for soundcard modules
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    228 */
    239
     
    3622#define MODULE_DEVICES(val)
    3723#define MODULE_PARM_SYNTAX(id, val)
    38 #define module_param_array(name, type, nump, perm)
    39 #define module_param(name, type, perm)
    4024#else
    4125#define MODULE_CLASSES(val) MODULE_GENERIC_STRING(info_classes, val)
     
    120104#define SNDRV_PORT_DESC         SNDRV_ENABLED ",allows:{{0,0xffff}},base:16"
    121105
     106#ifdef SNDRV_LEGACY_FIND_FREE_IOPORT
     107static long snd_legacy_find_free_ioport(const long *port_table, long size)
     108{
     109        while (*port_table != -1) {
     110                if (request_region(*port_table, size, "ALSA test")) {
     111                        release_region(*port_table, size);
     112                        return *port_table;
     113                }
     114                port_table++;
     115        }
     116        return -1;
     117}
     118#endif
     119
    122120#ifdef SNDRV_LEGACY_FIND_FREE_IRQ
    123121#include <linux/interrupt.h>
     
    128126}
    129127
    130 static int snd_legacy_find_free_irq(int *irq_table)
     128static int snd_legacy_find_free_irq(const int *irq_table)
    131129{
    132130        while (*irq_table != -1) {
    133131                if (!request_irq(*irq_table, snd_legacy_empty_irq_handler,
    134                                  IRQF_DISABLED | IRQF_PROBE_SHARED, "ALSA Test IRQ",
     132                                 IRQF_PROBE_SHARED, "ALSA Test IRQ",
    135133                                 (void *) irq_table)) {
    136134                        free_irq(*irq_table, (void *) irq_table);
     
    144142
    145143#ifdef SNDRV_LEGACY_FIND_FREE_DMA
    146 static int snd_legacy_find_free_dma(int *dma_table)
     144static int snd_legacy_find_free_dma(const int *dma_table)
    147145{
    148146        while (*dma_table != -1) {
  • GPL/trunk/alsa-kernel/include/sound/jack.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_JACK_H
    23#define __SOUND_JACK_H
     
    67 *
    78 *  Copyright 2008 Wolfson Microelectronics plc
    8  *
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    249 */
    2510
     
    2914
    3015/**
    31  * Jack types which can be reported.  These values are used as a
    32  * bitmask.
     16 * enum snd_jack_types - Jack types which can be reported
     17 * @SND_JACK_HEADPHONE: Headphone
     18 * @SND_JACK_MICROPHONE: Microphone
     19 * @SND_JACK_HEADSET: Headset
     20 * @SND_JACK_LINEOUT: Line out
     21 * @SND_JACK_MECHANICAL: Mechanical switch
     22 * @SND_JACK_VIDEOOUT: Video out
     23 * @SND_JACK_AVOUT: AV (Audio Video) out
     24 * @SND_JACK_LINEIN:  Line in
     25 * @SND_JACK_BTN_0: Button 0
     26 * @SND_JACK_BTN_1: Button 1
     27 * @SND_JACK_BTN_2: Button 2
     28 * @SND_JACK_BTN_3: Button 3
     29 * @SND_JACK_BTN_4: Button 4
     30 * @SND_JACK_BTN_5: Button 5
     31 *
     32 * These values are used as a bitmask.
    3333 *
    3434 * Note that this must be kept in sync with the lookup table in
     
    4343        SND_JACK_VIDEOOUT       = 0x0010,
    4444        SND_JACK_AVOUT          = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
     45        SND_JACK_LINEIN         = 0x0020,
    4546
    4647        /* Kept separate from switches to facilitate implementation */
     
    5354};
    5455
     56/* Keep in sync with definitions above */
     57#define SND_JACK_SWITCH_TYPES 6
     58
    5559struct snd_jack {
     60        struct list_head kctl_list;
     61        struct snd_card *card;
     62        const char *id;
     63#ifdef CONFIG_SND_JACK_INPUT_DEV
    5664        struct input_dev *input_dev;
    5765        int registered;
    5866        int type;
    59         const char *id;
    6067        char name[100];
    6168        unsigned int key[6];   /* Keep in sync with definitions above */
     69#endif /* CONFIG_SND_JACK_INPUT_DEV */
    6270        void *private_data;
    6371        void (*private_free)(struct snd_jack *);
     
    6775
    6876int snd_jack_new(struct snd_card *card, const char *id, int type,
    69                  struct snd_jack **jack);
     77                 struct snd_jack **jack, bool initial_kctl, bool phantom_jack);
     78int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask);
     79#ifdef CONFIG_SND_JACK_INPUT_DEV
    7080void snd_jack_set_parent(struct snd_jack *jack, struct device *parent);
    7181int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
    7282                     int keytype);
    73 
     83#endif
    7484void snd_jack_report(struct snd_jack *jack, int status);
    7585
    7686#else
    77 
    7887static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
    79                                struct snd_jack **jack)
     88                               struct snd_jack **jack, bool initial_kctl, bool phantom_jack)
    8089{
    8190        return 0;
    8291}
    8392
    84 static inline void snd_jack_set_parent(struct snd_jack *jack,
    85                                        struct device *parent)
     93static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
    8694{
     95        return 0;
    8796}
    8897
     
    93102#endif
    94103
     104#if !defined(CONFIG_SND_JACK) || !defined(CONFIG_SND_JACK_INPUT_DEV)
     105static inline void snd_jack_set_parent(struct snd_jack *jack,
     106                                       struct device *parent)
     107{
     108}
     109
     110static inline int snd_jack_set_key(struct snd_jack *jack,
     111                                   enum snd_jack_types type,
     112                                   int keytype)
     113{
     114        return 0;
     115}
     116#endif /* !CONFIG_SND_JACK || !CONFIG_SND_JACK_INPUT_DEV */
     117
    95118#endif
  • GPL/trunk/alsa-kernel/include/sound/memalloc.h

    r464 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    45 *
    56 *  Generic memory allocators
    6  *
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    227 */
    238
    249#ifndef __SOUND_MEMALLOC_H
    2510#define __SOUND_MEMALLOC_H
     11
     12#include <asm/page.h>
    2613
    2714struct device;
     
    3522};
    3623
    37 #ifndef snd_dma_pci_data
    38 #define snd_dma_pci_data(pci)   (&(pci)->dev)
    39 #define snd_dma_isa_data()      NULL
    40 #define snd_dma_continuous_data(x)      ((struct device *)(unsigned long)(x))
    41 #endif
     24#define snd_dma_continuous_data(x)      ((struct device *)(__force unsigned long)(x))
    4225
    4326
     
    4831#define SNDRV_DMA_TYPE_CONTINUOUS       1       /* continuous no-DMA memory */
    4932#define SNDRV_DMA_TYPE_DEV              2       /* generic device continuous */
     33#define SNDRV_DMA_TYPE_DEV_UC           5       /* continuous non-cahced */
    5034#ifdef CONFIG_SND_DMA_SGBUF
    5135#define SNDRV_DMA_TYPE_DEV_SG           3       /* generic device SG-buffer */
     36#define SNDRV_DMA_TYPE_DEV_UC_SG        6       /* SG non-cached */
    5237#else
    5338#define SNDRV_DMA_TYPE_DEV_SG   SNDRV_DMA_TYPE_DEV /* no SG-buf support */
     39#define SNDRV_DMA_TYPE_DEV_UC_SG        SNDRV_DMA_TYPE_DEV_UC
    5440#endif
     41#ifdef CONFIG_GENERIC_ALLOCATOR
     42#define SNDRV_DMA_TYPE_DEV_IRAM         4       /* generic device iram-buffer */
     43#else
     44#define SNDRV_DMA_TYPE_DEV_IRAM SNDRV_DMA_TYPE_DEV
     45#endif
     46#define SNDRV_DMA_TYPE_VMALLOC          7       /* vmalloc'ed buffer */
    5547
    5648/*
     
    6456        void *private_data;     /* private for allocator; don't touch */
    6557};
     58
     59/*
     60 * return the pages matching with the given byte size
     61 */
     62static inline unsigned int snd_sgbuf_aligned_pages(size_t size)
     63{
     64        return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
     65}
    6666
    6767#ifdef CONFIG_SND_DMA_SGBUF
     
    8989
    9090/*
    91  * return the pages matching with the given byte size
    92  */
    93 static inline unsigned int snd_sgbuf_aligned_pages(size_t size)
    94 {
    95         return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
    96 }
    97 
    98 /*
    9991 * return the physical address at the corresponding offset
    10092 */
    101 static inline dma_addr_t snd_sgbuf_get_addr(struct snd_sg_buf *sgbuf, size_t offset)
     93static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab,
     94                                           size_t offset)
    10295{
    103         dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr;
    104         addr &= PAGE_MASK;
     96        struct snd_sg_buf *sgbuf = dmab->private_data;
     97        dma_addr_t addr;
     98
     99        if (!sgbuf)
     100                return dmab->addr + offset;
     101        addr = sgbuf->table[offset >> PAGE_SHIFT].addr;
     102        addr &= ~((dma_addr_t)PAGE_SIZE - 1);
    105103        return addr + offset % PAGE_SIZE;
    106104}
     
    109107 * return the virtual address at the corresponding offset
    110108 */
    111 static inline void *snd_sgbuf_get_ptr(struct snd_sg_buf *sgbuf, size_t offset)
     109static inline void *snd_sgbuf_get_ptr(struct snd_dma_buffer *dmab,
     110                                     size_t offset)
    112111{
     112        struct snd_sg_buf *sgbuf = dmab->private_data;
     113
     114        if (!sgbuf)
     115                return dmab->area + offset;
    113116        return sgbuf->table[offset >> PAGE_SHIFT].buf + offset % PAGE_SIZE;
    114117}
     118
     119unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab,
     120                                      unsigned int ofs, unsigned int size);
     121#else
     122/* non-SG versions */
     123static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab,
     124                                            size_t offset)
     125{
     126        return dmab->addr + offset;
     127}
     128
     129static inline void *snd_sgbuf_get_ptr(struct snd_dma_buffer *dmab,
     130                                      size_t offset)
     131{
     132        return dmab->area + offset;
     133}
     134
     135#define snd_sgbuf_get_chunk_size(dmab, ofs, size)       (size)
     136
    115137#endif /* CONFIG_SND_DMA_SGBUF */
    116138
     
    122144void snd_dma_free_pages(struct snd_dma_buffer *dmab);
    123145
    124 /* buffer-preservation managements */
    125 
    126 #define snd_dma_pci_buf_id(pci) (((unsigned int)(pci)->vendor << 16) | (pci)->device)
    127 
    128 size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id);
    129 int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id);
    130 
    131 /* basic memory allocation functions */
    132 void *snd_malloc_pages(size_t size, gfp_t gfp_flags);
    133 void snd_free_pages(void *ptr, size_t size);
    134 
    135146#endif /* __SOUND_MEMALLOC_H */
    136147
  • GPL/trunk/alsa-kernel/include/sound/minors.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_MINORS_H
    23#define __SOUND_MINORS_H
     
    45/*
    56 *  MINOR numbers
    6  *
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    227 */
    238
     
    3621
    3722#ifndef CONFIG_SND_DYNAMIC_MINORS
    38                                                 /* 2 - 3 (reserved) */
     23#define SNDRV_MINOR_COMPRESS            2       /* 2 - 3 */
    3924#define SNDRV_MINOR_HWDEP               4       /* 4 - 7 */
    4025#define SNDRV_MINOR_RAWMIDI             8       /* 8 - 15 */
     
    5035#define SNDRV_DEVICE_TYPE_SEQUENCER     SNDRV_MINOR_SEQUENCER
    5136#define SNDRV_DEVICE_TYPE_TIMER         SNDRV_MINOR_TIMER
     37#define SNDRV_DEVICE_TYPE_COMPRESS      SNDRV_MINOR_COMPRESS
    5238
    5339#else /* CONFIG_SND_DYNAMIC_MINORS */
     
    6147        SNDRV_DEVICE_TYPE_PCM_PLAYBACK,
    6248        SNDRV_DEVICE_TYPE_PCM_CAPTURE,
     49        SNDRV_DEVICE_TYPE_COMPRESS,
    6350};
    6451
  • GPL/trunk/alsa-kernel/include/sound/mixer_oss.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_MIXER_OSS_H
    23#define __SOUND_MIXER_OSS_H
     
    56 *  OSS MIXER API
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
    25 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
     10#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
    2611
    2712#define SNDRV_OSS_MAX_MIXERS    32
     
    7459};
    7560
     61int snd_mixer_oss_ioctl_card(struct snd_card *card,
     62                             unsigned int cmd, unsigned long arg);
     63
    7664#endif /* CONFIG_SND_MIXER_OSS */
    7765
  • GPL/trunk/alsa-kernel/include/sound/mpu401.h

    r399 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_MPU401_H
    23#define __SOUND_MPU401_H
     
    56 *  Header file for MPU-401 and compatible cards
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
    25 #include "rawmidi.h"
     10#include <sound/rawmidi.h>
    2611#include <linux/interrupt.h>
    2712
     
    5136#define MPU401_INFO_MMIO        (1 << 3)        /* MMIO access */
    5237#define MPU401_INFO_TX_IRQ      (1 << 4)        /* independent TX irq */
     38#define MPU401_INFO_IRQ_HOOK    (1 << 5)        /* mpu401 irq handler is called
     39                                                   from driver irq handler */
    5340#define MPU401_INFO_NO_ACK      (1 << 6)        /* No ACK cmd needed */
     41#define MPU401_INFO_USE_TIMER   (1 << 15)       /* internal */
    5442
    5543#define MPU401_MODE_BIT_INPUT           0
     
    7462        unsigned long cport;            /* port + 1 (usually) */
    7563        struct resource *res;           /* port resource */
    76         int irq;                        /* IRQ number of MPU-401 chip (-1 = poll) */
    77         int irq_flags;
     64        int irq;                        /* IRQ number of MPU-401 chip */
    7865
    7966        unsigned long mode;             /* MPU401_MODE_XXXX */
     
    132119                        unsigned int info_flags,
    133120                        int irq,
    134                         int irq_flags,
    135121                        struct snd_rawmidi ** rrawmidi);
    136122
  • GPL/trunk/alsa-kernel/include/sound/opl3.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_OPL3_H
    23#define __SOUND_OPL3_H
     
    78 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
    89 *                  Hannu Savolainen 1993-1996
    9  *
    1010 *
    1111 *      The OPL-3 mode is switched on by writing 0x01, to the offset 5
     
    3434 *      register of the voice (0xC0-0xC8). In 4 OP voices these bits are
    3535 *      in the second half of the voice.
    36  *
    37  *
    38  *   This program is free software; you can redistribute it and/or modify
    39  *   it under the terms of the GNU General Public License as published by
    40  *   the Free Software Foundation; either version 2 of the License, or
    41  *   (at your option) any later version.
    42  *
    43  *   This program is distributed in the hope that it will be useful,
    44  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    45  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    46  *   GNU General Public License for more details.
    47  *
    48  *   You should have received a copy of the GNU General Public License
    49  *   along with this program; if not, write to the Free Software
    50  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    51  *
    5236 */
    5337
     
    5640#include <sound/timer.h>
    5741#include <sound/seq_midi_emul.h>
    58 #ifdef CONFIG_SND_SEQUENCER_OSS
    5942#include <sound/seq_oss.h>
    6043#include <sound/seq_oss_legacy.h>
    61 #endif
    6244#include <sound/seq_device.h>
    6345#include <sound/asound_fm.h>
     
    330312        unsigned char rhythm;           /* percussion mode flag */
    331313        unsigned char max_voices;       /* max number of voices */
    332 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
     314#if IS_ENABLED(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER)
    333315#define SNDRV_OPL3_MODE_SYNTH 0         /* OSS - voices allocated by application */
    334316#define SNDRV_OPL3_MODE_SEQ 1           /* ALSA - driver handles voice allocation */
     
    339321        struct snd_midi_channel_set * chset;
    340322
    341 #ifdef CONFIG_SND_SEQUENCER_OSS
     323#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS) || defined(CONFIG_SND_SEQUENCER)
    342324        struct snd_seq_device *oss_seq_dev;     /* OSS sequencer device */
    343325        struct snd_midi_channel_set * oss_chset;
     
    383365void snd_opl3_reset(struct snd_opl3 * opl3);
    384366
    385 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
     367#if IS_ENABLED(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER)
    386368long snd_opl3_write(struct snd_hwdep *hw, const char __user *buf, long count,
    387369                    loff_t *offset);
  • GPL/trunk/alsa-kernel/include/sound/opl4.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_OPL4_H
    23#define __SOUND_OPL4_H
     
    56 * Global definitions for the OPL4 driver
    67 * Copyright (c) 2003 by Clemens Ladisch <clemens@ladisch.de>
    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
  • GPL/trunk/alsa-kernel/include/sound/pcm-indirect.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 * Helper functions for indirect PCM data transfer
     
    45 *  Copyright (c) by Takashi Iwai <tiwai@suse.de>
    56 *                   Jaroslav Kysela <perex@perex.cz>
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    207 */
    218
     
    4431 * helper function for playback ack callback
    4532 */
    46 static inline void
     33static inline int
    4734snd_pcm_indirect_playback_transfer(struct snd_pcm_substream *substream,
    4835                                   struct snd_pcm_indirect *rec,
     
    5744                if (diff < -(snd_pcm_sframes_t) (runtime->boundary / 2))
    5845                        diff += runtime->boundary;
     46                if (diff < 0)
     47                        return -EINVAL;
    5948                rec->sw_ready += (int)frames_to_bytes(runtime, diff);
    6049                rec->appl_ptr = appl_ptr;
     
    8372                rec->sw_ready -= bytes;
    8473        }
     74        return 0;
    8575}
    8676
     
    110100 * helper function for capture ack callback
    111101 */
    112 static inline void
     102static inline int
    113103snd_pcm_indirect_capture_transfer(struct snd_pcm_substream *substream,
    114104                                  struct snd_pcm_indirect *rec,
     
    122112                if (diff < -(snd_pcm_sframes_t) (runtime->boundary / 2))
    123113                        diff += runtime->boundary;
     114                if (diff < 0)
     115                        return -EINVAL;
    124116                rec->sw_ready -= frames_to_bytes(runtime, diff);
    125117                rec->appl_ptr = appl_ptr;
     
    148140                rec->sw_ready += bytes;
    149141        }
     142        return 0;
    150143}
    151144
  • GPL/trunk/alsa-kernel/include/sound/pcm.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_PCM_H
    23#define __SOUND_PCM_H
     
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    78 *                   Abramo Bagnara <abramo@alsa-project.org>
    8  *
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    249 */
    2510
     
    3015#include <linux/mm.h>
    3116#include <linux/bitops.h>
    32 #include <linux/pm_qos_params.h>
     17#include <linux/pm_qos.h>
     18#include <linux/refcount.h>
    3319
    3420#define snd_pcm_substream_chip(substream) ((substream)->private_data)
    3521#define snd_pcm_chip(pcm) ((pcm)->private_data)
    3622
    37 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
    38 #include "pcm_oss.h"
     23#if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
     24#include <sound/pcm_oss.h>
    3925#endif
    4026
     
    5945};
    6046
     47struct snd_pcm_status64;
    6148struct snd_pcm_substream;
     49
     50struct snd_pcm_audio_tstamp_config; /* definitions further down */
     51struct snd_pcm_audio_tstamp_report;
    6252
    6353struct snd_pcm_ops {
     
    7161        int (*prepare)(struct snd_pcm_substream *substream);
    7262        int (*trigger)(struct snd_pcm_substream *substream, int cmd);
     63        int (*sync_stop)(struct snd_pcm_substream *substream);
    7364        snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
    74         int (*copy)(struct snd_pcm_substream *substream, int channel,
    75                     snd_pcm_uframes_t pos,
    76                     void __user *buf, snd_pcm_uframes_t count);
    77         int (*silence)(struct snd_pcm_substream *substream, int channel,
    78                        snd_pcm_uframes_t pos, snd_pcm_uframes_t count);
     65        int (*get_time_info)(struct snd_pcm_substream *substream,
     66                        struct timespec64 *system_ts, struct timespec64 *audio_ts,
     67                        struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
     68                        struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
     69        int (*fill_silence)(struct snd_pcm_substream *substream, int channel,
     70                            unsigned long pos, unsigned long bytes);
     71        int (*copy_user)(struct snd_pcm_substream *substream, int channel,
     72                         unsigned long pos, void __user *buf,
     73                         unsigned long bytes);
     74        int (*copy_kernel)(struct snd_pcm_substream *substream, int channel,
     75                           unsigned long pos, void *buf, unsigned long bytes);
    7976        struct page *(*page)(struct snd_pcm_substream *substream,
    8077                             unsigned long offset);
     
    9390#endif
    9491
    95 #define SNDRV_PCM_IOCTL1_FALSE          ((void *)0)
    96 #define SNDRV_PCM_IOCTL1_TRUE           ((void *)1)
    97 
    9892#define SNDRV_PCM_IOCTL1_RESET          0
    99 #define SNDRV_PCM_IOCTL1_INFO           1
     93/* 1 is absent slot. */
    10094#define SNDRV_PCM_IOCTL1_CHANNEL_INFO   2
    101 #define SNDRV_PCM_IOCTL1_GSTATE         3
     95/* 3 is absent slot. */
    10296#define SNDRV_PCM_IOCTL1_FIFO_SIZE      4
    10397
     
    108102#define SNDRV_PCM_TRIGGER_SUSPEND       5
    109103#define SNDRV_PCM_TRIGGER_RESUME        6
     104#define SNDRV_PCM_TRIGGER_DRAIN         7
    110105
    111106#define SNDRV_PCM_POS_XRUN              ((snd_pcm_uframes_t)-1)
     
    125120#define SNDRV_PCM_RATE_176400           (1<<11)         /* 176400Hz */
    126121#define SNDRV_PCM_RATE_192000           (1<<12)         /* 192000Hz */
     122#define SNDRV_PCM_RATE_352800           (1<<13)         /* 352800Hz */
     123#define SNDRV_PCM_RATE_384000           (1<<14)         /* 384000Hz */
    127124
    128125#define SNDRV_PCM_RATE_CONTINUOUS       (1<<30)         /* continuous range */
     
    137134#define SNDRV_PCM_RATE_8000_192000      (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
    138135                                         SNDRV_PCM_RATE_192000)
    139 #define SNDRV_PCM_FMTBIT_S8             (1ULL << SNDRV_PCM_FORMAT_S8)
    140 #define SNDRV_PCM_FMTBIT_U8             (1ULL << SNDRV_PCM_FORMAT_U8)
    141 #define SNDRV_PCM_FMTBIT_S16_LE         (1ULL << SNDRV_PCM_FORMAT_S16_LE)
    142 #define SNDRV_PCM_FMTBIT_S16_BE         (1ULL << SNDRV_PCM_FORMAT_S16_BE)
    143 #define SNDRV_PCM_FMTBIT_U16_LE         (1ULL << SNDRV_PCM_FORMAT_U16_LE)
    144 #define SNDRV_PCM_FMTBIT_U16_BE         (1ULL << SNDRV_PCM_FORMAT_U16_BE)
    145 #define SNDRV_PCM_FMTBIT_S24_LE         (1ULL << SNDRV_PCM_FORMAT_S24_LE)
    146 #define SNDRV_PCM_FMTBIT_S24_BE         (1ULL << SNDRV_PCM_FORMAT_S24_BE)
    147 #define SNDRV_PCM_FMTBIT_U24_LE         (1ULL << SNDRV_PCM_FORMAT_U24_LE)
    148 #define SNDRV_PCM_FMTBIT_U24_BE         (1ULL << SNDRV_PCM_FORMAT_U24_BE)
    149 #define SNDRV_PCM_FMTBIT_S32_LE         (1ULL << SNDRV_PCM_FORMAT_S32_LE)
    150 #define SNDRV_PCM_FMTBIT_S32_BE         (1ULL << SNDRV_PCM_FORMAT_S32_BE)
    151 #define SNDRV_PCM_FMTBIT_U32_LE         (1ULL << SNDRV_PCM_FORMAT_U32_LE)
    152 #define SNDRV_PCM_FMTBIT_U32_BE         (1ULL << SNDRV_PCM_FORMAT_U32_BE)
    153 #define SNDRV_PCM_FMTBIT_FLOAT_LE       (1ULL << SNDRV_PCM_FORMAT_FLOAT_LE)
    154 #define SNDRV_PCM_FMTBIT_FLOAT_BE       (1ULL << SNDRV_PCM_FORMAT_FLOAT_BE)
    155 #define SNDRV_PCM_FMTBIT_FLOAT64_LE     (1ULL << SNDRV_PCM_FORMAT_FLOAT64_LE)
    156 #define SNDRV_PCM_FMTBIT_FLOAT64_BE     (1ULL << SNDRV_PCM_FORMAT_FLOAT64_BE)
    157 #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE)
    158 #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE)
    159 #define SNDRV_PCM_FMTBIT_MU_LAW         (1ULL << SNDRV_PCM_FORMAT_MU_LAW)
    160 #define SNDRV_PCM_FMTBIT_A_LAW          (1ULL << SNDRV_PCM_FORMAT_A_LAW)
    161 #define SNDRV_PCM_FMTBIT_IMA_ADPCM      (1ULL << SNDRV_PCM_FORMAT_IMA_ADPCM)
    162 #define SNDRV_PCM_FMTBIT_MPEG           (1ULL << SNDRV_PCM_FORMAT_MPEG)
    163 #define SNDRV_PCM_FMTBIT_GSM            (1ULL << SNDRV_PCM_FORMAT_GSM)
    164 #define SNDRV_PCM_FMTBIT_SPECIAL        (1ULL << SNDRV_PCM_FORMAT_SPECIAL)
    165 #define SNDRV_PCM_FMTBIT_S24_3LE        (1ULL << SNDRV_PCM_FORMAT_S24_3LE)
    166 #define SNDRV_PCM_FMTBIT_U24_3LE        (1ULL << SNDRV_PCM_FORMAT_U24_3LE)
    167 #define SNDRV_PCM_FMTBIT_S24_3BE        (1ULL << SNDRV_PCM_FORMAT_S24_3BE)
    168 #define SNDRV_PCM_FMTBIT_U24_3BE        (1ULL << SNDRV_PCM_FORMAT_U24_3BE)
    169 #define SNDRV_PCM_FMTBIT_S20_3LE        (1ULL << SNDRV_PCM_FORMAT_S20_3LE)
    170 #define SNDRV_PCM_FMTBIT_U20_3LE        (1ULL << SNDRV_PCM_FORMAT_U20_3LE)
    171 #define SNDRV_PCM_FMTBIT_S20_3BE        (1ULL << SNDRV_PCM_FORMAT_S20_3BE)
    172 #define SNDRV_PCM_FMTBIT_U20_3BE        (1ULL << SNDRV_PCM_FORMAT_U20_3BE)
    173 #define SNDRV_PCM_FMTBIT_S18_3LE        (1ULL << SNDRV_PCM_FORMAT_S18_3LE)
    174 #define SNDRV_PCM_FMTBIT_U18_3LE        (1ULL << SNDRV_PCM_FORMAT_U18_3LE)
    175 #define SNDRV_PCM_FMTBIT_S18_3BE        (1ULL << SNDRV_PCM_FORMAT_S18_3BE)
    176 #define SNDRV_PCM_FMTBIT_U18_3BE        (1ULL << SNDRV_PCM_FORMAT_U18_3BE)
    177 #define SNDRV_PCM_FMTBIT_G723_24        (1ULL << SNDRV_PCM_FORMAT_G723_24)
    178 #define SNDRV_PCM_FMTBIT_G723_24_1B     (1ULL << SNDRV_PCM_FORMAT_G723_24_1B)
    179 #define SNDRV_PCM_FMTBIT_G723_40        (1ULL << SNDRV_PCM_FORMAT_G723_40)
    180 #define SNDRV_PCM_FMTBIT_G723_40_1B     (1ULL << SNDRV_PCM_FORMAT_G723_40_1B)
     136#define SNDRV_PCM_RATE_8000_384000      (SNDRV_PCM_RATE_8000_192000|\
     137                                         SNDRV_PCM_RATE_352800|\
     138                                         SNDRV_PCM_RATE_384000)
     139#define _SNDRV_PCM_FMTBIT(fmt)          (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
     140#define SNDRV_PCM_FMTBIT_S8             _SNDRV_PCM_FMTBIT(S8)
     141#define SNDRV_PCM_FMTBIT_U8             _SNDRV_PCM_FMTBIT(U8)
     142#define SNDRV_PCM_FMTBIT_S16_LE         _SNDRV_PCM_FMTBIT(S16_LE)
     143#define SNDRV_PCM_FMTBIT_S16_BE         _SNDRV_PCM_FMTBIT(S16_BE)
     144#define SNDRV_PCM_FMTBIT_U16_LE         _SNDRV_PCM_FMTBIT(U16_LE)
     145#define SNDRV_PCM_FMTBIT_U16_BE         _SNDRV_PCM_FMTBIT(U16_BE)
     146#define SNDRV_PCM_FMTBIT_S24_LE         _SNDRV_PCM_FMTBIT(S24_LE)
     147#define SNDRV_PCM_FMTBIT_S24_BE         _SNDRV_PCM_FMTBIT(S24_BE)
     148#define SNDRV_PCM_FMTBIT_U24_LE         _SNDRV_PCM_FMTBIT(U24_LE)
     149#define SNDRV_PCM_FMTBIT_U24_BE         _SNDRV_PCM_FMTBIT(U24_BE)
     150#define SNDRV_PCM_FMTBIT_S32_LE         _SNDRV_PCM_FMTBIT(S32_LE)
     151#define SNDRV_PCM_FMTBIT_S32_BE         _SNDRV_PCM_FMTBIT(S32_BE)
     152#define SNDRV_PCM_FMTBIT_U32_LE         _SNDRV_PCM_FMTBIT(U32_LE)
     153#define SNDRV_PCM_FMTBIT_U32_BE         _SNDRV_PCM_FMTBIT(U32_BE)
     154#define SNDRV_PCM_FMTBIT_FLOAT_LE       _SNDRV_PCM_FMTBIT(FLOAT_LE)
     155#define SNDRV_PCM_FMTBIT_FLOAT_BE       _SNDRV_PCM_FMTBIT(FLOAT_BE)
     156#define SNDRV_PCM_FMTBIT_FLOAT64_LE     _SNDRV_PCM_FMTBIT(FLOAT64_LE)
     157#define SNDRV_PCM_FMTBIT_FLOAT64_BE     _SNDRV_PCM_FMTBIT(FLOAT64_BE)
     158#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE)
     159#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE)
     160#define SNDRV_PCM_FMTBIT_MU_LAW         _SNDRV_PCM_FMTBIT(MU_LAW)
     161#define SNDRV_PCM_FMTBIT_A_LAW          _SNDRV_PCM_FMTBIT(A_LAW)
     162#define SNDRV_PCM_FMTBIT_IMA_ADPCM      _SNDRV_PCM_FMTBIT(IMA_ADPCM)
     163#define SNDRV_PCM_FMTBIT_MPEG           _SNDRV_PCM_FMTBIT(MPEG)
     164#define SNDRV_PCM_FMTBIT_GSM            _SNDRV_PCM_FMTBIT(GSM)
     165#define SNDRV_PCM_FMTBIT_S20_LE _SNDRV_PCM_FMTBIT(S20_LE)
     166#define SNDRV_PCM_FMTBIT_U20_LE _SNDRV_PCM_FMTBIT(U20_LE)
     167#define SNDRV_PCM_FMTBIT_S20_BE _SNDRV_PCM_FMTBIT(S20_BE)
     168#define SNDRV_PCM_FMTBIT_U20_BE _SNDRV_PCM_FMTBIT(U20_BE)
     169#define SNDRV_PCM_FMTBIT_SPECIAL        _SNDRV_PCM_FMTBIT(SPECIAL)
     170#define SNDRV_PCM_FMTBIT_S24_3LE        _SNDRV_PCM_FMTBIT(S24_3LE)
     171#define SNDRV_PCM_FMTBIT_U24_3LE        _SNDRV_PCM_FMTBIT(U24_3LE)
     172#define SNDRV_PCM_FMTBIT_S24_3BE        _SNDRV_PCM_FMTBIT(S24_3BE)
     173#define SNDRV_PCM_FMTBIT_U24_3BE        _SNDRV_PCM_FMTBIT(U24_3BE)
     174#define SNDRV_PCM_FMTBIT_S20_3LE        _SNDRV_PCM_FMTBIT(S20_3LE)
     175#define SNDRV_PCM_FMTBIT_U20_3LE        _SNDRV_PCM_FMTBIT(U20_3LE)
     176#define SNDRV_PCM_FMTBIT_S20_3BE        _SNDRV_PCM_FMTBIT(S20_3BE)
     177#define SNDRV_PCM_FMTBIT_U20_3BE        _SNDRV_PCM_FMTBIT(U20_3BE)
     178#define SNDRV_PCM_FMTBIT_S18_3LE        _SNDRV_PCM_FMTBIT(S18_3LE)
     179#define SNDRV_PCM_FMTBIT_U18_3LE        _SNDRV_PCM_FMTBIT(U18_3LE)
     180#define SNDRV_PCM_FMTBIT_S18_3BE        _SNDRV_PCM_FMTBIT(S18_3BE)
     181#define SNDRV_PCM_FMTBIT_U18_3BE        _SNDRV_PCM_FMTBIT(U18_3BE)
     182#define SNDRV_PCM_FMTBIT_G723_24        _SNDRV_PCM_FMTBIT(G723_24)
     183#define SNDRV_PCM_FMTBIT_G723_24_1B     _SNDRV_PCM_FMTBIT(G723_24_1B)
     184#define SNDRV_PCM_FMTBIT_G723_40        _SNDRV_PCM_FMTBIT(G723_40)
     185#define SNDRV_PCM_FMTBIT_G723_40_1B     _SNDRV_PCM_FMTBIT(G723_40_1B)
     186#define SNDRV_PCM_FMTBIT_DSD_U8         _SNDRV_PCM_FMTBIT(DSD_U8)
     187#define SNDRV_PCM_FMTBIT_DSD_U16_LE     _SNDRV_PCM_FMTBIT(DSD_U16_LE)
     188#define SNDRV_PCM_FMTBIT_DSD_U32_LE     _SNDRV_PCM_FMTBIT(DSD_U32_LE)
     189#define SNDRV_PCM_FMTBIT_DSD_U16_BE     _SNDRV_PCM_FMTBIT(DSD_U16_BE)
     190#define SNDRV_PCM_FMTBIT_DSD_U32_BE     _SNDRV_PCM_FMTBIT(DSD_U32_BE)
    181191
    182192#ifdef SNDRV_LITTLE_ENDIAN
     
    190200#define SNDRV_PCM_FMTBIT_FLOAT64        SNDRV_PCM_FMTBIT_FLOAT64_LE
    191201#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
     202#define SNDRV_PCM_FMTBIT_S20            SNDRV_PCM_FMTBIT_S20_LE
     203#define SNDRV_PCM_FMTBIT_U20            SNDRV_PCM_FMTBIT_U20_LE
    192204#endif
    193205#ifdef SNDRV_BIG_ENDIAN
     
    201213#define SNDRV_PCM_FMTBIT_FLOAT64        SNDRV_PCM_FMTBIT_FLOAT64_BE
    202214#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE
     215#define SNDRV_PCM_FMTBIT_S20            SNDRV_PCM_FMTBIT_S20_BE
     216#define SNDRV_PCM_FMTBIT_U20            SNDRV_PCM_FMTBIT_U20_BE
    203217#endif
    204218
     
    206220        struct snd_pcm_substream *substream;
    207221        int no_compat_mmap;
     222        unsigned int user_pversion;     /* supported protocol version */
    208223};
    209224
     
    214229struct snd_pcm_hw_rule {
    215230        unsigned int cond;
    216         snd_pcm_hw_rule_func_t func;
    217231        int var;
    218232        int deps[4];
     233
     234        snd_pcm_hw_rule_func_t func;
    219235        void *private;
    220236};
     
    254270struct snd_pcm_hw_constraint_ratnums {
    255271        int nrats;
    256         struct snd_ratnum *rats;
     272        const struct snd_ratnum *rats;
    257273};
    258274
    259275struct snd_pcm_hw_constraint_ratdens {
    260276        int nrats;
    261         struct snd_ratden *rats;
     277        const struct snd_ratden *rats;
    262278};
    263279
    264280struct snd_pcm_hw_constraint_list {
     281        const unsigned int *list;
    265282        unsigned int count;
    266         unsigned int *list;
    267283        unsigned int mask;
    268284};
    269285
    270 struct snd_pcm_hwptr_log;
     286struct snd_pcm_hw_constraint_ranges {
     287        unsigned int count;
     288        const struct snd_interval *ranges;
     289        unsigned int mask;
     290};
     291
     292/*
     293 * userspace-provided audio timestamp config to kernel,
     294 * structure is for internal use only and filled with dedicated unpack routine
     295 */
     296struct snd_pcm_audio_tstamp_config {
     297        /* 5 of max 16 bits used */
     298        u32 type_requested:4;
     299        u32 report_delay:1; /* add total delay to A/D or D/A */
     300};
     301
     302static inline void snd_pcm_unpack_audio_tstamp_config(__u32 data,
     303                                                struct snd_pcm_audio_tstamp_config *config)
     304{
     305        config->type_requested = data & 0xF;
     306        config->report_delay = (data >> 4) & 1;
     307}
     308
     309/*
     310 * kernel-provided audio timestamp report to user-space
     311 * structure is for internal use only and read by dedicated pack routine
     312 */
     313struct snd_pcm_audio_tstamp_report {
     314        /* 6 of max 16 bits used for bit-fields */
     315
     316        /* for backwards compatibility */
     317        u32 valid:1;
     318
     319        /* actual type if hardware could not support requested timestamp */
     320        u32 actual_type:4;
     321
     322        /* accuracy represented in ns units */
     323        u32 accuracy_report:1; /* 0 if accuracy unknown, 1 if accuracy field is valid */
     324        u32 accuracy; /* up to 4.29s, will be packed in separate field  */
     325};
     326
     327static inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy,
     328                                                const struct snd_pcm_audio_tstamp_report *report)
     329{
     330        u32 tmp;
     331
     332        tmp = report->accuracy_report;
     333        tmp <<= 4;
     334        tmp |= report->actual_type;
     335        tmp <<= 1;
     336        tmp |= report->valid;
     337
     338        *data &= 0xffff; /* zero-clear MSBs */
     339        *data |= (tmp << 16);
     340        *accuracy = report->accuracy;
     341}
     342
    271343
    272344struct snd_pcm_runtime {
    273345        /* -- Status -- */
    274346        struct snd_pcm_substream *trigger_master;
    275         struct timespec trigger_tstamp; /* trigger timestamp */
     347        struct timespec64 trigger_tstamp;       /* trigger timestamp */
     348        bool trigger_tstamp_latched;     /* trigger timestamp latched in low-level driver/hardware */
    276349        int overrange;
    277350        snd_pcm_uframes_t avail_max;
     
    281354        unsigned long hw_ptr_buffer_jiffies; /* buffer time in jiffies */
    282355        snd_pcm_sframes_t delay;        /* extra delay; typically FIFO size */
     356        u64 hw_ptr_wrap;                /* offset for hw_ptr due to boundary wrap-around */
    283357
    284358        /* -- HW params -- */
     
    324398        wait_queue_head_t tsleep;       /* transfer sleep */
    325399        struct fasync_struct *fasync;
     400        bool stop_operating;            /* sync_stop will be called */
    326401
    327402        /* -- private section -- */
     
    332407        struct snd_pcm_hardware hw;
    333408        struct snd_pcm_hw_constraints hw_constraints;
    334 
    335         /* -- interrupt callbacks -- */
    336         void (*transfer_ack_begin)(struct snd_pcm_substream *substream);
    337         void (*transfer_ack_end)(struct snd_pcm_substream *substream);
    338409
    339410        /* -- timer -- */
     
    347418
    348419        struct snd_dma_buffer *dma_buffer_p;    /* allocated buffer */
    349 
    350 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
     420        unsigned int buffer_changed:1;  /* buffer allocation changed; set only in managed mode */
     421
     422        /* -- audio timestamp config -- */
     423        struct snd_pcm_audio_tstamp_config audio_tstamp_config;
     424        struct snd_pcm_audio_tstamp_report audio_tstamp_report;
     425        struct timespec64 driver_tstamp;
     426
     427#if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
    351428        /* -- OSS things -- */
    352429        struct snd_pcm_oss_runtime oss;
    353430#endif
    354 
    355 #ifdef CONFIG_SND_PCM_XRUN_DEBUG
    356         struct snd_pcm_hwptr_log *hwptr_log;
    357 #endif
    358431};
    359432
    360433struct snd_pcm_group {          /* keep linked substreams */
    361434        spinlock_t lock;
     435        struct mutex mutex;
    362436        struct list_head substreams;
    363         int count;
     437        refcount_t refs;
    364438};
    365439
     
    373447        char name[32];                  /* substream name */
    374448        int stream;                     /* stream (direction) */
    375 #ifndef TARGET_OS2
    376         struct pm_qos_request_list latency_pm_qos_req; /* pm_qos request */
    377 #else
    378         char latency_id[20];
    379 #endif
     449        struct pm_qos_request latency_pm_qos_req; /* pm_qos request */
    380450        size_t buffer_bytes_max;        /* limit ring buffer size */
    381451        struct snd_dma_buffer dma_buffer;
    382         unsigned int dma_buf_id;
    383452        size_t dma_max;
    384453        /* -- hardware operations -- */
    385         struct snd_pcm_ops *ops;
     454        const struct snd_pcm_ops *ops;
    386455        /* -- runtime information -- */
    387456        struct snd_pcm_runtime *runtime;
     
    389458        struct snd_timer *timer;                /* timer */
    390459        unsigned timer_running: 1;      /* time is running */
     460        long wait_time; /* time in ms for R/W to wait for avail */
    391461        /* -- next substream -- */
    392462        struct snd_pcm_substream *next;
     
    396466        struct snd_pcm_group *group;            /* pointer to current group */
    397467        /* -- assigned files -- */
    398         void *file;
    399468        int ref_count;
    400469        atomic_t mmap_count;
     
    402471        void (*pcm_release)(struct snd_pcm_substream *);
    403472        struct pid *pid;
    404 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
     473#if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
    405474        /* -- OSS things -- */
    406475        struct snd_pcm_oss_substream oss;
     
    408477#ifdef CONFIG_SND_VERBOSE_PROCFS
    409478        struct snd_info_entry *proc_root;
    410         struct snd_info_entry *proc_info_entry;
    411         struct snd_info_entry *proc_hw_params_entry;
    412         struct snd_info_entry *proc_sw_params_entry;
    413         struct snd_info_entry *proc_status_entry;
    414         struct snd_info_entry *proc_prealloc_entry;
    415         struct snd_info_entry *proc_prealloc_max_entry;
    416 #endif
     479#endif /* CONFIG_SND_VERBOSE_PROCFS */
    417480        /* misc flags */
    418481        unsigned int hw_opened: 1;
     482        unsigned int managed_buffer_alloc:1;
    419483};
    420484
     
    429493        unsigned int substream_opened;
    430494        struct snd_pcm_substream *substream;
    431 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
     495#if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
    432496        /* -- OSS things -- */
    433497        struct snd_pcm_oss_stream oss;
     
    435499#ifdef CONFIG_SND_VERBOSE_PROCFS
    436500        struct snd_info_entry *proc_root;
    437         struct snd_info_entry *proc_info_entry;
    438501#ifdef CONFIG_SND_PCM_XRUN_DEBUG
    439502        unsigned int xrun_debug;        /* 0 = disabled, 1 = verbose, 2 = stacktrace */
    440         struct snd_info_entry *proc_xrun_debug_entry;
    441 #endif
    442 #endif
     503#endif
     504#endif
     505        struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */
     506        struct device dev;
    443507};
    444508
     
    457521        void *private_data;
    458522        void (*private_free) (struct snd_pcm *pcm);
    459         struct device *dev; /* actual hw device this belongs to */
    460 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
     523        bool internal; /* pcm is for internal use only */
     524        bool nonatomic; /* whole PCM operations are in non-atomic context */
     525        bool no_device_suspend; /* don't invoke device PM suspend */
     526#if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
    461527        struct snd_pcm_oss oss;
    462528#endif
    463529};
    464530
     531/*
     532 *  Registering
     533 */
     534
     535extern const struct file_operations snd_pcm_f_ops[2];
     536
     537int snd_pcm_new(struct snd_card *card, const char *id, int device,
     538                int playback_count, int capture_count,
     539                struct snd_pcm **rpcm);
     540int snd_pcm_new_internal(struct snd_card *card, const char *id, int device,
     541                int playback_count, int capture_count,
     542                struct snd_pcm **rpcm);
     543int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);
     544
     545#if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
    465546struct snd_pcm_notify {
    466547        int (*n_register) (struct snd_pcm * pcm);
     
    469550        struct list_head list;
    470551};
    471 
    472 /*
    473  *  Registering
    474  */
    475 
    476 #ifndef TARGET_OS2
    477 extern const struct file_operations snd_pcm_f_ops[2];
    478 #else
    479 extern struct file_operations snd_pcm_f_ops[2];
    480 #endif
    481 
    482 int snd_pcm_new(struct snd_card *card, const char *id, int device,
    483                 int playback_count, int capture_count,
    484                 struct snd_pcm **rpcm);
    485 int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);
    486 
    487552int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree);
     553#endif
    488554
    489555/*
    490556 *  Native I/O
    491557 */
    492 
    493 extern rwlock_t snd_pcm_link_rwlock;
    494558
    495559int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info);
    496560int snd_pcm_info_user(struct snd_pcm_substream *substream,
    497561                      struct snd_pcm_info __user *info);
    498 int snd_pcm_status(struct snd_pcm_substream *substream,
    499                    struct snd_pcm_status *status);
     562int snd_pcm_status64(struct snd_pcm_substream *substream,
     563                     struct snd_pcm_status64 *status);
    500564int snd_pcm_start(struct snd_pcm_substream *substream);
    501 int snd_pcm_stop(struct snd_pcm_substream *substream, int status);
     565int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
    502566int snd_pcm_drain_done(struct snd_pcm_substream *substream);
     567int snd_pcm_stop_xrun(struct snd_pcm_substream *substream);
    503568#ifdef CONFIG_PM
    504 int snd_pcm_suspend(struct snd_pcm_substream *substream);
    505569int snd_pcm_suspend_all(struct snd_pcm *pcm);
     570#else
     571static inline int snd_pcm_suspend_all(struct snd_pcm *pcm)
     572{
     573        return 0;
     574}
    506575#endif
    507576int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
     
    512581                             struct snd_pcm_substream **rsubstream);
    513582void snd_pcm_detach_substream(struct snd_pcm_substream *substream);
    514 void snd_pcm_vma_notify_data(void *client, void *data);
    515583int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area);
     584
     585
     586#ifdef CONFIG_SND_DEBUG
     587void snd_pcm_debug_name(struct snd_pcm_substream *substream,
     588                           char *name, size_t len);
     589#else
     590static inline void
     591snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size)
     592{
     593        *buf = 0;
     594}
     595#endif
    516596
    517597/*
     
    519599 */
    520600
     601/**
     602 * snd_pcm_stream_linked - Check whether the substream is linked with others
     603 * @substream: substream to check
     604 *
     605 * Returns true if the given substream is being linked with others.
     606 */
    521607static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream)
    522608{
     
    524610}
    525611
    526 static inline void snd_pcm_stream_lock(struct snd_pcm_substream *substream)
    527 {
    528         read_lock(&snd_pcm_link_rwlock);
    529         spin_lock(&substream->self_group.lock);
    530 }
    531 
    532 static inline void snd_pcm_stream_unlock(struct snd_pcm_substream *substream)
    533 {
    534         spin_unlock(&substream->self_group.lock);
    535         read_unlock(&snd_pcm_link_rwlock);
    536 }
    537 
    538 static inline void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream)
    539 {
    540         read_lock_irq(&snd_pcm_link_rwlock);
    541         spin_lock(&substream->self_group.lock);
    542 }
    543 
    544 static inline void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream)
    545 {
    546         spin_unlock(&substream->self_group.lock);
    547         read_unlock_irq(&snd_pcm_link_rwlock);
    548 }
    549 
    550 #define snd_pcm_stream_lock_irqsave(substream, flags) \
    551 do { \
    552         read_lock_irqsave(&snd_pcm_link_rwlock, (flags)); \
    553         spin_lock(&substream->self_group.lock); \
    554 } while (0)
    555 
    556 #define snd_pcm_stream_unlock_irqrestore(substream, flags) \
    557 do { \
    558         spin_unlock(&substream->self_group.lock); \
    559         read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \
    560 } while (0)
    561 
     612void snd_pcm_stream_lock(struct snd_pcm_substream *substream);
     613void snd_pcm_stream_unlock(struct snd_pcm_substream *substream);
     614void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream);
     615void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);
     616unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
     617
     618/**
     619 * snd_pcm_stream_lock_irqsave - Lock the PCM stream
     620 * @substream: PCM substream
     621 * @flags: irq flags
     622 *
     623 * This locks the PCM stream like snd_pcm_stream_lock() but with the local
     624 * IRQ (only when nonatomic is false).  In nonatomic case, this is identical
     625 * as snd_pcm_stream_lock().
     626 */
     627#ifndef TARGET_OS2
     628#define snd_pcm_stream_lock_irqsave(substream, flags)            \
     629        do {                                                     \
     630                typecheck(unsigned long, flags);                 \
     631                flags = _snd_pcm_stream_lock_irqsave(substream); \
     632        } while (0)
     633#else
     634#define snd_pcm_stream_lock_irqsave(substream, flags)            \
     635        do {                                                     \
     636                flags = _snd_pcm_stream_lock_irqsave(substream); \
     637        } while (0)
     638#endif
     639void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
     640                                      unsigned long flags);
     641
     642/**
     643 * snd_pcm_group_for_each_entry - iterate over the linked substreams
     644 * @s: the iterator
     645 * @substream: the substream
     646 *
     647 * Iterate over the all linked substreams to the given @substream.
     648 * When @substream isn't linked with any others, this gives returns @substream
     649 * itself once.
     650 */
    562651#define snd_pcm_group_for_each_entry(s, substream) \
    563652        list_for_each_entry(s, &substream->group->substreams, link_list, struct snd_pcm_substream)
    564653
     654#define for_each_pcm_streams(stream)                    \
     655        for (stream  = SNDRV_PCM_STREAM_PLAYBACK;       \
     656             stream <= SNDRV_PCM_STREAM_LAST;           \
     657             stream++)
     658
     659/**
     660 * snd_pcm_running - Check whether the substream is in a running state
     661 * @substream: substream to check
     662 *
     663 * Returns true if the given substream is in the state RUNNING, or in the
     664 * state DRAINING for playback.
     665 */
    565666static inline int snd_pcm_running(struct snd_pcm_substream *substream)
    566667{
     
    570671}
    571672
     673/**
     674 * bytes_to_samples - Unit conversion of the size from bytes to samples
     675 * @runtime: PCM runtime instance
     676 * @size: size in bytes
     677 */
    572678static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size)
    573679{
     
    575681}
    576682
     683/**
     684 * bytes_to_frames - Unit conversion of the size from bytes to frames
     685 * @runtime: PCM runtime instance
     686 * @size: size in bytes
     687 */
    577688static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size)
    578689{
     
    580691}
    581692
     693/**
     694 * samples_to_bytes - Unit conversion of the size from samples to bytes
     695 * @runtime: PCM runtime instance
     696 * @size: size in samples
     697 */
    582698static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size)
    583699{
     
    585701}
    586702
     703/**
     704 * frames_to_bytes - Unit conversion of the size from frames to bytes
     705 * @runtime: PCM runtime instance
     706 * @size: size in frames
     707 */
    587708static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size)
    588709{
     
    590711}
    591712
     713/**
     714 * frame_aligned - Check whether the byte size is aligned to frames
     715 * @runtime: PCM runtime instance
     716 * @bytes: size in bytes
     717 */
    592718static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes)
    593719{
     
    595721}
    596722
     723/**
     724 * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes
     725 * @substream: PCM substream
     726 */
    597727static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream)
    598728{
     
    601731}
    602732
     733/**
     734 * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes
     735 * @substream: PCM substream
     736 */
    603737static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream)
    604738{
     
    607741}
    608742
    609 /*
    610  *  result is: 0 ... (boundary - 1)
     743/**
     744 * snd_pcm_playback_avail - Get the available (writable) space for playback
     745 * @runtime: PCM runtime instance
     746 *
     747 * Result is between 0 ... (boundary - 1)
    611748 */
    612749static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime)
     
    633770}
    634771
    635 /*
    636  *  result is: 0 ... (boundary - 1)
     772/**
     773 * snd_pcm_capture_avail - Get the available (readable) space for capture
     774 * @runtime: PCM runtime instance
     775 *
     776 * Result is between 0 ... (boundary - 1)
    637777 */
    638778static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime)
     
    644784}
    645785
     786/**
     787 * snd_pcm_playback_hw_avail - Get the queued space for playback
     788 * @runtime: PCM runtime instance
     789 */
    646790static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime)
    647791{
     
    649793}
    650794
     795/**
     796 * snd_pcm_capture_hw_avail - Get the free space for capture
     797 * @runtime: PCM runtime instance
     798 */
    651799static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime)
    652800{
     
    660808 * Checks whether enough free space is available on the playback buffer.
    661809 *
    662  * Returns non-zero if available, or zero if not.
     810 * Return: Non-zero if available, or zero if not.
    663811 */
    664812static inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream)
     
    674822 * Checks whether enough capture data is available on the capture buffer.
    675823 *
    676  * Returns non-zero if available, or zero if not.
     824 * Return: Non-zero if available, or zero if not.
    677825 */
    678826static inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream)
     
    686834 * @substream: the pcm substream instance
    687835 *
    688  * Checks whether any data exists on the playback buffer. If stop_threshold
     836 * Checks whether any data exists on the playback buffer.
     837 *
     838 * Return: Non-zero if any data exists, or zero if not. If stop_threshold
    689839 * is bigger or equal to boundary, then this function returns always non-zero.
    690  *
    691  * Returns non-zero if exists, or zero if not.
    692840 */
    693841static inline int snd_pcm_playback_data(struct snd_pcm_substream *substream)
     
    706854 * Checks whether the playback buffer is empty.
    707855 *
    708  * Returns non-zero if empty, or zero if not.
     856 * Return: Non-zero if empty, or zero if not.
    709857 */
    710858static inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream)
     
    720868 * Checks whether the capture buffer is empty.
    721869 *
    722  * Returns non-zero if empty, or zero if not.
     870 * Return: Non-zero if empty, or zero if not.
    723871 */
    724872static inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream)
     
    728876}
    729877
     878/**
     879 * snd_pcm_trigger_done - Mark the master substream
     880 * @substream: the pcm substream instance
     881 * @master: the linked master substream
     882 *
     883 * When multiple substreams of the same card are linked and the hardware
     884 * supports the single-shot operation, the driver calls this in the loop
     885 * in snd_pcm_group_for_each_entry() for marking the substream as "done".
     886 * Then most of trigger operations are performed only to the given master
     887 * substream.
     888 *
     889 * The trigger_master mark is cleared at timestamp updates at the end
     890 * of trigger operations.
     891 */
    730892static inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream,
    731893                                        struct snd_pcm_substream *master)
     
    770932}
    771933
    772 #define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS))
    773 #define params_format(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT))
    774 #define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
    775 #define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min
    776 #define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min
    777 #define params_period_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min
    778 #define params_period_bytes(p) ((params_period_size(p)*snd_pcm_format_physical_width(params_format(p))*params_channels(p))/8)
    779 #define params_periods(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIODS)->min
    780 #define params_buffer_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min
    781 #define params_buffer_bytes(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min
    782 
     934/**
     935 * params_channels - Get the number of channels from the hw params
     936 * @p: hw params
     937 */
     938static inline unsigned int params_channels(const struct snd_pcm_hw_params *p)
     939{
     940        return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_CHANNELS)->min;
     941}
     942
     943/**
     944 * params_rate - Get the sample rate from the hw params
     945 * @p: hw params
     946 */
     947static inline unsigned int params_rate(const struct snd_pcm_hw_params *p)
     948{
     949        return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_RATE)->min;
     950}
     951
     952/**
     953 * params_period_size - Get the period size (in frames) from the hw params
     954 * @p: hw params
     955 */
     956static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p)
     957{
     958        return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min;
     959}
     960
     961/**
     962 * params_periods - Get the number of periods from the hw params
     963 * @p: hw params
     964 */
     965static inline unsigned int params_periods(const struct snd_pcm_hw_params *p)
     966{
     967        return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIODS)->min;
     968}
     969
     970/**
     971 * params_buffer_size - Get the buffer size (in frames) from the hw params
     972 * @p: hw params
     973 */
     974static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p)
     975{
     976        return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min;
     977}
     978
     979/**
     980 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params
     981 * @p: hw params
     982 */
     983static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p)
     984{
     985        return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min;
     986}
    783987
    784988int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v);
    785 void snd_interval_mul(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c);
    786 void snd_interval_div(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c);
    787 void snd_interval_muldivk(const struct snd_interval *a, const struct snd_interval *b,
    788                           unsigned int k, struct snd_interval *c);
    789 void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k,
    790                           const struct snd_interval *b, struct snd_interval *c);
    791 int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask);
     989int snd_interval_list(struct snd_interval *i, unsigned int count,
     990                      const unsigned int *list, unsigned int mask);
     991int snd_interval_ranges(struct snd_interval *i, unsigned int count,
     992                        const struct snd_interval *list, unsigned int mask);
    792993int snd_interval_ratnum(struct snd_interval *i,
    793                         unsigned int rats_count, struct snd_ratnum *rats,
     994                        unsigned int rats_count, const struct snd_ratnum *rats,
    794995                        unsigned int *nump, unsigned int *denp);
    795996
    796997void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params);
    797998void _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var);
    798 int snd_pcm_hw_params_choose(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
    799999
    8001000int snd_pcm_hw_refine(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
    8011001
    802 int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream);
    803 int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream);
    804 
    805 int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
    806                                u_int32_t mask);
    8071002int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
    8081003                                 u_int64_t mask);
     
    8131008                               unsigned int cond,
    8141009                               snd_pcm_hw_param_t var,
    815                                struct snd_pcm_hw_constraint_list *l);
     1010                               const struct snd_pcm_hw_constraint_list *l);
     1011int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime,
     1012                                 unsigned int cond,
     1013                                 snd_pcm_hw_param_t var,
     1014                                 const struct snd_pcm_hw_constraint_ranges *r);
    8161015int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime,
    8171016                                  unsigned int cond,
    8181017                                  snd_pcm_hw_param_t var,
    819                                   struct snd_pcm_hw_constraint_ratnums *r);
     1018                                  const struct snd_pcm_hw_constraint_ratnums *r);
    8201019int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime,
    8211020                                  unsigned int cond,
    8221021                                  snd_pcm_hw_param_t var,
    823                                   struct snd_pcm_hw_constraint_ratdens *r);
     1022                                  const struct snd_pcm_hw_constraint_ratdens *r);
    8241023int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime,
    8251024                                 unsigned int cond,
     
    8331032                               unsigned int cond,
    8341033                               snd_pcm_hw_param_t var);
     1034int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime,
     1035                               unsigned int base_rate);
    8351036int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime,
    8361037                        unsigned int cond,
     
    8391040                        int dep, ...);
    8401041
     1042/**
     1043 * snd_pcm_hw_constraint_single() - Constrain parameter to a single value
     1044 * @runtime: PCM runtime instance
     1045 * @var: The hw_params variable to constrain
     1046 * @val: The value to constrain to
     1047 *
     1048 * Return: Positive if the value is changed, zero if it's not changed, or a
     1049 * negative error code.
     1050 */
     1051static inline int snd_pcm_hw_constraint_single(
     1052        struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
     1053        unsigned int val)
     1054{
     1055        return snd_pcm_hw_constraint_minmax(runtime, var, val, val);
     1056}
     1057
    8411058int snd_pcm_format_signed(snd_pcm_format_t format);
    8421059int snd_pcm_format_unsigned(snd_pcm_format_t format);
     
    8441061int snd_pcm_format_little_endian(snd_pcm_format_t format);
    8451062int snd_pcm_format_big_endian(snd_pcm_format_t format);
    846 #if 0 /* just for DocBook */
     1063#if 0 /* just for kernel-doc */
    8471064/**
    8481065 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
    8491066 * @format: the format to check
    8501067 *
    851  * Returns 1 if the given PCM format is CPU-endian, 0 if
     1068 * Return: 1 if the given PCM format is CPU-endian, 0 if
    8521069 * opposite, or a negative error code if endian not specified.
    8531070 */
     
    8641081const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format);
    8651082int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);
    866 snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian);
    867 
    868 void snd_pcm_set_ops(struct snd_pcm * pcm, int direction, struct snd_pcm_ops *ops);
     1083
     1084void snd_pcm_set_ops(struct snd_pcm * pcm, int direction,
     1085                     const struct snd_pcm_ops *ops);
    8691086void snd_pcm_set_sync(struct snd_pcm_substream *substream);
    870 int snd_pcm_lib_interleave_len(struct snd_pcm_substream *substream);
    8711087int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream,
    8721088                      unsigned int cmd, void *arg);                     
    873 int snd_pcm_update_state(struct snd_pcm_substream *substream,
    874                          struct snd_pcm_runtime *runtime);
    875 int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream);
    876 int snd_pcm_playback_xrun_check(struct snd_pcm_substream *substream);
    877 int snd_pcm_capture_xrun_check(struct snd_pcm_substream *substream);
    878 int snd_pcm_playback_xrun_asap(struct snd_pcm_substream *substream);
    879 int snd_pcm_capture_xrun_asap(struct snd_pcm_substream *substream);
    880 void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr);
    8811089void snd_pcm_period_elapsed(struct snd_pcm_substream *substream);
    882 snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream,
    883                                     const void __user *buf,
    884                                     snd_pcm_uframes_t frames);
    885 snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream,
    886                                    void __user *buf, snd_pcm_uframes_t frames);
    887 snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream,
    888                                      void __user **bufs, snd_pcm_uframes_t frames);
    889 snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream,
    890                                     void __user **bufs, snd_pcm_uframes_t frames);
    891 
    892 extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
    893 
    894 int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime);
     1090snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
     1091                                     void *buf, bool interleaved,
     1092                                     snd_pcm_uframes_t frames, bool in_kernel);
     1093
     1094static inline snd_pcm_sframes_t
     1095snd_pcm_lib_write(struct snd_pcm_substream *substream,
     1096                  const void __user *buf, snd_pcm_uframes_t frames)
     1097{
     1098        return __snd_pcm_lib_xfer(substream, (void __force *)buf, true, frames, false);
     1099}
     1100
     1101static inline snd_pcm_sframes_t
     1102snd_pcm_lib_read(struct snd_pcm_substream *substream,
     1103                 void __user *buf, snd_pcm_uframes_t frames)
     1104{
     1105        return __snd_pcm_lib_xfer(substream, (void __force *)buf, true, frames, false);
     1106}
     1107
     1108static inline snd_pcm_sframes_t
     1109snd_pcm_lib_writev(struct snd_pcm_substream *substream,
     1110                   void __user **bufs, snd_pcm_uframes_t frames)
     1111{
     1112        return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false);
     1113}
     1114
     1115static inline snd_pcm_sframes_t
     1116snd_pcm_lib_readv(struct snd_pcm_substream *substream,
     1117                  void __user **bufs, snd_pcm_uframes_t frames)
     1118{
     1119        return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false);
     1120}
     1121
     1122static inline snd_pcm_sframes_t
     1123snd_pcm_kernel_write(struct snd_pcm_substream *substream,
     1124                     const void *buf, snd_pcm_uframes_t frames)
     1125{
     1126        return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames, true);
     1127}
     1128
     1129static inline snd_pcm_sframes_t
     1130snd_pcm_kernel_read(struct snd_pcm_substream *substream,
     1131                    void *buf, snd_pcm_uframes_t frames)
     1132{
     1133        return __snd_pcm_lib_xfer(substream, buf, true, frames, true);
     1134}
     1135
     1136static inline snd_pcm_sframes_t
     1137snd_pcm_kernel_writev(struct snd_pcm_substream *substream,
     1138                      void **bufs, snd_pcm_uframes_t frames)
     1139{
     1140        return __snd_pcm_lib_xfer(substream, bufs, false, frames, true);
     1141}
     1142
     1143static inline snd_pcm_sframes_t
     1144snd_pcm_kernel_readv(struct snd_pcm_substream *substream,
     1145                     void **bufs, snd_pcm_uframes_t frames)
     1146{
     1147        return __snd_pcm_lib_xfer(substream, bufs, false, frames, true);
     1148}
     1149
     1150int snd_pcm_hw_limit_rates(struct snd_pcm_hardware *hw);
     1151
     1152static inline int
     1153snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
     1154{
     1155        return snd_pcm_hw_limit_rates(&runtime->hw);
     1156}
     1157
    8951158unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
    896 
     1159unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
     1160unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
     1161                                         unsigned int rates_b);
     1162unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min,
     1163                                        unsigned int rate_max);
     1164
     1165/**
     1166 * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer
     1167 * @substream: PCM substream to set
     1168 * @bufp: the buffer information, NULL to clear
     1169 *
     1170 * Copy the buffer information to runtime->dma_buffer when @bufp is non-NULL.
     1171 * Otherwise it clears the current buffer information.
     1172 */
    8971173static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream,
    8981174                                              struct snd_dma_buffer *bufp)
     
    9121188}
    9131189
    914 /*
    915  *  Timer interface
    916  */
    917 
    918 void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream);
    919 void snd_pcm_timer_init(struct snd_pcm_substream *substream);
    920 void snd_pcm_timer_done(struct snd_pcm_substream *substream);
    921 
     1190/**
     1191 * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode
     1192 * @runtime: PCM runtime instance
     1193 * @tv: timespec64 to fill
     1194 */
    9221195static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
    923                                    struct timespec *tv)
    924 {
    925         if (runtime->tstamp_type == SNDRV_PCM_TSTAMP_TYPE_MONOTONIC)
    926                 do_posix_clock_monotonic_gettime(tv);
    927         else
    928                 getnstimeofday(tv);
     1196                                   struct timespec64 *tv)
     1197{
     1198        switch (runtime->tstamp_type) {
     1199        case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC:
     1200                ktime_get_ts64(tv);
     1201                break;
     1202        case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
     1203                ktime_get_raw_ts64(tv);
     1204                break;
     1205        default:
     1206                ktime_get_real_ts64(tv);
     1207                break;
     1208        }
    9291209}
    9301210
     
    9331213 */
    9341214
    935 int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream);
    936 int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm);
    937 int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
     1215void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream);
     1216void snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm);
     1217void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
    9381218                                  int type, struct device *data,
    9391219                                  size_t size, size_t max);
    940 int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
     1220void snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
    9411221                                          int type, void *data,
    9421222                                          size_t size, size_t max);
    9431223int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size);
    9441224int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream);
     1225
     1226void snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type,
     1227                                struct device *data, size_t size, size_t max);
     1228void snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type,
     1229                                    struct device *data,
     1230                                    size_t size, size_t max);
    9451231
    9461232int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream,
     
    9491235struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream,
    9501236                                          unsigned long offset);
    951 #if 0 /* for kernel-doc */
    9521237/**
    9531238 * snd_pcm_lib_alloc_vmalloc_buffer - allocate virtual DMA buffer
     
    9591244 * if the buffer is accessed by kernel code but not by device DMA.
    9601245 *
    961  * Returns 1 if the buffer was changed, 0 if not changed, or a negative error
     1246 * Return: 1 if the buffer was changed, 0 if not changed, or a negative error
    9621247 * code.
    9631248 */
    964 static int snd_pcm_lib_alloc_vmalloc_buffer
    965                         (struct snd_pcm_substream *substream, size_t size);
     1249static inline int snd_pcm_lib_alloc_vmalloc_buffer
     1250                        (struct snd_pcm_substream *substream, size_t size)
     1251{
     1252        return _snd_pcm_lib_alloc_vmalloc_buffer(substream, size,
     1253                                                 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
     1254}
     1255
    9661256/**
    9671257 * snd_pcm_lib_alloc_vmalloc_32_buffer - allocate 32-bit-addressable buffer
     
    9711261 * This function works like snd_pcm_lib_alloc_vmalloc_buffer(), but uses
    9721262 * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory.
    973  */
    974 static int snd_pcm_lib_alloc_vmalloc_32_buffer
    975                         (struct snd_pcm_substream *substream, size_t size);
    976 #endif
    977 #define snd_pcm_lib_alloc_vmalloc_buffer(subs, size) \
    978         _snd_pcm_lib_alloc_vmalloc_buffer \
    979                         (subs, size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO)
    980 #define snd_pcm_lib_alloc_vmalloc_32_buffer(subs, size) \
    981         _snd_pcm_lib_alloc_vmalloc_buffer \
    982                         (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO)
     1263 *
     1264 * Return: 1 if the buffer was changed, 0 if not changed, or a negative error
     1265 * code.
     1266 */
     1267static inline int snd_pcm_lib_alloc_vmalloc_32_buffer
     1268                        (struct snd_pcm_substream *substream, size_t size)
     1269{
     1270        return _snd_pcm_lib_alloc_vmalloc_buffer(substream, size,
     1271                                                 GFP_KERNEL | GFP_DMA32 | __GFP_ZERO);
     1272}
     1273
     1274#define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p)
    9831275
    9841276#ifdef CONFIG_SND_DMA_SGBUF
     
    9871279 */
    9881280#define snd_pcm_substream_sgbuf(substream) \
    989         ((substream)->runtime->dma_buffer_p->private_data)
    990 
     1281        snd_pcm_get_dma_buf(substream)->private_data
     1282#endif /* SND_DMA_SGBUF */
     1283
     1284/**
     1285 * snd_pcm_sgbuf_get_addr - Get the DMA address at the corresponding offset
     1286 * @substream: PCM substream
     1287 * @ofs: byte offset
     1288 */
    9911289static inline dma_addr_t
    9921290snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs)
    9931291{
    994         struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream);
    995         return snd_sgbuf_get_addr(sg, ofs);
    996 }
    997 
     1292        return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs);
     1293}
     1294
     1295/**
     1296 * snd_pcm_sgbuf_get_ptr - Get the virtual address at the corresponding offset
     1297 * @substream: PCM substream
     1298 * @ofs: byte offset
     1299 */
    9981300static inline void *
    9991301snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs)
    10001302{
    1001         struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream);
    1002         return snd_sgbuf_get_ptr(sg, ofs);
    1003 }
    1004 
    1005 struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream,
    1006                                     unsigned long offset);
    1007 unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream,
    1008                                           unsigned int ofs, unsigned int size);
    1009 
    1010 #else /* !SND_DMA_SGBUF */
    1011 /*
    1012  * fake using a continuous buffer
    1013  */
    1014 static inline dma_addr_t
    1015 snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs)
    1016 {
    1017         return substream->runtime->dma_addr + ofs;
    1018 }
    1019 
    1020 static inline void *
    1021 snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs)
    1022 {
    1023         return substream->runtime->dma_area + ofs;
    1024 }
    1025 
    1026 #define snd_pcm_sgbuf_ops_page  NULL
    1027 
    1028 #define snd_pcm_sgbuf_get_chunk_size(subs, ofs, size)   (size)
    1029 
    1030 #endif /* SND_DMA_SGBUF */
    1031 
    1032 /* handle mmap counter - PCM mmap callback should handle this counter properly */
     1303        return snd_sgbuf_get_ptr(snd_pcm_get_dma_buf(substream), ofs);
     1304}
     1305
     1306/**
     1307 * snd_pcm_sgbuf_get_chunk_size - Compute the max size that fits within the
     1308 * contig. page from the given size
     1309 * @substream: PCM substream
     1310 * @ofs: byte offset
     1311 * @size: byte size to examine
     1312 */
     1313static inline unsigned int
     1314snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream,
     1315                             unsigned int ofs, unsigned int size)
     1316{
     1317        return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size);
     1318}
     1319
     1320/**
     1321 * snd_pcm_mmap_data_open - increase the mmap counter
     1322 * @area: VMA
     1323 *
     1324 * PCM mmap callback should handle this counter properly
     1325 */
    10331326static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area)
    10341327{
     
    10371330}
    10381331
     1332/**
     1333 * snd_pcm_mmap_data_close - decrease the mmap counter
     1334 * @area: VMA
     1335 *
     1336 * PCM mmap callback should handle this counter properly
     1337 */
    10391338static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area)
    10401339{
     
    10431342}
    10441343
     1344int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream,
     1345                             struct vm_area_struct *area);
    10451346/* mmap for io-memory area */
    10461347#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA)
     
    10521353#endif
    10531354
    1054 int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream,
    1055                                struct vm_area_struct *area);
    1056 #define snd_pcm_lib_mmap_vmalloc        snd_pcm_lib_mmap_noncached
    1057 
     1355/**
     1356 * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer
     1357 * @dma: DMA number
     1358 * @max: pointer to store the max size
     1359 */
    10581360static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
    10591361{
     
    10701372                                         (IEC958_AES3_CON_FS_48000<<24))
    10711373
    1072 #define PCM_RUNTIME_CHECK(sub) snd_BUG_ON(!(sub) || !(sub)->runtime)
    1073 
    10741374const char *snd_pcm_format_name(snd_pcm_format_t format);
    10751375
     1376/**
     1377 * snd_pcm_stream_str - Get a string naming the direction of a stream
     1378 * @substream: the pcm substream instance
     1379 *
     1380 * Return: A string naming the direction of the stream.
     1381 */
     1382static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
     1383{
     1384        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
     1385                return "Playback";
     1386        else
     1387                return "Capture";
     1388}
     1389
     1390/*
     1391 * PCM channel-mapping control API
     1392 */
     1393/* array element of channel maps */
     1394struct snd_pcm_chmap_elem {
     1395        unsigned char channels;
     1396        unsigned char map[15];
     1397};
     1398
     1399/* channel map information; retrieved via snd_kcontrol_chip() */
     1400struct snd_pcm_chmap {
     1401        struct snd_pcm *pcm;    /* assigned PCM instance */
     1402        int stream;             /* PLAYBACK or CAPTURE */
     1403        struct snd_kcontrol *kctl;
     1404        const struct snd_pcm_chmap_elem *chmap;
     1405        unsigned int max_channels;
     1406        unsigned int channel_mask;      /* optional: active channels bitmask */
     1407        void *private_data;     /* optional: private data pointer */
     1408};
     1409
     1410/**
     1411 * snd_pcm_chmap_substream - get the PCM substream assigned to the given chmap info
     1412 * @info: chmap information
     1413 * @idx: the substream number index
     1414 */
     1415static inline struct snd_pcm_substream *
     1416snd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx)
     1417{
     1418        struct snd_pcm_substream *s;
     1419        for (s = info->pcm->streams[info->stream].substream; s; s = s->next)
     1420                if (s->number == idx)
     1421                        return s;
     1422        return NULL;
     1423}
     1424
     1425/* ALSA-standard channel maps (RL/RR prior to C/LFE) */
     1426extern const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[];
     1427/* Other world's standard channel maps (C/LFE prior to RL/RR) */
     1428extern const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[];
     1429
     1430/* bit masks to be passed to snd_pcm_chmap.channel_mask field */
     1431#define SND_PCM_CHMAP_MASK_24   ((1U << 2) | (1U << 4))
     1432#define SND_PCM_CHMAP_MASK_246  (SND_PCM_CHMAP_MASK_24 | (1U << 6))
     1433#define SND_PCM_CHMAP_MASK_2468 (SND_PCM_CHMAP_MASK_246 | (1U << 8))
     1434
     1435int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream,
     1436                           const struct snd_pcm_chmap_elem *chmap,
     1437                           int max_channels,
     1438                           unsigned long private_value,
     1439                           struct snd_pcm_chmap **info_ret);
     1440
     1441/**
     1442 * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise
     1443 * @pcm_format: PCM format
     1444 */
     1445static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
     1446{
     1447        return 1ULL << (__force int) pcm_format;
     1448}
     1449
     1450/**
     1451 * pcm_for_each_format - helper to iterate for each format type
     1452 * @f: the iterator variable in snd_pcm_format_t type
     1453 */
     1454#define pcm_for_each_format(f)                                          \
     1455        for ((f) = SNDRV_PCM_FORMAT_FIRST;                              \
     1456             (__force int)(f) <= (__force int)SNDRV_PCM_FORMAT_LAST;    \
     1457             (f) = (__force snd_pcm_format_t)((__force int)(f) + 1))
     1458
     1459/* printk helpers */
     1460#ifndef TARGET_OS2
     1461#define pcm_err(pcm, fmt, args...) \
     1462        dev_err((pcm)->card->dev, fmt, ##args)
     1463#define pcm_warn(pcm, fmt, args...) \
     1464        dev_warn((pcm)->card->dev, fmt, ##args)
     1465#define pcm_dbg(pcm, fmt, args...) \
     1466        dev_dbg((pcm)->card->dev, fmt, ##args)
     1467#else
     1468#define pcm_err pcm_dbg
     1469#define pcm_warn pcm_dbg
     1470int pcm_dbg(struct snd_pcm *dev, const char *fmt, ...);
     1471#endif
     1472
     1473struct snd_pcm_status64 {
     1474        snd_pcm_state_t state;          /* stream state */
     1475        u8 rsvd[4];
     1476        s64 trigger_tstamp_sec;         /* time when stream was started/stopped/paused */
     1477        s64 trigger_tstamp_nsec;
     1478        s64 tstamp_sec;                 /* reference timestamp */
     1479        s64 tstamp_nsec;
     1480        snd_pcm_uframes_t appl_ptr;     /* appl ptr */
     1481        snd_pcm_uframes_t hw_ptr;       /* hw ptr */
     1482        snd_pcm_sframes_t delay;        /* current delay in frames */
     1483        snd_pcm_uframes_t avail;        /* number of frames available */
     1484        snd_pcm_uframes_t avail_max;    /* max frames available on hw since last status */
     1485        snd_pcm_uframes_t overrange;    /* count of ADC (capture) overrange detections from last status */
     1486        snd_pcm_state_t suspended_state; /* suspended stream state */
     1487        __u32 audio_tstamp_data;         /* needed for 64-bit alignment, used for configs/report to/from userspace */
     1488        s64 audio_tstamp_sec;           /* sample counter, wall clock, PHC or on-demand sync'ed */
     1489        s64 audio_tstamp_nsec;
     1490        s64 driver_tstamp_sec;          /* useful in case reference system tstamp is reported with delay */
     1491        s64 driver_tstamp_nsec;
     1492        __u32 audio_tstamp_accuracy;    /* in ns units, only valid if indicated in audio_tstamp_data */
     1493        unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */
     1494};
     1495
     1496#define SNDRV_PCM_IOCTL_STATUS64        _IOR('A', 0x20, struct snd_pcm_status64)
     1497#define SNDRV_PCM_IOCTL_STATUS_EXT64    _IOWR('A', 0x24, struct snd_pcm_status64)
     1498
     1499struct snd_pcm_status32 {
     1500        snd_pcm_state_t state;          /* stream state */
     1501        s32 trigger_tstamp_sec; /* time when stream was started/stopped/paused */
     1502        s32 trigger_tstamp_nsec;
     1503        s32 tstamp_sec;         /* reference timestamp */
     1504        s32 tstamp_nsec;
     1505        u32 appl_ptr;           /* appl ptr */
     1506        u32 hw_ptr;             /* hw ptr */
     1507        s32 delay;              /* current delay in frames */
     1508        u32 avail;              /* number of frames available */
     1509        u32 avail_max;          /* max frames available on hw since last status */
     1510        u32 overrange;          /* count of ADC (capture) overrange detections from last status */
     1511        snd_pcm_state_t suspended_state;        /* suspended stream state */
     1512        u32 audio_tstamp_data;  /* needed for 64-bit alignment, used for configs/report to/from userspace */
     1513        s32 audio_tstamp_sec;   /* sample counter, wall clock, PHC or on-demand sync'ed */
     1514        s32 audio_tstamp_nsec;
     1515        s32 driver_tstamp_sec;  /* useful in case reference system tstamp is reported with delay */
     1516        s32 driver_tstamp_nsec;
     1517        u32 audio_tstamp_accuracy;      /* in ns units, only valid if indicated in audio_tstamp_data */
     1518        unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */
     1519};
     1520
     1521#define SNDRV_PCM_IOCTL_STATUS32        _IOR('A', 0x20, struct snd_pcm_status32)
     1522#define SNDRV_PCM_IOCTL_STATUS_EXT32    _IOWR('A', 0x24, struct snd_pcm_status32)
     1523
    10761524#endif /* __SOUND_PCM_H */
  • GPL/trunk/alsa-kernel/include/sound/pcm_oss.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_PCM_OSS_H
    23#define __SOUND_PCM_OSS_H
     
    56 *  Digital Audio (PCM) - OSS compatibility abstract layer
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     
    5843        size_t buffer_used;                     /* used length from period buffer */
    5944        struct mutex params_lock;
     45        atomic_t rw_ref;                /* concurrent read/write accesses */
    6046#ifdef CONFIG_SND_PCM_OSS_PLUGINS
    6147        struct snd_pcm_plugin *plugin_first;
  • GPL/trunk/alsa-kernel/include/sound/pcm_params.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_PCM_PARAMS_H
    23#define __SOUND_PCM_PARAMS_H
     
    56 *  PCM params helpers
    67 *  Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    23  */
     8 */
     9
     10#include <sound/pcm.h>
    2411
    2512int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm,
     
    3724#define MASK_BIT(i)     (1U << ((i) & 31))
    3825
    39 static inline unsigned int ld2(u_int32_t v)
    40 {
    41         unsigned r = 0;
    42 
    43         if (v >= 0x10000) {
    44                 v >>= 16;
    45                 r += 16;
    46         }
    47         if (v >= 0x100) {
    48                 v >>= 8;
    49                 r += 8;
    50         }
    51         if (v >= 0x10) {
    52                 v >>= 4;
    53                 r += 4;
    54         }
    55         if (v >= 4) {
    56                 v >>= 2;
    57                 r += 2;
    58         }
    59         if (v >= 2)
    60                 r++;
    61         return r;
    62 }
    63 
    64 static inline size_t snd_mask_sizeof(void)
    65 {
    66         return sizeof(struct snd_mask);
    67 }
    68 
    6926static inline void snd_mask_none(struct snd_mask *mask)
    7027{
     
    9148        for (i = 0; i < SNDRV_MASK_SIZE; i++) {
    9249                if (mask->bits[i])
    93                         return ffs(mask->bits[i]) - 1 + (i << 5);
     50                        return __ffs(mask->bits[i]) + (i << 5);
    9451        }
    9552        return 0;
     
    10158        for (i = SNDRV_MASK_SIZE - 1; i >= 0; i--) {
    10259                if (mask->bits[i])
    103                         return ld2(mask->bits[i]) + (i << 5);
     60                        return __fls(mask->bits[i]) + (i << 5);
    10461        }
    10562        return 0;
     
    10966{
    11067        mask->bits[MASK_OFS(val)] |= MASK_BIT(val);
     68}
     69
     70/* Most of drivers need only this one */
     71static inline void snd_mask_set_format(struct snd_mask *mask,
     72                                       snd_pcm_format_t format)
     73{
     74        snd_mask_set(mask, (__force unsigned int)format);
    11175}
    11276
     
    163127{
    164128        return mask->bits[MASK_OFS(val)] & MASK_BIT(val);
     129}
     130
     131/* Most of drivers need only this one */
     132static inline int snd_mask_test_format(const struct snd_mask *mask,
     133                                       snd_pcm_format_t format)
     134{
     135        return snd_mask_test(mask, (__force unsigned int)format);
    165136}
    166137
     
    271242{
    272243        return (i->min == i->max ||
    273                 (i->min + 1 == i->max && i->openmax));
     244                (i->min + 1 == i->max && (i->openmin || i->openmax)));
    274245}
    275246
    276247static inline int snd_interval_value(const struct snd_interval *i)
    277248{
     249        if (i->openmin && !i->openmax)
     250                return i->max;
    278251        return i->min;
    279252}
     
    324297}
    325298
    326 static inline unsigned int add(unsigned int a, unsigned int b)
    327 {
    328         if (a >= UINT_MAX - b)
    329                 return UINT_MAX;
    330         return a + b;
    331 }
    332 
    333 static inline unsigned int sub(unsigned int a, unsigned int b)
    334 {
    335         if (a > b)
    336                 return a - b;
    337         return 0;
     299/**
     300 * params_access - get the access type from the hw params
     301 * @p: hw params
     302 */
     303static inline snd_pcm_access_t params_access(const struct snd_pcm_hw_params *p)
     304{
     305        return (__force snd_pcm_access_t)snd_mask_min(hw_param_mask_c(p,
     306                SNDRV_PCM_HW_PARAM_ACCESS));
     307}
     308
     309/**
     310 * params_format - get the sample format from the hw params
     311 * @p: hw params
     312 */
     313static inline snd_pcm_format_t params_format(const struct snd_pcm_hw_params *p)
     314{
     315        return (__force snd_pcm_format_t)snd_mask_min(hw_param_mask_c(p,
     316                SNDRV_PCM_HW_PARAM_FORMAT));
     317}
     318
     319/**
     320 * params_subformat - get the sample subformat from the hw params
     321 * @p: hw params
     322 */
     323static inline snd_pcm_subformat_t
     324params_subformat(const struct snd_pcm_hw_params *p)
     325{
     326        return (__force snd_pcm_subformat_t)snd_mask_min(hw_param_mask_c(p,
     327                SNDRV_PCM_HW_PARAM_SUBFORMAT));
     328}
     329
     330/**
     331 * params_period_bytes - get the period size (in bytes) from the hw params
     332 * @p: hw params
     333 */
     334static inline unsigned int
     335params_period_bytes(const struct snd_pcm_hw_params *p)
     336{
     337        return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIOD_BYTES)->min;
     338}
     339
     340/**
     341 * params_width - get the number of bits of the sample format from the hw params
     342 * @p: hw params
     343 *
     344 * This function returns the number of bits per sample that the selected sample
     345 * format of the hw params has.
     346 */
     347static inline int params_width(const struct snd_pcm_hw_params *p)
     348{
     349        return snd_pcm_format_width(params_format(p));
     350}
     351
     352/*
     353 * params_physical_width - get the storage size of the sample format from the hw params
     354 * @p: hw params
     355 *
     356 * This functions returns the number of bits per sample that the selected sample
     357 * format of the hw params takes up in memory. This will be equal or larger than
     358 * params_width().
     359 */
     360static inline int params_physical_width(const struct snd_pcm_hw_params *p)
     361{
     362        return snd_pcm_format_physical_width(params_format(p));
     363}
     364
     365static inline void
     366params_set_format(struct snd_pcm_hw_params *p, snd_pcm_format_t fmt)
     367{
     368        snd_mask_set_format(hw_param_mask(p, SNDRV_PCM_HW_PARAM_FORMAT), fmt);
    338369}
    339370
    340371#endif /* __SOUND_PCM_PARAMS_H */
    341 
  • GPL/trunk/alsa-kernel/include/sound/pt2258.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 *   ALSA Driver for the PT2258 volume controller.
    34 *
    45 *      Copyright (c) 2006  Jochen Voss <voss@seehuhn.de>
    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  *
    206 */     
    217
  • GPL/trunk/alsa-kernel/include/sound/rawmidi.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_RAWMIDI_H
    23#define __SOUND_RAWMIDI_H
     
    56 *  Abstract layer for MIDI v1.0 stream
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     
    2813#include <linux/wait.h>
    2914#include <linux/mutex.h>
     15#include <linux/workqueue.h>
     16#include <linux/device.h>
    3017
    31 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
    32 #include "seq_device.h"
     18#if IS_ENABLED(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER)
     19#include <sound/seq_device.h>
    3320#endif
    3421
     
    6451
    6552struct snd_rawmidi_runtime {
     53        struct snd_rawmidi_substream *substream;
    6654        unsigned int drain: 1,  /* drain stage */
    6755                     oss: 1;    /* OSS compatible mode */
     
    7462        size_t avail;           /* max used buffer for wakeup */
    7563        size_t xruns;           /* over/underruns counter */
     64        int buffer_ref;         /* buffer reference count */
    7665        /* misc */
    7766        spinlock_t lock;
     
    8069        void (*event)(struct snd_rawmidi_substream *substream);
    8170        /* defers calls to event [input] or ops->trigger [output] */
    82         struct tasklet_struct tasklet;
     71        struct work_struct event_work;
    8372        /* private data */
    8473        void *private_data;
     
    9079        int stream;                     /* direction */
    9180        int number;                     /* substream number */
    92         unsigned int opened: 1,         /* open flag */
    93                      append: 1,         /* append flag (merge more streams) */
    94                      active_sensing: 1; /* send active sensing when close */
     81        bool opened;                    /* open flag */
     82        bool append;                    /* append flag (merge more streams) */
     83        bool active_sensing;            /* send active sensing when close */
    9584        int use_count;                  /* use counter (for output) */
    9685        size_t bytes;
     
    10190        struct pid *pid;
    10291        /* hardware layer */
    103         struct snd_rawmidi_ops *ops;
     92        const struct snd_rawmidi_ops *ops;
    10493};
    10594
     
    128117#endif
    129118
    130         struct snd_rawmidi_global_ops *ops;
     119        const struct snd_rawmidi_global_ops *ops;
    131120
    132121        struct snd_rawmidi_str streams[2];
     
    138127        wait_queue_head_t open_wait;
    139128
    140         struct snd_info_entry *dev;
     129        struct device dev;
     130
    141131        struct snd_info_entry *proc_entry;
    142132
    143 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
     133#if IS_ENABLED(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER)
    144134        struct snd_seq_device *seq_dev;
    145135#endif
     
    152142                    struct snd_rawmidi **rmidi);
    153143void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
    154                          struct snd_rawmidi_ops *ops);
     144                         const struct snd_rawmidi_ops *ops);
    155145
    156146/* callbacks */
    157147
    158 void snd_rawmidi_receive_reset(struct snd_rawmidi_substream *substream);
    159148int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
    160149                        const unsigned char *buffer, int count);
    161 void snd_rawmidi_transmit_reset(struct snd_rawmidi_substream *substream);
    162150int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream);
    163151int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
     
    166154int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
    167155                         unsigned char *buffer, int count);
     156int __snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
     157                              unsigned char *buffer, int count);
     158int __snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream,
     159                               int count);
     160int snd_rawmidi_proceed(struct snd_rawmidi_substream *substream);
    168161
    169162/* main midi functions */
  • GPL/trunk/alsa-kernel/include/sound/sb.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SB_H
    23#define __SOUND_SB_H
     
    56 *  Header file for SoundBlaster cards
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
    25 #include "pcm.h"
    26 #include "rawmidi.h"
     10#include <sound/pcm.h>
     11#include <sound/rawmidi.h>
    2712#include <linux/interrupt.h>
    28 #include <asm/io.h>
     13#include <linux/io.h>
    2914
    3015enum sb_hw_type {
     
    309294
    310295/* sb8_init.c */
    311 int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm);
     296int snd_sb8dsp_pcm(struct snd_sb *chip, int device);
    312297/* sb8.c */
    313298irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip);
     
    318303/* midi8.c */
    319304irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb *chip);
    320 int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawmidi);
     305int snd_sb8dsp_midi(struct snd_sb *chip, int device);
    321306
    322307/* sb16_init.c */
    323 int snd_sb16dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm);
     308int snd_sb16dsp_pcm(struct snd_sb *chip, int device);
    324309const struct snd_pcm_ops *snd_sb16dsp_get_pcm_ops(int direction);
    325310int snd_sb16dsp_configure(struct snd_sb *chip);
  • GPL/trunk/alsa-kernel/include/sound/sb16_csp.h

    r398 r679  
    1 #ifndef __SOUND_SB16_CSP_H
    2 #define __SOUND_SB16_CSP_H
    3 
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    42/*
    53 *  Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si>
     
    75 *
    86 *  SB16ASP/AWE32 CSP control
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    247 */
     8#ifndef __SOUND_SB16_CSP_H
     9#define __SOUND_SB16_CSP_H
    2510
    26 /* CSP modes */
    27 #define SNDRV_SB_CSP_MODE_NONE          0x00
    28 #define SNDRV_SB_CSP_MODE_DSP_READ      0x01    /* Record from DSP */
    29 #define SNDRV_SB_CSP_MODE_DSP_WRITE     0x02    /* Play to DSP */
    30 #define SNDRV_SB_CSP_MODE_QSOUND                0x04    /* QSound */
    31 
    32 /* CSP load flags */
    33 #define SNDRV_SB_CSP_LOAD_FROMUSER      0x01
    34 #define SNDRV_SB_CSP_LOAD_INITBLOCK     0x02
    35 
    36 /* CSP sample width */
    37 #define SNDRV_SB_CSP_SAMPLE_8BIT                0x01
    38 #define SNDRV_SB_CSP_SAMPLE_16BIT               0x02
    39 
    40 /* CSP channels */
    41 #define SNDRV_SB_CSP_MONO                       0x01
    42 #define SNDRV_SB_CSP_STEREO             0x02
    43 
    44 /* CSP rates */
    45 #define SNDRV_SB_CSP_RATE_8000          0x01
    46 #define SNDRV_SB_CSP_RATE_11025         0x02
    47 #define SNDRV_SB_CSP_RATE_22050         0x04
    48 #define SNDRV_SB_CSP_RATE_44100         0x08
    49 #define SNDRV_SB_CSP_RATE_ALL           0x0f
    50 
    51 /* CSP running state */
    52 #define SNDRV_SB_CSP_ST_IDLE            0x00
    53 #define SNDRV_SB_CSP_ST_LOADED          0x01
    54 #define SNDRV_SB_CSP_ST_RUNNING         0x02
    55 #define SNDRV_SB_CSP_ST_PAUSED          0x04
    56 #define SNDRV_SB_CSP_ST_AUTO            0x08
    57 #define SNDRV_SB_CSP_ST_QSOUND          0x10
    58 
    59 /* maximum QSound value (180 degrees right) */
    60 #define SNDRV_SB_CSP_QSOUND_MAX_RIGHT   0x20
    61 
    62 /* maximum microcode RIFF file size */
    63 #define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE    0x3000
    64 
    65 /* microcode header */
    66 struct snd_sb_csp_mc_header {
    67         char codec_name[16];            /* id name of codec */
    68         unsigned short func_req;        /* requested function */
    69 };
    70 
    71 /* microcode to be loaded */
    72 struct snd_sb_csp_microcode {
    73         struct snd_sb_csp_mc_header info;
    74         unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE];
    75 };
    76 
    77 /* start CSP with sample_width in mono/stereo */
    78 struct snd_sb_csp_start {
    79         int sample_width;       /* sample width, look above */
    80         int channels;           /* channels, look above */
    81 };
    82 
    83 /* CSP information */
    84 struct snd_sb_csp_info {
    85         char codec_name[16];            /* id name of codec */
    86         unsigned short func_nr;         /* function number */
    87         unsigned int acc_format;        /* accepted PCM formats */
    88         unsigned short acc_channels;    /* accepted channels */
    89         unsigned short acc_width;       /* accepted sample width */
    90         unsigned short acc_rates;       /* accepted sample rates */
    91         unsigned short csp_mode;        /* CSP mode, see above */
    92         unsigned short run_channels;    /* current channels  */
    93         unsigned short run_width;       /* current sample width */
    94         unsigned short version;         /* version id: 0x10 - 0x1f */
    95         unsigned short state;           /* state bits */
    96 };
    97 
    98 /* HWDEP controls */
    99 /* get CSP information */
    100 #define SNDRV_SB_CSP_IOCTL_INFO         _IOR('H', 0x10, struct snd_sb_csp_info)
    101 /* load microcode to CSP */
    102 #define SNDRV_SB_CSP_IOCTL_LOAD_CODE    _IOW('H', 0x11, struct snd_sb_csp_microcode)
    103 /* unload microcode from CSP */
    104 #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE  _IO('H', 0x12)
    105 /* start CSP */
    106 #define SNDRV_SB_CSP_IOCTL_START                _IOW('H', 0x13, struct snd_sb_csp_start)
    107 /* stop CSP */
    108 #define SNDRV_SB_CSP_IOCTL_STOP         _IO('H', 0x14)
    109 /* pause CSP and DMA transfer */
    110 #define SNDRV_SB_CSP_IOCTL_PAUSE                _IO('H', 0x15)
    111 /* restart CSP and DMA transfer */
    112 #define SNDRV_SB_CSP_IOCTL_RESTART      _IO('H', 0x16)
    113 
    114 #ifdef __KERNEL__
    115 #include "sb.h"
    116 #include "hwdep.h"
     11#include <sound/sb.h>
     12#include <sound/hwdep.h>
    11713#include <linux/firmware.h>
     14#include <uapi/sound/sb16_csp.h>
    11815
    11916struct snd_sb_csp;
     
    13633        int (*csp_use) (struct snd_sb_csp * p);
    13734        int (*csp_unuse) (struct snd_sb_csp * p);
    138         int (*csp_autoload) (struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode);
     35        int (*csp_autoload) (struct snd_sb_csp * p, snd_pcm_format_t pcm_sfmt, int play_rec_mode);
    13936        int (*csp_start) (struct snd_sb_csp * p, int sample_width, int channels);
    14037        int (*csp_stop) (struct snd_sb_csp * p);
     
    17774
    17875int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep);
    179 #endif
    180 
    18176#endif /* __SOUND_SB16_CSP */
  • GPL/trunk/alsa-kernel/include/sound/seq_device.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SEQ_DEVICE_H
    23#define __SOUND_SEQ_DEVICE_H
     
    56 *  ALSA sequencer device management
    67 *  Copyright (c) 1999 by Takashi Iwai <tiwai@suse.de>
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    228 */
    239
     
    2612 */
    2713
    28 #define ID_LEN  32
    29 
    30 /* status flag */
    31 #define SNDRV_SEQ_DEVICE_FREE           0
    32 #define SNDRV_SEQ_DEVICE_REGISTERED     1
    33 
    3414struct snd_seq_device {
    3515        /* device info */
    3616        struct snd_card *card;  /* sound card */
    3717        int device;             /* device number */
    38         char id[ID_LEN];        /* driver id */
     18        const char *id;         /* driver id */
    3919        char name[80];          /* device name */
    4020        int argsize;            /* size of the argument */
    4121        void *driver_data;      /* private data for driver */
    42         int status;             /* flag - read only */
    4322        void *private_data;     /* private data for the caller */
    4423        void (*private_free)(struct snd_seq_device *device);
    45         struct list_head list;  /* link to next device */
     24        struct device dev;
    4625};
    4726
     27#define to_seq_dev(_dev) \
     28        container_of(_dev, struct snd_seq_device, dev)
     29
     30/* sequencer driver */
    4831
    4932/* driver operators
    50  * init_device:
     33 * probe:
    5134 *      Initialize the device with given parameters.
    5235 *      Typically,
     
    5639 *              4. store the instance to dev->driver_data pointer.
    5740 *             
    58  * free_device:
     41 * remove:
    5942 *      Release the private data.
    6043 *      Typically, call snd_device_free(dev->card, dev->driver_data)
    6144 */
    62 struct snd_seq_dev_ops {
    63         int (*init_device)(struct snd_seq_device *dev);
    64         int (*free_device)(struct snd_seq_device *dev);
     45struct snd_seq_driver {
     46        struct device_driver driver;
     47        char *id;
     48        int argsize;
    6549};
     50
     51#define to_seq_drv(_drv) \
     52        container_of(_drv, struct snd_seq_driver, driver)
    6653
    6754/*
    6855 * prototypes
    6956 */
     57#ifdef CONFIG_MODULES
    7058void snd_seq_device_load_drivers(void);
    71 int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, struct snd_seq_device **result);
    72 int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize);
    73 int snd_seq_device_unregister_driver(char *id);
     59#else
     60#define snd_seq_device_load_drivers()
     61#endif
     62int snd_seq_device_new(struct snd_card *card, int device, const char *id,
     63                       int argsize, struct snd_seq_device **result);
    7464
    7565#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
    7666
     67int __must_check __snd_seq_driver_register(struct snd_seq_driver *drv,
     68                                           struct module *mod);
     69#define snd_seq_driver_register(drv) \
     70        __snd_seq_driver_register(drv, THIS_MODULE)
     71void snd_seq_driver_unregister(struct snd_seq_driver *drv);
     72
     73#define module_snd_seq_driver(drv) \
     74        module_driver(drv, snd_seq_driver_register, snd_seq_driver_unregister)
    7775
    7876/*
  • GPL/trunk/alsa-kernel/include/sound/seq_kernel.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SEQ_KERNEL_H
    23#define __SOUND_SEQ_KERNEL_H
     
    56 *  Main kernel header file for the ALSA sequencer
    67 *  Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249#include <linux/time.h>
    25 #include "asequencer.h"
     10#include <sound/asequencer.h>
    2611
    2712typedef struct snd_seq_real_time snd_seq_real_time_t;
    2813typedef union snd_seq_timestamp snd_seq_timestamp_t;
    2914
    30 /* maximum number of events dequeued per schedule interval */
    31 #define SNDRV_SEQ_MAX_DEQUEUE           50
    32 
    3315/* maximum number of queues */
    34 #define SNDRV_SEQ_MAX_QUEUES            8
     16#define SNDRV_SEQ_MAX_QUEUES            32
    3517
    3618/* max number of concurrent clients */
     
    4224/* max number of events in memory pool */
    4325#define SNDRV_SEQ_MAX_EVENTS            2000
    44 
    45 /* default number of events in memory chunk */
    46 #define SNDRV_SEQ_DEFAULT_CHUNK_EVENTS  64
    4726
    4827/* default number of events in memory pool */
     
    5635
    5736/* max delivery path length */
    58 #define SNDRV_SEQ_MAX_HOPS              10
     37/* NOTE: this shouldn't be greater than MAX_LOCKDEP_SUBCLASSES */
     38#define SNDRV_SEQ_MAX_HOPS              8
    5939
    6040/* max size of event size */
     
    7151        int (*event_input)(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop);
    7252        void (*private_free)(void *private_data);
    73         unsigned int callback_all;      /* call subscribe callbacks at each connection/disconnection */
    7453        /*...*/
    7554};
     
    7756/* interface for kernel client */
    7857#ifndef TARGET_OS2
    79 int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
    80                                  const char *name_fmt, ...)
    81         __attribute__ ((format (printf, 3, 4)));
    82 #else
     58__printf(3, 4)
     59#endif
    8360int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
    8461                                 const char *name_fmt, ...);
    85 #endif
    8662int snd_seq_delete_kernel_client(int client);
    87 int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop);
     63int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev,
     64                                  struct file *file, bool blocking);
    8865int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop);
    8966int snd_seq_kernel_client_ctl(int client, unsigned int cmd, void *arg);
     
    11289
    11390#ifdef CONFIG_MODULES
    114 void snd_seq_autoload_lock(void);
    115 void snd_seq_autoload_unlock(void);
     91void snd_seq_autoload_init(void);
     92void snd_seq_autoload_exit(void);
    11693#else
    117 #define snd_seq_autoload_lock()
    118 #define snd_seq_autoload_unlock()
     94#define snd_seq_autoload_init()
     95#define snd_seq_autoload_exit()
    11996#endif
    12097
  • GPL/trunk/alsa-kernel/include/sound/seq_midi_emul.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SEQ_MIDI_EMUL_H
    23#define __SOUND_SEQ_MIDI_EMUL_H
     
    67 *
    78 *  Copyright (C) 1999 Steve Ratcliffe
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    239 */
    2410
    25 #include "seq_kernel.h"
     11#include <sound/seq_kernel.h>
    2612
    2713/*
     
    189175
    190176/* Prototypes for midi_process.c */
    191 void snd_midi_process_event(struct snd_midi_op *ops, struct snd_seq_event *ev,
     177void snd_midi_process_event(const struct snd_midi_op *ops,
     178                            struct snd_seq_event *ev,
    192179                            struct snd_midi_channel_set *chanset);
    193180void snd_midi_channel_set_clear(struct snd_midi_channel_set *chset);
  • GPL/trunk/alsa-kernel/include/sound/seq_midi_event.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SEQ_MIDI_EVENT_H
    23#define __SOUND_SEQ_MIDI_EVENT_H
     
    78 *  Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>,
    89 *                        Jaroslav Kysela <perex@perex.cz>
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2310 */
    2411
    25 #include "asequencer.h"
     12#include <sound/asequencer.h>
    2613
    2714#define MAX_MIDI_EVENT_BUF      256
     
    4431void snd_midi_event_reset_decode(struct snd_midi_event *dev);
    4532void snd_midi_event_no_status(struct snd_midi_event *dev, int on);
    46 /* encode from byte stream - return number of written bytes if success */
    47 long snd_midi_event_encode(struct snd_midi_event *dev, unsigned char *buf, long count,
    48                            struct snd_seq_event *ev);
    49 int snd_midi_event_encode_byte(struct snd_midi_event *dev, int c, struct snd_seq_event *ev);
     33bool snd_midi_event_encode_byte(struct snd_midi_event *dev, unsigned char c,
     34                                struct snd_seq_event *ev);
    5035/* decode from event to bytes - return number of written bytes if success */
    5136long snd_midi_event_decode(struct snd_midi_event *dev, unsigned char *buf, long count,
  • GPL/trunk/alsa-kernel/include/sound/seq_oss.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SEQ_OSS_H
    23#define __SOUND_SEQ_OSS_H
     
    67 *
    78 * Copyright (C) 1998,99 Takashi Iwai
    8  *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU General Public License
    20  * along with this program; if not, write to the Free Software
    21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    229 */
    2310
    24 #include "asequencer.h"
    25 #include "seq_kernel.h"
     11#include <sound/asequencer.h>
     12#include <sound/seq_kernel.h>
    2613
    2714/*
  • GPL/trunk/alsa-kernel/include/sound/seq_oss_legacy.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SEQ_OSS_LEGACY_H
    23#define __SOUND_SEQ_OSS_LEGACY_H
     
    67 *
    78 * Copyright (C) 2000 Abramo Bagnara <abramo@alsa-project.org>
    8  *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU General Public License
    20  * along with this program; if not, write to the Free Software
    21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    229 */
    2310
  • GPL/trunk/alsa-kernel/include/sound/seq_virmidi.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SEQ_VIRMIDI_H
    23#define __SOUND_SEQ_VIRMIDI_H
     
    67 *  Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de>,
    78 *                        Jaroslav Kysela <perex@perex.cz>
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    239 */
    2410
    25 #include "rawmidi.h"
    26 #include "seq_midi_event.h"
     11#include <sound/rawmidi.h>
     12#include <sound/seq_midi_event.h>
    2713
    2814/*
     
    3723        int client;
    3824        int port;
    39         unsigned int trigger: 1;
     25        bool trigger;
    4026        struct snd_midi_event *parser;
    4127        struct snd_seq_event event;
    4228        struct snd_virmidi_dev *rdev;
    4329        struct snd_rawmidi_substream *substream;
     30        struct work_struct output_work;
    4431};
    4532
     
    6148        unsigned int flags;             /* SNDRV_VIRMIDI_* */
    6249        rwlock_t filelist_lock;
     50        struct rw_semaphore filelist_sem;
    6351        struct list_head filelist;
    6452};
  • GPL/trunk/alsa-kernel/include/sound/snd_wavefront.h

    r399 r679  
     1/* SPDX-License-Identifier: GPL-2.0 */
    12#ifndef __SOUND_SND_WAVEFRONT_H__
    23#define __SOUND_SND_WAVEFRONT_H__
    34
    4 #include "mpu401.h"
    5 #include "hwdep.h"
    6 #include "rawmidi.h"
    7 #include "wavefront.h"  /* generic OSS/ALSA/user-level wavefront header */
     5#include <sound/mpu401.h>
     6#include <sound/hwdep.h>
     7#include <sound/rawmidi.h>
     8#include <sound/wavefront.h>  /* generic OSS/ALSA/user-level wavefront header */
    89
    910/* MIDI interface */
     
    2930        struct snd_rawmidi_substream     *substream_input[2];
    3031        struct timer_list        timer;
     32        snd_wavefront_card_t     *timer_card;
    3133        spinlock_t               open;
    3234        spinlock_t               virtual;     /* protects isvirtual */
     
    3840#define UART_MODE_ON    0x3F
    3941
    40 extern struct snd_rawmidi_ops snd_wavefront_midi_output;
    41 extern struct snd_rawmidi_ops snd_wavefront_midi_input;
     42extern const struct snd_rawmidi_ops snd_wavefront_midi_output;
     43extern const struct snd_rawmidi_ops snd_wavefront_midi_input;
    4244
    4345extern void   snd_wavefront_midi_enable_virtual (snd_wavefront_card_t *);
  • GPL/trunk/alsa-kernel/include/sound/soc-dapm.h

    r598 r679  
    1 /*
     1/* SPDX-License-Identifier: GPL-2.0
     2 *
    23 * linux/sound/soc-dapm.h -- ALSA SoC Dynamic Audio Power Management
    34 *
    4  * Author:              Liam Girdwood
    5  * Created:             Aug 11th 2005
     5 * Author:      Liam Girdwood
     6 * Created:     Aug 11th 2005
    67 * Copyright:   Wolfson Microelectronics. PLC.
    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 version 2 as
    10  * published by the Free Software Foundation.
    118 */
    129
     
    1411#define __LINUX_SND_SOC_DAPM_H
    1512
    16 #include <linux/device.h>
    1713#include <linux/types.h>
    1814#include <sound/control.h>
     15#include <sound/soc-topology.h>
     16#include <sound/asoc.h>
     17
     18struct device;
     19struct snd_soc_pcm_runtime;
     20struct soc_enum;
    1921
    2022/* widget has no PM register bit */
     
    2426 * SoC dynamic audio power management
    2527 *
    26  * We can have upto 4 power domains
    27  *      1. Codec domain - VREF, VMID
     28 * We can have up to 4 power domains
     29 *  1. Codec domain - VREF, VMID
    2830 *     Usually controlled at codec probe/remove, although can be set
    2931 *     at stream time if power is not needed for sidetone, etc.
     
    4042/* codec domain */
    4143#define SND_SOC_DAPM_VMID(wname) \
    42 {       .id = snd_soc_dapm_vmid, .name = wname, .kcontrols = NULL, \
     44{       .id = snd_soc_dapm_vmid, .name = wname, .kcontrol_news = NULL, \
    4345        .num_kcontrols = 0}
    4446
    4547/* platform domain */
     48#define SND_SOC_DAPM_SIGGEN(wname) \
     49{       .id = snd_soc_dapm_siggen, .name = wname, .kcontrol_news = NULL, \
     50        .num_kcontrols = 0, .reg = SND_SOC_NOPM }
     51#define SND_SOC_DAPM_SINK(wname) \
     52{       .id = snd_soc_dapm_sink, .name = wname, .kcontrol_news = NULL, \
     53        .num_kcontrols = 0, .reg = SND_SOC_NOPM }
    4654#define SND_SOC_DAPM_INPUT(wname) \
    47 {       .id = snd_soc_dapm_input, .name = wname, .kcontrols = NULL, \
    48         .num_kcontrols = 0}
     55{       .id = snd_soc_dapm_input, .name = wname, .kcontrol_news = NULL, \
     56        .num_kcontrols = 0, .reg = SND_SOC_NOPM }
    4957#define SND_SOC_DAPM_OUTPUT(wname) \
    50 {       .id = snd_soc_dapm_output, .name = wname, .kcontrols = NULL, \
    51         .num_kcontrols = 0}
     58{       .id = snd_soc_dapm_output, .name = wname, .kcontrol_news = NULL, \
     59        .num_kcontrols = 0, .reg = SND_SOC_NOPM }
    5260#define SND_SOC_DAPM_MIC(wname, wevent) \
    53 {       .id = snd_soc_dapm_mic, .name = wname, .kcontrols = NULL, \
    54         .num_kcontrols = 0, .event = wevent, \
     61{       .id = snd_soc_dapm_mic, .name = wname, .kcontrol_news = NULL, \
     62        .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
    5563        .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
    5664#define SND_SOC_DAPM_HP(wname, wevent) \
    57 {       .id = snd_soc_dapm_hp, .name = wname, .kcontrols = NULL, \
    58         .num_kcontrols = 0, .event = wevent, \
     65{       .id = snd_soc_dapm_hp, .name = wname, .kcontrol_news = NULL, \
     66        .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
    5967        .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
    6068#define SND_SOC_DAPM_SPK(wname, wevent) \
    61 {       .id = snd_soc_dapm_spk, .name = wname, .kcontrols = NULL, \
    62         .num_kcontrols = 0, .event = wevent, \
     69{       .id = snd_soc_dapm_spk, .name = wname, .kcontrol_news = NULL, \
     70        .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
    6371        .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
    6472#define SND_SOC_DAPM_LINE(wname, wevent) \
    65 {       .id = snd_soc_dapm_line, .name = wname, .kcontrols = NULL, \
    66         .num_kcontrols = 0, .event = wevent, \
     73{       .id = snd_soc_dapm_line, .name = wname, .kcontrol_news = NULL, \
     74        .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
    6775        .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
     76
     77#define SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert) \
     78        .reg = wreg, .mask = 1, .shift = wshift, \
     79        .on_val = winvert ? 0 : 1, .off_val = winvert ? 1 : 0
    6880
    6981/* path domain */
    7082#define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\
    7183         wcontrols, wncontrols) \
    72 {       .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
    73         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols}
     84{       .id = snd_soc_dapm_pga, .name = wname, \
     85        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     86        .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
    7487#define SND_SOC_DAPM_OUT_DRV(wname, wreg, wshift, winvert,\
    7588         wcontrols, wncontrols) \
    76 {       .id = snd_soc_dapm_out_drv, .name = wname, .reg = wreg, .shift = wshift, \
    77         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols}
     89{       .id = snd_soc_dapm_out_drv, .name = wname, \
     90        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     91        .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
    7892#define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \
    7993         wcontrols, wncontrols)\
    80 {       .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
    81         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols}
     94{       .id = snd_soc_dapm_mixer, .name = wname, \
     95        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     96        .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
    8297#define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \
    8398         wcontrols, wncontrols)\
    84 {       .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \
    85         .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
    86         .num_kcontrols = wncontrols}
     99{       .id = snd_soc_dapm_mixer_named_ctl, .name = wname, \
     100        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     101        .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
     102/* DEPRECATED: use SND_SOC_DAPM_SUPPLY */
    87103#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \
    88 {       .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
    89         .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0}
     104{       .id = snd_soc_dapm_micbias, .name = wname, \
     105        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     106        .kcontrol_news = NULL, .num_kcontrols = 0}
    90107#define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \
    91 {       .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \
    92         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1}
     108{       .id = snd_soc_dapm_switch, .name = wname, \
     109        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     110        .kcontrol_news = wcontrols, .num_kcontrols = 1}
    93111#define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \
    94 {       .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
    95         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1}
    96 #define SND_SOC_DAPM_VIRT_MUX(wname, wreg, wshift, winvert, wcontrols) \
    97 {       .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \
    98         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1}
    99 #define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \
    100 {       .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \
    101         .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
    102         .num_kcontrols = 1}
     112{       .id = snd_soc_dapm_mux, .name = wname, \
     113        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     114        .kcontrol_news = wcontrols, .num_kcontrols = 1}
     115#define SND_SOC_DAPM_DEMUX(wname, wreg, wshift, winvert, wcontrols) \
     116{       .id = snd_soc_dapm_demux, .name = wname, \
     117        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     118        .kcontrol_news = wcontrols, .num_kcontrols = 1}
    103119
    104120/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
    105121#define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\
    106122         wcontrols) \
    107 {       .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
    108         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
     123{       .id = snd_soc_dapm_pga, .name = wname, \
     124        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     125        .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
    109126#define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \
    110127         wcontrols)\
    111 {       .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
    112         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
     128{       .id = snd_soc_dapm_mixer, .name = wname, \
     129        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     130        .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
    113131#define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \
    114132         wcontrols)\
    115 {       .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \
    116         .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
    117         .num_kcontrols = ARRAY_SIZE(wcontrols)}
     133{       .id = snd_soc_dapm_mixer_named_ctl, .name = wname, \
     134        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     135        .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
    118136
    119137/* path domain with event - event handler must return 0 for success */
    120138#define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \
    121139        wncontrols, wevent, wflags) \
    122 {       .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
    123         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \
     140{       .id = snd_soc_dapm_pga, .name = wname, \
     141        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     142        .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
    124143        .event = wevent, .event_flags = wflags}
    125144#define SND_SOC_DAPM_OUT_DRV_E(wname, wreg, wshift, winvert, wcontrols, \
    126145        wncontrols, wevent, wflags) \
    127 {       .id = snd_soc_dapm_out_drv, .name = wname, .reg = wreg, .shift = wshift, \
    128         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \
     146{       .id = snd_soc_dapm_out_drv, .name = wname, \
     147        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     148        .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
    129149        .event = wevent, .event_flags = wflags}
    130150#define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \
    131151        wncontrols, wevent, wflags) \
    132 {       .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
    133         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \
     152{       .id = snd_soc_dapm_mixer, .name = wname, \
     153        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     154        .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
    134155        .event = wevent, .event_flags = wflags}
    135156#define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \
    136157        wcontrols, wncontrols, wevent, wflags) \
    137 {       .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
    138         .invert = winvert, .kcontrols = wcontrols, \
     158{       .id = snd_soc_dapm_mixer, .name = wname, \
     159        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     160        .kcontrol_news = wcontrols, \
    139161        .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags}
    140 #define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \
    141 {       .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
    142         .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \
    143         .event = wevent, .event_flags = wflags}
    144162#define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \
    145163        wevent, wflags) \
    146 {       .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \
    147         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
     164{       .id = snd_soc_dapm_switch, .name = wname, \
     165        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     166        .kcontrol_news = wcontrols, .num_kcontrols = 1, \
    148167        .event = wevent, .event_flags = wflags}
    149168#define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
    150169        wevent, wflags) \
    151 {       .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
    152         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
    153         .event = wevent, .event_flags = wflags}
    154 #define SND_SOC_DAPM_VIRT_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
     170{       .id = snd_soc_dapm_mux, .name = wname, \
     171        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     172        .kcontrol_news = wcontrols, .num_kcontrols = 1, \
     173        .event = wevent, .event_flags = wflags}
     174
     175/* additional sequencing control within an event type */
     176#define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \
    155177        wevent, wflags) \
    156 {       .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \
    157         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
    158         .event = wevent, .event_flags = wflags}
     178{       .id = snd_soc_dapm_pga, .name = wname, \
     179        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     180        .event = wevent, .event_flags = wflags, \
     181        .subseq = wsubseq}
     182#define SND_SOC_DAPM_SUPPLY_S(wname, wsubseq, wreg, wshift, winvert, wevent, \
     183        wflags) \
     184{       .id = snd_soc_dapm_supply, .name = wname, \
     185        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     186        .event = wevent, .event_flags = wflags, .subseq = wsubseq}
    159187
    160188/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
    161189#define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
    162190        wevent, wflags) \
    163 {       .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
    164         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
     191{       .id = snd_soc_dapm_pga, .name = wname, \
     192        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     193        .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
    165194        .event = wevent, .event_flags = wflags}
    166195#define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
    167196        wevent, wflags) \
    168 {       .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
    169         .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
     197{       .id = snd_soc_dapm_mixer, .name = wname, \
     198        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     199        .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
    170200        .event = wevent, .event_flags = wflags}
    171201#define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \
    172202        wcontrols, wevent, wflags) \
    173 {       .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
    174         .invert = winvert, .kcontrols = wcontrols, \
    175         .num_kcontrols = ARRAY_SIZE(wcontrols), .event = wevent, .event_flags = wflags}
     203{       .id = snd_soc_dapm_mixer, .name = wname, \
     204        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     205        .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
     206        .event = wevent, .event_flags = wflags}
    176207
    177208/* events that are pre and post DAPM */
    178209#define SND_SOC_DAPM_PRE(wname, wevent) \
    179 {       .id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \
    180         .num_kcontrols = 0, .event = wevent, \
     210{       .id = snd_soc_dapm_pre, .name = wname, .kcontrol_news = NULL, \
     211        .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
    181212        .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD}
    182213#define SND_SOC_DAPM_POST(wname, wevent) \
    183 {       .id = snd_soc_dapm_post, .name = wname, .kcontrols = NULL, \
    184         .num_kcontrols = 0, .event = wevent, \
     214{       .id = snd_soc_dapm_post, .name = wname, .kcontrol_news = NULL, \
     215        .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
    185216        .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD}
    186217
    187218/* stream domain */
    188 #define SND_SOC_DAPM_AIF_IN(wname, stname, wslot, wreg, wshift, winvert) \
     219#define SND_SOC_DAPM_AIF_IN(wname, stname, wchan, wreg, wshift, winvert) \
    189220{       .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
    190         .reg = wreg, .shift = wshift, .invert = winvert }
    191 #define SND_SOC_DAPM_AIF_IN_E(wname, stname, wslot, wreg, wshift, winvert, \
     221        .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
     222#define SND_SOC_DAPM_AIF_IN_E(wname, stname, wchan, wreg, wshift, winvert, \
    192223                              wevent, wflags)                           \
    193224{       .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
    194         .reg = wreg, .shift = wshift, .invert = winvert, \
     225        .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
    195226        .event = wevent, .event_flags = wflags }
    196 #define SND_SOC_DAPM_AIF_OUT(wname, stname, wslot, wreg, wshift, winvert) \
     227#define SND_SOC_DAPM_AIF_OUT(wname, stname, wchan, wreg, wshift, winvert) \
    197228{       .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
    198         .reg = wreg, .shift = wshift, .invert = winvert }
    199 #define SND_SOC_DAPM_AIF_OUT_E(wname, stname, wslot, wreg, wshift, winvert, \
     229        .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
     230#define SND_SOC_DAPM_AIF_OUT_E(wname, stname, wchan, wreg, wshift, winvert, \
    200231                             wevent, wflags)                            \
    201232{       .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
    202         .reg = wreg, .shift = wshift, .invert = winvert, \
     233        .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
    203234        .event = wevent, .event_flags = wflags }
    204235#define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \
    205 {       .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \
    206         .shift = wshift, .invert = winvert}
     236{       .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \
     237        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert) }
    207238#define SND_SOC_DAPM_DAC_E(wname, stname, wreg, wshift, winvert, \
    208239                           wevent, wflags)                              \
    209 {       .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \
    210         .shift = wshift, .invert = winvert, \
    211         .event = wevent, .event_flags = wflags}
     240{       .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \
     241        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     242        .event = wevent, .event_flags = wflags}
     243
    212244#define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \
    213 {       .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \
    214         .shift = wshift, .invert = winvert}
     245{       .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \
     246        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
    215247#define SND_SOC_DAPM_ADC_E(wname, stname, wreg, wshift, winvert, \
    216248                           wevent, wflags)                              \
    217 {       .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \
    218         .shift = wshift, .invert = winvert, \
    219         .event = wevent, .event_flags = wflags}
     249{       .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \
     250        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     251        .event = wevent, .event_flags = wflags}
     252#define SND_SOC_DAPM_CLOCK_SUPPLY(wname) \
     253{       .id = snd_soc_dapm_clock_supply, .name = wname, \
     254        .reg = SND_SOC_NOPM, .event = dapm_clock_event, \
     255        .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD }
    220256
    221257/* generic widgets */
    222258#define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \
    223 {       .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \
    224         .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \
    225         .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \
    226         .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
     259{       .id = wid, .name = wname, .kcontrol_news = NULL, .num_kcontrols = 0, \
     260        .reg = wreg, .shift = wshift, .mask = wmask, \
     261        .on_val = won_val, .off_val = woff_val, }
    227262#define SND_SOC_DAPM_SUPPLY(wname, wreg, wshift, winvert, wevent, wflags) \
    228 {       .id = snd_soc_dapm_supply, .name = wname, .reg = wreg,  \
    229         .shift = wshift, .invert = winvert, .event = wevent, \
    230         .event_flags = wflags}
     263{       .id = snd_soc_dapm_supply, .name = wname, \
     264        SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
     265        .event = wevent, .event_flags = wflags}
     266#define SND_SOC_DAPM_REGULATOR_SUPPLY(wname, wdelay, wflags)        \
     267{       .id = snd_soc_dapm_regulator_supply, .name = wname, \
     268        .reg = SND_SOC_NOPM, .shift = wdelay, .event = dapm_regulator_event, \
     269        .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
     270        .on_val = wflags}
     271#define SND_SOC_DAPM_PINCTRL(wname, active, sleep) \
     272{       .id = snd_soc_dapm_pinctrl, .name = wname, \
     273        .priv = (&(struct snd_soc_dapm_pinctrl_priv) \
     274                { .active_state = active, .sleep_state = sleep,}), \
     275        .reg = SND_SOC_NOPM, .event = dapm_pinctrl_event, \
     276        .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD }
     277
     278
    231279
    232280/* dapm kcontrol types */
     281#define SOC_DAPM_DOUBLE(xname, reg, lshift, rshift, max, invert) \
     282{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     283        .info = snd_soc_info_volsw, \
     284        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
     285        .private_value = SOC_DOUBLE_VALUE(reg, lshift, rshift, max, invert, 0) }
     286#define SOC_DAPM_DOUBLE_R(xname, lreg, rreg, shift, max, invert) \
     287{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     288        .info = snd_soc_info_volsw, \
     289        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
     290        .private_value = SOC_DOUBLE_R_VALUE(lreg, rreg, shift, max, invert) }
    233291#define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \
    234292{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
    235293        .info = snd_soc_info_volsw, \
    236294        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
    237         .private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
     295        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
     296#define SOC_DAPM_SINGLE_AUTODISABLE(xname, reg, shift, max, invert) \
     297{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     298        .info = snd_soc_info_volsw, \
     299        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
     300        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
     301#define SOC_DAPM_SINGLE_VIRT(xname, max) \
     302        SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0)
    238303#define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
    239304{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     
    242307        .tlv.p = (tlv_array), \
    243308        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
    244         .private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
     309        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
     310#define SOC_DAPM_SINGLE_TLV_AUTODISABLE(xname, reg, shift, max, invert, tlv_array) \
     311{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     312        .info = snd_soc_info_volsw, \
     313        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
     314        .tlv.p = (tlv_array), \
     315        .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
     316        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
     317#define SOC_DAPM_SINGLE_TLV_VIRT(xname, max, tlv_array) \
     318        SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array)
    245319#define SOC_DAPM_ENUM(xname, xenum) \
    246320{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     
    249323        .put = snd_soc_dapm_put_enum_double, \
    250324        .private_value = (unsigned long)&xenum }
    251 #define SOC_DAPM_ENUM_VIRT(xname, xenum)                    \
     325#define SOC_DAPM_ENUM_EXT(xname, xenum, xget, xput) \
    252326{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
    253327        .info = snd_soc_info_enum_double, \
    254         .get = snd_soc_dapm_get_enum_virt, \
    255         .put = snd_soc_dapm_put_enum_virt, \
    256         .private_value = (unsigned long)&xenum }
    257 #define SOC_DAPM_VALUE_ENUM(xname, xenum) \
    258 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
    259         .info = snd_soc_info_enum_double, \
    260         .get = snd_soc_dapm_get_value_enum_double, \
    261         .put = snd_soc_dapm_put_value_enum_double, \
     328        .get = xget, \
     329        .put = xput, \
    262330        .private_value = (unsigned long)&xenum }
    263331#define SOC_DAPM_PIN_SWITCH(xname) \
     
    284352#define SND_SOC_DAPM_PRE_REG    0x10    /* before audio path setup */
    285353#define SND_SOC_DAPM_POST_REG   0x20    /* after audio path setup */
     354#define SND_SOC_DAPM_WILL_PMU   0x40    /* called at start of sequence */
     355#define SND_SOC_DAPM_WILL_PMD   0x80    /* called at start of sequence */
    286356#define SND_SOC_DAPM_PRE_POST_PMD \
    287357                                (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)
     358#define SND_SOC_DAPM_PRE_POST_PMU \
     359                                (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)
    288360
    289361/* convenience event type detection */
     
    292364#define SND_SOC_DAPM_EVENT_OFF(e)       \
    293365        (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD))
     366
     367/* regulator widget flags */
     368#define SND_SOC_DAPM_REGULATOR_BYPASS     0x1     /* bypass when disabled */
    294369
    295370struct snd_soc_dapm_widget;
     
    299374struct snd_soc_dapm_route;
    300375struct snd_soc_dapm_context;
    301 
    302 int dapm_reg_event(struct snd_soc_dapm_widget *w,
    303                    struct snd_kcontrol *kcontrol, int event);
     376struct regulator;
     377struct snd_soc_dapm_widget_list;
     378struct snd_soc_dapm_update;
     379enum snd_soc_dapm_direction;
     380
     381/*
     382 * Bias levels
     383 *
     384 * @ON:      Bias is fully on for audio playback and capture operations.
     385 * @PREPARE: Prepare for audio operations. Called before DAPM switching for
     386 *           stream start and stop operations.
     387 * @STANDBY: Low power standby state when no playback/capture operations are
     388 *           in progress. NOTE: The transition time between STANDBY and ON
     389 *           should be as fast as possible and no longer than 10ms.
     390 * @OFF:     Power Off. No restrictions on transition times.
     391 */
     392enum snd_soc_bias_level {
     393        SND_SOC_BIAS_OFF = 0,
     394        SND_SOC_BIAS_STANDBY = 1,
     395        SND_SOC_BIAS_PREPARE = 2,
     396        SND_SOC_BIAS_ON = 3,
     397};
     398
     399int dapm_regulator_event(struct snd_soc_dapm_widget *w,
     400                         struct snd_kcontrol *kcontrol, int event);
     401int dapm_clock_event(struct snd_soc_dapm_widget *w,
     402                         struct snd_kcontrol *kcontrol, int event);
     403int dapm_pinctrl_event(struct snd_soc_dapm_widget *w,
     404                         struct snd_kcontrol *kcontrol, int event);
    304405
    305406/* dapm controls */
     
    312413int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
    313414        struct snd_ctl_elem_value *ucontrol);
    314 int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
    315         struct snd_ctl_elem_value *ucontrol);
    316 int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
    317         struct snd_ctl_elem_value *ucontrol);
    318 int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
    319         struct snd_ctl_elem_value *ucontrol);
    320 int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
    321         struct snd_ctl_elem_value *ucontrol);
    322415int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
    323416        struct snd_ctl_elem_info *uinfo);
     
    326419int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
    327420        struct snd_ctl_elem_value *uncontrol);
    328 int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
    329         const struct snd_soc_dapm_widget *widget);
    330421int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
    331422        const struct snd_soc_dapm_widget *widget,
    332423        int num);
     424struct snd_soc_dapm_widget *snd_soc_dapm_new_control(
     425                struct snd_soc_dapm_context *dapm,
     426                const struct snd_soc_dapm_widget *widget);
     427struct snd_soc_dapm_widget *snd_soc_dapm_new_control_unlocked(
     428                struct snd_soc_dapm_context *dapm,
     429                const struct snd_soc_dapm_widget *widget);
     430int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
     431                                 struct snd_soc_dai *dai);
     432int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
     433void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
     434
     435int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
     436                            struct snd_pcm_hw_params *params,
     437                            struct snd_soc_dai *dai);
    333438
    334439/* dapm path setup */
    335 int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm);
     440int snd_soc_dapm_new_widgets(struct snd_soc_card *card);
    336441void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm);
     442void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm,
     443                       struct snd_soc_card *card,
     444                       struct snd_soc_component *component);
    337445int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
    338446                            const struct snd_soc_dapm_route *route, int num);
     447int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm,
     448                            const struct snd_soc_dapm_route *route, int num);
     449int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
     450                             const struct snd_soc_dapm_route *route, int num);
     451void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w);
     452void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm);
    339453
    340454/* dapm events */
    341 int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
    342         const char *stream, int event);
     455void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
     456        int event);
     457void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream);
    343458void snd_soc_dapm_shutdown(struct snd_soc_card *card);
    344459
     460/* external DAPM widget events */
     461int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
     462                struct snd_kcontrol *kcontrol, int connect,
     463                struct snd_soc_dapm_update *update);
     464int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
     465                struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e,
     466                struct snd_soc_dapm_update *update);
     467
    345468/* dapm sys fs - used by the core */
    346 int snd_soc_dapm_sys_add(struct device *dev);
    347 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm);
     469extern struct attribute *soc_dapm_dev_attrs[];
     470void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
     471                                struct dentry *parent);
    348472
    349473/* dapm audio pin control and status */
    350474int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm,
    351475                            const char *pin);
     476int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
     477                                     const char *pin);
    352478int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
    353479                             const char *pin);
     480int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
     481                                      const char *pin);
    354482int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin);
     483int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
     484                                 const char *pin);
    355485int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
    356486                                const char *pin);
    357487int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
     488int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm);
    358489int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
    359490                                  const char *pin);
     491int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
     492                                           const char *pin);
    360493int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
    361494                                const char *pin);
     495unsigned int dapm_kcontrol_get_value(const struct snd_kcontrol *kcontrol);
     496
     497/* Mostly internal - should not normally be used */
     498void dapm_mark_endpoints_dirty(struct snd_soc_card *card);
     499
     500/* dapm path query */
     501int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,
     502        struct snd_soc_dapm_widget_list **list,
     503        bool (*custom_stop_condition)(struct snd_soc_dapm_widget *,
     504                                      enum snd_soc_dapm_direction));
     505void snd_soc_dapm_dai_free_widgets(struct snd_soc_dapm_widget_list **list);
     506
     507struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm(
     508        struct snd_kcontrol *kcontrol);
     509
     510struct snd_soc_dapm_widget *snd_soc_dapm_kcontrol_widget(
     511                struct snd_kcontrol *kcontrol);
     512
     513int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm,
     514        enum snd_soc_bias_level level);
    362515
    363516/* dapm widget types */
     
    366519        snd_soc_dapm_output,            /* output pin */
    367520        snd_soc_dapm_mux,                       /* selects 1 analog signal from many inputs */
    368         snd_soc_dapm_virt_mux,                  /* virtual version of snd_soc_dapm_mux */
    369         snd_soc_dapm_value_mux,                 /* selects 1 analog signal from many inputs */
     521        snd_soc_dapm_demux,                     /* connects the input to one of multiple outputs */
    370522        snd_soc_dapm_mixer,                     /* mixes several analog signals together */
    371523        snd_soc_dapm_mixer_named_ctl,           /* mixer with named controls */
     
    374526        snd_soc_dapm_adc,                       /* analog to digital converter */
    375527        snd_soc_dapm_dac,                       /* digital to analog converter */
    376         snd_soc_dapm_micbias,           /* microphone bias (power) */
     528        snd_soc_dapm_micbias,           /* microphone bias (power) - DEPRECATED: use snd_soc_dapm_supply */
    377529        snd_soc_dapm_mic,                       /* microphone */
    378530        snd_soc_dapm_hp,                        /* headphones */
     
    384536        snd_soc_dapm_post,                      /* machine specific post widget - exec last */
    385537        snd_soc_dapm_supply,            /* power/clock supply */
     538        snd_soc_dapm_pinctrl,           /* pinctrl */
     539        snd_soc_dapm_regulator_supply,  /* external regulator */
     540        snd_soc_dapm_clock_supply,      /* external clock */
    386541        snd_soc_dapm_aif_in,            /* audio interface input */
    387542        snd_soc_dapm_aif_out,           /* audio interface output */
     543        snd_soc_dapm_siggen,            /* signal generator */
     544        snd_soc_dapm_sink,
     545        snd_soc_dapm_dai_in,            /* link to DAI structure */
     546        snd_soc_dapm_dai_out,
     547        snd_soc_dapm_dai_link,          /* link between two DAI structures */
     548        snd_soc_dapm_kcontrol,          /* Auto-disabled kcontrol */
     549        snd_soc_dapm_buffer,            /* DSP/CODEC internal buffer */
     550        snd_soc_dapm_scheduler,         /* DSP/CODEC internal scheduler */
     551        snd_soc_dapm_effect,            /* DSP/CODEC effect component */
     552        snd_soc_dapm_src,               /* DSP/CODEC SRC component */
     553        snd_soc_dapm_asrc,              /* DSP/CODEC ASRC component */
     554        snd_soc_dapm_encoder,           /* FW/SW audio encoder component */
     555        snd_soc_dapm_decoder,           /* FW/SW audio decoder component */
     556
     557        /* Don't edit below this line */
     558        SND_SOC_DAPM_TYPE_COUNT
     559};
     560
     561enum snd_soc_dapm_subclass {
     562        SND_SOC_DAPM_CLASS_INIT         = 0,
     563        SND_SOC_DAPM_CLASS_RUNTIME      = 1,
    388564};
    389565
     
    402578        int (*connected)(struct snd_soc_dapm_widget *source,
    403579                         struct snd_soc_dapm_widget *sink);
     580
     581        struct snd_soc_dobj dobj;
    404582};
    405583
    406584/* dapm audio path between two widgets */
    407585struct snd_soc_dapm_path {
    408         char *name;
    409         char *long_name;
    410 
    411         /* source (input) and sink (output) widgets */
    412         struct snd_soc_dapm_widget *source;
    413         struct snd_soc_dapm_widget *sink;
    414         struct snd_kcontrol *kcontrol;
     586        const char *name;
     587
     588        /*
     589         * source (input) and sink (output) widgets
     590         * The union is for convience, since it is a lot nicer to type
     591         * p->source, rather than p->node[SND_SOC_DAPM_DIR_IN]
     592         */
     593        union {
     594                struct {
     595                        struct snd_soc_dapm_widget *source;
     596                        struct snd_soc_dapm_widget *sink;
     597                };
     598                struct snd_soc_dapm_widget *node[2];
     599        };
    415600
    416601        /* status */
    417602        u32 connect:1;  /* source and sink widgets are connected */
    418         u32 walked:1;   /* path has been walked */
     603        u32 walking:1;  /* path is in the process of being walked */
     604        u32 weak:1;     /* path ignored for power management */
     605        u32 is_supply:1;        /* At least one of the connected widgets is a supply */
    419606
    420607        int (*connected)(struct snd_soc_dapm_widget *source,
    421608                         struct snd_soc_dapm_widget *sink);
    422609
    423         struct list_head list_source;
    424         struct list_head list_sink;
     610        struct list_head list_node[2];
     611        struct list_head list_kcontrol;
    425612        struct list_head list;
    426613};
     
    429616struct snd_soc_dapm_widget {
    430617        enum snd_soc_dapm_type id;
    431         char *name;             /* widget name */
    432         char *sname;    /* stream name */
    433         struct snd_soc_codec *codec;
     618        const char *name;               /* widget name */
     619        const char *sname;      /* stream name */
    434620        struct list_head list;
    435621        struct snd_soc_dapm_context *dapm;
    436622
     623        void *priv;                             /* widget specific data */
     624        struct regulator *regulator;            /* attached regulator */
     625        struct pinctrl *pinctrl;                /* attached pinctrl */
     626
    437627        /* dapm control */
    438         short reg;                                              /* negative reg = no direct dapm */
     628        int reg;                                /* negative reg = no direct dapm */
    439629        unsigned char shift;                    /* bits to shift */
    440         unsigned int saved_value;               /* widget saved value */
    441         unsigned int value;                             /* widget current value */
    442630        unsigned int mask;                      /* non-shifted mask */
    443631        unsigned int on_val;                    /* on state value */
    444632        unsigned int off_val;                   /* off state value */
    445633        unsigned char power:1;                  /* block power status */
    446         unsigned char invert:1;                 /* invert the power bit */
    447634        unsigned char active:1;                 /* active stream on DAC, ADC's */
    448635        unsigned char connected:1;              /* connected codec pin */
    449636        unsigned char new:1;                    /* cnew complete */
    450         unsigned char ext:1;                    /* has external widgets */
    451637        unsigned char force:1;                  /* force state */
    452638        unsigned char ignore_suspend:1;         /* kept enabled over suspend */
     639        unsigned char new_power:1;              /* power from this run */
     640        unsigned char power_checked:1;          /* power checked this run */
     641        unsigned char is_supply:1;              /* Widget is a supply type widget */
     642        unsigned char is_ep:2;                  /* Widget is a endpoint type widget */
     643        int subseq;                             /* sort within widget type */
    453644
    454645        int (*power_check)(struct snd_soc_dapm_widget *w);
     
    460651        /* kcontrols that relate to this widget */
    461652        int num_kcontrols;
    462         const struct snd_kcontrol_new *kcontrols;
    463 
    464         /* widget input and outputs */
    465         struct list_head sources;
    466         struct list_head sinks;
     653        const struct snd_kcontrol_new *kcontrol_news;
     654        struct snd_kcontrol **kcontrols;
     655        struct snd_soc_dobj dobj;
     656
     657        /* widget input and output edges */
     658        struct list_head edges[2];
    467659
    468660        /* used during DAPM updates */
     661        struct list_head work_list;
    469662        struct list_head power_list;
     663        struct list_head dirty;
     664        int endpoints[2];
     665
     666        struct clk *clk;
     667
     668        int channel;
    470669};
    471670
    472671struct snd_soc_dapm_update {
    473         struct snd_soc_dapm_widget *widget;
    474672        struct snd_kcontrol *kcontrol;
    475673        int reg;
    476674        int mask;
    477675        int val;
     676        int reg2;
     677        int mask2;
     678        int val2;
     679        bool has_second_set;
     680};
     681
     682struct snd_soc_dapm_wcache {
     683        struct snd_soc_dapm_widget *widget;
    478684};
    479685
    480686/* DAPM context */
    481687struct snd_soc_dapm_context {
    482         int n_widgets; /* number of widgets in this context */
    483688        enum snd_soc_bias_level bias_level;
    484         enum snd_soc_bias_level suspend_bias_level;
    485         struct delayed_work delayed_work;
    486689        unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
    487 
    488         struct snd_soc_dapm_update *update;
     690        /* Go to BIAS_OFF in suspend if the DAPM context is idle */
     691        unsigned int suspend_bias_off:1;
    489692
    490693        struct device *dev; /* from parent - for debug */
    491         struct snd_soc_codec *codec; /* parent codec */
     694        struct snd_soc_component *component; /* parent component */
    492695        struct snd_soc_card *card; /* parent card */
    493696
    494697        /* used during DAPM updates */
    495         int dev_power;
     698        enum snd_soc_bias_level target_bias_level;
    496699        struct list_head list;
     700
     701        struct snd_soc_dapm_wcache path_sink_cache;
     702        struct snd_soc_dapm_wcache path_source_cache;
    497703
    498704#ifdef CONFIG_DEBUG_FS
     
    501707};
    502708
     709/* A list of widgets associated with an object, typically a snd_kcontrol */
     710struct snd_soc_dapm_widget_list {
     711        int num_widgets;
     712        struct snd_soc_dapm_widget *widgets[];
     713};
     714
     715#define for_each_dapm_widgets(list, i, widget)                          \
     716        for ((i) = 0;                                                   \
     717             (i) < list->num_widgets && (widget = list->widgets[i]);    \
     718             (i)++)
     719
     720struct snd_soc_dapm_stats {
     721        int power_checks;
     722        int path_checks;
     723        int neighbour_checks;
     724};
     725
     726struct snd_soc_dapm_pinctrl_priv {
     727        const char *active_state;
     728        const char *sleep_state;
     729};
     730
     731/**
     732 * snd_soc_dapm_init_bias_level() - Initialize DAPM bias level
     733 * @dapm: The DAPM context to initialize
     734 * @level: The DAPM level to initialize to
     735 *
     736 * This function only sets the driver internal state of the DAPM level and will
     737 * not modify the state of the device. Hence it should not be used during normal
     738 * operation, but only to synchronize the internal state to the device state.
     739 * E.g. during driver probe to set the DAPM level to the one corresponding with
     740 * the power-on reset state of the device.
     741 *
     742 * To change the DAPM state of the device use snd_soc_dapm_set_bias_level().
     743 */
     744static inline void snd_soc_dapm_init_bias_level(
     745        struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
     746{
     747        dapm->bias_level = level;
     748}
     749
     750/**
     751 * snd_soc_dapm_get_bias_level() - Get current DAPM bias level
     752 * @dapm: The context for which to get the bias level
     753 *
     754 * Returns: The current bias level of the passed DAPM context.
     755 */
     756static inline enum snd_soc_bias_level snd_soc_dapm_get_bias_level(
     757        struct snd_soc_dapm_context *dapm)
     758{
     759        return dapm->bias_level;
     760}
     761
     762enum snd_soc_dapm_direction {
     763        SND_SOC_DAPM_DIR_IN,
     764        SND_SOC_DAPM_DIR_OUT
     765};
     766
     767#define SND_SOC_DAPM_DIR_TO_EP(x) BIT(x)
     768
     769#define SND_SOC_DAPM_EP_SOURCE SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_IN)
     770#define SND_SOC_DAPM_EP_SINK SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_OUT)
     771
     772/**
     773 * snd_soc_dapm_widget_for_each_sink_path - Iterates over all paths in the
     774 *   specified direction of a widget
     775 * @w: The widget
     776 * @dir: Whether to iterate over the paths where the specified widget is the
     777 *       incoming or outgoing widgets
     778 * @p: The path iterator variable
     779 */
     780#define snd_soc_dapm_widget_for_each_path(w, dir, p) \
     781        list_for_each_entry(p, &w->edges[dir], list_node[dir])
     782
     783/**
     784 * snd_soc_dapm_widget_for_each_sink_path_safe - Iterates over all paths in the
     785 *   specified direction of a widget
     786 * @w: The widget
     787 * @dir: Whether to iterate over the paths where the specified widget is the
     788 *       incoming or outgoing widgets
     789 * @p: The path iterator variable
     790 * @next_p: Temporary storage for the next path
     791 *
     792 *  This function works like snd_soc_dapm_widget_for_each_sink_path, expect that
     793 *  it is safe to remove the current path from the list while iterating
     794 */
     795#define snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) \
     796        list_for_each_entry_safe(p, next_p, &w->edges[dir], list_node[dir])
     797
     798/**
     799 * snd_soc_dapm_widget_for_each_sink_path - Iterates over all paths leaving a
     800 *  widget
     801 * @w: The widget
     802 * @p: The path iterator variable
     803 */
     804#define snd_soc_dapm_widget_for_each_sink_path(w, p) \
     805        snd_soc_dapm_widget_for_each_path(w, SND_SOC_DAPM_DIR_IN, p)
     806
     807/**
     808 * snd_soc_dapm_widget_for_each_source_path - Iterates over all paths leading to
     809 *  a widget
     810 * @w: The widget
     811 * @p: The path iterator variable
     812 */
     813#define snd_soc_dapm_widget_for_each_source_path(w, p) \
     814        snd_soc_dapm_widget_for_each_path(w, SND_SOC_DAPM_DIR_OUT, p)
     815
    503816#endif
  • GPL/trunk/alsa-kernel/include/sound/soc.h

    r598 r679  
    1 /*
     1/* SPDX-License-Identifier: GPL-2.0
     2 *
    23 * linux/sound/soc.h -- ALSA SoC Layer
    34 *
    4  * Author:              Liam Girdwood
    5  * Created:             Aug 11th 2005
     5 * Author:      Liam Girdwood
     6 * Created:     Aug 11th 2005
    67 * Copyright:   Wolfson Microelectronics. PLC.
    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 version 2 as
    10  * published by the Free Software Foundation.
    118 */
    129
     
    1411#define __LINUX_SND_SOC_H
    1512
     13#include <linux/of.h>
    1614#include <linux/platform_device.h>
    1715#include <linux/types.h>
     
    2018#include <linux/interrupt.h>
    2119#include <linux/kernel.h>
     20#include <linux/regmap.h>
     21#include <linux/log2.h>
    2222#include <sound/core.h>
    2323#include <sound/pcm.h>
     24#include <sound/compress_driver.h>
    2425#include <sound/control.h>
    2526#include <sound/ac97_codec.h>
     
    2829 * Convenience kcontrol builders
    2930 */
    30 #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
     31#define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
    3132        ((unsigned long)&(struct soc_mixer_control) \
    32         {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
    33         .platform_max = xmax, .invert = xinvert})
     33        {.reg = xreg, .rreg = xreg, .shift = shift_left, \
     34        .rshift = shift_right, .max = xmax, .platform_max = xmax, \
     35        .invert = xinvert, .autodisable = xautodisable})
     36#define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
     37        ((unsigned long)&(struct soc_mixer_control) \
     38        {.reg = xreg, .rreg = xreg, .shift = shift_left, \
     39        .rshift = shift_right, .min = xmin, .max = xmax, .platform_max = xmax, \
     40        .sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
     41#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
     42        SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
    3443#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
    3544        ((unsigned long)&(struct soc_mixer_control) \
    3645        {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
     46#define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
     47        ((unsigned long)&(struct soc_mixer_control) \
     48        {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
     49        .max = xmax, .platform_max = xmax, .invert = xinvert})
     50#define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
     51        ((unsigned long)&(struct soc_mixer_control) \
     52        {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
     53        .max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
     54        .invert = xinvert})
     55#define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
     56        ((unsigned long)&(struct soc_mixer_control) \
     57        {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
     58        .min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert})
    3759#define SOC_SINGLE(xname, reg, shift, max, invert) \
    3860{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
    3961        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
    4062        .put = snd_soc_put_volsw, \
    41         .private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
     63        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
     64#define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
     65{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     66        .info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
     67        .put = snd_soc_put_volsw_range, \
     68        .private_value = (unsigned long)&(struct soc_mixer_control) \
     69                {.reg = xreg, .rreg = xreg, .shift = xshift, \
     70                 .rshift = xshift,  .min = xmin, .max = xmax, \
     71                 .platform_max = xmax, .invert = xinvert} }
    4272#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
    4373{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     
    4777        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
    4878        .put = snd_soc_put_volsw, \
    49         .private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
    50 #define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \
     79        .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
     80#define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
     81{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     82        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
     83        SNDRV_CTL_ELEM_ACCESS_READWRITE, \
     84        .tlv.p  = (tlv_array),\
     85        .info = snd_soc_info_volsw_sx, \
     86        .get = snd_soc_get_volsw_sx,\
     87        .put = snd_soc_put_volsw_sx, \
     88        .private_value = (unsigned long)&(struct soc_mixer_control) \
     89                {.reg = xreg, .rreg = xreg, \
     90                .shift = xshift, .rshift = xshift, \
     91                .max = xmax, .min = xmin} }
     92#define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
     93{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     94        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
     95                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
     96        .tlv.p = (tlv_array), \
     97        .info = snd_soc_info_volsw_range, \
     98        .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
     99        .private_value = (unsigned long)&(struct soc_mixer_control) \
     100                {.reg = xreg, .rreg = xreg, .shift = xshift, \
     101                 .rshift = xshift, .min = xmin, .max = xmax, \
     102                 .platform_max = xmax, .invert = xinvert} }
     103#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
    51104{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
    52105        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
    53106        .put = snd_soc_put_volsw, \
    54         .private_value = (unsigned long)&(struct soc_mixer_control) \
    55                 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
    56                  .max = xmax, .platform_max = xmax, .invert = xinvert} }
     107        .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
     108                                          max, invert, 0) }
     109#define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
     110{                                                                       \
     111        .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),           \
     112        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,           \
     113        .access = SNDRV_CTL_ELEM_ACCESS_READ |                          \
     114                SNDRV_CTL_ELEM_ACCESS_VOLATILE,                         \
     115        .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
     116                                          max, invert, 0) }
    57117#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
    58118{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
    59         .info = snd_soc_info_volsw_2r, \
    60         .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
    61         .private_value = (unsigned long)&(struct soc_mixer_control) \
    62                 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
    63                 .max = xmax, .platform_max = xmax, .invert = xinvert} }
    64 #define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \
     119        .info = snd_soc_info_volsw, \
     120        .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
     121        .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
     122                                            xmax, xinvert) }
     123#define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
     124                           xmax, xinvert)               \
     125{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     126        .info = snd_soc_info_volsw_range, \
     127        .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
     128        .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
     129                                            xshift, xmin, xmax, xinvert) }
     130#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
    65131{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
    66132        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
     
    69135        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
    70136        .put = snd_soc_put_volsw, \
    71         .private_value = (unsigned long)&(struct soc_mixer_control) \
    72                 {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
    73                  .max = xmax, .platform_max = xmax, .invert = xinvert} }
     137        .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
     138                                          max, invert, 0) }
    74139#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
    75140{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     
    77142                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
    78143        .tlv.p = (tlv_array), \
    79         .info = snd_soc_info_volsw_2r, \
    80         .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
     144        .info = snd_soc_info_volsw, \
     145        .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
     146        .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
     147                                            xmax, xinvert) }
     148#define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
     149                               xmax, xinvert, tlv_array)                \
     150{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     151        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
     152                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
     153        .tlv.p = (tlv_array), \
     154        .info = snd_soc_info_volsw_range, \
     155        .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
     156        .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
     157                                            xshift, xmin, xmax, xinvert) }
     158#define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
     159{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     160        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
     161        SNDRV_CTL_ELEM_ACCESS_READWRITE, \
     162        .tlv.p  = (tlv_array), \
     163        .info = snd_soc_info_volsw_sx, \
     164        .get = snd_soc_get_volsw_sx, \
     165        .put = snd_soc_put_volsw_sx, \
    81166        .private_value = (unsigned long)&(struct soc_mixer_control) \
    82                 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
    83                 .max = xmax, .platform_max = xmax, .invert = xinvert} }
     167                {.reg = xreg, .rreg = xrreg, \
     168                .shift = xshift, .rshift = xshift, \
     169                .max = xmax, .min = xmin} }
     170#define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
     171{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     172        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
     173                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
     174        .tlv.p = (tlv_array), \
     175        .info = snd_soc_info_volsw, \
     176        .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
     177        .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
     178                                            xmin, xmax, xsign_bit, xinvert) }
     179#define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
     180{       .iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     181        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
     182                  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
     183        .tlv.p  = (tlv_array), \
     184        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
     185        .put = snd_soc_put_volsw, \
     186        .private_value = (unsigned long)&(struct soc_mixer_control) \
     187        {.reg = xreg, .rreg = xreg,  \
     188         .min = xmin, .max = xmax, .platform_max = xmax, \
     189        .sign_bit = 7,} }
    84190#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
    85191{       .iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     
    87193                  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
    88194        .tlv.p  = (tlv_array), \
    89         .info   = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
    90         .put    = snd_soc_put_volsw_s8, \
    91         .private_value = (unsigned long)&(struct soc_mixer_control) \
    92                 {.reg = xreg, .min = xmin, .max = xmax, \
    93                  .platform_max = xmax} }
    94 #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \
     195        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
     196        .put = snd_soc_put_volsw, \
     197        .private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
     198#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
    95199{       .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
    96         .max = xmax, .texts = xtexts }
    97 #define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \
    98         SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts)
    99 #define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \
    100 {       .max = xmax, .texts = xtexts }
    101 #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \
     200        .items = xitems, .texts = xtexts, \
     201        .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
     202#define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
     203        SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
     204#define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
     205{       .items = xitems, .texts = xtexts }
     206#define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
    102207{       .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
    103         .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues}
    104 #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \
    105         SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues)
     208        .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
     209#define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
     210        SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
     211#define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
     212{       .reg = xreg, .shift_l = xshift, .shift_r = xshift, \
     213        .mask = xmask, .items = xitems, .texts = xtexts, \
     214        .values = xvalues, .autodisable = 1}
     215#define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
     216        SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
    106217#define SOC_ENUM(xname, xenum) \
    107218{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
    108219        .info = snd_soc_info_enum_double, \
    109220        .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
    110         .private_value = (unsigned long)&xenum }
    111 #define SOC_VALUE_ENUM(xname, xenum) \
    112 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
    113         .info = snd_soc_info_enum_double, \
    114         .get = snd_soc_get_value_enum_double, \
    115         .put = snd_soc_put_value_enum_double, \
    116221        .private_value = (unsigned long)&xenum }
    117222#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
     
    120225        .info = snd_soc_info_volsw, \
    121226        .get = xhandler_get, .put = xhandler_put, \
    122         .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
    123 #define SOC_DOUBLE_EXT(xname, xreg, shift_left, shift_right, xmax, xinvert,\
     227        .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
     228#define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
    124229         xhandler_get, xhandler_put) \
    125230{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
    126231        .info = snd_soc_info_volsw, \
    127232        .get = xhandler_get, .put = xhandler_put, \
    128         .private_value = (unsigned long)&(struct soc_mixer_control) \
    129                 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
    130                  .max = xmax, .platform_max = xmax, .invert = xinvert} }
     233        .private_value = \
     234                SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
     235#define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
     236         xhandler_get, xhandler_put) \
     237{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     238        .info = snd_soc_info_volsw, \
     239        .get = xhandler_get, .put = xhandler_put, \
     240        .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
     241                                            xmax, xinvert) }
    131242#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
    132243         xhandler_get, xhandler_put, tlv_array) \
     
    137248        .info = snd_soc_info_volsw, \
    138249        .get = xhandler_get, .put = xhandler_put, \
    139         .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
     250        .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
     251#define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
     252                                 xhandler_get, xhandler_put, tlv_array) \
     253{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     254        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
     255                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
     256        .tlv.p = (tlv_array), \
     257        .info = snd_soc_info_volsw_range, \
     258        .get = xhandler_get, .put = xhandler_put, \
     259        .private_value = (unsigned long)&(struct soc_mixer_control) \
     260                {.reg = xreg, .rreg = xreg, .shift = xshift, \
     261                 .rshift = xshift, .min = xmin, .max = xmax, \
     262                 .platform_max = xmax, .invert = xinvert} }
    140263#define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
    141264         xhandler_get, xhandler_put, tlv_array) \
     
    146269        .info = snd_soc_info_volsw, \
    147270        .get = xhandler_get, .put = xhandler_put, \
    148         .private_value = (unsigned long)&(struct soc_mixer_control) \
    149                 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
    150                 .max = xmax, .platform_max = xmax, .invert = xinvert} }
     271        .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
     272                                          xmax, xinvert, 0) }
    151273#define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
    152274         xhandler_get, xhandler_put, tlv_array) \
     
    155277                 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
    156278        .tlv.p = (tlv_array), \
    157         .info = snd_soc_info_volsw_2r, \
     279        .info = snd_soc_info_volsw, \
    158280        .get = xhandler_get, .put = xhandler_put, \
    159         .private_value = (unsigned long)&(struct soc_mixer_control) \
    160                 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
    161                 .max = xmax, .platform_max = xmax, .invert = xinvert} }
     281        .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
     282                                            xmax, xinvert) }
    162283#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
    163284{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     
    167288#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
    168289{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
    169         .info = snd_soc_info_enum_ext, \
     290        .info = snd_soc_info_enum_double, \
    170291        .get = xhandler_get, .put = xhandler_put, \
    171292        .private_value = (unsigned long)&xenum }
    172 
    173 #define SOC_DOUBLE_R_SX_TLV(xname, xreg_left, xreg_right, xshift,\
    174                 xmin, xmax, tlv_array) \
     293#define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
     294        SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
     295
     296#define SND_SOC_BYTES(xname, xbase, xregs)                    \
     297{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
     298        .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
     299        .put = snd_soc_bytes_put, .private_value =            \
     300                ((unsigned long)&(struct soc_bytes)           \
     301                {.base = xbase, .num_regs = xregs }) }
     302#define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
     303{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     304        .info = snd_soc_bytes_info, .get = xhandler_get, \
     305        .put = xhandler_put, .private_value = \
     306                ((unsigned long)&(struct soc_bytes) \
     307                {.base = xbase, .num_regs = xregs }) }
     308
     309#define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask)        \
     310{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
     311        .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
     312        .put = snd_soc_bytes_put, .private_value =            \
     313                ((unsigned long)&(struct soc_bytes)           \
     314                {.base = xbase, .num_regs = xregs,            \
     315                 .mask = xmask }) }
     316
     317/*
     318 * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
     319 */
     320#define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
     321{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     322        .info = snd_soc_bytes_info_ext, \
     323        .get = xhandler_get, .put = xhandler_put, \
     324        .private_value = (unsigned long)&(struct soc_bytes_ext) \
     325                {.max = xcount} }
     326#define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
     327{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     328        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
     329                  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
     330        .tlv.c = (snd_soc_bytes_tlv_callback), \
     331        .info = snd_soc_bytes_info_ext, \
     332        .private_value = (unsigned long)&(struct soc_bytes_ext) \
     333                {.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
     334#define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
     335                xmin, xmax, xinvert) \
    175336{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
    176         .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
    177                   SNDRV_CTL_ELEM_ACCESS_READWRITE, \
    178         .tlv.p = (tlv_array), \
    179         .info = snd_soc_info_volsw_2r_sx, \
    180         .get = snd_soc_get_volsw_2r_sx, \
    181         .put = snd_soc_put_volsw_2r_sx, \
    182         .private_value = (unsigned long)&(struct soc_mixer_control) \
    183                 {.reg = xreg_left, \
    184                  .rreg = xreg_right, .shift = xshift, \
    185                  .min = xmin, .max = xmax} }
    186 
     337        .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
     338        .put = snd_soc_put_xr_sx, \
     339        .private_value = (unsigned long)&(struct soc_mreg_control) \
     340                {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
     341                .invert = xinvert, .min = xmin, .max = xmax} }
     342
     343#define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
     344        SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
     345                snd_soc_get_strobe, snd_soc_put_strobe)
    187346
    188347/*
     
    191350 */
    192351#define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
    193         struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
     352        const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
    194353                                                ARRAY_SIZE(xtexts), xtexts)
    195354#define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
    196355        SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
    197356#define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
    198         struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
     357        const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
    199358#define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
    200         struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
     359        const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
    201360                                                        ARRAY_SIZE(xtexts), xtexts, xvalues)
    202361#define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
    203362        SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
    204363
    205 /*
    206  * Bias levels
    207  *
    208  * @ON:      Bias is fully on for audio playback and capture operations.
    209  * @PREPARE: Prepare for audio operations. Called before DAPM switching for
    210  *           stream start and stop operations.
    211  * @STANDBY: Low power standby state when no playback/capture operations are
    212  *           in progress. NOTE: The transition time between STANDBY and ON
    213  *           should be as fast as possible and no longer than 10ms.
    214  * @OFF:     Power Off. No restrictions on transition times.
    215  */
    216 enum snd_soc_bias_level {
    217         SND_SOC_BIAS_OFF,
    218         SND_SOC_BIAS_STANDBY,
    219         SND_SOC_BIAS_PREPARE,
    220         SND_SOC_BIAS_ON,
    221 };
    222 
     364#define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
     365        const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
     366                xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
     367
     368#define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
     369        const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
     370
     371struct device_node;
    223372struct snd_jack;
    224373struct snd_soc_card;
     
    228377struct snd_soc_dai;
    229378struct snd_soc_dai_driver;
    230 struct snd_soc_platform;
    231379struct snd_soc_dai_link;
    232 struct snd_soc_platform_driver;
    233 struct snd_soc_codec;
    234 struct snd_soc_codec_driver;
     380struct snd_soc_component;
     381struct snd_soc_component_driver;
    235382struct soc_enum;
    236383struct snd_soc_jack;
     384struct snd_soc_jack_zone;
    237385struct snd_soc_jack_pin;
    238 struct snd_soc_cache_ops;
    239386#include <sound/soc-dapm.h>
    240 
    241 #ifdef CONFIG_GPIOLIB
     387#include <sound/soc-dpcm.h>
     388#include <sound/soc-topology.h>
     389
    242390struct snd_soc_jack_gpio;
    243 #endif
    244391
    245392typedef int (*hw_write_t)(void *,const char* ,int);
    246393
    247 extern struct snd_ac97_bus_ops soc_ac97_ops;
    248 
    249 enum snd_soc_control_type {
    250         SND_SOC_CUSTOM,
    251         SND_SOC_I2C,
    252         SND_SOC_SPI,
    253 };
    254 
    255 enum snd_soc_compress_type {
    256         SND_SOC_FLAT_COMPRESSION = 1,
    257         SND_SOC_LZO_COMPRESSION,
    258         SND_SOC_RBTREE_COMPRESSION
     394enum snd_soc_pcm_subclass {
     395        SND_SOC_PCM_CLASS_PCM   = 0,
     396        SND_SOC_PCM_CLASS_BE    = 1,
    259397};
    260398
    261399int snd_soc_register_card(struct snd_soc_card *card);
    262400int snd_soc_unregister_card(struct snd_soc_card *card);
    263 int snd_soc_register_platform(struct device *dev,
    264                 struct snd_soc_platform_driver *platform_drv);
    265 void snd_soc_unregister_platform(struct device *dev);
    266 int snd_soc_register_codec(struct device *dev,
    267                 const struct snd_soc_codec_driver *codec_drv,
    268                 struct snd_soc_dai_driver *dai_drv, int num_dai);
    269 void snd_soc_unregister_codec(struct device *dev);
    270 int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg);
    271 int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
    272                                int addr_bits, int data_bits,
    273                                enum snd_soc_control_type control);
    274 int snd_soc_cache_sync(struct snd_soc_codec *codec);
    275 int snd_soc_cache_init(struct snd_soc_codec *codec);
    276 int snd_soc_cache_exit(struct snd_soc_codec *codec);
    277 int snd_soc_cache_write(struct snd_soc_codec *codec,
    278                         unsigned int reg, unsigned int value);
    279 int snd_soc_cache_read(struct snd_soc_codec *codec,
    280                        unsigned int reg, unsigned int *value);
    281 int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
    282                                       unsigned int reg);
    283 int snd_soc_default_readable_register(struct snd_soc_codec *codec,
    284                                       unsigned int reg);
     401int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
     402#ifdef CONFIG_PM_SLEEP
     403int snd_soc_suspend(struct device *dev);
     404int snd_soc_resume(struct device *dev);
     405#else
     406static inline int snd_soc_suspend(struct device *dev)
     407{
     408        return 0;
     409}
     410
     411static inline int snd_soc_resume(struct device *dev)
     412{
     413        return 0;
     414}
     415#endif
     416int snd_soc_poweroff(struct device *dev);
     417int snd_soc_component_initialize(struct snd_soc_component *component,
     418                                 const struct snd_soc_component_driver *driver,
     419                                 struct device *dev);
     420int snd_soc_add_component(struct snd_soc_component *component,
     421                          struct snd_soc_dai_driver *dai_drv,
     422                          int num_dai);
     423int snd_soc_register_component(struct device *dev,
     424                         const struct snd_soc_component_driver *component_driver,
     425                         struct snd_soc_dai_driver *dai_drv, int num_dai);
     426int devm_snd_soc_register_component(struct device *dev,
     427                         const struct snd_soc_component_driver *component_driver,
     428                         struct snd_soc_dai_driver *dai_drv, int num_dai);
     429void snd_soc_unregister_component(struct device *dev);
     430void snd_soc_unregister_component_by_driver(struct device *dev,
     431                         const struct snd_soc_component_driver *component_driver);
     432struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
     433                                                            const char *driver_name);
     434struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
     435                                                   const char *driver_name);
     436
     437int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
     438#ifdef CONFIG_SND_SOC_COMPRESS
     439int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
     440#else
     441static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
     442{
     443        return 0;
     444}
     445#endif
     446
     447void snd_soc_disconnect_sync(struct device *dev);
     448
     449struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
     450                                struct snd_soc_dai_link *dai_link);
     451
     452bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
     453
     454void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
     455                            int stream, int action);
     456static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
     457                                     int stream)
     458{
     459        snd_soc_runtime_action(rtd, stream, 1);
     460}
     461static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
     462                                       int stream)
     463{
     464        snd_soc_runtime_action(rtd, stream, -1);
     465}
     466
     467int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
     468                            struct snd_pcm_hardware *hw, int stream);
     469
     470int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
     471        unsigned int dai_fmt);
     472
     473#ifdef CONFIG_DMI
     474int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
     475#else
     476static inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
     477                                       const char *flavour)
     478{
     479        return 0;
     480}
     481#endif
    285482
    286483/* Utility functions to get clock rates from various things */
     
    295492
    296493/* Jack reporting */
    297 int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
    298                      struct snd_soc_jack *jack);
    299494void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
    300495int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
     
    304499void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
    305500                                      struct notifier_block *nb);
     501int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
     502                          struct snd_soc_jack_zone *zones);
     503int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
    306504#ifdef CONFIG_GPIOLIB
    307505int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
    308506                        struct snd_soc_jack_gpio *gpios);
     507int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
     508                            struct snd_soc_jack *jack,
     509                            int count, struct snd_soc_jack_gpio *gpios);
    309510void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
    310511                        struct snd_soc_jack_gpio *gpios);
     512#else
     513static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
     514                                         struct snd_soc_jack_gpio *gpios)
     515{
     516        return 0;
     517}
     518
     519static inline int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
     520                                          struct snd_soc_jack *jack,
     521                                          int count,
     522                                          struct snd_soc_jack_gpio *gpios)
     523{
     524        return 0;
     525}
     526
     527static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
     528                                           struct snd_soc_jack_gpio *gpios)
     529{
     530}
    311531#endif
    312532
    313 /* codec register bit access */
    314 int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
    315                                 unsigned int mask, unsigned int value);
    316 int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
    317                                unsigned short reg, unsigned int mask,
    318                                unsigned int value);
    319 int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
    320                                 unsigned int mask, unsigned int value);
    321 
    322 int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
    323         struct snd_ac97_bus_ops *ops, int num);
    324 void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
     533struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
     534struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
     535        unsigned int id, unsigned int id_mask);
     536void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
     537
     538#ifdef CONFIG_SND_SOC_AC97_BUS
     539int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
     540int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
     541                struct platform_device *pdev);
     542
     543extern struct snd_ac97_bus_ops *soc_ac97_ops;
     544#else
     545static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
     546        struct platform_device *pdev)
     547{
     548        return 0;
     549}
     550
     551static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
     552{
     553        return 0;
     554}
     555#endif
    325556
    326557/*
     
    328559 */
    329560struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
    330         void *data, char *long_name);
    331 int snd_soc_add_controls(struct snd_soc_codec *codec,
     561                                  void *data, const char *long_name,
     562                                  const char *prefix);
     563int snd_soc_add_component_controls(struct snd_soc_component *component,
     564        const struct snd_kcontrol_new *controls, unsigned int num_controls);
     565int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
     566        const struct snd_kcontrol_new *controls, int num_controls);
     567int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
    332568        const struct snd_kcontrol_new *controls, int num_controls);
    333569int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
    334         struct snd_ctl_elem_info *uinfo);
    335 int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
    336570        struct snd_ctl_elem_info *uinfo);
    337571int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
     
    339573int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
    340574        struct snd_ctl_elem_value *ucontrol);
    341 int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
    342         struct snd_ctl_elem_value *ucontrol);
    343 int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
    344         struct snd_ctl_elem_value *ucontrol);
    345575int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
    346576        struct snd_ctl_elem_info *uinfo);
    347 int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
    348         struct snd_ctl_elem_info *uinfo);
     577int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
     578                          struct snd_ctl_elem_info *uinfo);
    349579#define snd_soc_info_bool_ext           snd_ctl_boolean_mono_info
    350580int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
     
    352582int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
    353583        struct snd_ctl_elem_value *ucontrol);
    354 int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
     584#define snd_soc_get_volsw_2r snd_soc_get_volsw
     585#define snd_soc_put_volsw_2r snd_soc_put_volsw
     586int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
     587        struct snd_ctl_elem_value *ucontrol);
     588int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
     589        struct snd_ctl_elem_value *ucontrol);
     590int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
    355591        struct snd_ctl_elem_info *uinfo);
    356 int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
     592int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
    357593        struct snd_ctl_elem_value *ucontrol);
    358 int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
     594int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
    359595        struct snd_ctl_elem_value *ucontrol);
    360 int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
     596int snd_soc_limit_volume(struct snd_soc_card *card,
     597        const char *name, int max);
     598int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
     599                       struct snd_ctl_elem_info *uinfo);
     600int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
     601                      struct snd_ctl_elem_value *ucontrol);
     602int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
     603                      struct snd_ctl_elem_value *ucontrol);
     604int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
     605        struct snd_ctl_elem_info *ucontrol);
     606int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
     607        unsigned int size, unsigned int __user *tlv);
     608int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
    361609        struct snd_ctl_elem_info *uinfo);
    362 int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
     610int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
    363611        struct snd_ctl_elem_value *ucontrol);
    364 int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
     612int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
    365613        struct snd_ctl_elem_value *ucontrol);
    366 int snd_soc_limit_volume(struct snd_soc_codec *codec,
    367         const char *name, int max);
    368 int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol,
    369         struct snd_ctl_elem_info *uinfo);
    370 int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
     614int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
    371615        struct snd_ctl_elem_value *ucontrol);
    372 int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
     616int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
    373617        struct snd_ctl_elem_value *ucontrol);
    374 
    375 /**
    376  * struct snd_soc_reg_access - Describes whether a given register is
    377  * readable, writable or volatile.
    378  *
    379  * @reg: the register number
    380  * @read: whether this register is readable
    381  * @write: whether this register is writable
    382  * @vol: whether this register is volatile
    383  */
    384 struct snd_soc_reg_access {
    385         u16 reg;
    386         u16 read;
    387         u16 write;
    388         u16 vol;
    389 };
    390618
    391619/**
     
    395623 * @mask:   bits to check for in reported jack status
    396624 * @invert: if non-zero then pin is enabled when status is not reported
     625 * @list:   internal list entry
    397626 */
    398627struct snd_soc_jack_pin {
     
    404633
    405634/**
     635 * struct snd_soc_jack_zone - Describes voltage zones of jack detection
     636 *
     637 * @min_mv: start voltage in mv
     638 * @max_mv: end voltage in mv
     639 * @jack_type: type of jack that is expected for this voltage
     640 * @debounce_time: debounce_time for jack, codec driver should wait for this
     641 *              duration before reading the adc for voltages
     642 * @list:   internal list entry
     643 */
     644struct snd_soc_jack_zone {
     645        unsigned int min_mv;
     646        unsigned int max_mv;
     647        unsigned int jack_type;
     648        unsigned int debounce_time;
     649        struct list_head list;
     650};
     651
     652/**
    406653 * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
    407654 *
    408  * @gpio:         gpio number
    409  * @name:         gpio name
     655 * @gpio:         legacy gpio number
     656 * @idx:          gpio descriptor index within the function of the GPIO
     657 *                consumer device
     658 * @gpiod_dev:    GPIO consumer device
     659 * @name:         gpio name. Also as connection ID for the GPIO consumer
     660 *                device function name lookup
    410661 * @report:       value to report when jack detected
    411662 * @invert:       report presence in low state
    412  * @debouce_time: debouce time in ms
     663 * @debounce_time: debounce time in ms
     664 * @wake:         enable as wake source
     665 * @jack_status_check: callback function which overrides the detection
     666 *                     to provide more complex checks (eg, reading an
     667 *                     ADC).
    413668 */
    414 #ifdef CONFIG_GPIOLIB
    415669struct snd_soc_jack_gpio {
    416670        unsigned int gpio;
     671        unsigned int idx;
     672        struct device *gpiod_dev;
    417673        const char *name;
    418674        int report;
    419675        int invert;
    420676        int debounce_time;
     677        bool wake;
     678
     679        /* private: */
    421680        struct snd_soc_jack *jack;
    422681        struct delayed_work work;
    423 
    424         int (*jack_status_check)(void);
    425 };
    426 #endif
     682        struct notifier_block pm_notifier;
     683        struct gpio_desc *desc;
     684
     685        void *data;
     686        /* public: */
     687        int (*jack_status_check)(void *data);
     688};
    427689
    428690struct snd_soc_jack {
     691        struct mutex mutex;
    429692        struct snd_jack *jack;
    430         struct snd_soc_codec *codec;
     693        struct snd_soc_card *card;
    431694        struct list_head pins;
    432695        int status;
    433696        struct blocking_notifier_head notifier;
     697        struct list_head jack_zones;
    434698};
    435699
     
    443707        unsigned int channels_min;      /* min channels */
    444708        unsigned int channels_max;      /* max channels */
     709        unsigned int sig_bits;          /* number of bits of content */
    445710};
    446711
     
    455720};
    456721
    457 /* SoC cache ops */
    458 struct snd_soc_cache_ops {
     722struct snd_soc_compr_ops {
     723        int (*startup)(struct snd_compr_stream *);
     724        void (*shutdown)(struct snd_compr_stream *);
     725        int (*set_params)(struct snd_compr_stream *);
     726        int (*trigger)(struct snd_compr_stream *);
     727};
     728
     729struct snd_soc_component*
     730snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
     731                       const char *driver_name);
     732
     733struct snd_soc_dai_link_component {
    459734        const char *name;
    460         enum snd_soc_compress_type id;
    461         int (*init)(struct snd_soc_codec *codec);
    462         int (*exit)(struct snd_soc_codec *codec);
    463         int (*read)(struct snd_soc_codec *codec, unsigned int reg,
    464                 unsigned int *value);
    465         int (*write)(struct snd_soc_codec *codec, unsigned int reg,
    466                 unsigned int value);
    467         int (*sync)(struct snd_soc_codec *codec);
    468 };
    469 
    470 /* SoC Audio Codec device */
    471 struct snd_soc_codec {
    472         const char *name;
    473         const char *name_prefix;
    474         int id;
    475         struct device *dev;
    476         const struct snd_soc_codec_driver *driver;
    477 
    478         struct mutex mutex;
    479         struct snd_soc_card *card;
    480         struct list_head list;
    481         struct list_head card_list;
    482         int num_dai;
    483         enum snd_soc_compress_type compress_type;
    484         size_t reg_size;        /* reg_cache_size * reg_word_size */
    485         int (*volatile_register)(struct snd_soc_codec *, unsigned int);
    486         int (*readable_register)(struct snd_soc_codec *, unsigned int);
    487 
    488         /* runtime */
    489         struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */
    490         unsigned int active;
    491         unsigned int cache_only:1;  /* Suppress writes to hardware */
    492         unsigned int cache_sync:1; /* Cache needs to be synced to hardware */
    493         unsigned int suspended:1; /* Codec is in suspend PM state */
    494         unsigned int probed:1; /* Codec has been probed */
    495         unsigned int ac97_registered:1; /* Codec has been AC97 registered */
    496         unsigned int ac97_created:1; /* Codec has been created by SoC */
    497         unsigned int sysfs_registered:1; /* codec has been sysfs registered */
    498         unsigned int cache_init:1; /* codec cache has been initialized */
    499 
    500         /* codec IO */
    501         void *control_data; /* codec control (i2c/3wire) data */
    502         hw_write_t hw_write;
    503         unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
    504         unsigned int (*read)(struct snd_soc_codec *, unsigned int);
    505         int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
    506         void *reg_cache;
    507         const void *reg_def_copy;
    508         const struct snd_soc_cache_ops *cache_ops;
    509         struct mutex cache_rw_mutex;
    510 
    511         /* dapm */
    512         struct snd_soc_dapm_context dapm;
    513 
    514 #ifdef CONFIG_DEBUG_FS
    515         struct dentry *debugfs_codec_root;
    516         struct dentry *debugfs_reg;
    517         struct dentry *debugfs_dapm;
    518 #endif
    519 };
    520 
    521 /* codec driver */
    522 struct snd_soc_codec_driver {
    523 
    524         /* driver ops */
    525         int (*probe)(struct snd_soc_codec *);
    526         int (*remove)(struct snd_soc_codec *);
    527         int (*suspend)(struct snd_soc_codec *,
    528                         pm_message_t state);
    529         int (*resume)(struct snd_soc_codec *);
    530 
    531         /* codec IO */
    532         unsigned int (*read)(struct snd_soc_codec *, unsigned int);
    533         int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
    534         int (*display_register)(struct snd_soc_codec *, char *,
    535                                 size_t, unsigned int);
    536         int (*volatile_register)(struct snd_soc_codec *, unsigned int);
    537         int (*readable_register)(struct snd_soc_codec *, unsigned int);
    538         short reg_cache_size;
    539         short reg_cache_step;
    540         short reg_word_size;
    541         const void *reg_cache_default;
    542         short reg_access_size;
    543         const struct snd_soc_reg_access *reg_access_default;
    544         enum snd_soc_compress_type compress_type;
    545 
    546         /* codec bias level */
    547         int (*set_bias_level)(struct snd_soc_codec *,
    548                               enum snd_soc_bias_level level);
    549 };
    550 
    551 /* SoC platform interface */
    552 struct snd_soc_platform_driver {
    553 
    554         int (*probe)(struct snd_soc_platform *);
    555         int (*remove)(struct snd_soc_platform *);
    556         int (*suspend)(struct snd_soc_dai *dai);
    557         int (*resume)(struct snd_soc_dai *dai);
    558 
    559         /* pcm creation and destruction */
    560         int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
    561                 struct snd_pcm *);
    562         void (*pcm_free)(struct snd_pcm *);
    563 
    564         /*
    565          * For platform caused delay reporting.
    566          * Optional.
    567          */
    568         snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
    569                 struct snd_soc_dai *);
    570 
    571         /* platform stream ops */
    572         struct snd_pcm_ops *ops;
    573 };
    574 
    575 struct snd_soc_platform {
    576         const char *name;
    577         int id;
    578         struct device *dev;
    579         struct snd_soc_platform_driver *driver;
    580 
    581         unsigned int suspended:1; /* platform is suspended */
    582         unsigned int probed:1;
    583 
    584         struct snd_soc_card *card;
    585         struct list_head list;
    586         struct list_head card_list;
     735        struct device_node *of_node;
     736        const char *dai_name;
    587737};
    588738
     
    591741        const char *name;                       /* Codec name */
    592742        const char *stream_name;                /* Stream name */
    593         const char *codec_name;         /* for multi-codec */
    594         const char *platform_name;      /* for multi-platform */
    595         const char *cpu_dai_name;
    596         const char *codec_dai_name;
     743
     744        /*
     745         * You MAY specify the link's CPU-side device, either by device name,
     746         * or by DT/OF node, but not both. If this information is omitted,
     747         * the CPU-side DAI is matched using .cpu_dai_name only, which hence
     748         * must be globally unique. These fields are currently typically used
     749         * only for codec to codec links, or systems using device tree.
     750         */
     751        /*
     752         * You MAY specify the DAI name of the CPU DAI. If this information is
     753         * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
     754         * only, which only works well when that device exposes a single DAI.
     755         */
     756        struct snd_soc_dai_link_component *cpus;
     757        unsigned int num_cpus;
     758
     759        /*
     760         * You MUST specify the link's codec, either by device name, or by
     761         * DT/OF node, but not both.
     762         */
     763        /* You MUST specify the DAI name within the codec */
     764        struct snd_soc_dai_link_component *codecs;
     765        unsigned int num_codecs;
     766
     767        /*
     768         * You MAY specify the link's platform/PCM/DMA driver, either by
     769         * device name, or by DT/OF node, but not both. Some forms of link
     770         * do not need a platform. In such case, platforms are not mandatory.
     771         */
     772        struct snd_soc_dai_link_component *platforms;
     773        unsigned int num_platforms;
     774
     775        int id; /* optional ID for machine driver link identification */
     776
     777        const struct snd_soc_pcm_stream *params;
     778        unsigned int num_params;
     779
     780        unsigned int dai_fmt;           /* format to set on init */
     781
     782        enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
     783
     784        /* codec/machine specific init - e.g. add machine controls */
     785        int (*init)(struct snd_soc_pcm_runtime *rtd);
     786
     787        /* codec/machine specific exit - dual of init() */
     788        void (*exit)(struct snd_soc_pcm_runtime *rtd);
     789
     790        /* optional hw_params re-writing for BE and FE sync */
     791        int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
     792                        struct snd_pcm_hw_params *params);
     793
     794        /* machine stream operations */
     795        const struct snd_soc_ops *ops;
     796        const struct snd_soc_compr_ops *compr_ops;
     797
     798        /* Mark this pcm with non atomic ops */
     799        unsigned int nonatomic:1;
     800
     801        /* For unidirectional dai links */
     802        unsigned int playback_only:1;
     803        unsigned int capture_only:1;
    597804
    598805        /* Keep DAI active over suspend */
     
    601808        /* Symmetry requirements */
    602809        unsigned int symmetric_rates:1;
    603 
    604         /* codec/machine specific init - e.g. add machine controls */
    605         int (*init)(struct snd_soc_pcm_runtime *rtd);
    606 
    607         /* machine stream operations */
    608         struct snd_soc_ops *ops;
    609 };
     810        unsigned int symmetric_channels:1;
     811        unsigned int symmetric_samplebits:1;
     812
     813        /* Do not create a PCM for this DAI link (Backend link) */
     814        unsigned int no_pcm:1;
     815
     816        /* This DAI link can route to other DAI links at runtime (Frontend)*/
     817        unsigned int dynamic:1;
     818
     819        /* DPCM capture and Playback support */
     820        unsigned int dpcm_capture:1;
     821        unsigned int dpcm_playback:1;
     822
     823        /* DPCM used FE & BE merged format */
     824        unsigned int dpcm_merged_format:1;
     825        /* DPCM used FE & BE merged channel */
     826        unsigned int dpcm_merged_chan:1;
     827        /* DPCM used FE & BE merged rate */
     828        unsigned int dpcm_merged_rate:1;
     829
     830        /* pmdown_time is ignored at stop */
     831        unsigned int ignore_pmdown_time:1;
     832
     833        /* Do not create a PCM for this DAI link (Backend link) */
     834        unsigned int ignore:1;
     835
     836#ifdef CONFIG_SND_SOC_TOPOLOGY
     837        struct snd_soc_dobj dobj; /* For topology */
     838#endif
     839};
     840#define for_each_link_codecs(link, i, codec)                            \
     841        for ((i) = 0;                                                   \
     842             ((i) < link->num_codecs) && ((codec) = &link->codecs[i]);  \
     843             (i)++)
     844
     845#define for_each_link_platforms(link, i, platform)                      \
     846        for ((i) = 0;                                                   \
     847             ((i) < link->num_platforms) &&                             \
     848             ((platform) = &link->platforms[i]);                        \
     849             (i)++)
     850
     851#define for_each_link_cpus(link, i, cpu)                                \
     852        for ((i) = 0;                                                   \
     853             ((i) < link->num_cpus) && ((cpu) = &link->cpus[i]);        \
     854             (i)++)
     855
     856/*
     857 * Sample 1 : Single CPU/Codec/Platform
     858 *
     859 * SND_SOC_DAILINK_DEFS(test,
     860 *      DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
     861 *      DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
     862 *      DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
     863 *
     864 * struct snd_soc_dai_link link = {
     865 *      ...
     866 *      SND_SOC_DAILINK_REG(test),
     867 * };
     868 *
     869 * Sample 2 : Multi CPU/Codec, no Platform
     870 *
     871 * SND_SOC_DAILINK_DEFS(test,
     872 *      DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
     873 *                         COMP_CPU("cpu_dai2")),
     874 *      DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
     875 *                         COMP_CODEC("codec2", "codec_dai2")));
     876 *
     877 * struct snd_soc_dai_link link = {
     878 *      ...
     879 *      SND_SOC_DAILINK_REG(test),
     880 * };
     881 *
     882 * Sample 3 : Define each CPU/Codec/Platform manually
     883 *
     884 * SND_SOC_DAILINK_DEF(test_cpu,
     885 *              DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
     886 *                                 COMP_CPU("cpu_dai2")));
     887 * SND_SOC_DAILINK_DEF(test_codec,
     888 *              DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
     889 *                                 COMP_CODEC("codec2", "codec_dai2")));
     890 * SND_SOC_DAILINK_DEF(test_platform,
     891 *              DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
     892 *
     893 * struct snd_soc_dai_link link = {
     894 *      ...
     895 *      SND_SOC_DAILINK_REG(test_cpu,
     896 *                          test_codec,
     897 *                          test_platform),
     898 * };
     899 *
     900 * Sample 4 : Sample3 without platform
     901 *
     902 * struct snd_soc_dai_link link = {
     903 *      ...
     904 *      SND_SOC_DAILINK_REG(test_cpu,
     905 *                          test_codec);
     906 * };
     907 */
     908
     909#define SND_SOC_DAILINK_REG1(name)       SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
     910#define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
     911#define SND_SOC_DAILINK_REG3(cpu, codec, platform)      \
     912        .cpus           = cpu,                          \
     913        .num_cpus       = ARRAY_SIZE(cpu),              \
     914        .codecs         = codec,                        \
     915        .num_codecs     = ARRAY_SIZE(codec),            \
     916        .platforms      = platform,                     \
     917        .num_platforms  = ARRAY_SIZE(platform)
     918
     919#define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
     920#define SND_SOC_DAILINK_REG(...) \
     921        SND_SOC_DAILINK_REGx(__VA_ARGS__,               \
     922                        SND_SOC_DAILINK_REG3,   \
     923                        SND_SOC_DAILINK_REG2,   \
     924                        SND_SOC_DAILINK_REG1)(__VA_ARGS__)
     925
     926#define SND_SOC_DAILINK_DEF(name, def...)               \
     927        static struct snd_soc_dai_link_component name[] = { def }
     928
     929#define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...)     \
     930        SND_SOC_DAILINK_DEF(name##_cpus, cpu);                  \
     931        SND_SOC_DAILINK_DEF(name##_codecs, codec);              \
     932        SND_SOC_DAILINK_DEF(name##_platforms, platform)
     933
     934#define DAILINK_COMP_ARRAY(param...)    param
     935#define COMP_EMPTY()                    { }
     936#define COMP_CPU(_dai)                  { .dai_name = _dai, }
     937#define COMP_CODEC(_name, _dai)         { .name = _name, .dai_name = _dai, }
     938#define COMP_PLATFORM(_name)            { .name = _name }
     939#define COMP_AUX(_name)                 { .name = _name }
     940#define COMP_CODEC_CONF(_name)          { .name = _name }
     941#define COMP_DUMMY()                    { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
     942
     943extern struct snd_soc_dai_link_component null_dailink_component[0];
     944
    610945
    611946struct snd_soc_codec_conf {
    612         const char *dev_name;
     947        /*
     948         * specify device either by device name, or by
     949         * DT/OF node, but not both.
     950         */
     951        struct snd_soc_dai_link_component dlc;
    613952
    614953        /*
     
    617956         */
    618957        const char *name_prefix;
    619 
     958};
     959
     960struct snd_soc_aux_dev {
    620961        /*
    621          * set this to the desired compression type if you want to
    622          * override the one supplied in codec->driver->compress_type
     962         * specify multi-codec either by device name, or by
     963         * DT/OF node, but not both.
    623964         */
    624         enum snd_soc_compress_type compress_type;
    625 };
    626 
    627 struct snd_soc_aux_dev {
    628         const char *name;               /* Codec name */
    629         const char *codec_name;         /* for multi-codec */
     965        struct snd_soc_dai_link_component dlc;
    630966
    631967        /* codec/machine specific init - e.g. add machine controls */
    632         int (*init)(struct snd_soc_dapm_context *dapm);
     968        int (*init)(struct snd_soc_component *component);
    633969};
    634970
     
    636972struct snd_soc_card {
    637973        const char *name;
     974        const char *long_name;
     975        const char *driver_name;
     976        const char *components;
     977#ifdef CONFIG_DMI
     978        char dmi_longname[80];
     979#endif /* CONFIG_DMI */
     980        char topology_shortname[32];
     981
    638982        struct device *dev;
    639983        struct snd_card *snd_card;
    640984        struct module *owner;
    641985
    642         struct list_head list;
    643986        struct mutex mutex;
    644 
    645         bool instantiated;
    646 
    647         int (*probe)(struct platform_device *pdev);
    648         int (*remove)(struct platform_device *pdev);
     987        struct mutex dapm_mutex;
     988
     989        /* Mutex for PCM operations */
     990        struct mutex pcm_mutex;
     991        enum snd_soc_pcm_subclass pcm_subclass;
     992
     993        spinlock_t dpcm_lock;
     994
     995        int (*probe)(struct snd_soc_card *card);
     996        int (*late_probe)(struct snd_soc_card *card);
     997        int (*remove)(struct snd_soc_card *card);
    649998
    650999        /* the pre and post PM functions are used to do any PM work before and
    6511000         * after the codec and DAI's do any PM work. */
    652         int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
    653         int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
    654         int (*resume_pre)(struct platform_device *pdev);
    655         int (*resume_post)(struct platform_device *pdev);
     1001        int (*suspend_pre)(struct snd_soc_card *card);
     1002        int (*suspend_post)(struct snd_soc_card *card);
     1003        int (*resume_pre)(struct snd_soc_card *card);
     1004        int (*resume_post)(struct snd_soc_card *card);
    6561005
    6571006        /* callbacks */
    6581007        int (*set_bias_level)(struct snd_soc_card *,
     1008                              struct snd_soc_dapm_context *dapm,
    6591009                              enum snd_soc_bias_level level);
    6601010        int (*set_bias_level_post)(struct snd_soc_card *,
     1011                                   struct snd_soc_dapm_context *dapm,
    6611012                                   enum snd_soc_bias_level level);
    6621013
     1014        int (*add_dai_link)(struct snd_soc_card *,
     1015                            struct snd_soc_dai_link *link);
     1016        void (*remove_dai_link)(struct snd_soc_card *,
     1017                            struct snd_soc_dai_link *link);
     1018
    6631019        long pmdown_time;
    6641020
    6651021        /* CPU <--> Codec DAI links  */
    666         struct snd_soc_dai_link *dai_link;
    667         int num_links;
    668         struct snd_soc_pcm_runtime *rtd;
     1022        struct snd_soc_dai_link *dai_link;  /* predefined links only */
     1023        int num_links;  /* predefined links only */
     1024
     1025        struct list_head rtd_list;
    6691026        int num_rtd;
    6701027
     
    6791036        struct snd_soc_aux_dev *aux_dev;
    6801037        int num_aux_devs;
    681         struct snd_soc_pcm_runtime *rtd_aux;
    682         int num_aux_rtd;
    683 
    684         struct work_struct deferred_resume_work;
     1038        struct list_head aux_comp_list;
     1039
     1040        const struct snd_kcontrol_new *controls;
     1041        int num_controls;
     1042
     1043        /*
     1044         * Card-specific routes and widgets.
     1045         * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
     1046         */
     1047        const struct snd_soc_dapm_widget *dapm_widgets;
     1048        int num_dapm_widgets;
     1049        const struct snd_soc_dapm_route *dapm_routes;
     1050        int num_dapm_routes;
     1051        const struct snd_soc_dapm_widget *of_dapm_widgets;
     1052        int num_of_dapm_widgets;
     1053        const struct snd_soc_dapm_route *of_dapm_routes;
     1054        int num_of_dapm_routes;
    6851055
    6861056        /* lists of probed devices belonging to this card */
    687         struct list_head codec_dev_list;
    688         struct list_head platform_dev_list;
    689         struct list_head dai_dev_list;
     1057        struct list_head component_dev_list;
     1058        struct list_head list;
    6901059
    6911060        struct list_head widgets;
    6921061        struct list_head paths;
    6931062        struct list_head dapm_list;
     1063        struct list_head dapm_dirty;
     1064
     1065        /* attached dynamic objects */
     1066        struct list_head dobj_list;
     1067
     1068        /* Generic DAPM context for the card */
     1069        struct snd_soc_dapm_context dapm;
     1070        struct snd_soc_dapm_stats dapm_stats;
     1071        struct snd_soc_dapm_update *update;
    6941072
    6951073#ifdef CONFIG_DEBUG_FS
    6961074        struct dentry *debugfs_card_root;
    697         struct dentry *debugfs_pop_time;
     1075#endif
     1076#ifdef CONFIG_PM_SLEEP
     1077        struct work_struct deferred_resume_work;
    6981078#endif
    6991079        u32 pop_time;
    700 };
     1080
     1081        /* bit field */
     1082        unsigned int instantiated:1;
     1083        unsigned int topology_shortname_created:1;
     1084        unsigned int fully_routed:1;
     1085        unsigned int disable_route_checks:1;
     1086        unsigned int probed:1;
     1087
     1088        void *drvdata;
     1089};
     1090#define for_each_card_prelinks(card, i, link)                           \
     1091        for ((i) = 0;                                                   \
     1092             ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
     1093             (i)++)
     1094#define for_each_card_pre_auxs(card, i, aux)                            \
     1095        for ((i) = 0;                                                   \
     1096             ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
     1097             (i)++)
     1098
     1099#define for_each_card_rtds(card, rtd)                   \
     1100        list_for_each_entry(rtd, &(card)->rtd_list, list)
     1101#define for_each_card_rtds_safe(card, rtd, _rtd)        \
     1102        list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
     1103
     1104#define for_each_card_auxs(card, component)                     \
     1105        list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
     1106#define for_each_card_auxs_safe(card, component, _comp) \
     1107        list_for_each_entry_safe(component, _comp,      \
     1108                                 &card->aux_comp_list, card_aux_list)
     1109
     1110#define for_each_card_components(card, component)                       \
     1111        list_for_each_entry(component, &(card)->component_dev_list, card_list)
     1112
     1113#define for_each_card_dapms(card, dapm)                                 \
     1114        list_for_each_entry(dapm, &card->dapm_list, list)
     1115
     1116#define for_each_card_widgets(card, w)\
     1117        list_for_each_entry(w, &card->widgets, list)
     1118#define for_each_card_widgets_safe(card, w, _w) \
     1119        list_for_each_entry_safe(w, _w, &card->widgets, list)
    7011120
    7021121/* SoC machine DAI configuration, glues a codec and cpu DAI together */
    703 struct snd_soc_pcm_runtime  {
    704         struct device dev;
     1122struct snd_soc_pcm_runtime {
     1123        struct device *dev;
    7051124        struct snd_soc_card *card;
    7061125        struct snd_soc_dai_link *dai_link;
    707 
    708         unsigned int complete:1;
    709         unsigned int dev_registered:1;
    710 
    711         /* Symmetry data - only valid if symmetry is being enforced */
    712         unsigned int rate;
     1126        struct snd_pcm_ops ops;
     1127
     1128        unsigned int params_select; /* currently selected param for dai link */
     1129
     1130        /* Dynamic PCM BE runtime data */
     1131        struct snd_soc_dpcm_runtime dpcm[2];
     1132
    7131133        long pmdown_time;
    7141134
    7151135        /* runtime devices */
    7161136        struct snd_pcm *pcm;
    717         struct snd_soc_codec *codec;
    718         struct snd_soc_platform *platform;
    719         struct snd_soc_dai *codec_dai;
    720         struct snd_soc_dai *cpu_dai;
     1137        struct snd_compr *compr;
     1138
     1139        /*
     1140         * dais = cpu_dai + codec_dai
     1141         * see
     1142         *      soc_new_pcm_runtime()
     1143         *      asoc_rtd_to_cpu()
     1144         *      asoc_rtd_to_codec()
     1145         */
     1146        struct snd_soc_dai **dais;
     1147        unsigned int num_codecs;
     1148        unsigned int num_cpus;
     1149
     1150        struct snd_soc_dapm_widget *playback_widget;
     1151        struct snd_soc_dapm_widget *capture_widget;
    7211152
    7221153        struct delayed_work delayed_work;
    723 };
     1154        void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
     1155#ifdef CONFIG_DEBUG_FS
     1156        struct dentry *debugfs_dpcm_root;
     1157#endif
     1158
     1159        unsigned int num; /* 0-based and monotonic increasing */
     1160        struct list_head list; /* rtd list of the soc card */
     1161
     1162        /* function mark */
     1163        struct snd_pcm_substream *mark_startup;
     1164
     1165        /* bit field */
     1166        unsigned int pop_wait:1;
     1167        unsigned int fe_compr:1; /* for Dynamic PCM */
     1168
     1169        int num_components;
     1170        struct snd_soc_component *components[]; /* CPU/Codec/Platform */
     1171};
     1172/* see soc_new_pcm_runtime()  */
     1173#define asoc_rtd_to_cpu(rtd, n)   (rtd)->dais[n]
     1174#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus]
     1175#define asoc_substream_to_rtd(substream) \
     1176        (struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
     1177
     1178#define for_each_rtd_components(rtd, i, component)                      \
     1179        for ((i) = 0, component = NULL;                                 \
     1180             ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
     1181             (i)++)
     1182#define for_each_rtd_cpu_dais(rtd, i, dai)                              \
     1183        for ((i) = 0;                                                   \
     1184             ((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \
     1185             (i)++)
     1186#define for_each_rtd_cpu_dais_rollback(rtd, i, dai)             \
     1187        for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_cpu(rtd, i));)
     1188#define for_each_rtd_codec_dais(rtd, i, dai)                            \
     1189        for ((i) = 0;                                                   \
     1190             ((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \
     1191             (i)++)
     1192#define for_each_rtd_codec_dais_rollback(rtd, i, dai)           \
     1193        for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_codec(rtd, i));)
     1194#define for_each_rtd_dais(rtd, i, dai)                                  \
     1195        for ((i) = 0;                                                   \
     1196             ((i) < (rtd)->num_cpus + (rtd)->num_codecs) &&             \
     1197                     ((dai) = (rtd)->dais[i]);                          \
     1198             (i)++)
     1199#define for_each_rtd_dais_rollback(rtd, i, dai)         \
     1200        for (; (--(i) >= 0) && ((dai) = (rtd)->dais[i]);)
     1201
     1202void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
    7241203
    7251204/* mixer control */
    7261205struct soc_mixer_control {
    7271206        int min, max, platform_max;
    728         unsigned int reg, rreg, shift, rshift, invert;
     1207        int reg, rreg;
     1208        unsigned int shift, rshift;
     1209        unsigned int sign_bit;
     1210        unsigned int invert:1;
     1211        unsigned int autodisable:1;
     1212#ifdef CONFIG_SND_SOC_TOPOLOGY
     1213        struct snd_soc_dobj dobj;
     1214#endif
     1215};
     1216
     1217struct soc_bytes {
     1218        int base;
     1219        int num_regs;
     1220        u32 mask;
     1221};
     1222
     1223struct soc_bytes_ext {
     1224        int max;
     1225#ifdef CONFIG_SND_SOC_TOPOLOGY
     1226        struct snd_soc_dobj dobj;
     1227#endif
     1228        /* used for TLV byte control */
     1229        int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
     1230                        unsigned int size);
     1231        int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
     1232                        unsigned int size);
     1233};
     1234
     1235/* multi register control */
     1236struct soc_mreg_control {
     1237        long min, max;
     1238        unsigned int regbase, regcount, nbits, invert;
    7291239};
    7301240
    7311241/* enumerated kcontrol */
    7321242struct soc_enum {
    733         unsigned short reg;
    734         unsigned short reg2;
     1243        int reg;
    7351244        unsigned char shift_l;
    7361245        unsigned char shift_r;
    737         unsigned int max;
     1246        unsigned int items;
    7381247        unsigned int mask;
    739         const char **texts;
     1248        const char * const *texts;
    7401249        const unsigned int *values;
    741         void *dapm;
    742 };
    743 
    744 /* codec IO */
    745 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
    746 unsigned int snd_soc_write(struct snd_soc_codec *codec,
    747                            unsigned int reg, unsigned int val);
    748 
    749 /* device driver data */
    750 
    751 static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
    752                 void *data)
    753 {
    754         dev_set_drvdata(codec->dev, data);
    755 }
    756 
    757 static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
    758 {
    759         return dev_get_drvdata(codec->dev);
    760 }
    761 
    762 static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
    763                 void *data)
    764 {
    765         dev_set_drvdata(platform->dev, data);
    766 }
    767 
    768 static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
    769 {
    770         return dev_get_drvdata(platform->dev);
    771 }
    772 
    773 static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
    774                 void *data)
    775 {
    776         dev_set_drvdata(&rtd->dev, data);
    777 }
    778 
    779 static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
    780 {
    781         return dev_get_drvdata(&rtd->dev);
    782 }
    783 
    784 static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
    785 {
    786         INIT_LIST_HEAD(&card->dai_dev_list);
    787         INIT_LIST_HEAD(&card->codec_dev_list);
    788         INIT_LIST_HEAD(&card->platform_dev_list);
    789         INIT_LIST_HEAD(&card->widgets);
    790         INIT_LIST_HEAD(&card->paths);
    791         INIT_LIST_HEAD(&card->dapm_list);
    792 }
     1250        unsigned int autodisable:1;
     1251#ifdef CONFIG_SND_SOC_TOPOLOGY
     1252        struct snd_soc_dobj dobj;
     1253#endif
     1254};
     1255
     1256static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
     1257{
     1258        if (mc->reg == mc->rreg && mc->shift == mc->rshift)
     1259                return false;
     1260        /*
     1261         * mc->reg == mc->rreg && mc->shift != mc->rshift, or
     1262         * mc->reg != mc->rreg means that the control is
     1263         * stereo (bits in one register or in two registers)
     1264         */
     1265        return true;
     1266}
     1267
     1268static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
     1269        unsigned int val)
     1270{
     1271        unsigned int i;
     1272
     1273        if (!e->values)
     1274                return val;
     1275
     1276        for (i = 0; i < e->items; i++)
     1277                if (val == e->values[i])
     1278                        return i;
     1279
     1280        return 0;
     1281}
     1282
     1283static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
     1284        unsigned int item)
     1285{
     1286        if (!e->values)
     1287                return item;
     1288
     1289        return e->values[item];
     1290}
     1291
     1292/**
     1293 * snd_soc_kcontrol_component() - Returns the component that registered the
     1294 *  control
     1295 * @kcontrol: The control for which to get the component
     1296 *
     1297 * Note: This function will work correctly if the control has been registered
     1298 * for a component. With snd_soc_add_codec_controls() or via table based
     1299 * setup for either a CODEC or component driver. Otherwise the behavior is
     1300 * undefined.
     1301 */
     1302static inline struct snd_soc_component *snd_soc_kcontrol_component(
     1303        struct snd_kcontrol *kcontrol)
     1304{
     1305        return snd_kcontrol_chip(kcontrol);
     1306}
     1307
     1308int snd_soc_util_init(void);
     1309void snd_soc_util_exit(void);
     1310
     1311int snd_soc_of_parse_card_name(struct snd_soc_card *card,
     1312                               const char *propname);
     1313int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
     1314                                          const char *propname);
     1315int snd_soc_of_get_slot_mask(struct device_node *np,
     1316                             const char *prop_name,
     1317                             unsigned int *mask);
     1318int snd_soc_of_parse_tdm_slot(struct device_node *np,
     1319                              unsigned int *tx_mask,
     1320                              unsigned int *rx_mask,
     1321                              unsigned int *slots,
     1322                              unsigned int *slot_width);
     1323void snd_soc_of_parse_node_prefix(struct device_node *np,
     1324                                   struct snd_soc_codec_conf *codec_conf,
     1325                                   struct device_node *of_node,
     1326                                   const char *propname);
     1327static inline
     1328void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
     1329                                   struct snd_soc_codec_conf *codec_conf,
     1330                                   struct device_node *of_node,
     1331                                   const char *propname)
     1332{
     1333        snd_soc_of_parse_node_prefix(card->dev->of_node,
     1334                                     codec_conf, of_node, propname);
     1335}
     1336
     1337int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
     1338                                   const char *propname);
     1339int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
     1340unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
     1341                                     const char *prefix,
     1342                                     struct device_node **bitclkmaster,
     1343                                     struct device_node **framemaster);
     1344int snd_soc_get_dai_id(struct device_node *ep);
     1345int snd_soc_get_dai_name(struct of_phandle_args *args,
     1346                         const char **dai_name);
     1347int snd_soc_of_get_dai_name(struct device_node *of_node,
     1348                            const char **dai_name);
     1349int snd_soc_of_get_dai_link_codecs(struct device *dev,
     1350                                   struct device_node *of_node,
     1351                                   struct snd_soc_dai_link *dai_link);
     1352void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
     1353
     1354int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
     1355                            struct snd_soc_dai_link *dai_link);
     1356void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
     1357                                struct snd_soc_pcm_runtime *rtd);
     1358
     1359struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
     1360                                         struct snd_soc_dai_driver *dai_drv,
     1361                                         bool legacy_dai_naming);
     1362struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
     1363                                              struct snd_soc_component *component,
     1364                                              struct snd_soc_dai_driver *dai_drv,
     1365                                              bool legacy_dai_naming);
     1366void snd_soc_unregister_dai(struct snd_soc_dai *dai);
     1367
     1368struct snd_soc_dai *snd_soc_find_dai(
     1369        const struct snd_soc_dai_link_component *dlc);
     1370struct snd_soc_dai *snd_soc_find_dai_with_mutex(
     1371        const struct snd_soc_dai_link_component *dlc);
    7931372
    7941373#include <sound/soc-dai.h>
     1374
     1375static inline
     1376int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
     1377                                          const char *platform_name)
     1378{
     1379        struct snd_soc_dai_link *dai_link;
     1380        const char *name;
     1381        int i;
     1382
     1383        if (!platform_name) /* nothing to do */
     1384                return 0;
     1385
     1386        /* set platform name for each dailink */
     1387        for_each_card_prelinks(card, i, dai_link) {
     1388                name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
     1389                if (!name)
     1390                        return -ENOMEM;
     1391
     1392                if (!dai_link->platforms)
     1393                        return -EINVAL;
     1394
     1395                /* only single platform is supported for now */
     1396                dai_link->platforms->name = name;
     1397        }
     1398
     1399        return 0;
     1400}
    7951401
    7961402#ifdef CONFIG_DEBUG_FS
     
    7981404#endif
    7991405
     1406extern const struct dev_pm_ops snd_soc_pm_ops;
     1407
     1408/* Helper functions */
     1409static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
     1410{
     1411        mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
     1412}
     1413
     1414static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
     1415{
     1416        mutex_unlock(&dapm->card->dapm_mutex);
     1417}
     1418
     1419#include <sound/soc-component.h>
     1420#include <sound/soc-card.h>
     1421
    8001422#endif
  • GPL/trunk/alsa-kernel/include/sound/soundfont.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_SOUNDFONT_H
    23#define __SOUND_SOUNDFONT_H
     
    78 *  Copyright (C) 1999 Steve Ratcliffe
    89 *  Copyright (c) 1999-2000 Takashi iwai <tiwai@suse.de>
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2310 */
    2411
    25 #include "sfnt_info.h"
    26 #include "util_mem.h"
     12#include <sound/sfnt_info.h>
     13#include <sound/util_mem.h>
    2714
    2815#define SF_MAX_INSTRUMENTS      128     /* maximum instrument number */
     
    122109int snd_sf_calc_parm_attack(int msec);
    123110int snd_sf_calc_parm_decay(int msec);
    124 #define snd_sf_calc_parm_delay(msec) (0x8000 - (msec) * 1000 / 725);
     111#define snd_sf_calc_parm_delay(msec) (0x8000 - (msec) * 1000 / 725)
    125112extern int snd_sf_vol_table[128];
    126113int snd_sf_linear_to_log(unsigned int amount, int offset, int ratio);
  • GPL/trunk/alsa-kernel/include/sound/tea575x-tuner.h

    r426 r679  
    2424
    2525#include <linux/videodev2.h>
     26#include <media/v4l2-ctrls.h>
    2627#include <media/v4l2-dev.h>
    27 #include <media/v4l2-ioctl.h>
     28#include <media/v4l2-device.h>
     29
     30#define TEA575X_FMIF    10700
     31#define TEA575X_AMIF      450
     32
     33#define TEA575X_DATA    (1 << 0)
     34#define TEA575X_CLK     (1 << 1)
     35#define TEA575X_WREN    (1 << 2)
     36#define TEA575X_MOST    (1 << 3)
    2837
    2938struct snd_tea575x;
    3039
    3140struct snd_tea575x_ops {
    32         void (*write)(struct snd_tea575x *tea, unsigned int val);
    33         unsigned int (*read)(struct snd_tea575x *tea);
    34         void (*mute)(struct snd_tea575x *tea, unsigned int mute);
     41        /* Drivers using snd_tea575x must either define read_ and write_val */
     42        void (*write_val)(struct snd_tea575x *tea, u32 val);
     43        u32 (*read_val)(struct snd_tea575x *tea);
     44        /* Or define the 3 pin functions */
     45        void (*set_pins)(struct snd_tea575x *tea, u8 pins);
     46        u8 (*get_pins)(struct snd_tea575x *tea);
     47        void (*set_direction)(struct snd_tea575x *tea, bool output);
    3548};
    3649
    3750struct snd_tea575x {
    38         struct snd_card *card;
    39         struct video_device *vd;        /* video device */
    40         int dev_nr;                     /* requested device number + 1 */
    41         int tea5759;                    /* 5759 chip is present */
    42         int mute;                       /* Device is muted? */
    43         unsigned int freq_fixup;        /* crystal onboard */
     51        struct v4l2_device *v4l2_dev;
     52        struct v4l2_file_operations fops;
     53        struct video_device vd;         /* video device */
     54        int radio_nr;                   /* radio_nr */
     55        bool tea5759;                   /* 5759 chip is present */
     56        bool has_am;                    /* Device can tune to AM freqs */
     57        bool cannot_read_data;          /* Device cannot read the data pin */
     58        bool cannot_mute;               /* Device cannot mute */
     59        bool mute;                      /* Device is muted? */
     60        bool stereo;                    /* receiving stereo */
     61        bool tuned;                     /* tuned to a station */
    4462        unsigned int val;               /* hw value */
    45         unsigned long freq;             /* frequency */
    46         unsigned long in_use;           /* set if the device is in use */
     63        u32 band;                       /* 0: FM, 1: FM-Japan, 2: AM */
     64        u32 freq;                       /* frequency */
     65        struct mutex mutex;
    4766        struct snd_tea575x_ops *ops;
    4867        void *private_data;
     68        u8 card[32];
     69        u8 bus_info[32];
     70        struct v4l2_ctrl_handler ctrl_handler;
     71        int (*ext_init)(struct snd_tea575x *tea);
    4972};
    5073
    51 void snd_tea575x_init(struct snd_tea575x *tea);
     74int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner);
    5275void snd_tea575x_exit(struct snd_tea575x *tea);
     76void snd_tea575x_set_freq(struct snd_tea575x *tea);
    5377
    5478#endif /* __SOUND_TEA575X_TUNER_H */
  • GPL/trunk/alsa-kernel/include/sound/tea6330t.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_TEA6330T_H
    23#define __SOUND_TEA6330T_H
     
    56 *  Routines for control of TEA6330T circuit.
    67 *  Sound fader control circuit for car radios.
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    22  *
    238 */
    249
    25 #include "i2c.h"                /* generic i2c support */
     10#include <sound/i2c.h>          /* generic i2c support */
    2611
    2712int snd_tea6330t_detect(struct snd_i2c_bus *bus, int equalizer);
  • GPL/trunk/alsa-kernel/include/sound/timer.h

    r399 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_TIMER_H
    23#define __SOUND_TIMER_H
     
    67 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
    78 *                   Abramo Bagnara <abramo@alsa-project.org>
    8  *
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
    249 */
    2510
     
    3722#define SNDRV_TIMER_HW_SLAVE    0x00000004      /* only slave timer (variable resolution) */
    3823#define SNDRV_TIMER_HW_FIRST    0x00000008      /* first tick can be incomplete */
    39 #define SNDRV_TIMER_HW_TASKLET  0x00000010      /* timer is called from tasklet */
     24#define SNDRV_TIMER_HW_WORK     0x00000010      /* timer is called from work */
    4025
    4126#define SNDRV_TIMER_IFLG_SLAVE    0x00000001
     
    4328#define SNDRV_TIMER_IFLG_START    0x00000004
    4429#define SNDRV_TIMER_IFLG_AUTO     0x00000008    /* auto restart */
    45 #define SNDRV_TIMER_IFLG_FAST     0x00000010    /* fast callback (do not use tasklet) */
     30#define SNDRV_TIMER_IFLG_FAST     0x00000010    /* fast callback (do not use work) */
    4631#define SNDRV_TIMER_IFLG_CALLBACK 0x00000020    /* timer callback is active */
    4732#define SNDRV_TIMER_IFLG_EXCLUSIVE 0x00000040   /* exclusive owner - no more instances */
     
    9075        struct list_head ack_list_head;
    9176        struct list_head sack_list_head; /* slow ack list head */
    92         struct tasklet_struct task_queue;
     77        struct work_struct task_work;
     78        int max_instances;      /* upper limit of timer instances */
     79        int num_instances;      /* current number of timer instances */
    9380};
    9481
     
    10390        void (*ccallback) (struct snd_timer_instance * timeri,
    10491                           int event,
    105                            struct timespec * tstamp,
     92                           struct timespec64 * tstamp,
    10693                           unsigned long resolution);
     94        void (*disconnect)(struct snd_timer_instance *timeri);
    10795        void *callback_data;
    10896        unsigned long ticks;            /* auto-load ticks when expired */
    10997        unsigned long cticks;           /* current ticks */
    11098        unsigned long pticks;           /* accumulated ticks for callback */
    111         unsigned long resolution;       /* current resolution for tasklet */
     99        unsigned long resolution;       /* current resolution for work */
    112100        unsigned long lost;             /* lost ticks */
    113101        int slave_class;
     
    126114
    127115int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, struct snd_timer **rtimer);
    128 void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp);
     116void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp);
    129117int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer);
    130118int snd_timer_global_free(struct snd_timer *timer);
    131119int snd_timer_global_register(struct snd_timer *timer);
    132120
    133 int snd_timer_open(struct snd_timer_instance **ti, char *owner, struct snd_timer_id *tid, unsigned int slave_id);
    134 int snd_timer_close(struct snd_timer_instance *timeri);
     121struct snd_timer_instance *snd_timer_instance_new(const char *owner);
     122void snd_timer_instance_free(struct snd_timer_instance *timeri);
     123int snd_timer_open(struct snd_timer_instance *timeri, struct snd_timer_id *tid, unsigned int slave_id);
     124void snd_timer_close(struct snd_timer_instance *timeri);
    135125unsigned long snd_timer_resolution(struct snd_timer_instance *timeri);
    136126int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks);
  • GPL/trunk/alsa-kernel/include/sound/tlv.h

    r598 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_TLV_H
    23#define __SOUND_TLV_H
     
    56 *  Advanced Linux Sound Architecture - ALSA - Driver
    67 *  Copyright (c) 2006 by Jaroslav Kysela <perex@perex.cz>
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    238 */
    249
     10#include <uapi/sound/tlv.h>
     11
     12/* For historical reasons, these macros are aliases to the ones in UAPI. */
     13#define TLV_ITEM                        SNDRV_CTL_TLVD_ITEM
     14#define TLV_LENGTH                      SNDRV_CTL_TLVD_LENGTH
     15
     16#define TLV_CONTAINER_ITEM              SNDRV_CTL_TLVD_CONTAINER_ITEM
     17#define DECLARE_TLV_CONTAINER           SNDRV_CTL_TLVD_DECLARE_CONTAINER
     18
     19#define TLV_DB_SCALE_MASK               SNDRV_CTL_TLVD_DB_SCALE_MASK
     20#define TLV_DB_SCALE_MUTE               SNDRV_CTL_TLVD_DB_SCALE_MUTE
     21#define TLV_DB_SCALE_ITEM               SNDRV_CTL_TLVD_DB_SCALE_ITEM
     22#define DECLARE_TLV_DB_SCALE            SNDRV_CTL_TLVD_DECLARE_DB_SCALE
     23
     24#define TLV_DB_MINMAX_ITEM              SNDRV_CTL_TLVD_DB_MINMAX_ITEM
     25#define TLV_DB_MINMAX_MUTE_ITEM         SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM
     26#define DECLARE_TLV_DB_MINMAX           SNDRV_CTL_TLVD_DECLARE_DB_MINMAX
     27#define DECLARE_TLV_DB_MINMAX_MUTE      SNDRV_CTL_TLVD_DECLARE_DB_MINMAX_MUTE
     28
     29#define TLV_DB_LINEAR_ITEM              SNDRV_CTL_TLVD_DB_LINEAR_ITEM
     30#define DECLARE_TLV_DB_LINEAR           SNDRV_CTL_TLVD_DECLARE_DB_LINEAR
     31
     32#define TLV_DB_RANGE_ITEM               SNDRV_CTL_TLVD_DB_RANGE_ITEM
     33#define DECLARE_TLV_DB_RANGE            SNDRV_CTL_TLVD_DECLARE_DB_RANGE
     34
     35#define TLV_DB_GAIN_MUTE                SNDRV_CTL_TLVD_DB_GAIN_MUTE
     36
    2537/*
    26  * TLV structure is right behind the struct snd_ctl_tlv:
    27  *   unsigned int type          - see SNDRV_CTL_TLVT_*
    28  *   unsigned int length
    29  *   .... data aligned to sizeof(unsigned int), use
    30  *        block_length = (length + (sizeof(unsigned int) - 1)) &
    31  *                       ~(sizeof(unsigned int) - 1)) ....
     38 * The below assumes that each item TLV is 4 words like DB_SCALE or LINEAR.
     39 * This is an old fasion and obsoleted by commit bf1d1c9b6179("ALSA: tlv: add
     40 * DECLARE_TLV_DB_RANGE()").
    3241 */
    33 
    34 #define SNDRV_CTL_TLVT_CONTAINER 0      /* one level down - group of TLVs */
    35 #define SNDRV_CTL_TLVT_DB_SCALE 1       /* dB scale */
    36 #define SNDRV_CTL_TLVT_DB_LINEAR 2      /* linear volume */
    37 #define SNDRV_CTL_TLVT_DB_RANGE 3       /* dB range container */
    38 #define SNDRV_CTL_TLVT_DB_MINMAX 4      /* dB scale with min/max */
    39 #define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */
    40 
    41 #define TLV_DB_SCALE_MASK       0xffff
    42 #define TLV_DB_SCALE_MUTE       0x10000
    43 #define TLV_DB_SCALE_ITEM(min, step, mute)                      \
    44         SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int),      \
    45         (min), ((step) & TLV_DB_SCALE_MASK) | ((mute) ? TLV_DB_SCALE_MUTE : 0)
    46 #define DECLARE_TLV_DB_SCALE(name, min, step, mute) \
    47         unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) }
    48 
    49 /* dB scale specified with min/max values instead of step */
    50 #define TLV_DB_MINMAX_ITEM(min_dB, max_dB)                      \
    51         SNDRV_CTL_TLVT_DB_MINMAX, 2 * sizeof(unsigned int),     \
    52         (min_dB), (max_dB)
    53 #define TLV_DB_MINMAX_MUTE_ITEM(min_dB, max_dB)                 \
    54         SNDRV_CTL_TLVT_DB_MINMAX_MUTE, 2 * sizeof(unsigned int),        \
    55         (min_dB), (max_dB)
    56 #define DECLARE_TLV_DB_MINMAX(name, min_dB, max_dB) \
    57         unsigned int name[] = { TLV_DB_MINMAX_ITEM(min_dB, max_dB) }
    58 #define DECLARE_TLV_DB_MINMAX_MUTE(name, min_dB, max_dB) \
    59         unsigned int name[] = { TLV_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) }
    60 
    61 /* linear volume between min_dB and max_dB (.01dB unit) */
    62 #define TLV_DB_LINEAR_ITEM(min_dB, max_dB)                  \
    63         SNDRV_CTL_TLVT_DB_LINEAR, 2 * sizeof(unsigned int), \
    64         (min_dB), (max_dB)
    65 #define DECLARE_TLV_DB_LINEAR(name, min_dB, max_dB)     \
    66         unsigned int name[] = { TLV_DB_LINEAR_ITEM(min_dB, max_dB) }
    67 
    68 /* dB range container */
    69 /* Each item is: <min> <max> <TLV> */
    70 /* The below assumes that each item TLV is 4 words like DB_SCALE or LINEAR */
    71 #define TLV_DB_RANGE_HEAD(num)                  \
     42#define TLV_DB_RANGE_HEAD(num) \
    7243        SNDRV_CTL_TLVT_DB_RANGE, 6 * (num) * sizeof(unsigned int)
    7344
    74 #define TLV_DB_GAIN_MUTE        -9999999
    75 
    7645#endif /* __SOUND_TLV_H */
  • GPL/trunk/alsa-kernel/include/sound/util_mem.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_UTIL_MEM_H
    23#define __SOUND_UTIL_MEM_H
     
    78 *
    89 *  Generic memory management routines for soundcard memory allocation
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2310 */
    2411
  • GPL/trunk/alsa-kernel/include/sound/version.h

    r598 r679  
    11/* include/version.h */
    2 #define CONFIG_SND_VERSION "1.0.24"
     2#define CONFIG_SND_VERSION "5.10.20"
    33#define CONFIG_SND_DATE ""
  • GPL/trunk/alsa-kernel/include/sound/vx_core.h

    r399 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 * Driver for Digigram VX soundcards
     
    56 *
    67 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
    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
     
    2714#include <sound/hwdep.h>
    2815#include <linux/interrupt.h>
    29 
    30 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
    31 #if !defined(CONFIG_USE_VXLOADER) && !defined(CONFIG_SND_VX_LIB) /* built-in kernel */
    32 #define SND_VX_FW_LOADER        /* use the standard firmware loader */
    33 #endif
    34 #endif
    3516
    3617struct firmware;
     
    8768        unsigned int references;     /* an output pipe may be used for monitoring and/or playback */
    8869        struct vx_pipe *monitoring_pipe;  /* pointer to the monitoring pipe (capture pipe only)*/
    89 
    90         struct tasklet_struct start_tq;
    9170};
    9271
     
    169148
    170149        /* low-level functions */
    171         struct snd_vx_hardware *hw;
    172         struct snd_vx_ops *ops;
    173 
    174         spinlock_t lock;
    175         spinlock_t irq_lock;
    176         struct tasklet_struct tq;
     150        const struct snd_vx_hardware *hw;
     151        const struct snd_vx_ops *ops;
     152
     153        struct mutex lock;
    177154
    178155        unsigned int chip_status;
     
    217194 * constructor
    218195 */
    219 struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw,
    220                               struct snd_vx_ops *ops, int extra_size);
     196struct vx_core *snd_vx_create(struct snd_card *card,
     197                              const struct snd_vx_hardware *hw,
     198                              const struct snd_vx_ops *ops, int extra_size);
    221199int snd_vx_setup_firmware(struct vx_core *chip);
    222200int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *dsp);
     
    230208 */
    231209irqreturn_t snd_vx_irq_handler(int irq, void *dev);
     210irqreturn_t snd_vx_threaded_irq_handler(int irq, void *dev);
    232211
    233212/*
     
    342321 * PM
    343322 */
    344 int snd_vx_suspend(struct vx_core *card, pm_message_t state);
     323int snd_vx_suspend(struct vx_core *card);
    345324int snd_vx_resume(struct vx_core *card);
    346325
  • GPL/trunk/alsa-kernel/include/sound/wavefront.h

    r398 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __SOUND_WAVEFRONT_H__
    23#define __SOUND_WAVEFRONT_H__
     
    67 *
    78 *  Copyright (c) by Paul Barton-Davis <pbd@op.net>
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    229 */
    2310
Note: See TracChangeset for help on using the changeset viewer.