blob: 3d289e990aca14f7debf1db1dbf92ab79fc71f47 [file] [log] [blame]
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +01001/*
2 * Copyright 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>
3 *
4 * description of display timings
5 *
6 * This file is released under the GPLv2
7 */
8
9#ifndef __LINUX_DISPLAY_TIMING_H
10#define __LINUX_DISPLAY_TIMING_H
11
12#include <linux/bitops.h>
13#include <linux/types.h>
14
Tomi Valkeinen32ed6ef2013-03-12 10:31:29 +020015enum display_flags {
16 DISPLAY_FLAGS_HSYNC_LOW = BIT(0),
17 DISPLAY_FLAGS_HSYNC_HIGH = BIT(1),
18 DISPLAY_FLAGS_VSYNC_LOW = BIT(2),
19 DISPLAY_FLAGS_VSYNC_HIGH = BIT(3),
20
21 /* data enable flag */
22 DISPLAY_FLAGS_DE_LOW = BIT(4),
23 DISPLAY_FLAGS_DE_HIGH = BIT(5),
24 /* drive data on pos. edge */
25 DISPLAY_FLAGS_PIXDATA_POSEDGE = BIT(6),
26 /* drive data on neg. edge */
27 DISPLAY_FLAGS_PIXDATA_NEGEDGE = BIT(7),
28 DISPLAY_FLAGS_INTERLACED = BIT(8),
29 DISPLAY_FLAGS_DOUBLESCAN = BIT(9),
Steffen Trumtrar267fdd92013-05-27 12:33:33 +000030 DISPLAY_FLAGS_DOUBLECLK = BIT(10),
Peter Ujfalusie886fec2016-09-22 13:35:25 +030031 /* drive sync on pos. edge */
32 DISPLAY_FLAGS_SYNC_POSEDGE = BIT(11),
33 /* drive sync on neg. edge */
34 DISPLAY_FLAGS_SYNC_NEGEDGE = BIT(12),
Tomi Valkeinen32ed6ef2013-03-12 10:31:29 +020035};
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010036
37/*
38 * A single signal can be specified via a range of minimal and maximal values
39 * with a typical value, that lies somewhere inbetween.
40 */
41struct timing_entry {
42 u32 min;
43 u32 typ;
44 u32 max;
45};
46
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010047/*
48 * Single "mode" entry. This describes one set of signal timings a display can
49 * have in one setting. This struct can later be converted to struct videomode
50 * (see include/video/videomode.h). As each timing_entry can be defined as a
51 * range, one struct display_timing may become multiple struct videomodes.
52 *
53 * Example: hsync active high, vsync active low
54 *
55 * Active Video
56 * Video ______________________XXXXXXXXXXXXXXXXXXXXXX_____________________
57 * |<- sync ->|<- back ->|<----- active ----->|<- front ->|<- sync..
58 * | | porch | | porch |
59 *
60 * HSync _|¯¯¯¯¯¯¯¯¯¯|___________________________________________|¯¯¯¯¯¯¯¯¯
61 *
62 * VSync ¯|__________|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|_________
63 */
64struct display_timing {
65 struct timing_entry pixelclock;
66
67 struct timing_entry hactive; /* hor. active video */
68 struct timing_entry hfront_porch; /* hor. front porch */
69 struct timing_entry hback_porch; /* hor. back porch */
70 struct timing_entry hsync_len; /* hor. sync len */
71
72 struct timing_entry vactive; /* ver. active video */
73 struct timing_entry vfront_porch; /* ver. front porch */
74 struct timing_entry vback_porch; /* ver. back porch */
75 struct timing_entry vsync_len; /* ver. sync len */
76
Tomi Valkeinen32ed6ef2013-03-12 10:31:29 +020077 enum display_flags flags; /* display flags */
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010078};
79
80/*
81 * This describes all timing settings a display provides.
82 * The native_mode is the default setting for this display.
83 * Drivers that can handle multiple videomodes should work with this struct and
84 * convert each entry to the desired end result.
85 */
86struct display_timings {
87 unsigned int num_timings;
88 unsigned int native_mode;
89
90 struct display_timing **timings;
91};
92
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010093/* get one entry from struct display_timings */
94static inline struct display_timing *display_timings_get(const struct
95 display_timings *disp,
96 unsigned int index)
97{
98 if (disp->num_timings > index)
99 return disp->timings[index];
100 else
101 return NULL;
102}
103
104void display_timings_release(struct display_timings *disp);
105
106#endif