1 /* 2 * Copyright (c) 2010 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #include <lk/err.h> 9 #include <lk/debug.h> 10 #include <lk/trace.h> 11 #include <platform.h> 12 #include "platform_p.h" 13 #include <platform/armemu.h> 14 #include <dev/display.h> 15 #include <lib/gfx.h> 16 #include <lk/reg.h> 17 #include <assert.h> 18 19 #define DRAW_TEST_PATTERN 0 20 21 static int display_w, display_h; 22 static void *display_fb; 23 has_display(void)24inline static int has_display(void) { 25 return *REG32(SYSINFO_FEATURES) & SYSINFO_FEATURE_DISPLAY; 26 } 27 platform_init_display(void)28void platform_init_display(void) { 29 if (!has_display()) 30 return; 31 32 display_fb = (void *)DISPLAY_FRAMEBUFFER; 33 display_w = *REG32(DISPLAY_WIDTH); 34 display_h = *REG32(DISPLAY_HEIGHT); 35 36 #if DRAW_TEST_PATTERN 37 gfx_draw_pattern(); 38 #endif 39 } 40 display_get_framebuffer(struct display_framebuffer * fb)41status_t display_get_framebuffer(struct display_framebuffer *fb) { 42 DEBUG_ASSERT(fb); 43 if (!has_display()) 44 return ERR_NOT_FOUND; 45 46 fb->image.format = IMAGE_FORMAT_RGB_x888; 47 fb->image.pixels = display_fb; 48 fb->image.width = display_w; 49 fb->image.height = display_h; 50 fb->image.stride = display_w; 51 fb->image.rowbytes = display_w * 4; 52 fb->flush = NULL; 53 fb->format = DISPLAY_FORMAT_RGB_x888; 54 55 return NO_ERROR; 56 } 57 display_get_info(struct display_info * info)58status_t display_get_info(struct display_info *info) { 59 DEBUG_ASSERT(info); 60 if (!has_display()) 61 return ERR_NOT_FOUND; 62 63 info->format = DISPLAY_FORMAT_RGB_x888; 64 info->width = display_w; 65 info->height = display_h; 66 67 return NO_ERROR; 68 } 69 display_present(struct display_image * image,uint starty,uint endy)70status_t display_present(struct display_image *image, uint starty, uint endy) { 71 TRACEF("display_present - not implemented"); 72 DEBUG_ASSERT(false); 73 return NO_ERROR; 74 } 75