diff options
author | Thierry Reding <treding@nvidia.com> | 2013-09-24 10:30:32 -0400 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2013-10-31 04:20:11 -0400 |
commit | 35d747a81d7eb824bd0c3476cd0c564b52ad5353 (patch) | |
tree | 75bf333cba5d9dfbce532bb0c1391ca9bbeb7b43 | |
parent | 53fa7f7204c97dc0c86b99ff8365ad6a7b2ebd78 (diff) |
gpu: host1x: Expose syncpt and channel functionality
Expose the buffer objects, syncpoint and channel functionality in the
public public header so that drivers can use them.
Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r-- | drivers/gpu/host1x/cdma.c | 2 | ||||
-rw-r--r-- | drivers/gpu/host1x/channel.h | 6 | ||||
-rw-r--r-- | drivers/gpu/host1x/drm/drm.c | 2 | ||||
-rw-r--r-- | drivers/gpu/host1x/drm/gem.h | 4 | ||||
-rw-r--r-- | drivers/gpu/host1x/drm/gr2d.c | 6 | ||||
-rw-r--r-- | drivers/gpu/host1x/drm/hdmi.c | 2 | ||||
-rw-r--r-- | drivers/gpu/host1x/host1x_bo.h | 87 | ||||
-rw-r--r-- | drivers/gpu/host1x/hw/channel_hw.c | 1 | ||||
-rw-r--r-- | drivers/gpu/host1x/hw/debug_hw.c | 1 | ||||
-rw-r--r-- | drivers/gpu/host1x/job.c | 2 | ||||
-rw-r--r-- | drivers/gpu/host1x/job.h | 108 | ||||
-rw-r--r-- | drivers/gpu/host1x/syncpt.c | 19 | ||||
-rw-r--r-- | drivers/gpu/host1x/syncpt.h | 40 | ||||
-rw-r--r-- | include/linux/host1x.h | 185 |
14 files changed, 211 insertions, 254 deletions
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c index de72172d3b5f..3995255b16c7 100644 --- a/drivers/gpu/host1x/cdma.c +++ b/drivers/gpu/host1x/cdma.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <asm/cacheflush.h> | 20 | #include <asm/cacheflush.h> |
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
23 | #include <linux/host1x.h> | ||
23 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
24 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
25 | #include <linux/kfifo.h> | 26 | #include <linux/kfifo.h> |
@@ -30,7 +31,6 @@ | |||
30 | #include "channel.h" | 31 | #include "channel.h" |
31 | #include "dev.h" | 32 | #include "dev.h" |
32 | #include "debug.h" | 33 | #include "debug.h" |
33 | #include "host1x_bo.h" | ||
34 | #include "job.h" | 34 | #include "job.h" |
35 | 35 | ||
36 | /* | 36 | /* |
diff --git a/drivers/gpu/host1x/channel.h b/drivers/gpu/host1x/channel.h index 48723b8eea42..df767cf90d51 100644 --- a/drivers/gpu/host1x/channel.h +++ b/drivers/gpu/host1x/channel.h | |||
@@ -40,12 +40,6 @@ struct host1x_channel { | |||
40 | /* channel list operations */ | 40 | /* channel list operations */ |
41 | int host1x_channel_list_init(struct host1x *host); | 41 | int host1x_channel_list_init(struct host1x *host); |
42 | 42 | ||
43 | struct host1x_channel *host1x_channel_request(struct device *dev); | ||
44 | void host1x_channel_free(struct host1x_channel *channel); | ||
45 | struct host1x_channel *host1x_channel_get(struct host1x_channel *channel); | ||
46 | void host1x_channel_put(struct host1x_channel *channel); | ||
47 | int host1x_job_submit(struct host1x_job *job); | ||
48 | |||
49 | #define host1x_for_each_channel(host, channel) \ | 43 | #define host1x_for_each_channel(host, channel) \ |
50 | list_for_each_entry(channel, &host->chlist.list, list) | 44 | list_for_each_entry(channel, &host->chlist.list, list) |
51 | 45 | ||
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c index 33d966145293..1abcdbc7f4cd 100644 --- a/drivers/gpu/host1x/drm/drm.c +++ b/drivers/gpu/host1x/drm/drm.c | |||
@@ -8,10 +8,8 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "host1x_client.h" | 10 | #include "host1x_client.h" |
11 | #include "dev.h" | ||
12 | #include "drm.h" | 11 | #include "drm.h" |
13 | #include "gem.h" | 12 | #include "gem.h" |
14 | #include "syncpt.h" | ||
15 | 13 | ||
16 | #define DRIVER_NAME "tegra" | 14 | #define DRIVER_NAME "tegra" |
17 | #define DRIVER_DESC "NVIDIA Tegra graphics" | 15 | #define DRIVER_DESC "NVIDIA Tegra graphics" |
diff --git a/drivers/gpu/host1x/drm/gem.h b/drivers/gpu/host1x/drm/gem.h index 492533a2dacb..2b54f1425d5e 100644 --- a/drivers/gpu/host1x/drm/gem.h +++ b/drivers/gpu/host1x/drm/gem.h | |||
@@ -19,11 +19,11 @@ | |||
19 | #ifndef __HOST1X_GEM_H | 19 | #ifndef __HOST1X_GEM_H |
20 | #define __HOST1X_GEM_H | 20 | #define __HOST1X_GEM_H |
21 | 21 | ||
22 | #include <linux/host1x.h> | ||
23 | |||
22 | #include <drm/drm.h> | 24 | #include <drm/drm.h> |
23 | #include <drm/drmP.h> | 25 | #include <drm/drmP.h> |
24 | 26 | ||
25 | #include "host1x_bo.h" | ||
26 | |||
27 | struct tegra_bo { | 27 | struct tegra_bo { |
28 | struct drm_gem_object gem; | 28 | struct drm_gem_object gem; |
29 | struct host1x_bo base; | 29 | struct host1x_bo base; |
diff --git a/drivers/gpu/host1x/drm/gr2d.c b/drivers/gpu/host1x/drm/gr2d.c index a7edc794c5ce..dfb822428ca0 100644 --- a/drivers/gpu/host1x/drm/gr2d.c +++ b/drivers/gpu/host1x/drm/gr2d.c | |||
@@ -16,13 +16,9 @@ | |||
16 | 16 | ||
17 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | 18 | ||
19 | #include "channel.h" | 19 | #include "host1x_client.h" |
20 | #include "drm.h" | 20 | #include "drm.h" |
21 | #include "gem.h" | 21 | #include "gem.h" |
22 | #include "job.h" | ||
23 | #include "host1x_bo.h" | ||
24 | #include "host1x_client.h" | ||
25 | #include "syncpt.h" | ||
26 | 22 | ||
27 | #define GR2D_NUM_REGS 0x4d | 23 | #define GR2D_NUM_REGS 0x4d |
28 | 24 | ||
diff --git a/drivers/gpu/host1x/drm/hdmi.c b/drivers/gpu/host1x/drm/hdmi.c index 30ac9e872b0d..a2370045993c 100644 --- a/drivers/gpu/host1x/drm/hdmi.c +++ b/drivers/gpu/host1x/drm/hdmi.c | |||
@@ -13,10 +13,10 @@ | |||
13 | #include <linux/hdmi.h> | 13 | #include <linux/hdmi.h> |
14 | #include <linux/regulator/consumer.h> | 14 | #include <linux/regulator/consumer.h> |
15 | 15 | ||
16 | #include "host1x_client.h" | ||
16 | #include "hdmi.h" | 17 | #include "hdmi.h" |
17 | #include "drm.h" | 18 | #include "drm.h" |
18 | #include "dc.h" | 19 | #include "dc.h" |
19 | #include "host1x_client.h" | ||
20 | 20 | ||
21 | struct tegra_hdmi { | 21 | struct tegra_hdmi { |
22 | struct tegra_drm_client client; | 22 | struct tegra_drm_client client; |
diff --git a/drivers/gpu/host1x/host1x_bo.h b/drivers/gpu/host1x/host1x_bo.h deleted file mode 100644 index 4c1f10bd773d..000000000000 --- a/drivers/gpu/host1x/host1x_bo.h +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* | ||
2 | * Tegra host1x Memory Management Abstraction header | ||
3 | * | ||
4 | * Copyright (c) 2012-2013, NVIDIA Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef _HOST1X_BO_H | ||
20 | #define _HOST1X_BO_H | ||
21 | |||
22 | struct host1x_bo; | ||
23 | |||
24 | struct host1x_bo_ops { | ||
25 | struct host1x_bo *(*get)(struct host1x_bo *bo); | ||
26 | void (*put)(struct host1x_bo *bo); | ||
27 | dma_addr_t (*pin)(struct host1x_bo *bo, struct sg_table **sgt); | ||
28 | void (*unpin)(struct host1x_bo *bo, struct sg_table *sgt); | ||
29 | void *(*mmap)(struct host1x_bo *bo); | ||
30 | void (*munmap)(struct host1x_bo *bo, void *addr); | ||
31 | void *(*kmap)(struct host1x_bo *bo, unsigned int pagenum); | ||
32 | void (*kunmap)(struct host1x_bo *bo, unsigned int pagenum, void *addr); | ||
33 | }; | ||
34 | |||
35 | struct host1x_bo { | ||
36 | const struct host1x_bo_ops *ops; | ||
37 | }; | ||
38 | |||
39 | static inline void host1x_bo_init(struct host1x_bo *bo, | ||
40 | const struct host1x_bo_ops *ops) | ||
41 | { | ||
42 | bo->ops = ops; | ||
43 | } | ||
44 | |||
45 | static inline struct host1x_bo *host1x_bo_get(struct host1x_bo *bo) | ||
46 | { | ||
47 | return bo->ops->get(bo); | ||
48 | } | ||
49 | |||
50 | static inline void host1x_bo_put(struct host1x_bo *bo) | ||
51 | { | ||
52 | bo->ops->put(bo); | ||
53 | } | ||
54 | |||
55 | static inline dma_addr_t host1x_bo_pin(struct host1x_bo *bo, | ||
56 | struct sg_table **sgt) | ||
57 | { | ||
58 | return bo->ops->pin(bo, sgt); | ||
59 | } | ||
60 | |||
61 | static inline void host1x_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt) | ||
62 | { | ||
63 | bo->ops->unpin(bo, sgt); | ||
64 | } | ||
65 | |||
66 | static inline void *host1x_bo_mmap(struct host1x_bo *bo) | ||
67 | { | ||
68 | return bo->ops->mmap(bo); | ||
69 | } | ||
70 | |||
71 | static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr) | ||
72 | { | ||
73 | bo->ops->munmap(bo, addr); | ||
74 | } | ||
75 | |||
76 | static inline void *host1x_bo_kmap(struct host1x_bo *bo, unsigned int pagenum) | ||
77 | { | ||
78 | return bo->ops->kmap(bo, pagenum); | ||
79 | } | ||
80 | |||
81 | static inline void host1x_bo_kunmap(struct host1x_bo *bo, | ||
82 | unsigned int pagenum, void *addr) | ||
83 | { | ||
84 | bo->ops->kunmap(bo, pagenum, addr); | ||
85 | } | ||
86 | |||
87 | #endif | ||
diff --git a/drivers/gpu/host1x/hw/channel_hw.c b/drivers/gpu/host1x/hw/channel_hw.c index c950bc655ade..aa9bdf331139 100644 --- a/drivers/gpu/host1x/hw/channel_hw.c +++ b/drivers/gpu/host1x/hw/channel_hw.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #include <trace/events/host1x.h> | 22 | #include <trace/events/host1x.h> |
23 | 23 | ||
24 | #include "host1x_bo.h" | ||
25 | #include "channel.h" | 24 | #include "channel.h" |
26 | #include "dev.h" | 25 | #include "dev.h" |
27 | #include "intr.h" | 26 | #include "intr.h" |
diff --git a/drivers/gpu/host1x/hw/debug_hw.c b/drivers/gpu/host1x/hw/debug_hw.c index dfad66312286..788fe7179d8f 100644 --- a/drivers/gpu/host1x/hw/debug_hw.c +++ b/drivers/gpu/host1x/hw/debug_hw.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include "debug.h" | 19 | #include "debug.h" |
20 | #include "cdma.h" | 20 | #include "cdma.h" |
21 | #include "channel.h" | 21 | #include "channel.h" |
22 | #include "host1x_bo.h" | ||
23 | 22 | ||
24 | #define HOST1X_DEBUG_MAX_PAGE_OFFSET 102400 | 23 | #define HOST1X_DEBUG_MAX_PAGE_OFFSET 102400 |
25 | 24 | ||
diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c index d1b72f4c744d..de5ec333ce1a 100644 --- a/drivers/gpu/host1x/job.c +++ b/drivers/gpu/host1x/job.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
20 | #include <linux/err.h> | 20 | #include <linux/err.h> |
21 | #include <linux/host1x.h> | ||
21 | #include <linux/kref.h> | 22 | #include <linux/kref.h> |
22 | #include <linux/module.h> | 23 | #include <linux/module.h> |
23 | #include <linux/scatterlist.h> | 24 | #include <linux/scatterlist.h> |
@@ -27,7 +28,6 @@ | |||
27 | 28 | ||
28 | #include "channel.h" | 29 | #include "channel.h" |
29 | #include "dev.h" | 30 | #include "dev.h" |
30 | #include "host1x_bo.h" | ||
31 | #include "job.h" | 31 | #include "job.h" |
32 | #include "syncpt.h" | 32 | #include "syncpt.h" |
33 | 33 | ||
diff --git a/drivers/gpu/host1x/job.h b/drivers/gpu/host1x/job.h index fba45f20458e..33a697d6dcef 100644 --- a/drivers/gpu/host1x/job.h +++ b/drivers/gpu/host1x/job.h | |||
@@ -34,15 +34,6 @@ struct host1x_cmdbuf { | |||
34 | u32 pad; | 34 | u32 pad; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | struct host1x_reloc { | ||
38 | struct host1x_bo *cmdbuf; | ||
39 | u32 cmdbuf_offset; | ||
40 | struct host1x_bo *target; | ||
41 | u32 target_offset; | ||
42 | u32 shift; | ||
43 | u32 pad; | ||
44 | }; | ||
45 | |||
46 | struct host1x_waitchk { | 37 | struct host1x_waitchk { |
47 | struct host1x_bo *bo; | 38 | struct host1x_bo *bo; |
48 | u32 offset; | 39 | u32 offset; |
@@ -56,105 +47,6 @@ struct host1x_job_unpin_data { | |||
56 | }; | 47 | }; |
57 | 48 | ||
58 | /* | 49 | /* |
59 | * Each submit is tracked as a host1x_job. | ||
60 | */ | ||
61 | struct host1x_job { | ||
62 | /* When refcount goes to zero, job can be freed */ | ||
63 | struct kref ref; | ||
64 | |||
65 | /* List entry */ | ||
66 | struct list_head list; | ||
67 | |||
68 | /* Channel where job is submitted to */ | ||
69 | struct host1x_channel *channel; | ||
70 | |||
71 | u32 client; | ||
72 | |||
73 | /* Gathers and their memory */ | ||
74 | struct host1x_job_gather *gathers; | ||
75 | unsigned int num_gathers; | ||
76 | |||
77 | /* Wait checks to be processed at submit time */ | ||
78 | struct host1x_waitchk *waitchk; | ||
79 | unsigned int num_waitchk; | ||
80 | u32 waitchk_mask; | ||
81 | |||
82 | /* Array of handles to be pinned & unpinned */ | ||
83 | struct host1x_reloc *relocarray; | ||
84 | unsigned int num_relocs; | ||
85 | struct host1x_job_unpin_data *unpins; | ||
86 | unsigned int num_unpins; | ||
87 | |||
88 | dma_addr_t *addr_phys; | ||
89 | dma_addr_t *gather_addr_phys; | ||
90 | dma_addr_t *reloc_addr_phys; | ||
91 | |||
92 | /* Sync point id, number of increments and end related to the submit */ | ||
93 | u32 syncpt_id; | ||
94 | u32 syncpt_incrs; | ||
95 | u32 syncpt_end; | ||
96 | |||
97 | /* Maximum time to wait for this job */ | ||
98 | unsigned int timeout; | ||
99 | |||
100 | /* Index and number of slots used in the push buffer */ | ||
101 | unsigned int first_get; | ||
102 | unsigned int num_slots; | ||
103 | |||
104 | /* Copy of gathers */ | ||
105 | size_t gather_copy_size; | ||
106 | dma_addr_t gather_copy; | ||
107 | u8 *gather_copy_mapped; | ||
108 | |||
109 | /* Check if register is marked as an address reg */ | ||
110 | int (*is_addr_reg)(struct device *dev, u32 reg, u32 class); | ||
111 | |||
112 | /* Request a SETCLASS to this class */ | ||
113 | u32 class; | ||
114 | |||
115 | /* Add a channel wait for previous ops to complete */ | ||
116 | bool serialize; | ||
117 | }; | ||
118 | /* | ||
119 | * Allocate memory for a job. Just enough memory will be allocated to | ||
120 | * accomodate the submit. | ||
121 | */ | ||
122 | struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, | ||
123 | u32 num_cmdbufs, u32 num_relocs, | ||
124 | u32 num_waitchks); | ||
125 | |||
126 | /* | ||
127 | * Add a gather to a job. | ||
128 | */ | ||
129 | void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *mem_id, | ||
130 | u32 words, u32 offset); | ||
131 | |||
132 | /* | ||
133 | * Increment reference going to host1x_job. | ||
134 | */ | ||
135 | struct host1x_job *host1x_job_get(struct host1x_job *job); | ||
136 | |||
137 | /* | ||
138 | * Decrement reference job, free if goes to zero. | ||
139 | */ | ||
140 | void host1x_job_put(struct host1x_job *job); | ||
141 | |||
142 | /* | ||
143 | * Pin memory related to job. This handles relocation of addresses to the | ||
144 | * host1x address space. Handles both the gather memory and any other memory | ||
145 | * referred to from the gather buffers. | ||
146 | * | ||
147 | * Handles also patching out host waits that would wait for an expired sync | ||
148 | * point value. | ||
149 | */ | ||
150 | int host1x_job_pin(struct host1x_job *job, struct device *dev); | ||
151 | |||
152 | /* | ||
153 | * Unpin memory related to job. | ||
154 | */ | ||
155 | void host1x_job_unpin(struct host1x_job *job); | ||
156 | |||
157 | /* | ||
158 | * Dump contents of job to debug output. | 50 | * Dump contents of job to debug output. |
159 | */ | 51 | */ |
160 | void host1x_job_dump(struct device *dev, struct host1x_job *job); | 52 | void host1x_job_dump(struct device *dev, struct host1x_job *job); |
diff --git a/drivers/gpu/host1x/syncpt.c b/drivers/gpu/host1x/syncpt.c index 409745b949db..03cf2922e469 100644 --- a/drivers/gpu/host1x/syncpt.c +++ b/drivers/gpu/host1x/syncpt.c | |||
@@ -354,6 +354,25 @@ void host1x_syncpt_deinit(struct host1x *host) | |||
354 | kfree(sp->name); | 354 | kfree(sp->name); |
355 | } | 355 | } |
356 | 356 | ||
357 | /* | ||
358 | * Read max. It indicates how many operations there are in queue, either in | ||
359 | * channel or in a software thread. | ||
360 | * */ | ||
361 | u32 host1x_syncpt_read_max(struct host1x_syncpt *sp) | ||
362 | { | ||
363 | smp_rmb(); | ||
364 | return (u32)atomic_read(&sp->max_val); | ||
365 | } | ||
366 | |||
367 | /* | ||
368 | * Read min, which is a shadow of the current sync point value in hardware. | ||
369 | */ | ||
370 | u32 host1x_syncpt_read_min(struct host1x_syncpt *sp) | ||
371 | { | ||
372 | smp_rmb(); | ||
373 | return (u32)atomic_read(&sp->min_val); | ||
374 | } | ||
375 | |||
357 | int host1x_syncpt_nb_pts(struct host1x *host) | 376 | int host1x_syncpt_nb_pts(struct host1x *host) |
358 | { | 377 | { |
359 | return host->info->nb_pts; | 378 | return host->info->nb_pts; |
diff --git a/drivers/gpu/host1x/syncpt.h b/drivers/gpu/host1x/syncpt.h index 267c0b9d3647..4eb933a497fd 100644 --- a/drivers/gpu/host1x/syncpt.h +++ b/drivers/gpu/host1x/syncpt.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #define __HOST1X_SYNCPT_H | 20 | #define __HOST1X_SYNCPT_H |
21 | 21 | ||
22 | #include <linux/atomic.h> | 22 | #include <linux/atomic.h> |
23 | #include <linux/host1x.h> | ||
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
24 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
25 | 26 | ||
@@ -50,25 +51,6 @@ int host1x_syncpt_init(struct host1x *host); | |||
50 | /* Free sync point array */ | 51 | /* Free sync point array */ |
51 | void host1x_syncpt_deinit(struct host1x *host); | 52 | void host1x_syncpt_deinit(struct host1x *host); |
52 | 53 | ||
53 | /* | ||
54 | * Read max. It indicates how many operations there are in queue, either in | ||
55 | * channel or in a software thread. | ||
56 | * */ | ||
57 | static inline u32 host1x_syncpt_read_max(struct host1x_syncpt *sp) | ||
58 | { | ||
59 | smp_rmb(); | ||
60 | return (u32)atomic_read(&sp->max_val); | ||
61 | } | ||
62 | |||
63 | /* | ||
64 | * Read min, which is a shadow of the current sync point value in hardware. | ||
65 | */ | ||
66 | static inline u32 host1x_syncpt_read_min(struct host1x_syncpt *sp) | ||
67 | { | ||
68 | smp_rmb(); | ||
69 | return (u32)atomic_read(&sp->min_val); | ||
70 | } | ||
71 | |||
72 | /* Return number of sync point supported. */ | 54 | /* Return number of sync point supported. */ |
73 | int host1x_syncpt_nb_pts(struct host1x *host); | 55 | int host1x_syncpt_nb_pts(struct host1x *host); |
74 | 56 | ||
@@ -112,9 +94,6 @@ static inline bool host1x_syncpt_idle(struct host1x_syncpt *sp) | |||
112 | return (min == max); | 94 | return (min == max); |
113 | } | 95 | } |
114 | 96 | ||
115 | /* Return pointer to struct denoting sync point id. */ | ||
116 | struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, u32 id); | ||
117 | |||
118 | /* Load current value from hardware to the shadow register. */ | 97 | /* Load current value from hardware to the shadow register. */ |
119 | u32 host1x_syncpt_load(struct host1x_syncpt *sp); | 98 | u32 host1x_syncpt_load(struct host1x_syncpt *sp); |
120 | 99 | ||
@@ -130,16 +109,9 @@ void host1x_syncpt_restore(struct host1x *host); | |||
130 | /* Read current wait base value into shadow register and return it. */ | 109 | /* Read current wait base value into shadow register and return it. */ |
131 | u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp); | 110 | u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp); |
132 | 111 | ||
133 | /* Request incrementing a sync point. */ | ||
134 | int host1x_syncpt_incr(struct host1x_syncpt *sp); | ||
135 | |||
136 | /* Indicate future operations by incrementing the sync point max. */ | 112 | /* Indicate future operations by incrementing the sync point max. */ |
137 | u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs); | 113 | u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs); |
138 | 114 | ||
139 | /* Wait until sync point reaches a threshold value, or a timeout. */ | ||
140 | int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, | ||
141 | long timeout, u32 *value); | ||
142 | |||
143 | /* Check if sync point id is valid. */ | 115 | /* Check if sync point id is valid. */ |
144 | static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp) | 116 | static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp) |
145 | { | 117 | { |
@@ -149,14 +121,4 @@ static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp) | |||
149 | /* Patch a wait by replacing it with a wait for syncpt 0 value 0 */ | 121 | /* Patch a wait by replacing it with a wait for syncpt 0 value 0 */ |
150 | int host1x_syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr); | 122 | int host1x_syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr); |
151 | 123 | ||
152 | /* Return id of the sync point */ | ||
153 | u32 host1x_syncpt_id(struct host1x_syncpt *sp); | ||
154 | |||
155 | /* Allocate a sync point for a device. */ | ||
156 | struct host1x_syncpt *host1x_syncpt_request(struct device *dev, | ||
157 | bool client_managed); | ||
158 | |||
159 | /* Free a sync point. */ | ||
160 | void host1x_syncpt_free(struct host1x_syncpt *sp); | ||
161 | |||
162 | #endif | 124 | #endif |
diff --git a/include/linux/host1x.h b/include/linux/host1x.h index d429a938ba13..7442f2a57039 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h | |||
@@ -19,6 +19,9 @@ | |||
19 | #ifndef __LINUX_HOST1X_H | 19 | #ifndef __LINUX_HOST1X_H |
20 | #define __LINUX_HOST1X_H | 20 | #define __LINUX_HOST1X_H |
21 | 21 | ||
22 | #include <linux/kref.h> | ||
23 | #include <linux/types.h> | ||
24 | |||
22 | enum host1x_class { | 25 | enum host1x_class { |
23 | HOST1X_CLASS_HOST1X = 0x1, | 26 | HOST1X_CLASS_HOST1X = 0x1, |
24 | HOST1X_CLASS_GR2D = 0x51, | 27 | HOST1X_CLASS_GR2D = 0x51, |
@@ -45,4 +48,186 @@ struct host1x_client { | |||
45 | unsigned int num_syncpts; | 48 | unsigned int num_syncpts; |
46 | }; | 49 | }; |
47 | 50 | ||
51 | /* | ||
52 | * host1x buffer objects | ||
53 | */ | ||
54 | |||
55 | struct host1x_bo; | ||
56 | struct sg_table; | ||
57 | |||
58 | struct host1x_bo_ops { | ||
59 | struct host1x_bo *(*get)(struct host1x_bo *bo); | ||
60 | void (*put)(struct host1x_bo *bo); | ||
61 | dma_addr_t (*pin)(struct host1x_bo *bo, struct sg_table **sgt); | ||
62 | void (*unpin)(struct host1x_bo *bo, struct sg_table *sgt); | ||
63 | void *(*mmap)(struct host1x_bo *bo); | ||
64 | void (*munmap)(struct host1x_bo *bo, void *addr); | ||
65 | void *(*kmap)(struct host1x_bo *bo, unsigned int pagenum); | ||
66 | void (*kunmap)(struct host1x_bo *bo, unsigned int pagenum, void *addr); | ||
67 | }; | ||
68 | |||
69 | struct host1x_bo { | ||
70 | const struct host1x_bo_ops *ops; | ||
71 | }; | ||
72 | |||
73 | static inline void host1x_bo_init(struct host1x_bo *bo, | ||
74 | const struct host1x_bo_ops *ops) | ||
75 | { | ||
76 | bo->ops = ops; | ||
77 | } | ||
78 | |||
79 | static inline struct host1x_bo *host1x_bo_get(struct host1x_bo *bo) | ||
80 | { | ||
81 | return bo->ops->get(bo); | ||
82 | } | ||
83 | |||
84 | static inline void host1x_bo_put(struct host1x_bo *bo) | ||
85 | { | ||
86 | bo->ops->put(bo); | ||
87 | } | ||
88 | |||
89 | static inline dma_addr_t host1x_bo_pin(struct host1x_bo *bo, | ||
90 | struct sg_table **sgt) | ||
91 | { | ||
92 | return bo->ops->pin(bo, sgt); | ||
93 | } | ||
94 | |||
95 | static inline void host1x_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt) | ||
96 | { | ||
97 | bo->ops->unpin(bo, sgt); | ||
98 | } | ||
99 | |||
100 | static inline void *host1x_bo_mmap(struct host1x_bo *bo) | ||
101 | { | ||
102 | return bo->ops->mmap(bo); | ||
103 | } | ||
104 | |||
105 | static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr) | ||
106 | { | ||
107 | bo->ops->munmap(bo, addr); | ||
108 | } | ||
109 | |||
110 | static inline void *host1x_bo_kmap(struct host1x_bo *bo, unsigned int pagenum) | ||
111 | { | ||
112 | return bo->ops->kmap(bo, pagenum); | ||
113 | } | ||
114 | |||
115 | static inline void host1x_bo_kunmap(struct host1x_bo *bo, | ||
116 | unsigned int pagenum, void *addr) | ||
117 | { | ||
118 | bo->ops->kunmap(bo, pagenum, addr); | ||
119 | } | ||
120 | |||
121 | /* | ||
122 | * host1x syncpoints | ||
123 | */ | ||
124 | |||
125 | struct host1x_syncpt; | ||
126 | struct host1x; | ||
127 | |||
128 | struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, u32 id); | ||
129 | u32 host1x_syncpt_id(struct host1x_syncpt *sp); | ||
130 | u32 host1x_syncpt_read_min(struct host1x_syncpt *sp); | ||
131 | u32 host1x_syncpt_read_max(struct host1x_syncpt *sp); | ||
132 | int host1x_syncpt_incr(struct host1x_syncpt *sp); | ||
133 | int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, | ||
134 | u32 *value); | ||
135 | struct host1x_syncpt *host1x_syncpt_request(struct device *dev, | ||
136 | bool client_managed); | ||
137 | void host1x_syncpt_free(struct host1x_syncpt *sp); | ||
138 | |||
139 | /* | ||
140 | * host1x channel | ||
141 | */ | ||
142 | |||
143 | struct host1x_channel; | ||
144 | struct host1x_job; | ||
145 | |||
146 | struct host1x_channel *host1x_channel_request(struct device *dev); | ||
147 | void host1x_channel_free(struct host1x_channel *channel); | ||
148 | struct host1x_channel *host1x_channel_get(struct host1x_channel *channel); | ||
149 | void host1x_channel_put(struct host1x_channel *channel); | ||
150 | int host1x_job_submit(struct host1x_job *job); | ||
151 | |||
152 | /* | ||
153 | * host1x job | ||
154 | */ | ||
155 | |||
156 | struct host1x_reloc { | ||
157 | struct host1x_bo *cmdbuf; | ||
158 | u32 cmdbuf_offset; | ||
159 | struct host1x_bo *target; | ||
160 | u32 target_offset; | ||
161 | u32 shift; | ||
162 | u32 pad; | ||
163 | }; | ||
164 | |||
165 | struct host1x_job { | ||
166 | /* When refcount goes to zero, job can be freed */ | ||
167 | struct kref ref; | ||
168 | |||
169 | /* List entry */ | ||
170 | struct list_head list; | ||
171 | |||
172 | /* Channel where job is submitted to */ | ||
173 | struct host1x_channel *channel; | ||
174 | |||
175 | u32 client; | ||
176 | |||
177 | /* Gathers and their memory */ | ||
178 | struct host1x_job_gather *gathers; | ||
179 | unsigned int num_gathers; | ||
180 | |||
181 | /* Wait checks to be processed at submit time */ | ||
182 | struct host1x_waitchk *waitchk; | ||
183 | unsigned int num_waitchk; | ||
184 | u32 waitchk_mask; | ||
185 | |||
186 | /* Array of handles to be pinned & unpinned */ | ||
187 | struct host1x_reloc *relocarray; | ||
188 | unsigned int num_relocs; | ||
189 | struct host1x_job_unpin_data *unpins; | ||
190 | unsigned int num_unpins; | ||
191 | |||
192 | dma_addr_t *addr_phys; | ||
193 | dma_addr_t *gather_addr_phys; | ||
194 | dma_addr_t *reloc_addr_phys; | ||
195 | |||
196 | /* Sync point id, number of increments and end related to the submit */ | ||
197 | u32 syncpt_id; | ||
198 | u32 syncpt_incrs; | ||
199 | u32 syncpt_end; | ||
200 | |||
201 | /* Maximum time to wait for this job */ | ||
202 | unsigned int timeout; | ||
203 | |||
204 | /* Index and number of slots used in the push buffer */ | ||
205 | unsigned int first_get; | ||
206 | unsigned int num_slots; | ||
207 | |||
208 | /* Copy of gathers */ | ||
209 | size_t gather_copy_size; | ||
210 | dma_addr_t gather_copy; | ||
211 | u8 *gather_copy_mapped; | ||
212 | |||
213 | /* Check if register is marked as an address reg */ | ||
214 | int (*is_addr_reg)(struct device *dev, u32 reg, u32 class); | ||
215 | |||
216 | /* Request a SETCLASS to this class */ | ||
217 | u32 class; | ||
218 | |||
219 | /* Add a channel wait for previous ops to complete */ | ||
220 | bool serialize; | ||
221 | }; | ||
222 | |||
223 | struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, | ||
224 | u32 num_cmdbufs, u32 num_relocs, | ||
225 | u32 num_waitchks); | ||
226 | void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *mem_id, | ||
227 | u32 words, u32 offset); | ||
228 | struct host1x_job *host1x_job_get(struct host1x_job *job); | ||
229 | void host1x_job_put(struct host1x_job *job); | ||
230 | int host1x_job_pin(struct host1x_job *job, struct device *dev); | ||
231 | void host1x_job_unpin(struct host1x_job *job); | ||
232 | |||
48 | #endif | 233 | #endif |