📄 i915_xvmc.c
字号:
s4->cull_mode = CULLMODE_NONE; s4->color_shade_mode = SHADEMODE_FLAT; s4->specular_shade_mode = SHADEMODE_FLAT; s4->fog_shade_mode = SHADEMODE_FLAT; s4->alpha_shade_mode = SHADEMODE_FLAT; s4->line_width = 0x2; /* FIXME: 1.0??? */ s4->point_width = 0x1; s5 = (struct s5_dword *)(++s4); s6 = (struct s6_dword *)(++s5); s6->src_blend_factor = 1; s6->dest_blend_factor = 1; s6->color_buffer_write = 1; s7 = (struct s7_dword *)(++s6); intelBatchbufferData(base, size, 0); free(base); /* 3DSTATE_3DSTATE_SCISSOR_RECTANGLE */ scissor_rectangle.dw0.type = CMD_3D; scissor_rectangle.dw0.opcode = OPC_3DSTATE_SCISSOR_RECTANGLE; scissor_rectangle.dw0.length = 1; scissor_rectangle.dw1.min_x = 0; scissor_rectangle.dw1.min_y = 0; scissor_rectangle.dw2.max_x = 2047; scissor_rectangle.dw2.max_y = 2047; intelBatchbufferData(&scissor_rectangle, sizeof(scissor_rectangle), 0); /* 3DSTATE_LOAD_INDIRECT */ size = sizeof(*load_indirect) + sizeof(*sis) + sizeof(*ssb) + sizeof(*msb) + sizeof(*psp); base = calloc(1, size); load_indirect = (struct i915_3dstate_load_indirect *)base; load_indirect->dw0.type = CMD_3D; load_indirect->dw0.opcode = OPC_3DSTATE_LOAD_INDIRECT; load_indirect->dw0.mem_select = 1; /* Bearlake only */ load_indirect->dw0.block_mask = BLOCK_SIS | BLOCK_SSB | BLOCK_MSB | BLOCK_PSP; load_indirect->dw0.length = 7; /* SIS */ sis = (sis_state *)(++load_indirect); sis->dw0.valid = 1; sis->dw0.buffer_address = pI915XvMC->sis.offset; sis->dw1.length = ((sizeof(struct i915_3dstate_buffer_info) + sizeof(struct i915_3dstate_dest_buffer_variables)) >> 2) - 1; /* SSB */ ssb = (ssb_state *)(++sis); ssb->dw0.valid = 1; ssb->dw0.buffer_address = pI915XvMC->ssb.offset; ssb->dw1.length = ((sizeof(struct i915_3dstate_sampler_state) + sizeof(struct texture_sampler) * 3) >> 2) - 1; /* MSB */ msb = (msb_state *)(++ssb); msb->dw0.valid = 1; msb->dw0.buffer_address = pI915XvMC->msb.offset; msb->dw1.length = ((sizeof(struct i915_3dstate_map_state) + sizeof(struct texture_map) * 3) >> 2) - 1; /* PSP */ psp = (psp_state *)(++msb); psp->dw0.valid = 1; psp->dw0.buffer_address = pI915XvMC->psp.offset; psp->dw1.length = ((sizeof(struct i915_3dstate_pixel_shader_program) + sizeof(union shader_inst)) >> 2) - 1; intelBatchbufferData(base, size, 0); free(base); /* 3DPRIMITIVE */ size = sizeof(*_3dprimitive) + sizeof(*vd) * 3; base = calloc(1, size); _3dprimitive = (struct i915_3dprimitive *)base; _3dprimitive->dw0.inline_prim.type = CMD_3D; _3dprimitive->dw0.inline_prim.opcode = OPC_3DPRIMITIVE; _3dprimitive->dw0.inline_prim.vertex_location = VERTEX_INLINE; _3dprimitive->dw0.inline_prim.prim = PRIM_RECTLIST; _3dprimitive->dw0.inline_prim.length = size - 2; vd = (struct vertex_data *)(++_3dprimitive); vd->x = 0; /* FIXME!!! */ vd->x = 0; /* FIXME */ vd->tc0.tcx = 0; vd->tc0.tcy = 0; vd->tc1.tcx = 0; vd->tc1.tcy = 0; ++vd; vd->x = 0; /* FIXME!!! */ vd->x = 0; /* FIXME */ vd->tc0.tcx = 0; vd->tc0.tcy = 0; vd->tc1.tcx = 0; vd->tc1.tcy = 0; ++vd; vd->x = 0; /* FIXME!!! */ vd->x = 0; /* FIXME */ vd->tc0.tcx = 0; vd->tc0.tcy = 0; vd->tc1.tcx = 0; vd->tc1.tcy = 0; intelBatchbufferData(base, size, 0); free(base);}#endif/* * Function: i915_release_resource */static void i915_release_resource(Display *display, XvMCContext *context){ i915XvMCContext *pI915XvMC; if (!(pI915XvMC = context->privData)) return; pI915XvMC->ref--; i915_xvmc_unmap_buffers(pI915XvMC); free(pI915XvMC); context->privData = NULL;}static Status i915_xvmc_mc_create_context(Display *display, XvMCContext *context, int priv_count, CARD32 *priv_data){ i915XvMCContext *pI915XvMC = NULL; I915XvMCCreateContextRec *tmpComm = NULL; drm_sarea_t *pSAREA; XVMC_DBG("%s\n", __FUNCTION__); if (priv_count != (sizeof(I915XvMCCreateContextRec) >> 2)) { XVMC_ERR("_xvmc_create_context() returned incorrect data size!"); XVMC_INFO("\tExpected %d, got %d", (int)(sizeof(I915XvMCCreateContextRec) >> 2),priv_count); _xvmc_destroy_context(display, context); XFree(priv_data); context->privData = NULL; return BadValue; } context->privData = (void *)calloc(1, sizeof(i915XvMCContext)); if (!context->privData) { XVMC_ERR("Unable to allocate resources for XvMC context."); return BadAlloc; } pI915XvMC = (i915XvMCContext *)context->privData; tmpComm = (I915XvMCCreateContextRec *)priv_data; pI915XvMC->ctxno = tmpComm->ctxno; pI915XvMC->deviceID = tmpComm->deviceID; pI915XvMC->sis.handle = tmpComm->sis.handle; pI915XvMC->sis.offset = tmpComm->sis.offset; pI915XvMC->sis.size = tmpComm->sis.size; pI915XvMC->ssb.handle = tmpComm->ssb.handle; pI915XvMC->ssb.offset = tmpComm->ssb.offset; pI915XvMC->ssb.size = tmpComm->ssb.size; pI915XvMC->msb.handle = tmpComm->msb.handle; pI915XvMC->msb.offset = tmpComm->msb.offset; pI915XvMC->msb.size = tmpComm->msb.size; pI915XvMC->psp.handle = tmpComm->psp.handle; pI915XvMC->psp.offset = tmpComm->psp.offset; pI915XvMC->psp.size = tmpComm->psp.size; pI915XvMC->psc.handle = tmpComm->psc.handle; pI915XvMC->psc.offset = tmpComm->psc.offset; pI915XvMC->psc.size = tmpComm->psc.size; if (pI915XvMC->deviceID == PCI_CHIP_I915_G || pI915XvMC->deviceID == PCI_CHIP_I915_GM) { pI915XvMC->sis.bus_addr = tmpComm->sis.bus_addr; pI915XvMC->ssb.bus_addr = tmpComm->ssb.bus_addr; pI915XvMC->msb.bus_addr = tmpComm->msb.bus_addr; pI915XvMC->psp.bus_addr = tmpComm->psp.bus_addr; pI915XvMC->psc.bus_addr = tmpComm->psc.bus_addr; } pI915XvMC->corrdata.handle = tmpComm->corrdata.handle; pI915XvMC->corrdata.offset = tmpComm->corrdata.offset; pI915XvMC->corrdata.size = tmpComm->corrdata.size; pI915XvMC->sarea_priv_offset = tmpComm->sarea_priv_offset; /* Must free the private data we were passed from X */ XFree(priv_data); priv_data = NULL; pSAREA = (drm_sarea_t *)xvmc_driver->sarea_address; pI915XvMC->sarea = (drmI830Sarea*)((char*)pSAREA + pI915XvMC->sarea_priv_offset); if (i915_xvmc_map_buffers(pI915XvMC)) { i915_xvmc_unmap_buffers(pI915XvMC); free(pI915XvMC); context->privData = NULL; return BadAlloc; } /* Initialize private context values */ pI915XvMC->yStride = STRIDE(context->width); pI915XvMC->uvStride = STRIDE(context->width >> 1); pI915XvMC->haveXv = 0; pI915XvMC->dual_prime = 0; pI915XvMC->last_flip = 0; pI915XvMC->port = context->port; pI915XvMC->ref = 1; /* pre-init state buffers */ i915_mc_one_time_context_init(context); i915_mc_one_time_state_init(context); i915_mc_static_indirect_state_init(context); i915_mc_map_state_init(context); i915_mc_load_indirect_render_init(context); return Success;}static int i915_xvmc_mc_destroy_context(Display *display, XvMCContext *context){ i915XvMCContext *pI915XvMC; if (!(pI915XvMC = context->privData)) return XvMCBadContext; /* Pass Control to the X server to destroy the drm_context_t */ i915_release_resource(display,context); free(one_time_load_state_imm1); free(one_time_load_indirect); free(mc_render_load_indirect); return Success;}static Status i915_xvmc_mc_create_surface(Display *display, XvMCContext *context, XvMCSurface *surface, int priv_count, CARD32 *priv_data){ i915XvMCContext *pI915XvMC; i915XvMCSurface *pI915Surface; I915XvMCCreateSurfaceRec *tmpComm = NULL; if (!(pI915XvMC = context->privData)) return XvMCBadContext; XVMC_DBG("%s\n", __FUNCTION__); if (priv_count != (sizeof(I915XvMCCreateSurfaceRec) >> 2)) { XVMC_ERR("_xvmc_create_surface() returned incorrect data size!"); XVMC_INFO("\tExpected %d, got %d", (int)(sizeof(I915XvMCCreateSurfaceRec) >> 2), priv_count); _xvmc_destroy_surface(display, surface); XFree(priv_data); return BadAlloc; } PPTHREAD_MUTEX_LOCK(); surface->privData = (i915XvMCSurface *)malloc(sizeof(i915XvMCSurface)); if (!(pI915Surface = surface->privData)) { PPTHREAD_MUTEX_UNLOCK(); return BadAlloc; } /* Initialize private values */ pI915Surface->last_render = 0; pI915Surface->last_flip = 0; pI915Surface->yStride = pI915XvMC->yStride; pI915Surface->uvStride = pI915XvMC->uvStride; pI915Surface->width = context->width; pI915Surface->height = context->height; pI915Surface->privContext = pI915XvMC; pI915Surface->privSubPic = NULL; pI915Surface->srf.map = NULL; tmpComm = (I915XvMCCreateSurfaceRec *)priv_data; pI915Surface->srfNo = tmpComm->srfno; pI915Surface->srf.handle = tmpComm->srf.handle; pI915Surface->srf.offset = tmpComm->srf.offset; pI915Surface->srf.size = tmpComm->srf.size; XFree(priv_data); if (drmMap(xvmc_driver->fd, pI915Surface->srf.handle, pI915Surface->srf.size, (drmAddress *)&pI915Surface->srf.map) != 0) { XVMC_ERR("mapping surface memory failed!\n"); _xvmc_destroy_surface(display, surface); free(pI915Surface); surface->privData = NULL; PPTHREAD_MUTEX_UNLOCK(); return BadAlloc; } pI915XvMC->ref++; PPTHREAD_MUTEX_UNLOCK(); return 0;}static int i915_xvmc_mc_destroy_surface(Display *display, XvMCSurface *surface){ i915XvMCSurface *pI915Surface; i915XvMCContext *pI915XvMC; if (!display || !surface) return BadValue; if (!(pI915Surface = surface->privData)) return XvMCBadSurface; if (!(pI915XvMC = pI915Surface->privContext)) return XvMCBadSurface; if (pI915Surface->last_flip) XvMCSyncSurface(display,surface); if (pI915Surface->srf.map) drmUnmap(pI915Surface->srf.map, pI915Surface->srf.size); free(pI915Surface); surface->privData = NULL; pI915XvMC->ref--; return Success;}static int i915_xvmc_mc_render_surface(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){ int i; int picture_coding_type = MPEG_I_PICTURE; /* correction data buffer */ char *corrdata_ptr; int corrdata_size = 0; /* Block Pointer */ short *block_ptr; /* Current Macroblock Pointer */ XvMCMacroBlock *mb; intel_xvmc_context_ptr intel_ctx; i915XvMCSurface *privTarget = NULL; i915XvMCSurface *privFuture = NUL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -