[Openchrome-devel] drm-openchrome: Branch 'drm-next-3.19' - 14 commits - drivers/gpu/drm

Kevin Brace kevinbrace at kemper.freedesktop.org
Mon Oct 23 01:54:31 UTC 2017


 drivers/gpu/drm/openchrome/crtc_hw.h     |    4 
 drivers/gpu/drm/openchrome/via_display.c |   20 -
 drivers/gpu/drm/openchrome/via_display.h |   42 ++--
 drivers/gpu/drm/openchrome/via_drv.c     |   90 +++++++-
 drivers/gpu/drm/openchrome/via_drv.h     |   13 +
 drivers/gpu/drm/openchrome/via_tmds.c    |  320 ++++++++++++++++++++++++++-----
 6 files changed, 398 insertions(+), 91 deletions(-)

New commits:
commit 55d3aa8f6d01ca5fec671459da0c17c9ddb0bea2
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 20:24:04 2017 -0500

    Version bumped to 3.0.50
    
    This version adds initial support for DVI provided by CX700 / VX700
    and VX800 chipsets’ integrated TMDS transmitter. Standby resume was
    tested with the DVI, and it is working.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_drv.h b/drivers/gpu/drm/openchrome/via_drv.h
index 02d79dce8063..028fa163adc4 100644
--- a/drivers/gpu/drm/openchrome/via_drv.h
+++ b/drivers/gpu/drm/openchrome/via_drv.h
@@ -30,11 +30,11 @@
 #define DRIVER_AUTHOR       "OpenChrome Project"
 #define DRIVER_NAME         "openchrome"
 #define DRIVER_DESC         "OpenChrome DRM for VIA Technologies Chrome IGP"
-#define DRIVER_DATE         "20171015"
+#define DRIVER_DATE         "20171022"
 
 #define DRIVER_MAJOR		3
 #define DRIVER_MINOR		0
-#define DRIVER_PATCHLEVEL	49
+#define DRIVER_PATCHLEVEL	50
 
 #include <linux/module.h>
 
commit 24030930d586caf830a186012b5fa5aa8cbfb634
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 20:16:55 2017 -0500

    Add via_tmds_disable
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index ceca57251ff1..dd52d41472f9 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -279,6 +279,20 @@ via_tmds_mode_set(struct drm_encoder *encoder,
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
+static void via_tmds_disable(struct drm_encoder *encoder)
+{
+	struct via_encoder *enc = container_of(encoder,
+					struct via_encoder, base);
+	struct via_device *dev_priv = encoder->dev->dev_private;
+
+	DRM_DEBUG_KMS("Entered %s.", __func__);
+
+	via_tmds_power(dev_priv, false);
+	via_tmds_io_pad_setting(dev_priv, enc->di_port, false);
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
 static const struct drm_encoder_helper_funcs
 			via_tmds_enc_helper_funcs = {
 	.dpms = via_tmds_dpms,
@@ -286,7 +300,7 @@ static const struct drm_encoder_helper_funcs
 	.prepare = via_tmds_prepare,
 	.commit = via_tmds_commit,
 	.mode_set = via_tmds_mode_set,
-	.disable = via_encoder_disable,
+	.disable = via_tmds_disable,
 };
 
 static enum drm_connector_status
commit 2db6a358288725cd1122ecc21b43e0627337e26a
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 19:49:30 2017 -0500

    Add via_tmds_commit
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 53d28d66e002..ceca57251ff1 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -244,6 +244,20 @@ static void via_tmds_prepare(struct drm_encoder *encoder)
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
+static void via_tmds_commit(struct drm_encoder *encoder)
+{
+	struct via_encoder *enc = container_of(encoder,
+					struct via_encoder, base);
+	struct via_device *dev_priv = encoder->dev->dev_private;
+
+	DRM_DEBUG_KMS("Entered %s.", __func__);
+
+	via_tmds_power(dev_priv, true);
+	via_tmds_io_pad_setting(dev_priv, enc->di_port, true);
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
 /*
  * Handle CX700 / VX700 and VX800 integrated TMDS (DVI) mode setting.
  */
@@ -270,8 +284,8 @@ static const struct drm_encoder_helper_funcs
 	.dpms = via_tmds_dpms,
 	.mode_fixup = via_tmds_mode_fixup,
 	.prepare = via_tmds_prepare,
+	.commit = via_tmds_commit,
 	.mode_set = via_tmds_mode_set,
-	.commit = via_encoder_commit,
 	.disable = via_encoder_disable,
 };
 
commit 278de42e67e39fc93b5023befa1b09d7036acdb7
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 18:53:22 2017 -0500

    Add via_tmds_prepare
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 64f5094b1486..53d28d66e002 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -230,6 +230,20 @@ via_tmds_mode_fixup(struct drm_encoder *encoder,
 	return true;
 }
 
+static void via_tmds_prepare(struct drm_encoder *encoder)
+{
+	struct via_encoder *enc = container_of(encoder,
+					struct via_encoder, base);
+	struct via_device *dev_priv = encoder->dev->dev_private;
+
+	DRM_DEBUG_KMS("Entered %s.", __func__);
+
+	via_tmds_power(dev_priv, false);
+	via_tmds_io_pad_setting(dev_priv, enc->di_port, false);
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
 /*
  * Handle CX700 / VX700 and VX800 integrated TMDS (DVI) mode setting.
  */
@@ -251,11 +265,12 @@ via_tmds_mode_set(struct drm_encoder *encoder,
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
-static const struct drm_encoder_helper_funcs via_tmds_enc_helper_funcs = {
+static const struct drm_encoder_helper_funcs
+			via_tmds_enc_helper_funcs = {
 	.dpms = via_tmds_dpms,
 	.mode_fixup = via_tmds_mode_fixup,
+	.prepare = via_tmds_prepare,
 	.mode_set = via_tmds_mode_set,
-	.prepare = via_encoder_prepare,
 	.commit = via_encoder_commit,
 	.disable = via_encoder_disable,
 };
commit 65b404e83b31f2cbb52bec31dbcdc652330a8eec
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 18:44:10 2017 -0500

    Update via_tmds_dpms
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 4812db1531a7..64f5094b1486 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -190,29 +190,31 @@ static const struct drm_encoder_funcs via_tmds_enc_funcs = {
 	.destroy = via_encoder_cleanup,
 };
 
-/* Manage the power state of the DAC */
-static void
-via_tmds_dpms(struct drm_encoder *encoder, int mode)
+static void via_tmds_dpms(struct drm_encoder *encoder, int mode)
 {
+	struct via_encoder *enc = container_of(encoder,
+					struct via_encoder, base);
 	struct via_device *dev_priv = encoder->dev->dev_private;
 
-    DRM_DEBUG("Entered via_tmds_dpms.\n");
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
 	switch (mode) {
-	case DRM_MODE_DPMS_SUSPEND:
+	case DRM_MODE_DPMS_ON:
+		via_tmds_power(dev_priv, true);
+		via_tmds_io_pad_setting(dev_priv, enc->di_port, true);
+		break;
 	case DRM_MODE_DPMS_STANDBY:
+	case DRM_MODE_DPMS_SUSPEND:
 	case DRM_MODE_DPMS_OFF:
 		via_tmds_power(dev_priv, false);
-		break;
-	case DRM_MODE_DPMS_ON:
-		via_tmds_power(dev_priv, true);
+		via_tmds_io_pad_setting(dev_priv, enc->di_port, false);
 		break;
 	default:
-        DRM_ERROR("Bad DPMS mode.");
-	    break;
+		DRM_ERROR("Bad DPMS mode.");
+		break;
 	}
 
-    DRM_DEBUG("Exiting via_tmds_dpms.\n");
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
 /* Pass our mode to the connectors and the CRTC to give them a chance to
commit 5ed3ff240e6e491d3161a37749c939f1aad604c7
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 18:35:04 2017 -0500

    Update via_tmds_init
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_display.c b/drivers/gpu/drm/openchrome/via_display.c
index d2db450569a2..f6293e754b2c 100644
--- a/drivers/gpu/drm/openchrome/via_display.c
+++ b/drivers/gpu/drm/openchrome/via_display.c
@@ -521,22 +521,13 @@ via_modeset_init(struct drm_device *dev)
 	via_fp_probe(dev);
 
 
+	via_tmds_init(dev);
+
 	via_analog_init(dev);
 
 	via_lvds_init(dev);
 
 	switch (dev->pdev->device) {
-    /* Only CX700 / VX700 and VX800 have an integrated TMDS (DVI) 
-     * transmitter. */
-	case PCI_DEVICE_ID_VIA_VT3157:
-	case PCI_DEVICE_ID_VIA_VT1122:
-		via_tmds_init(dev);
-		break;
-    default:
-        break;
-    }
-
-	switch (dev->pdev->device) {
 	case PCI_DEVICE_ID_VIA_VX900_VGA:
 		via_hdmi_init(dev, VIA_DI_PORT_NONE);
 		break;
diff --git a/drivers/gpu/drm/openchrome/via_display.h b/drivers/gpu/drm/openchrome/via_display.h
index d0b076c05eae..642907a83a36 100644
--- a/drivers/gpu/drm/openchrome/via_display.h
+++ b/drivers/gpu/drm/openchrome/via_display.h
@@ -188,6 +188,6 @@ extern void via_fp_probe(struct drm_device *dev);
 extern void via_hdmi_init(struct drm_device *dev, u32 di_port);
 extern void via_analog_init(struct drm_device *dev);
 extern void via_lvds_init(struct drm_device *dev);
-extern int via_tmds_init(struct drm_device *dev);
+extern void via_tmds_init(struct drm_device *dev);
 
 #endif
diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 5f5fe2368a6e..4812db1531a7 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -373,34 +373,41 @@ void via_tmds_probe(struct drm_device *dev)
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
-int
-via_tmds_init(struct drm_device *dev)
+void via_tmds_init(struct drm_device *dev)
 {
 	struct via_device *dev_priv = dev->dev_private;
 	struct via_connector *con;
 	struct via_encoder *enc;
 	int i2c_port = 0x31;
 
-	if (!(vga_rseq(VGABASE, 0x3E) & BIT(5))) {
-		DRM_INFO("Internal DVI not detected\n");
-		return 1;
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+	if (!dev_priv->int_tmds_presence) {
+		goto exit;
 	}
 
 	enc = kzalloc(sizeof(*enc) + 2 * sizeof(*con), GFP_KERNEL);
 	if (!enc) {
-		DRM_ERROR("Failed to allocate connector and encoder\n");
-		return -ENOMEM;
+		DRM_ERROR("Failed to allocate connector "
+				"and encoder.\n");
+		goto exit;
 	}
 
 	/* Setup the encoders and attach them */
-	drm_encoder_init(dev, &enc->base, &via_tmds_enc_funcs, DRM_MODE_ENCODER_DAC);
+	drm_encoder_init(dev, &enc->base, &via_tmds_enc_funcs,
+				DRM_MODE_ENCODER_TMDS);
 	drm_encoder_helper_add(&enc->base, &via_tmds_enc_helper_funcs);
 
 	enc->base.possible_crtcs = BIT(1) | BIT(0);
 	enc->base.possible_clones = 0;
-	enc->di_port = VIA_DI_PORT_DFPL;
 
-	/* Piece together our DVI-D connector */
+	enc->di_port = dev_priv->int_tmds_di_port;
+
+	/* Increment the number of DVI connectors. */
+	dev_priv->number_dvi++;
+
+
+	/* Piece together our DVI-D connector. */
 	con = &enc->cons[0];
 	drm_connector_init(dev, &con->base, &via_dvi_connector_funcs,
 				DRM_MODE_CONNECTOR_DVID);
@@ -414,17 +421,19 @@ via_tmds_init(struct drm_device *dev)
 
 	drm_mode_connector_attach_encoder(&con->base, &enc->base);
 
-	/* Now handle the DVI-A case */
+	/* Now handle the DVI-A case. */
 	con = &enc->cons[1];
 	drm_connector_init(dev, &con->base, &via_dvi_connector_funcs,
 				DRM_MODE_CONNECTOR_DVIA);
 	drm_connector_helper_add(&con->base, &via_dvi_connector_helper_funcs);
 	drm_connector_register(&con->base);
+
 	con->ddc_bus = via_find_ddc_bus(i2c_port);
 	con->base.doublescan_allowed = false;
 	con->base.interlace_allowed = true;
 	INIT_LIST_HEAD(&con->props);
 
 	drm_mode_connector_attach_encoder(&con->base, &enc->base);
-	return 0;
+exit:
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
commit 7fe1ef2d987fa71e1856938b714cb2a85752d849
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 17:57:58 2017 -0500

    Update via_tmds_mode_set
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 307fac2d5955..5f5fe2368a6e 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -237,14 +237,16 @@ via_tmds_mode_set(struct drm_encoder *encoder,
 			struct drm_display_mode *adjusted_mode)
 {
 	struct via_device *dev_priv = encoder->dev->dev_private;
-	struct via_crtc *iga = container_of(encoder->crtc, struct via_crtc, base);
+	struct via_crtc *iga = container_of(encoder->crtc,
+						struct via_crtc, base);
 
-	DRM_DEBUG_KMS("Entered via_tmds_mode_set.\n");
+	DRM_DEBUG_KMS("Entered %s.", __func__);
 
+	via_tmds_init_reg(dev_priv);
 	via_tmds_sync_polarity(dev_priv, adjusted_mode->flags);
 	via_tmds_display_source(dev_priv, iga->index);
 
-	DRM_DEBUG_KMS("Exiting via_tmds_mode_set.\n");
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
 static const struct drm_encoder_helper_funcs via_tmds_enc_helper_funcs = {
commit a80daabdba3729012afd9e04ace7aedd8a4f9014
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 17:54:31 2017 -0500

    Add via_tmds_init_reg
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 2854f6204ce3..307fac2d5955 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -69,6 +69,77 @@ static void via_tmds_io_pad_setting(struct via_device *dev_priv,
 }
 
 /*
+ * Initializes most registers related to VIA Technologies IGP
+ * integrated TMDS transmitter. Synchronization polarity and
+ * display output source need to be set separately.
+ */
+static void via_tmds_init_reg(struct via_device *dev_priv)
+{
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+	/* Turn off hardware controlled FP power on / off circuit. */
+	via_fp_set_primary_hard_power(VGABASE, false);
+
+	/* Use software FP power sequence control. */
+	via_fp_set_primary_power_seq_type(VGABASE, false);
+
+	/* Turn off software controlled primary FP power rails. */
+	via_fp_set_primary_soft_vdd(VGABASE, false);
+	via_fp_set_primary_soft_vee(VGABASE, false);
+
+	/* Turn off software controlled primary FP back light
+	* control. */
+	via_fp_set_primary_soft_back_light(VGABASE, false);
+
+	/* Turn off direct control of FP back light. */
+	via_fp_set_primary_direct_back_light_ctrl(VGABASE, false);
+
+	/* Activate DVI + LVDS2 mode. */
+	/* 3X5.D2[5:4] - Display Channel Select
+	 *               00: LVDS1 + LVDS2
+	 *               01: DVI + LVDS2
+	 *               10: One Dual LVDS Channel (High Resolution Pannel)
+	 *               11: Single Channel DVI */
+	svga_wcrt_mask(VGABASE, 0xd2, 0x10, 0x30);
+
+	/* Various DVI PLL settings should be set to default settings. */
+	/* 3X5.D1[7]   - PLL2 Reference Clock Edge Select Bit
+	 *               0: PLLCK lock to rising edge of reference clock
+	 *               1: PLLCK lock to falling edge of reference clock
+	 * 3X5.D1[6:5] - PLL2 Charge Pump Current Set Bits
+	 *               00: ICH = 12.5 uA
+	 *               01: ICH = 25.0 uA
+	 *               10: ICH = 37.5 uA
+	 *               11: ICH = 50.0 uA
+	 * 3X5.D1[4:1] - Reserved
+	 * 3X5.D1[0]   - PLL2 Control Voltage Measurement Enable Bit */
+	svga_wcrt_mask(VGABASE, 0xd1, 0x00, 0xe1);
+
+	/* Disable DVI test mode. */
+	/* 3X5.D5[7] - PD1 Enable Selection
+	 *             1: Select by power flag
+	 *             0: By register
+	 * 3X5.D5[5] - DVI Testing Mode Enable
+	 * 3X5.D5[4] - DVI Testing Format Selection
+	 *             0: Half cycle
+	 *             1: LFSR mode */
+	svga_wcrt_mask(VGABASE, 0xd5, 0x00, 0xb0);
+
+	/* Disable DVI sense interrupt. */
+	/* 3C5.2B[7] - DVI Sense Interrupt Enable
+	 *             0: Disable
+	 *             1: Enable */
+	svga_wseq_mask(VGABASE, 0x2b, 0x00, 0x80);
+
+	/* Clear DVI sense interrupt status. */
+	/* 3C5.2B[6] - DVI Sense Interrupt Status
+	 *             (This bit has a RW1C attribute.) */
+	svga_wseq_mask(VGABASE, 0x2b, 0x40, 0x40);
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
+/*
  * Set TMDS (DVI) sync polarity.
  */
 static void
commit 837e7648f7db1ebf78cb660f84ca0d790ab8a236
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 17:50:21 2017 -0500

    Add via_tmds_io_pad_setting
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 34b84b2f5cec..2854f6204ce3 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -49,6 +49,25 @@ static void via_tmds_power(struct via_device *dev_priv,
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
+static void via_tmds_io_pad_setting(struct via_device *dev_priv,
+					u32 di_port, bool io_pad_on)
+{
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+	switch(di_port) {
+	case VIA_DI_PORT_TMDS:
+		via_lvds1_set_io_pad_setting(VGABASE,
+				io_pad_on ? 0x03 : 0x00);
+		break;
+	default:
+		break;
+	}
+
+	DRM_DEBUG_KMS("DVI I/O Pad: %s\n", io_pad_on ? "On": "Off");
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
 /*
  * Set TMDS (DVI) sync polarity.
  */
commit 669f7ce5b20f375047730de5c09eab53c4ba1ce9
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 16:47:34 2017 -0500

    Replace viaTMDSPower with via_tmds_power
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 82e5bae1c9eb..34b84b2f5cec 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -28,32 +28,25 @@
 
 #include "via_drv.h"
 
-static void
-viaTMDSPower(struct via_device *dev_priv,
-                bool powerState)
+static void via_tmds_power(struct via_device *dev_priv,
+				bool power_state)
 {
-    DRM_DEBUG("Entered viaTMDSPower.\n");
-
-    if (powerState) {
-        /* Software control for LVDS1 power sequence. */
-        via_lvds1_set_power_seq(VGABASE, true);
-
-        via_lvds1_set_soft_display_period(VGABASE, true);
-        via_lvds1_set_soft_data(VGABASE, true);
-        via_tmds_set_power(VGABASE, true);
-    } else {
-        /* Software control for LVDS1 power sequence. */
-        via_lvds1_set_power_seq(VGABASE, true);
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
-        via_tmds_set_power(VGABASE, false);
-        via_lvds1_set_soft_data(VGABASE, false);
-        via_lvds1_set_soft_display_period(VGABASE, false);
-    }
+	if (power_state) {
+		via_lvds1_set_soft_display_period(VGABASE, true);
+		via_lvds1_set_soft_data(VGABASE, true);
+		via_tmds_set_power(VGABASE, true);
+	} else {
+		via_tmds_set_power(VGABASE, false);
+		via_lvds1_set_soft_data(VGABASE, false);
+		via_lvds1_set_soft_display_period(VGABASE, false);
+	}
 
-    DRM_INFO("Integrated TMDS (DVI) Power: %s\n",
-                powerState ? "On" : "Off");
+	DRM_INFO("DVI Power: %s\n",
+			power_state ? "On" : "Off");
 
-    DRM_DEBUG("Exiting viaTMDSPower.\n");
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
 /*
@@ -119,10 +112,10 @@ via_tmds_dpms(struct drm_encoder *encoder, int mode)
 	case DRM_MODE_DPMS_SUSPEND:
 	case DRM_MODE_DPMS_STANDBY:
 	case DRM_MODE_DPMS_OFF:
-        viaTMDSPower(dev_priv, false);
+		via_tmds_power(dev_priv, false);
 		break;
 	case DRM_MODE_DPMS_ON:
-        viaTMDSPower(dev_priv, true);
+		via_tmds_power(dev_priv, true);
 		break;
 	default:
         DRM_ERROR("Bad DPMS mode.");
commit 5c3bc4d958e07a55ba9007183ae81d6117e71f2c
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 16:31:24 2017 -0500

    Add via_tmds_probe
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_display.c b/drivers/gpu/drm/openchrome/via_display.c
index 74655a12d268..d2db450569a2 100644
--- a/drivers/gpu/drm/openchrome/via_display.c
+++ b/drivers/gpu/drm/openchrome/via_display.c
@@ -504,6 +504,10 @@ via_modeset_init(struct drm_device *dev)
 	dev->mode_config.max_width = 2044;
 	dev->mode_config.max_height = 4096;
 
+	/* Initialize the number of display connectors. */
+	dev_priv->number_fp = 0;
+	dev_priv->number_dvi = 0;
+
 	via_display_init(dev);
 	via_i2c_reg_init(dev_priv);
 	via_i2c_init(dev);
@@ -512,8 +516,7 @@ via_modeset_init(struct drm_device *dev)
 	for (i = 0; i < 2; i++)
 		via_crtc_init(dev, i);
 
-	/* Initialize the number of FP connectors. */
-	dev_priv->number_fp = 0;
+	via_tmds_probe(dev);
 
 	via_fp_probe(dev);
 
diff --git a/drivers/gpu/drm/openchrome/via_display.h b/drivers/gpu/drm/openchrome/via_display.h
index 33ffbff4a489..d0b076c05eae 100644
--- a/drivers/gpu/drm/openchrome/via_display.h
+++ b/drivers/gpu/drm/openchrome/via_display.h
@@ -53,6 +53,31 @@
 /* Is IGA Hor and Ver scaling up/down status */
 #define	HOR_VER_SCALE	(BIT(0) | BIT(1))
 
+#define	VIA_I2C_NONE	0x0
+#define	VIA_I2C_BUS1	BIT(0)
+#define	VIA_I2C_BUS2	BIT(1)
+#define	VIA_I2C_BUS3	BIT(2)
+#define	VIA_I2C_BUS4	BIT(3)
+#define	VIA_I2C_BUS5	BIT(4)
+
+#define VIA_DI_PORT_NONE	0x0
+#define VIA_DI_PORT_DIP0	BIT(0)
+#define VIA_DI_PORT_DIP1	BIT(1)
+#define VIA_DI_PORT_DVP0	BIT(2)
+#define VIA_DI_PORT_DVP1	BIT(3)
+#define VIA_DI_PORT_DFPL	BIT(4)
+#define VIA_DI_PORT_FPDPLOW	BIT(4)
+#define VIA_DI_PORT_DFPH	BIT(5)
+#define VIA_DI_PORT_FPDPHIGH	BIT(5)
+#define VIA_DI_PORT_DFP		BIT(6)
+#define VIA_DI_PORT_LVDS1	BIT(7)
+#define VIA_DI_PORT_TMDS	BIT(7)
+#define VIA_DI_PORT_LVDS2	BIT(8)
+
+/* External TMDS (DVI) Transmitter Type */
+#define	VIA_TMDS_NONE	0x0
+#define	VIA_TMDS_VT1632	BIT(0)
+
 struct via_crtc {
 	struct drm_crtc base;
 	struct ttm_bo_kmap_obj cursor_kmap;
@@ -79,19 +104,6 @@ struct via_connector {
 	uint32_t flags;
 };
 
-#define VIA_DI_PORT_NONE		0x00
-#define VIA_DI_PORT_DIP0		BIT(0)
-#define VIA_DI_PORT_DIP1		BIT(1)
-#define VIA_DI_PORT_DVP0		BIT(2)
-#define VIA_DI_PORT_DVP1		BIT(3)
-#define VIA_DI_PORT_DFPL		BIT(4)
-#define VIA_DI_PORT_FPDPLOW		BIT(4)
-#define VIA_DI_PORT_DFPH		BIT(5)
-#define VIA_DI_PORT_FPDPHIGH		BIT(5)
-#define VIA_DI_PORT_DFP			BIT(6)
-#define VIA_DI_PORT_LVDS1		BIT(7)
-#define VIA_DI_PORT_LVDS2		BIT(8)
-
 struct via_encoder {
 	struct drm_encoder base;
 	uint32_t flags;
@@ -170,7 +182,7 @@ extern int via_connector_mode_valid(struct drm_connector *connector,
 extern void via_connector_destroy(struct drm_connector *connector);
 extern int via_get_edid_modes(struct drm_connector *connector);
 
-/* FP */
+extern void via_tmds_probe(struct drm_device *dev);
 extern void via_fp_probe(struct drm_device *dev);
 
 extern void via_hdmi_init(struct drm_device *dev, u32 di_port);
diff --git a/drivers/gpu/drm/openchrome/via_drv.h b/drivers/gpu/drm/openchrome/via_drv.h
index c1950ef1cca5..02d79dce8063 100644
--- a/drivers/gpu/drm/openchrome/via_drv.h
+++ b/drivers/gpu/drm/openchrome/via_drv.h
@@ -209,14 +209,23 @@ struct via_device {
 	 * is needed for properly controlling its FP. */
 	bool is_quanta_il1;
 
+	bool int_tmds_presence;
+	u32 int_tmds_di_port;
+	u32 int_tmds_i2c_bus;
+
 	bool int_fp1_presence;
 	u32 int_fp1_di_port;
 
 	bool int_fp2_presence;
 	u32 int_fp2_di_port;
 
+	/* Keeping track of the number of DVI connectors. */
+	u32 number_dvi;
+
 	/* Keeping track of the number of FP (Flat Panel) connectors. */
 	u32 number_fp;
+
+	u32 mapped_i2c_bus;
 };
 
 #define VIA_MEM_NONE		0x00
diff --git a/drivers/gpu/drm/openchrome/via_tmds.c b/drivers/gpu/drm/openchrome/via_tmds.c
index 7fbf9275e766..82e5bae1c9eb 100644
--- a/drivers/gpu/drm/openchrome/via_tmds.c
+++ b/drivers/gpu/drm/openchrome/via_tmds.c
@@ -209,6 +209,85 @@ static const struct drm_connector_helper_funcs via_dvi_connector_helper_funcs =
 	.best_encoder = via_best_encoder,
 };
 
+/*
+ * Probe (pre-initialization detection) of integrated TMDS transmitters.
+ */
+void via_tmds_probe(struct drm_device *dev)
+{
+	struct via_device *dev_priv = dev->dev_private;
+	u16 chipset = dev->pdev->device;
+	u8 sr13, sr5a;
+
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+	/* Detect the presence of integrated TMDS transmitter. */
+	switch (chipset) {
+	case PCI_DEVICE_ID_VIA_VT3157:
+	case PCI_DEVICE_ID_VIA_VT1122:
+		sr5a = vga_rseq(VGABASE, 0x5a);
+
+		/* Setting SR5A[0] to 1.
+		 * This allows the reading out the alternative
+		 * pin strapping information from SR12 and SR13. */
+		svga_wseq_mask(VGABASE, 0x5a, BIT(0), BIT(0));
+
+		sr13 = vga_rseq(VGABASE, 0x13);
+		DRM_DEBUG_KMS("sr13: 0x%02x\n", sr13);
+
+		vga_wseq(VGABASE, 0x5a, sr5a);
+
+		/* 3C5.13[7:6] - Integrated LVDS / DVI Mode Select
+		 *               (DVP1D15-14 pin strapping)
+		 *               00: LVDS1 + LVDS2
+		 *               01: DVI + LVDS2
+		 *               10: Dual LVDS Channel (High Resolution Panel)
+		 *               11: One DVI only (decrease the clock jitter) */
+		/* Check for DVI presence using pin strappings.
+		 * VIA Technologies NanoBook reference design based products
+		 * have their pin strappings set to a wrong setting to communicate
+		 * the presence of DVI, so it requires special handling here. */
+		if (dev_priv->is_via_nanobook) {
+			dev_priv->int_tmds_presence = true;
+			dev_priv->int_tmds_di_port = VIA_DI_PORT_TMDS;
+			dev_priv->int_tmds_i2c_bus = VIA_I2C_BUS2;
+			dev_priv->mapped_i2c_bus |= VIA_I2C_BUS2;
+			DRM_DEBUG_KMS("Integrated TMDS (DVI) "
+					"transmitter detected.\n");
+		} else if (((!(sr13 & BIT(7))) && (sr13 & BIT(6))) ||
+				((sr13 & BIT(7)) && (sr13 & BIT(6)))) {
+			dev_priv->int_tmds_presence = true;
+			dev_priv->int_tmds_di_port = VIA_DI_PORT_TMDS;
+			dev_priv->int_tmds_i2c_bus = VIA_I2C_BUS2;
+			dev_priv->mapped_i2c_bus |= VIA_I2C_BUS2;
+			DRM_DEBUG_KMS("Integrated TMDS (DVI) "
+					"transmitter detected via pin "
+					"strapping.\n");
+		} else {
+			dev_priv->int_tmds_presence = false;
+			dev_priv->int_tmds_di_port = VIA_DI_PORT_NONE;
+			dev_priv->int_tmds_i2c_bus = VIA_I2C_NONE;
+		}
+
+		break;
+	default:
+		dev_priv->int_tmds_presence = false;
+		dev_priv->int_tmds_di_port = VIA_DI_PORT_NONE;
+		dev_priv->int_tmds_i2c_bus = VIA_I2C_NONE;
+		break;
+	}
+
+	DRM_DEBUG_KMS("int_tmds_presence: %x\n",
+			dev_priv->int_tmds_presence);
+	DRM_DEBUG_KMS("int_tmds_di_port: 0x%08x\n",
+			dev_priv->int_tmds_di_port);
+	DRM_DEBUG_KMS("int_tmds_i2c_bus: 0x%08x\n",
+			dev_priv->int_tmds_i2c_bus);
+	DRM_DEBUG_KMS("mapped_i2c_bus: 0x%08x\n",
+			dev_priv->mapped_i2c_bus);
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
 int
 via_tmds_init(struct drm_device *dev)
 {
commit c043f3c35475289b0d4fc073e1e012c88a8d62e0
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 15:58:32 2017 -0500

    Updating chip_revision_info code
    
    Added code to detect VIA Technologies NanoBook reference design and
    Quanta IL1 netbook.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_drv.c b/drivers/gpu/drm/openchrome/via_drv.c
index 62251cd93cae..9904f8c73ac3 100644
--- a/drivers/gpu/drm/openchrome/via_drv.c
+++ b/drivers/gpu/drm/openchrome/via_drv.c
@@ -154,26 +154,70 @@ via_mmio_setup(struct via_device *dev_priv)
     DRM_INFO("Exiting via_mmio_setup.\n");
 }
 
-static void
-chip_revision_info(struct drm_device *dev)
+static void chip_revision_info(struct drm_device *dev)
 {
 	struct via_device *dev_priv = dev->dev_private;
+	struct pci_bus *bus;
+	struct pci_dev *device;
+	u16 device_id, subsystem_vendor_id, subsystem_device_id;
 	u8 tmp;
+	int ret;
+
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+	bus = pci_find_bus(0, 1);
+	if (!bus) {
+		goto pci_error;
+	}
+
+	device = pci_get_slot(bus, PCI_DEVFN(0, 0));
+	if (!device) {
+		goto pci_error;
+	}
+
+	ret = pci_read_config_word(device, 0x02, &device_id);
+	if (ret) {
+		goto pci_error;
+	}
+
+	ret = pci_read_config_word(device, 0x2c,
+					&subsystem_vendor_id);
+	if (ret) {
+		goto pci_error;
+	}
+
+	ret = pci_read_config_word(device, 0x2e,
+					&subsystem_device_id);
+	if (ret) {
+		goto pci_error;
+	}
+
+	DRM_DEBUG_KMS("Chrome IGP Device ID: "
+			"0x%04X\n", device_id);
+	DRM_DEBUG_KMS("Chrome IGP Subsystem Vendor ID: "
+			"0x%04X\n", subsystem_vendor_id);
+	DRM_DEBUG_KMS("Chrome IGP Subsystem Device ID: "
+			"0x%04X\n", subsystem_device_id);
 
 	switch (dev->pdev->device) {
-	/* Check revision of CLE266 Chip */
+
+	/* Check the revision of CLE266 chipset. */
 	case PCI_DEVICE_ID_VIA_CLE266:
-		/* CR4F only define in CLE266.CX chip */
+
+		/* CR4F only defined in CLE266.CX chipset. */
 		tmp = vga_rcrt(VGABASE, 0x4F);
 		vga_wcrt(VGABASE, 0x4F, 0x55);
-		if (vga_rcrt(VGABASE, 0x4F) != 0x55)
+		if (vga_rcrt(VGABASE, 0x4F) != 0x55) {
 			dev_priv->revision = CLE266_REVISION_AX;
-		else
+		} else {
 			dev_priv->revision = CLE266_REVISION_CX;
-		/* restore orignal CR4F value */
+		}
+
+		/* Restore original CR4F value. */
 		vga_wcrt(VGABASE, 0x4F, tmp);
 		break;
 
+	/* CX700 / VX700 Chipset */
 	case PCI_DEVICE_ID_VIA_VT3157:
 		tmp = vga_rseq(VGABASE, 0x43);
 		if (tmp & 0x02) {
@@ -183,17 +227,47 @@ chip_revision_info(struct drm_device *dev)
 		} else {
 			dev_priv->revision = CX700_REVISION_700;
 		}
+
+		/* Check for VIA Technologies NanoBook reference
+		 * design. This is necessary due to its strapping
+		 * resistors not being set to indicate the
+		 * availability of DVI. */
+		if ((subsystem_vendor_id == 0x1509) &&
+			(subsystem_device_id == 0x2d30)) {
+			dev_priv->is_via_nanobook = true;
+		} else {
+			dev_priv->is_via_nanobook = false;
+		}
+
 		break;
 
+	/* VX800 / VX820 Chipset */
 	case PCI_DEVICE_ID_VIA_VT1122:
+
+		/* Check for Quanta IL1 netbook. This is necessary
+		 * due to its flat panel connected to DVP1 (Digital
+		 * Video Port 1) rather than its LVDS channel. */
+		if ((subsystem_vendor_id == 0x152d) &&
+			(subsystem_device_id == 0x0771)) {
+			dev_priv->is_quanta_il1 = true;
+		} else {
+			dev_priv->is_quanta_il1 = false;
+		}
+
+		break;
 	case PCI_DEVICE_ID_VIA_VX875:
 	case PCI_DEVICE_ID_VIA_VX900_VGA:
 		dev_priv->revision = vga_rseq(VGABASE, 0x3B);
 		break;
-
 	default:
 		break;
 	}
+
+	goto exit;
+pci_error:
+	DRM_ERROR("PCI bus related error.");
+exit:
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
 static int via_dumb_create(struct drm_file *filp, struct drm_device *dev,
commit 832a5174db44fcc0192207b797099ce34574cf6d
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 15:00:17 2017 -0500

    Fix for via_lvds2_set_io_pad_setting writing to the wrong location
    
    This is a really bad error.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/crtc_hw.h b/drivers/gpu/drm/openchrome/crtc_hw.h
index 86159cb6b99d..130cdc133098 100644
--- a/drivers/gpu/drm/openchrome/crtc_hw.h
+++ b/drivers/gpu/drm/openchrome/crtc_hw.h
@@ -817,7 +817,7 @@ via_lvds2_set_io_pad_setting(void __iomem *regs, u8 io_pad_state)
 	 *               10: Depend on the other control signal
 	 *               11: Pad on/off according to the
 	 *                   Power Management Status (PMS) */
-	svga_wcrt_mask(regs, 0x2A,
+	svga_wseq_mask(regs, 0x2A,
 			io_pad_state << 2, BIT(3) | BIT(2));
 	DRM_DEBUG_KMS("LVDS2 I/O Pad State: %s\n",
 			((io_pad_state & (BIT(1) | BIT(0))) == 0x03) ?
commit 9a63a7848fc1a04a1e5d82f4d4934b04ce23f666
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 22 14:55:44 2017 -0500

    Fix for via_lvds1_set_io_pad_setting writing to the wrong location
    
    This is a really bad error.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/crtc_hw.h b/drivers/gpu/drm/openchrome/crtc_hw.h
index fe57d1476851..86159cb6b99d 100644
--- a/drivers/gpu/drm/openchrome/crtc_hw.h
+++ b/drivers/gpu/drm/openchrome/crtc_hw.h
@@ -764,7 +764,7 @@ via_lvds1_set_io_pad_setting(void __iomem *regs, u8 io_pad_state)
 	 *               10: Depend on the other control signal
 	 *               11: Pad on/off according to the
 	 *                   Power Management Status (PMS) */
-	svga_wcrt_mask(regs, 0x2A,
+	svga_wseq_mask(regs, 0x2A,
 			io_pad_state, BIT(1) | BIT(0));
 	DRM_DEBUG_KMS("LVDS1 I/O Pad State: %s\n",
 			((io_pad_state & (BIT(1) | BIT(0))) == 0x03) ?


More information about the Openchrome-devel mailing list