Skip to contentSkip to conversation

drm/msm: convert to drm_bridge

PATCH New Rob Clark 1 participant 1 message Aug 30, 2013

Subsystems (2)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/msm: convert to drm_bridge

Drop the msm_connector base class, and special calls to base class methods from the encoder, and use instead drm_bridge. This allows for a cleaner division between the hdmi (and in future dsi) blocks, from the mdp block.

---
 drivers/gpu/drm/msm/Makefile                |   2 +-
 drivers/gpu/drm/msm/hdmi/hdmi.c             |  49 +++++++-
 drivers/gpu/drm/msm/hdmi/hdmi.h             |  31 +++++-
 drivers/gpu/drm/msm/hdmi/hdmi_bridge.c      | 167 ++++++++++++++++++++++++++++
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c   | 156 ++++++--------------------
 drivers/gpu/drm/msm/mdp4/mdp4_dtv_encoder.c |  12 --
 drivers/gpu/drm/msm/mdp4/mdp4_kms.c         |   9 +-
 drivers/gpu/drm/msm/msm_connector.c         |  34 ------
 drivers/gpu/drm/msm/msm_connector.h         |  68 -----------
 drivers/gpu/drm/msm/msm_drv.h               |   6 +-
 10 files changed, 274 insertions(+), 260 deletions(-)
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
 delete mode 100644 drivers/gpu/drm/msm/msm_connector.c
 delete mode 100644 drivers/gpu/drm/msm/msm_connector.h
drivers/gpu/drm/msm/Makefile +1 -1
index 439dfb5..e179148 100644
@@ -7,6 +7,7 @@ msm-y := \
 	adreno/adreno_gpu.o \
 	adreno/a3xx_gpu.o \
 	hdmi/hdmi.o \
+	hdmi/hdmi_bridge.o \
 	hdmi/hdmi_connector.o \
 	hdmi/hdmi_i2c.o \
 	hdmi/hdmi_phy_8960.o \
@@ -17,7 +18,6 @@ msm-y := \
 	mdp4/mdp4_irq.o \
 	mdp4/mdp4_kms.o \
 	mdp4/mdp4_plane.o \
-	msm_connector.o \
 	msm_drv.o \
 	msm_fb.o \
 	msm_gem.o \
drivers/gpu/drm/msm/hdmi/hdmi.c +43 -6

88 lines not on this page · raw message

drivers/gpu/drm/msm/hdmi/hdmi.h +25 -6
index 34703fe..2c2ec56 100644
@@ -30,6 +30,8 @@
 struct hdmi_phy;
 
 struct hdmi {
+	struct kref refcount;
+
 	struct drm_device *dev;
 	struct platform_device *pdev;
 
@@ -45,6 +47,10 @@ struct hdmi {
 	struct hdmi_phy *phy;
 	struct i2c_adapter *i2c;
 	struct drm_connector *connector;
+	struct drm_bridge *bridge;
+
+	/* the encoder we are hooked to (outside of hdmi block) */
+	struct drm_encoder *encoder;
 
 	bool hdmi_mode;               /* are we in hdmi mode? */
 
@@ -58,9 +64,7 @@ struct hdmi_platform_config {
 };
 
 void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
-void hdmi_destroy(struct hdmi *hdmi);
-int hdmi_init(struct hdmi *hdmi, struct drm_device *dev,
-		struct drm_connector *connector);
+void hdmi_destroy(struct kref *kref);
 
 static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data)
 {
@@ -72,6 +76,17 @@ static inline u32 hdmi_read(struct hdmi *hdmi, u32 reg)
 	return msm_readl(hdmi->mmio + reg);
 }
 
+static inline struct hdmi * hdmi_reference(struct hdmi *hdmi)
+{
+	kref_get(&hdmi->refcount);
+	return hdmi;
+}
+
+static inline void hdmi_unreference(struct hdmi *hdmi)
+{
+	kref_put(&hdmi->refcount, hdmi_destroy);
+}
+
 /*
  * The phy appears to be different, for example between 8960 and 8x60,
  * so split the phy related functions out and load the correct one at
@@ -89,17 +104,21 @@ struct hdmi_phy {
 	const struct hdmi_phy_funcs *funcs;
 };
 
-/*
- * phy can be different on different generations:
- */
 struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi);
 struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi);
 
 /*
+ * hdmi bridge:
+ */
+
+struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi);
+
+/*
  * hdmi connector:
  */
 
 void hdmi_connector_irq(struct drm_connector *connector);
+struct drm_connector *hdmi_connector_init(struct hdmi *hdmi);
 
 /*
  * i2c adapter for ddc:
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c new file +167 -0

167 lines not on this page · raw message

drivers/gpu/drm/msm/hdmi/hdmi_connector.c +31 -125

252 lines not on this page · raw message

drivers/gpu/drm/msm/mdp4/mdp4_dtv_encoder.c +0 -12
index 06d49e3..5e0dcae 100644
@@ -18,7 +18,6 @@
 #include <mach/clk.h>
 
 #include "mdp4_kms.h"
-#include "msm_connector.h"
 
 #include "drm_crtc.h"
 #include "drm_crtc_helper.h"
@@ -101,7 +100,6 @@ static void mdp4_dtv_encoder_dpms(struct drm_encoder *encoder, int mode)
 {
 	struct drm_device *dev = encoder->dev;
 	struct mdp4_dtv_encoder *mdp4_dtv_encoder = to_mdp4_dtv_encoder(encoder);
-	struct msm_connector *msm_connector = get_connector(encoder);
 	struct mdp4_kms *mdp4_kms = get_kms(encoder);
 	bool enabled = (mode == DRM_MODE_DPMS_ON);
 
@@ -116,9 +114,6 @@ static void mdp4_dtv_encoder_dpms(struct drm_encoder *encoder, int mode)
 
 		bs_set(mdp4_dtv_encoder, 1);
 
-		if (msm_connector)
-			msm_connector->funcs->dpms(msm_connector, mode);
-
 		DBG("setting src_clk=%lu", pc);
 
 		ret = clk_set_rate(mdp4_dtv_encoder->src_clk, pc);
@@ -150,9 +145,6 @@ static void mdp4_dtv_encoder_dpms(struct drm_encoder *encoder, int mode)
 		clk_disable_unprepare(mdp4_dtv_encoder->hdmi_clk);
 		clk_disable_unprepare(mdp4_dtv_encoder->mdp_clk);
 
-		if (msm_connector)
-			msm_connector->funcs->dpms(msm_connector, mode);
-
 		bs_set(mdp4_dtv_encoder, 0);
 	}
 
@@ -171,7 +163,6 @@ static void mdp4_dtv_encoder_mode_set(struct drm_encoder *encoder,
 		struct drm_display_mode *adjusted_mode)
 {
 	struct mdp4_dtv_encoder *mdp4_dtv_encoder = to_mdp4_dtv_encoder(encoder);
-	struct msm_connector *msm_connector = get_connector(encoder);
 	struct mdp4_kms *mdp4_kms = get_kms(encoder);
 	uint32_t dtv_hsync_skew, vsync_period, vsync_len, ctrl_pol;
 	uint32_t display_v_start, display_v_end;
@@ -230,9 +221,6 @@ static void mdp4_dtv_encoder_mode_set(struct drm_encoder *encoder,
 			MDP4_DTV_ACTIVE_HCTL_END(0));
 	mdp4_write(mdp4_kms, REG_MDP4_DTV_ACTIVE_VSTART, 0);
 	mdp4_write(mdp4_kms, REG_MDP4_DTV_ACTIVE_VEND, 0);
-
-	if (msm_connector)
-		msm_connector->funcs->mode_set(msm_connector, mode);
 }
 
 static void mdp4_dtv_encoder_prepare(struct drm_encoder *encoder)
drivers/gpu/drm/msm/mdp4/mdp4_kms.c +3 -6
index 960cd89..5db5bba 100644
@@ -191,7 +191,6 @@ static int modeset_init(struct mdp4_kms *mdp4_kms)
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
 	struct drm_encoder *encoder;
-	struct drm_connector *connector;
 	int ret;
 
 	/*
@@ -224,13 +223,11 @@ static int modeset_init(struct mdp4_kms *mdp4_kms)
 	encoder->possible_crtcs = 0x1;     /* DTV can be hooked to DMA_E */
 	priv->encoders[priv->num_encoders++] = encoder;
 
-	connector = hdmi_connector_init(dev, encoder);
-	if (IS_ERR(connector)) {
-		dev_err(dev->dev, "failed to construct HDMI connector\n");
-		ret = PTR_ERR(connector);
+	ret = hdmi_init(dev, encoder);
+	if (ret) {
+		dev_err(dev->dev, "failed to initialize HDMI\n");
 		goto fail;
 	}
-	priv->connectors[priv->num_connectors++] = connector;
 
 	return 0;
 
drivers/gpu/drm/msm/msm_connector.c deleted +0 -34
deleted file mode 100644
index aeea887..0000000
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2013 Red Hat
- * Author: Rob Clark <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "msm_drv.h"
-#include "msm_connector.h"
-
-void msm_connector_init(struct msm_connector *connector,
-		const struct msm_connector_funcs *funcs,
-		struct drm_encoder *encoder)
-{
-	connector->funcs = funcs;
-	connector->encoder = encoder;
-}
-
-struct drm_encoder *msm_connector_attached_encoder(
-		struct drm_connector *connector)
-{
-	struct msm_connector *msm_connector = to_msm_connector(connector);
-	return msm_connector->encoder;
-}
drivers/gpu/drm/msm/msm_connector.h deleted +0 -68

68 lines not on this page · raw message

drivers/gpu/drm/msm/msm_drv.h +4 -2
index 34c36b2..80d7509 100644
@@ -83,6 +83,9 @@ struct msm_drm_private {
 	unsigned int num_encoders;
 	struct drm_encoder *encoders[8];
 
+	unsigned int num_bridges;
+	struct drm_bridge *bridges[8];
+
 	unsigned int num_connectors;
 	struct drm_connector *connectors[8];
 };
@@ -170,8 +173,7 @@ struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
 
 struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev);
 
-struct drm_connector *hdmi_connector_init(struct drm_device *dev,
-		struct drm_encoder *encoder);
+int hdmi_init(struct drm_device *dev, struct drm_encoder *encoder);
 void __init hdmi_register(void);
 void __exit hdmi_unregister(void);
 
Signature · 1 line
1.8.3.1