diff options
-rw-r--r-- | src/Android.mk | 26 | ||||
-rwxr-xr-x | src/android/psb_android_glue.cpp | 14 | ||||
-rw-r--r-- | src/android/psb_surface_gralloc.c | 106 | ||||
-rwxr-xr-x | src/pnw_H264.c | 215 | ||||
-rwxr-xr-x | src/psb_drv_video.c | 195 | ||||
-rwxr-xr-x | src/psb_drv_video.h | 21 | ||||
-rw-r--r-- | src/psb_surface.c | 2 | ||||
-rw-r--r-- | src/psb_surface.h | 3 | ||||
-rw-r--r-- | src/psb_surface_attrib.c | 6 | ||||
-rw-r--r-- | src/vsp_VPP.c | 111 | ||||
-rw-r--r-- | src/vsp_cmdbuf.c | 102 | ||||
-rw-r--r-- | src/vsp_compose.c | 6 | ||||
-rw-r--r-- | src/vsp_vp8.c | 34 |
13 files changed, 518 insertions, 323 deletions
diff --git a/src/Android.mk b/src/Android.mk index 3ec4397..5cbe6b5 100644 --- a/src/Android.mk +++ b/src/Android.mk @@ -44,7 +44,6 @@ LOCAL_CFLAGS := \ LOCAL_C_INCLUDES := \ $(call include-path-for, libhardware)/hardware \ - $(call include-path-for, frameworks-base) \ $(TARGET_OUT_HEADERS)/libva \ $(TARGET_OUT_HEADERS)/libttm \ $(TARGET_OUT_HEADERS)/libwsbm \ @@ -54,7 +53,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/hwdefs LOCAL_SHARED_LIBRARIES += libdl libdrm libwsbm libcutils \ - libui libutils libbinder libhardware liblog + libutils libbinder libhardware liblog LOCAL_SRC_FILES := \ object_heap.c \ @@ -105,12 +104,27 @@ LOCAL_SRC_FILES += \ tng_jpegES.c \ tng_slotorder.c \ tng_hostair.c \ - tng_trace.c \ + tng_trace.c + +ifeq ($(TARGET_HAS_ISV),true) +LOCAL_SRC_FILES += \ vsp_VPP.c \ - vsp_vp8.c \ vsp_cmdbuf.c \ - vsp_compose.c \ + vsp_vp8.c \ + vsp_compose.c + +LOCAL_CFLAGS += \ + -DPSBVIDEO_MRFL_VPP \ + -DPSBVIDEO_VPP_TILING +endif +ifeq ($(TARGET_HAS_VPP),true) +LOCAL_SRC_FILES += \ + vsp_VPP.c \ + vsp_vp8.c \ + vsp_cmdbuf.c \ + vsp_compose.c +endif ifeq ($(TARGET_HAS_VPP),true) LOCAL_C_INCLUDES += \ @@ -123,7 +137,6 @@ LOCAL_SHARED_LIBRARIES += libvpp_setting LOCAL_CFLAGS += DPSBVIDEO_MRFL_VPP_SETTING endif - ifeq ($(TARGET_HAS_VPP),true) LOCAL_CFLAGS += \ -DPSBVIDEO_MRFL_VPP -DPSBVIDEO_MRFL \ @@ -153,6 +166,7 @@ LOCAL_CFLAGS += -DTARGET_HAS_MULTIPLE_DISPLAY LOCAL_SHARED_LIBRARIES += libmultidisplay endif LOCAL_CFLAGS += -Werror + LOCAL_MODULE_TAGS := optional LOCAL_MODULE := pvr_drv_video diff --git a/src/android/psb_android_glue.cpp b/src/android/psb_android_glue.cpp index 9d5b88e..0ac3f27 100755 --- a/src/android/psb_android_glue.cpp +++ b/src/android/psb_android_glue.cpp @@ -44,9 +44,6 @@ #ifdef TARGET_HAS_MULTIPLE_DISPLAY #include "psb_mds.h" #endif -#if defined (PSBVIDEO_MRFL_VPP_SETTING) && !defined (TARGET_HAS_MULTIPLE_DISPLAY) -#include <VPPSetting.h> -#endif #ifdef LOG_TAG #undef LOG_TAG @@ -147,14 +144,11 @@ int psb_android_get_mds_vpp_state(void* output) { #else //TARGET_HAS_MULTIPLE_DISPLAY #ifdef PSBVIDEO_MRFL_VPP - +/* VPP is always enabled. It disables decoder rotate. + * TODO: remove the dependency the on libVPP. Get it form ISB configure + */ int psb_android_get_vpp_state() { -#ifdef PSBVIDEO_MRFL_VPP_SETTING - bool ret = VPPSetting::isVppOn(); - return (ret ? 1 : 0); -#else - return 0; -#endif + return 1; } #endif diff --git a/src/android/psb_surface_gralloc.c b/src/android/psb_surface_gralloc.c index 4093dbb..ff7699b 100644 --- a/src/android/psb_surface_gralloc.c +++ b/src/android/psb_surface_gralloc.c @@ -43,6 +43,9 @@ #define CONTEXT(id) ((object_context_p) object_heap_lookup( &driver_data->context_heap, id )) #define SURFACE(id) ((object_surface_p) object_heap_lookup( &driver_data->surface_heap, id )) #define BUFFER(id) ((object_buffer_p) object_heap_lookup( &driver_data->buffer_heap, id )) +#define SHARE_INFO_INIT_VALUE 0x12345678 + +static pthread_mutex_t gralloc_mutex = PTHREAD_MUTEX_INITIALIZER; /*FIXME: include hal_public.h instead of define it here*/ enum { @@ -62,6 +65,7 @@ VAStatus psb_DestroySurfaceGralloc(object_surface_p obj_surface) usage |= GRALLOC_USAGE_SW_WRITE_OFTEN; #endif + pthread_mutex_lock(&gralloc_mutex); if (!gralloc_lock(handle, usage, 0, 0, obj_surface->width, obj_surface->height, (void **)&vaddr[GRALLOC_SUB_BUFFER0])){ if (obj_surface->share_info && vaddr[GRALLOC_SUB_BUFFER1] == obj_surface->share_info) { @@ -79,6 +83,7 @@ VAStatus psb_DestroySurfaceGralloc(object_surface_p obj_surface) } gralloc_unlock(handle); } + pthread_mutex_unlock(&gralloc_mutex); return VA_STATUS_SUCCESS; } @@ -190,6 +195,7 @@ VAStatus psb_CreateSurfacesFromGralloc( usage |= GRALLOC_USAGE_HW_VIDEO_ENCODER; handle = (unsigned long)external_buffers->buffers[i]; + pthread_mutex_lock(&gralloc_mutex); if (gralloc_lock(handle, usage, 0, 0, width, height, (void **)&vaddr)) { vaStatus = VA_STATUS_ERROR_UNKNOWN; } else { @@ -203,6 +209,7 @@ VAStatus psb_CreateSurfacesFromGralloc( obj_surface->share_info = NULL; gralloc_unlock(handle); } + pthread_mutex_unlock(&gralloc_mutex); if (VA_STATUS_SUCCESS != vaStatus) { free(psb_surface); @@ -256,6 +263,7 @@ VAStatus psb_CreateSurfacesFromGralloc( unsigned long handle; int size = num_surfaces * sizeof(unsigned int); void *vaddr[GRALLOC_SUB_BUFFER_MAX]; + unsigned char * surface_data = NULL; /* follow are gralloc-buffers */ @@ -270,7 +278,7 @@ VAStatus psb_CreateSurfacesFromGralloc( /* We only support one format */ if ((VA_RT_FORMAT_YUV420 != format) && (VA_RT_FORMAT_YUV422 != format) - && (VA_RT_FORMAT_RGB32 != format)) { + && (VA_RT_FORMAT_RGB32 != format)) { vaStatus = VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; DEBUG_FAILURE; return vaStatus; @@ -293,7 +301,7 @@ VAStatus psb_CreateSurfacesFromGralloc( /* get native window from the reserved field */ driver_data->native_window = (void *)external_buffers->reserved[0]; - + for (i = 0; i < num_surfaces; i++) { int surfaceID; object_surface_p obj_surface; @@ -332,7 +340,7 @@ VAStatus psb_CreateSurfacesFromGralloc( case VA_RT_FORMAT_YUV422: fourcc = VA_FOURCC_YV16; break; - case VA_RT_FORMAT_RGB32: + case VA_RT_FORMAT_RGB32: fourcc = VA_FOURCC_RGBA; break; case VA_RT_FORMAT_YUV420: @@ -356,6 +364,7 @@ VAStatus psb_CreateSurfacesFromGralloc( } handle = (unsigned long)external_buffers->buffers[i]; + pthread_mutex_lock(&gralloc_mutex); if (gralloc_lock((buffer_handle_t)handle, usage, 0, 0, width, height, (void **)&vaddr[GRALLOC_SUB_BUFFER0])) { vaStatus = VA_STATUS_ERROR_UNKNOWN; } else { @@ -371,53 +380,72 @@ VAStatus psb_CreateSurfacesFromGralloc( if ((gfx_colorformat != HAL_PIXEL_FORMAT_NV12) && (gfx_colorformat != HAL_PIXEL_FORMAT_YV12) && - (format != VA_RT_FORMAT_RGB32)) { + (format != VA_RT_FORMAT_RGB32)) { + + unsigned int decoder_share_info = (unsigned int)external_buffers->reserved[2]; + drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s : Create graphic buffer initialized share info %d",__FUNCTION__, decoder_share_info); obj_surface->share_info = (psb_surface_share_info_t *)vaddr[GRALLOC_SUB_BUFFER1]; - memset(obj_surface->share_info, 0, sizeof(struct psb_surface_share_info_s)); - // Set clear video the default output method as OUTPUT_FORCE_OVERLAY_FOR_SW_DECODE - // if the video can be decoded by HW, will reset the output method as 0 in psb_BeginPicture - obj_surface->share_info->force_output_method = protected ? OUTPUT_FORCE_OVERLAY : OUTPUT_FORCE_OVERLAY_FOR_SW_DECODE; + + if (obj_surface->share_info->initialized != SHARE_INFO_INIT_VALUE) { + memset(obj_surface->share_info, 0, sizeof(struct psb_surface_share_info_s)); + // Set clear video the default output method as OUTPUT_FORCE_OVERLAY_FOR_SW_DECODE + // if the video can be decoded by HW, will reset the output method as 0 in psb_BeginPicture #ifdef PSBVIDEO_MSVDX_DEC_TILING - obj_surface->share_info->tiling = external_buffers->tiling; + obj_surface->share_info->tiling = external_buffers->tiling; #endif - obj_surface->share_info->width = obj_surface->width; - obj_surface->share_info->height = obj_surface->height_origin; - - obj_surface->share_info->luma_stride = psb_surface->stride; - obj_surface->share_info->chroma_u_stride = psb_surface->stride; - obj_surface->share_info->chroma_v_stride = psb_surface->stride; - obj_surface->share_info->format = VA_FOURCC_NV12; - - obj_surface->share_info->khandle = (uint32_t)(wsbmKBufHandle(wsbmKBuf(psb_surface->buf.drm_buf))); + obj_surface->share_info->width = obj_surface->width; + obj_surface->share_info->height = obj_surface->height_origin; - obj_surface->share_info->renderStatus = 0; - obj_surface->share_info->used_by_widi = 0; - obj_surface->share_info->native_window = (void *)external_buffers->reserved[0]; + obj_surface->share_info->luma_stride = psb_surface->stride; + obj_surface->share_info->chroma_u_stride = psb_surface->stride; + obj_surface->share_info->chroma_v_stride = psb_surface->stride; + obj_surface->share_info->format = VA_FOURCC_NV12; - attribute_tpi->reserved[1] = (unsigned long)obj_surface->share_info; + obj_surface->share_info->khandle = (uint32_t)(wsbmKBufHandle(wsbmKBuf(psb_surface->buf.drm_buf))); - obj_surface->share_info->surface_protected = driver_data->protected; - if (driver_data->render_rect.width == 0 || driver_data->render_rect.height == 0) { - obj_surface->share_info->crop_width = obj_surface->share_info->width; - obj_surface->share_info->crop_height = obj_surface->share_info->height; - } else { - obj_surface->share_info->crop_width = driver_data->render_rect.width; - obj_surface->share_info->crop_height = driver_data->render_rect.height; + obj_surface->share_info->initialized = SHARE_INFO_INIT_VALUE; } - if (obj_surface->share_info->coded_width == 0 || obj_surface->share_info->coded_height == 0) { - obj_surface->share_info->coded_width = (obj_surface->share_info->width + 0xf) & ~0xf; - obj_surface->share_info->coded_height = (obj_surface->share_info->height + 0xf) & ~0xf; + if (decoder_share_info) { + obj_surface->share_info->force_output_method = protected ? OUTPUT_FORCE_OVERLAY : OUTPUT_FORCE_OVERLAY_FOR_SW_DECODE; + obj_surface->share_info->native_window = (void *)external_buffers->reserved[0]; + + attribute_tpi->reserved[1] = (unsigned long)obj_surface->share_info; + + obj_surface->share_info->surface_protected = driver_data->protected; + if (driver_data->render_rect.width == 0 || driver_data->render_rect.height == 0) { + obj_surface->share_info->crop_width = obj_surface->share_info->width; + obj_surface->share_info->crop_height = obj_surface->share_info->height; + } else { + obj_surface->share_info->crop_width = driver_data->render_rect.width; + obj_surface->share_info->crop_height = driver_data->render_rect.height; + } + + if (obj_surface->share_info->coded_width == 0 || obj_surface->share_info->coded_height == 0) { + obj_surface->share_info->coded_width = (obj_surface->share_info->width + 0xf) & ~0xf; + obj_surface->share_info->coded_height = (obj_surface->share_info->height + 0xf) & ~0xf; + } + + drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s : Create graphic buffer success" + "surface_id= 0x%x, vaddr[0] (0x%x), vaddr[1] (0x%x)\n", + __FUNCTION__, surfaceID, vaddr[GRALLOC_SUB_BUFFER0], vaddr[GRALLOC_SUB_BUFFER1]); } - - drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s : Create graphic buffer success" - "surface_id= 0x%x, vaddr[0] (0x%x), vaddr[1] (0x%x)\n", - __FUNCTION__, surfaceID, vaddr[GRALLOC_SUB_BUFFER0], vaddr[GRALLOC_SUB_BUFFER1]); } gralloc_unlock((buffer_handle_t)handle); psb_surface->buf.user_ptr = NULL; + + if (psb_buffer_map(&psb_surface->buf, &surface_data)) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "Failed to map rotation buffer before clear it"); + } + else { + size = psb_surface->chroma_offset; + memset(surface_data, 0, size); + memset(surface_data + size, 0x80, psb_surface->size - size); + psb_buffer_unmap(&psb_surface->buf); + } } - + pthread_mutex_unlock(&gralloc_mutex); + if (VA_STATUS_SUCCESS != vaStatus) { free(psb_surface); object_heap_free(&driver_data->surface_heap, (object_base_p) obj_surface); @@ -429,6 +457,8 @@ VAStatus psb_CreateSurfacesFromGralloc( buffer_stride = psb_surface->stride; /* by default, surface fourcc is NV12 */ psb_surface->extra_info[4] = fourcc; + /* save the pixel format set by application */ + psb_surface->extra_info[8] = external_buffers->pixel_format; #ifdef PSBVIDEO_MSVDX_DEC_TILING psb_surface->extra_info[7] = external_buffers->tiling; #endif @@ -444,7 +474,7 @@ VAStatus psb_CreateSurfacesFromGralloc( surface_list[i] = VA_INVALID_SURFACE; } drv_debug_msg(VIDEO_DEBUG_ERROR, "CreateSurfaces failed\n"); - + return vaStatus; } diff --git a/src/pnw_H264.c b/src/pnw_H264.c index 88460a2..bd762c5 100755 --- a/src/pnw_H264.c +++ b/src/pnw_H264.c @@ -49,6 +49,8 @@ #include <stdint.h> #include <string.h> +#include <wsbm/wsbm_manager.h> + #define BUFFER(id) ((object_buffer_p) object_heap_lookup( &ctx->obj_context->driver_data->buffer_heap, id )) #define GET_SURFACE_INFO_is_used(psb_surface) ((int) (psb_surface->extra_info[0])) @@ -187,6 +189,11 @@ struct context_H264_s { /* Reference Cache */ struct psb_buffer_s reference_cache; + + /* map picture_id to dpbidx consistently between pictures */ + uint32_t map_dpbidx_to_picture_id[16]; + uint32_t map_dpbidx_to_refidx[16]; + }; typedef struct context_H264_s *context_H264_p; @@ -403,6 +410,7 @@ static VAStatus pnw_H264_CreateContext( { VAStatus vaStatus = VA_STATUS_SUCCESS; context_H264_p ctx; + int i = 0; /* Validate flag */ /* Validate picture dimensions */ //vaStatus = psb__H264_check_legal_picture(obj_context, obj_config); @@ -420,6 +428,10 @@ static VAStatus pnw_H264_CreateContext( ctx->dec_ctx.end_slice = psb__H264_end_slice; ctx->dec_ctx.process_buffer = pnw_H264_process_buffer; + for(i = 0; i < 16; i++) { + ctx->map_dpbidx_to_picture_id[i] = VA_INVALID_SURFACE; + } + switch (obj_config->profile) { case VAProfileH264Baseline: ctx->profile = H264_BASELINE_PROFILE; @@ -612,7 +624,7 @@ static VAStatus psb__H264_process_picture_param(context_H264_p ctx, object_buffe ctx->picture_size_map_units = ctx->picture_width_mb * ctx->picture_height_map_units;/* (7-14) */ pic_params->seq_fields.bits.mb_adaptive_frame_field_flag = (pic_params->seq_fields.bits.mb_adaptive_frame_field_flag && - !pic_params->pic_fields.bits.field_pic_flag); + !pic_params->pic_fields.bits.field_pic_flag); /* record just what type of picture we are */ if (pic_params->pic_fields.bits.field_pic_flag) { if (pic_params->CurrPic.flags & VA_PICTURE_H264_BOTTOM_FIELD) { @@ -628,18 +640,91 @@ static VAStatus psb__H264_process_picture_param(context_H264_p ctx, object_buffe } uint32_t i; + uint32_t dpbidx; + uint32_t num_new_pics = 0; + uint32_t new_pic_ids[16]; + uint32_t dpbidx_used_this_pic_flags = 0; ctx->long_term_frame_flags = 0; - /* We go from high to low so that we are left with the lowest index */ - for (i = pic_params->num_ref_frames; i--;) { + + if (pic_params->num_ref_frames > 16) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%s:%d Too many ref frames %d",__FILE__, __LINE__,pic_params->num_ref_frames); + // error here + pic_params->num_ref_frames = 16; + } + /* find new reference picture */ + for (i = 0; i < pic_params->num_ref_frames; i++) { if (pic_params->ReferenceFrames[i].flags == VA_PICTURE_H264_INVALID) { + // warning here continue; } - object_surface_p ref_surface = SURFACE(pic_params->ReferenceFrames[i].picture_id); - if (pic_params->ReferenceFrames[i].flags & VA_PICTURE_H264_BOTTOM_FIELD) { - ctx->long_term_frame_flags |= 0x01 << i; + for (dpbidx = 0; dpbidx < 16; dpbidx++) { + if (ctx->map_dpbidx_to_picture_id[dpbidx] == pic_params->ReferenceFrames[i].picture_id) { + dpbidx_used_this_pic_flags |= (0x1 << dpbidx); + break; + } + } + if (16 == dpbidx) { + new_pic_ids[num_new_pics] = pic_params->ReferenceFrames[i].picture_id; + num_new_pics++; } + } + + /* invalidate unused dpb entries */ + for (i = 0; i < 16; i++) { + if (!(dpbidx_used_this_pic_flags & (1 << i))) { + ctx->map_dpbidx_to_picture_id[i] = VA_INVALID_SURFACE; + } + } + + /* find an empty dpb location for new entries */ + dpbidx = 0; + for (i = 0; i < num_new_pics; i++) { + for (; dpbidx < 16; dpbidx++) { + if (VA_INVALID_SURFACE == ctx->map_dpbidx_to_picture_id[dpbidx]) { + ctx->map_dpbidx_to_picture_id[dpbidx] = new_pic_ids[i]; + break; + } + } + if (16 == dpbidx) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%s:%d No empty space for new frame %d (%08x)",__FILE__, __LINE__,i,dpbidx_used_this_pic_flags); + // error here + break; + } + } + + /* update surfaces with dpbidx */ + for (dpbidx = 0; dpbidx < 16; dpbidx++) { + if (VA_INVALID_SURFACE != ctx->map_dpbidx_to_picture_id[dpbidx]) { + object_surface_p ref_surface = SURFACE(ctx->map_dpbidx_to_picture_id[dpbidx]); + if (!ref_surface) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%s:%d No surface for refernce frame",__FILE__, __LINE__); + // error here + continue; + } + SET_SURFACE_INFO_dpb_idx(ref_surface->psb_surface, dpbidx); + } + } + + /* get the reference location and long term flag for each dpb location */ + memset(ctx->map_dpbidx_to_refidx, 0xff, sizeof(ctx->map_dpbidx_to_refidx)); + for (i = 0; i < pic_params->num_ref_frames; i++) { + if (pic_params->ReferenceFrames[i].flags == VA_PICTURE_H264_INVALID) { + continue; + } + object_surface_p ref_surface = SURFACE(pic_params->ReferenceFrames[i].picture_id); if (ref_surface) { - SET_SURFACE_INFO_dpb_idx(ref_surface->psb_surface, i); + dpbidx = GET_SURFACE_INFO_dpb_idx(ref_surface->psb_surface); + if (dpbidx < 16) { + ctx->map_dpbidx_to_refidx[dpbidx] = i; + if (pic_params->ReferenceFrames[i].flags & VA_PICTURE_H264_BOTTOM_FIELD) { + ctx->long_term_frame_flags |= 0x01 << dpbidx; + } + } + else { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%s:%d No invalid dpbidx stored with surface %d",__FILE__, __LINE__,dpbidx); + // error here + continue; + } } } @@ -854,8 +939,12 @@ static VAStatus psb__H264_process_slice_header_group(context_H264_p ctx, object_ psb__suspend_buffer(driver_data, frame_obj_buffer); psb__suspend_buffer(driver_data, slice_header_obj_buffer); - if (psb_context_flush_cmdbuf(obj_context)) - drv_debug_msg(VIDEO_DEBUG_GENERAL, "psb_H264: flush parse cmdbuf error\n"); + wsbmBOWaitIdle(ctx->reference_cache.drm_buf, 0); + + if (psb_context_flush_cmdbuf(obj_context)) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "psb_H264: flush parse cmdbuf error\n"); + return VA_STATUS_ERROR_UNKNOWN; + } return vaStatus; } @@ -933,19 +1022,23 @@ static void psb__H264_build_picture_order_chunk(context_H264_p ctx) pic_params->num_ref_frames = 16; } - for (i = 0; i < pic_params->num_ref_frames; i++) { - if (pic_params->ReferenceFrames[i].flags == VA_PICTURE_H264_INVALID) { - continue; - } - reg_value = 0; - REGIO_WRITE_FIELD_LITE(reg_value, MSVDX_VEC_H264, CR_VEC_H264_BE_TOP_FOC, TOPFIELDORDERCNT, - SIGNTRUNC(pic_params->ReferenceFrames[i].TopFieldOrderCnt)); - psb_cmdbuf_rendec_write(cmdbuf, reg_value); + for (i = 0; i < 16; i++) { + uint32_t refidx = ctx->map_dpbidx_to_refidx[i]; + if (refidx < 16) { + reg_value = 0; + REGIO_WRITE_FIELD_LITE(reg_value, MSVDX_VEC_H264, CR_VEC_H264_BE_TOP_FOC, TOPFIELDORDERCNT, + SIGNTRUNC(pic_params->ReferenceFrames[refidx].TopFieldOrderCnt)); + psb_cmdbuf_rendec_write(cmdbuf, reg_value); - reg_value = 0; - REGIO_WRITE_FIELD_LITE(reg_value, MSVDX_VEC_H264, CR_VEC_H264_BE_BOT_FOC, BOTTOMFIELDORDERCNT, - SIGNTRUNC(pic_params->ReferenceFrames[i].BottomFieldOrderCnt)); - psb_cmdbuf_rendec_write(cmdbuf, reg_value); + reg_value = 0; + REGIO_WRITE_FIELD_LITE(reg_value, MSVDX_VEC_H264, CR_VEC_H264_BE_BOT_FOC, BOTTOMFIELDORDERCNT, + SIGNTRUNC(pic_params->ReferenceFrames[refidx].BottomFieldOrderCnt)); + psb_cmdbuf_rendec_write(cmdbuf, reg_value); + } + else { + psb_cmdbuf_rendec_write(cmdbuf, 0); + psb_cmdbuf_rendec_write(cmdbuf, 0); + } } psb_cmdbuf_rendec_end(cmdbuf); @@ -1189,56 +1282,22 @@ static void psb__H264_build_rendec_params(context_H264_p ctx, VASliceParameterBu /* send DPB information (for P and B slices?) only needed once per frame */ // if ( sh->slice_type == ST_B || sh->slice_type == ST_P ) if (pic_params->num_ref_frames > 0 && (slice_param->slice_type == ST_B || slice_param->slice_type == ST_P)) { - IMG_BOOL is_used[16]; psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES)); - /* Mark all surfaces as unused */ - memset(is_used, 0, sizeof(is_used)); - - if (slice_param->num_ref_idx_l0_active_minus1 > 31) - slice_param->num_ref_idx_l0_active_minus1 = 31; - /* Mark onlys frame that are actualy used */ - for (i = 0; i <= slice_param->num_ref_idx_l0_active_minus1; i++) { - object_surface_p ref_surface = SURFACE(slice_param->RefPicList0[i].picture_id); - if (ref_surface) { - uint32_t idx = GET_SURFACE_INFO_dpb_idx(ref_surface->psb_surface); - if (idx < 16) { - is_used[idx] = IMG_TRUE; - } - } - } - - if (slice_param->num_ref_idx_l1_active_minus1 > 31) - slice_param->num_ref_idx_l1_active_minus1 = 31; - - /* Mark onlys frame that are actualy used */ - for (i = 0; i <= slice_param->num_ref_idx_l1_active_minus1; i++) { - object_surface_p ref_surface = SURFACE(slice_param->RefPicList1[i].picture_id); - if (ref_surface) { - uint32_t idx = GET_SURFACE_INFO_dpb_idx(ref_surface->psb_surface); - if (idx < 16) { - is_used[idx] = IMG_TRUE; - } - } - } - - if (pic_params->num_ref_frames > 16) - pic_params->num_ref_frames = 16; + uint32_t dpbidx = 0; + for (dpbidx = 0; dpbidx < 16; dpbidx++) { /* Only load used surfaces */ - for (i = 0; i < pic_params->num_ref_frames; i++) { - if (pic_params->ReferenceFrames[i].flags == VA_PICTURE_H264_INVALID) { - continue; - } - object_surface_p ref_surface = SURFACE(pic_params->ReferenceFrames[i].picture_id); - psb_buffer_p buffer; - - if (NULL == ref_surface) { - drv_debug_msg(VIDEO_DEBUG_ERROR, "%s L%d Invalide reference surface handle\n", - __FUNCTION__, __LINE__); - return; - } + if (VA_INVALID_SURFACE != ctx->map_dpbidx_to_picture_id[dpbidx]) { + object_surface_p ref_surface = SURFACE(ctx->map_dpbidx_to_picture_id[dpbidx]); + psb_buffer_p buffer; + + if (NULL == ref_surface) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%s L%d Invalide reference surface handle\n", + __FUNCTION__, __LINE__); + return; + } - buffer = ref_surface->psb_surface->ref_buf; + buffer = ref_surface->psb_surface->ref_buf; /* drv_debug_msg(VIDEO_DEBUG_GENERAL, "pic_params->ReferenceFrames[%d] = %08x --> %08x frame_idx:0x%08x flags:%02x TopFieldOrderCnt: 0x%08x BottomFieldOrderCnt: 0x%08x %s\n", i, @@ -1250,15 +1309,19 @@ static void psb__H264_build_rendec_params(context_H264_p ctx, VASliceParameterBu pic_params->ReferenceFrames[i].BottomFieldOrderCnt, is_used[i] ? "used" : ""); */ - if (ref_surface && is_used[i] && buffer) - // GET_SURFACE_INFO_is_used(ref_surface->psb_surface)) - { - psb_cmdbuf_rendec_write_address(cmdbuf, buffer, - buffer->buffer_ofs); - psb_cmdbuf_rendec_write_address(cmdbuf, buffer, - buffer->buffer_ofs + - ref_surface->psb_surface->chroma_offset); - buffer->unfence_flag = 1; + if (ref_surface && buffer) { + psb_cmdbuf_rendec_write_address(cmdbuf, buffer, + buffer->buffer_ofs); + psb_cmdbuf_rendec_write_address(cmdbuf, buffer, + buffer->buffer_ofs + + ref_surface->psb_surface->chroma_offset); + buffer->unfence_flag = 1; + } else { + // error here + drv_debug_msg(VIDEO_DEBUG_ERROR, "%s:%d No valid buffer for DPB",__FILE__, __LINE__); + psb_cmdbuf_rendec_write(cmdbuf, 0xdeadbeef); + psb_cmdbuf_rendec_write(cmdbuf, 0xdeadbeef); + } } else { psb_cmdbuf_rendec_write(cmdbuf, 0xdeadbeef); psb_cmdbuf_rendec_write(cmdbuf, 0xdeadbeef); diff --git a/src/psb_drv_video.c b/src/psb_drv_video.c index f261daa..930f208 100755 --- a/src/psb_drv_video.c +++ b/src/psb_drv_video.c @@ -217,10 +217,10 @@ VAStatus psb_QueryConfigEntrypoints( i == VAEntrypointVideoProc) { entrypoints++; *entrypoint_list++ = i; - } else + } else #endif #endif - if (profile != VAProfileNone && driver_data->profile2Format[profile][i]) { + if (profile != VAProfileNone && driver_data->profile2Format[profile][i]) { entrypoints++; *entrypoint_list++ = i; } @@ -440,26 +440,26 @@ VAStatus psb_CreateConfig( CHECK_VASTATUS(); if ((IS_MFLD(driver_data)) && - ((VAEntrypointEncPicture == entrypoint) - || (VAEntrypointEncSlice == entrypoint))) { - int active_slc, active_pic; + ((VAEntrypointEncPicture == entrypoint) + || (VAEntrypointEncSlice == entrypoint))) { + int active_slc, active_pic; /* Only allow one encoding entrypoint at the sametime. - * But if video encoding request comes when process JPEG encoding, - * it will wait until current JPEG picture encoding finish. - * Further JPEG encoding should fall back to software path.*/ - active_slc = psb_get_active_entrypoint_number(ctx, VAEntrypointEncSlice); - active_pic = psb_get_active_entrypoint_number(ctx, VAEntrypointEncPicture); - - if (active_slc > 0) { - drv_debug_msg(VIDEO_DEBUG_ERROR, "There already is a active video encoding entrypoint." - "Entrypoint %d isn't available.\n", entrypoint); - return VA_STATUS_ERROR_HW_BUSY; - } - else if (active_pic > 0 && VAEntrypointEncPicture == entrypoint) { - drv_debug_msg(VIDEO_DEBUG_ERROR, "There already is a active picture encoding entrypoint." - "Entrypoint %d isn't available.\n", entrypoint); - return VA_STATUS_ERROR_HW_BUSY; - } + * But if video encoding request comes when process JPEG encoding, + * it will wait until current JPEG picture encoding finish. + * Further JPEG encoding should fall back to software path.*/ + active_slc = psb_get_active_entrypoint_number(ctx, VAEntrypointEncSlice); + active_pic = psb_get_active_entrypoint_number(ctx, VAEntrypointEncPicture); + + if (active_slc > 0) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "There already is a active video encoding entrypoint." + "Entrypoint %d isn't available.\n", entrypoint); + return VA_STATUS_ERROR_HW_BUSY; + } + else if (active_pic > 0 && VAEntrypointEncPicture == entrypoint) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "There already is a active picture encoding entrypoint." + "Entrypoint %d isn't available.\n", entrypoint); + return VA_STATUS_ERROR_HW_BUSY; + } } configID = object_heap_allocate(&driver_data->config_heap); @@ -510,11 +510,11 @@ VAStatus psb_CreateConfig( } if (profile == VAProfileVP8Version0_3 || - profile == VAProfileH264Baseline || - profile == VAProfileH264Main || - profile == VAProfileH264High || - profile == VAProfileH264ConstrainedBaseline) - driver_data->ec_enabled = 1; + profile == VAProfileH264Baseline || + profile == VAProfileH264Main || + profile == VAProfileH264High || + profile == VAProfileH264ConstrainedBaseline) + driver_data->ec_enabled = 1; if (!IS_MRFL(driver_data)) { if (profile == VAProfileMPEG4Simple || @@ -589,9 +589,9 @@ void psb__destroy_surface(psb_driver_data_p driver_data, object_surface_p obj_su /* delete subpicture association */ psb_SurfaceDeassociateSubpict(driver_data, obj_surface); - obj_surface->is_ref_surface = 0; + obj_surface->is_ref_surface = 0; - psb_surface_sync(obj_surface->psb_surface); + psb_surface_sync(obj_surface->psb_surface); psb_surface_destroy(obj_surface->psb_surface); if (obj_surface->out_loop_surface) { @@ -701,6 +701,7 @@ VAStatus psb_CreateSurfaces2( unsigned long fourcc; unsigned int flags = 0; int memory_type = -1; + unsigned int initalized_info_flag = 1; VASurfaceAttribExternalBuffers *pExternalBufDesc = NULL; PsbSurfaceAttributeTPI attribute_tpi; @@ -767,6 +768,19 @@ VAStatus psb_CreateSurfaces2( } } break; + case VASurfaceAttribUsageHint: + { + /* Share info is to be initialized when created sufaces by default (for the data producer) + * VPP Read indicate we do not NOT touch share info (for data consumer, which share buffer with data + * producer, such as of VPP). + */ + drv_debug_msg(VIDEO_DEBUG_GENERAL, "VASurfaceAttribUsageHint.\n"); + if ((attrib_list->value.value.i & VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ)!= 0){ + initalized_info_flag = 0; + drv_debug_msg(VIDEO_DEBUG_GENERAL, "explicat not initialized share info.\n"); + } + } + break; default: drv_debug_msg(VIDEO_DEBUG_ERROR, "Unsupported attribute.\n"); return VA_STATUS_ERROR_INVALID_PARAMETER; @@ -780,6 +794,8 @@ VAStatus psb_CreateSurfaces2( } else if(memory_type !=-1 && pExternalBufDesc != NULL) { attribute_tpi.type = memory_type; + //set initialized share info in reserverd 1, by default we will initialized share_info + attribute_tpi.reserved[2] = (unsigned int)initalized_info_flag; vaStatus = psb_CreateSurfacesWithAttribute(ctx, width, height, format, num_surfaces, surface_list, (VASurfaceAttributeTPI *)&attribute_tpi); pExternalBufDesc->private_data = (void *)(attribute_tpi.reserved[1]); if (attribute_tpi.buffers) free(attribute_tpi.buffers); @@ -804,7 +820,7 @@ VAStatus psb_CreateSurfaces2( height_origin = height; height = (height + 0x1f) & ~0x1f; - + for (i = 0; i < num_surfaces; i++) { int surfaceID; object_surface_p obj_surface; @@ -865,6 +881,7 @@ VAStatus psb_CreateSurfaces2( buffer_stride = psb_surface->stride; /* by default, surface fourcc is NV12 */ psb_surface->extra_info[4] = fourcc; + psb_surface->extra_info[8] = fourcc; obj_surface->psb_surface = psb_surface; } @@ -1036,12 +1053,12 @@ VAStatus psb_CreateContext( object_config_p obj_config; int cmdbuf_num, encode = 0, proc = 0; int i; - drv_debug_msg(VIDEO_DEBUG_INIT, "CreateContext config_id:%d, pic_w:%d, pic_h:%d, flag:%d, num_render_targets:%d.\n", + drv_debug_msg(VIDEO_DEBUG_ERROR, "CreateContext config_id:%d, pic_w:%d, pic_h:%d, flag:%d, num_render_targets:%d.\n", config_id, picture_width, picture_height, flag, num_render_targets); - CHECK_INVALID_PARAM(num_render_targets <= 0); + //CHECK_INVALID_PARAM(num_render_targets <= 0); - CHECK_SURFACE(render_targets); + //CHECK_SURFACE(render_targets); CHECK_CONTEXT(context); vaStatus = psb__checkSurfaceDimensions(driver_data, picture_width, picture_height); @@ -1081,14 +1098,17 @@ VAStatus psb_CreateContext( #endif obj_context->scaling_width = 0; obj_context->scaling_height = 0; - obj_context->render_targets = (VASurfaceID *) calloc(1, num_render_targets * sizeof(VASurfaceID)); - if (obj_context->render_targets == NULL) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - DEBUG_FAILURE; - object_heap_free(&driver_data->context_heap, (object_base_p) obj_context); + if (num_render_targets > 0) { + obj_context->render_targets = (VASurfaceID *) calloc(1, num_render_targets * sizeof(VASurfaceID)); + if (obj_context->render_targets == NULL) { + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; + DEBUG_FAILURE; - return vaStatus; + object_heap_free(&driver_data->context_heap, (object_base_p) obj_context); + + return vaStatus; + } } /* allocate buffer points for vaRenderPicture */ @@ -1098,7 +1118,8 @@ VAStatus psb_CreateContext( vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; DEBUG_FAILURE; - free(obj_context->render_targets); + if (NULL != obj_context->render_targets) + free(obj_context->render_targets); object_heap_free(&driver_data->context_heap, (object_base_p) obj_context); return vaStatus; @@ -1131,28 +1152,29 @@ VAStatus psb_CreateContext( else cmdbuf_num = PSB_MAX_CMDBUFS; - for (i = 0; i < num_render_targets; i++) { - object_surface_p obj_surface = SURFACE(render_targets[i]); - psb_surface_p psb_surface; + if (num_render_targets > 0) { + for (i = 0; i < num_render_targets; i++) { + object_surface_p obj_surface = SURFACE(render_targets[i]); + psb_surface_p psb_surface; - if (NULL == obj_surface) { - vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; - DEBUG_FAILURE; - break; - } + if (NULL == obj_surface) { + vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; + DEBUG_FAILURE; + break; + } - if (!driver_data->protected && obj_surface->share_info) - obj_surface->share_info->force_output_method = 0; + if (!driver_data->protected && obj_surface->share_info) + obj_surface->share_info->force_output_method = 0; - psb_surface = obj_surface->psb_surface; + psb_surface = obj_surface->psb_surface; - /* Clear format specific surface info */ - obj_context->render_targets[i] = render_targets[i]; - obj_surface->context_id = contextID; /* Claim ownership of surface */ + /* Clear format specific surface info */ + obj_context->render_targets[i] = render_targets[i]; + obj_surface->context_id = contextID; /* Claim ownership of surface */ #ifdef PSBVIDEO_MSVDX_DEC_TILING - if (GET_SURFACE_INFO_tiling(psb_surface)) + if (GET_SURFACE_INFO_tiling(psb_surface)) #ifdef BAYTRAIL - obj_context->msvdx_tile = psb__tile_stride_log2_512(obj_surface->width); + obj_context->msvdx_tile = psb__tile_stride_log2_512(obj_surface->width); #else if (obj_config->entrypoint == VAEntrypointVideoProc && obj_config->profile == VAProfileNone) // It's for two pass rotation case @@ -1166,12 +1188,13 @@ VAStatus psb_CreateContext( } #endif #if 0 - /* for decode, move the surface into |TT */ - if ((encode == 0) && /* decode */ - ((psb_surface->buf.pl_flags & DRM_PSB_FLAG_MEM_RAR) == 0)) /* surface not in RAR */ - psb_buffer_setstatus(&obj_surface->psb_surface->buf, - WSBM_PL_FLAG_TT | WSBM_PL_FLAG_SHARED, DRM_PSB_FLAG_MEM_MMU); + /* for decode, move the surface into |TT */ + if ((encode == 0) && /* decode */ + ((psb_surface->buf.pl_flags & DRM_PSB_FLAG_MEM_RAR) == 0)) /* surface not in RAR */ + psb_buffer_setstatus(&obj_surface->psb_surface->buf, + WSBM_PL_FLAG_TT | WSBM_PL_FLAG_SHARED, DRM_PSB_FLAG_MEM_MMU); #endif + } } obj_context->va_flags = flag; @@ -1188,7 +1211,8 @@ VAStatus psb_CreateContext( obj_context->config_id = -1; obj_context->picture_width = 0; obj_context->picture_height = 0; - free(obj_context->render_targets); + if (NULL != obj_context->render_targets) + free(obj_context->render_targets); free(obj_context->buffer_list); obj_context->num_buffers = 0; obj_context->render_targets = NULL; @@ -1342,7 +1366,7 @@ VAStatus psb_CreateContext( free(obj_context->tng_cmdbuf_list[i]); obj_context->tng_cmdbuf_list[i] = NULL; } -#endif +#endif if (obj_context->cmdbuf_list[i]) { psb_cmdbuf_destroy(obj_context->cmdbuf_list[i]); free(obj_context->cmdbuf_list[i]); @@ -1366,14 +1390,15 @@ VAStatus psb_CreateContext( obj_context->config_id = -1; obj_context->picture_width = 0; obj_context->picture_height = 0; - free(obj_context->render_targets); + if (NULL != obj_context->render_targets) + free(obj_context->render_targets); free(obj_context->buffer_list); obj_context->num_buffers = 0; obj_context->render_targets = NULL; obj_context->num_render_targets = 0; obj_context->va_flags = 0; object_heap_free(&driver_data->context_heap, (object_base_p) obj_context); - } + } obj_context->ctp_type = (((obj_config->profile << 8) | obj_config->entrypoint | driver_data->protected) & 0xffff); @@ -2039,7 +2064,7 @@ VAStatus psb_BeginPicture( obj_context = CONTEXT(context); CHECK_CONTEXT(obj_context); - + /* Must not be within BeginPicture / EndPicture already */ ASSERT(obj_context->current_render_target == NULL); @@ -2064,7 +2089,7 @@ VAStatus psb_BeginPicture( vaStatus = obj_context->format_vtable->beginPicture(obj_context); } -#ifdef ANDROID +#ifdef ANDROID /* want msvdx to do rotate * but check per-context stream type: interlace or not */ @@ -2080,13 +2105,15 @@ VAStatus psb_BeginPicture( if (obj_context->interlaced_stream || driver_data->disable_msvdx_rotate) { int i; obj_context->msvdx_rotate = 0; - for (i = 0; i < obj_context->num_render_targets; i++) { - object_surface_p obj_surface = SURFACE(obj_context->render_targets[i]); - /*we invalidate all surfaces's rotate buffer share info here.*/ - if (obj_surface && obj_surface->share_info) { - obj_surface->share_info->surface_rotate = 0; + if (obj_context->num_render_targets > 0) { + for (i = 0; i < obj_context->num_render_targets; i++) { + object_surface_p obj_surface = SURFACE(obj_context->render_targets[i]); + /*we invalidate all surfaces's rotate buffer share info here.*/ + if (obj_surface && obj_surface->share_info) { + obj_surface->share_info->surface_rotate = 0; + } } - } + } } else obj_context->msvdx_rotate = driver_data->msvdx_rotate_want; @@ -2117,7 +2144,7 @@ VAStatus psb_BeginPicture( } } else #endif - vaStatus = psb_CreateRotateSurface(obj_context, obj_surface, obj_context->msvdx_rotate); + vaStatus = psb_CreateRotateSurface(obj_context, obj_surface, obj_context->msvdx_rotate); if (VA_STATUS_SUCCESS !=vaStatus) ALOGE("%s: fail to allocate out loop surface", __func__); @@ -2366,7 +2393,7 @@ VAStatus psb_SyncSurface( vaStatus = psb_surface_sync(obj_surface->out_loop_surface); else vaStatus = psb_surface_sync(obj_surface->psb_surface); - } else + } else #endif vaStatus = psb_surface_sync(obj_surface->psb_surface); } @@ -2553,10 +2580,10 @@ VAStatus psb_QuerySurfaceError( arg.value = (uint64_t)((unsigned long)decode_status); ret = drmCommandWriteRead(driver_data->drm_fd, driver_data->getParamIoctlOffset, &arg, sizeof(arg)); - if (ret != 0) { - drv_debug_msg(VIDEO_DEBUG_GENERAL,"return value is %d drmCommandWriteRead\n",ret); - return VA_STATUS_ERROR_UNKNOWN; - } + if (ret != 0) { + drv_debug_msg(VIDEO_DEBUG_GENERAL,"return value is %d drmCommandWriteRead\n",ret); + return VA_STATUS_ERROR_UNKNOWN; + } #ifndef _FOR_FPGA_ if (decode_status->num_region > MAX_MB_ERRORS) { drv_debug_msg(VIDEO_DEBUG_GENERAL, "too much mb errors are reported.\n"); @@ -2623,8 +2650,8 @@ VAStatus psb_QuerySurfaceAttributes(VADriverContextP ctx, if (obj_config->entrypoint == VAEntrypointEncSlice && obj_config->profile == VAProfileVP8Version0_3) { attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | - VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_GRALLOC | - VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_ION; + VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_GRALLOC | + VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_ION; } else { attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | @@ -3137,7 +3164,7 @@ EXPORT VAStatus __vaDriverInit_0_31(VADriverContextP ctx) ctx->vtable->vaCreateConfig = psb_CreateConfig; ctx->vtable->vaDestroyConfig = psb_DestroyConfig; ctx->vtable->vaGetConfigAttributes = psb_GetConfigAttributes; - ctx->vtable->vaCreateSurfaces2 = psb_CreateSurfaces2; + ctx->vtable->vaCreateSurfaces2 = psb_CreateSurfaces2; ctx->vtable->vaCreateSurfaces = psb_CreateSurfaces; ctx->vtable->vaGetSurfaceAttributes = psb_GetSurfaceAttributes; ctx->vtable->vaDestroySurfaces = psb_DestroySurfaces; @@ -3196,7 +3223,7 @@ EXPORT VAStatus __vaDriverInit_0_31(VADriverContextP ctx) tpi = (struct VADriverVTableTPI *)ctx->vtable_tpi; tpi->vaCreateSurfacesWithAttribute = psb_CreateSurfacesWithAttribute; tpi->vaPutSurfaceBuf = psb_PutSurfaceBuf; - tpi->vaSetTimestampForSurface = psb_SetTimestampForSurface; + tpi->vaSetTimestampForSurface = psb_SetTimestampForSurface; ctx->vtable_egl = calloc(1, sizeof(struct VADriverVTableEGL)); if (NULL == ctx->vtable_egl) @@ -3303,7 +3330,7 @@ EXPORT VAStatus __vaDriverInit_0_31(VADriverContextP ctx) #ifdef PSBVIDEO_VXD392 if (IS_MRFL(driver_data) || IS_BAYTRAIL(driver_data)) { drv_debug_msg(VIDEO_DEBUG_GENERAL, "merrifield VXD392 decoder\n"); - driver_data->profile2Format[VAProfileVP8Version0_3][VAEntrypointVLD] = &tng_VP8_vtable; + driver_data->profile2Format[VAProfileVP8Version0_3][VAEntrypointVLD] = &tng_VP8_vtable; driver_data->profile2Format[VAProfileJPEGBaseline][VAEntrypointVLD] = &tng_JPEG_vtable; driver_data->profile2Format[VAProfileMPEG4Simple][VAEntrypointVLD] = &pnw_MPEG4_vtable; @@ -3400,7 +3427,7 @@ EXPORT VAStatus __vaDriverInit_0_31(VADriverContextP ctx) { if (IS_LEXINGTON(driver_data)) ctx->str_vendor = PSB_STR_VENDOR_LEXINGTON; - else + else ctx->str_vendor = PSB_STR_VENDOR_MFLD; } else diff --git a/src/psb_drv_video.h b/src/psb_drv_video.h index 11c24b0..e036985 100755 --- a/src/psb_drv_video.h +++ b/src/psb_drv_video.h @@ -377,17 +377,13 @@ struct object_context_s { struct lnc_cmdbuf_s *lnc_cmdbuf_list[LNC_MAX_CMDBUFS_ENCODE]; struct pnw_cmdbuf_s *pnw_cmdbuf_list[PNW_MAX_CMDBUFS_ENCODE]; struct tng_cmdbuf_s *tng_cmdbuf_list[TNG_MAX_CMDBUFS_ENCODE]; -#ifdef PSBVIDEO_MRFL_VPP struct vsp_cmdbuf_s *vsp_cmdbuf_list[VSP_MAX_CMDBUFS]; -#endif struct psb_cmdbuf_s *cmdbuf; /* Current cmd buffer */ struct lnc_cmdbuf_s *lnc_cmdbuf; struct pnw_cmdbuf_s *pnw_cmdbuf; struct tng_cmdbuf_s *tng_cmdbuf; -#ifdef PSBVIDEO_MRFL_VPP struct vsp_cmdbuf_s *vsp_cmdbuf; -#endif int cmdbuf_current; @@ -507,6 +503,7 @@ struct psb_surface_share_info_s { unsigned int coded_width; unsigned int coded_height; + unsigned int initialized; }; struct object_surface_s { @@ -545,18 +542,18 @@ struct object_surface_s { #define SET_CODEDBUF_INFO(flag, aux_info, slice_num) \ do {\ - (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ - (aux_info) |= ((slice_num) & PSB_CODEDBUF_##flag##_MASK)\ - <<PSB_CODEDBUF_##flag##_SHIFT;\ + (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ + (aux_info) |= ((slice_num) & PSB_CODEDBUF_##flag##_MASK)\ + <<PSB_CODEDBUF_##flag##_SHIFT;\ } while (0) #define CLEAR_CODEDBUF_INFO(flag, aux_info) \ do {\ - (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ + (aux_info) &= ~(PSB_CODEDBUF_##flag##_MASK<<PSB_CODEDBUF_##flag##_SHIFT);\ } while (0) #define GET_CODEDBUF_INFO(flag, aux_info) \ - (((aux_info)>>PSB_CODEDBUF_##flag##_SHIFT) & PSB_CODEDBUF_##flag##_MASK) + (((aux_info)>>PSB_CODEDBUF_##flag##_SHIFT) & PSB_CODEDBUF_##flag##_MASK) #define PSB_CODEDBUF_SEGMENT_MAX (9) @@ -624,8 +621,8 @@ typedef struct _PsbSurfaceAttributeTPI { unsigned int count; /* buffer count for surface creation */ unsigned long *buffers; /* buffer handles or user pointers */ unsigned long reserved[4]; /* used to pass additional information, like 362 - * Android native window pointer 363 - */ + * Android native window pointer 363 + */ } PsbSurfaceAttributeTPI; #define MEMSET_OBJECT(ptr, data_struct) \ @@ -710,7 +707,7 @@ inline static char * buffer_type_to_string(int type) case VAEncMiscParameterBufferType: return "VAEncMiscParameterBufferType"; case VAProbabilityBufferType: - return "VAProbabilityBufferType"; + return "VAProbabilityBufferType"; case VAHuffmanTableBufferType: return "VAHuffmanTableBufferType"; case VAQMatrixBufferType: diff --git a/src/psb_surface.c b/src/psb_surface.c index 876ea0d..446be3e 100644 --- a/src/psb_surface.c +++ b/src/psb_surface.c @@ -183,6 +183,7 @@ VAStatus psb_surface_create_for_userptr( psb_surface->chroma_offset = chroma_u_offset; psb_surface->size = size; psb_surface->extra_info[4] = VA_FOURCC_NV12; + psb_surface->extra_info[8] = VA_FOURCC_NV12; ret = psb_buffer_create(driver_data, psb_surface->size, psb_bt_cpu_vpu_shared, &psb_surface->buf); @@ -231,6 +232,7 @@ VAStatus psb_surface_create_from_kbuf( psb_surface->chroma_offset = chroma_u_offset; psb_surface->size = size; psb_surface->extra_info[4] = VA_FOURCC_NV12; + psb_surface->extra_info[8] = VA_FOURCC_NV12; ret = psb_kbuffer_reference(driver_data, &psb_surface->buf, kbuf_handle); diff --git a/src/psb_surface.h b/src/psb_surface.h index 3eaf53d..5ed0997 100644 --- a/src/psb_surface.h +++ b/src/psb_surface.h @@ -69,8 +69,9 @@ struct psb_surface_s { * extra_info[5]: surface skippeded or not for encode, rotate info for decode * extra_info[6]: mfld protected surface * extra_info[7]: linear or tiled + * extra_info[8]: the fourcc set by application */ - int extra_info[8]; + int extra_info[9]; int size; unsigned int bc_buffer; void *handle; diff --git a/src/psb_surface_attrib.c b/src/psb_surface_attrib.c index 492891f..be236dc 100644 --- a/src/psb_surface_attrib.c +++ b/src/psb_surface_attrib.c @@ -111,6 +111,8 @@ VAStatus psb_surface_create_from_ub( psb_surface->extra_info[4] = VA_FOURCC_RGBA; } + psb_surface->extra_info[8] = psb_surface->extra_info[4]; + } else { return VA_STATUS_ERROR_ALLOCATION_FAILED; } @@ -388,6 +390,7 @@ VAStatus psb_CreateSurfacesForUserPtr( /* by default, surface fourcc is NV12 */ memset(psb_surface->extra_info, 0, sizeof(psb_surface->extra_info)); psb_surface->extra_info[4] = fourcc; + psb_surface->extra_info[8] = fourcc; #ifdef PSBVIDEO_MSVDX_DEC_TILING psb_surface->extra_info[7] = tiling; #endif @@ -525,6 +528,7 @@ VAStatus psb_CreateSurfaceFromKBuf( /* by default, surface fourcc is NV12 */ memset(psb_surface->extra_info, 0, sizeof(psb_surface->extra_info)); psb_surface->extra_info[4] = kBuf_fourcc; + psb_surface->extra_info[8] = kBuf_fourcc; #ifdef PSBVIDEO_MSVDX_DEC_TILING psb_surface->extra_info[7] = tiling; #endif @@ -617,6 +621,7 @@ VAStatus psb_CreateSurfaceFromUserspace( /* by default, surface fourcc is NV12 */ memset(psb_surface->extra_info, 0, sizeof(psb_surface->extra_info)); psb_surface->extra_info[4] = fourcc; + psb_surface->extra_info[8] = fourcc; obj_surface->psb_surface = psb_surface; /* Error recovery */ @@ -735,6 +740,7 @@ VAStatus psb_CreateSurfaceFromION( /* by default, surface fourcc is NV12 */ memset(psb_surface->extra_info, 0, sizeof(psb_surface->extra_info)); psb_surface->extra_info[4] = fourcc; + psb_surface->extra_info[8] = fourcc; obj_surface->psb_surface = psb_surface; /* Error recovery */ diff --git a/src/vsp_VPP.c b/src/vsp_VPP.c index 4e97aae..0da7aad 100644 --- a/src/vsp_VPP.c +++ b/src/vsp_VPP.c @@ -8,11 +8,11 @@ * distribute, sub license, 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 NON-INFRINGEMENT. @@ -120,7 +120,7 @@ struct filter_strength { struct VssProcColorEnhancementParameterBuffer enhancer[RESOLUTION_SET_NUM]; struct VssProcSharpenParameterBuffer sharpen[RESOLUTION_SET_NUM]; }; - + enum filter_strength_type { INVALID_STRENGTH = -1, LOW_STRENGTH = 0, @@ -401,9 +401,14 @@ static VAStatus vsp__VPP_process_pipeline_param(context_VPP_p ctx, object_contex object_surface_p input_surface = NULL; object_surface_p cur_output_surf = NULL; unsigned int rotation_angle = 0, vsp_rotation_angle = 0; - int tiled = 0, width = 0, height = 0, stride = 0; + unsigned int tiled = 0, width = 0, height = 0, stride = 0; unsigned char *src_addr, *dest_addr; struct psb_surface_s *output_surface; + psb_surface_share_info_p input_share_info = NULL; + psb_surface_share_info_p output_share_info = NULL; + enum vsp_format format; + + psb_driver_data_p driver_data = obj_context->driver_data; if (pipeline_param->surface_region != NULL) { @@ -411,13 +416,13 @@ static VAStatus vsp__VPP_process_pipeline_param(context_VPP_p ctx, object_contex vaStatus = VA_STATUS_ERROR_UNKNOWN; goto out; } - + if (pipeline_param->output_region != NULL) { drv_debug_msg(VIDEO_DEBUG_ERROR, "Cann't scale\n"); vaStatus = VA_STATUS_ERROR_UNKNOWN; goto out; } - + if (pipeline_param->output_background_color != 0) { drv_debug_msg(VIDEO_DEBUG_ERROR, "Cann't support background color here\n"); vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; @@ -538,10 +543,29 @@ static VAStatus vsp__VPP_process_pipeline_param(context_VPP_p ctx, object_contex /* get the tiling flag*/ tiled = GET_SURFACE_INFO_tiling(input_surface->psb_surface); #endif + + /* get the surface format info */ + switch (input_surface->psb_surface->extra_info[8]) { + case VA_FOURCC_YV12: + format = VSP_YV12; + break; + case VA_FOURCC_NV12: + format = VSP_NV12; + break; + default: + vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; + drv_debug_msg(VIDEO_DEBUG_ERROR, "Only support NV12 and YV12 format!\n"); + goto out; + } + /* According to VIED's design, the width must be multiple of 16 */ width = ALIGN_TO_16(input_surface->width); - if (width > (int)input_surface->psb_surface->stride) - width = (int)input_surface->psb_surface->stride; + if (width > input_surface->psb_surface->stride) + width = input_surface->psb_surface->stride; + + /* get the input share info */ + input_share_info = input_surface->share_info; + drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s The input surface %p share info %p\n", __func__, input_surface,input_surface->share_info); /* Setup input surface */ cell_proc_picture_param->num_input_pictures = 1; @@ -552,7 +576,7 @@ static VAStatus vsp__VPP_process_pipeline_param(context_VPP_p ctx, object_contex cell_proc_picture_param->input_picture[0].width = width; cell_proc_picture_param->input_picture[0].irq = 0; cell_proc_picture_param->input_picture[0].stride = input_surface->psb_surface->stride; - cell_proc_picture_param->input_picture[0].format = ctx->format; + cell_proc_picture_param->input_picture[0].format = format; cell_proc_picture_param->input_picture[0].tiled = tiled; cell_proc_picture_param->input_picture[0].rot_angle = 0; @@ -635,7 +659,7 @@ static VAStatus vsp__VPP_process_pipeline_param(context_VPP_p ctx, object_contex /* According to VIED's design, the width must be multiple of 16 */ width = ALIGN_TO_16(cur_output_surf->width); - if (width > (int)cur_output_surf->psb_surface->stride) + if (width > cur_output_surf->psb_surface->stride) width = cur_output_surf->psb_surface->stride; height = cur_output_surf->height_origin; stride = cur_output_surf->psb_surface->stride; @@ -660,9 +684,26 @@ static VAStatus vsp__VPP_process_pipeline_param(context_VPP_p ctx, object_contex cell_proc_picture_param->output_picture[i].width = width; cell_proc_picture_param->output_picture[i].stride = stride; cell_proc_picture_param->output_picture[i].irq = 1; - cell_proc_picture_param->output_picture[i].format = ctx->format; + cell_proc_picture_param->output_picture[i].format = format; cell_proc_picture_param->output_picture[i].rot_angle = vsp_rotation_angle; cell_proc_picture_param->output_picture[i].tiled = tiled; + + /* copy the input share info to output */ + output_share_info = cur_output_surf->share_info; + if (input_share_info != NULL && output_share_info != NULL) { + output_share_info->native_window = input_share_info->native_window; + output_share_info->force_output_method = input_share_info->force_output_method; + output_share_info->surface_protected = input_share_info->surface_protected; + output_share_info->bob_deinterlace = input_share_info->bob_deinterlace; + + output_share_info->crop_width = input_share_info->crop_width; + output_share_info->crop_height = input_share_info->crop_height; + output_share_info->coded_width = input_share_info->coded_width; + output_share_info->coded_height = input_share_info->coded_height; + drv_debug_msg(VIDEO_DEBUG_GENERAL, "The input/output wxh %dx%d\n",input_share_info->width,input_share_info->height); + } else { + drv_debug_msg(VIDEO_DEBUG_WARNING, "The input/output share_info is NULL!!\n"); + } } vsp_cmdbuf_insert_command(cmdbuf, CONTEXT_VPP_ID, &cmdbuf->param_mem, VssProcPictureCommand, @@ -809,10 +850,10 @@ vsp_VPP_EndPicture }; VAStatus vsp_QueryVideoProcFilters( - VADriverContextP ctx, - VAContextID context, - VAProcFilterType *filters, - unsigned int *num_filters + VADriverContextP ctx, + VAContextID context, + VAProcFilterType *filters, + unsigned int *num_filters ) { INIT_DRIVER_DATA; @@ -877,11 +918,11 @@ err: } VAStatus vsp_QueryVideoProcFilterCaps( - VADriverContextP ctx, - VAContextID context, - VAProcFilterType type, - void *filter_caps, - unsigned int *num_filter_caps + VADriverContextP ctx, + VAContextID context, + VAProcFilterType type, + void *filter_caps, + unsigned int *num_filter_caps ) { INIT_DRIVER_DATA; @@ -1003,10 +1044,10 @@ err: VAStatus vsp_QueryVideoProcPipelineCaps( VADriverContextP ctx, - VAContextID context, - VABufferID *filters, - unsigned int num_filters, - VAProcPipelineCaps *pipeline_caps + VAContextID context, + VABufferID *filters, + unsigned int num_filters, + VAProcPipelineCaps *pipeline_caps ) { INIT_DRIVER_DATA; @@ -1296,7 +1337,7 @@ static VAStatus vsp_set_pipeline(context_VPP_p ctx) for (i = 0; i < ctx->num_filters; ++i) { cur_param = (VAProcFilterParameterBufferBase *)ctx->filter_buf[i]->buffer_data; switch (cur_param->type) { - case VAProcFilterNone: + case VAProcFilterNone: goto finished; break; case VAProcFilterNoiseReduction: @@ -1313,7 +1354,7 @@ static VAStatus vsp_set_pipeline(context_VPP_p ctx) case VAProcFilterFrameRateConversion: cell_pipeline_param->filter_pipeline[filter_count++] = VssProcFilterFrameRateConversion; break; - default: + default: cell_pipeline_param->filter_pipeline[filter_count++] = -1; vaStatus = VA_STATUS_ERROR_UNKNOWN; goto out; @@ -1370,7 +1411,7 @@ static VAStatus vsp_set_filter_param(context_VPP_p ctx) cell_denoiser_param->type = VssProcDeblock; vsp_cmdbuf_insert_command(cmdbuf, - CONTEXT_VPP_ID, + CONTEXT_VPP_ID, &cmdbuf->param_mem, VssProcDenoiseParameterCommand, ctx->denoise_param_offset, @@ -1384,7 +1425,7 @@ static VAStatus vsp_set_filter_param(context_VPP_p ctx) cell_denoiser_param->type = VssProcDegrain; vsp_cmdbuf_insert_command(cmdbuf, - CONTEXT_VPP_ID, + CONTEXT_VPP_ID, &cmdbuf->param_mem, VssProcDenoiseParameterCommand, ctx->denoise_param_offset, @@ -1397,7 +1438,7 @@ static VAStatus vsp_set_filter_param(context_VPP_p ctx) sizeof(ctx->sharpen_param)); vsp_cmdbuf_insert_command(cmdbuf, - CONTEXT_VPP_ID, + CONTEXT_VPP_ID, &cmdbuf->param_mem, VssProcSharpenParameterCommand, ctx->sharpen_param_offset, @@ -1410,7 +1451,7 @@ static VAStatus vsp_set_filter_param(context_VPP_p ctx) sizeof(ctx->enhancer_param)); vsp_cmdbuf_insert_command(cmdbuf, - CONTEXT_VPP_ID, + CONTEXT_VPP_ID, &cmdbuf->param_mem, VssProcColorEnhancementParameterCommand, ctx->enhancer_param_offset, @@ -1427,7 +1468,7 @@ static VAStatus vsp_set_filter_param(context_VPP_p ctx) /* set the FRC quality */ /* cell_proc_frc_param->quality = VssFrcMediumQuality; */ cell_proc_frc_param->quality = VssFrcHighQuality; - + /* check if the input fps is in the range of HW capability */ if (ratio == 2) cell_proc_frc_param->conversion_rate = VssFrc2xConversionRate; @@ -1435,8 +1476,8 @@ static VAStatus vsp_set_filter_param(context_VPP_p ctx) cell_proc_frc_param->conversion_rate = VssFrc2_5xConversionRate; else if (ratio == 4) cell_proc_frc_param->conversion_rate = VssFrc4xConversionRate; - else if (ratio == 1.25) - cell_proc_frc_param->conversion_rate = VssFrc1_25xConversionRate; + else if (ratio == 1.25) + cell_proc_frc_param->conversion_rate = VssFrc1_25xConversionRate; else { drv_debug_msg(VIDEO_DEBUG_ERROR, "invalid frame rate conversion ratio %f \n", ratio); vaStatus = VA_STATUS_ERROR_UNKNOWN; @@ -1444,13 +1485,13 @@ static VAStatus vsp_set_filter_param(context_VPP_p ctx) } vsp_cmdbuf_insert_command(cmdbuf, - CONTEXT_VPP_ID, + CONTEXT_VPP_ID, &cmdbuf->param_mem, VssProcFrcParameterCommand, ctx->frc_param_offset, sizeof(struct VssProcFrcParameterBuffer)); break; - default: + default: vaStatus = VA_STATUS_ERROR_UNKNOWN; goto out; } diff --git a/src/vsp_cmdbuf.c b/src/vsp_cmdbuf.c index a5a6ee3..d74261c 100644 --- a/src/vsp_cmdbuf.c +++ b/src/vsp_cmdbuf.c @@ -8,11 +8,11 @@ * distribute, sub license, 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 NON-INFRINGEMENT. @@ -34,6 +34,13 @@ #define LLDMA_SIZE (0x2000) #define RELOC_SIZE (0x3000) +static int +vspDRMCmdBuf(int fd, int ioctl_offset, psb_buffer_p *buffer_list, int buffer_count, unsigned cmdBufHandle, + unsigned cmdBufOffset, unsigned cmdBufSize, + unsigned relocBufHandle, unsigned relocBufOffset, + unsigned numRelocs, int damage, + unsigned engine, unsigned fence_flags, struct psb_ttm_fence_rep *fence_rep); + /* * Create command buffer */ @@ -156,35 +163,34 @@ int vsp_cmdbuf_unmap(vsp_cmdbuf_p cmdbuf) */ int vsp_cmdbuf_buffer_ref(vsp_cmdbuf_p cmdbuf, psb_buffer_p buf) { - int item_loc = 0; - -// while ((item_loc < cmdbuf->buffer_refs_count) && (cmdbuf->buffer_refs[item_loc] != buf)) { - /*Reserve the same TTM BO twice will cause kernel lock up*/ - while ((item_loc < cmdbuf->buffer_refs_count) - && (wsbmKBufHandle(wsbmKBuf(cmdbuf->buffer_refs[item_loc]->drm_buf)) - != wsbmKBufHandle(wsbmKBuf(buf->drm_buf)))) { - item_loc++; - } - if (item_loc == cmdbuf->buffer_refs_count) { - /* Add new entry */ - if (item_loc >= cmdbuf->buffer_refs_allocated) { - /* Allocate more entries */ - int new_size = cmdbuf->buffer_refs_allocated + 10; - psb_buffer_p *new_array; - new_array = (psb_buffer_p *) calloc(1, sizeof(psb_buffer_p) * new_size); - if (NULL == new_array) { - return -1; /* Allocation failure */ - } - memcpy(new_array, cmdbuf->buffer_refs, sizeof(psb_buffer_p) * cmdbuf->buffer_refs_allocated); - free(cmdbuf->buffer_refs); - cmdbuf->buffer_refs_allocated = new_size; - cmdbuf->buffer_refs = new_array; - } - cmdbuf->buffer_refs[item_loc] = buf; - cmdbuf->buffer_refs_count++; - buf->status = psb_bs_queued; - } - return item_loc; + int item_loc = 0; + + /*Reserve the same TTM BO twice will cause kernel lock up*/ + while ((item_loc < cmdbuf->buffer_refs_count) + && (wsbmKBufHandle(wsbmKBuf(cmdbuf->buffer_refs[item_loc]->drm_buf)) + != wsbmKBufHandle(wsbmKBuf(buf->drm_buf)))) { + item_loc++; + } + if (item_loc == cmdbuf->buffer_refs_count) { + /* Add new entry */ + if (item_loc >= cmdbuf->buffer_refs_allocated) { + /* Allocate more entries */ + int new_size = cmdbuf->buffer_refs_allocated + 10; + psb_buffer_p *new_array; + new_array = (psb_buffer_p *) calloc(1, sizeof(psb_buffer_p) * new_size); + if (NULL == new_array) { + return -1; /* Allocation failure */ + } + memcpy(new_array, cmdbuf->buffer_refs, sizeof(psb_buffer_p) * cmdbuf->buffer_refs_allocated); + free(cmdbuf->buffer_refs); + cmdbuf->buffer_refs_allocated = new_size; + cmdbuf->buffer_refs = new_array; + } + cmdbuf->buffer_refs[item_loc] = buf; + cmdbuf->buffer_refs_count++; + buf->status = psb_bs_queued; + } + return item_loc; } /* Creates a relocation record for a DWORD in the mapped "cmdbuf" at address @@ -196,14 +202,14 @@ int vsp_cmdbuf_buffer_ref(vsp_cmdbuf_p cmdbuf, psb_buffer_p buf) * constructed address. The remaining bits will be filled with bits from "background". */ void vsp_cmdbuf_add_relocation(vsp_cmdbuf_p cmdbuf, - uint32_t *addr_in_dst_buffer,/*addr of dst_buffer for the DWORD*/ - psb_buffer_p ref_buffer, - uint32_t buf_offset, - uint32_t mask, - uint32_t background, - uint32_t align_shift, - uint32_t dst_buffer, - uint32_t *start_of_dst_buffer) /*Index of the list refered by cmdbuf->buffer_refs */ + uint32_t *addr_in_dst_buffer,/*addr of dst_buffer for the DWORD*/ + psb_buffer_p ref_buffer, + uint32_t buf_offset, + uint32_t mask, + uint32_t background, + uint32_t align_shift, + uint32_t dst_buffer, + uint32_t *start_of_dst_buffer) /*Index of the list refered by cmdbuf->buffer_refs */ { struct drm_psb_reloc *reloc = cmdbuf->reloc_idx; uint64_t presumed_offset = wsbmBOOffsetHint(ref_buffer->drm_buf); @@ -216,13 +222,13 @@ void vsp_cmdbuf_add_relocation(vsp_cmdbuf_p cmdbuf, reloc->reloc_op = PSB_RELOC_OP_OFFSET; #ifndef VA_EMULATOR if (presumed_offset) { - uint32_t new_val = presumed_offset + buf_offset; + uint32_t new_val = presumed_offset + buf_offset; - new_val = ((new_val >> align_shift) << (align_shift << PSB_RELOC_ALSHIFT_SHIFT)); - new_val = (background & ~mask) | (new_val & mask); - *addr_in_dst_buffer = new_val; + new_val = ((new_val >> align_shift) << (align_shift << PSB_RELOC_ALSHIFT_SHIFT)); + new_val = (background & ~mask) | (new_val & mask); + *addr_in_dst_buffer = new_val; } else { - *addr_in_dst_buffer = PSB_RELOC_MAGIC; + *addr_in_dst_buffer = PSB_RELOC_MAGIC; } #else /* indicate subscript of relocation buffer */ @@ -282,10 +288,10 @@ int vsp_context_get_next_cmdbuf(object_context_p obj_context) */ static int vspDRMCmdBuf(int fd, int ioctl_offset, psb_buffer_p *buffer_list, int buffer_count, unsigned cmdBufHandle, - unsigned cmdBufOffset, unsigned cmdBufSize, - unsigned relocBufHandle, unsigned relocBufOffset, - unsigned __maybe_unused numRelocs, int __maybe_unused damage, - unsigned engine, unsigned fence_flags, struct psb_ttm_fence_rep *fence_rep) + unsigned cmdBufOffset, unsigned cmdBufSize, + unsigned relocBufHandle, unsigned relocBufOffset, + unsigned numRelocs, int __maybe_unused damage, + unsigned engine, unsigned fence_flags, struct psb_ttm_fence_rep *fence_rep) { drm_psb_cmdbuf_arg_t ca; struct psb_validate_arg *arg_list; diff --git a/src/vsp_compose.c b/src/vsp_compose.c index 899361d..62e75b4 100644 --- a/src/vsp_compose.c +++ b/src/vsp_compose.c @@ -8,11 +8,11 @@ * distribute, sub license, 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 NON-INFRINGEMENT. @@ -45,7 +45,7 @@ #define ALIGN_TO_128(value) ((value + 128 - 1) & ~(128 - 1)) #define ALIGN_TO_16(value) ((value + 16 - 1) & ~(16 - 1)) -VAStatus vsp_compose_process_pipeline_param(context_VPP_p ctx, object_context_p obj_context, object_buffer_p obj_buffer) +VAStatus vsp_compose_process_pipeline_param(context_VPP_p ctx, object_context_p __maybe_unused obj_context, object_buffer_p obj_buffer) { VAStatus vaStatus = VA_STATUS_SUCCESS; diff --git a/src/vsp_vp8.c b/src/vsp_vp8.c index 2e0315e..1e6bb9b 100644 --- a/src/vsp_vp8.c +++ b/src/vsp_vp8.c @@ -102,7 +102,7 @@ static void vsp_VP8_DestroyContext(object_context_p obj_context); static VAStatus vsp__VP8_check_legal_picture(object_context_p obj_context, object_config_p obj_config); static void vsp_VP8_QueryConfigAttributes( - VAProfile __maybe_unused profile, + VAProfile __maybe_unused profile, VAEntrypoint __maybe_unused entrypoint, VAConfigAttrib *attrib_list, int num_attribs) @@ -559,9 +559,17 @@ static VAStatus vsp_vp8_process_misc_param(context_VPP_p ctx, object_buffer_p ob break; case VAEncMiscParameterTypeFrameRate: frame_rate_param = (VAEncMiscParameterFrameRate *)pBuffer->data; - if (frame_rate_param->framerate < 1 || frame_rate_param->framerate > 65535) { - vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; - break; + if (frame_rate_param->framerate > 120) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%d is invalid." + "framerate could not be larger than 120\n", + frame_rate_param->framerate); + frame_rate_param->framerate = 120; + } + if (frame_rate_param->framerate < 1) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%d is invalid." + "framerate could not be smaller than 1\n", + frame_rate_param->framerate); + frame_rate_param->framerate = 1; } if (ctx->temporal_layer_number == 1) { @@ -587,13 +595,13 @@ static VAStatus vsp_vp8_process_misc_param(context_VPP_p ctx, object_buffer_p ob break; case VAEncMiscParameterTypeRateControl: rate_control_param = (VAEncMiscParameterRateControl *)pBuffer->data; - if (rate_control_param->initial_qp > 63 || + if (rate_control_param->max_qp > 63 || rate_control_param->min_qp > 63) { - drv_debug_msg(VIDEO_DEBUG_ERROR, "Initial_qp(%d) and min_qpinitial_qp(%d) " + drv_debug_msg(VIDEO_DEBUG_ERROR, "max_qp(%d) and min_qp(%d) " "are invalid.\nQP shouldn't be larger than 63 for VP8\n", - rate_control_param->initial_qp, rate_control_param->min_qp); - vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; - break; + rate_control_param->max_qp, rate_control_param->min_qp); + rate_control_param->max_qp = 63; + rate_control_param->min_qp = rate_control_param->max_qp; } if (rate_control_param->min_qp != seq->rc_min_quantizer) { @@ -616,6 +624,13 @@ static VAStatus vsp_vp8_process_misc_param(context_VPP_p ctx, object_buffer_p ob seq->rc_undershoot_pct = rate_control_param->target_percentage; } + if (rate_control_param->bits_per_second / 1000 > 20000) { + drv_debug_msg(VIDEO_DEBUG_ERROR, "%d is invalid." + "bitrate could not be larger than 20000\n", + rate_control_param->bits_per_second / 1000); + rate_control_param->bits_per_second = 20000000; + } + if (ctx->temporal_layer_number == 1) { if (rate_control_param->bits_per_second / 1000 != seq->rc_target_bitrate) { drv_debug_msg(VIDEO_DEBUG_ERROR, "bitrate was changed from %dkbps to %dkbps\n", @@ -896,4 +911,3 @@ renderPicture: endPicture: vsp_VP8_EndPicture }; - |