xref: /linux/include/uapi/linux/hsi/cs-protocol.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
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 
11 #ifndef _CS_PROTOCOL_H
12 #define _CS_PROTOCOL_H
13 
14 #include <linux/types.h>
15 #include <linux/ioctl.h>
16 
17 /* chardev parameters */
18 #define CS_DEV_FILE_NAME		"/dev/cmt_speech"
19 
20 /* user-space API versioning */
21 #define CS_IF_VERSION			2
22 
23 /* APE kernel <-> user space messages */
24 #define CS_CMD_SHIFT			28
25 #define CS_DOMAIN_SHIFT			24
26 
27 #define CS_CMD_MASK			0xff000000
28 #define CS_PARAM_MASK			0xffffff
29 
30 #define CS_CMD(id, dom) \
31 	(((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
32 
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)
37 
38 /* params to CS_ERROR indication */
39 #define CS_ERR_PEER_RESET		0
40 
41 /* ioctl interface */
42 
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)
46 
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 */
51 
52 /* maximum number of TX/RX buffers */
53 #define CS_MAX_BUFFERS_SHIFT		4
54 #define CS_MAX_BUFFERS			(1 << CS_MAX_BUFFERS_SHIFT)
55 
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_* */
62 	__u32 reserved[4];
63 };
64 
65 /*
66  * struct for monotonic timestamp taken when the
67  * last control command was received
68  */
69 struct cs_timestamp {
70 	__u32 tv_sec;  /* seconds */
71 	__u32 tv_nsec; /* nanoseconds */
72 };
73 
74 /*
75  * Struct describing the layout and contents of the driver mmap area.
76  * This information is meant as read-only information for the application.
77  */
78 struct cs_mmap_config_block {
79 	__u32 reserved1;
80 	__u32 buf_size;		/* 0=disabled, otherwise the transfer size */
81 	__u32 rx_bufs;		/* # of RX buffers */
82 	__u32 tx_bufs;		/* # of TX buffers */
83 	__u32 reserved2;
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];
87 	__u32 rx_ptr;
88 	__u32 rx_ptr_boundary;
89 	__u32 reserved3[2];
90 	/* enabled with CS_FEAT_TSTAMP_RX_CTRL */
91 	struct cs_timestamp tstamp_rx_ctrl;
92 };
93 
94 #define CS_IO_MAGIC		'C'
95 
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)
100 
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)
105 
106 #endif /* _CS_PROTOCOL_H */
107