Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
omap_dmm_tiler.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4  * Author: Rob Clark <[email protected]>
5  * Andy Gross <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation version 2.
10  *
11  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12  * kind, whether express or implied; without even the implied warranty
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  */
16 #ifndef OMAP_DMM_TILER_H
17 #define OMAP_DMM_TILER_H
18 
19 #include <plat/cpu.h>
20 #include "omap_drv.h"
21 #include "tcm.h"
22 
23 enum tiler_fmt {
29 };
30 
31 struct pat_area {
32  u32 x0:8;
33  u32 y0:8;
34  u32 x1:8;
35  u32 y1:8;
36 };
37 
38 struct tiler_block {
39  struct list_head alloc_node; /* node for global block list */
40  struct tcm_area area; /* area */
41  enum tiler_fmt fmt; /* format */
42 };
43 
44 /* bits representing the same slot in DMM-TILER hw-block */
45 #define SLOT_WIDTH_BITS 6
46 #define SLOT_HEIGHT_BITS 6
47 
48 /* bits reserved to describe coordinates in DMM-TILER hw-block */
49 #define CONT_WIDTH_BITS 14
50 #define CONT_HEIGHT_BITS 13
51 
52 /* calculated constants */
53 #define TILER_PAGE (1 << (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS))
54 #define TILER_WIDTH (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS))
55 #define TILER_HEIGHT (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS))
56 
57 /*
58 Table 15-11. Coding and Description of TILER Orientations
59 S Y X Description Alternate description
60 0 0 0 0-degree view Natural view
61 0 0 1 0-degree view with vertical mirror 180-degree view with horizontal mirror
62 0 1 0 0-degree view with horizontal mirror 180-degree view with vertical mirror
63 0 1 1 180-degree view
64 1 0 0 90-degree view with vertical mirror 270-degree view with horizontal mirror
65 1 0 1 270-degree view
66 1 1 0 90-degree view
67 1 1 1 90-degree view with horizontal mirror 270-degree view with vertical mirror
68  */
69 #define MASK_XY_FLIP (1 << 31)
70 #define MASK_Y_INVERT (1 << 30)
71 #define MASK_X_INVERT (1 << 29)
72 #define SHIFT_ACC_MODE 27
73 #define MASK_ACC_MODE 3
74 
75 #define MASK(bits) ((1 << (bits)) - 1)
76 
77 #define TILVIEW_8BIT 0x60000000u
78 #define TILVIEW_16BIT (TILVIEW_8BIT + VIEW_SIZE)
79 #define TILVIEW_32BIT (TILVIEW_16BIT + VIEW_SIZE)
80 #define TILVIEW_PAGE (TILVIEW_32BIT + VIEW_SIZE)
81 #define TILVIEW_END (TILVIEW_PAGE + VIEW_SIZE)
82 
83 /* create tsptr by adding view orientation and access mode */
84 #define TIL_ADDR(x, orient, a)\
85  ((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE))
86 
87 #ifdef CONFIG_DEBUG_FS
88 int tiler_map_show(struct seq_file *s, void *arg);
89 #endif
90 
91 /* pin/unpin */
92 int tiler_pin(struct tiler_block *block, struct page **pages,
93  uint32_t npages, uint32_t roll, bool wait);
94 int tiler_unpin(struct tiler_block *block);
95 
96 /* reserve/release */
98  uint16_t align);
99 struct tiler_block *tiler_reserve_1d(size_t size);
100 int tiler_release(struct tiler_block *block);
101 
102 /* utilities */
105  uint32_t x, uint32_t y);
107 size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h);
108 size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h);
109 void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h);
110 bool dmm_is_initialized(void);
111 
112 extern struct platform_driver omap_dmm_driver;
113 
114 /* GEM bo flags -> tiler fmt */
115 static 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 
129 static 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 static inline int dmm_is_available(void)
143 {
144  return cpu_is_omap44xx();
145 }
146 
147 #endif