1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef _CS_PROTOCOL_H
25#define _CS_PROTOCOL_H
26
27#include <linux/types.h>
28#include <linux/ioctl.h>
29
30
31#define CS_DEV_FILE_NAME "/dev/cmt_speech"
32
33
34#define CS_IF_VERSION 2
35
36
37#define CS_CMD_SHIFT 28
38#define CS_DOMAIN_SHIFT 24
39
40#define CS_CMD_MASK 0xff000000
41#define CS_PARAM_MASK 0xffffff
42
43#define CS_CMD(id, dom) \
44 (((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
45
46#define CS_ERROR CS_CMD(1, 0)
47#define CS_RX_DATA_RECEIVED CS_CMD(2, 0)
48#define CS_TX_DATA_READY CS_CMD(3, 0)
49#define CS_TX_DATA_SENT CS_CMD(4, 0)
50
51
52#define CS_ERR_PEER_RESET 0
53
54
55
56
57#define CS_FEAT_TSTAMP_RX_CTRL (1 << 0)
58#define CS_FEAT_ROLLING_RX_COUNTER (2 << 0)
59
60
61#define CS_STATE_CLOSED 0
62#define CS_STATE_OPENED 1
63#define CS_STATE_CONFIGURED 2
64
65
66#define CS_MAX_BUFFERS_SHIFT 4
67#define CS_MAX_BUFFERS (1 << CS_MAX_BUFFERS_SHIFT)
68
69
70struct cs_buffer_config {
71 __u32 rx_bufs;
72 __u32 tx_bufs;
73 __u32 buf_size;
74 __u32 flags;
75 __u32 reserved[4];
76};
77
78
79
80
81
82struct cs_timestamp {
83 __u32 tv_sec;
84 __u32 tv_nsec;
85};
86
87
88
89
90
91struct cs_mmap_config_block {
92 __u32 reserved1;
93 __u32 buf_size;
94 __u32 rx_bufs;
95 __u32 tx_bufs;
96 __u32 reserved2;
97
98 __u32 rx_offsets[CS_MAX_BUFFERS];
99 __u32 tx_offsets[CS_MAX_BUFFERS];
100 __u32 rx_ptr;
101 __u32 rx_ptr_boundary;
102 __u32 reserved3[2];
103
104 struct cs_timestamp tstamp_rx_ctrl;
105};
106
107#define CS_IO_MAGIC 'C'
108
109#define CS_IOW(num, dtype) _IOW(CS_IO_MAGIC, num, dtype)
110#define CS_IOR(num, dtype) _IOR(CS_IO_MAGIC, num, dtype)
111#define CS_IOWR(num, dtype) _IOWR(CS_IO_MAGIC, num, dtype)
112#define CS_IO(num) _IO(CS_IO_MAGIC, num)
113
114#define CS_GET_STATE CS_IOR(21, unsigned int)
115#define CS_SET_WAKELINE CS_IOW(23, unsigned int)
116#define CS_GET_IF_VERSION CS_IOR(30, unsigned int)
117#define CS_CONFIG_BUFS CS_IOW(31, struct cs_buffer_config)
118
119#endif
120