2009-08-04 13:12:50 +00:00
|
|
|
/*
|
|
|
|
* linux/drivers/video/omap2/omapfb.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Nokia Corporation
|
|
|
|
* Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
|
|
|
|
*
|
|
|
|
* Some code and ideas taken from drivers/video/omap/ driver
|
|
|
|
* by Imre Deak.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
|
|
|
|
#define __DRIVERS_VIDEO_OMAP2_OMAPFB_H__
|
|
|
|
|
|
|
|
#ifdef CONFIG_FB_OMAP2_DEBUG_SUPPORT
|
|
|
|
#define DEBUG
|
|
|
|
#endif
|
|
|
|
|
2010-03-17 18:58:03 +00:00
|
|
|
#include <linux/rwsem.h>
|
2012-11-09 13:52:20 +00:00
|
|
|
#include <linux/dma-mapping.h>
|
2010-03-17 18:58:03 +00:00
|
|
|
|
2016-05-31 08:43:12 +00:00
|
|
|
#include <video/omapfb_dss.h>
|
2009-08-04 13:12:50 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-01-12 23:02:20 +00:00
|
|
|
extern bool omapfb_debug;
|
2009-08-04 13:12:50 +00:00
|
|
|
#define DBG(format, ...) \
|
2011-05-10 11:07:33 +00:00
|
|
|
do { \
|
|
|
|
if (omapfb_debug) \
|
|
|
|
printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__); \
|
|
|
|
} while (0)
|
2009-08-04 13:12:50 +00:00
|
|
|
#else
|
|
|
|
#define DBG(format, ...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FB2OFB(fb_info) ((struct omapfb_info *)(fb_info->par))
|
|
|
|
|
|
|
|
/* max number of overlays to which a framebuffer data can be direct */
|
|
|
|
#define OMAPFB_MAX_OVL_PER_FB 3
|
|
|
|
|
|
|
|
struct omapfb2_mem_region {
|
2010-03-17 18:36:51 +00:00
|
|
|
int id;
|
2016-08-03 20:46:00 +00:00
|
|
|
unsigned long attrs;
|
2012-11-09 13:52:20 +00:00
|
|
|
void *token;
|
|
|
|
dma_addr_t dma_handle;
|
2009-08-04 13:12:50 +00:00
|
|
|
u32 paddr;
|
|
|
|
void __iomem *vaddr;
|
|
|
|
struct vrfb vrfb;
|
|
|
|
unsigned long size;
|
|
|
|
u8 type; /* OMAPFB_PLANE_MEM_* */
|
|
|
|
bool alloc; /* allocated by the driver */
|
|
|
|
bool map; /* kernel mapped by the driver */
|
2010-03-17 18:36:51 +00:00
|
|
|
atomic_t map_count;
|
2012-12-13 11:19:05 +00:00
|
|
|
struct rw_semaphore lock;
|
|
|
|
atomic_t lock_count;
|
2009-08-04 13:12:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* appended to fb_info */
|
|
|
|
struct omapfb_info {
|
|
|
|
int id;
|
2010-03-17 18:36:51 +00:00
|
|
|
struct omapfb2_mem_region *region;
|
2009-08-04 13:12:50 +00:00
|
|
|
int num_overlays;
|
|
|
|
struct omap_overlay *overlays[OMAPFB_MAX_OVL_PER_FB];
|
|
|
|
struct omapfb2_device *fbdev;
|
|
|
|
enum omap_dss_rotation_type rotation_type;
|
|
|
|
u8 rotation[OMAPFB_MAX_OVL_PER_FB];
|
|
|
|
bool mirror;
|
|
|
|
};
|
|
|
|
|
2011-04-30 09:13:14 +00:00
|
|
|
struct omapfb_display_data {
|
2011-04-30 13:55:12 +00:00
|
|
|
struct omapfb2_device *fbdev;
|
2011-04-30 09:13:14 +00:00
|
|
|
struct omap_dss_device *dssdev;
|
|
|
|
u8 bpp_override;
|
2011-04-30 13:55:12 +00:00
|
|
|
enum omapfb_update_mode update_mode;
|
|
|
|
bool auto_update_work_enabled;
|
|
|
|
struct delayed_work auto_update_work;
|
2011-04-30 09:13:14 +00:00
|
|
|
};
|
|
|
|
|
2009-08-04 13:12:50 +00:00
|
|
|
struct omapfb2_device {
|
|
|
|
struct device *dev;
|
|
|
|
struct mutex mtx;
|
|
|
|
|
|
|
|
u32 pseudo_palette[17];
|
|
|
|
|
|
|
|
int state;
|
|
|
|
|
|
|
|
unsigned num_fbs;
|
|
|
|
struct fb_info *fbs[10];
|
2010-03-17 18:36:51 +00:00
|
|
|
struct omapfb2_mem_region regions[10];
|
2009-08-04 13:12:50 +00:00
|
|
|
|
|
|
|
unsigned num_displays;
|
2011-04-30 09:13:14 +00:00
|
|
|
struct omapfb_display_data displays[10];
|
2009-08-04 13:12:50 +00:00
|
|
|
unsigned num_overlays;
|
|
|
|
struct omap_overlay *overlays[10];
|
|
|
|
unsigned num_managers;
|
|
|
|
struct omap_overlay_manager *managers[10];
|
2011-04-30 13:55:12 +00:00
|
|
|
|
|
|
|
struct workqueue_struct *auto_update_wq;
|
2009-08-04 13:12:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct omapfb_colormode {
|
|
|
|
enum omap_color_mode dssmode;
|
|
|
|
u32 bits_per_pixel;
|
|
|
|
u32 nonstd;
|
|
|
|
struct fb_bitfield red;
|
|
|
|
struct fb_bitfield green;
|
|
|
|
struct fb_bitfield blue;
|
|
|
|
struct fb_bitfield transp;
|
|
|
|
};
|
|
|
|
|
|
|
|
void set_fb_fix(struct fb_info *fbi);
|
|
|
|
int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var);
|
|
|
|
int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type);
|
|
|
|
int omapfb_apply_changes(struct fb_info *fbi, int init);
|
|
|
|
|
|
|
|
int omapfb_create_sysfs(struct omapfb2_device *fbdev);
|
|
|
|
void omapfb_remove_sysfs(struct omapfb2_device *fbdev);
|
|
|
|
|
|
|
|
int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg);
|
|
|
|
|
|
|
|
int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
|
|
|
|
struct fb_var_screeninfo *var);
|
|
|
|
|
2010-03-17 18:36:51 +00:00
|
|
|
int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
|
|
|
|
u16 posx, u16 posy, u16 outw, u16 outh);
|
|
|
|
|
2011-04-30 13:55:12 +00:00
|
|
|
void omapfb_start_auto_update(struct omapfb2_device *fbdev,
|
|
|
|
struct omap_dss_device *display);
|
|
|
|
void omapfb_stop_auto_update(struct omapfb2_device *fbdev,
|
|
|
|
struct omap_dss_device *display);
|
|
|
|
int omapfb_get_update_mode(struct fb_info *fbi, enum omapfb_update_mode *mode);
|
|
|
|
int omapfb_set_update_mode(struct fb_info *fbi, enum omapfb_update_mode mode);
|
|
|
|
|
2009-08-04 13:12:50 +00:00
|
|
|
/* find the display connected to this fb, if any */
|
|
|
|
static inline struct omap_dss_device *fb2display(struct fb_info *fbi)
|
|
|
|
{
|
|
|
|
struct omapfb_info *ofbi = FB2OFB(fbi);
|
2012-12-13 10:17:08 +00:00
|
|
|
struct omap_overlay *ovl;
|
2009-08-04 13:12:50 +00:00
|
|
|
|
|
|
|
/* XXX: returns the display connected to first attached overlay */
|
2012-07-20 12:56:56 +00:00
|
|
|
|
2012-12-13 10:17:08 +00:00
|
|
|
if (ofbi->num_overlays == 0)
|
|
|
|
return NULL;
|
2009-08-04 13:12:50 +00:00
|
|
|
|
2012-12-13 10:17:08 +00:00
|
|
|
ovl = ofbi->overlays[0];
|
|
|
|
|
|
|
|
return ovl->get_device(ovl);
|
2009-08-04 13:12:50 +00:00
|
|
|
}
|
|
|
|
|
2011-04-30 09:13:14 +00:00
|
|
|
static inline struct omapfb_display_data *get_display_data(
|
|
|
|
struct omapfb2_device *fbdev, struct omap_dss_device *dssdev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fbdev->num_displays; ++i)
|
|
|
|
if (fbdev->displays[i].dssdev == dssdev)
|
|
|
|
return &fbdev->displays[i];
|
|
|
|
|
|
|
|
/* This should never happen */
|
|
|
|
BUG();
|
2012-05-18 08:48:28 +00:00
|
|
|
return NULL;
|
2011-04-30 09:13:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-04 13:12:50 +00:00
|
|
|
static inline void omapfb_lock(struct omapfb2_device *fbdev)
|
|
|
|
{
|
|
|
|
mutex_lock(&fbdev->mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void omapfb_unlock(struct omapfb2_device *fbdev)
|
|
|
|
{
|
|
|
|
mutex_unlock(&fbdev->mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int omapfb_overlay_enable(struct omap_overlay *ovl,
|
|
|
|
int enable)
|
|
|
|
{
|
OMAPDSS: APPLY: rewrite overlay enable/disable
Overlays are currently enabled and disabled with a boolean in the struct
omap_overlay_info. The overlay info is set with ovl->set_overlay_info(),
and made into use with mgr->apply().
This doesn't work properly, as the enable/disable status may affect also
other overlays, for example when using fifo-merge. Thus the enabling and
disabling of the overlay needs to be done outside the normal overlay
configuration.
This patch achieves that by doing the following things:
1) Add function pointers to struct omap_overlay: enable(), disable() and
is_enabled(). These are used to do the obvious. The functions may block.
2) Move the "enabled" field from struct omap_overlay to ovl_priv_data.
3) Add a new route for settings to be applied to the HW, called
"extra_info". The status of the normal info and extra_info are tracked
separately.
The point here is to allow the normal info to be changed and
applied in non-blocking matter, whereas the extra_info can only be
changed when holding the mutex. This makes it possible to, for example,
set the overlay enable flag, apply it, and wait until the HW has taken
the flag into use.
This is not possible if the enable flag would be in the normal info, as
a new value for the flag could be set at any time from the users of
omapdss.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2011-11-15 14:37:53 +00:00
|
|
|
if (enable)
|
|
|
|
return ovl->enable(ovl);
|
|
|
|
else
|
|
|
|
return ovl->disable(ovl);
|
2009-08-04 13:12:50 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 11:19:05 +00:00
|
|
|
static inline struct omapfb2_mem_region *
|
|
|
|
omapfb_get_mem_region(struct omapfb2_mem_region *rg)
|
|
|
|
{
|
|
|
|
down_read_nested(&rg->lock, rg->id);
|
|
|
|
atomic_inc(&rg->lock_count);
|
|
|
|
return rg;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg)
|
|
|
|
{
|
|
|
|
atomic_dec(&rg->lock_count);
|
|
|
|
up_read(&rg->lock);
|
|
|
|
}
|
|
|
|
|
2009-08-04 13:12:50 +00:00
|
|
|
#endif
|