blob: 830995391646fa163608646bb09c17c4893e1254 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13#ifndef __APR_H_
14#define __APR_H_
15
16#define APR_Q6_NOIMG 0
17#define APR_Q6_LOADING 1
18#define APR_Q6_LOADED 2
19
20struct apr_q6 {
21 void *pil;
22 uint32_t state;
23 struct mutex lock;
24};
25
26struct apr_hdr {
27 uint16_t hdr_field;
28 uint16_t pkt_size;
29 uint8_t src_svc;
30 uint8_t src_domain;
31 uint16_t src_port;
32 uint8_t dest_svc;
33 uint8_t dest_domain;
34 uint16_t dest_port;
35 uint32_t token;
36 uint32_t opcode;
37};
38
39#define APR_HDR_LEN(hdr_len) ((hdr_len)/4)
40#define APR_PKT_SIZE(hdr_len, payload_len) ((hdr_len) + (payload_len))
41#define APR_HDR_FIELD(msg_type, hdr_len, ver)\
42 (((msg_type & 0x3) << 8) | ((hdr_len & 0xF) << 4) | (ver & 0xF))
43
44#define APR_HDR_SIZE sizeof(struct apr_hdr)
45
46/* Version */
47#define APR_PKT_VER 0x0
48
49/* Command and Response Types */
50#define APR_MSG_TYPE_EVENT 0x0
51#define APR_MSG_TYPE_CMD_RSP 0x1
52#define APR_MSG_TYPE_SEQ_CMD 0x2
53#define APR_MSG_TYPE_NSEQ_CMD 0x3
54#define APR_MSG_TYPE_MAX 0x04
55
56/* APR Basic Response Message */
57#define APR_BASIC_RSP_RESULT 0x000110E8
58#define APR_RSP_ACCEPTED 0x000100BE
59
60/* Domain IDs */
61#define APR_DOMAIN_SIM 0x1
62#define APR_DOMAIN_PC 0x2
63#define APR_DOMAIN_MODEM 0x3
64#define APR_DOMAIN_ADSP 0x4
65#define APR_DOMAIN_APPS 0x5
66#define APR_DOMAIN_MAX 0x6
67
68/* ADSP service IDs */
69#define APR_SVC_TEST_CLIENT 0x2
70#define APR_SVC_ADSP_CORE 0x3
71#define APR_SVC_AFE 0x4
72#define APR_SVC_VSM 0x5
73#define APR_SVC_VPM 0x6
74#define APR_SVC_ASM 0x7
75#define APR_SVC_ADM 0x8
76#define APR_SVC_ADSP_MVM 0x09
77#define APR_SVC_ADSP_CVS 0x0A
78#define APR_SVC_ADSP_CVP 0x0B
79#define APR_SVC_MAX 0x0C
80
81/* Modem Service IDs */
82#define APR_SVC_MVS 0x3
83#define APR_SVC_MVM 0x4
84#define APR_SVC_CVS 0x5
85#define APR_SVC_CVP 0x6
86#define APR_SVC_SRD 0x7
87
88/* APR Port IDs */
89#define APR_MAX_PORTS 0x40
90
91#define APR_NAME_MAX 0x40
92
93#define RESET_EVENTS 0xFFFFFFFF
94
95#define LPASS_RESTART_EVENT 0x1000
96#define LPASS_RESTART_READY 0x1001
97
98struct apr_client_data {
99 uint16_t reset_event;
100 uint16_t reset_proc;
101 uint16_t payload_size;
102 uint16_t hdr_len;
103 uint16_t msg_type;
104 uint16_t src;
105 uint16_t dest_svc;
106 uint16_t src_port;
107 uint16_t dest_port;
108 uint32_t token;
109 uint32_t opcode;
110 void *payload;
111};
112
113typedef int32_t (*apr_fn)(struct apr_client_data *data, void *priv);
114
115struct apr_svc {
116 uint16_t id;
117 uint16_t dest_id;
118 uint16_t client_id;
119 uint8_t rvd;
120 uint8_t port_cnt;
121 uint8_t svc_cnt;
122 uint8_t need_reset;
123 apr_fn port_fn[APR_MAX_PORTS];
124 void *port_priv[APR_MAX_PORTS];
125 apr_fn fn;
126 void *priv;
127 struct mutex m_lock;
128 spinlock_t w_lock;
129};
130
131struct apr_client {
132 uint8_t id;
133 uint8_t svc_cnt;
134 uint8_t rvd;
135 struct mutex m_lock;
136 struct apr_svc_ch_dev *handle;
137 struct apr_svc svc[APR_SVC_MAX];
138};
139
140struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn,
141 uint32_t src_port, void *priv);
142inline int apr_fill_hdr(void *handle, uint32_t *buf, uint16_t src_port,
143 uint16_t msg_type, uint16_t dest_port,
144 uint32_t token, uint32_t opcode, uint16_t len);
145
146int apr_send_pkt(void *handle, uint32_t *buf);
147int apr_deregister(void *handle);
148void change_q6_state(int state);
149void q6audio_dsp_not_responding(void);
150void apr_reset(void *handle);
151#endif