0001
0002
0003
0004
0005
0006
0007 #ifndef OMAP_DMM_TILER_H
0008 #define OMAP_DMM_TILER_H
0009
0010 #include "omap_drv.h"
0011 #include "tcm.h"
0012
0013 enum tiler_fmt {
0014 TILFMT_8BIT = 0,
0015 TILFMT_16BIT,
0016 TILFMT_32BIT,
0017 TILFMT_PAGE,
0018 TILFMT_NFORMATS
0019 };
0020
0021 struct pat_area {
0022 u32 x0:8;
0023 u32 y0:8;
0024 u32 x1:8;
0025 u32 y1:8;
0026 };
0027
0028 struct tiler_block {
0029 struct list_head alloc_node;
0030 struct tcm_area area;
0031 enum tiler_fmt fmt;
0032 };
0033
0034
0035 #define SLOT_WIDTH_BITS 6
0036 #define SLOT_HEIGHT_BITS 6
0037
0038
0039 #define CONT_WIDTH_BITS 14
0040 #define CONT_HEIGHT_BITS 13
0041
0042
0043 #define TILER_PAGE (1 << (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS))
0044 #define TILER_WIDTH (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS))
0045 #define TILER_HEIGHT (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS))
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 #define MASK_XY_FLIP (1 << 31)
0060 #define MASK_Y_INVERT (1 << 30)
0061 #define MASK_X_INVERT (1 << 29)
0062 #define SHIFT_ACC_MODE 27
0063 #define MASK_ACC_MODE 3
0064
0065 #define MASK(bits) ((1 << (bits)) - 1)
0066
0067 #define TILVIEW_8BIT 0x60000000u
0068 #define TILVIEW_16BIT (TILVIEW_8BIT + VIEW_SIZE)
0069 #define TILVIEW_32BIT (TILVIEW_16BIT + VIEW_SIZE)
0070 #define TILVIEW_PAGE (TILVIEW_32BIT + VIEW_SIZE)
0071 #define TILVIEW_END (TILVIEW_PAGE + VIEW_SIZE)
0072
0073
0074 #define TIL_ADDR(x, orient, a)\
0075 ((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE))
0076
0077 #ifdef CONFIG_DEBUG_FS
0078 int tiler_map_show(struct seq_file *s, void *arg);
0079 #endif
0080
0081
0082 int tiler_pin(struct tiler_block *block, struct page **pages,
0083 u32 npages, u32 roll, bool wait);
0084 int tiler_unpin(struct tiler_block *block);
0085
0086
0087 struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w, u16 h,
0088 u16 align);
0089 struct tiler_block *tiler_reserve_1d(size_t size);
0090 int tiler_release(struct tiler_block *block);
0091
0092
0093 dma_addr_t tiler_ssptr(struct tiler_block *block);
0094 dma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient,
0095 u32 x, u32 y);
0096 u32 tiler_stride(enum tiler_fmt fmt, u32 orient);
0097 size_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h);
0098 size_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h);
0099 void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
0100 u32 tiler_get_cpu_cache_flags(void);
0101 bool dmm_is_available(void);
0102
0103 extern struct platform_driver omap_dmm_driver;
0104
0105
0106 static inline enum tiler_fmt gem2fmt(u32 flags)
0107 {
0108 switch (flags & OMAP_BO_TILED_MASK) {
0109 case OMAP_BO_TILED_8:
0110 return TILFMT_8BIT;
0111 case OMAP_BO_TILED_16:
0112 return TILFMT_16BIT;
0113 case OMAP_BO_TILED_32:
0114 return TILFMT_32BIT;
0115 default:
0116 return TILFMT_PAGE;
0117 }
0118 }
0119
0120 static inline bool validfmt(enum tiler_fmt fmt)
0121 {
0122 switch (fmt) {
0123 case TILFMT_8BIT:
0124 case TILFMT_16BIT:
0125 case TILFMT_32BIT:
0126 case TILFMT_PAGE:
0127 return true;
0128 default:
0129 return false;
0130 }
0131 }
0132
0133 #endif