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