1 /*
2 * Copyright (c) 2010, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * */
32 /*
33 * _tcm_sita.h
34 *
35 * SImple Tiler Allocator (SiTA) private structures.
36 *
37 * Author: Ravi Ramachandra <r.ramachandra@ti.com>
38 */
40 #ifndef _TCM_SITA_H_
41 #define _TCM_SITA_H_
43 #include "proto.h"
44 #include "tcm.h"
46 #define TL_CORNER 0
47 #define TR_CORNER 1
48 #define BL_CORNER 3
49 #define BR_CORNER 4
51 /*Provide inclusive length between co-ordinates */
52 #define INCL_LEN(high, low) ((high) - (low) + 1)
53 #define INCL_LEN_MOD(start, end) ((start) > (end) ? (start) - (end) + 1 : \
54 (end) - (start) + 1)
56 #define BOUNDARY(stat) ((stat)->top_boundary + (stat)->bottom_boundary + \
57 (stat)->left_boundary + (stat)->right_boundary)
58 #define OCCUPIED(stat) ((stat)->top_occupied + (stat)->bottom_occupied + \
59 (stat)->left_occupied + (stat)->right_occupied)
61 enum Criteria {
62 CR_MAX_NEIGHS = 0x01,
63 CR_FIRST_FOUND = 0x10,
64 CR_BIAS_HORIZONTAL = 0x20,
65 CR_BIAS_VERTICAL = 0x40,
66 CR_DIAGONAL_BALANCE = 0x80
67 };
69 struct nearness_factor {
70 s32 x;
71 s32 y;
72 };
74 /*
75 * Area info kept
76 */
77 struct area_spec {
78 struct tcm_area area;
79 struct list_head list;
80 };
82 /*
83 * Everything is a rectangle with four sides and on
84 * each side you could have a boundary or another Tile.
85 * The tile could be Occupied or Not. These info is stored
86 */
87 struct neighbour_stats {
88 u16 left_boundary;
89 u16 left_occupied;
90 u16 top_boundary;
91 u16 top_occupied;
92 u16 right_boundary;
93 u16 right_occupied;
94 u16 bottom_boundary;
95 u16 bottom_occupied;
96 };
98 struct slot {
99 u8 busy; /* is slot occupied */
100 struct tcm_area parent; /* parent area */
101 u32 reserved;
102 };
104 struct sita_pvt {
105 u16 width;
106 u16 height;
107 struct list_head res; /* all allocations */
108 //struct mutex mtx;
109 pthread_mutex_t mtx;
110 struct tcm_pt div_pt; /* divider point splitting container */
111 struct slot **map; /* container slots */
112 };
114 #endif /* _TCM_SITA_H_ */