Skip to content

Commit faff77d

Browse files
Sally QiAndroid (Google) Code Review
authored andcommitted
Merge "[LUT implementation] add Lut HAL new interface changes." into main
2 parents 1e9887e + 11dcd58 commit faff77d

13 files changed

Lines changed: 107 additions & 22 deletions

File tree

services/surfaceflinger/CompositionEngine/tests/MockHWC2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "DisplayHardware/HWC2.h"
3434

3535
#include <aidl/android/hardware/graphics/composer3/Composition.h>
36+
#include <aidl/android/hardware/graphics/composer3/Lut.h>
3637

3738
// TODO(b/129481165): remove the #pragma below and fix conversion issues
3839
#pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
@@ -77,6 +78,7 @@ class Layer : public HWC2::Layer {
7778
Error(const std::string&, bool, const std::vector<uint8_t>&));
7879
MOCK_METHOD1(setBrightness, Error(float));
7980
MOCK_METHOD1(setBlockingRegion, Error(const android::Region&));
81+
MOCK_METHOD(Error, setLuts, (std::vector<aidl::android::hardware::graphics::composer3::Lut>&));
8082
};
8183

8284
} // namespace mock

services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ class HWComposer : public android::HWComposer {
151151
getOverlaySupport, (), (const, override));
152152
MOCK_METHOD(status_t, setRefreshRateChangedCallbackDebugEnabled, (PhysicalDisplayId, bool));
153153
MOCK_METHOD(status_t, notifyExpectedPresent, (PhysicalDisplayId, TimePoint, Fps));
154+
MOCK_METHOD(status_t, getRequestedLuts,
155+
(PhysicalDisplayId,
156+
std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>*),
157+
(override));
154158
};
155159

156160
} // namespace mock

services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ Error AidlComposer::getClientTargetProperty(
15401540
return error;
15411541
}
15421542

1543-
Error AidlComposer::getDisplayLuts(Display display, std::vector<Lut>* outLuts) {
1543+
Error AidlComposer::getRequestedLuts(Display display, std::vector<DisplayLuts::LayerLut>* outLuts) {
15441544
Error error = Error::NONE;
15451545
mMutex.lock_shared();
15461546
if (auto reader = getReader(display)) {
@@ -1552,6 +1552,18 @@ Error AidlComposer::getDisplayLuts(Display display, std::vector<Lut>* outLuts) {
15521552
return error;
15531553
}
15541554

1555+
Error AidlComposer::setLayerLuts(Display display, Layer layer, std::vector<Lut>& luts) {
1556+
Error error = Error::NONE;
1557+
mMutex.lock_shared();
1558+
if (auto writer = getWriter(display)) {
1559+
writer->get().setLayerLuts(translate<int64_t>(display), translate<int64_t>(layer), luts);
1560+
} else {
1561+
error = Error::BAD_DISPLAY;
1562+
}
1563+
mMutex.unlock_shared();
1564+
return error;
1565+
}
1566+
15551567
Error AidlComposer::setLayerBrightness(Display display, Layer layer, float brightness) {
15561568
Error error = Error::NONE;
15571569
mMutex.lock_shared();

services/surfaceflinger/DisplayHardware/AidlComposerHal.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,13 @@ class AidlComposer final : public Hwc2::Composer {
244244
Error setRefreshRateChangedCallbackDebugEnabled(Display, bool) override;
245245
Error notifyExpectedPresent(Display, nsecs_t expectedPresentTime,
246246
int32_t frameIntervalNs) override;
247-
Error getDisplayLuts(
247+
Error getRequestedLuts(
248248
Display display,
249-
std::vector<aidl::android::hardware::graphics::composer3::Lut>* outLuts) override;
249+
std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>*
250+
outLuts) override;
251+
Error setLayerLuts(
252+
Display display, Layer layer,
253+
std::vector<aidl::android::hardware::graphics::composer3::Lut>& luts) override;
250254

251255
private:
252256
// Many public functions above simply write a command into the command

services/surfaceflinger/DisplayHardware/ComposerHal.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <aidl/android/hardware/graphics/composer3/Composition.h>
4141
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
4242
#include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h>
43+
#include <aidl/android/hardware/graphics/composer3/DisplayLuts.h>
4344
#include <aidl/android/hardware/graphics/composer3/IComposerCallback.h>
4445
#include <aidl/android/hardware/graphics/composer3/Lut.h>
4546
#include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>
@@ -304,7 +305,9 @@ class Composer {
304305
virtual Error setRefreshRateChangedCallbackDebugEnabled(Display, bool) = 0;
305306
virtual Error notifyExpectedPresent(Display, nsecs_t expectedPresentTime,
306307
int32_t frameIntervalNs) = 0;
307-
virtual Error getDisplayLuts(Display display, std::vector<V3_0::Lut>* outLuts) = 0;
308+
virtual Error getRequestedLuts(Display display,
309+
std::vector<V3_0::DisplayLuts::LayerLut>* outLuts) = 0;
310+
virtual Error setLayerLuts(Display display, Layer layer, std::vector<V3_0::Lut>& luts) = 0;
308311
};
309312

310313
} // namespace Hwc2

services/surfaceflinger/DisplayHardware/HWC2.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ using aidl::android::hardware::graphics::composer3::Color;
4141
using aidl::android::hardware::graphics::composer3::Composition;
4242
using AidlCapability = aidl::android::hardware::graphics::composer3::Capability;
4343
using aidl::android::hardware::graphics::composer3::DisplayCapability;
44+
using aidl::android::hardware::graphics::composer3::DisplayLuts;
4445
using aidl::android::hardware::graphics::composer3::Lut;
4546
using aidl::android::hardware::graphics::composer3::OverlayProperties;
4647

@@ -608,13 +609,14 @@ Error Display::getClientTargetProperty(
608609
return static_cast<Error>(error);
609610
}
610611

611-
Error Display::getDisplayLuts(std::vector<Lut>* outLuts) {
612-
std::vector<Lut> tmpLuts;
613-
const auto error = mComposer.getDisplayLuts(mId, &tmpLuts);
614-
for (Lut& lut : tmpLuts) {
615-
if (lut.pfd.get() >= 0) {
616-
outLuts->push_back(
617-
{lut.layer, ndk::ScopedFileDescriptor(lut.pfd.release()), lut.lutProperties});
612+
Error Display::getRequestedLuts(std::vector<DisplayLuts::LayerLut>* outLayerLuts) {
613+
std::vector<DisplayLuts::LayerLut> tmpLayerLuts;
614+
const auto error = mComposer.getRequestedLuts(mId, &tmpLayerLuts);
615+
for (DisplayLuts::LayerLut& layerLut : tmpLayerLuts) {
616+
if (layerLut.lut.pfd.get() >= 0) {
617+
outLayerLuts->push_back({layerLut.layer,
618+
Lut{ndk::ScopedFileDescriptor(layerLut.lut.pfd.release()),
619+
layerLut.lut.lutProperties}});
618620
}
619621
}
620622
return static_cast<Error>(error);
@@ -1050,6 +1052,14 @@ Error Layer::setBlockingRegion(const Region& region) {
10501052
return static_cast<Error>(intError);
10511053
}
10521054

1055+
Error Layer::setLuts(std::vector<Lut>& luts) {
1056+
if (CC_UNLIKELY(!mDisplay)) {
1057+
return Error::BAD_DISPLAY;
1058+
}
1059+
const auto intError = mComposer.setLayerLuts(mDisplay->getId(), mId, luts);
1060+
return static_cast<Error>(intError);
1061+
}
1062+
10531063
} // namespace impl
10541064
} // namespace HWC2
10551065
} // namespace android

services/surfaceflinger/DisplayHardware/HWC2.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ class Display {
179179
[[nodiscard]] virtual hal::Error getClientTargetProperty(
180180
aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness*
181181
outClientTargetProperty) = 0;
182-
[[nodiscard]] virtual hal::Error getDisplayLuts(
183-
std::vector<aidl::android::hardware::graphics::composer3::Lut>* outLuts) = 0;
182+
[[nodiscard]] virtual hal::Error getRequestedLuts(
183+
std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>*
184+
outLuts) = 0;
184185
[[nodiscard]] virtual hal::Error getDisplayDecorationSupport(
185186
std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>*
186187
support) = 0;
@@ -264,8 +265,9 @@ class Display : public HWC2::Display {
264265
hal::Error getClientTargetProperty(
265266
aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness*
266267
outClientTargetProperty) override;
267-
hal::Error getDisplayLuts(
268-
std::vector<aidl::android::hardware::graphics::composer3::Lut>* outLuts) override;
268+
hal::Error getRequestedLuts(
269+
std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>*
270+
outLuts) override;
269271
hal::Error getDisplayDecorationSupport(
270272
std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>*
271273
support) override;
@@ -359,6 +361,8 @@ class Layer {
359361
// AIDL HAL
360362
[[nodiscard]] virtual hal::Error setBrightness(float brightness) = 0;
361363
[[nodiscard]] virtual hal::Error setBlockingRegion(const android::Region& region) = 0;
364+
[[nodiscard]] virtual hal::Error setLuts(
365+
std::vector<aidl::android::hardware::graphics::composer3::Lut>& luts) = 0;
362366
};
363367

364368
namespace impl {
@@ -409,6 +413,8 @@ class Layer : public HWC2::Layer {
409413
// AIDL HAL
410414
hal::Error setBrightness(float brightness) override;
411415
hal::Error setBlockingRegion(const android::Region& region) override;
416+
hal::Error setLuts(
417+
std::vector<aidl::android::hardware::graphics::composer3::Lut>& luts) override;
412418

413419
private:
414420
// These are references to data owned by HWComposer, which will outlive

services/surfaceflinger/DisplayHardware/HWComposer.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ status_t HWComposer::getDeviceCompositionChanges(
533533

534534
DeviceRequestedChanges::ClientTargetProperty clientTargetProperty;
535535
error = hwcDisplay->getClientTargetProperty(&clientTargetProperty);
536+
RETURN_IF_HWC_ERROR_FOR("getClientTargetProperty", error, displayId, BAD_INDEX);
536537

537538
outChanges->emplace(DeviceRequestedChanges{std::move(changedTypes), std::move(displayRequests),
538539
std::move(layerRequests),
@@ -925,6 +926,21 @@ status_t HWComposer::getDisplayDecorationSupport(
925926
return NO_ERROR;
926927
}
927928

929+
status_t HWComposer::getRequestedLuts(
930+
PhysicalDisplayId displayId,
931+
std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>* outLuts) {
932+
RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
933+
const auto error = mDisplayData[displayId].hwcDisplay->getRequestedLuts(outLuts);
934+
if (error == hal::Error::UNSUPPORTED) {
935+
RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
936+
}
937+
if (error == hal::Error::BAD_PARAMETER) {
938+
RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
939+
}
940+
RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
941+
return NO_ERROR;
942+
}
943+
928944
status_t HWComposer::setAutoLowLatencyMode(PhysicalDisplayId displayId, bool on) {
929945
RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
930946
const auto error = mDisplayData[displayId].hwcDisplay->setAutoLowLatencyMode(on);

services/surfaceflinger/DisplayHardware/HWComposer.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <aidl/android/hardware/graphics/composer3/ClientTargetPropertyWithBrightness.h>
5353
#include <aidl/android/hardware/graphics/composer3/Composition.h>
5454
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
55+
#include <aidl/android/hardware/graphics/composer3/DisplayLuts.h>
5556
#include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>
5657

5758
namespace android {
@@ -309,6 +310,11 @@ class HWComposer {
309310
virtual status_t setRefreshRateChangedCallbackDebugEnabled(PhysicalDisplayId, bool enabled) = 0;
310311
virtual status_t notifyExpectedPresent(PhysicalDisplayId, TimePoint expectedPresentTime,
311312
Fps frameInterval) = 0;
313+
314+
// Composer 4.0
315+
virtual status_t getRequestedLuts(
316+
PhysicalDisplayId,
317+
std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>*) = 0;
312318
};
313319

314320
static inline bool operator==(const android::HWComposer::DeviceRequestedChanges& lhs,
@@ -472,6 +478,12 @@ class HWComposer final : public android::HWComposer {
472478
status_t notifyExpectedPresent(PhysicalDisplayId, TimePoint expectedPresentTime,
473479
Fps frameInterval) override;
474480

481+
// Composer 4.0
482+
status_t getRequestedLuts(
483+
PhysicalDisplayId,
484+
std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>*)
485+
override;
486+
475487
// for debugging ----------------------------------------------------------
476488
void dump(std::string& out) const override;
477489
void dumpOverlayProperties(std::string& out) const override;

services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ using aidl::android::hardware::graphics::composer3::Capability;
4646
using aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness;
4747
using aidl::android::hardware::graphics::composer3::DimmingStage;
4848
using aidl::android::hardware::graphics::composer3::DisplayCapability;
49+
using aidl::android::hardware::graphics::composer3::DisplayLuts;
4950
using aidl::android::hardware::graphics::composer3::Lut;
5051
using aidl::android::hardware::graphics::composer3::OverlayProperties;
5152

@@ -1409,7 +1410,11 @@ Error HidlComposer::getClientTargetProperty(
14091410
return Error::NONE;
14101411
}
14111412

1412-
Error HidlComposer::getDisplayLuts(Display, std::vector<Lut>*) {
1413+
Error HidlComposer::getRequestedLuts(Display, std::vector<DisplayLuts::LayerLut>*) {
1414+
return Error::NONE;
1415+
}
1416+
1417+
Error HidlComposer::setLayerLuts(Display, Layer, std::vector<Lut>&) {
14131418
return Error::NONE;
14141419
}
14151420

0 commit comments

Comments
 (0)