diff options
author | Alan Hourihane <alanh@tungstengraphics.com> | 2008-05-28 15:55:36 +0100 |
---|---|---|
committer | Alan Hourihane <alanh@tungstengraphics.com> | 2008-05-28 15:55:36 +0100 |
commit | d0fa72447735a2288b2f492a27168d4aa42912b6 (patch) | |
tree | c337d35bf7a5cb4810585188bec78d8bd41726c9 | |
parent | b212306ae7bd3a79fb290a32ebd3952c2cba846d (diff) |
Run indent
-rw-r--r-- | src/crtc.c | 166 | ||||
-rw-r--r-- | src/driver.c | 1251 | ||||
-rw-r--r-- | src/driver.h | 68 | ||||
-rw-r--r-- | src/exa.c | 30 | ||||
-rw-r--r-- | src/output.c | 252 |
5 files changed, 890 insertions, 877 deletions
@@ -50,22 +50,22 @@ static void crtc_dpms(xf86CrtcPtr crtc, int mode) { - ScrnInfoPtr pScrn = crtc->scrn; - - switch (mode) { - case DPMSModeOn: - case DPMSModeStandby: - case DPMSModeSuspend: - break; - case DPMSModeOff: - break; - } + ScrnInfoPtr pScrn = crtc->scrn; + + switch (mode) { + case DPMSModeOn: + case DPMSModeStandby: + case DPMSModeSuspend: + break; + case DPMSModeOff: + break; + } } static Bool crtc_lock(xf86CrtcPtr crtc) { - return FALSE; + return FALSE; } static void @@ -87,43 +87,43 @@ static Bool crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode, DisplayModePtr adjusted_mode) { - return TRUE; + return TRUE; } static void crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, DisplayModePtr adjusted_mode, int x, int y) { - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); - modesettingPtr ms = modesettingPTR(crtc->scrn); - xf86OutputPtr output = config->output[config->compat_output]; - drmModeOutputPtr drm_output = output->driver_private; - drmModeCrtcPtr drm_crtc = crtc->driver_private; - struct drm_mode_modeinfo drm_mode; - - drm_mode.clock = mode->Clock; - drm_mode.hdisplay = mode->HDisplay; - drm_mode.hsync_start = mode->HSyncStart; - drm_mode.hsync_end = mode->HSyncEnd; - drm_mode.htotal = mode->HTotal; - drm_mode.vdisplay = mode->VDisplay; - drm_mode.vsync_start = mode->VSyncStart; - drm_mode.vsync_end = mode->VSyncEnd; - drm_mode.vtotal = mode->VTotal; - drm_mode.flags = mode->Flags; - drm_mode.hskew = mode->HSkew; - drm_mode.vscan = mode->VScan; - drm_mode.vrefresh = mode->VRefresh; - strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN); - - drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, - &drm_output->output_id, 1, &drm_mode); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); + modesettingPtr ms = modesettingPTR(crtc->scrn); + xf86OutputPtr output = config->output[config->compat_output]; + drmModeOutputPtr drm_output = output->driver_private; + drmModeCrtcPtr drm_crtc = crtc->driver_private; + struct drm_mode_modeinfo drm_mode; + + drm_mode.clock = mode->Clock; + drm_mode.hdisplay = mode->HDisplay; + drm_mode.hsync_start = mode->HSyncStart; + drm_mode.hsync_end = mode->HSyncEnd; + drm_mode.htotal = mode->HTotal; + drm_mode.vdisplay = mode->VDisplay; + drm_mode.vsync_start = mode->VSyncStart; + drm_mode.vsync_end = mode->VSyncEnd; + drm_mode.vtotal = mode->VTotal; + drm_mode.flags = mode->Flags; + drm_mode.hskew = mode->HSkew; + drm_mode.vscan = mode->VScan; + drm_mode.vrefresh = mode->VRefresh; + strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN); + + drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, + &drm_output->output_id, 1, &drm_mode); } void crtc_load_lut(xf86CrtcPtr crtc) { - ScrnInfoPtr pScrn = crtc->scrn; + ScrnInfoPtr pScrn = crtc->scrn; } static void @@ -135,81 +135,81 @@ crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue, static void * crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) { - ScrnInfoPtr pScrn = crtc->scrn; + ScrnInfoPtr pScrn = crtc->scrn; - return NULL; + return NULL; } static PixmapPtr crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) { - ScrnInfoPtr pScrn = crtc->scrn; + ScrnInfoPtr pScrn = crtc->scrn; - return NULL; + return NULL; } static void crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) { - ScrnInfoPtr pScrn = crtc->scrn; + ScrnInfoPtr pScrn = crtc->scrn; } static void crtc_destroy(xf86CrtcPtr crtc) { - drmModeFreeCrtc(crtc->driver_private); + drmModeFreeCrtc(crtc->driver_private); } static const xf86CrtcFuncsRec crtc_funcs = { - .dpms = crtc_dpms, - .save = NULL, /* XXX */ - .restore = NULL, /* XXX */ - .lock = crtc_lock, - .unlock = crtc_unlock, - .mode_fixup = crtc_mode_fixup, - .prepare = crtc_prepare, - .mode_set = crtc_mode_set, - .commit = crtc_commit, - .gamma_set = crtc_gamma_set, - .shadow_create = crtc_shadow_create, - .shadow_allocate = crtc_shadow_allocate, - .shadow_destroy = crtc_shadow_destroy, + .dpms = crtc_dpms, + .save = NULL, /* XXX */ + .restore = NULL, /* XXX */ + .lock = crtc_lock, + .unlock = crtc_unlock, + .mode_fixup = crtc_mode_fixup, + .prepare = crtc_prepare, + .mode_set = crtc_mode_set, + .commit = crtc_commit, + .gamma_set = crtc_gamma_set, + .shadow_create = crtc_shadow_create, + .shadow_allocate = crtc_shadow_allocate, + .shadow_destroy = crtc_shadow_destroy, // .set_cursor_colors = crtc_set_cursor_colors, // .set_cursor_position = crtc_set_cursor_position, // .show_cursor = crtc_show_cursor, // .hide_cursor = crtc_hide_cursor, // .load_cursor_image = crtc_load_cursor_image, // .load_cursor_argb = crtc_load_cursor_argb, - .destroy = crtc_destroy, /* XXX */ + .destroy = crtc_destroy, /* XXX */ }; void crtc_init(ScrnInfoPtr pScrn) { - modesettingPtr ms = modesettingPTR(pScrn); - xf86CrtcPtr crtc; - drmModeResPtr res; - drmModeCrtcPtr drm_crtc = NULL; - int c, k, p; - - res = drmModeGetResources(ms->fd); - if (res == 0) { - ErrorF("Failed drmModeGetResources %d\n",errno); - return; - } - - for (c = 0; c < res->count_crtcs; c++) { - drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]); - if (!drm_crtc) - continue; - - crtc = xf86CrtcCreate(pScrn, &crtc_funcs); - if (crtc == NULL) - goto out; - - crtc->driver_private = drm_crtc; - } - -out: - drmModeFreeResources(res); + modesettingPtr ms = modesettingPTR(pScrn); + xf86CrtcPtr crtc; + drmModeResPtr res; + drmModeCrtcPtr drm_crtc = NULL; + int c, k, p; + + res = drmModeGetResources(ms->fd); + if (res == 0) { + ErrorF("Failed drmModeGetResources %d\n", errno); + return; + } + + for (c = 0; c < res->count_crtcs; c++) { + drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]); + if (!drm_crtc) + continue; + + crtc = xf86CrtcCreate(pScrn, &crtc_funcs); + if (crtc == NULL) + goto out; + + crtc->driver_private = drm_crtc; + } + + out: + drmModeFreeResources(res); } diff --git a/src/driver.c b/src/driver.c index ba6bfdf..de4b260 100644 --- a/src/driver.c +++ b/src/driver.c @@ -65,12 +65,15 @@ static Bool SaveHWState(ScrnInfoPtr pScrn); static Bool RestoreHWState(ScrnInfoPtr pScrn); static void Identify(int flags); static const OptionInfoRec *AvailableOptions(int chipid, int busid); -static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags); +static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, + int flags); static void FreeScreen(int scrnIndex, int flags); static void LeaveVT(int scrnIndex, int flags); static Bool SwitchMode(int scrnIndex, DisplayModePtr mode, int flags); -static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv); +static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, + char **argv); static Bool PreInit(ScrnInfoPtr pScrn, int flags); + #if XSERVER_LIBPCIACCESS static Bool pci_probe(DriverPtr driver, @@ -81,64 +84,64 @@ static Bool Probe(DriverPtr drv, int flags); #if XSERVER_LIBPCIACCESS static const struct pci_id_match device_match[] = { - {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0}, - {0, 0, 0}, + {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0}, + {0, 0, 0}, }; #endif _X_EXPORT DriverRec modesetting = { - 1, - "modesetting", - Identify, + 1, + "modesetting", + Identify, #if XSERVER_LIBPCIACCESS - NULL, + NULL, #else - Probe, + Probe, #endif - AvailableOptions, - NULL, - 0, - NULL, + AvailableOptions, + NULL, + 0, + NULL, #if XSERVER_LIBPCIACCESS - device_match, - pci_probe + device_match, + pci_probe #endif }; static SymTabRec Chipsets[] = { - {0x2592, "Intel Graphics Device"}, - {-1, NULL} + {0x2592, "Intel Graphics Device"}, + {-1, NULL} }; static PciChipsets PciDevices[] = { - {0x2592, 0x2592, RES_SHARED_VGA}, - {-1, -1, RES_UNDEFINED} + {0x2592, 0x2592, RES_SHARED_VGA}, + {-1, -1, RES_UNDEFINED} }; typedef enum { - OPTION_NOACCEL, - OPTION_SW_CURSOR, - OPTION_SHADOWFB, + OPTION_NOACCEL, + OPTION_SW_CURSOR, + OPTION_SHADOWFB, } modesettingOpts; static const OptionInfoRec Options[] = { - {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_SHADOWFB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, - {-1, NULL, OPTV_NONE, {0}, FALSE} + {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_SHADOWFB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, + {-1, NULL, OPTV_NONE, {0}, FALSE} }; static const char *fbSymbols[] = { - "fbPictureInit", - "fbScreenInit", - NULL + "fbPictureInit", + "fbScreenInit", + NULL }; static const char *ddcSymbols[] = { - "xf86PrintEDID", - "xf86SetDDCproperties", - NULL + "xf86PrintEDID", + "xf86SetDDCproperties", + NULL }; static const char *shadowSymbols[] = { @@ -148,9 +151,9 @@ static const char *shadowSymbols[] = { }; static const char *i2cSymbols[] = { - "xf86CreateI2CBusRec", - "xf86I2CBusInit", - NULL + "xf86CreateI2CBusRec", + "xf86I2CBusInit", + NULL }; int modesettingEntityIndex = -1; @@ -158,16 +161,16 @@ int modesettingEntityIndex = -1; static MODULESETUPPROTO(Setup); static XF86ModuleVersionInfo VersRec = { - "modesetting", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL, - ABI_CLASS_VIDEODRV, - ABI_VIDEODRV_VERSION, - MOD_CLASS_VIDEODRV, - {0, 0, 0, 0} + "modesetting", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} }; _X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL }; @@ -175,44 +178,43 @@ _X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL }; static pointer Setup(pointer module, pointer opts, int *errmaj, int *errmin) { - static Bool setupDone = 0; - - /* This module should be loaded only once, but check to be sure. - */ - if (!setupDone) { - setupDone = 1; - xf86AddDriver(&modesetting, module, HaveDriverFuncs); - - /* - * Tell the loader about symbols from other modules that this module - * might refer to. - */ - LoaderRefSymLists(fbSymbols, - shadowSymbols, ddcSymbols, NULL); - - /* - * The return value must be non-NULL on success even though there - * is no TearDownProc. - */ - return (pointer) 1; - } else { - if (errmaj) - *errmaj = LDR_ONCEONLY; - return NULL; - } + static Bool setupDone = 0; + + /* This module should be loaded only once, but check to be sure. + */ + if (!setupDone) { + setupDone = 1; + xf86AddDriver(&modesetting, module, HaveDriverFuncs); + + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + */ + LoaderRefSymLists(fbSymbols, shadowSymbols, ddcSymbols, NULL); + + /* + * The return value must be non-NULL on success even though there + * is no TearDownProc. + */ + return (pointer) 1; + } else { + if (errmaj) + *errmaj = LDR_ONCEONLY; + return NULL; + } } static void Identify(int flags) { - xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers", - Chipsets); + xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers", + Chipsets); } static const OptionInfoRec * AvailableOptions(int chipid, int busid) { - return Options; + return Options; } #if XSERVER_LIBPCIACCESS @@ -220,267 +222,271 @@ static Bool pci_probe(DriverPtr driver, int entity_num, struct pci_device *device, intptr_t match_data) { - ScrnInfoPtr scrn = NULL; - EntityInfoPtr entity; - DevUnion *private; - - scrn = xf86ConfigPciEntity(scrn, 0, entity_num, PciDevices, - NULL, NULL, NULL, NULL, NULL); - if (scrn != NULL) { - scrn->driverVersion = 1; - scrn->driverName = "modesetting"; - scrn->name = "modesetting"; - scrn->Probe = NULL; - - entity = xf86GetEntityInfo(entity_num); - - switch (device->device_id) { - case 0x2592: - scrn->PreInit = PreInit; - scrn->ScreenInit = ScreenInit; - scrn->SwitchMode = SwitchMode; - scrn->AdjustFrame = AdjustFrame; - scrn->EnterVT = EnterVT; - scrn->LeaveVT = LeaveVT; - scrn->FreeScreen = FreeScreen; - scrn->ValidMode = ValidMode; - break; - } - } - return scrn != NULL; + ScrnInfoPtr scrn = NULL; + EntityInfoPtr entity; + DevUnion *private; + + scrn = xf86ConfigPciEntity(scrn, 0, entity_num, PciDevices, + NULL, NULL, NULL, NULL, NULL); + if (scrn != NULL) { + scrn->driverVersion = 1; + scrn->driverName = "modesetting"; + scrn->name = "modesetting"; + scrn->Probe = NULL; + + entity = xf86GetEntityInfo(entity_num); + + switch (device->device_id) { + case 0x2592: + scrn->PreInit = PreInit; + scrn->ScreenInit = ScreenInit; + scrn->SwitchMode = SwitchMode; + scrn->AdjustFrame = AdjustFrame; + scrn->EnterVT = EnterVT; + scrn->LeaveVT = LeaveVT; + scrn->FreeScreen = FreeScreen; + scrn->ValidMode = ValidMode; + break; + } + } + return scrn != NULL; } #else static Bool Probe(DriverPtr drv, int flags) { - int i, numUsed, numDevSections, *usedChips; - EntPtr msEnt = NULL; - DevUnion *pPriv; - GDevPtr *devSections; - Bool foundScreen = FALSE; - pciVideoPtr *VideoInfo; - pciVideoPtr *ppPci; - int numDevs; - - /* - * Find the config file Device sections that match this - * driver, and return if there are none. - */ - if ((numDevSections = - xf86MatchDevice("modesetting", &devSections)) <= 0) { - return FALSE; - } - - /* - * This probing is just checking the PCI data the server already - * collected. - */ - if (!(VideoInfo = xf86GetPciVideoInfo())) - return FALSE; + int i, numUsed, numDevSections, *usedChips; + EntPtr msEnt = NULL; + DevUnion *pPriv; + GDevPtr *devSections; + Bool foundScreen = FALSE; + pciVideoPtr *VideoInfo; + pciVideoPtr *ppPci; + int numDevs; + + /* + * Find the config file Device sections that match this + * driver, and return if there are none. + */ + if ((numDevSections = xf86MatchDevice("modesetting", &devSections)) <= 0) { + return FALSE; + } + + /* + * This probing is just checking the PCI data the server already + * collected. + */ + if (!(VideoInfo = xf86GetPciVideoInfo())) + return FALSE; #if 0 - numUsed = 0; - for (ppPci = VideoInfo; ppPci != NULL && *ppPci != NULL; ppPci++) { - for (numDevs = 0; numDevs < numDevSections; numDevs++) { - if (devSections[numDevs]->busID && *devSections[numDevs]->busID) { - if (xf86ComparePciBusString(devSections[numDevs]->busID, (*ppPci)->bus, (*ppPci)->device, (*ppPci)->func)) { - /* Claim slot */ - if (xf86CheckPciSlot((*ppPci)->bus, (*ppPci)->device, - (*ppPci)->func)) { - usedChips[numUsed++] = xf86ClaimPciSlot((*ppPci)->bus, (*ppPci)->device, - (*ppPci)->func, drv, (*ppPci)->chipType, - NULL, TRUE); - ErrorF("CLAIMED %d %d %d\n",(*ppPci)->bus,(*ppPci)->device, (*ppPci)->func); - } - } - } - } - } + numUsed = 0; + for (ppPci = VideoInfo; ppPci != NULL && *ppPci != NULL; ppPci++) { + for (numDevs = 0; numDevs < numDevSections; numDevs++) { + if (devSections[numDevs]->busID && *devSections[numDevs]->busID) { + if (xf86ComparePciBusString + (devSections[numDevs]->busID, (*ppPci)->bus, + (*ppPci)->device, (*ppPci)->func)) { + /* Claim slot */ + if (xf86CheckPciSlot((*ppPci)->bus, (*ppPci)->device, + (*ppPci)->func)) { + usedChips[numUsed++] = + xf86ClaimPciSlot((*ppPci)->bus, (*ppPci)->device, + (*ppPci)->func, drv, + (*ppPci)->chipType, NULL, TRUE); + ErrorF("CLAIMED %d %d %d\n", (*ppPci)->bus, + (*ppPci)->device, (*ppPci)->func); + } + } + } + } + } #else - /* Look for Intel i8xx devices. */ - numUsed = xf86MatchPciInstances("modesetting", PCI_VENDOR_INTEL, - Chipsets, PciDevices, - devSections, numDevSections, - drv, &usedChips); + /* Look for Intel i8xx devices. */ + numUsed = xf86MatchPciInstances("modesetting", PCI_VENDOR_INTEL, + Chipsets, PciDevices, + devSections, numDevSections, + drv, &usedChips); #endif - if (flags & PROBE_DETECT) { - if (numUsed > 0) - foundScreen = TRUE; - } else { - ErrorF("NUMUSED %d\n",numUsed); - for (i = 0; i < numUsed; i++) { - ScrnInfoPtr pScrn = NULL; - - /* Allocate new ScrnInfoRec and claim the slot */ - if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], - PciDevices, NULL, NULL, NULL, - NULL, NULL))) { - EntityInfoPtr pEnt; - - pEnt = xf86GetEntityInfo(usedChips[i]); - - pScrn->driverVersion = 1; - pScrn->driverName = "modesetting"; - pScrn->name = "modesetting"; - pScrn->Probe = Probe; + if (flags & PROBE_DETECT) { + if (numUsed > 0) foundScreen = TRUE; - { - /* Allocate an entity private if necessary */ - if (modesettingEntityIndex < 0) - modesettingEntityIndex = xf86AllocateEntityPrivateIndex(); - - pPriv = xf86GetEntityPrivate(pScrn->entityList[0], - modesettingEntityIndex); - if (!pPriv->ptr) { - pPriv->ptr = xnfcalloc(sizeof(EntRec), 1); - msEnt = pPriv->ptr; - msEnt->lastInstance = -1; - } else { - msEnt = pPriv->ptr; - } - - /* - * Set the entity instance for this instance of the driver. - * For dual head per card, instance 0 is the "master" - * instance, driving the primary head, and instance 1 is - * the "slave". - */ - msEnt->lastInstance++; - xf86SetEntityInstanceForScreen(pScrn, - pScrn->entityList[0], - msEnt->lastInstance); - pScrn->PreInit = PreInit; - pScrn->ScreenInit = ScreenInit; - pScrn->SwitchMode = SwitchMode; - pScrn->AdjustFrame = AdjustFrame; - pScrn->EnterVT = EnterVT; - pScrn->LeaveVT = LeaveVT; - pScrn->FreeScreen = FreeScreen; - pScrn->ValidMode = ValidMode; - break; - } - } else - ErrorF("FAILED PSCRN\n"); - } - } + } else { + ErrorF("NUMUSED %d\n", numUsed); + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + + /* Allocate new ScrnInfoRec and claim the slot */ + if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], + PciDevices, NULL, NULL, NULL, + NULL, NULL))) { + EntityInfoPtr pEnt; + + pEnt = xf86GetEntityInfo(usedChips[i]); + + pScrn->driverVersion = 1; + pScrn->driverName = "modesetting"; + pScrn->name = "modesetting"; + pScrn->Probe = Probe; + foundScreen = TRUE; + { + /* Allocate an entity private if necessary */ + if (modesettingEntityIndex < 0) + modesettingEntityIndex = + xf86AllocateEntityPrivateIndex(); + + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], + modesettingEntityIndex); + if (!pPriv->ptr) { + pPriv->ptr = xnfcalloc(sizeof(EntRec), 1); + msEnt = pPriv->ptr; + msEnt->lastInstance = -1; + } else { + msEnt = pPriv->ptr; + } + + /* + * Set the entity instance for this instance of the driver. + * For dual head per card, instance 0 is the "master" + * instance, driving the primary head, and instance 1 is + * the "slave". + */ + msEnt->lastInstance++; + xf86SetEntityInstanceForScreen(pScrn, + pScrn->entityList[0], + msEnt->lastInstance); + pScrn->PreInit = PreInit; + pScrn->ScreenInit = ScreenInit; + pScrn->SwitchMode = SwitchMode; + pScrn->AdjustFrame = AdjustFrame; + pScrn->EnterVT = EnterVT; + pScrn->LeaveVT = LeaveVT; + pScrn->FreeScreen = FreeScreen; + pScrn->ValidMode = ValidMode; + break; + } + } else + ErrorF("FAILED PSCRN\n"); + } + } - xfree(usedChips); - xfree(devSections); + xfree(usedChips); + xfree(devSections); - return foundScreen; + return foundScreen; } #endif static Bool GetRec(ScrnInfoPtr pScrn) { - if (pScrn->driverPrivate) - return TRUE; + if (pScrn->driverPrivate) + return TRUE; - pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1); + pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1); - return TRUE; + return TRUE; } static void FreeRec(ScrnInfoPtr pScrn) { - if (!pScrn) - return; + if (!pScrn) + return; - if (!pScrn->driverPrivate) - return; + if (!pScrn->driverPrivate) + return; - xfree(pScrn->driverPrivate); + xfree(pScrn->driverPrivate); - pScrn->driverPrivate = NULL; + pScrn->driverPrivate = NULL; } static void ProbeDDC(ScrnInfoPtr pScrn, int index) { - ConfiguredMonitor = NULL; + ConfiguredMonitor = NULL; } static Bool MapMem(ScrnInfoPtr pScrn) { - modesettingPtr ms = modesettingPTR(pScrn); + modesettingPtr ms = modesettingPTR(pScrn); - drmBOMap(ms->fd, - &ms->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &ms->virtual); + drmBOMap(ms->fd, + &ms->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &ms->virtual); - return TRUE; + return TRUE; } static Bool UnmapMem(ScrnInfoPtr pScrn) { - modesettingPtr ms = modesettingPTR(pScrn); + modesettingPtr ms = modesettingPTR(pScrn); - drmBOUnmap(ms->fd, &ms->bo); + drmBOUnmap(ms->fd, &ms->bo); - return TRUE; + return TRUE; } static void LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO * colors, VisualPtr pVisual) { - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); } static Bool crtc_resize(ScrnInfoPtr pScrn, int width, int height) { - modesettingPtr ms = modesettingPTR(pScrn); - ScreenPtr pScreen = pScrn->pScreen; - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - Bool fbAccessDisabled; - CARD8 *fbstart; - - if (width == pScrn->virtualX && height == pScrn->virtualY) - return TRUE; - - ErrorF("RESIZING TO %dx%d\n",width,height); - - pScrn->virtualX = width; - pScrn->virtualY = height; - pScrn->displayWidth = (pScrn->virtualX + 63) & ~63; - - if (ms->shadowMem) { - xfree(ms->shadowMem); - ms->shadowMem = NULL; - } - - UnmapMem(pScrn); - - /* move old buffer out of the way */ - drmBOSetStatus(ms->fd, &ms->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_MEM_LOCAL, - DRM_BO_MASK_MEM | DRM_BO_FLAG_NO_EVICT, - DRM_BO_HINT_DONT_FENCE, 0, 0); - - /* unreference it */ - drmBOUnreference(ms->fd, &ms->bo); - - drmBOCreate(ms->fd, - pScrn->virtualY * pScrn->displayWidth * - pScrn->bitsPerPixel / 8, 0, NULL, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_SHAREABLE - | DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_MAPPABLE | - DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT, DRM_BO_HINT_DONT_FENCE, &ms->bo); - - MapMem(pScrn); - - drmModeAddFB(ms->fd, - pScrn->virtualX, - pScrn->virtualY, - pScrn->depth, - pScrn->bitsPerPixel, - pScrn->displayWidth * pScrn->bitsPerPixel / 8, - ms->bo.handle, - &ms->fb_id); + modesettingPtr ms = modesettingPTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; + PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); + Bool fbAccessDisabled; + CARD8 *fbstart; + + if (width == pScrn->virtualX && height == pScrn->virtualY) + return TRUE; + + ErrorF("RESIZING TO %dx%d\n", width, height); + + pScrn->virtualX = width; + pScrn->virtualY = height; + pScrn->displayWidth = (pScrn->virtualX + 63) & ~63; + + if (ms->shadowMem) { + xfree(ms->shadowMem); + ms->shadowMem = NULL; + } + + UnmapMem(pScrn); + + /* move old buffer out of the way */ + drmBOSetStatus(ms->fd, &ms->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_MEM_LOCAL, + DRM_BO_MASK_MEM | DRM_BO_FLAG_NO_EVICT, + DRM_BO_HINT_DONT_FENCE, 0, 0); + + /* unreference it */ + drmBOUnreference(ms->fd, &ms->bo); + + drmBOCreate(ms->fd, + pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8, 0, NULL, + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_SHAREABLE + | DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_MAPPABLE | + DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT, + DRM_BO_HINT_DONT_FENCE, &ms->bo); + + MapMem(pScrn); + + drmModeAddFB(ms->fd, + pScrn->virtualX, + pScrn->virtualY, + pScrn->depth, + pScrn->bitsPerPixel, + pScrn->displayWidth * pScrn->bitsPerPixel / 8, + ms->bo.handle, &ms->fb_id); if (ms->shadowFB) { if ((ms->shadowMem = @@ -488,7 +494,7 @@ crtc_resize(ScrnInfoPtr pScrn, int width, int height) pScrn->bitsPerPixel)) == NULL) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Allocation of shadow memory failed\n"); - return FALSE; + return FALSE; } fbstart = ms->shadowMem; } else { @@ -508,7 +514,7 @@ crtc_resize(ScrnInfoPtr pScrn, int width, int height) pScreen->ModifyPixmapHeader(rootPixmap, pScrn->virtualX, pScrn->virtualY, pScrn->depth, pScrn->bitsPerPixel, - pScrn->displayWidth * pScrn->bitsPerPixel / 8, + pScrn->displayWidth * pScrn->bitsPerPixel / 8, fbstart); if (fbAccessDisabled) { @@ -516,148 +522,148 @@ crtc_resize(ScrnInfoPtr pScrn, int width, int height) rootPixmap->devPrivate.ptr = NULL; } - pScrn->frameX0 = 0; - pScrn->frameY0 = 0; - AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + pScrn->frameX0 = 0; + pScrn->frameY0 = 0; + AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - return TRUE; + return TRUE; } static const xf86CrtcConfigFuncsRec crtc_config_funcs = { - crtc_resize + crtc_resize }; static Bool PreInit(ScrnInfoPtr pScrn, int flags) { - xf86CrtcConfigPtr xf86_config; - modesettingPtr ms; - MessageType from = X_PROBED; - rgb defaultWeight = { 0, 0, 0 }; - EntityInfoPtr pEnt; - EntPtr msEnt = NULL; - int flags24; - char *BusID; - int i; - char *s; - int num_pipe; - int max_width, max_height; - - if (pScrn->numEntities != 1) - return FALSE; - - pEnt = xf86GetEntityInfo(pScrn->entityList[0]); - - if (flags & PROBE_DETECT) { - ProbeDDC(pScrn, pEnt->index); - return TRUE; - } - - /* Allocate driverPrivate */ - if (!GetRec(pScrn)) - return FALSE; - - ms = modesettingPTR(pScrn); - ms->SaveGeneration = -1; - ms->pEnt = pEnt; - - pScrn->displayWidth = 640; /* default it */ - - if (ms->pEnt->location.type != BUS_PCI) - return FALSE; - - ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); - - /* Allocate an entity private if necessary */ - if (xf86IsEntityShared(pScrn->entityList[0])) { - msEnt = xf86GetEntityPrivate(pScrn->entityList[0], - modesettingEntityIndex)->ptr; - ms->entityPrivate = msEnt; - } else - ms->entityPrivate = NULL; - - if (xf86RegisterResources(ms->pEnt->index, NULL, ResNone)) { - return FALSE; - } - - if (xf86IsEntityShared(pScrn->entityList[0])) { - if (xf86IsPrimInitDone(pScrn->entityList[0])) { - /* do something */ - } else { - xf86SetPrimInitDone(pScrn->entityList[0]); - } - } - - BusID = xalloc(64); - sprintf(BusID, "PCI:%d:%d:%d", + xf86CrtcConfigPtr xf86_config; + modesettingPtr ms; + MessageType from = X_PROBED; + rgb defaultWeight = { 0, 0, 0 }; + EntityInfoPtr pEnt; + EntPtr msEnt = NULL; + int flags24; + char *BusID; + int i; + char *s; + int num_pipe; + int max_width, max_height; + + if (pScrn->numEntities != 1) + return FALSE; + + pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + + if (flags & PROBE_DETECT) { + ProbeDDC(pScrn, pEnt->index); + return TRUE; + } + + /* Allocate driverPrivate */ + if (!GetRec(pScrn)) + return FALSE; + + ms = modesettingPTR(pScrn); + ms->SaveGeneration = -1; + ms->pEnt = pEnt; + + pScrn->displayWidth = 640; /* default it */ + + if (ms->pEnt->location.type != BUS_PCI) + return FALSE; + + ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); + + /* Allocate an entity private if necessary */ + if (xf86IsEntityShared(pScrn->entityList[0])) { + msEnt = xf86GetEntityPrivate(pScrn->entityList[0], + modesettingEntityIndex)->ptr; + ms->entityPrivate = msEnt; + } else + ms->entityPrivate = NULL; + + if (xf86RegisterResources(ms->pEnt->index, NULL, ResNone)) { + return FALSE; + } + + if (xf86IsEntityShared(pScrn->entityList[0])) { + if (xf86IsPrimInitDone(pScrn->entityList[0])) { + /* do something */ + } else { + xf86SetPrimInitDone(pScrn->entityList[0]); + } + } + + BusID = xalloc(64); + sprintf(BusID, "PCI:%d:%d:%d", #if XSERVER_LIBPCIACCESS - ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), - ms->PciInfo->dev, ms->PciInfo->func + ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), + ms->PciInfo->dev, ms->PciInfo->func #else - ((pciConfigPtr) ms->PciInfo->thisCard)->busnum, - ((pciConfigPtr) ms->PciInfo->thisCard)->devnum, - ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum + ((pciConfigPtr) ms->PciInfo->thisCard)->busnum, + ((pciConfigPtr) ms->PciInfo->thisCard)->devnum, + ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum #endif - ); - - ms->fd = drmOpen(NULL, BusID); - - if (ms->fd < 0) - return FALSE; - - pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; - pScrn->monitor = pScrn->confScreen->monitor; - pScrn->progClock = TRUE; - pScrn->rgbBits = 8; - - flags24 = Support32bppFb | PreferConvert24to32 | SupportConvert24to32; - - if (!xf86SetDepthBpp(pScrn, 0, 0, 0, flags24)) - return FALSE; - - switch (pScrn->depth) { - case 8: - case 15: - case 16: - case 24: - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Given depth (%d) is not supported by the driver\n", - pScrn->depth); - return FALSE; - } - xf86PrintDepthBpp(pScrn); - - if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) - return FALSE; - if (!xf86SetDefaultVisual(pScrn, -1)) - return FALSE; - - /* Process the options */ - xf86CollectOptions(pScrn, NULL); - if (!(ms->Options = xalloc(sizeof(Options)))) - return FALSE; - memcpy(ms->Options, Options, sizeof(Options)); - xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options); - - /* Allocate an xf86CrtcConfig */ - xf86CrtcConfigInit(pScrn, &crtc_config_funcs); - xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - - max_width = 8192; - max_height = 8192; - xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height); - - if (xf86ReturnOptValBool(ms->Options, OPTION_NOACCEL, FALSE)) { - ms->noAccel = TRUE; - } - - if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) { - ms->SWCursor = TRUE; - } - - if (xf86ReturnOptValBool(ms->Options, OPTION_SHADOWFB, FALSE)) { + ); + + ms->fd = drmOpen(NULL, BusID); + + if (ms->fd < 0) + return FALSE; + + pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; + pScrn->monitor = pScrn->confScreen->monitor; + pScrn->progClock = TRUE; + pScrn->rgbBits = 8; + + flags24 = Support32bppFb | PreferConvert24to32 | SupportConvert24to32; + + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, flags24)) + return FALSE; + + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by the driver\n", + pScrn->depth); + return FALSE; + } + xf86PrintDepthBpp(pScrn); + + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) + return FALSE; + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; + + /* Process the options */ + xf86CollectOptions(pScrn, NULL); + if (!(ms->Options = xalloc(sizeof(Options)))) + return FALSE; + memcpy(ms->Options, Options, sizeof(Options)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options); + + /* Allocate an xf86CrtcConfig */ + xf86CrtcConfigInit(pScrn, &crtc_config_funcs); + xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + + max_width = 8192; + max_height = 8192; + xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height); + + if (xf86ReturnOptValBool(ms->Options, OPTION_NOACCEL, FALSE)) { + ms->noAccel = TRUE; + } + + if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) { + ms->SWCursor = TRUE; + } + + if (xf86ReturnOptValBool(ms->Options, OPTION_SHADOWFB, FALSE)) { if (!xf86LoadSubModule(pScrn, "shadow")) return FALSE; @@ -666,144 +672,144 @@ PreInit(ScrnInfoPtr pScrn, int flags) ms->shadowFB = TRUE; } - SaveHWState(pScrn); + SaveHWState(pScrn); - crtc_init(pScrn); - output_init(pScrn); + crtc_init(pScrn); + output_init(pScrn); - if (!xf86InitialConfiguration(pScrn, TRUE)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); - RestoreHWState(pScrn); - return FALSE; - } + if (!xf86InitialConfiguration(pScrn, TRUE)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); + RestoreHWState(pScrn); + return FALSE; + } - RestoreHWState(pScrn); + RestoreHWState(pScrn); - /* - * If the driver can do gamma correction, it should call xf86SetGamma() here. - */ - { - Gamma zeros = { 0.0, 0.0, 0.0 }; + /* + * If the driver can do gamma correction, it should call xf86SetGamma() here. + */ + { + Gamma zeros = { 0.0, 0.0, 0.0 }; - if (!xf86SetGamma(pScrn, zeros)) { - return FALSE; - } - } + if (!xf86SetGamma(pScrn, zeros)) { + return FALSE; + } + } - if (pScrn->modes == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n"); - return FALSE; - } + if (pScrn->modes == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n"); + return FALSE; + } - pScrn->currentMode = pScrn->modes; + pScrn->currentMode = pScrn->modes; - /* Set display resolution */ - xf86SetDpi(pScrn, 0, 0); + /* Set display resolution */ + xf86SetDpi(pScrn, 0, 0); - /* Load the required sub modules */ - if (!xf86LoadSubModule(pScrn, "fb")) { - return FALSE; - } + /* Load the required sub modules */ + if (!xf86LoadSubModule(pScrn, "fb")) { + return FALSE; + } - xf86LoaderReqSymLists(fbSymbols, NULL); + xf86LoaderReqSymLists(fbSymbols, NULL); - return TRUE; + return TRUE; } static Bool SaveHWState(ScrnInfoPtr pScrn) { - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - return TRUE; + return TRUE; } static Bool RestoreHWState(ScrnInfoPtr pScrn) { - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - return TRUE; + return TRUE; } static void * WindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, - CARD32 * size, void *closure) + CARD32 * size, void *closure) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); - if (!pScrn->vtSema) - return NULL; + if (!pScrn->vtSema) + return NULL; - *size = pScrn->displayWidth * pScrn->bitsPerPixel / 8; + *size = pScrn->displayWidth * pScrn->bitsPerPixel / 8; - return ((CARD8 *) ms->virtual + row * (*size) + offset); + return ((CARD8 *) ms->virtual + row * (*size) + offset); } static Bool CreateScreenResources(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - Bool ret; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + Bool ret; - pScreen->CreateScreenResources = ms->createScreenResources; - ret = pScreen->CreateScreenResources(pScreen); - pScreen->CreateScreenResources = CreateScreenResources; + pScreen->CreateScreenResources = ms->createScreenResources; + ret = pScreen->CreateScreenResources(pScreen); + pScreen->CreateScreenResources = CreateScreenResources; - shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen), + shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen), ms->update, WindowLinear, 0, 0); - return ret; + return ret; } static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - VisualPtr visual; - unsigned long sys_mem; - int c; - MessageType from; - CARD8 *fbstart; - - pScrn->displayWidth = (pScrn->virtualX + 63) & ~63; - - miClearVisualTypes(); - - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - - if (!miSetPixmapDepths()) - return FALSE; - - if (!MapMem(pScrn)) - return FALSE; - - pScrn->memPhysBase = 0; - pScrn->fbOffset = 0; - - drmBOCreate(ms->fd, - pScrn->virtualY * pScrn->displayWidth * - pScrn->bitsPerPixel / 8, 0, NULL, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_SHAREABLE - | DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_MAPPABLE | - DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT, DRM_BO_HINT_DONT_FENCE, &ms->bo); - - MapMem(pScrn); - - drmModeAddFB(ms->fd, - pScrn->virtualX, - pScrn->virtualY, - pScrn->depth, - pScrn->bitsPerPixel, - pScrn->displayWidth * pScrn->bitsPerPixel / 8, - ms->bo.handle, - &ms->fb_id); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + VisualPtr visual; + unsigned long sys_mem; + int c; + MessageType from; + CARD8 *fbstart; + + pScrn->displayWidth = (pScrn->virtualX + 63) & ~63; + + miClearVisualTypes(); + + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + if (!miSetPixmapDepths()) + return FALSE; + + if (!MapMem(pScrn)) + return FALSE; + + pScrn->memPhysBase = 0; + pScrn->fbOffset = 0; + + drmBOCreate(ms->fd, + pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8, 0, NULL, + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_SHAREABLE + | DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_MAPPABLE | + DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT, + DRM_BO_HINT_DONT_FENCE, &ms->bo); + + MapMem(pScrn); + + drmModeAddFB(ms->fd, + pScrn->virtualX, + pScrn->virtualY, + pScrn->depth, + pScrn->bitsPerPixel, + pScrn->displayWidth * pScrn->bitsPerPixel / 8, + ms->bo.handle, &ms->fb_id); if (ms->shadowFB) { if ((ms->shadowMem = @@ -811,140 +817,141 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pScrn->bitsPerPixel)) == NULL) { xf86DrvMsg(scrnIndex, X_ERROR, "Allocation of shadow memory failed\n"); - return FALSE; + return FALSE; } fbstart = ms->shadowMem; } else { fbstart = ms->virtual; } - if (!fbScreenInit(pScreen, fbstart, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth, pScrn->bitsPerPixel)) - return FALSE; - - if (pScrn->bitsPerPixel > 8) { - /* Fixup RGB ordering */ - visual = pScreen->visuals + pScreen->numVisuals; - while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScrn->offset.red; - visual->offsetGreen = pScrn->offset.green; - visual->offsetBlue = pScrn->offset.blue; - visual->redMask = pScrn->mask.red; - visual->greenMask = pScrn->mask.green; - visual->blueMask = pScrn->mask.blue; - } - } - } - - fbPictureInit(pScreen, NULL, 0); + if (!fbScreenInit(pScreen, fbstart, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel)) + return FALSE; + + if (pScrn->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + fbPictureInit(pScreen, NULL, 0); if (ms->shadowFB) { ms->update = shadowUpdatePackedWeak(); if (!shadowSetup(pScreen)) { xf86DrvMsg(scrnIndex, X_ERROR, "Shadow framebuffer initialization failed.\n"); - return FALSE; + return FALSE; } ms->createScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = CreateScreenResources; } - xf86SetBlackWhitePixels(pScreen); + xf86SetBlackWhitePixels(pScreen); #if 0 - glucoseScreenInit(pScreen, 0); + glucoseScreenInit(pScreen, 0); #endif #if 0 - ms->pExa = ExaInit(pScreen); + ms->pExa = ExaInit(pScreen); #endif - miInitializeBackingStore(pScreen); - xf86SetBackingStore(pScreen); - xf86SetSilkenMouse(pScreen); - miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); - /* Must force it before EnterVT, so we are in control of VT and - * later memory should be bound when allocating, e.g rotate_mem */ - pScrn->vtSema = TRUE; + /* Must force it before EnterVT, so we are in control of VT and + * later memory should be bound when allocating, e.g rotate_mem */ + pScrn->vtSema = TRUE; - pScreen->SaveScreen = xf86SaveScreen; - ms->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = CloseScreen; + pScreen->SaveScreen = xf86SaveScreen; + ms->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = CloseScreen; - if (!xf86CrtcScreenInit(pScreen)) - return FALSE; + if (!xf86CrtcScreenInit(pScreen)) + return FALSE; - if (!miCreateDefColormap(pScreen)) - return FALSE; + if (!miCreateDefColormap(pScreen)) + return FALSE; #if 0 - if (!xf86HandleColormaps(pScreen, 256, 8, LoadPalette, NULL, - CMAP_RELOAD_ON_MODE_SWITCH | - CMAP_PALETTED_TRUECOLOR)) { - return FALSE; - } + if (!xf86HandleColormaps(pScreen, 256, 8, LoadPalette, NULL, + CMAP_RELOAD_ON_MODE_SWITCH | + CMAP_PALETTED_TRUECOLOR)) { + return FALSE; + } #endif - xf86DPMSInit(pScreen, xf86DPMSSet, 0); + xf86DPMSInit(pScreen, xf86DPMSSet, 0); #if 0 - glucoseInitVideo(pScreen); + glucoseInitVideo(pScreen); #endif - if (serverGeneration == 1) - xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); - return EnterVT(scrnIndex, 0); + return EnterVT(scrnIndex, 0); } static void AdjustFrame(int scrnIndex, int x, int y, int flags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - xf86OutputPtr output = config->output[config->compat_output]; - xf86CrtcPtr crtc = output->crtc; - - if (crtc && crtc->enabled) { - crtc->funcs->mode_set(crtc, pScrn->currentMode, pScrn->currentMode, x, y); - crtc->x = output->initial_x + x; - crtc->y = output->initial_y + y; - } + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86OutputPtr output = config->output[config->compat_output]; + xf86CrtcPtr crtc = output->crtc; + + if (crtc && crtc->enabled) { + crtc->funcs->mode_set(crtc, pScrn->currentMode, pScrn->currentMode, x, + y); + crtc->x = output->initial_x + x; + crtc->y = output->initial_y + y; + } } static void FreeScreen(int scrnIndex, int flags) { - FreeRec(xf86Screens[scrnIndex]); + FreeRec(xf86Screens[scrnIndex]); } static void LeaveVT(int scrnIndex, int flags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - modesettingPtr ms = modesettingPTR(pScrn); - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - int o; - - for (o = 0; o < config->num_crtc; o++) { - xf86CrtcPtr crtc = config->crtc[o]; - - if (crtc->rotatedPixmap || crtc->rotatedData) { - crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap, - crtc->rotatedData); - crtc->rotatedPixmap = NULL; - crtc->rotatedData = NULL; - } - } + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + modesettingPtr ms = modesettingPTR(pScrn); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int o; + + for (o = 0; o < config->num_crtc; o++) { + xf86CrtcPtr crtc = config->crtc[o]; + + if (crtc->rotatedPixmap || crtc->rotatedData) { + crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap, + crtc->rotatedData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + } - xf86_hide_cursors(pScrn); + xf86_hide_cursors(pScrn); - drmMMLock(ms->fd, DRM_BO_MEM_VRAM, 1, 0); + drmMMLock(ms->fd, DRM_BO_MEM_VRAM, 1, 0); - RestoreHWState(pScrn); + RestoreHWState(pScrn); } /* @@ -953,76 +960,76 @@ LeaveVT(int scrnIndex, int flags) static Bool EnterVT(int scrnIndex, int flags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - modesettingPtr ms = modesettingPTR(pScrn); + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + modesettingPtr ms = modesettingPTR(pScrn); - /* - * Only save state once per server generation since that's what most - * drivers do. Could change this to save state at each VT enter. - */ - if (ms->SaveGeneration != serverGeneration) { - ms->SaveGeneration = serverGeneration; - SaveHWState(pScrn); - } + /* + * Only save state once per server generation since that's what most + * drivers do. Could change this to save state at each VT enter. + */ + if (ms->SaveGeneration != serverGeneration) { + ms->SaveGeneration = serverGeneration; + SaveHWState(pScrn); + } - drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1); + drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1); - if (!xf86SetDesiredModes(pScrn)) - return FALSE; + if (!xf86SetDesiredModes(pScrn)) + return FALSE; - AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - return TRUE; + return TRUE; } static Bool SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - return xf86SetSingleMode(pScrn, mode, RR_Rotate_0); + return xf86SetSingleMode(pScrn, mode, RR_Rotate_0); } static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - modesettingPtr ms = modesettingPTR(pScrn); + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + modesettingPtr ms = modesettingPTR(pScrn); - if (pScrn->vtSema == TRUE) { - LeaveVT(scrnIndex, 0); - drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1); - } + if (pScrn->vtSema == TRUE) { + LeaveVT(scrnIndex, 0); + drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1); + } - UnmapMem(pScrn); + UnmapMem(pScrn); - if (ms->shadowFB) - pScreen->CreateScreenResources = ms->createScreenResources; + if (ms->shadowFB) + pScreen->CreateScreenResources = ms->createScreenResources; - if (ms->shadowMem) { - xfree(ms->shadowMem); - ms->shadowMem = NULL; - } + if (ms->shadowMem) { + xfree(ms->shadowMem); + ms->shadowMem = NULL; + } - if (ms->pExa) - ExaClose(pScrn); + if (ms->pExa) + ExaClose(pScrn); - /* move old buffer out of the way */ - drmBOSetStatus(ms->fd, &ms->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_MEM_LOCAL, - DRM_BO_MASK_MEM | DRM_BO_FLAG_NO_EVICT, - DRM_BO_HINT_DONT_FENCE, 0, 0); + /* move old buffer out of the way */ + drmBOSetStatus(ms->fd, &ms->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_MEM_LOCAL, + DRM_BO_MASK_MEM | DRM_BO_FLAG_NO_EVICT, + DRM_BO_HINT_DONT_FENCE, 0, 0); - drmBOUnreference(ms->fd, &ms->bo); + drmBOUnreference(ms->fd, &ms->bo); - drmClose(ms->fd); + drmClose(ms->fd); - pScrn->vtSema = FALSE; - pScreen->CloseScreen = ms->CloseScreen; - return (*pScreen->CloseScreen) (scrnIndex, pScreen); + pScrn->vtSema = FALSE; + pScreen->CloseScreen = ms->CloseScreen; + return (*pScreen->CloseScreen) (scrnIndex, pScreen); } static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) { - return MODE_OK; + return MODE_OK; } diff --git a/src/driver.h b/src/driver.h index 2a09903..c9cb764 100644 --- a/src/driver.h +++ b/src/driver.h @@ -36,53 +36,55 @@ #define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); -typedef struct { - int lastInstance; - int refCount; - ScrnInfoPtr pScrn_1; - ScrnInfoPtr pScrn_2; +typedef struct +{ + int lastInstance; + int refCount; + ScrnInfoPtr pScrn_1; + ScrnInfoPtr pScrn_2; } EntRec, *EntPtr; -typedef struct _modesettingRec { - int fd; - unsigned int fb_id; - void *virtual; - drmBO bo; +typedef struct _modesettingRec +{ + int fd; + unsigned int fb_id; + void *virtual; + drmBO bo; - EntPtr entityPrivate; + EntPtr entityPrivate; - void (*PointerMoved)(int, int, int); + void (*PointerMoved) (int, int, int); - int Chipset; - EntityInfoPtr pEnt; + int Chipset; + EntityInfoPtr pEnt; #if XSERVER_LIBPCIACCESS - struct pci_device *PciInfo; + struct pci_device *PciInfo; #else - pciVideoPtr PciInfo; - PCITAG PciTag; + pciVideoPtr PciInfo; + PCITAG PciTag; #endif - Bool noAccel; - Bool SWCursor; - CloseScreenProcPtr CloseScreen; + Bool noAccel; + Bool SWCursor; + CloseScreenProcPtr CloseScreen; - Bool directRenderingDisabled; /* DRI disabled in PreInit. */ - Bool directRenderingEnabled; /* DRI enabled this generation. */ + Bool directRenderingDisabled; /* DRI disabled in PreInit. */ + Bool directRenderingEnabled; /* DRI enabled this generation. */ - /* Broken-out options. */ - OptionInfoPtr Options; + /* Broken-out options. */ + OptionInfoPtr Options; - unsigned int SaveGeneration; + unsigned int SaveGeneration; - /* shadowfb */ - CARD8 *shadowMem; - Bool shadowFB; - CreateScreenResourcesProcPtr createScreenResources; - ShadowUpdateProc update; + /* shadowfb */ + CARD8 *shadowMem; + Bool shadowFB; + CreateScreenResourcesProcPtr createScreenResources; + ShadowUpdateProc update; - /* exa */ - ExaDriverPtr pExa; - drmBO exa_bo; + /* exa */ + ExaDriverPtr pExa; + drmBO exa_bo; } modesettingRec, *modesettingPtr; #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) @@ -102,7 +102,7 @@ ExaSolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) static Bool ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, - int ydir, int alu, Pixel planeMask) + int ydir, int alu, Pixel planeMask) { ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; @@ -115,15 +115,15 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, static void ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, - int width, int height) + int width, int height) { ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; } static Bool ExaPrepareComposite(int op, PicturePtr pSrcPicture, - PicturePtr pMaskPicture, PicturePtr pDstPicture, - PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) { ScreenPtr pScreen = pDst->drawable.pScreen; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -133,7 +133,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, static Bool ExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, - int src_pitch) + int src_pitch) { ScreenPtr pScreen = pDst->drawable.pScreen; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -143,7 +143,7 @@ ExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, static void ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, - int dstX, int dstY, int width, int height) + int dstX, int dstY, int width, int height) { ScreenPtr pScreen = pDst->drawable.pScreen; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -151,8 +151,8 @@ ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, static Bool ExaCheckComposite(int op, - PicturePtr pSrcPicture, PicturePtr pMaskPicture, - PicturePtr pDstPicture) + PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) { DrawablePtr pDraw = pSrcPicture->pDrawable; int w = pDraw->width; @@ -173,17 +173,17 @@ ExaPixmapIsOffscreen(PixmapPtr p) void ExaClose(ScrnInfoPtr pScrn) { - modesettingPtr ms = modesettingPTR(pScrn); + modesettingPtr ms = modesettingPTR(pScrn); exaDriverFini(pScrn->pScreen); - drmBOUnreference(ms->fd, &ms->exa_bo); + drmBOUnreference(ms->fd, &ms->exa_bo); } ExaDriverPtr ExaInit(ScrnInfoPtr pScrn) { - modesettingPtr ms = modesettingPTR(pScrn); + modesettingPtr ms = modesettingPTR(pScrn); ExaDriverPtr pExa; pExa = exaDriverAlloc(); @@ -192,7 +192,9 @@ ExaInit(ScrnInfoPtr pScrn) } /* Create a 256KB offscreen area */ - drmBOCreate(ms->fd, 256 * 1024, 0, NULL, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MEM_TT, DRM_BO_HINT_DONT_FENCE, &ms->exa_bo); + drmBOCreate(ms->fd, 256 * 1024, 0, NULL, + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MEM_TT, + DRM_BO_HINT_DONT_FENCE, &ms->exa_bo); memset(pExa, 0, sizeof(*pExa)); pExa->exa_major = 2; @@ -203,8 +205,8 @@ ExaInit(ScrnInfoPtr pScrn) pExa->pixmapOffsetAlign = 8; pExa->pixmapPitchAlign = 32 * 4; pExa->flags = EXA_OFFSCREEN_PIXMAPS; - pExa->maxX = 8191; /* FIXME */ - pExa->maxY = 8191; /* FIXME */ + pExa->maxX = 8191; /* FIXME */ + pExa->maxY = 8191; /* FIXME */ pExa->WaitMarker = ExaWaitMarker; pExa->MarkSync = ExaMarkSync; pExa->PrepareSolid = ExaPrepareSolid; diff --git a/src/output.c b/src/output.c index b25540e..4a67ccc 100644 --- a/src/output.c +++ b/src/output.c @@ -69,20 +69,20 @@ restore(xf86OutputPtr output) static int mode_valid(xf86OutputPtr output, DisplayModePtr pMode) { - return MODE_OK; + return MODE_OK; } static Bool mode_fixup(xf86OutputPtr output, DisplayModePtr mode, DisplayModePtr adjusted_mode) { - return TRUE; + return TRUE; } static void prepare(xf86OutputPtr output) { - dpms(output, DPMSModeOff); + dpms(output, DPMSModeOff); } static void @@ -94,69 +94,69 @@ mode_set(xf86OutputPtr output, DisplayModePtr mode, static void commit(xf86OutputPtr output) { - dpms(output, DPMSModeOn); + dpms(output, DPMSModeOn); - if (output->scrn->pScreen != NULL) - xf86_reload_cursors(output->scrn->pScreen); + if (output->scrn->pScreen != NULL) + xf86_reload_cursors(output->scrn->pScreen); } static xf86OutputStatus detect(xf86OutputPtr output) { - drmModeOutputPtr drm_output = output->driver_private; - - switch (drm_output->connection) { - case DRM_MODE_CONNECTED: - return XF86OutputStatusConnected; - case DRM_MODE_DISCONNECTED: - return XF86OutputStatusDisconnected; - default: - return XF86OutputStatusUnknown; - } + drmModeOutputPtr drm_output = output->driver_private; + + switch (drm_output->connection) { + case DRM_MODE_CONNECTED: + return XF86OutputStatusConnected; + case DRM_MODE_DISCONNECTED: + return XF86OutputStatusDisconnected; + default: + return XF86OutputStatusUnknown; + } } static DisplayModePtr get_modes(xf86OutputPtr output) { - drmModeOutputPtr drm_output = output->driver_private; - struct drm_mode_modeinfo *drm_mode = NULL; - DisplayModePtr modes = NULL, mode = NULL; - int i; - - for (i = 0; i < drm_output->count_modes; i++) { - drm_mode = &drm_output->modes[i]; - if (drm_mode) { - mode = xcalloc(1, sizeof(DisplayModeRec)); - if (!mode) - continue; - mode->type = 0; - mode->Clock = drm_mode->clock; - mode->HDisplay = drm_mode->hdisplay; - mode->HSyncStart = drm_mode->hsync_start; - mode->HSyncEnd = drm_mode->hsync_end; - mode->HTotal = drm_mode->htotal; - mode->VDisplay = drm_mode->vdisplay; - mode->VSyncStart = drm_mode->vsync_start; - mode->VSyncEnd = drm_mode->vsync_end; - mode->VTotal = drm_mode->vtotal; - mode->Flags = drm_mode->flags; - mode->HSkew = drm_mode->hskew; - mode->VScan = drm_mode->vscan; - mode->VRefresh = xf86ModeVRefresh(mode); - mode->Private = (void *)drm_mode; - xf86SetModeDefaultName(mode); - modes = xf86ModesAdd(modes, mode); - xf86PrintModeline(0, mode); - } - } - - return modes; + drmModeOutputPtr drm_output = output->driver_private; + struct drm_mode_modeinfo *drm_mode = NULL; + DisplayModePtr modes = NULL, mode = NULL; + int i; + + for (i = 0; i < drm_output->count_modes; i++) { + drm_mode = &drm_output->modes[i]; + if (drm_mode) { + mode = xcalloc(1, sizeof(DisplayModeRec)); + if (!mode) + continue; + mode->type = 0; + mode->Clock = drm_mode->clock; + mode->HDisplay = drm_mode->hdisplay; + mode->HSyncStart = drm_mode->hsync_start; + mode->HSyncEnd = drm_mode->hsync_end; + mode->HTotal = drm_mode->htotal; + mode->VDisplay = drm_mode->vdisplay; + mode->VSyncStart = drm_mode->vsync_start; + mode->VSyncEnd = drm_mode->vsync_end; + mode->VTotal = drm_mode->vtotal; + mode->Flags = drm_mode->flags; + mode->HSkew = drm_mode->hskew; + mode->VScan = drm_mode->vscan; + mode->VRefresh = xf86ModeVRefresh(mode); + mode->Private = (void *)drm_mode; + xf86SetModeDefaultName(mode); + modes = xf86ModesAdd(modes, mode); + xf86PrintModeline(0, mode); + } + } + + return modes; } static void destroy(xf86OutputPtr output) { - drmModeFreeOutput(output->driver_private); + drmModeFreeOutput(output->driver_private); } static void @@ -170,7 +170,7 @@ create_resources(xf86OutputPtr output) static Bool set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value) { - return TRUE; + return TRUE; } #endif /* RANDR_12_INTERFACE */ @@ -178,7 +178,7 @@ set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value) static Bool get_property(xf86OutputPtr output, Atom property) { - return TRUE; + return TRUE; } #endif /* RANDR_13_INTERFACE */ @@ -186,100 +186,102 @@ get_property(xf86OutputPtr output, Atom property) static xf86CrtcPtr get_crtc(xf86OutputPtr output) { - return NULL; + return NULL; } #endif static const xf86OutputFuncsRec output_funcs = { - .create_resources = create_resources, - .dpms = dpms, - .save = save, - .restore = restore, - .mode_valid = mode_valid, - .mode_fixup = mode_fixup, - .prepare = prepare, - .mode_set = mode_set, - .commit = commit, - .detect = detect, - .get_modes = get_modes, + .create_resources = create_resources, + .dpms = dpms, + .save = save, + .restore = restore, + .mode_valid = mode_valid, + .mode_fixup = mode_fixup, + .prepare = prepare, + .mode_set = mode_set, + .commit = commit, + .detect = detect, + .get_modes = get_modes, #ifdef RANDR_12_INTERFACE - .set_property = set_property, + .set_property = set_property, #endif #ifdef RANDR_13_INTERFACE - .get_property = get_property, + .get_property = get_property, #endif - .destroy = destroy, + .destroy = destroy, #ifdef RANDR_GET_CRTC_INTERFACE - .get_crtc = get_crtc, + .get_crtc = get_crtc, #endif }; void output_init(ScrnInfoPtr pScrn) { - modesettingPtr ms = modesettingPTR(pScrn); - xf86OutputPtr output; - drmModeResPtr res; - drmModeOutputPtr drm_output = NULL; - drmModeCrtcPtr crtc; - char *name; - int o, v, p; - - res = drmModeGetResources(ms->fd); - if (res == 0) { - DRV_ERROR("Failed drmModeGetResources\n"); - return; - } - - for (o = 0; o < res->count_outputs; o++) { - drm_output = drmModeGetOutput(ms->fd, res->outputs[o]); - if (!drm_output) - goto out; - - for (p = 0; p < drm_output->count_props; p++) { - drmModePropertyPtr prop; - - prop = drmModeGetProperty(ms->fd, drm_output->props[p]); - - name = NULL; - if (prop) { - ErrorF("VALUES %d\n",prop->count_values); - - for (v=0;v<prop->count_values;v++) - ErrorF("%s %lld\n", prop->name, prop->values[v]); - - for (v=0;v<prop->count_enums;v++) { - ErrorF("%s %s\n", prop->name, prop->enums[v].name); - if (drm_output->prop_values[p] == prop->enums[v].value) { - if (!strncmp("Connector Type", prop->name, 14)) { - ErrorF("WE'VE GOT %s\n",prop->enums[v].name); - name = xalloc(strlen(prop->enums[v].name)); - strncpy(name, prop->enums[v].name, strlen(name)); - } + modesettingPtr ms = modesettingPTR(pScrn); + xf86OutputPtr output; + drmModeResPtr res; + drmModeOutputPtr drm_output = NULL; + drmModeCrtcPtr crtc; + char *name; + int o, v, p; + + res = drmModeGetResources(ms->fd); + if (res == 0) { + DRV_ERROR("Failed drmModeGetResources\n"); + return; + } + + for (o = 0; o < res->count_outputs; o++) { + drm_output = drmModeGetOutput(ms->fd, res->outputs[o]); + if (!drm_output) + goto out; + + for (p = 0; p < drm_output->count_props; p++) { + drmModePropertyPtr prop; + + prop = drmModeGetProperty(ms->fd, drm_output->props[p]); + + name = NULL; + if (prop) { + ErrorF("VALUES %d\n", prop->count_values); + + for (v = 0; v < prop->count_values; v++) + ErrorF("%s %lld\n", prop->name, prop->values[v]); + + for (v = 0; v < prop->count_enums; v++) { + ErrorF("%s %s\n", prop->name, prop->enums[v].name); + if (drm_output->prop_values[p] == prop->enums[v].value) { + if (!strncmp("Connector Type", prop->name, 14)) { + ErrorF("WE'VE GOT %s\n", prop->enums[v].name); + name = xalloc(strlen(prop->enums[v].name)); + strncpy(name, prop->enums[v].name, strlen(name)); + } + } + if (name) + break; } - if (name) break; + if (name) + break; } - if (name) break; - } - } + } - if (!name) - continue; + if (!name) + continue; - output = xf86OutputCreate(pScrn, &output_funcs, name); - if (!output) - continue; + output = xf86OutputCreate(pScrn, &output_funcs, name); + if (!output) + continue; free(name); - output->possible_crtcs = drm_output->crtcs; - output->possible_clones = drm_output->clones; - output->driver_private = drm_output; - output->subpixel_order = SubPixelHorizontalRGB; - output->interlaceAllowed = FALSE; - output->doubleScanAllowed = FALSE; - } + output->possible_crtcs = drm_output->crtcs; + output->possible_clones = drm_output->clones; + output->driver_private = drm_output; + output->subpixel_order = SubPixelHorizontalRGB; + output->interlaceAllowed = FALSE; + output->doubleScanAllowed = FALSE; + } -out: - drmModeFreeResources(res); + out: + drmModeFreeResources(res); } |