xref: /openbmc/linux/drivers/video/fbdev/omap/omapfb.h (revision 7cc39531)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * File: drivers/video/omap/omapfb.h
4  *
5  * Framebuffer driver for TI OMAP boards
6  *
7  * Copyright (C) 2004 Nokia Corporation
8  * Author: Imre Deak <imre.deak@nokia.com>
9  */
10 
11 #ifndef __OMAPFB_H
12 #define __OMAPFB_H
13 
14 #include <linux/fb.h>
15 #include <linux/mutex.h>
16 #include <linux/omapfb.h>
17 
18 #define OMAPFB_EVENT_READY	1
19 #define OMAPFB_EVENT_DISABLED	2
20 
21 #define OMAP_LCDC_INV_VSYNC             0x0001
22 #define OMAP_LCDC_INV_HSYNC             0x0002
23 #define OMAP_LCDC_INV_PIX_CLOCK         0x0004
24 #define OMAP_LCDC_INV_OUTPUT_EN         0x0008
25 #define OMAP_LCDC_HSVS_RISING_EDGE      0x0010
26 #define OMAP_LCDC_HSVS_OPPOSITE         0x0020
27 
28 #define OMAP_LCDC_SIGNAL_MASK		0x003f
29 
30 #define OMAP_LCDC_PANEL_TFT		0x0100
31 
32 #define OMAPFB_PLANE_XRES_MIN		8
33 #define OMAPFB_PLANE_YRES_MIN		8
34 
35 struct omapfb_device;
36 
37 #define OMAPFB_PLANE_NUM		1
38 
39 struct omapfb_mem_region {
40 	u32		paddr;
41 	void __iomem	*vaddr;
42 	unsigned long	size;
43 	u8		type;		/* OMAPFB_PLANE_MEM_* */
44 	enum omapfb_color_format format;/* OMAPFB_COLOR_* */
45 	unsigned	format_used:1;	/* Must be set when format is set.
46 					 * Needed b/c of the badly chosen 0
47 					 * base for OMAPFB_COLOR_* values
48 					 */
49 	unsigned	alloc:1;	/* allocated by the driver */
50 	unsigned	map:1;		/* kernel mapped by the driver */
51 };
52 
53 struct omapfb_mem_desc {
54 	int				region_cnt;
55 	struct omapfb_mem_region	region[OMAPFB_PLANE_NUM];
56 };
57 
58 struct lcd_panel {
59 	const char	*name;
60 	int		config;		/* TFT/STN, signal inversion */
61 	int		bpp;		/* Pixel format in fb mem */
62 	int		data_lines;	/* Lines on LCD HW interface */
63 
64 	int		x_res, y_res;
65 	int		pixel_clock;	/* In kHz */
66 	int		hsw;		/* Horizontal synchronization
67 					   pulse width */
68 	int		hfp;		/* Horizontal front porch */
69 	int		hbp;		/* Horizontal back porch */
70 	int		vsw;		/* Vertical synchronization
71 					   pulse width */
72 	int		vfp;		/* Vertical front porch */
73 	int		vbp;		/* Vertical back porch */
74 	int		acb;		/* ac-bias pin frequency */
75 	int		pcd;		/* pixel clock divider.
76 					   Obsolete use pixel_clock instead */
77 
78 	int		(*init)		(struct lcd_panel *panel,
79 					 struct omapfb_device *fbdev);
80 	void		(*cleanup)	(struct lcd_panel *panel);
81 	int		(*enable)	(struct lcd_panel *panel);
82 	void		(*disable)	(struct lcd_panel *panel);
83 	unsigned long	(*get_caps)	(struct lcd_panel *panel);
84 	int		(*set_bklight_level)(struct lcd_panel *panel,
85 					     unsigned int level);
86 	unsigned int	(*get_bklight_level)(struct lcd_panel *panel);
87 	unsigned int	(*get_bklight_max)  (struct lcd_panel *panel);
88 	int		(*run_test)	(struct lcd_panel *panel, int test_num);
89 };
90 
91 struct extif_timings {
92 	int cs_on_time;
93 	int cs_off_time;
94 	int we_on_time;
95 	int we_off_time;
96 	int re_on_time;
97 	int re_off_time;
98 	int we_cycle_time;
99 	int re_cycle_time;
100 	int cs_pulse_width;
101 	int access_time;
102 
103 	int clk_div;
104 
105 	u32 tim[5];		/* set by extif->convert_timings */
106 
107 	int converted;
108 };
109 
110 struct lcd_ctrl_extif {
111 	int  (*init)		(struct omapfb_device *fbdev);
112 	void (*cleanup)		(void);
113 	void (*get_clk_info)	(u32 *clk_period, u32 *max_clk_div);
114 	unsigned long (*get_max_tx_rate)(void);
115 	int  (*convert_timings)	(struct extif_timings *timings);
116 	void (*set_timings)	(const struct extif_timings *timings);
117 	void (*set_bits_per_cycle)(int bpc);
118 	void (*write_command)	(const void *buf, unsigned int len);
119 	void (*read_data)	(void *buf, unsigned int len);
120 	void (*write_data)	(const void *buf, unsigned int len);
121 	void (*transfer_area)	(int width, int height,
122 				 void (callback)(void *data), void *data);
123 	int  (*setup_tearsync)	(unsigned pin_cnt,
124 				 unsigned hs_pulse_time, unsigned vs_pulse_time,
125 				 int hs_pol_inv, int vs_pol_inv, int div);
126 	int  (*enable_tearsync) (int enable, unsigned line);
127 
128 	unsigned long		max_transmit_size;
129 };
130 
131 struct omapfb_notifier_block {
132 	struct notifier_block	nb;
133 	void			*data;
134 	int			plane_idx;
135 };
136 
137 typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
138 					  unsigned long event,
139 					  void *fbi);
140 
141 struct lcd_ctrl {
142 	const char	*name;
143 	void		*data;
144 
145 	int		(*init)		  (struct omapfb_device *fbdev,
146 					   int ext_mode,
147 					   struct omapfb_mem_desc *req_md);
148 	void		(*cleanup)	  (void);
149 	void		(*bind_client)	  (struct omapfb_notifier_block *nb);
150 	void		(*get_caps)	  (int plane, struct omapfb_caps *caps);
151 	int		(*set_update_mode)(enum omapfb_update_mode mode);
152 	enum omapfb_update_mode (*get_update_mode)(void);
153 	int		(*setup_plane)	  (int plane, int channel_out,
154 					   unsigned long offset,
155 					   int screen_width,
156 					   int pos_x, int pos_y, int width,
157 					   int height, int color_mode);
158 	int		(*set_rotate)	  (int angle);
159 	int		(*setup_mem)	  (int plane, size_t size,
160 					   int mem_type, unsigned long *paddr);
161 	int		(*mmap)		  (struct fb_info *info,
162 					   struct vm_area_struct *vma);
163 	int		(*set_scale)	  (int plane,
164 					   int orig_width, int orig_height,
165 					   int out_width, int out_height);
166 	int		(*enable_plane)	  (int plane, int enable);
167 	int		(*update_window)  (struct fb_info *fbi,
168 					   struct omapfb_update_window *win,
169 					   void (*callback)(void *),
170 					   void *callback_data);
171 	void		(*sync)		  (void);
172 	void		(*suspend)	  (void);
173 	void		(*resume)	  (void);
174 	int		(*run_test)	  (int test_num);
175 	int		(*setcolreg)	  (u_int regno, u16 red, u16 green,
176 					   u16 blue, u16 transp,
177 					   int update_hw_mem);
178 	int		(*set_color_key)  (struct omapfb_color_key *ck);
179 	int		(*get_color_key)  (struct omapfb_color_key *ck);
180 };
181 
182 enum omapfb_state {
183 	OMAPFB_DISABLED		= 0,
184 	OMAPFB_SUSPENDED	= 99,
185 	OMAPFB_ACTIVE		= 100
186 };
187 
188 struct omapfb_plane_struct {
189 	int				idx;
190 	struct omapfb_plane_info	info;
191 	enum omapfb_color_format	color_mode;
192 	struct omapfb_device		*fbdev;
193 };
194 
195 struct omapfb_device {
196 	int			state;
197 	int                     ext_lcdc;		/* Using external
198 							   LCD controller */
199 	struct mutex		rqueue_mutex;
200 
201 	int			palette_size;
202 	u32			pseudo_palette[17];
203 
204 	struct lcd_panel	*panel;			/* LCD panel */
205 	const struct lcd_ctrl	*ctrl;			/* LCD controller */
206 	const struct lcd_ctrl	*int_ctrl;		/* internal LCD ctrl */
207 	int			ext_irq;
208 	int			int_irq;
209 	struct lcd_ctrl_extif	*ext_if;		/* LCD ctrl external
210 							   interface */
211 	struct device		*dev;
212 	struct fb_var_screeninfo	new_var;	/* for mode changes */
213 
214 	struct omapfb_mem_desc		mem_desc;
215 	struct fb_info			*fb_info[OMAPFB_PLANE_NUM];
216 
217 	struct platform_device	*dssdev;	/* dummy dev for clocks */
218 };
219 
220 extern struct lcd_ctrl omap1_lcd_ctrl;
221 
222 extern void omapfb_register_panel(struct lcd_panel *panel);
223 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
224 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
225 				  unsigned long event);
226 extern int  omapfb_register_client(struct omapfb_notifier_block *nb,
227 				   omapfb_notifier_callback_t callback,
228 				   void *callback_data);
229 extern int  omapfb_unregister_client(struct omapfb_notifier_block *nb);
230 #endif /* __OMAPFB_H */
231