omap_dmm_tiler.h 4.1 KB

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