2 * drivers/video/tegra/host/nvhost_hwctx.h
4 * Tegra Graphics Host Hardware Context Interface
6 * Copyright (c) 2010, NVIDIA Corporation.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef __NVHOST_HWCTX_H
24 #define __NVHOST_HWCTX_H
26 #include <linux/string.h>
27 #include <linux/kref.h>
29 #include <mach/nvhost.h>
30 #include <mach/nvmap.h>
32 struct nvhost_channel;
37 struct nvhost_channel *channel;
40 struct nvmap_handle_ref *save;
46 struct nvmap_handle_ref *restore;
52 struct nvhost_hwctx_handler {
53 struct nvhost_hwctx * (*alloc) (struct nvhost_channel *ch);
54 void (*get) (struct nvhost_hwctx *ctx);
55 void (*put) (struct nvhost_hwctx *ctx);
56 void (*save_service) (struct nvhost_hwctx *ctx);
59 int nvhost_3dctx_handler_init(struct nvhost_hwctx_handler *h);
60 int nvhost_mpectx_handler_init(struct nvhost_hwctx_handler *h);
62 static inline int nvhost_hwctx_handler_init(struct nvhost_hwctx_handler *h,
65 if (strcmp(module, "gr3d") == 0)
66 return nvhost_3dctx_handler_init(h);
67 else if (strcmp(module, "mpe") == 0)
68 return nvhost_mpectx_handler_init(h);
73 struct hwctx_reginfo {
74 unsigned int offset:12;
75 unsigned int count:16;
80 HWCTX_REGINFO_DIRECT = 0,
81 HWCTX_REGINFO_INDIRECT,
82 HWCTX_REGINFO_INDIRECT_OFFSET,
83 HWCTX_REGINFO_INDIRECT_DATA
86 #define HWCTX_REGINFO(offset, count, type) {offset, count, HWCTX_REGINFO_##type}