11
#include "va_backend.h"
14
#include "va_dricommon.h"
18
struct dri_drawable base;
19
union dri_buffer buffer;
24
static struct dri_drawable *
25
dri1CreateDrawable(VADriverContextP ctx, XID x_drawable)
27
struct dri1_drawable *dri1_drawable;
29
dri1_drawable = calloc(1, sizeof(*dri1_drawable));
34
dri1_drawable->base.x_drawable = x_drawable;
36
return &dri1_drawable->base;
40
dri1DestroyDrawable(VADriverContextP ctx, struct dri_drawable *dri_drawable)
46
dri1SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
51
static union dri_buffer *
52
dri1GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
54
struct dri1_drawable *dri1_drawable = (struct dri1_drawable *)dri_drawable;
56
return &dri1_drawable->buffer;
60
dri1Close(VADriverContextP ctx)
62
struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
64
free_drawable_hashtable(ctx);
65
VA_DRIDestroyContext(ctx->x11_dpy, ctx->x11_screen, dri_state->hwContextID);
66
assert(dri_state->pSAREA != MAP_FAILED);
67
drmUnmap(dri_state->pSAREA, SAREA_MAX);
68
assert(dri_state->fd >= 0);
69
drmCloseOnce(dri_state->fd);
70
VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen);
74
isDRI1Connected(VADriverContextP ctx, char **driver_name)
76
struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
87
dri_state->pSAREA = MAP_FAILED;
88
dri_state->driConnectedFlag = VA_NONE;
90
if (!VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy,
98
if (!VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen,
99
&driver_major, &driver_minor,
100
&driver_patch, driver_name))
103
if (!VA_DRIOpenConnection(ctx->x11_dpy, ctx->x11_screen,
104
&dri_state->hSAREA, &BusID))
108
dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened);
111
if (dri_state->fd < 0)
115
if (drmGetMagic(dri_state->fd, &magic))
118
if (newlyopened && !VA_DRIAuthConnection(ctx->x11_dpy, ctx->x11_screen, magic))
121
if (drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA))
124
if (!VA_DRICreateContext(ctx->x11_dpy, ctx->x11_screen,
125
DefaultVisual(ctx->x11_dpy, ctx->x11_screen),
126
&dri_state->hwContextID, &dri_state->hwContext))
129
dri_state->driConnectedFlag = VA_DRI1;
130
dri_state->createDrawable = dri1CreateDrawable;
131
dri_state->destroyDrawable = dri1DestroyDrawable;
132
dri_state->swapBuffer = dri1SwapBuffer;
133
dri_state->getRenderingBuffer = dri1GetRenderingBuffer;
134
dri_state->close = dri1Close;
139
if (dri_state->pSAREA != MAP_FAILED)
140
drmUnmap(dri_state->pSAREA, SAREA_MAX);
142
if (dri_state->fd >= 0)
143
drmCloseOnce(dri_state->fd);
145
VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen);
151
dri_state->pSAREA = MAP_FAILED;