diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-30 10:02:50 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-10-30 10:42:27 -0400 |
commit | 30b771cf8c3120c5c946811ecc5a9b87a34003a2 (patch) | |
tree | 3883bd7d092e5a822759604e3e0b9ead40345334 /include/sound/pcm.h | |
parent | f213d8f79a3928eaa2e2936f8ab40761aac04b95 (diff) |
ALSA: pcm: More kerneldoc updates
Add proper kerneldoc comments to the exported functions.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/pcm.h')
-rw-r--r-- | include/sound/pcm.h | 160 |
1 files changed, 153 insertions, 7 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 5c3310d7d4b8..f78a5722f5cc 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -533,6 +533,12 @@ snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size) | |||
533 | * PCM library | 533 | * PCM library |
534 | */ | 534 | */ |
535 | 535 | ||
536 | /** | ||
537 | * snd_pcm_stream_linked - Check whether the substream is linked with others | ||
538 | * @substream: substream to check | ||
539 | * | ||
540 | * Returns true if the given substream is being linked with others. | ||
541 | */ | ||
536 | static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream) | 542 | static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream) |
537 | { | 543 | { |
538 | return substream->group != &substream->self_group; | 544 | return substream->group != &substream->self_group; |
@@ -543,6 +549,16 @@ void snd_pcm_stream_unlock(struct snd_pcm_substream *substream); | |||
543 | void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream); | 549 | void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream); |
544 | void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream); | 550 | void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream); |
545 | unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream); | 551 | unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream); |
552 | |||
553 | /** | ||
554 | * snd_pcm_stream_lock_irqsave - Lock the PCM stream | ||
555 | * @substream: PCM substream | ||
556 | * @flags: irq flags | ||
557 | * | ||
558 | * This locks the PCM stream like snd_pcm_stream_lock() but with the local | ||
559 | * IRQ (only when nonatomic is false). In nonatomic case, this is identical | ||
560 | * as snd_pcm_stream_lock(). | ||
561 | */ | ||
546 | #define snd_pcm_stream_lock_irqsave(substream, flags) \ | 562 | #define snd_pcm_stream_lock_irqsave(substream, flags) \ |
547 | do { \ | 563 | do { \ |
548 | typecheck(unsigned long, flags); \ | 564 | typecheck(unsigned long, flags); \ |
@@ -551,9 +567,25 @@ unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream); | |||
551 | void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, | 567 | void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, |
552 | unsigned long flags); | 568 | unsigned long flags); |
553 | 569 | ||
570 | /** | ||
571 | * snd_pcm_group_for_each_entry - iterate over the linked substreams | ||
572 | * @s: the iterator | ||
573 | * @substream: the substream | ||
574 | * | ||
575 | * Iterate over the all linked substreams to the given @substream. | ||
576 | * When @substream isn't linked with any others, this gives returns @substream | ||
577 | * itself once. | ||
578 | */ | ||
554 | #define snd_pcm_group_for_each_entry(s, substream) \ | 579 | #define snd_pcm_group_for_each_entry(s, substream) \ |
555 | list_for_each_entry(s, &substream->group->substreams, link_list) | 580 | list_for_each_entry(s, &substream->group->substreams, link_list) |
556 | 581 | ||
582 | /** | ||
583 | * snd_pcm_running - Check whether the substream is in a running state | ||
584 | * @substream: substream to check | ||
585 | * | ||
586 | * Returns true if the given substream is in the state RUNNING, or in the | ||
587 | * state DRAINING for playback. | ||
588 | */ | ||
557 | static inline int snd_pcm_running(struct snd_pcm_substream *substream) | 589 | static inline int snd_pcm_running(struct snd_pcm_substream *substream) |
558 | { | 590 | { |
559 | return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING || | 591 | return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING || |
@@ -561,45 +593,81 @@ static inline int snd_pcm_running(struct snd_pcm_substream *substream) | |||
561 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK)); | 593 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK)); |
562 | } | 594 | } |
563 | 595 | ||
596 | /** | ||
597 | * bytes_to_samples - Unit conversion of the size from bytes to samples | ||
598 | * @runtime: PCM runtime instance | ||
599 | * @size: size in bytes | ||
600 | */ | ||
564 | static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size) | 601 | static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size) |
565 | { | 602 | { |
566 | return size * 8 / runtime->sample_bits; | 603 | return size * 8 / runtime->sample_bits; |
567 | } | 604 | } |
568 | 605 | ||
606 | /** | ||
607 | * bytes_to_frames - Unit conversion of the size from bytes to frames | ||
608 | * @runtime: PCM runtime instance | ||
609 | * @size: size in bytes | ||
610 | */ | ||
569 | static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size) | 611 | static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size) |
570 | { | 612 | { |
571 | return size * 8 / runtime->frame_bits; | 613 | return size * 8 / runtime->frame_bits; |
572 | } | 614 | } |
573 | 615 | ||
616 | /** | ||
617 | * samples_to_bytes - Unit conversion of the size from samples to bytes | ||
618 | * @runtime: PCM runtime instance | ||
619 | * @size: size in samples | ||
620 | */ | ||
574 | static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size) | 621 | static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size) |
575 | { | 622 | { |
576 | return size * runtime->sample_bits / 8; | 623 | return size * runtime->sample_bits / 8; |
577 | } | 624 | } |
578 | 625 | ||
626 | /** | ||
627 | * frames_to_bytes - Unit conversion of the size from frames to bytes | ||
628 | * @runtime: PCM runtime instance | ||
629 | * @size: size in frames | ||
630 | */ | ||
579 | static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size) | 631 | static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size) |
580 | { | 632 | { |
581 | return size * runtime->frame_bits / 8; | 633 | return size * runtime->frame_bits / 8; |
582 | } | 634 | } |
583 | 635 | ||
636 | /** | ||
637 | * frame_aligned - Check whether the byte size is aligned to frames | ||
638 | * @runtime: PCM runtime instance | ||
639 | * @bytes: size in bytes | ||
640 | */ | ||
584 | static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes) | 641 | static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes) |
585 | { | 642 | { |
586 | return bytes % runtime->byte_align == 0; | 643 | return bytes % runtime->byte_align == 0; |
587 | } | 644 | } |
588 | 645 | ||
646 | /** | ||
647 | * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes | ||
648 | * @substream: PCM substream | ||
649 | */ | ||
589 | static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream) | 650 | static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream) |
590 | { | 651 | { |
591 | struct snd_pcm_runtime *runtime = substream->runtime; | 652 | struct snd_pcm_runtime *runtime = substream->runtime; |
592 | return frames_to_bytes(runtime, runtime->buffer_size); | 653 | return frames_to_bytes(runtime, runtime->buffer_size); |
593 | } | 654 | } |
594 | 655 | ||
656 | /** | ||
657 | * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes | ||
658 | * @substream: PCM substream | ||
659 | */ | ||
595 | static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream) | 660 | static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream) |
596 | { | 661 | { |
597 | struct snd_pcm_runtime *runtime = substream->runtime; | 662 | struct snd_pcm_runtime *runtime = substream->runtime; |
598 | return frames_to_bytes(runtime, runtime->period_size); | 663 | return frames_to_bytes(runtime, runtime->period_size); |
599 | } | 664 | } |
600 | 665 | ||
601 | /* | 666 | /** |
602 | * result is: 0 ... (boundary - 1) | 667 | * snd_pcm_playback_avail - Get the available (writable) space for playback |
668 | * @runtime: PCM runtime instance | ||
669 | * | ||
670 | * Result is between 0 ... (boundary - 1) | ||
603 | */ | 671 | */ |
604 | static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime) | 672 | static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime) |
605 | { | 673 | { |
@@ -611,8 +679,11 @@ static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *r | |||
611 | return avail; | 679 | return avail; |
612 | } | 680 | } |
613 | 681 | ||
614 | /* | 682 | /** |
615 | * result is: 0 ... (boundary - 1) | 683 | * snd_pcm_playback_avail - Get the available (readable) space for capture |
684 | * @runtime: PCM runtime instance | ||
685 | * | ||
686 | * Result is between 0 ... (boundary - 1) | ||
616 | */ | 687 | */ |
617 | static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime) | 688 | static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime) |
618 | { | 689 | { |
@@ -622,11 +693,19 @@ static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *ru | |||
622 | return avail; | 693 | return avail; |
623 | } | 694 | } |
624 | 695 | ||
696 | /** | ||
697 | * snd_pcm_playback_hw_avail - Get the queued space for playback | ||
698 | * @runtime: PCM runtime instance | ||
699 | */ | ||
625 | static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime) | 700 | static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime) |
626 | { | 701 | { |
627 | return runtime->buffer_size - snd_pcm_playback_avail(runtime); | 702 | return runtime->buffer_size - snd_pcm_playback_avail(runtime); |
628 | } | 703 | } |
629 | 704 | ||
705 | /** | ||
706 | * snd_pcm_capture_hw_avail - Get the free space for capture | ||
707 | * @runtime: PCM runtime instance | ||
708 | */ | ||
630 | static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime) | 709 | static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime) |
631 | { | 710 | { |
632 | return runtime->buffer_size - snd_pcm_capture_avail(runtime); | 711 | return runtime->buffer_size - snd_pcm_capture_avail(runtime); |
@@ -706,6 +785,20 @@ static inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream) | |||
706 | return snd_pcm_capture_avail(runtime) == 0; | 785 | return snd_pcm_capture_avail(runtime) == 0; |
707 | } | 786 | } |
708 | 787 | ||
788 | /** | ||
789 | * snd_pcm_trigger_done - Mark the master substream | ||
790 | * @substream: the pcm substream instance | ||
791 | * @master: the linked master substream | ||
792 | * | ||
793 | * When multiple substreams of the same card are linked and the hardware | ||
794 | * supports the single-shot operation, the driver calls this in the loop | ||
795 | * in snd_pcm_group_for_each_entry() for marking the substream as "done". | ||
796 | * Then most of trigger operations are performed only to the given master | ||
797 | * substream. | ||
798 | * | ||
799 | * The trigger_master mark is cleared at timestamp updates at the end | ||
800 | * of trigger operations. | ||
801 | */ | ||
709 | static inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream, | 802 | static inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream, |
710 | struct snd_pcm_substream *master) | 803 | struct snd_pcm_substream *master) |
711 | { | 804 | { |
@@ -881,6 +974,14 @@ unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit); | |||
881 | unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a, | 974 | unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a, |
882 | unsigned int rates_b); | 975 | unsigned int rates_b); |
883 | 976 | ||
977 | /** | ||
978 | * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer | ||
979 | * @substream: PCM substream to set | ||
980 | * @bufp: the buffer information, NULL to clear | ||
981 | * | ||
982 | * Copy the buffer information to runtime->dma_buffer when @bufp is non-NULL. | ||
983 | * Otherwise it clears the current buffer information. | ||
984 | */ | ||
884 | static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream, | 985 | static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream, |
885 | struct snd_dma_buffer *bufp) | 986 | struct snd_dma_buffer *bufp) |
886 | { | 987 | { |
@@ -906,6 +1007,11 @@ void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream); | |||
906 | void snd_pcm_timer_init(struct snd_pcm_substream *substream); | 1007 | void snd_pcm_timer_init(struct snd_pcm_substream *substream); |
907 | void snd_pcm_timer_done(struct snd_pcm_substream *substream); | 1008 | void snd_pcm_timer_done(struct snd_pcm_substream *substream); |
908 | 1009 | ||
1010 | /** | ||
1011 | * snd_pcm_gettime - Fill the timespec depending on the timestamp mode | ||
1012 | * @runtime: PCM runtime instance | ||
1013 | * @tv: timespec to fill | ||
1014 | */ | ||
909 | static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime, | 1015 | static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime, |
910 | struct timespec *tv) | 1016 | struct timespec *tv) |
911 | { | 1017 | { |
@@ -997,18 +1103,35 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, | |||
997 | #define snd_pcm_sgbuf_ops_page NULL | 1103 | #define snd_pcm_sgbuf_ops_page NULL |
998 | #endif /* SND_DMA_SGBUF */ | 1104 | #endif /* SND_DMA_SGBUF */ |
999 | 1105 | ||
1106 | /** | ||
1107 | * snd_pcm_sgbuf_get_addr - Get the DMA address at the corresponding offset | ||
1108 | * @substream: PCM substream | ||
1109 | * @ofs: byte offset | ||
1110 | */ | ||
1000 | static inline dma_addr_t | 1111 | static inline dma_addr_t |
1001 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) | 1112 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) |
1002 | { | 1113 | { |
1003 | return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs); | 1114 | return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs); |
1004 | } | 1115 | } |
1005 | 1116 | ||
1117 | /** | ||
1118 | * snd_pcm_sgbuf_get_ptr - Get the virtual address at the corresponding offset | ||
1119 | * @substream: PCM substream | ||
1120 | * @ofs: byte offset | ||
1121 | */ | ||
1006 | static inline void * | 1122 | static inline void * |
1007 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) | 1123 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) |
1008 | { | 1124 | { |
1009 | return snd_sgbuf_get_ptr(snd_pcm_get_dma_buf(substream), ofs); | 1125 | return snd_sgbuf_get_ptr(snd_pcm_get_dma_buf(substream), ofs); |
1010 | } | 1126 | } |
1011 | 1127 | ||
1128 | /** | ||
1129 | * snd_pcm_sgbuf_chunk_size - Compute the max size that fits within the contig. | ||
1130 | * page from the given size | ||
1131 | * @substream: PCM substream | ||
1132 | * @ofs: byte offset | ||
1133 | * @size: byte size to examine | ||
1134 | */ | ||
1012 | static inline unsigned int | 1135 | static inline unsigned int |
1013 | snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | 1136 | snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, |
1014 | unsigned int ofs, unsigned int size) | 1137 | unsigned int ofs, unsigned int size) |
@@ -1016,13 +1139,24 @@ snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | |||
1016 | return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size); | 1139 | return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size); |
1017 | } | 1140 | } |
1018 | 1141 | ||
1019 | /* handle mmap counter - PCM mmap callback should handle this counter properly */ | 1142 | /** |
1143 | * snd_pcm_mmap_data_open - increase the mmap counter | ||
1144 | * @area: VMA | ||
1145 | * | ||
1146 | * PCM mmap callback should handle this counter properly | ||
1147 | */ | ||
1020 | static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) | 1148 | static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) |
1021 | { | 1149 | { |
1022 | struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; | 1150 | struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; |
1023 | atomic_inc(&substream->mmap_count); | 1151 | atomic_inc(&substream->mmap_count); |
1024 | } | 1152 | } |
1025 | 1153 | ||
1154 | /** | ||
1155 | * snd_pcm_mmap_data_close - decrease the mmap counter | ||
1156 | * @area: VMA | ||
1157 | * | ||
1158 | * PCM mmap callback should handle this counter properly | ||
1159 | */ | ||
1026 | static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area) | 1160 | static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area) |
1027 | { | 1161 | { |
1028 | struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; | 1162 | struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; |
@@ -1042,6 +1176,11 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_s | |||
1042 | 1176 | ||
1043 | #define snd_pcm_lib_mmap_vmalloc NULL | 1177 | #define snd_pcm_lib_mmap_vmalloc NULL |
1044 | 1178 | ||
1179 | /** | ||
1180 | * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer | ||
1181 | * @dma: DMA number | ||
1182 | * @max: pointer to store the max size | ||
1183 | */ | ||
1045 | static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max) | 1184 | static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max) |
1046 | { | 1185 | { |
1047 | *max = dma < 4 ? 64 * 1024 : 128 * 1024; | 1186 | *max = dma < 4 ? 64 * 1024 : 128 * 1024; |
@@ -1094,7 +1233,11 @@ struct snd_pcm_chmap { | |||
1094 | void *private_data; /* optional: private data pointer */ | 1233 | void *private_data; /* optional: private data pointer */ |
1095 | }; | 1234 | }; |
1096 | 1235 | ||
1097 | /* get the PCM substream assigned to the given chmap info */ | 1236 | /** |
1237 | * snd_pcm_chmap_substream - get the PCM substream assigned to the given chmap info | ||
1238 | * @info: chmap information | ||
1239 | * @idx: the substream number index | ||
1240 | */ | ||
1098 | static inline struct snd_pcm_substream * | 1241 | static inline struct snd_pcm_substream * |
1099 | snd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx) | 1242 | snd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx) |
1100 | { | 1243 | { |
@@ -1121,7 +1264,10 @@ int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, | |||
1121 | unsigned long private_value, | 1264 | unsigned long private_value, |
1122 | struct snd_pcm_chmap **info_ret); | 1265 | struct snd_pcm_chmap **info_ret); |
1123 | 1266 | ||
1124 | /* Strong-typed conversion of pcm_format to bitwise */ | 1267 | /** |
1268 | * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise | ||
1269 | * @pcm_format: PCM format | ||
1270 | */ | ||
1125 | static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) | 1271 | static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) |
1126 | { | 1272 | { |
1127 | return 1ULL << (__force int) pcm_format; | 1273 | return 1ULL << (__force int) pcm_format; |