[openchrome-devel] xf86-video-openchrome: Branch 'main' - 17 commits - src/via_display.c src/via_outputs.c src/via_ums.h

Kevin Brace kevinbrace at kemper.freedesktop.org
Fri May 28 20:32:30 UTC 2021


 src/via_display.c |  506 +++++++++++++++++++++---------------------------------
 src/via_outputs.c |   10 -
 src/via_ums.h     |   33 +++
 3 files changed, 238 insertions(+), 311 deletions(-)

New commits:
commit 9d9f47981f038bda4cb5458bdbbd4325933467a9
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 13:30:09 2021 -0700

    Merge iga*_crtc_unlock() into iga_crtc_unlock()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index e9d1cd2..6550869 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3173,8 +3173,15 @@ iga_crtc_lock(xf86CrtcPtr crtc)
 }
 
 static void
-iga1_crtc_unlock(xf86CrtcPtr crtc)
+iga_crtc_unlock(xf86CrtcPtr crtc)
 {
+    ScrnInfoPtr pScrn = crtc->scrn;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
 }
 
 static Bool
@@ -3569,7 +3576,7 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .save                   = iga_crtc_save,
     .restore                = iga_crtc_restore,
     .lock                   = iga_crtc_lock,
-    .unlock                 = iga1_crtc_unlock,
+    .unlock                 = iga_crtc_unlock,
     .mode_fixup             = iga1_crtc_mode_fixup,
     .prepare                = iga_crtc_prepare,
     .mode_set               = iga_crtc_mode_set,
@@ -3589,11 +3596,6 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .destroy                = iga_crtc_destroy,
 };
 
-static void
-iga2_crtc_unlock(xf86CrtcPtr crtc)
-{
-}
-
 static Bool
 iga2_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
                         DisplayModePtr adjusted_mode)
@@ -3727,7 +3729,7 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .save                   = iga_crtc_save,
     .restore                = iga_crtc_restore,
     .lock                   = iga_crtc_lock,
-    .unlock                 = iga2_crtc_unlock,
+    .unlock                 = iga_crtc_unlock,
     .mode_fixup             = iga2_crtc_mode_fixup,
     .prepare                = iga_crtc_prepare,
     .mode_set               = iga_crtc_mode_set,
commit 987c1379899a3c57964b8d80cd1723c0125a864a
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 13:25:31 2021 -0700

    Merge iga*_crtc_lock() into iga_crtc_lock()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index a578549..e9d1cd2 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3159,8 +3159,16 @@ iga_crtc_restore(xf86CrtcPtr crtc)
 }
 
 static Bool
-iga1_crtc_lock(xf86CrtcPtr crtc)
+iga_crtc_lock(xf86CrtcPtr crtc)
 {
+    ScrnInfoPtr pScrn = crtc->scrn;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
+
     return FALSE;
 }
 
@@ -3560,7 +3568,7 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .dpms                   = iga_crtc_dpms,
     .save                   = iga_crtc_save,
     .restore                = iga_crtc_restore,
-    .lock                   = iga1_crtc_lock,
+    .lock                   = iga_crtc_lock,
     .unlock                 = iga1_crtc_unlock,
     .mode_fixup             = iga1_crtc_mode_fixup,
     .prepare                = iga_crtc_prepare,
@@ -3581,12 +3589,6 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .destroy                = iga_crtc_destroy,
 };
 
-static Bool
-iga2_crtc_lock(xf86CrtcPtr crtc)
-{
-    return FALSE;
-}
-
 static void
 iga2_crtc_unlock(xf86CrtcPtr crtc)
 {
@@ -3724,7 +3726,7 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .dpms                   = iga_crtc_dpms,
     .save                   = iga_crtc_save,
     .restore                = iga_crtc_restore,
-    .lock                   = iga2_crtc_lock,
+    .lock                   = iga_crtc_lock,
     .unlock                 = iga2_crtc_unlock,
     .mode_fixup             = iga2_crtc_mode_fixup,
     .prepare                = iga_crtc_prepare,
commit bc4fafc177d3053ca7dd3a5cd522017a3254b2f3
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 13:18:53 2021 -0700

    Merge iga*_crtc_set_origin() into iga_crtc_set_origin()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 394d565..a578549 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3241,21 +3241,6 @@ iga_crtc_prepare(xf86CrtcPtr crtc)
                         "Exiting %s.\n", __func__));
 }
 
-static void
-iga1_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga1_crtc_set_origin.\n"));
-
-    viaIGA1SetFBStartingAddress(crtc, x, y);
-    VIAVidAdjustFrame(pScrn, x, y);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga1_crtc_set_origin.\n"));
-}
-
 static void
 iga_crtc_mode_set(xf86CrtcPtr crtc,
                     DisplayModePtr mode, DisplayModePtr adjusted_mode,
@@ -3541,6 +3526,29 @@ iga_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
     }
 }
 
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
+static void
+iga_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
+{
+    ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    if (!iga->index) {
+        viaIGA1SetFBStartingAddress(crtc, x, y);
+    } else {
+        viaIGA2SetFBStartingAddress(crtc, x, y);
+    }
+
+    VIAVidAdjustFrame(pScrn, x, y);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
+}
+#endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2 */
+
 static void
 iga_crtc_destroy(xf86CrtcPtr crtc)
 {
@@ -3568,8 +3576,8 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .hide_cursor            = iga_crtc_hide_cursor,
     .load_cursor_argb       = iga_crtc_load_cursor_argb,
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
-    .set_origin             = iga1_crtc_set_origin,
-#endif
+    .set_origin             = iga_crtc_set_origin,
+#endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2 */
     .destroy                = iga_crtc_destroy,
 };
 
@@ -3635,21 +3643,6 @@ iga2_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
     return TRUE;
 }
 
-static void
-iga2_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga2_crtc_set_origin.\n"));
-
-    viaIGA2SetFBStartingAddress(crtc, x, y);
-    VIAVidAdjustFrame(pScrn, x, y);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga2_crtc_set_origin.\n"));
-}
-
 static void
 iga2_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
                     int size)
@@ -3747,7 +3740,7 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .hide_cursor            = iga_crtc_hide_cursor,
     .load_cursor_argb       = iga_crtc_load_cursor_argb,
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2
-    .set_origin             = iga2_crtc_set_origin,
-#endif
+    .set_origin             = iga_crtc_set_origin,
+#endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 2 */
     .destroy                = iga_crtc_destroy,
 };
commit 3b2ec2dbd9981b1730f786d38c65ae78690064c3
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 13:08:36 2021 -0700

    Merge iga*_crtc_restore() into iga_crtc_restore()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index b18c615..394d565 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3140,11 +3140,22 @@ iga_crtc_save(xf86CrtcPtr crtc)
 }
 
 static void
-iga1_crtc_restore(xf86CrtcPtr crtc)
+iga_crtc_restore(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    if (!iga->index) {
+        viaIGA1Restore(pScrn);
+    } else {
+        viaIGA2Restore(pScrn);
+    }
 
-    viaIGA1Restore(pScrn);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
 }
 
 static Bool
@@ -3540,7 +3551,7 @@ iga_crtc_destroy(xf86CrtcPtr crtc)
 const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .dpms                   = iga_crtc_dpms,
     .save                   = iga_crtc_save,
-    .restore                = iga1_crtc_restore,
+    .restore                = iga_crtc_restore,
     .lock                   = iga1_crtc_lock,
     .unlock                 = iga1_crtc_unlock,
     .mode_fixup             = iga1_crtc_mode_fixup,
@@ -3562,20 +3573,6 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .destroy                = iga_crtc_destroy,
 };
 
-static void
-iga2_crtc_restore(xf86CrtcPtr crtc)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga2_crtc_restore.\n"));
-
-    viaIGA2Restore(pScrn);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga2_crtc_restore.\n"));
-}
-
 static Bool
 iga2_crtc_lock(xf86CrtcPtr crtc)
 {
@@ -3733,7 +3730,7 @@ iga2_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .dpms                   = iga_crtc_dpms,
     .save                   = iga_crtc_save,
-    .restore                = iga2_crtc_restore,
+    .restore                = iga_crtc_restore,
     .lock                   = iga2_crtc_lock,
     .unlock                 = iga2_crtc_unlock,
     .mode_fixup             = iga2_crtc_mode_fixup,
commit 1bebca59cc9aa1a2d085d9a8db1273863136a62e
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:59:54 2021 -0700

    Merge iga*_crtc_save() into iga_crtc_save()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index dc6ea71..b18c615 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3121,11 +3121,22 @@ iga_crtc_dpms(xf86CrtcPtr crtc, int mode)
 }
 
 static void
-iga1_crtc_save(xf86CrtcPtr crtc)
+iga_crtc_save(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
+
+    if (!iga->index) {
+        viaIGA1Save(pScrn);
+    } else {
+        viaIGA2Save(pScrn);
+    }
 
-    viaIGA1Save(pScrn);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
 }
 
 static void
@@ -3528,7 +3539,7 @@ iga_crtc_destroy(xf86CrtcPtr crtc)
 
 const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .dpms                   = iga_crtc_dpms,
-    .save                   = iga1_crtc_save,
+    .save                   = iga_crtc_save,
     .restore                = iga1_crtc_restore,
     .lock                   = iga1_crtc_lock,
     .unlock                 = iga1_crtc_unlock,
@@ -3551,20 +3562,6 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .destroy                = iga_crtc_destroy,
 };
 
-static void
-iga2_crtc_save(xf86CrtcPtr crtc)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga2_crtc_save.\n"));
-
-    viaIGA2Save(pScrn);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga2_crtc_save.\n"));
-}
-
 static void
 iga2_crtc_restore(xf86CrtcPtr crtc)
 {
@@ -3735,7 +3732,7 @@ iga2_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 
 const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .dpms                   = iga_crtc_dpms,
-    .save                   = iga2_crtc_save,
+    .save                   = iga_crtc_save,
     .restore                = iga2_crtc_restore,
     .lock                   = iga2_crtc_lock,
     .unlock                 = iga2_crtc_unlock,
commit 3f362b2acbad44945167b2b36c7ed072ace38d21
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:43:49 2021 -0700

    Merge iga*_crtc_dpms() into iga_crtc_dpms()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 25d76a7..dc6ea71 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3080,28 +3080,44 @@ ViaShadowCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
 }
 
 static void
-iga1_crtc_dpms(xf86CrtcPtr crtc, int mode)
+iga_crtc_dpms(xf86CrtcPtr crtc, int mode)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga1_crtc_dpms.\n"));
+                        "Entered %s.\n", __func__));
 
-    switch (mode) {
-    case DPMSModeOn:
-    case DPMSModeStandby:
-    case DPMSModeSuspend:
-        viaIGA1SetDisplayOutput(pScrn, TRUE);
-        break;
-    case DPMSModeOff:
-        viaIGA1SetDisplayOutput(pScrn, FALSE);
-        break;
-    default:
-        break;
+    if (!iga->index) {
+        switch (mode) {
+        case DPMSModeOn:
+        case DPMSModeStandby:
+        case DPMSModeSuspend:
+            viaIGA1SetDisplayOutput(pScrn, TRUE);
+            break;
+        case DPMSModeOff:
+            viaIGA1SetDisplayOutput(pScrn, FALSE);
+            break;
+        default:
+            break;
+        }
+    } else {
+        switch (mode) {
+        case DPMSModeOn:
+            viaIGA2SetDisplayOutput(pScrn, TRUE);
+            break;
+        case DPMSModeStandby:
+        case DPMSModeSuspend:
+        case DPMSModeOff:
+            viaIGA2SetDisplayOutput(pScrn, FALSE);
+            break;
+        default:
+            break;
+        }
     }
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga1_crtc_dpms.\n"));
+                        "Exiting %s.\n", __func__));
 }
 
 static void
@@ -3511,7 +3527,7 @@ iga_crtc_destroy(xf86CrtcPtr crtc)
 }
 
 const xf86CrtcFuncsRec iga1_crtc_funcs = {
-    .dpms                   = iga1_crtc_dpms,
+    .dpms                   = iga_crtc_dpms,
     .save                   = iga1_crtc_save,
     .restore                = iga1_crtc_restore,
     .lock                   = iga1_crtc_lock,
@@ -3535,34 +3551,6 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .destroy                = iga_crtc_destroy,
 };
 
-static void
-iga2_crtc_dpms(xf86CrtcPtr crtc, int mode)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga2_crtc_dpms.\n"));
-
-    switch (mode) {
-    case DPMSModeOn:
-        viaIGA2SetDisplayOutput(pScrn, TRUE);
-        break;
-    case DPMSModeStandby:
-    case DPMSModeSuspend:
-    case DPMSModeOff:
-        viaIGA2SetDisplayOutput(pScrn, FALSE);
-        break;
-    default:
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode: %d\n",
-                    mode);
-        break;
-    }
-    //vgaHWSaveScreen(pScrn->pScreen, mode);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga2_crtc_dpms.\n"));
-}
-
 static void
 iga2_crtc_save(xf86CrtcPtr crtc)
 {
@@ -3746,7 +3734,7 @@ iga2_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 }
 
 const xf86CrtcFuncsRec iga2_crtc_funcs = {
-    .dpms                   = iga2_crtc_dpms,
+    .dpms                   = iga_crtc_dpms,
     .save                   = iga2_crtc_save,
     .restore                = iga2_crtc_restore,
     .lock                   = iga2_crtc_lock,
commit 53eed32f2f7b6d3f6fe1ea996bdb2a49d0a658ac
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:35:31 2021 -0700

    Merge iga*_crtc_commit() into iga_crtc_prepare()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 8b24c77..25d76a7 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3297,18 +3297,24 @@ iga_crtc_mode_set(xf86CrtcPtr crtc,
 }
 
 static void
-iga1_crtc_commit(xf86CrtcPtr crtc)
+iga_crtc_commit(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entering iga1_crtc_commit.\n"));
+                        "Entered %s.\n", __func__));
 
-    /* Turn on IGA1. */
-    viaIGA1SetDisplayOutput(pScrn, TRUE);
+    if (!iga->index) {
+        /* Turn on IGA1. */
+        viaIGA1SetDisplayOutput(pScrn, TRUE);
+    } else {
+        /* Turn on IGA2. */
+        viaIGA2SetDisplayOutput(pScrn, TRUE);
+    }
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga1_crtc_commit.\n"));
+                        "Exiting %s.\n", __func__));
 }
 
 static void
@@ -3513,7 +3519,7 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .mode_fixup             = iga1_crtc_mode_fixup,
     .prepare                = iga_crtc_prepare,
     .mode_set               = iga_crtc_mode_set,
-    .commit                 = iga1_crtc_commit,
+    .commit                 = iga_crtc_commit,
     .gamma_set              = iga1_crtc_gamma_set,
     .shadow_create          = iga1_crtc_shadow_create,
     .shadow_allocate        = iga1_crtc_shadow_allocate,
@@ -3662,21 +3668,6 @@ iga2_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
                         "Exiting iga2_crtc_set_origin.\n"));
 }
 
-static void
-iga2_crtc_commit(xf86CrtcPtr crtc)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entering iga2_crtc_commit.\n"));
-
-    /* Turn on IGA2. */
-    viaIGA2SetDisplayOutput(pScrn, TRUE);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga2_crtc_commit.\n"));
-}
-
 static void
 iga2_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
                     int size)
@@ -3763,7 +3754,7 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .mode_fixup             = iga2_crtc_mode_fixup,
     .prepare                = iga_crtc_prepare,
     .mode_set               = iga_crtc_mode_set,
-    .commit                 = iga2_crtc_commit,
+    .commit                 = iga_crtc_commit,
     .gamma_set              = iga2_crtc_gamma_set,
     .shadow_create          = iga2_crtc_shadow_create,
     .shadow_allocate        = iga2_crtc_shadow_allocate,
commit 96d8ae76a577ce1ac7297cdd8d49dc88da8e2da5
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:33:39 2021 -0700

    Merge iga*_crtc_prepare() into iga_crtc_prepare()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 34bd08a..8b24c77 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3183,18 +3183,24 @@ iga1_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
 }
 
 static void
-iga1_crtc_prepare(xf86CrtcPtr crtc)
+iga_crtc_prepare(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga1_crtc_prepare.\n"));
+                        "Entered %s.\n", __func__));
 
-    /* Turn off IGA1. */
-    viaIGA1SetDisplayOutput(pScrn, FALSE);
+    if (!iga->index) {
+        /* Turn off IGA1. */
+        viaIGA1SetDisplayOutput(pScrn, FALSE);
+    } else {
+        /* Turn off IGA2. */
+        viaIGA2SetDisplayOutput(pScrn, FALSE);
+    }
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga1_crtc_prepare.\n"));
+                        "Exiting %s.\n", __func__));
 }
 
 static void
@@ -3505,7 +3511,7 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .lock                   = iga1_crtc_lock,
     .unlock                 = iga1_crtc_unlock,
     .mode_fixup             = iga1_crtc_mode_fixup,
-    .prepare                = iga1_crtc_prepare,
+    .prepare                = iga_crtc_prepare,
     .mode_set               = iga_crtc_mode_set,
     .commit                 = iga1_crtc_commit,
     .gamma_set              = iga1_crtc_gamma_set,
@@ -3641,21 +3647,6 @@ iga2_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
     return TRUE;
 }
 
-static void
-iga2_crtc_prepare(xf86CrtcPtr crtc)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga2_crtc_prepare.\n"));
-
-    /* Turn off IGA2. */
-    viaIGA2SetDisplayOutput(pScrn, FALSE);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga2_crtc_prepare.\n"));
-}
-
 static void
 iga2_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
 {
@@ -3770,7 +3761,7 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .lock                   = iga2_crtc_lock,
     .unlock                 = iga2_crtc_unlock,
     .mode_fixup             = iga2_crtc_mode_fixup,
-    .prepare                = iga2_crtc_prepare,
+    .prepare                = iga_crtc_prepare,
     .mode_set               = iga_crtc_mode_set,
     .commit                 = iga2_crtc_commit,
     .gamma_set              = iga2_crtc_gamma_set,
commit b88cd9e1d835d0d6428508d0f115b9539a5695bb
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:33:22 2021 -0700

    Use a conditional operator for selecting IGA1 interlace mode
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index e2971a4..34bd08a 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -1207,11 +1207,11 @@ viaIGA1SetDisplayRegister(ScrnInfoPtr pScrn, DisplayModePtr mode)
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                 "IGA1 Requested Screen Mode: %s\n", mode->name);
 
-    if (mode->Flags & V_CLKDIV2) {
-        ViaSeqMask(hwp, 0x01, 0x08, 0x08);
-    } else {
-        ViaSeqMask(hwp, 0x01, 0x00, 0x08);
-    }
+    /* Interlace mode selection for IGA1. */
+    /* 3C5.01[3] - First Display Interlace Mode
+     *             0: Off
+     *             1: On */
+    ViaSeqMask(hwp, 0x01, (mode->Flags & V_CLKDIV2) ? BIT(3) : 0x00, BIT(3));
 
     ViaCrtcMask(hwp, 0x03, 0x80, 0x80); /* enable vertical retrace access */
 
commit ca2d3e7cfd7434522163f5d6252f23435067eb9d
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:32:59 2021 -0700

    Make IGA2 able to use interlace mode
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index d92c137..e2971a4 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -2366,11 +2366,11 @@ viaIGA2SetDisplayRegister(ScrnInfoPtr pScrn, DisplayModePtr mode)
         ViaCrtcMask(hwp, 0x62, 0x00, 0x01);
     }
 
-    /* Keep interlace mode off. */
+    /* Interlace mode selection for IGA2. */
     /* 3X5.67[5] - Second Display Interlace Mode
      *             0: Off
      *             1: On */
-    ViaCrtcMask(hwp, 0x67, 0x00, 0x20);
+    ViaCrtcMask(hwp, 0x67, (mode->Flags & V_CLKDIV2) ? BIT(5) : 0x00, BIT(5));
 
 
     /* Set IGA2 horizontal total pixels.*/
commit 983dce6d263f66eaf19510159cc6bb7c664642c4
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:32:40 2021 -0700

    Stop clearing a bit IGA2 uses from IGA1 mode setting code path
    
    CR6B[0] is used only by VX900 chipset for setting IGA2 Horizontal
    Blanking Start Bit [11].  Obviously, IGA1 mode setting code path
    should never be touching it in the first place.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 8ff1ffd..d92c137 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3219,7 +3219,6 @@ iga_crtc_mode_set(xf86CrtcPtr crtc,
 {
     ScrnInfoPtr pScrn = crtc->scrn;
     drmmode_crtc_private_ptr iga = crtc->driver_private;
-    vgaHWPtr hwp = VGAHWPTR(pScrn);
     VIAPtr pVia = VIAPTR(pScrn);
     VIADisplayPtr pVIADisplay = pVia->pVIADisplay;
 
@@ -3247,7 +3246,6 @@ iga_crtc_mode_set(xf86CrtcPtr crtc,
         pVIADisplay->ClockExternal = FALSE;
         ViaSetPrimaryDotclock(pScrn, pVIADisplay->Clock);
         viaSetUseExternalClock(pScrn);
-        ViaCrtcMask(hwp, 0x6B, 0x00, 0x01);
 
         viaIGA1SetFBStartingAddress(crtc, x, y);
         VIAVidAdjustFrame(pScrn, x, y);
commit 45708f1d14157b7be29da989ed4b0f8d472f9519
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:32:21 2021 -0700

    Rename ViaSetUseExternalClock() to viaSetUseExternalClock()
    
    Make minor adjustments like changing its input parameter.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 9c07154..8ff1ffd 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3246,7 +3246,7 @@ iga_crtc_mode_set(xf86CrtcPtr crtc,
         pVIADisplay->Clock = ViaModeDotClockTranslate(pScrn, adjusted_mode);
         pVIADisplay->ClockExternal = FALSE;
         ViaSetPrimaryDotclock(pScrn, pVIADisplay->Clock);
-        ViaSetUseExternalClock(hwp);
+        viaSetUseExternalClock(pScrn);
         ViaCrtcMask(hwp, 0x6B, 0x00, 0x01);
 
         viaIGA1SetFBStartingAddress(crtc, x, y);
@@ -3276,7 +3276,7 @@ iga_crtc_mode_set(xf86CrtcPtr crtc,
         pVIADisplay->Clock = ViaModeDotClockTranslate(pScrn, adjusted_mode);
         pVIADisplay->ClockExternal = FALSE;
         ViaSetSecondaryDotclock(pScrn, pVIADisplay->Clock);
-        ViaSetUseExternalClock(hwp);
+        viaSetUseExternalClock(pScrn);
 
         viaIGA2SetFBStartingAddress(crtc, x, y);
         VIAVidAdjustFrame(pScrn, x, y);
diff --git a/src/via_outputs.c b/src/via_outputs.c
index 6641b7d..84d5f28 100644
--- a/src/via_outputs.c
+++ b/src/via_outputs.c
@@ -156,15 +156,19 @@ ViaGetMemoryBandwidth(ScrnInfoPtr pScrn)
  * Needs to be called to reset the dotclock (after SR40:2/1 reset)
  */
 void
-ViaSetUseExternalClock(vgaHWPtr hwp)
+viaSetUseExternalClock(ScrnInfoPtr pScrn)
 {
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
     CARD8 data;
 
-    DEBUG(xf86DrvMsg(hwp->pScrn->scrnIndex, X_INFO,
-                     "ViaSetUseExternalClock\n"));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered %s.\n", __func__));
 
     data = hwp->readMiscOut(hwp);
     hwp->writeMiscOut(hwp, data | 0x0C);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting %s.\n", __func__));
 }
 
 /*
diff --git a/src/via_ums.h b/src/via_ums.h
index 175a748..ef3a856 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -1602,10 +1602,10 @@ Bool xf86I2CMaskByte(I2CDevPtr d, I2CByte subaddr,
 /* via_output.c */
 void viaInitDisplay(ScrnInfoPtr pScrn);
 CARD32 ViaGetMemoryBandwidth(ScrnInfoPtr pScrn);
+void viaSetUseExternalClock(ScrnInfoPtr pScrn);
 CARD32 ViaModeDotClockTranslate(ScrnInfoPtr pScrn, DisplayModePtr mode);
 void ViaSetPrimaryDotclock(ScrnInfoPtr pScrn, CARD32 clock);
 void ViaSetSecondaryDotclock(ScrnInfoPtr pScrn, CARD32 clock);
-void ViaSetUseExternalClock(vgaHWPtr hwp);
 
 /* via_display.c */
 void ViaGammaDisable(ScrnInfoPtr pScrn);
commit c9973cbee745f32d6e6954553d62f557ef3ae8b1
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:32:03 2021 -0700

    Make viaIGA2DisplayChannel() into an inline function
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 026fe85..9c07154 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -290,28 +290,6 @@ viaIGA1SetHIDisplayLocation(ScrnInfoPtr pScrn,
     }
 }
 
-/*
- * Controls IGA2 display channel state.
- */
-void
-viaIGA2DisplayChannel(ScrnInfoPtr pScrn, Bool channelState)
-{
-    vgaHWPtr hwp = VGAHWPTR(pScrn);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered viaIGA2DisplayChannel.\n"));
-
-    /* 3X5.6A[7] - Second Display Channel Enable */
-    ViaCrtcMask(hwp, 0x6A, channelState << 7, 0x80);
-
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                "IGA2 Display Channel: %s\n",
-                channelState ? "On" : "Off");
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting viaIGA2DisplayChannel.\n"));
-}
-
 /*
  * Sets IGA2 color depth.
  */
diff --git a/src/via_ums.h b/src/via_ums.h
index aed7cb5..175a748 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -460,6 +460,21 @@ viaIGA2SetDisplayOutput(ScrnInfoPtr pScrn, Bool outputState)
                         outputState ? "On" : "Off"));
 }
 
+/*
+ * Controls IGA2 display channel state.
+ */
+static inline void
+viaIGA2DisplayChannel(ScrnInfoPtr pScrn, Bool channelState)
+{
+    /* 3X5.6A[7] - Second Display Channel Enable */
+    ViaCrtcMask(VGAHWPTR(pScrn), 0x6A,
+                channelState ? BIT(7) : 0x00, BIT(7));
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "IGA2 Display Channel: %s\n",
+                        channelState ? "On" : "Off"));
+}
+
 /*
  * Sets DIP0 (Digital Interface Port 0) I/O pad state.
  * CLE266 chipset only.
@@ -1593,7 +1608,6 @@ void ViaSetSecondaryDotclock(ScrnInfoPtr pScrn, CARD32 clock);
 void ViaSetUseExternalClock(vgaHWPtr hwp);
 
 /* via_display.c */
-void viaIGA2DisplayChannel(ScrnInfoPtr pScrn, Bool channelState);
 void ViaGammaDisable(ScrnInfoPtr pScrn);
 void viaIGAInitCommon(ScrnInfoPtr pScrn);
 void viaIGA1Init(ScrnInfoPtr pScrn);
commit d882e6863aa87641520b21f7de0bfd5544b2cbb4
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:31:22 2021 -0700

    Merge iga*_crtc_mode_set() into iga_crtc_mode_set()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 5664827..026fe85 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3235,48 +3235,83 @@ iga1_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
 }
 
 static void
-iga1_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
-                    DisplayModePtr adjusted_mode,
+iga_crtc_mode_set(xf86CrtcPtr crtc,
+                    DisplayModePtr mode, DisplayModePtr adjusted_mode,
                     int x, int y)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    drmmode_crtc_private_ptr iga = crtc->driver_private;
     vgaHWPtr hwp = VGAHWPTR(pScrn);
     VIAPtr pVia = VIAPTR(pScrn);
     VIADisplayPtr pVIADisplay = pVia->pVIADisplay;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga1_crtc_mode_set.\n"));
+                        "Entered %s.\n", __func__));
 
-    /* Put IGA1 into a reset state. */
-    viaIGA1HWReset(pScrn, TRUE);
+    if (!iga->index) {
+        /* Put IGA1 into a reset state. */
+        viaIGA1HWReset(pScrn, TRUE);
 
-    viaIGAInitCommon(pScrn);
-    viaIGA1Init(pScrn);
+        viaIGAInitCommon(pScrn);
+        viaIGA1Init(pScrn);
 
-    ViaPrintMode(pScrn, adjusted_mode);
+        ViaPrintMode(pScrn, adjusted_mode);
 
-    /* Set color depth. */
-    viaIGA1SetColorDepth(pScrn, pScrn->bitsPerPixel);
+        /* Set color depth. */
+        viaIGA1SetColorDepth(pScrn, pScrn->bitsPerPixel);
 
-    /* Set display controller screen parameters. */
-    viaIGA1SetDisplayRegister(pScrn, adjusted_mode);
+        /* Set display controller screen parameters. */
+        viaIGA1SetDisplayRegister(pScrn, adjusted_mode);
 
-    ViaSetPrimaryFIFO(pScrn, adjusted_mode);
+        ViaSetPrimaryFIFO(pScrn, adjusted_mode);
 
-    pVIADisplay->Clock = ViaModeDotClockTranslate(pScrn, adjusted_mode);
-    pVIADisplay->ClockExternal = FALSE;
-    ViaSetPrimaryDotclock(pScrn, pVIADisplay->Clock);
-    ViaSetUseExternalClock(hwp);
-    ViaCrtcMask(hwp, 0x6B, 0x00, 0x01);
+        pVIADisplay->Clock = ViaModeDotClockTranslate(pScrn, adjusted_mode);
+        pVIADisplay->ClockExternal = FALSE;
+        ViaSetPrimaryDotclock(pScrn, pVIADisplay->Clock);
+        ViaSetUseExternalClock(hwp);
+        ViaCrtcMask(hwp, 0x6B, 0x00, 0x01);
 
-    viaIGA1SetFBStartingAddress(crtc, x, y);
-    VIAVidAdjustFrame(pScrn, x, y);
+        viaIGA1SetFBStartingAddress(crtc, x, y);
+        VIAVidAdjustFrame(pScrn, x, y);
+
+        /* Put IGA1 back into a normal operating state. */
+        viaIGA1HWReset(pScrn, FALSE);
+    } else {
+        /* Put IGA2 into a reset state. */
+        viaIGA2HWReset(pScrn, TRUE);
+
+        /* Disable IGA2 display channel. */
+        viaIGA2DisplayChannel(pScrn, FALSE);
+
+        viaIGAInitCommon(pScrn);
+        viaIGA2Init(pScrn);
+
+        ViaPrintMode(pScrn, adjusted_mode);
+
+        /* Set color depth. */
+        viaIGA2SetColorDepth(pScrn, pScrn->bitsPerPixel);
 
-    /* Put IGA1 back into a normal operating state. */
-    viaIGA1HWReset(pScrn, FALSE);
+        /* Set display controller screen parameters. */
+        viaIGA2SetDisplayRegister(pScrn, adjusted_mode);
+
+        ViaSetSecondaryFIFO(pScrn, adjusted_mode);
+        pVIADisplay->Clock = ViaModeDotClockTranslate(pScrn, adjusted_mode);
+        pVIADisplay->ClockExternal = FALSE;
+        ViaSetSecondaryDotclock(pScrn, pVIADisplay->Clock);
+        ViaSetUseExternalClock(hwp);
+
+        viaIGA2SetFBStartingAddress(crtc, x, y);
+        VIAVidAdjustFrame(pScrn, x, y);
+
+        /* Enable IGA2 display channel. */
+        viaIGA2DisplayChannel(pScrn, TRUE);
+
+        /* Put IGA2 back into a normal operating state. */
+        viaIGA2HWReset(pScrn, FALSE);
+    }
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga1_crtc_mode_set.\n"));
+                        "Exiting %s.\n", __func__));
 }
 
 static void
@@ -3495,7 +3530,7 @@ const xf86CrtcFuncsRec iga1_crtc_funcs = {
     .unlock                 = iga1_crtc_unlock,
     .mode_fixup             = iga1_crtc_mode_fixup,
     .prepare                = iga1_crtc_prepare,
-    .mode_set               = iga1_crtc_mode_set,
+    .mode_set               = iga_crtc_mode_set,
     .commit                 = iga1_crtc_commit,
     .gamma_set              = iga1_crtc_gamma_set,
     .shadow_create          = iga1_crtc_shadow_create,
@@ -3660,54 +3695,6 @@ iga2_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
                         "Exiting iga2_crtc_set_origin.\n"));
 }
 
-static void
-iga2_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
-                    DisplayModePtr adjusted_mode, int x, int y)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-    vgaHWPtr hwp = VGAHWPTR(pScrn);
-    VIAPtr pVia = VIAPTR(pScrn);
-    VIADisplayPtr pVIADisplay = pVia->pVIADisplay;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered iga2_crtc_mode_set.\n"));
-
-    /* Put IGA2 into a reset state. */
-    viaIGA2HWReset(pScrn, TRUE);
-
-    /* Disable IGA2 display channel. */
-    viaIGA2DisplayChannel(pScrn, FALSE);
-
-    viaIGAInitCommon(pScrn);
-    viaIGA2Init(pScrn);
-
-    ViaPrintMode(pScrn, adjusted_mode);
-
-    /* Set color depth. */
-    viaIGA2SetColorDepth(pScrn, pScrn->bitsPerPixel);
-
-    /* Set display controller screen parameters. */
-    viaIGA2SetDisplayRegister(pScrn, adjusted_mode);
-
-    ViaSetSecondaryFIFO(pScrn, adjusted_mode);
-    pVIADisplay->Clock = ViaModeDotClockTranslate(pScrn, adjusted_mode);
-    pVIADisplay->ClockExternal = FALSE;
-    ViaSetSecondaryDotclock(pScrn, pVIADisplay->Clock);
-    ViaSetUseExternalClock(hwp);
-
-    viaIGA2SetFBStartingAddress(crtc, x, y);
-    VIAVidAdjustFrame(pScrn, x, y);
-
-    /* Enable IGA2 display channel. */
-    viaIGA2DisplayChannel(pScrn, TRUE);
-
-    /* Put IGA2 back into a normal operating state. */
-    viaIGA2HWReset(pScrn, FALSE);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting iga2_crtc_mode_set.\n"));
-}
-
 static void
 iga2_crtc_commit(xf86CrtcPtr crtc)
 {
@@ -3808,7 +3795,7 @@ const xf86CrtcFuncsRec iga2_crtc_funcs = {
     .unlock                 = iga2_crtc_unlock,
     .mode_fixup             = iga2_crtc_mode_fixup,
     .prepare                = iga2_crtc_prepare,
-    .mode_set               = iga2_crtc_mode_set,
+    .mode_set               = iga_crtc_mode_set,
     .commit                 = iga2_crtc_commit,
     .gamma_set              = iga2_crtc_gamma_set,
     .shadow_create          = iga2_crtc_shadow_create,
commit 4fe8ffa98aedb631e696c25af1b0bbdd81ddd375
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:31:07 2021 -0700

    No longer call vgaHWInit() from iga1_crtc_mode_set()
    
    It is not clear why vgaHWInit() needs to be called.
    iga2_crtc_mode_set() does not do this.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index d6a6bbd..5664827 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3250,12 +3250,6 @@ iga1_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
     /* Put IGA1 into a reset state. */
     viaIGA1HWReset(pScrn, TRUE);
 
-    if (!vgaHWInit(pScrn, adjusted_mode)) {
-        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                            "vgaHWInit failed.\n"));
-        goto exit;
-    }
-
     viaIGAInitCommon(pScrn);
     viaIGA1Init(pScrn);
 
@@ -3278,7 +3272,6 @@ iga1_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
     viaIGA1SetFBStartingAddress(crtc, x, y);
     VIAVidAdjustFrame(pScrn, x, y);
 
-exit:
     /* Put IGA1 back into a normal operating state. */
     viaIGA1HWReset(pScrn, FALSE);
 
commit 0f9fd9feae11ccf9177901e0188f8343dddfbc2b
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:30:52 2021 -0700

    Use Bool type for viaIGA2HWReset()
    
    Matching the behavior of viaIGA1HWReset().
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index c00446a..d6a6bbd 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -3680,7 +3680,7 @@ iga2_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
                         "Entered iga2_crtc_mode_set.\n"));
 
     /* Put IGA2 into a reset state. */
-    viaIGA2HWReset(pScrn, 0x00);
+    viaIGA2HWReset(pScrn, TRUE);
 
     /* Disable IGA2 display channel. */
     viaIGA2DisplayChannel(pScrn, FALSE);
@@ -3709,7 +3709,7 @@ iga2_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
     viaIGA2DisplayChannel(pScrn, TRUE);
 
     /* Put IGA2 back into a normal operating state. */
-    viaIGA2HWReset(pScrn, 0x01);
+    viaIGA2HWReset(pScrn, FALSE);
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Exiting iga2_crtc_mode_set.\n"));
diff --git a/src/via_ums.h b/src/via_ums.h
index cb6d899..aed7cb5 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -385,15 +385,15 @@ viaIGA1HWReset(ScrnInfoPtr pScrn, Bool resetState)
  * Resets IGA2 hardware.
  */
 static inline void
-viaIGA2HWReset(ScrnInfoPtr pScrn, CARD8 resetState)
+viaIGA2HWReset(ScrnInfoPtr pScrn, Bool resetState)
 {
     /* 3X5.6A[6] - Second Display Channel Reset
      *             0: Reset
      *             1: Normal Operation */
-    ViaCrtcMask(VGAHWPTR(pScrn), 0x6A, resetState << 6, 0x40);
+    ViaCrtcMask(VGAHWPTR(pScrn), 0x6A, resetState ? 0x00 : BIT(6), BIT(6));
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "IGA2 HW Reset: %s\n",
-                        (resetState & 0x01) ? "Off" : "On"));
+                        resetState ? "On" : "Off"));
 }
 
 /*
commit ea57ca3b0e3a3edc7aa7a8fdd88ee586861fee98
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Fri May 28 12:30:37 2021 -0700

    Make viaIGA2HWReset() into an inline function
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_display.c b/src/via_display.c
index 8663ce6..c00446a 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -290,29 +290,6 @@ viaIGA1SetHIDisplayLocation(ScrnInfoPtr pScrn,
     }
 }
 
-/*
- * Resets IGA2 hardware.
- */
-static void
-viaIGA2HWReset(ScrnInfoPtr pScrn, CARD8 resetState)
-{
-    vgaHWPtr hwp = VGAHWPTR(pScrn);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered viaIGA2HWReset.\n"));
-
-    /* 3X5.6A[6] - Second Display Channel Reset
-     *             0: Reset
-     *             1: Normal Operation */
-    ViaCrtcMask(hwp, 0x6A, resetState << 6, 0x40);
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                "IGA2 HW Reset: %s\n",
-                (resetState & 0x01) ? "Off" : "On");
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting viaIGA2HWReset.\n"));
-}
-
 /*
  * Controls IGA2 display channel state.
  */
diff --git a/src/via_ums.h b/src/via_ums.h
index 03c6cbf..cb6d899 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -381,6 +381,21 @@ viaIGA1HWReset(ScrnInfoPtr pScrn, Bool resetState)
                         resetState ? "On" : "Off"));
 }
 
+/*
+ * Resets IGA2 hardware.
+ */
+static inline void
+viaIGA2HWReset(ScrnInfoPtr pScrn, CARD8 resetState)
+{
+    /* 3X5.6A[6] - Second Display Channel Reset
+     *             0: Reset
+     *             1: Normal Operation */
+    ViaCrtcMask(VGAHWPTR(pScrn), 0x6A, resetState << 6, 0x40);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "IGA2 HW Reset: %s\n",
+                        (resetState & 0x01) ? "Off" : "On"));
+}
+
 /*
  * Sets IGA1 palette LUT resolution. (6-bit or 8-bit)
  */


More information about the openchrome-devel mailing list