Sound Open Firmware
Loading...
Searching...
No Matches
msg.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 * Keyon Jie <yang.jie@linux.intel.com>
7 */
8
9#ifndef __SOF_IPC_MSG_H__
10#define __SOF_IPC_MSG_H__
11
12#include <sof/audio/buffer.h>
13#include <sof/audio/component.h>
14#include <sof/audio/pipeline.h>
15#include <rtos/alloc.h>
16#include <sof/lib/memory.h>
17#include <sof/list.h>
18#include <sof/platform.h>
19#include <rtos/task.h>
20#include <rtos/sof.h>
21#include <rtos/spinlock.h>
22#include <sof/trace/trace.h>
23#include <sof/ipc/common.h>
24#include <ipc/trace.h>
25
26#include <stdbool.h>
27#include <stdint.h>
28
29struct dai_config;
30struct dma;
32
33struct ipc_msg {
34 uint32_t header; /* specific to platform */
35 uint32_t extension; /* extension specific to platform */
36 uint32_t tx_size; /* payload size in bytes */
37 void *tx_data; /* pointer to payload data, must be in a non-cached memory */
39 void (*callback)(struct ipc_msg *msg); /* Function called after sending the message */
40};
41
49static inline struct ipc_msg *ipc_msg_w_ext_init(uint32_t header, uint32_t extension,
50 uint32_t size)
51{
52 struct ipc_msg *msg;
53
54 msg = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, sizeof(*msg));
55 if (!msg)
56 return NULL;
57
58 if (size) {
60 if (!msg->tx_data) {
61 rfree(msg);
62 return NULL;
63 }
64 }
65
66 msg->header = header;
67 msg->extension = extension;
68 msg->tx_size = size;
69 list_init(&msg->list);
70
71 return msg;
72}
73
80static inline struct ipc_msg *ipc_msg_init(uint32_t header, uint32_t size)
81{
82 return ipc_msg_w_ext_init(header, 0, size);
83}
84
89static inline void ipc_msg_free(struct ipc_msg *msg)
90{
91 if (!msg)
92 return;
93
94 struct ipc *ipc = ipc_get();
95 k_spinlock_key_t key;
96
97 key = k_spin_lock(&ipc->lock);
98
99 list_item_del(&msg->list);
100 rfree(msg->tx_data);
101 rfree(msg);
102
103 k_spin_unlock(&ipc->lock, key);
104}
105
110
117void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority);
118
124void ipc_msg_send_direct(struct ipc_msg *msg, void *data);
125
133 uint32_t id);
134
141void ipc_build_comp_event(struct sof_ipc_comp_event *event, uint32_t type,
142 uint32_t id);
143
148bool ipc_trigger_trace_xfer(uint32_t avail);
149
155
156#endif
Component API definition.
uint32_t data[]
Definition debug_stream_slot.h:2
void * rzalloc(uint32_t flags, size_t bytes)
Similar to rmalloc(), guarantees that returned block is zeroed.
#define SOF_MEM_FLAG_USER
Allocate user memory address.
Definition alloc.h:45
void rfree(void *ptr)
Frees the memory block.
#define SOF_MEM_FLAG_COHERENT
Allocate uncached address.
Definition alloc.h:37
int dai_config(struct dai_data *dd, struct comp_dev *dev, struct ipc_config_dai *common_cfg, const void *spec_cfg)
Configure DAI physical interface.
static struct ipc * ipc_get(void)
Get the IPC global context.
Definition common.h:147
static void list_init(struct list_item *list)
Definition list.h:25
static void list_item_del(struct list_item *item)
Definition list.h:58
#define list_item(item, type, member)
Definition list.h:80
bool ipc_trigger_trace_xfer(uint32_t avail)
Check if trace buffer is ready for transmission.
void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
Queues an IPC message for transmission.
void ipc_build_comp_event(struct sof_ipc_comp_event *event, uint32_t type, uint32_t id)
Build component event IPC message.
static struct ipc_msg * ipc_msg_w_ext_init(uint32_t header, uint32_t extension, uint32_t size)
Initialize a new IPC message.
Definition msg.h:49
void ipc_build_trace_posn(struct sof_ipc_dma_trace_posn *posn)
Build trace position IPC message.
void ipc_send_queued_msg(void)
Sends the next message in the IPC message queue.
void ipc_build_stream_posn(struct sof_ipc_stream_posn *posn, uint32_t type, uint32_t id)
Build stream position IPC message.
static void ipc_msg_free(struct ipc_msg *msg)
Frees IPC message header and data.
Definition msg.h:89
static struct ipc_msg * ipc_msg_init(uint32_t header, uint32_t size)
Initialise a new IPC message.
Definition msg.h:80
void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
Send an IPC message directly for emergency.
Platform API definition.
IPC definitions.
SG elem array.
Definition dma.h:155
Definition dma.h:209
Definition msg.h:33
uint32_t tx_size
Definition msg.h:36
uint32_t extension
Definition msg.h:35
struct list_item list
Definition msg.h:38
uint32_t header
Definition msg.h:34
void * tx_data
Definition msg.h:37
void(* callback)(struct ipc_msg *msg)
Definition msg.h:39
Definition common.h:90
struct k_spinlock lock
Definition common.h:91
Generic notification data.
Definition control.h:168
Definition trace.h:48
Definition stream.h:134
uint32_t type
Definition tlv.h:0