framebuffer.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2023 Daniele Lacamera <root@danielinux.net>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef FRAMEBUFFER_INCLUDED
  18. #define FRAMEBUFFER_INCLUDED
  19. #include <stdint.h>
  20. struct fb_ops;
  21. struct fb_info {
  22. struct fb_var_screeninfo var; /* Current var */
  23. //struct fb_fix_screeninfo fix; /* Current fix */
  24. struct fb_videomode *mode; /* current mode */
  25. //struct backlight_device *bl_dev;
  26. struct fb_ops *fbops;
  27. struct device *dev; /* This is this fb device */
  28. uint8_t *screen_buffer; /* Framebuffer address */
  29. };
  30. struct fb_ops {
  31. /* open/release and usage marking */
  32. int (*fb_open)(struct fb_info *info);
  33. int (*fb_release)(struct fb_info *info);
  34. /* checks var and eventually tweaks it to something supported,
  35. * DO NOT MODIFY PAR */
  36. int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);
  37. /* set the video mode according to info->var */
  38. int (*fb_set_par)(struct fb_info *info);
  39. /* set color registers in batch */
  40. int (*fb_setcmap)(uint32_t *cmap, struct fb_info *info);
  41. /* blank display */
  42. int (*fb_blank)(struct fb_info *info);
  43. /* Draws a rectangle */
  44. //void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
  45. /* Copy data from area to another */
  46. //void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
  47. /* Draws a image to the display */
  48. //void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
  49. /* Draws cursor */
  50. //int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);
  51. /* Rotates the display */
  52. //void (*fb_rotate)(struct fb_info *info, int angle);
  53. /* perform fb specific ioctl (optional) */
  54. int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, unsigned long arg);
  55. /* teardown any resources to do with this framebuffer */
  56. void (*fb_destroy)(struct fb_info *info);
  57. };
  58. #ifdef CONFIG_DEVFRAMEBUFFER
  59. /* low-level drivers must call this register function first */
  60. int register_framebuffer(struct fb_info *fb_info);
  61. /* Higher level drivers may access fb screen directly */
  62. unsigned char *framebuffer_get(void);
  63. int framebuffer_setcmap(uint32_t *cmap);
  64. /* kernel init */
  65. int fb_init(void);
  66. #else
  67. # define register_framebuffer(...) ((-ENOENT))
  68. # define fb_init() ((-ENOENT))
  69. #endif
  70. #endif