1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * File: drivers/video/omap/omapfb.h
5 * Framebuffer driver for TI OMAP boards
7 * Copyright (C) 2004 Nokia Corporation
8 * Author: Imre Deak <imre.deak@nokia.com>
15 #include <linux/mutex.h>
16 #include <linux/omapfb.h>
18 #define OMAPFB_EVENT_READY 1
19 #define OMAPFB_EVENT_DISABLED 2
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
28 #define OMAP_LCDC_SIGNAL_MASK 0x003f
30 #define OMAP_LCDC_PANEL_TFT 0x0100
32 #define OMAPFB_PLANE_XRES_MIN 8
33 #define OMAPFB_PLANE_YRES_MIN 8
37 #define OMAPFB_PLANE_NUM 1
39 struct omapfb_mem_region
{
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
49 unsigned alloc
:1; /* allocated by the driver */
50 unsigned map
:1; /* kernel mapped by the driver */
53 struct omapfb_mem_desc
{
55 struct omapfb_mem_region region
[OMAPFB_PLANE_NUM
];
60 int config
; /* TFT/STN, signal inversion */
61 int bpp
; /* Pixel format in fb mem */
62 int data_lines
; /* Lines on LCD HW interface */
65 int pixel_clock
; /* In kHz */
66 int hsw
; /* Horizontal synchronization
68 int hfp
; /* Horizontal front porch */
69 int hbp
; /* Horizontal back porch */
70 int vsw
; /* Vertical synchronization
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 */
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
,
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
);
91 struct extif_timings
{
105 u32 tim
[5]; /* set by extif->convert_timings */
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
);
128 unsigned long max_transmit_size
;
131 struct omapfb_notifier_block
{
132 struct notifier_block nb
;
137 typedef int (*omapfb_notifier_callback_t
)(struct notifier_block
*,
145 int (*init
) (struct omapfb_device
*fbdev
,
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
,
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
);
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
,
178 int (*set_color_key
) (struct omapfb_color_key
*ck
);
179 int (*get_color_key
) (struct omapfb_color_key
*ck
);
184 OMAPFB_SUSPENDED
= 99,
188 struct omapfb_plane_struct
{
190 struct omapfb_plane_info info
;
191 enum omapfb_color_format color_mode
;
192 struct omapfb_device
*fbdev
;
195 struct omapfb_device
{
197 int ext_lcdc
; /* Using external
199 struct mutex rqueue_mutex
;
202 u32 pseudo_palette
[17];
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 struct lcd_ctrl_extif
*ext_if
; /* LCD ctrl external
210 struct fb_var_screeninfo new_var
; /* for mode changes */
212 struct omapfb_mem_desc mem_desc
;
213 struct fb_info
*fb_info
[OMAPFB_PLANE_NUM
];
215 struct platform_device
*dssdev
; /* dummy dev for clocks */
218 extern struct lcd_ctrl omap1_lcd_ctrl
;
220 extern void omapfb_register_panel(struct lcd_panel
*panel
);
221 extern void omapfb_write_first_pixel(struct omapfb_device
*fbdev
, u16 pixval
);
222 extern void omapfb_notify_clients(struct omapfb_device
*fbdev
,
223 unsigned long event
);
224 extern int omapfb_register_client(struct omapfb_notifier_block
*nb
,
225 omapfb_notifier_callback_t callback
,
226 void *callback_data
);
227 extern int omapfb_unregister_client(struct omapfb_notifier_block
*nb
);
228 extern int omapfb_update_window_async(struct fb_info
*fbi
,
229 struct omapfb_update_window
*win
,
230 void (*callback
)(void *),
231 void *callback_data
);
233 #endif /* __OMAPFB_H */