2022-03-11 16:35:31 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
|
/*
|
|
|
|
|
* Copyright(c) 2021-2022 Intel Corporation. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Authors: Cezary Rojewski <cezary.rojewski@intel.com>
|
|
|
|
|
* Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __SOUND_SOC_INTEL_AVS_MSGS_H
|
|
|
|
|
#define __SOUND_SOC_INTEL_AVS_MSGS_H
|
|
|
|
|
|
|
|
|
|
struct avs_dev;
|
|
|
|
|
|
|
|
|
|
#define AVS_MAILBOX_SIZE 4096
|
|
|
|
|
|
|
|
|
|
enum avs_msg_target {
|
|
|
|
|
AVS_FW_GEN_MSG = 0,
|
|
|
|
|
AVS_MOD_MSG = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum avs_msg_direction {
|
|
|
|
|
AVS_MSG_REQUEST = 0,
|
|
|
|
|
AVS_MSG_REPLY = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum avs_global_msg_type {
|
2022-03-11 16:35:32 +01:00
|
|
|
AVS_GLB_LOAD_MULTIPLE_MODULES = 15,
|
|
|
|
|
AVS_GLB_UNLOAD_MULTIPLE_MODULES = 16,
|
2022-03-11 16:35:33 +01:00
|
|
|
AVS_GLB_CREATE_PIPELINE = 17,
|
|
|
|
|
AVS_GLB_DELETE_PIPELINE = 18,
|
|
|
|
|
AVS_GLB_SET_PIPELINE_STATE = 19,
|
|
|
|
|
AVS_GLB_GET_PIPELINE_STATE = 20,
|
2022-03-11 16:35:32 +01:00
|
|
|
AVS_GLB_LOAD_LIBRARY = 24,
|
2022-03-11 16:35:31 +01:00
|
|
|
AVS_GLB_NOTIFICATION = 27,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
union avs_global_msg {
|
|
|
|
|
u64 val;
|
|
|
|
|
struct {
|
|
|
|
|
union {
|
|
|
|
|
u32 primary;
|
|
|
|
|
struct {
|
|
|
|
|
u32 rsvd:24;
|
|
|
|
|
u32 global_msg_type:5;
|
|
|
|
|
u32 msg_direction:1;
|
|
|
|
|
u32 msg_target:1;
|
|
|
|
|
};
|
2022-03-11 16:35:32 +01:00
|
|
|
/* module loading */
|
|
|
|
|
struct {
|
|
|
|
|
u32 mod_cnt:8;
|
|
|
|
|
} load_multi_mods;
|
2022-03-11 16:35:33 +01:00
|
|
|
/* pipeline management */
|
|
|
|
|
struct {
|
|
|
|
|
u32 ppl_mem_size:11;
|
|
|
|
|
u32 ppl_priority:5;
|
|
|
|
|
u32 instance_id:8;
|
|
|
|
|
} create_ppl;
|
|
|
|
|
struct {
|
|
|
|
|
u32 rsvd:16;
|
|
|
|
|
u32 instance_id:8;
|
|
|
|
|
} ppl; /* generic ppl request */
|
|
|
|
|
struct {
|
|
|
|
|
u32 state:16;
|
|
|
|
|
u32 ppl_id:8;
|
|
|
|
|
} set_ppl_state;
|
|
|
|
|
struct {
|
|
|
|
|
u32 ppl_id:8;
|
|
|
|
|
} get_ppl_state;
|
2022-03-11 16:35:32 +01:00
|
|
|
/* library loading */
|
|
|
|
|
struct {
|
|
|
|
|
u32 dma_id:5;
|
|
|
|
|
u32 rsvd:11;
|
|
|
|
|
u32 lib_id:4;
|
|
|
|
|
} load_lib;
|
2022-03-11 16:35:31 +01:00
|
|
|
};
|
|
|
|
|
union {
|
|
|
|
|
u32 val;
|
2022-03-11 16:35:33 +01:00
|
|
|
/* pipeline management */
|
|
|
|
|
struct {
|
|
|
|
|
u32 lp:1; /* low power flag */
|
|
|
|
|
u32 rsvd:3;
|
|
|
|
|
u32 attributes:16; /* additional scheduling flags */
|
|
|
|
|
} create_ppl;
|
2022-03-11 16:35:31 +01:00
|
|
|
} ext;
|
|
|
|
|
};
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
struct avs_tlv {
|
|
|
|
|
u32 type;
|
|
|
|
|
u32 length;
|
|
|
|
|
u32 value[];
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
union avs_module_msg {
|
|
|
|
|
u64 val;
|
|
|
|
|
struct {
|
|
|
|
|
union {
|
|
|
|
|
u32 primary;
|
|
|
|
|
struct {
|
|
|
|
|
u32 module_id:16;
|
|
|
|
|
u32 instance_id:8;
|
|
|
|
|
u32 module_msg_type:5;
|
|
|
|
|
u32 msg_direction:1;
|
|
|
|
|
u32 msg_target:1;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
union {
|
|
|
|
|
u32 val;
|
|
|
|
|
} ext;
|
|
|
|
|
};
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
union avs_reply_msg {
|
|
|
|
|
u64 val;
|
|
|
|
|
struct {
|
|
|
|
|
union {
|
|
|
|
|
u32 primary;
|
|
|
|
|
struct {
|
|
|
|
|
u32 status:24;
|
|
|
|
|
u32 global_msg_type:5;
|
|
|
|
|
u32 msg_direction:1;
|
|
|
|
|
u32 msg_target:1;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
union {
|
|
|
|
|
u32 val;
|
2022-03-11 16:35:32 +01:00
|
|
|
/* module loading */
|
|
|
|
|
struct {
|
|
|
|
|
u32 err_mod_id:16;
|
|
|
|
|
} load_multi_mods;
|
2022-03-11 16:35:33 +01:00
|
|
|
/* pipeline management */
|
|
|
|
|
struct {
|
|
|
|
|
u32 state:5;
|
|
|
|
|
} get_ppl_state;
|
2022-03-11 16:35:31 +01:00
|
|
|
} ext;
|
|
|
|
|
};
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
enum avs_notify_msg_type {
|
|
|
|
|
AVS_NOTIFY_PHRASE_DETECTED = 4,
|
|
|
|
|
AVS_NOTIFY_RESOURCE_EVENT = 5,
|
|
|
|
|
AVS_NOTIFY_FW_READY = 8,
|
|
|
|
|
AVS_NOTIFY_MODULE_EVENT = 12,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
union avs_notify_msg {
|
|
|
|
|
u64 val;
|
|
|
|
|
struct {
|
|
|
|
|
union {
|
|
|
|
|
u32 primary;
|
|
|
|
|
struct {
|
|
|
|
|
u32 rsvd:16;
|
|
|
|
|
u32 notify_msg_type:8;
|
|
|
|
|
u32 global_msg_type:5;
|
|
|
|
|
u32 msg_direction:1;
|
|
|
|
|
u32 msg_target:1;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
union {
|
|
|
|
|
u32 val;
|
|
|
|
|
} ext;
|
|
|
|
|
};
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
#define AVS_MSG(hdr) { .val = hdr }
|
|
|
|
|
|
|
|
|
|
#define AVS_GLOBAL_REQUEST(msg_type) \
|
|
|
|
|
{ \
|
|
|
|
|
.global_msg_type = AVS_GLB_##msg_type, \
|
|
|
|
|
.msg_direction = AVS_MSG_REQUEST, \
|
|
|
|
|
.msg_target = AVS_FW_GEN_MSG, \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define AVS_MODULE_REQUEST(msg_type) \
|
|
|
|
|
{ \
|
|
|
|
|
.module_msg_type = AVS_MOD_##msg_type, \
|
|
|
|
|
.msg_direction = AVS_MSG_REQUEST, \
|
|
|
|
|
.msg_target = AVS_MOD_MSG, \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define AVS_NOTIFICATION(msg_type) \
|
|
|
|
|
{ \
|
|
|
|
|
.notify_msg_type = AVS_NOTIFY_##msg_type,\
|
|
|
|
|
.global_msg_type = AVS_GLB_NOTIFICATION,\
|
|
|
|
|
.msg_direction = AVS_MSG_REPLY, \
|
|
|
|
|
.msg_target = AVS_FW_GEN_MSG, \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define avs_msg_is_reply(hdr) \
|
|
|
|
|
({ \
|
|
|
|
|
union avs_reply_msg __msg = AVS_MSG(hdr); \
|
|
|
|
|
__msg.msg_direction == AVS_MSG_REPLY && \
|
|
|
|
|
__msg.global_msg_type != AVS_GLB_NOTIFICATION; \
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/* Notification types */
|
|
|
|
|
|
|
|
|
|
struct avs_notify_voice_data {
|
|
|
|
|
u16 kpd_score;
|
|
|
|
|
u16 reserved;
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
struct avs_notify_res_data {
|
|
|
|
|
u32 resource_type;
|
|
|
|
|
u32 resource_id;
|
|
|
|
|
u32 event_type;
|
|
|
|
|
u32 reserved;
|
|
|
|
|
u32 data[6];
|
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
|
|
struct avs_notify_mod_data {
|
|
|
|
|
u32 module_instance_id;
|
|
|
|
|
u32 event_id;
|
|
|
|
|
u32 data_size;
|
|
|
|
|
u32 data[];
|
|
|
|
|
} __packed;
|
|
|
|
|
|
2022-03-11 16:35:32 +01:00
|
|
|
/* Code loading messages */
|
|
|
|
|
int avs_ipc_load_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids);
|
|
|
|
|
int avs_ipc_unload_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids);
|
|
|
|
|
int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id);
|
|
|
|
|
|
2022-03-11 16:35:33 +01:00
|
|
|
/* Pipeline management messages */
|
|
|
|
|
enum avs_pipeline_state {
|
|
|
|
|
AVS_PPL_STATE_INVALID,
|
|
|
|
|
AVS_PPL_STATE_UNINITIALIZED,
|
|
|
|
|
AVS_PPL_STATE_RESET,
|
|
|
|
|
AVS_PPL_STATE_PAUSED,
|
|
|
|
|
AVS_PPL_STATE_RUNNING,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int avs_ipc_create_pipeline(struct avs_dev *adev, u16 req_size, u8 priority,
|
|
|
|
|
u8 instance_id, bool lp, u16 attributes);
|
|
|
|
|
int avs_ipc_delete_pipeline(struct avs_dev *adev, u8 instance_id);
|
|
|
|
|
int avs_ipc_set_pipeline_state(struct avs_dev *adev, u8 instance_id,
|
|
|
|
|
enum avs_pipeline_state state);
|
|
|
|
|
int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id,
|
|
|
|
|
enum avs_pipeline_state *state);
|
|
|
|
|
|
2022-03-11 16:35:31 +01:00
|
|
|
#endif /* __SOUND_SOC_INTEL_AVS_MSGS_H */
|