omap_dmm_tiler.h 3.6 KB

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