Changeset 772 for GPL/trunk/alsa-kernel/include/sound/pcm.h
- Timestamp:
- Apr 19, 2025, 8:08:37 PM (5 months ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-6.6-LTS (added) merged: 765,768-769 /GPL/branches/uniaud32-exp (added) merged: 735-741,743-744,748-751,753-760,762-764 /GPL/branches/uniaud32-next merged: 718-734
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/include/sound/pcm.h
r717 r772 17 17 #include <linux/pm_qos.h> 18 18 #include <linux/refcount.h> 19 #include <linux/uio.h> 19 20 20 21 #define snd_pcm_substream_chip(substream) ((substream)->private_data) … … 47 48 struct snd_pcm_status64; 48 49 struct snd_pcm_substream; 49 50 50 struct snd_pcm_audio_tstamp_config; /* definitions further down */ 51 51 struct snd_pcm_audio_tstamp_report; … … 69 69 int (*fill_silence)(struct snd_pcm_substream *substream, int channel, 70 70 unsigned long pos, unsigned long bytes); 71 int (*copy_user)(struct snd_pcm_substream *substream, int channel, 72 unsigned long pos, void __user *buf, 73 unsigned long bytes); 74 int (*copy_kernel)(struct snd_pcm_substream *substream, int channel, 75 unsigned long pos, void *buf, unsigned long bytes); 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 76 78 struct page *(*page)(struct snd_pcm_substream *substream, 77 79 unsigned long offset); … … 107 109 108 110 /* 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 */ 127 129 128 130 #define SNDRV_PCM_RATE_8000_44100 (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\ … … 148 150 #define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE) 149 151 #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. 150 155 #define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE) 151 156 #define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE) … … 344 349 struct snd_pcm_runtime { 345 350 /* -- Status -- */ 351 snd_pcm_state_t state; /* stream state */ 352 snd_pcm_state_t suspended_state; /* suspended stream state */ 346 353 struct snd_pcm_substream *trigger_master; 347 354 struct timespec64 trigger_tstamp; /* trigger timestamp */ … … 374 381 unsigned int no_period_wakeup: 1; 375 382 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; 378 385 unsigned int period_step; 379 386 snd_pcm_uframes_t start_threshold; 380 387 snd_pcm_uframes_t stop_threshold; 381 snd_pcm_uframes_t silence_threshold; /* Silence filling happens when382 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 */ 386 393 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 */ 388 395 389 396 union snd_pcm_sync_id sync; /* hardware synchronization ID */ … … 397 404 wait_queue_head_t sleep; /* poll sleep */ 398 405 wait_queue_head_t tsleep; /* transfer sleep */ 399 struct fasync_struct*fasync;406 struct snd_fasync *fasync; 400 407 bool stop_operating; /* sync_stop will be called */ 401 408 struct mutex buffer_mutex; /* protect for buffer changes */ … … 506 513 #endif 507 514 struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */ 508 struct device dev;515 struct device *dev; 509 516 }; 510 517 … … 605 612 * @substream: substream to check 606 613 * 607 * Return s true if the given substream is being linked with others.614 * Return: true if the given substream is being linked with others 608 615 */ 609 616 static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream) … … 617 624 void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream); 618 625 unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream); 626 unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream); 619 627 620 628 /** … … 643 651 644 652 /** 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 /** 645 667 * snd_pcm_group_for_each_entry - iterate over the linked substreams 646 668 * @s: the iterator … … 663 685 * @substream: substream to check 664 686 * 665 * Return strue if the given substream is in the state RUNNING, or in the687 * Return: true if the given substream is in the state RUNNING, or in the 666 688 * state DRAINING for playback. 667 689 */ 668 690 static inline int snd_pcm_running(struct snd_pcm_substream *substream) 669 691 { 670 return (substream->runtime->stat us->state == SNDRV_PCM_STATE_RUNNING ||671 (substream->runtime->stat us->state == SNDRV_PCM_STATE_DRAINING &&692 return (substream->runtime->state == SNDRV_PCM_STATE_RUNNING || 693 (substream->runtime->state == SNDRV_PCM_STATE_DRAINING && 672 694 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 */ 704 static 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 */ 673 709 } 674 710 … … 677 713 * @runtime: PCM runtime instance 678 714 * @size: size in bytes 715 * 716 * Return: the size in samples 679 717 */ 680 718 static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size) … … 687 725 * @runtime: PCM runtime instance 688 726 * @size: size in bytes 727 * 728 * Return: the size in frames 689 729 */ 690 730 static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size) … … 697 737 * @runtime: PCM runtime instance 698 738 * @size: size in samples 739 * 740 * Return: the byte size 699 741 */ 700 742 static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size) … … 707 749 * @runtime: PCM runtime instance 708 750 * @size: size in frames 751 * 752 * Return: the byte size 709 753 */ 710 754 static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size) … … 717 761 * @runtime: PCM runtime instance 718 762 * @bytes: size in bytes 763 * 764 * Return: true if aligned, or false if not 719 765 */ 720 766 static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes) … … 726 772 * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes 727 773 * @substream: PCM substream 774 * 775 * Return: buffer byte size 728 776 */ 729 777 static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream) … … 736 784 * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes 737 785 * @substream: PCM substream 786 * 787 * Return: period byte size 738 788 */ 739 789 static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream) … … 748 798 * 749 799 * Result is between 0 ... (boundary - 1) 800 * 801 * Return: available frame size 750 802 */ 751 803 static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime) … … 777 829 * 778 830 * Result is between 0 ... (boundary - 1) 831 * 832 * Return: available frame size 779 833 */ 780 834 static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime) … … 789 843 * snd_pcm_playback_hw_avail - Get the queued space for playback 790 844 * @runtime: PCM runtime instance 845 * 846 * Return: available frame size 791 847 */ 792 848 static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime) … … 798 854 * snd_pcm_capture_hw_avail - Get the free space for capture 799 855 * @runtime: PCM runtime instance 856 * 857 * Return: available frame size 800 858 */ 801 859 static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime) … … 937 995 * params_channels - Get the number of channels from the hw params 938 996 * @p: hw params 997 * 998 * Return: the number of channels 939 999 */ 940 1000 static inline unsigned int params_channels(const struct snd_pcm_hw_params *p) … … 946 1006 * params_rate - Get the sample rate from the hw params 947 1007 * @p: hw params 1008 * 1009 * Return: the sample rate 948 1010 */ 949 1011 static inline unsigned int params_rate(const struct snd_pcm_hw_params *p) … … 955 1017 * params_period_size - Get the period size (in frames) from the hw params 956 1018 * @p: hw params 1019 * 1020 * Return: the period size in frames 957 1021 */ 958 1022 static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p) … … 964 1028 * params_periods - Get the number of periods from the hw params 965 1029 * @p: hw params 1030 * 1031 * Return: the number of periods 966 1032 */ 967 1033 static inline unsigned int params_periods(const struct snd_pcm_hw_params *p) … … 973 1039 * params_buffer_size - Get the buffer size (in frames) from the hw params 974 1040 * @p: hw params 1041 * 1042 * Return: the buffer size in frames 975 1043 */ 976 1044 static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p) … … 982 1050 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params 983 1051 * @p: hw params 1052 * 1053 * Return: the buffer size in bytes 984 1054 */ 985 1055 static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p) … … 1244 1314 * allocation of a larger buffer unlike the standard one. 1245 1315 * The function may return -ENOMEM error, hence the caller must check it. 1316 * 1317 * Return: zero if successful, or a negative error code 1246 1318 */ 1247 1319 static inline int __must_check … … 1262 1334 * all substream. If any of allocation fails, it returns -ENOMEM, hence the 1263 1335 * caller must check the return value. 1336 * 1337 * Return: zero if successful, or a negative error code 1264 1338 */ 1265 1339 static inline int __must_check … … 1318 1392 * @substream: PCM substream 1319 1393 * @ofs: byte offset 1394 * 1395 * Return: DMA address 1320 1396 */ 1321 1397 static inline dma_addr_t … … 1331 1407 * @ofs: byte offset 1332 1408 * @size: byte size to examine 1409 * 1410 * Return: chunk size 1333 1411 */ 1334 1412 static inline unsigned int … … 1396 1474 1397 1475 /** 1398 * snd_pcm_ stream_str- Get a string naming the direction of a stream1399 * @ substream: the pcm substream instance1400 * 1401 * Return : Astring 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 */ 1481 static inline const char *snd_pcm_direction_name(int direction) 1482 { 1483 if (direction == SNDRV_PCM_STREAM_PLAYBACK) 1406 1484 return "Playback"; 1407 1485 else 1408 1486 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 */ 1495 static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream) 1496 { 1497 return snd_pcm_direction_name(substream->stream); 1409 1498 } 1410 1499 … … 1433 1522 * @info: chmap information 1434 1523 * @idx: the substream number index 1524 * 1525 * Return: the matched PCM substream, or NULL if not found 1435 1526 */ 1436 1527 static inline struct snd_pcm_substream * … … 1463 1554 * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise 1464 1555 * @pcm_format: PCM format 1556 * 1557 * Return: 64bit mask corresponding to the given PCM format 1465 1558 */ 1466 1559 static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) … … 1491 1584 int pcm_dbg(struct snd_pcm *dev, const char *fmt, ...); 1492 1585 #endif 1586 1587 /* helpers for copying between iov_iter and iomem */ 1588 int copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src, 1589 size_t count); 1590 int copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count); 1493 1591 1494 1592 struct snd_pcm_status64 {
Note:
See TracChangeset
for help on using the changeset viewer.