diff options
Diffstat (limited to 'xorg-server/hw')
75 files changed, 821 insertions, 1126 deletions
diff --git a/xorg-server/hw/dmx/config/dmxconfig.c b/xorg-server/hw/dmx/config/dmxconfig.c index 2cc9ab396..1d10ec018 100644 --- a/xorg-server/hw/dmx/config/dmxconfig.c +++ b/xorg-server/hw/dmx/config/dmxconfig.c @@ -204,8 +204,8 @@ dmxConfigAddDisplay(const char *name, { DMXScreenInfo *dmxScreen; - if (!(dmxScreens = realloc(dmxScreens, - (dmxNumScreens + 1) * sizeof(*dmxScreens)))) + if (!(dmxScreens = reallocarray(dmxScreens, dmxNumScreens + 1, + sizeof(*dmxScreens)))) dmxLog(dmxFatal, "dmxConfigAddDisplay: realloc failed for screen %d (%s)\n", dmxNumScreens, name); @@ -234,8 +234,8 @@ dmxConfigAddInput(const char *name, int core) { DMXInputInfo *dmxInput; - if (!(dmxInputs = realloc(dmxInputs, - (dmxNumInputs + 1) * sizeof(*dmxInputs)))) + if (!(dmxInputs = reallocarray(dmxInputs, dmxNumInputs + 1, + sizeof(*dmxInputs)))) dmxLog(dmxFatal, "dmxConfigAddInput: realloc failed for input %d (%s)\n", dmxNumInputs, name); @@ -341,7 +341,7 @@ dmxConfigCopyFromOption(DMXConfigOptionPtr o) for (pt = o->option; pt; pt = pt->next) { if (pt->string) { ++argc; - argv = realloc(argv, (argc + 1) * sizeof(*argv)); + argv = reallocarray(argv, argc + 1, sizeof(*argv)); argv[argc] = (char *) pt->string; } } diff --git a/xorg-server/hw/dmx/dmx.c b/xorg-server/hw/dmx/dmx.c index 2988df33a..9729963da 100644 --- a/xorg-server/hw/dmx/dmx.c +++ b/xorg-server/hw/dmx/dmx.c @@ -427,7 +427,7 @@ ProcDMXChangeScreensAttributes(ClientPtr client) if (!_DMXXineramaActive()) goto noxinerama; - if (!(attribs = malloc(stuff->screenCount * sizeof(*attribs)))) + if (!(attribs = xallocarray(stuff->screenCount, sizeof(*attribs)))) return BadAlloc; for (i = 0; i < stuff->screenCount; i++) { @@ -624,18 +624,18 @@ ProcDMXGetWindowAttributes(ClientPtr client) REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq); - if (!(screens = malloc(count * sizeof(*screens)))) + if (!(screens = xallocarray(count, sizeof(*screens)))) return BadAlloc; - if (!(windows = malloc(count * sizeof(*windows)))) { + if (!(windows = xallocarray(count, sizeof(*windows)))) { free(screens); return BadAlloc; } - if (!(pos = malloc(count * sizeof(*pos)))) { + if (!(pos = xallocarray(count, sizeof(*pos)))) { free(windows); free(screens); return BadAlloc; } - if (!(vis = malloc(count * sizeof(*vis)))) { + if (!(vis = xallocarray(count, sizeof(*vis)))) { free(pos); free(windows); free(screens); diff --git a/xorg-server/hw/dmx/dmxcmap.c b/xorg-server/hw/dmx/dmxcmap.c index 450627b40..7a87a9864 100644 --- a/xorg-server/hw/dmx/dmxcmap.c +++ b/xorg-server/hw/dmx/dmxcmap.c @@ -177,7 +177,7 @@ dmxStoreColors(ColormapPtr pColormap, int ndef, xColorItem * pdef) dmxColormapPrivPtr pCmapPriv = DMX_GET_COLORMAP_PRIV(pColormap); if (dmxScreen->beDisplay && (pColormap->pVisual->class & DynamicClass)) { - XColor *color = malloc(sizeof(*color) * ndef); + XColor *color = xallocarray(ndef, sizeof(*color)); int i; if (color) { diff --git a/xorg-server/hw/dmx/dmxcursor.c b/xorg-server/hw/dmx/dmxcursor.c index 70f2bc4b4..0ef800e39 100644 --- a/xorg-server/hw/dmx/dmxcursor.c +++ b/xorg-server/hw/dmx/dmxcursor.c @@ -203,7 +203,7 @@ miPointerScreenFuncRec dmxPointerCursorFuncs = { static int * dmxSLCreate(void) { - int *list = malloc(dmxNumScreens * sizeof(*list)); + int *list = xallocarray(dmxNumScreens, sizeof(*list)); int i; for (i = 0; i < dmxNumScreens; i++) diff --git a/xorg-server/hw/dmx/dmxextension.c b/xorg-server/hw/dmx/dmxextension.c index fcc97e3df..75d7166f3 100644 --- a/xorg-server/hw/dmx/dmxextension.c +++ b/xorg-server/hw/dmx/dmxextension.c @@ -1188,8 +1188,8 @@ dmxBERestoreRenderGlyph(void *value, XID id, void *n) /* Now allocate the memory we need */ images = calloc(len_images, sizeof(char)); - gids = malloc(glyphSet->hash.tableEntries * sizeof(Glyph)); - glyphs = malloc(glyphSet->hash.tableEntries * sizeof(XGlyphInfo)); + gids = xallocarray(glyphSet->hash.tableEntries, sizeof(Glyph)); + glyphs = xallocarray(glyphSet->hash.tableEntries, sizeof(XGlyphInfo)); pos = images; ctr = 0; diff --git a/xorg-server/hw/dmx/dmxfont.c b/xorg-server/hw/dmx/dmxfont.c index 115422d41..25a04a6f0 100644 --- a/xorg-server/hw/dmx/dmxfont.c +++ b/xorg-server/hw/dmx/dmxfont.c @@ -72,7 +72,7 @@ dmxGetFontPath(int *npaths) newfp = malloc(*npaths + len); c = (unsigned char *) newfp; - fp = malloc(*npaths * sizeof(*fp)); + fp = xallocarray(*npaths, sizeof(*fp)); memmove(newfp, paths + 1, *npaths + len - 1); l = *paths; @@ -306,7 +306,7 @@ dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont) if (!dmxFontPath) dmxLog(dmxWarning, "No default font path is set.\n"); - goodfps = malloc(npaths * sizeof(*goodfps)); + goodfps = xallocarray(npaths, sizeof(*goodfps)); dmxLog(dmxError, "The DMX server failed to set the following font paths on " @@ -354,7 +354,7 @@ dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont) return FALSE; } - newfp = malloc(len * sizeof(*newfp)); + newfp = xallocarray(len, sizeof(*newfp)); for (i = 0; i < npaths; i++) { if (goodfps[i]) { int n = strlen(fp[i]); diff --git a/xorg-server/hw/dmx/dmxgc.c b/xorg-server/hw/dmx/dmxgc.c index ec15d27aa..c4789a607 100644 --- a/xorg-server/hw/dmx/dmxgc.c +++ b/xorg-server/hw/dmx/dmxgc.c @@ -397,7 +397,7 @@ dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects) } else { if (dmxScreen->beDisplay) { nRects = RegionNumRects((RegionPtr) pGC->clientClip); - pRects = malloc(nRects * sizeof(*pRects)); + pRects = xallocarray(nRects, sizeof(*pRects)); pBox = RegionRects((RegionPtr) pGC->clientClip); for (i = 0; i < nRects; i++) { diff --git a/xorg-server/hw/dmx/dmxinit.c b/xorg-server/hw/dmx/dmxinit.c index 2d3b2e9e0..24b0b4ebb 100644 --- a/xorg-server/hw/dmx/dmxinit.c +++ b/xorg-server/hw/dmx/dmxinit.c @@ -438,7 +438,7 @@ dmxGetColormaps(DMXScreenInfo * dmxScreen) int i; dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals; - dmxScreen->beDefColormaps = malloc(dmxScreen->beNumDefColormaps * + dmxScreen->beDefColormaps = xallocarray(dmxScreen->beNumDefColormaps, sizeof(*dmxScreen->beDefColormaps)); for (i = 0; i < dmxScreen->beNumDefColormaps; i++) @@ -793,7 +793,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[]) nconfigs = dmxScreen->numGlxVisuals; } - configprivs = malloc(nconfigs * sizeof(dmxGlxVisualPrivate *)); + configprivs = xallocarray(nconfigs, sizeof(dmxGlxVisualPrivate *)); if (configs != NULL && configprivs != NULL) { int j; diff --git a/xorg-server/hw/dmx/dmxpict.c b/xorg-server/hw/dmx/dmxpict.c index aaca178b9..1f1022ee6 100644 --- a/xorg-server/hw/dmx/dmxpict.c +++ b/xorg-server/hw/dmx/dmxpict.c @@ -390,7 +390,7 @@ dmxProcRenderAddGlyphs(ClientPtr client) sizeof(xRenderAddGlyphsReq) - (sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs); - gidsCopy = malloc(sizeof(*gidsCopy) * nglyphs); + gidsCopy = xallocarray(nglyphs, sizeof(*gidsCopy)); for (i = 0; i < nglyphs; i++) gidsCopy[i] = gids[i]; @@ -434,7 +434,7 @@ dmxProcRenderFreeGlyphs(ClientPtr client) nglyphs = ((client->req_len << 2) - sizeof(xRenderFreeGlyphsReq)) >> 2; if (nglyphs) { - gids = malloc(sizeof(*gids) * nglyphs); + gids = xallocarray(nglyphs, sizeof(*gids)); for (i = 0; i < nglyphs; i++) gids[i] = ((CARD32 *) (stuff + 1))[i]; @@ -569,11 +569,11 @@ dmxProcRenderCompositeGlyphs(ClientPtr client) /* The following only works for Render version > 0.2 */ /* All of the XGlyphElt* structure sizes are identical */ - elts = malloc(nelt * sizeof(XGlyphElt8)); + elts = xallocarray(nelt, sizeof(XGlyphElt8)); if (!elts) return BadAlloc; - glyphs = malloc(nglyph * size); + glyphs = xallocarray(nglyph, size); if (!glyphs) { free(elts); return BadAlloc; @@ -925,7 +925,7 @@ dmxChangePictureClip(PicturePtr pPicture, int clipType, void *value, int n) int nRects; nRects = nBox; - pRects = pRect = malloc(nRects * sizeof(*pRect)); + pRects = pRect = xallocarray(nRects, sizeof(*pRect)); while (nBox--) { pRect->x = pBox->x1; diff --git a/xorg-server/hw/dmx/dmxprop.c b/xorg-server/hw/dmx/dmxprop.c index 5e306d286..4c85268b7 100644 --- a/xorg-server/hw/dmx/dmxprop.c +++ b/xorg-server/hw/dmx/dmxprop.c @@ -171,7 +171,7 @@ dmxPropertyCheckOtherServers(DMXScreenInfo * dmxScreen, Atom atom) dmxLogOutputWarning(dmxScreen, "%s also running on %s\n", tp.value, dmxScreen->name); - list = realloc(list, ++count * sizeof(*list)); + list = reallocarray(list, ++count, sizeof(*list)); list[count - 1] = malloc(tp.nitems + 2); strncpy(list[count - 1], (char *) tp.value, tp.nitems + 1); } diff --git a/xorg-server/hw/dmx/dmxwindow.c b/xorg-server/hw/dmx/dmxwindow.c index c157e1099..dcdb9ac60 100644 --- a/xorg-server/hw/dmx/dmxwindow.c +++ b/xorg-server/hw/dmx/dmxwindow.c @@ -969,7 +969,7 @@ dmxDoSetShape(WindowPtr pWindow) if (wBoundingShape(pWindow)) { pBox = RegionRects(wBoundingShape(pWindow)); nRect = nBox = RegionNumRects(wBoundingShape(pWindow)); - pRectFirst = pRect = malloc(nRect * sizeof(*pRect)); + pRectFirst = pRect = xallocarray(nRect, sizeof(*pRect)); while (nBox--) { pRect->x = pBox->x1; pRect->y = pBox->y1; @@ -992,7 +992,7 @@ dmxDoSetShape(WindowPtr pWindow) if (wClipShape(pWindow)) { pBox = RegionRects(wClipShape(pWindow)); nRect = nBox = RegionNumRects(wClipShape(pWindow)); - pRectFirst = pRect = malloc(nRect * sizeof(*pRect)); + pRectFirst = pRect = xallocarray(nRect, sizeof(*pRect)); while (nBox--) { pRect->x = pBox->x1; pRect->y = pBox->y1; diff --git a/xorg-server/hw/dmx/glxProxy/glxcmds.c b/xorg-server/hw/dmx/glxProxy/glxcmds.c index 4c500c93d..ddcb98135 100644 --- a/xorg-server/hw/dmx/glxProxy/glxcmds.c +++ b/xorg-server/hw/dmx/glxProxy/glxcmds.c @@ -284,11 +284,11 @@ CreateContext(__GLXclientState * cl, * allocate memory for back-end servers info */ num_be_screens = to_screen - from_screen + 1; - glxc->real_ids = (XID *) malloc(sizeof(XID) * num_be_screens); + glxc->real_ids = xallocarray(num_be_screens, sizeof(XID)); if (!glxc->real_ids) { return BadAlloc; } - glxc->real_vids = (XID *) malloc(sizeof(XID) * num_be_screens); + glxc->real_vids = xallocarray(num_be_screens, sizeof(XID)); if (!glxc->real_vids) { return BadAlloc; } @@ -685,22 +685,16 @@ AddCurrentContext(__GLXclientState * cl, __GLXcontext * glxc, DrawablePtr pDraw) if (!num) { table = (__GLXcontext **) malloc(sizeof(__GLXcontext *)); cl->currentDrawables = (DrawablePtr *) malloc(sizeof(DrawablePtr)); - cl->be_currentCTag = - (GLXContextTag *) malloc(screenInfo.numScreens * - sizeof(GLXContextTag)); + cl->be_currentCTag = xallocarray(screenInfo.numScreens, + sizeof(GLXContextTag)); } else { - table = (__GLXcontext **) realloc(table, - (num + 1) * sizeof(__GLXcontext *)); - cl->currentDrawables = (DrawablePtr *) realloc(cl->currentDrawables, - (num + - 1) * - sizeof(DrawablePtr)); - cl->be_currentCTag = - (GLXContextTag *) realloc(cl->be_currentCTag, - (num + - 1) * screenInfo.numScreens * - sizeof(GLXContextTag)); + table = reallocarray(table, num + 1, sizeof(__GLXcontext *)); + cl->currentDrawables = reallocarray(cl->currentDrawables, num + 1, + sizeof(DrawablePtr)); + cl->be_currentCTag = reallocarray(cl->be_currentCTag, + (num + 1) * screenInfo.numScreens, + sizeof(GLXContextTag)); } table[num] = glxc; cl->currentDrawables[num] = pDraw; @@ -1896,7 +1890,7 @@ CreateGLXPixmap(__GLXclientState * cl, if (!pGlxPixmap) { return BadAlloc; } - pGlxPixmap->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens); + pGlxPixmap->be_xids = xallocarray(screenInfo.numScreens, sizeof(XID)); if (!pGlxPixmap->be_xids) { free(pGlxPixmap); return BadAlloc; @@ -3356,7 +3350,7 @@ __glXCreatePbuffer(__GLXclientState * cl, GLbyte * pc) return BadAlloc; } - pGlxPbuffer->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens); + pGlxPbuffer->be_xids = xallocarray(screenInfo.numScreens, sizeof(XID)); if (!pGlxPbuffer->be_xids) { free(pGlxPbuffer); return BadAlloc; @@ -3617,13 +3611,13 @@ __glXGetDrawableAttributes(__GLXclientState * cl, GLbyte * pc) } if (reply.numAttribs) { - attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32; - attribs = (CARD32 *) malloc(attribs_size); + attribs = xallocarray(reply.numAttribs, 2 * __GLX_SIZE_CARD32); if (attribs == NULL) { UnlockDisplay(dpy); SyncHandle(); return BadAlloc; } + attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32; _XRead(dpy, (char *) attribs, attribs_size); } diff --git a/xorg-server/hw/dmx/glxProxy/glxscreens.c b/xorg-server/hw/dmx/glxProxy/glxscreens.c index 15bb1e862..508e67ed4 100644 --- a/xorg-server/hw/dmx/glxProxy/glxscreens.c +++ b/xorg-server/hw/dmx/glxProxy/glxscreens.c @@ -129,7 +129,7 @@ CalcServerVersionAndExtensions(void) /* * read extensions strings of all back-end servers */ - be_extensions = (char **) malloc(__glXNumActiveScreens * sizeof(char *)); + be_extensions = xallocarray(__glXNumActiveScreens, sizeof(char *)); if (!be_extensions) return; @@ -237,10 +237,9 @@ __glXScreenInit(GLint numscreens) // find the set of FBConfigs that are present on all back-end // servers - only those configs will be supported */ - __glXFBConfigs = (__GLXFBConfig **) malloc(dmxScreen0->numFBConfigs * - (numscreens + - 1) * - sizeof(__GLXFBConfig *)); + __glXFBConfigs = + xallocarray(dmxScreen0->numFBConfigs * (numscreens + 1), + sizeof(__GLXFBConfig *)); __glXNumFBConfigs = 0; for (c = 0; c < dmxScreen0->numFBConfigs; c++) { diff --git a/xorg-server/hw/dmx/input/dmxarg.c b/xorg-server/hw/dmx/input/dmxarg.c index 4a74b4c9e..6c21ae959 100644 --- a/xorg-server/hw/dmx/input/dmxarg.c +++ b/xorg-server/hw/dmx/input/dmxarg.c @@ -86,7 +86,7 @@ void dmxArgAdd(dmxArg a, const char *string) { if (a->argm <= a->argc + 2) - a->argv = realloc(a->argv, sizeof(*a->argv) * (a->argm *= 2)); + a->argv = reallocarray(a->argv, (a->argm *= 2), sizeof(*a->argv)); a->argv[a->argc++] = strdup(string); a->argv[a->argc] = NULL; } diff --git a/xorg-server/hw/dmx/input/dmxinputinit.c b/xorg-server/hw/dmx/input/dmxinputinit.c index 56a39df8c..cdefd9ae0 100644 --- a/xorg-server/hw/dmx/input/dmxinputinit.c +++ b/xorg-server/hw/dmx/input/dmxinputinit.c @@ -814,8 +814,8 @@ dmxInputCopyLocal(DMXInputInfo * dmxInput, DMXLocalInputInfoPtr s) dmxLocal->deviceId = -1; ++dmxInput->numDevs; - dmxInput->devs = realloc(dmxInput->devs, - dmxInput->numDevs * sizeof(*dmxInput->devs)); + dmxInput->devs = reallocarray(dmxInput->devs, + dmxInput->numDevs, sizeof(*dmxInput->devs)); dmxInput->devs[dmxInput->numDevs - 1] = dmxLocal; return dmxLocal; diff --git a/xorg-server/hw/dmx/input/dmxmotion.c b/xorg-server/hw/dmx/input/dmxmotion.c index 1642894a2..7f2cb8ed9 100644 --- a/xorg-server/hw/dmx/input/dmxmotion.c +++ b/xorg-server/hw/dmx/input/dmxmotion.c @@ -113,9 +113,8 @@ dmxPointerPutMotionEvent(DeviceIntPtr pDevice, int i; if (!dmxLocal->history) { - dmxLocal->history = malloc(sizeof(*dmxLocal->history) - * (numAxes + 1) - * DMX_MOTION_SIZE); + dmxLocal->history = xallocarray(numAxes + 1, + sizeof(*dmxLocal->history) * DMX_MOTION_SIZE); dmxLocal->head = 0; dmxLocal->tail = 0; dmxLocal->valuators = calloc(sizeof(*dmxLocal->valuators), numAxes); diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c index 3d5cf7721..748b608c2 100644 --- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c +++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c @@ -431,8 +431,8 @@ EphyrDuplicateVisual(unsigned int a_screen, * extend the list of visual IDs in that entry, * so to add a_new_id in there. */ - vids = realloc(cur_depth->vids, - (cur_depth->numVids + 1) * sizeof(VisualID)); + vids = reallocarray(cur_depth->vids, + cur_depth->numVids + 1, sizeof(VisualID)); if (!vids) { EPHYR_LOG_ERROR("failed to realloc numids\n"); goto out; diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c index 65b1a47fc..46070c28d 100755 --- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c +++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c @@ -52,6 +52,13 @@ void processScreenOrOutputArg(const char *screen_size, const char *output, char void processOutputArg(const char *output, char *parent_id); void processScreenArg(const char *screen_size, char *parent_id); +int +main(int argc, char *argv[], char *envp[]) +{ + hostx_use_resname(basename(argv[0]), 0); + return dix_main(argc, argv, envp); +} + void InitCard(char *name) { @@ -212,10 +219,6 @@ ddxProcessArgument(int argc, char **argv, int i) EPHYR_DBG("mark argv[%d]='%s'", i, argv[i]); - if (i == 1) { - hostx_use_resname(basename(argv[0]), 0); - } - if (!strcmp(argv[i], "-parent")) { if (i + 1 < argc) { int j; diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c index 14d4a6c23..63412d317 100755 --- a/xorg-server/hw/kdrive/ephyr/hostx.c +++ b/xorg-server/hw/kdrive/ephyr/hostx.c @@ -131,8 +131,8 @@ hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num, Boo int index = HostX.n_screens; HostX.n_screens += 1; - HostX.screens = realloc(HostX.screens, - HostX.n_screens * sizeof(HostX.screens[0])); + HostX.screens = reallocarray(HostX.screens, + HostX.n_screens, sizeof(HostX.screens[0])); HostX.screens[index] = screen; scrpriv->screen = screen; @@ -183,7 +183,7 @@ hostx_set_win_title(KdScreenInfo *screen, const char *extra_text) memset(buf, 0, BUF_LEN + 1); snprintf(buf, BUF_LEN, "Xephyr on %s.%d %s", - HostX.server_dpy_name, + HostX.server_dpy_name ? HostX.server_dpy_name : ":0", scrpriv->mynum, (extra_text != NULL) ? extra_text : ""); xcb_icccm_set_wm_name(HostX.conn, @@ -808,7 +808,7 @@ hostx_screen_init(KdScreenInfo *screen, } EPHYR_DBG("host_screen=%p x=%d, y=%d, wxh=%dx%d, buffer_height=%d", - host_screen, x, y, width, height, buffer_height); + screen, x, y, width, height, buffer_height); if (scrpriv->ximg != NULL) { /* Free up the image data if previously used @@ -884,8 +884,13 @@ __asm int 3; ~0, NULL); + /* Match server byte order so that the image can be converted to + * the native byte order by xcb_image_put() before drawing */ + if (host_depth_matches_server(scrpriv)) + scrpriv->ximg->byte_order = IMAGE_BYTE_ORDER; + scrpriv->ximg->data = - malloc(scrpriv->ximg->stride * buffer_height); + xallocarray(scrpriv->ximg->stride, buffer_height); } { @@ -951,7 +956,7 @@ __asm int 3; *bits_per_pixel = scrpriv->server_depth; EPHYR_DBG("server bpp %i", bytes_per_pixel); - scrpriv->fb_data = malloc (stride * buffer_height); + scrpriv->fb_data = xallocarray (stride, buffer_height); return scrpriv->fb_data; } } @@ -1056,8 +1061,11 @@ hostx_paint_rect(KdScreenInfo *screen, #endif } else { - xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, scrpriv->ximg, - dx, dy, 0); + /* This is slow and could be done better */ + xcb_image_t *img = xcb_image_native (HostX.conn, scrpriv->ximg, 1); + xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, img, 0, 0, 0); + if (scrpriv->ximg != img) + xcb_image_destroy(img); } xcb_aux_sync(HostX.conn); @@ -1174,9 +1182,9 @@ hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries) for (; depths.rem; xcb_depth_next(&depths)) { xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data); EphyrHostVisualInfo *tmp_visuals = - realloc(host_visuals, - (nb_items + depths.data->visuals_len) - * sizeof(EphyrHostVisualInfo)); + reallocarray(host_visuals, + nb_items + depths.data->visuals_len, + sizeof(EphyrHostVisualInfo)); if (!tmp_visuals) { goto out; } diff --git a/xorg-server/hw/kdrive/fake/Makefile.am b/xorg-server/hw/kdrive/fake/Makefile.am index 14c99c3cc..d28bd2752 100644 --- a/xorg-server/hw/kdrive/fake/Makefile.am +++ b/xorg-server/hw/kdrive/fake/Makefile.am @@ -18,6 +18,7 @@ Xfake_SOURCES = \ Xfake_LDADD = \ libfake.la \ + @KDRIVE_MAIN_LIB@ \ @KDRIVE_LIBS@ Xfake_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) diff --git a/xorg-server/hw/kdrive/fake/fake.c b/xorg-server/hw/kdrive/fake/fake.c index 90e3ec9a6..04a727897 100644 --- a/xorg-server/hw/kdrive/fake/fake.c +++ b/xorg-server/hw/kdrive/fake/fake.c @@ -158,7 +158,7 @@ fakeMapFramebuffer(KdScreenInfo * screen) priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2; free(priv->base); - priv->base = malloc(priv->bytes_per_line * screen->height); + priv->base = xallocarray(priv->bytes_per_line, screen->height); if (scrpriv->shadow) { if (!KdShadowFbAlloc diff --git a/xorg-server/hw/kdrive/fbdev/Makefile.am b/xorg-server/hw/kdrive/fbdev/Makefile.am index 7e8ba024c..d550c1391 100644 --- a/xorg-server/hw/kdrive/fbdev/Makefile.am +++ b/xorg-server/hw/kdrive/fbdev/Makefile.am @@ -16,6 +16,7 @@ Xfbdev_SOURCES = \ Xfbdev_LDADD = \ libfbdev.la \ + @KDRIVE_MAIN_LIB@ \ @KDRIVE_LIBS@ Xfbdev_DEPENDENCIES = \ diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.c b/xorg-server/hw/kdrive/fbdev/fbdev.c index 95f64cbef..23f750924 100644 --- a/xorg-server/hw/kdrive/fbdev/fbdev.c +++ b/xorg-server/hw/kdrive/fbdev/fbdev.c @@ -677,7 +677,7 @@ fbdevCreateColormap(ColormapPtr pmap) case FB_VISUAL_STATIC_PSEUDOCOLOR: pVisual = pmap->pVisual; nent = pVisual->ColormapEntries; - pdefs = malloc(nent * sizeof(xColorItem)); + pdefs = xallocarray(nent, sizeof(xColorItem)); if (!pdefs) return FALSE; for (i = 0; i < nent; i++) diff --git a/xorg-server/hw/kdrive/src/kshadow.c b/xorg-server/hw/kdrive/src/kshadow.c index 828ea19a6..7f1e2ee19 100644 --- a/xorg-server/hw/kdrive/src/kshadow.c +++ b/xorg-server/hw/kdrive/src/kshadow.c @@ -36,7 +36,7 @@ KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate) /* use fb computation for width */ paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits); - buf = malloc(paddedWidth * height); + buf = xallocarray(paddedWidth, height); if (!buf) return FALSE; if (screen->fb.shadow) diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c index 369db3332..844deca0d 100644 --- a/xorg-server/hw/kdrive/src/kxv.c +++ b/xorg-server/hw/kdrive/src/kxv.c @@ -327,8 +327,8 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr infoPtr, int number) void *moreSpace; totFormat *= 2; - moreSpace = realloc(pFormat, - totFormat * sizeof(XvFormatRec)); + moreSpace = reallocarray(pFormat, totFormat, + sizeof(XvFormatRec)); if (!moreSpace) break; pFormat = moreSpace; diff --git a/xorg-server/hw/vfb/InitOutput.c b/xorg-server/hw/vfb/InitOutput.c index bcaaa85e4..8b867e3b9 100644 --- a/xorg-server/hw/vfb/InitOutput.c +++ b/xorg-server/hw/vfb/InitOutput.c @@ -292,7 +292,7 @@ ddxProcessArgument(int argc, char *argv[], int i) if (vfbNumScreens <= screenNum) { vfbScreens = - realloc(vfbScreens, sizeof(*vfbScreens) * (screenNum + 1)); + reallocarray(vfbScreens, screenNum + 1, sizeof(*vfbScreens)); if (!vfbScreens) FatalError("Not enough memory for screen %d\n", screenNum); for (; vfbNumScreens <= screenNum; ++vfbNumScreens) @@ -407,9 +407,9 @@ vfbInstallColormap(ColormapPtr pmap) swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue); swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries); - ppix = (Pixel *) malloc(entries * sizeof(Pixel)); - prgb = (xrgb *) malloc(entries * sizeof(xrgb)); - defs = (xColorItem *) malloc(entries * sizeof(xColorItem)); + ppix = xallocarray(entries, sizeof(Pixel)); + prgb = xallocarray(entries, sizeof(xrgb)); + defs = xallocarray(entries, sizeof(xColorItem)); for (i = 0; i < entries; i++) ppix[i] = i; diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c index 1450afbfc..6b8d0eb89 100644 --- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c +++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c @@ -105,7 +105,7 @@ AppendToList(const char *s, const char ***list, int *lines) str = xnfstrdup(s); for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) { (*lines)++; - *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list)); + *list = xnfreallocarray(*list, *lines + 1, sizeof(**list)); newstr = xnfalloc(strlen(p) + 2); strcpy(newstr, p); strcat(newstr, "\n"); diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c index 889294fe7..bd36fc5ab 100644 --- a/xorg-server/hw/xfree86/common/xf86Bus.c +++ b/xorg-server/hw/xfree86/common/xf86Bus.c @@ -256,11 +256,11 @@ int xf86AllocateEntity(void) { xf86NumEntities++; - xf86Entities = xnfrealloc(xf86Entities, - sizeof(EntityPtr) * xf86NumEntities); + xf86Entities = xnfreallocarray(xf86Entities, + xf86NumEntities, sizeof(EntityPtr)); xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec)); xf86Entities[xf86NumEntities - 1]->entityPrivates = - xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1); + xnfcalloc(xf86EntityPrivateCount, sizeof(DevUnion)); return xf86NumEntities - 1; } @@ -326,12 +326,13 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex) } pScrn->numEntities++; - pScrn->entityList = xnfrealloc(pScrn->entityList, - pScrn->numEntities * sizeof(int)); + pScrn->entityList = xnfreallocarray(pScrn->entityList, + pScrn->numEntities, sizeof(int)); pScrn->entityList[pScrn->numEntities - 1] = entityIndex; xf86Entities[entityIndex]->inUse = TRUE; - pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList, - pScrn->numEntities * sizeof(int)); + pScrn->entityInstanceList = xnfreallocarray(pScrn->entityInstanceList, + pScrn->numEntities, + sizeof(int)); pScrn->entityInstanceList[pScrn->numEntities - 1] = 0; } @@ -427,8 +428,8 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev) pEnt = xf86Entities[entityIndex]; pEnt->numInstances++; - pEnt->devices = xnfrealloc(pEnt->devices, - pEnt->numInstances * sizeof(GDevPtr)); + pEnt->devices = xnfreallocarray(pEnt->devices, + pEnt->numInstances, sizeof(GDevPtr)); pEnt->devices[pEnt->numInstances - 1] = dev; dev->claimed = TRUE; } @@ -670,8 +671,8 @@ xf86AllocateEntityPrivateIndex(void) idx = xf86EntityPrivateCount++; for (i = 0; i < xf86NumEntities; i++) { pEnt = xf86Entities[i]; - nprivs = xnfrealloc(pEnt->entityPrivates, - xf86EntityPrivateCount * sizeof(DevUnion)); + nprivs = xnfreallocarray(pEnt->entityPrivates, + xf86EntityPrivateCount, sizeof(DevUnion)); /* Zero the new private */ memset(&nprivs[idx], 0, sizeof(DevUnion)); pEnt->entityPrivates = nprivs; diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c index d42572f38..b8ec8a0ef 100644 --- a/xorg-server/hw/xfree86/common/xf86Config.c +++ b/xorg-server/hw/xfree86/common/xf86Config.c @@ -126,7 +126,7 @@ static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, MessageType from); static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor); static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, - Bool active); + Bool active, Bool gpu); static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input, MessageType from); static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display); @@ -363,8 +363,8 @@ xf86ModulelistFromConfig(void ***optlist) /* * allocate the memory and walk the list again to fill in the pointers */ - modulearray = xnfalloc((count + 1) * sizeof(char *)); - optarray = xnfalloc((count + 1) * sizeof(void *)); + modulearray = xnfallocarray(count + 1, sizeof(char *)); + optarray = xnfallocarray(count + 1, sizeof(void *)); count = 0; if (xf86configptr->conf_modules) { modp = xf86configptr->conf_modules->mod_load_lst; @@ -390,7 +390,7 @@ const char ** xf86DriverlistFromConfig(void) { int count = 0; - int j; + int j, k; const char **modulearray; screenLayoutPtr slp; @@ -411,8 +411,10 @@ xf86DriverlistFromConfig(void) */ if (xf86ConfigLayout.screens) { slp = xf86ConfigLayout.screens; - while ((slp++)->screen) { + while (slp->screen) { count++; + count += slp->screen->num_gpu_devices; + slp++; } } @@ -429,12 +431,16 @@ xf86DriverlistFromConfig(void) /* * allocate the memory and walk the list again to fill in the pointers */ - modulearray = xnfalloc((count + 1) * sizeof(char *)); + modulearray = xnfallocarray(count + 1, sizeof(char *)); count = 0; slp = xf86ConfigLayout.screens; while (slp->screen) { modulearray[count] = slp->screen->device->driver; count++; + for (k = 0; k < slp->screen->num_gpu_devices; k++) { + modulearray[count] = slp->screen->gpu_devices[k]->driver; + count++; + } slp++; } @@ -493,7 +499,7 @@ xf86InputDriverlistFromConfig(void) /* * allocate the memory and walk the list again to fill in the pointers */ - modulearray = xnfalloc((count + 1) * sizeof(char *)); + modulearray = xnfallocarray(count + 1, sizeof(char *)); count = 0; idp = xf86ConfigLayout.inputs; while (idp && *idp) { @@ -1086,7 +1092,7 @@ addDevice(InputInfoPtr * list, InputInfoPtr pInfo) for (devs = list; devs && *devs; devs++) count++; - list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr)); + list = xnfreallocarray(list, count + 1, sizeof(InputInfoPtr)); list[count] = NULL; list[count - 1] = pInfo; @@ -1502,7 +1508,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, if (!count) /* alloc enough storage even if no screen is specified */ count = 1; - slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec)); + slp = xnfcalloc((count + 1), sizeof(screenLayoutRec)); slp[count].screen = NULL; /* * now that we have storage, loop over the list again and fill in our @@ -1626,12 +1632,12 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, } DebugF("Found %d inactive devices in the layout section %s\n", count, conf_layout->lay_identifier); - gdp = xnfalloc((count + 1) * sizeof(GDevRec)); + gdp = xnfallocarray(count + 1, sizeof(GDevRec)); gdp[count].identifier = NULL; idp = conf_layout->lay_inactive_lst; count = 0; while (idp) { - if (!configDevice(&gdp[count], idp->inactive_device, FALSE)) + if (!configDevice(&gdp[count], idp->inactive_device, FALSE, FALSE)) goto bail; count++; idp = (XF86ConfInactivePtr) idp->list.next; @@ -1746,7 +1752,7 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor) count++; conf_port = (XF86ConfVideoPortPtr) conf_port->list.next; } - adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec)); + adaptor->ports = xnfallocarray(count, sizeof(confXvPortRec)); adaptor->numports = count; count = 0; conf_port = conf_adaptor->va_port_lst; @@ -1769,6 +1775,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, XF86ConfAdaptorLinkPtr conf_adaptor; Bool defaultMonitor = FALSE; XF86ConfScreenRec local_conf_screen; + int i; if (!conf_screen) { memset(&local_conf_screen, 0, sizeof(local_conf_screen)); @@ -1811,12 +1818,41 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n" "\tUsing the first device section listed.\n", screenp->id); } - if (configDevice(screenp->device, conf_screen->scrn_device, TRUE)) { + if (configDevice(screenp->device, conf_screen->scrn_device, TRUE, FALSE)) { screenp->device->myScreenSection = screenp; } else { screenp->device = NULL; } + + if (conf_screen->num_gpu_devices == 0 && xf86configptr->conf_device_lst) { + XF86ConfDevicePtr sdevice = xf86configptr->conf_device_lst->list.next; + + for (i = 0; i < MAX_GPUDEVICES; i++) { + if (!sdevice) + break; + + FIND_SUITABLE (XF86ConfDevicePtr, sdevice, conf_screen->scrn_gpu_devices[i]); + if (!conf_screen->scrn_gpu_devices[i]) + break; + screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec)); + if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) { + screenp->gpu_devices[i]->myScreenSection = screenp; + } + sdevice = conf_screen->scrn_gpu_devices[i]->list.next; + } + screenp->num_gpu_devices = i; + + } else { + for (i = 0; i < conf_screen->num_gpu_devices; i++) { + screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec)); + if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) { + screenp->gpu_devices[i]->myScreenSection = screenp; + } + } + screenp->num_gpu_devices = conf_screen->num_gpu_devices; + } + screenp->options = conf_screen->scrn_option_lst; /* @@ -1827,7 +1863,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, count++; dispptr = (XF86ConfDisplayPtr) dispptr->list.next; } - screenp->displays = xnfalloc((count) * sizeof(DispRec)); + screenp->displays = xnfallocarray(count, sizeof(DispRec)); screenp->numdisplays = count; /* Fill in the default Virtual size, if any */ @@ -1857,7 +1893,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, count++; conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next; } - screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec)); + screenp->xvadaptors = xnfallocarray(count, sizeof(confXvAdaptorRec)); screenp->numxvadaptors = 0; conf_adaptor = conf_screen->scrn_adaptor_lst; while (conf_adaptor) { @@ -2096,7 +2132,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display) count++; modep = (XF86ModePtr) modep->list.next; } - displayp->modes = xnfalloc((count + 1) * sizeof(char *)); + displayp->modes = xnfallocarray(count + 1, sizeof(char *)); modep = conf_display->disp_mode_lst; count = 0; while (modep) { @@ -2110,7 +2146,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display) } static Bool -configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active) +configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active, Bool gpu) { int i; @@ -2118,10 +2154,14 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active) return FALSE; } - if (active) - xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n", - conf_device->dev_identifier); - else + if (active) { + if (gpu) + xf86Msg(X_CONFIG, "| |-->GPUDevice \"%s\"\n", + conf_device->dev_identifier); + else + xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n", + conf_device->dev_identifier); + } else xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n", conf_device->dev_identifier); diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c index cc7ff1bb5..1271010fa 100644 --- a/xorg-server/hw/xfree86/common/xf86Configure.c +++ b/xorg-server/hw/xfree86/common/xf86Configure.c @@ -109,7 +109,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, /* Allocate new structure occurrence */ i = nDevToConfig++; DevToConfig = - xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); + xnfreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec)); memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); DevToConfig[i].GDev.chipID = @@ -645,10 +645,10 @@ DoConfigure(void) xf86DoConfigurePass1 = FALSE; - dev2screen = xnfcalloc(1, xf86NumDrivers * sizeof(int)); + dev2screen = xnfcalloc(xf86NumDrivers, sizeof(int)); { - Bool *driverProbed = xnfcalloc(1, xf86NumDrivers * sizeof(Bool)); + Bool *driverProbed = xnfcalloc(xf86NumDrivers, sizeof(Bool)); for (screennum = 0; screennum < nDevToConfig; screennum++) { int k, l, n, oldNumScreens; diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c index b9e1e3f88..9533e1c52 100644 --- a/xorg-server/hw/xfree86/common/xf86DGA.c +++ b/xorg-server/hw/xfree86/common/xf86DGA.c @@ -1349,7 +1349,7 @@ ProcXDGAQueryModes(ClientPtr client) return Success; } - if (!(mode = (XDGAModePtr) malloc(num * sizeof(XDGAModeRec)))) + if (!(mode = xallocarray(num, sizeof(XDGAModeRec)))) return BadAlloc; for (i = 0; i < num; i++) diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index e2b32a074..359bac762 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -77,8 +77,8 @@ xf86AddDriver(DriverPtr driver, void *module, int flags) xf86NumDrivers = 0; xf86NumDrivers++; - xf86DriverList = xnfrealloc(xf86DriverList, - xf86NumDrivers * sizeof(DriverPtr)); + xf86DriverList = xnfreallocarray(xf86DriverList, + xf86NumDrivers, sizeof(DriverPtr)); xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec)); if (flags & HaveDriverFuncs) *xf86DriverList[xf86NumDrivers - 1] = *driver; @@ -117,9 +117,9 @@ xf86AddInputDriver(InputDriverPtr driver, void *module, int flags) xf86NumInputDrivers = 0; xf86NumInputDrivers++; - xf86InputDriverList = xnfrealloc(xf86InputDriverList, - xf86NumInputDrivers * - sizeof(InputDriverPtr)); + xf86InputDriverList = xnfreallocarray(xf86InputDriverList, + xf86NumInputDrivers, + sizeof(InputDriverPtr)); xf86InputDriverList[xf86NumInputDrivers - 1] = xnfalloc(sizeof(InputDriverRec)); *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver; @@ -173,7 +173,8 @@ xf86AllocateScreen(DriverPtr drv, int flags) if (xf86GPUScreens == NULL) xf86NumGPUScreens = 0; i = xf86NumGPUScreens++; - xf86GPUScreens = xnfrealloc(xf86GPUScreens, xf86NumGPUScreens * sizeof(ScrnInfoPtr)); + xf86GPUScreens = xnfreallocarray(xf86GPUScreens, xf86NumGPUScreens, + sizeof(ScrnInfoPtr)); xf86GPUScreens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); pScrn = xf86GPUScreens[i]; pScrn->scrnIndex = i + GPU_SCREEN_OFFSET; /* Changes when a screen is removed */ @@ -183,7 +184,8 @@ xf86AllocateScreen(DriverPtr drv, int flags) xf86NumScreens = 0; i = xf86NumScreens++; - xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr)); + xf86Screens = xnfreallocarray(xf86Screens, xf86NumScreens, + sizeof(ScrnInfoPtr)); xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); pScrn = xf86Screens[i]; @@ -293,16 +295,16 @@ xf86AllocateScrnInfoPrivateIndex(void) idx = xf86ScrnInfoPrivateCount++; for (i = 0; i < xf86NumScreens; i++) { pScr = xf86Screens[i]; - nprivs = xnfrealloc(pScr->privates, - xf86ScrnInfoPrivateCount * sizeof(DevUnion)); + nprivs = xnfreallocarray(pScr->privates, + xf86ScrnInfoPrivateCount, sizeof(DevUnion)); /* Zero the new private */ memset(&nprivs[idx], 0, sizeof(DevUnion)); pScr->privates = nprivs; } for (i = 0; i < xf86NumGPUScreens; i++) { pScr = xf86GPUScreens[i]; - nprivs = xnfrealloc(pScr->privates, - xf86ScrnInfoPrivateCount * sizeof(DevUnion)); + nprivs = xnfreallocarray(pScr->privates, + xf86ScrnInfoPrivateCount, sizeof(DevUnion)); /* Zero the new private */ memset(&nprivs[idx], 0, sizeof(DevUnion)); pScr->privates = nprivs; @@ -636,8 +638,8 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp, if (i == scrp->confScreen->numdisplays) { scrp->confScreen->numdisplays++; scrp->confScreen->displays = - xnfrealloc(scrp->confScreen->displays, - scrp->confScreen->numdisplays * sizeof(DispRec)); + xnfreallocarray(scrp->confScreen->displays, + scrp->confScreen->numdisplays, sizeof(DispRec)); xf86DrvMsg(scrp->scrnIndex, X_INFO, "Creating default Display subsection in Screen section\n" "\t\"%s\" for depth/fbbpp %d/%d\n", @@ -1367,7 +1369,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist) { GDevPtr gdp, *pgdp = NULL; confScreenPtr screensecptr; - int i, j; + int i, j, k; if (sectlist) *sectlist = NULL; @@ -1408,9 +1410,20 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist) /* * we have a matching driver that wasn't claimed, yet */ - pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr)); pgdp[i++] = screensecptr->device; } + for (k = 0; k < screensecptr->num_gpu_devices; k++) { + if ((screensecptr->gpu_devices[k]->driver != NULL) + && (xf86NameCmp(screensecptr->gpu_devices[k]->driver, drivername) == 0) + && (!screensecptr->gpu_devices[k]->claimed)) { + /* + * we have a matching driver that wasn't claimed, yet + */ + pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp[i++] = screensecptr->gpu_devices[k]; + } + } } /* Then handle the inactive devices */ @@ -1420,7 +1433,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist) if (gdp->driver && !gdp->claimed && !xf86NameCmp(gdp->driver, drivername)) { /* we have a matching driver that wasn't claimed yet */ - pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr)); pgdp[i++] = gdp; } j++; diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c index 9fa3dc43c..55bf2bbe4 100644 --- a/xorg-server/hw/xfree86/common/xf86Xinput.c +++ b/xorg-server/hw/xfree86/common/xf86Xinput.c @@ -867,8 +867,9 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable) if (fd != -1) { if (paused) { /* Put on new_input_devices list for delayed probe */ - new_input_devices = xnfrealloc(new_input_devices, - sizeof(pInfo) * (new_input_devices_count + 1)); + new_input_devices = xnfreallocarray(new_input_devices, + new_input_devices_count + 1, + sizeof(pInfo)); new_input_devices[new_input_devices_count] = pInfo; new_input_devices_count++; systemd_logind_release_fd(pInfo->major, pInfo->minor, fd); diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c index ab51f9603..704e35358 100644 --- a/xorg-server/hw/xfree86/common/xf86cmap.c +++ b/xorg-server/hw/xfree86/common/xf86cmap.c @@ -166,10 +166,10 @@ xf86HandleColormaps(ScreenPtr pScreen, elements = 1 << sigRGBbits; - if (!(gamma = malloc(elements * sizeof(LOCO)))) + if (!(gamma = xallocarray(elements, sizeof(LOCO)))) return FALSE; - if (!(indices = malloc(maxColors * sizeof(int)))) { + if (!(indices = xallocarray(maxColors, sizeof(int)))) { free(gamma); return FALSE; } @@ -270,7 +270,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap) else numColors = 1 << pmap->pVisual->nplanes; - if (!(colors = malloc(numColors * sizeof(LOCO)))) + if (!(colors = xallocarray(numColors, sizeof(LOCO)))) return FALSE; if (!(pColPriv = malloc(sizeof(CMapColormapRec)))) { diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c index 1b2cb5704..91ddedc29 100644 --- a/xorg-server/hw/xfree86/common/xf86fbman.c +++ b/xorg-server/hw/xfree86/common/xf86fbman.c @@ -317,16 +317,17 @@ localRegisterFreeBoxCallback(ScreenPtr pScreen, offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey); - newCallbacks = realloc(offman->FreeBoxesUpdateCallback, - sizeof(FreeBoxCallbackProcPtr) * - (offman->NumCallbacks + 1)); + newCallbacks = reallocarray(offman->FreeBoxesUpdateCallback, + offman->NumCallbacks + 1, + sizeof(FreeBoxCallbackProcPtr)); if (!newCallbacks) return FALSE; else offman->FreeBoxesUpdateCallback = newCallbacks; - newPrivates = realloc(offman->devPrivates, - sizeof(DevUnion) * (offman->NumCallbacks + 1)); + newPrivates = reallocarray(offman->devPrivates, + offman->NumCallbacks + 1, + sizeof(DevUnion)); if (!newPrivates) return FALSE; else diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c index e86ecb9d4..8158c2b62 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.c +++ b/xorg-server/hw/xfree86/common/xf86pciBus.c @@ -103,9 +103,9 @@ xf86PciProbe(void) while ((info = pci_device_next(iter)) != NULL) { if (PCIINFOCLASSES(info->device_class)) { num++; - xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, - (sizeof(struct pci_device *) - * (num + 1))); + xf86PciVideoInfo = xnfreallocarray(xf86PciVideoInfo, + num + 1, + sizeof(struct pci_device *)); xf86PciVideoInfo[num] = NULL; xf86PciVideoInfo[num - 1] = info; @@ -679,7 +679,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID, } pci_iterator_destroy(iter); - instances = xnfalloc(max_entries * sizeof(struct Inst)); + instances = xnfallocarray(max_entries, sizeof(struct Inst)); } iter = pci_slot_match_iterator_create(NULL); @@ -976,7 +976,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID, /* Allocate an entry in the lists to be returned */ numFound++; - retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); + retEntities = xnfreallocarray(retEntities, numFound, sizeof(int)); retEntities[numFound - 1] = xf86ClaimPciSlot(pPci, drvp, instances[i].chip, instances[i].dev, diff --git a/xorg-server/hw/xfree86/common/xf86platformBus.c b/xorg-server/hw/xfree86/common/xf86platformBus.c index c1aaba41a..f1e942378 100644 --- a/xorg-server/hw/xfree86/common/xf86platformBus.c +++ b/xorg-server/hw/xfree86/common/xf86platformBus.c @@ -59,9 +59,9 @@ struct xf86_platform_device *xf86_platform_devices; int xf86_add_platform_device(struct OdevAttributes *attribs, Bool unowned) { - xf86_platform_devices = xnfrealloc(xf86_platform_devices, - (sizeof(struct xf86_platform_device) - * (xf86_num_platform_devices + 1))); + xf86_platform_devices = xnfreallocarray(xf86_platform_devices, + xf86_num_platform_devices + 1, + sizeof(struct xf86_platform_device)); xf86_platform_devices[xf86_num_platform_devices].attribs = attribs; xf86_platform_devices[xf86_num_platform_devices].pdev = NULL; diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c index 07eb71ed8..119211dc5 100644 --- a/xorg-server/hw/xfree86/common/xf86sbusBus.c +++ b/xorg-server/hw/xfree86/common/xf86sbusBus.c @@ -68,7 +68,7 @@ CheckSbusDevice(const char *device, int fbNum) if (!sbusDeviceTable[i].devId) return; xf86SbusInfo = - xnfrealloc(xf86SbusInfo, sizeof(psdp) * (++xf86nSbusInfo + 1)); + xnfreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp)); xf86SbusInfo[xf86nSbusInfo] = NULL; xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof(sbusDevice), 1); psdp->devId = sbusDeviceTable[i].devId; @@ -406,8 +406,8 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId, if (psdp->fd == -2) continue; ++allocatedInstances; - instances = xnfrealloc(instances, - allocatedInstances * sizeof(struct Inst)); + instances = xnfreallocarray(instances, + allocatedInstances, sizeof(struct Inst)); instances[allocatedInstances - 1].sbus = psdp; instances[allocatedInstances - 1].dev = NULL; instances[allocatedInstances - 1].claimed = FALSE; @@ -532,7 +532,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId, /* Allocate an entry in the lists to be returned */ numFound++; - retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); + retEntities = xnfreallocarray(retEntities, numFound, sizeof(int)); retEntities[numFound - 1] = xf86ClaimSbusSlot(psdp, drvp, instances[i].dev, instances[i].dev->active ? TRUE : FALSE); @@ -648,7 +648,7 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, return; fbcmap.count = 0; fbcmap.index = indices[0]; - fbcmap.red = data = malloc(numColors * 3); + fbcmap.red = data = xallocarray(numColors, 3); if (!data) return; fbcmap.green = data + numColors; diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h index 643a65db1..a58fafebd 100644 --- a/xorg-server/hw/xfree86/common/xf86str.h +++ b/xorg-server/hw/xfree86/common/xf86str.h @@ -440,6 +440,7 @@ typedef struct _confxvadaptrec { void *options; } confXvAdaptorRec, *confXvAdaptorPtr; +#define MAX_GPUDEVICES 4 typedef struct _confscreenrec { const char *id; int screennum; @@ -453,6 +454,9 @@ typedef struct _confscreenrec { int numxvadaptors; confXvAdaptorPtr xvadaptors; void *options; + + int num_gpu_devices; + GDevPtr gpu_devices[MAX_GPUDEVICES]; } confScreenRec, *confScreenPtr; typedef enum { @@ -512,6 +516,9 @@ typedef struct _confdrirec { #define NUM_RESERVED_POINTERS 14 #define NUM_RESERVED_FUNCS 10 +/* let clients know they can use this */ +#define XF86_SCRN_HAS_PREFER_CLONE 1 + typedef void *(*funcPointer) (void); /* flags for depth 24 pixmap options */ @@ -768,6 +775,9 @@ typedef struct _ScrnInfoRec { ClockRangePtr clockRanges; int adjustFlags; + /* initial rightof support disable */ + int preferClone; + /* * These can be used when the minor ABI version is incremented. * The NUM_* parameters must be reduced appropriately to keep the diff --git a/xorg-server/hw/xfree86/common/xf86vmode.c b/xorg-server/hw/xfree86/common/xf86vmode.c index 0ce58e365..818e7dc45 100644 --- a/xorg-server/hw/xfree86/common/xf86vmode.c +++ b/xorg-server/hw/xfree86/common/xf86vmode.c @@ -1240,11 +1240,11 @@ ProcXF86VidModeGetMonitor(ClientPtr client) pad_to_int32(rep.modelLength)); rep.nhsync = nHsync; rep.nvsync = nVrefresh; - hsyncdata = malloc(nHsync * sizeof(CARD32)); + hsyncdata = xallocarray(nHsync, sizeof(CARD32)); if (!hsyncdata) { return BadAlloc; } - vsyncdata = malloc(nVrefresh * sizeof(CARD32)); + vsyncdata = xallocarray(nVrefresh, sizeof(CARD32)); if (!vsyncdata) { free(hsyncdata); @@ -1512,9 +1512,9 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client) length = (stuff->size + 1) & ~1; if (stuff->size) { - ramplen = length * 3 * sizeof(CARD16); - if (!(ramp = malloc(ramplen))) + if (!(ramp = xallocarray(length, 3 * sizeof(CARD16)))) return BadAlloc; + ramplen = length * 3 * sizeof(CARD16); if (!VidModeGetGammaRamp(stuff->screen, stuff->size, ramp, ramp + length, ramp + (length * 2))) { diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c index b974cd212..d613d712c 100644 --- a/xorg-server/hw/xfree86/common/xf86xv.c +++ b/xorg-server/hw/xfree86/common/xf86xv.c @@ -131,8 +131,8 @@ xf86XVRegisterGenericAdaptorDriver(xf86XVInitGenericAdaptorPtr InitFunc) { xf86XVInitGenericAdaptorPtr *newdrivers; - newdrivers = realloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) * - (1 + NumGenDrivers)); + newdrivers = reallocarray(GenDrivers, 1 + NumGenDrivers, + sizeof(xf86XVInitGenericAdaptorPtr)); if (!newdrivers) return 0; GenDrivers = newdrivers; @@ -159,7 +159,7 @@ xf86XVListGenericAdaptors(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr ** adaptors) n = (*GenDrivers[i]) (pScrn, &DrivAdap); if (0 == n) continue; - new = realloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num + n)); + new = reallocarray(*adaptors, num + n, sizeof(XF86VideoAdaptorPtr)); if (NULL == new) continue; *adaptors = new; @@ -436,8 +436,8 @@ xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number) void *moreSpace; totFormat *= 2; - moreSpace = realloc(pFormat, - totFormat * sizeof(XvFormatRec)); + moreSpace = reallocarray(pFormat, totFormat, + sizeof(XvFormatRec)); if (!moreSpace) break; pFormat = moreSpace; diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.c b/xorg-server/hw/xfree86/common/xf86xvmc.c index 3169c054c..a0a94c74b 100644 --- a/xorg-server/hw/xfree86/common/xf86xvmc.c +++ b/xorg-server/hw/xfree86/common/xf86xvmc.c @@ -155,7 +155,7 @@ xf86XvMCScreenInit(ScreenPtr pScreen, if (noXvExtension) return FALSE; - if (!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors))) + if (!(pAdapt = xallocarray(num_adaptors, sizeof(XvMCAdaptorRec)))) return FALSE; if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0)) { diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c index 29185ad8b..ee533db1c 100644 --- a/xorg-server/hw/xfree86/ddc/ddc.c +++ b/xorg-server/hw/xfree86/ddc/ddc.c @@ -437,7 +437,7 @@ xf86DoEEDID(ScrnInfoPtr pScrn, I2CBusPtr pBus, Bool complete) int i, n = EDID_block[0x7e]; if (complete && n) { - EDID_block = realloc(EDID_block, EDID1_LEN * (1 + n)); + EDID_block = reallocarray(EDID_block, 1 + n, EDID1_LEN); for (i = 0; i < n; i++) DDC2Read(dev, i + 1, EDID_block + (EDID1_LEN * (1 + i))); diff --git a/xorg-server/hw/xfree86/dri/xf86dri.c b/xorg-server/hw/xfree86/dri/xf86dri.c index 086e833ed..68f8b7e72 100644 --- a/xorg-server/hw/xfree86/dri/xf86dri.c +++ b/xorg-server/hw/xfree86/dri/xf86dri.c @@ -422,7 +422,7 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) if (rep.numClipRects) { /* Clip cliprects to screen dimensions (redirected windows) */ - pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t)); + pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t)); if (pClippedRects) { ScreenPtr pScreen = screenInfo.screens[stuff->screen]; diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c index 0c038b3d1..60ea6dd93 100644 --- a/xorg-server/hw/xfree86/dri2/dri2.c +++ b/xorg-server/hw/xfree86/dri2/dri2.c @@ -1577,7 +1577,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) if (info->version == 3 || info->numDrivers == 0) { /* Driver too old: use the old-style driverName field */ ds->numDrivers = info->driverName ? 1 : 2; - ds->driverNames = malloc(ds->numDrivers * sizeof(*ds->driverNames)); + ds->driverNames = xallocarray(ds->numDrivers, sizeof(*ds->driverNames)); if (!ds->driverNames) goto err_out; @@ -1591,7 +1591,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) } else { ds->numDrivers = info->numDrivers; - ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames)); + ds->driverNames = xallocarray(info->numDrivers, sizeof(*ds->driverNames)); if (!ds->driverNames) goto err_out; memcpy(ds->driverNames, info->driverNames, diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.c b/xorg-server/hw/xfree86/drivers/modesetting/driver.c index e2f3846ca..e90e4b842 100644 --- a/xorg-server/hw/xfree86/drivers/modesetting/driver.c +++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.c @@ -451,7 +451,7 @@ dispatch_dirty_region(ScrnInfoPtr scrn, int ret = 0; if (num_cliprects) { - drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip)); + drmModeClip *clip = xallocarray(num_cliprects, sizeof(drmModeClip)); BoxPtr rect = REGION_RECTS(dirty); int i; diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c index 1ea799b3a..f3c9909ef 100644 --- a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -326,6 +326,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, continue; drmmode_output = output->driver_private; + if (drmmode_output->output_id == -1) + continue; output_ids[output_count] = drmmode_output->mode_output->connector_id; output_count++; @@ -366,10 +368,14 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, /* go through all the outputs and force DPMS them back on? */ for (i = 0; i < xf86_config->num_output; i++) { xf86OutputPtr output = xf86_config->output[i]; + drmmode_output_private_ptr drmmode_output; if (output->crtc != crtc) continue; + drmmode_output = output->driver_private; + if (drmmode_output->output_id == -1) + continue; output->funcs->dpms(output, DPMSModeOn); } } @@ -427,10 +433,10 @@ drmmode_set_cursor(xf86CrtcPtr crtc) drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, ms->cursor_width, ms->cursor_height, cursor->bits->xhot, cursor->bits->yhot); + if (!ret) + return; if (ret == -EINVAL) use_set_cursor2 = FALSE; - else - return; } ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, @@ -687,7 +693,7 @@ drmmode_crtc_vblank_pipe(int crtc_id) } static void -drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num) +drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num) { xf86CrtcPtr crtc; drmmode_crtc_private_ptr drmmode_crtc; @@ -698,7 +704,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num) drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1); drmmode_crtc->mode_crtc = - drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]); + drmModeGetCrtc(drmmode->fd, mode_res->crtcs[num]); drmmode_crtc->drmmode = drmmode; drmmode_crtc->vblank_pipe = drmmode_crtc_vblank_pipe(num); crtc->driver_private = drmmode_crtc; @@ -712,6 +718,9 @@ drmmode_output_detect(xf86OutputPtr output) drmmode_ptr drmmode = drmmode_output->drmmode; xf86OutputStatus status; + if (drmmode_output->output_id == -1) + return XF86OutputStatusDisconnected; + drmModeFreeConnector(drmmode_output->mode_output); drmmode_output->mode_output = @@ -740,6 +749,46 @@ drmmode_output_mode_valid(xf86OutputPtr output, DisplayModePtr pModes) return MODE_OK; } +static void +drmmode_output_attach_tile(xf86OutputPtr output) +{ + drmmode_output_private_ptr drmmode_output = output->driver_private; + drmModeConnectorPtr koutput = drmmode_output->mode_output; + drmmode_ptr drmmode = drmmode_output->drmmode; + int i; + struct xf86CrtcTileInfo tile_info, *set = NULL; + + if (!koutput) { + xf86OutputSetTile(output, NULL); + return; + } + + /* look for a TILE property */ + for (i = 0; i < koutput->count_props; i++) { + drmModePropertyPtr props; + props = drmModeGetProperty(drmmode->fd, koutput->props[i]); + if (!props) + continue; + + if (!(props->flags & DRM_MODE_PROP_BLOB)) { + drmModeFreeProperty(props); + continue; + } + + if (!strcmp(props->name, "TILE")) { + drmModeFreePropertyBlob(drmmode_output->tile_blob); + drmmode_output->tile_blob = + drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]); + } + drmModeFreeProperty(props); + } + if (drmmode_output->tile_blob) { + if (xf86OutputParseKMSTile(drmmode_output->tile_blob->data, drmmode_output->tile_blob->length, &tile_info) == TRUE) + set = &tile_info; + } + xf86OutputSetTile(output, set); +} + static Bool has_panel_fitter(xf86OutputPtr output) { @@ -848,6 +897,8 @@ drmmode_output_get_modes(xf86OutputPtr output) } xf86OutputSetEDID(output, mon); + drmmode_output_attach_tile(output); + /* modes should already be available */ for (i = 0; i < koutput->count_modes; i++) { Mode = xnfalloc(sizeof(DisplayModeRec)); @@ -873,11 +924,13 @@ drmmode_output_destroy(xf86OutputPtr output) free(drmmode_output->props[i].atoms); } free(drmmode_output->props); - for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) { - drmModeFreeEncoder(drmmode_output->mode_encoders[i]); + if (drmmode_output->mode_output) { + for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) { + drmModeFreeEncoder(drmmode_output->mode_encoders[i]); + } + drmModeFreeConnector(drmmode_output->mode_output); } free(drmmode_output->mode_encoders); - drmModeFreeConnector(drmmode_output->mode_output); free(drmmode_output); output->driver_private = NULL; } @@ -1111,22 +1164,134 @@ static const char *const output_names[] = { "DSI", }; +static xf86OutputPtr find_output(ScrnInfoPtr pScrn, int id) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int i; + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + drmmode_output_private_ptr drmmode_output; + + drmmode_output = output->driver_private; + if (drmmode_output->output_id == id) + return output; + } + return NULL; +} + +static int parse_path_blob(drmModePropertyBlobPtr path_blob, int *conn_base_id, char **path) +{ + char *conn; + char conn_id[5]; + int id, len; + char *blob_data; + + if (!path_blob) + return -1; + + blob_data = path_blob->data; + /* we only handle MST paths for now */ + if (strncmp(blob_data, "mst:", 4)) + return -1; + + conn = strchr(blob_data + 4, '-'); + if (!conn) + return -1; + len = conn - (blob_data + 4); + if (len + 1> 5) + return -1; + memcpy(conn_id, blob_data + 4, len); + conn_id[len + 1] = '\0'; + id = strtoul(conn_id, NULL, 10); + + *conn_base_id = id; + + *path = conn + 1; + return 0; +} + +static void +drmmode_create_name(ScrnInfoPtr pScrn, drmModeConnectorPtr koutput, char *name, + drmModePropertyBlobPtr path_blob) +{ + int ret; + char *extra_path; + int conn_id; + xf86OutputPtr output; + + ret = parse_path_blob(path_blob, &conn_id, &extra_path); + if (ret == -1) + goto fallback; + + output = find_output(pScrn, conn_id); + if (!output) + goto fallback; + + snprintf(name, 32, "%s-%s", output->name, extra_path); + return; + + fallback: + if (koutput->connector_type >= MS_ARRAY_SIZE(output_names)) + snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1); +#ifdef MODESETTING_OUTPUT_SLAVE_SUPPORT + else if (pScrn->is_gpu) + snprintf(name, 32, "%s-%d-%d", output_names[koutput->connector_type], pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1, koutput->connector_type_id - 1); +#endif + else + snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], koutput->connector_type_id - 1); +} + static void -drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num) +drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num, Bool dynamic) { xf86OutputPtr output; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); drmModeConnectorPtr koutput; drmModeEncoderPtr *kencoders = NULL; drmmode_output_private_ptr drmmode_output; drmModePropertyPtr props; char name[32]; int i; + drmModePropertyBlobPtr path_blob = NULL; koutput = - drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]); + drmModeGetConnector(drmmode->fd, mode_res->connectors[num]); if (!koutput) return; + for (i = 0; i < koutput->count_props; i++) { + props = drmModeGetProperty(drmmode->fd, koutput->props[i]); + if (props && (props->flags & DRM_MODE_PROP_BLOB)) { + if (!strcmp(props->name, "PATH")) { + path_blob = drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]); + drmModeFreeProperty(props); + break; + } + drmModeFreeProperty(props); + } + } + + drmmode_create_name(pScrn, koutput, name, path_blob); + + if (path_blob) + drmModeFreePropertyBlob(path_blob); + + if (path_blob && dynamic) { + /* see if we have an output with this name already + and hook stuff up */ + for (i = 0; i < xf86_config->num_output; i++) { + output = xf86_config->output[i]; + + if (strncmp(output->name, name, 32)) + continue; + + drmmode_output = output->driver_private; + drmmode_output->output_id = mode_res->connectors[num]; + drmmode_output->mode_output = koutput; + return; + } + } + kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders); if (!kencoders) { goto out_free_encoders; @@ -1139,17 +1304,6 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num) } } - /* need to do smart conversion here for compat with non-kms ATI driver */ - if (koutput->connector_type >= MS_ARRAY_SIZE(output_names)) - snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1); - else if (pScrn->is_gpu) - snprintf(name, 32, "%s-%d-%d", output_names[koutput->connector_type], - pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1, - koutput->connector_type_id - 1); - else - snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], - koutput->connector_type_id - 1); - output = xf86OutputCreate(pScrn, &drmmode_output_funcs, name); if (!output) { goto out_free_encoders; @@ -1161,7 +1315,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num) goto out_free_encoders; } - drmmode_output->output_id = drmmode->mode_res->connectors[num]; + drmmode_output->output_id = mode_res->connectors[num]; drmmode_output->mode_output = koutput; drmmode_output->mode_encoders = kencoders; drmmode_output->drmmode = drmmode; @@ -1192,6 +1346,8 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num) } } + if (dynamic) + output->randr_output = RROutputCreate(xf86ScrnToScreen(pScrn), output->name, strlen(output->name), output); return; out_free_encoders: if (kencoders) { @@ -1231,7 +1387,7 @@ find_clones(ScrnInfoPtr scrn, xf86OutputPtr output) } static void -drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode) +drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode, drmModeResPtr mode_res) { int i, j; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); @@ -1246,8 +1402,8 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode) for (j = 0; j < drmmode_output->mode_output->count_encoders; j++) { int k; - for (k = 0; k < drmmode->mode_res->count_encoders; k++) { - if (drmmode->mode_res->encoders[k] == + for (k = 0; k < mode_res->count_encoders; k++) { + if (mode_res->encoders[k] == drmmode_output->mode_encoders[j]->encoder_id) drmmode_output->enc_mask |= (1 << k); } @@ -1425,6 +1581,7 @@ drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) int i; int ret; uint64_t value = 0; + drmModeResPtr mode_res; /* check for dumb capability */ ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_BUFFER, &value); @@ -1438,23 +1595,24 @@ drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) drmmode->scrn = pScrn; drmmode->cpp = cpp; - drmmode->mode_res = drmModeGetResources(drmmode->fd); - if (!drmmode->mode_res) + mode_res = drmModeGetResources(drmmode->fd); + if (!mode_res) return FALSE; - xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width, - drmmode->mode_res->max_height); - for (i = 0; i < drmmode->mode_res->count_crtcs; i++) + xf86CrtcSetSizeRange(pScrn, 320, 200, mode_res->max_width, + mode_res->max_height); + for (i = 0; i < mode_res->count_crtcs; i++) if (!xf86IsEntityShared(pScrn->entityList[0]) || pScrn->confScreen->device->screen == i) - drmmode_crtc_init(pScrn, drmmode, i); + drmmode_crtc_init(pScrn, drmmode, mode_res, i); - for (i = 0; i < drmmode->mode_res->count_connectors; i++) - drmmode_output_init(pScrn, drmmode, i); + for (i = 0; i < mode_res->count_connectors; i++) + drmmode_output_init(pScrn, drmmode, mode_res, i, FALSE); /* workout clones */ - drmmode_clones_init(pScrn, drmmode); + drmmode_clones_init(pScrn, drmmode, mode_res); + drmModeFreeResources(mode_res); #if XF86_CRTC_VERSION >= 5 xf86ProviderSetup(pScrn, NULL, "modesetting"); #endif @@ -1618,11 +1776,78 @@ drmmode_handle_uevents(int fd, void *closure) drmmode_ptr drmmode = closure; ScrnInfoPtr scrn = drmmode->scrn; struct udev_device *dev; + drmModeResPtr mode_res; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i, j; + Bool found; + Bool changed = FALSE; dev = udev_monitor_receive_device(drmmode->uevent_monitor); if (!dev) return; + mode_res = drmModeGetResources(drmmode->fd); + if (!mode_res) + goto out; + + if (mode_res->count_crtcs != config->num_crtc) { + ErrorF("number of CRTCs changed - failed to handle, %d vs %d\n", mode_res->count_crtcs, config->num_crtc); + goto out_free_res; + } + + /* figure out if we have gotten rid of any connectors + traverse old output list looking for outputs */ + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + drmmode_output_private_ptr drmmode_output; + + drmmode_output = output->driver_private; + found = FALSE; + for (j = 0; j < mode_res->count_connectors; j++) { + if (mode_res->connectors[j] == drmmode_output->output_id) { + found = TRUE; + break; + } + } + if (found) + continue; + + drmModeFreeConnector(drmmode_output->mode_output); + drmmode_output->mode_output = NULL; + drmmode_output->output_id = -1; + + changed = TRUE; + } + + /* find new output ids we don't have outputs for */ + for (i = 0; i < mode_res->count_connectors; i++) { + found = FALSE; + + for (j = 0; j < config->num_output; j++) { + xf86OutputPtr output = config->output[j]; + drmmode_output_private_ptr drmmode_output; + + drmmode_output = output->driver_private; + if (mode_res->connectors[i] == drmmode_output->output_id) { + found = TRUE; + break; + } + } + if (found) + continue; + + changed = TRUE; + drmmode_output_init(scrn, drmmode, mode_res, i, 1); + } + + if (changed) { + RRSetChanged(xf86ScrnToScreen(scrn)); + RRTellChanged(xf86ScrnToScreen(scrn)); + } + +out_free_res: + drmModeFreeResources(mode_res); +out: RRGetInfo(xf86ScrnToScreen(scrn), TRUE); udev_device_unref(dev); } diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h index 3a8959ac3..b0e45b6e0 100644 --- a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h +++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h @@ -47,7 +47,6 @@ typedef struct { int fd; unsigned fb_id; unsigned old_fb_id; - drmModeResPtr mode_res; drmModeFBPtr mode_fb; int cpp; ScrnInfoPtr scrn; @@ -121,6 +120,7 @@ typedef struct { drmModeConnectorPtr mode_output; drmModeEncoderPtr *mode_encoders; drmModePropertyBlobPtr edid_blob; + drmModePropertyBlobPtr tile_blob; int dpms_enum_id; int num_props; drmmode_prop_ptr props; diff --git a/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c b/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c index 58d420e07..cf13f0a9c 100644 --- a/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c +++ b/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c @@ -25,6 +25,10 @@ * */ +#ifdef HAVE_DIX_CONFIG_H +#include "dix-config.h" +#endif + #include "dumb_bo.h" #include <errno.h> diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.c b/xorg-server/hw/xfree86/i2c/xf86i2c.c index cf2cd0971..2a8b8df22 100644 --- a/xorg-server/hw/xfree86/i2c/xf86i2c.c +++ b/xorg-server/hw/xfree86/i2c/xf86i2c.c @@ -872,7 +872,7 @@ xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr ** pppI2CBus) if (!pppI2CBus) continue; - *pppI2CBus = xnfrealloc(*pppI2CBus, n * sizeof(I2CBusPtr)); + *pppI2CBus = xnfreallocarray(*pppI2CBus, n, sizeof(I2CBusPtr)); (*pppI2CBus)[n - 1] = pI2CBus; } diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c index fdf5bd8c9..73dc1b8dc 100644 --- a/xorg-server/hw/xfree86/loader/loadmod.c +++ b/xorg-server/hw/xfree86/loader/loadmod.c @@ -142,7 +142,7 @@ InitPathList(const char *path) if (addslash) len++; save = list; - list = realloc(list, (n + 2) * sizeof(char *)); + list = reallocarray(list, n + 2, sizeof(char *)); if (!list) { if (save) { save[n] = NULL; @@ -244,7 +244,7 @@ InitPatterns(const char **patternlist) for (i = 0, s = patternlist; *s; i++, s++) if (*s == DEFAULT_LIST) i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1; - patterns = malloc((i + 1) * sizeof(PatternRec)); + patterns = xallocarray(i + 1, sizeof(PatternRec)); if (!patterns) { return NULL; } @@ -323,7 +323,7 @@ InitSubdirs(const char **subdirlist) } } } - subdirs = malloc((i * 2 + 1) * sizeof(char *)); + subdirs = xallocarray(i * 2 + 1, sizeof(char *)); if (!subdirs) { free(tmp_subdirlist); return NULL; @@ -530,8 +530,8 @@ LoaderListDirs(const char **subdirlist, const char **patternlist) match[1].rm_so != -1) { len = match[1].rm_eo - match[1].rm_so; save = listing; - listing = realloc(listing, - (n + 2) * sizeof(char *)); + listing = reallocarray(listing, n + 2, + sizeof(char *)); if (!listing) { if (save) { save[n] = NULL; diff --git a/xorg-server/hw/xfree86/man/xorg.conf.man b/xorg-server/hw/xfree86/man/xorg.conf.man index d26c3cc4d..e9b6d9990 100644 --- a/xorg-server/hw/xfree86/man/xorg.conf.man +++ b/xorg-server/hw/xfree86/man/xorg.conf.man @@ -1906,6 +1906,7 @@ sections have the following format: .B "Section \*qScreen\*q" .BI " Identifier \*q" name \*q .BI " Device \*q" devid \*q +.BI " GPUDevice \*q" devid \*q .BI " Monitor \*q" monid \*q .I " entries" .I " ..." @@ -1949,6 +1950,18 @@ of a .B Device section in the config file. .TP 7 +.BI "GPUDevice \*q" device\-id \*q +This entry specifies the +.B Device +section to be used as a secondary GPU device for this screen. When multiple graphics cards are +present, this is what ties a specific secondary card to a screen. The +.I device\-id +must match the +.B Identifier +of a +.B Device +section in the config file. This can be specified up to 4 times for a single screen. +.TP 7 .BI "Monitor \*q" monitor\-id \*q specifies which monitor description is to be used for this screen. If a diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c index a1947241b..38bc58cbc 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.c +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -118,7 +118,7 @@ xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs) /* Preallocate gamma at a sensible size. */ crtc->gamma_size = 256; - crtc->gamma_red = malloc(3 * crtc->gamma_size * sizeof(CARD16)); + crtc->gamma_red = xallocarray(crtc->gamma_size, 3 * sizeof(CARD16)); if (!crtc->gamma_red) { free(crtc); return NULL; @@ -127,10 +127,10 @@ xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs) crtc->gamma_blue = crtc->gamma_green + crtc->gamma_size; if (xf86_config->crtc) - crtcs = realloc(xf86_config->crtc, - (xf86_config->num_crtc + 1) * sizeof(xf86CrtcPtr)); + crtcs = reallocarray(xf86_config->crtc, + xf86_config->num_crtc + 1, sizeof(xf86CrtcPtr)); else - crtcs = malloc((xf86_config->num_crtc + 1) * sizeof(xf86CrtcPtr)); + crtcs = xallocarray(xf86_config->num_crtc + 1, sizeof(xf86CrtcPtr)); if (!crtcs) { free(crtc->gamma_red); free(crtc); @@ -620,11 +620,12 @@ xf86OutputCreate(ScrnInfoPtr scrn, } if (xf86_config->output) - outputs = realloc(xf86_config->output, - (xf86_config->num_output + - 1) * sizeof(xf86OutputPtr)); + outputs = reallocarray(xf86_config->output, + xf86_config->num_output + 1, + sizeof(xf86OutputPtr)); else - outputs = malloc((xf86_config->num_output + 1) * sizeof(xf86OutputPtr)); + outputs = xallocarray(xf86_config->num_output + 1, + sizeof(xf86OutputPtr)); if (!outputs) { free(output); return NULL; @@ -942,7 +943,7 @@ xf86PickCrtcs(ScrnInfoPtr scrn, if (modes[n] == NULL) return best_score; - crtcs = malloc(config->num_output * sizeof(xf86CrtcPtr)); + crtcs = xallocarray(config->num_output, sizeof(xf86CrtcPtr)); if (!crtcs) return best_score; @@ -1123,6 +1124,15 @@ xf86InitialOutputPositions(ScrnInfoPtr scrn, DisplayModePtr * modes) int o; int min_x, min_y; + /* check for initial right-of heuristic */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + if (output->initial_x || output->initial_y) + return TRUE; + } + for (o = 0; o < config->num_output; o++) { xf86OutputPtr output = config->output[o]; @@ -2102,6 +2112,118 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect) return match; } +static int +numEnabledOutputs(xf86CrtcConfigPtr config, Bool *enabled) +{ + int i = 0, p; + + for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ; + + return i; +} + +static Bool +xf86TargetRightOf(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, + DisplayModePtr *modes, Bool *enabled, + int width, int height) +{ + int o; + int w = 0; + Bool has_tile = FALSE; + uint32_t configured_outputs; + + if (scrn->preferClone) + return FALSE; + + if (numEnabledOutputs(config, enabled) < 2) + return FALSE; + + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + DisplayModePtr mode = + xf86OutputHasPreferredMode(config->output[o], width, height); + + if (!mode) + return FALSE; + + w += mode->HDisplay; + } + + if (w > width) + return FALSE; + + w = 0; + configured_outputs = 0; + + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + DisplayModePtr mode = + xf86OutputHasPreferredMode(config->output[o], width, height); + + if (configured_outputs & (1 << o)) + continue; + + if (config->output[o]->tile_info.group_id) { + has_tile = TRUE; + continue; + } + + config->output[o]->initial_x = w; + w += mode->HDisplay; + + configured_outputs |= (1 << o); + modes[o] = mode; + } + + if (has_tile) { + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + int ht, vt, ot; + int add_x, cur_x = w; + struct xf86CrtcTileInfo *tile_info = &config->output[o]->tile_info, *this_tile; + if (configured_outputs & (1 << o)) + continue; + if (!tile_info->group_id) + continue; + + if (tile_info->tile_h_loc != 0 && tile_info->tile_v_loc != 0) + continue; + + for (ht = 0; ht < tile_info->num_h_tile; ht++) { + int cur_y = 0; + add_x = 0; + for (vt = 0; vt < tile_info->num_v_tile; vt++) { + + for (ot = -1; nextEnabledOutput(config, enabled, &ot); ) { + + DisplayModePtr mode = + xf86OutputHasPreferredMode(config->output[ot], width, height); + if (!config->output[ot]->tile_info.group_id) + continue; + + this_tile = &config->output[ot]->tile_info; + if (this_tile->group_id != tile_info->group_id) + continue; + + if (this_tile->tile_h_loc != ht || + this_tile->tile_v_loc != vt) + continue; + + config->output[ot]->initial_x = cur_x; + config->output[ot]->initial_y = cur_y; + + if (vt == 0) + add_x = this_tile->tile_h_size; + cur_y += this_tile->tile_v_size; + configured_outputs |= (1 << ot); + modes[ot] = mode; + } + } + cur_x += add_x; + } + w = cur_x; + } + } + return TRUE; +} + static Bool xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, DisplayModePtr * modes, Bool *enabled, @@ -2178,14 +2300,10 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, */ if (!ret) do { - int i = 0; float aspect = 0.0; DisplayModePtr a = NULL, b = NULL; - /* count the number of enabled outputs */ - for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++); - - if (i != 1) + if (numEnabledOutputs(config, enabled) != 1) break; p = -1; @@ -2334,7 +2452,7 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green, int i, size = 256; CARD16 *red, *green, *blue; - red = malloc(3 * size * sizeof(CARD16)); + red = xallocarray(size, 3 * sizeof(CARD16)); green = red + size; blue = green + size; @@ -2491,6 +2609,8 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) else { if (xf86TargetUserpref(scrn, config, modes, enabled, width, height)) xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n"); + else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height)) + xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n"); else if (xf86TargetPreferred (scrn, config, modes, enabled, width, height)) xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n"); @@ -2510,9 +2630,11 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) "Output %s enabled but has no modes\n", config->output[o]->name); else - xf86DrvMsg(scrn->scrnIndex, X_INFO, - "Output %s using initial mode %s\n", - config->output[o]->name, modes[o]->name); + xf86DrvMsg (scrn->scrnIndex, X_INFO, + "Output %s using initial mode %s +%d+%d\n", + config->output[o]->name, modes[o]->name, + config->output[o]->initial_x, + config->output[o]->initial_y); } /* diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h index 3c5bbcfd5..8b0160845 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.h +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h @@ -745,6 +745,8 @@ xf86CompatOutput(ScrnInfoPtr pScrn) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + if (config->compat_output < 0) + return NULL; return config->output[config->compat_output]; } diff --git a/xorg-server/hw/xfree86/modes/xf86DiDGA.c b/xorg-server/hw/xfree86/modes/xf86DiDGA.c index 3f1a3309f..645727441 100644 --- a/xorg-server/hw/xfree86/modes/xf86DiDGA.c +++ b/xorg-server/hw/xfree86/modes/xf86DiDGA.c @@ -60,7 +60,7 @@ xf86_dga_get_modes(ScreenPtr pScreen) if (!num) return FALSE; - modes = malloc(num * sizeof(DGAModeRec)); + modes = xallocarray(num, sizeof(DGAModeRec)); if (!modes) return FALSE; diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c index b1c306a88..0d446da64 100644 --- a/xorg-server/hw/xfree86/modes/xf86RandR12.c +++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c @@ -1058,7 +1058,7 @@ xf86RandR12CrtcNotify(RRCrtcPtr randr_crtc) DisplayModePtr mode = &crtc->mode; Bool ret; - randr_outputs = malloc(config->num_output * sizeof(RROutputPtr)); + randr_outputs = xallocarray(config->num_output, sizeof(RROutputPtr)); if (!randr_outputs) return FALSE; x = crtc->x; @@ -1150,7 +1150,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen, if (!crtc->scrn->vtSema) return FALSE; - save_crtcs = malloc(config->num_output * sizeof(xf86CrtcPtr)); + save_crtcs = xallocarray(config->num_output, sizeof(xf86CrtcPtr)); if ((randr_mode != NULL) != crtc->enabled) changed = TRUE; else if (randr_mode && !xf86RandRModeMatches(randr_mode, &crtc->mode)) @@ -1255,9 +1255,8 @@ xf86RandR12CrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc) if (randr_crtc->gammaSize != crtc->gamma_size) { CARD16 *tmp_ptr; - tmp_ptr = - realloc(crtc->gamma_red, - 3 * randr_crtc->gammaSize * sizeof(CARD16)); + tmp_ptr = reallocarray(crtc->gamma_red, + randr_crtc->gammaSize, 3 * sizeof(CARD16)); if (!tmp_ptr) return FALSE; crtc->gamma_red = tmp_ptr; @@ -1298,9 +1297,8 @@ xf86RandR12CrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc) if (randr_crtc->gammaSize != crtc->gamma_size) { CARD16 *tmp_ptr; - tmp_ptr = - realloc(randr_crtc->gammaRed, - 3 * crtc->gamma_size * sizeof(CARD16)); + tmp_ptr = reallocarray(randr_crtc->gammaRed, + crtc->gamma_size, 3 * sizeof(CARD16)); if (!tmp_ptr) return FALSE; randr_crtc->gammaRed = tmp_ptr; @@ -1394,7 +1392,7 @@ xf86RROutputSetModes(RROutputPtr randr_output, DisplayModePtr modes) nmode++; if (nmode) { - rrmodes = malloc(nmode * sizeof(RRModePtr)); + rrmodes = xallocarray(nmode, sizeof(RRModePtr)); if (!rrmodes) return FALSE; @@ -1449,8 +1447,8 @@ xf86RandR12SetInfo12(ScreenPtr pScreen) int o, c, l; int nclone; - clones = malloc(config->num_output * sizeof(RROutputPtr)); - crtcs = malloc(config->num_crtc * sizeof(RRCrtcPtr)); + clones = xallocarray(config->num_output, sizeof(RROutputPtr)); + crtcs = xallocarray(config->num_crtc, sizeof(RRCrtcPtr)); for (o = 0; o < config->num_output; o++) { xf86OutputPtr output = config->output[o]; @@ -1564,6 +1562,70 @@ xf86RandR12CreateObjects12(ScreenPtr pScreen) return TRUE; } +static void +xf86RandR12CreateMonitors(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int o, ot; + int ht, vt; + int ret; + char buf[25]; + + for (o = 0; o < config->num_output; o++) { + xf86OutputPtr output = config->output[o]; + struct xf86CrtcTileInfo *tile_info = &output->tile_info, *this_tile; + RRMonitorPtr monitor; + int output_num, num_outputs; + if (!tile_info->group_id) + continue; + + if (tile_info->tile_h_loc || + tile_info->tile_v_loc) + continue; + + num_outputs = tile_info->num_h_tile * tile_info->num_v_tile; + + monitor = RRMonitorAlloc(num_outputs); + if (!monitor) + return; + monitor->pScreen = pScreen; + snprintf(buf, 25, "Auto-Monitor-%d", tile_info->group_id); + monitor->name = MakeAtom(buf, strlen(buf), TRUE); + monitor->primary = 0; + monitor->automatic = TRUE; + memset(&monitor->geometry.box, 0, sizeof(monitor->geometry.box)); + + output_num = 0; + for (ht = 0; ht < tile_info->num_h_tile; ht++) { + for (vt = 0; vt < tile_info->num_v_tile; vt++) { + + for (ot = 0; ot < config->num_output; ot++) { + this_tile = &config->output[ot]->tile_info; + + if (this_tile->group_id != tile_info->group_id) + continue; + + if (this_tile->tile_h_loc != ht || + this_tile->tile_v_loc != vt) + continue; + + monitor->outputs[output_num] = config->output[ot]->randr_output->id; + output_num++; + + } + + } + } + + ret = RRMonitorAdd(serverClient, pScreen, monitor); + if (ret) { + RRMonitorFree(monitor); + return; + } + } +} + static Bool xf86RandR12CreateScreenResources12(ScreenPtr pScreen) { @@ -1579,6 +1641,8 @@ xf86RandR12CreateScreenResources12(ScreenPtr pScreen) RRScreenSetSizeRange(pScreen, config->minWidth, config->minHeight, config->maxWidth, config->maxHeight); + + xf86RandR12CreateMonitors(pScreen); return TRUE; } diff --git a/xorg-server/hw/xfree86/os-support/bus/Sbus.c b/xorg-server/hw/xfree86/os-support/bus/Sbus.c index 16ce5b58a..86b4d685a 100644 --- a/xorg-server/hw/xfree86/os-support/bus/Sbus.c +++ b/xorg-server/hw/xfree86/os-support/bus/Sbus.c @@ -440,7 +440,7 @@ sparcPromAssignNodes(void) for (i = 0, j = 0; i < 32; i++) if (devicePtrs[i] && devicePtrs[i]->fbNum == -1) j++; - xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (n + j + 1)); + xf86SbusInfo = xnfreallocarray(xf86SbusInfo, n + j + 1, sizeof(psdp)); for (i = 0, psdpp = xf86SbusInfo; i < 32; i++) if (devicePtrs[i]) { if (devicePtrs[i]->fbNum == -1) { diff --git a/xorg-server/hw/xfree86/os-support/solaris/Makefile.am b/xorg-server/hw/xfree86/os-support/solaris/Makefile.am index 6cda4b361..e534bc8dc 100644 --- a/xorg-server/hw/xfree86/os-support/solaris/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/solaris/Makefile.am @@ -33,5 +33,4 @@ AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) AM_CPPFLAGS = $(XORG_INCS) -EXTRA_DIST = solaris-amd64.S solaris-ia32.S solaris-sparcv8plus.S \ - apSolaris.shar sun_inout.s +EXTRA_DIST = solaris-amd64.S solaris-ia32.S solaris-sparcv8plus.S sun_inout.s diff --git a/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar b/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar deleted file mode 100644 index a3548f7b4..000000000 --- a/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar +++ /dev/null @@ -1,806 +0,0 @@ -#!/bin/sh -# -# This is a shell archive. Save it in a file, remove anything before -# this line, and then unpack it by entering "sh file". Note, it may -# create directories; files and directories will be owned by you and -# have default permissions. -# Made on Sun Jun 25 20:24:59 CEST 2006 by Martin Bochnig at martux.org -# -# This archive contains: -# -# ./aperture -# -# ./aperture/Makefile -# ./aperture/Makefile.amd64 -# ./aperture/Makefile.sparcv9 -# ./aperture/README -# ./aperture/aperture.c -# ./aperture/aperture.conf -# ./aperture/devlink.tab -# -echo c - ./aperture -mkdir -p ./aperture > /dev/null 2>&1 -# -echo x - ./aperture/Makefile -sed 's/^X//' >./aperture/Makefile << 'END-of-./aperture/Makefile' -X# -X# File: makefile for aperture Framebuffer Driver -X# Author: Doug Anson (danson@lgc.com) -X# Date: 2/15/94 -X# Modified: David Holland (davidh@use.com) -X# Date: 2/23/94 -X# - Changed name, and debugging structure -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Date: 2001.06.08 -X# - SPARC support, cleanup and turf aptest. -X# -X# >>NOTE<< Have a look at Makefile.sparcv9 for specifics. -X# -X# Modified: Martin Bochnig (martin@martux.org) -X# Date: 2006.06.24 -X# - Slightly modified to also build on Solaris 10 and 11. -X# - amd64 64 bit kernel support -X# - cosmetical changes to also support sun4v, not only sun4u -X# -X# >>NOTE<< Have a look at Makefile.amd64 for amd64 specifics. -X# -X# GNU gcc compiler -XCC=gcc -XCFLGS=-fno-builtin -Wall -O3 -X -X# -X# SUNWspro compiler -X#CC=/opt/SUNWspro/bin/cc -X#CFLGS=-Xa -xnolib -xO3 -X -X# -X# Debug error reporting -X#DEBUG_FLG= -X#DEBUG_FLG=-DAPERTURE_DEBUG -X -X# -X# Files and object declarations -XKERNEL_FLGS=-D_KERNEL -DSUNDDI -XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) -XCFILES= aperture.c -XOBJS= aperture.o -XDRIVER= aperture -X -X# -X# Make rules -Xall: $(DRIVER) -X -X$(DRIVER): $(OBJS) -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` $(DRIVER); \ -X else \ -X rm -f $(DRIVER); \ -X ld -r -o $(DRIVER) $(OBJS); \ -X fi -X -Xinstall: $(DRIVER) -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` install; \ -X else \ -X cp aperture.conf /kernel/drv; \ -X cp $(DRIVER) /kernel/drv; \ -X fi -X -Xadd_drv: -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` add_drv; \ -X else \ -X add_drv aperture; \ -X fi -X -Xclean: -X rm -f *% *.BAK $(OBJS) $(DRIVER) core -X -X.SUFFIXES: .i -X -X.c.i: -X $(CC) -E $(CFLAGS) $*.c > $@ -X -X.c.o: -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` $@; \ -X else \ -X rm -f $@; \ -X $(CC) -c $(CFLAGS) $*.c -o $@; \ -X fi -END-of-./aperture/Makefile -echo x - ./aperture/Makefile.amd64 -sed 's/^X//' >./aperture/Makefile.amd64 << 'END-of-./aperture/Makefile.amd64' -X# -X# File: Makefile for aperture Framebuffer Driver -X# Author: Doug Anson (danson@lgc.com) -X# Date: 2/15/94 -X# Modified: David Holland (davidh@use.com) -X# Date: 2/23/94 -X# - Changed name, and debugging structure -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Date: 2001.06.08 -X# - SPARC support, cleanup and turf aptest. -X# Modified: Martin Bochnig (martin@martux.org) -X# - amd64 64 bit kernel support, cosmetics and also -X# supporting sun4v (and arbitrary sparcv9) platforms -X# as well as SunOS 5.10 or higher now -X# - Changed name -X# -X -X# -X# GNU gcc compiler, version 3.2 or later -X# -XCC=gcc -XCFLGS=-fno-builtin -Wall -O3 -m64 -mcmodel=kernel -X -X# -X# SUNWspro compiler (untested, might not properly work for amd64 here) -X#CC=/opt/SUNWspro/bin/cc -X#CFLGS=-Xa -xarch=v9 -xnolib -xO3 -X -X# -X# Debug error reporting -X#DEBUG_FLG= -X#DEBUG_FLG=-DAPERTURE_DEBUG -X -X# -X# Files and object declarations -XKERNEL_FLGS=-D_KERNEL -DSUNDDI -XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) -XCFILES= aperture.c -XOBJS= aperture.o -XDRIVER= aperture -X -X# -X# Make rules -Xall: $(DRIVER) -X -X$(DRIVER): $(OBJS) -X rm -f $(DRIVER) -X ld -r -o $(DRIVER) $(OBJS) -X -Xinstall: $(DRIVER) -X cp aperture.conf /kernel/drv -X cp $(DRIVER) /kernel/drv/amd64 -X -Xadd_drv: -X add_drv aperture -X -Xclean: -X rm -f *% *.BAK $(OBJS) $(DRIVER) core -X -X.SUFFIXES: .i -X -X.c.i: -X $(CC) -E $(CFLAGS) $*.c > $@ -END-of-./aperture/Makefile.amd64 -echo x - ./aperture/Makefile.sparcv9 -sed 's/^X//' >./aperture/Makefile.sparcv9 << 'END-of-./aperture/Makefile.sparcv9' -X# -X# File: makefile for aperture Framebuffer Driver -X# Author: Doug Anson (danson@lgc.com) -X# Date: 2/15/94 -X# Modified: David Holland (davidh@use.com) -X# Date: 2/23/94 -X# - Changed name, and debugging structure -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Date: 2001.06.08 -X# - SPARC support, cleanup and turf aptest. -X# Modified: Martin Bochnig (martin@martux.org) -X# Date: 2006.06.24 -X# - Changed name for generic sparcv9 support -X# - updated to better work with Solaris 10 and 11 -X# -X -X# -X# GNU gcc compiler, version 3.2 or later -X# -XCC=gcc -XCFLGS=-fno-builtin -Wall -O3 -m64 -X -X# -X# SUNWspro compiler -X#CC=/opt/SUNWspro/bin/cc -X#CFLGS=-Xa -xarch=v9 -xnolib -xO3 -X -X# -X# Debug error reporting -X#DEBUG_FLG= -X#DEBUG_FLG=-DAPERTURE_DEBUG -X -X# -X# Files and object declarations -XKERNEL_FLGS=-D_KERNEL -DSUNDDI -XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) -XCFILES= aperture.c -XOBJS= aperture.o -XDRIVER= aperture -X -X# -X# Make rules -Xall: $(DRIVER) -X -X$(DRIVER): $(OBJS) -X rm -f $(DRIVER) -X ld -r -o $(DRIVER) $(OBJS) -X -Xinstall: $(DRIVER) -X cp aperture.conf /kernel/drv -X cp $(DRIVER) /kernel/drv/sparcv9 -X -Xadd_drv: -X add_drv aperture -X -Xclean: -X rm -f *% *.BAK $(OBJS) $(DRIVER) core -X -X.SUFFIXES: .i -X -X.c.i: -X $(CC) -E $(CFLAGS) $*.c > $@ -END-of-./aperture/Makefile.sparcv9 -echo x - ./aperture/README -sed 's/^X//' >./aperture/README << 'END-of-./aperture/README' -XFramebuffer aperture driver. -X -XThis driver was written to provide a device that, unlike /dev/mem, allows -Xmmap()'ing of ranges beyond installed memory. -X -XThe original x86-based version of this driver was the collaborative work of -XDoug Anson (danson@lgc.com), and David Holland (davidh@use.com). It has since -Xbeen rewritten to also work on sparc machines and - later on - also on sparcv9 -Xand recently amd64 64 bit kernels. -XIt flawlessly compiles and installs on Solaris 10 and 11 now. -X -X -XInstallation instructions: -X -X1) Check the Makefile, for appropriate CC, and CFLAGS definitions. Compiling -X with APERTURE_DEBUG defined means the driver will generate reams of -X debugging output. You'll probably want to leave this off... -X -X2) Type 'make' (or 'gmake'). Both the driver and test program should compile -X without any problems. No warning messages should be generated. -X -X3) Become 'root'. -X -X4) Type 'make install' and 'make add_drv'. The screen should look something -X like this: -X -X # make install -X cp aperture aperture.conf /kernel/drv -X # make add_drv -X add_drv aperture -X -X On a sparcv9 machine this will mention the /kernel/drv/sparcv9 directory -X instead of /kernel/drv. Similarily /kernel/drv/amd64 should be used on amd64. -X -X This installs the driver to the system. -X -X5) While as root modify the file /etc/devlink.tab, adding these lines: -X -X# The following entry is for the framebuffer driver -Xtype=ddi_pseudo;name=aperture fbs/\M0 -X -X Add that line exactly as shown. You may also simply add the -X contents of the devlink.tab file supplied to /etc/devlink.tab. -X It contains the lines as well. (Yes, that is a tab between -X aperture and fbs, not spaces - very important) -X -X6) Perform a reconfiguration boot of the system. -X -X # touch /reconfigure -X # init 6 -X -XBug reports, questions, suggestions, etc can be sent to xfree86@xfree86.org. -END-of-./aperture/README -echo x - ./aperture/aperture.c -sed 's/^X//' >./aperture/aperture.c << 'END-of-./aperture/aperture.c' -X/* -X * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved. -X * -X * Permission is hereby granted, free of charge, to any person obtaining a copy -X * of this software and associated documentation files (the "Software"), to -X * deal in the Software without restriction, including without limitation the -X * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -X * sell copies of the Software, and to permit persons to whom the Software is -X * furnished to do so, subject to the following conditions: -X * -X * The above copyright notice and this permission notice shall be included in -X * all copies or substantial portions of the Software. -X * -X * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -X * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -X * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -X * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -X * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -X * -X * Except as contained in this notice, the name of the XFree86 Project shall -X * not be used in advertising or otherwise to promote the sale, use or other -X * dealings in this Software without prior written authorization from the -X * XFree86 Project. -X */ -X -X/* -X * Aperture driver for Solaris. -X */ -X -X/* -X * Modified: Martin Bochnig (martin@martux.org) -X * Log: Commented out obsolete kernel interfaces DDI_IDENTIFIED and DDI_NOT_IDENTIFIED -X * not supported by SunOS 5.10 or higher anymore, -X * see http://docs.sun.com/app/docs/doc/819-2255/6n4ibnffr?a=view -X */ -X -X#include <sys/conf.h> -X#include <sys/ddi.h> -X#include <sys/modctl.h> -X#include <sys/open.h> -X#include <sys/stat.h> -X#include <sys/sunddi.h> -X -X#define DEV_IDENT "aperture" -X#define DEV_BANNER "XFree86 aperture driver" -X -X#ifndef D_64BIT -X#define D_64BIT 0 -X#endif -X -X#ifndef NULL -X#define NULL ((void *)0) -X#endif -X -X/* -X * open(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_open -X( -X#ifdef __STDC__ -X dev_t *devp, -X int flag, -X int typ, -X struct cred *cred -X#endif -X) -X#ifndef __STDC__ -X dev_t *devp; -X int flag; -X int typ; -X struct cred *cred; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering open()\n"); -X -X#endif -X -X if ((typ != OTYP_CHR) || (getminor(*devp))) -X error = EINVAL; -X else -X error = 0; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving open() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * mmap(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_mmap -X( -X#ifdef __STDC__ -X dev_t dev, -X off_t off, -X int prot -X#endif -X) -X#ifndef __STDC__ -X dev_t dev; -X off_t off; -X int prot; -X#endif -X{ -X pfn_t pf; -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering mmap(0x%016lx)\n", off); -X -X#endif -X -X pf = btop((unsigned long)off); -X -X /* Deal with mmap(9E) interface limits */ -X error = (int)pf; -X if ((error < 0) || (pf != (pfn_t)error)) -X error = -1; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving mmap() = 0x%08lx", error); -X -X#endif -X -X return error; -X} -X -Xstatic struct cb_ops aperture_cb_ops = -X{ -X aperture_open, /* open */ -X nulldev, /* close */ -X nodev, /* strategy */ -X nodev, /* print */ -X nodev, /* dump */ -X nodev, /* read */ -X nodev, /* write */ -X nodev, /* ioctl */ -X nodev, /* devmap */ -X aperture_mmap, /* mmap */ -X ddi_segmap, /* segmap */ -X nochpoll, /* poll */ -X ddi_prop_op, /* cb_prop_op */ -X 0, /* streamtab */ -X D_NEW | D_MP | D_64BIT /* Driver compatibility flag */ -X}; -X -X -Xstatic dev_info_t *aperture_dip; /* private copy of devinfo pointer */ -X -X/* -X * getinfo(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_getinfo -X( -X#ifdef __STDC__ -X dev_info_t *dip, -X ddi_info_cmd_t infocmd, -X void *arg, -X void **result -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X ddi_info_cmd_t infocmd; -X void *arg; -X void **result; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering getinfo()\n"); -X -X#endif -X -X switch (infocmd) { -X case DDI_INFO_DEVT2DEVINFO: -X *result = aperture_dip; -X error = DDI_SUCCESS; -X break; -X case DDI_INFO_DEVT2INSTANCE: -X *result = NULL; -X error = DDI_SUCCESS; -X break; -X default: -X error = DDI_FAILURE; -X } -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving getinfo() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * identify(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_identify -X( -X#ifdef __STDC__ -X dev_info_t *dip -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering identify()\n"); -X -X#endif -X -X if (strcmp(ddi_get_name(dip), DEV_IDENT)) -X error = 1 /* DDI_NOT_IDENTIFIED obsolete since SunOS 5.10 */ ; -X else -X error = 2 /* DDI_IDENTIFIED obsolete since SunOS 5.10 */ ; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving identify() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * attach(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_attach -X( -X#ifdef __STDC__ -X dev_info_t *dip, -X ddi_attach_cmd_t cmd -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X ddi_attach_cmd_t cmd; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering attach()\n"); -X -X#endif -X -X if (cmd != DDI_ATTACH) -X { -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": not attach(, DDI_ATTACH)\n"); -X -X#endif -X -X error = DDI_FAILURE; -X } -X else -X { -X error = ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR, -X (minor_t)ddi_get_instance(dip), -X NULL, 0 /* NODESPECIFIC_DEV obsolete since SunOS 5.10 */ ); -X -X if (error == DDI_SUCCESS) -X { -X aperture_dip = dip; -X ddi_report_dev(dip); -X } -X } -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving attach() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * detach(9E) -X */ -Xstatic int -Xaperture_detach -X( -X#ifdef __STDC__ -X dev_info_t *dip, -X ddi_detach_cmd_t cmd -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X ddi_detach_cmd_t cmd; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering detach()\n"); -X -X#endif -X -X if (cmd != DDI_DETACH) -X { -X error = DDI_FAILURE; -X } -X else -X { -X ddi_remove_minor_node(dip, NULL); -X aperture_dip = NULL; -X error = DDI_SUCCESS; -X } -X -X#if APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving detach() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X -Xstatic struct dev_ops aperture_ops = -X{ -X DEVO_REV, /* revision */ -X 0, /* refcnt */ -X aperture_getinfo, /* getinfo */ -X aperture_identify, /* identify */ -X nulldev, /* probe */ -X aperture_attach, /* attach */ -X aperture_detach, /* detach */ -X nodev, /* reset */ -X &aperture_cb_ops, /* driver operations */ -X NULL /* bus operations */ -X}; -X -X -Xstatic struct modldrv modldrv = -X{ -X &mod_driverops, /* mod_ops structure pointer */ -X DEV_BANNER, /* driver banner string */ -X &aperture_ops, /* dev_ops structure pointer */ -X}; -X -X -Xstatic struct modlinkage modlinkage = -X{ -X MODREV_1, /* module API revision */ -X { -X &modldrv, /* module driver structure pointer */ -X NULL /* list termination */ -X } -X}; -X -X -X/* -X * _init(9E) -X */ -Xint -X_init -X( -X#ifdef __STDC__ -X void -X#endif -X) -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering _init()\n"); -X -X#endif -X -X error = mod_install(&modlinkage); -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving _init() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * _info(9E) -X */ -Xint -X_info -X( -X#ifdef __STDC__ -X struct modinfo *modinfop -X#endif -X) -X#ifndef __STDC__ -X struct modinfo *modinfop; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering _info()\n"); -X -X#endif -X -X error = mod_info(&modlinkage, modinfop); -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving _info() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * _fini(9E) -X */ -Xint -X_fini -X( -X#ifdef __STDC__ -X void -X#endif -X) -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering _fini()\n"); -X -X#endif -X -X error = mod_remove(&modlinkage); -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving _fini() = %d\n", error); -X -X#endif -X -X return error; -X} -END-of-./aperture/aperture.c -echo x - ./aperture/aperture.conf -sed 's/^X//' >./aperture/aperture.conf << 'END-of-./aperture/aperture.conf' -X# -X# Copyright 1994 Doug Anson, danson@lgc.com & David Holland, davidh@use.com -X# -X# File: aperture.conf -X# Author: Doug Anson (danson@lgc.com) -X# -X# Modified: David Holland (davidh@use.com) -X# Log: Change comments 02/23/94 -X# Change defaults/comments 09/25/94 -X# -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Log: SPARC changes 2001.09 -X# -X# Purpose: This conf file is used by the aperture driver. -X# -Xname="aperture" parent="pseudo"; -END-of-./aperture/aperture.conf -echo x - ./aperture/devlink.tab -sed 's/^X//' >./aperture/devlink.tab << 'END-of-./aperture/devlink.tab' -X# The following entry is for the aperture driver -Xtype=ddi_pseudo;name=aperture fbs/\M0 -END-of-./aperture/devlink.tab -exit - diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h index 31035ae2d..e5fa6cec2 100644 --- a/xorg-server/hw/xfree86/parser/Configint.h +++ b/xorg-server/hw/xfree86/parser/Configint.h @@ -204,6 +204,8 @@ else\ "Multiple \"%s\" lines." #define MUST_BE_OCTAL_MSG \ "The number \"%d\" given in this section must be in octal (0xxx) format." +#define GPU_DEVICE_TOO_MANY \ +"More than %d GPU devices defined." /* Warning messages */ #define OBSOLETE_MSG \ diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c index 9d8eda277..b5b454ff4 100644 --- a/xorg-server/hw/xfree86/parser/Screen.c +++ b/xorg-server/hw/xfree86/parser/Screen.c @@ -211,6 +211,7 @@ static xf86ConfigSymTabRec ScreenTab[] = { {DEFAULTFBBPP, "defaultfbbpp"}, {VIRTUAL, "virtual"}, {OPTION, "option"}, + {GDEVICE, "gpudevice"}, {-1, ""}, }; @@ -270,6 +271,13 @@ xf86parseScreenSection(void) Error(QUOTE_MSG, "Device"); ptr->scrn_device_str = xf86_lex_val.str; break; + case GDEVICE: + if (xf86getSubToken(&(ptr->scrn_comment)) != STRING) + Error(QUOTE_MSG, "GPUDevice"); + if (ptr->num_gpu_devices == CONF_MAXGPUDEVICES) + Error(GPU_DEVICE_TOO_MANY, CONF_MAXGPUDEVICES); + ptr->scrn_gpu_device_str[ptr->num_gpu_devices++] = xf86_lex_val.str; + break; case MONITOR: if (xf86getSubToken(&(ptr->scrn_comment)) != STRING) Error(QUOTE_MSG, "Monitor"); @@ -342,7 +350,7 @@ xf86printScreenSection(FILE * cf, XF86ConfScreenPtr ptr) XF86ConfAdaptorLinkPtr aptr; XF86ConfDisplayPtr dptr; XF86ModePtr mptr; - + int i; while (ptr) { fprintf(cf, "Section \"Screen\"\n"); if (ptr->scrn_comment) @@ -353,6 +361,9 @@ xf86printScreenSection(FILE * cf, XF86ConfScreenPtr ptr) fprintf(cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver); if (ptr->scrn_device_str) fprintf(cf, "\tDevice \"%s\"\n", ptr->scrn_device_str); + for (i = 0; i < ptr->num_gpu_devices; i++) + if (ptr->scrn_gpu_device_str[i]) + fprintf(cf, "\tGPUDevice \"%s\"\n", ptr->scrn_gpu_device_str[i]); if (ptr->scrn_monitor_str) fprintf(cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str); if (ptr->scrn_defaultdepth) @@ -426,11 +437,13 @@ void xf86freeScreenList(XF86ConfScreenPtr ptr) { XF86ConfScreenPtr prev; - + int i; while (ptr) { TestFree(ptr->scrn_identifier); TestFree(ptr->scrn_monitor_str); TestFree(ptr->scrn_device_str); + for (i = 0; i < ptr->num_gpu_devices; i++) + TestFree(ptr->scrn_gpu_device_str[i]); TestFree(ptr->scrn_comment); xf86optionListFree(ptr->scrn_option_lst); xf86freeAdaptorLinkList(ptr->scrn_adaptor_lst); @@ -487,6 +500,7 @@ xf86validateScreen(XF86ConfigPtr p) XF86ConfScreenPtr screen = p->conf_screen_lst; XF86ConfMonitorPtr monitor; XF86ConfAdaptorLinkPtr adaptor; + int i; while (screen) { if (screen->scrn_obso_driver && !screen->scrn_identifier) @@ -505,6 +519,10 @@ xf86validateScreen(XF86ConfigPtr p) screen->scrn_device = xf86findDevice(screen->scrn_device_str, p->conf_device_lst); + for (i = 0; i < screen->num_gpu_devices; i++) { + screen->scrn_gpu_devices[i] = + xf86findDevice(screen->scrn_gpu_device_str[i], p->conf_device_lst); + } adaptor = screen->scrn_adaptor_lst; while (adaptor) { adaptor->al_adaptor = diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h index 43e17550c..b3a50e52f 100644 --- a/xorg-server/hw/xfree86/parser/xf86Parser.h +++ b/xorg-server/hw/xfree86/parser/xf86Parser.h @@ -259,6 +259,7 @@ typedef struct { XF86ConfVideoAdaptorPtr al_adaptor; } XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr; +#define CONF_MAXGPUDEVICES 4 typedef struct { GenericListRec list; const char *scrn_identifier; @@ -276,6 +277,10 @@ typedef struct { char *scrn_comment; int scrn_virtualX, scrn_virtualY; char *match_seat; + + int num_gpu_devices; + const char *scrn_gpu_device_str[CONF_MAXGPUDEVICES]; + XF86ConfDevicePtr scrn_gpu_devices[CONF_MAXGPUDEVICES]; } XF86ConfScreenRec, *XF86ConfScreenPtr; typedef struct { diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h index 9c44970ea..bbd6b90d1 100644 --- a/xorg-server/hw/xfree86/parser/xf86tokens.h +++ b/xorg-server/hw/xfree86/parser/xf86tokens.h @@ -143,6 +143,7 @@ typedef enum { /* Screen tokens */ OBSDRIVER, MDEVICE, + GDEVICE, MONITOR, SCREENNO, DEFAULTDEPTH, diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c index d5df17fd9..9413c20fa 100644 --- a/xorg-server/hw/xfree86/utils/cvt/cvt.c +++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c @@ -54,11 +54,11 @@ XNFalloc(unsigned long n) /* xnfcalloc implementation used by the server code we built in */ void * -XNFcalloc(unsigned long n) +XNFcallocarray(size_t nmemb, size_t size) { void *r; - r = calloc(1, n); + r = calloc(nmemb, size); if (!r) { perror("calloc failed"); exit(1); diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c index 5ea019733..ef12cb805 100644 --- a/xorg-server/hw/xfree86/vbe/vbe.c +++ b/xorg-server/hw/xfree86/vbe/vbe.c @@ -397,7 +397,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) i = 0; while (modes[i] != 0xffff) i++; - block->VideoModePtr = malloc(sizeof(CARD16) * (i + 1)); + block->VideoModePtr = xallocarray(i + 1, sizeof(CARD16)); memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i); block->VideoModePtr[i] = 0xffff; @@ -825,7 +825,7 @@ VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num, if (set) return data; - data = malloc(num * sizeof(CARD32)); + data = xallocarray(num, sizeof(CARD32)); memcpy(data, pVbe->memory, num * sizeof(CARD32)); return data; diff --git a/xorg-server/hw/xnest/Color.c b/xorg-server/hw/xnest/Color.c index 8d9d35621..3a9e42203 100644 --- a/xorg-server/hw/xnest/Color.c +++ b/xorg-server/hw/xnest/Color.c @@ -62,7 +62,7 @@ xnestCreateColormap(ColormapPtr pCmap) switch (pVisual->class) { case StaticGray: /* read only */ - colors = (XColor *) malloc(ncolors * sizeof(XColor)); + colors = xallocarray(ncolors, sizeof(XColor)); for (i = 0; i < ncolors; i++) colors[i].pixel = i; XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); @@ -75,7 +75,7 @@ xnestCreateColormap(ColormapPtr pCmap) break; case StaticColor: /* read only */ - colors = (XColor *) malloc(ncolors * sizeof(XColor)); + colors = xallocarray(ncolors, sizeof(XColor)); for (i = 0; i < ncolors; i++) colors[i].pixel = i; XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); @@ -88,7 +88,7 @@ xnestCreateColormap(ColormapPtr pCmap) break; case TrueColor: /* read only */ - colors = (XColor *) malloc(ncolors * sizeof(XColor)); + colors = xallocarray(ncolors, sizeof(XColor)); red = green = blue = 0L; redInc = lowbit(pVisual->redMask); greenInc = lowbit(pVisual->greenMask); @@ -194,14 +194,12 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen) xnestInstalledColormapWindows icws; int numWindows; - icws.cmapIDs = (Colormap *) malloc(pScreen->maxInstalledCmaps * - sizeof(Colormap)); + icws.cmapIDs = xallocarray(pScreen->maxInstalledCmaps, sizeof(Colormap)); icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs); icws.numWindows = 0; WalkTree(pScreen, xnestCountInstalledColormapWindows, (void *) &icws); if (icws.numWindows) { - icws.windows = - (Window *) malloc((icws.numWindows + 1) * sizeof(Window)); + icws.windows = xallocarray(icws.numWindows + 1, sizeof(Window)); icws.index = 0; WalkTree(pScreen, xnestGetInstalledColormapWindows, (void *) &icws); icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum]; @@ -220,8 +218,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen) #ifdef _XSERVER64 { int i; - Window64 *windows = - (Window64 *) malloc(numWindows * sizeof(Window64)); + Window64 *windows = xallocarray(numWindows, sizeof(Window64)); for (i = 0; i < numWindows; ++i) windows[i] = icws.windows[i]; @@ -393,7 +390,7 @@ xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem * pColors) #ifdef _XSERVER64 { int i; - XColor *pColors64 = (XColor *) malloc(nColors * sizeof(XColor)); + XColor *pColors64 = xallocarray(nColors, sizeof(XColor)); for (i = 0; i < nColors; ++i) { pColors64[i].pixel = pColors[i].pixel; diff --git a/xorg-server/hw/xnest/Display.c b/xorg-server/hw/xnest/Display.c index a2f8acbaa..e6d07dfd1 100644 --- a/xorg-server/hw/xnest/Display.c +++ b/xorg-server/hw/xnest/Display.c @@ -121,8 +121,8 @@ xnestOpenDisplay(int argc, char *argv[]) } xnestNumDefaultColormaps = xnestNumVisuals; - xnestDefaultColormaps = (Colormap *) malloc(xnestNumDefaultColormaps * - sizeof(Colormap)); + xnestDefaultColormaps = xallocarray(xnestNumDefaultColormaps, + sizeof(Colormap)); for (i = 0; i < xnestNumDefaultColormaps; i++) xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay, DefaultRootWindow diff --git a/xorg-server/hw/xnest/GC.c b/xorg-server/hw/xnest/GC.c index 96af6eb91..ecfa61e39 100644 --- a/xorg-server/hw/xnest/GC.c +++ b/xorg-server/hw/xnest/GC.c @@ -190,7 +190,7 @@ xnestDestroyGC(GCPtr pGC) void xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects) { - int i, size; + int i; BoxPtr pBox; XRectangle *pRects; @@ -204,8 +204,7 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects) case CT_REGION: nRects = RegionNumRects((RegionPtr) pValue); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); + pRects = xallocarray(nRects, sizeof(*pRects)); pBox = RegionRects((RegionPtr) pValue); for (i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; diff --git a/xorg-server/hw/xnest/Keyboard.c b/xorg-server/hw/xnest/Keyboard.c index ee3f68e3f..7ee7a7c3c 100644 --- a/xorg-server/hw/xnest/Keyboard.c +++ b/xorg-server/hw/xnest/Keyboard.c @@ -16,6 +16,10 @@ is" without express or implied warranty. #include <xnest-config.h> #endif +#ifdef WIN32 +#include <X11/Xwindows.h> +#endif + #include <X11/X.h> #include <X11/Xproto.h> #include <xcb/xcb_keysyms.h> @@ -134,7 +138,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) max_keycode - min_keycode + 1, &mapWidth); len = (max_keycode - min_keycode + 1) * mapWidth; - keymap = (KeySym *) malloc(len * sizeof(KeySym)); + keymap = xallocarray(len, sizeof(KeySym)); for (i = 0; i < len; ++i) keymap[i] = keymap64[i]; XFree(keymap64); diff --git a/xorg-server/hw/xnest/Screen.c b/xorg-server/hw/xnest/Screen.c index abb4d372d..214b55015 100644 --- a/xorg-server/hw/xnest/Screen.c +++ b/xorg-server/hw/xnest/Screen.c @@ -158,7 +158,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0)) return FALSE; - visuals = (VisualPtr) malloc(xnestNumVisuals * sizeof(VisualRec)); + visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec)); numVisuals = 0; depths = (DepthPtr) malloc(MAXDEPTH * sizeof(DepthRec)); @@ -224,7 +224,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) numVisuals++; } - visuals = (VisualPtr) realloc(visuals, numVisuals * sizeof(VisualRec)); + visuals = reallocarray(visuals, numVisuals, sizeof(VisualRec)); defaultVisual = visuals[xnestDefaultVisualIndex].vid; rootDepth = visuals[xnestDefaultVisualIndex].nplanes; diff --git a/xorg-server/hw/xwayland/xwayland-glamor.c b/xorg-server/hw/xwayland/xwayland-glamor.c index d06006c70..6b6e59756 100644 --- a/xorg-server/hw/xwayland/xwayland-glamor.c +++ b/xorg-server/hw/xwayland/xwayland-glamor.c @@ -310,7 +310,7 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen) } if (!epoxy_has_gl_extension("GL_OES_EGL_image")) { - ErrorF("GL_OES_EGL_image no available"); + ErrorF("GL_OES_EGL_image not available\n"); return; } @@ -329,7 +329,7 @@ xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device) xwl_screen->drm_fd = open(xwl_screen->device_name, O_RDWR | O_CLOEXEC); if (xwl_screen->drm_fd == -1) { - ErrorF("wayland-egl: could not open %s (%s)", + ErrorF("wayland-egl: could not open %s (%s)\n", xwl_screen->device_name, strerror(errno)); return; } diff --git a/xorg-server/hw/xwayland/xwayland-input.c b/xorg-server/hw/xwayland/xwayland-input.c index cc3bc53c8..78d9702ac 100644 --- a/xorg-server/hw/xwayland/xwayland-input.c +++ b/xorg-server/hw/xwayland/xwayland-input.c @@ -43,7 +43,7 @@ static int xwl_pointer_proc(DeviceIntPtr device, int what) { #define NBUTTONS 10 -#define NAXES 2 +#define NAXES 4 BYTE map[NBUTTONS + 1]; int i = 0; Atom btn_labels[NBUTTONS] = { 0 }; @@ -67,8 +67,10 @@ xwl_pointer_proc(DeviceIntPtr device, int what) axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X); axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y); + axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HWHEEL); + axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_WHEEL); - if (!InitValuatorClassDeviceStruct(device, 2, btn_labels, + if (!InitValuatorClassDeviceStruct(device, NAXES, btn_labels, GetMotionHistorySize(), Absolute)) return BadValue; @@ -77,6 +79,13 @@ xwl_pointer_proc(DeviceIntPtr device, int what) 0, 0xFFFF, 10000, 0, 10000, Absolute); InitValuatorAxisStruct(device, 1, axes_labels[1], 0, 0xFFFF, 10000, 0, 10000, Absolute); + InitValuatorAxisStruct(device, 2, axes_labels[2], + NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative); + InitValuatorAxisStruct(device, 3, axes_labels[3], + NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative); + + SetScrollValuator(device, 2, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE); + SetScrollValuator(device, 3, SCROLL_TYPE_VERTICAL, 1.0, SCROLL_FLAG_PREFERRED); if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control)) return BadValue; @@ -259,54 +268,24 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { struct xwl_seat *xwl_seat = data; - int index, count; - int i, val; + int index; const int divisor = 10; ValuatorMask mask; - if (time - xwl_seat->scroll_time > 2000) { - xwl_seat->vertical_scroll = 0; - xwl_seat->horizontal_scroll = 0; - } - xwl_seat->scroll_time = time; - - /* FIXME: Need to do proper smooth scrolling here! */ switch (axis) { case WL_POINTER_AXIS_VERTICAL_SCROLL: - xwl_seat->vertical_scroll += value / divisor; - val = wl_fixed_to_int(xwl_seat->vertical_scroll); - xwl_seat->vertical_scroll -= wl_fixed_from_int(val); - - if (val <= -1) - index = 4; - else if (val >= 1) - index = 5; - else - return; + index = 3; break; case WL_POINTER_AXIS_HORIZONTAL_SCROLL: - xwl_seat->horizontal_scroll += value / divisor; - val = wl_fixed_to_int(xwl_seat->horizontal_scroll); - xwl_seat->horizontal_scroll -= wl_fixed_from_int(val); - - if (val <= -1) - index = 6; - else if (val >= 1) - index = 7; - else - return; + index = 2; break; default: return; } valuator_mask_zero(&mask); - - count = abs(val); - for (i = 0; i < count; i++) { - QueuePointerEvents(xwl_seat->pointer, ButtonPress, index, 0, &mask); - QueuePointerEvents(xwl_seat->pointer, ButtonRelease, index, 0, &mask); - } + valuator_mask_set_double(&mask, index, wl_fixed_to_double(value) / divisor); + QueuePointerEvents(xwl_seat->pointer, MotionNotify, 0, POINTER_RELATIVE, &mask); } static const struct wl_pointer_listener pointer_listener = { @@ -561,7 +540,7 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id) xwl_seat = calloc(sizeof *xwl_seat, 1); if (xwl_seat == NULL) { - ErrorF("create_input ENOMEM"); + ErrorF("create_input ENOMEM\n"); return; } diff --git a/xorg-server/hw/xwayland/xwayland-output.c b/xorg-server/hw/xwayland/xwayland-output.c index 778914c61..155cbc109 100644 --- a/xorg-server/hw/xwayland/xwayland-output.c +++ b/xorg-server/hw/xwayland/xwayland-output.c @@ -159,7 +159,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id) xwl_output = calloc(sizeof *xwl_output, 1); if (xwl_output == NULL) { - ErrorF("create_output ENOMEM"); + ErrorF("create_output ENOMEM\n"); return NULL; } @@ -168,7 +168,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id) wl_output_add_listener(xwl_output->output, &output_listener, xwl_output); if (snprintf(name, sizeof name, "XWAYLAND%d", serial++) < 0) { - ErrorF("create_output ENOMEM"); + ErrorF("create_output ENOMEM\n"); free(xwl_output); return NULL; } diff --git a/xorg-server/hw/xwayland/xwayland.h b/xorg-server/hw/xwayland/xwayland.h index bfffa712f..cfb343d36 100644 --- a/xorg-server/hw/xwayland/xwayland.h +++ b/xorg-server/hw/xwayland/xwayland.h @@ -122,10 +122,6 @@ struct xwl_seat { struct xorg_list link; CursorPtr x_cursor; - wl_fixed_t horizontal_scroll; - wl_fixed_t vertical_scroll; - uint32_t scroll_time; - size_t keymap_size; char *keymap; struct wl_surface *keyboard_focus; diff --git a/xorg-server/hw/xwin/winclipboard/Makefile.am b/xorg-server/hw/xwin/winclipboard/Makefile.am index b1c95f4ef..a1079aec6 100644 --- a/xorg-server/hw/xwin/winclipboard/Makefile.am +++ b/xorg-server/hw/xwin/winclipboard/Makefile.am @@ -19,7 +19,7 @@ xwinclip_SOURCES = xwinclip.c debug.c xwinclip_CFLAGS = $(XWINMODULES_CFLAGS) -xwinclip_LDADD = libXWinclipboard.la $(XWINMODULES_LIBS) -lgdi32 +xwinclip_LDADD = libXWinclipboard.la $(XWINMODULES_LIBS) -lgdi32 -lpthread include $(top_srcdir)/manpages.am appman_PRE = xwinclip.man |