tcm-sita.h 2.9 KB

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