18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * cmt-speech interface definitions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2008,2009,2010 Nokia Corporation. All rights reserved.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Contact: Kai Vehmanen <kai.vehmanen@nokia.com>
88c2ecf20Sopenharmony_ci * Original author: Peter Ujfalusi <peter.ujfalusi@nokia.com>
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
118c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License
128c2ecf20Sopenharmony_ci * version 2 as published by the Free Software Foundation.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but
158c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
168c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
178c2ecf20Sopenharmony_ci * General Public License for more details.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License
208c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software
218c2ecf20Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
228c2ecf20Sopenharmony_ci * 02110-1301 USA
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#ifndef _CS_PROTOCOL_H
268c2ecf20Sopenharmony_ci#define _CS_PROTOCOL_H
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include <linux/types.h>
298c2ecf20Sopenharmony_ci#include <linux/ioctl.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/* chardev parameters */
328c2ecf20Sopenharmony_ci#define CS_DEV_FILE_NAME		"/dev/cmt_speech"
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* user-space API versioning */
358c2ecf20Sopenharmony_ci#define CS_IF_VERSION			2
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/* APE kernel <-> user space messages */
388c2ecf20Sopenharmony_ci#define CS_CMD_SHIFT			28
398c2ecf20Sopenharmony_ci#define CS_DOMAIN_SHIFT			24
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define CS_CMD_MASK			0xff000000
428c2ecf20Sopenharmony_ci#define CS_PARAM_MASK			0xffffff
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define CS_CMD(id, dom) \
458c2ecf20Sopenharmony_ci	(((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define CS_ERROR			CS_CMD(1, 0)
488c2ecf20Sopenharmony_ci#define CS_RX_DATA_RECEIVED		CS_CMD(2, 0)
498c2ecf20Sopenharmony_ci#define CS_TX_DATA_READY		CS_CMD(3, 0)
508c2ecf20Sopenharmony_ci#define CS_TX_DATA_SENT			CS_CMD(4, 0)
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* params to CS_ERROR indication */
538c2ecf20Sopenharmony_ci#define CS_ERR_PEER_RESET		0
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/* ioctl interface */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* parameters to CS_CONFIG_BUFS ioctl */
588c2ecf20Sopenharmony_ci#define CS_FEAT_TSTAMP_RX_CTRL		(1 << 0)
598c2ecf20Sopenharmony_ci#define CS_FEAT_ROLLING_RX_COUNTER	(2 << 0)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* parameters to CS_GET_STATE ioctl */
628c2ecf20Sopenharmony_ci#define CS_STATE_CLOSED			0
638c2ecf20Sopenharmony_ci#define CS_STATE_OPENED			1 /* resource allocated */
648c2ecf20Sopenharmony_ci#define CS_STATE_CONFIGURED		2 /* data path active */
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* maximum number of TX/RX buffers */
678c2ecf20Sopenharmony_ci#define CS_MAX_BUFFERS_SHIFT		4
688c2ecf20Sopenharmony_ci#define CS_MAX_BUFFERS			(1 << CS_MAX_BUFFERS_SHIFT)
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/* Parameters for setting up the data buffers */
718c2ecf20Sopenharmony_cistruct cs_buffer_config {
728c2ecf20Sopenharmony_ci	__u32 rx_bufs;	/* number of RX buffer slots */
738c2ecf20Sopenharmony_ci	__u32 tx_bufs;	/* number of TX buffer slots */
748c2ecf20Sopenharmony_ci	__u32 buf_size;	/* bytes */
758c2ecf20Sopenharmony_ci	__u32 flags;	/* see CS_FEAT_* */
768c2ecf20Sopenharmony_ci	__u32 reserved[4];
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/*
808c2ecf20Sopenharmony_ci * struct for monotonic timestamp taken when the
818c2ecf20Sopenharmony_ci * last control command was received
828c2ecf20Sopenharmony_ci */
838c2ecf20Sopenharmony_cistruct cs_timestamp {
848c2ecf20Sopenharmony_ci	__u32 tv_sec;  /* seconds */
858c2ecf20Sopenharmony_ci	__u32 tv_nsec; /* nanoseconds */
868c2ecf20Sopenharmony_ci};
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/*
898c2ecf20Sopenharmony_ci * Struct describing the layout and contents of the driver mmap area.
908c2ecf20Sopenharmony_ci * This information is meant as read-only information for the application.
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_cistruct cs_mmap_config_block {
938c2ecf20Sopenharmony_ci	__u32 reserved1;
948c2ecf20Sopenharmony_ci	__u32 buf_size;		/* 0=disabled, otherwise the transfer size */
958c2ecf20Sopenharmony_ci	__u32 rx_bufs;		/* # of RX buffers */
968c2ecf20Sopenharmony_ci	__u32 tx_bufs;		/* # of TX buffers */
978c2ecf20Sopenharmony_ci	__u32 reserved2;
988c2ecf20Sopenharmony_ci	/* array of offsets within the mmap area for each RX and TX buffer */
998c2ecf20Sopenharmony_ci	__u32 rx_offsets[CS_MAX_BUFFERS];
1008c2ecf20Sopenharmony_ci	__u32 tx_offsets[CS_MAX_BUFFERS];
1018c2ecf20Sopenharmony_ci	__u32 rx_ptr;
1028c2ecf20Sopenharmony_ci	__u32 rx_ptr_boundary;
1038c2ecf20Sopenharmony_ci	__u32 reserved3[2];
1048c2ecf20Sopenharmony_ci	/* enabled with CS_FEAT_TSTAMP_RX_CTRL */
1058c2ecf20Sopenharmony_ci	struct cs_timestamp tstamp_rx_ctrl;
1068c2ecf20Sopenharmony_ci};
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#define CS_IO_MAGIC		'C'
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define CS_IOW(num, dtype)	_IOW(CS_IO_MAGIC, num, dtype)
1118c2ecf20Sopenharmony_ci#define CS_IOR(num, dtype)	_IOR(CS_IO_MAGIC, num, dtype)
1128c2ecf20Sopenharmony_ci#define CS_IOWR(num, dtype)	_IOWR(CS_IO_MAGIC, num, dtype)
1138c2ecf20Sopenharmony_ci#define CS_IO(num)		_IO(CS_IO_MAGIC, num)
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define CS_GET_STATE		CS_IOR(21, unsigned int)
1168c2ecf20Sopenharmony_ci#define CS_SET_WAKELINE		CS_IOW(23, unsigned int)
1178c2ecf20Sopenharmony_ci#define CS_GET_IF_VERSION	CS_IOR(30, unsigned int)
1188c2ecf20Sopenharmony_ci#define CS_CONFIG_BUFS		CS_IOW(31, struct cs_buffer_config)
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#endif /* _CS_PROTOCOL_H */
121