[PATCH 05/36] dix: introduce gpu screens. (v4)

Fernando Carrijo fcarrijo at freedesktop.org
Thu Jul 5 19:00:56 PDT 2012


Dave Airlie <airlied at gmail.com> wrote:

> +int
> +AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
> +                              int /*argc */ ,
> +                              char **      /*argv */
> +                              ),
> +             int argc, char **argv)
> +{
> +    int i;
> +    ScreenPtr pScreen;
> +    Bool ret;
> +
> +    i = screenInfo.numGPUScreens;
> +    if (i == MAXGPUSCREENS)
> +        return -1;
> +
> +    pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec));
> +    if (!pScreen)
> +        return -1;
> +
> +    ret = init_screen(pScreen, i, TRUE);
> +    if (ret != 0) {
> +        free(pScreen);
> +        return ret;
> +    }
> +
> +    /* This is where screen specific stuff gets initialized.  Load the
> +       screen structure, call the hardware, whatever.
> +       This is also where the default colormap should be allocated and
> +       also pixel values for blackPixel, whitePixel, and the cursor
> +       Note that InitScreen is NOT allowed to modify argc, argv, or
> +       any of the strings pointed to by argv.  They may be passed to
> +       multiple screens.
> +     */
> +    screenInfo.gpuscreens[i] = pScreen;
> +    screenInfo.numGPUScreens++;
> +    if (!(*pfnInit) (pScreen, argc, argv)) {
> +        dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
> +        free(pScreen);
> +        screenInfo.numGPUScreens--;
> +        return -1;
> +    }
> +
> +    update_desktop_dimensions();

Don't we need to update_desktop_dimensions() also in RemoveGPUScreen?

> +
> +    dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen, PRIVATE_CURSOR,
> +                                0);
> +
> +    return i;
> +}
> +
> +void
> +RemoveGPUScreen(ScreenPtr pScreen)
> +{
> +    int idx, j;
> +    if (!pScreen->isGPU)
> +        return;
> +
> +    idx = pScreen->myNum - GPU_SCREEN_OFFSET;
> +    for (j = idx; j < screenInfo.numGPUScreens - 1; j++) {
> +        screenInfo.gpuscreens[j] = screenInfo.gpuscreens[j + 1];
> +        screenInfo.gpuscreens[j]->myNum = j + GPU_SCREEN_OFFSET;
> +    }
> +    screenInfo.numGPUScreens--;
> +
> +    free(pScreen);
> +
> +}


More information about the xorg-devel mailing list