1
2
3
4
5
6
7
8 #ifndef __HOST1X_CDMA_H
9 #define __HOST1X_CDMA_H
10
11 #include <linux/sched.h>
12 #include <linux/completion.h>
13 #include <linux/list.h>
14
15 struct host1x_syncpt;
16 struct host1x_userctx_timeout;
17 struct host1x_job;
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 struct push_buffer {
34 void *mapped;
35 dma_addr_t dma;
36 dma_addr_t phys;
37 u32 fence;
38 u32 pos;
39 u32 size;
40 u32 alloc_size;
41 };
42
43 struct buffer_timeout {
44 struct delayed_work wq;
45 bool initialized;
46 struct host1x_syncpt *syncpt;
47 u32 syncpt_val;
48 ktime_t start_ktime;
49
50 struct host1x_client *client;
51 };
52
53 enum cdma_event {
54 CDMA_EVENT_NONE,
55 CDMA_EVENT_SYNC_QUEUE_EMPTY,
56 CDMA_EVENT_PUSH_BUFFER_SPACE
57 };
58
59 struct host1x_cdma {
60 struct mutex lock;
61 struct completion complete;
62 enum cdma_event event;
63 unsigned int slots_used;
64 unsigned int slots_free;
65 unsigned int first_get;
66 unsigned int last_pos;
67 struct push_buffer push_buffer;
68 struct list_head sync_queue;
69 struct buffer_timeout timeout;
70 bool running;
71 bool torndown;
72 };
73
74 #define cdma_to_channel(cdma) container_of(cdma, struct host1x_channel, cdma)
75 #define cdma_to_host1x(cdma) dev_get_drvdata(cdma_to_channel(cdma)->dev->parent)
76 #define pb_to_cdma(pb) container_of(pb, struct host1x_cdma, push_buffer)
77
78 int host1x_cdma_init(struct host1x_cdma *cdma);
79 int host1x_cdma_deinit(struct host1x_cdma *cdma);
80 int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job);
81 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2);
82 void host1x_cdma_push_wide(struct host1x_cdma *cdma, u32 op1, u32 op2,
83 u32 op3, u32 op4);
84 void host1x_cdma_end(struct host1x_cdma *cdma, struct host1x_job *job);
85 void host1x_cdma_update(struct host1x_cdma *cdma);
86 void host1x_cdma_peek(struct host1x_cdma *cdma, u32 dmaget, int slot,
87 u32 *out);
88 unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma,
89 enum cdma_event event);
90 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
91 struct device *dev);
92 #endif