kernel-drm: avoid msvdx power-on to read IED register
authorFei Jiang <fei.jiang@intel.com>
Sun, 3 Jun 2012 15:45:50 +0000 (23:45 +0800)
committerbuildbot <buildbot@intel.com>
Wed, 6 Jun 2012 00:15:53 +0000 (17:15 -0700)
BZ: 37972

Instead to use VA_RT_FORMAT_PROTECTED to detect if IED is on.
Power-on msvdx to read IED register is not reliable,
because driver only suspend msvdx during interrupt handler.

Change-Id: I28815478ae3baee1f47682955dbf3144575e6071
Signed-off-by: Fei Jiang <fei.jiang@intel.com>
Reviewed-on: http://android.intel.com:8080/51061
Reviewed-by: Zeng, Li <li.zeng@intel.com>
Reviewed-by: Ding, Haitao <haitao.ding@intel.com>
Tested-by: Ding, Haitao <haitao.ding@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/staging/mrst/drv/psb_drv.h
drivers/staging/mrst/drv/psb_sgx.c
drivers/staging/mrst/imgv/psb_msvdx.c
drivers/staging/mrst/imgv/psb_msvdxinit.c

index c209275..15473ab 100644 (file)
@@ -411,11 +411,12 @@ enum VAEntrypoint {
        VAEntrypointEncPicture  = 7     /* pictuer encode, JPEG, etc */
 };
 
+#define VA_RT_FORMAT_PROTECTED 0x80000000
 
 struct psb_video_ctx {
        struct list_head head;
        struct file *filp; /* DRM device file pointer */
-       int ctx_type; /* profile<<8|entrypoint */
+       int ctx_type; /* protect_flag | (profile<<8) & 0xff |entrypoint */
        /* todo: more context specific data for multi-context support */
 };
 
index b6c9ddd..5ac03b7 100644 (file)
@@ -892,7 +892,8 @@ int psb_cmdbuf_ioctl(struct drm_device *dev, void *data,
                        int entrypoint = pos->ctx_type & 0xff;
 
                        PSB_DEBUG_GENERAL("Video:commands for profile %d, entrypoint %d",
-                                         (pos->ctx_type >> 8), (pos->ctx_type & 0xff));
+                                       (pos->ctx_type >> 8) & 0xff,
+                                       (pos->ctx_type & 0xff));
 
                        if (entrypoint == VAEntrypointEncSlice ||
                            entrypoint == VAEntrypointEncPicture)
index fcbde3f..95119c0 100644 (file)
@@ -33,6 +33,8 @@
        list_entry((ptr)->next, type, member)
 #endif
 
+static int ied_enabled;
+
 static int psb_msvdx_send(struct drm_device *dev, void *cmd,
                          unsigned long cmd_size);
 
@@ -400,8 +402,11 @@ int psb_submit_video_cmdbuf(struct drm_device *dev,
                if (IS_MRST(dev) && dev_priv->msvdx_ctx && dev_priv->last_msvdx_ctx) {
                        uint32_t from_profile, to_profile;
 
-                       from_profile = dev_priv->last_msvdx_ctx->ctx_type >> 8;
-                       to_profile = dev_priv->msvdx_ctx->ctx_type >> 8;
+                       from_profile =
+                               (dev_priv->last_msvdx_ctx->ctx_type >> 8) &
+                               0xff;
+                       to_profile =
+                               (dev_priv->msvdx_ctx->ctx_type >> 8) & 0xff;
 
                        /* not the same profile, and one of them is H264 constrained BP
                         * which needs Error Concealment firmware
@@ -1298,12 +1303,14 @@ int psb_check_msvdx_idle(struct drm_device *dev)
 int psb_remove_videoctx(struct drm_psb_private *dev_priv, struct file *filp)
 {
        struct psb_video_ctx *pos, *n;
+       /* iterate to query all ctx to if there is DRM running*/
+       ied_enabled = 0;
 
        list_for_each_entry_safe(pos, n, &dev_priv->video_ctx, head) {
                if (pos->filp == filp) {
                        PSB_DEBUG_GENERAL("Video:remove context profile %d,"
                                          " entrypoint %d",
-                                         (pos->ctx_type >> 8),
+                                         (pos->ctx_type >> 8) & 0xff,
                                          (pos->ctx_type & 0xff));
 
                        /* if current ctx points to it, set to NULL */
@@ -1335,6 +1342,9 @@ int psb_remove_videoctx(struct drm_psb_private *dev_priv, struct file *filp)
 
                        list_del(&pos->head);
                        kfree(pos);
+               } else {
+                       if (pos->ctx_type & VA_RT_FORMAT_PROTECTED)
+                               ied_enabled = 1;
                }
        }
        return 0;
@@ -1430,8 +1440,13 @@ int lnc_video_getparam(struct drm_device *dev, void *data,
                                 (ctx_type & 0xff)))
                        pnw_reset_fw_status(dev_priv->dev);
 
-               PSB_DEBUG_GENERAL("Video:add context profile %d, entrypoint %d",
-                                 (ctx_type >> 8), (ctx_type & 0xff));
+               PSB_DEBUG_GENERAL("Video:add ctx profile %d, entry %d.\n",
+                                       ((ctx_type >> 8) & 0xff),
+                                       (ctx_type & 0xff));
+               PSB_DEBUG_GENERAL("Video:add context protected 0x%x.\n",
+                                       (ctx_type & VA_RT_FORMAT_PROTECTED));
+               if (ctx_type & VA_RT_FORMAT_PROTECTED)
+                       ied_enabled = 1;
                break;
 
        case IMG_VIDEO_RM_CONTEXT:
@@ -1548,6 +1563,10 @@ int lnc_video_getparam(struct drm_device *dev, void *data,
                break;
                case IMG_VIDEO_IED_STATE:
                if (IS_MDFLD(dev)) {
+                       /* query IED status by register is not safe */
+                       /* need first power-on msvdx, while now only  */
+                       /* schedule vxd suspend wq in interrupt handler */
+#if 0
                        int ied_enable;
                        /* VXD must be power on during query IED register */
                        if (!ospm_power_using_hw_begin(OSPM_VIDEO_DEC_ISLAND,
@@ -1560,10 +1579,10 @@ int lnc_video_getparam(struct drm_device *dev, void *data,
                                ied_enable = 0;
                        PSB_DEBUG_GENERAL("ied_enable is %d.\n", ied_enable);
                        ospm_power_using_hw_end(OSPM_VIDEO_DEC_ISLAND);
-
+#endif
                        ret = copy_to_user((void __user *)
                                        ((unsigned long)arg->value),
-                                       &ied_enable, sizeof(ied_enable));
+                                       &ied_enabled, sizeof(ied_enabled));
                } else { /* Moorestown should not call it */
                        DRM_ERROR("IMG_VIDEO_IED_EANBLE error.\n");
                        return -EFAULT;
@@ -1641,8 +1660,8 @@ int psb_msvdx_check_reset_fw(struct drm_device *dev)
        if (IS_MRST(dev) && dev_priv->msvdx_ctx && dev_priv->last_msvdx_ctx) {
                uint32_t from_profile, to_profile;
 
-               from_profile = dev_priv->last_msvdx_ctx->ctx_type >> 8;
-               to_profile = dev_priv->msvdx_ctx->ctx_type >> 8;
+               from_profile = (dev_priv->last_msvdx_ctx->ctx_type >> 8) & 0xff;
+               to_profile = (dev_priv->msvdx_ctx->ctx_type >> 8) & 0xff;
 
                /* not the same profile, and one of them is H264 constrained BP
                 * which needs Error Concealment firmware
index 29bedd7..e444dc5 100644 (file)
@@ -611,7 +611,8 @@ int psb_setup_fw(struct drm_device *dev)
 
         /* load error concealment firmware? */
         if (IS_MRST(dev) && dev_priv->last_msvdx_ctx &&
-            (dev_priv->last_msvdx_ctx->ctx_type >> 8) == VAProfileH264ConstrainedBaseline) {
+                       (((dev_priv->last_msvdx_ctx->ctx_type >> 8) & 0xff) ==
+                       VAProfileH264ConstrainedBaseline)) {
             ec_firmware = 1;
             PSB_DEBUG_INIT("MSVDX: load error concealment firmware\n");
         }