PageRenderTime 40ms CodeModel.GetById 22ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/arm/mach-fsm/qdsp6/dal.h

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase
C++ Header | 94 lines | 62 code | 14 blank | 18 comment | 3 complexity | 2bcf54114b41b08fcbbc0e648305d26e MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
 1/* arch/arm/mach-msm/qdsp6/dal.h
 2 *
 3 * Copyright (C) 2009 Google, Inc.
 4 * Author: Brian Swetland <swetland@google.com>
 5 *
 6 * This software is licensed under the terms of the GNU General Public
 7 * License version 2, as published by the Free Software Foundation, and
 8 * may be copied, distributed, and modified under those terms.
 9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef _MACH_MSM_DAL_
18#define _MACH_MSM_DAL_
19
20struct dal_client;
21
22struct dal_info {
23	uint32_t size;
24	uint32_t version;
25	char name[32];
26};
27
28typedef void (*dal_event_func_t)(void *data, int len, void *cookie);
29
30struct dal_client *dal_attach(uint32_t device_id, const char *name,
31			uint32_t cpu, dal_event_func_t func, void *cookie);
32
33int dal_detach(struct dal_client *client);
34
35int dal_call(struct dal_client *client,
36	     unsigned ddi, unsigned prototype,
37	     void *data, int data_len,
38	     void *reply, int reply_max);
39
40void dal_trace(struct dal_client *client);
41void dal_trace_dump(struct dal_client *client);
42
43/* function to call before panic on stalled dal calls */
44void dal_set_oops(struct dal_client *client, void (*oops)(void));
45
46/* convenience wrappers */
47int dal_call_f0(struct dal_client *client, uint32_t ddi,
48		uint32_t arg1);
49int dal_call_f1(struct dal_client *client, uint32_t ddi,
50		uint32_t arg1, uint32_t arg2);
51int dal_call_f5(struct dal_client *client, uint32_t ddi,
52		void *ibuf, uint32_t ilen);
53int dal_call_f6(struct dal_client *client, uint32_t ddi,
54		uint32_t s1, void *ibuf, uint32_t ilen);
55int dal_call_f9(struct dal_client *client, uint32_t ddi,
56		void *obuf, uint32_t olen);
57int dal_call_f13(struct dal_client *client, uint32_t ddi, void *ibuf1,
58		 uint32_t ilen1, void *ibuf2, uint32_t ilen2, void *obuf,
59		 uint32_t olen);
60int dal_call_f14(struct dal_client *client, uint32_t ddi, void *ibuf,
61		 uint32_t ilen, void *obuf1, uint32_t olen1, void *obuf2,
62		 uint32_t olen2, uint32_t *oalen2);
63
64/* common DAL operations */
65enum {
66	DAL_OP_ATTACH = 0,
67	DAL_OP_DETACH,
68	DAL_OP_INIT,
69	DAL_OP_DEINIT,
70	DAL_OP_OPEN,
71	DAL_OP_CLOSE,
72	DAL_OP_INFO,
73	DAL_OP_POWEREVENT,
74	DAL_OP_SYSREQUEST,
75	DAL_OP_FIRST_DEVICE_API,
76};
77
78static inline int check_version(struct dal_client *client, uint32_t version)
79{
80	struct dal_info info;
81	int res;
82
83	res = dal_call_f9(client, DAL_OP_INFO, &info, sizeof(struct dal_info));
84	if (!res) {
85		if (((info.version & 0xFFFF0000) != (version & 0xFFFF0000)) ||
86		((info.version & 0x0000FFFF) <
87		(version & 0x0000FFFF))) {
88			res = -EINVAL;
89		}
90	}
91	return res;
92}
93
94#endif