| Index: ui/gfx/ozone/dri/hardware_display_controller.cc
|
| diff --git a/ui/gfx/ozone/dri/hardware_display_controller.cc b/ui/gfx/ozone/dri/hardware_display_controller.cc
|
| index 6accfc00d536c278c60bc2e7b8007421de0d6adf..48f8700f0219e3ae1e8ae5903a82199b3e2758ce 100644
|
| --- a/ui/gfx/ozone/dri/hardware_display_controller.cc
|
| +++ b/ui/gfx/ozone/dri/hardware_display_controller.cc
|
| @@ -11,11 +11,83 @@
|
| #include "base/logging.h"
|
| #include "base/time/time.h"
|
| #include "ui/gfx/ozone/dri/dri_skbitmap.h"
|
| -#include "ui/gfx/ozone/dri/dri_surface.h"
|
| #include "ui/gfx/ozone/dri/dri_wrapper.h"
|
| +#include "ui/gfx/ozone/dri/dri_surface.h"
|
| +#include "ui/gfx/ozone/dri/scanout_surface.h"
|
|
|
| namespace gfx {
|
|
|
| +static unsigned FindOverlayPlane(DriWrapper* drm) {
|
| + unsigned int plane_index;
|
| + int i;
|
| + drmModeRes* device_res = NULL;
|
| + drmModePlane* plane_info = NULL;
|
| + int crtc_id;
|
| +
|
| + device_res = drmModeGetResources(drm->get_fd());
|
| + drmModePlaneRes* planes_res = drmModeGetPlaneResources(drm->get_fd());
|
| +
|
| + char buffer[1024];
|
| +
|
| + if (planes_res) {
|
| + for (plane_index = 0; plane_index < planes_res->count_planes;
|
| + ++plane_index) {
|
| + uint32_t planei = planes_res->planes[plane_index];
|
| + plane_info = drmModeGetPlane(drm->get_fd(), planei);
|
| + if (!plane_info)
|
| + continue;
|
| +
|
| + for (unsigned int j = 0; j < plane_info->count_formats; j++) {
|
| + sprintf(buffer, " %4.4s", (char*)&plane_info->formats[j]);
|
| + LOG(ERROR) << __FUNCTION__ << " " << buffer;
|
| + }
|
| +
|
| + sprintf(buffer,
|
| + "%d\t%d\t%d\t%d,%d\t\t%d,%d\t%-8d\t0x%08x",
|
| + plane_info->plane_id,
|
| + plane_info->crtc_id,
|
| + plane_info->fb_id,
|
| + plane_info->crtc_x,
|
| + plane_info->crtc_y,
|
| + plane_info->x,
|
| + plane_info->y,
|
| + plane_info->gamma_size,
|
| + plane_info->possible_crtcs);
|
| +
|
| + LOG(ERROR) << __FUNCTION__ << " Props " << buffer;
|
| +
|
| + // Assume that every plane supports one and only one CRTC.
|
| + crtc_id = 0;
|
| + for (i = 0; i < device_res->count_crtcs; ++i) {
|
| + if (plane_info->possible_crtcs & (1UL << i)) {
|
| + crtc_id = device_res->crtcs[i];
|
| + break;
|
| + }
|
| + }
|
| + if (crtc_id == 0) {
|
| + LOG(ERROR) << __FUNCTION__
|
| + << "Could not find a CRTC compatible with plane";
|
| + continue;
|
| + }
|
| + if (plane_info->possible_crtcs >> (i + 1)) {
|
| + LOG(ERROR) << __FUNCTION__
|
| + << "Video plane %lu supports more than one CRTC";
|
| + }
|
| +
|
| + LOG(ERROR) << __FUNCTION__ << " ---> Using video plane "
|
| + << (unsigned long)plane_info->plane_id << " on crtc "
|
| + << (unsigned long)crtc_id;
|
| +
|
| + if (plane_info->plane_id)
|
| + return plane_info->plane_id;
|
| + }
|
| + } else {
|
| + LOG(ERROR) << __FUNCTION__ << "No plain res";
|
| + }
|
| +
|
| + return 0;
|
| +}
|
| +
|
| HardwareDisplayController::HardwareDisplayController()
|
| : drm_(NULL),
|
| connector_id_(0),
|
| @@ -24,7 +96,9 @@ HardwareDisplayController::HardwareDisplayController()
|
| saved_crtc_(NULL),
|
| state_(UNASSOCIATED),
|
| surface_(),
|
| - time_of_last_flip_(0) {}
|
| + time_of_last_flip_(0),
|
| + overlay_plane_fb_id_(0),
|
| + overlay_plane_(0) {}
|
|
|
| void HardwareDisplayController::SetControllerInfo(
|
| DriWrapper* drm,
|
| @@ -47,42 +121,48 @@ HardwareDisplayController::~HardwareDisplayController() {
|
| DLOG(ERROR) << "Failed to restore CRTC state: " << strerror(errno);
|
| drm_->FreeCrtc(saved_crtc_);
|
| }
|
| -
|
| - if (surface_.get()) {
|
| - // Unregister the buffers.
|
| - for (int i = 0; i < 2; ++i) {
|
| - if (!drm_->RemoveFramebuffer(surface_->bitmaps_[i]->get_framebuffer()))
|
| - DLOG(ERROR) << "Failed to remove FB: " << strerror(errno);
|
| - }
|
| - }
|
| }
|
|
|
| bool
|
| HardwareDisplayController::BindSurfaceToController(
|
| - scoped_ptr<DriSurface> surface) {
|
| + scoped_ptr<ScanoutSurface> surface) {
|
| CHECK(state_ == UNINITIALIZED);
|
|
|
| - // Register the buffers.
|
| - for (int i = 0; i < 2; ++i) {
|
| - uint32_t fb_id;
|
| - if (!drm_->AddFramebuffer(mode_,
|
| - surface->bitmaps_[i]->GetColorDepth(),
|
| - surface->bitmaps_[i]->bytesPerPixel() << 3,
|
| - surface->bitmaps_[i]->rowBytes(),
|
| - surface->bitmaps_[i]->get_handle(),
|
| - &fb_id)) {
|
| - DLOG(ERROR) << "Failed to register framebuffer: " << strerror(errno);
|
| - state_ = FAILED;
|
| - return false;
|
| - }
|
| - surface->bitmaps_[i]->set_framebuffer(fb_id);
|
| - }
|
| -
|
| surface_.reset(surface.release());
|
| state_ = SURFACE_INITIALIZED;
|
| return true;
|
| }
|
|
|
| +bool HardwareDisplayController::AddFramebuffer(
|
| + uint8_t depth,
|
| + uint8_t bpp,
|
| + uint32_t stride,
|
| + uint32_t handle,
|
| + uint32_t* framebuffer_id) {
|
| + CHECK(state_ != UNASSOCIATED && state_ != FAILED);
|
| + if (!drm_->AddFramebuffer(mode_,
|
| + depth,
|
| + bpp,
|
| + stride,
|
| + handle,
|
| + framebuffer_id)){
|
| + DLOG(ERROR) << "Failed to register framebuffer: " << strerror(errno);
|
| + state_ = FAILED;
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +bool HardwareDisplayController::RemoveFramebuffer(
|
| + uint32_t framebuffer_id) {
|
| + CHECK(state_ != UNASSOCIATED);
|
| + if (!drm_->RemoveFramebuffer(framebuffer_id)) {
|
| + DLOG(ERROR) << "Failed to remove FB: " << strerror(errno);
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| bool HardwareDisplayController::SchedulePageFlip() {
|
| CHECK(state_ == SURFACE_INITIALIZED || state_ == INITIALIZED);
|
|
|
| @@ -99,6 +179,8 @@ bool HardwareDisplayController::SchedulePageFlip() {
|
| state_ = INITIALIZED;
|
| }
|
|
|
| + overlay_plane_ = FindOverlayPlane(drm_);
|
| +
|
| if (dpms_property_id_)
|
| drm_->ConnectorSetProperty(connector_id_,
|
| dpms_property_id_,
|
| @@ -107,6 +189,10 @@ bool HardwareDisplayController::SchedulePageFlip() {
|
|
|
| if (!drm_->PageFlip(crtc_id_,
|
| surface_->GetFramebufferId(),
|
| + overlay_plane_rect_,
|
| + overlay_plane_size_,
|
| + overlay_plane_fb_id_,
|
| + overlay_plane_,
|
| this)) {
|
| state_ = FAILED;
|
| LOG(ERROR) << "Cannot page flip: " << strerror(errno);
|
| @@ -126,4 +212,13 @@ void HardwareDisplayController::OnPageFlipEvent(unsigned int frame,
|
| surface_->SwapBuffers();
|
| }
|
|
|
| +void HardwareDisplayController::SetOverlayPlaneInfo(
|
| + gfx::Rect overlay_plane_rect,
|
| + gfx::Size overlay_plane_size,
|
| + unsigned overlay_plane_fb_id) {
|
| + overlay_plane_rect_ = overlay_plane_rect;
|
| + overlay_plane_size_ = overlay_plane_size;
|
| + overlay_plane_fb_id_ = overlay_plane_fb_id;
|
| +}
|
| +
|
| } // namespace gfx
|
|
|