brintos

brintos / linux-shallow public Read only

0
0
Text · 28.3 KiB · 8286b55 Raw
513 lines · c
1/* SPDX-License-Identifier: GPL-2.0+ */2/*3 * Copyright 2017-2021  NXP4 *5 ******************************************************************************6 * Communication stack of audio with rpmsg7 ******************************************************************************8 * Packet structure:9 *   A SRTM message consists of a 10 bytes header followed by 0~N bytes of data10 *11 *   +---------------+-------------------------------+12 *   |               |            Content            |13 *   +---------------+-------------------------------+14 *   |  Byte Offset  | 7   6   5   4   3   2   1   0 |15 *   +---------------+---+---+---+---+---+---+---+---+16 *   |       0       |           Category            |17 *   +---------------+---+---+---+---+---+---+---+---+18 *   |     1 ~ 2     |           Version             |19 *   +---------------+---+---+---+---+---+---+---+---+20 *   |       3       |             Type              |21 *   +---------------+---+---+---+---+---+---+---+---+22 *   |       4       |           Command             |23 *   +---------------+---+---+---+---+---+---+---+---+24 *   |       5       |           Reserved0           |25 *   +---------------+---+---+---+---+---+---+---+---+26 *   |       6       |           Reserved1           |27 *   +---------------+---+---+---+---+---+---+---+---+28 *   |       7       |           Reserved2           |29 *   +---------------+---+---+---+---+---+---+---+---+30 *   |       8       |           Reserved3           |31 *   +---------------+---+---+---+---+---+---+---+---+32 *   |       9       |           Reserved4           |33 *   +---------------+---+---+---+---+---+---+---+---+34 *   |       10      |            DATA 0             |35 *   +---------------+---+---+---+---+---+---+---+---+36 *   :   :   :   :   :   :   :   :   :   :   :   :   :37 *   +---------------+---+---+---+---+---+---+---+---+38 *   |   N + 10 - 1  |            DATA N-1           |39 *   +---------------+---+---+---+---+---+---+---+---+40 *41 *   +----------+------------+------------------------------------------------+42 *   |  Field   |    Byte    |                                                |43 *   +----------+------------+------------------------------------------------+44 *   | Category |     0      | The destination category.                      |45 *   +----------+------------+------------------------------------------------+46 *   | Version  |   1 ~ 2    | The category version of the sender of the      |47 *   |          |            | packet.                                        |48 *   |          |            | The first byte represent the major version of  |49 *   |          |            | the packet.The second byte represent the minor |50 *   |          |            | version of the packet.                         |51 *   +----------+------------+------------------------------------------------+52 *   |  Type    |     3      | The message type of current message packet.    |53 *   +----------+------------+------------------------------------------------+54 *   | Command  |     4      | The command byte sent to remote processor/SoC. |55 *   +----------+------------+------------------------------------------------+56 *   | Reserved |   5 ~ 9    | Reserved field for future extension.           |57 *   +----------+------------+------------------------------------------------+58 *   | Data     |     N      | The data payload of the message packet.        |59 *   +----------+------------+------------------------------------------------+60 *61 * Audio control:62 *   SRTM Audio Control Category Request Command Table:63 *   +----------+---------+------+---------+-------------------------------+-----------------------+64 *   | Category | Version | Type | Command | Data                          | Function              |65 *   +----------+---------+------+---------+-------------------------------+-----------------------+66 *   |  0x03    | 0x0100  | 0x00 |  0x00   | Data[0]: Audio Device Index   | Open a TX Instance.   |67 *   |          |         |      |         | Data[1]:     format           |                       |68 *   |          |         |      |         | Data[2]:     channels         |                       |69 *   |          |         |      |         | Data[3-6]:   samplerate       |                       |70 *   |          |         |      |         | Data[7-10]:  buffer_addr      |                       |71 *   |          |         |      |         | Data[11-14]: buffer_size      |                       |72 *   |          |         |      |         | Data[15-18]: period_size      |                       |73 *   |          |         |      |         | Data[19-22]: buffer_tail      |                       |74 *   +----------+---------+------+---------+-------------------------------+-----------------------+75 *   |  0x03    | 0x0100  | 0x00 |  0x01   | Data[0]: Audio Device Index   | Start a TX Instance.  |76 *   |          |         |      |         | Same as above command         |                       |77 *   +----------+---------+------+---------+-------------------------------+-----------------------+78 *   |  0x03    | 0x0100  | 0x00 |  0x02   | Data[0]: Audio Device Index   | Pause a TX Instance.  |79 *   |          |         |      |         | Same as above command         |                       |80 *   +----------+---------+------+---------+-------------------------------+-----------------------+81 *   |  0x03    | 0x0100  | 0x00 |  0x03   | Data[0]: Audio Device Index   | Resume a TX Instance. |82 *   +----------+---------+------+---------+-------------------------------+-----------------------+83 *   |  0x03    | 0x0100  | 0x00 |  0x04   | Data[0]: Audio Device Index   | Stop a TX Instance.   |84 *   +----------+---------+------+---------+-------------------------------+-----------------------+85 *   |  0x03    | 0x0100  | 0x00 |  0x05   | Data[0]: Audio Device Index   | Close a TX Instance.  |86 *   +----------+---------+------+---------+-------------------------------+-----------------------+87 *   |  0x03    | 0x0100  | 0x00 |  0x06   | Data[0]: Audio Device Index   | Set Parameters for    |88 *   |          |         |      |         | Data[1]:     format           | a TX Instance.        |89 *   |          |         |      |         | Data[2]:     channels         |                       |90 *   |          |         |      |         | Data[3-6]:   samplerate       |                       |91 *   |          |         |      |         | Data[7-22]:  reserved         |                       |92 *   +----------+---------+------+---------+-------------------------------+-----------------------+93 *   |  0x03    | 0x0100  | 0x00 |  0x07   | Data[0]: Audio Device Index   | Set TX Buffer.        |94 *   |          |         |      |         | Data[1-6]:   reserved         |                       |95 *   |          |         |      |         | Data[7-10]:  buffer_addr      |                       |96 *   |          |         |      |         | Data[11-14]: buffer_size      |                       |97 *   |          |         |      |         | Data[15-18]: period_size      |                       |98 *   |          |         |      |         | Data[19-22]: buffer_tail      |                       |99 *   +----------+---------+------+---------+-------------------------------+-----------------------+100 *   |  0x03    | 0x0100  | 0x00 |  0x08   | Data[0]: Audio Device Index   | Suspend a TX Instance |101 *   +----------+---------+------+---------+-------------------------------+-----------------------+102 *   |  0x03    | 0x0100  | 0x00 |  0x09   | Data[0]: Audio Device Index   | Resume a TX Instance. |103 *   |          |         |      |         | Data[1]:     format           |                       |104 *   |          |         |      |         | Data[2]:     channels         |                       |105 *   |          |         |      |         | Data[3-6]:   samplerate       |                       |106 *   |          |         |      |         | Data[7-10]:  buffer_addr      |                       |107 *   |          |         |      |         | Data[11-14]: buffer_size      |                       |108 *   |          |         |      |         | Data[15-18]: period_size      |                       |109 *   |          |         |      |         | Data[19-22]: buffer_tail      |                       |110 *   +----------+---------+------+---------+-------------------------------+-----------------------+111 *   |  0x03    | 0x0100  | 0x00 |  0x0A   | Data[0]: Audio Device Index   | Open a RX Instance.   |112 *   +----------+---------+------+---------+-------------------------------+-----------------------+113 *   |  0x03    | 0x0100  | 0x00 |  0x0B   | Data[0]: Audio Device Index   | Start a RX Instance.  |114 *   +----------+---------+------+---------+-------------------------------+-----------------------+115 *   |  0x03    | 0x0100  | 0x00 |  0x0C   | Data[0]: Audio Device Index   | Pause a RX Instance.  |116 *   +----------+---------+------+---------+-------------------------------+-----------------------+117 *   |  0x03    | 0x0100  | 0x00 |  0x0D   | Data[0]: Audio Device Index   | Resume a RX Instance. |118 *   +----------+---------+------+---------+-------------------------------+-----------------------+119 *   |  0x03    | 0x0100  | 0x00 |  0x0E   | Data[0]: Audio Device Index   | Stop a RX Instance.   |120 *   +----------+---------+------+---------+-------------------------------+-----------------------+121 *   |  0x03    | 0x0100  | 0x00 |  0x0F   | Data[0]: Audio Device Index   | Close a RX Instance.  |122 *   +----------+---------+------+---------+-------------------------------+-----------------------+123 *   |  0x03    | 0x0100  | 0x00 |  0x10   | Data[0]: Audio Device Index   | Set Parameters for    |124 *   |          |         |      |         | Data[1]:     format           | a RX Instance.        |125 *   |          |         |      |         | Data[2]:     channels         |                       |126 *   |          |         |      |         | Data[3-6]:   samplerate       |                       |127 *   |          |         |      |         | Data[7-22]:  reserved         |                       |128 *   +----------+---------+------+---------+-------------------------------+-----------------------+129 *   |  0x03    | 0x0100  | 0x00 |  0x11   | Data[0]: Audio Device Index   | Set RX Buffer.        |130 *   |          |         |      |         | Data[1-6]:   reserved         |                       |131 *   |          |         |      |         | Data[7-10]:  buffer_addr      |                       |132 *   |          |         |      |         | Data[11-14]: buffer_size      |                       |133 *   |          |         |      |         | Data[15-18]: period_size      |                       |134 *   |          |         |      |         | Data[19-22]: buffer_tail      |                       |135 *   +----------+---------+------+---------+-------------------------------+-----------------------+136 *   |  0x03    | 0x0100  | 0x00 |  0x12   | Data[0]: Audio Device Index   | Suspend a RX Instance.|137 *   +----------+---------+------+---------+-------------------------------+-----------------------+138 *   |  0x03    | 0x0100  | 0x00 |  0x13   | Data[0]: Audio Device Index   | Resume a RX Instance. |139 *   |          |         |      |         | Data[1]:     format           |                       |140 *   |          |         |      |         | Data[2]:     channels         |                       |141 *   |          |         |      |         | Data[3-6]:   samplerate       |                       |142 *   |          |         |      |         | Data[7-10]:  buffer_addr      |                       |143 *   |          |         |      |         | Data[11-14]: buffer_size      |                       |144 *   |          |         |      |         | Data[15-18]: period_size      |                       |145 *   |          |         |      |         | Data[19-22]: buffer_tail      |                       |146 *   +----------+---------+------+---------+-------------------------------+-----------------------+147 *   |  0x03    | 0x0100  | 0x00 |  0x14   | Data[0]: Audio Device Index   | Set register value    |148 *   |          |         |      |         | Data[1-6]:   reserved         | to codec              |149 *   |          |         |      |         | Data[7-10]:  register         |                       |150 *   |          |         |      |         | Data[11-14]: value            |                       |151 *   |          |         |      |         | Data[15-22]: reserved         |                       |152 *   +----------+---------+------+---------+-------------------------------+-----------------------+153 *   |  0x03    | 0x0100  | 0x00 |  0x15   | Data[0]: Audio Device Index   | Get register value    |154 *   |          |         |      |         | Data[1-6]:   reserved         | from codec            |155 *   |          |         |      |         | Data[7-10]:  register         |                       |156 *   |          |         |      |         | Data[11-22]: reserved         |                       |157 *   +----------+---------+------+---------+-------------------------------+-----------------------+158 *   Note 1: See <List of Sample Format> for available value of159 *           Sample Format;160 *   Note 2: See <List of Audio Channels> for available value of Channels;161 *   Note 3: Sample Rate of Set Parameters for an Audio TX Instance162 *           Command and Set Parameters for an Audio RX Instance Command is163 *           in little-endian format.164 *165 *   SRTM Audio Control Category Response Command Table:166 *   +----------+---------+------+---------+-------------------------------+-----------------------+167 *   | Category | Version | Type | Command | Data                          | Function              |168 *   +----------+---------+------+---------+-------------------------------+-----------------------+169 *   |  0x03    | 0x0100  | 0x01 |  0x00   | Data[0]: Audio Device Index   | Reply for Open        |170 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |171 *   +----------+---------+------+---------+-------------------------------+-----------------------+172 *   |  0x03    | 0x0100  | 0x01 |  0x01   | Data[0]: Audio Device Index   | Reply for Start       |173 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |174 *   +----------+---------+------+---------+-------------------------------+-----------------------+175 *   |  0x03    | 0x0100  | 0x01 |  0x02   | Data[0]: Audio Device Index   | Reply for Pause       |176 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |177 *   +----------+---------+------+---------+-------------------------------+-----------------------+178 *   |  0x03    | 0x0100  | 0x01 |  0x03   | Data[0]: Audio Device Index   | Reply for Resume      |179 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |180 *   +----------+---------+------+---------+-------------------------------+-----------------------+181 *   |  0x03    | 0x0100  | 0x01 |  0x04   | Data[0]: Audio Device Index   | Reply for Stop        |182 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |183 *   +----------+---------+------+---------+-------------------------------+-----------------------+184 *   |  0x03    | 0x0100  | 0x01 |  0x05   | Data[0]: Audio Device Index   | Reply for Close       |185 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |186 *   +----------+---------+------+---------+-------------------------------+-----------------------+187 *   |  0x03    | 0x0100  | 0x01 |  0x06   | Data[0]: Audio Device Index   | Reply for Set Param   |188 *   |          |         |      |         | Data[1]: Return code          | for a TX Instance.    |189 *   +----------+---------+------+---------+-------------------------------+-----------------------+190 *   |  0x03    | 0x0100  | 0x01 |  0x07   | Data[0]: Audio Device Index   | Reply for Set         |191 *   |          |         |      |         | Data[1]: Return code          | TX Buffer             |192 *   +----------+---------+------+---------+-------------------------------+-----------------------+193 *   |  0x03    | 0x0100  | 0x01 |  0x08   | Data[0]: Audio Device Index   | Reply for Suspend     |194 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |195 *   +----------+---------+------+---------+-------------------------------+-----------------------+196 *   |  0x03    | 0x0100  | 0x01 |  0x09   | Data[0]: Audio Device Index   | Reply for Resume      |197 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |198 *   +----------+---------+------+---------+-------------------------------+-----------------------+199 *   |  0x03    | 0x0100  | 0x01 |  0x0A   | Data[0]: Audio Device Index   | Reply for Open        |200 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |201 *   +----------+---------+------+---------+-------------------------------+-----------------------+202 *   |  0x03    | 0x0100  | 0x01 |  0x0B   | Data[0]: Audio Device Index   | Reply for Start       |203 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |204 *   +----------+---------+------+---------+-------------------------------+-----------------------+205 *   |  0x03    | 0x0100  | 0x01 |  0x0C   | Data[0]: Audio Device Index   | Reply for Pause       |206 *   |          |         |      |         | Data[1]: Return code          | a TX Instance         |207 *   +----------+---------+------+---------+-------------------------------+-----------------------+208 *   |  0x03    | 0x0100  | 0x01 |  0x0D   | Data[0]: Audio Device Index   | Reply for Resume      |209 *   |          |         |      |         | Data[1]: Return code          | a RX Instance         |210 *   +----------+---------+------+---------+-------------------------------+-----------------------+211 *   |  0x03    | 0x0100  | 0x01 |  0x0E   | Data[0]: Audio Device Index   | Reply for Stop        |212 *   |          |         |      |         | Data[1]: Return code          | a RX Instance         |213 *   +----------+---------+------+---------+-------------------------------+-----------------------+214 *   |  0x03    | 0x0100  | 0x01 |  0x0F   | Data[0]: Audio Device Index   | Reply for Close       |215 *   |          |         |      |         | Data[1]: Return code          | a RX Instance         |216 *   +----------+---------+------+---------+-------------------------------+-----------------------+217 *   |  0x03    | 0x0100  | 0x01 |  0x10   | Data[0]: Audio Device Index   | Reply for Set Param   |218 *   |          |         |      |         | Data[1]: Return code          | for a RX Instance.    |219 *   +----------+---------+------+---------+-------------------------------+-----------------------+220 *   |  0x03    | 0x0100  | 0x01 |  0x11   | Data[0]: Audio Device Index   | Reply for Set         |221 *   |          |         |      |         | Data[1]: Return code          | RX Buffer             |222 *   +----------+---------+------+---------+-------------------------------+-----------------------+223 *   |  0x03    | 0x0100  | 0x01 |  0x12   | Data[0]: Audio Device Index   | Reply for Suspend     |224 *   |          |         |      |         | Data[1]: Return code          | a RX Instance         |225 *   +----------+---------+------+---------+-------------------------------+-----------------------+226 *   |  0x03    | 0x0100  | 0x01 |  0x13   | Data[0]: Audio Device Index   | Reply for Resume      |227 *   |          |         |      |         | Data[1]: Return code          | a RX Instance         |228 *   +----------+---------+------+---------+-------------------------------+-----------------------+229 *   |  0x03    | 0x0100  | 0x01 |  0x14   | Data[0]: Audio Device Index   | Reply for Set codec   |230 *   |          |         |      |         | Data[1]: Return code          | register value        |231 *   +----------+---------+------+---------+-------------------------------+-----------------------+232 *   |  0x03    | 0x0100  | 0x01 |  0x15   | Data[0]: Audio Device Index   | Reply for Get codec   |233 *   |          |         |      |         | Data[1]: Return code          | register value        |234 *   |          |         |      |         | Data[2-6]:   reserved         |                       |235 *   |          |         |      |         | Data[7-10]:  register         |                       |236 *   |          |         |      |         | Data[11-14]: value            |                       |237 *   |          |         |      |         | Data[15-22]: reserved         |                       |238 *   +----------+---------+------+---------+-------------------------------+-----------------------+239 *240 *   SRTM Audio Control Category Notification Command Table:241 *   +----------+---------+------+---------+-------------------------------+-----------------------+242 *   | Category | Version | Type | Command | Data                          | Function              |243 *   +----------+---------+------+---------+-------------------------------+-----------------------+244 *   |  0x03    | 0x0100  | 0x02 |  0x00   | Data[0]: Audio Device Index   | Notify one TX period  |245 *   |          |         |      |         |                               | is finished           |246 *   +----------+---------+------+---------+-------------------------------+-----------------------+247 *   |  0x03    | 0x0100  | 0x02 |  0x01   | Data[0]: Audio Device Index   | Notify one RX period  |248 *   |          |         |      |         |                               | is finished           |249 *   +----------+---------+------+---------+-------------------------------+-----------------------+250 *251 *   List of Sample Format:252 *   +------------------+-----------------------+253 *   | Sample Format    |   Description         |254 *   +------------------+-----------------------+255 *   |       0x0        | S16_LE                |256 *   +------------------+-----------------------+257 *   |       0x1        | S24_LE                |258 *   +------------------+-----------------------+259 *260 *   List of Audio Channels261 *   +------------------+-----------------------+262 *   |  Audio Channel   |   Description         |263 *   +------------------+-----------------------+264 *   |       0x0        | Left Channel          |265 *   +------------------+-----------------------+266 *   |       0x1        | Right Channel         |267 *   +------------------+---------------- ------+268 *   |       0x2        | Left & Right Channel  |269 *   +------------------+-----------------------+270 *271 */272 273#ifndef _IMX_PCM_RPMSG_H274#define _IMX_PCM_RPMSG_H275 276#include <linux/pm_qos.h>277#include <linux/interrupt.h>278#include <sound/dmaengine_pcm.h>279 280#define RPMSG_TIMEOUT 1000281 282/* RPMSG Command (TYPE A)*/283#define TX_OPEN		0x0284#define	TX_START	0x1285#define	TX_PAUSE	0x2286#define	TX_RESTART	0x3287#define	TX_TERMINATE	0x4288#define	TX_CLOSE	0x5289#define TX_HW_PARAM	0x6290#define	TX_BUFFER	0x7291#define	TX_SUSPEND	0x8292#define	TX_RESUME	0x9293 294#define	RX_OPEN		0xA295#define	RX_START	0xB296#define	RX_PAUSE	0xC297#define	RX_RESTART	0xD298#define	RX_TERMINATE	0xE299#define	RX_CLOSE	0xF300#define	RX_HW_PARAM	0x10301#define	RX_BUFFER	0x11302#define	RX_SUSPEND	0x12303#define	RX_RESUME	0x13304#define SET_CODEC_VALUE 0x14305#define GET_CODEC_VALUE 0x15306#define	TX_POINTER	0x16307#define	RX_POINTER	0x17308/* Total msg numver for type A */309#define MSG_TYPE_A_NUM  0x18310 311/* RPMSG Command (TYPE C)*/312#define	TX_PERIOD_DONE	0x0313#define	RX_PERIOD_DONE	0x1314/* Total msg numver for type C */315#define MSG_TYPE_C_NUM  0x2316 317#define MSG_MAX_NUM     (MSG_TYPE_A_NUM + MSG_TYPE_C_NUM)318 319#define MSG_TYPE_A	0x0320#define MSG_TYPE_B	0x1321#define MSG_TYPE_C	0x2322 323#define RESP_NONE		0x0324#define RESP_NOT_ALLOWED	0x1325#define	RESP_SUCCESS		0x2326#define	RESP_FAILED		0x3327 328#define	RPMSG_S16_LE		0x0329#define	RPMSG_S24_LE		0x1330#define	RPMSG_S32_LE		0x2331#define	RPMSG_DSD_U16_LE	49  /* SNDRV_PCM_FORMAT_DSD_U16_LE */332#define	RPMSG_DSD_U24_LE	0x4333#define	RPMSG_DSD_U32_LE	50  /* SNDRV_PCM_FORMAT_DSD_U32_LE */334 335#define	RPMSG_CH_LEFT		0x0336#define	RPMSG_CH_RIGHT		0x1337#define	RPMSG_CH_STEREO		0x2338 339#define WORK_MAX_NUM    0x30340 341/* Category define */342#define IMX_RMPSG_LIFECYCLE     1343#define IMX_RPMSG_PMIC          2344#define IMX_RPMSG_AUDIO         3345#define IMX_RPMSG_KEY           4346#define IMX_RPMSG_GPIO          5347#define IMX_RPMSG_RTC           6348#define IMX_RPMSG_SENSOR        7349 350/* rpmsg version */351#define IMX_RMPSG_MAJOR         1352#define IMX_RMPSG_MINOR         0353 354#define TX SNDRV_PCM_STREAM_PLAYBACK355#define RX SNDRV_PCM_STREAM_CAPTURE356 357/**358 * struct rpmsg_head: rpmsg header structure359 *360 * @cate: category361 * @major: major version362 * @minor: minor version363 * @type: message type (A/B/C)364 * @cmd: message command365 * @reserved: reserved space366 */367struct rpmsg_head {368	u8 cate;369	u8 major;370	u8 minor;371	u8 type;372	u8 cmd;373	u8 reserved[5];374} __packed;375 376/**377 * struct param_s: sent rpmsg parameter378 *379 * @audioindex: audio instance index380 * @format: audio format381 * @channels: audio channel number382 * @rate: sample rate383 * @buffer_addr: dma buffer physical address or register for SET_CODEC_VALUE384 * @buffer_size: dma buffer size or register value for SET_CODEC_VALUE385 * @period_size: period size386 * @buffer_tail: current period index387 */388struct param_s {389	unsigned char audioindex;390	unsigned char format;391	unsigned char channels;392	unsigned int  rate;393	unsigned int  buffer_addr;394	unsigned int  buffer_size;395	unsigned int  period_size;396	unsigned int  buffer_tail;397} __packed;398 399/**400 * struct param_s: send rpmsg parameter401 *402 * @audioindex: audio instance index403 * @resp: response value404 * @reserved1: reserved space405 * @buffer_offset: the consumed offset of buffer406 * @reg_addr: register addr of codec407 * @reg_data: register value of codec408 * @reserved2: reserved space409 * @buffer_tail: current period index410 */411struct param_r {412	unsigned char audioindex;413	unsigned char resp;414	unsigned char reserved1[1];415	unsigned int  buffer_offset;416	unsigned int  reg_addr;417	unsigned int  reg_data;418	unsigned char reserved2[4];419	unsigned int  buffer_tail;420} __packed;421 422/* Struct of sent message */423struct rpmsg_s_msg {424	struct rpmsg_head header;425	struct param_s    param;426};427 428/* Struct of received message */429struct rpmsg_r_msg {430	struct rpmsg_head header;431	struct param_r    param;432};433 434/* Struct of rpmsg */435struct rpmsg_msg {436	struct rpmsg_s_msg  s_msg;437	struct rpmsg_r_msg  r_msg;438};439 440/* Struct of rpmsg for workqueue */441struct work_of_rpmsg {442	struct rpmsg_info   *info;443	/* Sent msg for each work */444	struct rpmsg_msg    msg;445	struct work_struct  work;446};447 448/* Struct of timer */449struct stream_timer {450	struct timer_list   timer;451	struct rpmsg_info   *info;452	struct snd_pcm_substream *substream;453};454 455typedef void (*dma_callback)(void *arg);456 457/**458 * struct rpmsg_info: rpmsg audio information459 *460 * @rpdev: pointer of rpmsg_device461 * @dev: pointer for imx_pcm_rpmsg device462 * @cmd_complete: command is finished463 * @pm_qos_req: request of pm qos464 * @r_msg: received rpmsg465 * @msg: array of rpmsg466 * @notify: notification msg (type C) for TX & RX467 * @notify_updated: notification flag for TX & RX468 * @rpmsg_wq: rpmsg workqueue469 * @work_list: array of work list for workqueue470 * @work_write_index: write index of work list471 * @work_read_index: read index of work list472 * @msg_drop_count: counter of dropped msg for TX & RX473 * @num_period: period number for TX & RX474 * @callback_param: parameter for period elapse callback for TX & RX475 * @callback: period elapse callback for TX & RX476 * @send_message: function pointer for send message477 * @lock: spin lock for TX & RX478 * @wq_lock: lock for work queue479 * @msg_lock: lock for send message480 * @stream_timer: timer for tigger workqueue481 */482struct rpmsg_info {483	struct rpmsg_device      *rpdev;484	struct device            *dev;485	struct completion        cmd_complete;486	struct pm_qos_request    pm_qos_req;487 488	/* Received msg (global) */489	struct rpmsg_r_msg       r_msg;490	struct rpmsg_msg         msg[MSG_MAX_NUM];491	/* period done */492	struct rpmsg_msg         notify[2];493	bool                     notify_updated[2];494 495	struct workqueue_struct  *rpmsg_wq;496	struct work_of_rpmsg	 work_list[WORK_MAX_NUM];497	int                      work_write_index;498	int                      work_read_index;499	int                      msg_drop_count[2];500	int                      num_period[2];501	void                     *callback_param[2];502	dma_callback             callback[2];503	int (*send_message)(struct rpmsg_msg *msg, struct rpmsg_info *info);504	spinlock_t               lock[2]; /* spin lock for resource protection */505	spinlock_t               wq_lock; /* spin lock for resource protection */506	struct mutex             msg_lock; /* mutex for resource protection */507	struct stream_timer      stream_timer[2];508};509 510#define IMX_PCM_DRV_NAME "imx_pcm_rpmsg"511 512#endif /* IMX_PCM_RPMSG_H */513