XvMC: dynamically allocate adaptor
And kill all the static structures. This way it's clearer what's common and what's specific. And the code is shorter too. Also clean up src/i830_hwmc.c - kill the nonstandard surface types for i915 and the associated code. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
00b63ecb19
commit
79fe4caafd
249
src/i830_hwmc.c
249
src/i830_hwmc.c
|
|
@ -30,111 +30,12 @@
|
|||
|
||||
#define _INTEL_XVMC_SERVER_
|
||||
#include "i830.h"
|
||||
#include "intel_bufmgr.h"
|
||||
#include "i830_hwmc.h"
|
||||
|
||||
#include <X11/extensions/Xv.h>
|
||||
#include <X11/extensions/XvMC.h>
|
||||
#include <fourcc.h>
|
||||
|
||||
struct intel_xvmc_driver *xvmc_driver;
|
||||
|
||||
/* set global current driver for xvmc */
|
||||
static Bool intel_xvmc_set_driver(struct intel_xvmc_driver *d)
|
||||
{
|
||||
if (xvmc_driver) {
|
||||
ErrorF("XvMC driver already set!\n");
|
||||
return FALSE;
|
||||
} else
|
||||
xvmc_driver = d;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* check chip type and load xvmc driver */
|
||||
/* This must be first called! */
|
||||
Bool intel_xvmc_adaptor_init(ScreenPtr pScreen)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
|
||||
intel_screen_private *intel = intel_get_screen_private(scrn);
|
||||
Bool ret = FALSE;
|
||||
char buf[64];
|
||||
|
||||
if (!intel->XvMCEnabled)
|
||||
return FALSE;
|
||||
|
||||
/* Needs KMS support. */
|
||||
if (IS_I915G(intel) || IS_I915GM(intel))
|
||||
return FALSE;
|
||||
|
||||
if (IS_I9XX(intel)) {
|
||||
if (IS_I915(intel))
|
||||
ret = intel_xvmc_set_driver(&i915_xvmc_driver);
|
||||
else if (IS_G4X(intel) || IS_IGDNG(intel))
|
||||
ret = intel_xvmc_set_driver(&vld_xvmc_driver);
|
||||
else
|
||||
ret = intel_xvmc_set_driver(&i965_xvmc_driver);
|
||||
} else {
|
||||
ErrorF("Your chipset doesn't support XvMC.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (xf86XvMCScreenInit(pScreen, 1, &xvmc_driver->adaptor)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_INFO,
|
||||
"[XvMC] %s driver initialized.\n",
|
||||
xvmc_driver->name);
|
||||
} else {
|
||||
intel->XvMCEnabled = FALSE;
|
||||
xf86DrvMsg(scrn->scrnIndex, X_INFO,
|
||||
"[XvMC] Failed to initialize XvMC.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sprintf(buf, "pci:%04x:%02x:%02x.%d",
|
||||
intel->PciInfo->domain,
|
||||
intel->PciInfo->bus, intel->PciInfo->dev, intel->PciInfo->func);
|
||||
|
||||
xf86XvMCRegisterDRInfo(pScreen, INTEL_XVMC_LIBNAME,
|
||||
buf,
|
||||
INTEL_XVMC_MAJOR, INTEL_XVMC_MINOR,
|
||||
INTEL_XVMC_PATCHLEVEL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* i915 hwmc support */
|
||||
static XF86MCSurfaceInfoRec i915_YV12_mpg2_surface = {
|
||||
SURFACE_TYPE_MPEG2_MPML,
|
||||
XVMC_CHROMA_FORMAT_420,
|
||||
0,
|
||||
720,
|
||||
576,
|
||||
720,
|
||||
576,
|
||||
XVMC_MPEG_2,
|
||||
/* XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING, */
|
||||
0,
|
||||
/* &yv12_subpicture_list */
|
||||
NULL,
|
||||
};
|
||||
|
||||
static XF86MCSurfaceInfoRec i915_YV12_mpg1_surface = {
|
||||
SURFACE_TYPE_MPEG1_MPML,
|
||||
XVMC_CHROMA_FORMAT_420,
|
||||
0,
|
||||
720,
|
||||
576,
|
||||
720,
|
||||
576,
|
||||
XVMC_MPEG_1,
|
||||
/* XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING, */
|
||||
0,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static XF86MCSurfaceInfoPtr ppSI[2] = {
|
||||
(XF86MCSurfaceInfoPtr) & i915_YV12_mpg2_surface,
|
||||
(XF86MCSurfaceInfoPtr) & i915_YV12_mpg1_surface
|
||||
};
|
||||
|
||||
static int create_subpicture(ScrnInfoPtr scrn, XvMCSubpicturePtr subpicture,
|
||||
int *num_priv, CARD32 ** priv)
|
||||
{
|
||||
|
|
@ -190,30 +91,39 @@ static void destroy_context(ScrnInfoPtr scrn, XvMCContextPtr context)
|
|||
{
|
||||
}
|
||||
|
||||
/* Fill in the device dependent adaptor record.
|
||||
* This is named "Intel(R) Textured Video" because this code falls under the
|
||||
* XV extenstion, the name must match or it won't be used.
|
||||
*
|
||||
* Surface and Subpicture - see above
|
||||
* Function pointers to functions below
|
||||
*/
|
||||
static XF86MCAdaptorRec pAdapt = {
|
||||
.name = "Intel(R) Textured Video",
|
||||
.num_surfaces = ARRAY_SIZE(ppSI),
|
||||
.surfaces = ppSI,
|
||||
.num_subpictures = 0,
|
||||
.subpictures = NULL,
|
||||
.CreateContext = create_context,
|
||||
.DestroyContext = destroy_context,
|
||||
.CreateSurface = create_surface,
|
||||
.DestroySurface = destroy_surface,
|
||||
.CreateSubpicture = create_subpicture,
|
||||
.DestroySubpicture = destroy_subpicture,
|
||||
/* i915 hwmc support */
|
||||
static XF86MCSurfaceInfoRec i915_YV12_mpg2_surface = {
|
||||
FOURCC_YV12,
|
||||
XVMC_CHROMA_FORMAT_420,
|
||||
0,
|
||||
720,
|
||||
576,
|
||||
720,
|
||||
576,
|
||||
XVMC_MPEG_2,
|
||||
/* XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING, */
|
||||
0,
|
||||
/* &yv12_subpicture_list */
|
||||
NULL,
|
||||
};
|
||||
|
||||
struct intel_xvmc_driver i915_xvmc_driver = {
|
||||
.name = "i915_xvmc",
|
||||
.adaptor = &pAdapt,
|
||||
static XF86MCSurfaceInfoRec i915_YV12_mpg1_surface = {
|
||||
FOURCC_YV12,
|
||||
XVMC_CHROMA_FORMAT_420,
|
||||
0,
|
||||
720,
|
||||
576,
|
||||
720,
|
||||
576,
|
||||
XVMC_MPEG_1,
|
||||
/* XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING, */
|
||||
0,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static XF86MCSurfaceInfoPtr surface_info_i915[2] = {
|
||||
(XF86MCSurfaceInfoPtr) & i915_YV12_mpg2_surface,
|
||||
(XF86MCSurfaceInfoPtr) & i915_YV12_mpg1_surface
|
||||
};
|
||||
|
||||
/* i965 and later hwmc support */
|
||||
|
|
@ -276,38 +186,75 @@ static XF86MCSurfaceInfoPtr surface_info_vld[] = {
|
|||
&yv12_mpeg2_i965_surface,
|
||||
};
|
||||
|
||||
static XF86MCAdaptorRec adaptor_vld = {
|
||||
.name = "Intel(R) Textured Video",
|
||||
.num_surfaces = sizeof(surface_info_vld) / sizeof(surface_info_vld[0]),
|
||||
.surfaces = surface_info_vld,
|
||||
/* check chip type and load xvmc driver */
|
||||
Bool intel_xvmc_adaptor_init(ScreenPtr pScreen)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
|
||||
intel_screen_private *intel = intel_get_screen_private(scrn);
|
||||
static XF86MCAdaptorRec *pAdapt;
|
||||
char *name;
|
||||
char buf[64];
|
||||
|
||||
.CreateContext = create_context,
|
||||
.DestroyContext = destroy_context,
|
||||
.CreateSurface = create_surface,
|
||||
.DestroySurface = destroy_surface,
|
||||
.CreateSubpicture = create_subpicture,
|
||||
.DestroySubpicture = destroy_subpicture
|
||||
};
|
||||
if (!intel->XvMCEnabled)
|
||||
return FALSE;
|
||||
|
||||
static XF86MCAdaptorRec adaptor = {
|
||||
.name = "Intel(R) Textured Video",
|
||||
.num_surfaces = sizeof(surface_info_i965) / sizeof(surface_info_i965[0]),
|
||||
.surfaces = surface_info_i965,
|
||||
/* Needs KMS support. */
|
||||
if (IS_I915G(intel) || IS_I915GM(intel))
|
||||
return FALSE;
|
||||
|
||||
.CreateContext = create_context,
|
||||
.DestroyContext = destroy_context,
|
||||
.CreateSurface = create_surface,
|
||||
.DestroySurface = destroy_surface,
|
||||
.CreateSubpicture = create_subpicture,
|
||||
.DestroySubpicture = destroy_subpicture
|
||||
};
|
||||
if (!IS_I9XX(intel)) {
|
||||
ErrorF("Your chipset doesn't support XvMC.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct intel_xvmc_driver i965_xvmc_driver = {
|
||||
.name = "i965_xvmc",
|
||||
.adaptor = &adaptor,
|
||||
};
|
||||
pAdapt = xcalloc(1, sizeof(struct intel_xvmc_hw_context));
|
||||
if (!pAdapt) {
|
||||
ErrorF("Allocation error.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct intel_xvmc_driver vld_xvmc_driver = {
|
||||
.name = "xvmc_vld",
|
||||
.adaptor = &adaptor_vld,
|
||||
};
|
||||
pAdapt->name = "Intel(R) Textured Video";
|
||||
pAdapt->num_subpictures = 0;
|
||||
pAdapt->subpictures = NULL;
|
||||
pAdapt->CreateContext = create_context;
|
||||
pAdapt->DestroyContext = destroy_context;
|
||||
pAdapt->CreateSurface = create_surface;
|
||||
pAdapt->DestroySurface = destroy_surface;
|
||||
pAdapt->CreateSubpicture = create_subpicture;
|
||||
pAdapt->DestroySubpicture = destroy_subpicture;
|
||||
|
||||
if (IS_I915(intel)) {
|
||||
name = "i915_xvmc",
|
||||
pAdapt->num_surfaces = ARRAY_SIZE(surface_info_i915);
|
||||
pAdapt->surfaces = surface_info_i915;
|
||||
} else if (IS_G4X(intel) || IS_IGDNG(intel)) {
|
||||
name = "xvmc_vld",
|
||||
pAdapt->num_surfaces = ARRAY_SIZE(surface_info_vld);
|
||||
pAdapt->surfaces = surface_info_vld;
|
||||
} else {
|
||||
name = "i965_xvmc",
|
||||
pAdapt->num_surfaces = ARRAY_SIZE(surface_info_i965);
|
||||
pAdapt->surfaces = surface_info_i965;
|
||||
}
|
||||
|
||||
if (xf86XvMCScreenInit(pScreen, 1, &pAdapt)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_INFO,
|
||||
"[XvMC] %s driver initialized.\n",
|
||||
name);
|
||||
} else {
|
||||
intel->XvMCEnabled = FALSE;
|
||||
xf86DrvMsg(scrn->scrnIndex, X_INFO,
|
||||
"[XvMC] Failed to initialize XvMC.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sprintf(buf, "pci:%04x:%02x:%02x.%d",
|
||||
intel->PciInfo->domain,
|
||||
intel->PciInfo->bus, intel->PciInfo->dev, intel->PciInfo->func);
|
||||
|
||||
xf86XvMCRegisterDRInfo(pScreen, INTEL_XVMC_LIBNAME,
|
||||
buf,
|
||||
INTEL_XVMC_MAJOR, INTEL_XVMC_MINOR,
|
||||
INTEL_XVMC_PATCHLEVEL);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,21 +47,6 @@
|
|||
#define XVMC_I945_MPEG2_VLD 0x04
|
||||
#define XVMC_I965_MPEG2_VLD 0x08
|
||||
|
||||
/* supported surface types */
|
||||
enum {
|
||||
SURFACE_TYPE_MPEG2_MPML = FOURCC_XVMC, /* mpeg2 MP@ML */
|
||||
SURFACE_TYPE_MPEG1_MPML, /* mpeg1 MP@ML */
|
||||
SURFACE_TYPE_MAX
|
||||
};
|
||||
|
||||
/* common header for context private */
|
||||
struct hwmc_buffer {
|
||||
drm_handle_t handle;
|
||||
unsigned long offset;
|
||||
unsigned long size;
|
||||
unsigned long bus_addr;
|
||||
};
|
||||
|
||||
struct intel_xvmc_hw_context {
|
||||
unsigned int type;
|
||||
union {
|
||||
|
|
@ -91,18 +76,6 @@ struct intel_xvmc_command {
|
|||
#ifdef _INTEL_XVMC_SERVER_
|
||||
#include <xf86xvmc.h>
|
||||
|
||||
struct intel_xvmc_driver {
|
||||
char *name;
|
||||
XF86MCAdaptorPtr adaptor;
|
||||
/* more items for xvmv surface manage? */
|
||||
void *devPrivate;
|
||||
};
|
||||
|
||||
extern struct intel_xvmc_driver *xvmc_driver;
|
||||
extern struct intel_xvmc_driver i915_xvmc_driver;
|
||||
extern struct intel_xvmc_driver i965_xvmc_driver;
|
||||
extern struct intel_xvmc_driver vld_xvmc_driver;
|
||||
|
||||
extern Bool intel_xvmc_adaptor_init(ScreenPtr);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1137,12 +1137,6 @@ static int i915_xvmc_mc_render_surface(Display * display, XvMCContext * context,
|
|||
if (!i915_xvmc_alloc_render_state_buffers(pI915XvMC))
|
||||
return BadAlloc;
|
||||
|
||||
if (context->surface_type_id >= SURFACE_TYPE_MAX) {
|
||||
XVMC_ERR("Unsupprted surface_type_id %d.",
|
||||
context->surface_type_id);
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
intel_ctx = intel_xvmc_find_context(context->context_id);
|
||||
if (!intel_ctx) {
|
||||
XVMC_ERR("Can't find intel xvmc context\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue