sna: Disable all outputs when initializing as a slaved output provider
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 23 Jul 2014 09:53:40 +0000 (10:53 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 23 Jul 2014 10:04:54 +0000 (11:04 +0100)
When we are constructed as a slaved device, we need to disable all
outputs or else they are not correctly hooked into the master device
upon startup.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/intel_module.c
src/sna/sna.h
src/sna/sna_display.c
src/sna/sna_driver.c
src/uxa/intel_driver.c

index c884603..969f2a7 100644 (file)
@@ -543,7 +543,7 @@ intel_scrn_create(DriverPtr         driver,
        scrn->driverVersion = INTEL_VERSION;
        scrn->driverName = (char *)INTEL_DRIVER_NAME;
        scrn->name = (char *)INTEL_NAME;
-       scrn->driverPrivate = (void *)(match_data | 1);
+       scrn->driverPrivate = (void *)(match_data | (flags & XF86_ALLOCATE_GPU_SCREEN) | 2);
        scrn->Probe = NULL;
 
        if (xf86IsEntitySharable(entity_num))
index 6e70c56..281418b 100644 (file)
@@ -241,17 +241,18 @@ struct sna {
        ScrnInfoPtr scrn;
 
        unsigned flags;
-#define SNA_NO_WAIT            0x1
-#define SNA_NO_FLIP            0x2
-#define SNA_NO_VSYNC           0x4
-#define SNA_TRIPLE_BUFFER      0x8
-#define SNA_TEAR_FREE          0x10
-#define SNA_FORCE_SHADOW       0x20
-#define SNA_FLUSH_GTT          0x40
-#define SNA_IS_HOSTED          0x80
-#define SNA_PERFORMANCE                0x100
-#define SNA_POWERSAVE          0x200
-#define SNA_REMOVE_OUTPUTS     0x400
+#define SNA_IS_SLAVED          0x1
+#define SNA_IS_HOSTED          0x2
+#define SNA_NO_WAIT            0x10
+#define SNA_NO_FLIP            0x20
+#define SNA_NO_VSYNC           0x40
+#define SNA_TRIPLE_BUFFER      0x80
+#define SNA_TEAR_FREE          0x100
+#define SNA_FORCE_SHADOW       0x200
+#define SNA_FLUSH_GTT          0x400
+#define SNA_PERFORMANCE                0x1000
+#define SNA_POWERSAVE          0x2000
+#define SNA_REMOVE_OUTPUTS     0x4000
 #define SNA_HAS_FLIP           0x10000
 #define SNA_HAS_ASYNC_FLIP     0x20000
 #define SNA_LINEAR_FB          0x40000
index af884c4..6952d55 100644 (file)
@@ -5189,36 +5189,38 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 {
        ScrnInfoPtr scrn = sna->scrn;
        xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
-       const int user_overrides[] = {
-               OPTION_POSITION,
-               OPTION_BELOW,
-               OPTION_RIGHT_OF,
-               OPTION_ABOVE,
-               OPTION_LEFT_OF,
-               OPTION_ROTATE,
-               OPTION_PANNING,
-       };
        int width, height;
        int i, j;
 
        assert((sna->flags & SNA_IS_HOSTED) == 0);
 
-       if (xf86ReturnOptValBool(sna->Options, OPTION_REPROBE, FALSE)) {
-               DBG(("%s: user requests reprobing\n", __FUNCTION__));
-               return false;
-       }
+       if ((sna->flags & SNA_IS_SLAVED) == 0) {
+               const int user_overrides[] = {
+                       OPTION_POSITION,
+                       OPTION_BELOW,
+                       OPTION_RIGHT_OF,
+                       OPTION_ABOVE,
+                       OPTION_LEFT_OF,
+                       OPTION_ROTATE,
+                       OPTION_PANNING,
+               };
+               if (xf86ReturnOptValBool(sna->Options, OPTION_REPROBE, FALSE)) {
+                       DBG(("%s: user requests reprobing\n", __FUNCTION__));
+                       return false;
+               }
 
-       /* First scan through all outputs and look for user overrides */
-       for (i = 0; i < sna->mode.num_real_output; i++) {
-               xf86OutputPtr output = config->output[i];
+               /* First scan through all outputs and look for user overrides */
+               for (i = 0; i < sna->mode.num_real_output; i++) {
+                       xf86OutputPtr output = config->output[i];
 
-               for (j = 0; j < ARRAY_SIZE(user_overrides); j++) {
-                       if (xf86GetOptValString(output->options, user_overrides[j])) {
-                               DBG(("%s: user placement [%d] for %s\n",
-                                    __FUNCTION__,
-                                    user_overrides[j],
-                                    output->name));
-                               return false;
+                       for (j = 0; j < ARRAY_SIZE(user_overrides); j++) {
+                               if (xf86GetOptValString(output->options, user_overrides[j])) {
+                                       DBG(("%s: user placement [%d] for %s\n",
+                                            __FUNCTION__,
+                                            user_overrides[j],
+                                            output->name));
+                                       return false;
+                               }
                        }
                }
        }
@@ -5263,6 +5265,8 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 
                crtc_id = (uintptr_t)output->crtc;
                output->crtc = NULL;
+               if (sna->flags & SNA_IS_SLAVED)
+                       continue;
 
                if (crtc_id == 0) {
                        DBG(("%s: not using output %s, disconnected\n",
@@ -5331,7 +5335,7 @@ static bool sna_probe_initial_configuration(struct sna *sna)
        }
 
        width = height = 0;
-       for (i = 0; i < config->num_crtc; i++) {
+       for (i = 0; i < sna->mode.num_real_crtc; i++) {
                xf86CrtcPtr crtc = config->crtc[i];
                int w, h;
 
index e5e7783..7f4540d 100644 (file)
@@ -540,7 +540,7 @@ done:
  * As a result, we want to set up that server initialization once rather
  * that doing it per generation.
  */
-static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
+static Bool sna_pre_init(ScrnInfoPtr scrn, int probe)
 {
        struct sna *sna;
        char buf[1024];
@@ -550,7 +550,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
        int fd;
 
        DBG(("%s flags=%x, numEntities=%d\n",
-            __FUNCTION__, flags, scrn->numEntities));
+            __FUNCTION__, probe, scrn->numEntities));
 
        if (scrn->numEntities != 1)
                return FALSE;
@@ -566,17 +566,19 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
                )
                return FALSE;
 
-       if (flags & PROBE_DETECT)
+       if (probe & PROBE_DETECT)
                return TRUE;
 
        sna_selftest();
 
-       if (((uintptr_t)scrn->driverPrivate) & 1) {
+       probe = 0;
+       if (((uintptr_t)scrn->driverPrivate) & 3) {
                if (posix_memalign((void **)&sna, 4096, sizeof(*sna)))
                        return FALSE;
 
                memset(sna, 0, sizeof(*sna)); /* should be unnecessary */
-               sna->info = (void *)((uintptr_t)scrn->driverPrivate & ~1);
+               probe = (uintptr_t)scrn->driverPrivate & 1;
+               sna->info = (void *)((uintptr_t)scrn->driverPrivate & ~3);
                scrn->driverPrivate = sna;
 
                sna->cpu_features = sna_cpu_detect();
@@ -585,7 +587,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
        sna = to_sna(scrn);
        sna->scrn = scrn;
        sna->pEnt = pEnt;
-       sna->flags = 0;
+       sna->flags = probe;
 
        scrn->displayWidth = 640;       /* default it */
 
@@ -710,7 +712,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
        return TRUE;
 
 cleanup:
-       scrn->driverPrivate = (void *)((uintptr_t)sna->info | 1);
+       scrn->driverPrivate = (void *)((uintptr_t)sna->info | (sna->flags & SNA_IS_SLAVED) | 2);
        free(sna);
        return FALSE;
 }
@@ -1180,7 +1182,7 @@ static void sna_free_screen(FREE_SCREEN_ARGS_DECL)
        if ((uintptr_t)sna & 1)
                return;
 
-       scrn->driverPrivate = (void *)((uintptr_t)sna->info | 1);
+       scrn->driverPrivate = (void *)((uintptr_t)sna->info | (sna->flags & SNA_IS_SLAVED) | 2);
 
        sna_mode_fini(sna);
        sna_acpi_fini(sna);
index c73d831..a7ca906 100644 (file)
@@ -447,12 +447,12 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
        if (flags & PROBE_DETECT)
                return TRUE;
 
-       if (((uintptr_t)scrn->driverPrivate) & 1) {
+       if (((uintptr_t)scrn->driverPrivate) & 3) {
                intel = xnfcalloc(sizeof(*intel), 1);
                if (intel == NULL)
                        return FALSE;
 
-               intel->info = (void *)((uintptr_t)scrn->driverPrivate & ~1);
+               intel->info = (void *)((uintptr_t)scrn->driverPrivate & ~3);
                scrn->driverPrivate = intel;
        }
        intel = intel_get_screen_private(scrn);
@@ -1069,7 +1069,7 @@ static void I830FreeScreen(FREE_SCREEN_ARGS_DECL)
        SCRN_INFO_PTR(arg);
        intel_screen_private *intel = intel_get_screen_private(scrn);
 
-       if (intel && !((uintptr_t)intel & 1)) {
+       if (intel && !((uintptr_t)intel & 3)) {
                intel_mode_fini(intel);
                intel_bufmgr_fini(intel);
                intel_put_device(scrn);