Lines Matching refs:bo

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