summaryrefslogtreecommitdiffstats
path: root/bsp/meta-rcar/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0135-LVDS-ar0233-set-frame-size-1920x1200.patch
blob: 0796810a2283ebecb764b0ab676371a50d21e30d (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
From 6e4407c3dfdcb3694b860d09024020135071343e Mon Sep 17 00:00:00 2001
From: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Date: Sat, 15 Dec 2018 18:32:45 +0300
Subject: [PATCH 084/122] LVDS: ar0233: set frame size 1920x1200

1) Set default frame seze 1920x1200 accordingly to sequencer
2) add crop possibility in imager
---
 drivers/media/i2c/soc_camera/ar0233.c | 21 +++++++++++++++++++++
 drivers/media/i2c/soc_camera/ar0233.h | 21 +++++++++++----------
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/ar0233.c b/drivers/media/i2c/soc_camera/ar0233.c
index 6d034e2..7c1141c 100644
--- a/drivers/media/i2c/soc_camera/ar0233.c
+++ b/drivers/media/i2c/soc_camera/ar0233.c
@@ -71,6 +71,25 @@ static int ar0233_s_stream(struct v4l2_subdev *sd, int enable)
 	return 0;
 }
 
+static int ar0233_set_window(struct v4l2_subdev *sd)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	struct ar0233_priv *priv = to_ar0233(client);
+
+	dev_err(&client->dev, "L=%d T=%d %dx%d\n", priv->rect.left, priv->rect.top, priv->rect.width, priv->rect.height);
+
+	/* horiz crop start */
+	reg16_write16(client, 0x3004, priv->rect.left);
+	/* horiz crop end */
+	reg16_write16(client, 0x3008, priv->rect.left + priv->rect.width - 1);
+	/* vert crop start */
+	reg16_write16(client, 0x3002, priv->rect.top);
+	/* vert crop end */
+	reg16_write16(client, 0x3006, priv->rect.top + priv->rect.height + 1);
+
+	return 0;
+};
+
 static int ar0233_get_fmt(struct v4l2_subdev *sd,
 			 struct v4l2_subdev_pad_config *cfg,
 			 struct v4l2_subdev_format *format)
@@ -160,6 +179,8 @@ static int ar0233_set_selection(struct v4l2_subdev *sd,
 	priv->rect.width = rect->width;
 	priv->rect.height = rect->height;
 
+	ar0233_set_window(sd);
+
 	return 0;
 }
 
diff --git a/drivers/media/i2c/soc_camera/ar0233.h b/drivers/media/i2c/soc_camera/ar0233.h
index f88e5a3..ad65390 100644
--- a/drivers/media/i2c/soc_camera/ar0233.h
+++ b/drivers/media/i2c/soc_camera/ar0233.h
@@ -12,13 +12,13 @@
 //#define AR0233_DISPLAY_PATTERN_FIXED
 //#define AR0233_DISPLAY_PATTERN_COLOR_BAR
 
-#define AR0233_MAX_WIDTH	1792 //1920
-#define AR0233_MAX_HEIGHT	1080
+#define AR0233_MAX_WIDTH	1920
+#define AR0233_MAX_HEIGHT	1200
 
 #define AR0233_DELAY		0xffff
 
 #define AR0233_SENSOR_WIDTH	1920
-#define AR0233_SENSOR_HEIGHT	1280
+#define AR0233_SENSOR_HEIGHT	1200
 
 #define AR0233_X_START		((AR0233_SENSOR_WIDTH - AR0233_MAX_WIDTH) / 2)
 #define AR0233_Y_START		((AR0233_SENSOR_HEIGHT - AR0233_MAX_HEIGHT) / 2)
@@ -311,12 +311,13 @@ static const struct ar0233_reg ar0233_regs_wizard[] = {
 {0x32D6, 0x3C04},
 {0x32DC, 0x370A},
 {0x30B0, 0x0800},
-{0x302A, 0x0006},
-{0x302C, 0x0001},
-{0x302E, 0x0002},
-{0x3030, 0x002C},
-{0x3036, 0x000C},
-{0x3038, 0x0001},
+/* PCLK=22Mhz/2 *44/1/6= 88.6Mhz - TI serializers */
+{0x302A,      6}, // VT_PIX_CLK_DIV
+{0x302C,      1}, // VT_SYS_CLK_DIV
+{0x302E,      2}, // PRE_PLL_CLK_DIV
+{0x3030,     44}, // PLL_MULTIPLIER
+{0x3036, 0x000C}, // OP_WORD_CLK_DIV
+{0x3038, 0x0001}, // OP_SYS_CLK_DIV
 {0x30B0, 0x0A00},
 {0x30A2, 0x0001},
 {0x30A6, 0x0001},
@@ -355,7 +356,7 @@ static const struct ar0233_reg ar0233_regs_wizard[] = {
 {0x300A, AR0233_SENSOR_HEIGHT + 356}, // FRAME_LENGTH_LINES_
 {0x300C, AR0233_SENSOR_WIDTH + 100}, // LINE_LENGTH_PCK_
 #else
-{0x300A, AR0233_SENSOR_HEIGHT + 208}, // FRAME_LENGTH_LINES_
+{0x300A, AR0233_SENSOR_HEIGHT + 288}, // FRAME_LENGTH_LINES_
 {0x300C, AR0233_SENSOR_WIDTH + 300}, // LINE_LENGTH_PCK_
 #endif
 {0x3042, 0x0000},
-- 
2.7.4