Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / drivers / gpu / drm / omapdrm / tcm-sita.h
blob460e63dbf825ee91f86b58722a978cda8d7044ed
1 /*
2 * SImple Tiler Allocator (SiTA) private structures.
4 * Copyright (C) 2009-2011 Texas Instruments Incorporated - http://www.ti.com/
5 * Author: Ravi Ramachandra <r.ramachandra@ti.com>
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
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.
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.
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.
37 #ifndef _TCM_SITA_H
38 #define _TCM_SITA_H
40 #include "tcm.h"
42 /* length between two coordinates */
43 #define LEN(a, b) ((a) > (b) ? (a) - (b) + 1 : (b) - (a) + 1)
45 enum criteria {
46 CR_MAX_NEIGHS = 0x01,
47 CR_FIRST_FOUND = 0x10,
48 CR_BIAS_HORIZONTAL = 0x20,
49 CR_BIAS_VERTICAL = 0x40,
50 CR_DIAGONAL_BALANCE = 0x80
53 /* nearness to the beginning of the search field from 0 to 1000 */
54 struct nearness_factor {
55 s32 x;
56 s32 y;
60 * Statistics on immediately neighboring slots. Edge is the number of
61 * border segments that are also border segments of the scan field. Busy
62 * refers to the number of neighbors that are occupied.
64 struct neighbor_stats {
65 u16 edge;
66 u16 busy;
69 /* structure to keep the score of a potential allocation */
70 struct score {
71 struct nearness_factor f;
72 struct neighbor_stats n;
73 struct tcm_area a;
74 u16 neighs; /* number of busy neighbors */
77 struct sita_pvt {
78 spinlock_t lock; /* spinlock to protect access */
79 struct tcm_pt div_pt; /* divider point splitting container */
80 struct tcm_area ***map; /* pointers to the parent area for each slot */
83 /* assign coordinates to area */
84 static inline
85 void assign(struct tcm_area *a, u16 x0, u16 y0, u16 x1, u16 y1)
87 a->p0.x = x0;
88 a->p0.y = y0;
89 a->p1.x = x1;
90 a->p1.y = y1;
93 #endif