bcm2835_fb.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Raspberry Pi emulation (c) 2012 Gregory Estrade
  3. * Upstreaming code cleanup [including bcm2835_*] (c) 2013 Jan Petrous
  4. *
  5. * Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft
  6. * Written by Andrew Baumann
  7. *
  8. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  9. * See the COPYING file in the top-level directory.
  10. */
  11. #ifndef BCM2835_FB_H
  12. #define BCM2835_FB_H
  13. #include "hw/sysbus.h"
  14. #include "ui/console.h"
  15. #include "qom/object.h"
  16. #define UPPER_RAM_BASE 0x40000000
  17. #define TYPE_BCM2835_FB "bcm2835-fb"
  18. OBJECT_DECLARE_SIMPLE_TYPE(BCM2835FBState, BCM2835_FB)
  19. /*
  20. * Configuration information about the fb which the guest can program
  21. * via the mailbox property interface.
  22. */
  23. typedef struct {
  24. uint32_t xres, yres;
  25. uint32_t xres_virtual, yres_virtual;
  26. uint32_t xoffset, yoffset;
  27. uint32_t bpp;
  28. uint32_t base;
  29. uint32_t pixo;
  30. uint32_t alpha;
  31. } BCM2835FBConfig;
  32. struct BCM2835FBState {
  33. /*< private >*/
  34. SysBusDevice busdev;
  35. /*< public >*/
  36. uint32_t vcram_base, vcram_size;
  37. MemoryRegion *dma_mr;
  38. AddressSpace dma_as;
  39. MemoryRegion iomem;
  40. MemoryRegionSection fbsection;
  41. QemuConsole *con;
  42. qemu_irq mbox_irq;
  43. bool lock, invalidate, pending;
  44. BCM2835FBConfig config;
  45. BCM2835FBConfig initial_config;
  46. };
  47. void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
  48. /**
  49. * bcm2835_fb_get_pitch: return number of bytes per line of the framebuffer
  50. * @config: configuration info for the framebuffer
  51. *
  52. * Return the number of bytes per line of the framebuffer, ie the number
  53. * that must be added to a pixel address to get the address of the pixel
  54. * directly below it on screen.
  55. */
  56. static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig *config)
  57. {
  58. uint32_t xres = MAX(config->xres, config->xres_virtual);
  59. return xres * (config->bpp >> 3);
  60. }
  61. /**
  62. * bcm2835_fb_get_size: return total size of framebuffer in bytes
  63. * @config: configuration info for the framebuffer
  64. */
  65. static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig *config)
  66. {
  67. uint32_t yres = MAX(config->yres, config->yres_virtual);
  68. return yres * bcm2835_fb_get_pitch(config);
  69. }
  70. /**
  71. * bcm2835_fb_validate_config: check provided config
  72. *
  73. * Validates the configuration information provided by the guest and
  74. * adjusts it if necessary.
  75. */
  76. void bcm2835_fb_validate_config(BCM2835FBConfig *config);
  77. #endif