Lines Matching defs:tcm
18 #include "tcm.h"
154 static s32 sita_reserve_1d(struct tcm *tcm, u32 num_slots,
160 spin_lock(&(tcm->lock));
161 ret = r2l_b2t_1d(num_slots, &pos, tcm->bitmap, tcm->map_size);
163 area->p0.x = pos % tcm->width;
164 area->p0.y = pos / tcm->width;
165 area->p1.x = (pos + num_slots - 1) % tcm->width;
166 area->p1.y = (pos + num_slots - 1) / tcm->width;
168 spin_unlock(&(tcm->lock));
173 static s32 sita_reserve_2d(struct tcm *tcm, u16 h, u16 w, u16 align,
180 spin_lock(&(tcm->lock));
181 ret = l2r_t2b(w, h, align, offset, &pos, slot_bytes, tcm->bitmap,
182 tcm->map_size, tcm->width);
185 area->p0.x = pos % tcm->width;
186 area->p0.y = pos / tcm->width;
190 spin_unlock(&(tcm->lock));
195 static void sita_deinit(struct tcm *tcm)
197 kfree(tcm);
200 static s32 sita_free(struct tcm *tcm, struct tcm_area *area)
205 pos = area->p0.x + area->p0.y * tcm->width;
210 w = area->p1.x + area->p1.y * tcm->width - pos + 1;
214 spin_lock(&(tcm->lock));
215 free_slots(pos, w, h, tcm->bitmap, tcm->width);
216 spin_unlock(&(tcm->lock));
220 struct tcm *sita_init(u16 width, u16 height)
222 struct tcm *tcm;
228 tcm = kzalloc(sizeof(*tcm) + map_size, GFP_KERNEL);
229 if (!tcm)
233 tcm->height = height;
234 tcm->width = width;
235 tcm->reserve_2d = sita_reserve_2d;
236 tcm->reserve_1d = sita_reserve_1d;
237 tcm->free = sita_free;
238 tcm->deinit = sita_deinit;
240 spin_lock_init(&tcm->lock);
241 tcm->bitmap = (unsigned long *)(tcm + 1);
242 bitmap_clear(tcm->bitmap, 0, width*height);
244 tcm->map_size = width*height;
246 return tcm;