0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __HOST1X_CDMA_H
0009 #define __HOST1X_CDMA_H
0010
0011 #include <linux/sched.h>
0012 #include <linux/completion.h>
0013 #include <linux/list.h>
0014
0015 struct host1x_syncpt;
0016 struct host1x_userctx_timeout;
0017 struct host1x_job;
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 struct push_buffer {
0034 void *mapped;
0035 dma_addr_t dma;
0036 dma_addr_t phys;
0037 u32 fence;
0038 u32 pos;
0039 u32 size;
0040 u32 alloc_size;
0041 };
0042
0043 struct buffer_timeout {
0044 struct delayed_work wq;
0045 bool initialized;
0046 struct host1x_syncpt *syncpt;
0047 u32 syncpt_val;
0048 ktime_t start_ktime;
0049
0050 struct host1x_client *client;
0051 };
0052
0053 enum cdma_event {
0054 CDMA_EVENT_NONE,
0055 CDMA_EVENT_SYNC_QUEUE_EMPTY,
0056 CDMA_EVENT_PUSH_BUFFER_SPACE
0057 };
0058
0059 struct host1x_cdma {
0060 struct mutex lock;
0061 struct completion complete;
0062 enum cdma_event event;
0063 unsigned int slots_used;
0064 unsigned int slots_free;
0065 unsigned int first_get;
0066 unsigned int last_pos;
0067 struct push_buffer push_buffer;
0068 struct list_head sync_queue;
0069 struct buffer_timeout timeout;
0070 bool running;
0071 bool torndown;
0072 };
0073
0074 #define cdma_to_channel(cdma) container_of(cdma, struct host1x_channel, cdma)
0075 #define cdma_to_host1x(cdma) dev_get_drvdata(cdma_to_channel(cdma)->dev->parent)
0076 #define pb_to_cdma(pb) container_of(pb, struct host1x_cdma, push_buffer)
0077
0078 int host1x_cdma_init(struct host1x_cdma *cdma);
0079 int host1x_cdma_deinit(struct host1x_cdma *cdma);
0080 int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job);
0081 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2);
0082 void host1x_cdma_push_wide(struct host1x_cdma *cdma, u32 op1, u32 op2,
0083 u32 op3, u32 op4);
0084 void host1x_cdma_end(struct host1x_cdma *cdma, struct host1x_job *job);
0085 void host1x_cdma_update(struct host1x_cdma *cdma);
0086 void host1x_cdma_peek(struct host1x_cdma *cdma, u32 dmaget, int slot,
0087 u32 *out);
0088 unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma,
0089 enum cdma_event event);
0090 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
0091 struct device *dev);
0092 #endif