temp revert rk change
[firefly-linux-kernel-4.4.55.git] / drivers / video / tegra / host / nvhost_hwctx.h
1 /*
2  * drivers/video/tegra/host/nvhost_hwctx.h
3  *
4  * Tegra Graphics Host Hardware Context Interface
5  *
6  * Copyright (c) 2010, NVIDIA Corporation.
7  *
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.
12  *
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
16  * more details.
17  *
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.
21  */
22
23 #ifndef __NVHOST_HWCTX_H
24 #define __NVHOST_HWCTX_H
25
26 #include <linux/string.h>
27 #include <linux/kref.h>
28
29 #include <mach/nvhost.h>
30 #include <mach/nvmap.h>
31
32 struct nvhost_channel;
33
34 struct nvhost_hwctx {
35         struct kref ref;
36
37         struct nvhost_channel *channel;
38         bool valid;
39
40         struct nvmap_handle_ref *save;
41         u32 save_phys;
42         u32 save_size;
43         u32 save_incrs;
44         void *save_cpu_data;
45
46         struct nvmap_handle_ref *restore;
47         u32 restore_phys;
48         u32 restore_size;
49         u32 restore_incrs;
50 };
51
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);
57 };
58
59 int nvhost_3dctx_handler_init(struct nvhost_hwctx_handler *h);
60 int nvhost_mpectx_handler_init(struct nvhost_hwctx_handler *h);
61
62 static inline int nvhost_hwctx_handler_init(struct nvhost_hwctx_handler *h,
63                                             const char *module)
64 {
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);
69
70         return 0;
71 }
72
73 struct hwctx_reginfo {
74         unsigned int offset:12;
75         unsigned int count:16;
76         unsigned int type:2;
77 };
78
79 enum {
80         HWCTX_REGINFO_DIRECT = 0,
81         HWCTX_REGINFO_INDIRECT,
82         HWCTX_REGINFO_INDIRECT_OFFSET,
83         HWCTX_REGINFO_INDIRECT_DATA
84 };
85
86 #define HWCTX_REGINFO(offset, count, type) {offset, count, HWCTX_REGINFO_##type}
87
88 #endif