blob: b63471d1409774e33f710ca64accc7710d09c001 [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),
30};
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010031
32/*
33 * A single signal can be specified via a range of minimal and maximal values
34 * with a typical value, that lies somewhere inbetween.
35 */
36struct timing_entry {
37 u32 min;
38 u32 typ;
39 u32 max;
40};
41
42enum timing_entry_index {
43 TE_MIN = 0,
44 TE_TYP = 1,
45 TE_MAX = 2,
46};
47
48/*
49 * Single "mode" entry. This describes one set of signal timings a display can
50 * have in one setting. This struct can later be converted to struct videomode
51 * (see include/video/videomode.h). As each timing_entry can be defined as a
52 * range, one struct display_timing may become multiple struct videomodes.
53 *
54 * Example: hsync active high, vsync active low
55 *
56 * Active Video
57 * Video ______________________XXXXXXXXXXXXXXXXXXXXXX_____________________
58 * |<- sync ->|<- back ->|<----- active ----->|<- front ->|<- sync..
59 * | | porch | | porch |
60 *
61 * HSync _|¯¯¯¯¯¯¯¯¯¯|___________________________________________|¯¯¯¯¯¯¯¯¯
62 *
63 * VSync ¯|__________|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|_________
64 */
65struct display_timing {
66 struct timing_entry pixelclock;
67
68 struct timing_entry hactive; /* hor. active video */
69 struct timing_entry hfront_porch; /* hor. front porch */
70 struct timing_entry hback_porch; /* hor. back porch */
71 struct timing_entry hsync_len; /* hor. sync len */
72
73 struct timing_entry vactive; /* ver. active video */
74 struct timing_entry vfront_porch; /* ver. front porch */
75 struct timing_entry vback_porch; /* ver. back porch */
76 struct timing_entry vsync_len; /* ver. sync len */
77
Tomi Valkeinen32ed6ef2013-03-12 10:31:29 +020078 enum display_flags flags; /* display flags */
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010079};
80
81/*
82 * This describes all timing settings a display provides.
83 * The native_mode is the default setting for this display.
84 * Drivers that can handle multiple videomodes should work with this struct and
85 * convert each entry to the desired end result.
86 */
87struct display_timings {
88 unsigned int num_timings;
89 unsigned int native_mode;
90
91 struct display_timing **timings;
92};
93
94/* get value specified by index from struct timing_entry */
95static inline u32 display_timing_get_value(const struct timing_entry *te,
96 enum timing_entry_index index)
97{
98 switch (index) {
99 case TE_MIN:
100 return te->min;
101 break;
102 case TE_TYP:
103 return te->typ;
104 break;
105 case TE_MAX:
106 return te->max;
107 break;
108 default:
109 return te->typ;
110 }
111}
112
113/* get one entry from struct display_timings */
114static inline struct display_timing *display_timings_get(const struct
115 display_timings *disp,
116 unsigned int index)
117{
118 if (disp->num_timings > index)
119 return disp->timings[index];
120 else
121 return NULL;
122}
123
124void display_timings_release(struct display_timings *disp);
125
126#endif