Lines Matching refs:bo

16 void fill_bo(struct sp_bo *bo, uint8_t a, uint8_t r, uint8_t g, uint8_t b)  in fill_bo()  argument
18 draw_rect(bo, 0, 0, bo->width, bo->height, a, r, g, b); in fill_bo()
21 void draw_rect(struct sp_bo *bo, uint32_t x, uint32_t y, uint32_t width, in draw_rect() argument
26 if (xmax > bo->width) in draw_rect()
27 xmax = bo->width; in draw_rect()
28 if (ymax > bo->height) in draw_rect()
29 ymax = bo->height; in draw_rect()
32 uint8_t *row = bo->map_addr + i * bo->pitch; in draw_rect()
37 if (bo->format == DRM_FORMAT_ARGB8888 || in draw_rect()
38 bo->format == DRM_FORMAT_XRGB8888) in draw_rect()
44 } else if (bo->format == DRM_FORMAT_RGBA8888) { in draw_rect()
54 static int add_fb_sp_bo(struct sp_bo *bo, uint32_t format) in add_fb_sp_bo() argument
59 handles[0] = bo->handle; in add_fb_sp_bo()
60 pitches[0] = bo->pitch; in add_fb_sp_bo()
63 ret = drmModeAddFB2(bo->dev->fd, bo->width, bo->height, in add_fb_sp_bo()
65 &bo->fb_id, bo->flags); in add_fb_sp_bo()
73 static int map_sp_bo(struct sp_bo *bo) in map_sp_bo() argument
78 if (bo->map_addr) in map_sp_bo()
81 md.handle = bo->handle; in map_sp_bo()
82 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_MODE_MAP_DUMB, &md); in map_sp_bo()
88 bo->map_addr = mmap(NULL, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, in map_sp_bo()
89 bo->dev->fd, md.offset); in map_sp_bo()
90 if (bo->map_addr == MAP_FAILED) { in map_sp_bo()
102 struct sp_bo *bo; in create_sp_bo() local
104 bo = calloc(1, sizeof(*bo)); in create_sp_bo()
105 if (!bo) in create_sp_bo()
119 bo->dev = dev; in create_sp_bo()
120 bo->width = width; in create_sp_bo()
121 bo->height = height; in create_sp_bo()
122 bo->depth = depth; in create_sp_bo()
123 bo->bpp = bpp; in create_sp_bo()
124 bo->format = format; in create_sp_bo()
125 bo->flags = flags; in create_sp_bo()
127 bo->handle = cd.handle; in create_sp_bo()
128 bo->pitch = cd.pitch; in create_sp_bo()
129 bo->size = cd.size; in create_sp_bo()
131 ret = add_fb_sp_bo(bo, format); in create_sp_bo()
137 ret = map_sp_bo(bo); in create_sp_bo()
143 return bo; in create_sp_bo()
146 free_sp_bo(bo); in create_sp_bo()
150 void free_sp_bo(struct sp_bo *bo) in free_sp_bo() argument
155 if (!bo) in free_sp_bo()
158 if (bo->map_addr) in free_sp_bo()
159 munmap(bo->map_addr, bo->size); in free_sp_bo()
161 if (bo->fb_id) { in free_sp_bo()
162 ret = drmModeRmFB(bo->dev->fd, bo->fb_id); in free_sp_bo()
167 if (bo->handle) { in free_sp_bo()
168 dd.handle = bo->handle; in free_sp_bo()
169 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dd); in free_sp_bo()
174 free(bo); in free_sp_bo()