Lines Matching defs:tcm
26 #include "tcm.h"
162 static s32 sita_reserve_1d(struct tcm *tcm, u32 num_slots,
168 spin_lock(&(tcm->lock));
169 ret = r2l_b2t_1d(num_slots, &pos, tcm->bitmap, tcm->map_size);
171 area->p0.x = pos % tcm->width;
172 area->p0.y = pos / tcm->width;
173 area->p1.x = (pos + num_slots - 1) % tcm->width;
174 area->p1.y = (pos + num_slots - 1) / tcm->width;
176 spin_unlock(&(tcm->lock));
181 static s32 sita_reserve_2d(struct tcm *tcm, u16 h, u16 w, u16 align,
188 spin_lock(&(tcm->lock));
189 ret = l2r_t2b(w, h, align, offset, &pos, slot_bytes, tcm->bitmap,
190 tcm->map_size, tcm->width);
193 area->p0.x = pos % tcm->width;
194 area->p0.y = pos / tcm->width;
198 spin_unlock(&(tcm->lock));
203 static void sita_deinit(struct tcm *tcm)
205 kfree(tcm);
208 static s32 sita_free(struct tcm *tcm, struct tcm_area *area)
213 pos = area->p0.x + area->p0.y * tcm->width;
218 w = area->p1.x + area->p1.y * tcm->width - pos + 1;
222 spin_lock(&(tcm->lock));
223 free_slots(pos, w, h, tcm->bitmap, tcm->width);
224 spin_unlock(&(tcm->lock));
228 struct tcm *sita_init(u16 width, u16 height)
230 struct tcm *tcm;
236 tcm = kzalloc(sizeof(*tcm) + map_size, GFP_KERNEL);
237 if (!tcm)
241 tcm->height = height;
242 tcm->width = width;
243 tcm->reserve_2d = sita_reserve_2d;
244 tcm->reserve_1d = sita_reserve_1d;
245 tcm->free = sita_free;
246 tcm->deinit = sita_deinit;
248 spin_lock_init(&tcm->lock);
249 tcm->bitmap = (unsigned long *)(tcm + 1);
250 bitmap_clear(tcm->bitmap, 0, width*height);
252 tcm->map_size = width*height;
254 return tcm;
257 kfree(tcm);