diff options
Diffstat (limited to 'drivers/video/tegra/host/nvhost_cdma.h')
-rw-r--r-- | drivers/video/tegra/host/nvhost_cdma.h | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/drivers/video/tegra/host/nvhost_cdma.h b/drivers/video/tegra/host/nvhost_cdma.h new file mode 100644 index 00000000000..9cb9b827725 --- /dev/null +++ b/drivers/video/tegra/host/nvhost_cdma.h | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * drivers/video/tegra/host/nvhost_cdma.h | ||
3 | * | ||
4 | * Tegra Graphics Host Command DMA | ||
5 | * | ||
6 | * Copyright (c) 2010-2012, NVIDIA Corporation. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms and conditions of the GNU General Public License, | ||
10 | * version 2, as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
15 | * more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef __NVHOST_CDMA_H | ||
22 | #define __NVHOST_CDMA_H | ||
23 | |||
24 | #include <linux/sched.h> | ||
25 | #include <linux/semaphore.h> | ||
26 | |||
27 | #include <linux/nvhost.h> | ||
28 | #include <mach/nvmap.h> | ||
29 | #include <linux/list.h> | ||
30 | |||
31 | #include "nvhost_acm.h" | ||
32 | |||
33 | struct nvhost_syncpt; | ||
34 | struct nvhost_userctx_timeout; | ||
35 | struct nvhost_job; | ||
36 | |||
37 | /* | ||
38 | * cdma | ||
39 | * | ||
40 | * This is in charge of a host command DMA channel. | ||
41 | * Sends ops to a push buffer, and takes responsibility for unpinning | ||
42 | * (& possibly freeing) of memory after those ops have completed. | ||
43 | * Producer: | ||
44 | * begin | ||
45 | * push - send ops to the push buffer | ||
46 | * end - start command DMA and enqueue handles to be unpinned | ||
47 | * Consumer: | ||
48 | * update - call to update sync queue and push buffer, unpin memory | ||
49 | */ | ||
50 | |||
51 | struct nvmap_client_handle { | ||
52 | struct nvmap_client *client; | ||
53 | struct nvmap_handle *handle; | ||
54 | }; | ||
55 | |||
56 | struct push_buffer { | ||
57 | struct nvmap_handle_ref *mem; /* handle to pushbuffer memory */ | ||
58 | u32 *mapped; /* mapped pushbuffer memory */ | ||
59 | u32 phys; /* physical address of pushbuffer */ | ||
60 | u32 fence; /* index we've written */ | ||
61 | u32 cur; /* index to write to */ | ||
62 | struct nvmap_client_handle *nvmap; | ||
63 | /* nvmap handle for each opcode pair */ | ||
64 | }; | ||
65 | |||
66 | struct syncpt_buffer { | ||
67 | struct nvmap_handle_ref *mem; /* handle to pushbuffer memory */ | ||
68 | u32 *mapped; /* mapped gather buffer (at channel offset */ | ||
69 | u32 phys; /* physical address (at channel offset) */ | ||
70 | u32 incr_per_buffer; /* max # of incrs per GATHER */ | ||
71 | u32 words_per_incr; /* # of DWORDS in buffer to incr a syncpt */ | ||
72 | }; | ||
73 | |||
74 | struct buffer_timeout { | ||
75 | struct delayed_work wq; /* work queue */ | ||
76 | bool initialized; /* timer one-time setup flag */ | ||
77 | u32 syncpt_id; /* buffer completion syncpt id */ | ||
78 | u32 syncpt_val; /* syncpt value when completed */ | ||
79 | ktime_t start_ktime; /* starting time */ | ||
80 | /* context timeout information */ | ||
81 | struct nvhost_hwctx *ctx; | ||
82 | int clientid; | ||
83 | }; | ||
84 | |||
85 | enum cdma_event { | ||
86 | CDMA_EVENT_NONE, /* not waiting for any event */ | ||
87 | CDMA_EVENT_SYNC_QUEUE_EMPTY, /* wait for empty sync queue */ | ||
88 | CDMA_EVENT_PUSH_BUFFER_SPACE /* wait for space in push buffer */ | ||
89 | }; | ||
90 | |||
91 | struct nvhost_cdma { | ||
92 | struct mutex lock; /* controls access to shared state */ | ||
93 | struct semaphore sem; /* signalled when event occurs */ | ||
94 | enum cdma_event event; /* event that sem is waiting for */ | ||
95 | unsigned int slots_used; /* pb slots used in current submit */ | ||
96 | unsigned int slots_free; /* pb slots free in current submit */ | ||
97 | unsigned int first_get; /* DMAGET value, where submit begins */ | ||
98 | unsigned int last_put; /* last value written to DMAPUT */ | ||
99 | struct push_buffer push_buffer; /* channel's push buffer */ | ||
100 | struct syncpt_buffer syncpt_buffer; /* syncpt incr buffer */ | ||
101 | struct list_head sync_queue; /* job queue */ | ||
102 | struct buffer_timeout timeout; /* channel's timeout state/wq */ | ||
103 | bool running; | ||
104 | bool torndown; | ||
105 | }; | ||
106 | |||
107 | #define cdma_to_channel(cdma) container_of(cdma, struct nvhost_channel, cdma) | ||
108 | #define cdma_to_dev(cdma) nvhost_get_host(cdma_to_channel(cdma)->dev) | ||
109 | #define cdma_op(cdma) (cdma_to_dev(cdma)->op.cdma) | ||
110 | #define cdma_to_nvmap(cdma) ((cdma_to_dev(cdma))->nvmap) | ||
111 | #define pb_to_cdma(pb) container_of(pb, struct nvhost_cdma, push_buffer) | ||
112 | #define cdma_pb_op(cdma) (cdma_to_dev(cdma)->op.push_buffer) | ||
113 | |||
114 | int nvhost_cdma_init(struct nvhost_cdma *cdma); | ||
115 | void nvhost_cdma_deinit(struct nvhost_cdma *cdma); | ||
116 | void nvhost_cdma_stop(struct nvhost_cdma *cdma); | ||
117 | int nvhost_cdma_begin(struct nvhost_cdma *cdma, struct nvhost_job *job); | ||
118 | void nvhost_cdma_push(struct nvhost_cdma *cdma, u32 op1, u32 op2); | ||
119 | #define NVHOST_CDMA_PUSH_GATHER_CTXSAVE 0xffffffff | ||
120 | void nvhost_cdma_push_gather(struct nvhost_cdma *cdma, | ||
121 | struct nvmap_client *client, | ||
122 | struct nvmap_handle *handle, u32 op1, u32 op2); | ||
123 | void nvhost_cdma_end(struct nvhost_cdma *cdma, | ||
124 | struct nvhost_job *job); | ||
125 | void nvhost_cdma_update(struct nvhost_cdma *cdma); | ||
126 | int nvhost_cdma_flush(struct nvhost_cdma *cdma, int timeout); | ||
127 | void nvhost_cdma_peek(struct nvhost_cdma *cdma, | ||
128 | u32 dmaget, int slot, u32 *out); | ||
129 | unsigned int nvhost_cdma_wait_locked(struct nvhost_cdma *cdma, | ||
130 | enum cdma_event event); | ||
131 | void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma, | ||
132 | struct nvhost_syncpt *syncpt, struct device *dev); | ||
133 | #endif | ||