Ignore:
Timestamp:
Apr 19, 2025, 8:08:37 PM (5 months ago)
Author:
David Azarewicz
Message:

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

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

    r717 r772  
    1717#include <linux/pm_qos.h>
    1818#include <linux/refcount.h>
     19#include <linux/uio.h>
    1920
    2021#define snd_pcm_substream_chip(substream) ((substream)->private_data)
     
    4748struct snd_pcm_status64;
    4849struct snd_pcm_substream;
    49 
    5050struct snd_pcm_audio_tstamp_config; /* definitions further down */
    5151struct snd_pcm_audio_tstamp_report;
     
    6969        int (*fill_silence)(struct snd_pcm_substream *substream, int channel,
    7070                            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);
     71#ifndef TARGET_OS2
     72        int (*copy)(struct snd_pcm_substream *substream, int channel,
     73                    unsigned long pos, struct iov_iter *iter, unsigned long bytes);
     74#else
     75        int (*copy)(struct snd_pcm_substream *substream, int channel,
     76                    unsigned long pos, void *iter, unsigned long bytes);
     77#endif
    7678        struct page *(*page)(struct snd_pcm_substream *substream,
    7779                             unsigned long offset);
     
    107109
    108110/* If you change this don't forget to change rates[] table in pcm_native.c */
    109 #define SNDRV_PCM_RATE_5512             (1<<0)          /* 5512Hz */
    110 #define SNDRV_PCM_RATE_8000             (1<<1)          /* 8000Hz */
    111 #define SNDRV_PCM_RATE_11025            (1<<2)          /* 11025Hz */
    112 #define SNDRV_PCM_RATE_16000            (1<<3)          /* 16000Hz */
    113 #define SNDRV_PCM_RATE_22050            (1<<4)          /* 22050Hz */
    114 #define SNDRV_PCM_RATE_32000            (1<<5)          /* 32000Hz */
    115 #define SNDRV_PCM_RATE_44100            (1<<6)          /* 44100Hz */
    116 #define SNDRV_PCM_RATE_48000            (1<<7)          /* 48000Hz */
    117 #define SNDRV_PCM_RATE_64000            (1<<8)          /* 64000Hz */
    118 #define SNDRV_PCM_RATE_88200            (1<<9)          /* 88200Hz */
    119 #define SNDRV_PCM_RATE_96000            (1<<10)         /* 96000Hz */
    120 #define SNDRV_PCM_RATE_176400           (1<<11)         /* 176400Hz */
    121 #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 */
    124 
    125 #define SNDRV_PCM_RATE_CONTINUOUS       (1<<30)         /* continuous range */
    126 #define SNDRV_PCM_RATE_KNOT             (1<<31)         /* supports more non-continuos rates */
     111#define SNDRV_PCM_RATE_5512             (1U<<0)         /* 5512Hz */
     112#define SNDRV_PCM_RATE_8000             (1U<<1)         /* 8000Hz */
     113#define SNDRV_PCM_RATE_11025            (1U<<2)         /* 11025Hz */
     114#define SNDRV_PCM_RATE_16000            (1U<<3)         /* 16000Hz */
     115#define SNDRV_PCM_RATE_22050            (1U<<4)         /* 22050Hz */
     116#define SNDRV_PCM_RATE_32000            (1U<<5)         /* 32000Hz */
     117#define SNDRV_PCM_RATE_44100            (1U<<6)         /* 44100Hz */
     118#define SNDRV_PCM_RATE_48000            (1U<<7)         /* 48000Hz */
     119#define SNDRV_PCM_RATE_64000            (1U<<8)         /* 64000Hz */
     120#define SNDRV_PCM_RATE_88200            (1U<<9)         /* 88200Hz */
     121#define SNDRV_PCM_RATE_96000            (1U<<10)        /* 96000Hz */
     122#define SNDRV_PCM_RATE_176400           (1U<<11)        /* 176400Hz */
     123#define SNDRV_PCM_RATE_192000           (1U<<12)        /* 192000Hz */
     124#define SNDRV_PCM_RATE_352800           (1U<<13)        /* 352800Hz */
     125#define SNDRV_PCM_RATE_384000           (1U<<14)        /* 384000Hz */
     126
     127#define SNDRV_PCM_RATE_CONTINUOUS       (1U<<30)        /* continuous range */
     128#define SNDRV_PCM_RATE_KNOT             (1U<<31)        /* supports more non-continuos rates */
    127129
    128130#define SNDRV_PCM_RATE_8000_44100       (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\
     
    148150#define SNDRV_PCM_FMTBIT_U24_LE         _SNDRV_PCM_FMTBIT(U24_LE)
    149151#define SNDRV_PCM_FMTBIT_U24_BE         _SNDRV_PCM_FMTBIT(U24_BE)
     152// For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the
     153// available bit count in most significant bit. It's for the case of so-called 'left-justified' or
     154// `right-padding` sample which has less width than 32 bit.
    150155#define SNDRV_PCM_FMTBIT_S32_LE         _SNDRV_PCM_FMTBIT(S32_LE)
    151156#define SNDRV_PCM_FMTBIT_S32_BE         _SNDRV_PCM_FMTBIT(S32_BE)
     
    344349struct snd_pcm_runtime {
    345350        /* -- Status -- */
     351        snd_pcm_state_t state;          /* stream state */
     352        snd_pcm_state_t suspended_state; /* suspended stream state */
    346353        struct snd_pcm_substream *trigger_master;
    347354        struct timespec64 trigger_tstamp;       /* trigger timestamp */
     
    374381        unsigned int no_period_wakeup: 1;
    375382
    376         /* -- SW params -- */
    377         int tstamp_mode;                /* mmap timestamp is updated */
     383        /* -- SW params; see struct snd_pcm_sw_params for comments -- */
     384        int tstamp_mode;
    378385        unsigned int period_step;
    379386        snd_pcm_uframes_t start_threshold;
    380387        snd_pcm_uframes_t stop_threshold;
    381         snd_pcm_uframes_t silence_threshold; /* Silence filling happens when
    382                                                 noise is nearest than this */
    383         snd_pcm_uframes_t silence_size; /* Silence filling size */
    384         snd_pcm_uframes_t boundary;     /* pointers wrap point */
    385 
     388        snd_pcm_uframes_t silence_threshold;
     389        snd_pcm_uframes_t silence_size;
     390        snd_pcm_uframes_t boundary;
     391
     392        /* internal data of auto-silencer */
    386393        snd_pcm_uframes_t silence_start; /* starting pointer to silence area */
    387         snd_pcm_uframes_t silence_filled; /* size filled with silence */
     394        snd_pcm_uframes_t silence_filled; /* already filled part of silence area */
    388395
    389396        union snd_pcm_sync_id sync;     /* hardware synchronization ID */
     
    397404        wait_queue_head_t sleep;        /* poll sleep */
    398405        wait_queue_head_t tsleep;       /* transfer sleep */
    399         struct fasync_struct *fasync;
     406        struct snd_fasync *fasync;
    400407        bool stop_operating;            /* sync_stop will be called */
    401408        struct mutex buffer_mutex;      /* protect for buffer changes */
     
    506513#endif
    507514        struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */
    508         struct device dev;
     515        struct device *dev;
    509516};
    510517
     
    605612 * @substream: substream to check
    606613 *
    607  * Returns true if the given substream is being linked with others.
     614 * Return: true if the given substream is being linked with others
    608615 */
    609616static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream)
     
    617624void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);
    618625unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
     626unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream);
    619627
    620628/**
     
    643651
    644652/**
     653 * snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking
     654 * @substream: PCM substream
     655 * @flags: irq flags
     656 *
     657 * This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with
     658 * the single-depth lockdep subclass.
     659 */
     660#define snd_pcm_stream_lock_irqsave_nested(substream, flags)            \
     661        do {                                                            \
     662                typecheck(unsigned long, flags);                        \
     663                flags = _snd_pcm_stream_lock_irqsave_nested(substream); \
     664        } while (0)
     665
     666/**
    645667 * snd_pcm_group_for_each_entry - iterate over the linked substreams
    646668 * @s: the iterator
     
    663685 * @substream: substream to check
    664686 *
    665  * Returns true if the given substream is in the state RUNNING, or in the
     687 * Return: true if the given substream is in the state RUNNING, or in the
    666688 * state DRAINING for playback.
    667689 */
    668690static inline int snd_pcm_running(struct snd_pcm_substream *substream)
    669691{
    670         return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
    671                 (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
     692        return (substream->runtime->state == SNDRV_PCM_STATE_RUNNING ||
     693                (substream->runtime->state == SNDRV_PCM_STATE_DRAINING &&
    672694                 substream->stream == SNDRV_PCM_STREAM_PLAYBACK));
     695}
     696
     697/**
     698 * __snd_pcm_set_state - Change the current PCM state
     699 * @runtime: PCM runtime to set
     700 * @state: the current state to set
     701 *
     702 * Call within the stream lock
     703 */
     704static inline void __snd_pcm_set_state(struct snd_pcm_runtime *runtime,
     705                                       snd_pcm_state_t state)
     706{
     707        runtime->state = state;
     708        runtime->status->state = state; /* copy for mmap */
    673709}
    674710
     
    677713 * @runtime: PCM runtime instance
    678714 * @size: size in bytes
     715 *
     716 * Return: the size in samples
    679717 */
    680718static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size)
     
    687725 * @runtime: PCM runtime instance
    688726 * @size: size in bytes
     727 *
     728 * Return: the size in frames
    689729 */
    690730static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size)
     
    697737 * @runtime: PCM runtime instance
    698738 * @size: size in samples
     739 *
     740 * Return: the byte size
    699741 */
    700742static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size)
     
    707749 * @runtime: PCM runtime instance
    708750 * @size: size in frames
     751 *
     752 * Return: the byte size
    709753 */
    710754static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size)
     
    717761 * @runtime: PCM runtime instance
    718762 * @bytes: size in bytes
     763 *
     764 * Return: true if aligned, or false if not
    719765 */
    720766static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes)
     
    726772 * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes
    727773 * @substream: PCM substream
     774 *
     775 * Return: buffer byte size
    728776 */
    729777static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream)
     
    736784 * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes
    737785 * @substream: PCM substream
     786 *
     787 * Return: period byte size
    738788 */
    739789static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream)
     
    748798 *
    749799 * Result is between 0 ... (boundary - 1)
     800 *
     801 * Return: available frame size
    750802 */
    751803static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime)
     
    777829 *
    778830 * Result is between 0 ... (boundary - 1)
     831 *
     832 * Return: available frame size
    779833 */
    780834static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime)
     
    789843 * snd_pcm_playback_hw_avail - Get the queued space for playback
    790844 * @runtime: PCM runtime instance
     845 *
     846 * Return: available frame size
    791847 */
    792848static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime)
     
    798854 * snd_pcm_capture_hw_avail - Get the free space for capture
    799855 * @runtime: PCM runtime instance
     856 *
     857 * Return: available frame size
    800858 */
    801859static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime)
     
    937995 * params_channels - Get the number of channels from the hw params
    938996 * @p: hw params
     997 *
     998 * Return: the number of channels
    939999 */
    9401000static inline unsigned int params_channels(const struct snd_pcm_hw_params *p)
     
    9461006 * params_rate - Get the sample rate from the hw params
    9471007 * @p: hw params
     1008 *
     1009 * Return: the sample rate
    9481010 */
    9491011static inline unsigned int params_rate(const struct snd_pcm_hw_params *p)
     
    9551017 * params_period_size - Get the period size (in frames) from the hw params
    9561018 * @p: hw params
     1019 *
     1020 * Return: the period size in frames
    9571021 */
    9581022static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p)
     
    9641028 * params_periods - Get the number of periods from the hw params
    9651029 * @p: hw params
     1030 *
     1031 * Return: the number of periods
    9661032 */
    9671033static inline unsigned int params_periods(const struct snd_pcm_hw_params *p)
     
    9731039 * params_buffer_size - Get the buffer size (in frames) from the hw params
    9741040 * @p: hw params
     1041 *
     1042 * Return: the buffer size in frames
    9751043 */
    9761044static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p)
     
    9821050 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params
    9831051 * @p: hw params
     1052 *
     1053 * Return: the buffer size in bytes
    9841054 */
    9851055static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p)
     
    12441314 * allocation of a larger buffer unlike the standard one.
    12451315 * The function may return -ENOMEM error, hence the caller must check it.
     1316 *
     1317 * Return: zero if successful, or a negative error code
    12461318 */
    12471319static inline int __must_check
     
    12621334 * all substream.  If any of allocation fails, it returns -ENOMEM, hence the
    12631335 * caller must check the return value.
     1336 *
     1337 * Return: zero if successful, or a negative error code
    12641338 */
    12651339static inline int __must_check
     
    13181392 * @substream: PCM substream
    13191393 * @ofs: byte offset
     1394 *
     1395 * Return: DMA address
    13201396 */
    13211397static inline dma_addr_t
     
    13311407 * @ofs: byte offset
    13321408 * @size: byte size to examine
     1409 *
     1410 * Return: chunk size
    13331411 */
    13341412static inline unsigned int
     
    13961474
    13971475/**
    1398  * snd_pcm_stream_str - Get a string naming the direction of a stream
    1399  * @substream: the pcm substream instance
    1400  *
    1401  * Return: A string naming the direction of the stream.
    1402  */
    1403 static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
    1404 {
    1405         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
     1476 * snd_pcm_direction_name - Get a string naming the direction of a stream
     1477 * @direction: Stream's direction, one of SNDRV_PCM_STREAM_XXX
     1478 *
     1479 * Returns a string naming the direction of the stream.
     1480 */
     1481static inline const char *snd_pcm_direction_name(int direction)
     1482{
     1483        if (direction == SNDRV_PCM_STREAM_PLAYBACK)
    14061484                return "Playback";
    14071485        else
    14081486                return "Capture";
     1487}
     1488
     1489/**
     1490 * snd_pcm_stream_str - Get a string naming the direction of a stream
     1491 * @substream: the pcm substream instance
     1492 *
     1493 * Return: A string naming the direction of the stream.
     1494 */
     1495static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
     1496{
     1497        return snd_pcm_direction_name(substream->stream);
    14091498}
    14101499
     
    14331522 * @info: chmap information
    14341523 * @idx: the substream number index
     1524 *
     1525 * Return: the matched PCM substream, or NULL if not found
    14351526 */
    14361527static inline struct snd_pcm_substream *
     
    14631554 * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise
    14641555 * @pcm_format: PCM format
     1556 *
     1557 * Return: 64bit mask corresponding to the given PCM format
    14651558 */
    14661559static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
     
    14911584int pcm_dbg(struct snd_pcm *dev, const char *fmt, ...);
    14921585#endif
     1586
     1587/* helpers for copying between iov_iter and iomem */
     1588int copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src,
     1589                        size_t count);
     1590int copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count);
    14931591
    14941592struct snd_pcm_status64 {
Note: See TracChangeset for help on using the changeset viewer.