Lines Matching refs:area

48 /* 1d or 2d area */
50 bool is2d; /* whether area is 1d or 2d */
69 struct tcm_area *area);
70 s32 (*reserve_1d)(struct tcm *tcm, u32 slots, struct tcm_area *area);
71 s32 (*free)(struct tcm *tcm, struct tcm_area *area);
85 * area pointer is NULL
111 * Reserves a 2D area in the container.
114 * @param height Height(in pages) of area to be reserved.
115 * @param width Width(in pages) of area to be reserved.
116 * @param align Alignment requirement for top-left corner of area. Not
123 * @param area Pointer to where the reserved area should be stored.
126 * the tcm field of the area will be set to NULL on
128 * -EINVAL: invalid area, -ENOMEM: not enough space for
133 struct tcm_area *area)
137 (area == NULL || width == 0 || height == 0 ||
143 area->is2d = true;
145 slot_bytes, area);
146 area->tcm = res ? NULL : tcm;
153 * Reserves a 1D area in the container.
157 * @param area Pointer to where the reserved area should be stored.
160 * the tcm field of the area will be set to NULL on
162 * -EINVAL: invalid area, -ENOMEM: not enough space for
166 struct tcm_area *area)
170 (area == NULL || slots == 0) ? -EINVAL :
174 area->is2d = false;
175 res = tcm->reserve_1d(tcm, slots, area);
176 area->tcm = res ? NULL : tcm;
183 * Free a previously reserved area from the container.
185 * @param area Pointer to area reserved by a prior call to
191 * field of the area is set to NULL on success to avoid subsequent
193 * the area from a failed reserved call.
195 static inline s32 tcm_free(struct tcm_area *area)
199 if (area && area->tcm) {
200 res = area->tcm->free(area->tcm, area);
202 area->tcm = NULL;
213 * This method slices off the topmost 2D slice from the parent area, and stores
215 * contain the remaining portion of the area. If the whole parent area can
217 * longer a valid area.
219 * @param parent Pointer to a VALID parent area that will get modified
220 * @param slice Pointer to the slice area that will get modified
233 /* adjust remaining area */
242 /* Verify if a tcm area is logically valid */
243 static inline bool tcm_area_is_valid(struct tcm_area *area)
245 return area && area->tcm &&
247 area->p1.x < area->tcm->width &&
248 area->p1.y < area->tcm->height &&
249 area->p0.y <= area->p1.y &&
251 ((!area->is2d &&
252 area->p0.x < area->tcm->width &&
253 area->p0.x + area->p0.y * area->tcm->width <=
254 area->p1.x + area->p1.y * area->tcm->width) ||
256 (area->is2d &&
257 area->p0.x <= area->p1.x));
260 /* see if a coordinate is within an area */
275 /* calculate area width */
276 static inline u16 __tcm_area_width(struct tcm_area *area)
278 return area->p1.x - area->p0.x + 1;
281 /* calculate area height */
282 static inline u16 __tcm_area_height(struct tcm_area *area)
284 return area->p1.y - area->p0.y + 1;
287 /* calculate number of slots in an area */
288 static inline u16 __tcm_sizeof(struct tcm_area *area)
290 return area->is2d ?
291 __tcm_area_width(area) * __tcm_area_height(area) :
292 (area->p1.x - area->p0.x + 1) + (area->p1.y - area->p0.y) *
293 area->tcm->width;
295 #define tcm_sizeof(area) __tcm_sizeof(&(area))
296 #define tcm_awidth(area) __tcm_area_width(&(area))
297 #define tcm_aheight(area) __tcm_area_height(&(area))
298 #define tcm_is_in(pt, area) __tcm_is_in(&(pt), &(area))
300 /* limit a 1D area to the first N pages */
314 * Iterate through 2D slices of a valid area. Behaves
320 * @param area Pointer to the VALID parent area. This
325 #define tcm_for_each_slice(var, area, safe) \
326 for (safe = area, \