• Home
  • Raw
  • Download

Lines Matching refs:bo

23 static void draw_rect_yuv(struct sp_bo *bo, uint32_t x, uint32_t y, uint32_t width,  in draw_rect_yuv()  argument
28 if (xmax > bo->width) in draw_rect_yuv()
29 xmax = bo->width; in draw_rect_yuv()
30 if (ymax > bo->height) in draw_rect_yuv()
31 ymax = bo->height; in draw_rect_yuv()
34 uint8_t *luma = bo->map_addr + i * bo->pitch; in draw_rect_yuv()
41 uint8_t *chroma = bo->map_addr + (i + height) * bo->pitch; in draw_rect_yuv()
50 void fill_bo(struct sp_bo *bo, uint8_t a, uint8_t r, uint8_t g, uint8_t b) in fill_bo() argument
52 if (bo->format == DRM_FORMAT_NV12) in fill_bo()
53 draw_rect_yuv(bo, 0, 0, bo->width, bo->height, a, r, g, b); in fill_bo()
55 draw_rect(bo, 0, 0, bo->width, bo->height, a, r, g, b); in fill_bo()
58 void draw_rect(struct sp_bo *bo, uint32_t x, uint32_t y, uint32_t width, in draw_rect() argument
63 if (xmax > bo->width) in draw_rect()
64 xmax = bo->width; in draw_rect()
65 if (ymax > bo->height) in draw_rect()
66 ymax = bo->height; in draw_rect()
69 uint8_t *row = bo->map_addr + i * bo->pitch; in draw_rect()
74 if (bo->format == DRM_FORMAT_ARGB8888 || in draw_rect()
75 bo->format == DRM_FORMAT_XRGB8888) in draw_rect()
81 } else if (bo->format == DRM_FORMAT_RGBA8888) { in draw_rect()
91 static int add_fb_sp_bo(struct sp_bo *bo, uint32_t format) in add_fb_sp_bo() argument
96 handles[0] = bo->handle; in add_fb_sp_bo()
97 pitches[0] = bo->pitch; in add_fb_sp_bo()
99 if (bo->format == DRM_FORMAT_NV12) { in add_fb_sp_bo()
100 handles[1] = bo->handle; in add_fb_sp_bo()
102 offsets[1] = pitches[0] * bo->height; in add_fb_sp_bo()
105 ret = drmModeAddFB2(bo->dev->fd, bo->width, bo->height, in add_fb_sp_bo()
107 &bo->fb_id, bo->flags); in add_fb_sp_bo()
115 static int map_sp_bo(struct sp_bo *bo) in map_sp_bo() argument
120 if (bo->map_addr) in map_sp_bo()
123 md.handle = bo->handle; in map_sp_bo()
124 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_MODE_MAP_DUMB, &md); in map_sp_bo()
130 bo->map_addr = mmap(NULL, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, in map_sp_bo()
131 bo->dev->fd, md.offset); in map_sp_bo()
132 if (bo->map_addr == MAP_FAILED) { in map_sp_bo()
157 struct sp_bo *bo; in create_sp_bo() local
159 bo = calloc(1, sizeof(*bo)); in create_sp_bo()
160 if (!bo) in create_sp_bo()
178 bo->dev = dev; in create_sp_bo()
179 bo->width = width; in create_sp_bo()
180 bo->height = height; in create_sp_bo()
181 bo->depth = depth; in create_sp_bo()
182 bo->bpp = format_to_bpp(format); in create_sp_bo()
183 bo->format = format; in create_sp_bo()
184 bo->flags = flags; in create_sp_bo()
186 bo->handle = cd.handle; in create_sp_bo()
187 bo->pitch = cd.pitch; in create_sp_bo()
188 bo->size = cd.size; in create_sp_bo()
190 ret = add_fb_sp_bo(bo, format); in create_sp_bo()
196 ret = map_sp_bo(bo); in create_sp_bo()
202 return bo; in create_sp_bo()
205 free_sp_bo(bo); in create_sp_bo()
209 void free_sp_bo(struct sp_bo *bo) in free_sp_bo() argument
214 if (!bo) in free_sp_bo()
217 if (bo->map_addr) in free_sp_bo()
218 munmap(bo->map_addr, bo->size); in free_sp_bo()
220 if (bo->fb_id) { in free_sp_bo()
221 ret = drmModeRmFB(bo->dev->fd, bo->fb_id); in free_sp_bo()
226 if (bo->handle) { in free_sp_bo()
227 dd.handle = bo->handle; in free_sp_bo()
228 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dd); in free_sp_bo()
233 free(bo); in free_sp_bo()