2008-05-21 14:19:51 -06:00
|
|
|
/*
|
|
|
|
* Copyright © 2007 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Zhenyu Wang <zhenyu.z.wang@intel.com>
|
|
|
|
*
|
|
|
|
*/
|
2014-02-03 08:54:42 -07:00
|
|
|
#include "intel_xvmc_private.h"
|
2010-05-23 15:28:34 -06:00
|
|
|
#include <xcb/xcb.h>
|
|
|
|
#include <xcb/xcb_aux.h>
|
|
|
|
#include <xcb/dri2.h>
|
|
|
|
#include <X11/Xlib-xcb.h>
|
|
|
|
#include <X11/extensions/dri2tokens.h>
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2008-10-12 09:20:49 -06:00
|
|
|
/* global */
|
2008-05-21 14:19:51 -06:00
|
|
|
struct _intel_xvmc_driver *xvmc_driver = NULL;
|
2008-10-12 09:20:49 -06:00
|
|
|
|
|
|
|
/* Lookup tables to speed common calculations for coded_block_pattern */
|
|
|
|
/* each block is ((8*8) * sizeof(short)) */
|
|
|
|
unsigned int mb_bytes_420[] = {
|
2010-05-10 16:32:28 -06:00
|
|
|
0, /* 0 */
|
|
|
|
128, /* 1 */
|
|
|
|
128, /* 10 */
|
|
|
|
256, /* 11 */
|
|
|
|
128, /* 100 */
|
|
|
|
256, /* 101 */
|
|
|
|
256, /* 110 */
|
|
|
|
384, /* 111 */
|
|
|
|
128, /* 1000 */
|
|
|
|
256, /* 1001 */
|
|
|
|
256, /* 1010 */
|
|
|
|
384, /* 1011 */
|
|
|
|
256, /* 1100 */
|
|
|
|
384, /* 1101 */
|
|
|
|
384, /* 1110 */
|
|
|
|
512, /* 1111 */
|
|
|
|
128, /* 10000 */
|
|
|
|
256, /* 10001 */
|
|
|
|
256, /* 10010 */
|
|
|
|
384, /* 10011 */
|
|
|
|
256, /* 10100 */
|
|
|
|
384, /* 10101 */
|
|
|
|
384, /* 10110 */
|
|
|
|
512, /* 10111 */
|
|
|
|
256, /* 11000 */
|
|
|
|
384, /* 11001 */
|
|
|
|
384, /* 11010 */
|
|
|
|
512, /* 11011 */
|
|
|
|
384, /* 11100 */
|
|
|
|
512, /* 11101 */
|
|
|
|
512, /* 11110 */
|
|
|
|
640, /* 11111 */
|
|
|
|
128, /* 100000 */
|
|
|
|
256, /* 100001 */
|
|
|
|
256, /* 100010 */
|
|
|
|
384, /* 100011 */
|
|
|
|
256, /* 100100 */
|
|
|
|
384, /* 100101 */
|
|
|
|
384, /* 100110 */
|
|
|
|
512, /* 100111 */
|
|
|
|
256, /* 101000 */
|
|
|
|
384, /* 101001 */
|
|
|
|
384, /* 101010 */
|
|
|
|
512, /* 101011 */
|
|
|
|
384, /* 101100 */
|
|
|
|
512, /* 101101 */
|
|
|
|
512, /* 101110 */
|
|
|
|
640, /* 101111 */
|
|
|
|
256, /* 110000 */
|
|
|
|
384, /* 110001 */
|
|
|
|
384, /* 110010 */
|
|
|
|
512, /* 110011 */
|
|
|
|
384, /* 110100 */
|
|
|
|
512, /* 110101 */
|
|
|
|
512, /* 110110 */
|
|
|
|
640, /* 110111 */
|
|
|
|
384, /* 111000 */
|
|
|
|
512, /* 111001 */
|
|
|
|
512, /* 111010 */
|
|
|
|
640, /* 111011 */
|
|
|
|
512, /* 111100 */
|
|
|
|
640, /* 111101 */
|
|
|
|
640, /* 111110 */
|
|
|
|
768 /* 111111 */
|
2008-10-12 09:20:49 -06:00
|
|
|
};
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
static int
|
|
|
|
dri2_connect(Display *display)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-23 15:28:34 -06:00
|
|
|
xcb_dri2_query_version_cookie_t query_version_cookie;
|
|
|
|
xcb_dri2_query_version_reply_t *query_version_reply;
|
|
|
|
xcb_dri2_connect_cookie_t connect_cookie;
|
|
|
|
xcb_dri2_connect_reply_t *connect_reply;
|
|
|
|
xcb_dri2_authenticate_cookie_t auth_cookie;
|
|
|
|
xcb_dri2_authenticate_reply_t *auth_reply;
|
|
|
|
xcb_screen_t *root;
|
|
|
|
xcb_connection_t *c = XGetXCBConnection(display);
|
|
|
|
drm_magic_t magic;
|
|
|
|
const xcb_query_extension_reply_t *dri2_reply;
|
|
|
|
char *device_name;
|
|
|
|
int len;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
root = xcb_aux_get_screen(c, DefaultScreen(display));
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
dri2_reply = xcb_get_extension_data(c, &xcb_dri2_id);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
if (!dri2_reply) {
|
|
|
|
XVMC_ERR("DRI2 required");
|
|
|
|
return BadValue;
|
2010-05-10 16:32:28 -06:00
|
|
|
}
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
/* Query the extension and make our first use of it at the same time. */
|
|
|
|
query_version_cookie = xcb_dri2_query_version(c, 1, 0);
|
|
|
|
connect_cookie = xcb_dri2_connect(c, root->root, DRI2DriverDRI);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
query_version_reply =
|
|
|
|
xcb_dri2_query_version_reply(c, query_version_cookie, NULL);
|
|
|
|
connect_reply = xcb_dri2_connect_reply(c, connect_cookie, NULL);
|
2010-05-10 16:32:28 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
if (!query_version_reply) {
|
|
|
|
XVMC_ERR("DRI2 required");
|
|
|
|
return BadValue;
|
2010-05-10 16:32:28 -06:00
|
|
|
}
|
2010-05-23 15:28:34 -06:00
|
|
|
free(query_version_reply);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
len = xcb_dri2_connect_device_name_length(connect_reply);
|
|
|
|
device_name = malloc(len + 1);
|
|
|
|
if (!device_name) {
|
|
|
|
XVMC_ERR("malloc failure");
|
|
|
|
return BadAlloc;
|
2010-05-10 16:32:28 -06:00
|
|
|
}
|
2010-05-23 15:28:34 -06:00
|
|
|
strncpy(device_name, xcb_dri2_connect_device_name(connect_reply), len);
|
|
|
|
device_name[len] = 0;
|
|
|
|
xvmc_driver->fd = open(device_name, O_RDWR);
|
|
|
|
free(device_name);
|
|
|
|
free(connect_reply);
|
|
|
|
if (xvmc_driver->fd < 0) {
|
|
|
|
XVMC_ERR("Failed to open drm device: %s\n", strerror(errno));
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
if (drmGetMagic(xvmc_driver->fd, &magic)) {
|
|
|
|
XVMC_ERR("Failed to get magic\n");
|
|
|
|
return BadValue;
|
|
|
|
}
|
2010-05-10 16:32:28 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
auth_cookie = xcb_dri2_authenticate(c, root->root, magic);
|
|
|
|
auth_reply = xcb_dri2_authenticate_reply(c, auth_cookie, NULL);
|
|
|
|
if (!auth_reply) {
|
|
|
|
XVMC_ERR("Failed to authenticate magic %d\n", magic);
|
|
|
|
return BadValue;
|
2010-05-10 16:32:28 -06:00
|
|
|
}
|
2010-05-23 15:28:34 -06:00
|
|
|
free(auth_reply);
|
|
|
|
|
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
2010-05-10 16:32:28 -06:00
|
|
|
|
2008-05-21 14:19:51 -06:00
|
|
|
/*
|
|
|
|
* Function: XvMCCreateContext
|
|
|
|
* Description: Create a XvMC context for the given surface parameters.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* port - XvPortID to use as avertised by the X connection.
|
|
|
|
* surface_type_id - Unique identifier for the Surface type.
|
|
|
|
* width - Width of the surfaces.
|
|
|
|
* height - Height of the surfaces.
|
|
|
|
* flags - one or more of the following
|
|
|
|
* XVMC_DIRECT - A direct rendered context is requested.
|
|
|
|
*
|
|
|
|
* Notes: surface_type_id and width/height parameters must match those
|
|
|
|
* returned by XvMCListSurfaceTypes.
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port,
|
|
|
|
int surface_type_id, int width, int height,
|
|
|
|
int flags, XvMCContext * context)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
Status ret;
|
|
|
|
CARD32 *priv_data = NULL;
|
2010-05-23 15:28:34 -06:00
|
|
|
struct intel_xvmc_hw_context *comm;
|
2010-05-10 16:32:28 -06:00
|
|
|
int major, minor;
|
|
|
|
int error_base;
|
|
|
|
int event_base;
|
|
|
|
int priv_count;
|
|
|
|
|
|
|
|
/* Verify Obvious things first */
|
|
|
|
if (!display || !context)
|
|
|
|
return BadValue;
|
|
|
|
|
|
|
|
if (!(flags & XVMC_DIRECT)) {
|
|
|
|
XVMC_ERR("Indirect Rendering not supported! Using Direct.");
|
2008-05-21 14:19:51 -06:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
/*
|
|
|
|
Width, Height, and flags are checked against surface_type_id
|
|
|
|
and port for validity inside the X server, no need to check
|
|
|
|
here.
|
|
|
|
*/
|
|
|
|
context->surface_type_id = surface_type_id;
|
|
|
|
context->width = (unsigned short)((width + 15) & ~15);
|
|
|
|
context->height = (unsigned short)((height + 15) & ~15);
|
|
|
|
context->flags = flags;
|
|
|
|
context->port = port;
|
|
|
|
|
|
|
|
if (!XvMCQueryExtension(display, &event_base, &error_base)) {
|
|
|
|
XVMC_ERR("XvMCExtension is not available!");
|
|
|
|
return BadValue;
|
|
|
|
}
|
2010-05-23 15:28:34 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
ret = XvMCQueryVersion(display, &major, &minor);
|
|
|
|
if (ret) {
|
|
|
|
XVMC_ERR
|
|
|
|
("XvMCQueryVersion Failed, unable to determine protocol version.");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: major and minor could be checked in future for XvMC
|
|
|
|
* protocol capability (i.e H.264/AVC decode available)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Pass control to the X server to create a drm_context_t for us and
|
|
|
|
validate the with/height and flags.
|
|
|
|
*/
|
|
|
|
if ((ret =
|
|
|
|
_xvmc_create_context(display, context, &priv_count, &priv_data))) {
|
|
|
|
XVMC_ERR("Unable to create XvMC Context.");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
comm = (struct intel_xvmc_hw_context *)priv_data;
|
2010-05-10 16:32:28 -06:00
|
|
|
|
|
|
|
if (xvmc_driver == NULL || xvmc_driver->type != comm->type) {
|
|
|
|
switch (comm->type) {
|
|
|
|
case XVMC_I915_MPEG2_MC:
|
|
|
|
xvmc_driver = &i915_xvmc_mc_driver;
|
|
|
|
break;
|
|
|
|
case XVMC_I965_MPEG2_MC:
|
|
|
|
xvmc_driver = &i965_xvmc_mc_driver;
|
|
|
|
break;
|
|
|
|
case XVMC_I965_MPEG2_VLD:
|
|
|
|
xvmc_driver = &xvmc_vld_driver;
|
|
|
|
break;
|
|
|
|
case XVMC_I945_MPEG2_VLD:
|
|
|
|
default:
|
|
|
|
XVMC_ERR("unimplemented xvmc type %d", comm->type);
|
|
|
|
XFree(priv_data);
|
|
|
|
priv_data = NULL;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
}
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
if (xvmc_driver == NULL || xvmc_driver->type != comm->type) {
|
|
|
|
XVMC_ERR("fail to load xvmc driver for type %d\n", comm->type);
|
|
|
|
return BadValue;
|
|
|
|
}
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_INFO("decoder type is %s", intel_xvmc_decoder_string(comm->type));
|
2008-10-12 09:20:49 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
/* check DRI2 */
|
|
|
|
ret = Success;
|
|
|
|
xvmc_driver->fd = -1;
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
ret = dri2_connect(display);
|
2010-05-10 16:32:28 -06:00
|
|
|
if (ret != Success) {
|
|
|
|
XFree(priv_data);
|
|
|
|
context->privData = NULL;
|
|
|
|
if (xvmc_driver->fd >= 0)
|
|
|
|
close(xvmc_driver->fd);
|
|
|
|
xvmc_driver = NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((xvmc_driver->bufmgr =
|
|
|
|
intel_bufmgr_gem_init(xvmc_driver->fd, 1024 * 64)) == NULL) {
|
|
|
|
XVMC_ERR("Can't init bufmgr\n");
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
drm_intel_bufmgr_gem_enable_reuse(xvmc_driver->bufmgr);
|
|
|
|
|
2014-02-03 08:54:42 -07:00
|
|
|
if (!intelInitBatchBuffer()) {
|
|
|
|
XFree(priv_data);
|
|
|
|
context->privData = NULL;
|
|
|
|
|
|
|
|
dri_bufmgr_destroy(xvmc_driver->bufmgr);
|
|
|
|
xvmc_driver = NULL;
|
|
|
|
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
/* call driver hook.
|
|
|
|
* driver hook should free priv_data after return if success.*/
|
|
|
|
ret =
|
|
|
|
(xvmc_driver->create_context) (display, context, priv_count,
|
|
|
|
priv_data);
|
|
|
|
if (ret) {
|
|
|
|
XVMC_ERR("driver create context failed\n");
|
2014-02-03 08:54:42 -07:00
|
|
|
intelFiniBatchBuffer();
|
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
XFree(priv_data);
|
|
|
|
context->privData = NULL;
|
2014-02-03 08:54:42 -07:00
|
|
|
|
|
|
|
dri_bufmgr_destroy(xvmc_driver->bufmgr);
|
2010-05-10 16:32:28 -06:00
|
|
|
xvmc_driver = NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-12 13:41:54 -06:00
|
|
|
sigfillset(&xvmc_driver->sa_mask);
|
|
|
|
sigdelset(&xvmc_driver->sa_mask, SIGFPE);
|
|
|
|
sigdelset(&xvmc_driver->sa_mask, SIGILL);
|
|
|
|
sigdelset(&xvmc_driver->sa_mask, SIGSEGV);
|
|
|
|
sigdelset(&xvmc_driver->sa_mask, SIGBUS);
|
|
|
|
sigdelset(&xvmc_driver->sa_mask, SIGKILL);
|
2010-05-10 16:32:28 -06:00
|
|
|
pthread_mutex_init(&xvmc_driver->ctxmutex, NULL);
|
2015-04-12 13:41:54 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
intel_xvmc_dump_open();
|
|
|
|
|
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCDestroyContext
|
|
|
|
* Description: Destorys the specified context.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* display - Specifies the connection to the server.
|
|
|
|
* context - The context to be destroyed.
|
|
|
|
*
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCDestroyContext(Display * display, XvMCContext * context)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
Status ret;
|
|
|
|
int screen;
|
|
|
|
|
|
|
|
if (!display || !context)
|
|
|
|
return XvMCBadContext;
|
|
|
|
screen = DefaultScreen(display);
|
|
|
|
ret = (xvmc_driver->destroy_context) (display, context);
|
|
|
|
if (ret) {
|
|
|
|
XVMC_ERR("destroy context fail\n");
|
|
|
|
return ret;
|
|
|
|
}
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
intelFiniBatchBuffer();
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
dri_bufmgr_destroy(xvmc_driver->bufmgr);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
ret = _xvmc_destroy_context(display, context);
|
|
|
|
if (ret != Success) {
|
|
|
|
XVMC_ERR("_xvmc_destroy_context fail\n");
|
|
|
|
return ret;
|
|
|
|
}
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
if (xvmc_driver->num_ctx == 0) {
|
|
|
|
pthread_mutex_destroy(&xvmc_driver->ctxmutex);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
if (xvmc_driver->fd >= 0)
|
|
|
|
close(xvmc_driver->fd);
|
2008-10-12 09:20:49 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
xvmc_driver->fd = -1;
|
|
|
|
intel_xvmc_dump_close();
|
|
|
|
}
|
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCCreateSurface
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCCreateSurface(Display * display, XvMCContext * context,
|
|
|
|
XvMCSurface * surface)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
Status ret;
|
|
|
|
int priv_count;
|
|
|
|
CARD32 *priv_data;
|
|
|
|
intel_xvmc_surface_ptr intel_surf = NULL;
|
2010-05-23 15:28:34 -06:00
|
|
|
struct intel_xvmc_context *intel_ctx;
|
2010-05-10 16:32:28 -06:00
|
|
|
|
|
|
|
if (!display || !context)
|
|
|
|
return XvMCBadContext;
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
return XvMCBadSurface;
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
intel_ctx = context->privData;
|
2010-05-10 16:32:28 -06:00
|
|
|
|
|
|
|
if ((ret = _xvmc_create_surface(display, context, surface,
|
|
|
|
&priv_count, &priv_data))) {
|
|
|
|
XVMC_ERR("Unable to create XvMCSurface.");
|
|
|
|
return ret;
|
|
|
|
}
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
XFree(priv_data);
|
|
|
|
|
|
|
|
surface->privData = calloc(1, sizeof(struct intel_xvmc_surface));
|
|
|
|
|
2014-02-03 08:54:42 -07:00
|
|
|
if (!(intel_surf = surface->privData))
|
|
|
|
goto out_xvmc;
|
2010-05-23 15:28:34 -06:00
|
|
|
|
|
|
|
intel_surf->bo = drm_intel_bo_alloc(xvmc_driver->bufmgr,
|
|
|
|
"surface",
|
|
|
|
intel_ctx->surface_bo_size,
|
|
|
|
GTT_PAGE_SIZE);
|
2014-02-03 08:54:42 -07:00
|
|
|
if (!intel_surf->bo)
|
|
|
|
goto out_surf;
|
2010-05-23 15:28:34 -06:00
|
|
|
|
2014-02-03 08:54:42 -07:00
|
|
|
if (drm_intel_bo_flink(intel_surf->bo, &intel_surf->gem_handle))
|
|
|
|
goto out_bo;
|
2010-05-23 15:28:34 -06:00
|
|
|
|
|
|
|
intel_surf = surface->privData;
|
|
|
|
intel_surf->context = context;
|
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
intel_surf->image = XvCreateImage(display, context->port,
|
|
|
|
FOURCC_XVMC,
|
2010-05-23 15:28:34 -06:00
|
|
|
(char *) &intel_surf->gem_handle,
|
2010-05-10 16:32:28 -06:00
|
|
|
surface->width, surface->height);
|
|
|
|
if (!intel_surf->image) {
|
|
|
|
XVMC_ERR("Can't create XvImage for surface\n");
|
2014-02-03 08:54:42 -07:00
|
|
|
goto out_bo;
|
2010-05-10 16:32:28 -06:00
|
|
|
}
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2014-02-03 08:54:42 -07:00
|
|
|
|
|
|
|
out_bo:
|
|
|
|
drm_intel_bo_unreference(intel_surf->bo);
|
|
|
|
out_surf:
|
|
|
|
free(intel_surf);
|
|
|
|
out_xvmc:
|
|
|
|
_xvmc_destroy_surface(display, surface);
|
|
|
|
return BadAlloc;
|
2010-05-10 16:32:28 -06:00
|
|
|
}
|
2008-05-21 14:19:51 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCDestroySurface
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCDestroySurface(Display * display, XvMCSurface * surface)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
intel_xvmc_surface_ptr intel_surf;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !surface)
|
|
|
|
return XvMCBadSurface;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
intel_surf = surface->privData;
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!intel_surf)
|
|
|
|
return XvMCBadSurface;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
XFree(intel_surf->image);
|
|
|
|
if (intel_surf->gc_init)
|
|
|
|
XFreeGC(display, intel_surf->gc);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
drm_intel_bo_unreference(intel_surf->bo);
|
|
|
|
|
|
|
|
free(intel_surf);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
_xvmc_destroy_surface(display, surface);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCCreateBlocks
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCCreateBlocks(Display * display, XvMCContext * context,
|
|
|
|
unsigned int num_blocks,
|
|
|
|
XvMCBlockArray * block)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !context || !num_blocks || !block)
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
memset(block, 0, sizeof(XvMCBlockArray));
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!
|
|
|
|
(block->blocks =
|
|
|
|
(short *)malloc((num_blocks << 6) * sizeof(short))))
|
|
|
|
return BadAlloc;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
block->num_blocks = num_blocks;
|
|
|
|
block->context_id = context->context_id;
|
|
|
|
block->privData = NULL;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCDestroyBlocks
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCDestroyBlocks(Display * display, XvMCBlockArray * block)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !block)
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
if (block->blocks)
|
|
|
|
free(block->blocks);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
block->context_id = 0;
|
|
|
|
block->num_blocks = 0;
|
|
|
|
block->blocks = NULL;
|
|
|
|
block->privData = NULL;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCCreateMacroBlocks
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCCreateMacroBlocks(Display * display, XvMCContext * context,
|
|
|
|
unsigned int num_blocks,
|
|
|
|
XvMCMacroBlockArray * blocks)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !context || !blocks || !num_blocks)
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
memset(blocks, 0, sizeof(XvMCMacroBlockArray));
|
|
|
|
blocks->macro_blocks =
|
|
|
|
(XvMCMacroBlock *) malloc(num_blocks * sizeof(XvMCMacroBlock));
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!blocks->macro_blocks)
|
|
|
|
return BadAlloc;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
blocks->num_blocks = num_blocks;
|
|
|
|
blocks->context_id = context->context_id;
|
|
|
|
blocks->privData = NULL;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCDestroyMacroBlocks
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCDestroyMacroBlocks(Display * display,
|
|
|
|
XvMCMacroBlockArray * block)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !block)
|
|
|
|
return BadValue;
|
|
|
|
if (block->macro_blocks)
|
|
|
|
free(block->macro_blocks);
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
block->context_id = 0;
|
|
|
|
block->num_blocks = 0;
|
|
|
|
block->macro_blocks = NULL;
|
|
|
|
block->privData = NULL;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCRenderSurface
|
|
|
|
*
|
|
|
|
* Description: This function does the actual HWMC. Given a list of
|
|
|
|
* macroblock structures it dispatched the hardware commands to execute
|
|
|
|
* them.
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCRenderSurface(Display * display, XvMCContext * context,
|
|
|
|
unsigned int picture_structure,
|
|
|
|
XvMCSurface * target_surface,
|
|
|
|
XvMCSurface * past_surface,
|
|
|
|
XvMCSurface * future_surface,
|
|
|
|
unsigned int flags,
|
|
|
|
unsigned int num_macroblocks,
|
|
|
|
unsigned int first_macroblock,
|
|
|
|
XvMCMacroBlockArray * macroblock_array,
|
|
|
|
XvMCBlockArray * blocks)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
Status ret;
|
|
|
|
|
|
|
|
if (!display || !context) {
|
|
|
|
XVMC_ERR("Invalid Display, Context or Target!");
|
|
|
|
return XvMCBadContext;
|
|
|
|
}
|
|
|
|
if (!target_surface)
|
|
|
|
return XvMCBadSurface;
|
|
|
|
|
|
|
|
intel_xvmc_dump_render(context, picture_structure, target_surface,
|
|
|
|
past_surface, future_surface, flags,
|
|
|
|
num_macroblocks, first_macroblock,
|
|
|
|
macroblock_array, blocks);
|
|
|
|
|
|
|
|
ret =
|
|
|
|
(xvmc_driver->render_surface) (display, context, picture_structure,
|
|
|
|
target_surface, past_surface,
|
|
|
|
future_surface, flags,
|
|
|
|
num_macroblocks, first_macroblock,
|
|
|
|
macroblock_array, blocks);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
XVMC_ERR("render surface fail\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCPutSurface
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Arguments:
|
|
|
|
* display: Connection to X server
|
|
|
|
* surface: Surface to be displayed
|
|
|
|
* draw: X Drawable on which to display the surface
|
|
|
|
* srcx: X coordinate of the top left corner of the region to be
|
|
|
|
* displayed within the surface.
|
|
|
|
* srcy: Y coordinate of the top left corner of the region to be
|
|
|
|
* displayed within the surface.
|
|
|
|
* srcw: Width of the region to be displayed.
|
|
|
|
* srch: Height of the region to be displayed.
|
|
|
|
* destx: X cordinate of the top left corner of the destination region
|
|
|
|
* in the drawable coordinates.
|
|
|
|
* desty: Y cordinate of the top left corner of the destination region
|
|
|
|
* in the drawable coordinates.
|
|
|
|
* destw: Width of the destination region.
|
|
|
|
* desth: Height of the destination region.
|
|
|
|
* flags: One or more of the following.
|
|
|
|
* XVMC_TOP_FIELD - Display only the Top field of the surface.
|
|
|
|
* XVMC_BOTTOM_FIELD - Display only the Bottom Field of the surface.
|
|
|
|
* XVMC_FRAME_PICTURE - Display both fields or frame.
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
|
|
|
|
Drawable draw, short srcx, short srcy,
|
|
|
|
unsigned short srcw, unsigned short srch,
|
|
|
|
short destx, short desty,
|
|
|
|
unsigned short destw, unsigned short desth,
|
|
|
|
int flags)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XvMCContext *context;
|
|
|
|
intel_xvmc_surface_ptr intel_surf;
|
|
|
|
|
|
|
|
if (!display || !surface)
|
|
|
|
return XvMCBadSurface;
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
intel_surf = surface->privData;
|
2014-02-03 08:54:42 -07:00
|
|
|
if (!intel_surf)
|
|
|
|
return XvMCBadSurface;
|
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
context = intel_surf->context;
|
2014-02-03 08:54:42 -07:00
|
|
|
if (!context)
|
2010-05-10 16:32:28 -06:00
|
|
|
return XvMCBadSurface;
|
|
|
|
|
|
|
|
if (intel_surf->gc_init == FALSE) {
|
|
|
|
intel_surf->gc = XCreateGC(display, draw, 0, NULL);
|
|
|
|
intel_surf->gc_init = TRUE;
|
|
|
|
} else if (draw != intel_surf->last_draw) {
|
|
|
|
XFreeGC(display, intel_surf->gc);
|
|
|
|
intel_surf->gc = XCreateGC(display, draw, 0, NULL);
|
|
|
|
}
|
|
|
|
intel_surf->last_draw = draw;
|
2010-05-23 15:28:34 -06:00
|
|
|
|
2014-02-03 08:54:42 -07:00
|
|
|
return XvPutImage(display, context->port, draw, intel_surf->gc,
|
|
|
|
intel_surf->image, srcx, srcy, srcw, srch, destx,
|
|
|
|
desty, destw, desth);
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCSyncSurface
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server
|
|
|
|
* surface - The surface to synchronize
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCSyncSurface(Display * display, XvMCSurface * surface)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !surface)
|
|
|
|
return XvMCBadSurface;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2011-11-29 05:39:02 -07:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCFlushSurface
|
|
|
|
* Description:
|
|
|
|
* This function commits pending rendering requests to ensure that they
|
|
|
|
* wll be completed in a finite amount of time.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to X server
|
|
|
|
* surface - Surface to flush
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCFlushSurface(Display * display, XvMCSurface * surface)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !surface)
|
|
|
|
return XvMCBadSurface;
|
2010-05-23 15:28:34 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCGetSurfaceStatus
|
|
|
|
* Description:
|
|
|
|
* Arguments:
|
|
|
|
* display: connection to X server
|
|
|
|
* surface: The surface to query
|
|
|
|
* stat: One of the Following
|
|
|
|
* XVMC_RENDERING - The last XvMCRenderSurface command has not
|
|
|
|
* completed.
|
|
|
|
* XVMC_DISPLAYING - The surface is currently being displayed or a
|
|
|
|
* display is pending.
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCGetSurfaceStatus(Display * display, XvMCSurface * surface,
|
|
|
|
int *stat)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !surface || !stat)
|
|
|
|
return XvMCBadSurface;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
*stat = 0;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCHideSurface
|
|
|
|
* Description: Stops the display of a surface.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* surface - surface to be hidden.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCHideSurface(Display * display, XvMCSurface * surface)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (!display || !surface)
|
|
|
|
return XvMCBadSurface;
|
2008-05-21 14:19:51 -06:00
|
|
|
|
2010-05-23 15:28:34 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCCreateSubpicture
|
|
|
|
* Description: This creates a subpicture by filling out the XvMCSubpicture
|
|
|
|
* structure passed to it and returning Success.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* context - The context to create the subpicture for.
|
|
|
|
* subpicture - Pre-allocated XvMCSubpicture structure to be filled in.
|
|
|
|
* width - of subpicture
|
|
|
|
* height - of subpicture
|
|
|
|
* xvimage_id - The id describing the XvImage format.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCCreateSubpicture(Display * display, XvMCContext * context,
|
|
|
|
XvMCSubpicture * subpicture,
|
|
|
|
unsigned short width,
|
|
|
|
unsigned short height, int xvimage_id)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCCreateSubpicture not implemented!\n");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCClearSubpicture
|
|
|
|
* Description: Clear the area of the given subpicture to "color".
|
|
|
|
* structure passed to it and returning Success.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - Subpicture to clear.
|
|
|
|
* x, y, width, height - rectangle in the subpicture to clear.
|
|
|
|
* color - The data to file the rectangle with.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCClearSubpicture(Display * display,
|
|
|
|
XvMCSubpicture * subpicture, short x,
|
|
|
|
short y, unsigned short width,
|
|
|
|
unsigned short height, unsigned int color)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCClearSubpicture not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCCompositeSubpicture
|
|
|
|
* Description: Composite the XvImae on the subpicture. This composit uses
|
|
|
|
* non-premultiplied alpha. Destination alpha is utilized
|
|
|
|
* except for with indexed subpictures. Indexed subpictures
|
|
|
|
* use a simple "replace".
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - Subpicture to clear.
|
|
|
|
* image - the XvImage to be used as the source of the composite.
|
|
|
|
* srcx, srcy, width, height - The rectangle from the image to be used.
|
|
|
|
* dstx, dsty - location in the subpicture to composite the source.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCCompositeSubpicture(Display * display,
|
|
|
|
XvMCSubpicture * subpicture,
|
|
|
|
XvImage * image, short srcx,
|
|
|
|
short srcy, unsigned short width,
|
|
|
|
unsigned short height, short dstx,
|
|
|
|
short dsty)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCCompositeSubpicture not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCDestroySubpicture
|
|
|
|
* Description: Destroys the specified subpicture.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - Subpicture to be destroyed.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCDestroySubpicture(Display * display,
|
|
|
|
XvMCSubpicture * subpicture)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCDestroySubpicture not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCSetSubpicturePalette
|
|
|
|
* Description: Set the subpictures palette
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - Subpiture to set palette for.
|
|
|
|
* palette - A pointer to an array holding the palette data. The array
|
|
|
|
* is num_palette_entries * entry_bytes in size.
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCSetSubpicturePalette(Display * display,
|
|
|
|
XvMCSubpicture * subpicture,
|
|
|
|
unsigned char *palette)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCSetSubpicturePalette not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCBlendSubpicture
|
|
|
|
* Description:
|
|
|
|
* The behavior of this function is different depending on whether
|
|
|
|
* or not the XVMC_BACKEND_SUBPICTURE flag is set in the XvMCSurfaceInfo.
|
|
|
|
* i915 only support frontend behavior.
|
|
|
|
*
|
|
|
|
* XVMC_BACKEND_SUBPICTURE not set ("frontend" behavior):
|
|
|
|
*
|
|
|
|
* XvMCBlendSubpicture is a no-op in this case.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - The subpicture to be blended into the video.
|
|
|
|
* target_surface - The surface to be displayed with the blended subpic.
|
|
|
|
* source_surface - Source surface prior to blending.
|
|
|
|
* subx, suby, subw, subh - The rectangle from the subpicture to use.
|
|
|
|
* surfx, surfy, surfw, surfh - The rectangle in the surface to blend
|
|
|
|
* blend the subpicture rectangle into. Scaling can ocure if
|
|
|
|
* XVMC_SUBPICTURE_INDEPENDENT_SCALING is set.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCBlendSubpicture(Display * display,
|
|
|
|
XvMCSurface * target_surface,
|
|
|
|
XvMCSubpicture * subpicture, short subx,
|
|
|
|
short suby, unsigned short subw,
|
|
|
|
unsigned short subh, short surfx,
|
|
|
|
short surfy, unsigned short surfw,
|
|
|
|
unsigned short surfh)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCBlendSubpicture not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCBlendSubpicture2
|
|
|
|
* Description:
|
|
|
|
* The behavior of this function is different depending on whether
|
|
|
|
* or not the XVMC_BACKEND_SUBPICTURE flag is set in the XvMCSurfaceInfo.
|
|
|
|
* i915 only supports frontend blending.
|
|
|
|
*
|
|
|
|
* XVMC_BACKEND_SUBPICTURE not set ("frontend" behavior):
|
|
|
|
*
|
|
|
|
* XvMCBlendSubpicture2 blends the source_surface and subpicture and
|
|
|
|
* puts it in the target_surface. This does not effect the status of
|
|
|
|
* the source surface but will cause the target_surface to query
|
|
|
|
* XVMC_RENDERING until the blend is completed.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - The subpicture to be blended into the video.
|
|
|
|
* target_surface - The surface to be displayed with the blended subpic.
|
|
|
|
* source_surface - Source surface prior to blending.
|
|
|
|
* subx, suby, subw, subh - The rectangle from the subpicture to use.
|
|
|
|
* surfx, surfy, surfw, surfh - The rectangle in the surface to blend
|
|
|
|
* blend the subpicture rectangle into. Scaling can ocure if
|
|
|
|
* XVMC_SUBPICTURE_INDEPENDENT_SCALING is set.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCBlendSubpicture2(Display * display,
|
|
|
|
XvMCSurface * source_surface,
|
|
|
|
XvMCSurface * target_surface,
|
|
|
|
XvMCSubpicture * subpicture,
|
|
|
|
short subx, short suby,
|
|
|
|
unsigned short subw, unsigned short subh,
|
|
|
|
short surfx, short surfy,
|
|
|
|
unsigned short surfw,
|
|
|
|
unsigned short surfh)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCBlendSubpicture2 not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCSyncSubpicture
|
|
|
|
* Description: This function blocks until all composite/clear requests on
|
|
|
|
* the subpicture have been complete.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - The subpicture to synchronize
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCSyncSubpicture(Display * display,
|
|
|
|
XvMCSubpicture * subpicture)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCSyncSubpicture not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCFlushSubpicture
|
|
|
|
* Description: This function commits pending composite/clear requests to
|
|
|
|
* ensure that they will be completed in a finite amount of
|
|
|
|
* time.
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - The subpicture whos compsiting should be flushed
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCFlushSubpicture(Display * display,
|
|
|
|
XvMCSubpicture * subpicture)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCFlushSubpicture not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCGetSubpictureStatus
|
|
|
|
* Description: This function gets the current status of a subpicture
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* subpicture - The subpicture whos status is being queried
|
|
|
|
* stat - The status of the subpicture. It can be any of the following
|
|
|
|
* OR'd together:
|
|
|
|
* XVMC_RENDERING - Last composite or clear request not completed
|
|
|
|
* XVMC_DISPLAYING - Suppicture currently being displayed.
|
|
|
|
*
|
|
|
|
* Returns: Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCGetSubpictureStatus(Display * display,
|
|
|
|
XvMCSubpicture * subpicture, int *stat)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("XvMCGetSubpictureStatus not implemented!");
|
|
|
|
return BadValue;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCQueryAttributes
|
|
|
|
* Description: An array of XvAttributes of size "number" is returned by
|
|
|
|
* this function. If there are no attributes, NULL is returned and number
|
2013-03-18 12:38:18 -06:00
|
|
|
* is set to 0. The array may be freed with free().
|
2008-05-21 14:19:51 -06:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* context - The context whos attributes we are querying.
|
|
|
|
* number - The returned number of recognized atoms
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* An array of XvAttributes.
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT XvAttribute *XvMCQueryAttributes(Display * display,
|
|
|
|
XvMCContext * context, int *number)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
/* now XvMC has no extra attribs than Xv */
|
|
|
|
*number = 0;
|
|
|
|
return NULL;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCSetAttribute
|
|
|
|
* Description: This function sets a context-specific attribute.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* context - The context whos attributes we are querying.
|
|
|
|
* attribute - The X atom of the attribute to be changed.
|
|
|
|
* value - The new value for the attribute.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCSetAttribute(Display * display, XvMCContext * context,
|
|
|
|
Atom attribute, int value)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: XvMCGetAttribute
|
|
|
|
* Description: This function queries a context-specific attribute and
|
|
|
|
* returns the value.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* display - Connection to the X server.
|
|
|
|
* context - The context whos attributes we are querying.
|
|
|
|
* attribute - The X atom of the attribute to be queried
|
|
|
|
* value - The returned attribute value
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Status
|
|
|
|
*/
|
2010-05-10 16:32:28 -06:00
|
|
|
_X_EXPORT Status XvMCGetAttribute(Display * display, XvMCContext * context,
|
|
|
|
Atom attribute, int *value)
|
|
|
|
{
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
_X_EXPORT Status XvMCBeginSurface(Display * display, XvMCContext * context,
|
|
|
|
XvMCSurface * target,
|
|
|
|
XvMCSurface * past,
|
|
|
|
XvMCSurface * future,
|
|
|
|
const XvMCMpegControl * control)
|
2008-05-21 14:19:51 -06:00
|
|
|
{
|
2010-05-10 16:32:28 -06:00
|
|
|
if (xvmc_driver->begin_surface(display, context,
|
|
|
|
target, past, future, control)) {
|
|
|
|
XVMC_ERR("BeginSurface fail\n");
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
_X_EXPORT Status XvMCLoadQMatrix(Display * display, XvMCContext * context,
|
|
|
|
const XvMCQMatrix * qmx)
|
|
|
|
{
|
|
|
|
if (xvmc_driver->load_qmatrix(display, context, qmx)) {
|
|
|
|
XVMC_ERR("LoadQMatrix fail\n");
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
_X_EXPORT Status XvMCPutSlice(Display * display, XvMCContext * context,
|
|
|
|
char *slice, int nbytes)
|
|
|
|
{
|
2011-11-29 05:39:02 -07:00
|
|
|
if (xvmc_driver->put_slice(display, context, (unsigned char *) slice, nbytes)) {
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("PutSlice fail\n");
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
_X_EXPORT Status XvMCPutSlice2(Display * display, XvMCContext * context,
|
|
|
|
char *slice, int nbytes, int slice_code)
|
|
|
|
{
|
|
|
|
if (xvmc_driver->put_slice2
|
2011-11-29 05:39:02 -07:00
|
|
|
(display, context, (unsigned char *) slice, nbytes, slice_code)) {
|
2010-05-10 16:32:28 -06:00
|
|
|
XVMC_ERR("PutSlice2 fail\n");
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
return Success;
|
2008-05-21 14:19:51 -06:00
|
|
|
}
|