1 /* 2 * Copyright (c) 2008-2010 Travis Geiselbrecht 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 #ifndef __DEV_DISPLAY_H 24 #define __DEV_DISPLAY_H 25 26 #include <stdbool.h> 27 #include <sys/types.h> 28 #include <inttypes.h> 29 #include <compiler.h> 30 31 __BEGIN_CDECLS 32 33 int display_init(void *framebuffer); 34 int display_enable(bool enable); 35 void display_pre_freq_change(void); 36 void display_post_freq_change(void); 37 38 enum display_format { 39 DISPLAY_FORMAT_UNKNOWN, 40 DISPLAY_FORMAT_MONO_1, 41 DISPLAY_FORMAT_RGB_111, 42 DISPLAY_FORMAT_RGB_565, 43 DISPLAY_FORMAT_RGB_x888, 44 DISPLAY_FORMAT_ARGB_8888, 45 }; 46 47 enum image_format { 48 IMAGE_FORMAT_UNKNOWN, 49 IMAGE_FORMAT_MONO_1, 50 IMAGE_FORMAT_MONO_8, 51 IMAGE_FORMAT_RGB_x111, 52 IMAGE_FORMAT_RGB_332, 53 IMAGE_FORMAT_RGB_565, 54 IMAGE_FORMAT_RGB_2220, 55 IMAGE_FORMAT_RGB_x888, 56 IMAGE_FORMAT_ARGB_8888, 57 }; 58 59 struct display_info { 60 enum display_format format; 61 uint width; 62 uint height; 63 }; 64 65 status_t display_get_info(struct display_info *info) __NONNULL((1)); 66 67 struct display_image { 68 enum image_format format; 69 void *pixels; 70 uint width; 71 uint height; 72 int stride; // row length in pixels 73 int rowbytes; // row length in bytes 74 }; 75 76 status_t display_present(struct display_image *image, uint starty, uint endy) 77 __NONNULL((1)); 78 79 struct display_framebuffer { 80 enum display_format format; 81 struct display_image image; 82 // Update function 83 void (*flush)(uint starty, uint endy); 84 }; 85 86 status_t display_get_framebuffer(struct display_framebuffer *fb) 87 __NONNULL((1)); 88 89 __END_CDECLS 90 91 #endif 92