112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * cmt-speech interface definitions
312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Copyright (C) 2008,2009,2010 Nokia Corporation. All rights reserved.
512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Contact: Kai Vehmanen <kai.vehmanen@nokia.com>
712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Original author: Peter Ujfalusi <peter.ujfalusi@nokia.com>
812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This program is free software; you can redistribute it and/or
1012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * modify it under the terms of the GNU General Public License
1112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * version 2 as published by the Free Software Foundation.
1212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
1312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This program is distributed in the hope that it will be useful, but
1412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * WITHOUT ANY WARRANTY; without even the implied warranty of
1512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * General Public License for more details.
1712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
1812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * You should have received a copy of the GNU General Public License
1912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * along with this program; if not, write to the Free Software
2012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
2112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * 02110-1301 USA
2212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
2312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
2412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#ifndef _CS_PROTOCOL_H
2512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define _CS_PROTOCOL_H
2612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
2712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#include <linux/types.h>
2812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#include <linux/ioctl.h>
2912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
3012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* chardev parameters */
3112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_DEV_FILE_NAME		"/dev/cmt_speech"
3212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
3312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* user-space API versioning */
3412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_IF_VERSION			2
3512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
3612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* APE kernel <-> user space messages */
3712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_CMD_SHIFT			28
3812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_DOMAIN_SHIFT			24
3912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
4012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_CMD_MASK			0xff000000
4112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_PARAM_MASK			0xffffff
4212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
4312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_CMD(id, dom) \
4412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	(((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
4512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
4612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_ERROR			CS_CMD(1, 0)
4712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_RX_DATA_RECEIVED		CS_CMD(2, 0)
4812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_TX_DATA_READY		CS_CMD(3, 0)
4912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_TX_DATA_SENT			CS_CMD(4, 0)
5012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
5112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* params to CS_ERROR indication */
5212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_ERR_PEER_RESET		0
5312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
5412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* ioctl interface */
5512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
5612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* parameters to CS_CONFIG_BUFS ioctl */
5712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_FEAT_TSTAMP_RX_CTRL		(1 << 0)
5812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_FEAT_ROLLING_RX_COUNTER	(2 << 0)
5912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
6012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* parameters to CS_GET_STATE ioctl */
6112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_STATE_CLOSED			0
6212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_STATE_OPENED			1 /* resource allocated */
6312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_STATE_CONFIGURED		2 /* data path active */
6412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
6512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* maximum number of TX/RX buffers */
6612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_MAX_BUFFERS_SHIFT		4
6712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_MAX_BUFFERS			(1 << CS_MAX_BUFFERS_SHIFT)
6812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
6912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* Parameters for setting up the data buffers */
7012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct cs_buffer_config {
7112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 rx_bufs;	/* number of RX buffer slots */
7212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 tx_bufs;	/* number of TX buffer slots */
7312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 buf_size;	/* bytes */
7412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 flags;	/* see CS_FEAT_* */
7512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 reserved[4];
7612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
7712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
7812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
7912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct for monotonic timestamp taken when the
8012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * last control command was received
8112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
8212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct cs_timestamp {
8312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 tv_sec;  /* seconds */
8412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 tv_nsec; /* nanoseconds */
8512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
8612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
8712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
8812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Struct describing the layout and contents of the driver mmap area.
8912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This information is meant as read-only information for the application.
9012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
9112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct cs_mmap_config_block {
9212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 reserved1;
9312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 buf_size;		/* 0=disabled, otherwise the transfer size */
9412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 rx_bufs;		/* # of RX buffers */
9512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 tx_bufs;		/* # of TX buffers */
9612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 reserved2;
9712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* array of offsets within the mmap area for each RX and TX buffer */
9812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 rx_offsets[CS_MAX_BUFFERS];
9912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 tx_offsets[CS_MAX_BUFFERS];
10012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 rx_ptr;
10112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 rx_ptr_boundary;
10212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 reserved3[2];
10312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* enabled with CS_FEAT_TSTAMP_RX_CTRL */
10412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	struct cs_timestamp tstamp_rx_ctrl;
10512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
10612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
10712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_IO_MAGIC		'C'
10812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
10912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_IOW(num, dtype)	_IOW(CS_IO_MAGIC, num, dtype)
11012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_IOR(num, dtype)	_IOR(CS_IO_MAGIC, num, dtype)
11112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_IOWR(num, dtype)	_IOWR(CS_IO_MAGIC, num, dtype)
11212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_IO(num)		_IO(CS_IO_MAGIC, num)
11312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
11412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_GET_STATE		CS_IOR(21, unsigned int)
11512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_SET_WAKELINE		CS_IOW(23, unsigned int)
11612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_GET_IF_VERSION	CS_IOR(30, unsigned int)
11712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define CS_CONFIG_BUFS		CS_IOW(31, struct cs_buffer_config)
11812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
11912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#endif /* _CS_PROTOCOL_H */
120