Repository navigation
Expand file tree
/
Copy pathmsg.h
More file actions
123 lines (103 loc) · 2.83 KB
/
Copy pathmsg.h
File metadata and controls
123 lines (103 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Keyon Jie <yang.jie@linux.intel.com>
*/
#ifndef __SOF_IPC_MSG_H__
#define __SOF_IPC_MSG_H__
#include <sof/audio/buffer.h>
#include <sof/audio/component.h>
#include <sof/audio/pipeline.h>
#include <sof/lib/alloc.h>
#include <sof/lib/memory.h>
#include <sof/list.h>
#include <sof/platform.h>
#include <sof/schedule/task.h>
#include <sof/sof.h>
#include <sof/spinlock.h>
#include <sof/trace/trace.h>
#include <sof/ipc/common.h>
#include <stdbool.h>
#include <stdint.h>
struct dai_config;
struct dma;
struct dma_sg_elem_array;
struct ipc_msg {
uint32_t header; /* specific to platform */
uint32_t tx_size; /* payload size in bytes */
void *tx_data; /* pointer to payload data */
struct list_item list;
};
/**
* \brief Initialise a new IPC message.
* @param header Message header metadata
* @param size Message size in bytes.
* @return New IPC message.
*/
static inline struct ipc_msg *ipc_msg_init(uint32_t header, uint32_t size)
{
struct ipc_msg *msg;
msg = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*msg));
if (!msg)
return NULL;
msg->tx_data = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, size);
if (!msg->tx_data) {
rfree(msg);
return NULL;
}
msg->header = header;
msg->tx_size = size;
list_init(&msg->list);
return msg;
}
/**
* \brief Frees IPC message header and data.
* @param msg The IPC message to be freed.
*/
static inline void ipc_msg_free(struct ipc_msg *msg)
{
if (!msg)
return;
struct ipc *ipc = ipc_get();
uint32_t flags;
spin_lock_irq(&ipc->lock, flags);
list_item_del(&msg->list);
rfree(msg->tx_data);
rfree(msg);
spin_unlock_irq(&ipc->lock, flags);
}
/**
* \brief Sends the next message in the IPC message queue.
*/
void ipc_send_queued_msg(void);
/**
* \brief Queues an IPC message for transmission.
* @param msg The IPC message to be freed.
* @param data The message data.
* @param high_priority True if a high priortity message.
*/
void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority);
/**
* \brief Build stream position IPC message.
* @param[in,out] posn Stream position message
* @param[in] type Stream message type
* @param[in] id Stream ID.
*/
void ipc_build_stream_posn(struct sof_ipc_stream_posn *posn, uint32_t type,
uint32_t id);
/**
* \brief Build component event IPC message.
* @param[in,out] event Component event message
* @param[in] type Component event type
* @param[in] id Component ID.
*/
void ipc_build_comp_event(struct sof_ipc_comp_event *event, uint32_t type,
uint32_t id);
/**
* \brief Build trace position IPC message.
* @param[in,out] posn Trace position message
*/
void ipc_build_trace_posn(struct sof_ipc_dma_trace_posn *posn);
#endif