[Mesa-dev] [PATCH 7/7] st/va: start of P016 support

Christian König deathsimple at vodafone.de
Wed Jan 25 14:42:00 UTC 2017


From: Christian König <christian.koenig at amd.com>

Most likely only partially correct, but at least a start.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 src/gallium/state_trackers/va/config.c     |  9 ++++++---
 src/gallium/state_trackers/va/image.c      | 10 ++++++++++
 src/gallium/state_trackers/va/surface.c    | 28 ++++++++++++++--------------
 src/gallium/state_trackers/va/va_private.h |  3 ++-
 4 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c
index da52a58..01f1403 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -118,7 +118,9 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint en
       if (entrypoint == VAEntrypointVLD) {
          switch (attrib_list[i].type) {
          case VAConfigAttribRTFormat:
-            value = VA_RT_FORMAT_YUV420;
+	    /* TODO: this depends on the profile */
+            value = VA_RT_FORMAT_YUV420 |
+		VA_RT_FORMAT_YUV420_10BPP;
             break;
          default:
             value = VA_ATTRIB_NOT_SUPPORTED;
@@ -146,6 +148,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint en
          switch (attrib_list[i].type) {
          case VAConfigAttribRTFormat:
             value = (VA_RT_FORMAT_YUV420 |
+                     VA_RT_FORMAT_YUV420_10BPP |
                      VA_RT_FORMAT_RGB32);
             break;
          default:
@@ -187,7 +190,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
       config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
       for (int i = 0; i < num_attribs; i++) {
          if (attrib_list[i].type == VAConfigAttribRTFormat) {
-            if (attrib_list[i].value & (VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_RGB32)) {
+            if (attrib_list[i].value & (VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | VA_RT_FORMAT_RGB32)) {
                config->rt_format = attrib_list[i].value;
             } else {
                FREE(config);
@@ -198,7 +201,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
 
       /* Default value if not specified in the input attributes. */
       if (!config->rt_format)
-         config->rt_format = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_RGB32;
+         config->rt_format = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | VA_RT_FORMAT_RGB32;
 
       pipe_mutex_lock(drv->mutex);
       *config_id = handle_table_add(drv->htab, config);
diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c
index bd60d3e..4d2f6fb 100644
--- a/src/gallium/state_trackers/va/image.c
+++ b/src/gallium/state_trackers/va/image.c
@@ -41,6 +41,7 @@
 static const VAImageFormat formats[] =
 {
    {VA_FOURCC('N','V','1','2')},
+   {VA_FOURCC('P','0','1','6')},
    {VA_FOURCC('I','4','2','0')},
    {VA_FOURCC('Y','V','1','2')},
    {VA_FOURCC('Y','U','Y','V')},
@@ -134,6 +135,15 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig
       img->data_size  = w * h * 3 / 2;
       break;
 
+   case VA_FOURCC('P','0','1','6'):
+      img->num_planes = 2;
+      img->pitches[0] = w * 2;
+      img->offsets[0] = 0;
+      img->pitches[1] = w * 2;
+      img->offsets[1] = w * h * 2;
+      img->data_size  = w * h * 3;
+      break;
+
    case VA_FOURCC('I','4','2','0'):
    case VA_FOURCC('Y','V','1','2'):
       img->num_planes = 3;
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index ec9ec9d..bd73115 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -421,31 +421,30 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config_id,
 
    /* vlVaCreateConfig returns PIPE_VIDEO_PROFILE_UNKNOWN
     * only for VAEntrypointVideoProc. */
-   if (config->profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
-      if (config->rt_format & VA_RT_FORMAT_RGB32) {
-         for (j = 0; j < ARRAY_SIZE(vpp_surface_formats); ++j) {
-            attribs[i].type = VASurfaceAttribPixelFormat;
-            attribs[i].value.type = VAGenericValueTypeInteger;
-            attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
-            attribs[i].value.value.i = PipeFormatToVaFourcc(vpp_surface_formats[j]);
-            i++;
-         }
-      }
-      if (config->rt_format & VA_RT_FORMAT_YUV420) {
+   if (config->profile == PIPE_VIDEO_PROFILE_UNKNOWN &&
+       config->rt_format & VA_RT_FORMAT_RGB32) {
+      for (j = 0; j < ARRAY_SIZE(vpp_surface_formats); ++j) {
          attribs[i].type = VASurfaceAttribPixelFormat;
          attribs[i].value.type = VAGenericValueTypeInteger;
          attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
-         attribs[i].value.value.i = VA_FOURCC_NV12;
+         attribs[i].value.value.i = PipeFormatToVaFourcc(vpp_surface_formats[j]);
          i++;
       }
-   } else {
-      /* Assume VAEntrypointVLD for now. */
+   }
+   if (config->rt_format & VA_RT_FORMAT_YUV420) {
       attribs[i].type = VASurfaceAttribPixelFormat;
       attribs[i].value.type = VAGenericValueTypeInteger;
       attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
       attribs[i].value.value.i = VA_FOURCC_NV12;
       i++;
    }
+   if (config->rt_format & VA_RT_FORMAT_YUV420_10BPP) {
+      attribs[i].type = VASurfaceAttribPixelFormat;
+      attribs[i].value.type = VAGenericValueTypeInteger;
+      attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
+      attribs[i].value.value.i = VA_FOURCC_P016;
+      i++;
+   }
 
    attribs[i].type = VASurfaceAttribMemoryType;
    attribs[i].value.type = VAGenericValueTypeInteger;
@@ -625,6 +624,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
    if (VA_RT_FORMAT_YUV420 != format &&
        VA_RT_FORMAT_YUV422 != format &&
        VA_RT_FORMAT_YUV444 != format &&
+       VA_RT_FORMAT_YUV420_10BPP != format &&
        VA_RT_FORMAT_RGB32  != format) {
       return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
    }
diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h
index 0877236..8ff9e9a 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -49,7 +49,7 @@
 #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)
 #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)
 
-#define VL_VA_MAX_IMAGE_FORMATS 9
+#define VL_VA_MAX_IMAGE_FORMATS 10
 #define VL_VA_ENC_GOP_COEFF 16
 
 static inline enum pipe_video_chroma_format
@@ -57,6 +57,7 @@ ChromaToPipe(int format)
 {
    switch (format) {
    case VA_RT_FORMAT_YUV420:
+   case VA_RT_FORMAT_YUV420_10BPP:
       return PIPE_VIDEO_CHROMA_FORMAT_420;
    case VA_RT_FORMAT_YUV422:
       return PIPE_VIDEO_CHROMA_FORMAT_422;
-- 
2.7.4



More information about the mesa-dev mailing list