blob: 85953a0bc7c2facc4ba0ac5a2d45ed13a0494010 [file] [log] [blame]
Tomi Valkeinen35a339a2016-02-19 16:54:36 +02001/*
2 * Copyright (C) 2016 Texas Instruments
3 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __OMAP_DRM_DSS_H
19#define __OMAP_DRM_DSS_H
20
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030021#include <linux/list.h>
22#include <linux/kobject.h>
23#include <linux/device.h>
24#include <linux/interrupt.h>
25#include <video/videomode.h>
26#include <linux/platform_data/omapdss.h>
Jyri Sarhaacc3a232016-06-07 15:09:15 +030027#include <uapi/drm/drm_mode.h>
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030028
29#define DISPC_IRQ_FRAMEDONE (1 << 0)
30#define DISPC_IRQ_VSYNC (1 << 1)
31#define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
32#define DISPC_IRQ_EVSYNC_ODD (1 << 3)
33#define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
34#define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
35#define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
36#define DISPC_IRQ_GFX_END_WIN (1 << 7)
37#define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
38#define DISPC_IRQ_OCP_ERR (1 << 9)
39#define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
40#define DISPC_IRQ_VID1_END_WIN (1 << 11)
41#define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
42#define DISPC_IRQ_VID2_END_WIN (1 << 13)
43#define DISPC_IRQ_SYNC_LOST (1 << 14)
44#define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
45#define DISPC_IRQ_WAKEUP (1 << 16)
46#define DISPC_IRQ_SYNC_LOST2 (1 << 17)
47#define DISPC_IRQ_VSYNC2 (1 << 18)
48#define DISPC_IRQ_VID3_END_WIN (1 << 19)
49#define DISPC_IRQ_VID3_FIFO_UNDERFLOW (1 << 20)
50#define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21)
51#define DISPC_IRQ_FRAMEDONE2 (1 << 22)
52#define DISPC_IRQ_FRAMEDONEWB (1 << 23)
53#define DISPC_IRQ_FRAMEDONETV (1 << 24)
54#define DISPC_IRQ_WBBUFFEROVERFLOW (1 << 25)
55#define DISPC_IRQ_WBUNCOMPLETEERROR (1 << 26)
56#define DISPC_IRQ_SYNC_LOST3 (1 << 27)
57#define DISPC_IRQ_VSYNC3 (1 << 28)
58#define DISPC_IRQ_ACBIAS_COUNT_STAT3 (1 << 29)
59#define DISPC_IRQ_FRAMEDONE3 (1 << 30)
60
61struct omap_dss_device;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030062struct dss_lcd_mgr_config;
63struct snd_aes_iec958;
64struct snd_cea_861_aud_if;
65struct hdmi_avi_infoframe;
66
67enum omap_display_type {
68 OMAP_DISPLAY_TYPE_NONE = 0,
69 OMAP_DISPLAY_TYPE_DPI = 1 << 0,
70 OMAP_DISPLAY_TYPE_DBI = 1 << 1,
71 OMAP_DISPLAY_TYPE_SDI = 1 << 2,
72 OMAP_DISPLAY_TYPE_DSI = 1 << 3,
73 OMAP_DISPLAY_TYPE_VENC = 1 << 4,
74 OMAP_DISPLAY_TYPE_HDMI = 1 << 5,
75 OMAP_DISPLAY_TYPE_DVI = 1 << 6,
76};
77
Jyri Sarha864050c2017-03-24 16:47:52 +020078enum omap_plane_id {
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030079 OMAP_DSS_GFX = 0,
80 OMAP_DSS_VIDEO1 = 1,
81 OMAP_DSS_VIDEO2 = 2,
82 OMAP_DSS_VIDEO3 = 3,
83 OMAP_DSS_WB = 4,
84};
85
86enum omap_channel {
87 OMAP_DSS_CHANNEL_LCD = 0,
88 OMAP_DSS_CHANNEL_DIGIT = 1,
89 OMAP_DSS_CHANNEL_LCD2 = 2,
90 OMAP_DSS_CHANNEL_LCD3 = 3,
91 OMAP_DSS_CHANNEL_WB = 4,
92};
93
94enum omap_color_mode {
Tomi Valkeinen3e1d65c2017-05-04 10:40:46 +030095 _UNUSED_,
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030096};
97
98enum omap_dss_load_mode {
99 OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
100 OMAP_DSS_LOAD_CLUT_ONLY = 1,
101 OMAP_DSS_LOAD_FRAME_ONLY = 2,
102 OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
103};
104
105enum omap_dss_trans_key_type {
106 OMAP_DSS_COLOR_KEY_GFX_DST = 0,
107 OMAP_DSS_COLOR_KEY_VID_SRC = 1,
108};
109
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300110enum omap_dss_signal_level {
111 OMAPDSS_SIG_ACTIVE_LOW,
112 OMAPDSS_SIG_ACTIVE_HIGH,
113};
114
115enum omap_dss_signal_edge {
116 OMAPDSS_DRIVE_SIG_FALLING_EDGE,
117 OMAPDSS_DRIVE_SIG_RISING_EDGE,
118};
119
120enum omap_dss_venc_type {
121 OMAP_DSS_VENC_TYPE_COMPOSITE,
122 OMAP_DSS_VENC_TYPE_SVIDEO,
123};
124
125enum omap_dss_dsi_pixel_format {
126 OMAP_DSS_DSI_FMT_RGB888,
127 OMAP_DSS_DSI_FMT_RGB666,
128 OMAP_DSS_DSI_FMT_RGB666_PACKED,
129 OMAP_DSS_DSI_FMT_RGB565,
130};
131
132enum omap_dss_dsi_mode {
133 OMAP_DSS_DSI_CMD_MODE = 0,
134 OMAP_DSS_DSI_VIDEO_MODE,
135};
136
137enum omap_display_caps {
138 OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE = 1 << 0,
139 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM = 1 << 1,
140};
141
142enum omap_dss_display_state {
143 OMAP_DSS_DISPLAY_DISABLED = 0,
144 OMAP_DSS_DISPLAY_ACTIVE,
145};
146
147enum omap_dss_rotation_type {
Tomi Valkeinen517a8a92017-05-03 14:14:27 +0300148 OMAP_DSS_ROT_NONE = 0,
149 OMAP_DSS_ROT_TILER = 1 << 0,
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300150};
151
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300152enum omap_overlay_caps {
153 OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
154 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA = 1 << 1,
155 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA = 1 << 2,
156 OMAP_DSS_OVL_CAP_ZORDER = 1 << 3,
157 OMAP_DSS_OVL_CAP_POS = 1 << 4,
158 OMAP_DSS_OVL_CAP_REPLICATION = 1 << 5,
159};
160
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300161enum omap_dss_clk_source {
162 OMAP_DSS_CLK_SRC_FCK = 0, /* OMAP2/3: DSS1_ALWON_FCLK
163 * OMAP4: DSS_FCLK */
164 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, /* OMAP3: DSI1_PLL_FCLK
165 * OMAP4: PLL1_CLK1 */
166 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, /* OMAP3: DSI2_PLL_FCLK
167 * OMAP4: PLL1_CLK2 */
168 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC, /* OMAP4: PLL2_CLK1 */
169 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI, /* OMAP4: PLL2_CLK2 */
170};
171
172enum omap_hdmi_flags {
173 OMAP_HDMI_SDA_SCL_EXTERNAL_PULLUP = 1 << 0,
174};
175
176enum omap_dss_output_id {
177 OMAP_DSS_OUTPUT_DPI = 1 << 0,
178 OMAP_DSS_OUTPUT_DBI = 1 << 1,
179 OMAP_DSS_OUTPUT_SDI = 1 << 2,
180 OMAP_DSS_OUTPUT_DSI1 = 1 << 3,
181 OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
182 OMAP_DSS_OUTPUT_VENC = 1 << 5,
183 OMAP_DSS_OUTPUT_HDMI = 1 << 6,
184};
185
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300186/* DSI */
187
188enum omap_dss_dsi_trans_mode {
189 /* Sync Pulses: both sync start and end packets sent */
190 OMAP_DSS_DSI_PULSE_MODE,
191 /* Sync Events: only sync start packets sent */
192 OMAP_DSS_DSI_EVENT_MODE,
193 /* Burst: only sync start packets sent, pixels are time compressed */
194 OMAP_DSS_DSI_BURST_MODE,
195};
196
197struct omap_dss_dsi_videomode_timings {
198 unsigned long hsclk;
199
200 unsigned ndl;
201 unsigned bitspp;
202
203 /* pixels */
204 u16 hact;
205 /* lines */
206 u16 vact;
207
208 /* DSI video mode blanking data */
209 /* Unit: byte clock cycles */
210 u16 hss;
211 u16 hsa;
212 u16 hse;
213 u16 hfp;
214 u16 hbp;
215 /* Unit: line clocks */
216 u16 vsa;
217 u16 vfp;
218 u16 vbp;
219
220 /* DSI blanking modes */
221 int blanking_mode;
222 int hsa_blanking_mode;
223 int hbp_blanking_mode;
224 int hfp_blanking_mode;
225
226 enum omap_dss_dsi_trans_mode trans_mode;
227
228 bool ddr_clk_always_on;
229 int window_sync;
230};
231
232struct omap_dss_dsi_config {
233 enum omap_dss_dsi_mode mode;
234 enum omap_dss_dsi_pixel_format pixel_format;
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300235 const struct videomode *vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300236
237 unsigned long hs_clk_min, hs_clk_max;
238 unsigned long lp_clk_min, lp_clk_max;
239
240 bool ddr_clk_always_on;
241 enum omap_dss_dsi_trans_mode trans_mode;
242};
243
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300244/* Hardcoded videomodes for tv. Venc only uses these to
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300245 * identify the mode, and does not actually use the configs
246 * itself. However, the configs should be something that
247 * a normal monitor can also show */
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300248extern const struct videomode omap_dss_pal_vm;
249extern const struct videomode omap_dss_ntsc_vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300250
251struct omap_dss_cpr_coefs {
252 s16 rr, rg, rb;
253 s16 gr, gg, gb;
254 s16 br, bg, bb;
255};
256
257struct omap_overlay_info {
258 dma_addr_t paddr;
259 dma_addr_t p_uv_addr; /* for NV12 format */
260 u16 screen_width;
261 u16 width;
262 u16 height;
Tomi Valkeinen41aff422017-05-04 11:31:56 +0300263 u32 fourcc;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300264 u8 rotation;
265 enum omap_dss_rotation_type rotation_type;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300266
267 u16 pos_x;
268 u16 pos_y;
269 u16 out_width; /* if 0, out_width == width */
270 u16 out_height; /* if 0, out_height == height */
271 u8 global_alpha;
272 u8 pre_mult_alpha;
273 u8 zorder;
274};
275
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300276struct omap_overlay_manager_info {
277 u32 default_color;
278
279 enum omap_dss_trans_key_type trans_key_type;
280 u32 trans_key;
281 bool trans_enabled;
282
283 bool partial_alpha_enabled;
284
285 bool cpr_enable;
286 struct omap_dss_cpr_coefs cpr_coefs;
287};
288
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300289/* 22 pins means 1 clk lane and 10 data lanes */
290#define OMAP_DSS_MAX_DSI_PINS 22
291
292struct omap_dsi_pin_config {
293 int num_pins;
294 /*
295 * pin numbers in the following order:
296 * clk+, clk-
297 * data1+, data1-
298 * data2+, data2-
299 * ...
300 */
301 int pins[OMAP_DSS_MAX_DSI_PINS];
302};
303
304struct omap_dss_writeback_info {
305 u32 paddr;
306 u32 p_uv_addr;
307 u16 buf_width;
308 u16 width;
309 u16 height;
Tomi Valkeinen41aff422017-05-04 11:31:56 +0300310 u32 fourcc;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300311 u8 rotation;
312 enum omap_dss_rotation_type rotation_type;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300313 u8 pre_mult_alpha;
314};
315
316struct omapdss_dpi_ops {
317 int (*connect)(struct omap_dss_device *dssdev,
318 struct omap_dss_device *dst);
319 void (*disconnect)(struct omap_dss_device *dssdev,
320 struct omap_dss_device *dst);
321
322 int (*enable)(struct omap_dss_device *dssdev);
323 void (*disable)(struct omap_dss_device *dssdev);
324
325 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300326 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300327 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300328 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300329 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300330 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300331};
332
333struct omapdss_sdi_ops {
334 int (*connect)(struct omap_dss_device *dssdev,
335 struct omap_dss_device *dst);
336 void (*disconnect)(struct omap_dss_device *dssdev,
337 struct omap_dss_device *dst);
338
339 int (*enable)(struct omap_dss_device *dssdev);
340 void (*disable)(struct omap_dss_device *dssdev);
341
342 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300343 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300344 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300345 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300346 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300347 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300348};
349
350struct omapdss_dvi_ops {
351 int (*connect)(struct omap_dss_device *dssdev,
352 struct omap_dss_device *dst);
353 void (*disconnect)(struct omap_dss_device *dssdev,
354 struct omap_dss_device *dst);
355
356 int (*enable)(struct omap_dss_device *dssdev);
357 void (*disable)(struct omap_dss_device *dssdev);
358
359 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300360 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300361 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300362 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300363 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300364 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300365};
366
367struct omapdss_atv_ops {
368 int (*connect)(struct omap_dss_device *dssdev,
369 struct omap_dss_device *dst);
370 void (*disconnect)(struct omap_dss_device *dssdev,
371 struct omap_dss_device *dst);
372
373 int (*enable)(struct omap_dss_device *dssdev);
374 void (*disable)(struct omap_dss_device *dssdev);
375
376 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300377 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300378 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300379 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300380 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300381 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300382
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300383 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
384 u32 (*get_wss)(struct omap_dss_device *dssdev);
385};
386
387struct omapdss_hdmi_ops {
388 int (*connect)(struct omap_dss_device *dssdev,
389 struct omap_dss_device *dst);
390 void (*disconnect)(struct omap_dss_device *dssdev,
391 struct omap_dss_device *dst);
392
393 int (*enable)(struct omap_dss_device *dssdev);
394 void (*disable)(struct omap_dss_device *dssdev);
395
396 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300397 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300398 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300399 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300400 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300401 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300402
403 int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
404 bool (*detect)(struct omap_dss_device *dssdev);
405
406 int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
407 int (*set_infoframe)(struct omap_dss_device *dssdev,
408 const struct hdmi_avi_infoframe *avi);
409};
410
411struct omapdss_dsi_ops {
412 int (*connect)(struct omap_dss_device *dssdev,
413 struct omap_dss_device *dst);
414 void (*disconnect)(struct omap_dss_device *dssdev,
415 struct omap_dss_device *dst);
416
417 int (*enable)(struct omap_dss_device *dssdev);
418 void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
419 bool enter_ulps);
420
421 /* bus configuration */
422 int (*set_config)(struct omap_dss_device *dssdev,
423 const struct omap_dss_dsi_config *cfg);
424 int (*configure_pins)(struct omap_dss_device *dssdev,
425 const struct omap_dsi_pin_config *pin_cfg);
426
427 void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
428 bool enable);
429 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
430
431 int (*update)(struct omap_dss_device *dssdev, int channel,
432 void (*callback)(int, void *), void *data);
433
434 void (*bus_lock)(struct omap_dss_device *dssdev);
435 void (*bus_unlock)(struct omap_dss_device *dssdev);
436
437 int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
438 void (*disable_video_output)(struct omap_dss_device *dssdev,
439 int channel);
440
441 int (*request_vc)(struct omap_dss_device *dssdev, int *channel);
442 int (*set_vc_id)(struct omap_dss_device *dssdev, int channel,
443 int vc_id);
444 void (*release_vc)(struct omap_dss_device *dssdev, int channel);
445
446 /* data transfer */
447 int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
448 u8 *data, int len);
449 int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
450 u8 *data, int len);
451 int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
452 u8 *data, int len);
453
454 int (*gen_write)(struct omap_dss_device *dssdev, int channel,
455 u8 *data, int len);
456 int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
457 u8 *data, int len);
458 int (*gen_read)(struct omap_dss_device *dssdev, int channel,
459 u8 *reqdata, int reqlen,
460 u8 *data, int len);
461
462 int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
463
464 int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
465 int channel, u16 plen);
466};
467
468struct omap_dss_device {
469 struct kobject kobj;
470 struct device *dev;
471
472 struct module *owner;
473
474 struct list_head panel_list;
475
476 /* alias in the form of "display%d" */
477 char alias[16];
478
479 enum omap_display_type type;
480 enum omap_display_type output_type;
481
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300482 struct {
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300483 struct videomode vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300484
485 enum omap_dss_dsi_pixel_format dsi_pix_fmt;
486 enum omap_dss_dsi_mode dsi_mode;
487 } panel;
488
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300489 const char *name;
490
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300491 struct omap_dss_driver *driver;
492
493 union {
494 const struct omapdss_dpi_ops *dpi;
495 const struct omapdss_sdi_ops *sdi;
496 const struct omapdss_dvi_ops *dvi;
497 const struct omapdss_hdmi_ops *hdmi;
498 const struct omapdss_atv_ops *atv;
499 const struct omapdss_dsi_ops *dsi;
500 } ops;
501
502 /* helper variable for driver suspend/resume */
503 bool activate_after_resume;
504
505 enum omap_display_caps caps;
506
507 struct omap_dss_device *src;
508
509 enum omap_dss_display_state state;
510
511 /* OMAP DSS output specific fields */
512
513 struct list_head list;
514
515 /* DISPC channel for this output */
516 enum omap_channel dispc_channel;
517 bool dispc_channel_connected;
518
519 /* output instance */
520 enum omap_dss_output_id id;
521
522 /* the port number in the DT node */
523 int port_num;
524
525 /* dynamic fields */
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300526 struct omap_dss_device *dst;
527};
528
529struct omap_dss_driver {
530 int (*probe)(struct omap_dss_device *);
531 void (*remove)(struct omap_dss_device *);
532
533 int (*connect)(struct omap_dss_device *dssdev);
534 void (*disconnect)(struct omap_dss_device *dssdev);
535
536 int (*enable)(struct omap_dss_device *display);
537 void (*disable)(struct omap_dss_device *display);
538 int (*run_test)(struct omap_dss_device *display, int test);
539
540 int (*update)(struct omap_dss_device *dssdev,
541 u16 x, u16 y, u16 w, u16 h);
542 int (*sync)(struct omap_dss_device *dssdev);
543
544 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
545 int (*get_te)(struct omap_dss_device *dssdev);
546
547 u8 (*get_rotate)(struct omap_dss_device *dssdev);
548 int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
549
550 bool (*get_mirror)(struct omap_dss_device *dssdev);
551 int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
552
553 int (*memory_read)(struct omap_dss_device *dssdev,
554 void *buf, size_t size,
555 u16 x, u16 y, u16 w, u16 h);
556
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300557 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300558 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300559 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300560 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300561 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300562 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300563
564 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
565 u32 (*get_wss)(struct omap_dss_device *dssdev);
566
567 int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
568 bool (*detect)(struct omap_dss_device *dssdev);
569
570 int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
571 int (*set_hdmi_infoframe)(struct omap_dss_device *dssdev,
572 const struct hdmi_avi_infoframe *avi);
573};
574
575enum omapdss_version omapdss_get_version(void);
576bool omapdss_is_initialized(void);
577
578int omap_dss_register_driver(struct omap_dss_driver *);
579void omap_dss_unregister_driver(struct omap_dss_driver *);
580
581int omapdss_register_display(struct omap_dss_device *dssdev);
582void omapdss_unregister_display(struct omap_dss_device *dssdev);
583
584struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
585void omap_dss_put_device(struct omap_dss_device *dssdev);
586#define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
587struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
588struct omap_dss_device *omap_dss_find_device(void *data,
589 int (*match)(struct omap_dss_device *dssdev, void *data));
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300590
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300591
592int omap_dss_get_num_overlay_managers(void);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300593
594int omap_dss_get_num_overlays(void);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300595
596int omapdss_register_output(struct omap_dss_device *output);
597void omapdss_unregister_output(struct omap_dss_device *output);
598struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300599struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port);
600int omapdss_output_set_device(struct omap_dss_device *out,
601 struct omap_dss_device *dssdev);
602int omapdss_output_unset_device(struct omap_dss_device *out);
603
604struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300605
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300606void omapdss_default_get_timings(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300607 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300608
609typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
610int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
611int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
612
613int omapdss_compat_init(void);
614void omapdss_compat_uninit(void);
615
616static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
617{
618 return dssdev->src;
619}
620
621static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
622{
623 return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
624}
625
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300626struct omap_dss_device *
627omapdss_of_find_source_for_first_ep(struct device_node *node);
Tomi Valkeinen35a339a2016-02-19 16:54:36 +0200628
Tomi Valkeinen7c299712015-11-05 17:23:14 +0200629void omapdss_set_is_initialized(bool set);
630
Tomi Valkeinen82e83f62015-11-05 17:26:18 +0200631struct device_node *dss_of_port_get_parent_device(struct device_node *port);
632u32 dss_of_port_get_port_number(struct device_node *port);
633
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200634struct dss_mgr_ops {
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200635 int (*connect)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200636 struct omap_dss_device *dst);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200637 void (*disconnect)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200638 struct omap_dss_device *dst);
639
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200640 void (*start_update)(enum omap_channel channel);
641 int (*enable)(enum omap_channel channel);
642 void (*disable)(enum omap_channel channel);
643 void (*set_timings)(enum omap_channel channel,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300644 const struct videomode *vm);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200645 void (*set_lcd_config)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200646 const struct dss_lcd_mgr_config *config);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200647 int (*register_framedone_handler)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200648 void (*handler)(void *), void *data);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200649 void (*unregister_framedone_handler)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200650 void (*handler)(void *), void *data);
651};
652
653int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
654void dss_uninstall_mgr_ops(void);
655
Tomi Valkeinen1b07b062015-11-04 20:21:48 +0200656int dss_mgr_connect(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200657 struct omap_dss_device *dst);
Tomi Valkeinenbdac3bb2015-11-04 20:23:37 +0200658void dss_mgr_disconnect(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200659 struct omap_dss_device *dst);
Tomi Valkeinen5c6ff3c2015-11-04 20:25:05 +0200660void dss_mgr_set_timings(enum omap_channel channel,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300661 const struct videomode *vm);
Tomi Valkeinenbb772e12015-11-04 20:26:15 +0200662void dss_mgr_set_lcd_config(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200663 const struct dss_lcd_mgr_config *config);
Tomi Valkeinen85a8c622015-11-04 20:27:31 +0200664int dss_mgr_enable(enum omap_channel channel);
Tomi Valkeinen705fd452015-11-04 20:28:45 +0200665void dss_mgr_disable(enum omap_channel channel);
Tomi Valkeinen1f03f932015-11-05 09:20:46 +0200666void dss_mgr_start_update(enum omap_channel channel);
Tomi Valkeinenaf235e32015-11-05 09:23:03 +0200667int dss_mgr_register_framedone_handler(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200668 void (*handler)(void *), void *data);
Tomi Valkeinen34218992015-11-05 09:23:47 +0200669void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200670 void (*handler)(void *), void *data);
671
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200672/* dispc ops */
673
674struct dispc_ops {
675 u32 (*read_irqstatus)(void);
676 void (*clear_irqstatus)(u32 mask);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200677 void (*write_irqenable)(u32 mask);
678
679 int (*request_irq)(irq_handler_t handler, void *dev_id);
680 void (*free_irq)(void *dev_id);
681
682 int (*runtime_get)(void);
683 void (*runtime_put)(void);
684
685 int (*get_num_ovls)(void);
686 int (*get_num_mgrs)(void);
687
688 void (*mgr_enable)(enum omap_channel channel, bool enable);
689 bool (*mgr_is_enabled)(enum omap_channel channel);
690 u32 (*mgr_get_vsync_irq)(enum omap_channel channel);
691 u32 (*mgr_get_framedone_irq)(enum omap_channel channel);
692 u32 (*mgr_get_sync_lost_irq)(enum omap_channel channel);
693 bool (*mgr_go_busy)(enum omap_channel channel);
694 void (*mgr_go)(enum omap_channel channel);
695 void (*mgr_set_lcd_config)(enum omap_channel channel,
696 const struct dss_lcd_mgr_config *config);
697 void (*mgr_set_timings)(enum omap_channel channel,
698 const struct videomode *vm);
699 void (*mgr_setup)(enum omap_channel channel,
700 const struct omap_overlay_manager_info *info);
701 enum omap_dss_output_id (*mgr_get_supported_outputs)(enum omap_channel channel);
702 u32 (*mgr_gamma_size)(enum omap_channel channel);
703 void (*mgr_set_gamma)(enum omap_channel channel,
704 const struct drm_color_lut *lut,
705 unsigned int length);
706
Jyri Sarha864050c2017-03-24 16:47:52 +0200707 int (*ovl_enable)(enum omap_plane_id plane, bool enable);
Jyri Sarha864050c2017-03-24 16:47:52 +0200708 int (*ovl_setup)(enum omap_plane_id plane,
709 const struct omap_overlay_info *oi,
Tomi Valkeinen49a30572017-02-17 12:30:07 +0200710 const struct videomode *vm, bool mem_to_mem,
711 enum omap_channel channel);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200712
Tomi Valkeinen9c39d172017-05-04 11:19:12 +0300713 const u32 *(*ovl_get_color_modes)(enum omap_plane_id plane);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200714};
715
716void dispc_set_ops(const struct dispc_ops *o);
717const struct dispc_ops *dispc_get_ops(void);
718
Peter Ujfalusi7c79e8d2016-05-02 14:55:38 +0300719bool omapdss_component_is_display(struct device_node *node);
720bool omapdss_component_is_output(struct device_node *node);
721
Peter Ujfalusi1e08c822016-05-03 22:07:10 +0300722bool omapdss_stack_is_ready(void);
723void omapdss_gather_components(struct device *dev);
724
Tomi Valkeinen35a339a2016-02-19 16:54:36 +0200725#endif /* __OMAP_DRM_DSS_H */