summaryrefslogtreecommitdiffstats
path: root/src/psb_texture.c
diff options
context:
space:
mode:
authorLiu, Shuo <shuo.liu@intel.com>2011-01-07 19:32:51 +0800
committerPatrick Tjin <pattjin@google.com>2014-07-21 22:05:52 -0700
commit4b5b72d7dd3fe944d75029ff0ca6db1e74600e59 (patch)
tree55c63798511812c42095cf0cfa4350d937ade624 /src/psb_texture.c
parent2f768e2db3e4074a6e9a3d5f0f6e321233d96e4c (diff)
downloadandroid_hardware_intel_img_psb_video-4b5b72d7dd3fe944d75029ff0ca6db1e74600e59.tar.gz
android_hardware_intel_img_psb_video-4b5b72d7dd3fe944d75029ff0ca6db1e74600e59.tar.bz2
android_hardware_intel_img_psb_video-4b5b72d7dd3fe944d75029ff0ca6db1e74600e59.zip
Update psb_video from medfield-meego 2010-12-15 release to enable
stagefright based video playback Change-Id: I41ca5c27a819895ef3c0eed529b84edca0f1fa24 Signed-off-by: Liu, Shuo <shuo.liu@intel.com>
Diffstat (limited to 'src/psb_texture.c')
-rw-r--r--src/psb_texture.c229
1 files changed, 138 insertions, 91 deletions
diff --git a/src/psb_texture.c b/src/psb_texture.c
index dd5f672..62ef5f9 100644
--- a/src/psb_texture.c
+++ b/src/psb_texture.c
@@ -26,12 +26,14 @@
#include <psb_drm.h>
#include <va/va_backend.h>
+#include <va/va_dricommon.h>
#include <wsbm/wsbm_manager.h>
#ifndef ANDROID
#include <X11/Xlib.h>
#include "x11/psb_xrandr.h"
+#include "x11/psb_x11.h"
#endif
#include "pvr2d.h"
@@ -42,8 +44,8 @@
#include "psb_texture.h"
-
#define INIT_DRIVER_DATA psb_driver_data_p driver_data = (psb_driver_data_p) ctx->pDriverData;
+#define INIT_OUTPUT_PRIV psb_x11_output_p output = (psb_x11_output_p)(((psb_driver_data_p)ctx->pDriverData)->ws_priv)
#define SURFACE(id) ((object_surface_p) object_heap_lookup( &driver_data->surface_heap, id ))
#define Degree (2*PI / 360.0)
@@ -166,7 +168,6 @@ static int pvr_context_create(void **pvr_ctx)
ret = PVR2DEnumerateDevices(pvr_devs);
if (ret != PVR2D_OK) {
- free(pvr_devs);
psb__error_message("%s(): PVR2DEnumerateDevices() failed(%d)", __func__,
ret);
goto out;
@@ -190,6 +191,8 @@ static int pvr_context_create(void **pvr_ctx)
void psb_ctexture_init(VADriverContextP ctx)
{
INIT_DRIVER_DATA;
+ INIT_OUTPUT_PRIV;
+
struct psb_texture_s *texture_priv = &driver_data->ctexture_priv;
int ret;
@@ -223,28 +226,62 @@ void psb_ctexture_init(VADriverContextP ctx)
texture_priv->gamma0 = 0x080808;
#ifndef ANDROID
texture_priv->dri_init_flag = 0;
+ texture_priv->drawable_update_flag = 0;
+ texture_priv->extend_dri_init_flag = 0;
texture_priv->current_blt_buffer = 0;
texture_priv->extend_current_blt_buffer = 0;
-#ifdef SUBPIC
+ texture_priv->adjust_window_flag = 0;
+ texture_priv->destw_save = 0;
+ texture_priv->desth_save = 0;
+ output->output_drawable = 0;
+ output->extend_drawable = 0;
+ int i;
for (i = 0; i < 6; i++)
texture_priv->pal_meminfo[i] = NULL;
#endif
- XWindowAttributes attr;
- XGetWindowAttributes(ctx->native_dpy, DefaultRootWindow(ctx->native_dpy), &attr);
- texture_priv->rootwin_width = attr.width;
- texture_priv->rootwin_height = attr.height;
-#endif
psb_setup_coeffs(texture_priv);
}
+void psb_extend_ctexture_deinit(VADriverContextP ctx)
+{
+ INIT_DRIVER_DATA;
+ INIT_OUTPUT_PRIV;
+ PVR2DERROR ePVR2DStatus;
+ int i;
+
+ struct psb_texture_s *texture_priv = &driver_data->ctexture_priv;
+#ifndef ANDROID
+ for(i = 0; i < DRI2_BLIT_BUFFERS_NUM; i++) {
+ ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, texture_priv->extend_blt_meminfo[i]);
+ if (ePVR2DStatus!= PVR2D_OK)
+ psb__error_message("%s: PVR2DMemFree error %d\n", __FUNCTION__, ePVR2DStatus);
+ }
+ XDestroyWindow(ctx->native_dpy, output->extend_drawable);
+ for (i = 0; i < 6; i++) {
+ if (texture_priv->pal_meminfo[i]) {
+ ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, texture_priv->pal_meminfo[i]);
+ if (ePVR2DStatus!= PVR2D_OK)
+ psb__error_message("%s: PVR2DMemFree error %d\n", __FUNCTION__, ePVR2DStatus);
+ }
+ }
+#endif
+}
+
void psb_ctexture_deinit(VADriverContextP ctx)
{
INIT_DRIVER_DATA;
+ PVR2DERROR ePVR2DStatus;
int i;
struct psb_texture_s *texture_priv = &driver_data->ctexture_priv;
#ifndef ANDROID
+ if (!texture_priv->dri_drawable->is_window) {
+ ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, texture_priv->blt_meminfo_pixmap);
+ if (ePVR2DStatus!= PVR2D_OK)
+ psb__error_message("%s: PVR2DMemFree error %d\n", __FUNCTION__, ePVR2DStatus);
+ }
+
if (texture_priv->dri2_bb_export.ui32Type == DRI2_BACK_BUFFER_EXPORT_TYPE_BUFFERS)
for(i = 0; i < DRI2_BLIT_BUFFERS_NUM; i++) {
ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, texture_priv->blt_meminfo[i]);
@@ -257,21 +294,6 @@ void psb_ctexture_deinit(VADriverContextP ctx)
if (ePVR2DStatus!= PVR2D_OK)
psb__error_message("%s: PVR2DMemFree error %d\n", __FUNCTION__, ePVR2DStatus);
}
-
- if (driver_data->xrandr_thread_id) {
- if (psb_xrandr_extvideo_mode())
- for(i = 0; i < DRI2_BLIT_BUFFERS_NUM; i++) {
- ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, texture_priv->extend_blt_meminfo[i]);
- if (ePVR2DStatus!= PVR2D_OK)
- psb__error_message("%s: PVR2DMemFree error %d\n", __FUNCTION__, ePVR2DStatus);
- }
- }
-
- texture_priv->dri_init_flag = 0;
- texture_priv->current_blt_buffer = 0;
- texture_priv->extend_current_blt_buffer = 0;
- texture_priv->rootwin_width = texture_priv->rootwin_height = 0;
-#ifdef SUBPIC
for (i = 0; i < 6; i++) {
if (texture_priv->pal_meminfo[i]) {
ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, texture_priv->pal_meminfo[i]);
@@ -280,16 +302,15 @@ void psb_ctexture_deinit(VADriverContextP ctx)
}
}
#endif
-#endif
(void)texture_priv;
-
+
}
#ifndef ANDROID
void psb_putsurface_textureblit(
VADriverContextP ctx, PPVR2DMEMINFO pDstMeminfo, VASurfaceID surface, int src_x, int src_y, int src_w,
- int src_h, int dst_x, int dst_y, int dst_w, int dst_h,
+ int src_h, int dst_x, int dst_y, int dst_w, int dst_h, unsigned int subtitle,
int width, int height,
int src_pitch, struct _WsbmBufferObject * src_buf,
unsigned int placement)
@@ -304,25 +325,28 @@ void psb_putsurface_textureblit(
{
#ifndef ANDROID
INIT_DRIVER_DATA;
- int i, j = 0, update_coeffs = 0;
+ int i, j, update_coeffs = 0;
unsigned char tmp;
- unsigned char * tmp_buffer;
- unsigned char * tmp_subpic_buffer;
- unsigned char temp;
+ unsigned char *tmp_buffer, *tmp_palette;
struct psb_texture_s *texture_priv = &driver_data->ctexture_priv;
- object_surface_p obj_surface = SURFACE(surface);
- PsbVASurfaceRec *surface_subpic;
- surface_subpic = (PsbVASurfaceRec *)obj_surface->subpictures;
+ object_surface_p obj_surface;
+ PsbVASurfaceRec *surface_subpic = NULL;
+ obj_surface = SURFACE(surface);
PVR2D_VPBLT sBltVP;
PVR2DERROR ePVR2DStatus;
PPVR2DMEMINFO pVaVideoMemInfo;
-#ifdef SUBPIC
PPVR2DMEMINFO pVaVideoSubpicMemInfo[6];
-#endif
+ unsigned char * tmp_subpic_buffer;
src_pitch = (src_pitch + 0x3) & ~0x3;
+ if (NULL == obj_surface)
+ {
+ psb__error_message("%s: Invalid surface ID 0x%08x!\n", __func__, surface);
+ return;
+ }
+ surface_subpic = (PsbVASurfaceRec *)obj_surface->subpictures;
/* check whether we need to update coeffs */
if ((height > 576) &&
(texture_priv->video_transfermatrix != PSB_VideoTransferMatrix_BT709)) {
@@ -340,7 +364,7 @@ void psb_putsurface_textureblit(
psb_setup_coeffs(texture_priv);
sBltVP.psYUVCoeffs = (PPVR2D_YUVCOEFFS) &texture_priv->coeffs;
/* FIXME: is it right? */
- sBltVP.bCoeffsGiven = 1;
+ sBltVP.bCoeffsGiven = 1;
}
/* now wrap the source wsbmBO */
@@ -383,7 +407,7 @@ void psb_putsurface_textureblit(
#ifndef ANDROID
if (IS_MFLD(driver_data))
//FIXME: zhaohan, mdfld gfx driver requires 8 bits aligned in the future, use 32 bits temporary
- sBltVP.sDst.Stride = PVRCalculateStride(dst_w, 32, 32);
+ sBltVP.sDst.Stride = PVRCalculateStride(dst_w, 32, 8);
if (IS_MRST(driver_data))
sBltVP.sDst.Stride = PVRCalculateStride(dst_w, 32, 32);
sBltVP.sDst.Format = PVR2D_ARGB8888;
@@ -420,62 +444,82 @@ void psb_putsurface_textureblit(
sBltVP.rcSource->right = src_x + src_w;
sBltVP.rcSource->top = src_y;
sBltVP.rcSource->bottom = src_y + src_h;
-#ifdef SUBPIC
- for (i = 0; i < obj_surface->subpic_count; i++) {
- tmp_subpic_buffer = NULL;
- tmp_subpic_buffer = wsbmBOMap (surface_subpic->bo, WSBM_ACCESS_READ | WSBM_ACCESS_WRITE);
- for (i = 0; i < surface_subpic->stride * surface_subpic->subpic_srch * 4; i = i + 4096) {
- tmp = *(tmp_subpic_buffer + i);
- if (tmp == 0)
- *(tmp_subpic_buffer + i) = 0;
- }
- ePVR2DStatus = PVR2DMemWrap(texture_priv->hPVR2DContext,
- tmp_subpic_buffer,
- 0,
- (surface_subpic->subpic_srcw * surface_subpic->subpic_srch * 4),
- NULL,
- &pVaVideoSubpicMemInfo[j]);
- if (ePVR2DStatus!= PVR2D_OK)
- {
- psb__error_message("%s: PVR2DMemWrap subpic error %d\n", __FUNCTION__, ePVR2DStatus);
- }
+ if (subtitle == 0 && obj_surface->subpic_count) {
+ for (i = 0; i < obj_surface->subpic_count; i++) {
+ tmp_subpic_buffer = NULL;
+ tmp_subpic_buffer = wsbmBOMap (surface_subpic->bo, WSBM_ACCESS_READ | WSBM_ACCESS_WRITE);
+ for (j = 0; j < surface_subpic->stride * surface_subpic->subpic_srch * 4; j = j + 4096) {
+ tmp = *(tmp_subpic_buffer + j);
+ if (tmp == 0)
+ *(tmp_subpic_buffer + j) = 0;
+ }
- sBltVP.uiNumLayers += 1;
-
- sBltVP.sSrcSubpic[j].pSurfMemInfo = pVaVideoSubpicMemInfo[j];
- sBltVP.sSrcSubpic[j].SurfOffset = 0;
- sBltVP.sSrcSubpic[j].Stride = surface_subpic->stride;
- sBltVP.sSrcSubpic[j].Format = surface_subpic->fourcc;
- sBltVP.sSrcSubpic[j].SurfWidth = surface_subpic->subpic_srcw;
- sBltVP.sSrcSubpic[j].SurfHeight = surface_subpic->subpic_srch;
-
- sBltVP.rcSubPicSource[j].left = surface_subpic->subpic_srcx;
- sBltVP.rcSubpicSource[j].right = surface_subpic->subpic_srcx + surface_subpic->subpic_srcw;
- sBltVP.rcSubpicSource[j].top = surface_subpic->subpic_srcy;
- sBltVP.rcSubpicSource[j].bottom = surface_subpic->subpic_srcy + surface_subpic->subpic_srch;
-
- sBltVP.rcSubpicDest[j].left = surface_subpic->subpic_dstx;
- sBltVP.rcSubpicDest[j].right = surface_subpic->subpic_dstx + surface_subpic->subpic_dstw;
- sBltVP.rcSubpicDest[j].top = surface_subpic->subpic_dsty;
- sBltVP.rcSubpicDest[j].bottom = surface_subpic->subpic_dsty + surface_subpic->subpic_desth;
-
- //only allocate memory once for palette
- if ((surface_subpic->fourcc == MAKEFOURCC('A', 'I' , '4', '4')) && !texture_priv->pal_meminfo[j]) {
- ePVR2DStatus = PVR2DMemAlloc(texture_priv->hPVR2DContext, 16 * sizeof(unsigned int), &texture_priv->pal_meminfo[j]);
- if (ePVR2DStatus!= PVR2D_OK) {
- psb__error_message("%s: PVR2DMemAlloc error %d\n", __FUNCTION__, ePVR2DStatus);
- return;
+ ePVR2DStatus = PVR2DMemWrap(texture_priv->hPVR2DContext,
+ tmp_subpic_buffer,
+ 0,
+ (surface_subpic->subpic_srcw * surface_subpic->subpic_srch * 4),
+ NULL,
+ &pVaVideoSubpicMemInfo[i]);
+ if (ePVR2DStatus!= PVR2D_OK)
+ psb__error_message("%s: PVR2DMemWrap subpic error %d\n", __FUNCTION__, ePVR2DStatus);
+
+ sBltVP.uiNumLayers += 1;
+
+ float h_ratio, v_ratio;
+ if (src_w > dst_w) {
+ h_ratio = (float)src_w / dst_w;
+ surface_subpic->subpic_dstx /= h_ratio;
+ surface_subpic->subpic_dstw /= h_ratio;
+ } else if (src_w < dst_w) {
+ h_ratio = (float)dst_w / src_w;
+ surface_subpic->subpic_dstx *= h_ratio;
+ surface_subpic->subpic_dstw *= h_ratio;
+ }
+
+ if (src_h > dst_h) {
+ v_ratio = (float)src_h / dst_h;
+ surface_subpic->subpic_dsty /= v_ratio;
+ surface_subpic->subpic_dsth /= v_ratio;
+ } else if (src_h < dst_h) {
+ v_ratio = (float)dst_h / src_h;
+ surface_subpic->subpic_dsty *= v_ratio;
+ surface_subpic->subpic_dsth *= v_ratio;
}
- sBltVP.pPalMemInfo[j] = texture_priv->pal_meminfo[j];
- tmp = sBltVP.pPalMemInfo[j]->pBase;
- memcpy(tmp, surface_subpic->palette_ptr, 16 * sizeof(unsigned int));
- sBltVP.PalOffset[j] = 0;
+ sBltVP.sSrcSubpic[i].pSurfMemInfo = pVaVideoSubpicMemInfo[i];
+ sBltVP.sSrcSubpic[i].SurfOffset = 0;
+ sBltVP.sSrcSubpic[i].Stride = surface_subpic->stride;
+ sBltVP.sSrcSubpic[i].Format = surface_subpic->fourcc;
+ sBltVP.sSrcSubpic[i].SurfWidth = surface_subpic->subpic_srcw;
+ sBltVP.sSrcSubpic[i].SurfHeight = surface_subpic->subpic_srch;
+
+ sBltVP.rcSubpicSource[i].left = surface_subpic->subpic_srcx;
+ sBltVP.rcSubpicSource[i].right = surface_subpic->subpic_srcx + surface_subpic->subpic_srcw;
+ sBltVP.rcSubpicSource[i].top = surface_subpic->subpic_srcy;
+ sBltVP.rcSubpicSource[i].bottom = surface_subpic->subpic_srcy + surface_subpic->subpic_srch;
+
+ sBltVP.rcSubpicDest[i].left = surface_subpic->subpic_dstx;
+ sBltVP.rcSubpicDest[i].right = surface_subpic->subpic_dstx + surface_subpic->subpic_dstw;
+ sBltVP.rcSubpicDest[i].top = surface_subpic->subpic_dsty;
+ sBltVP.rcSubpicDest[i].bottom = surface_subpic->subpic_dsty + surface_subpic->subpic_dsth;
+
+ //only allocate memory once for palette
+ if ((surface_subpic->fourcc == MAKEFOURCC('A', 'I' , '4', '4')) && !texture_priv->pal_meminfo[i]) {
+ ePVR2DStatus = PVR2DMemAlloc(texture_priv->hPVR2DContext, 16 * sizeof(unsigned int), 0, 0, &texture_priv->pal_meminfo[i]);
+ if (ePVR2DStatus!= PVR2D_OK) {
+ psb__error_message("%s: PVR2DMemAlloc error %d\n", __FUNCTION__, ePVR2DStatus);
+ return;
+ }
+
+ sBltVP.pPalMemInfo[i] = texture_priv->pal_meminfo[i];
+ tmp_palette = sBltVP.pPalMemInfo[i]->pBase;
+ memcpy(tmp_palette, surface_subpic->palette_ptr, 16 * sizeof(unsigned int));
+ sBltVP.PalOffset[i] = 0;
+ }
+ surface_subpic = surface_subpic->next;
}
- surface_subpic = surface_subpic->next;
}
-#endif
ePVR2DStatus = PVR2DBltVideo(texture_priv->hPVR2DContext, &sBltVP);
if (ePVR2DStatus != PVR2D_OK)
@@ -495,14 +539,17 @@ void psb_putsurface_textureblit(
{
psb__error_message("%s: PVR2DMemFree error %d\n", __FUNCTION__, ePVR2DStatus);
}
-#ifdef SUBPIC
+
+ surface_subpic = (PsbVASurfaceRec *)obj_surface->subpictures;
for (i = 0; i < obj_surface->subpic_count; i++) {
- ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, pVaVideoSubpicMemInfo[j]);
+ ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, pVaVideoSubpicMemInfo[i]);
if (ePVR2DStatus!= PVR2D_OK)
psb__error_message("%s: PVR2DMemFree error %d\n", __FUNCTION__, ePVR2DStatus);
+
+ wsbmBOUnmap(surface_subpic->bo);
+ surface_subpic = surface_subpic->next;
}
- wsbmBOUnmap(surface_subpic->bo);
-#endif
+
#ifdef ANDROID
ePVR2DStatus = PVR2DMemFree(texture_priv->hPVR2DContext, pDstMeminfo);
if (ePVR2DStatus!= PVR2D_OK)