diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-03-09 14:56:44 +0100 |
---|---|---|
committer | Owain G. Ainsworth <oga@openbsd.org> | 2010-05-16 19:59:24 +0100 |
commit | fe37e7907b9446659cfa1d086a7be2d2efbc7f70 (patch) | |
tree | 287159f3e25d270fe3fd41fe16b354d26c988a46 | |
parent | 1797e6e9f4420e2405e6120b07c51eea31c91649 (diff) |
XvMC: move i965 specific stuff to common context
Like for the i915. With this create_context is now also shared.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit b666e3e29f22894f43a8e9f7f3d1b950d431c42d)
Signed-off-by: Owain G. Ainsworth <oga@openbsd.org>
-rw-r--r-- | src/i830_hwmc.c | 93 | ||||
-rw-r--r-- | src/i830_hwmc.h | 5 | ||||
-rw-r--r-- | src/i965_hwmc.h | 7 | ||||
-rw-r--r-- | src/xvmc/i965_xvmc.c | 12 | ||||
-rw-r--r-- | src/xvmc/xvmc_vld.c | 30 |
5 files changed, 55 insertions, 92 deletions
diff --git a/src/i830_hwmc.c b/src/i830_hwmc.c index 974c5b72..7512b8cc 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 "i965_hwmc.h" #include <X11/extensions/Xv.h> #include <X11/extensions/XvMC.h> @@ -145,40 +144,6 @@ static XF86MCSurfaceInfoPtr ppSI[2] = { (XF86MCSurfaceInfoPtr) & i915_YV12_mpg1_surface }; -/* - * i915_xvmc_create_context - * - * Some info about the private data: - * - * Set *num_priv to the number of 32bit words that make up the size of - * of the data that priv will point to. - * - * *priv = (long *) xcalloc (elements, sizeof(element)) - * *num_priv = (elements * sizeof(element)) >> 2; - * - **************************************************************************/ - -static int i915_xvmc_create_context(ScrnInfoPtr scrn, XvMCContextPtr pContext, - int *num_priv, long **priv) -{ - struct intel_xvmc_hw_context *contextRec; - - *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(struct intel_xvmc_hw_context) >> 2; - - contextRec->type = xvmc_driver->flag; - /* i915 private context */ - contextRec->i915.use_phys_addr = 0; - - return Success; -} - static int create_subpicture(ScrnInfoPtr scrn, XvMCSubpicturePtr subpicture, int *num_priv, CARD32 ** priv) { @@ -199,6 +164,34 @@ static void destroy_surface(ScrnInfoPtr scrn, XvMCSurfacePtr surface) { } +static int create_context(ScrnInfoPtr scrn, XvMCContextPtr pContext, + int *num_priv, CARD32 **priv) +{ + intel_screen_private *intel = intel_get_screen_private(scrn); + struct intel_xvmc_hw_context *contextRec; + + *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(struct intel_xvmc_hw_context) >> 2; + + contextRec->type = xvmc_driver->flag; + if (contextRec->type == XVMC_I915_MPEG2_MC) { + /* i915 private context */ + contextRec->i915.use_phys_addr = 0; + } else { + contextRec->i965.is_g4x = IS_G4X(intel); + contextRec->i965.is_965_q = IS_965_Q(intel); + contextRec->i965.is_igdng = IS_IGDNG(intel); + } + + return Success; +} + static void destroy_context(ScrnInfoPtr scrn, XvMCContextPtr context) { } @@ -216,8 +209,7 @@ static XF86MCAdaptorRec pAdapt = { .surfaces = ppSI, .num_subpictures = 0, .subpictures = NULL, - .CreateContext = - (xf86XvMCCreateContextProcPtr) i915_xvmc_create_context, + .CreateContext = create_context, .DestroyContext = destroy_context, .CreateSurface = create_surface, .DestroySurface = destroy_surface, @@ -236,33 +228,6 @@ struct intel_xvmc_driver i915_xvmc_driver = { #define XVMC_VLD 0x00020000 #endif -static int create_context(ScrnInfoPtr scrn, - XvMCContextPtr context, int *num_privates, - CARD32 ** private) -{ - struct i965_xvmc_context *private_context; - intel_screen_private *intel = intel_get_screen_private(scrn); - - unsigned int blocknum = - (((context->width + 15) / 16) * ((context->height + 15) / 16)); - unsigned int blocksize = 6 * blocknum * 64 * sizeof(short); - blocksize = (blocksize + 4095) & (~4095); - if ((private_context = Xcalloc(sizeof(*private_context))) == NULL) { - ErrorF("XVMC Can not allocate private context\n"); - return BadAlloc; - } - - private_context->is_g4x = IS_G4X(intel); - private_context->is_965_q = IS_965_Q(intel); - private_context->is_igdng = IS_IGDNG(intel); - private_context->comm.type = xvmc_driver->flag; - - *num_privates = sizeof(*private_context) / sizeof(CARD32); - *private = (CARD32 *) private_context; - - return Success; -} - static XF86MCSurfaceInfoRec yv12_mpeg2_vld_surface = { FOURCC_YV12, XVMC_CHROMA_FORMAT_420, diff --git a/src/i830_hwmc.h b/src/i830_hwmc.h index 2ca0d53e..1063938d 100644 --- a/src/i830_hwmc.h +++ b/src/i830_hwmc.h @@ -68,6 +68,11 @@ struct intel_xvmc_hw_context { struct { unsigned int use_phys_addr : 1; } i915; + struct { + unsigned int is_g4x:1; + unsigned int is_965_q:1; + unsigned int is_igdng:1; + } i965; }; }; diff --git a/src/i965_hwmc.h b/src/i965_hwmc.h deleted file mode 100644 index 7a23fc8f..00000000 --- a/src/i965_hwmc.h +++ /dev/null @@ -1,7 +0,0 @@ -#define I965_MC_STATIC_BUFFER_SIZE (1024*512) -struct i965_xvmc_context { - 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/i965_xvmc.c b/src/xvmc/i965_xvmc.c index 417c32e9..cf8d43fc 100644 --- a/src/xvmc/i965_xvmc.c +++ b/src/xvmc/i965_xvmc.c @@ -29,7 +29,7 @@ #include "brw_defines.h" #include "brw_structs.h" #include "intel_batchbuffer.h" -#include "i965_hwmc.h" +#include "i830_hwmc.h" #define BATCH_STRUCT(x) intelBatchbufferData(&x, sizeof(x), 0) #define URB_SIZE 256 /* XXX */ @@ -903,12 +903,12 @@ static Status get_surface_status(Display * display, static Status create_context(Display * display, XvMCContext * context, int priv_count, CARD32 * priv_data) { - struct i965_xvmc_context *i965_ctx; - i965_ctx = (struct i965_xvmc_context *)priv_data; - context->privData = i965_ctx; + struct intel_xvmc_hw_context *ctx; + ctx = (struct intel_xvmc_hw_context *)priv_data; + context->privData = ctx; - media_state.is_g4x = i965_ctx->is_g4x; - media_state.is_965_q = i965_ctx->is_965_q; + media_state.is_g4x = ctx->i965.is_g4x; + media_state.is_965_q = ctx->i965.is_965_q; if (alloc_object(&media_state)) return BadAlloc; diff --git a/src/xvmc/xvmc_vld.c b/src/xvmc/xvmc_vld.c index 8e8d4d6f..fdb9c606 100644 --- a/src/xvmc/xvmc_vld.c +++ b/src/xvmc/xvmc_vld.c @@ -24,7 +24,7 @@ * Zou Nan hai <nanhai.zou@intel.com> */ #include "xvmc_vld.h" -#include "i965_hwmc.h" +#include "i830_hwmc.h" #include "i810_reg.h" #include "brw_defines.h" #include "brw_structs.h" @@ -488,7 +488,7 @@ static Status interface_descriptor() return Success; } -static int setup_media_kernels(struct i965_xvmc_context *i965_ctx) +static int setup_media_kernels(struct intel_xvmc_hw_context *ctx) { int i; @@ -496,7 +496,7 @@ static int setup_media_kernels(struct i965_xvmc_context *i965_ctx) sizeof(media_gen5_kernels) / sizeof(media_gen5_kernels[0])); for (i = 0; i < MEDIA_KERNEL_NUM; i++) { - if (i965_ctx->is_igdng) + if (ctx->i965.is_igdng) media_state.vfe_state.interface.kernels[i].bo = drm_intel_bo_alloc(xvmc_driver->bufmgr, "kernel", media_gen5_kernels[i].size, @@ -513,7 +513,7 @@ static int setup_media_kernels(struct i965_xvmc_context *i965_ctx) for (i = 0; i < MEDIA_KERNEL_NUM; i++) { dri_bo *bo = media_state.vfe_state.interface.kernels[i].bo; - if (i965_ctx->is_igdng) + if (ctx->i965.is_igdng) drm_intel_bo_subdata(bo, 0, media_gen5_kernels[i].size, media_gen5_kernels[i].bin); else @@ -594,14 +594,14 @@ static Status cs_init(int interface_offset) static Status create_context(Display * display, XvMCContext * context, int priv_count, CARD32 * priv_data) { - struct i965_xvmc_context *i965_ctx; - i965_ctx = (struct i965_xvmc_context *)priv_data; + struct intel_xvmc_hw_context *ctx; + ctx = (struct intel_xvmc_hw_context *)priv_data; context->privData = priv_data; if (alloc_object(&media_state)) return BadAlloc; - if (setup_media_kernels(i965_ctx)) + if (setup_media_kernels(ctx)) return BadAlloc; return Success; } @@ -848,11 +848,11 @@ static Status put_slice(Display * display, XvMCContext * context, return Success; } -static void state_base_address(struct i965_xvmc_context *i965_ctx) +static void state_base_address(struct intel_xvmc_hw_context *ctx) { BATCH_LOCALS; - if (i965_ctx->is_igdng) { + if (ctx->i965.is_igdng) { BEGIN_BATCH(8); OUT_BATCH(BRW_STATE_BASE_ADDRESS | 6); OUT_BATCH(0 | BASE_ADDRESS_MODIFY); @@ -1005,10 +1005,10 @@ static Status put_slice2(Display * display, XvMCContext * context, { unsigned int bit_buf; intel_xvmc_context_ptr intel_ctx; - struct i965_xvmc_context *i965_ctx; + struct intel_xvmc_hw_context *ctx; int q_scale_code, mb_row; - i965_ctx = (struct i965_xvmc_context *)context->privData; + ctx = (struct intel_xvmc_hw_context *)context->privData; mb_row = *(slice - 1) - 1; bit_buf = (slice[0] << 24) | (slice[1] << 16) | (slice[2] << 8) | (slice[3]); @@ -1031,7 +1031,7 @@ static Status put_slice2(Display * display, XvMCContext * context, intel_ctx = intel_xvmc_find_context(context->context_id); LOCK_HARDWARE(intel_ctx->hw_context); - state_base_address(i965_ctx); + state_base_address(ctx); pipeline_select(); media_state_pointers(VFE_VLD_MODE); urb_layout(); @@ -1079,7 +1079,7 @@ static Status render_surface(Display * display, unsigned short *block_ptr; int i, j; int block_offset = 0; - struct i965_xvmc_context *i965_ctx; + struct intel_xvmc_hw_context *ctx; intel_ctx = intel_xvmc_find_context(context->context_id); if (!intel_ctx) { @@ -1087,7 +1087,7 @@ static Status render_surface(Display * display, return BadValue; } - i965_ctx = (struct i965_xvmc_context *)context->privData; + ctx = (struct intel_xvmc_hw_context *)context->privData; priv_target = target_surface->privData; priv_past = past_surface ? past_surface->privData : NULL; priv_future = future_surface ? future_surface->privData : NULL; @@ -1170,7 +1170,7 @@ static Status render_surface(Display * display, } LOCK_HARDWARE(intel_ctx->hw_context); - state_base_address(i965_ctx); + state_base_address(ctx); flush(); pipeline_select(); urb_layout(); |