From: Li Zeng
Date: Thu, 3 Nov 2011 01:57:22 +0000 (+0800)
Subject: ved/vec: Add video decode/encode driver, move to K3.0 TTM interface
X-Git-Tag: 2.1b_release~1898
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1aeb8b5ca915e6037556988dae30eb878ff4c28;p=kernel%2Fkernel-mfld-blackbay.git
ved/vec: Add video decode/encode driver, move to K3.0 TTM interface
BZ 14096
Change-Id: Ib562ec93ff19e4363e8e3004202b4a626a91a70f
Signed-off-by: Li Zeng
Reviewed-on: http://android.intel.com:8080/23713
Reviewed-by: Gross, Mark
Tested-by: Gross, Mark
---
diff --git a/arch/x86/configs/i386_mfld_defconfig b/arch/x86/configs/i386_mfld_defconfig
index c496784..3febdec 100644
--- a/arch/x86/configs/i386_mfld_defconfig
+++ b/arch/x86/configs/i386_mfld_defconfig
@@ -1760,7 +1760,7 @@ CONFIG_MDFD_HDMI=y
CONFIG_GFX_RTPM=y
# CONFIG_SUPPORT_TOSHIBA_MIPI_DISPLAY is not set
# CONFIG_SUPPORT_TMD_MIPI_600X1024_DISPLAY is not set
-# CONFIG_MDFD_VIDEO_DECODE is not set
+CONFIG_MDFD_VIDEO_DECODE=y
# CONFIG_MDFD_VIDEO_ENCODE is not set
CONFIG_X86_PLATFORM_DEVICES=y
# CONFIG_SENSORS_HDAPS is not set
diff --git a/drivers/staging/mrst/drv/psb_drv.c b/drivers/staging/mrst/drv/psb_drv.c
index ff3044e..c138950a 100755
--- a/drivers/staging/mrst/drv/psb_drv.c
+++ b/drivers/staging/mrst/drv/psb_drv.c
@@ -1434,7 +1434,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
hdmi_state = 0;
-#ifdef CONFIG_MDFD_VIDEO_DECODER
+#ifdef CONFIG_MDFD_VIDEO_DECODE
ret = psb_ttm_global_init(dev_priv);
if (unlikely(ret != 0))
goto out_err;
@@ -1848,7 +1848,7 @@ static int psb_vt_leave_ioctl(struct drm_device *dev, void *data,
man = &bdev->man[TTM_PL_TT];
/*spin_lock(&bdev->lru_lock);*///lru_lock is removed from upstream TTM
- clean = drm_mm_clean(&man->manager);
+ clean = drm_mm_clean((struct drm_mm *)man->priv);
/*spin_unlock(&bdev->lru_lock);*/
if (unlikely(!clean))
DRM_INFO("Warning: GATT was not clean after VT switch.\n");
diff --git a/drivers/staging/mrst/drv/psb_drv.h b/drivers/staging/mrst/drv/psb_drv.h
index 249226b..fdac7a0e 100755
--- a/drivers/staging/mrst/drv/psb_drv.h
+++ b/drivers/staging/mrst/drv/psb_drv.h
@@ -420,7 +420,7 @@ struct drm_psb_private {
*TTM Glue.
*/
#ifdef CONFIG_MDFD_VIDEO_DECODE
- struct ttm_global_reference mem_global_ref;
+ struct drm_global_reference mem_global_ref;
struct ttm_bo_global_ref bo_global_ref;
#endif
int has_global;
diff --git a/drivers/staging/mrst/drv/psb_sgx.c b/drivers/staging/mrst/drv/psb_sgx.c
index f3fefe3..da79fd1 100644
--- a/drivers/staging/mrst/drv/psb_sgx.c
+++ b/drivers/staging/mrst/drv/psb_sgx.c
@@ -240,6 +240,7 @@ psb_placement_fence_type(struct ttm_buffer_object *bo,
return 0;
}
+#if 0
int psb_validate_kernel_buffer(struct psb_context *context,
struct ttm_buffer_object *bo,
uint32_t fence_class,
@@ -290,6 +291,7 @@ out_unlock:
spin_unlock(&bo->lock);
return ret;
}
+#endif
static int psb_validate_buffer_list(struct drm_file *file_priv,
@@ -317,7 +319,7 @@ static int psb_validate_buffer_list(struct drm_file *file_priv,
item->ret = 0;
req = &item->req;
- spin_lock(&bo->lock);
+ spin_lock(&bo->bdev->fence_lock);
ret = psb_placement_fence_type(bo,
req->set_flags,
req->clear_flags,
@@ -334,9 +336,9 @@ static int psb_validate_buffer_list(struct drm_file *file_priv,
placement.fpfn = 0;
placement.lpfn = 0;
- spin_unlock(&bo->lock);
+ spin_unlock(&bo->bdev->fence_lock);
ret = ttm_bo_validate(bo, &placement, 1, 0, 0);
- spin_lock(&bo->lock);
+ /* spin_lock(&bo->lock); */ /* mem and offset field of bo is protected by ::reserve, this function is called in reserve*/
if (unlikely(ret != 0))
goto out_err;
@@ -346,7 +348,7 @@ static int psb_validate_buffer_list(struct drm_file *file_priv,
item->offset = bo->offset;
item->flags = bo->mem.placement;
- spin_unlock(&bo->lock);
+ /* spin_unlock(&bo->lock); */
ret =
psb_check_presumed(&item->req, bo, item->user_val_arg,
@@ -364,7 +366,7 @@ static int psb_validate_buffer_list(struct drm_file *file_priv,
return 0;
out_err:
- spin_unlock(&bo->lock);
+ /* spin_unlock(&bo->lock); */
item->ret = ret;
return ret;
}
@@ -765,13 +767,18 @@ static int psb_handle_copyback(struct drm_device *dev,
arg.ret = vbuf->ret;
if (!arg.ret) {
struct ttm_buffer_object *bo = entry->bo;
- spin_lock(&bo->lock);
+ /* spin_lock(&bo->lock); */
+ /* offset and mem field of bo is protected by reserve */
+ ret = ttm_bo_reserve(bo, 1, 0, 0, 0);
+ if (unlikely(ret != 0))
+ arg.ret = -EFAULT;
arg.d.rep.gpu_offset = bo->offset;
arg.d.rep.placement = bo->mem.placement;
arg.d.rep.fence_type_mask =
(uint32_t)(unsigned long)
entry->new_sync_obj_arg;
- spin_unlock(&bo->lock);
+ ttm_bo_unreserve(bo);
+ /* spin_unlock(&bo->lock); */
}
if (__copy_to_user(vbuf->user_val_arg,
@@ -850,10 +857,10 @@ int psb_cmdbuf_ioctl(struct drm_device *dev, void *data,
if (unlikely(ret != 0))
goto out_err1;
- context->val_seq = atomic_add_return(1, &dev_priv->val_seq);
+ /* Not used in K3 */
+ /* context->val_seq = atomic_add_return(1, &dev_priv->val_seq); */
- ret = ttm_eu_reserve_buffers(&context->validate_list,
- context->val_seq);
+ ret = ttm_eu_reserve_buffers(&context->validate_list);
if (unlikely(ret != 0))
goto out_err2;
diff --git a/drivers/staging/mrst/imgv/lnc_topaz.c b/drivers/staging/mrst/imgv/lnc_topaz.c
index 84820cd..4da53dd 100644
--- a/drivers/staging/mrst/imgv/lnc_topaz.c
+++ b/drivers/staging/mrst/imgv/lnc_topaz.c
@@ -27,7 +27,6 @@
/* include headers */
/* #define DRM_DEBUG_CODE 2 */
#include
-#include
#include "psb_drv.h"
#include "psb_drm.h"
@@ -287,10 +286,10 @@ int lnc_cmdbuf_video(struct drm_file *priv,
if (fence)
ttm_fence_object_unref(&fence);
- spin_lock(&cmd_buffer->lock);
+ spin_lock(&cmd_buffer->bdev->fence_lock);
if (cmd_buffer->sync_obj != NULL)
ttm_fence_sync_obj_unref(&cmd_buffer->sync_obj);
- spin_unlock(&cmd_buffer->lock);
+ spin_unlock(&cmd_buffer->bdev->fence_lock);
return 0;
}
diff --git a/drivers/staging/mrst/imgv/pnw_topaz.c b/drivers/staging/mrst/imgv/pnw_topaz.c
index 212c90b..f691707 100644
--- a/drivers/staging/mrst/imgv/pnw_topaz.c
+++ b/drivers/staging/mrst/imgv/pnw_topaz.c
@@ -27,7 +27,6 @@
/* include headers */
/* #define DRM_DEBUG_CODE 2 */
#include
-#include
#include "psb_drv.h"
#include "psb_drm.h"
@@ -292,10 +291,10 @@ int pnw_cmdbuf_video(struct drm_file *priv,
if (fence)
ttm_fence_object_unref(&fence);
- spin_lock(&cmd_buffer->lock);
+ spin_lock(&cmd_buffer->bdev->fence_lock);
if (cmd_buffer->sync_obj != NULL)
ttm_fence_sync_obj_unref(&cmd_buffer->sync_obj);
- spin_unlock(&cmd_buffer->lock);
+ spin_unlock(&cmd_buffer->bdev->fence_lock);
PSB_DEBUG_GENERAL("TOPAZ exit %s\n", __func__);
return 0;
diff --git a/drivers/staging/mrst/imgv/psb_buffer.c b/drivers/staging/mrst/imgv/psb_buffer.c
index 3d5a5a1..211db8b 100644
--- a/drivers/staging/mrst/imgv/psb_buffer.c
+++ b/drivers/staging/mrst/imgv/psb_buffer.c
@@ -30,6 +30,7 @@
struct drm_psb_ttm_backend {
struct ttm_backend base;
struct page **pages;
+ dma_addr_t *dma_addrs;
unsigned int desired_tile_stride;
unsigned int hw_tile_stride;
int mem_type;
@@ -61,6 +62,7 @@ static int psb_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
man->default_caching = TTM_PL_FLAG_CACHED;
break;
case DRM_PSB_MEM_MMU:
+ man->func = &ttm_bo_manager_func;
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
TTM_MEMTYPE_FLAG_CMA;
man->gpu_offset = PSB_MEM_MMU_START;
@@ -69,6 +71,7 @@ static int psb_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
man->default_caching = TTM_PL_FLAG_WC;
break;
case TTM_PL_CI:
+ man->func = &ttm_bo_manager_func;
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
TTM_MEMTYPE_FLAG_FIXED;
man->gpu_offset = pg->mmu_gatt_start + (pg->ci_start);
@@ -76,6 +79,7 @@ static int psb_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
man->default_caching = TTM_PL_FLAG_UNCACHED;
break;
case TTM_PL_RAR: /* Unmappable RAR memory */
+ man->func = &ttm_bo_manager_func;
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
TTM_MEMTYPE_FLAG_FIXED;
man->available_caching = TTM_PL_FLAG_UNCACHED;
@@ -83,6 +87,7 @@ static int psb_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
man->gpu_offset = pg->mmu_gatt_start + (pg->rar_start);
break;
case TTM_PL_TT: /* Mappable GATT memory */
+ man->func = &ttm_bo_manager_func;
#ifdef PSB_WORKING_HOST_MMU_ACCESS
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
#else
@@ -218,12 +223,14 @@ static int psb_move(struct ttm_buffer_object *bo,
static int drm_psb_tbe_populate(struct ttm_backend *backend,
unsigned long num_pages,
struct page **pages,
- struct page *dummy_read_page)
+ struct page *dummy_read_page,
+ dma_addr_t *dma_addrs)
{
struct drm_psb_ttm_backend *psb_be =
container_of(backend, struct drm_psb_ttm_backend, base);
psb_be->pages = pages;
+ psb_be->dma_addrs = dma_addrs; /* Not concretely implemented by TTM yet*/
return 0;
}
@@ -272,7 +279,7 @@ static int drm_psb_tbe_bind(struct ttm_backend *backend,
psb_be->num_pages = bo_mem->num_pages;
psb_be->desired_tile_stride = 0;
psb_be->hw_tile_stride = 0;
- psb_be->offset = (bo_mem->mm_node->start << PAGE_SHIFT) +
+ psb_be->offset = (bo_mem->start << PAGE_SHIFT) +
man->gpu_offset;
type =
@@ -310,6 +317,7 @@ static void drm_psb_tbe_clear(struct ttm_backend *backend)
container_of(backend, struct drm_psb_ttm_backend, base);
psb_be->pages = NULL;
+ psb_be->dma_addrs = NULL;
return;
}
@@ -361,21 +369,21 @@ static int psb_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg
/* system memory */
return 0;
case TTM_PL_TT:
- mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
+ mem->bus.offset = mem->start << PAGE_SHIFT;
mem->bus.base = pg->gatt_start;
mem->bus.is_iomem = false; /* Don't know whether it is IO_MEM, this flag used in vm_fault handle */
break;
case DRM_PSB_MEM_MMU:
- mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
+ mem->bus.offset = mem->start << PAGE_SHIFT;
mem->bus.base = 0x00000000;
break;
case TTM_PL_CI:
- mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
+ mem->bus.offset = mem->start << PAGE_SHIFT;
mem->bus.base = dev_priv->ci_region_start;;
mem->bus.is_iomem = true;
break;
case TTM_PL_RAR:
- mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
+ mem->bus.offset = mem->start << PAGE_SHIFT;
mem->bus.base = dev_priv->rar_region_start;;
mem->bus.is_iomem = true;
break;
diff --git a/drivers/staging/mrst/imgv/psb_msvdx.c b/drivers/staging/mrst/imgv/psb_msvdx.c
index a90a72a..3dee6f0 100644
--- a/drivers/staging/mrst/imgv/psb_msvdx.c
+++ b/drivers/staging/mrst/imgv/psb_msvdx.c
@@ -20,7 +20,6 @@
**************************************************************************/
#include
-#include
#include "psb_drm.h"
#include "psb_drv.h"
#include "psb_msvdx.h"
@@ -533,10 +532,10 @@ int psb_cmdbuf_video(struct drm_file *priv,
&fence);
ttm_fence_object_unref(&fence);
- spin_lock(&cmd_buffer->lock);
+ spin_lock(&cmd_buffer->bdev->fence_lock);
if (cmd_buffer->sync_obj != NULL)
ttm_fence_sync_obj_unref(&cmd_buffer->sync_obj);
- spin_unlock(&cmd_buffer->lock);
+ spin_unlock(&cmd_buffer->bdev->fence_lock);
return 0;
}
diff --git a/drivers/staging/mrst/imgv/psb_ttm_glue.c b/drivers/staging/mrst/imgv/psb_ttm_glue.c
index 5cafe13..3468dc0 100644
--- a/drivers/staging/mrst/imgv/psb_ttm_glue.c
+++ b/drivers/staging/mrst/imgv/psb_ttm_glue.c
@@ -333,29 +333,29 @@ int psb_verify_access(struct ttm_buffer_object *bo,
}
#ifdef CONFIG_MDFD_VIDEO_DECODE
-static int psb_ttm_mem_global_init(struct ttm_global_reference *ref)
+static int psb_ttm_mem_global_init(struct drm_global_reference *ref)
{
return ttm_mem_global_init(ref->object);
}
-static void psb_ttm_mem_global_release(struct ttm_global_reference *ref)
+static void psb_ttm_mem_global_release(struct drm_global_reference *ref)
{
ttm_mem_global_release(ref->object);
}
int psb_ttm_global_init(struct drm_psb_private *dev_priv)
{
- struct ttm_global_reference *global_ref;
- struct ttm_global_reference *global;
+ struct drm_global_reference *global_ref;
+ struct drm_global_reference *global;
int ret;
global_ref = &dev_priv->mem_global_ref;
- global_ref->global_type = TTM_GLOBAL_TTM_MEM;
+ global_ref->global_type = DRM_GLOBAL_TTM_MEM;
global_ref->size = sizeof(struct ttm_mem_global);
global_ref->init = &psb_ttm_mem_global_init;
global_ref->release = &psb_ttm_mem_global_release;
- ret = ttm_global_item_ref(global_ref);
+ ret = drm_global_item_ref(global_ref);
if (unlikely(ret != 0)) {
DRM_ERROR("Failed referencing a global TTM memory object.\n");
return ret;
@@ -363,14 +363,14 @@ int psb_ttm_global_init(struct drm_psb_private *dev_priv)
dev_priv->bo_global_ref.mem_glob = dev_priv->mem_global_ref.object;
global = &dev_priv->bo_global_ref.ref;
- global->global_type = TTM_GLOBAL_TTM_BO;
+ global->global_type = DRM_GLOBAL_TTM_BO;
global->size = sizeof(struct ttm_bo_global);
global->init = &ttm_bo_global_init;
global->release = &ttm_bo_global_release;
- ret = ttm_global_item_ref((struct ttm_global_reference *)global);
+ ret = drm_global_item_ref((struct drm_global_reference *)global);
if (ret != 0) {
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
- ttm_global_item_unref((struct ttm_global_reference *)global_ref);
+ drm_global_item_unref((struct drm_global_reference *)global_ref);
return ret;
}
@@ -379,7 +379,7 @@ int psb_ttm_global_init(struct drm_psb_private *dev_priv)
void psb_ttm_global_release(struct drm_psb_private *dev_priv)
{
- ttm_global_item_unref(&dev_priv->mem_global_ref);
+ drm_global_item_unref(&dev_priv->mem_global_ref);
}
#endif
diff --git a/drivers/staging/mrst/imgv/psb_ttm_placement_user.c b/drivers/staging/mrst/imgv/psb_ttm_placement_user.c
index 9102b64..bb18859 100644
--- a/drivers/staging/mrst/imgv/psb_ttm_placement_user.c
+++ b/drivers/staging/mrst/imgv/psb_ttm_placement_user.c
@@ -320,9 +320,11 @@ int ttm_pl_create_ioctl(struct ttm_object_file *tfile,
if (unlikely(ret != 0))
goto out_err;
- spin_lock(&bo->lock);
+ ret = ttm_bo_reserve(bo, true, false, false, 0);
+ if (unlikely(ret != 0))
+ goto out_err;
ttm_pl_fill_rep(bo, rep);
- spin_unlock(&bo->lock);
+ ttm_bo_unreserve(bo);
ttm_bo_unref(&bo);
out:
return 0;
@@ -398,9 +400,11 @@ int ttm_pl_ub_create_ioctl(struct ttm_object_file *tfile,
if (unlikely(ret != 0))
goto out_err;
- spin_lock(&bo->lock);
+ ret = ttm_bo_reserve(bo, true, false, false, 0);
+ if (unlikely(ret != 0))
+ goto out_err;
ttm_pl_fill_rep(bo, rep);
- spin_unlock(&bo->lock);
+ ttm_bo_unreserve(bo);
ttm_bo_unref(&bo);
out:
return 0;
@@ -433,9 +437,11 @@ int ttm_pl_reference_ioctl(struct ttm_object_file *tfile, void *data)
goto out;
}
- spin_lock(&bo->lock);
+ ret = ttm_bo_reserve(bo, true, false, false, 0);
+ if (unlikely(ret != 0))
+ goto out;
ttm_pl_fill_rep(bo, rep);
- spin_unlock(&bo->lock);
+ ttm_bo_unreserve(bo);
out:
base = &user_bo->base;
@@ -533,7 +539,7 @@ int ttm_pl_setstatus_ioctl(struct ttm_object_file *tfile,
placement.num_placement = 2;
placement.placement = flags;
- spin_lock(&bo->lock);
+ /* spin_lock(&bo->lock); */ /* Already get reserve lock */
ret = psb_ttm_bo_check_placement(bo, &placement);
if (unlikely(ret != 0))
@@ -548,7 +554,7 @@ int ttm_pl_setstatus_ioctl(struct ttm_object_file *tfile,
ttm_pl_fill_rep(bo, rep);
out_err2:
- spin_unlock(&bo->lock);
+ /* spin_unlock(&bo->lock); */
ttm_bo_unreserve(bo);
out_err1:
ttm_read_unlock(lock);
@@ -601,11 +607,11 @@ int ttm_pl_waitidle_ioctl(struct ttm_object_file *tfile, void *data)
arg->mode & TTM_PL_WAITIDLE_MODE_NO_BLOCK);
if (unlikely(ret != 0))
goto out;
- spin_lock(&bo->lock);
+ spin_lock(&bo->bdev->fence_lock);
ret = ttm_bo_wait(bo,
arg->mode & TTM_PL_WAITIDLE_MODE_LAZY,
true, arg->mode & TTM_PL_WAITIDLE_MODE_NO_BLOCK);
- spin_unlock(&bo->lock);
+ spin_unlock(&bo->bdev->fence_lock);
psb_ttm_bo_unblock_reservation(bo);
out:
ttm_bo_unref(&bo);