Lines Matching refs:tcm
34 static s32 sita_reserve_2d(struct tcm *tcm, u16 h, u16 w, u8 align,
36 static s32 sita_reserve_1d(struct tcm *tcm, u32 slots, struct tcm_area *area);
37 static s32 sita_free(struct tcm *tcm, struct tcm_area *area);
38 static void sita_deinit(struct tcm *tcm);
43 static s32 scan_areas_and_find_fit(struct tcm *tcm, u16 w, u16 h, u16 align,
46 static s32 scan_l2r_t2b(struct tcm *tcm, u16 w, u16 h, u16 align,
49 static s32 scan_r2l_t2b(struct tcm *tcm, u16 w, u16 h, u16 align,
52 static s32 scan_r2l_b2t_one_dim(struct tcm *tcm, u32 num_slots,
60 static s32 update_candidate(struct tcm *tcm, u16 x0, u16 y0, u16 w, u16 h,
68 static void get_neighbor_stats(struct tcm *tcm, struct tcm_area *area,
71 static void fill_area(struct tcm *tcm,
80 struct tcm *sita_init(u16 width, u16 height, struct tcm_pt *attr) in sita_init()
82 struct tcm *tcm; in sita_init() local
90 tcm = kmalloc(sizeof(*tcm), GFP_KERNEL); in sita_init()
92 if (!tcm || !pvt) in sita_init()
95 memset(tcm, 0, sizeof(*tcm)); in sita_init()
99 tcm->height = height; in sita_init()
100 tcm->width = width; in sita_init()
101 tcm->reserve_2d = sita_reserve_2d; in sita_init()
102 tcm->reserve_1d = sita_reserve_1d; in sita_init()
103 tcm->free = sita_free; in sita_init()
104 tcm->deinit = sita_deinit; in sita_init()
105 tcm->pvt = (void *)pvt; in sita_init()
110 pvt->map = kmalloc(sizeof(*pvt->map) * tcm->width, GFP_KERNEL); in sita_init()
114 for (i = 0; i < tcm->width; i++) { in sita_init()
116 kmalloc(sizeof(**pvt->map) * tcm->height, in sita_init()
126 if (attr && attr->x <= tcm->width && attr->y <= tcm->height) { in sita_init()
133 pvt->div_pt.x = (tcm->width * 3) / 4; in sita_init()
134 pvt->div_pt.y = (tcm->height * 3) / 4; in sita_init()
139 fill_area(tcm, &area, NULL); in sita_init()
141 return tcm; in sita_init()
144 kfree(tcm); in sita_init()
149 static void sita_deinit(struct tcm *tcm) in sita_deinit() argument
151 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in sita_deinit()
155 area.p1.x = tcm->width - 1; in sita_deinit()
156 area.p1.y = tcm->height - 1; in sita_deinit()
159 fill_area(tcm, &area, NULL); in sita_deinit()
162 for (i = 0; i < tcm->height; i++) in sita_deinit()
177 static s32 sita_reserve_1d(struct tcm *tcm, u32 num_slots, in sita_reserve_1d() argument
182 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in sita_reserve_1d()
187 assign(&field, tcm->width - 1, tcm->height - 1, 0, 0); in sita_reserve_1d()
189 ret = scan_r2l_b2t_one_dim(tcm, num_slots, &field, area); in sita_reserve_1d()
192 fill_area(tcm, area, area); in sita_reserve_1d()
208 static s32 sita_reserve_2d(struct tcm *tcm, u16 h, u16 w, u8 align, in sita_reserve_2d() argument
212 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in sita_reserve_2d()
222 ret = scan_areas_and_find_fit(tcm, w, h, align, area); in sita_reserve_2d()
225 fill_area(tcm, area, area); in sita_reserve_2d()
236 static s32 sita_free(struct tcm *tcm, struct tcm_area *area) in sita_free() argument
238 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in sita_free()
247 fill_area(tcm, area, NULL); in sita_free()
274 static s32 scan_r2l_t2b(struct tcm *tcm, u16 w, u16 h, u16 align, in scan_r2l_t2b() argument
279 struct tcm_area ***map = ((struct sita_pvt *)tcm->pvt)->map; in scan_r2l_t2b()
311 if (update_candidate(tcm, x, y, w, h, field, in scan_r2l_t2b()
329 if (!best.a.tcm) in scan_r2l_t2b()
348 static s32 scan_l2r_t2b(struct tcm *tcm, u16 w, u16 h, u16 align, in scan_l2r_t2b() argument
353 struct tcm_area ***map = ((struct sita_pvt *)tcm->pvt)->map; in scan_l2r_t2b()
387 if (update_candidate(tcm, x, y, w, h, field, in scan_l2r_t2b()
405 if (!best.a.tcm) in scan_l2r_t2b()
424 static s32 scan_r2l_b2t_one_dim(struct tcm *tcm, u32 num_slots, in scan_r2l_b2t_one_dim() argument
429 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in scan_r2l_b2t_one_dim()
440 if (tcm->width != field->p0.x - field->p1.x + 1) in scan_r2l_b2t_one_dim()
444 if (num_slots > tcm->width * LEN(field->p0.y, field->p1.y)) in scan_r2l_b2t_one_dim()
481 x = (x ? : tcm->width) - 1; in scan_r2l_b2t_one_dim()
502 static s32 scan_areas_and_find_fit(struct tcm *tcm, u16 w, u16 h, u16 align, in scan_areas_and_find_fit() argument
508 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in scan_areas_and_find_fit()
517 boundary_x = tcm->width - 1; in scan_areas_and_find_fit()
519 boundary_y = tcm->height - 1; in scan_areas_and_find_fit()
522 ret = scan_l2r_t2b(tcm, w, h, align, &field, area); in scan_areas_and_find_fit()
525 if (ret != 0 && (boundary_x != tcm->width - 1 || in scan_areas_and_find_fit()
526 boundary_y != tcm->height - 1)) { in scan_areas_and_find_fit()
528 assign(&field, 0, 0, tcm->width - 1, tcm->height - 1); in scan_areas_and_find_fit()
529 ret = scan_l2r_t2b(tcm, w, h, align, &field, area); in scan_areas_and_find_fit()
537 if (w > (tcm->width - pvt->div_pt.x)) in scan_areas_and_find_fit()
540 boundary_y = tcm->height - 1; in scan_areas_and_find_fit()
542 assign(&field, tcm->width - 1, 0, boundary_x, boundary_y); in scan_areas_and_find_fit()
543 ret = scan_r2l_t2b(tcm, w, h, align, &field, area); in scan_areas_and_find_fit()
547 boundary_y != tcm->height - 1)) { in scan_areas_and_find_fit()
549 assign(&field, tcm->width - 1, 0, 0, tcm->height - 1); in scan_areas_and_find_fit()
550 ret = scan_r2l_t2b(tcm, w, h, align, &field, in scan_areas_and_find_fit()
572 static void fill_area(struct tcm *tcm, struct tcm_area *area, in fill_area() argument
576 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in fill_area()
580 area->tcm = tcm; in fill_area()
602 static s32 update_candidate(struct tcm *tcm, u16 x0, u16 y0, u16 w, u16 h, in update_candidate() argument
619 get_neighbor_stats(tcm, &me.a, &me.n); in update_candidate()
625 if (!best->a.tcm) in update_candidate()
647 best->a.tcm = tcm; in update_candidate()
669 static void get_neighbor_stats(struct tcm *tcm, struct tcm_area *area, in get_neighbor_stats() argument
673 struct sita_pvt *pvt = (struct sita_pvt *)tcm->pvt; in get_neighbor_stats()
685 if (area->p1.y == tcm->height - 1) in get_neighbor_stats()
698 if (area->p1.x == tcm->width - 1) in get_neighbor_stats()