Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 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 | |
| 23 | #ifndef __DRIVERS_VIDEO_OMAP2_OMAPFB_H__ |
| 24 | #define __DRIVERS_VIDEO_OMAP2_OMAPFB_H__ |
| 25 | |
| 26 | #ifdef CONFIG_FB_OMAP2_DEBUG_SUPPORT |
| 27 | #define DEBUG |
| 28 | #endif |
| 29 | |
| 30 | #include <plat/display.h> |
| 31 | |
| 32 | #ifdef DEBUG |
| 33 | extern unsigned int omapfb_debug; |
| 34 | #define DBG(format, ...) \ |
| 35 | if (omapfb_debug) \ |
| 36 | printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__) |
| 37 | #else |
| 38 | #define DBG(format, ...) |
| 39 | #endif |
| 40 | |
| 41 | #define FB2OFB(fb_info) ((struct omapfb_info *)(fb_info->par)) |
| 42 | |
| 43 | /* max number of overlays to which a framebuffer data can be direct */ |
| 44 | #define OMAPFB_MAX_OVL_PER_FB 3 |
| 45 | |
| 46 | struct omapfb2_mem_region { |
Ville Syrjälä | 078ff54 | 2010-03-17 20:36:51 +0200 | [diff] [blame^] | 47 | int id; |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 48 | u32 paddr; |
| 49 | void __iomem *vaddr; |
| 50 | struct vrfb vrfb; |
| 51 | unsigned long size; |
| 52 | u8 type; /* OMAPFB_PLANE_MEM_* */ |
| 53 | bool alloc; /* allocated by the driver */ |
| 54 | bool map; /* kernel mapped by the driver */ |
Ville Syrjälä | 078ff54 | 2010-03-17 20:36:51 +0200 | [diff] [blame^] | 55 | atomic_t map_count; |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | /* appended to fb_info */ |
| 59 | struct omapfb_info { |
| 60 | int id; |
Ville Syrjälä | 078ff54 | 2010-03-17 20:36:51 +0200 | [diff] [blame^] | 61 | struct omapfb2_mem_region *region; |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 62 | int num_overlays; |
| 63 | struct omap_overlay *overlays[OMAPFB_MAX_OVL_PER_FB]; |
| 64 | struct omapfb2_device *fbdev; |
| 65 | enum omap_dss_rotation_type rotation_type; |
| 66 | u8 rotation[OMAPFB_MAX_OVL_PER_FB]; |
| 67 | bool mirror; |
| 68 | }; |
| 69 | |
| 70 | struct omapfb2_device { |
| 71 | struct device *dev; |
| 72 | struct mutex mtx; |
| 73 | |
| 74 | u32 pseudo_palette[17]; |
| 75 | |
| 76 | int state; |
| 77 | |
| 78 | unsigned num_fbs; |
| 79 | struct fb_info *fbs[10]; |
Ville Syrjälä | 078ff54 | 2010-03-17 20:36:51 +0200 | [diff] [blame^] | 80 | struct omapfb2_mem_region regions[10]; |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 81 | |
| 82 | unsigned num_displays; |
| 83 | struct omap_dss_device *displays[10]; |
| 84 | unsigned num_overlays; |
| 85 | struct omap_overlay *overlays[10]; |
| 86 | unsigned num_managers; |
| 87 | struct omap_overlay_manager *managers[10]; |
Tomi Valkeinen | a269950 | 2010-01-11 14:33:40 +0200 | [diff] [blame] | 88 | |
| 89 | unsigned num_bpp_overrides; |
| 90 | struct { |
| 91 | struct omap_dss_device *dssdev; |
| 92 | u8 bpp; |
| 93 | } bpp_overrides[10]; |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | struct omapfb_colormode { |
| 97 | enum omap_color_mode dssmode; |
| 98 | u32 bits_per_pixel; |
| 99 | u32 nonstd; |
| 100 | struct fb_bitfield red; |
| 101 | struct fb_bitfield green; |
| 102 | struct fb_bitfield blue; |
| 103 | struct fb_bitfield transp; |
| 104 | }; |
| 105 | |
| 106 | void set_fb_fix(struct fb_info *fbi); |
| 107 | int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var); |
| 108 | int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type); |
| 109 | int omapfb_apply_changes(struct fb_info *fbi, int init); |
| 110 | |
| 111 | int omapfb_create_sysfs(struct omapfb2_device *fbdev); |
| 112 | void omapfb_remove_sysfs(struct omapfb2_device *fbdev); |
| 113 | |
| 114 | int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg); |
| 115 | |
Tomi Valkeinen | b63c97f5 | 2010-02-05 14:46:19 +0200 | [diff] [blame] | 116 | int omapfb_update_window(struct fb_info *fbi, |
| 117 | u32 x, u32 y, u32 w, u32 h); |
| 118 | |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 119 | int dss_mode_to_fb_mode(enum omap_color_mode dssmode, |
| 120 | struct fb_var_screeninfo *var); |
| 121 | |
Ville Syrjälä | 078ff54 | 2010-03-17 20:36:51 +0200 | [diff] [blame^] | 122 | int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl, |
| 123 | u16 posx, u16 posy, u16 outw, u16 outh); |
| 124 | |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 125 | /* find the display connected to this fb, if any */ |
| 126 | static inline struct omap_dss_device *fb2display(struct fb_info *fbi) |
| 127 | { |
| 128 | struct omapfb_info *ofbi = FB2OFB(fbi); |
| 129 | int i; |
| 130 | |
| 131 | /* XXX: returns the display connected to first attached overlay */ |
| 132 | for (i = 0; i < ofbi->num_overlays; i++) { |
| 133 | if (ofbi->overlays[i]->manager) |
| 134 | return ofbi->overlays[i]->manager->device; |
| 135 | } |
| 136 | |
| 137 | return NULL; |
| 138 | } |
| 139 | |
| 140 | static inline void omapfb_lock(struct omapfb2_device *fbdev) |
| 141 | { |
| 142 | mutex_lock(&fbdev->mtx); |
| 143 | } |
| 144 | |
| 145 | static inline void omapfb_unlock(struct omapfb2_device *fbdev) |
| 146 | { |
| 147 | mutex_unlock(&fbdev->mtx); |
| 148 | } |
| 149 | |
| 150 | static inline int omapfb_overlay_enable(struct omap_overlay *ovl, |
| 151 | int enable) |
| 152 | { |
| 153 | struct omap_overlay_info info; |
| 154 | |
| 155 | ovl->get_overlay_info(ovl, &info); |
Ville Syrjälä | 2ad0c50 | 2010-03-17 20:13:44 +0200 | [diff] [blame] | 156 | if (info.enabled == enable) |
| 157 | return 0; |
Tomi Valkeinen | b39a982d | 2009-08-04 16:12:50 +0300 | [diff] [blame] | 158 | info.enabled = enable; |
| 159 | return ovl->set_overlay_info(ovl, &info); |
| 160 | } |
| 161 | |
| 162 | #endif |