1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * cmt-speech interface definitions
5 * Copyright (C) 2008,2009,2010 Nokia Corporation. All rights reserved.
11 #ifndef _CS_PROTOCOL_H
12 #define _CS_PROTOCOL_H
14 #include <linux/types.h>
15 #include <linux/ioctl.h>
17 /* chardev parameters */
18 #define CS_DEV_FILE_NAME "/dev/cmt_speech"
20 /* user-space API versioning */
21 #define CS_IF_VERSION 2
23 /* APE kernel <-> user space messages */
24 #define CS_CMD_SHIFT 28
25 #define CS_DOMAIN_SHIFT 24
27 #define CS_CMD_MASK 0xff000000
28 #define CS_PARAM_MASK 0xffffff
30 #define CS_CMD(id, dom) \
31 (((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
33 #define CS_ERROR CS_CMD(1, 0)
34 #define CS_RX_DATA_RECEIVED CS_CMD(2, 0)
35 #define CS_TX_DATA_READY CS_CMD(3, 0)
36 #define CS_TX_DATA_SENT CS_CMD(4, 0)
38 /* params to CS_ERROR indication */
39 #define CS_ERR_PEER_RESET 0
43 /* parameters to CS_CONFIG_BUFS ioctl */
44 #define CS_FEAT_TSTAMP_RX_CTRL (1 << 0)
45 #define CS_FEAT_ROLLING_RX_COUNTER (2 << 0)
47 /* parameters to CS_GET_STATE ioctl */
48 #define CS_STATE_CLOSED 0
49 #define CS_STATE_OPENED 1 /* resource allocated */
50 #define CS_STATE_CONFIGURED 2 /* data path active */
52 /* maximum number of TX/RX buffers */
53 #define CS_MAX_BUFFERS_SHIFT 4
54 #define CS_MAX_BUFFERS (1 << CS_MAX_BUFFERS_SHIFT)
56 /* Parameters for setting up the data buffers */
57 struct cs_buffer_config {
58 __u32 rx_bufs; /* number of RX buffer slots */
59 __u32 tx_bufs; /* number of TX buffer slots */
60 __u32 buf_size; /* bytes */
61 __u32 flags; /* see CS_FEAT_* */
66 * struct for monotonic timestamp taken when the
67 * last control command was received
70 __u32 tv_sec; /* seconds */
71 __u32 tv_nsec; /* nanoseconds */
75 * Struct describing the layout and contents of the driver mmap area.
76 * This information is meant as read-only information for the application.
78 struct cs_mmap_config_block {
80 __u32 buf_size; /* 0=disabled, otherwise the transfer size */
81 __u32 rx_bufs; /* # of RX buffers */
82 __u32 tx_bufs; /* # of TX buffers */
84 /* array of offsets within the mmap area for each RX and TX buffer */
85 __u32 rx_offsets[CS_MAX_BUFFERS];
86 __u32 tx_offsets[CS_MAX_BUFFERS];
88 __u32 rx_ptr_boundary;
90 /* enabled with CS_FEAT_TSTAMP_RX_CTRL */
91 struct cs_timestamp tstamp_rx_ctrl;
94 #define CS_IO_MAGIC 'C'
96 #define CS_IOW(num, dtype) _IOW(CS_IO_MAGIC, num, dtype)
97 #define CS_IOR(num, dtype) _IOR(CS_IO_MAGIC, num, dtype)
98 #define CS_IOWR(num, dtype) _IOWR(CS_IO_MAGIC, num, dtype)
99 #define CS_IO(num) _IO(CS_IO_MAGIC, num)
101 #define CS_GET_STATE CS_IOR(21, unsigned int)
102 #define CS_SET_WAKELINE CS_IOW(23, unsigned int)
103 #define CS_GET_IF_VERSION CS_IOR(30, unsigned int)
104 #define CS_CONFIG_BUFS CS_IOW(31, struct cs_buffer_config)
106 #endif /* _CS_PROTOCOL_H */