1 /*******************************************************************************
2 * Copyright (C) 2018 Cadence Design Systems, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to use this Software with Cadence processor cores only and
7 * not with any other processors and platforms, subject to
8 * the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included
11 * in all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 
21 ******************************************************************************/
22 
23 #ifndef __DSP_DRIVER_MAILBOX_H__
24 #define __DSP_DRIVER_MAILBOX_H__
25 
26 #include <stdint.h>
27 
28 #define HIKEY_MSG_HEAD_PROTECT_WORD 0xffff1234
29 #define HIKEY_MSG_BODY_PROTECT_WORD 0xffff4321
30 
31 #define	HIKEY_MSG_ID_AP_DSP_OM_CMD 0xDDCB
32 #define HIKEY_AUDIO_DSP_AP_OM_CMD   0xDDC9
33 
34 typedef enum HIFI_MSG_ID_ {
35 
36 	/*DTS command id from ap*/
37 	ID_AP_AUDIO_SET_DTS_ENABLE_CMD			= 0xDD36,
38 	ID_AP_AUDIO_SET_DTS_DEV_CMD			= 0xDD38,
39 	ID_AP_AUDIO_SET_DTS_GEQ_CMD			= 0xDD39,
40 	ID_AP_AUDIO_SET_DTS_GEQ_ENABLE_CMD		= 0xDD3B,
41 
42 	/* APºÍHIFIµÄ¿ØÖÆÍâÖöú»úHIFI codecœ»»¥ÏûÏ¢ */
43 	ID_AP_AUDIO_SET_EXCODEC_ENABLE_CMD		= 0xDD3D,
44 
45 	/* Voice Record */
46 	ID_AP_HIFI_VOICE_RECORD_START_CMD		= 0xDD40,
47 	ID_AP_HIFI_VOICE_RECORD_STOP_CMD		= 0xDD41,
48 
49 	/* voicePP MSG_ID */
50 	ID_AP_VOICEPP_START_REQ				= 0xDD42,						/* Æô¶¯VOICEPPÍš»° */
51 	ID_VOICEPP_MSG_START				= ID_AP_VOICEPP_START_REQ,
52 	ID_VOICEPP_AP_START_CNF				= 0xDD43,
53 	ID_AP_VOICEPP_STOP_REQ				= 0xDD44,						/* ÖÕÖ¹VOICEPPÍš»° */
54 	ID_VOICEPP_AP_STOP_CNF				= 0xDD45,
55 	ID_VOICEPP_MSG_END				= 0xDD4A,
56 
57 	ID_AP_AUDIO_PLAY_START_REQ			= 0xDD51,/* APÆô¶¯Hifi audio player requestÃüÁî */
58 	ID_AUDIO_AP_PLAY_START_CNF			= 0xDD52,/* HifiÆô¶¯audio playerºó»ØžŽAP confirmÃüÁî */
59 	ID_AP_AUDIO_PLAY_PAUSE_REQ			= 0xDD53,/* APÍ£Ö¹Hifi audio player requestÃüÁî */
60 	ID_AUDIO_AP_PLAY_PAUSE_CNF			= 0xDD54,/* HifiÍ£Ö¹audio playerºó»ØžŽAP confirmÃüÁî */
61 	ID_AUDIO_AP_PLAY_DONE_IND			= 0xDD56,/* HifiÍšÖªAP audio playerÒ»¿éÊýŸÝ²¥·ÅÍê±Ï»òÕß²¥·ÅÖжÏindication */
62 	ID_AP_AUDIO_PLAY_UPDATE_BUF_CMD			= 0xDD57,/* APÍšÖªHifiÐÂÊýŸÝ¿éžüÐÂcommand */
63 	ID_AP_AUDIO_PLAY_QUERY_TIME_REQ			= 0xDD59,/* AP²éѯHifi audio player²¥·Åœø¶ÈrequestÃüÁî */
64 	ID_AP_AUDIO_PLAY_WAKEUPTHREAD_REQ		= 0xDD5A,
65 	ID_AUDIO_AP_PLAY_QUERY_TIME_CNF			= 0xDD60,/* Hifi»ØžŽAP audio player²¥·Åœø¶ÈconfirmÃüÁî */
66 	ID_AP_AUDIO_PLAY_QUERY_STATUS_REQ		= 0xDD61,/* AP²éѯHifi audio player²¥·Å׎̬requestÃüÁî */
67 	ID_AUDIO_AP_PLAY_QUERY_STATUS_CNF		= 0xDD62,/* Hifi»ØžŽAP audio player²¥·Å׎̬confirmÃüÁî */
68 	ID_AP_AUDIO_PLAY_SEEK_REQ			= 0xDD63,/* AP seek Hifi audio playerµœÄ³Ò»Î»ÖÃrequestÃüÁî */
69 	ID_AUDIO_AP_PLAY_SEEK_CNF			= 0xDD64,/* Hifi»ØžŽAP seekœá¹ûconfirmÃüÁî */
70 	ID_AP_AUDIO_PLAY_SET_VOL_CMD			= 0xDD70,/* APÉèÖÃÒôÁ¿ÃüÁî */
71 	ID_AP_AUDIO_RECORD_PCM_HOOK_CMD			= 0xDD7A,/* AP ÍšÖªHIFI¿ªÊŒ×¥È¡PCMÊýŸÝ */
72 	ID_AUDIO_AP_UPDATE_PCM_BUFF_CMD			= 0xDD7C,
73 	ID_AP_AUDIO_DYN_EFFECT_GET_PARAM		= 0xDD7D,
74 	ID_AP_AUDIO_DYN_EFFECT_GET_PARAM_CNF		= 0xDD7E,
75 	ID_AP_AUDIO_DYN_EFFECT_TRIGGER			= 0xDD7F,
76 	/* enhance msgid between ap and hifi */
77 	ID_AP_HIFI_ENHANCE_START_REQ			= 0xDD81,
78 	ID_HIFI_AP_ENHANCE_START_CNF			= 0xDD82,
79 	ID_AP_HIFI_ENHANCE_STOP_REQ			= 0xDD83,
80 	ID_HIFI_AP_ENHANCE_STOP_CNF			= 0xDD84,
81 	ID_AP_HIFI_ENHANCE_SET_DEVICE_REQ		= 0xDD85,
82 	ID_HIFI_AP_ENHANCE_SET_DEVICE_CNF		= 0xDD86,
83 
84 	/* audio enhance msgid between ap and hifi */
85 	ID_AP_AUDIO_ENHANCE_SET_DEVICE_IND		= 0xDD91,
86 	ID_AP_AUDIO_MLIB_SET_PARA_IND			= 0xDD92,
87 	ID_AP_AUDIO_CMD_SET_SOURCE_CMD			= 0xDD95,
88 	ID_AP_AUDIO_CMD_SET_DEVICE_CMD			= 0xDD96,
89 	ID_AP_AUDIO_CMD_SET_MODE_CMD			= 0xDD97,
90 	ID_AP_AUDIO_CMD_SET_ANGLE_CMD			= 0xDD99,
91 
92 	/* for 3mic */
93 	ID_AP_AUDIO_ROUTING_COMPLETE_REQ		= 0xDDC0,/*AP ÍšÖªHIFI 3Mic/4Mic ͚·ÒÑœšÁ¢*/
94 	ID_AUDIO_AP_DP_CLK_EN_IND			= 0xDDC1,/* HIFI ÍšÖªAºËŽò¿ª»ò¹Ø±ÕCodec DPʱÖÓ */
95 	ID_AP_AUDIO_DP_CLK_STATE_IND			= 0xDDC2,/* AºËÍšÖªHIFI £¬Codec DPʱÖÓ׎̬( Žò¿ª»ò¹Ø±Õ) */
96 	ID_AUDIO_AP_OM_DUMP_CMD				= 0xDDC3,/* HIFI ÍšÖªAºËdumpÈÕÖŸ */
97 	ID_AUDIO_AP_FADE_OUT_REQ			= 0xDDC4,/* HIFIÍšÖªAP×öµ­³öŽŠÀí */
98 	ID_AP_AUDIO_FADE_OUT_IND			= 0xDDC5,/* APÍšÖªHIFIµ­³öÍê±Ï */
99 
100 	ID_AUDIO_AP_OM_CMD				= 0xDDC9,
101 	ID_AP_AUDIO_STR_CMD				= 0xDDCB,/* APžøHIFI·¢ËÍÒ»žö×Ö·ûŽ®£¬ŸßÌ庬ÒåhifiÖÐœâÎö */
102 	ID_AUDIO_AP_VOICE_BSD_PARAM_CMD			= 0xDDCC,/* VOICE BSD ²ÎÊýÉϱš */
103 
104 	ID_AP_ENABLE_MODEM_LOOP_REQ			= 0xDDCD,/* the audio hal notify HIFI to start/stop  MODEM LOOP*/
105 	ID_AP_HIFI_REQUEST_VOICE_PARA_REQ		= 0xDF00, /*AP REQUEST VOICE MSG*/
106 	ID_HIFI_AP_REQUEST_VOICE_PARA_CNF		= 0xDF01, /*HIFI REPLAY VOICE MSG*/
107 
108 	/* XAF message IDs */
109     ID_XAF_AP_TO_DSP                    = 0xDF10,
110     ID_XAF_DSP_TO_AP                    = 0xDF11,
111 } HIFI_MSG_ID;
112 
113 #define HIKEY_AP2DSP_MSG_QUEUE_ADDR HIFI_HIKEY_SHARE_MEM_ADDR
114 
115 #define HIKEY_AP2DSP_MSG_QUEUE_SIZE 0x1800
116 #define HIKEY_DSP2AP_MSG_QUEUE_ADDR (HIKEY_AP2DSP_MSG_QUEUE_ADDR + HIKEY_AP2DSP_MSG_QUEUE_SIZE)
117 #define HIKEY_DSP2AP_MSG_QUEUE_SIZE 0x1800
118 
119 #define HIKEY_AP_DSP_MSG_MAX_LEN 100
120 /////////////////////////////////////////////////////////////////////
121 //    XAF STRUCTURES                                               //
122 /////////////////////////////////////////////////////////////////////
123 #ifdef GJB_CHANGE
124 /* ...command/response message */
125 typedef struct xf_proxy_msg {
126 	/* ...session ID */
127 	uint32_t                 id;
128 
129 	/* ...proxy API command/reponse code */
130 	uint32_t                 opcode;
131 
132 	/* ...length of attached buffer */
133 	uint32_t                 length;
134 
135 	/* ...physical address of message buffer */
136 	uint64_t                 address;
137 	uint64_t                 v_address;
138 
139 }	__attribute__((__packed__)) xf_proxy_msg_t;
140 
141 struct hikey_ap_dsp_msg_head {
142 	unsigned int head_protect_word;
143 	unsigned int msg_num;
144 	unsigned int read_pos;
145 	unsigned int write_pos;
146 };
147 
148 /*struct hikey_ap_dsp_msg_body {
149 	unsigned short msg_id;
150 	unsigned short msg_len;
151 	char msg_content[0];
152 };*/
153 
154 struct hikey_ap_dsp_msg_body {
155 	unsigned short msg_id;
156 	unsigned short msg_len;
157     union {
158 	    char msg_content[0];
159         struct xf_proxy_msg xf_dsp_msg;
160     };
161 };
162 struct hikey_msg_with_content {
163 	struct hikey_ap_dsp_msg_body msg_info;
164 	char msg_content[HIKEY_AP_DSP_MSG_MAX_LEN];
165 };
166 void dsp_init_share_mem(char *share_mem_addr, unsigned int share_mem_size);
167 int dsp_mailbox_read(struct hikey_msg_with_content *hikey_msg);
168 void dsp_msg_process(struct hikey_msg_with_content *hikey_msg);
169 #else
170 #endif
171 #endif
172