All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Paul <seanpaul@chromium.org>
To: dri-devel@lists.freedesktop.org, inki.dae@samsung.com
Cc: marcheu@chromium.org
Subject: [PATCH v4 31/34] drm/exynos: Implement drm_connector directly in dp driver
Date: Thu, 30 Jan 2014 16:19:30 -0500	[thread overview]
Message-ID: <1391116773-28471-32-git-send-email-seanpaul@chromium.org> (raw)
In-Reply-To: <1391116773-28471-1-git-send-email-seanpaul@chromium.org>

This patch implements drm_connector directly in the dp driver, this will
allow us to move away from the exynos_drm_connector layer.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---

Changes in v3:
 - Added to the patchset
Changes in v4: None

 drivers/gpu/drm/exynos/exynos_dp_core.c | 99 ++++++++++++++++++++++++++++++---
 drivers/gpu/drm/exynos/exynos_dp_core.h |  4 ++
 2 files changed, 94 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
index 05ce947..af2c9d2 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -23,10 +23,15 @@
 #include <video/of_videomode.h>
 
 #include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
 
 #include "exynos_drm_drv.h"
 #include "exynos_dp_core.h"
 
+#define ctx_from_connector(c)	container_of(c, struct exynos_dp_device, \
+					connector)
+
 static int exynos_dp_init_dp(struct exynos_dp_device *dp)
 {
 	exynos_dp_reset(dp);
@@ -897,21 +902,98 @@ static void exynos_dp_hotplug(struct work_struct *work)
 		dev_err(dp->dev, "unable to config video\n");
 }
 
-static bool exynos_dp_display_is_connected(struct exynos_drm_display *display)
+static enum drm_connector_status exynos_dp_detect(
+				struct drm_connector *connector, bool force)
 {
-	return true;
+	return connector_status_connected;
 }
 
-static void *exynos_dp_get_panel(struct exynos_drm_display *display)
+static void exynos_dp_connector_destroy(struct drm_connector *connector)
 {
-	struct exynos_dp_device *dp = display->ctx;
+}
+
+static struct drm_connector_funcs exynos_dp_connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.detect = exynos_dp_detect,
+	.destroy = exynos_dp_connector_destroy,
+};
+
+static int exynos_dp_get_modes(struct drm_connector *connector)
+{
+	struct exynos_dp_device *dp = ctx_from_connector(connector);
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_create(connector->dev);
+	if (!mode) {
+		DRM_ERROR("failed to create a new display mode.\n");
+		return 0;
+	}
 
-	return &dp->panel;
+	drm_display_mode_from_videomode(&dp->panel.vm, mode);
+	mode->width_mm = dp->panel.width_mm;
+	mode->height_mm = dp->panel.height_mm;
+	connector->display_info.width_mm = mode->width_mm;
+	connector->display_info.height_mm = mode->height_mm;
+
+	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+	drm_mode_set_name(mode);
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
 }
 
-static int exynos_dp_check_mode(struct exynos_drm_display *display,
+static int exynos_dp_mode_valid(struct drm_connector *connector,
 			struct drm_display_mode *mode)
 {
+	return MODE_OK;
+}
+
+static struct drm_encoder *exynos_dp_best_encoder(
+			struct drm_connector *connector)
+{
+	struct exynos_dp_device *dp = ctx_from_connector(connector);
+
+	return dp->encoder;
+}
+
+static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
+	.get_modes = exynos_dp_get_modes,
+	.mode_valid = exynos_dp_mode_valid,
+	.best_encoder = exynos_dp_best_encoder,
+};
+
+static int exynos_dp_initialize(struct exynos_drm_display *display,
+				struct drm_device *drm_dev)
+{
+	struct exynos_dp_device *dp = display->ctx;
+
+	dp->drm_dev = drm_dev;
+
+	return 0;
+}
+
+static int exynos_dp_create_connector(struct exynos_drm_display *display,
+				struct drm_encoder *encoder)
+{
+	struct exynos_dp_device *dp = display->ctx;
+	struct drm_connector *connector = &dp->connector;
+	int ret;
+
+	dp->encoder = encoder;
+	connector->polled = DRM_CONNECTOR_POLL_HPD;
+
+	ret = drm_connector_init(dp->drm_dev, connector,
+			&exynos_dp_connector_funcs, DRM_MODE_CONNECTOR_eDP);
+	if (ret) {
+		DRM_ERROR("Failed to initialize connector with drm\n");
+		return ret;
+	}
+
+	drm_connector_helper_add(connector, &exynos_dp_connector_helper_funcs);
+	drm_sysfs_connector_add(connector);
+	drm_mode_connector_attach_encoder(connector, encoder);
+
 	return 0;
 }
 
@@ -983,9 +1065,8 @@ static void exynos_dp_dpms(struct exynos_drm_display *display, int mode)
 }
 
 static struct exynos_drm_display_ops exynos_dp_display_ops = {
-	.is_connected = exynos_dp_display_is_connected,
-	.get_panel = exynos_dp_get_panel,
-	.check_mode = exynos_dp_check_mode,
+	.initialize = exynos_dp_initialize,
+	.create_connector = exynos_dp_create_connector,
 	.dpms = exynos_dp_dpms,
 };
 
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.h b/drivers/gpu/drm/exynos/exynos_dp_core.h
index ccaeadc..d6a900d 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.h
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.h
@@ -13,6 +13,7 @@
 #ifndef _EXYNOS_DP_CORE_H
 #define _EXYNOS_DP_CORE_H
 
+#include <drm/drm_crtc.h>
 #include <drm/exynos_drm.h>
 
 #define DP_TIMEOUT_LOOP_COUNT 100
@@ -144,6 +145,9 @@ struct link_train {
 
 struct exynos_dp_device {
 	struct device		*dev;
+	struct drm_device	*drm_dev;
+	struct drm_connector	connector;
+	struct drm_encoder	*encoder;
 	struct clk		*clock;
 	unsigned int		irq;
 	void __iomem		*reg_base;
-- 
1.8.5.1

  parent reply	other threads:[~2014-01-30 21:20 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 21:18 [PATCH v4 00/34] drm/exynos: Refactor parts of the exynos driver Sean Paul
2014-01-30 21:19 ` [PATCH v4 01/34] drm/exynos: Rename hdmi_infoframe to avoid collision Sean Paul
2014-01-30 21:19 ` [PATCH v4 02/34] drm/exynos: Remove useless slab.h include Sean Paul
2014-01-30 21:19 ` [PATCH v4 03/34] drm/exynos: Merge overlay_ops into manager_ops Sean Paul
2014-01-30 21:19 ` [PATCH v4 04/34] drm/exynos: Add an initialize function to manager and display Sean Paul
2014-01-30 21:19 ` [PATCH v4 05/34] drm/exynos: Use manager_op initialize in fimd Sean Paul
2014-01-30 21:19 ` [PATCH v4 06/34] drm/exynos: hdmi: Implement initialize op for hdmi Sean Paul
2014-01-30 21:19 ` [PATCH v4 07/34] drm/exynos: Pass exynos_drm_manager in manager ops instead of dev Sean Paul
2014-01-30 21:19 ` [PATCH v4 08/34] drm/exynos: Remove apply manager callback Sean Paul
2014-01-30 21:19 ` [PATCH v4 09/34] drm/exynos: Remove dpms link between encoder/connector Sean Paul
2014-01-30 21:19 ` [PATCH v4 10/34] drm/exynos: Rename display_op power_on to dpms Sean Paul
2014-01-30 21:19 ` [PATCH v4 11/34] drm/exynos: Don't keep dpms state in encoder Sean Paul
2014-01-30 21:19 ` [PATCH v4 12/34] drm/exynos: Use unsigned long for possible_crtcs Sean Paul
2014-01-30 21:19 ` [PATCH v4 13/34] drm/exynos: Split manager/display/subdrv Sean Paul
2014-01-30 21:19 ` [PATCH v4 14/34] drm/exynos: hdmi: remove the i2c drivers and use devtree Sean Paul
2014-02-08  2:52   ` Tomasz Figa
2014-02-10  7:30     ` Inki Dae
2014-02-11 14:13       ` Tomasz Figa
2014-02-11 23:02     ` Olof Johansson
2014-02-12  0:44       ` Tomasz Figa
2014-02-14 14:13   ` Tomasz Stanislawski
2014-02-19 11:14     ` Inki Dae
2014-04-04 14:04       ` Tomasz Stanislawski
2014-02-19 11:43   ` Inki Dae
2014-01-30 21:19 ` [PATCH v4 15/34] ARM: dts: exynos: Add i2c phandles to hdmi node Sean Paul
2014-01-30 21:19 ` [PATCH v4 16/34] drm/exynos: Remove exynos_drm_hdmi shim Sean Paul
2014-01-30 21:19 ` [PATCH v4 17/34] drm/exynos: Use drm_mode_copy to copy modes Sean Paul
2014-01-30 21:19 ` [PATCH v4 18/34] drm/exynos: Disable unused crtc planes from crtc Sean Paul
2014-01-30 21:19 ` [PATCH v4 19/34] drm/exynos: Add mode_set manager operation Sean Paul
2014-01-30 21:19 ` [PATCH v4 20/34] drm/exynos: Implement mode_fixup " Sean Paul
2014-01-30 21:19 ` [PATCH v4 21/34] drm/exynos: Use mode_set to configure fimd Sean Paul
2014-02-10 10:36   ` Andrzej Hajda
2014-01-30 21:19 ` [PATCH v4 22/34] drm/exynos: Remove unused/useless fimd_context members Sean Paul
2014-01-30 21:19 ` [PATCH v4 23/34] drm/exynos: Move dp driver from video/ to drm/ Sean Paul
2014-01-30 21:19 ` [PATCH v4 24/34] drm/exynos: Move display implementation into dp Sean Paul
2014-01-30 21:19 ` [PATCH v4 25/34] ARM: dts: Move display-timings node from fimd to dp Sean Paul
2014-01-30 21:19 ` [PATCH v4 26/34] drm/exynos: Implement dpms display callback in DP Sean Paul
2014-01-30 21:19 ` [PATCH v4 27/34] drm/exynos: Clean up FIMD power on/off routines Sean Paul
2014-01-30 21:19 ` [PATCH v4 28/34] drm/exynos: Consolidate suspend/resume in drm_drv Sean Paul
2014-01-30 21:19 ` [PATCH v4 29/34] drm/exynos: Add create_connector callback Sean Paul
2014-01-30 21:19 ` [PATCH v4 30/34] drm/exynos: Implement drm_connector in hdmi directly Sean Paul
2014-01-30 21:19 ` Sean Paul [this message]
2014-01-30 21:19 ` [PATCH v4 32/34] drm/exynos: Implement drm_connector directly in vidi driver Sean Paul
2014-01-30 21:38   ` [PATCH v5 " Sean Paul
2014-01-30 21:19 ` [PATCH v4 33/34] drm/exynos: Move lvds bridge discovery into DP driver Sean Paul
2014-01-30 21:19 ` [PATCH v4 34/34] drm/exynos: Remove the exynos_drm_connector shim Sean Paul
2014-02-06 19:54 ` [PATCH v4 00/34] drm/exynos: Refactor parts of the exynos driver Olof Johansson
2014-02-07  4:13   ` Inki Dae
2014-02-08  2:48   ` Tomasz Figa
2014-02-27  4:43     ` Inki Dae
2014-02-27 13:49       ` Tomasz Figa
2014-02-27 17:09         ` Inki Dae
2014-02-28  2:28           ` Inki Dae
2014-03-04 11:03             ` Andrzej Hajda
2014-03-04 13:57               ` Inki Dae
2014-03-06 15:39                 ` Andrzej Hajda
2014-02-07 10:29 ` Tomasz Figa
2014-03-13  7:33 ` Inki Dae
2014-03-13 14:05   ` Tomasz Figa
2014-03-13 15:48     ` Inki Dae
2014-03-13 18:10       ` Tomasz Figa
2014-03-14 11:02         ` Inki Dae

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391116773-28471-32-git-send-email-seanpaul@chromium.org \
    --to=seanpaul@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=marcheu@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.