[cogl] kms: flatten setup_kms into _cogl_winsys_kms_display_setup



commit 7a91c91994f356a9c9dc6b55ba8fd885c4223b6a
Author: Robert Bragg <robert linux intel com>
Date:   Mon Nov 28 16:20:55 2011 +0000

    kms: flatten setup_kms into _cogl_winsys_kms_display_setup
    
    Since _cogl_winsys_kms_display_setup was basically just calling
    setup_kms() it made sense to fold the code of setup_kms() back into the
    _cogl_winsys_kms_display_setup() function.
    
    Reviewed-by: Rob Bradford <rob linux intel com>

 cogl/winsys/cogl-winsys-egl.c |    4 +-
 cogl/winsys/cogl-winsys-kms.c |  126 +++++++++++++++++++----------------------
 cogl/winsys/cogl-winsys-kms.h |    5 +-
 3 files changed, 61 insertions(+), 74 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 922e747..15d0d7a 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -1092,9 +1092,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
 #endif
 
 #ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
-  if (!_cogl_winsys_kms_display_setup (&egl_renderer->kms_renderer,
-                                       &egl_display->kms_display,
-                                       error))
+  if (!_cogl_winsys_kms_display_setup (display, error))
     goto error;
 #endif
 
diff --git a/cogl/winsys/cogl-winsys-kms.c b/cogl/winsys/cogl-winsys-kms.c
index b4f202b..51ec8d8 100644
--- a/cogl/winsys/cogl-winsys-kms.c
+++ b/cogl/winsys/cogl-winsys-kms.c
@@ -55,69 +55,6 @@
 
 static const char device_name[] = "/dev/dri/card0";
 
-static gboolean
-setup_kms (CoglRendererKMS *kms_renderer,
-           CoglDisplayKMS  *kms_display,
-           GError         **error)
-{
-  drmModeRes *resources;
-  drmModeConnector *connector;
-  drmModeEncoder *encoder;
-  int i;
-
-  resources = drmModeGetResources (kms_renderer->fd);
-  if (!resources)
-    {
-      g_set_error (error, COGL_WINSYS_ERROR,
-                   COGL_WINSYS_ERROR_INIT,
-                   "drmModeGetResources failed");
-      return FALSE;
-    }
-
-  for (i = 0; i < resources->count_connectors; i++)
-    {
-      connector = drmModeGetConnector (kms_renderer->fd, resources->connectors[i]);
-      if (connector == NULL)
-        continue;
-
-      if (connector->connection == DRM_MODE_CONNECTED &&
-          connector->count_modes > 0)
-        break;
-
-      drmModeFreeConnector(connector);
-    }
-
-  if (i == resources->count_connectors)
-    {
-      g_set_error (error, COGL_WINSYS_ERROR,
-                   COGL_WINSYS_ERROR_INIT,
-                   "No currently active connector found");
-      return FALSE;
-    }
-
-  for (i = 0; i < resources->count_encoders; i++)
-    {
-      encoder = drmModeGetEncoder (kms_renderer->fd, resources->encoders[i]);
-
-      if (encoder == NULL)
-        continue;
-
-      if (encoder->encoder_id == connector->encoder_id)
-        break;
-
-      drmModeFreeEncoder (encoder);
-    }
-
-  kms_display->saved_crtc = drmModeGetCrtc (kms_renderer->fd,
-                                            kms_display->encoder->crtc_id);
-
-  kms_display->connector = connector;
-  kms_display->encoder = encoder;
-  kms_display->mode = connector->modes[0];
-
-  return TRUE;
-}
-
 gboolean
 _cogl_winsys_kms_connect (CoglRendererKMS  *kms_renderer,
                           GError          **error)
@@ -172,13 +109,66 @@ close_fd:
 }
 
 gboolean
-_cogl_winsys_kms_display_setup (CoglRendererKMS *kms_renderer,
-                                CoglDisplayKMS  *kms_display,
-                                GError         **error)
+_cogl_winsys_kms_display_setup (CoglDisplay *display, GError **error)
 {
-  if (!setup_kms (kms_renderer, kms_display, error))
-    return FALSE;
+  CoglDisplayEGL *egl_display = display->winsys;
+  CoglDisplayKMS *kms_display = &egl_display->kms_display;
+  CoglRendererEGL *egl_renderer = display->renderer->winsys;
+  CoglRendererKMS *kms_renderer = &egl_renderer->kms_renderer;
+  drmModeRes *resources;
+  drmModeConnector *connector;
+  drmModeEncoder *encoder;
+  int i;
+
+  resources = drmModeGetResources (kms_renderer->fd);
+  if (!resources)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR,
+                   COGL_WINSYS_ERROR_INIT,
+                   "drmModeGetResources failed");
+      return FALSE;
+    }
+
+  for (i = 0; i < resources->count_connectors; i++)
+    {
+      connector = drmModeGetConnector (kms_renderer->fd, resources->connectors[i]);
+      if (connector == NULL)
+        continue;
+
+      if (connector->connection == DRM_MODE_CONNECTED &&
+          connector->count_modes > 0)
+        break;
+
+      drmModeFreeConnector(connector);
+    }
+
+  if (i == resources->count_connectors)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR,
+                   COGL_WINSYS_ERROR_INIT,
+                   "No currently active connector found");
+      return FALSE;
+    }
+
+  for (i = 0; i < resources->count_encoders; i++)
+    {
+      encoder = drmModeGetEncoder (kms_renderer->fd, resources->encoders[i]);
+
+      if (encoder == NULL)
+        continue;
+
+      if (encoder->encoder_id == connector->encoder_id)
+        break;
+
+      drmModeFreeEncoder (encoder);
+    }
+
+  kms_display->saved_crtc = drmModeGetCrtc (kms_renderer->fd,
+                                            kms_display->encoder->crtc_id);
 
+  kms_display->connector = connector;
+  kms_display->encoder = encoder;
+  kms_display->mode = connector->modes[0];
   kms_display->width = kms_display->mode.hdisplay;
   kms_display->height = kms_display->mode.vdisplay;
 
diff --git a/cogl/winsys/cogl-winsys-kms.h b/cogl/winsys/cogl-winsys-kms.h
index c6c7de1..519f8a1 100644
--- a/cogl/winsys/cogl-winsys-kms.h
+++ b/cogl/winsys/cogl-winsys-kms.h
@@ -78,9 +78,8 @@ _cogl_winsys_kms_onscreen_deinit (CoglRendererKMS *kms_renderer,
                                   CoglOnscreenKMS *kms_onscreen);
 
 gboolean
-_cogl_winsys_kms_display_setup (CoglRendererKMS *kms_renderer,
-                                CoglDisplayKMS  *kms_display,
-                                GError         **error);
+_cogl_winsys_kms_display_setup (CoglDisplay  *display,
+                                GError      **error);
 
 void
 _cogl_winsys_kms_swap_buffers (CoglRendererKMS *kms_renderer,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]