blob: bbda9357241b7a2bc6ae2c20e087c4ed15370dff [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
152/* clockwise rotation angle */
153enum omap_dss_rotation_angle {
154 OMAP_DSS_ROT_0 = 0,
155 OMAP_DSS_ROT_90 = 1,
156 OMAP_DSS_ROT_180 = 2,
157 OMAP_DSS_ROT_270 = 3,
158};
159
160enum omap_overlay_caps {
161 OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
162 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA = 1 << 1,
163 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA = 1 << 2,
164 OMAP_DSS_OVL_CAP_ZORDER = 1 << 3,
165 OMAP_DSS_OVL_CAP_POS = 1 << 4,
166 OMAP_DSS_OVL_CAP_REPLICATION = 1 << 5,
167};
168
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300169enum omap_dss_clk_source {
170 OMAP_DSS_CLK_SRC_FCK = 0, /* OMAP2/3: DSS1_ALWON_FCLK
171 * OMAP4: DSS_FCLK */
172 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, /* OMAP3: DSI1_PLL_FCLK
173 * OMAP4: PLL1_CLK1 */
174 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, /* OMAP3: DSI2_PLL_FCLK
175 * OMAP4: PLL1_CLK2 */
176 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC, /* OMAP4: PLL2_CLK1 */
177 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI, /* OMAP4: PLL2_CLK2 */
178};
179
180enum omap_hdmi_flags {
181 OMAP_HDMI_SDA_SCL_EXTERNAL_PULLUP = 1 << 0,
182};
183
184enum omap_dss_output_id {
185 OMAP_DSS_OUTPUT_DPI = 1 << 0,
186 OMAP_DSS_OUTPUT_DBI = 1 << 1,
187 OMAP_DSS_OUTPUT_SDI = 1 << 2,
188 OMAP_DSS_OUTPUT_DSI1 = 1 << 3,
189 OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
190 OMAP_DSS_OUTPUT_VENC = 1 << 5,
191 OMAP_DSS_OUTPUT_HDMI = 1 << 6,
192};
193
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300194/* DSI */
195
196enum omap_dss_dsi_trans_mode {
197 /* Sync Pulses: both sync start and end packets sent */
198 OMAP_DSS_DSI_PULSE_MODE,
199 /* Sync Events: only sync start packets sent */
200 OMAP_DSS_DSI_EVENT_MODE,
201 /* Burst: only sync start packets sent, pixels are time compressed */
202 OMAP_DSS_DSI_BURST_MODE,
203};
204
205struct omap_dss_dsi_videomode_timings {
206 unsigned long hsclk;
207
208 unsigned ndl;
209 unsigned bitspp;
210
211 /* pixels */
212 u16 hact;
213 /* lines */
214 u16 vact;
215
216 /* DSI video mode blanking data */
217 /* Unit: byte clock cycles */
218 u16 hss;
219 u16 hsa;
220 u16 hse;
221 u16 hfp;
222 u16 hbp;
223 /* Unit: line clocks */
224 u16 vsa;
225 u16 vfp;
226 u16 vbp;
227
228 /* DSI blanking modes */
229 int blanking_mode;
230 int hsa_blanking_mode;
231 int hbp_blanking_mode;
232 int hfp_blanking_mode;
233
234 enum omap_dss_dsi_trans_mode trans_mode;
235
236 bool ddr_clk_always_on;
237 int window_sync;
238};
239
240struct omap_dss_dsi_config {
241 enum omap_dss_dsi_mode mode;
242 enum omap_dss_dsi_pixel_format pixel_format;
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300243 const struct videomode *vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300244
245 unsigned long hs_clk_min, hs_clk_max;
246 unsigned long lp_clk_min, lp_clk_max;
247
248 bool ddr_clk_always_on;
249 enum omap_dss_dsi_trans_mode trans_mode;
250};
251
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300252/* Hardcoded videomodes for tv. Venc only uses these to
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300253 * identify the mode, and does not actually use the configs
254 * itself. However, the configs should be something that
255 * a normal monitor can also show */
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300256extern const struct videomode omap_dss_pal_vm;
257extern const struct videomode omap_dss_ntsc_vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300258
259struct omap_dss_cpr_coefs {
260 s16 rr, rg, rb;
261 s16 gr, gg, gb;
262 s16 br, bg, bb;
263};
264
265struct omap_overlay_info {
266 dma_addr_t paddr;
267 dma_addr_t p_uv_addr; /* for NV12 format */
268 u16 screen_width;
269 u16 width;
270 u16 height;
Tomi Valkeinen41aff422017-05-04 11:31:56 +0300271 u32 fourcc;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300272 u8 rotation;
273 enum omap_dss_rotation_type rotation_type;
274 bool mirror;
275
276 u16 pos_x;
277 u16 pos_y;
278 u16 out_width; /* if 0, out_width == width */
279 u16 out_height; /* if 0, out_height == height */
280 u8 global_alpha;
281 u8 pre_mult_alpha;
282 u8 zorder;
283};
284
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300285struct omap_overlay_manager_info {
286 u32 default_color;
287
288 enum omap_dss_trans_key_type trans_key_type;
289 u32 trans_key;
290 bool trans_enabled;
291
292 bool partial_alpha_enabled;
293
294 bool cpr_enable;
295 struct omap_dss_cpr_coefs cpr_coefs;
296};
297
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300298/* 22 pins means 1 clk lane and 10 data lanes */
299#define OMAP_DSS_MAX_DSI_PINS 22
300
301struct omap_dsi_pin_config {
302 int num_pins;
303 /*
304 * pin numbers in the following order:
305 * clk+, clk-
306 * data1+, data1-
307 * data2+, data2-
308 * ...
309 */
310 int pins[OMAP_DSS_MAX_DSI_PINS];
311};
312
313struct omap_dss_writeback_info {
314 u32 paddr;
315 u32 p_uv_addr;
316 u16 buf_width;
317 u16 width;
318 u16 height;
Tomi Valkeinen41aff422017-05-04 11:31:56 +0300319 u32 fourcc;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300320 u8 rotation;
321 enum omap_dss_rotation_type rotation_type;
322 bool mirror;
323 u8 pre_mult_alpha;
324};
325
326struct omapdss_dpi_ops {
327 int (*connect)(struct omap_dss_device *dssdev,
328 struct omap_dss_device *dst);
329 void (*disconnect)(struct omap_dss_device *dssdev,
330 struct omap_dss_device *dst);
331
332 int (*enable)(struct omap_dss_device *dssdev);
333 void (*disable)(struct omap_dss_device *dssdev);
334
335 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300336 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300337 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300338 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300339 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300340 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300341};
342
343struct omapdss_sdi_ops {
344 int (*connect)(struct omap_dss_device *dssdev,
345 struct omap_dss_device *dst);
346 void (*disconnect)(struct omap_dss_device *dssdev,
347 struct omap_dss_device *dst);
348
349 int (*enable)(struct omap_dss_device *dssdev);
350 void (*disable)(struct omap_dss_device *dssdev);
351
352 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300353 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300354 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300355 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300356 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300357 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300358};
359
360struct omapdss_dvi_ops {
361 int (*connect)(struct omap_dss_device *dssdev,
362 struct omap_dss_device *dst);
363 void (*disconnect)(struct omap_dss_device *dssdev,
364 struct omap_dss_device *dst);
365
366 int (*enable)(struct omap_dss_device *dssdev);
367 void (*disable)(struct omap_dss_device *dssdev);
368
369 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300370 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300371 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300372 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300373 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300374 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300375};
376
377struct omapdss_atv_ops {
378 int (*connect)(struct omap_dss_device *dssdev,
379 struct omap_dss_device *dst);
380 void (*disconnect)(struct omap_dss_device *dssdev,
381 struct omap_dss_device *dst);
382
383 int (*enable)(struct omap_dss_device *dssdev);
384 void (*disable)(struct omap_dss_device *dssdev);
385
386 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300387 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300388 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300389 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300390 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300391 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300392
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300393 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
394 u32 (*get_wss)(struct omap_dss_device *dssdev);
395};
396
397struct omapdss_hdmi_ops {
398 int (*connect)(struct omap_dss_device *dssdev,
399 struct omap_dss_device *dst);
400 void (*disconnect)(struct omap_dss_device *dssdev,
401 struct omap_dss_device *dst);
402
403 int (*enable)(struct omap_dss_device *dssdev);
404 void (*disable)(struct omap_dss_device *dssdev);
405
406 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300407 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300408 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300409 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300410 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300411 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300412
413 int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
414 bool (*detect)(struct omap_dss_device *dssdev);
415
416 int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
417 int (*set_infoframe)(struct omap_dss_device *dssdev,
418 const struct hdmi_avi_infoframe *avi);
419};
420
421struct omapdss_dsi_ops {
422 int (*connect)(struct omap_dss_device *dssdev,
423 struct omap_dss_device *dst);
424 void (*disconnect)(struct omap_dss_device *dssdev,
425 struct omap_dss_device *dst);
426
427 int (*enable)(struct omap_dss_device *dssdev);
428 void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
429 bool enter_ulps);
430
431 /* bus configuration */
432 int (*set_config)(struct omap_dss_device *dssdev,
433 const struct omap_dss_dsi_config *cfg);
434 int (*configure_pins)(struct omap_dss_device *dssdev,
435 const struct omap_dsi_pin_config *pin_cfg);
436
437 void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
438 bool enable);
439 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
440
441 int (*update)(struct omap_dss_device *dssdev, int channel,
442 void (*callback)(int, void *), void *data);
443
444 void (*bus_lock)(struct omap_dss_device *dssdev);
445 void (*bus_unlock)(struct omap_dss_device *dssdev);
446
447 int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
448 void (*disable_video_output)(struct omap_dss_device *dssdev,
449 int channel);
450
451 int (*request_vc)(struct omap_dss_device *dssdev, int *channel);
452 int (*set_vc_id)(struct omap_dss_device *dssdev, int channel,
453 int vc_id);
454 void (*release_vc)(struct omap_dss_device *dssdev, int channel);
455
456 /* data transfer */
457 int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
458 u8 *data, int len);
459 int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
460 u8 *data, int len);
461 int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
462 u8 *data, int len);
463
464 int (*gen_write)(struct omap_dss_device *dssdev, int channel,
465 u8 *data, int len);
466 int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
467 u8 *data, int len);
468 int (*gen_read)(struct omap_dss_device *dssdev, int channel,
469 u8 *reqdata, int reqlen,
470 u8 *data, int len);
471
472 int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
473
474 int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
475 int channel, u16 plen);
476};
477
478struct omap_dss_device {
479 struct kobject kobj;
480 struct device *dev;
481
482 struct module *owner;
483
484 struct list_head panel_list;
485
486 /* alias in the form of "display%d" */
487 char alias[16];
488
489 enum omap_display_type type;
490 enum omap_display_type output_type;
491
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300492 struct {
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300493 struct videomode vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300494
495 enum omap_dss_dsi_pixel_format dsi_pix_fmt;
496 enum omap_dss_dsi_mode dsi_mode;
497 } panel;
498
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300499 const char *name;
500
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300501 struct omap_dss_driver *driver;
502
503 union {
504 const struct omapdss_dpi_ops *dpi;
505 const struct omapdss_sdi_ops *sdi;
506 const struct omapdss_dvi_ops *dvi;
507 const struct omapdss_hdmi_ops *hdmi;
508 const struct omapdss_atv_ops *atv;
509 const struct omapdss_dsi_ops *dsi;
510 } ops;
511
512 /* helper variable for driver suspend/resume */
513 bool activate_after_resume;
514
515 enum omap_display_caps caps;
516
517 struct omap_dss_device *src;
518
519 enum omap_dss_display_state state;
520
521 /* OMAP DSS output specific fields */
522
523 struct list_head list;
524
525 /* DISPC channel for this output */
526 enum omap_channel dispc_channel;
527 bool dispc_channel_connected;
528
529 /* output instance */
530 enum omap_dss_output_id id;
531
532 /* the port number in the DT node */
533 int port_num;
534
535 /* dynamic fields */
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300536 struct omap_dss_device *dst;
537};
538
539struct omap_dss_driver {
540 int (*probe)(struct omap_dss_device *);
541 void (*remove)(struct omap_dss_device *);
542
543 int (*connect)(struct omap_dss_device *dssdev);
544 void (*disconnect)(struct omap_dss_device *dssdev);
545
546 int (*enable)(struct omap_dss_device *display);
547 void (*disable)(struct omap_dss_device *display);
548 int (*run_test)(struct omap_dss_device *display, int test);
549
550 int (*update)(struct omap_dss_device *dssdev,
551 u16 x, u16 y, u16 w, u16 h);
552 int (*sync)(struct omap_dss_device *dssdev);
553
554 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
555 int (*get_te)(struct omap_dss_device *dssdev);
556
557 u8 (*get_rotate)(struct omap_dss_device *dssdev);
558 int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
559
560 bool (*get_mirror)(struct omap_dss_device *dssdev);
561 int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
562
563 int (*memory_read)(struct omap_dss_device *dssdev,
564 void *buf, size_t size,
565 u16 x, u16 y, u16 w, u16 h);
566
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300567 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300568 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300569 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300570 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300571 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300572 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300573
574 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
575 u32 (*get_wss)(struct omap_dss_device *dssdev);
576
577 int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
578 bool (*detect)(struct omap_dss_device *dssdev);
579
580 int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
581 int (*set_hdmi_infoframe)(struct omap_dss_device *dssdev,
582 const struct hdmi_avi_infoframe *avi);
583};
584
585enum omapdss_version omapdss_get_version(void);
586bool omapdss_is_initialized(void);
587
588int omap_dss_register_driver(struct omap_dss_driver *);
589void omap_dss_unregister_driver(struct omap_dss_driver *);
590
591int omapdss_register_display(struct omap_dss_device *dssdev);
592void omapdss_unregister_display(struct omap_dss_device *dssdev);
593
594struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
595void omap_dss_put_device(struct omap_dss_device *dssdev);
596#define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
597struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
598struct omap_dss_device *omap_dss_find_device(void *data,
599 int (*match)(struct omap_dss_device *dssdev, void *data));
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300600
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300601
602int omap_dss_get_num_overlay_managers(void);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300603
604int omap_dss_get_num_overlays(void);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300605
606int omapdss_register_output(struct omap_dss_device *output);
607void omapdss_unregister_output(struct omap_dss_device *output);
608struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300609struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port);
610int omapdss_output_set_device(struct omap_dss_device *out,
611 struct omap_dss_device *dssdev);
612int omapdss_output_unset_device(struct omap_dss_device *out);
613
614struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300615
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300616void omapdss_default_get_timings(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300617 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300618
619typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
620int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
621int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
622
623int omapdss_compat_init(void);
624void omapdss_compat_uninit(void);
625
626static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
627{
628 return dssdev->src;
629}
630
631static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
632{
633 return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
634}
635
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300636struct omap_dss_device *
637omapdss_of_find_source_for_first_ep(struct device_node *node);
Tomi Valkeinen35a339a2016-02-19 16:54:36 +0200638
Tomi Valkeinen7c299712015-11-05 17:23:14 +0200639void omapdss_set_is_initialized(bool set);
640
Tomi Valkeinen82e83f62015-11-05 17:26:18 +0200641struct device_node *dss_of_port_get_parent_device(struct device_node *port);
642u32 dss_of_port_get_port_number(struct device_node *port);
643
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200644struct dss_mgr_ops {
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200645 int (*connect)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200646 struct omap_dss_device *dst);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200647 void (*disconnect)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200648 struct omap_dss_device *dst);
649
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200650 void (*start_update)(enum omap_channel channel);
651 int (*enable)(enum omap_channel channel);
652 void (*disable)(enum omap_channel channel);
653 void (*set_timings)(enum omap_channel channel,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300654 const struct videomode *vm);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200655 void (*set_lcd_config)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200656 const struct dss_lcd_mgr_config *config);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200657 int (*register_framedone_handler)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200658 void (*handler)(void *), void *data);
Tomi Valkeinene5cbb6e2015-11-04 19:36:26 +0200659 void (*unregister_framedone_handler)(enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200660 void (*handler)(void *), void *data);
661};
662
663int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
664void dss_uninstall_mgr_ops(void);
665
Tomi Valkeinen1b07b062015-11-04 20:21:48 +0200666int dss_mgr_connect(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200667 struct omap_dss_device *dst);
Tomi Valkeinenbdac3bb2015-11-04 20:23:37 +0200668void dss_mgr_disconnect(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200669 struct omap_dss_device *dst);
Tomi Valkeinen5c6ff3c2015-11-04 20:25:05 +0200670void dss_mgr_set_timings(enum omap_channel channel,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300671 const struct videomode *vm);
Tomi Valkeinenbb772e12015-11-04 20:26:15 +0200672void dss_mgr_set_lcd_config(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200673 const struct dss_lcd_mgr_config *config);
Tomi Valkeinen85a8c622015-11-04 20:27:31 +0200674int dss_mgr_enable(enum omap_channel channel);
Tomi Valkeinen705fd452015-11-04 20:28:45 +0200675void dss_mgr_disable(enum omap_channel channel);
Tomi Valkeinen1f03f932015-11-05 09:20:46 +0200676void dss_mgr_start_update(enum omap_channel channel);
Tomi Valkeinenaf235e32015-11-05 09:23:03 +0200677int dss_mgr_register_framedone_handler(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200678 void (*handler)(void *), void *data);
Tomi Valkeinen34218992015-11-05 09:23:47 +0200679void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200680 void (*handler)(void *), void *data);
681
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200682/* dispc ops */
683
684struct dispc_ops {
685 u32 (*read_irqstatus)(void);
686 void (*clear_irqstatus)(u32 mask);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200687 void (*write_irqenable)(u32 mask);
688
689 int (*request_irq)(irq_handler_t handler, void *dev_id);
690 void (*free_irq)(void *dev_id);
691
692 int (*runtime_get)(void);
693 void (*runtime_put)(void);
694
695 int (*get_num_ovls)(void);
696 int (*get_num_mgrs)(void);
697
698 void (*mgr_enable)(enum omap_channel channel, bool enable);
699 bool (*mgr_is_enabled)(enum omap_channel channel);
700 u32 (*mgr_get_vsync_irq)(enum omap_channel channel);
701 u32 (*mgr_get_framedone_irq)(enum omap_channel channel);
702 u32 (*mgr_get_sync_lost_irq)(enum omap_channel channel);
703 bool (*mgr_go_busy)(enum omap_channel channel);
704 void (*mgr_go)(enum omap_channel channel);
705 void (*mgr_set_lcd_config)(enum omap_channel channel,
706 const struct dss_lcd_mgr_config *config);
707 void (*mgr_set_timings)(enum omap_channel channel,
708 const struct videomode *vm);
709 void (*mgr_setup)(enum omap_channel channel,
710 const struct omap_overlay_manager_info *info);
711 enum omap_dss_output_id (*mgr_get_supported_outputs)(enum omap_channel channel);
712 u32 (*mgr_gamma_size)(enum omap_channel channel);
713 void (*mgr_set_gamma)(enum omap_channel channel,
714 const struct drm_color_lut *lut,
715 unsigned int length);
716
Jyri Sarha864050c2017-03-24 16:47:52 +0200717 int (*ovl_enable)(enum omap_plane_id plane, bool enable);
Jyri Sarha864050c2017-03-24 16:47:52 +0200718 int (*ovl_setup)(enum omap_plane_id plane,
719 const struct omap_overlay_info *oi,
Tomi Valkeinen49a30572017-02-17 12:30:07 +0200720 const struct videomode *vm, bool mem_to_mem,
721 enum omap_channel channel);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200722
Tomi Valkeinen9c39d172017-05-04 11:19:12 +0300723 const u32 *(*ovl_get_color_modes)(enum omap_plane_id plane);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200724};
725
726void dispc_set_ops(const struct dispc_ops *o);
727const struct dispc_ops *dispc_get_ops(void);
728
Peter Ujfalusi7c79e8d2016-05-02 14:55:38 +0300729bool omapdss_component_is_display(struct device_node *node);
730bool omapdss_component_is_output(struct device_node *node);
731
Peter Ujfalusi1e08c822016-05-03 22:07:10 +0300732bool omapdss_stack_is_ready(void);
733void omapdss_gather_components(struct device *dev);
734
Tomi Valkeinen35a339a2016-02-19 16:54:36 +0200735#endif /* __OMAP_DRM_DSS_H */