1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef OMAP_DMM_TILER_H
17#define OMAP_DMM_TILER_H
18
19#include "omap_drv.h"
20#include "tcm.h"
21
22enum tiler_fmt {
23 TILFMT_8BIT = 0,
24 TILFMT_16BIT,
25 TILFMT_32BIT,
26 TILFMT_PAGE,
27 TILFMT_NFORMATS
28};
29
30struct pat_area {
31 u32 x0:8;
32 u32 y0:8;
33 u32 x1:8;
34 u32 y1:8;
35};
36
37struct tiler_block {
38 struct list_head alloc_node;
39 struct tcm_area area;
40 enum tiler_fmt fmt;
41};
42
43
44#define SLOT_WIDTH_BITS 6
45#define SLOT_HEIGHT_BITS 6
46
47
48#define CONT_WIDTH_BITS 14
49#define CONT_HEIGHT_BITS 13
50
51
52#define TILER_PAGE (1 << (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS))
53#define TILER_WIDTH (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS))
54#define TILER_HEIGHT (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS))
55
56
57
58
59
60
61
62
63
64
65
66
67
68#define MASK_XY_FLIP (1 << 31)
69#define MASK_Y_INVERT (1 << 30)
70#define MASK_X_INVERT (1 << 29)
71#define SHIFT_ACC_MODE 27
72#define MASK_ACC_MODE 3
73
74#define MASK(bits) ((1 << (bits)) - 1)
75
76#define TILVIEW_8BIT 0x60000000u
77#define TILVIEW_16BIT (TILVIEW_8BIT + VIEW_SIZE)
78#define TILVIEW_32BIT (TILVIEW_16BIT + VIEW_SIZE)
79#define TILVIEW_PAGE (TILVIEW_32BIT + VIEW_SIZE)
80#define TILVIEW_END (TILVIEW_PAGE + VIEW_SIZE)
81
82
83#define TIL_ADDR(x, orient, a)\
84 ((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE))
85
86#ifdef CONFIG_DEBUG_FS
87int tiler_map_show(struct seq_file *s, void *arg);
88#endif
89
90
91int tiler_pin(struct tiler_block *block, struct page **pages,
92 uint32_t npages, uint32_t roll, bool wait);
93int tiler_unpin(struct tiler_block *block);
94
95
96struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w, uint16_t h,
97 uint16_t align);
98struct tiler_block *tiler_reserve_1d(size_t size);
99int tiler_release(struct tiler_block *block);
100
101
102dma_addr_t tiler_ssptr(struct tiler_block *block);
103dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
104 uint32_t x, uint32_t y);
105uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient);
106size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h);
107size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h);
108void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h);
109uint32_t tiler_get_cpu_cache_flags(void);
110bool dmm_is_available(void);
111
112extern struct platform_driver omap_dmm_driver;
113
114
115static inline enum tiler_fmt gem2fmt(uint32_t flags)
116{
117 switch (flags & OMAP_BO_TILED) {
118 case OMAP_BO_TILED_8:
119 return TILFMT_8BIT;
120 case OMAP_BO_TILED_16:
121 return TILFMT_16BIT;
122 case OMAP_BO_TILED_32:
123 return TILFMT_32BIT;
124 default:
125 return TILFMT_PAGE;
126 }
127}
128
129static inline bool validfmt(enum tiler_fmt fmt)
130{
131 switch (fmt) {
132 case TILFMT_8BIT:
133 case TILFMT_16BIT:
134 case TILFMT_32BIT:
135 case TILFMT_PAGE:
136 return true;
137 default:
138 return false;
139 }
140}
141
142#endif
143