aboutsummaryrefslogtreecommitdiff
path: root/drm
diff options
context:
space:
mode:
authorRoman Stratiienko <r.stratiienko@gmail.com>2020-08-29 11:26:16 +0300
committerRoman Stratiienko <r.stratiienko@gmail.com>2020-09-08 22:34:52 +0300
commitaa3cd5456293a2a30a142824e58fd8dd92e628c6 (patch)
tree0281eeaad8815f0a23d4439db457e63c654592d2 /drm
parentfbf5c0ca45b3c4dd1d9621eb5198c3d43f1afbf6 (diff)
downloaddrm_hwcomposer-aa3cd5456293a2a30a142824e58fd8dd92e628c6.tar.gz
drm_hwcomposer: move header files into source directory
... to improve navigation between source/header file. Unnecessary dependencies also removed. Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com> Change-Id: I2c3bf993b8c5f356490433fd94e90011487a1276
Diffstat (limited to 'drm')
-rw-r--r--drm/drmconnector.h116
-rw-r--r--drm/drmcrtc.h65
-rw-r--r--drm/drmdevice.cpp5
-rw-r--r--drm/drmdevice.h110
-rw-r--r--drm/drmencoder.cpp1
-rw-r--r--drm/drmencoder.h60
-rw-r--r--drm/drmeventlistener.h65
-rw-r--r--drm/drmmode.cpp4
-rw-r--r--drm/drmmode.h83
-rw-r--r--drm/drmplane.cpp1
-rw-r--r--drm/drmplane.h88
-rw-r--r--drm/drmproperty.h79
-rw-r--r--drm/resourcemanager.cpp1
-rw-r--r--drm/resourcemanager.h60
-rw-r--r--drm/vsyncworker.cpp4
-rw-r--r--drm/vsyncworker.h68
16 files changed, 794 insertions, 16 deletions
diff --git a/drm/drmconnector.h b/drm/drmconnector.h
new file mode 100644
index 0000000..0c19c55
--- /dev/null
+++ b/drm/drmconnector.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_CONNECTOR_H_
+#define ANDROID_DRM_CONNECTOR_H_
+
+#include <stdint.h>
+#include <xf86drmMode.h>
+
+#include <string>
+#include <vector>
+
+#include "drmencoder.h"
+#include "drmmode.h"
+#include "drmproperty.h"
+
+namespace android {
+
+class DrmDevice;
+
+class DrmConnector {
+ public:
+ DrmConnector(DrmDevice *drm, drmModeConnectorPtr c,
+ DrmEncoder *current_encoder,
+ std::vector<DrmEncoder *> &possible_encoders);
+ DrmConnector(const DrmProperty &) = delete;
+ DrmConnector &operator=(const DrmProperty &) = delete;
+
+ int Init();
+
+ uint32_t id() const;
+
+ int display() const;
+ void set_display(int display);
+
+ bool internal() const;
+ bool external() const;
+ bool writeback() const;
+ bool valid_type() const;
+
+ std::string name() const;
+
+ int UpdateModes();
+
+ const std::vector<DrmMode> &modes() const {
+ return modes_;
+ }
+ const DrmMode &active_mode() const;
+ void set_active_mode(const DrmMode &mode);
+
+ const DrmProperty &dpms_property() const;
+ const DrmProperty &crtc_id_property() const;
+ const DrmProperty &edid_property() const;
+ const DrmProperty &writeback_pixel_formats() const;
+ const DrmProperty &writeback_fb_id() const;
+ const DrmProperty &writeback_out_fence() const;
+
+ const std::vector<DrmEncoder *> &possible_encoders() const {
+ return possible_encoders_;
+ }
+ DrmEncoder *encoder() const;
+ void set_encoder(DrmEncoder *encoder);
+
+ drmModeConnection state() const;
+
+ uint32_t mm_width() const;
+ uint32_t mm_height() const;
+
+ uint32_t get_preferred_mode_id() const {
+ return preferred_mode_id_;
+ }
+
+ private:
+ DrmDevice *drm_;
+
+ uint32_t id_;
+ DrmEncoder *encoder_;
+ int display_;
+
+ uint32_t type_;
+ uint32_t type_id_;
+ drmModeConnection state_;
+
+ uint32_t mm_width_;
+ uint32_t mm_height_;
+
+ DrmMode active_mode_;
+ std::vector<DrmMode> modes_;
+
+ DrmProperty dpms_property_;
+ DrmProperty crtc_id_property_;
+ DrmProperty edid_property_;
+ DrmProperty writeback_pixel_formats_;
+ DrmProperty writeback_fb_id_;
+ DrmProperty writeback_out_fence_;
+
+ std::vector<DrmEncoder *> possible_encoders_;
+
+ uint32_t preferred_mode_id_;
+};
+} // namespace android
+
+#endif // ANDROID_DRM_PLANE_H_
diff --git a/drm/drmcrtc.h b/drm/drmcrtc.h
new file mode 100644
index 0000000..132c2d3
--- /dev/null
+++ b/drm/drmcrtc.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_CRTC_H_
+#define ANDROID_DRM_CRTC_H_
+
+#include <stdint.h>
+#include <xf86drmMode.h>
+
+#include "drmmode.h"
+#include "drmproperty.h"
+
+namespace android {
+
+class DrmDevice;
+
+class DrmCrtc {
+ public:
+ DrmCrtc(DrmDevice *drm, drmModeCrtcPtr c, unsigned pipe);
+ DrmCrtc(const DrmCrtc &) = delete;
+ DrmCrtc &operator=(const DrmCrtc &) = delete;
+
+ int Init();
+
+ uint32_t id() const;
+ unsigned pipe() const;
+
+ int display() const;
+ void set_display(int display);
+
+ bool can_bind(int display) const;
+
+ const DrmProperty &active_property() const;
+ const DrmProperty &mode_property() const;
+ const DrmProperty &out_fence_ptr_property() const;
+
+ private:
+ DrmDevice *drm_;
+
+ uint32_t id_;
+ unsigned pipe_;
+ int display_;
+
+ DrmMode mode_;
+
+ DrmProperty active_property_;
+ DrmProperty mode_property_;
+ DrmProperty out_fence_ptr_property_;
+};
+} // namespace android
+
+#endif // ANDROID_DRM_CRTC_H_
diff --git a/drm/drmdevice.cpp b/drm/drmdevice.cpp
index 91fe158..18b5b62 100644
--- a/drm/drmdevice.cpp
+++ b/drm/drmdevice.cpp
@@ -17,11 +17,6 @@
#define LOG_TAG "hwc-drm-device"
#include "drmdevice.h"
-#include "drmconnector.h"
-#include "drmcrtc.h"
-#include "drmencoder.h"
-#include "drmeventlistener.h"
-#include "drmplane.h"
#include <errno.h>
#include <fcntl.h>
diff --git a/drm/drmdevice.h b/drm/drmdevice.h
new file mode 100644
index 0000000..6a8de47
--- /dev/null
+++ b/drm/drmdevice.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_H_
+#define ANDROID_DRM_H_
+
+#include <stdint.h>
+
+#include <tuple>
+
+#include "drmconnector.h"
+#include "drmcrtc.h"
+#include "drmencoder.h"
+#include "drmeventlistener.h"
+#include "drmplane.h"
+#include "platform/platform.h"
+
+namespace android {
+
+class DrmDevice {
+ public:
+ DrmDevice();
+ ~DrmDevice();
+
+ std::tuple<int, int> Init(const char *path, int num_displays);
+
+ int fd() const {
+ return fd_.get();
+ }
+
+ const std::vector<std::unique_ptr<DrmConnector>> &connectors() const {
+ return connectors_;
+ }
+
+ const std::vector<std::unique_ptr<DrmPlane>> &planes() const {
+ return planes_;
+ }
+
+ std::pair<uint32_t, uint32_t> min_resolution() const {
+ return min_resolution_;
+ }
+
+ std::pair<uint32_t, uint32_t> max_resolution() const {
+ return max_resolution_;
+ }
+
+ DrmConnector *GetConnectorForDisplay(int display) const;
+ DrmConnector *GetWritebackConnectorForDisplay(int display) const;
+ DrmConnector *AvailableWritebackConnector(int display) const;
+ DrmCrtc *GetCrtcForDisplay(int display) const;
+ DrmPlane *GetPlane(uint32_t id) const;
+ DrmEventListener *event_listener();
+
+ int GetPlaneProperty(const DrmPlane &plane, const char *prop_name,
+ DrmProperty *property);
+ int GetCrtcProperty(const DrmCrtc &crtc, const char *prop_name,
+ DrmProperty *property);
+ int GetConnectorProperty(const DrmConnector &connector, const char *prop_name,
+ DrmProperty *property);
+
+ const std::string GetName() const;
+
+ const std::vector<std::unique_ptr<DrmCrtc>> &crtcs() const;
+ uint32_t next_mode_id();
+
+ int CreatePropertyBlob(void *data, size_t length, uint32_t *blob_id);
+ int DestroyPropertyBlob(uint32_t blob_id);
+ bool HandlesDisplay(int display) const;
+ void RegisterHotplugHandler(DrmEventHandler *handler) {
+ event_listener_.RegisterHotplugHandler(handler);
+ }
+
+ private:
+ int TryEncoderForDisplay(int display, DrmEncoder *enc);
+ int GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name,
+ DrmProperty *property);
+
+ int CreateDisplayPipe(DrmConnector *connector);
+ int AttachWriteback(DrmConnector *display_conn);
+
+ UniqueFd fd_;
+ uint32_t mode_id_ = 0;
+
+ std::vector<std::unique_ptr<DrmConnector>> connectors_;
+ std::vector<std::unique_ptr<DrmConnector>> writeback_connectors_;
+ std::vector<std::unique_ptr<DrmEncoder>> encoders_;
+ std::vector<std::unique_ptr<DrmCrtc>> crtcs_;
+ std::vector<std::unique_ptr<DrmPlane>> planes_;
+ DrmEventListener event_listener_;
+
+ std::pair<uint32_t, uint32_t> min_resolution_;
+ std::pair<uint32_t, uint32_t> max_resolution_;
+ std::map<int, int> displays_;
+};
+} // namespace android
+
+#endif // ANDROID_DRM_H_
diff --git a/drm/drmencoder.cpp b/drm/drmencoder.cpp
index c36fca1..9aa6805 100644
--- a/drm/drmencoder.cpp
+++ b/drm/drmencoder.cpp
@@ -15,7 +15,6 @@
*/
#include "drmencoder.h"
-#include "drmcrtc.h"
#include "drmdevice.h"
#include <stdint.h>
diff --git a/drm/drmencoder.h b/drm/drmencoder.h
new file mode 100644
index 0000000..4403d9f
--- /dev/null
+++ b/drm/drmencoder.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_ENCODER_H_
+#define ANDROID_DRM_ENCODER_H_
+
+#include <stdint.h>
+#include <xf86drmMode.h>
+
+#include <set>
+#include <vector>
+
+#include "drmcrtc.h"
+
+namespace android {
+
+class DrmEncoder {
+ public:
+ DrmEncoder(drmModeEncoderPtr e, DrmCrtc *current_crtc,
+ const std::vector<DrmCrtc *> &possible_crtcs);
+ DrmEncoder(const DrmEncoder &) = delete;
+ DrmEncoder &operator=(const DrmEncoder &) = delete;
+
+ uint32_t id() const;
+
+ DrmCrtc *crtc() const;
+ void set_crtc(DrmCrtc *crtc);
+ bool can_bind(int display) const;
+ int display() const;
+
+ const std::vector<DrmCrtc *> &possible_crtcs() const {
+ return possible_crtcs_;
+ }
+ bool CanClone(DrmEncoder *encoder);
+ void AddPossibleClone(DrmEncoder *possible_clone);
+
+ private:
+ uint32_t id_;
+ DrmCrtc *crtc_;
+ int display_;
+
+ std::vector<DrmCrtc *> possible_crtcs_;
+ std::set<DrmEncoder *> possible_clones_;
+};
+} // namespace android
+
+#endif // ANDROID_DRM_ENCODER_H_
diff --git a/drm/drmeventlistener.h b/drm/drmeventlistener.h
new file mode 100644
index 0000000..ff3b8e5
--- /dev/null
+++ b/drm/drmeventlistener.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_EVENT_LISTENER_H_
+#define ANDROID_DRM_EVENT_LISTENER_H_
+
+#include "autofd.h"
+#include "utils/worker.h"
+
+namespace android {
+
+class DrmDevice;
+
+class DrmEventHandler {
+ public:
+ DrmEventHandler() {
+ }
+ virtual ~DrmEventHandler() {
+ }
+
+ virtual void HandleEvent(uint64_t timestamp_us) = 0;
+};
+
+class DrmEventListener : public Worker {
+ public:
+ DrmEventListener(DrmDevice *drm);
+ virtual ~DrmEventListener() {
+ }
+
+ int Init();
+
+ void RegisterHotplugHandler(DrmEventHandler *handler);
+
+ static void FlipHandler(int fd, unsigned int sequence, unsigned int tv_sec,
+ unsigned int tv_usec, void *user_data);
+
+ protected:
+ virtual void Routine();
+
+ private:
+ void UEventHandler();
+
+ fd_set fds_;
+ UniqueFd uevent_fd_;
+ int max_fd_ = -1;
+
+ DrmDevice *drm_;
+ std::unique_ptr<DrmEventHandler> hotplug_handler_;
+};
+} // namespace android
+
+#endif
diff --git a/drm/drmmode.cpp b/drm/drmmode.cpp
index c3ab385..c1398ef 100644
--- a/drm/drmmode.cpp
+++ b/drm/drmmode.cpp
@@ -17,10 +17,6 @@
#include "drmmode.h"
#include "drmdevice.h"
-#include <stdint.h>
-#include <xf86drmMode.h>
-#include <string>
-
namespace android {
DrmMode::DrmMode(drmModeModeInfoPtr m)
diff --git a/drm/drmmode.h b/drm/drmmode.h
new file mode 100644
index 0000000..313a8ea
--- /dev/null
+++ b/drm/drmmode.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_MODE_H_
+#define ANDROID_DRM_MODE_H_
+
+#include <stdint.h>
+#include <xf86drmMode.h>
+
+#include <string>
+
+namespace android {
+
+class DrmMode {
+ public:
+ DrmMode() = default;
+ DrmMode(drmModeModeInfoPtr m);
+
+ bool operator==(const drmModeModeInfo &m) const;
+ void ToDrmModeModeInfo(drm_mode_modeinfo *m) const;
+
+ uint32_t id() const;
+ void set_id(uint32_t id);
+
+ uint32_t clock() const;
+
+ uint32_t h_display() const;
+ uint32_t h_sync_start() const;
+ uint32_t h_sync_end() const;
+ uint32_t h_total() const;
+ uint32_t h_skew() const;
+
+ uint32_t v_display() const;
+ uint32_t v_sync_start() const;
+ uint32_t v_sync_end() const;
+ uint32_t v_total() const;
+ uint32_t v_scan() const;
+ float v_refresh() const;
+
+ uint32_t flags() const;
+ uint32_t type() const;
+
+ std::string name() const;
+
+ private:
+ uint32_t id_ = 0;
+
+ uint32_t clock_ = 0;
+
+ uint32_t h_display_ = 0;
+ uint32_t h_sync_start_ = 0;
+ uint32_t h_sync_end_ = 0;
+ uint32_t h_total_ = 0;
+ uint32_t h_skew_ = 0;
+
+ uint32_t v_display_ = 0;
+ uint32_t v_sync_start_ = 0;
+ uint32_t v_sync_end_ = 0;
+ uint32_t v_total_ = 0;
+ uint32_t v_scan_ = 0;
+ uint32_t v_refresh_ = 0;
+
+ uint32_t flags_ = 0;
+ uint32_t type_ = 0;
+
+ std::string name_;
+};
+} // namespace android
+
+#endif // ANDROID_DRM_MODE_H_
diff --git a/drm/drmplane.cpp b/drm/drmplane.cpp
index 6f1bf9b..f0c7559 100644
--- a/drm/drmplane.cpp
+++ b/drm/drmplane.cpp
@@ -24,7 +24,6 @@
#include <cinttypes>
#include <log/log.h>
-#include <xf86drmMode.h>
namespace android {
diff --git a/drm/drmplane.h b/drm/drmplane.h
new file mode 100644
index 0000000..1a4dc91
--- /dev/null
+++ b/drm/drmplane.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_PLANE_H_
+#define ANDROID_DRM_PLANE_H_
+
+#include <stdint.h>
+#include <xf86drmMode.h>
+
+#include <vector>
+
+#include "drmcrtc.h"
+#include "drmproperty.h"
+
+namespace android {
+
+class DrmDevice;
+
+class DrmPlane {
+ public:
+ DrmPlane(DrmDevice *drm, drmModePlanePtr p);
+ DrmPlane(const DrmPlane &) = delete;
+ DrmPlane &operator=(const DrmPlane &) = delete;
+
+ int Init();
+
+ uint32_t id() const;
+
+ bool GetCrtcSupported(const DrmCrtc &crtc) const;
+
+ uint32_t type() const;
+
+ const DrmProperty &crtc_property() const;
+ const DrmProperty &fb_property() const;
+ const DrmProperty &crtc_x_property() const;
+ const DrmProperty &crtc_y_property() const;
+ const DrmProperty &crtc_w_property() const;
+ const DrmProperty &crtc_h_property() const;
+ const DrmProperty &src_x_property() const;
+ const DrmProperty &src_y_property() const;
+ const DrmProperty &src_w_property() const;
+ const DrmProperty &src_h_property() const;
+ const DrmProperty &zpos_property() const;
+ const DrmProperty &rotation_property() const;
+ const DrmProperty &alpha_property() const;
+ const DrmProperty &blend_property() const;
+ const DrmProperty &in_fence_fd_property() const;
+
+ private:
+ DrmDevice *drm_;
+ uint32_t id_;
+
+ uint32_t possible_crtc_mask_;
+
+ uint32_t type_;
+
+ DrmProperty crtc_property_;
+ DrmProperty fb_property_;
+ DrmProperty crtc_x_property_;
+ DrmProperty crtc_y_property_;
+ DrmProperty crtc_w_property_;
+ DrmProperty crtc_h_property_;
+ DrmProperty src_x_property_;
+ DrmProperty src_y_property_;
+ DrmProperty src_w_property_;
+ DrmProperty src_h_property_;
+ DrmProperty zpos_property_;
+ DrmProperty rotation_property_;
+ DrmProperty alpha_property_;
+ DrmProperty blend_property_;
+ DrmProperty in_fence_fd_property_;
+};
+} // namespace android
+
+#endif // ANDROID_DRM_PLANE_H_
diff --git a/drm/drmproperty.h b/drm/drmproperty.h
new file mode 100644
index 0000000..d293da3
--- /dev/null
+++ b/drm/drmproperty.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_DRM_PROPERTY_H_
+#define ANDROID_DRM_PROPERTY_H_
+
+#include <stdint.h>
+#include <xf86drmMode.h>
+
+#include <string>
+#include <vector>
+
+namespace android {
+
+enum DrmPropertyType {
+ DRM_PROPERTY_TYPE_INT,
+ DRM_PROPERTY_TYPE_ENUM,
+ DRM_PROPERTY_TYPE_OBJECT,
+ DRM_PROPERTY_TYPE_BLOB,
+ DRM_PROPERTY_TYPE_INVALID,
+};
+
+class DrmProperty {
+ public:
+ DrmProperty() = default;
+ DrmProperty(drmModePropertyPtr p, uint64_t value);
+ DrmProperty(const DrmProperty &) = delete;
+ DrmProperty &operator=(const DrmProperty &) = delete;
+
+ void Init(drmModePropertyPtr p, uint64_t value);
+ std::tuple<uint64_t, int> GetEnumValueWithName(std::string name) const;
+
+ uint32_t id() const;
+ std::string name() const;
+
+ std::tuple<int, uint64_t> value() const;
+ bool is_immutable() const;
+
+ bool is_range() const;
+ std::tuple<int, uint64_t> range_min() const;
+ std::tuple<int, uint64_t> range_max() const;
+
+ private:
+ class DrmPropertyEnum {
+ public:
+ DrmPropertyEnum(drm_mode_property_enum *e);
+ ~DrmPropertyEnum();
+
+ uint64_t value_;
+ std::string name_;
+ };
+
+ uint32_t id_ = 0;
+
+ DrmPropertyType type_ = DRM_PROPERTY_TYPE_INVALID;
+ uint32_t flags_ = 0;
+ std::string name_;
+ uint64_t value_ = 0;
+
+ std::vector<uint64_t> values_;
+ std::vector<DrmPropertyEnum> enums_;
+ std::vector<uint32_t> blob_ids_;
+};
+} // namespace android
+
+#endif // ANDROID_DRM_PROPERTY_H_
diff --git a/drm/resourcemanager.cpp b/drm/resourcemanager.cpp
index 986d4ab..45fa818 100644
--- a/drm/resourcemanager.cpp
+++ b/drm/resourcemanager.cpp
@@ -22,7 +22,6 @@
#include <log/log.h>
#include <sys/stat.h>
#include <sstream>
-#include <string>
namespace android {
diff --git a/drm/resourcemanager.h b/drm/resourcemanager.h
new file mode 100644
index 0000000..4afa842
--- /dev/null
+++ b/drm/resourcemanager.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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 RESOURCEMANAGER_H
+#define RESOURCEMANAGER_H
+
+#include <string.h>
+
+#include "drmdevice.h"
+#include "platform/platform.h"
+
+namespace android {
+
+class ResourceManager {
+ public:
+ ResourceManager();
+ ResourceManager(const ResourceManager &) = delete;
+ ResourceManager &operator=(const ResourceManager &) = delete;
+ int Init();
+ DrmDevice *GetDrmDevice(int display);
+ std::shared_ptr<Importer> GetImporter(int display);
+ const gralloc_module_t *gralloc();
+ DrmConnector *AvailableWritebackConnector(int display);
+ const std::vector<std::unique_ptr<DrmDevice>> &getDrmDevices() const {
+ return drms_;
+ }
+ int getDisplayCount() const {
+ return num_displays_;
+ }
+ bool ForcedScalingWithGpu() {
+ return scale_with_gpu_;
+ }
+
+ private:
+ int AddDrmDevice(std::string path);
+ static bool IsKMSDev(const char *path);
+
+ int num_displays_;
+ std::vector<std::unique_ptr<DrmDevice>> drms_;
+ std::vector<std::shared_ptr<Importer>> importers_;
+ const gralloc_module_t *gralloc_;
+
+ bool scale_with_gpu_;
+};
+} // namespace android
+
+#endif // RESOURCEMANAGER_H
diff --git a/drm/vsyncworker.cpp b/drm/vsyncworker.cpp
index 08ab301..55dbd26 100644
--- a/drm/vsyncworker.cpp
+++ b/drm/vsyncworker.cpp
@@ -17,16 +17,12 @@
#define LOG_TAG "hwc-vsync-worker"
#include "vsyncworker.h"
-#include "drmdevice.h"
-#include "worker.h"
#include <stdlib.h>
#include <time.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
-#include <map>
-#include <hardware/hardware.h>
#include <log/log.h>
namespace android {
diff --git a/drm/vsyncworker.h b/drm/vsyncworker.h
new file mode 100644
index 0000000..cbf4ffa
--- /dev/null
+++ b/drm/vsyncworker.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 ANDROID_EVENT_WORKER_H_
+#define ANDROID_EVENT_WORKER_H_
+
+#include <hardware/hardware.h>
+#include <hardware/hwcomposer.h>
+#include <stdint.h>
+
+#include <map>
+
+#include "drmdevice.h"
+#include "utils/worker.h"
+
+namespace android {
+
+class VsyncCallback {
+ public:
+ virtual ~VsyncCallback() {
+ }
+ virtual void Callback(int display, int64_t timestamp) = 0;
+};
+
+class VSyncWorker : public Worker {
+ public:
+ VSyncWorker();
+ ~VSyncWorker() override;
+
+ int Init(DrmDevice *drm, int display);
+ void RegisterCallback(std::shared_ptr<VsyncCallback> callback);
+
+ void VSyncControl(bool enabled);
+
+ protected:
+ void Routine() override;
+
+ private:
+ int64_t GetPhasedVSync(int64_t frame_ns, int64_t current);
+ int SyntheticWaitVBlank(int64_t *timestamp);
+
+ DrmDevice *drm_;
+
+ // shared_ptr since we need to use this outside of the thread lock (to
+ // actually call the hook) and we don't want the memory freed until we're
+ // done
+ std::shared_ptr<VsyncCallback> callback_ = NULL;
+
+ int display_;
+ std::atomic_bool enabled_;
+ int64_t last_timestamp_;
+};
+} // namespace android
+
+#endif