Sound Open Firmware
Loading...
Searching...
No Matches
audio_stream_hw.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2020 - 2023 Intel Corporation. All rights reserved.
4 */
5
15#ifndef __SOF_AUDIO_AUDIO_STREAM_HW_H__
16#define __SOF_AUDIO_AUDIO_STREAM_HW_H__
17
19#include <stdint.h>
20
21#ifdef __ZEPHYR__
22
23#include <zephyr/drivers/dma.h>
24
30static inline void audio_stream_sync_to_hw(struct audio_stream *stream,
31 const struct dma_status *dma_status)
32{
33 uintptr_t buf_start = (uintptr_t)audio_stream_get_addr(stream);
34
35 /* Note: It is assumed here that dma_status values are reported as bytes. However,
36 * this is actually platform-specific. Although unlikely, they could be, for example,
37 * words on some particular platform, and changes should be made here to address
38 * such case.
39 */
40
41 assert(dma_status->write_position < audio_stream_get_size(stream));
42 assert(dma_status->read_position < audio_stream_get_size(stream));
43 assert(dma_status->pending_length <= audio_stream_get_size(stream));
44 assert(dma_status->free <= audio_stream_get_size(stream));
45
46 audio_stream_set_wptr(stream, (void *)(buf_start + dma_status->write_position));
47 audio_stream_set_rptr(stream, (void *)(buf_start + dma_status->read_position));
48 audio_stream_set_avail(stream, dma_status->pending_length);
49 audio_stream_set_free(stream, dma_status->free);
50}
51
52#endif /* __ZEPHYR__ */
53
54#endif /* __SOF_AUDIO_AUDIO_STREAM_HW_H__ */
static void audio_stream_sync_to_hw(struct audio_stream *stream, const struct dma_status *dma_status)
Replicates the hardware state of the DMA buffer as a struct audio_stream.
Definition audio_stream_hw.h:30
static void audio_stream_set_wptr(struct audio_stream *buf, void *val)
Definition audio_stream.h:154
static void audio_stream_set_rptr(struct audio_stream *buf, void *val)
Definition audio_stream.h:149
static void audio_stream_set_avail(struct audio_stream *buf, uint32_t val)
Definition audio_stream.h:174
static void audio_stream_set_free(struct audio_stream *buf, uint32_t val)
Definition audio_stream.h:179
static uint32_t audio_stream_get_size(const struct audio_stream *buf)
Definition audio_stream.h:99
static void * audio_stream_get_addr(const struct audio_stream *buf)
Definition audio_stream.h:94
#define assert(x)
Definition panic.h:19
Audio Stream API definition.
Audio stream is a circular buffer aware of audio format of the data in the buffer so provides API for...
Definition audio_stream.h:51
uint32_t free
Free bytes for writing.
Definition audio_stream.h:55