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

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/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 */
Note: See TracChangeset for help on using the changeset viewer.