1193323Sed/* SPDX-License-Identifier: GPL-2.0-or-later */ 2193323Sed#ifndef __SOUND_PCM_H 3193323Sed#define __SOUND_PCM_H 4193323Sed 5193323Sed/* 6193323Sed * Digital Audio (PCM) abstract layer 7193323Sed * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 8193323Sed * Abramo Bagnara <abramo@alsa-project.org> 9193323Sed */ 10193323Sed 11193323Sed#include <sound/asound.h> 12193323Sed#include <sound/memalloc.h> 13193323Sed#include <sound/minors.h> 14193323Sed#include <linux/poll.h> 15193323Sed#include <linux/mm.h> 16193323Sed#include <linux/bitops.h> 17193323Sed#include <linux/pm_qos.h> 18193323Sed#include <linux/refcount.h> 19193323Sed#include <linux/uio.h> 20193323Sed 21193323Sed#define snd_pcm_substream_chip(substream) ((substream)->private_data) 22193323Sed#define snd_pcm_chip(pcm) ((pcm)->private_data) 23193323Sed 24193323Sed#if IS_ENABLED(CONFIG_SND_PCM_OSS) 25193323Sed#include <sound/pcm_oss.h> 26193323Sed#endif 27193323Sed 28193323Sed/* 29193323Sed * Hardware (lowlevel) section 30193323Sed */ 31193323Sed 32193323Sedstruct snd_pcm_hardware { 33193323Sed unsigned int info; /* SNDRV_PCM_INFO_* */ 34193323Sed u64 formats; /* SNDRV_PCM_FMTBIT_* */ 35193323Sed u32 subformats; /* for S32_LE, SNDRV_PCM_SUBFMTBIT_* */ 36210299Sed unsigned int rates; /* SNDRV_PCM_RATE_* */ 37193323Sed unsigned int rate_min; /* min rate */ 38198090Srdivacky unsigned int rate_max; /* max rate */ 39235633Sdim unsigned int channels_min; /* min channels */ 40193323Sed unsigned int channels_max; /* max channels */ 41193323Sed size_t buffer_bytes_max; /* max buffer size */ 42193323Sed size_t period_bytes_min; /* min period size */ 43193323Sed size_t period_bytes_max; /* max period size */ 44193323Sed unsigned int periods_min; /* min # of periods */ 45208599Srdivacky unsigned int periods_max; /* max # of periods */ 46193323Sed size_t fifo_size; /* fifo size in bytes */ 47193323Sed}; 48193323Sed 49193323Sedstruct snd_pcm_status64; 50193323Sedstruct snd_pcm_substream; 51193323Sed 52193323Sedstruct snd_pcm_audio_tstamp_config; /* definitions further down */ 53193323Sedstruct snd_pcm_audio_tstamp_report; 54193323Sed 55193323Sedstruct snd_pcm_ops { 56193323Sed int (*open)(struct snd_pcm_substream *substream); 57193323Sed int (*close)(struct snd_pcm_substream *substream); 58193323Sed int (*ioctl)(struct snd_pcm_substream * substream, 59193323Sed unsigned int cmd, void *arg); 60235633Sdim int (*hw_params)(struct snd_pcm_substream *substream, 61235633Sdim struct snd_pcm_hw_params *params); 62193323Sed int (*hw_free)(struct snd_pcm_substream *substream); 63193323Sed int (*prepare)(struct snd_pcm_substream *substream); 64198892Srdivacky int (*trigger)(struct snd_pcm_substream *substream, int cmd); 65193323Sed int (*sync_stop)(struct snd_pcm_substream *substream); 66193323Sed snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream); 67235633Sdim int (*get_time_info)(struct snd_pcm_substream *substream, 68193323Sed struct timespec64 *system_ts, struct timespec64 *audio_ts, 69193323Sed struct snd_pcm_audio_tstamp_config *audio_tstamp_config, 70198090Srdivacky struct snd_pcm_audio_tstamp_report *audio_tstamp_report); 71235633Sdim int (*fill_silence)(struct snd_pcm_substream *substream, int channel, 72193323Sed unsigned long pos, unsigned long bytes); 73193323Sed int (*copy)(struct snd_pcm_substream *substream, int channel, 74193323Sed unsigned long pos, struct iov_iter *iter, unsigned long bytes); 75193323Sed struct page *(*page)(struct snd_pcm_substream *substream, 76193323Sed unsigned long offset); 77193323Sed int (*mmap)(struct snd_pcm_substream *substream, struct vm_area_struct *vma); 78193323Sed int (*ack)(struct snd_pcm_substream *substream); 79193323Sed}; 80193323Sed 81193323Sed/* 82193323Sed * 83193323Sed */ 84193323Sed 85193323Sed#if defined(CONFIG_SND_DYNAMIC_MINORS) 86193323Sed#define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2) 87208599Srdivacky#else 88208599Srdivacky#define SNDRV_PCM_DEVICES 8 89208599Srdivacky#endif 90208599Srdivacky 91193323Sed#define SNDRV_PCM_IOCTL1_RESET 0 92193323Sed/* 1 is absent slot. */ 93193323Sed#define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2 94193323Sed/* 3 is absent slot. */ 95193323Sed#define SNDRV_PCM_IOCTL1_FIFO_SIZE 4 96193323Sed 97193323Sed#define SNDRV_PCM_TRIGGER_STOP 0 98193323Sed#define SNDRV_PCM_TRIGGER_START 1 99193323Sed#define SNDRV_PCM_TRIGGER_PAUSE_PUSH 3 100193323Sed#define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4 101193323Sed#define SNDRV_PCM_TRIGGER_SUSPEND 5 102193323Sed#define SNDRV_PCM_TRIGGER_RESUME 6 103193323Sed#define SNDRV_PCM_TRIGGER_DRAIN 7 104193323Sed 105193323Sed#define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1) 106193323Sed 107193323Sed/* If you change this don't forget to change rates[] table in pcm_native.c */ 108193323Sed#define SNDRV_PCM_RATE_5512 (1U<<0) /* 5512Hz */ 109193323Sed#define SNDRV_PCM_RATE_8000 (1U<<1) /* 8000Hz */ 110193323Sed#define SNDRV_PCM_RATE_11025 (1U<<2) /* 11025Hz */ 111193323Sed#define SNDRV_PCM_RATE_16000 (1U<<3) /* 16000Hz */ 112193323Sed#define SNDRV_PCM_RATE_22050 (1U<<4) /* 22050Hz */ 113221345Sdim#define SNDRV_PCM_RATE_32000 (1U<<5) /* 32000Hz */ 114193323Sed#define SNDRV_PCM_RATE_44100 (1U<<6) /* 44100Hz */ 115193323Sed#define SNDRV_PCM_RATE_48000 (1U<<7) /* 48000Hz */ 116193323Sed#define SNDRV_PCM_RATE_64000 (1U<<8) /* 64000Hz */ 117193323Sed#define SNDRV_PCM_RATE_88200 (1U<<9) /* 88200Hz */ 118218893Sdim#define SNDRV_PCM_RATE_96000 (1U<<10) /* 96000Hz */ 119193323Sed#define SNDRV_PCM_RATE_176400 (1U<<11) /* 176400Hz */ 120198090Srdivacky#define SNDRV_PCM_RATE_192000 (1U<<12) /* 192000Hz */ 121198090Srdivacky#define SNDRV_PCM_RATE_352800 (1U<<13) /* 352800Hz */ 122198090Srdivacky#define SNDRV_PCM_RATE_384000 (1U<<14) /* 384000Hz */ 123198090Srdivacky 124198090Srdivacky#define SNDRV_PCM_RATE_CONTINUOUS (1U<<30) /* continuous range */ 125198090Srdivacky#define SNDRV_PCM_RATE_KNOT (1U<<31) /* supports more non-continuos rates */ 126199511Srdivacky 127198090Srdivacky#define SNDRV_PCM_RATE_8000_44100 (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\ 128235633Sdim SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_22050|\ 129235633Sdim SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_44100) 130235633Sdim#define SNDRV_PCM_RATE_8000_48000 (SNDRV_PCM_RATE_8000_44100|SNDRV_PCM_RATE_48000) 131235633Sdim#define SNDRV_PCM_RATE_8000_96000 (SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_64000|\ 132235633Sdim SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000) 133235633Sdim#define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\ 134235633Sdim SNDRV_PCM_RATE_192000) 135235633Sdim#define SNDRV_PCM_RATE_8000_384000 (SNDRV_PCM_RATE_8000_192000|\ 136235633Sdim SNDRV_PCM_RATE_352800|\ 137235633Sdim SNDRV_PCM_RATE_384000) 138235633Sdim#define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt) 139235633Sdim#define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8) 140198090Srdivacky#define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8) 141198090Srdivacky#define SNDRV_PCM_FMTBIT_S16_LE _SNDRV_PCM_FMTBIT(S16_LE) 142198090Srdivacky#define SNDRV_PCM_FMTBIT_S16_BE _SNDRV_PCM_FMTBIT(S16_BE) 143198090Srdivacky#define SNDRV_PCM_FMTBIT_U16_LE _SNDRV_PCM_FMTBIT(U16_LE) 144221345Sdim#define SNDRV_PCM_FMTBIT_U16_BE _SNDRV_PCM_FMTBIT(U16_BE) 145221345Sdim#define SNDRV_PCM_FMTBIT_S24_LE _SNDRV_PCM_FMTBIT(S24_LE) 146198090Srdivacky#define SNDRV_PCM_FMTBIT_S24_BE _SNDRV_PCM_FMTBIT(S24_BE) 147221345Sdim#define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE) 148221345Sdim#define SNDRV_PCM_FMTBIT_U24_BE _SNDRV_PCM_FMTBIT(U24_BE) 149221345Sdim// For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the 150193323Sed// available bit count in most significant bit. It's for the case of so-called 'left-justified' or 151193323Sed// `right-padding` sample which has less width than 32 bit. 152198090Srdivacky#define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE) 153208599Srdivacky#define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE) 154208599Srdivacky#define SNDRV_PCM_FMTBIT_U32_LE _SNDRV_PCM_FMTBIT(U32_LE) 155208599Srdivacky#define SNDRV_PCM_FMTBIT_U32_BE _SNDRV_PCM_FMTBIT(U32_BE) 156208599Srdivacky#define SNDRV_PCM_FMTBIT_FLOAT_LE _SNDRV_PCM_FMTBIT(FLOAT_LE) 157208599Srdivacky#define SNDRV_PCM_FMTBIT_FLOAT_BE _SNDRV_PCM_FMTBIT(FLOAT_BE) 158208599Srdivacky#define SNDRV_PCM_FMTBIT_FLOAT64_LE _SNDRV_PCM_FMTBIT(FLOAT64_LE) 159208599Srdivacky#define SNDRV_PCM_FMTBIT_FLOAT64_BE _SNDRV_PCM_FMTBIT(FLOAT64_BE) 160193323Sed#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE) 161193323Sed#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE) 162218893Sdim#define SNDRV_PCM_FMTBIT_MU_LAW _SNDRV_PCM_FMTBIT(MU_LAW) 163218893Sdim#define SNDRV_PCM_FMTBIT_A_LAW _SNDRV_PCM_FMTBIT(A_LAW) 164218893Sdim#define SNDRV_PCM_FMTBIT_IMA_ADPCM _SNDRV_PCM_FMTBIT(IMA_ADPCM) 165193323Sed#define SNDRV_PCM_FMTBIT_MPEG _SNDRV_PCM_FMTBIT(MPEG) 166193323Sed#define SNDRV_PCM_FMTBIT_GSM _SNDRV_PCM_FMTBIT(GSM) 167198090Srdivacky#define SNDRV_PCM_FMTBIT_S20_LE _SNDRV_PCM_FMTBIT(S20_LE) 168198090Srdivacky#define SNDRV_PCM_FMTBIT_U20_LE _SNDRV_PCM_FMTBIT(U20_LE) 169193323Sed#define SNDRV_PCM_FMTBIT_S20_BE _SNDRV_PCM_FMTBIT(S20_BE) 170193323Sed#define SNDRV_PCM_FMTBIT_U20_BE _SNDRV_PCM_FMTBIT(U20_BE) 171193323Sed#define SNDRV_PCM_FMTBIT_SPECIAL _SNDRV_PCM_FMTBIT(SPECIAL) 172193323Sed#define SNDRV_PCM_FMTBIT_S24_3LE _SNDRV_PCM_FMTBIT(S24_3LE) 173193323Sed#define SNDRV_PCM_FMTBIT_U24_3LE _SNDRV_PCM_FMTBIT(U24_3LE) 174193323Sed#define SNDRV_PCM_FMTBIT_S24_3BE _SNDRV_PCM_FMTBIT(S24_3BE) 175193323Sed#define SNDRV_PCM_FMTBIT_U24_3BE _SNDRV_PCM_FMTBIT(U24_3BE) 176193323Sed#define SNDRV_PCM_FMTBIT_S20_3LE _SNDRV_PCM_FMTBIT(S20_3LE) 177193323Sed#define SNDRV_PCM_FMTBIT_U20_3LE _SNDRV_PCM_FMTBIT(U20_3LE) 178193323Sed#define SNDRV_PCM_FMTBIT_S20_3BE _SNDRV_PCM_FMTBIT(S20_3BE) 179193323Sed#define SNDRV_PCM_FMTBIT_U20_3BE _SNDRV_PCM_FMTBIT(U20_3BE) 180193323Sed#define SNDRV_PCM_FMTBIT_S18_3LE _SNDRV_PCM_FMTBIT(S18_3LE) 181218893Sdim#define SNDRV_PCM_FMTBIT_U18_3LE _SNDRV_PCM_FMTBIT(U18_3LE) 182218893Sdim#define SNDRV_PCM_FMTBIT_S18_3BE _SNDRV_PCM_FMTBIT(S18_3BE) 183218893Sdim#define SNDRV_PCM_FMTBIT_U18_3BE _SNDRV_PCM_FMTBIT(U18_3BE) 184218893Sdim#define SNDRV_PCM_FMTBIT_G723_24 _SNDRV_PCM_FMTBIT(G723_24) 185218893Sdim#define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B) 186193323Sed#define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40) 187212904Sdim#define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B) 188193323Sed#define SNDRV_PCM_FMTBIT_DSD_U8 _SNDRV_PCM_FMTBIT(DSD_U8) 189193323Sed#define SNDRV_PCM_FMTBIT_DSD_U16_LE _SNDRV_PCM_FMTBIT(DSD_U16_LE) 190193323Sed#define SNDRV_PCM_FMTBIT_DSD_U32_LE _SNDRV_PCM_FMTBIT(DSD_U32_LE) 191193323Sed#define SNDRV_PCM_FMTBIT_DSD_U16_BE _SNDRV_PCM_FMTBIT(DSD_U16_BE) 192193323Sed#define SNDRV_PCM_FMTBIT_DSD_U32_BE _SNDRV_PCM_FMTBIT(DSD_U32_BE) 193193323Sed 194193323Sed#ifdef SNDRV_LITTLE_ENDIAN 195193323Sed#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE 196226890Sdim#define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_LE 197226890Sdim#define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_LE 198226890Sdim#define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_LE 199226890Sdim#define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_LE 200193323Sed#define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_LE 201193323Sed#define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_LE 202204642Srdivacky#define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_LE 203193323Sed#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE 204193323Sed#define SNDRV_PCM_FMTBIT_S20 SNDRV_PCM_FMTBIT_S20_LE 205193323Sed#define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_LE 206193323Sed#endif 207193323Sed#ifdef SNDRV_BIG_ENDIAN 208193323Sed#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_BE 209193323Sed#define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_BE 210193323Sed#define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_BE 211193323Sed#define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_BE 212193323Sed#define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_BE 213193323Sed#define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_BE 214193323Sed#define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_BE 215193323Sed#define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_BE 216193323Sed#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE 217193323Sed#define SNDRV_PCM_FMTBIT_S20 SNDRV_PCM_FMTBIT_S20_BE 218193323Sed#define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_BE 219193323Sed#endif 220193323Sed 221193323Sed#define _SNDRV_PCM_SUBFMTBIT(fmt) BIT((__force int)SNDRV_PCM_SUBFORMAT_##fmt) 222193323Sed#define SNDRV_PCM_SUBFMTBIT_STD _SNDRV_PCM_SUBFMTBIT(STD) 223193323Sed#define SNDRV_PCM_SUBFMTBIT_MSBITS_MAX _SNDRV_PCM_SUBFMTBIT(MSBITS_MAX) 224193323Sed#define SNDRV_PCM_SUBFMTBIT_MSBITS_20 _SNDRV_PCM_SUBFMTBIT(MSBITS_20) 225193323Sed#define SNDRV_PCM_SUBFMTBIT_MSBITS_24 _SNDRV_PCM_SUBFMTBIT(MSBITS_24) 226193323Sed 227193323Sedstruct snd_pcm_file { 228193323Sed struct snd_pcm_substream *substream; 229193323Sed int no_compat_mmap; 230206083Srdivacky unsigned int user_pversion; /* supported protocol version */ 231206083Srdivacky}; 232206083Srdivacky 233193323Sedstruct snd_pcm_hw_rule; 234193323Sedtypedef int (*snd_pcm_hw_rule_func_t)(struct snd_pcm_hw_params *params, 235193323Sed struct snd_pcm_hw_rule *rule); 236193323Sed 237193323Sedstruct snd_pcm_hw_rule { 238193323Sed unsigned int cond; 239193323Sed int var; 240226890Sdim int deps[5]; 241226890Sdim 242226890Sdim snd_pcm_hw_rule_func_t func; 243226890Sdim void *private; 244235633Sdim}; 245193323Sed 246193323Sedstruct snd_pcm_hw_constraints { 247193323Sed struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - 248193323Sed SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; 249235633Sdim struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - 250193323Sed SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; 251193323Sed unsigned int rules_num; 252193323Sed unsigned int rules_all; 253193323Sed struct snd_pcm_hw_rule *rules; 254193323Sed}; 255193323Sed 256193323Sedstatic inline struct snd_mask *constrs_mask(struct snd_pcm_hw_constraints *constrs, 257193323Sed snd_pcm_hw_param_t var) 258200581Srdivacky{ 259193323Sed return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; 260203954Srdivacky} 261203954Srdivacky 262203954Srdivackystatic inline struct snd_interval *constrs_interval(struct snd_pcm_hw_constraints *constrs, 263193323Sed snd_pcm_hw_param_t var) 264193323Sed{ 265193323Sed return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; 266193323Sed} 267193323Sed 268193323Sedstruct snd_ratnum { 269193323Sed unsigned int num; 270193323Sed unsigned int den_min, den_max, den_step; 271193323Sed}; 272193323Sed 273193323Sedstruct snd_ratden { 274193323Sed unsigned int num_min, num_max, num_step; 275193323Sed unsigned int den; 276193323Sed}; 277193323Sed 278193323Sedstruct snd_pcm_hw_constraint_ratnums { 279193323Sed int nrats; 280193323Sed const struct snd_ratnum *rats; 281193323Sed}; 282193323Sed 283193323Sedstruct snd_pcm_hw_constraint_ratdens { 284193323Sed int nrats; 285193323Sed const struct snd_ratden *rats; 286193323Sed}; 287193323Sed 288193323Sedstruct snd_pcm_hw_constraint_list { 289193323Sed const unsigned int *list; 290193323Sed unsigned int count; 291193323Sed unsigned int mask; 292235633Sdim}; 293193323Sed 294193323Sedstruct snd_pcm_hw_constraint_ranges { 295193323Sed unsigned int count; 296193323Sed const struct snd_interval *ranges; 297193323Sed unsigned int mask; 298193323Sed}; 299193323Sed 300193323Sed/* 301193323Sed * userspace-provided audio timestamp config to kernel, 302193323Sed * structure is for internal use only and filled with dedicated unpack routine 303193323Sed */ 304193323Sedstruct snd_pcm_audio_tstamp_config { 305193323Sed /* 5 of max 16 bits used */ 306193323Sed u32 type_requested:4; 307224145Sdim u32 report_delay:1; /* add total delay to A/D or D/A */ 308224145Sdim}; 309193323Sed 310193323Sedstatic inline void snd_pcm_unpack_audio_tstamp_config(__u32 data, 311193323Sed struct snd_pcm_audio_tstamp_config *config) 312193323Sed{ 313193323Sed config->type_requested = data & 0xF; 314193323Sed config->report_delay = (data >> 4) & 1; 315193323Sed} 316193323Sed 317193323Sed/* 318193323Sed * kernel-provided audio timestamp report to user-space 319193323Sed * structure is for internal use only and read by dedicated pack routine 320193323Sed */ 321193323Sedstruct snd_pcm_audio_tstamp_report { 322193323Sed /* 6 of max 16 bits used for bit-fields */ 323193323Sed 324193323Sed /* for backwards compatibility */ 325193323Sed u32 valid:1; 326193323Sed 327206083Srdivacky /* actual type if hardware could not support requested timestamp */ 328206083Srdivacky u32 actual_type:4; 329193323Sed 330193323Sed /* accuracy represented in ns units */ 331193323Sed u32 accuracy_report:1; /* 0 if accuracy unknown, 1 if accuracy field is valid */ 332193323Sed u32 accuracy; /* up to 4.29s, will be packed in separate field */ 333193323Sed}; 334193323Sed 335193323Sedstatic inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy, 336193323Sed const struct snd_pcm_audio_tstamp_report *report) 337193323Sed{ 338235633Sdim u32 tmp; 339193323Sed 340193323Sed tmp = report->accuracy_report; 341193323Sed tmp <<= 4; 342193323Sed tmp |= report->actual_type; 343193323Sed tmp <<= 1; 344193323Sed tmp |= report->valid; 345193323Sed 346193323Sed *data &= 0xffff; /* zero-clear MSBs */ 347193323Sed *data |= (tmp << 16); 348193323Sed *accuracy = report->accuracy; 349193323Sed} 350193323Sed 351193323Sed 352193323Sedstruct snd_pcm_runtime { 353193323Sed /* -- Status -- */ 354193323Sed snd_pcm_state_t state; /* stream state */ 355193323Sed snd_pcm_state_t suspended_state; /* suspended stream state */ 356193323Sed struct snd_pcm_substream *trigger_master; 357193323Sed struct timespec64 trigger_tstamp; /* trigger timestamp */ 358193323Sed bool trigger_tstamp_latched; /* trigger timestamp latched in low-level driver/hardware */ 359193323Sed int overrange; 360193323Sed snd_pcm_uframes_t avail_max; 361193323Sed snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */ 362193323Sed snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time */ 363193323Sed unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */ 364193323Sed unsigned long hw_ptr_buffer_jiffies; /* buffer time in jiffies */ 365193323Sed snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */ 366203954Srdivacky u64 hw_ptr_wrap; /* offset for hw_ptr due to boundary wrap-around */ 367193323Sed 368193323Sed /* -- HW params -- */ 369193323Sed snd_pcm_access_t access; /* access mode */ 370193323Sed snd_pcm_format_t format; /* SNDRV_PCM_FORMAT_* */ 371193323Sed snd_pcm_subformat_t subformat; /* subformat */ 372193323Sed unsigned int rate; /* rate in Hz */ 373193323Sed unsigned int channels; /* channels */ 374193323Sed snd_pcm_uframes_t period_size; /* period size */ 375193323Sed unsigned int periods; /* periods */ 376193323Sed snd_pcm_uframes_t buffer_size; /* buffer size */ 377193323Sed snd_pcm_uframes_t min_align; /* Min alignment for the format */ 378193323Sed size_t byte_align; 379193323Sed unsigned int frame_bits; 380193323Sed unsigned int sample_bits; 381193323Sed unsigned int info; 382193323Sed unsigned int rate_num; 383193323Sed unsigned int rate_den; 384193323Sed unsigned int no_period_wakeup: 1; 385193323Sed 386193323Sed /* -- SW params; see struct snd_pcm_sw_params for comments -- */ 387193323Sed int tstamp_mode; 388193323Sed unsigned int period_step; 389203954Srdivacky snd_pcm_uframes_t start_threshold; 390193323Sed snd_pcm_uframes_t stop_threshold; 391193323Sed snd_pcm_uframes_t silence_threshold; 392193323Sed snd_pcm_uframes_t silence_size; 393193323Sed snd_pcm_uframes_t boundary; 394193323Sed 395193323Sed /* internal data of auto-silencer */ 396193323Sed snd_pcm_uframes_t silence_start; /* starting pointer to silence area */ 397193323Sed snd_pcm_uframes_t silence_filled; /* already filled part of silence area */ 398193323Sed 399193323Sed union snd_pcm_sync_id sync; /* hardware synchronization ID */ 400193323Sed 401193323Sed /* -- mmap -- */ 402193323Sed struct snd_pcm_mmap_status *status; 403193323Sed struct snd_pcm_mmap_control *control; 404193323Sed 405193323Sed /* -- locking / scheduling -- */ 406193323Sed snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */ 407193323Sed wait_queue_head_t sleep; /* poll sleep */ 408193323Sed wait_queue_head_t tsleep; /* transfer sleep */ 409193323Sed struct snd_fasync *fasync; 410193323Sed bool stop_operating; /* sync_stop will be called */ 411193323Sed struct mutex buffer_mutex; /* protect for buffer changes */ 412193323Sed atomic_t buffer_accessing; /* >0: in r/w operation, <0: blocked */ 413212904Sdim 414212904Sdim /* -- private section -- */ 415212904Sdim void *private_data; 416212904Sdim void (*private_free)(struct snd_pcm_runtime *runtime); 417212904Sdim 418212904Sdim /* -- hardware description -- */ 419212904Sdim struct snd_pcm_hardware hw; 420212904Sdim struct snd_pcm_hw_constraints hw_constraints; 421193323Sed 422212904Sdim /* -- timer -- */ 423212904Sdim unsigned int timer_resolution; /* timer resolution */ 424212904Sdim int tstamp_type; /* timestamp type */ 425193323Sed 426193323Sed /* -- DMA -- */ 427193323Sed unsigned char *dma_area; /* DMA area */ 428193323Sed dma_addr_t dma_addr; /* physical bus address (not accessible from main CPU) */ 429193323Sed size_t dma_bytes; /* size of DMA area */ 430193323Sed 431193323Sed struct snd_dma_buffer *dma_buffer_p; /* allocated buffer */ 432193323Sed unsigned int buffer_changed:1; /* buffer allocation changed; set only in managed mode */ 433193323Sed 434193323Sed /* -- audio timestamp config -- */ 435193323Sed struct snd_pcm_audio_tstamp_config audio_tstamp_config; 436193323Sed struct snd_pcm_audio_tstamp_report audio_tstamp_report; 437193323Sed struct timespec64 driver_tstamp; 438193323Sed 439193323Sed#if IS_ENABLED(CONFIG_SND_PCM_OSS) 440193323Sed /* -- OSS things -- */ 441193323Sed struct snd_pcm_oss_runtime oss; 442193323Sed#endif 443193323Sed}; 444193323Sed 445193323Sedstruct snd_pcm_group { /* keep linked substreams */ 446193323Sed spinlock_t lock; 447193323Sed struct mutex mutex; 448193323Sed struct list_head substreams; 449193323Sed refcount_t refs; 450193323Sed}; 451193323Sed 452193323Sedstruct pid; 453193323Sed 454200581Srdivackystruct snd_pcm_substream { 455193323Sed struct snd_pcm *pcm; 456193323Sed struct snd_pcm_str *pstr; 457193323Sed void *private_data; /* copied from pcm->private_data */ 458193323Sed int number; 459193323Sed char name[32]; /* substream name */ 460193323Sed int stream; /* stream (direction) */ 461193323Sed struct pm_qos_request latency_pm_qos_req; /* pm_qos request */ 462193323Sed size_t buffer_bytes_max; /* limit ring buffer size */ 463193323Sed struct snd_dma_buffer dma_buffer; 464193323Sed size_t dma_max; 465193323Sed /* -- hardware operations -- */ 466193323Sed const struct snd_pcm_ops *ops; 467193323Sed /* -- runtime information -- */ 468193323Sed struct snd_pcm_runtime *runtime; 469193323Sed /* -- timer section -- */ 470224145Sdim struct snd_timer *timer; /* timer */ 471224145Sdim unsigned timer_running: 1; /* time is running */ 472224145Sdim long wait_time; /* time in ms for R/W to wait for avail */ 473193323Sed /* -- next substream -- */ 474193323Sed struct snd_pcm_substream *next; 475193323Sed /* -- linked substreams -- */ 476193323Sed struct list_head link_list; /* linked list member */ 477193323Sed struct snd_pcm_group self_group; /* fake group for non linked substream (with substream lock inside) */ 478193323Sed struct snd_pcm_group *group; /* pointer to current group */ 479193323Sed /* -- assigned files -- */ 480193323Sed int ref_count; 481193323Sed atomic_t mmap_count; 482193323Sed unsigned int f_flags; 483193323Sed void (*pcm_release)(struct snd_pcm_substream *); 484193323Sed struct pid *pid; 485193323Sed#if IS_ENABLED(CONFIG_SND_PCM_OSS) 486235633Sdim /* -- OSS things -- */ 487235633Sdim struct snd_pcm_oss_substream oss; 488235633Sdim#endif 489235633Sdim#ifdef CONFIG_SND_VERBOSE_PROCFS 490235633Sdim struct snd_info_entry *proc_root; 491235633Sdim#endif /* CONFIG_SND_VERBOSE_PROCFS */ 492235633Sdim /* misc flags */ 493235633Sdim unsigned int hw_opened: 1; 494235633Sdim unsigned int managed_buffer_alloc:1; 495235633Sdim}; 496235633Sdim 497235633Sdim#define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0) 498235633Sdim 499235633Sdim 500235633Sdimstruct snd_pcm_str { 501235633Sdim int stream; /* stream (direction) */ 502235633Sdim struct snd_pcm *pcm; 503235633Sdim /* -- substreams -- */ 504235633Sdim unsigned int substream_count; 505235633Sdim unsigned int substream_opened; 506235633Sdim struct snd_pcm_substream *substream; 507235633Sdim#if IS_ENABLED(CONFIG_SND_PCM_OSS) 508235633Sdim /* -- OSS things -- */ 509235633Sdim struct snd_pcm_oss_stream oss; 510235633Sdim#endif 511235633Sdim#ifdef CONFIG_SND_VERBOSE_PROCFS 512193323Sed struct snd_info_entry *proc_root; 513193323Sed#ifdef CONFIG_SND_PCM_XRUN_DEBUG 514193323Sed unsigned int xrun_debug; /* 0 = disabled, 1 = verbose, 2 = stacktrace */ 515193323Sed#endif 516193323Sed#endif 517193323Sed struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */ 518193323Sed struct device *dev; 519193323Sed}; 520204792Srdivacky 521204792Srdivackystruct snd_pcm { 522193323Sed struct snd_card *card; 523204792Srdivacky struct list_head list; 524193323Sed int device; /* device number */ 525193323Sed unsigned int info_flags; 526193323Sed unsigned short dev_class; 527193323Sed unsigned short dev_subclass; 528193323Sed char id[64]; 529193323Sed char name[80]; 530193323Sed struct snd_pcm_str streams[2]; 531193323Sed struct mutex open_mutex; 532193323Sed wait_queue_head_t open_wait; 533193323Sed void *private_data; 534193323Sed void (*private_free) (struct snd_pcm *pcm); 535193323Sed bool internal; /* pcm is for internal use only */ 536193323Sed bool nonatomic; /* whole PCM operations are in non-atomic context */ 537193323Sed bool no_device_suspend; /* don't invoke device PM suspend */ 538193323Sed#if IS_ENABLED(CONFIG_SND_PCM_OSS) 539193323Sed struct snd_pcm_oss oss; 540193323Sed#endif 541193323Sed}; 542193323Sed 543193323Sed/* 544193323Sed * Registering 545193323Sed */ 546193323Sed 547193323Sedextern const struct file_operations snd_pcm_f_ops[2]; 548193323Sed 549193323Sedint snd_pcm_new(struct snd_card *card, const char *id, int device, 550193323Sed int playback_count, int capture_count, 551193323Sed struct snd_pcm **rpcm); 552193323Sedint snd_pcm_new_internal(struct snd_card *card, const char *id, int device, 553193323Sed int playback_count, int capture_count, 554193323Sed struct snd_pcm **rpcm); 555193323Sedint snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count); 556193323Sed 557193323Sed#if IS_ENABLED(CONFIG_SND_PCM_OSS) 558193323Sedstruct snd_pcm_notify { 559193323Sed int (*n_register) (struct snd_pcm * pcm); 560193323Sed int (*n_disconnect) (struct snd_pcm * pcm); 561193323Sed int (*n_unregister) (struct snd_pcm * pcm); 562193323Sed struct list_head list; 563193323Sed}; 564193323Sedint snd_pcm_notify(struct snd_pcm_notify *notify, int nfree); 565193323Sed#endif 566193323Sed 567193323Sed/* 568193323Sed * Native I/O 569193323Sed */ 570193323Sed 571193323Sedint snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info); 572193323Sedint snd_pcm_info_user(struct snd_pcm_substream *substream, 573235633Sdim struct snd_pcm_info __user *info); 574235633Sdimint snd_pcm_status64(struct snd_pcm_substream *substream, 575235633Sdim struct snd_pcm_status64 *status); 576193323Sedint snd_pcm_start(struct snd_pcm_substream *substream); 577193323Sedint snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status); 578193323Sedint snd_pcm_drain_done(struct snd_pcm_substream *substream); 579193323Sedint snd_pcm_stop_xrun(struct snd_pcm_substream *substream); 580193323Sed#ifdef CONFIG_PM 581193323Sedint snd_pcm_suspend_all(struct snd_pcm *pcm); 582193323Sed#else 583193323Sedstatic inline int snd_pcm_suspend_all(struct snd_pcm *pcm) 584193323Sed{ 585193323Sed return 0; 586193323Sed} 587193323Sed#endif 588193323Sedint snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg); 589193323Sedint snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct file *file, 590193323Sed struct snd_pcm_substream **rsubstream); 591193323Sedvoid snd_pcm_release_substream(struct snd_pcm_substream *substream); 592235633Sdimint snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, struct file *file, 593193323Sed struct snd_pcm_substream **rsubstream); 594193323Sedvoid snd_pcm_detach_substream(struct snd_pcm_substream *substream); 595193323Sedint snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area); 596193323Sed 597193323Sed 598193323Sed#ifdef CONFIG_SND_DEBUG 599193323Sedvoid snd_pcm_debug_name(struct snd_pcm_substream *substream, 600193323Sed char *name, size_t len); 601193323Sed#else 602193323Sedstatic inline void 603193323Sedsnd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size) 604193323Sed{ 605193323Sed *buf = 0; 606193323Sed} 607193323Sed#endif 608193323Sed 609193323Sed/* 610193323Sed * PCM library 611218893Sdim */ 612218893Sdim 613218893Sdim/** 614193323Sed * snd_pcm_stream_linked - Check whether the substream is linked with others 615193323Sed * @substream: substream to check 616193323Sed * 617193323Sed * Return: true if the given substream is being linked with others 618193323Sed */ 619193323Sedstatic inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream) 620193323Sed{ 621193323Sed return substream->group != &substream->self_group; 622193323Sed} 623193323Sed 624193323Sedvoid snd_pcm_stream_lock(struct snd_pcm_substream *substream); 625193323Sedvoid snd_pcm_stream_unlock(struct snd_pcm_substream *substream); 626193323Sedvoid snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream); 627193323Sedvoid snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream); 628193323Sedunsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream); 629193323Sedunsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream); 630193323Sed 631193323Sed/** 632193323Sed * snd_pcm_stream_lock_irqsave - Lock the PCM stream 633193323Sed * @substream: PCM substream 634193323Sed * @flags: irq flags 635193323Sed * 636193323Sed * This locks the PCM stream like snd_pcm_stream_lock() but with the local 637193323Sed * IRQ (only when nonatomic is false). In nonatomic case, this is identical 638193323Sed * as snd_pcm_stream_lock(). 639193323Sed */ 640193323Sed#define snd_pcm_stream_lock_irqsave(substream, flags) \ 641193323Sed do { \ 642202375Srdivacky typecheck(unsigned long, flags); \ 643193323Sed flags = _snd_pcm_stream_lock_irqsave(substream); \ 644193323Sed } while (0) 645193323Sedvoid snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, 646202375Srdivacky unsigned long flags); 647193323Sed 648193323Sed/** 649193323Sed * snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking 650202375Srdivacky * @substream: PCM substream 651193323Sed * @flags: irq flags 652193323Sed * 653193323Sed * This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with 654193323Sed * the single-depth lockdep subclass. 655193323Sed */ 656193323Sed#define snd_pcm_stream_lock_irqsave_nested(substream, flags) \ 657193323Sed do { \ 658193323Sed typecheck(unsigned long, flags); \ 659193323Sed flags = _snd_pcm_stream_lock_irqsave_nested(substream); \ 660193323Sed } while (0) 661193323Sed 662193323Sed/* definitions for guard(); use like guard(pcm_stream_lock) */ 663193323SedDEFINE_LOCK_GUARD_1(pcm_stream_lock, struct snd_pcm_substream, 664193323Sed snd_pcm_stream_lock(_T->lock), 665193323Sed snd_pcm_stream_unlock(_T->lock)) 666193323SedDEFINE_LOCK_GUARD_1(pcm_stream_lock_irq, struct snd_pcm_substream, 667193323Sed snd_pcm_stream_lock_irq(_T->lock), 668193323Sed snd_pcm_stream_unlock_irq(_T->lock)) 669193323SedDEFINE_LOCK_GUARD_1(pcm_stream_lock_irqsave, struct snd_pcm_substream, 670193323Sed snd_pcm_stream_lock_irqsave(_T->lock, _T->flags), 671193323Sed snd_pcm_stream_unlock_irqrestore(_T->lock, _T->flags), 672193323Sed unsigned long flags) 673193323Sed 674193323Sed/** 675193323Sed * snd_pcm_group_for_each_entry - iterate over the linked substreams 676221345Sdim * @s: the iterator 677193323Sed * @substream: the substream 678193323Sed * 679193323Sed * Iterate over the all linked substreams to the given @substream. 680193323Sed * When @substream isn't linked with any others, this gives returns @substream 681193323Sed * itself once. 682193323Sed */ 683221345Sdim#define snd_pcm_group_for_each_entry(s, substream) \ 684221345Sdim list_for_each_entry(s, &substream->group->substreams, link_list) 685221345Sdim 686193323Sed#define for_each_pcm_streams(stream) \ 687221345Sdim for (stream = SNDRV_PCM_STREAM_PLAYBACK; \ 688193323Sed stream <= SNDRV_PCM_STREAM_LAST; \ 689193323Sed stream++) 690193323Sed 691193323Sed/** 692193323Sed * snd_pcm_running - Check whether the substream is in a running state 693193323Sed * @substream: substream to check 694193323Sed * 695193323Sed * Return: true if the given substream is in the state RUNNING, or in the 696218893Sdim * state DRAINING for playback. 697218893Sdim */ 698193323Sedstatic inline int snd_pcm_running(struct snd_pcm_substream *substream) 699193323Sed{ 700202375Srdivacky return (substream->runtime->state == SNDRV_PCM_STATE_RUNNING || 701202375Srdivacky (substream->runtime->state == SNDRV_PCM_STATE_DRAINING && 702193323Sed substream->stream == SNDRV_PCM_STREAM_PLAYBACK)); 703193323Sed} 704193323Sed 705193323Sed/** 706193323Sed * __snd_pcm_set_state - Change the current PCM state 707193323Sed * @runtime: PCM runtime to set 708193323Sed * @state: the current state to set 709193323Sed * 710193323Sed * Call within the stream lock 711193323Sed */ 712193323Sedstatic inline void __snd_pcm_set_state(struct snd_pcm_runtime *runtime, 713193323Sed snd_pcm_state_t state) 714193323Sed{ 715200581Srdivacky runtime->state = state; 716193323Sed runtime->status->state = state; /* copy for mmap */ 717218893Sdim} 718218893Sdim 719218893Sdim/** 720218893Sdim * bytes_to_samples - Unit conversion of the size from bytes to samples 721193323Sed * @runtime: PCM runtime instance 722193323Sed * @size: size in bytes 723193323Sed * 724193323Sed * Return: the size in samples 725193323Sed */ 726193323Sedstatic inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size) 727221345Sdim{ 728221345Sdim return size * 8 / runtime->sample_bits; 729221345Sdim} 730221345Sdim 731221345Sdim/** 732221345Sdim * bytes_to_frames - Unit conversion of the size from bytes to frames 733221345Sdim * @runtime: PCM runtime instance 734221345Sdim * @size: size in bytes 735221345Sdim * 736221345Sdim * Return: the size in frames 737221345Sdim */ 738221345Sdimstatic inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size) 739221345Sdim{ 740221345Sdim return size * 8 / runtime->frame_bits; 741221345Sdim} 742221345Sdim 743221345Sdim/** 744221345Sdim * samples_to_bytes - Unit conversion of the size from samples to bytes 745221345Sdim * @runtime: PCM runtime instance 746221345Sdim * @size: size in samples 747221345Sdim * 748221345Sdim * Return: the byte size 749221345Sdim */ 750221345Sdimstatic inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size) 751221345Sdim{ 752221345Sdim return size * runtime->sample_bits / 8; 753221345Sdim} 754221345Sdim 755221345Sdim/** 756221345Sdim * frames_to_bytes - Unit conversion of the size from frames to bytes 757221345Sdim * @runtime: PCM runtime instance 758221345Sdim * @size: size in frames 759221345Sdim * 760221345Sdim * Return: the byte size 761221345Sdim */ 762221345Sdimstatic inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size) 763221345Sdim{ 764221345Sdim return size * runtime->frame_bits / 8; 765221345Sdim} 766221345Sdim 767221345Sdim/** 768221345Sdim * frame_aligned - Check whether the byte size is aligned to frames 769221345Sdim * @runtime: PCM runtime instance 770221345Sdim * @bytes: size in bytes 771221345Sdim * 772221345Sdim * Return: true if aligned, or false if not 773221345Sdim */ 774221345Sdimstatic inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes) 775193323Sed{ 776193323Sed return bytes % runtime->byte_align == 0; 777193323Sed} 778193323Sed 779193323Sed/** 780193323Sed * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes 781193323Sed * @substream: PCM substream 782193323Sed * 783193323Sed * Return: buffer byte size 784193323Sed */ 785193323Sedstatic inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream) 786193323Sed{ 787193323Sed struct snd_pcm_runtime *runtime = substream->runtime; 788193323Sed return frames_to_bytes(runtime, runtime->buffer_size); 789193323Sed} 790193323Sed 791193323Sed/** 792193323Sed * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes 793193323Sed * @substream: PCM substream 794193323Sed * 795193323Sed * Return: period byte size 796193323Sed */ 797193323Sedstatic inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream) 798193323Sed{ 799193323Sed struct snd_pcm_runtime *runtime = substream->runtime; 800193323Sed return frames_to_bytes(runtime, runtime->period_size); 801193323Sed} 802193323Sed 803193323Sed/** 804193323Sed * snd_pcm_playback_avail - Get the available (writable) space for playback 805193323Sed * @runtime: PCM runtime instance 806221345Sdim * 807193323Sed * Result is between 0 ... (boundary - 1) 808193323Sed * 809193323Sed * Return: available frame size 810221345Sdim */ 811193323Sedstatic inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime) 812193323Sed{ 813193323Sed snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_ptr; 814193323Sed if (avail < 0) 815199511Srdivacky avail += runtime->boundary; 816193323Sed else if ((snd_pcm_uframes_t) avail >= runtime->boundary) 817193323Sed avail -= runtime->boundary; 818235633Sdim return avail; 819193323Sed} 820235633Sdim 821193323Sed/** 822193323Sed * snd_pcm_capture_avail - Get the available (readable) space for capture 823193323Sed * @runtime: PCM runtime instance 824193323Sed * 825193323Sed * Result is between 0 ... (boundary - 1) 826193323Sed * 827193323Sed * Return: available frame size 828193323Sed */ 829199511Srdivackystatic inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime) 830193323Sed{ 831193323Sed snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr; 832193323Sed if (avail < 0) 833193323Sed avail += runtime->boundary; 834193323Sed return avail; 835198090Srdivacky} 836198090Srdivacky 837198090Srdivacky/** 838198090Srdivacky * snd_pcm_playback_hw_avail - Get the queued space for playback 839198090Srdivacky * @runtime: PCM runtime instance 840198090Srdivacky * 841198090Srdivacky * Return: available frame size 842198090Srdivacky */ 843198090Srdivackystatic inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime) 844198090Srdivacky{ 845198090Srdivacky return runtime->buffer_size - snd_pcm_playback_avail(runtime); 846198090Srdivacky} 847198090Srdivacky 848198090Srdivacky/** 849198090Srdivacky * snd_pcm_capture_hw_avail - Get the free space for capture 850198090Srdivacky * @runtime: PCM runtime instance 851198090Srdivacky * 852198090Srdivacky * Return: available frame size 853208599Srdivacky */ 854198090Srdivackystatic inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime) 855198090Srdivacky{ 856198090Srdivacky return runtime->buffer_size - snd_pcm_capture_avail(runtime); 857198090Srdivacky} 858198090Srdivacky 859198090Srdivacky/** 860198090Srdivacky * snd_pcm_playback_ready - check whether the playback buffer is available 861198090Srdivacky * @substream: the pcm substream instance 862198090Srdivacky * 863198090Srdivacky * Checks whether enough free space is available on the playback buffer. 864198090Srdivacky * 865198090Srdivacky * Return: Non-zero if available, or zero if not. 866198090Srdivacky */ 867198090Srdivackystatic inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream) 868198090Srdivacky{ 869199511Srdivacky struct snd_pcm_runtime *runtime = substream->runtime; 870198090Srdivacky return snd_pcm_playback_avail(runtime) >= runtime->control->avail_min; 871198090Srdivacky} 872198090Srdivacky 873198090Srdivacky/** 874198090Srdivacky * snd_pcm_capture_ready - check whether the capture buffer is available 875198090Srdivacky * @substream: the pcm substream instance 876198090Srdivacky * 877198090Srdivacky * Checks whether enough capture data is available on the capture buffer. 878198090Srdivacky * 879198090Srdivacky * Return: Non-zero if available, or zero if not. 880198090Srdivacky */ 881198090Srdivackystatic inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream) 882198090Srdivacky{ 883198090Srdivacky struct snd_pcm_runtime *runtime = substream->runtime; 884198090Srdivacky return snd_pcm_capture_avail(runtime) >= runtime->control->avail_min; 885198090Srdivacky} 886198090Srdivacky 887198090Srdivacky/** 888198090Srdivacky * snd_pcm_playback_data - check whether any data exists on the playback buffer 889198090Srdivacky * @substream: the pcm substream instance 890198090Srdivacky * 891198090Srdivacky * Checks whether any data exists on the playback buffer. 892198090Srdivacky * 893198090Srdivacky * Return: Non-zero if any data exists, or zero if not. If stop_threshold 894198090Srdivacky * is bigger or equal to boundary, then this function returns always non-zero. 895198090Srdivacky */ 896198090Srdivackystatic inline int snd_pcm_playback_data(struct snd_pcm_substream *substream) 897198090Srdivacky{ 898198090Srdivacky struct snd_pcm_runtime *runtime = substream->runtime; 899235633Sdim 900235633Sdim if (runtime->stop_threshold >= runtime->boundary) 901235633Sdim return 1; 902235633Sdim return snd_pcm_playback_avail(runtime) < runtime->buffer_size; 903235633Sdim} 904235633Sdim 905235633Sdim/** 906235633Sdim * snd_pcm_playback_empty - check whether the playback buffer is empty 907235633Sdim * @substream: the pcm substream instance 908235633Sdim * 909235633Sdim * Checks whether the playback buffer is empty. 910235633Sdim * 911235633Sdim * Return: Non-zero if empty, or zero if not. 912235633Sdim */ 913235633Sdimstatic inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream) 914235633Sdim{ 915235633Sdim struct snd_pcm_runtime *runtime = substream->runtime; 916235633Sdim return snd_pcm_playback_avail(runtime) >= runtime->buffer_size; 917235633Sdim} 918235633Sdim 919235633Sdim/** 920235633Sdim * snd_pcm_capture_empty - check whether the capture buffer is empty 921235633Sdim * @substream: the pcm substream instance 922235633Sdim * 923235633Sdim * Checks whether the capture buffer is empty. 924235633Sdim * 925235633Sdim * Return: Non-zero if empty, or zero if not. 926235633Sdim */ 927235633Sdimstatic inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream) 928235633Sdim{ 929235633Sdim struct snd_pcm_runtime *runtime = substream->runtime; 930235633Sdim return snd_pcm_capture_avail(runtime) == 0; 931235633Sdim} 932235633Sdim 933235633Sdim/** 934235633Sdim * snd_pcm_trigger_done - Mark the master substream 935235633Sdim * @substream: the pcm substream instance 936235633Sdim * @master: the linked master substream 937235633Sdim * 938235633Sdim * When multiple substreams of the same card are linked and the hardware 939235633Sdim * supports the single-shot operation, the driver calls this in the loop 940235633Sdim * in snd_pcm_group_for_each_entry() for marking the substream as "done". 941235633Sdim * Then most of trigger operations are performed only to the given master 942235633Sdim * substream. 943235633Sdim * 944235633Sdim * The trigger_master mark is cleared at timestamp updates at the end 945235633Sdim * of trigger operations. 946235633Sdim */ 947235633Sdimstatic inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream, 948235633Sdim struct snd_pcm_substream *master) 949235633Sdim{ 950235633Sdim substream->runtime->trigger_master = master; 951235633Sdim} 952235633Sdim 953235633Sdimstatic inline int hw_is_mask(int var) 954235633Sdim{ 955235633Sdim return var >= SNDRV_PCM_HW_PARAM_FIRST_MASK && 956235633Sdim var <= SNDRV_PCM_HW_PARAM_LAST_MASK; 957235633Sdim} 958235633Sdim 959235633Sdimstatic inline int hw_is_interval(int var) 960235633Sdim{ 961235633Sdim return var >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL && 962235633Sdim var <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; 963235633Sdim} 964235633Sdim 965235633Sdimstatic inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params, 966235633Sdim snd_pcm_hw_param_t var) 967235633Sdim{ 968235633Sdim return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; 969235633Sdim} 970235633Sdim 971235633Sdimstatic inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params, 972235633Sdim snd_pcm_hw_param_t var) 973235633Sdim{ 974235633Sdim return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; 975235633Sdim} 976235633Sdim 977235633Sdimstatic inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params, 978235633Sdim snd_pcm_hw_param_t var) 979235633Sdim{ 980235633Sdim return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; 981235633Sdim} 982235633Sdim 983235633Sdimstatic inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params, 984235633Sdim snd_pcm_hw_param_t var) 985235633Sdim{ 986235633Sdim return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; 987235633Sdim} 988235633Sdim 989235633Sdim/** 990235633Sdim * params_channels - Get the number of channels from the hw params 991235633Sdim * @p: hw params 992235633Sdim * 993235633Sdim * Return: the number of channels 994235633Sdim */ 995235633Sdimstatic inline unsigned int params_channels(const struct snd_pcm_hw_params *p) 996235633Sdim{ 997235633Sdim return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_CHANNELS)->min; 998235633Sdim} 999235633Sdim 1000235633Sdim/** 1001235633Sdim * params_rate - Get the sample rate from the hw params 1002235633Sdim * @p: hw params 1003235633Sdim * 1004235633Sdim * Return: the sample rate 1005235633Sdim */ 1006235633Sdimstatic inline unsigned int params_rate(const struct snd_pcm_hw_params *p) 1007235633Sdim{ 1008235633Sdim return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_RATE)->min; 1009235633Sdim} 1010235633Sdim 1011235633Sdim/** 1012235633Sdim * params_period_size - Get the period size (in frames) from the hw params 1013235633Sdim * @p: hw params 1014235633Sdim * 1015235633Sdim * Return: the period size in frames 1016235633Sdim */ 1017235633Sdimstatic inline unsigned int params_period_size(const struct snd_pcm_hw_params *p) 1018235633Sdim{ 1019235633Sdim return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min; 1020235633Sdim} 1021235633Sdim 1022235633Sdim/** 1023235633Sdim * params_periods - Get the number of periods from the hw params 1024235633Sdim * @p: hw params 1025235633Sdim * 1026235633Sdim * Return: the number of periods 1027235633Sdim */ 1028235633Sdimstatic inline unsigned int params_periods(const struct snd_pcm_hw_params *p) 1029235633Sdim{ 1030235633Sdim return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIODS)->min; 1031235633Sdim} 1032235633Sdim 1033235633Sdim/** 1034235633Sdim * params_buffer_size - Get the buffer size (in frames) from the hw params 1035235633Sdim * @p: hw params 1036235633Sdim * 1037235633Sdim * Return: the buffer size in frames 1038235633Sdim */ 1039235633Sdimstatic inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p) 1040235633Sdim{ 1041235633Sdim return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min; 1042235633Sdim} 1043235633Sdim 1044235633Sdim/** 1045235633Sdim * params_buffer_bytes - Get the buffer size (in bytes) from the hw params 1046235633Sdim * @p: hw params 1047235633Sdim * 1048235633Sdim * Return: the buffer size in bytes 1049235633Sdim */ 1050235633Sdimstatic inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p) 1051235633Sdim{ 1052235633Sdim return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min; 1053235633Sdim} 1054235633Sdim 1055235633Sdimint snd_interval_refine(struct snd_interval *i, const struct snd_interval *v); 1056235633Sdimint snd_interval_list(struct snd_interval *i, unsigned int count, 1057235633Sdim const unsigned int *list, unsigned int mask); 1058235633Sdimint snd_interval_ranges(struct snd_interval *i, unsigned int count, 1059235633Sdim const struct snd_interval *list, unsigned int mask); 1060235633Sdimint snd_interval_ratnum(struct snd_interval *i, 1061235633Sdim unsigned int rats_count, const struct snd_ratnum *rats, 1062235633Sdim unsigned int *nump, unsigned int *denp); 1063235633Sdim 1064235633Sdimvoid _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params); 1065235633Sdimvoid _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var); 1066235633Sdim 1067235633Sdimint snd_pcm_hw_refine(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); 1068235633Sdim 1069235633Sdimint snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, 1070235633Sdim u_int64_t mask); 1071235633Sdimint snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, 1072235633Sdim unsigned int min, unsigned int max); 1073235633Sdimint snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var); 1074235633Sdimint snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, 1075235633Sdim unsigned int cond, 1076235633Sdim snd_pcm_hw_param_t var, 1077235633Sdim const struct snd_pcm_hw_constraint_list *l); 1078235633Sdimint snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime, 1079235633Sdim unsigned int cond, 1080235633Sdim snd_pcm_hw_param_t var, 1081235633Sdim const struct snd_pcm_hw_constraint_ranges *r); 1082235633Sdimint snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, 1083235633Sdim unsigned int cond, 1084235633Sdim snd_pcm_hw_param_t var, 1085235633Sdim const struct snd_pcm_hw_constraint_ratnums *r); 1086235633Sdimint snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, 1087235633Sdim unsigned int cond, 1088235633Sdim snd_pcm_hw_param_t var, 1089235633Sdim const struct snd_pcm_hw_constraint_ratdens *r); 1090235633Sdimint snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, 1091235633Sdim unsigned int cond, 1092235633Sdim unsigned int width, 1093235633Sdim unsigned int msbits); 1094235633Sdimint snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, 1095235633Sdim unsigned int cond, 1096235633Sdim snd_pcm_hw_param_t var, 1097235633Sdim unsigned long step); 1098235633Sdimint snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, 1099235633Sdim unsigned int cond, 1100235633Sdim snd_pcm_hw_param_t var); 1101235633Sdimint snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime, 1102235633Sdim unsigned int base_rate); 1103235633Sdimint snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, 1104235633Sdim unsigned int cond, 1105235633Sdim int var, 1106235633Sdim snd_pcm_hw_rule_func_t func, void *private, 1107235633Sdim int dep, ...); 1108235633Sdim 1109235633Sdim/** 1110235633Sdim * snd_pcm_hw_constraint_single() - Constrain parameter to a single value 1111235633Sdim * @runtime: PCM runtime instance 1112235633Sdim * @var: The hw_params variable to constrain 1113235633Sdim * @val: The value to constrain to 1114235633Sdim * 1115235633Sdim * Return: Positive if the value is changed, zero if it's not changed, or a 1116235633Sdim * negative error code. 1117235633Sdim */ 1118235633Sdimstatic inline int snd_pcm_hw_constraint_single( 1119235633Sdim struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, 1120235633Sdim unsigned int val) 1121235633Sdim{ 1122235633Sdim return snd_pcm_hw_constraint_minmax(runtime, var, val, val); 1123235633Sdim} 1124235633Sdim 1125235633Sdimint snd_pcm_format_signed(snd_pcm_format_t format); 1126235633Sdimint snd_pcm_format_unsigned(snd_pcm_format_t format); 1127235633Sdimint snd_pcm_format_linear(snd_pcm_format_t format); 1128235633Sdimint snd_pcm_format_little_endian(snd_pcm_format_t format); 1129235633Sdimint snd_pcm_format_big_endian(snd_pcm_format_t format); 1130235633Sdim#if 0 /* just for kernel-doc */ 1131235633Sdim/** 1132235633Sdim * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian 1133235633Sdim * @format: the format to check 1134235633Sdim * 1135235633Sdim * Return: 1 if the given PCM format is CPU-endian, 0 if 1136235633Sdim * opposite, or a negative error code if endian not specified. 1137235633Sdim */ 1138235633Sdimint snd_pcm_format_cpu_endian(snd_pcm_format_t format); 1139235633Sdim#endif /* DocBook */ 1140235633Sdim#ifdef SNDRV_LITTLE_ENDIAN 1141235633Sdim#define snd_pcm_format_cpu_endian(format) snd_pcm_format_little_endian(format) 1142235633Sdim#else 1143235633Sdim#define snd_pcm_format_cpu_endian(format) snd_pcm_format_big_endian(format) 1144235633Sdim#endif 1145235633Sdimint snd_pcm_format_width(snd_pcm_format_t format); /* in bits */ 1146235633Sdimint snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */ 1147235633Sdimssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples); 1148235633Sdimconst unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format); 1149235633Sdimint snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames); 1150235633Sdim 1151235633Sdimvoid snd_pcm_set_ops(struct snd_pcm * pcm, int direction, 1152235633Sdim const struct snd_pcm_ops *ops); 1153235633Sdimvoid snd_pcm_set_sync(struct snd_pcm_substream *substream); 1154235633Sdimint snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, 1155235633Sdim unsigned int cmd, void *arg); 1156235633Sdimvoid snd_pcm_period_elapsed_under_stream_lock(struct snd_pcm_substream *substream); 1157235633Sdimvoid snd_pcm_period_elapsed(struct snd_pcm_substream *substream); 1158235633Sdimsnd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream, 1159235633Sdim void *buf, bool interleaved, 1160235633Sdim snd_pcm_uframes_t frames, bool in_kernel); 1161235633Sdim 1162235633Sdimstatic inline snd_pcm_sframes_t 1163235633Sdimsnd_pcm_lib_write(struct snd_pcm_substream *substream, 1164235633Sdim const void __user *buf, snd_pcm_uframes_t frames) 1165235633Sdim{ 1166235633Sdim return __snd_pcm_lib_xfer(substream, (void __force *)buf, true, frames, false); 1167235633Sdim} 1168235633Sdim 1169235633Sdimstatic inline snd_pcm_sframes_t 1170235633Sdimsnd_pcm_lib_read(struct snd_pcm_substream *substream, 1171235633Sdim void __user *buf, snd_pcm_uframes_t frames) 1172235633Sdim{ 1173235633Sdim return __snd_pcm_lib_xfer(substream, (void __force *)buf, true, frames, false); 1174235633Sdim} 1175235633Sdim 1176235633Sdimstatic inline snd_pcm_sframes_t 1177235633Sdimsnd_pcm_lib_writev(struct snd_pcm_substream *substream, 1178235633Sdim void __user **bufs, snd_pcm_uframes_t frames) 1179235633Sdim{ 1180235633Sdim return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false); 1181235633Sdim} 1182235633Sdim 1183198090Srdivackystatic inline snd_pcm_sframes_t 1184198090Srdivackysnd_pcm_lib_readv(struct snd_pcm_substream *substream, 1185198090Srdivacky void __user **bufs, snd_pcm_uframes_t frames) 1186235633Sdim{ 1187235633Sdim return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false); 1188235633Sdim} 1189198090Srdivacky 1190198090Srdivackystatic inline snd_pcm_sframes_t 1191198090Srdivackysnd_pcm_kernel_write(struct snd_pcm_substream *substream, 1192198090Srdivacky const void *buf, snd_pcm_uframes_t frames) 1193221345Sdim{ 1194221345Sdim return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames, true); 1195235633Sdim} 1196235633Sdim 1197198090Srdivackystatic inline snd_pcm_sframes_t 1198235633Sdimsnd_pcm_kernel_read(struct snd_pcm_substream *substream, 1199235633Sdim void *buf, snd_pcm_uframes_t frames) 1200235633Sdim{ 1201235633Sdim return __snd_pcm_lib_xfer(substream, buf, true, frames, true); 1202198090Srdivacky} 1203198090Srdivacky 1204198090Srdivackystatic inline snd_pcm_sframes_t 1205198090Srdivackysnd_pcm_kernel_writev(struct snd_pcm_substream *substream, 1206198090Srdivacky void **bufs, snd_pcm_uframes_t frames) 1207235633Sdim{ 1208235633Sdim return __snd_pcm_lib_xfer(substream, bufs, false, frames, true); 1209199511Srdivacky} 1210198090Srdivacky 1211198090Srdivackystatic inline snd_pcm_sframes_t 1212198090Srdivackysnd_pcm_kernel_readv(struct snd_pcm_substream *substream, 1213198090Srdivacky void **bufs, snd_pcm_uframes_t frames) 1214198090Srdivacky{ 1215198090Srdivacky return __snd_pcm_lib_xfer(substream, bufs, false, frames, true); 1216198090Srdivacky} 1217198090Srdivacky 1218198090Srdivackyint snd_pcm_hw_limit_rates(struct snd_pcm_hardware *hw); 1219198090Srdivacky 1220235633Sdimstatic inline int 1221235633Sdimsnd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) 1222198090Srdivacky{ 1223198090Srdivacky return snd_pcm_hw_limit_rates(&runtime->hw); 1224198090Srdivacky} 1225198090Srdivacky 1226198090Srdivackyunsigned int snd_pcm_rate_to_rate_bit(unsigned int rate); 1227198090Srdivackyunsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit); 1228235633Sdimunsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a, 1229235633Sdim unsigned int rates_b); 1230198090Srdivackyunsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min, 1231198090Srdivacky unsigned int rate_max); 1232198090Srdivacky 1233235633Sdim/** 1234198090Srdivacky * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer 1235198090Srdivacky * @substream: PCM substream to set 1236198090Srdivacky * @bufp: the buffer information, NULL to clear 1237198090Srdivacky * 1238198090Srdivacky * Copy the buffer information to runtime->dma_buffer when @bufp is non-NULL. 1239198090Srdivacky * Otherwise it clears the current buffer information. 1240198090Srdivacky */ 1241198090Srdivackystatic inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream, 1242198090Srdivacky struct snd_dma_buffer *bufp) 1243198090Srdivacky{ 1244198090Srdivacky struct snd_pcm_runtime *runtime = substream->runtime; 1245198090Srdivacky if (bufp) { 1246198090Srdivacky runtime->dma_buffer_p = bufp; 1247198090Srdivacky runtime->dma_area = bufp->area; 1248235633Sdim runtime->dma_addr = bufp->addr; 1249235633Sdim runtime->dma_bytes = bufp->bytes; 1250235633Sdim } else { 1251235633Sdim runtime->dma_buffer_p = NULL; 1252235633Sdim runtime->dma_area = NULL; 1253235633Sdim runtime->dma_addr = 0; 1254235633Sdim runtime->dma_bytes = 0; 1255221345Sdim } 1256221345Sdim} 1257221345Sdim 1258235633Sdim/** 1259198090Srdivacky * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode 1260198090Srdivacky * @runtime: PCM runtime instance 1261221345Sdim * @tv: timespec64 to fill 1262198090Srdivacky */ 1263218893Sdimstatic inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime, 1264198090Srdivacky struct timespec64 *tv) 1265198090Srdivacky{ 1266198090Srdivacky switch (runtime->tstamp_type) { 1267198090Srdivacky case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC: 1268198090Srdivacky ktime_get_ts64(tv); 1269210299Sed break; 1270235633Sdim case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW: 1271235633Sdim ktime_get_raw_ts64(tv); 1272235633Sdim break; 1273235633Sdim default: 1274235633Sdim ktime_get_real_ts64(tv); 1275235633Sdim break; 1276235633Sdim } 1277210299Sed} 1278210299Sed 1279210299Sed/* 1280210299Sed * Memory 1281210299Sed */ 1282210299Sed 1283210299Sedvoid snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream); 1284210299Sedvoid snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm); 1285235633Sdimvoid snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, 1286210299Sed int type, struct device *data, 1287210299Sed size_t size, size_t max); 1288210299Sedvoid snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, 1289235633Sdim int type, void *data, 1290210299Sed size_t size, size_t max); 1291210299Sedint snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size); 1292210299Sedint snd_pcm_lib_free_pages(struct snd_pcm_substream *substream); 1293210299Sed 1294224145Sdimint snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, 1295224145Sdim struct device *data, size_t size, size_t max); 1296210299Sedint snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type, 1297210299Sed struct device *data, 1298210299Sed size_t size, size_t max); 1299235633Sdim 1300210299Sed/** 1301224145Sdim * snd_pcm_set_fixed_buffer - Preallocate and set up the fixed size PCM buffer 1302210299Sed * @substream: the pcm substream instance 1303210299Sed * @type: DMA type (SNDRV_DMA_TYPE_*) 1304235633Sdim * @data: DMA type dependent data 1305210299Sed * @size: the requested pre-allocation size in bytes 1306210299Sed * 1307210299Sed * This is a variant of snd_pcm_set_managed_buffer(), but this pre-allocates 1308210299Sed * only the given sized buffer and doesn't allow re-allocation nor dynamic 1309210299Sed * allocation of a larger buffer unlike the standard one. 1310210299Sed * The function may return -ENOMEM error, hence the caller must check it. 1311210299Sed * 1312210299Sed * Return: zero if successful, or a negative error code 1313210299Sed */ 1314210299Sedstatic inline int __must_check 1315210299Sedsnd_pcm_set_fixed_buffer(struct snd_pcm_substream *substream, int type, 1316210299Sed struct device *data, size_t size) 1317210299Sed{ 1318210299Sed return snd_pcm_set_managed_buffer(substream, type, data, size, 0); 1319210299Sed} 1320210299Sed 1321210299Sed/** 1322210299Sed * snd_pcm_set_fixed_buffer_all - Preallocate and set up the fixed size PCM buffer 1323210299Sed * @pcm: the pcm instance 1324210299Sed * @type: DMA type (SNDRV_DMA_TYPE_*) 1325210299Sed * @data: DMA type dependent data 1326210299Sed * @size: the requested pre-allocation size in bytes 1327210299Sed * 1328210299Sed * Apply the set up of the fixed buffer via snd_pcm_set_fixed_buffer() for 1329221345Sdim * all substream. If any of allocation fails, it returns -ENOMEM, hence the 1330210299Sed * caller must check the return value. 1331210299Sed * 1332210299Sed * Return: zero if successful, or a negative error code 1333210299Sed */ 1334210299Sedstatic inline int __must_check 1335235633Sdimsnd_pcm_set_fixed_buffer_all(struct snd_pcm *pcm, int type, 1336235633Sdim struct device *data, size_t size) 1337235633Sdim{ 1338210299Sed return snd_pcm_set_managed_buffer_all(pcm, type, data, size, 0); 1339210299Sed} 1340210299Sed 1341210299Sedint _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, 1342235633Sdim size_t size, gfp_t gfp_flags); 1343210299Sedint snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream); 1344210299Sedstruct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, 1345210299Sed unsigned long offset); 1346235633Sdim/** 1347210299Sed * snd_pcm_lib_alloc_vmalloc_buffer - allocate virtual DMA buffer 1348210299Sed * @substream: the substream to allocate the buffer to 1349235633Sdim * @size: the requested buffer size, in bytes 1350210299Sed * 1351210299Sed * Allocates the PCM substream buffer using vmalloc(), i.e., the memory is 1352210299Sed * contiguous in kernel virtual space, but not in physical memory. Use this 1353210299Sed * if the buffer is accessed by kernel code but not by device DMA. 1354210299Sed * 1355210299Sed * Return: 1 if the buffer was changed, 0 if not changed, or a negative error 1356210299Sed * code. 1357210299Sed */ 1358210299Sedstatic inline int snd_pcm_lib_alloc_vmalloc_buffer 1359210299Sed (struct snd_pcm_substream *substream, size_t size) 1360210299Sed{ 1361210299Sed return _snd_pcm_lib_alloc_vmalloc_buffer(substream, size, 1362235633Sdim GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO); 1363210299Sed} 1364210299Sed 1365210299Sed/** 1366210299Sed * snd_pcm_lib_alloc_vmalloc_32_buffer - allocate 32-bit-addressable buffer 1367210299Sed * @substream: the substream to allocate the buffer to 1368210299Sed * @size: the requested buffer size, in bytes 1369210299Sed * 1370210299Sed * This function works like snd_pcm_lib_alloc_vmalloc_buffer(), but uses 1371210299Sed * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory. 1372210299Sed * 1373210299Sed * Return: 1 if the buffer was changed, 0 if not changed, or a negative error 1374210299Sed * code. 1375210299Sed */ 1376210299Sedstatic inline int snd_pcm_lib_alloc_vmalloc_32_buffer 1377210299Sed (struct snd_pcm_substream *substream, size_t size) 1378198090Srdivacky{ 1379198090Srdivacky return _snd_pcm_lib_alloc_vmalloc_buffer(substream, size, 1380198090Srdivacky GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); 1381193323Sed} 1382193323Sed 1383193323Sed#define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p) 1384193323Sed 1385193323Sed/** 1386193323Sed * snd_pcm_sgbuf_get_addr - Get the DMA address at the corresponding offset 1387193323Sed * @substream: PCM substream 1388235633Sdim * @ofs: byte offset 1389193323Sed * 1390198090Srdivacky * Return: DMA address 1391235633Sdim */ 1392193323Sedstatic inline dma_addr_t 1393193323Sedsnd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) 1394193323Sed{ 1395202375Srdivacky return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs); 1396235633Sdim} 1397198090Srdivacky 1398193323Sed/** 1399226890Sdim * snd_pcm_sgbuf_get_chunk_size - Compute the max size that fits within the 1400226890Sdim * contig. page from the given size 1401226890Sdim * @substream: PCM substream 1402193323Sed * @ofs: byte offset 1403218893Sdim * @size: byte size to examine 1404193323Sed * 1405198090Srdivacky * Return: chunk size 1406198090Srdivacky */ 1407198090Srdivackystatic inline unsigned int 1408198090Srdivackysnd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, 1409193323Sed unsigned int ofs, unsigned int size) 1410193323Sed{ 1411193323Sed return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size); 1412193323Sed} 1413193323Sed 1414193323Sed/** 1415193323Sed * snd_pcm_mmap_data_open - increase the mmap counter 1416193323Sed * @area: VMA 1417193323Sed * 1418193323Sed * PCM mmap callback should handle this counter properly 1419200581Srdivacky */ 1420203954Srdivackystatic inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) 1421203954Srdivacky{ 1422203954Srdivacky struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; 1423203954Srdivacky atomic_inc(&substream->mmap_count); 1424206083Srdivacky} 1425208599Srdivacky 1426208599Srdivacky/** 1427208599Srdivacky * snd_pcm_mmap_data_close - decrease the mmap counter 1428208599Srdivacky * @area: VMA 1429224145Sdim * 1430193323Sed * PCM mmap callback should handle this counter properly 1431193323Sed */ 1432193323Sedstatic inline void snd_pcm_mmap_data_close(struct vm_area_struct *area) 1433193323Sed{ 1434193323Sed struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; 1435193323Sed atomic_dec(&substream->mmap_count); 1436198090Srdivacky} 1437198090Srdivacky 1438203954Srdivackyint snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, 1439224145Sdim struct vm_area_struct *area); 1440198090Srdivacky/* mmap for io-memory area */ 1441198090Srdivacky#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA) 1442198090Srdivacky#define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAP 1443193323Sedint snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_struct *area); 1444193323Sed#else 1445193323Sed#define SNDRV_PCM_INFO_MMAP_IOMEM 0 1446198090Srdivacky#define snd_pcm_lib_mmap_iomem NULL 1447193323Sed#endif 1448202375Srdivacky 1449193323Sed/** 1450193323Sed * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer 1451198090Srdivacky * @dma: DMA number 1452198090Srdivacky * @max: pointer to store the max size 1453198090Srdivacky */ 1454198090Srdivackystatic inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max) 1455193323Sed{ 1456198090Srdivacky *max = dma < 4 ? 64 * 1024 : 128 * 1024; 1457224145Sdim} 1458198090Srdivacky 1459193323Sed/* 1460198090Srdivacky * Misc 1461198090Srdivacky */ 1462198090Srdivacky 1463198090Srdivacky#define SNDRV_PCM_DEFAULT_CON_SPDIF (IEC958_AES0_CON_EMPHASIS_NONE|\ 1464193323Sed (IEC958_AES1_CON_ORIGINAL<<8)|\ 1465198090Srdivacky (IEC958_AES1_CON_PCM_CODER<<8)|\ 1466198090Srdivacky (IEC958_AES3_CON_FS_48000<<24)) 1467198090Srdivacky 1468198090Srdivackyconst char *snd_pcm_format_name(snd_pcm_format_t format); 1469198090Srdivacky 1470198090Srdivacky/** 1471193323Sed * snd_pcm_direction_name - Get a string naming the direction of a stream 1472198090Srdivacky * @direction: Stream's direction, one of SNDRV_PCM_STREAM_XXX 1473198090Srdivacky * 1474198090Srdivacky * Returns a string naming the direction of the stream. 1475198090Srdivacky */ 1476193323Sedstatic inline const char *snd_pcm_direction_name(int direction) 1477221345Sdim{ 1478221345Sdim if (direction == SNDRV_PCM_STREAM_PLAYBACK) 1479198090Srdivacky return "Playback"; 1480198090Srdivacky else 1481193323Sed return "Capture"; 1482223017Sdim} 1483198090Srdivacky 1484198090Srdivacky/** 1485198090Srdivacky * snd_pcm_stream_str - Get a string naming the direction of a stream 1486198090Srdivacky * @substream: the pcm substream instance 1487198090Srdivacky * 1488198090Srdivacky * Return: A string naming the direction of the stream. 1489198090Srdivacky */ 1490223017Sdimstatic inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream) 1491223017Sdim{ 1492223017Sdim return snd_pcm_direction_name(substream->stream); 1493223017Sdim} 1494223017Sdim 1495198090Srdivacky/* 1496198090Srdivacky * PCM channel-mapping control API 1497198090Srdivacky */ 1498193323Sed/* array element of channel maps */ 1499198090Srdivackystruct snd_pcm_chmap_elem { 1500198090Srdivacky unsigned char channels; 1501198090Srdivacky unsigned char map[15]; 1502198090Srdivacky}; 1503198090Srdivacky 1504198090Srdivacky/* channel map information; retrieved via snd_kcontrol_chip() */ 1505198090Srdivackystruct snd_pcm_chmap { 1506198090Srdivacky struct snd_pcm *pcm; /* assigned PCM instance */ 1507193323Sed int stream; /* PLAYBACK or CAPTURE */ 1508198090Srdivacky struct snd_kcontrol *kctl; 1509198090Srdivacky const struct snd_pcm_chmap_elem *chmap; 1510193323Sed unsigned int max_channels; 1511193323Sed unsigned int channel_mask; /* optional: active channels bitmask */ 1512198090Srdivacky void *private_data; /* optional: private data pointer */ 1513198090Srdivacky}; 1514198090Srdivacky 1515198090Srdivacky/** 1516198090Srdivacky * snd_pcm_chmap_substream - get the PCM substream assigned to the given chmap info 1517198090Srdivacky * @info: chmap information 1518198090Srdivacky * @idx: the substream number index 1519193323Sed * 1520193323Sed * Return: the matched PCM substream, or NULL if not found 1521198090Srdivacky */ 1522198090Srdivackystatic inline struct snd_pcm_substream * 1523193323Sedsnd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx) 1524193323Sed{ 1525193323Sed struct snd_pcm_substream *s; 1526193323Sed for (s = info->pcm->streams[info->stream].substream; s; s = s->next) 1527235633Sdim if (s->number == idx) 1528204642Srdivacky return s; 1529193323Sed return NULL; 1530202375Srdivacky} 1531198090Srdivacky 1532210299Sed/* ALSA-standard channel maps (RL/RR prior to C/LFE) */ 1533218893Sdimextern const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[]; 1534193323Sed/* Other world's standard channel maps (C/LFE prior to RL/RR) */ 1535193323Sedextern const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[]; 1536210299Sed 1537210299Sed/* bit masks to be passed to snd_pcm_chmap.channel_mask field */ 1538193323Sed#define SND_PCM_CHMAP_MASK_24 ((1U << 2) | (1U << 4)) 1539193323Sed#define SND_PCM_CHMAP_MASK_246 (SND_PCM_CHMAP_MASK_24 | (1U << 6)) 1540193323Sed#define SND_PCM_CHMAP_MASK_2468 (SND_PCM_CHMAP_MASK_246 | (1U << 8)) 1541193323Sed 1542193323Sedint snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, 1543193323Sed const struct snd_pcm_chmap_elem *chmap, 1544193323Sed int max_channels, 1545202375Srdivacky unsigned long private_value, 1546193323Sed struct snd_pcm_chmap **info_ret); 1547198090Srdivacky 1548198090Srdivacky/** 1549198090Srdivacky * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise 1550198090Srdivacky * @pcm_format: PCM format 1551198090Srdivacky * 1552198090Srdivacky * Return: 64bit mask corresponding to the given PCM format 1553193323Sed */ 1554198090Srdivackystatic inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) 1555198090Srdivacky{ 1556193323Sed return 1ULL << (__force int) pcm_format; 1557198090Srdivacky} 1558223017Sdim 1559223017Sdim/** 1560223017Sdim * pcm_for_each_format - helper to iterate for each format type 1561223017Sdim * @f: the iterator variable in snd_pcm_format_t type 1562223017Sdim */ 1563223017Sdim#define pcm_for_each_format(f) \ 1564223017Sdim for ((f) = SNDRV_PCM_FORMAT_FIRST; \ 1565223017Sdim (__force int)(f) <= (__force int)SNDRV_PCM_FORMAT_LAST; \ 1566223017Sdim (f) = (__force snd_pcm_format_t)((__force int)(f) + 1)) 1567223017Sdim 1568198090Srdivacky/* printk helpers */ 1569198090Srdivacky#define pcm_err(pcm, fmt, args...) \ 1570193323Sed dev_err((pcm)->card->dev, fmt, ##args) 1571198090Srdivacky#define pcm_warn(pcm, fmt, args...) \ 1572198090Srdivacky dev_warn((pcm)->card->dev, fmt, ##args) 1573198090Srdivacky#define pcm_dbg(pcm, fmt, args...) \ 1574198090Srdivacky dev_dbg((pcm)->card->dev, fmt, ##args) 1575198090Srdivacky 1576198090Srdivacky/* helpers for copying between iov_iter and iomem */ 1577198090Srdivackyint copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src, 1578198090Srdivacky size_t count); 1579198090Srdivackyint copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count); 1580198090Srdivacky 1581198090Srdivackystruct snd_pcm_status64 { 1582198090Srdivacky snd_pcm_state_t state; /* stream state */ 1583198090Srdivacky u8 rsvd[4]; 1584198090Srdivacky s64 trigger_tstamp_sec; /* time when stream was started/stopped/paused */ 1585198090Srdivacky s64 trigger_tstamp_nsec; 1586198090Srdivacky s64 tstamp_sec; /* reference timestamp */ 1587198090Srdivacky s64 tstamp_nsec; 1588193323Sed snd_pcm_uframes_t appl_ptr; /* appl ptr */ 1589210299Sed snd_pcm_uframes_t hw_ptr; /* hw ptr */ 1590210299Sed snd_pcm_sframes_t delay; /* current delay in frames */ 1591210299Sed snd_pcm_uframes_t avail; /* number of frames available */ 1592210299Sed snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */ 1593210299Sed snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */ 1594210299Sed snd_pcm_state_t suspended_state; /* suspended stream state */ 1595193323Sed __u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */ 1596193323Sed s64 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */ 1597202375Srdivacky s64 audio_tstamp_nsec; 1598193323Sed s64 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */ 1599235633Sdim s64 driver_tstamp_nsec; 1600235633Sdim __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ 1601235633Sdim unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */ 1602235633Sdim}; 1603235633Sdim 1604235633Sdim#define SNDRV_PCM_IOCTL_STATUS64 _IOR('A', 0x20, struct snd_pcm_status64) 1605235633Sdim#define SNDRV_PCM_IOCTL_STATUS_EXT64 _IOWR('A', 0x24, struct snd_pcm_status64) 1606235633Sdim 1607235633Sdimstruct snd_pcm_status32 { 1608235633Sdim snd_pcm_state_t state; /* stream state */ 1609235633Sdim s32 trigger_tstamp_sec; /* time when stream was started/stopped/paused */ 1610235633Sdim s32 trigger_tstamp_nsec; 1611210299Sed s32 tstamp_sec; /* reference timestamp */ 1612210299Sed s32 tstamp_nsec; 1613198090Srdivacky u32 appl_ptr; /* appl ptr */ 1614198090Srdivacky u32 hw_ptr; /* hw ptr */ 1615198090Srdivacky s32 delay; /* current delay in frames */ 1616193323Sed u32 avail; /* number of frames available */ 1617193323Sed u32 avail_max; /* max frames available on hw since last status */ 1618193323Sed u32 overrange; /* count of ADC (capture) overrange detections from last status */ 1619193323Sed snd_pcm_state_t suspended_state; /* suspended stream state */ 1620193323Sed u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */ 1621218893Sdim s32 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */ 1622218893Sdim s32 audio_tstamp_nsec; 1623206083Srdivacky s32 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */ 1624193323Sed s32 driver_tstamp_nsec; 1625193323Sed u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ 1626193323Sed unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */ 1627193323Sed}; 1628193323Sed 1629208599Srdivacky#define SNDRV_PCM_IOCTL_STATUS32 _IOR('A', 0x20, struct snd_pcm_status32) 1630208599Srdivacky#define SNDRV_PCM_IOCTL_STATUS_EXT32 _IOWR('A', 0x24, struct snd_pcm_status32) 1631208599Srdivacky 1632208599Srdivacky#endif /* __SOUND_PCM_H */ 1633193323Sed