Skip to content

Commit 1045847

Browse files
committed
dai: turn dai_get_device() into a syscall
Make dai_get_device() a syscall, so it can be called from user-space threads. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent e3246b8 commit 1045847

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/include/sof/lib/dai-zephyr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ void dai_release_llp_slot(struct dai_data *dd);
309309
/**
310310
* \brief Retrieve a pointer to the Zephyr device structure for a DAI of a given type and index.
311311
*/
312-
const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index);
312+
__syscall const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index);
313313

314314
/**
315315
* \brief Retrieve the list of all DAI devices.
@@ -319,4 +319,6 @@ const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index);
319319
const struct device **dai_get_device_list(size_t *count);
320320
/** @}*/
321321

322+
#include <zephyr/syscalls/dai-zephyr.h>
323+
322324
#endif /* __SOF_LIB_DAI_ZEPHYR_H__ */

src/lib/dai.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int sof_dai_type_to_zephyr(uint32_t type)
243243
}
244244
}
245245

246-
const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index)
246+
const struct device *z_impl_dai_get_device(enum sof_ipc_dai_type type, uint32_t index)
247247
{
248248
struct dai_config cfg;
249249
int z_type;

zephyr/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/audio/module_adapter/module/ge
622622
zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/lib/fast-get.h)
623623
zephyr_syscall_header(include/rtos/alloc.h)
624624
zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_INTERFACE_ALLOC syscall/alloc.c)
625+
zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/lib/dai-zephyr.h)
626+
zephyr_library_sources_ifdef(CONFIG_USERSPACE syscall/dai.c)
625627

626628
zephyr_library_link_libraries(SOF)
627629
target_link_libraries(SOF INTERFACE zephyr_interface)

zephyr/syscall/dai.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
//
3+
// Copyright(c) 2026 Intel Corporation.
4+
5+
#include <sof/lib/dai.h>
6+
#include <zephyr/kernel.h>
7+
#include <zephyr/internal/syscall_handler.h>
8+
9+
static inline const struct device *z_vrfy_dai_get_device(enum sof_ipc_dai_type type,
10+
uint32_t index)
11+
{
12+
const struct device *dev = z_impl_dai_get_device(type, index);
13+
14+
if (dev && !k_object_is_valid(dev, K_OBJ_DRIVER_DAI))
15+
return NULL;
16+
17+
return dev;
18+
}
19+
#include <zephyr/syscalls/dai_get_device_mrsh.c>

0 commit comments

Comments
 (0)