sm8250-common: livedisplay: Use modules from common implementation
Change-Id: Iafb9f6a56187beb574ca2eb9a97fb9c7e72893ce
This commit is contained in:
parent
743d5a812f
commit
3210166b58
6 changed files with 19 additions and 473 deletions
|
@ -19,8 +19,9 @@ cc_binary {
|
||||||
defaults: ["hidl_defaults"],
|
defaults: ["hidl_defaults"],
|
||||||
relative_install_path: "hw",
|
relative_install_path: "hw",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
":vendor.lineage.livedisplay@2.0-sdm-pa",
|
||||||
|
":vendor.lineage.livedisplay@2.0-sdm-utils",
|
||||||
"DisplayModes.cpp",
|
"DisplayModes.cpp",
|
||||||
"PictureAdjustment.cpp",
|
|
||||||
"SunlightEnhancement.cpp",
|
"SunlightEnhancement.cpp",
|
||||||
"service.cpp",
|
"service.cpp",
|
||||||
],
|
],
|
||||||
|
@ -32,4 +33,8 @@ cc_binary {
|
||||||
"libutils",
|
"libutils",
|
||||||
"vendor.lineage.livedisplay@2.0",
|
"vendor.lineage.livedisplay@2.0",
|
||||||
],
|
],
|
||||||
|
header_libs: [
|
||||||
|
"vendor.lineage.livedisplay@2.0-sdm-headers",
|
||||||
|
],
|
||||||
|
cflags: ["-DLIVES_IN_SYSTEM"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS 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 VENDOR_LINEAGE_LIVEDISPLAY_V2_0_CONSTANTS_H
|
|
||||||
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_CONSTANTS_H
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
#define DPPS_BUF_SIZE 64
|
|
||||||
|
|
||||||
#define FOSS_PROPERTY "ro.vendor.display.foss"
|
|
||||||
#define FOSS_ON "foss:on"
|
|
||||||
#define FOSS_OFF "foss:off"
|
|
||||||
|
|
||||||
#define COLOR_BALANCE_FEATURE 3
|
|
||||||
#define DISPLAY_MODES_FEATURE 4
|
|
||||||
#define PICTURE_ADJUSTMENT_FEATURE 1
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_0
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_CONSTANTS_H
|
|
|
@ -1,216 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "PictureAdjustment.h"
|
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
#include "Constants.h"
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
static sp<PictureAdjustment> sInstance;
|
|
||||||
|
|
||||||
PictureAdjustment::PictureAdjustment(void* libHandle, uint64_t cookie) {
|
|
||||||
sInstance = this;
|
|
||||||
|
|
||||||
mLibHandle = libHandle;
|
|
||||||
mCookie = cookie;
|
|
||||||
disp_api_get_feature_version =
|
|
||||||
reinterpret_cast<int32_t (*)(uint64_t, uint32_t, void*, uint32_t*)>(
|
|
||||||
dlsym(mLibHandle, "disp_api_get_feature_version"));
|
|
||||||
disp_api_get_global_pa_range = reinterpret_cast<int32_t (*)(uint64_t, uint32_t, void*)>(
|
|
||||||
dlsym(mLibHandle, "disp_api_get_global_pa_range"));
|
|
||||||
disp_api_get_global_pa_config =
|
|
||||||
reinterpret_cast<int32_t (*)(uint64_t, uint32_t, uint32_t*, void*)>(
|
|
||||||
dlsym(mLibHandle, "disp_api_get_global_pa_config"));
|
|
||||||
disp_api_set_global_pa_config =
|
|
||||||
reinterpret_cast<int32_t (*)(uint64_t, uint32_t, uint32_t, void*)>(
|
|
||||||
dlsym(mLibHandle, "disp_api_set_global_pa_config"));
|
|
||||||
memset(&mDefaultPictureAdjustment, 0, sizeof(HSIC));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PictureAdjustment::isSupported() {
|
|
||||||
sdm_feature_version version{};
|
|
||||||
hsic_ranges r{};
|
|
||||||
uint32_t flags = 0;
|
|
||||||
static int supported = -1;
|
|
||||||
|
|
||||||
if (supported >= 0) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disp_api_get_feature_version == nullptr ||
|
|
||||||
disp_api_get_feature_version(mCookie, PICTURE_ADJUSTMENT_FEATURE, &version, &flags) != 0) {
|
|
||||||
supported = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version.x <= 0 && version.y <= 0 && version.z <= 0) {
|
|
||||||
supported = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disp_api_get_global_pa_range == nullptr ||
|
|
||||||
disp_api_get_global_pa_range(mCookie, 0, &r) != 0) {
|
|
||||||
supported = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
supported = r.hue.max != 0 && r.hue.min != 0 && r.saturation.max != 0.f &&
|
|
||||||
r.saturation.min != 0.f && r.intensity.max != 0.f && r.intensity.min != 0.f &&
|
|
||||||
r.contrast.max != 0.f && r.contrast.min != 0.f;
|
|
||||||
out:
|
|
||||||
return supported;
|
|
||||||
}
|
|
||||||
|
|
||||||
HSIC PictureAdjustment::getPictureAdjustmentInternal() {
|
|
||||||
hsic_config config{};
|
|
||||||
uint32_t enable = 0;
|
|
||||||
|
|
||||||
if (disp_api_get_global_pa_config != nullptr) {
|
|
||||||
if (disp_api_get_global_pa_config(mCookie, 0, &enable, &config) == 0) {
|
|
||||||
return HSIC{static_cast<float>(config.data.hue), config.data.saturation,
|
|
||||||
config.data.intensity, config.data.contrast,
|
|
||||||
config.data.saturationThreshold};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return HSIC{};
|
|
||||||
}
|
|
||||||
|
|
||||||
void PictureAdjustment::updateDefaultPictureAdjustment() {
|
|
||||||
if (sInstance != nullptr) {
|
|
||||||
sInstance->mDefaultPictureAdjustment = sInstance->getPictureAdjustmentInternal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methods from ::vendor::lineage::livedisplay::V2_0::IPictureAdjustment follow.
|
|
||||||
Return<void> PictureAdjustment::getHueRange(getHueRange_cb _hidl_cb) {
|
|
||||||
FloatRange range{};
|
|
||||||
hsic_ranges r{};
|
|
||||||
|
|
||||||
if (disp_api_get_global_pa_range != nullptr) {
|
|
||||||
if (disp_api_get_global_pa_range(mCookie, 0, &r) == 0) {
|
|
||||||
range.max = r.hue.max;
|
|
||||||
range.min = r.hue.min;
|
|
||||||
range.step = r.hue.step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_hidl_cb(range);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> PictureAdjustment::getSaturationRange(getSaturationRange_cb _hidl_cb) {
|
|
||||||
FloatRange range{};
|
|
||||||
hsic_ranges r{};
|
|
||||||
|
|
||||||
if (disp_api_get_global_pa_range != nullptr) {
|
|
||||||
if (disp_api_get_global_pa_range(mCookie, 0, &r) == 0) {
|
|
||||||
range.max = r.saturation.max;
|
|
||||||
range.min = r.saturation.min;
|
|
||||||
range.step = r.saturation.step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_hidl_cb(range);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> PictureAdjustment::getIntensityRange(getIntensityRange_cb _hidl_cb) {
|
|
||||||
FloatRange range{};
|
|
||||||
hsic_ranges r{};
|
|
||||||
|
|
||||||
if (disp_api_get_global_pa_range != nullptr) {
|
|
||||||
if (disp_api_get_global_pa_range(mCookie, 0, &r) == 0) {
|
|
||||||
range.max = r.intensity.max;
|
|
||||||
range.min = r.intensity.min;
|
|
||||||
range.step = r.intensity.step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_hidl_cb(range);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> PictureAdjustment::getContrastRange(getContrastRange_cb _hidl_cb) {
|
|
||||||
FloatRange range{};
|
|
||||||
hsic_ranges r{};
|
|
||||||
|
|
||||||
if (disp_api_get_global_pa_range != nullptr) {
|
|
||||||
if (disp_api_get_global_pa_range(mCookie, 0, &r) == 0) {
|
|
||||||
range.max = r.contrast.max;
|
|
||||||
range.min = r.contrast.min;
|
|
||||||
range.step = r.contrast.step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_hidl_cb(range);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> PictureAdjustment::getSaturationThresholdRange(
|
|
||||||
getSaturationThresholdRange_cb _hidl_cb) {
|
|
||||||
FloatRange range{};
|
|
||||||
hsic_ranges r{};
|
|
||||||
|
|
||||||
if (disp_api_get_global_pa_range != nullptr) {
|
|
||||||
if (disp_api_get_global_pa_range(mCookie, 0, &r) == 0) {
|
|
||||||
range.max = r.saturationThreshold.max;
|
|
||||||
range.min = r.saturationThreshold.min;
|
|
||||||
range.step = r.saturationThreshold.step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_hidl_cb(range);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> PictureAdjustment::getPictureAdjustment(getPictureAdjustment_cb _hidl_cb) {
|
|
||||||
_hidl_cb(getPictureAdjustmentInternal());
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> PictureAdjustment::getDefaultPictureAdjustment(
|
|
||||||
getDefaultPictureAdjustment_cb _hidl_cb) {
|
|
||||||
_hidl_cb(mDefaultPictureAdjustment);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<bool> PictureAdjustment::setPictureAdjustment(
|
|
||||||
const ::vendor::lineage::livedisplay::V2_0::HSIC& hsic) {
|
|
||||||
hsic_config config = {0,
|
|
||||||
{static_cast<int32_t>(hsic.hue), hsic.saturation, hsic.intensity,
|
|
||||||
hsic.contrast, hsic.saturationThreshold}};
|
|
||||||
|
|
||||||
if (disp_api_set_global_pa_config != nullptr) {
|
|
||||||
return disp_api_set_global_pa_config(mCookie, 0, 1, &config) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_0
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS 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 VENDOR_LINEAGE_LIVEDISPLAY_V2_0_PICTUREADJUSTMENT_H
|
|
||||||
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_PICTUREADJUSTMENT_H
|
|
||||||
|
|
||||||
#include <vendor/lineage/livedisplay/2.0/IPictureAdjustment.h>
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::sp;
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
|
|
||||||
class PictureAdjustment : public IPictureAdjustment {
|
|
||||||
public:
|
|
||||||
PictureAdjustment(void* libHandle, uint64_t cookie);
|
|
||||||
|
|
||||||
bool isSupported();
|
|
||||||
|
|
||||||
// Methods from ::vendor::lineage::livedisplay::V2_0::IPictureAdjustment follow.
|
|
||||||
Return<void> getHueRange(getHueRange_cb _hidl_cb) override;
|
|
||||||
Return<void> getSaturationRange(getSaturationRange_cb _hidl_cb) override;
|
|
||||||
Return<void> getIntensityRange(getIntensityRange_cb _hidl_cb) override;
|
|
||||||
Return<void> getContrastRange(getContrastRange_cb _hidl_cb) override;
|
|
||||||
Return<void> getSaturationThresholdRange(getSaturationThresholdRange_cb _hidl_cb) override;
|
|
||||||
Return<void> getPictureAdjustment(getPictureAdjustment_cb _hidl_cb) override;
|
|
||||||
Return<void> getDefaultPictureAdjustment(getDefaultPictureAdjustment_cb _hidl_cb) override;
|
|
||||||
Return<bool> setPictureAdjustment(
|
|
||||||
const ::vendor::lineage::livedisplay::V2_0::HSIC& hsic) override;
|
|
||||||
|
|
||||||
static void updateDefaultPictureAdjustment();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void* mLibHandle;
|
|
||||||
uint64_t mCookie;
|
|
||||||
|
|
||||||
int32_t (*disp_api_get_feature_version)(uint64_t, uint32_t, void*, uint32_t*);
|
|
||||||
int32_t (*disp_api_get_global_pa_range)(uint64_t, uint32_t, void*);
|
|
||||||
int32_t (*disp_api_get_global_pa_config)(uint64_t, uint32_t, uint32_t*, void*);
|
|
||||||
int32_t (*disp_api_set_global_pa_config)(uint64_t, uint32_t, uint32_t, void*);
|
|
||||||
|
|
||||||
HSIC getPictureAdjustmentInternal();
|
|
||||||
|
|
||||||
HSIC mDefaultPictureAdjustment;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_0
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_PICTUREADJUSTMENT_H
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The LineageOS 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 VENDOR_LINEAGE_LIVEDISPLAY_V2_0_TYPES_H
|
|
||||||
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_TYPES_H
|
|
||||||
|
|
||||||
namespace vendor {
|
|
||||||
namespace lineage {
|
|
||||||
namespace livedisplay {
|
|
||||||
namespace V2_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
struct sdm_feature_version {
|
|
||||||
uint8_t x, y;
|
|
||||||
uint16_t z;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sdm_disp_mode {
|
|
||||||
int32_t id;
|
|
||||||
int32_t type;
|
|
||||||
int32_t len;
|
|
||||||
char* name;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hsic_data {
|
|
||||||
int32_t hue;
|
|
||||||
float saturation;
|
|
||||||
float intensity;
|
|
||||||
float contrast;
|
|
||||||
float saturationThreshold;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hsic_config {
|
|
||||||
uint32_t unused;
|
|
||||||
hsic_data data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hsic_int_range {
|
|
||||||
int32_t max;
|
|
||||||
int32_t min;
|
|
||||||
uint32_t step;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hsic_float_range {
|
|
||||||
float max;
|
|
||||||
float min;
|
|
||||||
float step;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hsic_ranges {
|
|
||||||
uint32_t unused;
|
|
||||||
struct hsic_int_range hue;
|
|
||||||
struct hsic_float_range saturation;
|
|
||||||
struct hsic_float_range intensity;
|
|
||||||
struct hsic_float_range contrast;
|
|
||||||
struct hsic_float_range saturationThreshold;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V2_0
|
|
||||||
} // namespace livedisplay
|
|
||||||
} // namespace lineage
|
|
||||||
} // namespace vendor
|
|
||||||
|
|
||||||
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_TYPES_H
|
|
|
@ -14,18 +14,14 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
#define LOG_TAG "lineage.livedisplay@2.0-service.oneplus_kona"
|
#define LOG_TAG "lineage.livedisplay@2.0-service.oneplus_kona"
|
||||||
|
|
||||||
#define SDM_DISP_LIB "libsdm-disp-apis.qti.so"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <binder/ProcessState.h>
|
#include <binder/ProcessState.h>
|
||||||
#include <hidl/HidlTransportSupport.h>
|
#include <hidl/HidlTransportSupport.h>
|
||||||
|
#include <livedisplay/sdm/PictureAdjustment.h>
|
||||||
|
|
||||||
#include "DisplayModes.h"
|
#include "DisplayModes.h"
|
||||||
#include "PictureAdjustment.h"
|
|
||||||
#include "SunlightEnhancement.h"
|
#include "SunlightEnhancement.h"
|
||||||
|
|
||||||
using android::OK;
|
using android::OK;
|
||||||
|
@ -38,53 +34,21 @@ using ::vendor::lineage::livedisplay::V2_0::IDisplayModes;
|
||||||
using ::vendor::lineage::livedisplay::V2_0::IPictureAdjustment;
|
using ::vendor::lineage::livedisplay::V2_0::IPictureAdjustment;
|
||||||
using ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement;
|
using ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement;
|
||||||
using ::vendor::lineage::livedisplay::V2_0::implementation::DisplayModes;
|
using ::vendor::lineage::livedisplay::V2_0::implementation::DisplayModes;
|
||||||
using ::vendor::lineage::livedisplay::V2_0::implementation::PictureAdjustment;
|
|
||||||
using ::vendor::lineage::livedisplay::V2_0::implementation::SunlightEnhancement;
|
using ::vendor::lineage::livedisplay::V2_0::implementation::SunlightEnhancement;
|
||||||
|
using ::vendor::lineage::livedisplay::V2_0::sdm::PictureAdjustment;
|
||||||
|
using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// Vendor backend
|
|
||||||
void* libHandle = nullptr;
|
|
||||||
const char* libName = nullptr;
|
|
||||||
int32_t (*disp_api_init)(uint64_t*, uint32_t) = nullptr;
|
|
||||||
int32_t (*disp_api_deinit)(uint64_t, uint32_t) = nullptr;
|
|
||||||
uint64_t cookie = 0;
|
|
||||||
|
|
||||||
// HIDL frontend
|
|
||||||
sp<DisplayModes> dm;
|
|
||||||
sp<PictureAdjustment> pa;
|
|
||||||
sp<SunlightEnhancement> se;
|
|
||||||
|
|
||||||
status_t status = OK;
|
status_t status = OK;
|
||||||
|
|
||||||
android::ProcessState::initWithDriver("/dev/binder");
|
android::ProcessState::initWithDriver("/dev/binder");
|
||||||
|
|
||||||
LOG(INFO) << "LiveDisplay HAL service is starting.";
|
LOG(INFO) << "LiveDisplay HAL service is starting.";
|
||||||
|
|
||||||
libHandle = dlopen(SDM_DISP_LIB, RTLD_NOW);
|
std::shared_ptr<SDMController> controller = std::make_shared<SDMController>();
|
||||||
if (libHandle == nullptr) {
|
sp<DisplayModes> dm;
|
||||||
LOG(ERROR) << "Failed to load SDM display lib, exiting.";
|
sp<PictureAdjustment> pa;
|
||||||
goto shutdown;
|
sp<SunlightEnhancement> se;
|
||||||
}
|
|
||||||
|
|
||||||
disp_api_init =
|
|
||||||
reinterpret_cast<int32_t (*)(uint64_t*, uint32_t)>(dlsym(libHandle, "disp_api_init"));
|
|
||||||
if (disp_api_init == nullptr) {
|
|
||||||
LOG(ERROR) << "Can not get disp_api_init from " << libName << " (" << dlerror() << ")";
|
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
disp_api_deinit =
|
|
||||||
reinterpret_cast<int32_t (*)(uint64_t, uint32_t)>(dlsym(libHandle, "disp_api_deinit"));
|
|
||||||
if (disp_api_deinit == nullptr) {
|
|
||||||
LOG(ERROR) << "Can not get disp_api_deinit from " << libName << " (" << dlerror() << ")";
|
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = disp_api_init(&cookie, 0);
|
|
||||||
if (status != OK) {
|
|
||||||
LOG(ERROR) << "Can not initialize " << libName << " (" << status << ")";
|
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
dm = new DisplayModes();
|
dm = new DisplayModes();
|
||||||
if (dm == nullptr) {
|
if (dm == nullptr) {
|
||||||
|
@ -92,7 +56,7 @@ int main() {
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa = new PictureAdjustment(libHandle, cookie);
|
pa = new PictureAdjustment(controller);
|
||||||
if (pa == nullptr) {
|
if (pa == nullptr) {
|
||||||
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL PictureAdjustment Iface, "
|
LOG(ERROR) << "Can not create an instance of LiveDisplay HAL PictureAdjustment Iface, "
|
||||||
"exiting.";
|
"exiting.";
|
||||||
|
@ -106,11 +70,6 @@ int main() {
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pa->isSupported()) {
|
|
||||||
// Backend isn't ready yet, so restart and try again
|
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||||
|
|
||||||
status = dm->registerAsService();
|
status = dm->registerAsService();
|
||||||
|
@ -120,13 +79,11 @@ int main() {
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pa->isSupported()) {
|
status = pa->registerAsService();
|
||||||
status = pa->registerAsService();
|
if (status != OK) {
|
||||||
if (status != OK) {
|
LOG(ERROR) << "Could not register service for LiveDisplay HAL PictureAdjustment Iface ("
|
||||||
LOG(ERROR) << "Could not register service for LiveDisplay HAL PictureAdjustment Iface ("
|
<< status << ")";
|
||||||
<< status << ")";
|
goto shutdown;
|
||||||
goto shutdown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status = se->registerAsService();
|
status = se->registerAsService();
|
||||||
|
@ -141,15 +98,6 @@ int main() {
|
||||||
// Should not pass this line
|
// Should not pass this line
|
||||||
|
|
||||||
shutdown:
|
shutdown:
|
||||||
// Cleanup what we started
|
|
||||||
if (disp_api_deinit != nullptr) {
|
|
||||||
disp_api_deinit(cookie, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (libHandle != nullptr) {
|
|
||||||
dlclose(libHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
// In normal operation, we don't expect the thread pool to shutdown
|
// In normal operation, we don't expect the thread pool to shutdown
|
||||||
LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
|
LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue