aboutsummaryrefslogtreecommitdiffstats
path: root/patches.at91/0146-media-at91sam9x5-video-change-scaling-factor-calcula.patch
blob: 7a06df38f9920dd255d004a39df8e16e42eaf439 (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
From 5ce36caa7629ccccf5ae2b7c35c578cc2bfedc3f Mon Sep 17 00:00:00 2001
From: Nicolas Ferre <nicolas.ferre@atmel.com>
Date: Tue, 16 Oct 2012 18:30:47 +0200
Subject: media/at91sam9x5-video: change scaling factor calculation

Useful for future revision of the HEO IP

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 drivers/media/video/at91sam9x5-video.c | 36 ++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/media/video/at91sam9x5-video.c b/drivers/media/video/at91sam9x5-video.c
index 9d7e6c5..1e5a0a7 100644
--- a/drivers/media/video/at91sam9x5-video.c
+++ b/drivers/media/video/at91sam9x5-video.c
@@ -518,6 +518,19 @@ static void at91sam9x5_video_params(unsigned width, unsigned height,
 	*tloffset = e[ro(0)];
 }
 
+static void at91sam9x5_video_setup_scaling_coef(
+		struct at91sam9x5_video_priv *priv,
+		unsigned hwxmem_size, unsigned hwxsize,
+		unsigned hwymem_size, unsigned hwysize,
+		unsigned *xphidef, unsigned *yphidef) {}
+
+static void at91sam9x5_video_setup_scaling_factor(
+		unsigned hwmem_size, unsigned hwsize,
+		unsigned phidef, unsigned *factor)
+{
+	*factor = 1024 * hwmem_size / hwsize;
+}
+
 static void at91sam9x5_video_update_config_real(
 		struct at91sam9x5_video_priv *priv)
 {
@@ -529,6 +542,9 @@ static void at91sam9x5_video_update_config_real(
 
 	unsigned hwxpos, hwypos, hwxsize, hwysize;
 	unsigned hwxmem_size, hwymem_size;
+	unsigned xphidef = 0;
+	unsigned yphidef = 0;
+	unsigned xfactor, yfactor;
 	s32 hwxstride, hwpstride;
 	s32 hwuvxstride, hwuvpstride;
 	s32 rotated_pixwidth, rotated_pixheight;
@@ -600,12 +616,20 @@ static void at91sam9x5_video_update_config_real(
 			valtomask(hwxmem_size - 1, REG_HEOCFG4_XMEMSIZE) |
 			valtomask(hwymem_size - 1, REG_HEOCFG4_YMEMSIZE));
 
-	at91sam9x5_video_write32(priv, REG_HEOCFG13,
-			REG_HEOCFG13_SCALEN |
-			valtomask(1024 * hwxmem_size / hwxsize,
-				REG_HEOCFG13_XFACTOR) |
-			valtomask(1024 * hwymem_size / hwysize,
-				REG_HEOCFG13_YFACTOR));
+	at91sam9x5_video_setup_scaling_coef(priv,
+					    hwxmem_size, hwxsize,
+					    hwymem_size, hwysize,
+					    &xphidef, &yphidef);
+
+	at91sam9x5_video_setup_scaling_factor(hwxmem_size - 1, hwxsize - 1,
+					      xphidef, &xfactor);
+
+	at91sam9x5_video_setup_scaling_factor(hwymem_size - 1, hwysize - 1,
+					      yphidef, &yfactor);
+
+	at91sam9x5_video_write32(priv, REG_HEOCFG13, REG_HEOCFG13_SCALEN
+				| valtomask(xfactor, REG_HEOCFG13_XFACTOR)
+				| valtomask(yfactor, REG_HEOCFG13_YFACTOR));
 
 	at91sam9x5_video_params(pix->width, pix->height, priv->rotation,
 			&hwxstride, &hwpstride, &priv->y_offset);
-- 
1.8.0.197.g5a90748