Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * cmt-speech interface definitions
0004  *
0005  * Copyright (C) 2008,2009,2010 Nokia Corporation. All rights reserved.
0006  *
0007  * Contact: Kai Vehmanen <kai.vehmanen@nokia.com>
0008  * Original author: Peter Ujfalusi <peter.ujfalusi@nokia.com>
0009  *
0010  * This program is free software; you can redistribute it and/or
0011  * modify it under the terms of the GNU General Public License
0012  * version 2 as published by the Free Software Foundation.
0013  *
0014  * This program is distributed in the hope that it will be useful, but
0015  * WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017  * General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU General Public License
0020  * along with this program; if not, write to the Free Software
0021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0022  * 02110-1301 USA
0023  */
0024 
0025 #ifndef _CS_PROTOCOL_H
0026 #define _CS_PROTOCOL_H
0027 
0028 #include <linux/types.h>
0029 #include <linux/ioctl.h>
0030 
0031 /* chardev parameters */
0032 #define CS_DEV_FILE_NAME        "/dev/cmt_speech"
0033 
0034 /* user-space API versioning */
0035 #define CS_IF_VERSION           2
0036 
0037 /* APE kernel <-> user space messages */
0038 #define CS_CMD_SHIFT            28
0039 #define CS_DOMAIN_SHIFT         24
0040 
0041 #define CS_CMD_MASK         0xff000000
0042 #define CS_PARAM_MASK           0xffffff
0043 
0044 #define CS_CMD(id, dom) \
0045     (((id) << CS_CMD_SHIFT) | ((dom) << CS_DOMAIN_SHIFT))
0046 
0047 #define CS_ERROR            CS_CMD(1, 0)
0048 #define CS_RX_DATA_RECEIVED     CS_CMD(2, 0)
0049 #define CS_TX_DATA_READY        CS_CMD(3, 0)
0050 #define CS_TX_DATA_SENT         CS_CMD(4, 0)
0051 
0052 /* params to CS_ERROR indication */
0053 #define CS_ERR_PEER_RESET       0
0054 
0055 /* ioctl interface */
0056 
0057 /* parameters to CS_CONFIG_BUFS ioctl */
0058 #define CS_FEAT_TSTAMP_RX_CTRL      (1 << 0)
0059 #define CS_FEAT_ROLLING_RX_COUNTER  (2 << 0)
0060 
0061 /* parameters to CS_GET_STATE ioctl */
0062 #define CS_STATE_CLOSED         0
0063 #define CS_STATE_OPENED         1 /* resource allocated */
0064 #define CS_STATE_CONFIGURED     2 /* data path active */
0065 
0066 /* maximum number of TX/RX buffers */
0067 #define CS_MAX_BUFFERS_SHIFT        4
0068 #define CS_MAX_BUFFERS          (1 << CS_MAX_BUFFERS_SHIFT)
0069 
0070 /* Parameters for setting up the data buffers */
0071 struct cs_buffer_config {
0072     __u32 rx_bufs;  /* number of RX buffer slots */
0073     __u32 tx_bufs;  /* number of TX buffer slots */
0074     __u32 buf_size; /* bytes */
0075     __u32 flags;    /* see CS_FEAT_* */
0076     __u32 reserved[4];
0077 };
0078 
0079 /*
0080  * struct for monotonic timestamp taken when the
0081  * last control command was received
0082  */
0083 struct cs_timestamp {
0084     __u32 tv_sec;  /* seconds */
0085     __u32 tv_nsec; /* nanoseconds */
0086 };
0087 
0088 /*
0089  * Struct describing the layout and contents of the driver mmap area.
0090  * This information is meant as read-only information for the application.
0091  */
0092 struct cs_mmap_config_block {
0093     __u32 reserved1;
0094     __u32 buf_size;     /* 0=disabled, otherwise the transfer size */
0095     __u32 rx_bufs;      /* # of RX buffers */
0096     __u32 tx_bufs;      /* # of TX buffers */
0097     __u32 reserved2;
0098     /* array of offsets within the mmap area for each RX and TX buffer */
0099     __u32 rx_offsets[CS_MAX_BUFFERS];
0100     __u32 tx_offsets[CS_MAX_BUFFERS];
0101     __u32 rx_ptr;
0102     __u32 rx_ptr_boundary;
0103     __u32 reserved3[2];
0104     /* enabled with CS_FEAT_TSTAMP_RX_CTRL */
0105     struct cs_timestamp tstamp_rx_ctrl;
0106 };
0107 
0108 #define CS_IO_MAGIC     'C'
0109 
0110 #define CS_IOW(num, dtype)  _IOW(CS_IO_MAGIC, num, dtype)
0111 #define CS_IOR(num, dtype)  _IOR(CS_IO_MAGIC, num, dtype)
0112 #define CS_IOWR(num, dtype) _IOWR(CS_IO_MAGIC, num, dtype)
0113 #define CS_IO(num)      _IO(CS_IO_MAGIC, num)
0114 
0115 #define CS_GET_STATE        CS_IOR(21, unsigned int)
0116 #define CS_SET_WAKELINE     CS_IOW(23, unsigned int)
0117 #define CS_GET_IF_VERSION   CS_IOR(30, unsigned int)
0118 #define CS_CONFIG_BUFS      CS_IOW(31, struct cs_buffer_config)
0119 
0120 #endif /* _CS_PROTOCOL_H */