Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
  4.  * Copyright 2014 Advanced Micro Devices, Inc.
  5.  * All Rights Reserved.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the
  9.  * "Software"), to deal in the Software without restriction, including
  10.  * without limitation the rights to use, copy, modify, merge, publish,
  11.  * distribute, sub license, and/or sell copies of the Software, and to
  12.  * permit persons to whom the Software is furnished to do so, subject to
  13.  * the following conditions:
  14.  *
  15.  * The above copyright notice and this permission notice (including the
  16.  * next paragraph) shall be included in all copies or substantial portions
  17.  * of the Software.
  18.  *
  19.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  22.  * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
  23.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  24.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  25.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26.  *
  27.  **************************************************************************/
  28.  
  29. #include "pipe/p_screen.h"
  30.  
  31. #include "vl/vl_winsys.h"
  32.  
  33. #include "va_private.h"
  34.  
  35. VAStatus
  36. vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_profiles)
  37. {
  38.    struct pipe_screen *pscreen;
  39.    enum pipe_video_profile p;
  40.    VAProfile vap;
  41.  
  42.    if (!ctx)
  43.       return VA_STATUS_ERROR_INVALID_CONTEXT;
  44.  
  45.    *num_profiles = 0;
  46.  
  47.    pscreen = VL_VA_PSCREEN(ctx);
  48.    for (p = PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; p <= PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; ++p)
  49.       if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED)) {
  50.          vap = PipeToProfile(p);
  51.          if (vap != VAProfileNone)
  52.             profile_list[(*num_profiles)++] = vap;
  53.       }
  54.  
  55.    return VA_STATUS_SUCCESS;
  56. }
  57.  
  58. VAStatus
  59. vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile,
  60.                            VAEntrypoint *entrypoint_list, int *num_entrypoints)
  61. {
  62.    struct pipe_screen *pscreen;
  63.    enum pipe_video_profile p;
  64.  
  65.    if (!ctx)
  66.       return VA_STATUS_ERROR_INVALID_CONTEXT;
  67.  
  68.    *num_entrypoints = 0;
  69.  
  70.    p = ProfileToPipe(profile);
  71.    if (p == PIPE_VIDEO_PROFILE_UNKNOWN)
  72.       return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
  73.  
  74.    pscreen = VL_VA_PSCREEN(ctx);
  75.    if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED))
  76.       return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
  77.  
  78.    entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
  79.  
  80.    return VA_STATUS_SUCCESS;
  81. }
  82.  
  83. VAStatus
  84. vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
  85.                         VAConfigAttrib *attrib_list, int num_attribs)
  86. {
  87.    int i;
  88.  
  89.    if (!ctx)
  90.       return VA_STATUS_ERROR_INVALID_CONTEXT;
  91.  
  92.    for (i = 0; i < num_attribs; ++i) {
  93.       unsigned int value;
  94.       switch (attrib_list[i].type) {
  95.       case VAConfigAttribRTFormat:
  96.          value = VA_RT_FORMAT_YUV420;
  97.          break;
  98.       case VAConfigAttribRateControl:
  99.          value = VA_RC_NONE;
  100.          break;
  101.       default:
  102.          value = VA_ATTRIB_NOT_SUPPORTED;
  103.          break;
  104.       }
  105.       attrib_list[i].value = value;
  106.    }
  107.  
  108.    return VA_STATUS_SUCCESS;
  109. }
  110.  
  111. VAStatus
  112. vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
  113.                  VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id)
  114. {
  115.    struct pipe_screen *pscreen;
  116.    enum pipe_video_profile p;
  117.  
  118.    if (!ctx)
  119.       return VA_STATUS_ERROR_INVALID_CONTEXT;
  120.  
  121.    p = ProfileToPipe(profile);
  122.    if (p == PIPE_VIDEO_PROFILE_UNKNOWN)
  123.       return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
  124.  
  125.    pscreen = VL_VA_PSCREEN(ctx);
  126.    if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED))
  127.       return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
  128.  
  129.    if (entrypoint != VAEntrypointVLD)
  130.       return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
  131.  
  132.    *config_id = p;
  133.  
  134.    return VA_STATUS_SUCCESS;
  135. }
  136.  
  137. VAStatus
  138. vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id)
  139. {
  140.    if (!ctx)
  141.       return VA_STATUS_ERROR_INVALID_CONTEXT;
  142.  
  143.    return VA_STATUS_SUCCESS;
  144. }
  145.  
  146. VAStatus
  147. vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile *profile,
  148.                           VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs)
  149. {
  150.    if (!ctx)
  151.       return VA_STATUS_ERROR_INVALID_CONTEXT;
  152.  
  153.    *profile = PipeToProfile(config_id);
  154.    *entrypoint = VAEntrypointVLD;
  155.  
  156.    *num_attribs = 1;
  157.    attrib_list[0].type = VAConfigAttribRTFormat;
  158.    attrib_list[0].value = VA_RT_FORMAT_YUV420;
  159.  
  160.    return VA_STATUS_SUCCESS;
  161. }
  162.