Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 633332 | Differences between
and this patch

Collapse All | Expand All

(-)dev/media/gpu/vaapi_wrapper.cc (-5 / +62 lines)
Lines 9-14 Link Here
9
9
10
#include <va/va.h>
10
#include <va/va.h>
11
11
12
#include <string>
13
#include <fstream>
14
#include <sstream>
15
12
#include "base/bind.h"
16
#include "base/bind.h"
13
#include "base/callback_helpers.h"
17
#include "base/callback_helpers.h"
14
#include "base/logging.h"
18
#include "base/logging.h"
Lines 443-448 bool VaapiWrapper::AreAttribsSupported_L Link Here
443
  return true;
447
  return true;
444
}
448
}
445
449
450
int VaapiWrapper::va_fb_res_width = VA_FB_RES_DEFAULT_WIDTH;
451
int VaapiWrapper::va_fb_res_height = VA_FB_RES_DEFAULT_HEIGHT;
452
453
void VaapiWrapper::SetFallbackResolution(int w, int h)
454
{
455
  va_fb_res_width = w;
456
  va_fb_res_height = h;
457
}
458
459
void VaapiWrapper::GetFallbackResolution(gfx::Size* resolution)
460
{
461
  resolution->SetSize(va_fb_res_width, va_fb_res_height);
462
}
463
446
bool VaapiWrapper::GetMaxResolution_Locked(
464
bool VaapiWrapper::GetMaxResolution_Locked(
447
    VAProfile va_profile,
465
    VAProfile va_profile,
448
    VAEntrypoint entrypoint,
466
    VAEntrypoint entrypoint,
Lines 461-467 bool VaapiWrapper::GetMaxResolution_Lock Link Here
461
  unsigned int num_attribs;
479
  unsigned int num_attribs;
462
  va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, nullptr,
480
  va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, nullptr,
463
                                    &num_attribs);
481
                                    &num_attribs);
464
  VA_SUCCESS_OR_RETURN(va_res, "vaQuerySurfaceAttributes failed", false);
482
  if (va_res != VA_STATUS_SUCCESS) {
483
    LOG_VA_ERROR_AND_REPORT(va_res, "vaQuerySurfaceAttributes failed, returning fallback resolution");
484
    GetFallbackResolution(resolution);
485
    return true;
486
  }
465
  if (!num_attribs)
487
  if (!num_attribs)
466
    return false;
488
    return false;
467
489
Lines 470-476 bool VaapiWrapper::GetMaxResolution_Lock Link Here
470
492
471
  va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, &attrib_list[0],
493
  va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, &attrib_list[0],
472
                                    &num_attribs);
494
                                    &num_attribs);
473
  VA_SUCCESS_OR_RETURN(va_res, "vaQuerySurfaceAttributes failed", false);
495
  if (va_res != VA_STATUS_SUCCESS) {
496
    LOG_VA_ERROR_AND_REPORT(va_res, "vaQuerySurfaceAttributes failed, returning fallback resolution");
497
    GetFallbackResolution(resolution);
498
    return true;
499
  }
474
500
475
  resolution->SetSize(0, 0);
501
  resolution->SetSize(0, 0);
476
  for (const auto& attrib : attrib_list) {
502
  for (const auto& attrib : attrib_list) {
Lines 480-488 bool VaapiWrapper::GetMaxResolution_Lock Link Here
480
      resolution->set_height(attrib.value.value.i);
506
      resolution->set_height(attrib.value.value.i);
481
  }
507
  }
482
  if (resolution->IsEmpty()) {
508
  if (resolution->IsEmpty()) {
483
    LOG(ERROR) << "Codec resolution " << resolution->ToString()
509
    GetFallbackResolution(resolution);
484
               << " cannot be zero.";
485
    return false;
486
  }
510
  }
487
  return true;
511
  return true;
488
}
512
}
Lines 1108-1113 void VaapiWrapper::DeinitializeVpp() { Link Here
1108
1132
1109
// static
1133
// static
1110
void VaapiWrapper::PreSandboxInitialization() {
1134
void VaapiWrapper::PreSandboxInitialization() {
1135
  int w=VA_FB_RES_DEFAULT_WIDTH, h=VA_FB_RES_DEFAULT_HEIGHT;
1136
  std::string line;
1137
  // Open fallback resolution file before sandbox initialization
1138
  std::ifstream va_fb_res_file(VA_FALLBACK_RESOLUTION_FILENAME);
1139
  // If the file exists, open and read the resolution
1140
  // If not successful, use default values
1141
  if(va_fb_res_file.is_open()){
1142
    LOG(INFO) << "Opened fallback resolution file: " << VA_FALLBACK_RESOLUTION_FILENAME;
1143
    if(std::getline(va_fb_res_file,line)){
1144
      std::istringstream iss(line);
1145
      if(!((iss >> w) && (iss >> h))){
1146
        w=VA_FB_RES_DEFAULT_WIDTH;
1147
        h=VA_FB_RES_DEFAULT_HEIGHT;
1148
        LOG(ERROR) << "Could not read values. Please check that\
1149
         the first line has two space separated integers indicating\
1150
         the width and height in that order.";
1151
      }
1152
      else if( w<1 || h<1)
1153
      {
1154
        w=VA_FB_RES_DEFAULT_WIDTH;
1155
        h=VA_FB_RES_DEFAULT_HEIGHT;
1156
        LOG(WARNING) << "Non-positive dimension(s) specified. \
1157
        Using default values instead.";
1158
      }
1159
    }
1160
    else
1161
      LOG(ERROR) << "Failed to read resolution";
1162
  }
1163
  else
1164
    LOG(ERROR) << "Failed to open fallback resolution file: " << VA_FALLBACK_RESOLUTION_FILENAME;
1165
  va_fb_res_file.close();
1166
  LOG(INFO) << "Resolution used: " << w << " x " << h;
1167
  SetFallbackResolution(w,h);
1111
#if defined(USE_OZONE)
1168
#if defined(USE_OZONE)
1112
  const char kDriRenderNode0Path[] = "/dev/dri/renderD128";
1169
  const char kDriRenderNode0Path[] = "/dev/dri/renderD128";
1113
  base::File drm_file = base::File(
1170
  base::File drm_file = base::File(
(-)dev/media/gpu/vaapi_wrapper.h (+10 lines)
Lines 41-46 class NativePixmap; Link Here
41
}
41
}
42
#endif
42
#endif
43
43
44
#define VA_FB_RES_DEFAULT_WIDTH 1920
45
#define VA_FB_RES_DEFAULT_HEIGHT 1088 // Yes, this should be 1088.
46
#define VA_FALLBACK_RESOLUTION_FILENAME "/etc/chromium-browser/va_fallback_resolution"
47
44
namespace media {
48
namespace media {
45
49
46
// This class handles VA-API calls and ensures proper locking of VA-API calls
50
// This class handles VA-API calls and ensures proper locking of VA-API calls
Lines 295-300 class MEDIA_GPU_EXPORT VaapiWrapper Link Here
295
      VAProfile va_profile,
299
      VAProfile va_profile,
296
      VAEntrypoint entrypoint,
300
      VAEntrypoint entrypoint,
297
      const std::vector<VAConfigAttrib>& required_attribs);
301
      const std::vector<VAConfigAttrib>& required_attribs);
302
  
303
  static int va_fb_res_width, va_fb_res_height;
304
  // Set the maximum fallback resolution
305
  static void SetFallbackResolution(int w, int h);
306
  // Get the maximum fallback resolution
307
  static void GetFallbackResolution(gfx::Size* resolution);
298
308
299
  // Get maximum resolution for |va_profile| and |entrypoint| with
309
  // Get maximum resolution for |va_profile| and |entrypoint| with
300
  // |required_attribs|. If return value is true, |resolution| is the maximum
310
  // |required_attribs|. If return value is true, |resolution| is the maximum

Return to bug 633332