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

Kevin Brace kevinbrace at kemper.freedesktop.org
Sun Oct 15 02:39:51 UTC 2017


 drivers/gpu/drm/openchrome/via_crtc.c    |  236 +++++++++++++++----------------
 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, 335 insertions(+), 147 deletions(-)

New commits:
commit 02bca0f0491e326ce416c3ca525315a0ea5ef492
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sat Oct 14 19:38:10 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 79e0163d3b25..3c4394b31007 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         "20170914"
+#define DRIVER_DATE         "20171014"
 
 #define DRIVER_MAJOR		3
 #define DRIVER_MINOR		0
-#define DRIVER_PATCHLEVEL	44
+#define DRIVER_PATCHLEVEL	45
 
 #include <linux/module.h>
 
commit fdf0b8930a9abc194ffc8f9c09095bcef8cdcfd7
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sat Oct 14 19:33:57 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 eee70187c958..d22db455f78e 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 f8f9ff2dafce6928743032880f35cdf73a101ce6
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sat Oct 14 19:28:52 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 8cf099e40332..52e1c2d2a2d8 100644
--- a/drivers/gpu/drm/openchrome/via_display.c
+++ b/drivers/gpu/drm/openchrome/via_display.c
@@ -514,6 +514,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 c9b7f04668c2..b775346ad808 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 1f152ce0734c..79e0163d3b25 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 79686a085634..eee70187c958 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 379d42dc31a2cdc911d71edc166796278bf805e9
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sat Oct 14 19:13:32 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 37ac7a78b615..8cf099e40332 100644
--- a/drivers/gpu/drm/openchrome/via_display.c
+++ b/drivers/gpu/drm/openchrome/via_display.c
@@ -503,7 +503,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 ed0b2d5a41ab24fed777e8650992b7f9138ad5d9
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sat Oct 14 19:10:14 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 ce0aaac442dc..f6bcd82b0c00 100644
--- a/drivers/gpu/drm/openchrome/via_crtc.c
+++ b/drivers/gpu/drm/openchrome/via_crtc.c
@@ -1137,13 +1137,69 @@ via_iga1_crtc_mode_fixup(struct drm_crtc *crtc,
     return true;
 }
 
+static int via_iga1_crtc_mode_set_base(struct drm_crtc *crtc,
+                                        int x, int y,
+                                        struct drm_framebuffer *old_fb)
+{
+    struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+    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_funcs->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)
 {
     struct via_crtc *iga = container_of(crtc, struct via_crtc, base);
-    struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
     struct via_device *dev_priv = crtc->dev->dev_private;
     struct drm_device *dev = crtc->dev;
     u8 reg_value = 0;
@@ -1219,70 +1275,13 @@ via_iga1_crtc_mode_set(struct drm_crtc *crtc,
         via_set_vclock(crtc, pll_regs);
     }
 
-    ret = crtc_funcs->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");
     return ret;
 }
 
-static int via_iga1_crtc_mode_set_base(struct drm_crtc *crtc,
-                                        int x, int y,
-                                        struct drm_framebuffer *old_fb)
-{
-    struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
-    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_funcs->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,
@@ -1427,13 +1426,69 @@ via_iga2_crtc_mode_fixup(struct drm_crtc *crtc,
     return true;
 }
 
+static int via_iga2_crtc_mode_set_base(struct drm_crtc *crtc,
+                                        int x, int y,
+                                        struct drm_framebuffer *old_fb)
+{
+    struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+    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_funcs->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)
 {
     struct via_crtc *iga = container_of(crtc, struct via_crtc, base);
-    struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
     struct via_device *dev_priv = crtc->dev->dev_private;
     struct drm_device *dev = crtc->dev;
     int ret;
@@ -1538,70 +1593,13 @@ via_iga2_crtc_mode_set(struct drm_crtc *crtc,
         via_set_vclock(crtc, pll_regs);
     }
 
-    ret = crtc_funcs->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");
     return ret;
 }
 
-static int via_iga2_crtc_mode_set_base(struct drm_crtc *crtc,
-                                        int x, int y,
-                                        struct drm_framebuffer *old_fb)
-{
-    struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
-    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_funcs->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,
@@ -1658,7 +1656,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,
     .load_lut = drm_mode_crtc_load_lut,
 };
@@ -1670,7 +1667,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,
     .load_lut = drm_mode_crtc_load_lut,
 };


More information about the Openchrome-devel mailing list