From a0cef35d865798a8536c53fadfd14154f7bd6336 Mon Sep 17 00:00:00 2001 From: "Dobrowolski, PawelX" Date: Mon, 12 Feb 2024 15:23:12 +0100 Subject: [PATCH] lmdk: headers manifest Added manifest file of all neccesary headers to build independently loadable modules. Added also python script for parsing json manifest and copping them to separate location for packaging purpouses. Signed-off-by: Dobrowolski, PawelX --- lmdk/include/headers_list.json | 23 ++ lmdk/include/ipc4 | 218 +++++++++++++++++++ lmdk/src/include/ipc4/header.h | 218 +++++++++++++++++++ lmdk/src/include/module/audio/audio_stream.h | 54 +++++ scripts/lmdk/tools/header_pack.py | 26 +++ 5 files changed, 539 insertions(+) create mode 100644 lmdk/include/headers_list.json create mode 100644 lmdk/include/ipc4 create mode 100644 lmdk/src/include/ipc4/header.h create mode 100644 lmdk/src/include/module/audio/audio_stream.h create mode 100644 scripts/lmdk/tools/header_pack.py diff --git a/lmdk/include/headers_list.json b/lmdk/include/headers_list.json new file mode 100644 index 000000000000..b5cd44e3c066 --- /dev/null +++ b/lmdk/include/headers_list.json @@ -0,0 +1,23 @@ +[ + ["src", "include", "ipc4", "header.h"], + ["src", "include", "module","audio","audio_stream.h"], + ["src","include","module","audio","format.h"], + ["src","include","module","audio","sink_api.h"], + ["src","include","module","audio","source_api.h"], + ["src","include","module","iadk","adsp_error_code.h"], + ["src","include","module","ipc","stream.h"], + ["src","include","module","ipc4","base-config.h"], + ["src","include","module","module","api_ver.h"], + ["src","include","module","module","base.h"], + ["src","include","module","module","interface.h"], + ["src","include","sof","audio","ipc-config.h"], + ["src","include","sof","audio","module_adapter","library","native_system_service.h"], + ["src","include","sof","audio","module_adapter","module","generic.h"], + ["src","include","sof","compiler_attributes.h"], + ["src","include","sof","list.h"], + ["src","include","sof","rtos","string.h"], + ["src","include","user","trace.h"], + ["src","libraries","module_example","CMakeLists.txt"], + ["src","libraries","module_example","module_example_mtl.toml"], + ["src","modules","up_down_mixer","CMakeLists.txt"] +] \ No newline at end of file diff --git a/lmdk/include/ipc4 b/lmdk/include/ipc4 new file mode 100644 index 000000000000..5abef50342b0 --- /dev/null +++ b/lmdk/include/ipc4 @@ -0,0 +1,218 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2021 Intel Corporation. All rights reserved. + */ + +/* + * This file contains structures that are exact copies of an existing ABI used + * by IOT middleware. They are Intel specific and will be used by one middleware. + * + * Some of the structures may contain programming implementations that makes them + * unsuitable for generic use and general usage. + * + * This code is mostly copied "as-is" from existing C++ interface files hence the use of + * different style in places. The intention is to keep the interface as close as possible to + * original so it's easier to track changes with IPC host code. + */ + +/** + * \file include/ipc4/header.h + * \brief IPC4 global definitions. + * NOTE: This ABI uses bit fields and is non portable. + */ + +#ifndef __SOF_IPC4_HEADER_H__ +#define __SOF_IPC4_HEADER_H__ + +#include + +#define ipc_from_hdr(x) ((struct ipc4_message_request *)x) + +/**< Message target, value of msg_tgt field. */ +enum ipc4_message_target { + /**< Global FW message */ + SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG = 0, + /**< Module message */ + SOF_IPC4_MESSAGE_TARGET_MODULE_MSG = 1 +}; + +/**< Message direction, value of rsp field. */ +enum ipc4_message_direction { + /**< Request, Notification */ + SOF_IPC4_MESSAGE_DIR_MSG_REQUEST = 0, + /**< Reply */ + SOF_IPC4_MESSAGE_DIR_MSG_REPLY = 1, +}; + +/* + * Global IPC4 message types - must fit into 5 bits. + */ +enum ipc4_message_type { + /**< Boot Config. */ + SOF_IPC4_GLB_BOOT_CONFIG = 0, + /**< ROM Control (directed to ROM). */ + SOF_IPC4_GLB_ROM_CONTROL = 1, + /**< Execute IPC gateway command */ + SOF_IPC4_GLB_IPCGATEWAY_CMD = 2, + + /* GAP HERE- DO NOT USE - size 10 (3 .. 12) */ + + /**< Execute performance measurements command. */ + SOF_IPC4_GLB_PERF_MEASUREMENTS_CMD = 13, + /**< DMA Chain command. */ + SOF_IPC4_GLB_CHAIN_DMA = 14, + /**< Load multiple modules */ + SOF_IPC4_GLB_LOAD_MULTIPLE_MODULES = 15, + /**< Unload multiple modules */ + SOF_IPC4_GLB_UNLOAD_MULTIPLE_MODULES = 16, + /**< Create pipeline */ + SOF_IPC4_GLB_CREATE_PIPELINE = 17, + /**< Delete pipeline */ + SOF_IPC4_GLB_DELETE_PIPELINE = 18, + /**< Set pipeline state */ + SOF_IPC4_GLB_SET_PIPELINE_STATE = 19, + /**< Get pipeline state */ + SOF_IPC4_GLB_GET_PIPELINE_STATE = 20, + /**< Get pipeline context size */ + SOF_IPC4_GLB_GET_PIPELINE_CONTEXT_SIZE = 21, + /**< Save pipeline */ + SOF_IPC4_GLB_SAVE_PIPELINE = 22, + /**< Restore pipeline */ + SOF_IPC4_GLB_RESTORE_PIPELINE = 23, + /**< Loads library */ + SOF_IPC4_GLB_LOAD_LIBRARY = 24, + /**< Loads library prepare */ + SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE = 25, + /**< Internal FW message */ + SOF_IPC4_GLB_INTERNAL_MESSAGE = 26, + /**< Notification (FW to SW driver) */ + SOF_IPC4_GLB_NOTIFICATION = 27, + /* GAP HERE- DO NOT USE - size 3 (28 .. 30) */ + + /**< Maximum message number */ + SOF_IPC4_GLB_MAX_IXC_MESSAGE_TYPE = 31 +}; + +/** + * \brief Generic message header. IPC MAJOR 4 version. + * All IPC4 messages use this header as abstraction + * to platform specific calls. + */ +struct ipc_cmd_hdr { + uint32_t pri; + uint32_t ext; +}; + +/** + * \brief IPC MAJOR 4 message header. All IPC4 messages use this header. + * When msg_tgt is SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG then type is + * enum ipc4_message_type. + */ +struct ipc4_message_request { + union { + uint32_t dat; + + struct { + uint32_t rsvd0 : 24; + + /**< One of Global::Type */ + uint32_t type : 5; + + /**< Msg::MSG_REQUEST */ + uint32_t rsp : 1; + + /**< Msg::FW_GEN_MSG */ + uint32_t msg_tgt : 1; + + uint32_t _reserved_0 : 1; + } r; + } primary; + union { + uint32_t dat; + struct { + uint32_t ext_data : 30; + uint32_t _reserved_0 : 2; + } r; + } extension; +} __attribute__((packed, aligned(4))); + +struct ipc4_message_reply { + union { + uint32_t dat; + + struct { + /**< Processing status, one of IxcStatus values */ + uint32_t status : 24; + + /**< Type, symmetric to Msg */ + uint32_t type : 5; + + /**< MSG_REPLY */ + uint32_t rsp : 1; + + /**< same as request, one of FW_GEN_MSG, MODULE_MSG */ + uint32_t msg_tgt : 1; + + /**< Reserved field (HW ctrl bits) */ + uint32_t _reserved_0 : 1; + } r; + } primary; + + union { + uint32_t dat; + + struct { + /**< Reserved field */ + uint32_t rsvd1 : 30; + + /**< Reserved field (HW ctrl bits) */ + uint32_t _reserved_2 : 2; + } r; + } extension; +} __attribute((packed, aligned(4))); + +#define SOF_IPC4_SWITCH_CONTROL_PARAM_ID 200 +#define SOF_IPC4_ENUM_CONTROL_PARAM_ID 201 +#define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL ((uint32_t)(0xA15A << 16)) + +/** + * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data + * @channel: Channel ID + * @value: control value + */ +struct sof_ipc4_ctrl_value_chan { + uint32_t channel; + uint32_t value; +} __attribute((packed, aligned(4))); + +/** + * struct sof_ipc4_control_msg_payload - IPC payload for kcontrol parameters + * @id: unique id of the control + * @num_elems: Number of elememnts in the chanv array + * @reserved: reserved for future use, must be set to 0 + * @chanv: channel ID and value array + */ +struct sof_ipc4_control_msg_payload { + uint16_t id; + uint16_t num_elems; + uint32_t reserved[4]; + struct sof_ipc4_ctrl_value_chan chanv[]; +} __attribute((packed, aligned(4))); + +/** + * struct sof_ipc4_notify_module_data - payload for module notification + * @instance_id: instance ID of the originator module of the notification + * @module_id: module ID of the originator of the notification + * @event_id: module specific event id + * @event_data_size: Size of the @event_data (if any) in bytes + * @event_data: Optional notification data, module and notification dependent + */ +struct sof_ipc4_notify_module_data { + uint16_t instance_id; + uint16_t module_id; + uint32_t event_id; + uint32_t event_data_size; + uint8_t event_data[]; +} __attribute((packed, aligned(4))); + +#endif diff --git a/lmdk/src/include/ipc4/header.h b/lmdk/src/include/ipc4/header.h new file mode 100644 index 000000000000..5abef50342b0 --- /dev/null +++ b/lmdk/src/include/ipc4/header.h @@ -0,0 +1,218 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2021 Intel Corporation. All rights reserved. + */ + +/* + * This file contains structures that are exact copies of an existing ABI used + * by IOT middleware. They are Intel specific and will be used by one middleware. + * + * Some of the structures may contain programming implementations that makes them + * unsuitable for generic use and general usage. + * + * This code is mostly copied "as-is" from existing C++ interface files hence the use of + * different style in places. The intention is to keep the interface as close as possible to + * original so it's easier to track changes with IPC host code. + */ + +/** + * \file include/ipc4/header.h + * \brief IPC4 global definitions. + * NOTE: This ABI uses bit fields and is non portable. + */ + +#ifndef __SOF_IPC4_HEADER_H__ +#define __SOF_IPC4_HEADER_H__ + +#include + +#define ipc_from_hdr(x) ((struct ipc4_message_request *)x) + +/**< Message target, value of msg_tgt field. */ +enum ipc4_message_target { + /**< Global FW message */ + SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG = 0, + /**< Module message */ + SOF_IPC4_MESSAGE_TARGET_MODULE_MSG = 1 +}; + +/**< Message direction, value of rsp field. */ +enum ipc4_message_direction { + /**< Request, Notification */ + SOF_IPC4_MESSAGE_DIR_MSG_REQUEST = 0, + /**< Reply */ + SOF_IPC4_MESSAGE_DIR_MSG_REPLY = 1, +}; + +/* + * Global IPC4 message types - must fit into 5 bits. + */ +enum ipc4_message_type { + /**< Boot Config. */ + SOF_IPC4_GLB_BOOT_CONFIG = 0, + /**< ROM Control (directed to ROM). */ + SOF_IPC4_GLB_ROM_CONTROL = 1, + /**< Execute IPC gateway command */ + SOF_IPC4_GLB_IPCGATEWAY_CMD = 2, + + /* GAP HERE- DO NOT USE - size 10 (3 .. 12) */ + + /**< Execute performance measurements command. */ + SOF_IPC4_GLB_PERF_MEASUREMENTS_CMD = 13, + /**< DMA Chain command. */ + SOF_IPC4_GLB_CHAIN_DMA = 14, + /**< Load multiple modules */ + SOF_IPC4_GLB_LOAD_MULTIPLE_MODULES = 15, + /**< Unload multiple modules */ + SOF_IPC4_GLB_UNLOAD_MULTIPLE_MODULES = 16, + /**< Create pipeline */ + SOF_IPC4_GLB_CREATE_PIPELINE = 17, + /**< Delete pipeline */ + SOF_IPC4_GLB_DELETE_PIPELINE = 18, + /**< Set pipeline state */ + SOF_IPC4_GLB_SET_PIPELINE_STATE = 19, + /**< Get pipeline state */ + SOF_IPC4_GLB_GET_PIPELINE_STATE = 20, + /**< Get pipeline context size */ + SOF_IPC4_GLB_GET_PIPELINE_CONTEXT_SIZE = 21, + /**< Save pipeline */ + SOF_IPC4_GLB_SAVE_PIPELINE = 22, + /**< Restore pipeline */ + SOF_IPC4_GLB_RESTORE_PIPELINE = 23, + /**< Loads library */ + SOF_IPC4_GLB_LOAD_LIBRARY = 24, + /**< Loads library prepare */ + SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE = 25, + /**< Internal FW message */ + SOF_IPC4_GLB_INTERNAL_MESSAGE = 26, + /**< Notification (FW to SW driver) */ + SOF_IPC4_GLB_NOTIFICATION = 27, + /* GAP HERE- DO NOT USE - size 3 (28 .. 30) */ + + /**< Maximum message number */ + SOF_IPC4_GLB_MAX_IXC_MESSAGE_TYPE = 31 +}; + +/** + * \brief Generic message header. IPC MAJOR 4 version. + * All IPC4 messages use this header as abstraction + * to platform specific calls. + */ +struct ipc_cmd_hdr { + uint32_t pri; + uint32_t ext; +}; + +/** + * \brief IPC MAJOR 4 message header. All IPC4 messages use this header. + * When msg_tgt is SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG then type is + * enum ipc4_message_type. + */ +struct ipc4_message_request { + union { + uint32_t dat; + + struct { + uint32_t rsvd0 : 24; + + /**< One of Global::Type */ + uint32_t type : 5; + + /**< Msg::MSG_REQUEST */ + uint32_t rsp : 1; + + /**< Msg::FW_GEN_MSG */ + uint32_t msg_tgt : 1; + + uint32_t _reserved_0 : 1; + } r; + } primary; + union { + uint32_t dat; + struct { + uint32_t ext_data : 30; + uint32_t _reserved_0 : 2; + } r; + } extension; +} __attribute__((packed, aligned(4))); + +struct ipc4_message_reply { + union { + uint32_t dat; + + struct { + /**< Processing status, one of IxcStatus values */ + uint32_t status : 24; + + /**< Type, symmetric to Msg */ + uint32_t type : 5; + + /**< MSG_REPLY */ + uint32_t rsp : 1; + + /**< same as request, one of FW_GEN_MSG, MODULE_MSG */ + uint32_t msg_tgt : 1; + + /**< Reserved field (HW ctrl bits) */ + uint32_t _reserved_0 : 1; + } r; + } primary; + + union { + uint32_t dat; + + struct { + /**< Reserved field */ + uint32_t rsvd1 : 30; + + /**< Reserved field (HW ctrl bits) */ + uint32_t _reserved_2 : 2; + } r; + } extension; +} __attribute((packed, aligned(4))); + +#define SOF_IPC4_SWITCH_CONTROL_PARAM_ID 200 +#define SOF_IPC4_ENUM_CONTROL_PARAM_ID 201 +#define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL ((uint32_t)(0xA15A << 16)) + +/** + * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data + * @channel: Channel ID + * @value: control value + */ +struct sof_ipc4_ctrl_value_chan { + uint32_t channel; + uint32_t value; +} __attribute((packed, aligned(4))); + +/** + * struct sof_ipc4_control_msg_payload - IPC payload for kcontrol parameters + * @id: unique id of the control + * @num_elems: Number of elememnts in the chanv array + * @reserved: reserved for future use, must be set to 0 + * @chanv: channel ID and value array + */ +struct sof_ipc4_control_msg_payload { + uint16_t id; + uint16_t num_elems; + uint32_t reserved[4]; + struct sof_ipc4_ctrl_value_chan chanv[]; +} __attribute((packed, aligned(4))); + +/** + * struct sof_ipc4_notify_module_data - payload for module notification + * @instance_id: instance ID of the originator module of the notification + * @module_id: module ID of the originator of the notification + * @event_id: module specific event id + * @event_data_size: Size of the @event_data (if any) in bytes + * @event_data: Optional notification data, module and notification dependent + */ +struct sof_ipc4_notify_module_data { + uint16_t instance_id; + uint16_t module_id; + uint32_t event_id; + uint32_t event_data_size; + uint8_t event_data[]; +} __attribute((packed, aligned(4))); + +#endif diff --git a/lmdk/src/include/module/audio/audio_stream.h b/lmdk/src/include/module/audio/audio_stream.h new file mode 100644 index 000000000000..0941047a6395 --- /dev/null +++ b/lmdk/src/include/module/audio/audio_stream.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2020 - 2023 Intel Corporation. All rights reserved. + * + * Author: Karol Trzcinski + * Adrian Warecki + */ + +#ifndef __MODULE_AUDIO_AUDIO_STREAM_H__ +#define __MODULE_AUDIO_AUDIO_STREAM_H__ + +#include +#include +#include "../ipc/stream.h" + +/** + * set of parameters describing audio stream + * this structure is shared between audio_stream.h and sink/source interface + * TODO: compressed formats + */ +struct sof_audio_stream_params { + uint32_t id; + enum sof_ipc_frame frame_fmt; /**< Sample data format */ + enum sof_ipc_frame valid_sample_fmt; + + uint32_t rate; /**< Number of data frames per second [Hz] */ + uint16_t channels; /**< Number of samples in each frame */ + + /** + * align_frame_cnt indicates minimum number of frames that satisfies both byte + * align and frame align requirements. E.g: Consider an algorithm that processes + * in blocks of 3 frames configured to process 16-bit stereo using xtensa HiFi3 + * SIMD. Therefore with 16-bit stereo we have a frame size of 4 bytes, and + * SIMD intrinsic requirement of 8 bytes(2 frames) for HiFi3 and an algorithim + * requirement of 3 frames. Hence the common processing block size has to align + * with frame(1), intrinsic(2) and algorithm (3) giving us an optimum processing + * block size of 6 frames. + */ + uint16_t align_frame_cnt; + + /** + * the free/available bytes of sink/source right shift align_shift_idx, the result + * multiplied by align_frame_cnt is the frame count free/available that can meet + * the align requirement. + */ + uint16_t align_shift_idx; + + bool overrun_permitted; /**< indicates whether overrun is permitted */ + bool underrun_permitted; /**< indicates whether underrun is permitted */ + + uint32_t buffer_fmt; /**< enum sof_ipc_buffer_format */ +}; + +#endif /* __MODULE_AUDIO_AUDIO_STREAM_H__ */ diff --git a/scripts/lmdk/tools/header_pack.py b/scripts/lmdk/tools/header_pack.py new file mode 100644 index 000000000000..e607f0149e4c --- /dev/null +++ b/scripts/lmdk/tools/header_pack.py @@ -0,0 +1,26 @@ +from dataclasses import dataclass +from distutils.dir_util import copy_tree +import json +import pathlib +import shutil + +# Headers for needs of lmdk are defined in +# lmdk/include/headers_list.json +from typing import io + +SOF_TOP = pathlib.Path(__file__).parents[3].resolve() +LMDK_HEADERS = SOF_TOP / "lmdk" / "include" / "headers_list.json" +f = open(LMDK_HEADERS) +data = json.load(f) +src = '' + +for i in data: + for p in i[:-1]: + src += p + src += "/" + for p in i[-1:]: + src += p + print(src) + src = '' + # src = pathlib.Path(src) + # shutil.copytree(src, SOF_TOP / "lmdk")