omap_dmm_tiler.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  3. * Author: Rob Clark <rob@ti.com>
  4. * Andy Gross <andy.gross@ti.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  11. * kind, whether express or implied; without even the implied warranty
  12. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef OMAP_DMM_TILER_H
  16. #define OMAP_DMM_TILER_H
  17. #include "omap_drv.h"
  18. #include "tcm.h"
  19. enum tiler_fmt {
  20. TILFMT_8BIT = 0,
  21. TILFMT_16BIT,
  22. TILFMT_32BIT,
  23. TILFMT_PAGE,
  24. TILFMT_NFORMATS
  25. };
  26. struct pat_area {
  27. u32 x0:8;
  28. u32 y0:8;
  29. u32 x1:8;
  30. u32 y1:8;
  31. };
  32. struct tiler_block {
  33. struct list_head alloc_node; /* node for global block list */
  34. struct tcm_area area; /* area */
  35. enum tiler_fmt fmt; /* format */
  36. };
  37. /* bits representing the same slot in DMM-TILER hw-block */
  38. #define SLOT_WIDTH_BITS 6
  39. #define SLOT_HEIGHT_BITS 6
  40. /* bits reserved to describe coordinates in DMM-TILER hw-block */
  41. #define CONT_WIDTH_BITS 14
  42. #define CONT_HEIGHT_BITS 13
  43. /* calculated constants */
  44. #define TILER_PAGE (1 << (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS))
  45. #define TILER_WIDTH (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS))
  46. #define TILER_HEIGHT (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS))
  47. /*
  48. Table 15-11. Coding and Description of TILER Orientations
  49. S Y X Description Alternate description
  50. 0 0 0 0-degree view Natural view
  51. 0 0 1 0-degree view with vertical mirror 180-degree view with horizontal mirror
  52. 0 1 0 0-degree view with horizontal mirror 180-degree view with vertical mirror
  53. 0 1 1 180-degree view
  54. 1 0 0 90-degree view with vertical mirror 270-degree view with horizontal mirror
  55. 1 0 1 270-degree view
  56. 1 1 0 90-degree view
  57. 1 1 1 90-degree view with horizontal mirror 270-degree view with vertical mirror
  58. */
  59. #define MASK_XY_FLIP (1 << 31)
  60. #define MASK_Y_INVERT (1 << 30)
  61. #define MASK_X_INVERT (1 << 29)
  62. #define SHIFT_ACC_MODE 27
  63. #define MASK_ACC_MODE 3
  64. #define MASK(bits) ((1 << (bits)) - 1)
  65. #define TILVIEW_8BIT 0x60000000u
  66. #define TILVIEW_16BIT (TILVIEW_8BIT + VIEW_SIZE)
  67. #define TILVIEW_32BIT (TILVIEW_16BIT + VIEW_SIZE)
  68. #define TILVIEW_PAGE (TILVIEW_32BIT + VIEW_SIZE)
  69. #define TILVIEW_END (TILVIEW_PAGE + VIEW_SIZE)
  70. /* create tsptr by adding view orientation and access mode */
  71. #define TIL_ADDR(x, orient, a)\
  72. ((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE))
  73. #ifdef CONFIG_DEBUG_FS
  74. int tiler_map_show(struct seq_file *s, void *arg);
  75. #endif
  76. /* pin/unpin */
  77. int tiler_pin(struct tiler_block *block, struct page **pages,
  78. u32 npages, u32 roll, bool wait);
  79. int tiler_unpin(struct tiler_block *block);
  80. /* reserve/release */
  81. struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w, u16 h,
  82. u16 align);
  83. struct tiler_block *tiler_reserve_1d(size_t size);
  84. int tiler_release(struct tiler_block *block);
  85. /* utilities */
  86. dma_addr_t tiler_ssptr(struct tiler_block *block);
  87. dma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient,
  88. u32 x, u32 y);
  89. u32 tiler_stride(enum tiler_fmt fmt, u32 orient);
  90. size_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h);
  91. size_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h);
  92. void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
  93. u32 tiler_get_cpu_cache_flags(void);
  94. bool dmm_is_available(void);
  95. extern struct platform_driver omap_dmm_driver;
  96. /* GEM bo flags -> tiler fmt */
  97. static inline enum tiler_fmt gem2fmt(u32 flags)
  98. {
  99. switch (flags & OMAP_BO_TILED_MASK) {
  100. case OMAP_BO_TILED_8:
  101. return TILFMT_8BIT;
  102. case OMAP_BO_TILED_16:
  103. return TILFMT_16BIT;
  104. case OMAP_BO_TILED_32:
  105. return TILFMT_32BIT;
  106. default:
  107. return TILFMT_PAGE;
  108. }
  109. }
  110. static inline bool validfmt(enum tiler_fmt fmt)
  111. {
  112. switch (fmt) {
  113. case TILFMT_8BIT:
  114. case TILFMT_16BIT:
  115. case TILFMT_32BIT:
  116. case TILFMT_PAGE:
  117. return true;
  118. default:
  119. return false;
  120. }
  121. }
  122. #endif