1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/drivers/video/omap2/omapfb.h
5 * Copyright (C) 2008 Nokia Corporation
6 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
8 * Some code and ideas taken from drivers/video/omap/ driver
12 #ifndef __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
13 #define __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
15 #ifdef CONFIG_FB_OMAP2_DEBUG_SUPPORT
19 #include <linux/rwsem.h>
20 #include <linux/dma-mapping.h>
22 #include <video/omapfb_dss.h>
25 extern bool omapfb_debug
;
26 #define DBG(format, ...) \
29 printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__); \
32 #define DBG(format, ...) no_printk(format, ## __VA_ARGS__)
35 #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
40 struct omapfb2_mem_region
{
44 dma_addr_t dma_handle
;
49 u8 type
; /* OMAPFB_PLANE_MEM_* */
50 bool alloc
; /* allocated by the driver */
51 bool map
; /* kernel mapped by the driver */
53 struct rw_semaphore lock
;
57 /* appended to fb_info */
60 struct omapfb2_mem_region
*region
;
62 struct omap_overlay
*overlays
[OMAPFB_MAX_OVL_PER_FB
];
63 struct omapfb2_device
*fbdev
;
64 enum omap_dss_rotation_type rotation_type
;
65 u8 rotation
[OMAPFB_MAX_OVL_PER_FB
];
69 struct omapfb_display_data
{
70 struct omapfb2_device
*fbdev
;
71 struct omap_dss_device
*dssdev
;
73 enum omapfb_update_mode update_mode
;
74 bool auto_update_work_enabled
;
75 struct delayed_work auto_update_work
;
78 struct omapfb2_device
{
82 u32 pseudo_palette
[17];
87 struct fb_info
*fbs
[10];
88 struct omapfb2_mem_region regions
[10];
90 unsigned num_displays
;
91 struct omapfb_display_data displays
[10];
92 unsigned num_overlays
;
93 struct omap_overlay
*overlays
[10];
94 unsigned num_managers
;
95 struct omap_overlay_manager
*managers
[10];
97 struct workqueue_struct
*auto_update_wq
;
100 struct omapfb_colormode
{
101 enum omap_color_mode dssmode
;
104 struct fb_bitfield red
;
105 struct fb_bitfield green
;
106 struct fb_bitfield blue
;
107 struct fb_bitfield transp
;
110 void set_fb_fix(struct fb_info
*fbi
);
111 int check_fb_var(struct fb_info
*fbi
, struct fb_var_screeninfo
*var
);
112 int omapfb_realloc_fbmem(struct fb_info
*fbi
, unsigned long size
, int type
);
113 int omapfb_apply_changes(struct fb_info
*fbi
, int init
);
115 int omapfb_create_sysfs(struct omapfb2_device
*fbdev
);
116 void omapfb_remove_sysfs(struct omapfb2_device
*fbdev
);
118 int omapfb_ioctl(struct fb_info
*fbi
, unsigned int cmd
, unsigned long arg
);
120 int dss_mode_to_fb_mode(enum omap_color_mode dssmode
,
121 struct fb_var_screeninfo
*var
);
123 int omapfb_setup_overlay(struct fb_info
*fbi
, struct omap_overlay
*ovl
,
124 u16 posx
, u16 posy
, u16 outw
, u16 outh
);
126 void omapfb_start_auto_update(struct omapfb2_device
*fbdev
,
127 struct omap_dss_device
*display
);
128 void omapfb_stop_auto_update(struct omapfb2_device
*fbdev
,
129 struct omap_dss_device
*display
);
130 int omapfb_get_update_mode(struct fb_info
*fbi
, enum omapfb_update_mode
*mode
);
131 int omapfb_set_update_mode(struct fb_info
*fbi
, enum omapfb_update_mode mode
);
133 /* find the display connected to this fb, if any */
134 static inline struct omap_dss_device
*fb2display(struct fb_info
*fbi
)
136 struct omapfb_info
*ofbi
= FB2OFB(fbi
);
137 struct omap_overlay
*ovl
;
139 /* XXX: returns the display connected to first attached overlay */
141 if (ofbi
->num_overlays
== 0)
144 ovl
= ofbi
->overlays
[0];
146 return ovl
->get_device(ovl
);
149 static inline struct omapfb_display_data
*get_display_data(
150 struct omapfb2_device
*fbdev
, struct omap_dss_device
*dssdev
)
154 for (i
= 0; i
< fbdev
->num_displays
; ++i
)
155 if (fbdev
->displays
[i
].dssdev
== dssdev
)
156 return &fbdev
->displays
[i
];
158 /* This should never happen */
163 static inline void omapfb_lock(struct omapfb2_device
*fbdev
)
165 mutex_lock(&fbdev
->mtx
);
168 static inline void omapfb_unlock(struct omapfb2_device
*fbdev
)
170 mutex_unlock(&fbdev
->mtx
);
173 static inline int omapfb_overlay_enable(struct omap_overlay
*ovl
,
177 return ovl
->enable(ovl
);
179 return ovl
->disable(ovl
);
182 static inline struct omapfb2_mem_region
*
183 omapfb_get_mem_region(struct omapfb2_mem_region
*rg
)
185 down_read_nested(&rg
->lock
, rg
->id
);
186 atomic_inc(&rg
->lock_count
);
190 static inline void omapfb_put_mem_region(struct omapfb2_mem_region
*rg
)
192 atomic_dec(&rg
->lock_count
);