4 * SImple Tiler Allocator (SiTA) private structures.
6 * Author: Ravi Ramachandra <r.ramachandra@ti.com>
8 * Copyright (C) 2009-2011 Texas Instruments, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
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.
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.
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.
44 /* length between two coordinates */
45 #define LEN(a, b) ((a) > (b) ? (a) - (b) + 1 : (b) - (a) + 1)
49 CR_FIRST_FOUND
= 0x10,
50 CR_BIAS_HORIZONTAL
= 0x20,
51 CR_BIAS_VERTICAL
= 0x40,
52 CR_DIAGONAL_BALANCE
= 0x80
55 /* nearness to the beginning of the search field from 0 to 1000 */
56 struct nearness_factor
{
62 * Statistics on immediately neighboring slots. Edge is the number of
63 * border segments that are also border segments of the scan field. Busy
64 * refers to the number of neighbors that are occupied.
66 struct neighbor_stats
{
71 /* structure to keep the score of a potential allocation */
73 struct nearness_factor f
;
74 struct neighbor_stats n
;
76 u16 neighs
; /* number of busy neighbors */
80 spinlock_t lock
; /* spinlock to protect access */
81 struct tcm_pt div_pt
; /* divider point splitting container */
82 struct tcm_area
***map
; /* pointers to the parent area for each slot */
85 /* assign coordinates to area */
87 void assign(struct tcm_area
*a
, u16 x0
, u16 y0
, u16 x1
, u16 y1
)