blob: c28a5e5865948690064a3d4701abf85eda590bbd [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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
14#ifndef __DAL_H__
15#define __DAL_H__
16
17#include <linux/kernel.h>
18#include <mach/msm_smd.h>
19
20#define DALRPC_DEST_MODEM SMD_APPS_MODEM
21#define DALRPC_DEST_QDSP SMD_APPS_QDSP
22
23#define DALRPC_TIMEOUT_INFINITE -1
24
25enum {
26 DALDEVICE_ATTACH_IDX = 0,
27 DALDEVICE_DETACH_IDX,
28 DALDEVICE_INIT_IDX,
29 DALDEVICE_DEINIT_IDX,
30 DALDEVICE_OPEN_IDX,
31 DALDEVICE_CLOSE_IDX,
32 DALDEVICE_INFO_IDX,
33 DALDEVICE_POWEREVENT_IDX,
34 DALDEVICE_SYSREQUEST_IDX,
35 DALDEVICE_FIRST_DEVICE_API_IDX
36};
37
38struct daldevice_info_t {
39 uint32_t size;
40 uint32_t version;
41 char name[32];
42};
43
44#define DAL_CHUNK_NAME_LENGTH 12
45struct dal_chunk_header {
46 uint32_t size;
47 char name[DAL_CHUNK_NAME_LENGTH];
48 uint32_t lock;
49 uint32_t reserved;
50 uint32_t type;
51 uint32_t version;
52};
53
54int daldevice_attach(uint32_t device_id, char *port, int cpu,
55 void **handle_ptr);
56
57/* The caller must ensure there are no outstanding dalrpc calls on
58 * the client before (and while) calling daldevice_detach. */
59int daldevice_detach(void *handle);
60
61uint32_t dalrpc_fcn_0(uint32_t ddi_idx, void *handle, uint32_t s1);
62uint32_t dalrpc_fcn_1(uint32_t ddi_idx, void *handle, uint32_t s1,
63 uint32_t s2);
64uint32_t dalrpc_fcn_2(uint32_t ddi_idx, void *handle, uint32_t s1,
65 uint32_t *p_s2);
66uint32_t dalrpc_fcn_3(uint32_t ddi_idx, void *handle, uint32_t s1,
67 uint32_t s2, uint32_t s3);
68uint32_t dalrpc_fcn_4(uint32_t ddi_idx, void *handle, uint32_t s1,
69 uint32_t s2, uint32_t *p_s3);
70uint32_t dalrpc_fcn_5(uint32_t ddi_idx, void *handle, const void *ibuf,
71 uint32_t ilen);
72uint32_t dalrpc_fcn_6(uint32_t ddi_idx, void *handle, uint32_t s1,
73 const void *ibuf, uint32_t ilen);
74uint32_t dalrpc_fcn_7(uint32_t ddi_idx, void *handle, const void *ibuf,
75 uint32_t ilen, void *obuf, uint32_t olen,
76 uint32_t *oalen);
77uint32_t dalrpc_fcn_8(uint32_t ddi_idx, void *handle, const void *ibuf,
78 uint32_t ilen, void *obuf, uint32_t olen);
79uint32_t dalrpc_fcn_9(uint32_t ddi_idx, void *handle, void *obuf,
80 uint32_t olen);
81uint32_t dalrpc_fcn_10(uint32_t ddi_idx, void *handle, uint32_t s1,
82 const void *ibuf, uint32_t ilen, void *obuf,
83 uint32_t olen, uint32_t *oalen);
84uint32_t dalrpc_fcn_11(uint32_t ddi_idx, void *handle, uint32_t s1,
85 void *obuf, uint32_t olen);
86uint32_t dalrpc_fcn_12(uint32_t ddi_idx, void *handle, uint32_t s1,
87 void *obuf, uint32_t olen, uint32_t *oalen);
88uint32_t dalrpc_fcn_13(uint32_t ddi_idx, void *handle, const void *ibuf,
89 uint32_t ilen, const void *ibuf2, uint32_t ilen2,
90 void *obuf, uint32_t olen);
91uint32_t dalrpc_fcn_14(uint32_t ddi_idx, void *handle, const void *ibuf,
92 uint32_t ilen, void *obuf1, uint32_t olen1,
93 void *obuf2, uint32_t olen2, uint32_t *oalen2);
94uint32_t dalrpc_fcn_15(uint32_t ddi_idx, void *handle, const void *ibuf,
95 uint32_t ilen, const void *ibuf2, uint32_t ilen2,
96 void *obuf, uint32_t olen, uint32_t *oalen,
97 void *obuf2, uint32_t olen2);
98
99static inline uint32_t daldevice_info(void *handle,
100 struct daldevice_info_t *info,
101 uint32_t info_size)
102{
103 return dalrpc_fcn_9(DALDEVICE_INFO_IDX, handle, info, info_size);
104}
105
106static inline uint32_t daldevice_sysrequest(void *handle, uint32_t req_id,
107 const void *src_ptr,
108 uint32_t src_len, void *dest_ptr,
109 uint32_t dest_len,
110 uint32_t *dest_alen)
111{
112 return dalrpc_fcn_10(DALDEVICE_SYSREQUEST_IDX, handle, req_id,
113 src_ptr, src_len, dest_ptr, dest_len, dest_alen);
114}
115
116static inline uint32_t daldevice_init(void *handle)
117{
118 return dalrpc_fcn_0(DALDEVICE_INIT_IDX, handle, 0);
119}
120
121static inline uint32_t daldevice_deinit(void *handle)
122{
123 return dalrpc_fcn_0(DALDEVICE_DEINIT_IDX, handle, 0);
124}
125
126static inline uint32_t daldevice_open(void *handle, uint32_t mode)
127{
128 return dalrpc_fcn_0(DALDEVICE_OPEN_IDX, handle, mode);
129}
130
131static inline uint32_t daldevice_close(void *handle)
132{
133 return dalrpc_fcn_0(DALDEVICE_CLOSE_IDX, handle, 0);
134}
135
136void *dalrpc_alloc_event(void *handle);
137void *dalrpc_alloc_cb(void *handle,
138 void (*fn)(void *, uint32_t, void *, uint32_t),
139 void *context);
140void dalrpc_dealloc_event(void *handle,
141 void *ev_h);
142void dalrpc_dealloc_cb(void *handle,
143 void *cb_h);
144
145#define dalrpc_event_wait(ev_h, timeout) \
146 dalrpc_event_wait_multiple(1, &ev_h, timeout)
147
148int dalrpc_event_wait_multiple(int num, void **ev_h, int timeout);
149
150#endif /* __DAL_H__ */