]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/uapi/linux/hsi/cs-protocol.h
License cleanup: add SPDX license identifier to uapi header files with a license
[mirror_ubuntu-eoan-kernel.git] / include / uapi / linux / hsi / cs-protocol.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3 * cmt-speech interface definitions
4 *
5 * Copyright (C) 2008,2009,2010 Nokia Corporation. All rights reserved.
6 *
7 * Contact: Kai Vehmanen <kai.vehmanen@nokia.com>
8 * Original author: Peter Ujfalusi <peter.ujfalusi@nokia.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * version 2 as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */
24
25 #ifndef _CS_PROTOCOL_H
26 #define _CS_PROTOCOL_H
27
28 #include <linux/types.h>
29 #include <linux/ioctl.h>
30
31 /* chardev parameters */
32 #define CS_DEV_FILE_NAME "/dev/cmt_speech"
33
34 /* user-space API versioning */
35 #define CS_IF_VERSION 2
36
37 /* APE kernel <-> user space messages */
38 #define CS_CMD_SHIFT 28
39 #define CS_DOMAIN_SHIFT 24
40
41 #define CS_CMD_MASK 0xff000000
42 #define CS_PARAM_MASK 0xffffff
43
44 #define CS_CMD(id, dom) \
45 (((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
46
47 #define CS_ERROR CS_CMD(1, 0)
48 #define CS_RX_DATA_RECEIVED CS_CMD(2, 0)
49 #define CS_TX_DATA_READY CS_CMD(3, 0)
50 #define CS_TX_DATA_SENT CS_CMD(4, 0)
51
52 /* params to CS_ERROR indication */
53 #define CS_ERR_PEER_RESET 0
54
55 /* ioctl interface */
56
57 /* parameters to CS_CONFIG_BUFS ioctl */
58 #define CS_FEAT_TSTAMP_RX_CTRL (1 << 0)
59 #define CS_FEAT_ROLLING_RX_COUNTER (2 << 0)
60
61 /* parameters to CS_GET_STATE ioctl */
62 #define CS_STATE_CLOSED 0
63 #define CS_STATE_OPENED 1 /* resource allocated */
64 #define CS_STATE_CONFIGURED 2 /* data path active */
65
66 /* maximum number of TX/RX buffers */
67 #define CS_MAX_BUFFERS_SHIFT 4
68 #define CS_MAX_BUFFERS (1 << CS_MAX_BUFFERS_SHIFT)
69
70 /* Parameters for setting up the data buffers */
71 struct cs_buffer_config {
72 __u32 rx_bufs; /* number of RX buffer slots */
73 __u32 tx_bufs; /* number of TX buffer slots */
74 __u32 buf_size; /* bytes */
75 __u32 flags; /* see CS_FEAT_* */
76 __u32 reserved[4];
77 };
78
79 /*
80 * struct for monotonic timestamp taken when the
81 * last control command was received
82 */
83 struct cs_timestamp {
84 __u32 tv_sec; /* seconds */
85 __u32 tv_nsec; /* nanoseconds */
86 };
87
88 /*
89 * Struct describing the layout and contents of the driver mmap area.
90 * This information is meant as read-only information for the application.
91 */
92 struct cs_mmap_config_block {
93 __u32 reserved1;
94 __u32 buf_size; /* 0=disabled, otherwise the transfer size */
95 __u32 rx_bufs; /* # of RX buffers */
96 __u32 tx_bufs; /* # of TX buffers */
97 __u32 reserved2;
98 /* array of offsets within the mmap area for each RX and TX buffer */
99 __u32 rx_offsets[CS_MAX_BUFFERS];
100 __u32 tx_offsets[CS_MAX_BUFFERS];
101 __u32 rx_ptr;
102 __u32 rx_ptr_boundary;
103 __u32 reserved3[2];
104 /* enabled with CS_FEAT_TSTAMP_RX_CTRL */
105 struct cs_timestamp tstamp_rx_ctrl;
106 };
107
108 #define CS_IO_MAGIC 'C'
109
110 #define CS_IOW(num, dtype) _IOW(CS_IO_MAGIC, num, dtype)
111 #define CS_IOR(num, dtype) _IOR(CS_IO_MAGIC, num, dtype)
112 #define CS_IOWR(num, dtype) _IOWR(CS_IO_MAGIC, num, dtype)
113 #define CS_IO(num) _IO(CS_IO_MAGIC, num)
114
115 #define CS_GET_STATE CS_IOR(21, unsigned int)
116 #define CS_SET_WAKELINE CS_IOW(23, unsigned int)
117 #define CS_GET_IF_VERSION CS_IOR(30, unsigned int)
118 #define CS_CONFIG_BUFS CS_IOW(31, struct cs_buffer_config)
119
120 #endif /* _CS_PROTOCOL_H */