Example #1
0
static Bool
ephyrXVPrivSaveImageToPortPriv(EphyrPortPriv * a_port_priv,
                               const unsigned char *a_image_buf,
                               int a_image_len)
{
    Bool is_ok = FALSE;

    EPHYR_LOG("enter\n");

    if (a_port_priv->image_buf_size < a_image_len) {
        unsigned char *buf = NULL;

        buf = realloc(a_port_priv->image_buf, a_image_len);
        if (!buf) {
            EPHYR_LOG_ERROR("failed to realloc image buffer\n");
            goto out;
        }
        a_port_priv->image_buf = buf;
        a_port_priv->image_buf_size = a_image_len;
    }
    memmove(a_port_priv->image_buf, a_image_buf, a_image_len);
    is_ok = TRUE;

 out:
    return is_ok;
    EPHYR_LOG("leave\n");
}
Example #2
0
static int
ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
                      Atom a_attr_name, int *a_attr_value, pointer a_port_priv)
{
    int res = Success, host_atom = 0;
    EphyrPortPriv *port_priv = a_port_priv;

    EPHYR_RETURN_VAL_IF_FAIL(port_priv, BadMatch);
    EPHYR_RETURN_VAL_IF_FAIL(ValidAtom(a_attr_name), BadMatch);

    EPHYR_LOG("enter, portnum:%d, atomid:%d, attr_name:%s\n",
              port_priv->port_number,
              (int) a_attr_name, NameForAtom(a_attr_name));

    if (!ephyrLocalAtomToHost(a_attr_name, &host_atom)) {
        EPHYR_LOG_ERROR("failed to convert local atom to host atom\n");
        res = BadMatch;
        goto out;
    }

    if (!ephyrHostXVGetPortAttribute(port_priv->port_number,
                                     host_atom, a_attr_value)) {
        EPHYR_LOG_ERROR("failed to get port attribute\n");
        res = BadMatch;
        goto out;
    }

    res = Success;
 out:
    EPHYR_LOG("leave\n");
    return res;
}
Example #3
0
static EphyrXVPriv *
ephyrXVPrivNew(void)
{
    EphyrXVPriv *xv_priv = NULL;

    EPHYR_LOG("enter\n");

    xv_priv = calloc(1, sizeof(EphyrXVPriv));
    if (!xv_priv) {
        EPHYR_LOG_ERROR("failed to create EphyrXVPriv\n");
        goto error;
    }

    ephyrHostXVInit();

    if (!ephyrXVPrivQueryHostAdaptors(xv_priv)) {
        EPHYR_LOG_ERROR("failed to query the host x for xv properties\n");
        goto error;
    }
    if (!ephyrXVPrivSetAdaptorsHooks(xv_priv)) {
        EPHYR_LOG_ERROR("failed to set xv_priv hooks\n");
        goto error;
    }

    EPHYR_LOG("leave\n");
    return xv_priv;

 error:
    if (xv_priv) {
        ephyrXVPrivDelete(xv_priv);
        xv_priv = NULL;
    }
    return NULL;
}
Example #4
0
static void
ephyrQueryBestSize(KdScreenInfo * a_info,
                   Bool a_motion,
                   short a_src_w,
                   short a_src_h,
                   short a_drw_w,
                   short a_drw_h,
                   unsigned int *a_prefered_w,
                   unsigned int *a_prefered_h, pointer a_port_priv)
{
    int res = 0;
    EphyrPortPriv *port_priv = a_port_priv;

    EPHYR_RETURN_IF_FAIL(port_priv);

    EPHYR_LOG("enter\n");
    res = ephyrHostXVQueryBestSize(port_priv->port_number,
                                   a_motion,
                                   a_src_w, a_src_h,
                                   a_drw_w, a_drw_h,
                                   a_prefered_w, a_prefered_h);
    if (!res) {
        EPHYR_LOG_ERROR("Failed to query best size\n");
    }
    EPHYR_LOG("leave\n");
}
Example #5
0
static int
ephyrQueryImageAttributes(KdScreenInfo * a_info,
                          int a_id,
                          unsigned short *a_w,
                          unsigned short *a_h, int *a_pitches, int *a_offsets)
{
    int image_size = 0;

    EPHYR_RETURN_VAL_IF_FAIL(a_w && a_h, FALSE);

    EPHYR_LOG("enter: dim (%dx%d), pitches: %p, offsets: %p\n",
              *a_w, *a_h, a_pitches, a_offsets);

    if (!ephyrHostXVQueryImageAttributes(s_base_port_id,
                                         a_id,
                                         a_w, a_h,
                                         &image_size, a_pitches, a_offsets)) {
        EPHYR_LOG_ERROR("EphyrHostXVQueryImageAttributes() failed\n");
        goto out;
    }
    EPHYR_LOG("image size: %d, dim (%dx%d)\n", image_size, *a_w, *a_h);

 out:
    EPHYR_LOG("leave\n");
    return image_size;
}
Example #6
0
Bool
ephyrDRIGetClientDriverName(int a_screen,
                            int *a_ddx_driver_major_version,
                            int *a_ddx_driver_minor_version,
                            int *a_ddx_driver_patch_version,
                            char **a_client_driver_name)
{
    Display *dpy = hostx_get_display();
    Bool is_ok = FALSE;

    EPHYR_RETURN_VAL_IF_FAIL(a_ddx_driver_major_version
                             && a_ddx_driver_minor_version
                             && a_ddx_driver_patch_version
                             && a_client_driver_name, FALSE);
    EPHYR_LOG("enter\n");
    is_ok = XF86DRIGetClientDriverName(dpy, DefaultScreen(dpy),
                                       a_ddx_driver_major_version,
                                       a_ddx_driver_minor_version,
                                       a_ddx_driver_patch_version,
                                       a_client_driver_name);
    EPHYR_LOG("major:%d, minor:%d, patch:%d, name:%s\n",
              *a_ddx_driver_major_version,
              *a_ddx_driver_minor_version,
              *a_ddx_driver_patch_version, *a_client_driver_name);
    EPHYR_LOG("leave:%d\n", is_ok);
    return is_ok;
}
Example #7
0
Bool
ephyrDRIGetDrawableInfo(int a_screen,
                        int a_drawable,
                        unsigned int *a_index,
                        unsigned int *a_stamp,
                        int *a_x,
                        int *a_y,
                        int *a_w,
                        int *a_h,
                        int *a_num_clip_rects,
                        drm_clip_rect_t ** a_clip_rects,
                        int *a_back_x,
                        int *a_back_y,
                        int *a_num_back_clip_rects,
                        drm_clip_rect_t ** a_back_clip_rects)
{
    Bool is_ok = FALSE;
    Display *dpy = hostx_get_display();
    EphyrHostWindowAttributes attrs;

    EPHYR_RETURN_VAL_IF_FAIL(a_x && a_y && a_w && a_h
                             && a_num_clip_rects, FALSE);

    EPHYR_LOG("enter\n");
    memset(&attrs, 0, sizeof(attrs));
    if (!hostx_get_window_attributes(a_drawable, &attrs)) {
        EPHYR_LOG_ERROR("failed to query host window attributes\n");
        goto out;
    }
    if (!XF86DRIGetDrawableInfo(dpy, DefaultScreen(dpy), a_drawable,
                                a_index, a_stamp,
                                a_x, a_y,
                                a_w, a_h,
                                a_num_clip_rects, a_clip_rects,
                                a_back_x, a_back_y,
                                a_num_back_clip_rects, a_back_clip_rects)) {
        EPHYR_LOG_ERROR("XF86DRIGetDrawableInfo ()\n");
        goto out;
    }
    EPHYR_LOG("host x,y,w,h: (%d,%d,%d,%d)\n", *a_x, *a_y, *a_w, *a_h);
    if (*a_num_clip_rects) {
        free(*a_back_clip_rects);
        *a_back_clip_rects = calloc(*a_num_clip_rects, sizeof(drm_clip_rect_t));
        memmove(*a_back_clip_rects,
                *a_clip_rects, *a_num_clip_rects * sizeof(drm_clip_rect_t));
        *a_num_back_clip_rects = *a_num_clip_rects;
    }
    EPHYR_LOG("num back clip rects:%d, num clip rects:%d\n",
              *a_num_clip_rects, *a_num_back_clip_rects);
    *a_back_x = *a_x;
    *a_back_y = *a_y;
    *a_w = attrs.width;
    *a_h = attrs.height;

    is_ok = TRUE;
 out:
    EPHYR_LOG("leave. index:%d, stamp:%d, x,y:(%d,%d), w,y:(%d,%d)\n",
              *a_index, *a_stamp, *a_x, *a_y, *a_w, *a_h);
    return is_ok;
}
Example #8
0
static int
ephyrGLXGetIntegervReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
{
    int res = BadImplementation;
    xGLXSingleReq *const req = (xGLXSingleReq *) a_pc;
    GLenum int_name;
    int value = 0;
    GLint answer_buf_room[200];
    GLint *buf = NULL;

    EPHYR_LOG("enter\n");

    a_pc += __GLX_SINGLE_HDR_SIZE;

    int_name = *(GLenum *) (a_pc + 0);
    if (!ephyrHostGetIntegerValue(req->contextTag, int_name, &value)) {
        EPHYR_LOG_ERROR("ephyrHostGetIntegerValue() failed\n");
        goto out;
    }
    buf = __glXGetAnswerBuffer(a_cl, sizeof(value),
                               answer_buf_room, sizeof(answer_buf_room), 4);

    if (!buf) {
        EPHYR_LOG_ERROR("failed to allocate reply buffer\n");
        res = BadAlloc;
        goto out;
    }
    __glXSendReply(a_cl->client, buf, 1, sizeof(value), GL_FALSE, 0);
    res = Success;

 out:
    EPHYR_LOG("leave\n");
    return res;
}
Example #9
0
static int
ephyrGLXIsDirectReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
{
    int res=BadImplementation;
    ClientPtr client = a_cl->client;
    xGLXIsDirectReq *req = (xGLXIsDirectReq *) a_pc;
    xGLXIsDirectReply reply;
    int is_direct=0 ;

    EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, FALSE) ;

    EPHYR_LOG ("enter\n") ;

    memset (&reply, 0, sizeof (reply)) ;
    if (!ephyrHostIsContextDirect (req->context, (int*)&is_direct)) {
        EPHYR_LOG_ERROR ("ephyrHostIsContextDirect() failed\n") ;
        goto out ;
    }
    reply.isDirect = is_direct ;
    reply.length = 0;
    reply.type = X_Reply;
    reply.sequenceNumber = client->sequence;
    WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
    res = Success ;

out:
    EPHYR_LOG ("leave\n") ;
    return res ;
}
Example #10
0
Bool
ephyrHostDestroyContext(int a_ctxt_id)
{
    Bool is_ok = FALSE;
    Display *dpy = hostx_get_display();
    int major_opcode = 0, remote_ctxt_id = 0;
    xGLXDestroyContextReq *req = NULL;

    EPHYR_LOG("enter:%d\n", a_ctxt_id);

    if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
        EPHYR_LOG_ERROR("failed to get major opcode\n");
        goto out;
    }
    if (!hostx_get_resource_id_peer(a_ctxt_id, &remote_ctxt_id)) {
        EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
        goto out;
    }
    EPHYR_LOG("host context id:%d\n", remote_ctxt_id);

    LockDisplay(dpy);
    GetReq(GLXDestroyContext, req);
    req->reqType = major_opcode;
    req->glxCode = X_GLXDestroyContext;
    req->context = remote_ctxt_id;
    UnlockDisplay(dpy);
    SyncHandle();

    is_ok = TRUE;

 out:
    EPHYR_LOG("leave\n");
    return is_ok;
}
Example #11
0
Bool
ephyrInitScreen(ScreenPtr pScreen)
{
    KdScreenPriv(pScreen);
    KdScreenInfo *screen = pScreenPriv->screen;

    EPHYR_LOG("pScreen->myNum:%d\n", pScreen->myNum);
    hostx_set_screen_number(screen, pScreen->myNum);
    hostx_set_win_title(screen, "(ctrl+shift grabs mouse and keyboard)");
    pScreen->CreateColormap = ephyrCreateColormap;

#ifdef XV
    if (!ephyrNoXV) {
        if (!ephyrInitVideo(pScreen)) {
            EPHYR_LOG_ERROR("failed to initialize xvideo\n");
        }
        else {
            EPHYR_LOG("initialized xvideo okay\n");
        }
    }
#endif /*XV*/
#ifdef XF86DRI
    if (!ephyrNoDRI && !host_has_extension(&xcb_xf86dri_id)) {
        EPHYR_LOG("host x does not support DRI. Disabling DRI forwarding\n");
        ephyrNoDRI = TRUE;
    }
    if (!ephyrNoDRI) {
        ephyrDRIExtensionInit(pScreen);
        ephyrHijackGLXExtension();
    }
#endif

    return TRUE;
}
Example #12
0
Bool
ephyrInitScreen(ScreenPtr pScreen)
{
    KdScreenPriv(pScreen);
    KdScreenInfo *screen = pScreenPriv->screen;

    EPHYR_LOG("pScreen->myNum:%d\n", pScreen->myNum);
    hostx_set_screen_number(screen, pScreen->myNum);
    if (EphyrWantNoHostGrab) {
        hostx_set_win_title(screen, "xephyr");
    } else {
        hostx_set_win_title(screen, "(ctrl+shift grabs mouse and keyboard)");
    }
    pScreen->CreateColormap = ephyrCreateColormap;

#ifdef XV
    if (!ephyrNoXV) {
        if (ephyr_glamor)
            ephyr_glamor_xv_init(pScreen);
        else if (!ephyrInitVideo(pScreen)) {
            EPHYR_LOG_ERROR("failed to initialize xvideo\n");
        }
        else {
            EPHYR_LOG("initialized xvideo okay\n");
        }
    }
#endif /*XV*/

    return TRUE;
}
Example #13
0
static int
ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLXDrawable write,
                        GLXDrawable read, GLXContextTag ctx,
                        GLXContextTag old_ctx, Bool a_do_swap)
{
    int res = BadImplementation;
    xGLXMakeCurrentReply reply;
    DrawablePtr drawableR = NULL, drawableW = NULL;
    GLXContextTag new_ctx = 0;

    EPHYR_LOG("enter\n");
    res = dixLookupDrawable(&drawableW, write, a_cl->client, 0, DixReadAccess);
    EPHYR_RETURN_VAL_IF_FAIL(drawableW, BadValue);
    EPHYR_RETURN_VAL_IF_FAIL(drawableW->pScreen, BadValue);
    EPHYR_LOG("screen nummber requested:%d\n", drawableW->pScreen->myNum);

    if (read != write) {
        res = dixLookupDrawable(&drawableR, read, a_cl->client, 0,
                                DixReadAccess);
        EPHYR_RETURN_VAL_IF_FAIL(drawableR, BadValue);
        EPHYR_RETURN_VAL_IF_FAIL(drawableR->pScreen, BadValue);
    }
    else {
        drawableR = drawableW;
    }

    if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawableW->pScreen->myNum),
                                 hostx_get_window(drawableR->pScreen->myNum),
                                 ctx, old_ctx, (int *) &new_ctx)) {
        EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n");
        goto out;
    }
    reply = (xGLXMakeCurrentReply) {
        .type = X_Reply,
        .sequenceNumber = a_cl->client->sequence,
        .length = 0,
        .contextTag = new_ctx
    };
    if (a_do_swap) {
        __GLX_DECLARE_SWAP_VARIABLES;
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
        __GLX_SWAP_INT(&reply.length);
        __GLX_SWAP_INT(&reply.contextTag);
    }
    WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, &reply);

    res = Success;
 out:
    EPHYR_LOG("leave\n");
    return res;
}

int
ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc)
{
    xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
    return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable,
                                   req->context, req->oldContextTag, FALSE);
}
Example #14
0
Bool
ephyrDRIDestroyDrawable(int a_screen, int a_drawable)
{
    EPHYR_LOG("enter\n");
    EPHYR_LOG_ERROR("not implemented yet\n");
    EPHYR_LOG("leave\n");
    return FALSE;
}
Example #15
0
static int
ephyrGLXGetFBConfigsSGIXReal (__GLXclientState *a_cl,
                              GLbyte *a_pc,
                              Bool a_do_swap)
{
    xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)a_pc;
    ClientPtr client = a_cl->client;
    xGLXGetVisualConfigsReply reply;
    int32_t *props_buf=NULL, num_visuals=0,
            num_props=0, res=BadImplementation, i=0,
            props_per_visual_size=0,
            props_buf_size=0;
    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;

    EPHYR_LOG ("enter\n") ;

    if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX (req->screen,
                                                 &num_visuals,
                                                 &num_props,
                                                 &props_buf_size,
                                                 &props_buf)) {
        EPHYR_LOG_ERROR ("ephyrHostGLXGetVisualConfigs() failed\n") ;
        goto out ;
    }
    EPHYR_LOG ("num_visuals:%d, num_props:%d\n", num_visuals, num_props) ;

    reply.numVisuals = num_visuals;
    reply.numProps = num_props;
    reply.length = props_buf_size >> 2;
    reply.type = X_Reply;
    reply.sequenceNumber = client->sequence;

    if (a_do_swap) {
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
        __GLX_SWAP_INT(&reply.length);
        __GLX_SWAP_INT(&reply.numVisuals);
        __GLX_SWAP_INT(&reply.numProps);
        __GLX_SWAP_INT_ARRAY (props_buf, num_props) ;
    }
    WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char*)&reply);
    props_per_visual_size = props_buf_size/num_visuals ;
    for (i=0; i < num_visuals; i++) {
        WriteToClient (client,
                       props_per_visual_size,
                       &((char*)props_buf)[i*props_per_visual_size]);
    }
    res = Success ;

out:
    EPHYR_LOG ("leave\n") ;
    free(props_buf) ;
    props_buf = NULL ;

    return res ;
}
Example #16
0
static int
ephyrSetPortAttribute(KdScreenInfo * a_info,
                      Atom a_attr_name, int a_attr_value, pointer a_port_priv)
{
    int res = Success, host_atom = 0;
    EphyrPortPriv *port_priv = a_port_priv;
    Bool is_attr_valid = FALSE;

    EPHYR_RETURN_VAL_IF_FAIL(port_priv, BadMatch);
    EPHYR_RETURN_VAL_IF_FAIL(port_priv->current_adaptor, BadMatch);
    EPHYR_RETURN_VAL_IF_FAIL(port_priv->current_adaptor->pAttributes, BadMatch);
    EPHYR_RETURN_VAL_IF_FAIL(port_priv->current_adaptor->nAttributes, BadMatch);
    EPHYR_RETURN_VAL_IF_FAIL(ValidAtom(a_attr_name), BadMatch);

    EPHYR_LOG("enter, portnum:%d, atomid:%d, attr_name:%s, attr_val:%d\n",
              port_priv->port_number,
              (int) a_attr_name, NameForAtom(a_attr_name), a_attr_value);

    if (!ephyrLocalAtomToHost(a_attr_name, &host_atom)) {
        EPHYR_LOG_ERROR("failed to convert local atom to host atom\n");
        res = BadMatch;
        goto out;
    }

    if (!ephyrXVPrivIsAttrValueValid(port_priv->current_adaptor->pAttributes,
                                     port_priv->current_adaptor->nAttributes,
                                     NameForAtom(a_attr_name),
                                     a_attr_value, &is_attr_valid)) {
        EPHYR_LOG_ERROR("failed to validate attribute %s\n",
                        NameForAtom(a_attr_name));
        /*
           res = BadMatch ;
           goto out ;
         */
    }
    if (!is_attr_valid) {
        EPHYR_LOG_ERROR("attribute %s is not valid\n",
                        NameForAtom(a_attr_name));
        /*
           res = BadMatch ;
           goto out ;
         */
    }

    if (!ephyrHostXVSetPortAttribute(port_priv->port_number,
                                     host_atom, a_attr_value)) {
        EPHYR_LOG_ERROR("failed to set port attribute\n");
        res = BadMatch;
        goto out;
    }

    res = Success;
 out:
    EPHYR_LOG("leave\n");
    return res;
}
Example #17
0
Bool
ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic)
{
    Display *dpy = hostx_get_display();
    Bool is_ok = FALSE;

    EPHYR_LOG("enter\n");
    is_ok = XF86DRIAuthConnection(dpy, DefaultScreen(dpy), a_magic);
    EPHYR_LOG("leave. is_ok:%d\n", is_ok);
    return is_ok;
}
Example #18
0
Bool
ephyrDRICloseConnection(int a_screen)
{
    Display *dpy = hostx_get_display();
    Bool is_ok = FALSE;

    EPHYR_LOG("enter\n");
    is_ok = XF86DRICloseConnection(dpy, DefaultScreen(dpy));
    EPHYR_LOG("leave\n");
    return is_ok;
}
Example #19
0
Bool
ephyrDRIDestroyContext(int a_screen, int a_context_id)
{
    Display *dpy = hostx_get_display();
    Bool is_ok = FALSE;

    EPHYR_LOG("enter\n");
    is_ok = XF86DRIDestroyContext(dpy, DefaultScreen(dpy), a_context_id);
    EPHYR_LOG("leave:%d\n", is_ok);
    return is_ok;
}
Example #20
0
int
ephyrGLXQueryVersion(__GLXclientState * a_cl, GLbyte * a_pc)
{
    ClientPtr client = a_cl->client;
    xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
    xGLXQueryVersionReply reply;
    int major, minor;
    int res = BadImplementation;

    EPHYR_LOG("enter\n");

    major = req->majorVersion;
    minor = req->minorVersion;

    if (!ephyrHostGLXQueryVersion(&major, &minor)) {
        EPHYR_LOG_ERROR("ephyrHostGLXQueryVersion() failed\n");
        goto out;
    }
    EPHYR_LOG("major:%d, minor:%d\n", major, minor);
    reply = (xGLXQueryVersionReply) {
        .type = X_Reply,
        .sequenceNumber = client->sequence,
        .length = 0,
        .majorVersion = major,
        .minorVersion = minor
    };

    if (client->swapped) {
        __glXSwapQueryVersionReply(client, &reply);
    }
    else {
        WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
    }

    res = Success;
 out:
    EPHYR_LOG("leave\n");
    return res;
}

int
ephyrGLXQueryVersionSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
    xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;

    __GLX_DECLARE_SWAP_VARIABLES;

    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->majorVersion);
    __GLX_SWAP_INT(&req->minorVersion);
    return ephyrGLXQueryVersion(a_cl, a_pc);
}
Example #21
0
Bool
ephyrDRICreateDrawable(int a_screen,
                       int a_drawable, drm_drawable_t * a_hw_drawable)
{
    Bool is_ok = FALSE;
    Display *dpy = hostx_get_display();

    EPHYR_LOG("enter\n");
    is_ok = XF86DRICreateDrawable(dpy, DefaultScreen(dpy),
                                  a_drawable, a_hw_drawable);
    EPHYR_LOG("leave. is_ok:%d\n", is_ok);
    return is_ok;
}
Example #22
0
/*
 * Xephyr - A kdrive X server thats runs in a host X window.
 *          Authored by Matthew Allum <*****@*****.**>
 * 
 * Copyright © 2007 OpenedHand Ltd 
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of OpenedHand Ltd not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission. OpenedHand Ltd makes no
 * representations about the suitability of this software for any purpose.  It
 * is provided "as is" without express or implied warranty.
 *
 * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 * Authors:
 *    Dodji Seketeli <*****@*****.**>
 */
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif

#include <X11/Xutil.h>
#include <X11/Xlibint.h>
#include <GL/glx.h>
#include "xf86dri.h"
#include "hostx.h"
#include "ephyrdri.h"
#define _HAVE_XALLOC_DECLS
#include "ephyrlog.h"
#include "dixstruct.h"
#include "pixmapstr.h"

#ifndef TRUE
#define TRUE 1
#endif /*TRUE*/
#ifndef FALSE
#define FALSE 0
#endif /*FALSE*/
    Bool
ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable)
{
    Display *dpy = hostx_get_display();
    Bool is_ok = FALSE;

    EPHYR_RETURN_VAL_IF_FAIL(a_is_capable, FALSE);
    EPHYR_LOG("enter\n");
    is_ok = XF86DRIQueryDirectRenderingCapable(dpy, DefaultScreen(dpy),
                                               a_is_capable);
    EPHYR_LOG("leave. is_capable:%d, is_ok=%d\n", *a_is_capable, is_ok);

    return is_ok;
}
Example #23
0
static void
ephyrStopVideo(KdScreenInfo * a_info, pointer a_port_priv, Bool a_exit)
{
    EphyrPortPriv *port_priv = a_port_priv;

    EPHYR_RETURN_IF_FAIL(a_info && a_info->pScreen);
    EPHYR_RETURN_IF_FAIL(port_priv);

    EPHYR_LOG("enter\n");
    if (!ephyrHostXVStopVideo(a_info->pScreen->myNum, port_priv->port_number)) {
        EPHYR_LOG_ERROR("XvStopVideo() failed\n");
    }
    EPHYR_LOG("leave\n");
}
Example #24
0
static int
ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
{
    ClientPtr client=NULL ;
    int context_tag=0, name=0, res=BadImplementation, length=0 ;
    char *string=NULL;
    __GLX_DECLARE_SWAP_VARIABLES;

    EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, BadValue) ;

    EPHYR_LOG ("enter\n") ;

    client = a_cl->client ;

    if (a_do_swap) {
        __GLX_SWAP_INT (a_pc + 4);
        __GLX_SWAP_INT (a_pc + __GLX_SINGLE_HDR_SIZE);
    }
    context_tag = __GLX_GET_SINGLE_CONTEXT_TAG (a_pc) ;
    a_pc += __GLX_SINGLE_HDR_SIZE;
    name = *(GLenum*)(a_pc + 0);
    EPHYR_LOG ("context_tag:%d, name:%d\n", context_tag, name) ;
    if (!ephyrHostGLXGetStringFromServer (context_tag,
                                          name,
                                          EPHYR_HOST_GLX_GetString,
                                          &string)) {
        EPHYR_LOG_ERROR ("failed to get string from server\n") ;
        goto out ;
    }
    if (string) {
        length = strlen (string) + 1;
        EPHYR_LOG ("got string:'%s', size:%d\n", string, length) ;
    } else {
        EPHYR_LOG ("got string: string (null)\n") ;
    }
    __GLX_BEGIN_REPLY (length);
    __GLX_PUT_SIZE (length);
    __GLX_SEND_HEADER ();
    if (a_do_swap) {
        __GLX_SWAP_REPLY_SIZE ();
        __GLX_SWAP_REPLY_HEADER ();
    }
    WriteToClient (client, length, (char *)string);

    res = Success ;
out:
    EPHYR_LOG ("leave\n") ;
    return res ;
}
Example #25
0
static int
ephyrPutVideo(KdScreenInfo * a_info,
              DrawablePtr a_drawable,
              short a_vid_x, short a_vid_y,
              short a_drw_x, short a_drw_y,
              short a_vid_w, short a_vid_h,
              short a_drw_w, short a_drw_h,
              RegionPtr a_clipping_region, pointer a_port_priv)
{
    EphyrPortPriv *port_priv = a_port_priv;
    BoxRec clipped_area, dst_box;
    int result = BadImplementation;
    int drw_x = 0, drw_y = 0, drw_w = 0, drw_h = 0;

    EPHYR_RETURN_VAL_IF_FAIL(a_info->pScreen, BadValue);
    EPHYR_RETURN_VAL_IF_FAIL(a_drawable && port_priv, BadValue);

    EPHYR_LOG("enter\n");

    dst_box.x1 = a_drw_x;
    dst_box.x2 = a_drw_x + a_drw_w;
    dst_box.y1 = a_drw_y;
    dst_box.y2 = a_drw_y + a_drw_h;

    if (!DoSimpleClip(&dst_box,
                      RegionExtents(a_clipping_region), &clipped_area)) {
        EPHYR_LOG_ERROR("failed to simple clip\n");
        goto out;
    }

    drw_x = clipped_area.x1;
    drw_y = clipped_area.y1;
    drw_w = clipped_area.x2 - clipped_area.x1;
    drw_h = clipped_area.y2 - clipped_area.y1;

    if (!ephyrHostXVPutVideo(a_info->pScreen->myNum,
                             port_priv->port_number,
                             a_vid_x, a_vid_y, a_vid_w, a_vid_h,
                             a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
        EPHYR_LOG_ERROR("ephyrHostXVPutVideo() failed\n");
        goto out;
    }
    result = Success;

 out:
    EPHYR_LOG("leave\n");
    return result;
}
Example #26
0
Bool
ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
                                       int32_t * a_num_visuals,
                                       int32_t * a_num_props,
                                       int32_t * a_props_buf_size,
                                       int32_t ** a_props_buf)
{
    Bool is_ok = FALSE;

    EPHYR_LOG("enter\n");
    is_ok = ephyrHostGLXGetVisualConfigsInternal
        (EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
         a_screen, a_num_visuals, a_num_props, a_props_buf_size, a_props_buf);
    EPHYR_LOG("leave\n");
    return is_ok;
}
Example #27
0
Bool
ephyrInitVideo(ScreenPtr pScreen)
{
    Bool is_ok = FALSE;

    KdScreenPriv(pScreen);
    KdScreenInfo *screen = pScreenPriv->screen;
    static EphyrXVPriv *xv_priv;

    EPHYR_LOG("enter\n");

    if (screen->fb.bitsPerPixel == 8) {
        EPHYR_LOG_ERROR("8 bits depth not supported\n");
        return FALSE;
    }

    if (!xv_priv) {
        xv_priv = ephyrXVPrivNew();
    }
    if (!xv_priv) {
        EPHYR_LOG_ERROR("failed to create xv_priv\n");
        goto out;
    }

    if (!ephyrXVPrivRegisterAdaptors(xv_priv, pScreen)) {
        EPHYR_LOG_ERROR("failed to register adaptors\n");
        goto out;
    }
    is_ok = TRUE;

 out:
    return is_ok;
}
Example #28
0
static void
ephyrXVPrivDelete(EphyrXVPriv * a_this)
{
    EPHYR_LOG("enter\n");

    if (!a_this)
        return;
    if (a_this->host_adaptors) {
        ephyrHostXVAdaptorArrayDelete(a_this->host_adaptors);
        a_this->host_adaptors = NULL;
    }
    free(a_this->adaptors);
    a_this->adaptors = NULL;
    free(a_this);
    EPHYR_LOG("leave\n");
}
Example #29
0
Bool
ephyrHostGLXQueryVersion(int *a_major, int *a_minor)
{
    Bool is_ok = FALSE;
    Display *dpy = hostx_get_display();
    int major_opcode = 0;
    xGLXQueryVersionReq *req = NULL;
    xGLXQueryVersionReply reply;

    EPHYR_RETURN_VAL_IF_FAIL(a_major && a_minor, FALSE);
    EPHYR_LOG("enter\n");

    if (glx_major) {
        *a_major = glx_major;
        *a_minor = glx_minor;
        return TRUE;
    }

    if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
        EPHYR_LOG_ERROR("failed to get major opcode\n");
        goto out;
    }
    EPHYR_LOG("major opcode: %d\n", major_opcode);

    /* Send the glXQueryVersion request */
    memset(&reply, 0, sizeof(reply));
    LockDisplay(dpy);
    GetReq(GLXQueryVersion, req);
    req->reqType = major_opcode;
    req->glxCode = X_GLXQueryVersion;
    req->majorVersion = 2;
    req->minorVersion = 1;
    _XReply(dpy, (xReply *) &reply, 0, False);
    UnlockDisplay(dpy);
    SyncHandle();

    *a_major = glx_major = reply.majorVersion;
    *a_minor = glx_minor = reply.minorVersion;

    EPHYR_LOG("major:%d, minor:%d\n", *a_major, *a_minor);

    is_ok = TRUE;
 out:
    EPHYR_LOG("leave\n");
    return is_ok;
}
Example #30
0
static int
ephyrGLXCreateContextReal(xGLXCreateContextReq * a_req, Bool a_do_swap)
{
    int res = BadImplementation;
    EphyrHostWindowAttributes host_w_attrs;

    __GLX_DECLARE_SWAP_VARIABLES;

    EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue);
    EPHYR_LOG("enter\n");

    if (a_do_swap) {
        __GLX_SWAP_SHORT(&a_req->length);
        __GLX_SWAP_INT(&a_req->context);
        __GLX_SWAP_INT(&a_req->visual);
        __GLX_SWAP_INT(&a_req->screen);
        __GLX_SWAP_INT(&a_req->shareList);
    }

    EPHYR_LOG("context creation requested. localid:%d, "
              "screen:%d, visual:%d, direct:%d\n",
              (int) a_req->context, (int) a_req->screen,
              (int) a_req->visual, (int) a_req->isDirect);

    memset(&host_w_attrs, 0, sizeof(host_w_attrs));
    if (!hostx_get_window_attributes(hostx_get_window(a_req->screen),
                                     &host_w_attrs)) {
        EPHYR_LOG_ERROR("failed to get host window attrs\n");
        goto out;
    }

    EPHYR_LOG("host window visual id: %d\n", host_w_attrs.visualid);

    if (!ephyrHostGLXCreateContext(a_req->screen,
                                   host_w_attrs.visualid,
                                   a_req->context,
                                   a_req->shareList, 0,
                                   a_req->isDirect, X_GLXCreateContext)) {
        EPHYR_LOG_ERROR("ephyrHostGLXCreateContext() failed\n");
        goto out;
    }
    res = Success;
 out:
    EPHYR_LOG("leave\n");
    return res;
}