Skip to content

Commit 928dd0b

Browse files
lrgirdwoclaude
andcommitted
audio: split the kernel part of intel_uaol.c into src/kernel/audio
The UAOL feedback support made intel_uaol.c mixed: the DAI component calls the UAOL feedback, rate adjustment and feedback DMA functions from the user-space LL thread, while the base firmware queries the UAOL capabilities and stream mapping in kernel mode. Move the kernel part, tlv_value_set_uaol_caps() and uaol_stream_id_to_hda_link_stream_id(), with the IPC4 UAOL capabilities structures, to src/kernel/audio/intel_uaol-kernel.c. intel_uaol.c keeps the code that runs in the LL thread, including the UAOL device table and its lookup, get_uaol_zdevice(). The table is in rodata, readable from user space. It is no longer static: it is declared in sof/audio/intel_uaol.h, sized from the devicetree, so the kernel queries keep using ARRAY_SIZE() on it. intel_uaol.c is user code now, so drop it from the kernel sources listed under src/audio in the kernel include checker's manifest. The kernel part is built with the same condition as intel_uaol.c. The code is unchanged, but the two kernel queries now load the device from the table: with a single UAOL device, the compiler had reduced the static table to a constant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent a5bfec2 commit 928dd0b

5 files changed

Lines changed: 91 additions & 63 deletions

File tree

‎scripts/kernel_user_partition.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ src/lib/objpool.c
3030
[not-user-sources]
3131
src/audio/dai-legacy.c
3232
src/audio/host-legacy.c
33-
src/audio/intel_uaol.c
3433

3534
# SOF headers that only kernel code may include.
3635
# Not listed on purpose: rtos/init.h, which only provides the

‎src/audio/intel_uaol.c‎

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -14,74 +14,16 @@
1414

1515
LOG_MODULE_REGISTER(uaol, CONFIG_SOF_LOG_LEVEL);
1616

17-
struct ipc4_uaol_link_capabilities {
18-
uint32_t input_streams_supported : 4;
19-
uint32_t output_streams_supported : 4;
20-
uint32_t bidirectional_streams_supported : 5;
21-
uint32_t rsvd : 19;
22-
uint32_t max_tx_fifo_size;
23-
uint32_t max_rx_fifo_size;
24-
} __packed __aligned(4);
25-
26-
struct ipc4_uaol_capabilities {
27-
uint32_t link_count;
28-
struct ipc4_uaol_link_capabilities link_caps[];
29-
} __packed __aligned(4);
17+
/* The UAOL capabilities and stream mapping queries of the base firmware, which run in
18+
* kernel mode, are in src/kernel/audio/intel_uaol-kernel.c
19+
*/
3020

3121
#define DEV_AND_COMMA(node) DEVICE_DT_GET(node),
3222
/* const pointers keep the array in rodata, readable by the user-space LL thread */
33-
static const struct device *const uaol_devs[] = {
23+
const struct device *const uaol_devs[] = {
3424
DT_FOREACH_STATUS_OKAY(intel_adsp_uaol, DEV_AND_COMMA)
3525
};
3626

37-
#if !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY
38-
__cold void tlv_value_set_uaol_caps(struct sof_tlv *tuple, uint32_t type)
39-
{
40-
const size_t dev_count = ARRAY_SIZE(uaol_devs);
41-
struct uaol_capabilities dev_cap;
42-
struct ipc4_uaol_capabilities *caps = (struct ipc4_uaol_capabilities *)tuple->value;
43-
size_t caps_size = offsetof(struct ipc4_uaol_capabilities, link_caps[dev_count]);
44-
size_t i;
45-
int ret;
46-
47-
assert_can_be_cold();
48-
49-
memset(caps, 0, caps_size);
50-
51-
caps->link_count = dev_count;
52-
for (i = 0; i < dev_count; i++) {
53-
ret = uaol_get_capabilities(uaol_devs[i], &dev_cap);
54-
if (ret)
55-
continue;
56-
57-
caps->link_caps[i].input_streams_supported = dev_cap.input_streams;
58-
caps->link_caps[i].output_streams_supported = dev_cap.output_streams;
59-
caps->link_caps[i].bidirectional_streams_supported = dev_cap.bidirectional_streams;
60-
caps->link_caps[i].max_tx_fifo_size = dev_cap.max_tx_fifo_size;
61-
caps->link_caps[i].max_rx_fifo_size = dev_cap.max_rx_fifo_size;
62-
}
63-
64-
tlv_value_set(tuple, type, caps_size, caps);
65-
}
66-
#endif /* !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY */
67-
68-
__cold int uaol_stream_id_to_hda_link_stream_id(int uaol_stream_id)
69-
{
70-
size_t dev_count = ARRAY_SIZE(uaol_devs);
71-
size_t i;
72-
73-
assert_can_be_cold();
74-
75-
for (i = 0; i < dev_count; i++) {
76-
int hda_link_stream_id = uaol_get_mapped_hda_link_stream_id(uaol_devs[i],
77-
uaol_stream_id);
78-
if (hda_link_stream_id >= 0)
79-
return hda_link_stream_id;
80-
}
81-
82-
return -1;
83-
}
84-
8527
const struct device *get_uaol_zdevice(int uaol_link_id)
8628
{
8729
/* uaol_link_id is just an index for the device tree device */

‎src/include/sof/audio/intel_uaol.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <stdint.h>
1010
#include <sof/lib/memory.h>
11+
#include <zephyr/devicetree.h>
1112

1213
struct sof_tlv;
1314
struct device;
@@ -20,6 +21,11 @@ __cold int uaol_stream_id_to_hda_link_stream_id(int uaol_stream_id);
2021

2122
const struct device *get_uaol_zdevice(int uaol_link_id);
2223

24+
#if CONFIG_UAOL_INTEL_ADSP
25+
/* UAOL devices, defined in intel_uaol.c. In rodata, readable from user space. */
26+
extern const struct device *const uaol_devs[DT_NUM_INST_STATUS_OKAY(intel_adsp_uaol)];
27+
#endif
28+
2329
/* these are called from dai-zephyr.c */
2430

2531
struct dai;

‎src/kernel/audio/CMakeLists.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ if(CONFIG_COMP_BASEFW_IPC4 AND NOT CONFIG_LIBRARY)
44
add_local_sources(sof base_fw.c)
55
endif()
66
add_local_sources_ifdef(CONFIG_IPC4_BASE_FW_INTEL sof base_fw_intel.c)
7+
# The kernel part of src/audio/intel_uaol.c, built with it
8+
add_local_sources_ifdef(CONFIG_UAOL_INTEL_ADSP sof intel_uaol-kernel.c)
79
if(CONFIG_INTEL_ADSP_MIC_PRIVACY)
810
add_subdirectory(mic_privacy_manager)
911
endif()
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright 2026 Intel Corporation. All rights reserved.
4+
*/
5+
6+
#include <zephyr/drivers/uaol.h>
7+
#include <zephyr/logging/log.h>
8+
#include <rtos/alloc.h>
9+
#include <rtos/string.h>
10+
#include <sof/tlv.h>
11+
#include <sof/lib/dai-zephyr.h>
12+
#include <sof/audio/intel_uaol.h>
13+
14+
/* Kernel part of the UAOL support: the UAOL capabilities and stream mapping queries of
15+
* the base firmware. The UAOL device table, its lookup and the UAOL feedback and rate
16+
* adjustment, which run in the LL thread, are in src/audio/intel_uaol.c
17+
*/
18+
19+
struct ipc4_uaol_link_capabilities {
20+
uint32_t input_streams_supported : 4;
21+
uint32_t output_streams_supported : 4;
22+
uint32_t bidirectional_streams_supported : 5;
23+
uint32_t rsvd : 19;
24+
uint32_t max_tx_fifo_size;
25+
uint32_t max_rx_fifo_size;
26+
} __packed __aligned(4);
27+
28+
struct ipc4_uaol_capabilities {
29+
uint32_t link_count;
30+
struct ipc4_uaol_link_capabilities link_caps[];
31+
} __packed __aligned(4);
32+
33+
#if !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY
34+
__cold void tlv_value_set_uaol_caps(struct sof_tlv *tuple, uint32_t type)
35+
{
36+
const size_t dev_count = ARRAY_SIZE(uaol_devs);
37+
struct uaol_capabilities dev_cap;
38+
struct ipc4_uaol_capabilities *caps = (struct ipc4_uaol_capabilities *)tuple->value;
39+
size_t caps_size = offsetof(struct ipc4_uaol_capabilities, link_caps[dev_count]);
40+
size_t i;
41+
int ret;
42+
43+
assert_can_be_cold();
44+
45+
memset(caps, 0, caps_size);
46+
47+
caps->link_count = dev_count;
48+
for (i = 0; i < dev_count; i++) {
49+
ret = uaol_get_capabilities(uaol_devs[i], &dev_cap);
50+
if (ret)
51+
continue;
52+
53+
caps->link_caps[i].input_streams_supported = dev_cap.input_streams;
54+
caps->link_caps[i].output_streams_supported = dev_cap.output_streams;
55+
caps->link_caps[i].bidirectional_streams_supported = dev_cap.bidirectional_streams;
56+
caps->link_caps[i].max_tx_fifo_size = dev_cap.max_tx_fifo_size;
57+
caps->link_caps[i].max_rx_fifo_size = dev_cap.max_rx_fifo_size;
58+
}
59+
60+
tlv_value_set(tuple, type, caps_size, caps);
61+
}
62+
#endif /* !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY */
63+
64+
__cold int uaol_stream_id_to_hda_link_stream_id(int uaol_stream_id)
65+
{
66+
size_t dev_count = ARRAY_SIZE(uaol_devs);
67+
size_t i;
68+
69+
assert_can_be_cold();
70+
71+
for (i = 0; i < dev_count; i++) {
72+
int hda_link_stream_id = uaol_get_mapped_hda_link_stream_id(uaol_devs[i],
73+
uaol_stream_id);
74+
if (hda_link_stream_id >= 0)
75+
return hda_link_stream_id;
76+
}
77+
78+
return -1;
79+
}

0 commit comments

Comments
 (0)