external/drm_hwcomposer
Revisión | 30ee913030f7cb660d329f986b40c1fddcfa5b66 (tree) |
---|---|
Tiempo | 2018-11-02 15:45:27 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Merge remote-tracking branch 'origin/master' into oreo-x86
@@ -74,7 +74,9 @@ bool DrmConnector::internal() const { | ||
74 | 74 | } |
75 | 75 | |
76 | 76 | bool DrmConnector::external() const { |
77 | - return type_ == DRM_MODE_CONNECTOR_HDMIA; | |
77 | + return type_ == DRM_MODE_CONNECTOR_HDMIA || type_ == DRM_MODE_CONNECTOR_DisplayPort || | |
78 | + type_ == DRM_MODE_CONNECTOR_DVID || type_ == DRM_MODE_CONNECTOR_DVII || | |
79 | + type_ == DRM_MODE_CONNECTOR_VGA; | |
78 | 80 | } |
79 | 81 | |
80 | 82 | bool DrmConnector::valid_type() const { |
@@ -31,12 +31,7 @@ DrmCrtc::DrmCrtc(DrmResources *drm, drmModeCrtcPtr c, unsigned pipe) | ||
31 | 31 | id_(c->crtc_id), |
32 | 32 | pipe_(pipe), |
33 | 33 | display_(-1), |
34 | - x_(c->x), | |
35 | - y_(c->y), | |
36 | - width_(c->width), | |
37 | - height_(c->height), | |
38 | - mode_(&c->mode), | |
39 | - mode_valid_(c->mode_valid) { | |
34 | + mode_(&c->mode) { | |
40 | 35 | } |
41 | 36 | |
42 | 37 | int DrmCrtc::Init() { |
@@ -54,13 +54,7 @@ class DrmCrtc { | ||
54 | 54 | unsigned pipe_; |
55 | 55 | int display_; |
56 | 56 | |
57 | - uint32_t x_; | |
58 | - uint32_t y_; | |
59 | - uint32_t width_; | |
60 | - uint32_t height_; | |
61 | - | |
62 | 57 | DrmMode mode_; |
63 | - bool mode_valid_; | |
64 | 58 | |
65 | 59 | DrmProperty active_property_; |
66 | 60 | DrmProperty mode_property_; |
@@ -600,8 +600,6 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, | ||
600 | 600 | std::vector<DrmHwcLayer> &layers = display_comp->layers(); |
601 | 601 | std::vector<DrmCompositionPlane> &comp_planes = |
602 | 602 | display_comp->composition_planes(); |
603 | - std::vector<DrmCompositionRegion> &pre_comp_regions = | |
604 | - display_comp->pre_comp_regions(); | |
605 | 603 | uint64_t out_fences[drm_->crtcs().size()]; |
606 | 604 | |
607 | 605 | DrmConnector *connector = drm_->GetConnectorForDisplay(display_); |
@@ -632,6 +630,13 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, | ||
632 | 630 | } |
633 | 631 | |
634 | 632 | if (mode_.needs_modeset) { |
633 | + ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->active_property().id(), 1); | |
634 | + if (ret < 0) { | |
635 | + ALOGE("Failed to add crtc active to pset\n"); | |
636 | + drmModeAtomicFree(pset); | |
637 | + return ret; | |
638 | + } | |
639 | + | |
635 | 640 | ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->mode_property().id(), |
636 | 641 | mode_.blob_id) < 0 || |
637 | 642 | drmModeAtomicAddProperty(pset, connector->id(), |
@@ -694,7 +699,7 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, | ||
694 | 699 | else |
695 | 700 | rotation |= DRM_MODE_ROTATE_0; |
696 | 701 | |
697 | - if (fence_fd < 0) { | |
702 | + if (fence_fd >= 0) { | |
698 | 703 | int prop_id = plane->in_fence_fd_property().id(); |
699 | 704 | if (prop_id == 0) { |
700 | 705 | ALOGE("Failed to get IN_FENCE_FD property id"); |
@@ -791,7 +796,6 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, | ||
791 | 796 | } |
792 | 797 | } |
793 | 798 | |
794 | -out: | |
795 | 799 | if (!ret) { |
796 | 800 | uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET; |
797 | 801 | if (test_only) |
@@ -27,7 +27,6 @@ DrmEncoder::DrmEncoder(drmModeEncoderPtr e, DrmCrtc *current_crtc, | ||
27 | 27 | const std::vector<DrmCrtc *> &possible_crtcs) |
28 | 28 | : id_(e->encoder_id), |
29 | 29 | crtc_(current_crtc), |
30 | - type_(e->encoder_type), | |
31 | 30 | possible_crtcs_(possible_crtcs) { |
32 | 31 | } |
33 | 32 |
@@ -45,8 +45,6 @@ class DrmEncoder { | ||
45 | 45 | uint32_t id_; |
46 | 46 | DrmCrtc *crtc_; |
47 | 47 | |
48 | - uint32_t type_; | |
49 | - | |
50 | 48 | std::vector<DrmCrtc *> possible_crtcs_; |
51 | 49 | }; |
52 | 50 | } |
@@ -242,7 +242,6 @@ HWC2::Error DrmHwcTwo::HwcDisplay::RegisterVsyncCallback( | ||
242 | 242 | |
243 | 243 | HWC2::Error DrmHwcTwo::HwcDisplay::AcceptDisplayChanges() { |
244 | 244 | supported(__func__); |
245 | - uint32_t num_changes = 0; | |
246 | 245 | for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) |
247 | 246 | l.second.accept_type_change(); |
248 | 247 | return HWC2::Error::None; |
@@ -614,7 +613,7 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetActiveConfig(hwc2_config_t config) { | ||
614 | 613 | HWC2::Error DrmHwcTwo::HwcDisplay::SetClientTarget(buffer_handle_t target, |
615 | 614 | int32_t acquire_fence, |
616 | 615 | int32_t dataspace, |
617 | - hwc_region_t damage) { | |
616 | + hwc_region_t /*damage*/) { | |
618 | 617 | supported(__func__); |
619 | 618 | UniqueFd uf(acquire_fence); |
620 | 619 |
@@ -446,7 +446,6 @@ int GLWorkerCompositor::Init() { | ||
446 | 446 | const char *egl_extensions; |
447 | 447 | const char *gl_extensions; |
448 | 448 | EGLint num_configs; |
449 | - EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, EGL_NONE}; | |
450 | 449 | EGLConfig egl_config; |
451 | 450 | |
452 | 451 | // clang-format off |
@@ -142,8 +142,8 @@ int PlanStageProtected::ProvisionPlanes( | ||
142 | 142 | |
143 | 143 | int PlanStagePrecomp::ProvisionPlanes( |
144 | 144 | std::vector<DrmCompositionPlane> *composition, |
145 | - std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc, | |
146 | - std::vector<DrmPlane *> *planes) { | |
145 | + std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc * /*crtc*/, | |
146 | + std::vector<DrmPlane *> * /*planes*/) { | |
147 | 147 | DrmCompositionPlane *precomp = GetPrecomp(composition); |
148 | 148 | if (!precomp || precomp->source_layers().empty()) |
149 | 149 | return 0; |
@@ -315,102 +315,3 @@ void separate_rects_64(const std::vector<Rect<int>> &in, | ||
315 | 315 | } |
316 | 316 | |
317 | 317 | } // namespace separate_rects |
318 | - | |
319 | -#ifdef RECTS_TEST | |
320 | - | |
321 | -using namespace separate_rects; | |
322 | - | |
323 | -int main(int argc, char **argv) { | |
324 | -#define RectSet RectSet<TId, TNum> | |
325 | -#define Rect Rect<TNum> | |
326 | -#define IdSet IdSet<TId> | |
327 | - typedef uint64_t TId; | |
328 | - typedef float TNum; | |
329 | - | |
330 | - std::vector<Rect> in; | |
331 | - std::vector<RectSet> out; | |
332 | - std::vector<RectSet> expected_out; | |
333 | - | |
334 | - in.push_back({0, 0, 4, 5}); | |
335 | - in.push_back({2, 0, 6, 6}); | |
336 | - in.push_back({4, 0, 8, 5}); | |
337 | - in.push_back({0, 7, 8, 9}); | |
338 | - | |
339 | - in.push_back({10, 0, 18, 5}); | |
340 | - in.push_back({12, 0, 16, 5}); | |
341 | - | |
342 | - in.push_back({20, 11, 24, 17}); | |
343 | - in.push_back({22, 13, 26, 21}); | |
344 | - in.push_back({32, 33, 36, 37}); | |
345 | - in.push_back({30, 31, 38, 39}); | |
346 | - | |
347 | - in.push_back({40, 43, 48, 45}); | |
348 | - in.push_back({44, 41, 46, 47}); | |
349 | - | |
350 | - in.push_back({50, 51, 52, 53}); | |
351 | - in.push_back({50, 51, 52, 53}); | |
352 | - in.push_back({50, 51, 52, 53}); | |
353 | - | |
354 | - in.push_back({0, 0, 0, 10}); | |
355 | - in.push_back({0, 0, 10, 0}); | |
356 | - in.push_back({10, 0, 0, 10}); | |
357 | - in.push_back({0, 10, 10, 0}); | |
358 | - | |
359 | - for (int i = 0; i < 100000; i++) { | |
360 | - out.clear(); | |
361 | - separate_rects(in, &out); | |
362 | - } | |
363 | - | |
364 | - for (int i = 0; i < out.size(); i++) { | |
365 | - std::cout << out[i].id_set << "(" << out[i].rect << ")" << std::endl; | |
366 | - } | |
367 | - | |
368 | - std::cout << "# of rects: " << out.size() << std::endl; | |
369 | - | |
370 | - expected_out.push_back(RectSet(IdSet(0), Rect(0, 0, 2, 5))); | |
371 | - expected_out.push_back(RectSet(IdSet(1), Rect(2, 5, 6, 6))); | |
372 | - expected_out.push_back(RectSet(IdSet(1) | 0, Rect(2, 0, 4, 5))); | |
373 | - expected_out.push_back(RectSet(IdSet(1) | 2, Rect(4, 0, 6, 5))); | |
374 | - expected_out.push_back(RectSet(IdSet(2), Rect(6, 0, 8, 5))); | |
375 | - expected_out.push_back(RectSet(IdSet(3), Rect(0, 7, 8, 9))); | |
376 | - expected_out.push_back(RectSet(IdSet(4), Rect(10, 0, 12, 5))); | |
377 | - expected_out.push_back(RectSet(IdSet(5) | 4, Rect(12, 0, 16, 5))); | |
378 | - expected_out.push_back(RectSet(IdSet(4), Rect(16, 0, 18, 5))); | |
379 | - expected_out.push_back(RectSet(IdSet(6), Rect(20, 11, 22, 17))); | |
380 | - expected_out.push_back(RectSet(IdSet(6) | 7, Rect(22, 13, 24, 17))); | |
381 | - expected_out.push_back(RectSet(IdSet(6), Rect(22, 11, 24, 13))); | |
382 | - expected_out.push_back(RectSet(IdSet(7), Rect(22, 17, 24, 21))); | |
383 | - expected_out.push_back(RectSet(IdSet(7), Rect(24, 13, 26, 21))); | |
384 | - expected_out.push_back(RectSet(IdSet(9), Rect(30, 31, 32, 39))); | |
385 | - expected_out.push_back(RectSet(IdSet(8) | 9, Rect(32, 33, 36, 37))); | |
386 | - expected_out.push_back(RectSet(IdSet(9), Rect(32, 37, 36, 39))); | |
387 | - expected_out.push_back(RectSet(IdSet(9), Rect(32, 31, 36, 33))); | |
388 | - expected_out.push_back(RectSet(IdSet(9), Rect(36, 31, 38, 39))); | |
389 | - expected_out.push_back(RectSet(IdSet(10), Rect(40, 43, 44, 45))); | |
390 | - expected_out.push_back(RectSet(IdSet(10) | 11, Rect(44, 43, 46, 45))); | |
391 | - expected_out.push_back(RectSet(IdSet(11), Rect(44, 41, 46, 43))); | |
392 | - expected_out.push_back(RectSet(IdSet(11), Rect(44, 45, 46, 47))); | |
393 | - expected_out.push_back(RectSet(IdSet(10), Rect(46, 43, 48, 45))); | |
394 | - expected_out.push_back(RectSet(IdSet(12) | 13 | 14, Rect(50, 51, 52, 53))); | |
395 | - | |
396 | - for (int i = 0; i < expected_out.size(); i++) { | |
397 | - RectSet &ex_out = expected_out[i]; | |
398 | - if (std::find(out.begin(), out.end(), ex_out) == out.end()) { | |
399 | - std::cout << "Missing Rect: " << ex_out.id_set << "(" << ex_out.rect | |
400 | - << ")" << std::endl; | |
401 | - } | |
402 | - } | |
403 | - | |
404 | - for (int i = 0; i < out.size(); i++) { | |
405 | - RectSet &actual_out = out[i]; | |
406 | - if (std::find(expected_out.begin(), expected_out.end(), actual_out) == | |
407 | - expected_out.end()) { | |
408 | - std::cout << "Extra Rect: " << actual_out.id_set << "(" << actual_out.rect | |
409 | - << ")" << std::endl; | |
410 | - } | |
411 | - } | |
412 | - | |
413 | - return 0; | |
414 | -} | |
415 | - | |
416 | -#endif |
@@ -3,10 +3,12 @@ LOCAL_PATH := $(call my-dir) | ||
3 | 3 | include $(CLEAR_VARS) |
4 | 4 | |
5 | 5 | LOCAL_SRC_FILES := \ |
6 | + separate_rects_test.cpp \ | |
6 | 7 | worker_test.cpp |
7 | 8 | |
8 | 9 | LOCAL_MODULE := hwc-drm-tests |
9 | 10 | LOCAL_STATIC_LIBRARIES := libdrmhwc_utils |
11 | +LOCAL_SHARED_LIBRARIES := hwcomposer.drm | |
10 | 12 | LOCAL_C_INCLUDES := external/drm_hwcomposer |
11 | 13 | |
12 | 14 | include $(BUILD_NATIVE_TEST) |
@@ -0,0 +1,100 @@ | ||
1 | +#include <gtest/gtest.h> | |
2 | +#include <hardware/hardware.h> | |
3 | + | |
4 | +#include "separate_rects.h" | |
5 | + | |
6 | +using namespace separate_rects; | |
7 | + | |
8 | +#define RectSet RectSet<TId, TNum> | |
9 | +#define Rect Rect<TNum> | |
10 | +#define IdSet IdSet<TId> | |
11 | +typedef uint64_t TId; | |
12 | +typedef float TNum; | |
13 | + | |
14 | +struct SeparateRectTest : public testing::Test { | |
15 | + bool IsEquality(std::vector<RectSet> &out, | |
16 | + std::vector<RectSet> &expected_out) { | |
17 | + // Test for rects missing from out | |
18 | + for (size_t i = 0; i < expected_out.size(); i++) { | |
19 | + RectSet &ex_out = expected_out[i]; | |
20 | + if (std::find(out.begin(), out.end(), ex_out) == out.end()) { | |
21 | + return false; | |
22 | + } | |
23 | + } | |
24 | + | |
25 | + // Test for presence of unexpected rects in out | |
26 | + for (size_t i = 0; i < out.size(); i++) { | |
27 | + RectSet &actual_out = out[i]; | |
28 | + if (std::find(expected_out.begin(), expected_out.end(), actual_out) == | |
29 | + expected_out.end()) { | |
30 | + return false; | |
31 | + } | |
32 | + } | |
33 | + | |
34 | + return true; | |
35 | + } | |
36 | +}; | |
37 | + | |
38 | +TEST_F(SeparateRectTest, test_separate_rect) { | |
39 | + std::vector<Rect> in; | |
40 | + std::vector<RectSet> out; | |
41 | + std::vector<RectSet> expected_out; | |
42 | + | |
43 | + in.push_back({0, 0, 4, 5}); | |
44 | + in.push_back({2, 0, 6, 6}); | |
45 | + in.push_back({4, 0, 8, 5}); | |
46 | + in.push_back({0, 7, 8, 9}); | |
47 | + | |
48 | + in.push_back({10, 0, 18, 5}); | |
49 | + in.push_back({12, 0, 16, 5}); | |
50 | + | |
51 | + in.push_back({20, 11, 24, 17}); | |
52 | + in.push_back({22, 13, 26, 21}); | |
53 | + in.push_back({32, 33, 36, 37}); | |
54 | + in.push_back({30, 31, 38, 39}); | |
55 | + | |
56 | + in.push_back({40, 43, 48, 45}); | |
57 | + in.push_back({44, 41, 46, 47}); | |
58 | + | |
59 | + in.push_back({50, 51, 52, 53}); | |
60 | + in.push_back({50, 51, 52, 53}); | |
61 | + in.push_back({50, 51, 52, 53}); | |
62 | + | |
63 | + in.push_back({0, 0, 0, 10}); | |
64 | + in.push_back({0, 0, 10, 0}); | |
65 | + in.push_back({10, 0, 0, 10}); | |
66 | + in.push_back({0, 10, 10, 0}); | |
67 | + | |
68 | + for (int i = 0; i < 100000; i++) { | |
69 | + out.clear(); | |
70 | + separate_frects_64(in, &out); | |
71 | + } | |
72 | + | |
73 | + expected_out.push_back(RectSet(IdSet(0), Rect(0, 0, 2, 5))); | |
74 | + expected_out.push_back(RectSet(IdSet(1), Rect(2, 5, 6, 6))); | |
75 | + expected_out.push_back(RectSet(IdSet(1) | 0, Rect(2, 0, 4, 5))); | |
76 | + expected_out.push_back(RectSet(IdSet(1) | 2, Rect(4, 0, 6, 5))); | |
77 | + expected_out.push_back(RectSet(IdSet(2), Rect(6, 0, 8, 5))); | |
78 | + expected_out.push_back(RectSet(IdSet(3), Rect(0, 7, 8, 9))); | |
79 | + expected_out.push_back(RectSet(IdSet(4), Rect(10, 0, 12, 5))); | |
80 | + expected_out.push_back(RectSet(IdSet(5) | 4, Rect(12, 0, 16, 5))); | |
81 | + expected_out.push_back(RectSet(IdSet(4), Rect(16, 0, 18, 5))); | |
82 | + expected_out.push_back(RectSet(IdSet(6), Rect(20, 11, 22, 17))); | |
83 | + expected_out.push_back(RectSet(IdSet(6) | 7, Rect(22, 13, 24, 17))); | |
84 | + expected_out.push_back(RectSet(IdSet(6), Rect(22, 11, 24, 13))); | |
85 | + expected_out.push_back(RectSet(IdSet(7), Rect(22, 17, 24, 21))); | |
86 | + expected_out.push_back(RectSet(IdSet(7), Rect(24, 13, 26, 21))); | |
87 | + expected_out.push_back(RectSet(IdSet(9), Rect(30, 31, 32, 39))); | |
88 | + expected_out.push_back(RectSet(IdSet(8) | 9, Rect(32, 33, 36, 37))); | |
89 | + expected_out.push_back(RectSet(IdSet(9), Rect(32, 37, 36, 39))); | |
90 | + expected_out.push_back(RectSet(IdSet(9), Rect(32, 31, 36, 33))); | |
91 | + expected_out.push_back(RectSet(IdSet(9), Rect(36, 31, 38, 39))); | |
92 | + expected_out.push_back(RectSet(IdSet(10), Rect(40, 43, 44, 45))); | |
93 | + expected_out.push_back(RectSet(IdSet(10) | 11, Rect(44, 43, 46, 45))); | |
94 | + expected_out.push_back(RectSet(IdSet(11), Rect(44, 41, 46, 43))); | |
95 | + expected_out.push_back(RectSet(IdSet(11), Rect(44, 45, 46, 47))); | |
96 | + expected_out.push_back(RectSet(IdSet(10), Rect(46, 43, 48, 45))); | |
97 | + expected_out.push_back(RectSet(IdSet(12) | 13 | 14, Rect(50, 51, 52, 53))); | |
98 | + | |
99 | + ASSERT_TRUE(IsEquality(out, expected_out)); | |
100 | +} |
@@ -66,7 +66,7 @@ struct WorkerTest : public testing::Test { | ||
66 | 66 | }; |
67 | 67 | |
68 | 68 | TEST_F(WorkerTest, test_worker) { |
69 | - // already isInitialized so should fail | |
69 | + // already isInitialized so should succeed | |
70 | 70 | ASSERT_TRUE(worker.initialized()); |
71 | 71 | |
72 | 72 | int val = worker.value; |