omapfb.h 7.5 KB
Newer Older
1
/*
T
Tomi Valkeinen 已提交
2
 * File: drivers/video/omap/omapfb.h
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * Framebuffer driver for TI OMAP boards
 *
 * Copyright (C) 2004 Nokia Corporation
 * Author: Imre Deak <imre.deak@nokia.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * 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, write to the Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifndef __OMAPFB_H
#define __OMAPFB_H

#include <linux/fb.h>
28
#include <linux/mutex.h>
T
Tomi Valkeinen 已提交
29
#include <linux/omapfb.h>
30

T
Tomi Valkeinen 已提交
31 32
#define OMAPFB_EVENT_READY	1
#define OMAPFB_EVENT_DISABLED	2
33 34 35 36 37 38 39 40 41 42 43 44

#define OMAP_LCDC_INV_VSYNC             0x0001
#define OMAP_LCDC_INV_HSYNC             0x0002
#define OMAP_LCDC_INV_PIX_CLOCK         0x0004
#define OMAP_LCDC_INV_OUTPUT_EN         0x0008
#define OMAP_LCDC_HSVS_RISING_EDGE      0x0010
#define OMAP_LCDC_HSVS_OPPOSITE         0x0020

#define OMAP_LCDC_SIGNAL_MASK		0x003f

#define OMAP_LCDC_PANEL_TFT		0x0100

45 46 47
#define OMAPFB_PLANE_XRES_MIN		8
#define OMAPFB_PLANE_YRES_MIN		8

48 49
struct omapfb_device;

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#define OMAPFB_PLANE_NUM		1

struct omapfb_mem_region {
	u32		paddr;
	void __iomem	*vaddr;
	unsigned long	size;
	u8		type;		/* OMAPFB_PLANE_MEM_* */
	enum omapfb_color_format format;/* OMAPFB_COLOR_* */
	unsigned	format_used:1;	/* Must be set when format is set.
					 * Needed b/c of the badly chosen 0
					 * base for OMAPFB_COLOR_* values
					 */
	unsigned	alloc:1;	/* allocated by the driver */
	unsigned	map:1;		/* kernel mapped by the driver */
};

struct omapfb_mem_desc {
	int				region_cnt;
	struct omapfb_mem_region	region[OMAPFB_PLANE_NUM];
};

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
struct lcd_panel {
	const char	*name;
	int		config;		/* TFT/STN, signal inversion */
	int		bpp;		/* Pixel format in fb mem */
	int		data_lines;	/* Lines on LCD HW interface */

	int		x_res, y_res;
	int		pixel_clock;	/* In kHz */
	int		hsw;		/* Horizontal synchronization
					   pulse width */
	int		hfp;		/* Horizontal front porch */
	int		hbp;		/* Horizontal back porch */
	int		vsw;		/* Vertical synchronization
					   pulse width */
	int		vfp;		/* Vertical front porch */
	int		vbp;		/* Vertical back porch */
	int		acb;		/* ac-bias pin frequency */
	int		pcd;		/* pixel clock divider.
					   Obsolete use pixel_clock instead */

91 92 93 94 95 96 97 98 99 100 101
	int		(*init)		(struct lcd_panel *panel,
					 struct omapfb_device *fbdev);
	void		(*cleanup)	(struct lcd_panel *panel);
	int		(*enable)	(struct lcd_panel *panel);
	void		(*disable)	(struct lcd_panel *panel);
	unsigned long	(*get_caps)	(struct lcd_panel *panel);
	int		(*set_bklight_level)(struct lcd_panel *panel,
					     unsigned int level);
	unsigned int	(*get_bklight_level)(struct lcd_panel *panel);
	unsigned int	(*get_bklight_max)  (struct lcd_panel *panel);
	int		(*run_test)	(struct lcd_panel *panel, int test_num);
102 103 104 105 106 107 108 109 110 111 112 113 114
};

struct extif_timings {
	int cs_on_time;
	int cs_off_time;
	int we_on_time;
	int we_off_time;
	int re_on_time;
	int re_off_time;
	int we_cycle_time;
	int re_cycle_time;
	int cs_pulse_width;
	int access_time;
115 116 117 118 119 120

	int clk_div;

	u32 tim[5];		/* set by extif->convert_timings */

	int converted;
121 122 123
};

struct lcd_ctrl_extif {
124
	int  (*init)		(struct omapfb_device *fbdev);
125
	void (*cleanup)		(void);
126
	void (*get_clk_info)	(u32 *clk_period, u32 *max_clk_div);
127
	unsigned long (*get_max_tx_rate)(void);
128
	int  (*convert_timings)	(struct extif_timings *timings);
129
	void (*set_timings)	(const struct extif_timings *timings);
130 131 132 133
	void (*set_bits_per_cycle)(int bpc);
	void (*write_command)	(const void *buf, unsigned int len);
	void (*read_data)	(void *buf, unsigned int len);
	void (*write_data)	(const void *buf, unsigned int len);
134
	void (*transfer_area)	(int width, int height,
T
Tomi Valkeinen 已提交
135
				 void (callback)(void *data), void *data);
136 137 138 139
	int  (*setup_tearsync)	(unsigned pin_cnt,
				 unsigned hs_pulse_time, unsigned vs_pulse_time,
				 int hs_pol_inv, int vs_pol_inv, int div);
	int  (*enable_tearsync) (int enable, unsigned line);
140

141
	unsigned long		max_transmit_size;
142 143
};

144 145 146
struct omapfb_notifier_block {
	struct notifier_block	nb;
	void			*data;
147
	int			plane_idx;
148 149
};

150 151 152 153
typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
					  unsigned long event,
					  void *fbi);

154 155 156 157 158
struct lcd_ctrl {
	const char	*name;
	void		*data;

	int		(*init)		  (struct omapfb_device *fbdev,
159 160
					   int ext_mode,
					   struct omapfb_mem_desc *req_md);
161
	void		(*cleanup)	  (void);
162
	void		(*bind_client)	  (struct omapfb_notifier_block *nb);
163
	void		(*get_caps)	  (int plane, struct omapfb_caps *caps);
164 165 166 167 168 169 170
	int		(*set_update_mode)(enum omapfb_update_mode mode);
	enum omapfb_update_mode (*get_update_mode)(void);
	int		(*setup_plane)	  (int plane, int channel_out,
					   unsigned long offset,
					   int screen_width,
					   int pos_x, int pos_y, int width,
					   int height, int color_mode);
171
	int		(*set_rotate)	  (int angle);
172 173 174 175
	int		(*setup_mem)	  (int plane, size_t size,
					   int mem_type, unsigned long *paddr);
	int		(*mmap)		  (struct fb_info *info,
					   struct vm_area_struct *vma);
176 177 178
	int		(*set_scale)	  (int plane,
					   int orig_width, int orig_height,
					   int out_width, int out_height);
179
	int		(*enable_plane)	  (int plane, int enable);
180 181
	int		(*update_window)  (struct fb_info *fbi,
					   struct omapfb_update_window *win,
182 183 184 185 186 187 188 189 190 191
					   void (*callback)(void *),
					   void *callback_data);
	void		(*sync)		  (void);
	void		(*suspend)	  (void);
	void		(*resume)	  (void);
	int		(*run_test)	  (int test_num);
	int		(*setcolreg)	  (u_int regno, u16 red, u16 green,
					   u16 blue, u16 transp,
					   int update_hw_mem);
	int		(*set_color_key)  (struct omapfb_color_key *ck);
192
	int		(*get_color_key)  (struct omapfb_color_key *ck);
193 194 195
};

enum omapfb_state {
T
Tomi Valkeinen 已提交
196 197 198
	OMAPFB_DISABLED		= 0,
	OMAPFB_SUSPENDED	= 99,
	OMAPFB_ACTIVE		= 100
199 200
};

201 202 203 204 205 206 207
struct omapfb_plane_struct {
	int				idx;
	struct omapfb_plane_info	info;
	enum omapfb_color_format	color_mode;
	struct omapfb_device		*fbdev;
};

208 209
struct omapfb_device {
	int			state;
T
Tomi Valkeinen 已提交
210 211
	int                     ext_lcdc;		/* Using external
							   LCD controller */
212
	struct mutex		rqueue_mutex;
213 214 215 216 217

	int			palette_size;
	u32			pseudo_palette[17];

	struct lcd_panel	*panel;			/* LCD panel */
R
Russell King 已提交
218 219
	const struct lcd_ctrl	*ctrl;			/* LCD controller */
	const struct lcd_ctrl	*int_ctrl;		/* internal LCD ctrl */
220 221 222
	struct lcd_ctrl_extif	*ext_if;		/* LCD ctrl external
							   interface */
	struct device		*dev;
223
	struct fb_var_screeninfo	new_var;	/* for mode changes */
224 225 226

	struct omapfb_mem_desc		mem_desc;
	struct fb_info			*fb_info[OMAPFB_PLANE_NUM];
227 228

	struct platform_device	*dssdev;	/* dummy dev for clocks */
229 230 231 232
};

extern struct lcd_ctrl omap1_lcd_ctrl;

233
extern void omapfb_register_panel(struct lcd_panel *panel);
234
extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
235 236 237
extern void omapfb_notify_clients(struct omapfb_device *fbdev,
				  unsigned long event);
extern int  omapfb_register_client(struct omapfb_notifier_block *nb,
238 239
				   omapfb_notifier_callback_t callback,
				   void *callback_data);
240
extern int  omapfb_unregister_client(struct omapfb_notifier_block *nb);
241 242 243 244
extern int  omapfb_update_window_async(struct fb_info *fbi,
				       struct omapfb_update_window *win,
				       void (*callback)(void *),
				       void *callback_data);
245

246
#endif /* __OMAPFB_H */