blob: 318641f5bc245f38dc015b2000fbbbea8d4082b5 [file] [log] [blame]
Tomi Valkeinen35a339a2016-02-19 16:54:36 +02001/*
Andrew F. Davisbb5cdf82017-12-05 14:29:31 -06002 * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
Tomi Valkeinen35a339a2016-02-19 16:54:36 +02003 * 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 Ujfalusi3c596802017-06-02 15:26:35 +030028#include <drm/drm_crtc.h>
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030029
30#define DISPC_IRQ_FRAMEDONE (1 << 0)
31#define DISPC_IRQ_VSYNC (1 << 1)
32#define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
33#define DISPC_IRQ_EVSYNC_ODD (1 << 3)
34#define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
35#define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
36#define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
37#define DISPC_IRQ_GFX_END_WIN (1 << 7)
38#define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
39#define DISPC_IRQ_OCP_ERR (1 << 9)
40#define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
41#define DISPC_IRQ_VID1_END_WIN (1 << 11)
42#define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
43#define DISPC_IRQ_VID2_END_WIN (1 << 13)
44#define DISPC_IRQ_SYNC_LOST (1 << 14)
45#define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
46#define DISPC_IRQ_WAKEUP (1 << 16)
47#define DISPC_IRQ_SYNC_LOST2 (1 << 17)
48#define DISPC_IRQ_VSYNC2 (1 << 18)
49#define DISPC_IRQ_VID3_END_WIN (1 << 19)
50#define DISPC_IRQ_VID3_FIFO_UNDERFLOW (1 << 20)
51#define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21)
52#define DISPC_IRQ_FRAMEDONE2 (1 << 22)
53#define DISPC_IRQ_FRAMEDONEWB (1 << 23)
54#define DISPC_IRQ_FRAMEDONETV (1 << 24)
55#define DISPC_IRQ_WBBUFFEROVERFLOW (1 << 25)
56#define DISPC_IRQ_WBUNCOMPLETEERROR (1 << 26)
57#define DISPC_IRQ_SYNC_LOST3 (1 << 27)
58#define DISPC_IRQ_VSYNC3 (1 << 28)
59#define DISPC_IRQ_ACBIAS_COUNT_STAT3 (1 << 29)
60#define DISPC_IRQ_FRAMEDONE3 (1 << 30)
61
Laurent Pinchart64cb8172018-02-13 14:00:39 +020062struct omap_drm_private;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030063struct omap_dss_device;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030064struct dss_lcd_mgr_config;
65struct snd_aes_iec958;
66struct snd_cea_861_aud_if;
67struct hdmi_avi_infoframe;
68
69enum omap_display_type {
70 OMAP_DISPLAY_TYPE_NONE = 0,
71 OMAP_DISPLAY_TYPE_DPI = 1 << 0,
72 OMAP_DISPLAY_TYPE_DBI = 1 << 1,
73 OMAP_DISPLAY_TYPE_SDI = 1 << 2,
74 OMAP_DISPLAY_TYPE_DSI = 1 << 3,
75 OMAP_DISPLAY_TYPE_VENC = 1 << 4,
76 OMAP_DISPLAY_TYPE_HDMI = 1 << 5,
77 OMAP_DISPLAY_TYPE_DVI = 1 << 6,
78};
79
Jyri Sarha864050c2017-03-24 16:47:52 +020080enum omap_plane_id {
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030081 OMAP_DSS_GFX = 0,
82 OMAP_DSS_VIDEO1 = 1,
83 OMAP_DSS_VIDEO2 = 2,
84 OMAP_DSS_VIDEO3 = 3,
85 OMAP_DSS_WB = 4,
86};
87
88enum omap_channel {
89 OMAP_DSS_CHANNEL_LCD = 0,
90 OMAP_DSS_CHANNEL_DIGIT = 1,
91 OMAP_DSS_CHANNEL_LCD2 = 2,
92 OMAP_DSS_CHANNEL_LCD3 = 3,
93 OMAP_DSS_CHANNEL_WB = 4,
94};
95
96enum omap_color_mode {
Tomi Valkeinen3e1d65c2017-05-04 10:40:46 +030097 _UNUSED_,
Peter Ujfalusi26038aa2016-05-30 12:39:02 +030098};
99
100enum omap_dss_load_mode {
101 OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
102 OMAP_DSS_LOAD_CLUT_ONLY = 1,
103 OMAP_DSS_LOAD_FRAME_ONLY = 2,
104 OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
105};
106
107enum omap_dss_trans_key_type {
108 OMAP_DSS_COLOR_KEY_GFX_DST = 0,
109 OMAP_DSS_COLOR_KEY_VID_SRC = 1,
110};
111
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300112enum omap_dss_signal_level {
113 OMAPDSS_SIG_ACTIVE_LOW,
114 OMAPDSS_SIG_ACTIVE_HIGH,
115};
116
117enum omap_dss_signal_edge {
118 OMAPDSS_DRIVE_SIG_FALLING_EDGE,
119 OMAPDSS_DRIVE_SIG_RISING_EDGE,
120};
121
122enum omap_dss_venc_type {
123 OMAP_DSS_VENC_TYPE_COMPOSITE,
124 OMAP_DSS_VENC_TYPE_SVIDEO,
125};
126
127enum omap_dss_dsi_pixel_format {
128 OMAP_DSS_DSI_FMT_RGB888,
129 OMAP_DSS_DSI_FMT_RGB666,
130 OMAP_DSS_DSI_FMT_RGB666_PACKED,
131 OMAP_DSS_DSI_FMT_RGB565,
132};
133
134enum omap_dss_dsi_mode {
135 OMAP_DSS_DSI_CMD_MODE = 0,
136 OMAP_DSS_DSI_VIDEO_MODE,
137};
138
139enum omap_display_caps {
140 OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE = 1 << 0,
141 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM = 1 << 1,
142};
143
144enum omap_dss_display_state {
145 OMAP_DSS_DISPLAY_DISABLED = 0,
146 OMAP_DSS_DISPLAY_ACTIVE,
147};
148
149enum omap_dss_rotation_type {
Tomi Valkeinen517a8a952017-05-03 14:14:27 +0300150 OMAP_DSS_ROT_NONE = 0,
151 OMAP_DSS_ROT_TILER = 1 << 0,
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300152};
153
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300154enum omap_overlay_caps {
155 OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
156 OMAP_DSS_OVL_CAP_GLOBAL_ALPHA = 1 << 1,
157 OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA = 1 << 2,
158 OMAP_DSS_OVL_CAP_ZORDER = 1 << 3,
159 OMAP_DSS_OVL_CAP_POS = 1 << 4,
160 OMAP_DSS_OVL_CAP_REPLICATION = 1 << 5,
161};
162
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300163enum omap_dss_clk_source {
164 OMAP_DSS_CLK_SRC_FCK = 0, /* OMAP2/3: DSS1_ALWON_FCLK
165 * OMAP4: DSS_FCLK */
166 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, /* OMAP3: DSI1_PLL_FCLK
167 * OMAP4: PLL1_CLK1 */
168 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, /* OMAP3: DSI2_PLL_FCLK
169 * OMAP4: PLL1_CLK2 */
170 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC, /* OMAP4: PLL2_CLK1 */
171 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI, /* OMAP4: PLL2_CLK2 */
172};
173
174enum omap_hdmi_flags {
175 OMAP_HDMI_SDA_SCL_EXTERNAL_PULLUP = 1 << 0,
176};
177
178enum omap_dss_output_id {
179 OMAP_DSS_OUTPUT_DPI = 1 << 0,
180 OMAP_DSS_OUTPUT_DBI = 1 << 1,
181 OMAP_DSS_OUTPUT_SDI = 1 << 2,
182 OMAP_DSS_OUTPUT_DSI1 = 1 << 3,
183 OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
184 OMAP_DSS_OUTPUT_VENC = 1 << 5,
185 OMAP_DSS_OUTPUT_HDMI = 1 << 6,
186};
187
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300188/* DSI */
189
190enum omap_dss_dsi_trans_mode {
191 /* Sync Pulses: both sync start and end packets sent */
192 OMAP_DSS_DSI_PULSE_MODE,
193 /* Sync Events: only sync start packets sent */
194 OMAP_DSS_DSI_EVENT_MODE,
195 /* Burst: only sync start packets sent, pixels are time compressed */
196 OMAP_DSS_DSI_BURST_MODE,
197};
198
199struct omap_dss_dsi_videomode_timings {
200 unsigned long hsclk;
201
Laurent Pinchartd11e5c82018-02-11 15:07:34 +0200202 unsigned int ndl;
203 unsigned int bitspp;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300204
205 /* pixels */
206 u16 hact;
207 /* lines */
208 u16 vact;
209
210 /* DSI video mode blanking data */
211 /* Unit: byte clock cycles */
212 u16 hss;
213 u16 hsa;
214 u16 hse;
215 u16 hfp;
216 u16 hbp;
217 /* Unit: line clocks */
218 u16 vsa;
219 u16 vfp;
220 u16 vbp;
221
222 /* DSI blanking modes */
223 int blanking_mode;
224 int hsa_blanking_mode;
225 int hbp_blanking_mode;
226 int hfp_blanking_mode;
227
228 enum omap_dss_dsi_trans_mode trans_mode;
229
230 bool ddr_clk_always_on;
231 int window_sync;
232};
233
234struct omap_dss_dsi_config {
235 enum omap_dss_dsi_mode mode;
236 enum omap_dss_dsi_pixel_format pixel_format;
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300237 const struct videomode *vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300238
239 unsigned long hs_clk_min, hs_clk_max;
240 unsigned long lp_clk_min, lp_clk_max;
241
242 bool ddr_clk_always_on;
243 enum omap_dss_dsi_trans_mode trans_mode;
244};
245
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300246struct omap_dss_cpr_coefs {
247 s16 rr, rg, rb;
248 s16 gr, gg, gb;
249 s16 br, bg, bb;
250};
251
252struct omap_overlay_info {
253 dma_addr_t paddr;
254 dma_addr_t p_uv_addr; /* for NV12 format */
255 u16 screen_width;
256 u16 width;
257 u16 height;
Tomi Valkeinen41aff422017-05-04 11:31:56 +0300258 u32 fourcc;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300259 u8 rotation;
260 enum omap_dss_rotation_type rotation_type;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300261
262 u16 pos_x;
263 u16 pos_y;
264 u16 out_width; /* if 0, out_width == width */
265 u16 out_height; /* if 0, out_height == height */
266 u8 global_alpha;
267 u8 pre_mult_alpha;
268 u8 zorder;
269};
270
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300271struct omap_overlay_manager_info {
272 u32 default_color;
273
274 enum omap_dss_trans_key_type trans_key_type;
275 u32 trans_key;
276 bool trans_enabled;
277
278 bool partial_alpha_enabled;
279
280 bool cpr_enable;
281 struct omap_dss_cpr_coefs cpr_coefs;
282};
283
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300284/* 22 pins means 1 clk lane and 10 data lanes */
285#define OMAP_DSS_MAX_DSI_PINS 22
286
287struct omap_dsi_pin_config {
288 int num_pins;
289 /*
290 * pin numbers in the following order:
291 * clk+, clk-
292 * data1+, data1-
293 * data2+, data2-
294 * ...
295 */
296 int pins[OMAP_DSS_MAX_DSI_PINS];
297};
298
299struct omap_dss_writeback_info {
300 u32 paddr;
301 u32 p_uv_addr;
302 u16 buf_width;
303 u16 width;
304 u16 height;
Tomi Valkeinen41aff422017-05-04 11:31:56 +0300305 u32 fourcc;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300306 u8 rotation;
307 enum omap_dss_rotation_type rotation_type;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300308 u8 pre_mult_alpha;
309};
310
311struct omapdss_dpi_ops {
312 int (*connect)(struct omap_dss_device *dssdev,
313 struct omap_dss_device *dst);
314 void (*disconnect)(struct omap_dss_device *dssdev,
315 struct omap_dss_device *dst);
316
317 int (*enable)(struct omap_dss_device *dssdev);
318 void (*disable)(struct omap_dss_device *dssdev);
319
320 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300321 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300322 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300323 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300324 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300325 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300326};
327
328struct omapdss_sdi_ops {
329 int (*connect)(struct omap_dss_device *dssdev,
330 struct omap_dss_device *dst);
331 void (*disconnect)(struct omap_dss_device *dssdev,
332 struct omap_dss_device *dst);
333
334 int (*enable)(struct omap_dss_device *dssdev);
335 void (*disable)(struct omap_dss_device *dssdev);
336
337 int (*check_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 (*set_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 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300342 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300343};
344
345struct omapdss_dvi_ops {
346 int (*connect)(struct omap_dss_device *dssdev,
347 struct omap_dss_device *dst);
348 void (*disconnect)(struct omap_dss_device *dssdev,
349 struct omap_dss_device *dst);
350
351 int (*enable)(struct omap_dss_device *dssdev);
352 void (*disable)(struct omap_dss_device *dssdev);
353
354 int (*check_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 (*set_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 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300359 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300360};
361
362struct omapdss_atv_ops {
363 int (*connect)(struct omap_dss_device *dssdev,
364 struct omap_dss_device *dst);
365 void (*disconnect)(struct omap_dss_device *dssdev,
366 struct omap_dss_device *dst);
367
368 int (*enable)(struct omap_dss_device *dssdev);
369 void (*disable)(struct omap_dss_device *dssdev);
370
371 int (*check_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 (*set_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 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300376 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300377
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300378 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
379 u32 (*get_wss)(struct omap_dss_device *dssdev);
380};
381
382struct omapdss_hdmi_ops {
383 int (*connect)(struct omap_dss_device *dssdev,
384 struct omap_dss_device *dst);
385 void (*disconnect)(struct omap_dss_device *dssdev,
386 struct omap_dss_device *dst);
387
388 int (*enable)(struct omap_dss_device *dssdev);
389 void (*disable)(struct omap_dss_device *dssdev);
390
391 int (*check_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300392 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300393 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300394 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300395 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300396 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300397
398 int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
Hans Verkuil019114e2017-08-17 15:19:57 +0200399 void (*lost_hotplug)(struct omap_dss_device *dssdev);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300400 bool (*detect)(struct omap_dss_device *dssdev);
401
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300402 int (*register_hpd_cb)(struct omap_dss_device *dssdev,
403 void (*cb)(void *cb_data,
404 enum drm_connector_status status),
405 void *cb_data);
406 void (*unregister_hpd_cb)(struct omap_dss_device *dssdev);
407 void (*enable_hpd)(struct omap_dss_device *dssdev);
408 void (*disable_hpd)(struct omap_dss_device *dssdev);
409
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300410 int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
411 int (*set_infoframe)(struct omap_dss_device *dssdev,
412 const struct hdmi_avi_infoframe *avi);
413};
414
415struct omapdss_dsi_ops {
416 int (*connect)(struct omap_dss_device *dssdev,
417 struct omap_dss_device *dst);
418 void (*disconnect)(struct omap_dss_device *dssdev,
419 struct omap_dss_device *dst);
420
421 int (*enable)(struct omap_dss_device *dssdev);
422 void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
423 bool enter_ulps);
424
425 /* bus configuration */
426 int (*set_config)(struct omap_dss_device *dssdev,
427 const struct omap_dss_dsi_config *cfg);
428 int (*configure_pins)(struct omap_dss_device *dssdev,
429 const struct omap_dsi_pin_config *pin_cfg);
430
431 void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
432 bool enable);
433 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
434
435 int (*update)(struct omap_dss_device *dssdev, int channel,
436 void (*callback)(int, void *), void *data);
437
438 void (*bus_lock)(struct omap_dss_device *dssdev);
439 void (*bus_unlock)(struct omap_dss_device *dssdev);
440
441 int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
442 void (*disable_video_output)(struct omap_dss_device *dssdev,
443 int channel);
444
445 int (*request_vc)(struct omap_dss_device *dssdev, int *channel);
446 int (*set_vc_id)(struct omap_dss_device *dssdev, int channel,
447 int vc_id);
448 void (*release_vc)(struct omap_dss_device *dssdev, int channel);
449
450 /* data transfer */
451 int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
452 u8 *data, int len);
453 int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
454 u8 *data, int len);
455 int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
456 u8 *data, int len);
457
458 int (*gen_write)(struct omap_dss_device *dssdev, int channel,
459 u8 *data, int len);
460 int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
461 u8 *data, int len);
462 int (*gen_read)(struct omap_dss_device *dssdev, int channel,
463 u8 *reqdata, int reqlen,
464 u8 *data, int len);
465
466 int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
467
468 int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
469 int channel, u16 plen);
470};
471
472struct omap_dss_device {
473 struct kobject kobj;
474 struct device *dev;
475
476 struct module *owner;
477
478 struct list_head panel_list;
479
480 /* alias in the form of "display%d" */
481 char alias[16];
482
483 enum omap_display_type type;
484 enum omap_display_type output_type;
485
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300486 struct {
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300487 struct videomode vm;
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300488
489 enum omap_dss_dsi_pixel_format dsi_pix_fmt;
490 enum omap_dss_dsi_mode dsi_mode;
491 } panel;
492
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300493 const char *name;
494
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300495 struct omap_dss_driver *driver;
496
497 union {
498 const struct omapdss_dpi_ops *dpi;
499 const struct omapdss_sdi_ops *sdi;
500 const struct omapdss_dvi_ops *dvi;
501 const struct omapdss_hdmi_ops *hdmi;
502 const struct omapdss_atv_ops *atv;
503 const struct omapdss_dsi_ops *dsi;
504 } ops;
505
506 /* helper variable for driver suspend/resume */
507 bool activate_after_resume;
508
509 enum omap_display_caps caps;
510
511 struct omap_dss_device *src;
512
513 enum omap_dss_display_state state;
514
515 /* OMAP DSS output specific fields */
516
517 struct list_head list;
518
519 /* DISPC channel for this output */
520 enum omap_channel dispc_channel;
521 bool dispc_channel_connected;
522
523 /* output instance */
524 enum omap_dss_output_id id;
525
526 /* the port number in the DT node */
527 int port_num;
528
529 /* dynamic fields */
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300530 struct omap_dss_device *dst;
531};
532
533struct omap_dss_driver {
534 int (*probe)(struct omap_dss_device *);
535 void (*remove)(struct omap_dss_device *);
536
537 int (*connect)(struct omap_dss_device *dssdev);
538 void (*disconnect)(struct omap_dss_device *dssdev);
539
540 int (*enable)(struct omap_dss_device *display);
541 void (*disable)(struct omap_dss_device *display);
542 int (*run_test)(struct omap_dss_device *display, int test);
543
544 int (*update)(struct omap_dss_device *dssdev,
545 u16 x, u16 y, u16 w, u16 h);
546 int (*sync)(struct omap_dss_device *dssdev);
547
548 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
549 int (*get_te)(struct omap_dss_device *dssdev);
550
551 u8 (*get_rotate)(struct omap_dss_device *dssdev);
552 int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
553
554 bool (*get_mirror)(struct omap_dss_device *dssdev);
555 int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
556
557 int (*memory_read)(struct omap_dss_device *dssdev,
558 void *buf, size_t size,
559 u16 x, u16 y, u16 w, u16 h);
560
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300561 int (*check_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 void (*set_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300564 struct videomode *vm);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300565 void (*get_timings)(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300566 struct videomode *vm);
Sebastian Reichelb070d6e2017-07-24 19:33:04 +0200567 void (*get_size)(struct omap_dss_device *dssdev,
568 unsigned int *width, unsigned int *height);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300569
570 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
571 u32 (*get_wss)(struct omap_dss_device *dssdev);
572
573 int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
574 bool (*detect)(struct omap_dss_device *dssdev);
575
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300576 int (*register_hpd_cb)(struct omap_dss_device *dssdev,
577 void (*cb)(void *cb_data,
578 enum drm_connector_status status),
579 void *cb_data);
580 void (*unregister_hpd_cb)(struct omap_dss_device *dssdev);
581 void (*enable_hpd)(struct omap_dss_device *dssdev);
582 void (*disable_hpd)(struct omap_dss_device *dssdev);
583
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300584 int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
585 int (*set_hdmi_infoframe)(struct omap_dss_device *dssdev,
586 const struct hdmi_avi_infoframe *avi);
587};
588
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300589bool omapdss_is_initialized(void);
590
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300591int 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);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300598
599int omap_dss_get_num_overlay_managers(void);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300600
601int omap_dss_get_num_overlays(void);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300602
603int omapdss_register_output(struct omap_dss_device *output);
604void omapdss_unregister_output(struct omap_dss_device *output);
605struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300606struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port);
607int omapdss_output_set_device(struct omap_dss_device *out,
608 struct omap_dss_device *dssdev);
609int omapdss_output_unset_device(struct omap_dss_device *out);
610
611struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev);
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300612
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300613typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
614int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
615int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
616
617int omapdss_compat_init(void);
618void omapdss_compat_uninit(void);
619
620static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
621{
622 return dssdev->src;
623}
624
625static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
626{
627 return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
628}
629
Peter Ujfalusi26038aa2016-05-30 12:39:02 +0300630struct omap_dss_device *
631omapdss_of_find_source_for_first_ep(struct device_node *node);
Tomi Valkeinen35a339a2016-02-19 16:54:36 +0200632
Tomi Valkeinen7c299712015-11-05 17:23:14 +0200633void omapdss_set_is_initialized(bool set);
634
Tomi Valkeinen82e83f62015-11-05 17:26:18 +0200635struct device_node *dss_of_port_get_parent_device(struct device_node *port);
636u32 dss_of_port_get_port_number(struct device_node *port);
637
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200638struct dss_mgr_ops {
Laurent Pinchart64cb8172018-02-13 14:00:39 +0200639 int (*connect)(struct omap_drm_private *priv,
640 enum omap_channel channel,
641 struct omap_dss_device *dst);
642 void (*disconnect)(struct omap_drm_private *priv,
643 enum omap_channel channel,
644 struct omap_dss_device *dst);
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200645
Laurent Pinchart64cb8172018-02-13 14:00:39 +0200646 void (*start_update)(struct omap_drm_private *priv,
647 enum omap_channel channel);
648 int (*enable)(struct omap_drm_private *priv,
649 enum omap_channel channel);
650 void (*disable)(struct omap_drm_private *priv,
651 enum omap_channel channel);
652 void (*set_timings)(struct omap_drm_private *priv,
653 enum omap_channel channel,
654 const struct videomode *vm);
655 void (*set_lcd_config)(struct omap_drm_private *priv,
656 enum omap_channel channel,
657 const struct dss_lcd_mgr_config *config);
658 int (*register_framedone_handler)(struct omap_drm_private *priv,
659 enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200660 void (*handler)(void *), void *data);
Laurent Pinchart64cb8172018-02-13 14:00:39 +0200661 void (*unregister_framedone_handler)(struct omap_drm_private *priv,
662 enum omap_channel channel,
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200663 void (*handler)(void *), void *data);
664};
665
Laurent Pinchart64cb8172018-02-13 14:00:39 +0200666int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops,
667 struct omap_drm_private *priv);
Tomi Valkeinen564c7c72016-02-19 17:19:41 +0200668void dss_uninstall_mgr_ops(void);
669
Laurent Pinchart28d79f32018-02-13 14:00:38 +0200670int dss_mgr_connect(struct omap_dss_device *dssdev,
671 struct omap_dss_device *dst);
672void dss_mgr_disconnect(struct omap_dss_device *dssdev,
673 struct omap_dss_device *dst);
674void dss_mgr_set_timings(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300675 const struct videomode *vm);
Laurent Pinchart28d79f32018-02-13 14:00:38 +0200676void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200677 const struct dss_lcd_mgr_config *config);
Laurent Pinchart28d79f32018-02-13 14:00:38 +0200678int dss_mgr_enable(struct omap_dss_device *dssdev);
679void dss_mgr_disable(struct omap_dss_device *dssdev);
680void dss_mgr_start_update(struct omap_dss_device *dssdev);
681int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200682 void (*handler)(void *), void *data);
Laurent Pinchart28d79f32018-02-13 14:00:38 +0200683void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
Tomi Valkeinencaaecd92016-02-19 17:37:09 +0200684 void (*handler)(void *), void *data);
685
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200686/* dispc ops */
687
688struct dispc_ops {
689 u32 (*read_irqstatus)(void);
690 void (*clear_irqstatus)(u32 mask);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200691 void (*write_irqenable)(u32 mask);
692
693 int (*request_irq)(irq_handler_t handler, void *dev_id);
694 void (*free_irq)(void *dev_id);
695
696 int (*runtime_get)(void);
697 void (*runtime_put)(void);
698
699 int (*get_num_ovls)(void);
700 int (*get_num_mgrs)(void);
701
Peter Ujfalusi867d7e02017-11-30 14:12:36 +0200702 u32 (*get_memory_bandwidth_limit)(void);
703
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200704 void (*mgr_enable)(enum omap_channel channel, bool enable);
705 bool (*mgr_is_enabled)(enum omap_channel channel);
706 u32 (*mgr_get_vsync_irq)(enum omap_channel channel);
707 u32 (*mgr_get_framedone_irq)(enum omap_channel channel);
708 u32 (*mgr_get_sync_lost_irq)(enum omap_channel channel);
709 bool (*mgr_go_busy)(enum omap_channel channel);
710 void (*mgr_go)(enum omap_channel channel);
711 void (*mgr_set_lcd_config)(enum omap_channel channel,
712 const struct dss_lcd_mgr_config *config);
713 void (*mgr_set_timings)(enum omap_channel channel,
714 const struct videomode *vm);
715 void (*mgr_setup)(enum omap_channel channel,
716 const struct omap_overlay_manager_info *info);
717 enum omap_dss_output_id (*mgr_get_supported_outputs)(enum omap_channel channel);
718 u32 (*mgr_gamma_size)(enum omap_channel channel);
719 void (*mgr_set_gamma)(enum omap_channel channel,
720 const struct drm_color_lut *lut,
721 unsigned int length);
722
Jyri Sarha864050c2017-03-24 16:47:52 +0200723 int (*ovl_enable)(enum omap_plane_id plane, bool enable);
Jyri Sarha864050c2017-03-24 16:47:52 +0200724 int (*ovl_setup)(enum omap_plane_id plane,
725 const struct omap_overlay_info *oi,
Tomi Valkeinen49a30572017-02-17 12:30:07 +0200726 const struct videomode *vm, bool mem_to_mem,
727 enum omap_channel channel);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200728
Tomi Valkeinen9c39d172017-05-04 11:19:12 +0300729 const u32 *(*ovl_get_color_modes)(enum omap_plane_id plane);
Tomi Valkeinen8a133982015-11-05 19:36:02 +0200730};
731
732void dispc_set_ops(const struct dispc_ops *o);
733const struct dispc_ops *dispc_get_ops(void);
734
Peter Ujfalusi7c79e8d2016-05-02 14:55:38 +0300735bool omapdss_component_is_display(struct device_node *node);
736bool omapdss_component_is_output(struct device_node *node);
737
Peter Ujfalusi1e08c822016-05-03 22:07:10 +0300738bool omapdss_stack_is_ready(void);
739void omapdss_gather_components(struct device *dev);
740
Tomi Valkeinen35a339a2016-02-19 16:54:36 +0200741#endif /* __OMAP_DRM_DSS_H */