Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
9ad5897c | 2 | /* |
91773a00 | 3 | * File: drivers/video/omap/omapfb.h |
9ad5897c TL |
4 | * |
5 | * Framebuffer driver for TI OMAP boards | |
6 | * | |
7 | * Copyright (C) 2004 Nokia Corporation | |
8 | * Author: Imre Deak <imre.deak@nokia.com> | |
9ad5897c TL |
9 | */ |
10 | ||
11 | #ifndef __OMAPFB_H | |
12 | #define __OMAPFB_H | |
13 | ||
9ad5897c | 14 | #include <linux/fb.h> |
0dc5e77c | 15 | #include <linux/mutex.h> |
91773a00 | 16 | #include <linux/omapfb.h> |
0dc5e77c | 17 | |
91773a00 TV |
18 | #define OMAPFB_EVENT_READY 1 |
19 | #define OMAPFB_EVENT_DISABLED 2 | |
9ad5897c TL |
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 | ||
f4e4c324 TL |
32 | #define OMAPFB_PLANE_XRES_MIN 8 |
33 | #define OMAPFB_PLANE_YRES_MIN 8 | |
34 | ||
9ad5897c TL |
35 | struct omapfb_device; |
36 | ||
8f5e35a7 | 37 | #define OMAPFB_PLANE_NUM 1 |
8f5e35a7 TV |
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 | ||
9ad5897c TL |
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 | ||
f4e4c324 TL |
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); | |
9ad5897c TL |
89 | }; |
90 | ||
9ad5897c TL |
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; | |
0dc5e77c TL |
102 | |
103 | int clk_div; | |
104 | ||
105 | u32 tim[5]; /* set by extif->convert_timings */ | |
106 | ||
107 | int converted; | |
9ad5897c TL |
108 | }; |
109 | ||
110 | struct lcd_ctrl_extif { | |
f4e4c324 | 111 | int (*init) (struct omapfb_device *fbdev); |
9ad5897c | 112 | void (*cleanup) (void); |
0dc5e77c | 113 | void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div); |
b01d96d6 | 114 | unsigned long (*get_max_tx_rate)(void); |
0dc5e77c | 115 | int (*convert_timings) (struct extif_timings *timings); |
9ad5897c | 116 | void (*set_timings) (const struct extif_timings *timings); |
0dc5e77c TL |
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); | |
9ad5897c | 121 | void (*transfer_area) (int width, int height, |
91773a00 | 122 | void (callback)(void *data), void *data); |
b01d96d6 KS |
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); | |
f4e4c324 | 127 | |
0dc5e77c | 128 | unsigned long max_transmit_size; |
9ad5897c TL |
129 | }; |
130 | ||
0dc5e77c TL |
131 | struct omapfb_notifier_block { |
132 | struct notifier_block nb; | |
133 | void *data; | |
f4e4c324 | 134 | int plane_idx; |
0dc5e77c TL |
135 | }; |
136 | ||
f4e4c324 TL |
137 | typedef int (*omapfb_notifier_callback_t)(struct notifier_block *, |
138 | unsigned long event, | |
139 | void *fbi); | |
140 | ||
9ad5897c TL |
141 | struct lcd_ctrl { |
142 | const char *name; | |
143 | void *data; | |
144 | ||
145 | int (*init) (struct omapfb_device *fbdev, | |
f4e4c324 TL |
146 | int ext_mode, |
147 | struct omapfb_mem_desc *req_md); | |
9ad5897c | 148 | void (*cleanup) (void); |
0dc5e77c | 149 | void (*bind_client) (struct omapfb_notifier_block *nb); |
b01d96d6 | 150 | void (*get_caps) (int plane, struct omapfb_caps *caps); |
9ad5897c TL |
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); | |
646e3ed1 | 158 | int (*set_rotate) (int angle); |
b01d96d6 KS |
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); | |
f4e4c324 TL |
163 | int (*set_scale) (int plane, |
164 | int orig_width, int orig_height, | |
165 | int out_width, int out_height); | |
9ad5897c | 166 | int (*enable_plane) (int plane, int enable); |
f4e4c324 TL |
167 | int (*update_window) (struct fb_info *fbi, |
168 | struct omapfb_update_window *win, | |
9ad5897c TL |
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); | |
f4e4c324 | 179 | int (*get_color_key) (struct omapfb_color_key *ck); |
9ad5897c TL |
180 | }; |
181 | ||
182 | enum omapfb_state { | |
91773a00 TV |
183 | OMAPFB_DISABLED = 0, |
184 | OMAPFB_SUSPENDED = 99, | |
185 | OMAPFB_ACTIVE = 100 | |
9ad5897c TL |
186 | }; |
187 | ||
f4e4c324 TL |
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 | ||
9ad5897c TL |
195 | struct omapfb_device { |
196 | int state; | |
91773a00 TV |
197 | int ext_lcdc; /* Using external |
198 | LCD controller */ | |
0dc5e77c | 199 | struct mutex rqueue_mutex; |
9ad5897c | 200 | |
9ad5897c | 201 | int palette_size; |
9ad5897c TL |
202 | u32 pseudo_palette[17]; |
203 | ||
204 | struct lcd_panel *panel; /* LCD panel */ | |
020f9706 RK |
205 | const struct lcd_ctrl *ctrl; /* LCD controller */ |
206 | const struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */ | |
81ad0f5b AB |
207 | int ext_irq; |
208 | int int_irq; | |
9ad5897c TL |
209 | struct lcd_ctrl_extif *ext_if; /* LCD ctrl external |
210 | interface */ | |
9ad5897c | 211 | struct device *dev; |
b01d96d6 | 212 | struct fb_var_screeninfo new_var; /* for mode changes */ |
f4e4c324 TL |
213 | |
214 | struct omapfb_mem_desc mem_desc; | |
215 | struct fb_info *fb_info[OMAPFB_PLANE_NUM]; | |
f778a12d TV |
216 | |
217 | struct platform_device *dssdev; /* dummy dev for clocks */ | |
9ad5897c TL |
218 | }; |
219 | ||
9ad5897c | 220 | extern struct lcd_ctrl omap1_lcd_ctrl; |
9ad5897c | 221 | |
0dc5e77c | 222 | extern void omapfb_register_panel(struct lcd_panel *panel); |
9ad5897c | 223 | extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval); |
0dc5e77c TL |
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, | |
f4e4c324 TL |
227 | omapfb_notifier_callback_t callback, |
228 | void *callback_data); | |
0dc5e77c | 229 | extern int omapfb_unregister_client(struct omapfb_notifier_block *nb); |
9ad5897c | 230 | #endif /* __OMAPFB_H */ |