tcm-sita.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * tcm_sita.h
  3. *
  4. * SImple Tiler Allocator (SiTA) private structures.
  5. *
  6. * Author: Ravi Ramachandra <r.ramachandra@ti.com>
  7. *
  8. * Copyright (C) 2009-2011 Texas Instruments, Inc.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. *
  15. * * Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. *
  18. * * Redistributions in binary form must reproduce the above copyright
  19. * notice, this list of conditions and the following disclaimer in the
  20. * documentation and/or other materials provided with the distribution.
  21. *
  22. * * Neither the name of Texas Instruments Incorporated nor the names of
  23. * its contributors may be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  28. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  30. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  31. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  32. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  33. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  34. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  35. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  36. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. #ifndef _TCM_SITA_H
  39. #define _TCM_SITA_H
  40. #include "tcm.h"
  41. /* length between two coordinates */
  42. #define LEN(a, b) ((a) > (b) ? (a) - (b) + 1 : (b) - (a) + 1)
  43. enum criteria {
  44. CR_MAX_NEIGHS = 0x01,
  45. CR_FIRST_FOUND = 0x10,
  46. CR_BIAS_HORIZONTAL = 0x20,
  47. CR_BIAS_VERTICAL = 0x40,
  48. CR_DIAGONAL_BALANCE = 0x80
  49. };
  50. /* nearness to the beginning of the search field from 0 to 1000 */
  51. struct nearness_factor {
  52. s32 x;
  53. s32 y;
  54. };
  55. /*
  56. * Statistics on immediately neighboring slots. Edge is the number of
  57. * border segments that are also border segments of the scan field. Busy
  58. * refers to the number of neighbors that are occupied.
  59. */
  60. struct neighbor_stats {
  61. u16 edge;
  62. u16 busy;
  63. };
  64. /* structure to keep the score of a potential allocation */
  65. struct score {
  66. struct nearness_factor f;
  67. struct neighbor_stats n;
  68. struct tcm_area a;
  69. u16 neighs; /* number of busy neighbors */
  70. };
  71. struct sita_pvt {
  72. spinlock_t lock; /* spinlock to protect access */
  73. struct tcm_pt div_pt; /* divider point splitting container */
  74. struct tcm_area ***map; /* pointers to the parent area for each slot */
  75. };
  76. /* assign coordinates to area */
  77. static inline
  78. void assign(struct tcm_area *a, u16 x0, u16 y0, u16 x1, u16 y1)
  79. {
  80. a->p0.x = x0;
  81. a->p0.y = y0;
  82. a->p1.x = x1;
  83. a->p1.y = y1;
  84. }
  85. #endif