1 From 67f3fc050ab4e2006d5b7ec6ec341896627181ab Mon Sep 17 00:00:00 2001
2 From: =?utf-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@nokia.com>
3 Date: Mon, 6 Apr 2009 17:32:04 +0200
4 Subject: [PATCH] DSS2: Check fclk limits when configuring video planes
6 Content-Type: text/plain; charset=utf-8
7 Content-Transfer-Encoding: 8bit
9 Check that the currect functional clock is fast enough to support
10 the requested scaling ratios. Also check if 5-tap filtering can be
11 used even though the downscaling ratio is less than 1:2 since the
12 functional clock rate required for 5-tap filtering can be less than
13 the requirement for 3-tap filtering, and 5-tap filtering should look
16 Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com>
18 drivers/video/omap2/dss/dispc.c | 104 ++++++++++++++++++++++++++++++++++++---
19 1 files changed, 97 insertions(+), 7 deletions(-)
21 diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
22 index 41734f3..61861d8 100644
23 --- a/drivers/video/omap2/dss/dispc.c
24 +++ b/drivers/video/omap2/dss/dispc.c
25 @@ -1026,11 +1026,11 @@ static void _dispc_set_vid_accu1(enum omap_plane plane, int haccu, int vaccu)
26 static void _dispc_set_scaling(enum omap_plane plane,
27 u16 orig_width, u16 orig_height,
28 u16 out_width, u16 out_height,
30 + bool ilace, bool five_taps)
34 - int hscaleup, vscaleup, five_taps;
35 + int hscaleup, vscaleup;
39 @@ -1040,7 +1040,6 @@ static void _dispc_set_scaling(enum omap_plane plane,
41 hscaleup = orig_width <= out_width;
42 vscaleup = orig_height <= out_height;
43 - five_taps = orig_height > out_height * 2;
45 _dispc_set_scale_coef(plane, hscaleup, vscaleup, five_taps);
47 @@ -1283,6 +1282,73 @@ static void calc_rotation_offset(u8 rotation, bool mirror,
51 +static unsigned long calc_fclk_five_taps(u16 width, u16 height,
52 + u16 out_width, u16 out_height, enum omap_color_mode color_mode)
55 + /* FIXME venc pclk? */
56 + u64 tmp, pclk = dispc_pclk_rate();
58 + if (height > out_height) {
59 + /* FIXME get real display PPL */
60 + unsigned int ppl = 800;
62 + tmp = pclk * height * out_width;
63 + do_div(tmp, 2 * out_height * ppl);
66 + if (height > 2 * out_height) {
67 + tmp = pclk * (height - 2 * out_height) * out_width;
68 + do_div(tmp, 2 * out_height * (ppl - out_width));
69 + fclk = max(fclk, (u32) tmp);
73 + if (width > out_width) {
75 + do_div(tmp, out_width);
76 + fclk = max(fclk, (u32) tmp);
78 + if (color_mode == OMAP_DSS_COLOR_RGB24U)
85 +static unsigned long calc_fclk(u16 width, u16 height,
86 + u16 out_width, u16 out_height,
87 + enum omap_color_mode color_mode, bool five_taps)
89 + unsigned int hf, vf;
92 + return calc_fclk_five_taps(width, height,
93 + out_width, out_height, color_mode);
96 + * FIXME how to determine the 'A' factor
97 + * for the no downscaling case ?
100 + if (width > 3 * out_width)
102 + else if (width > 2 * out_width)
104 + else if (width > out_width)
109 + if (height > out_height)
114 + /* FIXME venc pclk? */
115 + return dispc_pclk_rate() * vf * hf;
118 static int _dispc_setup_plane(enum omap_plane plane,
119 enum omap_channel channel_out,
120 u32 paddr, u16 screen_width,
121 @@ -1294,7 +1360,7 @@ static int _dispc_setup_plane(enum omap_plane plane,
122 u8 rotation, int mirror)
124 const int maxdownscale = cpu_is_omap34xx() ? 4 : 2;
125 - bool five_taps = height > out_height * 2;
126 + bool five_taps = 0;
129 unsigned offset0, offset1;
130 @@ -1323,8 +1389,8 @@ static int _dispc_setup_plane(enum omap_plane plane,
134 - if (width > (2048 >> five_taps))
137 + unsigned long fclk;
139 if (out_width < width / maxdownscale ||
140 out_width > width * 8)
141 @@ -1356,6 +1422,30 @@ static int _dispc_setup_plane(enum omap_plane plane,
146 + /* Must use 5-tap filter? */
147 + five_taps = height > out_height * 2;
149 + /* Try to use 5-tap filter whenever possible. */
150 + if (cpu_is_omap34xx() && !five_taps &&
151 + height > out_height && width <= 1024) {
152 + fclk = calc_fclk_five_taps(width, height,
153 + out_width, out_height, color_mode);
154 + if (fclk <= dispc_fclk_rate())
158 + if (width > (2048 >> five_taps))
161 + fclk = calc_fclk(width, height, out_width, out_height,
162 + color_mode, five_taps);
164 + DSSDBG("required fclk rate = %lu Hz\n", fclk);
165 + DSSDBG("current fclk rate = %lu Hz\n", dispc_fclk_rate());
167 + if (fclk > dispc_fclk_rate())
171 if (ilace && height >= out_height)
172 @@ -1399,7 +1489,7 @@ static int _dispc_setup_plane(enum omap_plane plane,
173 if (plane != OMAP_DSS_GFX) {
174 _dispc_set_scaling(plane, width, height,
175 out_width, out_height,
178 _dispc_set_vid_size(plane, out_width, out_height);
179 _dispc_set_vid_color_conv(plane, cconv);