[Openchrome-devel] drm-openchrome: Branch 'drm-next-4.13' - 5 commits - drivers/gpu/drm

Kevin Brace kevinbrace at kemper.freedesktop.org
Sun Oct 1 17:17:00 UTC 2017


 drivers/gpu/drm/openchrome/via_crtc.c    |  230 +++++++++++++++----------------
 drivers/gpu/drm/openchrome/via_display.c |    8 -
 drivers/gpu/drm/openchrome/via_display.h |    3 
 drivers/gpu/drm/openchrome/via_drv.c     |    3 
 drivers/gpu/drm/openchrome/via_drv.h     |   18 ++
 drivers/gpu/drm/openchrome/via_fp.c      |  214 +++++++++++++++++++++++++---
 6 files changed, 333 insertions(+), 143 deletions(-)

New commits:
commit ee4db73f8be2e1c73a258858190b274a5988b7f7
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 1 10:07:57 2017 -0700

    Version bumped to 3.0.45
    
    Made improvements in how FP is detected and initialized. DRM / X Server
    will still not be able to reinitialize the screen properly after standby
    resume, but the improvements made by this version can restore FP only
    once when the user switches to a VT (Virtual Terminal) from a blank
    screen. For the developer, having a working VT is far better than a blank
    screen for debugging purposes.
    
    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 db0c519d3ff5..ccf589af7b33 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         "20170913"
+#define DRIVER_DATE         "20171001"
 
 #define DRIVER_MAJOR		3
 #define DRIVER_MINOR		0
-#define DRIVER_PATCHLEVEL	44
+#define DRIVER_PATCHLEVEL	45
 
 #include <linux/module.h>
 
commit 2931c20920655906e22b5a926e9f66591656ba24
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 1 09:55:49 2017 -0700

    Greatly consolidating FP DI (Digital Interface?) Port assignment
    
    Removed obsolete FP DI Port assignment code left behind by the
    previous developer.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_fp.c b/drivers/gpu/drm/openchrome/via_fp.c
index a4283045e0fe..9d19f95fb5b9 100644
--- a/drivers/gpu/drm/openchrome/via_fp.c
+++ b/drivers/gpu/drm/openchrome/via_fp.c
@@ -1326,35 +1326,17 @@ via_lvds_init(struct drm_device *dev)
 
 	enc->base.possible_crtcs = BIT(1);
 
-	switch (dev->pdev->device) {
-	case PCI_DEVICE_ID_VIA_CLE266:
-		enc->di_port = VIA_DI_PORT_DVP1;
-		break;
-
-	case PCI_DEVICE_ID_VIA_VX875:
-	case PCI_DEVICE_ID_VIA_VX900_VGA:
-		enc->di_port = VIA_DI_PORT_DFPL;
-		break;
-
-	default:
-		enc->di_port = VIA_DI_PORT_DFPH;
-		break;
-	}
-
 	/* There has to be a way to detect TTL LVDS
 	 * For now we use the DMI to handle this */
 	if (dmi_check_system(via_ttl_lvds))
 		enc->di_port = VIA_DI_PORT_DFPL | VIA_DI_PORT_DVP1;
 
-	reg_value = 0x00;
-	if (enc->di_port == VIA_DI_PORT_DFPH) {
-		if (!is_msb)
-			reg_value = BIT(0);
-		svga_wcrt_mask(VGABASE, 0xD2, reg_value, BIT(0));
-	} else if (enc->di_port == VIA_DI_PORT_DFPL) {
-		if (!is_msb)
-			reg_value = BIT(1);
-		svga_wcrt_mask(VGABASE, 0xD2, reg_value, BIT(1));
+	if (dev_priv->int_fp1_presence) {
+		enc->di_port = dev_priv->int_fp1_di_port;
+	} else if (dev_priv->int_fp2_presence) {
+		enc->di_port = dev_priv->int_fp2_di_port;
+	} else {
+		enc->di_port = VIA_DI_PORT_NONE;
 	}
 
 	if (dual_channel)
commit bbdd073b59b2761b36d4136191d52f6c9297083d
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 1 07:55:46 2017 -0700

    Add via_fp_probe
    
    via_fp_probe function probes for FP mostly based on hardware pin
    strapping information.
    
    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 9770187b6dd0..f94b3b6f21b3 100644
--- a/drivers/gpu/drm/openchrome/via_display.c
+++ b/drivers/gpu/drm/openchrome/via_display.c
@@ -507,6 +507,12 @@ 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_fp_probe(dev);
+
+
 	via_analog_init(dev);
 
 	via_lvds_init(dev);
diff --git a/drivers/gpu/drm/openchrome/via_display.h b/drivers/gpu/drm/openchrome/via_display.h
index f67beb15ec0c..33ffbff4a489 100644
--- a/drivers/gpu/drm/openchrome/via_display.h
+++ b/drivers/gpu/drm/openchrome/via_display.h
@@ -170,6 +170,9 @@ 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_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);
diff --git a/drivers/gpu/drm/openchrome/via_drv.c b/drivers/gpu/drm/openchrome/via_drv.c
index 2a4dd3f74941..e2716f36b6a3 100644
--- a/drivers/gpu/drm/openchrome/via_drv.c
+++ b/drivers/gpu/drm/openchrome/via_drv.c
@@ -244,6 +244,9 @@ via_device_init(struct via_device *dev_priv)
 
     DRM_DEBUG("Entered via_device_init.\n");
 
+    /* Temporary implementation. */
+    dev_priv->is_via_nanobook = false;
+
     ret = via_vram_init(dev_priv);
     if (ret) {
         DRM_ERROR("Failed to initialize video RAM.\n");
diff --git a/drivers/gpu/drm/openchrome/via_drv.h b/drivers/gpu/drm/openchrome/via_drv.h
index c39ca2fdb459..db0c519d3ff5 100644
--- a/drivers/gpu/drm/openchrome/via_drv.h
+++ b/drivers/gpu/drm/openchrome/via_drv.h
@@ -190,6 +190,20 @@ struct via_device {
 
 	struct via_crtc iga[2];
 	bool spread_spectrum;
+
+	/* Due to the way VIA NanoBook reference design implemented
+	 * the pin strapping settings, DRM needs to ignore them for
+	 * FP and DVI to be properly detected. */
+	bool is_via_nanobook;
+
+	bool int_fp1_presence;
+	u32 int_fp1_di_port;
+
+	bool int_fp2_presence;
+	u32 int_fp2_di_port;
+
+	/* Keeping track of the number of FP (Flat Panel) connectors. */
+	u32 number_fp;
 };
 
 #define VIA_MEM_NONE		0x00
diff --git a/drivers/gpu/drm/openchrome/via_fp.c b/drivers/gpu/drm/openchrome/via_fp.c
index 24c3ada5de28..a4283045e0fe 100644
--- a/drivers/gpu/drm/openchrome/via_fp.c
+++ b/drivers/gpu/drm/openchrome/via_fp.c
@@ -1051,6 +1051,190 @@ static const struct dmi_system_id via_ttl_lvds[] = {
 	{ }
 };
 
+/*
+ * Probe (pre-initialization detection) FP.
+ */
+void via_fp_probe(struct drm_device *dev)
+{
+	struct via_device *dev_priv = dev->dev_private;
+	u16 chipset = dev->pdev->device;
+	u8 sr12, sr13, sr5a;
+	u8 cr3b;
+
+	DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+	sr12 = vga_rseq(VGABASE, 0x12);
+	sr13 = vga_rseq(VGABASE, 0x13);
+	cr3b = vga_rcrt(VGABASE, 0x3b);
+
+	DRM_DEBUG_KMS("chipset: 0x%04x\n", chipset);
+	DRM_DEBUG_KMS("sr12: 0x%02x\n", sr12);
+	DRM_DEBUG_KMS("sr13: 0x%02x\n", sr13);
+	DRM_DEBUG_KMS("cr3b: 0x%02x\n", cr3b);
+
+	/* Detect the presence of FPs. */
+	switch (chipset) {
+	case PCI_DEVICE_ID_VIA_CLE266:
+		if ((sr12 & BIT(4)) || (cr3b & BIT(3))) {
+			dev_priv->int_fp1_presence = true;
+			dev_priv->int_fp1_di_port = VIA_DI_PORT_DIP0;
+		} else {
+			dev_priv->int_fp1_presence = false;
+			dev_priv->int_fp1_di_port = VIA_DI_PORT_NONE;
+		}
+
+		dev_priv->int_fp2_presence = false;
+		dev_priv->int_fp2_di_port = VIA_DI_PORT_NONE;
+		break;
+	case PCI_DEVICE_ID_VIA_KM400:
+	case PCI_DEVICE_ID_VIA_CN700:
+	case PCI_DEVICE_ID_VIA_PM800:
+	case PCI_DEVICE_ID_VIA_K8M800:
+		/* 3C5.13[3] - DVP0D8 pin strapping
+		 *             0: AGP pins are used for AGP
+		 *             1: AGP pins are used by FPDP
+		 *             (Flat Panel Display Port) */
+		if ((sr13 & BIT(3)) && (cr3b & BIT(1))) {
+			dev_priv->int_fp1_presence = true;
+			dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_FPDPHIGH |
+						VIA_DI_PORT_FPDPLOW;
+		} else {
+			dev_priv->int_fp1_presence = false;
+			dev_priv->int_fp1_di_port = VIA_DI_PORT_NONE;
+		}
+
+		dev_priv->int_fp2_presence = false;
+		dev_priv->int_fp2_di_port = VIA_DI_PORT_NONE;
+		break;
+	case PCI_DEVICE_ID_VIA_VT3343:
+	case PCI_DEVICE_ID_VIA_K8M890:
+	case PCI_DEVICE_ID_VIA_P4M900:
+		if (cr3b & BIT(1)) {
+			/* 3C5.12[4] - DVP0D4 pin strapping
+			 *             0: 12-bit FPDP (Flat Panel
+			 *                Display Port)
+			 *             1: 24-bit FPDP (Flat Panel
+			 *                Display Port) */
+			if (sr12 & BIT(4)) {
+				dev_priv->int_fp1_presence = true;
+				dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_FPDPLOW |
+						VIA_DI_PORT_FPDPHIGH;
+			} else {
+				dev_priv->int_fp1_presence = true;
+				dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_FPDPLOW;
+			}
+		} else {
+			dev_priv->int_fp1_presence = false;
+			dev_priv->int_fp1_di_port = VIA_DI_PORT_NONE;
+		}
+
+		dev_priv->int_fp2_presence = false;
+		dev_priv->int_fp2_di_port = VIA_DI_PORT_NONE;
+		break;
+	case PCI_DEVICE_ID_VIA_VT3157:
+	case PCI_DEVICE_ID_VIA_VT1122:
+	case PCI_DEVICE_ID_VIA_VX875:
+	case PCI_DEVICE_ID_VIA_VX900_VGA:
+		/* Save SR5A. */
+		sr5a = vga_rseq(VGABASE, 0x5a);
+
+		DRM_DEBUG_KMS("sr5a: 0x%02x\n", sr5a);
+
+		/* Set SR5A[0] to 1.
+		 * This allows the read out of the alternative
+		 * pin strapping settings from SR12 and SR13. */
+		svga_wseq_mask(VGABASE, 0x5a, BIT(0), BIT(0));
+
+		sr13 = vga_rseq(VGABASE, 0x13);
+		if (cr3b & BIT(1)) {
+			if (dev_priv->is_via_nanobook) {
+				dev_priv->int_fp1_presence = false;
+				dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_NONE;
+				dev_priv->int_fp2_presence = true;
+				dev_priv->int_fp2_di_port =
+						VIA_DI_PORT_LVDS2;
+
+			/* 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) */
+			} else if ((!(sr13 & BIT(7))) &&
+					(!(sr13 & BIT(6)))) {
+				dev_priv->int_fp1_presence = true;
+				dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_LVDS1;
+
+				/*
+				 * For now, don't support the second
+				 * FP.
+				 */
+				dev_priv->int_fp2_presence = false;
+				dev_priv->int_fp2_di_port =
+						VIA_DI_PORT_NONE;
+			} else if ((!(sr13 & BIT(7))) &&
+					(sr13 & BIT(6))) {
+				dev_priv->int_fp1_presence = false;
+				dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_NONE;
+				dev_priv->int_fp2_presence = true;
+				dev_priv->int_fp2_di_port =
+						VIA_DI_PORT_LVDS2;
+			} else if ((sr13 & BIT(7)) &&
+					(!(sr13 & BIT(6)))) {
+				dev_priv->int_fp1_presence = true;
+				dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_LVDS1 |
+						VIA_DI_PORT_LVDS2;
+				dev_priv->int_fp2_presence = false;
+				dev_priv->int_fp2_di_port =
+						VIA_DI_PORT_NONE;
+			} else {
+				dev_priv->int_fp1_presence = false;
+				dev_priv->int_fp1_di_port =
+						VIA_DI_PORT_NONE;
+				dev_priv->int_fp2_presence = false;
+				dev_priv->int_fp2_di_port =
+						VIA_DI_PORT_NONE;
+			}
+		} else {
+			dev_priv->int_fp1_presence = false;
+			dev_priv->int_fp1_di_port = VIA_DI_PORT_NONE;
+			dev_priv->int_fp2_presence = false;
+			dev_priv->int_fp2_di_port = VIA_DI_PORT_NONE;
+		}
+
+		/* Restore SR5A. */
+		vga_wseq(VGABASE, 0x5a, sr5a);
+		break;
+	default:
+		dev_priv->int_fp1_presence = false;
+		dev_priv->int_fp1_di_port = VIA_DI_PORT_NONE;
+		dev_priv->int_fp2_presence = false;
+		dev_priv->int_fp2_di_port = VIA_DI_PORT_NONE;
+		break;
+	}
+
+	DRM_DEBUG_KMS("dev_priv->int_fp1_presence: %x\n",
+			dev_priv->int_fp1_presence);
+	DRM_DEBUG_KMS("dev_priv->int_fp1_di_port: 0x%08x\n",
+			dev_priv->int_fp1_di_port);
+	DRM_DEBUG_KMS("dev_priv->int_fp2_presence: %x\n",
+			dev_priv->int_fp2_presence);
+	DRM_DEBUG_KMS("dev_priv->int_fp2_di_port: 0x%08x\n",
+			dev_priv->int_fp2_di_port);
+
+	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+}
+
 void
 via_lvds_init(struct drm_device *dev)
 {
commit 94e8320046f78c9e1dfafee3ead7a350cad273be
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 1 06:34:34 2017 -0700

    Limit total horizontal screen resolution to 2044 dots for now
    
    In 32-bit color mode, allowing greater than 2044 dots in the
    horizontal direction causes display issues. For now, the workaround
    is to limit total horizontal screen resolution to 2044 dots.
    
    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 49d4bf68be4c..9770187b6dd0 100644
--- a/drivers/gpu/drm/openchrome/via_display.c
+++ b/drivers/gpu/drm/openchrome/via_display.c
@@ -496,7 +496,7 @@ via_modeset_init(struct drm_device *dev)
 
 	dev->mode_config.min_width = 320;
 	dev->mode_config.min_height = 200;
-	dev->mode_config.max_width = 4096;
+	dev->mode_config.max_width = 2044;
 	dev->mode_config.max_height = 4096;
 
 	via_display_init(dev);
commit 0a36229cda587ce2124bbe1d761764223021e242
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Oct 1 06:27:00 2017 -0700

    Discontinue the use of mode_set_base callback
    
    Due to the way mode setting is handled by DRM, no full mode setting
    was being done when resuming from standby (ACPI S3 State). This causes
    the computer to lose control of the display after standby resume. Not
    defining mode_set_base callback forces DRM to perform full mode setting,
    and this is really how DRM should handle mode setting after standby
    resume.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/via_crtc.c b/drivers/gpu/drm/openchrome/via_crtc.c
index eea4ca4ff51f..6c73bb7e6968 100644
--- a/drivers/gpu/drm/openchrome/via_crtc.c
+++ b/drivers/gpu/drm/openchrome/via_crtc.c
@@ -1143,6 +1143,62 @@ via_iga1_crtc_mode_fixup(struct drm_crtc *crtc,
 }
 
 static int
+via_iga1_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
+                            struct drm_framebuffer *old_fb)
+{
+    struct ttm_buffer_object *bo;
+    struct via_framebuffer *via_fb =
+            container_of(crtc->primary->fb, struct via_framebuffer, fb);
+    struct drm_framebuffer *new_fb = &via_fb->fb;
+    struct drm_gem_object *gem_obj = via_fb->gem_obj;
+    int ret = 0;
+
+    DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+    /* No FB found. */
+    if (!new_fb) {
+        ret = -ENOMEM;
+        DRM_DEBUG_KMS("No FB found.\n");
+        goto exit;
+    }
+
+    gem_obj = via_fb->gem_obj;
+    bo = ttm_gem_mapping(gem_obj);
+
+    ret = via_bo_pin(bo, NULL);
+    if (unlikely(ret)) {
+        DRM_DEBUG_KMS("Failed to pin FB.\n");
+        goto exit;
+    }
+
+    ret = crtc->helper_private->mode_set_base_atomic(crtc, new_fb, x, y,
+            ENTER_ATOMIC_MODE_SET);
+    if (unlikely(ret)) {
+        DRM_DEBUG_KMS("Failed to set a new FB.\n");
+        via_bo_unpin(bo, NULL);
+        goto exit;
+    }
+
+    /* Free the old framebuffer if it exist */
+    if (old_fb) {
+        via_fb = container_of(old_fb,
+                                struct via_framebuffer, fb);
+        gem_obj = via_fb->gem_obj;
+        bo = ttm_gem_mapping(gem_obj);
+
+        ret = via_bo_unpin(bo, NULL);
+        if (unlikely(ret)) {
+            DRM_DEBUG_KMS("FB still locked.\n");
+            goto exit;
+        }
+    }
+
+exit:
+    DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+    return ret;
+}
+
+static int
 via_iga1_crtc_mode_set(struct drm_crtc *crtc,
                         struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode,
                         int x, int y, struct drm_framebuffer *fb)
@@ -1223,7 +1279,7 @@ via_iga1_crtc_mode_set(struct drm_crtc *crtc,
         via_set_vclock(crtc, pll_regs);
     }
 
-    ret = crtc->helper_private->mode_set_base(crtc, x, y, fb);
+    ret = via_iga1_crtc_mode_set_base(crtc, x, y, fb);
 
 exit:
     DRM_DEBUG("Exiting via_iga1_crtc_mode_set.\n");
@@ -1231,62 +1287,6 @@ exit:
 }
 
 static int
-via_iga1_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
-                            struct drm_framebuffer *old_fb)
-{
-    struct ttm_buffer_object *bo;
-    struct via_framebuffer *via_fb =
-            container_of(crtc->primary->fb, struct via_framebuffer, fb);
-    struct drm_framebuffer *new_fb = &via_fb->fb;
-    struct drm_gem_object *gem_obj = via_fb->gem_obj;
-    int ret = 0;
-
-    DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
-    /* No FB found. */
-    if (!new_fb) {
-        ret = -ENOMEM;
-        DRM_DEBUG_KMS("No FB found.\n");
-        goto exit;
-    }
-
-    gem_obj = via_fb->gem_obj;
-    bo = ttm_gem_mapping(gem_obj);
-
-    ret = via_bo_pin(bo, NULL);
-    if (unlikely(ret)) {
-        DRM_DEBUG_KMS("Failed to pin FB.\n");
-        goto exit;
-    }
-
-    ret = crtc->helper_private->mode_set_base_atomic(crtc, new_fb, x, y,
-            ENTER_ATOMIC_MODE_SET);
-    if (unlikely(ret)) {
-        DRM_DEBUG_KMS("Failed to set a new FB.\n");
-        via_bo_unpin(bo, NULL);
-        goto exit;
-    }
-
-    /* Free the old framebuffer if it exist */
-    if (old_fb) {
-        via_fb = container_of(old_fb,
-                                struct via_framebuffer, fb);
-        gem_obj = via_fb->gem_obj;
-        bo = ttm_gem_mapping(gem_obj);
-
-        ret = via_bo_unpin(bo, NULL);
-        if (unlikely(ret)) {
-            DRM_DEBUG_KMS("FB still locked.\n");
-            goto exit;
-        }
-    }
-
-exit:
-    DRM_DEBUG_KMS("Exiting %s.\n", __func__);
-    return ret;
-}
-
-static int
 via_iga1_mode_set_base_atomic(struct drm_crtc *crtc,
                                 struct drm_framebuffer *fb, int x, int y,
                                 enum mode_set_atomic state)
@@ -1426,6 +1426,62 @@ via_iga2_crtc_mode_fixup(struct drm_crtc *crtc,
 }
 
 static int
+via_iga2_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
+                            struct drm_framebuffer *old_fb)
+{
+    struct ttm_buffer_object *bo;
+    struct via_framebuffer *via_fb =
+            container_of(crtc->primary->fb, struct via_framebuffer, fb);
+    struct drm_framebuffer *new_fb = &via_fb->fb;
+    struct drm_gem_object *gem_obj = via_fb->gem_obj;
+    int ret = 0;
+
+    DRM_DEBUG_KMS("Entered %s.\n", __func__);
+
+    /* No FB found. */
+    if (!new_fb) {
+        ret = -ENOMEM;
+        DRM_DEBUG_KMS("No FB found.\n");
+        goto exit;
+    }
+
+    gem_obj = via_fb->gem_obj;
+    bo = ttm_gem_mapping(gem_obj);
+
+    ret = via_bo_pin(bo, NULL);
+    if (unlikely(ret)) {
+        DRM_DEBUG_KMS("Failed to pin FB.\n");
+        goto exit;
+    }
+
+    ret = crtc->helper_private->mode_set_base_atomic(crtc, new_fb, x, y,
+            ENTER_ATOMIC_MODE_SET);
+    if (unlikely(ret)) {
+        DRM_DEBUG_KMS("Failed to set a new FB.\n");
+        via_bo_unpin(bo, NULL);
+        goto exit;
+    }
+
+    /* Free the old framebuffer if it exist */
+    if (old_fb) {
+        via_fb = container_of(old_fb,
+                                struct via_framebuffer, fb);
+        gem_obj = via_fb->gem_obj;
+        bo = ttm_gem_mapping(gem_obj);
+
+        ret = via_bo_unpin(bo, NULL);
+        if (unlikely(ret)) {
+            DRM_DEBUG_KMS("FB still locked.\n");
+            goto exit;
+        }
+    }
+
+exit:
+    DRM_DEBUG_KMS("Exiting %s.\n", __func__);
+    return ret;
+}
+
+static int
 via_iga2_crtc_mode_set(struct drm_crtc *crtc,
                         struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode,
                         int x, int y, struct drm_framebuffer *fb)
@@ -1535,7 +1591,7 @@ via_iga2_crtc_mode_set(struct drm_crtc *crtc,
         via_set_vclock(crtc, pll_regs);
     }
 
-    ret = crtc->helper_private->mode_set_base(crtc, x, y, fb);
+    ret = via_iga2_crtc_mode_set_base(crtc, x, y, fb);
 
 exit:
     DRM_DEBUG("Exiting via_iga2_crtc_mode_set.\n");
@@ -1543,62 +1599,6 @@ exit:
 }
 
 static int
-via_iga2_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
-                            struct drm_framebuffer *old_fb)
-{
-    struct ttm_buffer_object *bo;
-    struct via_framebuffer *via_fb =
-            container_of(crtc->primary->fb, struct via_framebuffer, fb);
-    struct drm_framebuffer *new_fb = &via_fb->fb;
-    struct drm_gem_object *gem_obj = via_fb->gem_obj;
-    int ret = 0;
-
-    DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
-    /* No FB found. */
-    if (!new_fb) {
-        ret = -ENOMEM;
-        DRM_DEBUG_KMS("No FB found.\n");
-        goto exit;
-    }
-
-    gem_obj = via_fb->gem_obj;
-    bo = ttm_gem_mapping(gem_obj);
-
-    ret = via_bo_pin(bo, NULL);
-    if (unlikely(ret)) {
-        DRM_DEBUG_KMS("Failed to pin FB.\n");
-        goto exit;
-    }
-
-    ret = crtc->helper_private->mode_set_base_atomic(crtc, new_fb, x, y,
-            ENTER_ATOMIC_MODE_SET);
-    if (unlikely(ret)) {
-        DRM_DEBUG_KMS("Failed to set a new FB.\n");
-        via_bo_unpin(bo, NULL);
-        goto exit;
-    }
-
-    /* Free the old framebuffer if it exist */
-    if (old_fb) {
-        via_fb = container_of(old_fb,
-                                struct via_framebuffer, fb);
-        gem_obj = via_fb->gem_obj;
-        bo = ttm_gem_mapping(gem_obj);
-
-        ret = via_bo_unpin(bo, NULL);
-        if (unlikely(ret)) {
-            DRM_DEBUG_KMS("FB still locked.\n");
-            goto exit;
-        }
-    }
-
-exit:
-    DRM_DEBUG_KMS("Exiting %s.\n", __func__);
-    return ret;
-}
-
-static int
 via_iga2_mode_set_base_atomic(struct drm_crtc *crtc,
                                 struct drm_framebuffer *fb,
                                 int x, int y, enum mode_set_atomic state)
@@ -1654,7 +1654,6 @@ static const struct drm_crtc_helper_funcs via_iga1_helper_funcs = {
     .commit = via_iga1_crtc_commit,
     .mode_fixup = via_iga1_crtc_mode_fixup,
     .mode_set = via_iga1_crtc_mode_set,
-    .mode_set_base = via_iga1_crtc_mode_set_base,
     .mode_set_base_atomic = via_iga1_mode_set_base_atomic,
 };
 
@@ -1665,7 +1664,6 @@ static const struct drm_crtc_helper_funcs via_iga2_helper_funcs = {
     .commit = via_iga2_crtc_commit,
     .mode_fixup = via_iga2_crtc_mode_fixup,
     .mode_set = via_iga2_crtc_mode_set,
-    .mode_set_base = via_iga2_crtc_mode_set_base,
     .mode_set_base_atomic = via_iga2_mode_set_base_atomic,
 };
 


More information about the Openchrome-devel mailing list