aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-omap-pm/dss2/0099-DSS2-Implement-function-to-verify-lcd-timings.patch
blob: 0ba203f5ee7c68d209b1347830510db1957b788a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From 875cf440d5450f5d91b2ef1ba6f051f93e77b8eb Mon Sep 17 00:00:00 2001
From: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Date: Wed, 3 Jun 2009 10:45:54 +0300
Subject: [PATCH 099/146] DSS2: Implement function to verify lcd timings

---
 drivers/video/omap2/dss/dispc.c |   52 +++++++++++++++++++++++++++------------
 drivers/video/omap2/dss/dpi.c   |   25 +-----------------
 drivers/video/omap2/dss/dss.h   |    1 +
 3 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
index 5ef9a32..762a0f1 100644
--- a/drivers/video/omap2/dss/dispc.c
+++ b/drivers/video/omap2/dss/dispc.c
@@ -2015,34 +2015,49 @@ void dispc_set_parallel_interface_mode(enum omap_parallel_interface_mode mode)
 	enable_clocks(0);
 }
 
+static bool _dispc_lcd_timings_ok(int hsw, int hfp, int hbp,
+		int vsw, int vfp, int vbp)
+{
+	if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) {
+		if (hsw < 1 || hsw > 64 ||
+				hfp < 1 || hfp > 256 ||
+				hbp < 1 || hbp > 256 ||
+				vsw < 1 || vsw > 64 ||
+				vfp < 0 || vfp > 255 ||
+				vbp < 0 || vbp > 255)
+			return false;
+	} else {
+		if (hsw < 1 || hsw > 256 ||
+				hfp < 1 || hfp > 4096 ||
+				hbp < 1 || hbp > 4096 ||
+				vsw < 1 || vsw > 256 ||
+				vfp < 0 || vfp > 4095 ||
+				vbp < 0 || vbp > 4095)
+			return false;
+	}
+
+	return true;
+}
+
+bool dispc_lcd_timings_ok(struct omap_video_timings *timings)
+{
+	return _dispc_lcd_timings_ok(timings->hsw, timings->hfp,
+			timings->hbp, timings->vsw,
+			timings->vfp, timings->vbp);
+}
+
 static void _dispc_set_lcd_timings(int hsw, int hfp, int hbp,
 				   int vsw, int vfp, int vbp)
 {
 	u32 timing_h, timing_v;
 
 	if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) {
-		BUG_ON(hsw < 1 || hsw > 64);
-		BUG_ON(hfp < 1 || hfp > 256);
-		BUG_ON(hbp < 1 || hbp > 256);
-
-		BUG_ON(vsw < 1 || vsw > 64);
-		BUG_ON(vfp < 0 || vfp > 255);
-		BUG_ON(vbp < 0 || vbp > 255);
-
 		timing_h = FLD_VAL(hsw-1, 5, 0) | FLD_VAL(hfp-1, 15, 8) |
 			FLD_VAL(hbp-1, 27, 20);
 
 		timing_v = FLD_VAL(vsw-1, 5, 0) | FLD_VAL(vfp, 15, 8) |
 			FLD_VAL(vbp, 27, 20);
 	} else {
-		BUG_ON(hsw < 1 || hsw > 256);
-		BUG_ON(hfp < 1 || hfp > 4096);
-		BUG_ON(hbp < 1 || hbp > 4096);
-
-		BUG_ON(vsw < 1 || vsw > 256);
-		BUG_ON(vfp < 0 || vfp > 4095);
-		BUG_ON(vbp < 0 || vbp > 4095);
-
 		timing_h = FLD_VAL(hsw-1, 7, 0) | FLD_VAL(hfp-1, 19, 8) |
 			FLD_VAL(hbp-1, 31, 20);
 
@@ -2062,6 +2077,11 @@ void dispc_set_lcd_timings(struct omap_video_timings *timings)
 	unsigned xtot, ytot;
 	unsigned long ht, vt;
 
+	if (!_dispc_lcd_timings_ok(timings->hsw, timings->hfp,
+				timings->hbp, timings->vsw,
+				timings->vfp, timings->vbp))
+		BUG();
+
 	_dispc_set_lcd_timings(timings->hsw, timings->hfp, timings->hbp,
 			timings->vsw, timings->vfp, timings->vbp);
 
diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index f5867cf..d244e54 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -287,29 +287,8 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
 	unsigned long fck;
 	unsigned long pck;
 
-	if (cpu_is_omap24xx() || omap_rev() < OMAP3430_REV_ES3_0) {
-		if (timings->hsw < 1 || timings->hsw > 64 ||
-				timings->hfp < 1 || timings->hfp > 256 ||
-				timings->hbp < 1 || timings->hbp > 256) {
-			return -EINVAL;
-		}
-
-		if (timings->vsw < 1 || timings->vsw > 64 ||
-				timings->vfp > 255 || timings->vbp > 255) {
-			return -EINVAL;
-		}
-	} else {
-		if (timings->hsw < 1 || timings->hsw > 256 ||
-				timings->hfp < 1 || timings->hfp > 4096 ||
-				timings->hbp < 1 || timings->hbp > 4096) {
-			return -EINVAL;
-		}
-
-		if (timings->vsw < 1 || timings->vsw > 64 ||
-				timings->vfp > 4095 || timings->vbp > 4095) {
-			return -EINVAL;
-		}
-	}
+	if (!dispc_lcd_timings_ok(timings))
+		return -EINVAL;
 
 	if (timings->pixel_clock == 0)
 		return -EINVAL;
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 9a3aea1..370c54b 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -308,6 +308,7 @@ void dispc_enable_alpha_blending(enum omap_channel ch, bool enable);
 bool dispc_trans_key_enabled(enum omap_channel ch);
 bool dispc_alpha_blending_enabled(enum omap_channel ch);
 
+bool dispc_lcd_timings_ok(struct omap_video_timings *timings);
 void dispc_set_lcd_timings(struct omap_video_timings *timings);
 unsigned long dispc_fclk_rate(void);
 unsigned long dispc_lclk_rate(void);
-- 
1.6.2.4