flip_handler_->VSyncControl(enabled);
}
+bool Display::CheckPlaneFormat(uint32_t format) {
+ return display_queue_->CheckPlaneFormat(format);
+}
+
} // namespace hwcomposer
return pipe_;
}
- int32_t Width() const override {
+ uint32_t Width() const override {
return width_;
}
- int32_t Height() const override {
+ uint32_t Height() const override {
return height_;
}
uint32_t display_id) override;
void VSyncControl(bool enabled) override;
+ bool CheckPlaneFormat(uint32_t format) override;
protected:
uint32_t CrtcId() const override {
new DisplayPlane(plane_id, possible_crtcs));
}
+bool DisplayPlaneManager::CheckPlaneFormat(uint32_t format) {
+ return primary_plane_->IsSupportedFormat(format);
+}
+
} // namespace hwcomposer
void DisablePipe(drmModeAtomicReqPtr property_set);
void EndFrameUpdate();
+ bool CheckPlaneFormat(uint32_t format);
protected:
struct OverlayPlane {
ETRACE("Could not find property %s", name);
}
+bool DisplayQueue::CheckPlaneFormat(uint32_t format) {
+ return display_plane_manager_->CheckPlaneFormat(format);
+}
+
} // namespace hwcomposer
bool QueueUpdate(std::vector<HwcLayer*>& source_layers);
bool SetPowerMode(uint32_t power_mode);
+ bool CheckPlaneFormat(uint32_t format);
void HandleExit();
void Headless::VSyncControl(bool /*enabled*/) {
}
+bool Headless::CheckPlaneFormat(uint32_t /*format*/) {
+ // assuming that virtual display supports the format
+ return true;
+}
+
} // namespace hwcomposer
return 0;
}
- int32_t Width() const override {
+ uint32_t Width() const override {
return 1;
}
- int32_t Height() const override {
+ uint32_t Height() const override {
return 1;
}
uint32_t display_id) override;
void VSyncControl(bool enabled) override;
+ bool CheckPlaneFormat(uint32_t format) override;
protected:
uint32_t CrtcId() const override {
#define LOG_TAG "hwc-drm-two"
#include "drmhwctwo.h"
+#include "drmutils.h"
#include <xf86drmMode.h>
return HWC2::Error::None;
}
-HWC2::Error DrmHwcTwo::HwcDisplay::GetClientTargetSupport(uint32_t /*width*/,
- uint32_t /*height*/,
- int32_t /*format*/,
+HWC2::Error DrmHwcTwo::HwcDisplay::GetClientTargetSupport(uint32_t width,
+ uint32_t height,
+ int32_t format,
int32_t dataspace) {
- if (dataspace != HAL_DATASPACE_UNKNOWN &&
- dataspace != HAL_DATASPACE_STANDARD_UNSPECIFIED)
+ if (width != display_->Width() || height != display_->Height()) {
return HWC2::Error::Unsupported;
+ }
- // TODO: Validate format can be handled by either GL or planes
- return HWC2::Error::None;
+ if (format == HAL_PIXEL_FORMAT_RGBA_8888 &&
+ (dataspace == HAL_DATASPACE_UNKNOWN ||
+ dataspace == HAL_DATASPACE_STANDARD_UNSPECIFIED)) {
+ return HWC2::Error::None;
+ } else {
+ // Convert HAL to fourcc-based DRM formats
+ uint32_t drm_format = GetDrmFormat(format);
+ if (display_->CheckPlaneFormat(drm_format) &&
+ (dataspace == HAL_DATASPACE_UNKNOWN ||
+ dataspace == HAL_DATASPACE_STANDARD_UNSPECIFIED))
+ return HWC2::Error::None;
+ }
+
+ return HWC2::Error::Unsupported;
}
HWC2::Error DrmHwcTwo::HwcDisplay::GetColorModes(uint32_t *num_modes,
--- /dev/null
+
+/*
+// Copyright (c) 2017 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#ifndef OS_ANDROID_DRMUTILS_H_
+#define OS_ANDROID_DRMUTILS_H_
+
+#include <stdint.h>
+#include <drm_fourcc.h>
+#include <system/graphics.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DRM_FORMAT_NONE fourcc_code('0', '0', '0', '0')
+
+// Conversion from HAL to fourcc-based DRM formats
+uint32_t GetDrmFormat(int format) {
+ switch (format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ return DRM_FORMAT_BGRA8888;
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ return DRM_FORMAT_BGRX8888;
+ case HAL_PIXEL_FORMAT_RGB_888:
+ return DRM_FORMAT_BGR888;
+ case HAL_PIXEL_FORMAT_RGB_565:
+ return DRM_FORMAT_BGR565;
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ return DRM_FORMAT_ARGB8888;
+ case HAL_PIXEL_FORMAT_YV12:
+ return DRM_FORMAT_YVU420;
+ default:
+ break;
+ }
+
+ return DRM_FORMAT_NONE;
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
virtual uint32_t Pipe() const = 0;
- virtual int32_t Width() const = 0;
+ virtual uint32_t Width() const = 0;
- virtual int32_t Height() const = 0;
+ virtual uint32_t Height() const = 0;
virtual int32_t GetRefreshRate() const = 0;
virtual void SetOutputBuffer(HWCNativeHandle /*buffer*/,
int32_t /*acquire_fence*/) {
}
+ /**
+ * API to check the format support on the device
+ * @param format valid DRM formats found in drm_fourcc.h.
+ */
+ virtual bool CheckPlaneFormat(uint32_t format) = 0;
protected:
virtual uint32_t CrtcId() const = 0;