omapfb.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * linux/drivers/video/omap2/omapfb.h
  3. *
  4. * Copyright (C) 2008 Nokia Corporation
  5. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  6. *
  7. * Some code and ideas taken from drivers/video/omap/ driver
  8. * by Imre Deak.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published by
  12. * the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along with
  20. * this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #ifndef __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
  23. #define __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
  24. #ifdef CONFIG_FB_OMAP2_DEBUG_SUPPORT
  25. #define DEBUG
  26. #endif
  27. #include <plat/display.h>
  28. #ifdef DEBUG
  29. extern unsigned int omapfb_debug;
  30. #define DBG(format, ...) \
  31. if (omapfb_debug) \
  32. printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__)
  33. #else
  34. #define DBG(format, ...)
  35. #endif
  36. #define FB2OFB(fb_info) ((struct omapfb_info *)(fb_info->par))
  37. /* max number of overlays to which a framebuffer data can be direct */
  38. #define OMAPFB_MAX_OVL_PER_FB 3
  39. struct omapfb2_mem_region {
  40. u32 paddr;
  41. void __iomem *vaddr;
  42. struct vrfb vrfb;
  43. unsigned long size;
  44. u8 type; /* OMAPFB_PLANE_MEM_* */
  45. bool alloc; /* allocated by the driver */
  46. bool map; /* kernel mapped by the driver */
  47. };
  48. /* appended to fb_info */
  49. struct omapfb_info {
  50. int id;
  51. struct omapfb2_mem_region region;
  52. atomic_t map_count;
  53. int num_overlays;
  54. struct omap_overlay *overlays[OMAPFB_MAX_OVL_PER_FB];
  55. struct omapfb2_device *fbdev;
  56. enum omap_dss_rotation_type rotation_type;
  57. u8 rotation[OMAPFB_MAX_OVL_PER_FB];
  58. bool mirror;
  59. };
  60. struct omapfb2_device {
  61. struct device *dev;
  62. struct mutex mtx;
  63. u32 pseudo_palette[17];
  64. int state;
  65. unsigned num_fbs;
  66. struct fb_info *fbs[10];
  67. unsigned num_displays;
  68. struct omap_dss_device *displays[10];
  69. unsigned num_overlays;
  70. struct omap_overlay *overlays[10];
  71. unsigned num_managers;
  72. struct omap_overlay_manager *managers[10];
  73. unsigned num_bpp_overrides;
  74. struct {
  75. struct omap_dss_device *dssdev;
  76. u8 bpp;
  77. } bpp_overrides[10];
  78. };
  79. struct omapfb_colormode {
  80. enum omap_color_mode dssmode;
  81. u32 bits_per_pixel;
  82. u32 nonstd;
  83. struct fb_bitfield red;
  84. struct fb_bitfield green;
  85. struct fb_bitfield blue;
  86. struct fb_bitfield transp;
  87. };
  88. void set_fb_fix(struct fb_info *fbi);
  89. int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var);
  90. int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type);
  91. int omapfb_apply_changes(struct fb_info *fbi, int init);
  92. int omapfb_create_sysfs(struct omapfb2_device *fbdev);
  93. void omapfb_remove_sysfs(struct omapfb2_device *fbdev);
  94. int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg);
  95. int omapfb_update_window(struct fb_info *fbi,
  96. u32 x, u32 y, u32 w, u32 h);
  97. int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
  98. struct fb_var_screeninfo *var);
  99. /* find the display connected to this fb, if any */
  100. static inline struct omap_dss_device *fb2display(struct fb_info *fbi)
  101. {
  102. struct omapfb_info *ofbi = FB2OFB(fbi);
  103. int i;
  104. /* XXX: returns the display connected to first attached overlay */
  105. for (i = 0; i < ofbi->num_overlays; i++) {
  106. if (ofbi->overlays[i]->manager)
  107. return ofbi->overlays[i]->manager->device;
  108. }
  109. return NULL;
  110. }
  111. static inline void omapfb_lock(struct omapfb2_device *fbdev)
  112. {
  113. mutex_lock(&fbdev->mtx);
  114. }
  115. static inline void omapfb_unlock(struct omapfb2_device *fbdev)
  116. {
  117. mutex_unlock(&fbdev->mtx);
  118. }
  119. static inline int omapfb_overlay_enable(struct omap_overlay *ovl,
  120. int enable)
  121. {
  122. struct omap_overlay_info info;
  123. ovl->get_overlay_info(ovl, &info);
  124. info.enabled = enable;
  125. return ovl->set_overlay_info(ovl, &info);
  126. }
  127. #endif