~ubuntu-branches/ubuntu/utopic/xserver-xorg-video-intel/utopic

« back to all changes in this revision

Viewing changes to src/sna/sna_driver.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-09-12 07:43:59 UTC
  • mfrom: (1.4.22)
  • Revision ID: package-import@ubuntu.com-20120912074359-i3h8ol6hoghbemoq
Tags: 2:2.20.7-0ubuntu1
Merge from unreleased debian git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
#include "git_version.h"
76
76
#endif
77
77
 
78
 
static DevPrivateKeyRec sna_pixmap_key;
79
 
static DevPrivateKeyRec sna_gc_key;
80
 
static DevPrivateKeyRec sna_glyph_key;
81
 
static DevPrivateKeyRec sna_window_key;
 
78
DevPrivateKeyRec sna_pixmap_key;
 
79
DevPrivateKeyRec sna_gc_key;
 
80
DevPrivateKeyRec sna_window_key;
 
81
DevPrivateKeyRec sna_glyph_key;
82
82
 
83
83
static Bool sna_enter_vt(VT_FUNC_ARGS_DECL);
84
84
 
226
226
        int fd;
227
227
        int open_count;
228
228
};
229
 
static int sna_device_key;
 
229
static int sna_device_key = -1;
230
230
 
231
231
static inline struct sna_device *sna_device(ScrnInfoPtr scrn)
232
232
{
 
233
        if (scrn->entityList == NULL)
 
234
                return NULL;
 
235
 
233
236
        return xf86GetEntityPrivate(scrn->entityList[0], sna_device_key)->ptr;
234
237
}
235
238
 
343
346
        return v > 0;
344
347
}
345
348
 
 
349
static void sna_setup_capabilities(ScrnInfoPtr scrn, int fd)
 
350
{
 
351
#if HAS_PIXMAP_SHARING && defined(DRM_CAP_PRIME)
 
352
        uint64_t value;
 
353
 
 
354
        scrn->capabilities = 0;
 
355
        if (drmGetCap(fd, DRM_CAP_PRIME, &value) == 0) {
 
356
                if (value & DRM_PRIME_CAP_EXPORT)
 
357
                        scrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SinkOffload;
 
358
                if (value & DRM_PRIME_CAP_IMPORT)
 
359
                        scrn->capabilities |= RR_Capability_SinkOutput;
 
360
        }
 
361
#endif
 
362
}
 
363
 
346
364
/**
347
365
 * This is called before ScreenInit to do any require probing of screen
348
366
 * configuration.
371
389
                return FALSE;
372
390
 
373
391
        pEnt = xf86GetEntityInfo(scrn->entityList[0]);
374
 
        if (pEnt == NULL || pEnt->location.type != BUS_PCI)
 
392
        if (pEnt == NULL)
 
393
                return FALSE;
 
394
 
 
395
        if (pEnt->location.type != BUS_PCI
 
396
#ifdef XSERVER_PLATFORM_BUS
 
397
            && pEnt->location.type != BUS_PLATFORM
 
398
#endif
 
399
                )
375
400
                return FALSE;
376
401
 
377
402
        if (flags & PROBE_DETECT)
435
460
        if (sna->Options == NULL)
436
461
                return FALSE;
437
462
 
 
463
        sna_setup_capabilities(scrn, fd);
 
464
 
438
465
        intel_detect_chipset(scrn, sna->pEnt, sna->PciInfo);
439
466
 
440
467
        kgem_init(&sna->kgem, fd, sna->PciInfo, sna->info->gen);
677
704
{
678
705
        SCRN_INFO_PTR(arg);
679
706
        struct sna *sna = to_sna(scrn);
680
 
        int ret;
681
707
 
682
708
        DBG(("%s\n", __FUNCTION__));
683
709
 
684
 
        xf86RotateFreeShadow(scrn);
685
710
        xf86_hide_cursors(scrn);
686
711
 
687
 
        ret = drmDropMaster(sna->kgem.fd);
688
 
        if (ret)
 
712
        if (drmDropMaster(sna->kgem.fd))
689
713
                xf86DrvMsg(scrn->scrnIndex, X_WARNING,
690
714
                           "drmDropMaster failed: %s\n", strerror(errno));
691
715
}
715
739
        if (sna_mode_has_pending_events(sna))
716
740
                sna_mode_wakeup(sna);
717
741
 
718
 
        if (scrn->vtSema == TRUE) {
719
 
                sna_leave_vt(VT_FUNC_ARGS(0));
720
 
                scrn->vtSema = FALSE;
721
 
        }
722
 
 
723
742
        if (sna->dri_open) {
724
743
                sna_dri_close(sna, screen);
725
744
                sna->dri_open = false;
726
745
        }
727
746
 
 
747
        xf86_hide_cursors(scrn);
 
748
        scrn->vtSema = FALSE;
 
749
 
728
750
        xf86_cursors_fini(screen);
729
751
 
730
752
        return TRUE;
745
767
        }
746
768
 
747
769
        sna_accel_close(sna);
 
770
        drmDropMaster(sna->kgem.fd);
748
771
 
749
772
        depths = screen->allowedDepths;
750
773
        for (d = 0; d < screen->numDepths; d++)
770
793
        if (!dixRegisterPrivateKey(&sna_pixmap_key, PRIVATE_PIXMAP,
771
794
                                   3*sizeof(void *)))
772
795
                return FALSE;
773
 
        assert(sna_pixmap_key.offset == 0);
774
796
 
775
797
        if (!dixRegisterPrivateKey(&sna_gc_key, PRIVATE_GC,
776
798
                                   sizeof(FbGCPrivate)))
777
799
                return FALSE;
778
 
        assert(sna_gc_key.offset == 0);
779
800
 
780
801
        if (!dixRegisterPrivateKey(&sna_glyph_key, PRIVATE_GLYPH,
781
802
                                   sizeof(struct sna_glyph)))
782
803
                return FALSE;
783
 
        assert(sna_glyph_key.offset == 0);
784
804
 
785
805
        if (!dixRegisterPrivateKey(&sna_window_key, PRIVATE_WINDOW,
786
806
                                   2*sizeof(void *)))
787
807
                return FALSE;
788
 
        assert(sna_window_key.offset == 0);
789
808
 
790
809
        return TRUE;
791
810
}
947
966
 
948
967
        DBG(("%s\n", __FUNCTION__));
949
968
 
950
 
        if (sna) {
 
969
        if (sna && ((intptr_t)sna & 1) == 0) {
951
970
                sna_mode_fini(sna);
952
 
 
953
971
                free(sna);
954
 
                scrn->driverPrivate = NULL;
955
972
        }
 
973
        scrn->driverPrivate = NULL;
956
974
 
957
975
        sna_close_drm_master(scrn);
958
976
}
1062
1080
 
1063
1081
Bool sna_init_scrn(ScrnInfoPtr scrn, int entity_num)
1064
1082
{
1065
 
        EntityInfoPtr entity;
1066
 
 
1067
1083
#if defined(USE_GIT_DESCRIBE)
1068
1084
        xf86DrvMsg(scrn->scrnIndex, X_INFO,
1069
1085
                   "SNA compiled from %s\n", git_version);
1087
1103
        DBG(("%s\n", __FUNCTION__));
1088
1104
        DBG(("pixman version: %s\n", pixman_version_string()));
1089
1105
 
1090
 
        sna_device_key = xf86AllocateEntityPrivateIndex();
 
1106
        if (sna_device_key == -1)
 
1107
                sna_device_key = xf86AllocateEntityPrivateIndex();
1091
1108
 
1092
1109
        scrn->PreInit = sna_pre_init;
1093
1110
        scrn->ScreenInit = sna_screen_init;
1101
1118
 
1102
1119
        scrn->ModeSet = sna_mode_set;
1103
1120
 
1104
 
        xf86SetEntitySharable(scrn->entityList[0]);
1105
 
 
1106
 
        entity = xf86GetEntityInfo(entity_num);
1107
 
        if (!entity)
1108
 
                return FALSE;
1109
 
 
1110
 
        xf86SetEntityInstanceForScreen(scrn,
1111
 
                                       entity->index,
1112
 
                                       xf86GetNumEntityInstances(entity->index)-1);
1113
 
        free(entity);
 
1121
        xf86SetEntitySharable(entity_num);
 
1122
        xf86SetEntityInstanceForScreen(scrn, entity_num,
 
1123
                                       xf86GetNumEntityInstances(entity_num)-1);
1114
1124
 
1115
1125
        return TRUE;
1116
1126
}