summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-03-09 14:44:53 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2010-04-08 11:22:17 +0200
commite0068b1e63bc914940dbeb52de46657fcf5da1ea (patch)
treef79bf58e4c73bc427a8fc4324fae80a326be5257
parent8cab7b84da6d06c20ad9dbbcd8f3f3d971b438e7 (diff)
XvMC: move i915 specific stuff to common context
Doing the same with the i965 code will allow us to share the create_context function. src/i915_hwmc.h is now almost empty. Move the last #defines to src/xvmv/i915_xvmc.c where they are actually used and delete the file. Also rename the ddx context struct to something sane. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--src/i830_hwmc.c43
-rw-r--r--src/i830_hwmc.h7
-rw-r--r--src/i830_video.c1
-rw-r--r--src/i915_hwmc.h47
-rw-r--r--src/i965_hwmc.h2
-rw-r--r--src/xvmc/i915_xvmc.c20
-rw-r--r--src/xvmc/i915_xvmc.h4
-rw-r--r--src/xvmc/intel_xvmc.c4
8 files changed, 29 insertions, 99 deletions
diff --git a/src/i830_hwmc.c b/src/i830_hwmc.c
index de2c5c7b..fc653ce3 100644
--- a/src/i830_hwmc.c
+++ b/src/i830_hwmc.c
@@ -32,7 +32,6 @@
#include "i830.h"
#include "intel_bufmgr.h"
#include "i830_hwmc.h"
-#include "i915_hwmc.h"
#include "i965_hwmc.h"
#include <X11/extensions/Xv.h>
@@ -146,21 +145,6 @@ static XF86MCSurfaceInfoPtr ppSI[2] = {
(XF86MCSurfaceInfoPtr) & i915_YV12_mpg1_surface
};
-/* Check context size not exceed surface type max */
-static void i915_check_context_size(XvMCContextPtr ctx)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(ppSI); i++) {
- if (ctx->surface_type_id == ppSI[i]->surface_type_id) {
- if (ctx->width > ppSI[i]->max_width)
- ctx->width = ppSI[i]->max_width;
- if (ctx->height > ppSI[i]->max_height)
- ctx->height = ppSI[i]->max_height;
- }
- }
-}
-
/*
* i915_xvmc_create_context
*
@@ -177,33 +161,20 @@ static void i915_check_context_size(XvMCContextPtr ctx)
static int i915_xvmc_create_context(ScrnInfoPtr scrn, XvMCContextPtr pContext,
int *num_priv, long **priv)
{
- intel_screen_private *intel = intel_get_screen_private(scrn);
- I915XvMCCreateContextRec *contextRec = NULL;
-
- *priv = NULL;
- *num_priv = 0;
-
- if (!intel->XvMCEnabled) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915: XvMC disabled!\n");
- return BadAlloc;
- }
-
- i915_check_context_size(pContext);
-
- *priv = xcalloc(1, sizeof(I915XvMCCreateContextRec));
- contextRec = (I915XvMCCreateContextRec *) * priv;
+ struct intel_xvmc_hw_context *contextRec;
- if (!*priv) {
+ *priv = xcalloc(1, sizeof(struct intel_xvmc_hw_context));
+ contextRec = (struct intel_xvmc_hw_context *) *priv;
+ if (!contextRec) {
*num_priv = 0;
return BadAlloc;
}
- *num_priv = sizeof(I915XvMCCreateContextRec) >> 2;
+ *num_priv = sizeof(struct intel_xvmc_hw_context) >> 2;
- contextRec->comm.type = xvmc_driver->flag;
+ contextRec->type = xvmc_driver->flag;
/* i915 private context */
- contextRec->deviceID = DEVICE_ID(intel->PciInfo);
+ contextRec->i915.use_phys_addr = 0;
return Success;
}
diff --git a/src/i830_hwmc.h b/src/i830_hwmc.h
index 599b5be0..2ca0d53e 100644
--- a/src/i830_hwmc.h
+++ b/src/i830_hwmc.h
@@ -62,8 +62,13 @@ struct hwmc_buffer {
unsigned long bus_addr;
};
-struct _intel_xvmc_common {
+struct intel_xvmc_hw_context {
unsigned int type;
+ union {
+ struct {
+ unsigned int use_phys_addr : 1;
+ } i915;
+ };
};
/* Intel private XvMC command to DDX driver */
diff --git a/src/i830_video.c b/src/i830_video.c
index c2a02b5b..0e8799d3 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -74,7 +74,6 @@
#ifdef INTEL_XVMC
#define _INTEL_XVMC_SERVER_
#include "i830_hwmc.h"
-#include "i915_hwmc.h"
#endif
#define OFF_DELAY 250 /* milliseconds */
diff --git a/src/i915_hwmc.h b/src/i915_hwmc.h
deleted file mode 100644
index c036b638..00000000
--- a/src/i915_hwmc.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright © 2006 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:
- * Xiang Haihao <haihao.xiang@intel.com>
- *
- */
-#ifndef _I915_HWMC_H
-#define _I915_HWMC_H
-
-#include "i830_hwmc.h"
-
-/* i915 hw requires surface to be at least 1KB aligned */
-#define STRIDE(w) (((w) + 0x3ff) & ~0x3ff)
-#define SIZE_Y420(w, h) (h * STRIDE(w))
-#define SIZE_UV420(w, h) ((h >> 1) * STRIDE(w >> 1))
-#define SIZE_YUV420(w, h) (SIZE_Y420(w,h) + SIZE_UV420(w,h) * 2)
-#define SIZE_XX44(w, h) (h * STRIDE(w))
-
-#define I915_NUM_XVMC_ATTRIBUTES 0x02
-#define I915_XVMC_VALID 0x80000000
-
-typedef struct {
- struct _intel_xvmc_common comm;
- int deviceID;
-} I915XvMCCreateContextRec;
-
-#endif /* _I915_HWMC_H */
diff --git a/src/i965_hwmc.h b/src/i965_hwmc.h
index 8b388679..7a23fc8f 100644
--- a/src/i965_hwmc.h
+++ b/src/i965_hwmc.h
@@ -1,6 +1,6 @@
#define I965_MC_STATIC_BUFFER_SIZE (1024*512)
struct i965_xvmc_context {
- struct _intel_xvmc_common comm;
+ struct intel_xvmc_hw_context comm;
unsigned int is_g4x:1;
unsigned int is_965_q:1;
unsigned int is_igdng:1;
diff --git a/src/xvmc/i915_xvmc.c b/src/xvmc/i915_xvmc.c
index 0888d639..2b110be1 100644
--- a/src/xvmc/i915_xvmc.c
+++ b/src/xvmc/i915_xvmc.c
@@ -31,6 +31,10 @@
#include "i915_structs.h"
#include "i915_program.h"
+#define STRIDE(w) (((w) + 0x3ff) & ~0x3ff)
+#define SIZE_Y420(w, h) (h * STRIDE(w))
+#define SIZE_UV420(w, h) ((h >> 1) * STRIDE(w >> 1))
+#define SIZE_YUV420(w, h) (SIZE_Y420(w,h) + SIZE_UV420(w,h) * 2)
#define UOFFSET(surface) (SIZE_Y420(surface->width, surface->height))
#define VOFFSET(surface) (SIZE_Y420(surface->width, surface->height) + \
SIZE_UV420(surface->width, surface->height))
@@ -347,8 +351,7 @@ static void i915_mc_one_time_state_emit(XvMCContext * context)
<< BLOCK_MASK_SHIFT;
load_indirect |= 8 - 2; /* length */
- if (pI915XvMC->deviceID == PCI_CHIP_I915_G ||
- pI915XvMC->deviceID == PCI_CHIP_I915_GM)
+ if (pI915XvMC->use_phys_addr)
mem_select = 0; /* use physical address */
else {
load_indirect |= OP_3D_LOAD_INDIRECT_GFX_ADDR;
@@ -691,8 +694,7 @@ static void i915_mc_load_indirect_render_emit(XvMCContext * context)
load_indirect |= (BLOCK_SIS | BLOCK_MSB) << BLOCK_MASK_SHIFT;
load_indirect |= 5 - 2; /* length */
- if (pI915XvMC->deviceID == PCI_CHIP_I915_G ||
- pI915XvMC->deviceID == PCI_CHIP_I915_GM)
+ if (pI915XvMC->use_phys_addr)
mem_select = 0; /* use physical address */
else {
load_indirect |= OP_3D_LOAD_INDIRECT_GFX_ADDR;
@@ -901,15 +903,15 @@ static Status i915_xvmc_mc_create_context(Display * display,
CARD32 * priv_data)
{
i915XvMCContext *pI915XvMC = NULL;
- I915XvMCCreateContextRec *tmpComm = NULL;
+ struct intel_xvmc_hw_context *tmpComm = NULL;
XVMC_DBG("%s\n", __FUNCTION__);
- if (priv_count != (sizeof(I915XvMCCreateContextRec) >> 2)) {
+ if (priv_count != (sizeof(struct intel_xvmc_hw_context) >> 2)) {
XVMC_ERR
("_xvmc_create_context() returned incorrect data size!");
XVMC_INFO("\tExpected %d, got %d",
- (int)(sizeof(I915XvMCCreateContextRec) >> 2),
+ (int)(sizeof(struct intel_xvmc_hw_context) >> 2),
priv_count);
_xvmc_destroy_context(display, context);
XFree(priv_data);
@@ -924,8 +926,8 @@ static Status i915_xvmc_mc_create_context(Display * display,
}
pI915XvMC = (i915XvMCContext *) context->privData;
- tmpComm = (I915XvMCCreateContextRec *) priv_data;
- pI915XvMC->deviceID = tmpComm->deviceID;
+ tmpComm = (struct intel_xvmc_hw_context *) priv_data;
+ pI915XvMC->use_phys_addr = tmpComm->i915.use_phys_addr;
/* Must free the private data we were passed from X */
XFree(priv_data);
diff --git a/src/xvmc/i915_xvmc.h b/src/xvmc/i915_xvmc.h
index 7fd142e2..0bf59289 100644
--- a/src/xvmc/i915_xvmc.h
+++ b/src/xvmc/i915_xvmc.h
@@ -29,7 +29,7 @@
#define _I915XVMC_H
#include "intel_xvmc.h"
-#include "i915_hwmc.h"
+#include "i830_hwmc.h"
#define I915_SUBPIC_PALETTE_SIZE 16
#define MAX_SUBCONTEXT_LEN 1024
@@ -56,6 +56,7 @@ typedef struct _i915XvMCContext {
unsigned int uvStride;
unsigned short ref;
unsigned int depth;
+ unsigned int use_phys_addr;
XvPortID port; /* Xv Port ID when displaying */
int haveXv; /* Have I initialized the Xv
* connection for this surface? */
@@ -64,7 +65,6 @@ typedef struct _i915XvMCContext {
GC gc; /* X GC needed for displaying */
Drawable draw; /* Drawable to undisplay from */
void *drawHash;
- int deviceID;
drm_intel_bo *sis_bo;
drm_intel_bo *msb_bo;
diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c
index 328d3c1e..ade2d7d8 100644
--- a/src/xvmc/intel_xvmc.c
+++ b/src/xvmc/intel_xvmc.c
@@ -332,7 +332,7 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port,
{
Status ret;
CARD32 *priv_data = NULL;
- struct _intel_xvmc_common *comm;
+ struct intel_xvmc_hw_context *comm;
int major, minor;
int error_base;
int event_base;
@@ -392,7 +392,7 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port,
}
XVMC_DBG("new context %d created\n", (int)context->context_id);
- comm = (struct _intel_xvmc_common *)priv_data;
+ comm = (struct intel_xvmc_hw_context *)priv_data;
if (xvmc_driver == NULL || xvmc_driver->type != comm->type) {
switch (comm->type) {