vl: Add support for max level query v2
[mesa.git] / src / gallium / drivers / nvc0 / nvc0_video.c
index 462637b1a8b57a1147a416ee620929c40474f817..a871ab792d70b14b0f001a326f8dca35b7385d7e 100644 (file)
@@ -48,6 +48,31 @@ nvc0_screen_get_video_param(struct pipe_screen *pscreen,
       return true;
    case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE:
       return false;
+   case PIPE_VIDEO_CAP_MAX_LEVEL:
+      switch (profile) {
+      case PIPE_VIDEO_PROFILE_MPEG1:
+         return 0;
+      case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
+      case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
+         return 3;
+      case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
+         return 3;
+      case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
+         return 5;
+      case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
+         return 1;
+      case PIPE_VIDEO_PROFILE_VC1_MAIN:
+         return 2;
+      case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
+         return 4;
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
+         return 41;
+      default:
+         debug_printf("unknown video profile: %d\n", profile);
+         return 0;
+      }
    default:
       debug_printf("unknown video param: %d\n", param);
       return 0;
@@ -153,7 +178,7 @@ static void nvc0_video_getpath(enum pipe_video_profile profile, char *path)
          break;
       }
       case PIPE_VIDEO_CODEC_VC1: {
-         sprintf(path, "/lib/firmware/nouveau/vuc-vc1-%u", profile - PIPE_VIDEO_PROFILE_VC1_SIMPLE);
+         sprintf(path, "/lib/firmware/nouveau/vuc-vc1-0");
          break;
       }
       case PIPE_VIDEO_CODEC_MPEG4_AVC: {
@@ -440,7 +465,7 @@ nvc0_create_decoder(struct pipe_context *context,
 
 #if NVC0_DEBUG_FENCE
    ret = nouveau_bo_new(screen->device, NOUVEAU_BO_GART|NOUVEAU_BO_MAP,
-                        0, 0x1000, &cfg, &dec->fence_bo);
+                        0, 0x1000, NULL, &dec->fence_bo);
    if (ret)
       goto fail;
 
@@ -450,36 +475,42 @@ nvc0_create_decoder(struct pipe_context *context,
    dec->comm = (struct comm *)(dec->fence_map + (COMM_OFFSET/sizeof(*dec->fence_map)));
 
    /* So lets test if the fence is working? */
+   nouveau_pushbuf_space(push[0], 6, 1, 0);
+   PUSH_REFN (push[0], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR);
    BEGIN_NVC0(push[0], SUBC_BSP(0x240), 3);
    PUSH_DATAh(push[0], dec->fence_bo->offset);
    PUSH_DATA (push[0], dec->fence_bo->offset);
    PUSH_DATA (push[0], dec->fence_seq);
 
    BEGIN_NVC0(push[0], SUBC_BSP(0x304), 1);
-   PUSH_DATA (push[0], 1);
+   PUSH_DATA (push[0], 0);
    PUSH_KICK (push[0]);
 
+   nouveau_pushbuf_space(push[1], 6, 1, 0);
+   PUSH_REFN (push[1], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR);
    BEGIN_NVC0(push[1], SUBC_VP(0x240), 3);
    PUSH_DATAh(push[1], (dec->fence_bo->offset + 0x10));
    PUSH_DATA (push[1], (dec->fence_bo->offset + 0x10));
    PUSH_DATA (push[1], dec->fence_seq);
 
    BEGIN_NVC0(push[1], SUBC_VP(0x304), 1);
-   PUSH_DATA (push[1], 1);
+   PUSH_DATA (push[1], 0);
    PUSH_KICK (push[1]);
 
+   nouveau_pushbuf_space(push[2], 6, 1, 0);
+   PUSH_REFN (push[2], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR);
    BEGIN_NVC0(push[2], SUBC_PPP(0x240), 3);
    PUSH_DATAh(push[2], (dec->fence_bo->offset + 0x20));
    PUSH_DATA (push[2], (dec->fence_bo->offset + 0x20));
    PUSH_DATA (push[2], dec->fence_seq);
 
    BEGIN_NVC0(push[2], SUBC_PPP(0x304), 1);
-   PUSH_DATA (push[2], 1);
+   PUSH_DATA (push[2], 0);
    PUSH_KICK (push[2]);
 
    usleep(100);
-   while (dec->fence_seq > dec->fence_map[0] &&
-          dec->fence_seq > dec->fence_map[4] &&
+   while (dec->fence_seq > dec->fence_map[0] ||
+          dec->fence_seq > dec->fence_map[4] ||
           dec->fence_seq > dec->fence_map[8]) {
       debug_printf("%u: %u %u %u\n", dec->fence_seq, dec->fence_map[0], dec->fence_map[4], dec->fence_map[8]);
       usleep(100);