Lines Matching refs:fb

94 static uint8_t draw_char_vtmono(const struct char_framebuffer *fb,  in draw_char_vtmono()  argument
98 const struct cfb_font *fptr = &(fb->fonts[fb->font_idx]); in draw_char_vtmono()
101 (((fb->screen_info & SCREEN_INFO_MONO_MSB_FIRST) != 0) != font_is_msbfirst); in draw_char_vtmono()
123 const size_t fb_index = (fb_y / 8U) * fb->x_res + fb_x; in draw_char_vtmono()
130 if (fb_x < 0 || fb->x_res <= fb_x || fb_y < 0 || fb->y_res <= fb_y) { in draw_char_vtmono()
191 fb->buf[fb_index] &= ~bg_mask; in draw_char_vtmono()
197 fb->buf[fb_index] |= byte; in draw_char_vtmono()
212 static inline void draw_point(struct char_framebuffer *fb, int16_t x, int16_t y) in draw_point() argument
214 const bool need_reverse = ((fb->screen_info & SCREEN_INFO_MONO_MSB_FIRST) != 0); in draw_point()
215 const size_t index = ((y / 8) * fb->x_res); in draw_point()
218 if (x < 0 || x >= fb->x_res) { in draw_point()
222 if (y < 0 || y >= fb->y_res) { in draw_point()
230 fb->buf[index + x] |= m; in draw_point()
233 static void draw_line(struct char_framebuffer *fb, int16_t x0, int16_t y0, int16_t x1, int16_t y1) in draw_line() argument
243 draw_point(fb, x0, y0); in draw_line()
266 const struct char_framebuffer *fb = &char_fb; in draw_text() local
269 if (!fb->fonts || !fb->buf) { in draw_text()
273 fptr = &(fb->fonts[fb->font_idx]); in draw_text()
280 if ((fb->screen_info & SCREEN_INFO_MONO_VTILED)) { in draw_text()
282 if ((x + fptr->width > fb->x_res) && wrap) { in draw_text()
286 x += fb->kerning + draw_char_vtmono(fb, str[i], x, y, wrap); in draw_text()
297 struct char_framebuffer *fb = &char_fb; in cfb_draw_point() local
299 draw_point(fb, pos->x, pos->y); in cfb_draw_point()
307 struct char_framebuffer *fb = &char_fb; in cfb_draw_line() local
309 draw_line(fb, start->x, start->y, end->x, end->y); in cfb_draw_line()
317 struct char_framebuffer *fb = &char_fb; in cfb_draw_rect() local
319 draw_line(fb, start->x, start->y, end->x, start->y); in cfb_draw_rect()
320 draw_line(fb, end->x, start->y, end->x, end->y); in cfb_draw_rect()
321 draw_line(fb, end->x, end->y, start->x, end->y); in cfb_draw_rect()
322 draw_line(fb, start->x, end->y, start->x, start->y); in cfb_draw_rect()
340 const struct char_framebuffer *fb = &char_fb; in cfb_invert_area() local
341 const bool need_reverse = ((fb->screen_info & SCREEN_INFO_MONO_MSB_FIRST) != 0); in cfb_invert_area()
343 if (x >= fb->x_res || y >= fb->y_res) { in cfb_invert_area()
349 if ((fb->screen_info & SCREEN_INFO_MONO_VTILED)) { in cfb_invert_area()
350 if (x > fb->x_res) { in cfb_invert_area()
351 x = fb->x_res; in cfb_invert_area()
354 if (y > fb->y_res) { in cfb_invert_area()
355 y = fb->y_res; in cfb_invert_area()
358 if (x + width > fb->x_res) { in cfb_invert_area()
359 width = fb->x_res - x; in cfb_invert_area()
362 if (y + height > fb->y_res) { in cfb_invert_area()
363 height = fb->y_res - y; in cfb_invert_area()
373 const size_t index = ((j / 8) * fb->x_res) + i; in cfb_invert_area()
382 uint8_t b = fb->buf[index]; in cfb_invert_area()
397 fb->buf[index] = (b ^ (~m)); in cfb_invert_area()
401 fb->buf[index] = ~fb->buf[index]; in cfb_invert_area()
405 uint8_t b = fb->buf[index]; in cfb_invert_area()
411 fb->buf[index] = (b ^ (~m)); in cfb_invert_area()
424 static int cfb_invert(const struct char_framebuffer *fb) in cfb_invert() argument
426 for (size_t i = 0; i < fb->x_res * fb->y_res / 8U; i++) { in cfb_invert()
427 fb->buf[i] = ~fb->buf[i]; in cfb_invert()
435 const struct char_framebuffer *fb = &char_fb; in cfb_framebuffer_clear() local
437 if (!fb || !fb->buf) { in cfb_framebuffer_clear()
441 memset(fb->buf, 0, fb->size); in cfb_framebuffer_clear()
452 struct char_framebuffer *fb = &char_fb; in cfb_framebuffer_invert() local
454 fb->inverted = !fb->inverted; in cfb_framebuffer_invert()
462 const struct char_framebuffer *fb = &char_fb; in cfb_framebuffer_finalize() local
466 if (!fb || !fb->buf) { in cfb_framebuffer_finalize()
470 desc.buf_size = fb->size; in cfb_framebuffer_finalize()
471 desc.width = fb->x_res; in cfb_framebuffer_finalize()
472 desc.height = fb->y_res; in cfb_framebuffer_finalize()
473 desc.pitch = fb->x_res; in cfb_framebuffer_finalize()
475 if (!(fb->pixel_format & PIXEL_FORMAT_MONO10) != !(fb->inverted)) { in cfb_framebuffer_finalize()
476 cfb_invert(fb); in cfb_framebuffer_finalize()
477 err = api->write(dev, 0, 0, &desc, fb->buf); in cfb_framebuffer_finalize()
478 cfb_invert(fb); in cfb_framebuffer_finalize()
482 return api->write(dev, 0, 0, &desc, fb->buf); in cfb_framebuffer_finalize()
488 const struct char_framebuffer *fb = &char_fb; in cfb_get_display_parameter() local
492 return fb->y_res; in cfb_get_display_parameter()
494 return fb->x_res; in cfb_get_display_parameter()
496 return fb->ppt; in cfb_get_display_parameter()
498 if (fb->screen_info & SCREEN_INFO_MONO_VTILED) { in cfb_get_display_parameter()
499 return fb->y_res / fb->ppt; in cfb_get_display_parameter()
501 return fb->y_res; in cfb_get_display_parameter()
503 if (fb->screen_info & SCREEN_INFO_MONO_VTILED) { in cfb_get_display_parameter()
504 return fb->x_res; in cfb_get_display_parameter()
506 return fb->x_res / fb->ppt; in cfb_get_display_parameter()
513 struct char_framebuffer *fb = &char_fb; in cfb_framebuffer_set_font() local
515 if (idx >= fb->numof_fonts) { in cfb_framebuffer_set_font()
519 fb->font_idx = idx; in cfb_framebuffer_set_font()
527 const struct char_framebuffer *fb = &char_fb; in cfb_get_font_size() local
529 if (idx >= fb->numof_fonts) { in cfb_get_font_size()
553 const struct char_framebuffer *fb = &char_fb; in cfb_get_numof_fonts() local
555 return fb->numof_fonts; in cfb_get_numof_fonts()
561 struct char_framebuffer *fb = &char_fb; in cfb_framebuffer_init() local
566 STRUCT_SECTION_COUNT(cfb_font, &fb->numof_fonts); in cfb_framebuffer_init()
568 LOG_DBG("number of fonts %d", fb->numof_fonts); in cfb_framebuffer_init()
570 fb->x_res = cfg.x_resolution; in cfb_framebuffer_init()
571 fb->y_res = cfg.y_resolution; in cfb_framebuffer_init()
572 fb->ppt = 8U; in cfb_framebuffer_init()
573 fb->pixel_format = cfg.current_pixel_format; in cfb_framebuffer_init()
574 fb->screen_info = cfg.screen_info; in cfb_framebuffer_init()
575 fb->buf = NULL; in cfb_framebuffer_init()
576 fb->kerning = 0; in cfb_framebuffer_init()
577 fb->inverted = false; in cfb_framebuffer_init()
579 fb->fonts = TYPE_SECTION_START(cfb_font); in cfb_framebuffer_init()
580 fb->font_idx = 0U; in cfb_framebuffer_init()
582 fb->size = fb->x_res * fb->y_res / fb->ppt; in cfb_framebuffer_init()
583 fb->buf = k_malloc(fb->size); in cfb_framebuffer_init()
584 if (!fb->buf) { in cfb_framebuffer_init()
588 memset(fb->buf, 0, fb->size); in cfb_framebuffer_init()
595 struct char_framebuffer *fb = &char_fb; in cfb_framebuffer_deinit() local
597 if (fb->buf) { in cfb_framebuffer_deinit()
598 k_free(fb->buf); in cfb_framebuffer_deinit()
599 fb->buf = NULL; in cfb_framebuffer_deinit()