aboutsummaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen2/recipes-kernel/linux/linux-renesas/0006-Rcar-DU-add-RGB-connector.patch
blob: d1c8da87ad81b1ccaa14439505f42a0323dae48c (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
From 488e93a1d8371c6ce8cfd24d7299973c476a1aef Mon Sep 17 00:00:00 2001
From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Date: Sun, 28 Dec 2014 19:58:58 +0300
Subject: [PATCH] Rcar-DU: add RGB connector


Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
---
 drivers/gpu/drm/rcar-du/Makefile          |    1 +
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c |    9 ++
 drivers/gpu/drm/rcar-du/rcar_du_rgbcon.c  |  142 +++++++++++++++++++++++++++++
 drivers/gpu/drm/rcar-du/rcar_du_rgbcon.h  |   24 +++++
 include/linux/platform_data/rcar-du.h     |    7 ++
 5 files changed, 183 insertions(+)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_rgbcon.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_rgbcon.h

diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index a6909f0..744da0f 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -5,6 +5,7 @@ rcar-du-drm-y := rcar_du_crtc.o \
 		 rcar_du_hdmicon.o \
 		 rcar_du_kms.o \
 		 rcar_du_lvdscon.o \
+		 rcar_du_rgbcon.o \
 		 rcar_du_plane.o \
 		 rcar_du_vgacon.o
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index 0edec97..de0ccc1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -24,6 +24,7 @@
 #include "rcar_du_encoder.h"
 #include "rcar_du_kms.h"
 #include "rcar_du_lvdscon.h"
+#include "rcar_du_rgbcon.h"
 #include "rcar_du_lvdsenc.h"
 #include "rcar_du_vgacon.h"
 #include "rcar_du_hdmicon.h"
@@ -235,6 +236,9 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 	case RCAR_DU_ENCODER_LVDS:
 		encoder_type = DRM_MODE_ENCODER_LVDS;
 		break;
+	case RCAR_DU_ENCODER_RGB:
+		encoder_type = DRM_MODE_ENCODER_NONE;
+		break;
 	case RCAR_DU_ENCODER_HDMI:
 		encoder_type = DRM_MODE_ENCODER_TMDS;
 		break;
@@ -277,6 +281,11 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 	case DRM_MODE_ENCODER_DAC:
 		return rcar_du_vga_connector_init(rcdu, renc);
 
+	case DRM_MODE_ENCODER_NONE:
+		if (type == RCAR_DU_ENCODER_RGB)
+			return rcar_du_rgb_connector_init(rcdu, renc,
+						&data->connector.rgb.panel);
+		/* fallthrough */
 	default:
 		return -EINVAL;
 	}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_rgbcon.c b/drivers/gpu/drm/rcar-du/rcar_du_rgbcon.c
new file mode 100644
index 0000000..9ee845d
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_rgbcon.c
@@ -0,0 +1,142 @@
+/*
+ * rcar_du_rgbcon.c  --  R-Car Display Unit RGB Connector
+ * base on rcar_du_lvdscon.c
+ *
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_encoder_slave.h>
+
+#include "rcar_du_drv.h"
+#include "rcar_du_encoder.h"
+#include "rcar_du_kms.h"
+#include "rcar_du_rgbcon.h"
+
+struct rcar_du_rgb_connector {
+	struct rcar_du_connector connector;
+
+	const struct rcar_du_panel_data *panel;
+};
+
+#define to_rcar_rgb_connector(c) \
+	container_of(c, struct rcar_du_rgb_connector, connector.connector)
+
+static int rcar_du_rgb_connector_get_modes(struct drm_connector *connector)
+{
+	struct rcar_du_rgb_connector *rgbcon =
+		to_rcar_rgb_connector(connector);
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_create(connector->dev);
+	if (mode == NULL)
+		return 0;
+
+	mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
+	mode->clock = rgbcon->panel->mode.clock;
+	mode->hdisplay = rgbcon->panel->mode.hdisplay;
+	mode->hsync_start = rgbcon->panel->mode.hsync_start;
+	mode->hsync_end = rgbcon->panel->mode.hsync_end;
+	mode->htotal = rgbcon->panel->mode.htotal;
+	mode->vdisplay = rgbcon->panel->mode.vdisplay;
+	mode->vsync_start = rgbcon->panel->mode.vsync_start;
+	mode->vsync_end = rgbcon->panel->mode.vsync_end;
+	mode->vtotal = rgbcon->panel->mode.vtotal;
+	mode->flags = rgbcon->panel->mode.flags;
+
+	drm_mode_set_name(mode);
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
+}
+
+static int rcar_du_rgb_connector_mode_valid(struct drm_connector *connector,
+					    struct drm_display_mode *mode)
+{
+	return MODE_OK;
+}
+
+static const struct drm_connector_helper_funcs connector_helper_funcs = {
+	.get_modes = rcar_du_rgb_connector_get_modes,
+	.mode_valid = rcar_du_rgb_connector_mode_valid,
+	.best_encoder = rcar_du_connector_best_encoder,
+};
+
+static void rcar_du_rgb_connector_destroy(struct drm_connector *connector)
+{
+	drm_sysfs_connector_remove(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+rcar_du_rgb_connector_detect(struct drm_connector *connector, bool force)
+{
+	return connector_status_connected;
+}
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = rcar_du_rgb_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = rcar_du_rgb_connector_destroy,
+};
+
+int rcar_du_rgb_connector_init(struct rcar_du_device *rcdu,
+				struct rcar_du_encoder *renc,
+				const struct rcar_du_panel_data *panel)
+{
+	struct rcar_du_rgb_connector *rgbcon;
+	struct drm_connector *connector;
+	int ret;
+
+	if (rcdu->pdata->backlight_on) {
+		ret = rcdu->pdata->backlight_on();
+		if (ret < 0)
+			return ret;
+	}
+
+	rgbcon = devm_kzalloc(rcdu->dev, sizeof(*rgbcon), GFP_KERNEL);
+	if (rgbcon == NULL)
+		return -ENOMEM;
+
+	rgbcon->panel = panel;
+
+	connector = &rgbcon->connector.connector;
+	connector->display_info.width_mm = panel->width_mm;
+	connector->display_info.height_mm = panel->height_mm;
+
+	ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs,
+				 DRM_MODE_CONNECTOR_Component);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_sysfs_connector_add(connector);
+	if (ret < 0)
+		return ret;
+
+#if 0
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value(&connector->base,
+		rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
+#else
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
+	drm_object_property_set_value(&connector->base,
+		rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_ON);
+#endif
+	ret = drm_mode_connector_attach_encoder(connector, renc->encoder);
+	if (ret < 0)
+		return ret;
+
+	connector->encoder = renc->encoder;
+	rgbcon->connector.encoder = renc;
+
+	return 0;
+}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_rgbcon.h b/drivers/gpu/drm/rcar-du/rcar_du_rgbcon.h
new file mode 100644
index 0000000..d4d51be
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_rgbcon.h
@@ -0,0 +1,24 @@
+/*
+ * rcar_du_rgbcon.h  --  R-Car Display Unit RGB Connector
+ * based on rcar_du_lvdscon.h
+ *
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __RCAR_DU_RGBCON_H__
+#define __RCAR_DU_RGBCON_H__
+
+struct rcar_du_device;
+struct rcar_du_encoder;
+struct rcar_du_panel_data;
+
+int rcar_du_rgb_connector_init(struct rcar_du_device *rcdu,
+				struct rcar_du_encoder *renc,
+				const struct rcar_du_panel_data *panel);
+
+#endif /* __RCAR_DU_RGBCON_H__ */
diff --git a/include/linux/platform_data/rcar-du.h b/include/linux/platform_data/rcar-du.h
index 62464de..93c29af 100644
--- a/include/linux/platform_data/rcar-du.h
+++ b/include/linux/platform_data/rcar-du.h
@@ -31,6 +31,7 @@ enum rcar_du_encoder_type {
 	RCAR_DU_ENCODER_NONE,
 	RCAR_DU_ENCODER_VGA,
 	RCAR_DU_ENCODER_LVDS,
+	RCAR_DU_ENCODER_RGB,
 	RCAR_DU_ENCODER_HDMI,
 };
 
@@ -44,6 +45,11 @@ struct rcar_du_connector_lvds_data {
 	struct rcar_du_panel_data panel;
 };
 
+struct rcar_du_connector_rgb_data {
+	struct rcar_du_panel_data panel;
+};
+
+
 struct rcar_du_connector_vga_data {
 	/* TODO: Add DDC information for EDID retrieval */
 };
@@ -68,6 +74,7 @@ struct rcar_du_encoder_data {
 
 	union {
 		struct rcar_du_connector_lvds_data lvds;
+		struct rcar_du_connector_rgb_data rgb;
 		struct rcar_du_connector_vga_data vga;
 		struct rcar_du_connector_hdmi_data hdmi;
 	} connector;
-- 
1.7.10.4