Lines Matching +full:offset +full:- +full:y

1 // SPDX-License-Identifier: GPL-2.0-only
9 * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
50 *pos = num_bits - w; in r2l_b2t_1d()
55 if (bit - *pos >= w) { in r2l_b2t_1d()
62 search_count = num_bits - bit + w; in r2l_b2t_1d()
63 *pos = bit - w; in r2l_b2t_1d()
66 return (area_found) ? 0 : -ENOMEM; in r2l_b2t_1d()
72 * a = align in slots (mask, 2^n-1, 0 is unaligned)
73 * offset = offset in bytes from 4KiB
79 static int l2r_t2b(u16 w, u16 h, u16 a, s16 offset, in l2r_t2b() argument
87 unsigned long bit_offset = (offset > 0) ? offset / slot_bytes : 0; in l2r_t2b()
90 /* reset alignment to 1 if we are matching a specific offset */ in l2r_t2b()
91 /* adjust alignment - 1 to get to the format expected in bitmaps */ in l2r_t2b()
92 a = (offset > 0) ? 0 : a - 1; in l2r_t2b()
100 /* skip forward if we are not at right offset */ in l2r_t2b()
146 /* set area as in-use. iterate over rows */ in l2r_t2b()
151 return (area_free) ? 0 : -ENOMEM; in l2r_t2b()
160 spin_lock(&(tcm->lock)); in sita_reserve_1d()
161 ret = r2l_b2t_1d(num_slots, &pos, tcm->bitmap, tcm->map_size); in sita_reserve_1d()
163 area->p0.x = pos % tcm->width; in sita_reserve_1d()
164 area->p0.y = pos / tcm->width; in sita_reserve_1d()
165 area->p1.x = (pos + num_slots - 1) % tcm->width; in sita_reserve_1d()
166 area->p1.y = (pos + num_slots - 1) / tcm->width; in sita_reserve_1d()
168 spin_unlock(&(tcm->lock)); in sita_reserve_1d()
174 s16 offset, u16 slot_bytes, in sita_reserve_2d() argument
180 spin_lock(&(tcm->lock)); in sita_reserve_2d()
181 ret = l2r_t2b(w, h, align, offset, &pos, slot_bytes, tcm->bitmap, in sita_reserve_2d()
182 tcm->map_size, tcm->width); in sita_reserve_2d()
185 area->p0.x = pos % tcm->width; in sita_reserve_2d()
186 area->p0.y = pos / tcm->width; in sita_reserve_2d()
187 area->p1.x = area->p0.x + w - 1; in sita_reserve_2d()
188 area->p1.y = area->p0.y + h - 1; in sita_reserve_2d()
190 spin_unlock(&(tcm->lock)); in sita_reserve_2d()
205 pos = area->p0.x + area->p0.y * tcm->width; in sita_free()
206 if (area->is2d) { in sita_free()
207 w = area->p1.x - area->p0.x + 1; in sita_free()
208 h = area->p1.y - area->p0.y + 1; in sita_free()
210 w = area->p1.x + area->p1.y * tcm->width - pos + 1; in sita_free()
214 spin_lock(&(tcm->lock)); in sita_free()
215 free_slots(pos, w, h, tcm->bitmap, tcm->width); in sita_free()
216 spin_unlock(&(tcm->lock)); in sita_free()
233 tcm->height = height; in sita_init()
234 tcm->width = width; in sita_init()
235 tcm->reserve_2d = sita_reserve_2d; in sita_init()
236 tcm->reserve_1d = sita_reserve_1d; in sita_init()
237 tcm->free = sita_free; in sita_init()
238 tcm->deinit = sita_deinit; in sita_init()
240 spin_lock_init(&tcm->lock); in sita_init()
241 tcm->bitmap = (unsigned long *)(tcm + 1); in sita_init()
242 bitmap_clear(tcm->bitmap, 0, width*height); in sita_init()
244 tcm->map_size = width*height; in sita_init()