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/semaphore.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 phys;
47 u32 fence;
48 u32 pos;
49 u32 size_bytes;
50};
51
52struct buffer_timeout {
53 struct delayed_work wq;
54 bool initialized;
55 struct host1x_syncpt *syncpt;
56 u32 syncpt_val;
57 ktime_t start_ktime;
58
59 int client;
60};
61
62enum cdma_event {
63 CDMA_EVENT_NONE,
64 CDMA_EVENT_SYNC_QUEUE_EMPTY,
65 CDMA_EVENT_PUSH_BUFFER_SPACE
66};
67
68struct host1x_cdma {
69 struct mutex lock;
70 struct semaphore sem;
71 enum cdma_event event;
72 unsigned int slots_used;
73 unsigned int slots_free;
74 unsigned int first_get;
75 unsigned int last_pos;
76 struct push_buffer push_buffer;
77 struct list_head sync_queue;
78 struct buffer_timeout timeout;
79 bool running;
80 bool torndown;
81};
82
83#define cdma_to_channel(cdma) container_of(cdma, struct host1x_channel, cdma)
84#define cdma_to_host1x(cdma) dev_get_drvdata(cdma_to_channel(cdma)->dev->parent)
85#define pb_to_cdma(pb) container_of(pb, struct host1x_cdma, push_buffer)
86
87int host1x_cdma_init(struct host1x_cdma *cdma);
88int host1x_cdma_deinit(struct host1x_cdma *cdma);
89void host1x_cdma_stop(struct host1x_cdma *cdma);
90int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job);
91void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2);
92void host1x_cdma_end(struct host1x_cdma *cdma, struct host1x_job *job);
93void host1x_cdma_update(struct host1x_cdma *cdma);
94void host1x_cdma_peek(struct host1x_cdma *cdma, u32 dmaget, int slot,
95 u32 *out);
96unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma,
97 enum cdma_event event);
98void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
99 struct device *dev);
100#endif
101