diff options
author | Naseer Ahmed <naseer@codeaurora.org> | 2017-05-17 14:36:46 -0400 |
---|---|---|
committer | Naseer Ahmed <naseer@codeaurora.org> | 2017-07-10 18:19:08 -0400 |
commit | 8502008020e86be16f174d968acb6ba5ce365072 (patch) | |
tree | d3dcbdb026c7cc640d9a9f7f27f95a0b0c111bc4 | |
parent | 8aa99e0056a9bf8c701510589c6f958ab3068747 (diff) | |
download | display-8502008020e86be16f174d968acb6ba5ce365072.tar.gz |
display: Cleanup unused code
CRs-Fixed: 2048735
Change-Id: Ief7f8ae4006ab211272191b66bd4bd854d9098b2
40 files changed, 20 insertions, 5065 deletions
@@ -3,14 +3,10 @@ display-hals := include libqservice libqdutils $(sdm-libs)/utils $(sdm-libs)/cor ifneq ($(TARGET_IS_HEADLESS), true) display-hals += libcopybit liblight libmemtrack hdmi_cec \ - $(sdm-libs)/hwc $(sdm-libs)/hwc2 gpu_tonemapper libdrmutils libdisplayconfig + $(sdm-libs)/hwc2 gpu_tonemapper libdrmutils libdisplayconfig endif -ifneq ($(TARGET_USES_GRALLOC1), true) - display-hals += libgralloc -else - display-hals += libgralloc1 -endif +display-hals += libgralloc1 ifeq ($(call is-vendor-board-platform,QCOM),true) include $(call all-named-subdir-makefiles,$(display-hals)) @@ -4,6 +4,7 @@ display_top := $(call my-dir) #Common C flags common_flags := -DDEBUG_CALC_FPS -Wno-missing-field-initializers common_flags += -Wconversion -Wall -Werror -std=c++14 +common_flags += -DUSE_GRALLOC1 ifeq ($(TARGET_IS_HEADLESS), true) common_flags += -DTARGET_HEADLESS LOCAL_CLANG := false @@ -31,10 +32,6 @@ ifeq ($(TARGET_USES_HWC2), true) common_flags += -DVIDEO_MODE_DEFER_RETIRE_FENCE endif -ifeq ($(TARGET_USES_GRALLOC1), true) - common_flags += -DUSE_GRALLOC1 -endif - ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) common_flags += -DUSER_DEBUG endif diff --git a/include/Android.mk b/include/Android.mk index ec07ddee..6aacfb8b 100644 --- a/include/Android.mk +++ b/include/Android.mk @@ -16,11 +16,7 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) \ $(display_top)/libqdutils \ $(display_top)/libqservice \ $(display_top)/gpu_tonemapper \ - $(display_top)/sdm/include + $(display_top)/sdm/include \ + $(display_top)/libgralloc1 -ifeq ($(TARGET_USES_GRALLOC1), true) - LOCAL_EXPORT_C_INCLUDE_DIRS += $(display_top)/libgralloc1 -else - LOCAL_EXPORT_C_INCLUDE_DIRS += $(display_top)/libgralloc -endif include $(BUILD_HEADER_LIBRARY) diff --git a/libcopybit/Android.mk b/libcopybit/Android.mk index 6e906c36..a363b854 100644 --- a/libcopybit/Android.mk +++ b/libcopybit/Android.mk @@ -20,34 +20,3 @@ LOCAL_COPY_HEADERS_TO := $(common_header_export_path) LOCAL_COPY_HEADERS := copybit.h copybit_priv.h c2d2.h #Copy the headers regardless of whether copybit is built include $(BUILD_COPY_HEADERS) - -include $(CLEAR_VARS) -ifneq ($(TARGET_USES_GRALLOC1), true) -LOCAL_MODULE := copybit.$(TARGET_BOARD_PLATFORM) -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_MODULE_TAGS := optional -LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes) -LOCAL_SHARED_LIBRARIES := $(common_libs) libdl libmemalloc -LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdcopybit\" -Wno-sign-conversion -LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) -LOCAL_CLANG := true - -ifeq ($(TARGET_USES_C2D_COMPOSITION),true) - LOCAL_CFLAGS += -DCOPYBIT_Z180=1 -DC2D_SUPPORT_DISPLAY=1 - LOCAL_SRC_FILES := copybit_c2d.cpp software_converter.cpp - include $(BUILD_SHARED_LIBRARY) -else - ifneq ($(call is-chipset-in-board-platform,msm7630),true) - ifeq ($(call is-board-platform-in-list,$(MSM7K_BOARD_PLATFORMS)),true) - LOCAL_CFLAGS += -DCOPYBIT_MSM7K=1 - LOCAL_SRC_FILES := software_converter.cpp copybit.cpp - include $(BUILD_SHARED_LIBRARY) - endif - ifeq ($(call is-board-platform-in-list, msm8610 msm8909),true) - LOCAL_SRC_FILES := software_converter.cpp copybit.cpp - include $(BUILD_SHARED_LIBRARY) - endif - endif -endif -endif diff --git a/libgralloc/MODULE_LICENSE_APACHE2 b/libgralloc/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29b..00000000 --- a/libgralloc/MODULE_LICENSE_APACHE2 +++ /dev/null diff --git a/libgralloc/NOTICE b/libgralloc/NOTICE deleted file mode 100644 index 3237da67..00000000 --- a/libgralloc/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (c) 2008-2009, 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. - - 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. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/libgralloc/alloc_controller.h b/libgralloc/alloc_controller.h deleted file mode 100644 index 45977e2b..00000000 --- a/libgralloc/alloc_controller.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef GRALLOC_ALLOCCONTROLLER_H -#define GRALLOC_ALLOCCONTROLLER_H - -#define SZ_2M 0x200000 -#define SZ_1M 0x100000 -#define SZ_4K 0x1000 - -/* TODO: Move this to the common makefile */ -#ifdef MASTER_SIDE_CP -#define SECURE_ALIGN SZ_4K -#else -#define SECURE_ALIGN SZ_1M -#endif - -namespace gralloc { - -struct alloc_data; -class IMemAlloc; -class IonAlloc; - -class IAllocController { - - public: - /* Allocate using a suitable method - * Returns the type of buffer allocated - */ - virtual int allocate(alloc_data& data, int usage) = 0; - - virtual IMemAlloc* getAllocator(int flags) = 0; - - virtual bool isDisableUBWCForEncoder() = 0; - - virtual ~IAllocController() {}; - - static IAllocController* getInstance(void); - - private: - static IAllocController* sController; - -}; - -class IonController : public IAllocController { - - public: - virtual int allocate(alloc_data& data, int usage); - - virtual IMemAlloc* getAllocator(int flags); - - virtual bool isDisableUBWCForEncoder() { - return mDisableUBWCForEncode; - } - - IonController(); - - private: - IonAlloc* mIonAlloc; - bool mDisableUBWCForEncode; - void allocateIonMem(); - -}; -} //end namespace gralloc -#endif // GRALLOC_ALLOCCONTROLLER_H diff --git a/libgralloc/fb_priv.h b/libgralloc/fb_priv.h deleted file mode 100644 index e2eba6ab..00000000 --- a/libgralloc/fb_priv.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. - * - * 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 FB_PRIV_H -#define FB_PRIV_H -#include <linux/fb.h> -#include <linux/msm_mdp.h> - -#define NUM_FRAMEBUFFERS_MIN 2 -#define NUM_FRAMEBUFFERS_MAX 3 - -#define NO_SURFACEFLINGER_SWAPINTERVAL -#define COLOR_FORMAT(x) (x & 0xFFF) // Max range for colorFormats is 0 - FFF - -struct private_handle_t; - -enum { - // flag to indicate we'll post this buffer - PRIV_USAGE_LOCKED_FOR_POST = 0x80000000, - PRIV_MIN_SWAP_INTERVAL = 0, - PRIV_MAX_SWAP_INTERVAL = 1, -}; - -struct private_module_t { - gralloc_module_t base; - struct private_handle_t* framebuffer; - uint32_t fbFormat; - uint32_t flags; - uint32_t numBuffers; - uint32_t bufferMask; - pthread_mutex_t lock; - struct fb_var_screeninfo info; - struct fb_fix_screeninfo finfo; - float xdpi; - float ydpi; - float fps; - uint32_t swapInterval; -}; - - - -#endif /* FB_PRIV_H */ diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp deleted file mode 100644 index dd4842f2..00000000 --- a/libgralloc/framebuffer.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2010-2014 The Linux Foundation. All rights reserved. - * - * 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 <sys/mman.h> - -#include <cutils/log.h> -#include <cutils/properties.h> -#include <dlfcn.h> - -#include <hardware/hardware.h> - -#include <fcntl.h> -#include <errno.h> -#include <sys/ioctl.h> -#include <string.h> -#include <stdlib.h> -#include <pthread.h> -#include <cutils/atomic.h> - -#include <linux/fb.h> -#include <linux/msm_mdp.h> - -#ifndef TARGET_HEADLESS -#include <GLES/gl.h> -#endif - -#include "gralloc_priv.h" -#include "fb_priv.h" -#include "gr.h" -#include <cutils/properties.h> -#include <profiler.h> - -#define EVEN_OUT(x) if (x & 0x0001) {x--;} - -enum { - PAGE_FLIP = 0x00000001, -}; - -struct fb_context_t { - framebuffer_device_t device; - //fd - which is returned on open - int fbFd; -}; - -static int fb_setSwapInterval(struct framebuffer_device_t* dev, - int interval) -{ - //XXX: Get the value here and implement along with - //single vsync in HWC - char pval[PROPERTY_VALUE_MAX]; - property_get("debug.egl.swapinterval", pval, "-1"); - int property_interval = atoi(pval); - if (property_interval >= 0) - interval = property_interval; - - private_module_t* m = reinterpret_cast<private_module_t*>( - dev->common.module); - if (interval < dev->minSwapInterval || interval > dev->maxSwapInterval) - return -EINVAL; - - m->swapInterval = interval; - return 0; -} - -static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) -{ - private_module_t* m = - reinterpret_cast<private_module_t*>(dev->common.module); - private_handle_t *hnd = static_cast<private_handle_t*> - (const_cast<native_handle_t*>(buffer)); - fb_context_t *ctx = reinterpret_cast<fb_context_t*>(dev); - const unsigned int offset = (unsigned int) (hnd->base - - m->framebuffer->base); - m->info.activate = FB_ACTIVATE_VBL; - m->info.yoffset = (int)(offset / m->finfo.line_length); - if (ioctl(ctx->fbFd, FBIOPUT_VSCREENINFO, &m->info) == -1) { - ALOGE("%s: FBIOPUT_VSCREENINFO for primary failed, str: %s", - __FUNCTION__, strerror(errno)); - return -errno; - } - return 0; -} - -static int fb_compositionComplete(struct framebuffer_device_t* dev) -{ - // TODO: Properly implement composition complete callback - if(!dev) { - return -1; - } -#ifndef TARGET_HEADLESS - glFinish(); -#endif - - return 0; -} - -int mapFrameBufferLocked(framebuffer_device_t *dev) -{ - private_module_t* module = - reinterpret_cast<private_module_t*>(dev->common.module); - fb_context_t *ctx = reinterpret_cast<fb_context_t*>(dev); - // already initialized... - if (module->framebuffer) { - return 0; - } - char const * const device_template[] = { - "/dev/graphics/fb%u", - "/dev/fb%u", - 0 }; - - int fd = -1; - int i=0; - char name[64]; - char property[PROPERTY_VALUE_MAX]; - - while ((fd==-1) && device_template[i]) { - snprintf(name, 64, device_template[i], 0); - fd = open(name, O_RDWR, 0); - i++; - } - if (fd < 0) - return -errno; - - struct fb_fix_screeninfo finfo; - if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) { - close(fd); - return -errno; - } - - struct fb_var_screeninfo info; - if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) { - close(fd); - return -errno; - } - - info.reserved[0] = 0; - info.reserved[1] = 0; - info.reserved[2] = 0; - info.xoffset = 0; - info.yoffset = 0; - info.activate = FB_ACTIVATE_NOW; - - /* Interpretation of offset for color fields: All offsets are from the - * right, inside a "pixel" value, which is exactly 'bits_per_pixel' wide - * (means: you can use the offset as right argument to <<). A pixel - * afterwards is a bit stream and is written to video memory as that - * unmodified. This implies big-endian byte order if bits_per_pixel is - * greater than 8. - */ - - if(info.bits_per_pixel == 32) { - /* - * Explicitly request RGBA_8888 - */ - info.bits_per_pixel = 32; - info.red.offset = 24; - info.red.length = 8; - info.green.offset = 16; - info.green.length = 8; - info.blue.offset = 8; - info.blue.length = 8; - info.transp.offset = 0; - info.transp.length = 8; - - /* Note: the GL driver does not have a r=8 g=8 b=8 a=0 config, so if we - * do not use the MDP for composition (i.e. hw composition == 0), ask - * for RGBA instead of RGBX. */ - if (property_get("debug.sf.hw", property, NULL) > 0 && - atoi(property) == 0) - module->fbFormat = HAL_PIXEL_FORMAT_RGBX_8888; - else if(property_get("debug.composition.type", property, NULL) > 0 && - (strncmp(property, "mdp", 3) == 0)) - module->fbFormat = HAL_PIXEL_FORMAT_RGBX_8888; - else - module->fbFormat = HAL_PIXEL_FORMAT_RGBA_8888; - } else { - /* - * Explicitly request 5/6/5 - */ - info.bits_per_pixel = 16; - info.red.offset = 11; - info.red.length = 5; - info.green.offset = 5; - info.green.length = 6; - info.blue.offset = 0; - info.blue.length = 5; - info.transp.offset = 0; - info.transp.length = 0; - module->fbFormat = HAL_PIXEL_FORMAT_RGB_565; - } - - //adreno needs 4k aligned offsets. Max hole size is 4096-1 - unsigned int size = roundUpToPageSize(info.yres * info.xres * - (info.bits_per_pixel/8)); - - /* - * Request NUM_BUFFERS screens (at least 2 for page flipping) - */ - int numberOfBuffers = (int)(finfo.smem_len/size); - ALOGV("num supported framebuffers in kernel = %d", numberOfBuffers); - - if (property_get("debug.gr.numframebuffers", property, NULL) > 0) { - int num = atoi(property); - if ((num >= NUM_FRAMEBUFFERS_MIN) && (num <= NUM_FRAMEBUFFERS_MAX)) { - numberOfBuffers = num; - } - } - if (numberOfBuffers > NUM_FRAMEBUFFERS_MAX) - numberOfBuffers = NUM_FRAMEBUFFERS_MAX; - - ALOGV("We support %d buffers", numberOfBuffers); - - //consider the included hole by 4k alignment - uint32_t line_length = (info.xres * info.bits_per_pixel / 8); - info.yres_virtual = (uint32_t) ((size * numberOfBuffers) / line_length); - - uint32_t flags = PAGE_FLIP; - - if (info.yres_virtual < ((size * 2) / line_length) ) { - // we need at least 2 for page-flipping - info.yres_virtual = (int)(size / line_length); - flags &= ~PAGE_FLIP; - ALOGW("page flipping not supported (yres_virtual=%d, requested=%d)", - info.yres_virtual, info.yres*2); - } - - if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) { - close(fd); - return -errno; - } - - if (int(info.width) <= 0 || int(info.height) <= 0) { - // the driver doesn't return that information - // default to 160 dpi - info.width = (uint32_t)(((float)(info.xres) * 25.4f)/160.0f + 0.5f); - info.height = (uint32_t)(((float)(info.yres) * 25.4f)/160.0f + 0.5f); - } - - float xdpi = ((float)(info.xres) * 25.4f) / (float)info.width; - float ydpi = ((float)(info.yres) * 25.4f) / (float)info.height; - -#ifdef MSMFB_METADATA_GET - struct msmfb_metadata metadata; - memset(&metadata, 0 , sizeof(metadata)); - metadata.op = metadata_op_frame_rate; - if (ioctl(fd, MSMFB_METADATA_GET, &metadata) == -1) { - ALOGE("Error retrieving panel frame rate"); - close(fd); - return -errno; - } - float fps = (float)metadata.data.panel_frame_rate; -#else - //XXX: Remove reserved field usage on all baselines - //The reserved[3] field is used to store FPS by the driver. - float fps = info.reserved[3] & 0xFF; -#endif - ALOGI("using (fd=%d)\n" - "id = %s\n" - "xres = %d px\n" - "yres = %d px\n" - "xres_virtual = %d px\n" - "yres_virtual = %d px\n" - "bpp = %d\n" - "r = %2u:%u\n" - "g = %2u:%u\n" - "b = %2u:%u\n", - fd, - finfo.id, - info.xres, - info.yres, - info.xres_virtual, - info.yres_virtual, - info.bits_per_pixel, - info.red.offset, info.red.length, - info.green.offset, info.green.length, - info.blue.offset, info.blue.length - ); - - ALOGI("width = %d mm (%f dpi)\n" - "height = %d mm (%f dpi)\n" - "refresh rate = %.2f Hz\n", - info.width, xdpi, - info.height, ydpi, - fps - ); - - - if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) { - close(fd); - return -errno; - } - - if (finfo.smem_len <= 0) { - close(fd); - return -errno; - } - - module->flags = flags; - module->info = info; - module->finfo = finfo; - module->xdpi = xdpi; - module->ydpi = ydpi; - module->fps = fps; - module->swapInterval = 1; - - CALC_INIT(); - - /* - * map the framebuffer - */ - - module->numBuffers = info.yres_virtual / info.yres; - module->bufferMask = 0; - //adreno needs page aligned offsets. Align the fbsize to pagesize. - unsigned int fbSize = roundUpToPageSize(finfo.line_length * info.yres)* - module->numBuffers; - void* vaddr = mmap(0, fbSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); - if (vaddr == MAP_FAILED) { - ALOGE("Error mapping the framebuffer (%s)", strerror(errno)); - close(fd); - return -errno; - } - //store the framebuffer fd in the ctx - ctx->fbFd = fd; -#ifdef MSMFB_METADATA_GET - memset(&metadata, 0 , sizeof(metadata)); - metadata.op = metadata_op_get_ion_fd; - // get the ION fd for the framebuffer, as GPU needs ION fd - if (ioctl(fd, MSMFB_METADATA_GET, &metadata) == -1) { - ALOGE("Error getting ION fd (%s)", strerror(errno)); - close(fd); - return -errno; - } - if(metadata.data.fbmem_ionfd < 0) { - ALOGE("Error: Ioctl returned invalid ION fd = %d", - metadata.data.fbmem_ionfd); - close(fd); - return -errno; - } - fd = metadata.data.fbmem_ionfd; -#endif - // Create framebuffer handle using the ION fd - module->framebuffer = new private_handle_t(fd, fbSize, - private_handle_t::PRIV_FLAGS_USES_ION, - BUFFER_TYPE_UI, - module->fbFormat, info.xres, info.yres); - module->framebuffer->base = uint64_t(vaddr); - memset(vaddr, 0, fbSize); - //Enable vsync - int enable = 1; - ioctl(ctx->fbFd, MSMFB_OVERLAY_VSYNC_CTRL, &enable); - return 0; -} - -static int mapFrameBuffer(framebuffer_device_t *dev) -{ - int err = -1; - char property[PROPERTY_VALUE_MAX]; - if((property_get("debug.gralloc.map_fb_memory", property, NULL) > 0) && - (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || - (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { - private_module_t* module = - reinterpret_cast<private_module_t*>(dev->common.module); - pthread_mutex_lock(&module->lock); - err = mapFrameBufferLocked(dev); - pthread_mutex_unlock(&module->lock); - } - return err; -} - -/*****************************************************************************/ - -static int fb_close(struct hw_device_t *dev) -{ - fb_context_t* ctx = (fb_context_t*)dev; - if (ctx) { -#ifdef MSMFB_METADATA_GET - if(ctx->fbFd >=0) { - close(ctx->fbFd); - } -#endif - //Hack until fbdev is removed. Framework could close this causing hwc a - //pain. - //free(ctx); - } - return 0; -} - -int fb_device_open(hw_module_t const* module, const char* name, - hw_device_t** device) -{ - int status = -EINVAL; - if (!strcmp(name, GRALLOC_HARDWARE_FB0)) { - alloc_device_t* gralloc_device; - status = gralloc_open(module, &gralloc_device); - if (status < 0) - return status; - - /* initialize our state here */ - fb_context_t *dev = (fb_context_t*)malloc(sizeof(*dev)); - if(dev == NULL) { - gralloc_close(gralloc_device); - return status; - } - memset(dev, 0, sizeof(*dev)); - - /* initialize the procs */ - dev->device.common.tag = HARDWARE_DEVICE_TAG; - dev->device.common.version = 0; - dev->device.common.module = const_cast<hw_module_t*>(module); - dev->device.common.close = fb_close; - dev->device.setSwapInterval = fb_setSwapInterval; - dev->device.post = fb_post; - dev->device.setUpdateRect = 0; - dev->device.compositionComplete = fb_compositionComplete; - - status = mapFrameBuffer((framebuffer_device_t*)dev); - private_module_t* m = (private_module_t*)dev->device.common.module; - if (status >= 0) { - int stride = m->finfo.line_length / (m->info.bits_per_pixel >> 3); - const_cast<uint32_t&>(dev->device.flags) = 0; - const_cast<uint32_t&>(dev->device.width) = m->info.xres; - const_cast<uint32_t&>(dev->device.height) = m->info.yres; - const_cast<int&>(dev->device.stride) = stride; - const_cast<int&>(dev->device.format) = m->fbFormat; - const_cast<float&>(dev->device.xdpi) = m->xdpi; - const_cast<float&>(dev->device.ydpi) = m->ydpi; - const_cast<float&>(dev->device.fps) = m->fps; - const_cast<int&>(dev->device.minSwapInterval) = - PRIV_MIN_SWAP_INTERVAL; - const_cast<int&>(dev->device.maxSwapInterval) = - PRIV_MAX_SWAP_INTERVAL; - const_cast<int&>(dev->device.numFramebuffers) = m->numBuffers; - dev->device.setUpdateRect = 0; - - *device = &dev->device.common; - } - - // Close the gralloc module - gralloc_close(gralloc_device); - } - return status; -} diff --git a/libgralloc/gpu.h b/libgralloc/gpu.h deleted file mode 100644 index 2248d30d..00000000 --- a/libgralloc/gpu.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - * - * 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 GRALLOC_GPU_H_ -#define GRALLOC_GPU_H_ - -#include <errno.h> -#include <pthread.h> -#include <stdlib.h> -#include <string.h> - -#include <cutils/log.h> - -#include "gralloc_priv.h" -#include "fb_priv.h" - -namespace gralloc { -class IAllocController; -class gpu_context_t : public alloc_device_t { - public: - gpu_context_t(const private_module_t* module, - IAllocController* alloc_ctrl); - - int gralloc_alloc_buffer(unsigned int size, int usage, - buffer_handle_t* pHandle, - int bufferType, int format, - int width, int height); - - int free_impl(private_handle_t const* hnd); - - int alloc_impl(int w, int h, int format, int usage, - buffer_handle_t* pHandle, int* pStride, - unsigned int bufferSize = 0); - - static int gralloc_alloc(alloc_device_t* dev, int w, int h, - int format, int usage, - buffer_handle_t* pHandle, - int* pStride); - int gralloc_alloc_framebuffer_locked(int usage, - buffer_handle_t* pHandle); - - int gralloc_alloc_framebuffer(int usage, - buffer_handle_t* pHandle); - - static int gralloc_free(alloc_device_t* dev, buffer_handle_t handle); - - static int gralloc_alloc_size(alloc_device_t* dev, - int w, int h, int format, - int usage, buffer_handle_t* pHandle, - int* pStride, int bufferSize); - - static int gralloc_close(struct hw_device_t *dev); - - private: - IAllocController* mAllocCtrl; - void getGrallocInformationFromFormat(int inputFormat, - int *bufferType); -}; -} -#endif // GRALLOC_GPU_H diff --git a/libgralloc/gralloc.cpp b/libgralloc/gralloc.cpp deleted file mode 100644 index 237b8a80..00000000 --- a/libgralloc/gralloc.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2008, The Android Open Source Project - * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. - * - * 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 <unistd.h> -#include <fcntl.h> - -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/ioctl.h> -#include <cutils/properties.h> - -#include "gr.h" -#include "gpu.h" -#include "memalloc.h" -#include "alloc_controller.h" - -using namespace gralloc; - -int fb_device_open(const hw_module_t* module, const char* name, - hw_device_t** device); - -static int gralloc_device_open(const hw_module_t* module, const char* name, - hw_device_t** device); - -extern int gralloc_lock(gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int l, int t, int w, int h, - void** vaddr); - -extern int gralloc_lock_ycbcr(gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int l, int t, int w, int h, - struct android_ycbcr *ycbcr); - -extern int gralloc_unlock(gralloc_module_t const* module, - buffer_handle_t handle); - -extern int gralloc_register_buffer(gralloc_module_t const* module, - buffer_handle_t handle); - -extern int gralloc_unregister_buffer(gralloc_module_t const* module, - buffer_handle_t handle); - -extern int gralloc_perform(struct gralloc_module_t const* module, - int operation, ... ); - -// HAL module methods -static struct hw_module_methods_t gralloc_module_methods = { - .open = gralloc_device_open -}; - -// HAL module initialize -struct private_module_t HAL_MODULE_INFO_SYM = { - .base = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .version_major = 1, - .version_minor = 0, - .id = GRALLOC_HARDWARE_MODULE_ID, - .name = "Graphics Memory Allocator Module", - .author = "The Android Open Source Project", - .methods = &gralloc_module_methods, - .dso = 0, - .reserved = {0}, - }, - .registerBuffer = gralloc_register_buffer, - .unregisterBuffer = gralloc_unregister_buffer, - .lock = gralloc_lock, - .unlock = gralloc_unlock, - .perform = gralloc_perform, - .lock_ycbcr = gralloc_lock_ycbcr, - }, - .framebuffer = 0, - .fbFormat = 0, - .flags = 0, - .numBuffers = 0, - .bufferMask = 0, - .lock = PTHREAD_MUTEX_INITIALIZER, -}; - -// Open Gralloc device -int gralloc_device_open(const hw_module_t* module, const char* name, - hw_device_t** device) -{ - int status = -EINVAL; - if (!strcmp(name, GRALLOC_HARDWARE_GPU0)) { - const private_module_t* m = reinterpret_cast<const private_module_t*>( - module); - gpu_context_t *dev; - IAllocController* alloc_ctrl = IAllocController::getInstance(); - dev = new gpu_context_t(m, alloc_ctrl); - if(!dev) - return status; - - *device = &dev->common; - status = 0; - } else { - status = fb_device_open(module, name, device); - } - return status; -} diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h index 0f1f97a7..f0c6b4d6 100644 --- a/libgralloc/gralloc_priv.h +++ b/libgralloc/gralloc_priv.h @@ -26,6 +26,14 @@ #include <errno.h> #include <unistd.h> + +/* DEPRECATION NOTICE: This file is no longer used, please use the new + * implementation in libgralloc1 + */ + + + + #include <cutils/native_handle.h> #include <cutils/log.h> diff --git a/libgralloc/ionalloc.cpp b/libgralloc/ionalloc.cpp deleted file mode 100644 index 329e30f7..00000000 --- a/libgralloc/ionalloc.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define DEBUG 0 -#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL) -#include <sys/ioctl.h> -#include <sys/mman.h> -#include <stdlib.h> -#include <fcntl.h> -#include <cutils/log.h> -#include <errno.h> -#include <utils/Trace.h> -#include <cutils/trace.h> -#include "gralloc_priv.h" -#include "ionalloc.h" - -using gralloc::IonAlloc; - -#define ION_DEVICE "/dev/ion" - -int IonAlloc::open_device() -{ - if(mIonFd == FD_INIT) - mIonFd = open(ION_DEVICE, O_RDONLY); - - if(mIonFd < 0 ) { - ALOGE("%s: Failed to open ion device - %s", - __FUNCTION__, strerror(errno)); - mIonFd = FD_INIT; - return -errno; - } - return 0; -} - -void IonAlloc::close_device() -{ - if(mIonFd >= 0) - close(mIonFd); - mIonFd = FD_INIT; -} - -int IonAlloc::alloc_buffer(alloc_data& data) -{ - ATRACE_CALL(); - Locker::Autolock _l(mLock); - int err = 0; - struct ion_handle_data handle_data; - struct ion_fd_data fd_data; - struct ion_allocation_data ionAllocData; - void *base = 0; - - ionAllocData.len = data.size; - ionAllocData.align = data.align; - ionAllocData.heap_id_mask = data.heapId; - ionAllocData.flags = data.flags; - ionAllocData.flags |= data.uncached ? 0 : ION_FLAG_CACHED; - err = open_device(); - if (err) - return err; - if(ioctl(mIonFd, ION_IOC_ALLOC, &ionAllocData)) { - err = -errno; - ALOGE("ION_IOC_ALLOC failed with error - %s", strerror(errno)); - return err; - } - - fd_data.handle = ionAllocData.handle; - handle_data.handle = ionAllocData.handle; - if(ioctl(mIonFd, ION_IOC_MAP, &fd_data)) { - err = -errno; - ALOGE("%s: ION_IOC_MAP failed with error - %s", - __FUNCTION__, strerror(errno)); - ioctl(mIonFd, ION_IOC_FREE, &handle_data); - return err; - } - - if(!(data.flags & ION_SECURE)) { - base = mmap(0, ionAllocData.len, PROT_READ|PROT_WRITE, - MAP_SHARED, fd_data.fd, 0); - if(base == MAP_FAILED) { - err = -errno; - ALOGE("%s: Failed to map the allocated memory: %s", - __FUNCTION__, strerror(errno)); - ioctl(mIonFd, ION_IOC_FREE, &handle_data); - return err; - } - } - - data.base = base; - data.fd = fd_data.fd; - ioctl(mIonFd, ION_IOC_FREE, &handle_data); - ALOGD_IF(DEBUG, "ion: Allocated buffer base:%p size:%zu fd:%d", - data.base, ionAllocData.len, data.fd); - return 0; -} - - -int IonAlloc::free_buffer(void* base, unsigned int size, unsigned int offset, - int fd) -{ - ATRACE_CALL(); - Locker::Autolock _l(mLock); - ALOGD_IF(DEBUG, "ion: Freeing buffer base:%p size:%u fd:%d", - base, size, fd); - int err = 0; - err = open_device(); - if (err) - return err; - - if(base) - err = unmap_buffer(base, size, offset); - close(fd); - return err; -} - -int IonAlloc::map_buffer(void **pBase, unsigned int size, unsigned int offset, - int fd) -{ - ATRACE_CALL(); - int err = 0; - void *base = 0; - // It is a (quirky) requirement of ION to have opened the - // ion fd in the process that is doing the mapping - err = open_device(); - if (err) - return err; - - base = mmap(0, size, PROT_READ| PROT_WRITE, - MAP_SHARED, fd, 0); - *pBase = base; - if(base == MAP_FAILED) { - err = -errno; - ALOGE("ion: Failed to map memory in the client: %s", - strerror(errno)); - } else { - ALOGD_IF(DEBUG, "ion: Mapped buffer base:%p size:%u offset:%u fd:%d", - base, size, offset, fd); - } - return err; -} - -int IonAlloc::unmap_buffer(void *base, unsigned int size, - unsigned int /*offset*/) -{ - ATRACE_CALL(); - ALOGD_IF(DEBUG, "ion: Unmapping buffer base:%p size:%u", base, size); - int err = 0; - if(munmap(base, size)) { - err = -errno; - ALOGE("ion: Failed to unmap memory at %p : %s", - base, strerror(errno)); - } - return err; - -} -int IonAlloc::clean_buffer(void *base, unsigned int size, unsigned int offset, - int fd, int op) -{ - ATRACE_CALL(); - ATRACE_INT("operation id", op); - struct ion_flush_data flush_data; - struct ion_fd_data fd_data; - struct ion_handle_data handle_data; - int err = 0; - - err = open_device(); - if (err) - return err; - - fd_data.fd = fd; - if (ioctl(mIonFd, ION_IOC_IMPORT, &fd_data)) { - err = -errno; - ALOGE("%s: ION_IOC_IMPORT failed with error - %s", - __FUNCTION__, strerror(errno)); - return err; - } - - handle_data.handle = fd_data.handle; - flush_data.handle = fd_data.handle; - flush_data.vaddr = base; - // offset and length are unsigned int - flush_data.offset = offset; - flush_data.length = size; - - struct ion_custom_data d; - switch(op) { - case CACHE_CLEAN: - d.cmd = ION_IOC_CLEAN_CACHES; - break; - case CACHE_INVALIDATE: - d.cmd = ION_IOC_INV_CACHES; - break; - case CACHE_CLEAN_AND_INVALIDATE: - default: - d.cmd = ION_IOC_CLEAN_INV_CACHES; - } - - d.arg = (unsigned long int)&flush_data; - - if(ioctl(mIonFd, ION_IOC_CUSTOM, &d)) { - err = -errno; - ALOGE("%s: ION_IOC_CLEAN_INV_CACHES failed with error - %s", - - __FUNCTION__, strerror(errno)); - ioctl(mIonFd, ION_IOC_FREE, &handle_data); - return err; - } - ioctl(mIonFd, ION_IOC_FREE, &handle_data); - return 0; -} - diff --git a/libgralloc/ionalloc.h b/libgralloc/ionalloc.h deleted file mode 100644 index 635bda58..00000000 --- a/libgralloc/ionalloc.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GRALLOC_IONALLOC_H -#define GRALLOC_IONALLOC_H - -#include <linux/msm_ion.h> -#include "memalloc.h" -#include "gr.h" - -namespace gralloc { - -class IonAlloc : public IMemAlloc { - - public: - virtual int alloc_buffer(alloc_data& data); - - virtual int free_buffer(void *base, unsigned int size, - unsigned int offset, int fd); - - virtual int map_buffer(void **pBase, unsigned int size, - unsigned int offset, int fd); - - virtual int unmap_buffer(void *base, unsigned int size, - unsigned int offset); - - virtual int clean_buffer(void*base, unsigned int size, - unsigned int offset, int fd, int op); - - IonAlloc() { mIonFd = FD_INIT; } - - ~IonAlloc() { close_device(); } - - private: - int mIonFd; - - int open_device(); - - void close_device(); - - mutable Locker mLock; - -}; - -} - -#endif /* GRALLOC_IONALLOC_H */ - diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp deleted file mode 100644 index acf5e2c8..00000000 --- a/libgralloc/mapper.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. - * - * 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. - */ - -#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL) -#include <limits.h> -#include <errno.h> -#include <pthread.h> -#include <unistd.h> -#include <string.h> -#include <stdarg.h> - -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/ioctl.h> - -#include <cutils/log.h> -#include <cutils/atomic.h> -#include <utils/Trace.h> - -#include <hardware/hardware.h> -#include <hardware/gralloc.h> - -#include "gralloc_priv.h" -#include "gr.h" -#include "alloc_controller.h" -#include "memalloc.h" -#include <qdMetaData.h> - - -using namespace gralloc; -/*****************************************************************************/ - -// Return the type of allocator - -// these are used for mapping/unmapping -static IMemAlloc* getAllocator(int flags) -{ - IMemAlloc* memalloc; - IAllocController* alloc_ctrl = IAllocController::getInstance(); - memalloc = alloc_ctrl->getAllocator(flags); - return memalloc; -} - -static int gralloc_map_metadata(buffer_handle_t handle) { - private_handle_t* hnd = (private_handle_t*)handle; - hnd->base_metadata = 0; - IMemAlloc* memalloc = getAllocator(hnd->flags) ; - void *mappedAddress = MAP_FAILED; - unsigned int size = 0; - if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { - mappedAddress = MAP_FAILED; - size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); - int ret = memalloc->map_buffer(&mappedAddress, size, - hnd->offset_metadata, hnd->fd_metadata); - if(ret || mappedAddress == MAP_FAILED) { - ALOGE("Could not mmap metadata for handle %p, fd=%d (%s)", - hnd, hnd->fd_metadata, strerror(errno)); - return -errno; - } - hnd->base_metadata = uint64_t(mappedAddress) + hnd->offset_metadata; - } - return 0; -} - -static int gralloc_map(gralloc_module_t const* module, - buffer_handle_t handle) -{ - ATRACE_CALL(); - if(!module) - return -EINVAL; - - private_handle_t* hnd = (private_handle_t*)handle; - unsigned int size = 0; - int err = 0; - IMemAlloc* memalloc = getAllocator(hnd->flags) ; - void *mappedAddress = MAP_FAILED; - hnd->base = 0; - - // Dont map framebuffer and secure buffers - if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) && - !(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) { - size = hnd->size; - err = memalloc->map_buffer(&mappedAddress, size, - hnd->offset, hnd->fd); - if(err || mappedAddress == MAP_FAILED) { - ALOGE("Could not mmap handle %p, fd=%d (%s)", - handle, hnd->fd, strerror(errno)); - return -errno; - } - - hnd->base = uint64_t(mappedAddress) + hnd->offset; - } else { - // Cannot map secure buffers or framebuffers, but still need to map - // metadata for secure buffers. - // If mapping a secure buffers fails, the framework needs to get - // an error code. - err = -EACCES; - } - - //Allow mapping of metadata for all buffers including secure ones, but not - //of framebuffer - int metadata_err = gralloc_map_metadata(handle); - if (!err) { - err = metadata_err; - } - return err; -} - -static int gralloc_unmap(gralloc_module_t const* module, - buffer_handle_t handle) -{ - ATRACE_CALL(); - int err = -EINVAL; - if(!module) - return err; - - private_handle_t* hnd = (private_handle_t*)handle; - IMemAlloc* memalloc = getAllocator(hnd->flags) ; - if(!memalloc) - return err; - - if(hnd->base) { - err = memalloc->unmap_buffer((void*)hnd->base, hnd->size, hnd->offset); - if (err) { - ALOGE("Could not unmap memory at address %p, %s", (void*) hnd->base, - strerror(errno)); - return -errno; - } - hnd->base = 0; - } - - if(hnd->base_metadata) { - unsigned int size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); - err = memalloc->unmap_buffer((void*)hnd->base_metadata, - size, hnd->offset_metadata); - if (err) { - ALOGE("Could not unmap memory at address %p, %s", - (void*) hnd->base_metadata, strerror(errno)); - return -errno; - } - hnd->base_metadata = 0; - } - - return 0; -} - -/*****************************************************************************/ - -static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER; - -/*****************************************************************************/ - -int gralloc_register_buffer(gralloc_module_t const* module, - buffer_handle_t handle) -{ - ATRACE_CALL(); - if (!module || private_handle_t::validate(handle) < 0) - return -EINVAL; - - int err = gralloc_map(module, handle); - /* Do not fail register_buffer for secure buffers*/ - if (err == -EACCES) - err = 0; - return err; -} - -int gralloc_unregister_buffer(gralloc_module_t const* module, - buffer_handle_t handle) -{ - ATRACE_CALL(); - if (!module || private_handle_t::validate(handle) < 0) - return -EINVAL; - - /* - * If the buffer has been mapped during a lock operation, it's time - * to un-map it. It's an error to be here with a locked buffer. - * NOTE: the framebuffer is handled differently and is never unmapped. - * Also base and base_metadata are reset. - */ - return gralloc_unmap(module, handle); -} - -int terminateBuffer(gralloc_module_t const* module, - private_handle_t* hnd) -{ - ATRACE_CALL(); - if(!module) - return -EINVAL; - - /* - * If the buffer has been mapped during a lock operation, it's time - * to un-map it. It's an error to be here with a locked buffer. - * NOTE: the framebuffer is handled differently and is never unmapped. - * Also base and base_metadata are reset. - */ - return gralloc_unmap(module, hnd); -} - -static int gralloc_map_and_invalidate (gralloc_module_t const* module, - buffer_handle_t handle, int usage) -{ - ATRACE_CALL(); - if (!module || private_handle_t::validate(handle) < 0) - return -EINVAL; - - int err = 0; - private_handle_t* hnd = (private_handle_t*)handle; - if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) { - if (hnd->base == 0) { - // we need to map for real - pthread_mutex_t* const lock = &sMapLock; - pthread_mutex_lock(lock); - err = gralloc_map(module, handle); - pthread_mutex_unlock(lock); - } - if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION and - hnd->flags & private_handle_t::PRIV_FLAGS_CACHED) { - //Invalidate if CPU reads in software and there are non-CPU - //writers. No need to do this for the metadata buffer as it is - //only read/written in software. - if ((usage & GRALLOC_USAGE_SW_READ_MASK) and - (hnd->flags & private_handle_t::PRIV_FLAGS_NON_CPU_WRITER)) - { - IMemAlloc* memalloc = getAllocator(hnd->flags) ; - err = memalloc->clean_buffer((void*)hnd->base, - hnd->size, hnd->offset, hnd->fd, - CACHE_INVALIDATE); - } - //Mark the buffer to be flushed after CPU write. - if (usage & GRALLOC_USAGE_SW_WRITE_MASK) { - hnd->flags |= private_handle_t::PRIV_FLAGS_NEEDS_FLUSH; - } - } - } - - return err; -} - -int gralloc_lock(gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int /*l*/, int /*t*/, int /*w*/, int /*h*/, - void** vaddr) -{ - ATRACE_CALL(); - private_handle_t* hnd = (private_handle_t*)handle; - int err = gralloc_map_and_invalidate(module, handle, usage); - if(!err) - *vaddr = (void*)hnd->base; - return err; -} - -int gralloc_lock_ycbcr(gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int /*l*/, int /*t*/, int /*w*/, int /*h*/, - struct android_ycbcr *ycbcr) -{ - ATRACE_CALL(); - private_handle_t* hnd = (private_handle_t*)handle; - int err = gralloc_map_and_invalidate(module, handle, usage); - if(!err) - err = getYUVPlaneInfo(hnd, ycbcr); - return err; -} - -int gralloc_unlock(gralloc_module_t const* module, - buffer_handle_t handle) -{ - ATRACE_CALL(); - if (!module || private_handle_t::validate(handle) < 0) - return -EINVAL; - - int err = 0; - private_handle_t* hnd = (private_handle_t*)handle; - - IMemAlloc* memalloc = getAllocator(hnd->flags); - if (hnd->flags & private_handle_t::PRIV_FLAGS_NEEDS_FLUSH) { - err = memalloc->clean_buffer((void*)hnd->base, - hnd->size, hnd->offset, hnd->fd, - CACHE_CLEAN); - hnd->flags &= ~private_handle_t::PRIV_FLAGS_NEEDS_FLUSH; - } - - return err; -} - -/*****************************************************************************/ - -int gralloc_perform(struct gralloc_module_t const* module, - int operation, ... ) -{ - int res = -EINVAL; - va_list args; - if(!module) - return res; - - va_start(args, operation); - switch (operation) { - case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: - { - int fd = va_arg(args, int); - unsigned int size = va_arg(args, unsigned int); - unsigned int offset = va_arg(args, unsigned int); - void* base = va_arg(args, void*); - int width = va_arg(args, int); - int height = va_arg(args, int); - int format = va_arg(args, int); - int alignedw = 0, alignedh = 0; - - native_handle_t** handle = va_arg(args, native_handle_t**); - private_handle_t* hnd = (private_handle_t*)native_handle_create( - private_handle_t::sNumFds, private_handle_t::sNumInts()); - if (hnd) { - hnd->magic = private_handle_t::sMagic; - hnd->fd = fd; - hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION; - hnd->size = size; - hnd->offset = offset; - hnd->base = uint64_t(base) + offset; - hnd->gpuaddr = 0; - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width, - height, format, 0, alignedw, alignedh); - hnd->width = alignedw; - hnd->height = alignedh; - hnd->unaligned_width = width; - hnd->unaligned_height = height; - hnd->format = format; - *handle = (native_handle_t *)hnd; - res = 0; - } - break; - - } - case GRALLOC_MODULE_PERFORM_GET_STRIDE: - { - int width = va_arg(args, int); - int format = va_arg(args, int); - int *stride = va_arg(args, int *); - int alignedw = 0, alignedh = 0; - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width, - 0, format, 0, alignedw, alignedh); - *stride = alignedw; - res = 0; - } break; - - case GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE: - { - const private_handle_t* hnd = va_arg(args, private_handle_t*); - int *stride = va_arg(args, int *); - if (private_handle_t::validate(hnd)) { - return res; - } - - int alignedw = 0, alignedh = 0; - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(hnd, alignedw, alignedh); - *stride = alignedw; - - res = 0; - } break; - - case GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE: - { - const private_handle_t* hnd = va_arg(args, private_handle_t*); - int *stride = va_arg(args, int *); - int *height = va_arg(args, int *); - if (private_handle_t::validate(hnd)) { - return res; - } - - int alignedw = 0, alignedh = 0; - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(hnd, alignedw, alignedh); - *stride = alignedw; - *height = alignedh; - - res = 0; - } break; - - case GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES: - { - int width = va_arg(args, int); - int height = va_arg(args, int); - int format = va_arg(args, int); - int usage = va_arg(args, int); - int *alignedWidth = va_arg(args, int *); - int *alignedHeight = va_arg(args, int *); - int *tileEnabled = va_arg(args,int *); - *tileEnabled = isUBwcEnabled(format, usage); - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width, - height, format, usage, *alignedWidth, *alignedHeight); - res = 0; - } break; - - case GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE: - { - private_handle_t* hnd = va_arg(args, private_handle_t*); - int *color_space = va_arg(args, int *); - if (private_handle_t::validate(hnd)) { - return res; - } - MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; - if (!metadata) { - break; -#ifdef USE_COLOR_METADATA - } else if (metadata->operation & COLOR_METADATA) { - ColorMetaData *colorMetadata = &metadata->color; - res = 0; - switch (colorMetadata->colorPrimaries) { - case ColorPrimaries_BT709_5: - *color_space = HAL_CSC_ITU_R_709; - break; - case ColorPrimaries_BT601_6_525: - *color_space = ((colorMetadata->range) ? - HAL_CSC_ITU_R_601_FR : HAL_CSC_ITU_R_601); - break; - case ColorPrimaries_BT2020: - *color_space = (colorMetadata->range) ? - HAL_CSC_ITU_R_2020_FR : HAL_CSC_ITU_R_2020; - break; - default: - res = -EINVAL; - break; - } -#endif - } else if(metadata->operation & UPDATE_COLOR_SPACE) { - *color_space = metadata->colorSpace; - res = 0; - } - } break; - - case GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO: - { - private_handle_t* hnd = va_arg(args, private_handle_t*); - android_ycbcr* ycbcr = va_arg(args, struct android_ycbcr *); - if (!private_handle_t::validate(hnd)) { - res = getYUVPlaneInfo(hnd, ycbcr); - } - } break; - - case GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO: - { - private_handle_t* hnd = va_arg(args, private_handle_t*); - int *map_secure_buffer = va_arg(args, int *); - if (private_handle_t::validate(hnd)) { - return res; - } - MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; - if(metadata && metadata->operation & MAP_SECURE_BUFFER) { - *map_secure_buffer = metadata->mapSecureBuffer; - res = 0; - } else { - *map_secure_buffer = 0; - } - } break; - - case GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG: - { - private_handle_t* hnd = va_arg(args, private_handle_t*); - int *flag = va_arg(args, int *); - if (private_handle_t::validate(hnd)) { - return res; - } - *flag = hnd->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED; - MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; - if (metadata && (metadata->operation & LINEAR_FORMAT)) { - *flag = 0; - } - res = 0; - } break; - - case GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS: - { - private_handle_t* hnd = va_arg(args, private_handle_t*); - void** rgb_data = va_arg(args, void**); - if (!private_handle_t::validate(hnd)) { - res = getRgbDataAddress(hnd, rgb_data); - } - } break; - - case GRALLOC_MODULE_PERFORM_GET_IGC: - { - private_handle_t* hnd = va_arg(args, private_handle_t*); - uint32_t *igc = va_arg(args, uint32_t *); - if (!private_handle_t::validate(hnd) && igc) { - MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; - if (metadata && (metadata->operation & SET_IGC)) { - *igc = metadata->igc; - res = 0; - } - } - } break; - - case GRALLOC_MODULE_PERFORM_SET_IGC: - res = 0; - break; - - case GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE: - { - private_handle_t* hnd = va_arg(args, private_handle_t*); - uint32_t *enable = va_arg(args, uint32_t*); - if (!private_handle_t::validate(hnd)) { - setMetaData(hnd, SET_SINGLE_BUFFER_MODE, enable); - res = 0; - } - } break; - default: - break; - } - va_end(args); - return res; -} diff --git a/libgralloc/memalloc.h b/libgralloc/memalloc.h deleted file mode 100644 index 598d983e..00000000 --- a/libgralloc/memalloc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GRALLOC_MEMALLOC_H -#define GRALLOC_MEMALLOC_H - -#include <stdlib.h> - -namespace gralloc { - -enum { - CACHE_CLEAN = 0x1, - CACHE_INVALIDATE, - CACHE_CLEAN_AND_INVALIDATE, -}; - -struct alloc_data { - void *base; - int fd; - unsigned int offset; - unsigned int size; - unsigned int align; - uintptr_t pHandle; - bool uncached; - unsigned int flags; - unsigned int heapId; - int allocType; -}; - -class IMemAlloc { - - public: - // Allocate buffer - fill in the alloc_data - // structure and pass it in. Mapped address - // and fd are returned in the alloc_data struct - virtual int alloc_buffer(alloc_data& data) = 0; - - // Free buffer - virtual int free_buffer(void *base, unsigned int size, - unsigned int offset, int fd) = 0; - - // Map buffer - virtual int map_buffer(void **pBase, unsigned int size, - unsigned int offset, int fd) = 0; - - // Unmap buffer - virtual int unmap_buffer(void *base, unsigned int size, - unsigned int offset) = 0; - - // Clean and invalidate - virtual int clean_buffer(void *base, unsigned int size, - unsigned int offset, int fd, int op) = 0; - - // Destructor - virtual ~IMemAlloc() {}; - - enum { - FD_INIT = -1, - }; - -}; - -} // end gralloc namespace -#endif // GRALLOC_MEMALLOC_H diff --git a/sdm/libs/hwc/blit_engine.h b/sdm/libs/hwc/blit_engine.h deleted file mode 100644 index 6fa9733e..00000000 --- a/sdm/libs/hwc/blit_engine.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright (c) 2015, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/*! @file blit_engine.h - @brief Interface file for Blit based compositior. - - @details The client can use this interface to get the blit composition done - -*/ - -#ifndef __BLIT_ENGINE_H__ -#define __BLIT_ENGINE_H__ - -namespace sdm { - -/*! @brief Blit Engine implemented by the client - - @details This class declares prototype for BlitEngine Interface which must be - implemented by the client. HWC will use this interface to use a Blit engine to get the - composition done. - -*/ -class BlitEngine { - public: - BlitEngine() { } - virtual ~BlitEngine() { } - - virtual int Init() = 0; - virtual void DeInit() = 0; - virtual int Prepare(LayerStack *layer_stack) = 0; - virtual int PreCommit(hwc_display_contents_1_t *content_list, LayerStack *layer_stack) = 0; - virtual int Commit(hwc_display_contents_1_t *content_list, LayerStack *layer_stack) = 0; - virtual void PostCommit(LayerStack *layer_stack) = 0; - virtual bool BlitActive() = 0; - virtual void SetFrameDumpConfig(uint32_t count) = 0; -}; - -} // namespace sdm - -#endif // __BLIT_ENGINE_H__ diff --git a/sdm/libs/hwc/blit_engine_c2d.cpp b/sdm/libs/hwc/blit_engine_c2d.cpp deleted file mode 100644 index 4efe2f1a..00000000 --- a/sdm/libs/hwc/blit_engine_c2d.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -* Portions formerly licensed under Apache License, Version 2.0, are re licensed -* under section 4 of Apache License, Version 2.0. - -* Copyright (C) 2010 The Android Open Source Project - -* Not a Contribution. - -* 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 <hardware/hardware.h> -#include <sync/sync.h> -#include <copybit.h> -#include <memalloc.h> -#include <alloc_controller.h> -#include <gr.h> - -#include <utils/constants.h> -#include <utils/rect.h> -#include <utils/formats.h> -#include <algorithm> - -#include "blit_engine_c2d.h" -#include "hwc_debugger.h" - -#define __CLASS__ "BlitEngineC2D" - -// TODO(user): Remove pragma after fixing sign conversion errors -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wsign-conversion" -#endif - -namespace sdm { - - -BlitEngineC2d::RegionIterator::RegionIterator(LayerRectArray rect) { - rect_array = rect; - r.end = INT(rect.count); - r.current = 0; - this->next = iterate; -} - -int BlitEngineC2d::RegionIterator::iterate(copybit_region_t const *self, copybit_rect_t *rect) { - if (!self || !rect) { - DLOGE("iterate invalid parameters"); - return 0; - } - - RegionIterator const *me = static_cast<RegionIterator const*>(self); - if (me->r.current != me->r.end) { - rect->l = INT(me->rect_array.rect[me->r.current].left); - rect->t = INT(me->rect_array.rect[me->r.current].top); - rect->r = INT(me->rect_array.rect[me->r.current].right); - rect->b = INT(me->rect_array.rect[me->r.current].bottom); - me->r.current++; - return 1; - } - return 0; -} - -BlitEngineC2d::BlitEngineC2d() { - for (uint32_t i = 0; i < kNumBlitTargetBuffers; i++) { - blit_target_buffer_[i] = NULL; - release_fence_fd_[i] = -1; - } -} - -BlitEngineC2d::~BlitEngineC2d() { - if (blit_engine_c2d_) { - copybit_close(blit_engine_c2d_); - blit_engine_c2d_ = NULL; - } - FreeBlitTargetBuffers(); -} - -int BlitEngineC2d::Init() { - hw_module_t const *module; - if (hw_get_module("copybit", &module) == 0) { - if (copybit_open(module, &blit_engine_c2d_) < 0) { - DLOGI("CopyBitC2D Open failed."); - return -1; - } - DLOGI("Opened Copybit Module"); - } else { - DLOGI("Copybit HW Module not found"); - return -1; - } - - return 0; -} - -void BlitEngineC2d::DeInit() { - FreeBlitTargetBuffers(); - if (blit_engine_c2d_) { - copybit_close(blit_engine_c2d_); - blit_engine_c2d_ = NULL; - } -} - -int BlitEngineC2d::AllocateBlitTargetBuffers(uint32_t width, uint32_t height, uint32_t format, - uint32_t usage) { - int status = 0; - if (width <= 0 || height <= 0) { - return false; - } - - if (blit_target_buffer_[0]) { - // Free and reallocate the buffers if the w/h changes - if (INT(width) != blit_target_buffer_[0]->width || - INT(height) != blit_target_buffer_[0]->height) { - FreeBlitTargetBuffers(); - } - } - - for (uint32_t i = 0; i < kNumBlitTargetBuffers; i++) { - if (blit_target_buffer_[i] == NULL) { - status = alloc_buffer(&blit_target_buffer_[i], width, height, format, usage); - } - if (status < 0) { - DLOGE("Allocation of Blit target Buffer failed"); - FreeBlitTargetBuffers(); - break; - } - } - - return status; -} - -void BlitEngineC2d::FreeBlitTargetBuffers() { - for (uint32_t i = 0; i < kNumBlitTargetBuffers; i++) { - private_handle_t **target_buffer = &blit_target_buffer_[i]; - if (*target_buffer) { - // Free the valid fence - if (release_fence_fd_[i] >= 0) { - close(release_fence_fd_[i]); - release_fence_fd_[i] = -1; - } - free_buffer(*target_buffer); - *target_buffer = NULL; - } - } -} - -int BlitEngineC2d::ClearTargetBuffer(private_handle_t* hnd, const LayerRect& rect) { - int status = 0; - copybit_rect_t clear_rect = {INT(rect.left), INT(rect.top), INT(rect.right), INT(rect.bottom)}; - - copybit_image_t buffer; - buffer.w = ALIGN((hnd->width), 32); - buffer.h = hnd->height; - buffer.format = hnd->format; - buffer.base = reinterpret_cast<void *>(hnd->base); - buffer.handle = reinterpret_cast<native_handle_t *>(hnd); - int dst_format_mode = COPYBIT_LINEAR; - if (hnd->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED) { - dst_format_mode = COPYBIT_UBWC_COMPRESSED; - } - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_DST_FORMAT_MODE, dst_format_mode); - - status = blit_engine_c2d_->clear(blit_engine_c2d_, &buffer, &clear_rect); - return status; -} - -void BlitEngineC2d::PostCommit(LayerStack *layer_stack) { - int fence_fd = -1; - uint32_t count = 0; - int fd = -1; - - for (uint32_t i = blit_target_start_index_-2; (i > 0) && (count < num_blit_target_); i--) { - Layer *layer = layer_stack->layers.at(i); - LayerBuffer &layer_buffer = layer->input_buffer; - if (layer->composition == kCompositionBlit) { - int index = blit_target_start_index_ + count; - layer_buffer.release_fence_fd = - layer_stack->layers.at(index)->input_buffer.release_fence_fd; - fence_fd = layer_buffer.release_fence_fd; - close(layer_buffer.acquire_fence_fd); - layer_buffer.acquire_fence_fd = -1; - layer_stack->layers.at(index)->input_buffer.release_fence_fd = -1; - fd = layer_stack->layers.at(index)->input_buffer.acquire_fence_fd; - layer_stack->layers.at(index)->input_buffer.acquire_fence_fd = -1; - count++; - } - } - - if (fd >= 0) { - // Close the C2D fence FD - close(fd); - } - SetReleaseFence(fence_fd); -} - -// Sync wait to close the previous fd -void BlitEngineC2d::SetReleaseFence(int fd) { - if (release_fence_fd_[current_blit_target_index_] >= 0) { - int ret = -1; - ret = sync_wait(release_fence_fd_[current_blit_target_index_], 1000); - if (ret < 0) { - DLOGE("sync_wait error! errno = %d, err str = %s", errno, strerror(errno)); - } - close(release_fence_fd_[current_blit_target_index_]); - } - release_fence_fd_[current_blit_target_index_] = dup(fd); -} - -bool BlitEngineC2d::BlitActive() { - return blit_active_; -} - -void BlitEngineC2d::SetFrameDumpConfig(uint32_t count) { - dump_frame_count_ = count; - dump_frame_index_ = 0; -} - -int BlitEngineC2d::Prepare(LayerStack *layer_stack) { - blit_target_start_index_ = 0; - - uint32_t layer_count = UINT32(layer_stack->layers.size()); - uint32_t gpu_target_index = layer_count - 1; // default assumption - uint32_t i = 0; - - for (; i < layer_count; i++) { - Layer *layer = layer_stack->layers.at(i); - - // No 10 bit support for C2D - if (Is10BitFormat(layer->input_buffer.format)) { - return -1; - } - - if (layer->composition == kCompositionGPUTarget) { - // Need FBT size for allocating buffers - gpu_target_index = i; - break; - } - } - - if ((layer_count - 1) == gpu_target_index) { - // No blit target layer - return -1; - } - - blit_target_start_index_ = ++i; - num_blit_target_ = layer_count - blit_target_start_index_; - - LayerBuffer &layer_buffer = layer_stack->layers.at(gpu_target_index)->input_buffer; - int fbwidth = INT(layer_buffer.unaligned_width); - int fbheight = INT(layer_buffer.unaligned_height); - if ((fbwidth < 0) || (fbheight < 0)) { - return -1; - } - - current_blit_target_index_ = (current_blit_target_index_ + 1) % kNumBlitTargetBuffers; - int k = blit_target_start_index_; - - for (uint32_t j = 0; j < num_blit_target_; j++, k++) { - Layer *layer = layer_stack->layers.at(k); - LayerBuffer &layer_buffer = layer->input_buffer; - int aligned_w = 0; - int aligned_h = 0; - - // Set the buffer height and width - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(fbwidth, fbheight/3, - INT(HAL_PIXEL_FORMAT_RGBA_8888), 0, aligned_w, aligned_h); - layer_buffer.width = aligned_w; - layer_buffer.height = aligned_h; - layer_buffer.unaligned_width = fbwidth; - layer_buffer.unaligned_height = fbheight/3; - - layer->plane_alpha = 0xFF; - layer->blending = kBlendingOpaque; - layer->composition = kCompositionBlitTarget; - layer->frame_rate = layer_stack->layers.at(gpu_target_index)->frame_rate; - } - - return 0; -} - -int BlitEngineC2d::PreCommit(hwc_display_contents_1_t *content_list, LayerStack *layer_stack) { - int status = 0; - uint32_t num_app_layers = (uint32_t) content_list->numHwLayers-1; - int target_width = 0; - int target_height = 0; - int target_aligned_width = 0; - int target_aligned_height = 0; - uint32_t processed_blit = 0; - LayerRect dst_rects[kMaxBlitTargetLayers]; - bool blit_needed = false; - uint32_t usage = 0; - - if (!num_app_layers) { - return -1; - } - - for (uint32_t i = num_app_layers-1; (i > 0) && (processed_blit < num_blit_target_); i--) { - Layer *layer = layer_stack->layers.at(i); - if (layer->composition != kCompositionBlit) { - continue; - } - blit_needed = true; - layer_stack->flags.attributes_changed = true; - - Layer *blit_layer = layer_stack->layers.at(blit_target_start_index_ + processed_blit); - LayerRect &blit_src_rect = blit_layer->src_rect; - int width = INT(layer->dst_rect.right - layer->dst_rect.left); - int height = INT(layer->dst_rect.bottom - layer->dst_rect.top); - int aligned_w = 0; - int aligned_h = 0; - usage = GRALLOC_USAGE_PRIVATE_IOMMU_HEAP | GRALLOC_USAGE_HW_TEXTURE; - if (blit_engine_c2d_->get(blit_engine_c2d_, COPYBIT_UBWC_SUPPORT) > 0) { - usage |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC; - } - // TODO(user): FrameBuffer is assumed to be RGBA - target_width = std::max(target_width, width); - target_height += height; - - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width, height, - INT(HAL_PIXEL_FORMAT_RGBA_8888), usage, aligned_w, aligned_h); - - target_aligned_width = std::max(target_aligned_width, aligned_w); - target_aligned_height += aligned_h; - - // Left will be zero always - dst_rects[processed_blit].top = FLOAT(target_aligned_height - aligned_h); - dst_rects[processed_blit].right = dst_rects[processed_blit].left + - (layer->dst_rect.right - layer->dst_rect.left); - dst_rects[processed_blit].bottom = (dst_rects[processed_blit].top + - (layer->dst_rect.bottom - layer->dst_rect.top)); - blit_src_rect = dst_rects[processed_blit]; - processed_blit++; - } - - // Allocate a single buffer of RGBA8888 format - if (blit_needed && (AllocateBlitTargetBuffers(target_width, target_height, - HAL_PIXEL_FORMAT_RGBA_8888, usage) < 0)) { - status = -1; - return status; - } - - if (blit_needed) { - for (uint32_t j = 0; j < num_blit_target_; j++) { - Layer *layer = layer_stack->layers.at(j + content_list->numHwLayers); - private_handle_t *target_buffer = blit_target_buffer_[current_blit_target_index_]; - // Set the fd information - layer->input_buffer.width = target_aligned_width; - layer->input_buffer.height = target_aligned_height; - layer->input_buffer.unaligned_width = target_width; - layer->input_buffer.unaligned_height = target_height; - if (target_buffer->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED) { - layer->input_buffer.format = kFormatRGBA8888Ubwc; - } - layer->input_buffer.planes[0].fd = target_buffer->fd; - layer->input_buffer.planes[0].offset = 0; - layer->input_buffer.planes[0].stride = target_buffer->width; - } - } - - return status; -} - -int BlitEngineC2d::Commit(hwc_display_contents_1_t *content_list, LayerStack *layer_stack) { - int fd = -1; - int status = 0; - bool hybrid_present = false; - uint32_t num_app_layers = (uint32_t) content_list->numHwLayers-1; - private_handle_t *target_buffer = blit_target_buffer_[current_blit_target_index_]; - blit_active_ = false; - - if (!num_app_layers) { - return -1; - } - - // if not Blit Targets return - for (uint32_t i = 0; i < num_app_layers; i++) { - Layer *layer = layer_stack->layers.at(i); - if (layer->composition == kCompositionHybrid || layer->composition == kCompositionBlit) { - hybrid_present = true; - } - } - - if (!hybrid_present) { - return status; - } - - // Clear blit target buffer - LayerRect clear_rect; - clear_rect.left = 0; - clear_rect.top = 0; - clear_rect.right = FLOAT(target_buffer->width); - clear_rect.bottom = FLOAT(target_buffer->height); - ClearTargetBuffer(target_buffer, clear_rect); - - int copybit_layer_count = 0; - uint32_t processed_blit = 0; - for (uint32_t i = num_app_layers-1; (i > 0) && (processed_blit < num_blit_target_) && - (status == 0); i--) { - Layer *layer = layer_stack->layers.at(i); - if (layer->composition != kCompositionBlit) { - continue; - } - - for (uint32_t k = 0; k <= i; k++) { - Layer *bottom_layer = layer_stack->layers.at(k); - LayerBuffer &layer_buffer = bottom_layer->input_buffer; - // if layer below the blit layer does not intersect, ignore that layer - LayerRect inter_sect = Intersection(layer->dst_rect, bottom_layer->dst_rect); - if (bottom_layer->composition != kCompositionHybrid && !IsValid(inter_sect)) { - continue; - } - if (bottom_layer->composition == kCompositionGPU || - bottom_layer->composition == kCompositionSDE || - bottom_layer->composition == kCompositionGPUTarget) { - continue; - } - - // For each layer marked as Hybrid, wait for acquire fence and then blit using the C2D - if (layer_buffer.acquire_fence_fd >= 0) { - // Wait for acquire fence on the App buffers. - if (sync_wait(layer_buffer.acquire_fence_fd, 1000) < 0) { - DLOGE("sync_wait error!! error no = %d err str = %s", errno, strerror(errno)); - } - layer_buffer.acquire_fence_fd = -1; - } - hwc_layer_1_t *hwc_layer = &content_list->hwLayers[k]; - LayerRect &src_rect = bottom_layer->blit_regions.at(processed_blit); - Layer *blit_layer = layer_stack->layers.at(blit_target_start_index_ + processed_blit); - LayerRect dest_rect = blit_layer->src_rect; - int ret_val = DrawRectUsingCopybit(hwc_layer, bottom_layer, src_rect, dest_rect); - copybit_layer_count++; - if (ret_val < 0) { - copybit_layer_count = 0; - DLOGE("DrawRectUsingCopyBit failed"); - status = -1; - break; - } - } - processed_blit++; - } - - if (copybit_layer_count) { - blit_active_ = true; - blit_engine_c2d_->flush_get_fence(blit_engine_c2d_, &fd); - } - - if (blit_active_) { - // dump the render buffer - DumpBlitTargetBuffer(fd); - - // Set the fd to the LayerStack BlitTargets fd - uint32_t layer_count = UINT32(layer_stack->layers.size()); - for (uint32_t k = blit_target_start_index_; k < layer_count; k++) { - Layer *layer = layer_stack->layers.at(k); - LayerBuffer &layer_buffer = layer->input_buffer; - layer_buffer.acquire_fence_fd = fd; - } - } - - return status; -} - -int BlitEngineC2d::DrawRectUsingCopybit(hwc_layer_1_t *hwc_layer, Layer *layer, - LayerRect blit_rect, LayerRect blit_dest_Rect) { - private_handle_t *target_buffer = blit_target_buffer_[current_blit_target_index_]; - const private_handle_t *hnd = static_cast<const private_handle_t *>(hwc_layer->handle); - LayerBuffer &layer_buffer = layer->input_buffer; - - // Set the Copybit Source - copybit_image_t src; - src.handle = const_cast<native_handle_t *>(hwc_layer->handle); - src.w = hnd->width; - src.h = hnd->height; - src.base = reinterpret_cast<void *>(hnd->base); - src.format = hnd->format; - src.horiz_padding = 0; - src.vert_padding = 0; - - // Copybit source rect - copybit_rect_t src_rect = {INT(blit_rect.left), INT(blit_rect.top), INT(blit_rect.right), - INT(blit_rect.bottom)}; - - // Copybit destination rect - copybit_rect_t dst_rect = {INT(blit_dest_Rect.left), INT(blit_dest_Rect.top), - INT(blit_dest_Rect.right), INT(blit_dest_Rect.bottom)}; - - // Copybit destination buffer - copybit_image_t dst; - dst.handle = static_cast<native_handle_t *>(target_buffer); - dst.w = ALIGN(target_buffer->width, 32); - dst.h = ALIGN((target_buffer->height), 32); - dst.base = reinterpret_cast<void *>(target_buffer->base); - dst.format = target_buffer->format; - - // Copybit region is the destRect - LayerRect region_rect; - region_rect.left = FLOAT(dst_rect.l); - region_rect.top = FLOAT(dst_rect.t); - region_rect.right = FLOAT(dst_rect.r); - region_rect.bottom = FLOAT(dst_rect.b); - - LayerRectArray region; - region.count = 1; - region.rect = ®ion_rect; - RegionIterator copybitRegion(region); - int acquireFd = layer_buffer.acquire_fence_fd; - - // FRAMEBUFFER_WIDTH/HEIGHT for c2d is the target buffer w/h - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_FRAMEBUFFER_WIDTH, - target_buffer->width); - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_FRAMEBUFFER_HEIGHT, - target_buffer->height); - int transform = 0; - if (layer->transform.rotation != 0.0f) transform |= COPYBIT_TRANSFORM_ROT_90; - if (layer->transform.flip_horizontal) transform |= COPYBIT_TRANSFORM_FLIP_H; - if (layer->transform.flip_vertical) transform |= COPYBIT_TRANSFORM_FLIP_V; - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_TRANSFORM, transform); - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_PLANE_ALPHA, hwc_layer->planeAlpha); - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_BLEND_MODE, hwc_layer->blending); - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_DITHER, - (dst.format == HAL_PIXEL_FORMAT_RGB_565) ? COPYBIT_ENABLE : COPYBIT_DISABLE); - - int src_format_mode = COPYBIT_LINEAR; - if (hnd->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED) { - src_format_mode = COPYBIT_UBWC_COMPRESSED; - } - blit_engine_c2d_->set_parameter(blit_engine_c2d_, COPYBIT_SRC_FORMAT_MODE, src_format_mode); - - blit_engine_c2d_->set_sync(blit_engine_c2d_, acquireFd); - int err = blit_engine_c2d_->stretch(blit_engine_c2d_, &dst, &src, &dst_rect, &src_rect, - ©bitRegion); - - if (err < 0) { - DLOGE("copybit stretch failed"); - } - - return err; -} - -void BlitEngineC2d::DumpBlitTargetBuffer(int fd) { - if (!dump_frame_count_) { - return; - } - - private_handle_t *target_buffer = blit_target_buffer_[current_blit_target_index_]; - - if (fd >= 0) { - int error = sync_wait(fd, 1000); - if (error < 0) { - DLOGW("sync_wait error errno = %d, desc = %s", errno, strerror(errno)); - return; - } - } - - char dump_file_name[PATH_MAX]; - size_t result = 0; - snprintf(dump_file_name, sizeof(dump_file_name), "/data/misc/display/frame_dump_primary" - "/blit_target_%d.raw", (dump_frame_index_)); - FILE* fp = fopen(dump_file_name, "w+"); - if (fp) { - result = fwrite(reinterpret_cast<void *>(target_buffer->base), target_buffer->size, 1, fp); - fclose(fp); - } - dump_frame_count_--; - dump_frame_index_++; -} - -} // namespace sdm -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - diff --git a/sdm/libs/hwc/blit_engine_c2d.h b/sdm/libs/hwc/blit_engine_c2d.h deleted file mode 100644 index 6536d442..00000000 --- a/sdm/libs/hwc/blit_engine_c2d.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (c) 2012 - 2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -* Portions formerly licensed under Apache License, Version 2.0, are re licensed -* under section 4 of Apache License, Version 2.0. - -* Copyright (C) 2010 The Android Open Source Project - -* Not a Contribution. - -* 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. -*/ - -/*! @file blit_engine.h - @brief Interface file for Blit based compositior. - - @details The client can use this interface to get the blit composition done - -*/ - -#include <hardware/hwcomposer.h> -#include <core/layer_stack.h> -#include <copybit.h> -#include "blit_engine.h" - -#ifndef __BLIT_ENGINE_C2D_H__ -#define __BLIT_ENGINE_C2D_H__ - -namespace sdm { - -// C2D Blit implemented by the client -// This class implements the BlitEngine Interface which is used to get the -// Blit composition using C2D -class BlitEngineC2d : public BlitEngine { - public: - BlitEngineC2d(); - virtual ~BlitEngineC2d(); - - virtual int Init(); - virtual void DeInit(); - virtual int Prepare(LayerStack *layer_stack); - virtual int PreCommit(hwc_display_contents_1_t *content_list, LayerStack *layer_stack); - virtual int Commit(hwc_display_contents_1_t *content_list, LayerStack *layer_stack); - virtual void PostCommit(LayerStack *layer_stack); - virtual bool BlitActive(); - virtual void SetFrameDumpConfig(uint32_t count); - - - private: - static const uint32_t kNumBlitTargetBuffers = 3; - - struct Range { - int current; - int end; - }; - - struct RegionIterator : public copybit_region_t { - explicit RegionIterator(LayerRectArray rect); - private: - static int iterate(copybit_region_t const *self, copybit_rect_t *rect); - LayerRectArray rect_array; - mutable Range r; - }; - - int AllocateBlitTargetBuffers(uint32_t width, uint32_t height, uint32_t format, uint32_t usage); - void FreeBlitTargetBuffers(); - int ClearTargetBuffer(private_handle_t* hnd, const LayerRect& rect); - int DrawRectUsingCopybit(hwc_layer_1_t *hwc_layer, Layer *layer, LayerRect blit_rect, - LayerRect blit_dest_Rect); - void SetReleaseFence(int fence_fd); - void DumpBlitTargetBuffer(int fd); - - copybit_device_t *blit_engine_c2d_ = NULL; - private_handle_t *blit_target_buffer_[kNumBlitTargetBuffers]; - uint32_t current_blit_target_index_ = 0; - int release_fence_fd_[kNumBlitTargetBuffers]; - uint32_t num_blit_target_ = 0; - int blit_target_start_index_ = 0; - bool blit_active_ = false; - uint32_t dump_frame_count_ = 0; - uint32_t dump_frame_index_ = 0; -}; - -} // namespace sdm - -#endif // __BLIT_ENGINE_C2D_H__ diff --git a/sdm/libs/hwc/hwc_color_manager.cpp b/sdm/libs/hwc/hwc_color_manager.cpp deleted file mode 100644 index 471ca496..00000000 --- a/sdm/libs/hwc/hwc_color_manager.cpp +++ /dev/null @@ -1,652 +0,0 @@ -/* -* Copyright (c) 2015 - 2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include <dlfcn.h> -#include <powermanager/IPowerManager.h> -#include <cutils/sockets.h> -#include <cutils/native_handle.h> -#include <utils/String16.h> -#include <binder/Parcel.h> -#include <gralloc_priv.h> -#include <hardware/hwcomposer.h> -#include <hardware/hwcomposer_defs.h> -#include <QService.h> - -#include <core/dump_interface.h> -#include <utils/constants.h> -#include <utils/debug.h> -#include <core/buffer_allocator.h> -#include <private/color_params.h> -#include "hwc_buffer_allocator.h" -#include "hwc_buffer_sync_handler.h" -#include "hwc_session.h" -#include "hwc_debugger.h" - -#define __CLASS__ "HWCColorManager" - -namespace sdm { - -uint32_t HWCColorManager::Get8BitsARGBColorValue(const PPColorFillParams ¶ms) { - uint32_t argb_color = ((params.color.r << 16) & 0xff0000) | ((params.color.g << 8) & 0xff00) | - ((params.color.b) & 0xff); - return argb_color; -} - -int HWCColorManager::CreatePayloadFromParcel(const android::Parcel &in, uint32_t *disp_id, - PPDisplayAPIPayload *sink) { - int ret = 0; - uint32_t id(0); - uint32_t size(0); - - id = UINT32(in.readInt32()); - size = UINT32(in.readInt32()); - if (size > 0 && size == in.dataAvail()) { - const void *data = in.readInplace(size); - const uint8_t *temp = reinterpret_cast<const uint8_t *>(data); - - sink->size = size; - sink->payload = const_cast<uint8_t *>(temp); - *disp_id = id; - } else { - DLOGW("Failing size checking, size = %d", size); - ret = -EINVAL; - } - - return ret; -} - -void HWCColorManager::MarshallStructIntoParcel(const PPDisplayAPIPayload &data, - android::Parcel *out_parcel) { - out_parcel->writeInt32(INT32(data.size)); - if (data.payload) - out_parcel->write(data.payload, data.size); -} - -HWCColorManager *HWCColorManager::CreateColorManager() { - HWCColorManager *color_mgr = new HWCColorManager(); - - if (color_mgr) { - // Load display API interface library. And retrieve color API function tables. - DynLib &color_apis_lib = color_mgr->color_apis_lib_; - if (color_apis_lib.Open(DISPLAY_API_INTERFACE_LIBRARY_NAME)) { - if (!color_apis_lib.Sym(DISPLAY_API_FUNC_TABLES, &color_mgr->color_apis_)) { - DLOGE("Fail to retrieve = %s from %s", DISPLAY_API_FUNC_TABLES, - DISPLAY_API_INTERFACE_LIBRARY_NAME); - delete color_mgr; - return NULL; - } - } else { - DLOGW("Unable to load = %s", DISPLAY_API_INTERFACE_LIBRARY_NAME); - delete color_mgr; - return NULL; - } - DLOGI("Successfully loaded %s", DISPLAY_API_INTERFACE_LIBRARY_NAME); - - // Load diagclient library and invokes its entry point to pass in display APIs. - DynLib &diag_client_lib = color_mgr->diag_client_lib_; - if (diag_client_lib.Open(QDCM_DIAG_CLIENT_LIBRARY_NAME)) { - if (!diag_client_lib.Sym(INIT_QDCM_DIAG_CLIENT_NAME, - reinterpret_cast<void **>(&color_mgr->qdcm_diag_init_)) || - !diag_client_lib.Sym(DEINIT_QDCM_DIAG_CLIENT_NAME, - reinterpret_cast<void **>(&color_mgr->qdcm_diag_deinit_))) { - DLOGE("Fail to retrieve = %s from %s", INIT_QDCM_DIAG_CLIENT_NAME, - QDCM_DIAG_CLIENT_LIBRARY_NAME); - } else { - // invoke Diag Client entry point to initialize. - color_mgr->qdcm_diag_init_(color_mgr->color_apis_); - DLOGI("Successfully loaded %s and %s and diag_init'ed", DISPLAY_API_INTERFACE_LIBRARY_NAME, - QDCM_DIAG_CLIENT_LIBRARY_NAME); - } - } else { - DLOGW("Unable to load = %s", QDCM_DIAG_CLIENT_LIBRARY_NAME); - // only QDCM Diag client failed to be loaded and system still should function. - } - } else { - DLOGE("Unable to create HWCColorManager"); - return NULL; - } - - return color_mgr; -} - -HWCColorManager::~HWCColorManager() { -} - -void HWCColorManager::DestroyColorManager() { - if (qdcm_mode_mgr_) { - delete qdcm_mode_mgr_; - } - if (qdcm_diag_deinit_) { - qdcm_diag_deinit_(); - } - delete this; -} - -int HWCColorManager::EnableQDCMMode(bool enable, HWCDisplay *hwc_display) { - int ret = 0; - - if (!qdcm_mode_mgr_) { - qdcm_mode_mgr_ = HWCQDCMModeManager::CreateQDCMModeMgr(); - if (!qdcm_mode_mgr_) { - DLOGE("Unable to create QDCM operating mode manager."); - ret = -EFAULT; - } - } - - if (qdcm_mode_mgr_) { - ret = qdcm_mode_mgr_->EnableQDCMMode(enable, hwc_display); - } - - return ret; -} - -bool HWCColorManager::SolidFillLayersPrepare(hwc_display_contents_1_t **displays, - HWCDisplay *hwc_display) { - SCOPE_LOCK(locker_); - - // Query HWCColorManager if QDCM tool requesting SOLID_FILL mode. - uint32_t solid_fill_color = Get8BitsARGBColorValue(solid_fill_params_); - hwc_display_contents_1_t *layer_list = displays[HWC_DISPLAY_PRIMARY]; - - if (solid_fill_enable_ && solid_fill_layers_ && layer_list) { - // 1. shallow copy HWC_FRAMEBUFFER_TARGET layer info solid fill layer list. - solid_fill_layers_->hwLayers[1] = layer_list->hwLayers[layer_list->numHwLayers - 1]; - - // 2. continue the prepare<> on solid_fill_layers. - hwc_display->Perform(HWCDisplayPrimary::SET_QDCM_SOLID_FILL_INFO, solid_fill_color); - hwc_display->Prepare(solid_fill_layers_); // RECT info included. - - // 3. Set HWC_OVERLAY to all SF layers before returning to framework. - for (size_t i = 0; i < (layer_list->numHwLayers - 1); i++) { - hwc_layer_1_t *layer = &layer_list->hwLayers[i]; - layer->compositionType = HWC_OVERLAY; - } - - return true; - } else if (!solid_fill_enable_) { - hwc_display->Perform(HWCDisplayPrimary::UNSET_QDCM_SOLID_FILL_INFO, 0); - } - - return false; -} - -bool HWCColorManager::SolidFillLayersSet(hwc_display_contents_1_t **displays, - HWCDisplay *hwc_display) { - // Query HWCColorManager if QDCM tool requesting SOLID_FILL mode. - SCOPE_LOCK(locker_); - hwc_display_contents_1_t *layer_list = displays[HWC_DISPLAY_PRIMARY]; - if (solid_fill_enable_ && solid_fill_layers_ && layer_list) { - hwc_display->Commit(solid_fill_layers_); - - // SurfaceFlinger layer stack is dropped in solid fill case and replaced with local layer stack - // Close acquire fence fds associated with SF layer stack - // Close release/retire fence fds returned along with local layer stack - for (size_t i = 0; i < (layer_list->numHwLayers - 1); i++) { - int &fence_fd = layer_list->hwLayers[i].acquireFenceFd; - if (fence_fd >= 0) { - close(fence_fd); - fence_fd = -1; - } - } - - for (size_t i = 0; i < (solid_fill_layers_->numHwLayers - 1); i++) { - int &fence_fd = solid_fill_layers_->hwLayers[i].releaseFenceFd; - if (fence_fd >= 0) { - close(fence_fd); - fence_fd = -1; - } - } - if (solid_fill_layers_->retireFenceFd >= 0) { - close(solid_fill_layers_->retireFenceFd); - solid_fill_layers_->retireFenceFd = -1; - } - - return true; - } - - return false; -} - -int HWCColorManager::CreateSolidFillLayers(HWCDisplay *hwc_display) { - int ret = 0; - - if (!solid_fill_layers_) { - uint32_t size = sizeof(hwc_display_contents_1) + kNumSolidFillLayers * sizeof(hwc_layer_1_t); - uint32_t primary_width = 0; - uint32_t primary_height = 0; - - hwc_display->GetMixerResolution(&primary_width, &primary_height); - uint8_t *buf = new uint8_t[size](); - // handle for solid fill layer with fd = -1. - private_handle_t *handle = - new private_handle_t(-1, 0, private_handle_t::PRIV_FLAGS_FRAMEBUFFER, BUFFER_TYPE_UI, - HAL_PIXEL_FORMAT_RGBA_8888, INT32(primary_width), - INT32(primary_height)); - - if (!buf || !handle) { - DLOGE("Failed to allocate memory."); - if (buf) - delete[] buf; - if (handle) - delete handle; - - return -ENOMEM; - } - - solid_fill_layers_ = reinterpret_cast<hwc_display_contents_1 *>(buf); - hwc_layer_1_t &layer = solid_fill_layers_->hwLayers[0]; - layer.handle = handle; - } - - solid_fill_layers_->flags = HWC_GEOMETRY_CHANGED; - solid_fill_layers_->numHwLayers = kNumSolidFillLayers; - solid_fill_layers_->retireFenceFd = -1; - solid_fill_layers_->outbuf = NULL; - solid_fill_layers_->outbufAcquireFenceFd = -1; - - hwc_layer_1_t &layer = solid_fill_layers_->hwLayers[0]; - hwc_rect_t solid_fill_rect = { - INT(solid_fill_params_.rect.x), - INT(solid_fill_params_.rect.y), - solid_fill_params_.rect.x + INT(solid_fill_params_.rect.width), - solid_fill_params_.rect.y + INT(solid_fill_params_.rect.height), - }; - - layer.compositionType = HWC_FRAMEBUFFER; - layer.blending = HWC_BLENDING_PREMULT; - layer.sourceCropf.left = solid_fill_params_.rect.x; - layer.sourceCropf.top = solid_fill_params_.rect.y; - layer.sourceCropf.right = UINT32(solid_fill_params_.rect.x) + solid_fill_params_.rect.width; - layer.sourceCropf.bottom = UINT32(solid_fill_params_.rect.y) + solid_fill_params_.rect.height; - layer.acquireFenceFd = -1; - layer.releaseFenceFd = -1; - layer.flags = 0; - layer.transform = 0; - layer.hints = 0; - layer.planeAlpha = 0xff; - layer.displayFrame = solid_fill_rect; - layer.visibleRegionScreen.numRects = 1; - layer.visibleRegionScreen.rects = &layer.displayFrame; - layer.surfaceDamage.numRects = 0; - - return ret; -} - -void HWCColorManager::DestroySolidFillLayers() { - if (solid_fill_layers_) { - hwc_layer_1_t &layer = solid_fill_layers_->hwLayers[0]; - uint8_t *buf = reinterpret_cast<uint8_t *>(solid_fill_layers_); - private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(layer.handle); - - if (hnd) - delete hnd; - - if (buf) - delete[] buf; - - solid_fill_layers_ = NULL; - } -} - -int HWCColorManager::SetSolidFill(const void *params, bool enable, HWCDisplay *hwc_display) { - SCOPE_LOCK(locker_); - int ret = 0; - - if (params) { - solid_fill_params_ = *reinterpret_cast<const PPColorFillParams *>(params); - } else { - solid_fill_params_ = PPColorFillParams(); - } - - if (enable) { - // will create solid fill layers for rendering if not present. - ret = CreateSolidFillLayers(hwc_display); - } else { - DestroySolidFillLayers(); - } - solid_fill_enable_ = enable; - - return ret; -} - -int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_display) { - SCOPE_LOCK(locker_); - int ret = 0; - - PPFrameCaptureData *frame_capture_data = reinterpret_cast<PPFrameCaptureData*>(params); - - if (enable) { - std::memset(&buffer_info, 0x00, sizeof(buffer_info)); - hwc_display->GetPanelResolution(&buffer_info.buffer_config.width, - &buffer_info.buffer_config.height); - if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) { - buffer_info.buffer_config.format = kFormatRGB888; - } else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) { - buffer_info.buffer_config.format = kFormatRGBA1010102; - } else { - DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format); - return -EFAULT; - } - - buffer_info.buffer_config.buffer_count = 1; - buffer_info.alloc_buffer_info.fd = -1; - buffer_info.alloc_buffer_info.stride = 0; - buffer_info.alloc_buffer_info.size = 0; - - buffer_allocator_ = new HWCBufferAllocator(); - if (buffer_allocator_ == NULL) { - DLOGE("Memory allocation for buffer_allocator_ FAILED"); - return -ENOMEM; - } - - ret = buffer_allocator_->AllocateBuffer(&buffer_info); - if (ret != 0) { - DLOGE("Buffer allocation failed. ret: %d", ret); - delete buffer_allocator_; - buffer_allocator_ = NULL; - return -ENOMEM; - } else { - void *buffer = mmap(NULL, buffer_info.alloc_buffer_info.size, - PROT_READ|PROT_WRITE, - MAP_SHARED, buffer_info.alloc_buffer_info.fd, 0); - - if (buffer == MAP_FAILED) { - DLOGE("mmap failed. err = %d", errno); - frame_capture_data->buffer = NULL; - ret = buffer_allocator_->FreeBuffer(&buffer_info); - delete buffer_allocator_; - buffer_allocator_ = NULL; - return -EFAULT; - } else { - frame_capture_data->buffer = reinterpret_cast<uint8_t *>(buffer); - frame_capture_data->buffer_stride = buffer_info.alloc_buffer_info.aligned_width; - frame_capture_data->buffer_size = buffer_info.alloc_buffer_info.size; - } - ret = hwc_display->FrameCaptureAsync(buffer_info, 1); - if (ret < 0) { - DLOGE("FrameCaptureAsync failed. ret = %d", ret); - } - } - } else { - ret = hwc_display->GetFrameCaptureStatus(); - if (!ret) { - if (frame_capture_data->buffer != NULL) { - if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) { - DLOGE("munmap failed. err = %d", errno); - } - } - if (buffer_allocator_ != NULL) { - std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData)); - ret = buffer_allocator_->FreeBuffer(&buffer_info); - if (ret != 0) { - DLOGE("FreeBuffer failed. ret = %d", ret); - } - delete buffer_allocator_; - buffer_allocator_ = NULL; - } - } else { - DLOGE("GetFrameCaptureStatus failed. ret = %d", ret); - } - } - return ret; -} - -int HWCColorManager::SetHWDetailedEnhancerConfig(void *params, HWCDisplay *hwc_display) { - int err = -1; - DisplayDetailEnhancerData de_data; - - PPDETuningCfgData *de_tuning_cfg_data = reinterpret_cast<PPDETuningCfgData*>(params); - if (de_tuning_cfg_data->cfg_pending == true) { - if (!de_tuning_cfg_data->cfg_en) { - de_data.override_flags = kOverrideDEEnable; - de_data.enable = 0; - } else { - de_data.override_flags = kOverrideDEEnable; - de_data.enable = 1; - - if (de_tuning_cfg_data->params.flags & kDeTuningFlagSharpFactor) { - de_data.override_flags |= kOverrideDESharpen1; - de_data.sharp_factor = de_tuning_cfg_data->params.sharp_factor; - } - - if (de_tuning_cfg_data->params.flags & kDeTuningFlagClip) { - de_data.override_flags |= kOverrideDEClip; - de_data.clip = de_tuning_cfg_data->params.clip; - } - - if (de_tuning_cfg_data->params.flags & kDeTuningFlagThrQuiet) { - de_data.override_flags |= kOverrideDEThrQuiet; - de_data.thr_quiet = de_tuning_cfg_data->params.thr_quiet; - } - - if (de_tuning_cfg_data->params.flags & kDeTuningFlagThrDieout) { - de_data.override_flags |= kOverrideDEThrDieout; - de_data.thr_dieout = de_tuning_cfg_data->params.thr_dieout; - } - - if (de_tuning_cfg_data->params.flags & kDeTuningFlagThrLow) { - de_data.override_flags |= kOverrideDEThrLow; - de_data.thr_low = de_tuning_cfg_data->params.thr_low; - } - - if (de_tuning_cfg_data->params.flags & kDeTuningFlagThrHigh) { - de_data.override_flags |= kOverrideDEThrHigh; - de_data.thr_high = de_tuning_cfg_data->params.thr_high; - } - - if (de_tuning_cfg_data->params.flags & kDeTuningFlagContentQualLevel) { - switch (de_tuning_cfg_data->params.quality) { - case kDeContentQualLow: - de_data.quality_level = kContentQualityLow; - break; - case kDeContentQualMedium: - de_data.quality_level = kContentQualityMedium; - break; - case kDeContentQualHigh: - de_data.quality_level = kContentQualityHigh; - break; - case kDeContentQualUnknown: - default: - de_data.quality_level = kContentQualityUnknown; - break; - } - } - } - err = hwc_display->SetDetailEnhancerConfig(de_data); - if (err) { - DLOGW("SetDetailEnhancerConfig failed. err = %d", err); - } - de_tuning_cfg_data->cfg_pending = false; - } - return err; -} - -void HWCColorManager::SetColorModeDetailEnhancer(HWCDisplay *hwc_display) { - SCOPE_LOCK(locker_); - int err = -1; - PPPendingParams pending_action; - PPDisplayAPIPayload req_payload; - - pending_action.action = kGetDetailedEnhancerData; - pending_action.params = NULL; - - if (hwc_display) { - err = hwc_display->ColorSVCRequestRoute(req_payload, NULL, &pending_action); - if (!err && pending_action.action == kConfigureDetailedEnhancer) { - err = SetHWDetailedEnhancerConfig(pending_action.params, hwc_display); - } - } - return; -} - -int HWCColorManager::SetDetailedEnhancer(void *params, HWCDisplay *hwc_display) { - SCOPE_LOCK(locker_); - int err = -1; - err = SetHWDetailedEnhancerConfig(params, hwc_display); - return err; -} - -const HWCQDCMModeManager::ActiveFeatureCMD HWCQDCMModeManager::kActiveFeatureCMD[] = { - HWCQDCMModeManager::ActiveFeatureCMD("cabl:on", "cabl:off", "cabl:status", "running"), - HWCQDCMModeManager::ActiveFeatureCMD("ad:on", "ad:off", "ad:query:status", "running"), - HWCQDCMModeManager::ActiveFeatureCMD("svi:on", "svi:off", "svi:status", "running"), -}; - -const char *const HWCQDCMModeManager::kSocketName = "pps"; -const char *const HWCQDCMModeManager::kTagName = "surfaceflinger"; -const char *const HWCQDCMModeManager::kPackageName = "colormanager"; - -HWCQDCMModeManager *HWCQDCMModeManager::CreateQDCMModeMgr() { - HWCQDCMModeManager *mode_mgr = new HWCQDCMModeManager(); - - if (!mode_mgr) { - DLOGW("No memory to create HWCQDCMModeManager."); - return NULL; - } else { - mode_mgr->socket_fd_ = - ::socket_local_client(kSocketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); - if (mode_mgr->socket_fd_ < 0) { - // it should not be disastrous and we still can grab wakelock in QDCM mode. - DLOGW("Unable to connect to dpps socket!"); - } - - // retrieve system GPU idle timeout value for later to recover. - mode_mgr->entry_timeout_ = UINT32(HWCDebugHandler::GetIdleTimeoutMs()); - - // acquire the binder handle to Android system PowerManager for later use. - android::sp<android::IBinder> binder = - android::defaultServiceManager()->checkService(android::String16("power")); - if (binder == NULL) { - DLOGW("Application can't connect to power manager service"); - delete mode_mgr; - mode_mgr = NULL; - } else { - mode_mgr->power_mgr_ = android::interface_cast<android::IPowerManager>(binder); - } - } - - return mode_mgr; -} - -HWCQDCMModeManager::~HWCQDCMModeManager() { - if (socket_fd_ >= 0) - ::close(socket_fd_); -} - -int HWCQDCMModeManager::AcquireAndroidWakeLock(bool enable) { - int ret = 0; - - if (enable) { - if (wakelock_token_ == NULL) { - android::sp<android::IBinder> binder = new android::BBinder(); - android::status_t status = power_mgr_->acquireWakeLock( - (kFullWakeLock | kAcquireCauseWakeup | kONAfterRelease), binder, - android::String16(kTagName), android::String16(kPackageName)); - if (status == android::NO_ERROR) { - wakelock_token_ = binder; - } - } - } else { - if (wakelock_token_ != NULL && power_mgr_ != NULL) { - power_mgr_->releaseWakeLock(wakelock_token_, 0); - wakelock_token_.clear(); - wakelock_token_ = NULL; - } - } - - return ret; -} - -int HWCQDCMModeManager::EnableActiveFeatures(bool enable, - const HWCQDCMModeManager::ActiveFeatureCMD &cmds, - bool *was_running) { - int ret = 0; - ssize_t size = 0; - char response[kSocketCMDMaxLength] = { - 0, - }; - - if (socket_fd_ < 0) { - DLOGW("No socket connection available!"); - return -EFAULT; - } - - if (!enable) { // if client requesting to disable it. - // query CABL status, if off, no action. keep the status. - size = ::write(socket_fd_, cmds.cmd_query_status, strlen(cmds.cmd_query_status)); - if (size < 0) { - DLOGW("Unable to send data over socket %s", ::strerror(errno)); - ret = -EFAULT; - } else { - size = ::read(socket_fd_, response, kSocketCMDMaxLength); - if (size < 0) { - DLOGW("Unable to read data over socket %s", ::strerror(errno)); - ret = -EFAULT; - } else if (!strncmp(response, cmds.running, strlen(cmds.running))) { - *was_running = true; - } - } - - if (*was_running) { // if was running, it's requested to disable it. - size = ::write(socket_fd_, cmds.cmd_off, strlen(cmds.cmd_off)); - if (size < 0) { - DLOGW("Unable to send data over socket %s", ::strerror(errno)); - ret = -EFAULT; - } - } - } else { // if was running, need enable it back. - if (*was_running) { - size = ::write(socket_fd_, cmds.cmd_on, strlen(cmds.cmd_on)); - if (size < 0) { - DLOGW("Unable to send data over socket %s", ::strerror(errno)); - ret = -EFAULT; - } - } - } - - return ret; -} - -int HWCQDCMModeManager::EnableQDCMMode(bool enable, HWCDisplay *hwc_display) { - int ret = 0; - - ret = EnableActiveFeatures((enable ? false : true), kActiveFeatureCMD[kCABLFeature], - &cabl_was_running_); - ret = AcquireAndroidWakeLock(enable); - - // if enter QDCM mode, disable GPU fallback idle timeout. - if (hwc_display) { - uint32_t timeout = enable ? 0 : entry_timeout_; - hwc_display->SetIdleTimeoutMs(timeout); - } - - return ret; -} - -} // namespace sdm diff --git a/sdm/libs/hwc/hwc_color_manager.h b/sdm/libs/hwc/hwc_color_manager.h deleted file mode 100644 index 20d2b391..00000000 --- a/sdm/libs/hwc/hwc_color_manager.h +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (c) 2015-2017, The Linux Foundataion. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -#ifndef __HWC_COLOR_MANAGER_H__ -#define __HWC_COLOR_MANAGER_H__ - -#include <stdlib.h> -#include <binder/Parcel.h> -#include <powermanager/IPowerManager.h> -#include <binder/BinderService.h> -#include <core/sdm_types.h> -#include <utils/locker.h> -#include <utils/sys.h> - -namespace sdm { - -// This macro defines name for display APIs interface wrapper library. -// This macro shall be used to load library using dlopen(). -#define DISPLAY_API_INTERFACE_LIBRARY_NAME "libsdm-disp-vndapis.so" - -// This macro defines variable name of display color APIs function tables -// This macro shall be used to specify name of the variable in dlsym(). -#define DISPLAY_API_FUNC_TABLES "display_color_apis_ftables" -#define QDCM_DIAG_CLIENT_LIBRARY_NAME "libsdm-diag.so" -#define INIT_QDCM_DIAG_CLIENT_NAME "QDCMDiagInit" -#define DEINIT_QDCM_DIAG_CLIENT_NAME "QDCMDiagDeInit" - -typedef int (*QDCMDiagInit)(void *ftables); - -typedef int (*QDCMDiagDeInit)(void); - -// Class to encapsulte all details of managing QDCM operating mode. -class HWCQDCMModeManager { - public: - static const uint32_t kSocketCMDMaxLength = 4096; - static const uint32_t kFullWakeLock = 0x0000001a; - static const uint32_t kAcquireCauseWakeup = 0x10000000; - static const uint32_t kONAfterRelease = 0x20000000; - enum ActiveFeatureID { - kCABLFeature, - kADFeature, - kSVIFeature, - kMaxNumActiveFeature, - }; - - struct ActiveFeatureCMD { - const char *cmd_on = NULL; - const char *cmd_off = NULL; - const char *cmd_query_status = NULL; - const char *running = NULL; - ActiveFeatureCMD(const char *arg1, const char *arg2, const char *arg3, const char *arg4) - : cmd_on(arg1), cmd_off(arg2), cmd_query_status(arg3), running(arg4) {} - }; - - static const ActiveFeatureCMD kActiveFeatureCMD[kMaxNumActiveFeature]; - - public: - static HWCQDCMModeManager *CreateQDCMModeMgr(); - ~HWCQDCMModeManager(); - int EnableQDCMMode(bool enable, HWCDisplay *hwc_display); - - protected: - bool SendSocketCmd(); - int AcquireAndroidWakeLock(bool enable); - int EnableActiveFeatures(bool enable); - int EnableActiveFeatures(bool enable, const ActiveFeatureCMD &cmds, bool *was_running); - - private: - bool cabl_was_running_ = false; - int socket_fd_ = -1; - android::sp<android::IBinder> wakelock_token_ = NULL; - android::sp<android::IPowerManager> power_mgr_ = NULL; - uint32_t entry_timeout_ = 0; - static const char *const kSocketName; - static const char *const kTagName; - static const char *const kPackageName; -}; - -// Class to encapsulte all HWC/OS specific behaviours for ColorManager. -class HWCColorManager { - public: - static const int kNumSolidFillLayers = 2; - static HWCColorManager *CreateColorManager(); - static int CreatePayloadFromParcel(const android::Parcel &in, uint32_t *disp_id, - PPDisplayAPIPayload *sink); - static void MarshallStructIntoParcel(const PPDisplayAPIPayload &data, - android::Parcel *out_parcel); - - ~HWCColorManager(); - void DestroyColorManager(); - int EnableQDCMMode(bool enable, HWCDisplay *hwc_display); - int SetSolidFill(const void *params, bool enable, HWCDisplay *hwc_display); - bool SolidFillLayersPrepare(hwc_display_contents_1_t **displays, HWCDisplay *hwc_display); - bool SolidFillLayersSet(hwc_display_contents_1_t **displays, HWCDisplay *hwc_display); - int SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_display); - int SetDetailedEnhancer(void *params, HWCDisplay *hwc_display); - void SetColorModeDetailEnhancer(HWCDisplay *hwc_display); - int SetHWDetailedEnhancerConfig(void *params, HWCDisplay *hwc_display); - - protected: - int CreateSolidFillLayers(HWCDisplay *hwc_display); - void DestroySolidFillLayers(); - static uint32_t Get8BitsARGBColorValue(const PPColorFillParams ¶ms); - - private: - DynLib color_apis_lib_; - DynLib diag_client_lib_; - void *color_apis_ = NULL; - QDCMDiagInit qdcm_diag_init_ = NULL; - QDCMDiagDeInit qdcm_diag_deinit_ = NULL; - HWCQDCMModeManager *qdcm_mode_mgr_ = NULL; - - bool solid_fill_enable_ = false; - PPColorFillParams solid_fill_params_; - hwc_display_contents_1_t *solid_fill_layers_ = NULL; - HWCBufferAllocator *buffer_allocator_ = NULL; - BufferInfo buffer_info; - Locker locker_; -}; - -} // namespace sdm - -#endif // __HWC_COLOR_MANAGER_H__ diff --git a/sdm/libs/hwc/hwc_display.h b/sdm/libs/hwc/hwc_display.h deleted file mode 100644 index b0a40d5b..00000000 --- a/sdm/libs/hwc/hwc_display.h +++ /dev/null @@ -1,266 +0,0 @@ -/* -* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright notice, this list of -* conditions and the following disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its contributors may be used to -* endorse or promote products derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __HWC_DISPLAY_H__ -#define __HWC_DISPLAY_H__ - -#include <hardware/hwcomposer.h> -#include <core/core_interface.h> -#include <qdMetaData.h> -#include <QService.h> -#include <private/color_params.h> -#include <map> -#include <vector> -#include <string> - -namespace sdm { - -class BlitEngine; -class HWCToneMapper; - -// Subclasses set this to their type. This has to be different from DisplayType. -// This is to avoid RTTI and dynamic_cast -enum DisplayClass { - DISPLAY_CLASS_PRIMARY, - DISPLAY_CLASS_EXTERNAL, - DISPLAY_CLASS_VIRTUAL, - DISPLAY_CLASS_NULL -}; - -class HWCColorMode { - public: - explicit HWCColorMode(DisplayInterface *display_intf) : display_intf_(display_intf) {} - ~HWCColorMode() {} - void Init(); - void DeInit() {} - int SetColorMode(const std::string &color_mode); - const std::vector<std::string> &GetColorModes(); - int SetColorTransform(uint32_t matrix_count, const float *matrix); - - private: - static const uint32_t kColorTransformMatrixCount = 16; - template <class T> - void CopyColorTransformMatrix(const T *input_matrix, double *output_matrix) { - for (uint32_t i = 0; i < kColorTransformMatrixCount; i++) { - output_matrix[i] = static_cast<double>(input_matrix[i]); - } - } - int PopulateColorModes(); - DisplayInterface *display_intf_ = NULL; - std::vector<std::string> color_modes_ = {}; - std::string current_color_mode_ = {}; -}; - -class HWCDisplay : public DisplayEventHandler { - public: - enum { - SET_METADATA_DYN_REFRESH_RATE, - SET_BINDER_DYN_REFRESH_RATE, - SET_DISPLAY_MODE, - SET_QDCM_SOLID_FILL_INFO, - UNSET_QDCM_SOLID_FILL_INFO, - }; - - virtual ~HWCDisplay() { } - virtual int Init(); - virtual int Deinit(); - virtual int Prepare(hwc_display_contents_1_t *content_list) = 0; - virtual int Commit(hwc_display_contents_1_t *content_list) = 0; - virtual int EventControl(int event, int enable); - virtual int SetPowerMode(int mode); - - // Framebuffer configurations - virtual int GetDisplayConfigs(uint32_t *configs, size_t *num_configs); - virtual int GetDisplayAttributes(uint32_t config, const uint32_t *display_attributes, - int32_t *values); - virtual int GetActiveConfig(); - virtual int SetActiveConfig(int index); - - virtual void SetIdleTimeoutMs(uint32_t timeout_ms); - virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type); - virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages); - virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending) { - return kErrorNotSupported; - } - virtual uint32_t GetLastPowerMode(); - virtual int SetFrameBufferResolution(uint32_t x_pixels, uint32_t y_pixels); - virtual void GetFrameBufferResolution(uint32_t *x_pixels, uint32_t *y_pixels); - virtual int SetDisplayStatus(uint32_t display_status); - virtual int OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level); - virtual int Perform(uint32_t operation, ...); - virtual int SetCursorPosition(int x, int y); - virtual void SetSecureDisplay(bool secure_display_active, bool force_flush); - virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height); - virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height); - virtual void GetPanelResolution(uint32_t *width, uint32_t *height); - - // Captures frame output in the buffer specified by output_buffer_info. The API is - // non-blocking and the client is expected to check operation status later on. - // Returns -1 if the input is invalid. - virtual int FrameCaptureAsync(const BufferInfo& output_buffer_info, bool post_processed) { - return -1; - } - // Returns the status of frame capture operation requested with FrameCaptureAsync(). - // -EAGAIN : No status obtain yet, call API again after another frame. - // < 0 : Operation happened but failed. - // 0 : Success. - virtual int GetFrameCaptureStatus() { return -EAGAIN; } - - virtual DisplayError SetDetailEnhancerConfig(const DisplayDetailEnhancerData &de_data) { - return kErrorNotSupported; - } - - // Display Configurations - virtual int SetActiveDisplayConfig(int config); - virtual int GetActiveDisplayConfig(uint32_t *config); - virtual int GetDisplayConfigCount(uint32_t *count); - virtual int GetDisplayAttributesForConfig(int config, - DisplayConfigVariableInfo *display_attributes); - virtual int GetDisplayFixedConfig(DisplayConfigFixedInfo *fixed_info); - - int SetPanelBrightness(int level); - int GetPanelBrightness(int *level); - int CachePanelBrightness(int level); - int ToggleScreenUpdates(bool enable); - int ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload, - PPDisplayAPIPayload *out_payload, - PPPendingParams *pending_action); - int GetVisibleDisplayRect(hwc_rect_t* rect); - DisplayClass GetDisplayClass(); - int GetDisplayPort(DisplayPort *port); - - protected: - enum DisplayStatus { - kDisplayStatusOffline = 0, - kDisplayStatusOnline, - kDisplayStatusPause, - kDisplayStatusResume, - }; - - // Dim layer flag set by SurfaceFlinger service. - static const uint32_t kDimLayer = 0x80000000; - - // Maximum number of layers supported by display manager. - static const uint32_t kMaxLayerCount = 32; - - HWCDisplay(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, DisplayType type, int id, - bool needs_blit, qService::QService *qservice, DisplayClass display_class); - - // DisplayEventHandler methods - virtual DisplayError VSync(const DisplayEventVSync &vsync); - virtual DisplayError Refresh(); - virtual DisplayError CECMessage(char *message); - - int AllocateLayerStack(hwc_display_contents_1_t *content_list); - void FreeLayerStack(); - virtual int PrePrepareLayerStack(hwc_display_contents_1_t *content_list); - virtual int PrepareLayerStack(hwc_display_contents_1_t *content_list); - virtual int CommitLayerStack(hwc_display_contents_1_t *content_list); - virtual int PostCommitLayerStack(hwc_display_contents_1_t *content_list); - virtual void DumpOutputBuffer(const BufferInfo& buffer_info, void *base, int fence); - virtual uint32_t RoundToStandardFPS(float fps); - virtual uint32_t SanitizeRefreshRate(uint32_t req_refresh_rate); - virtual void PrepareDynamicRefreshRate(Layer *layer); - virtual DisplayError DisablePartialUpdateOneFrame() { - return kErrorNotSupported; - } - inline void SetRect(const hwc_rect_t &source, LayerRect *target); - inline void SetRect(const hwc_frect_t &source, LayerRect *target); - inline void SetComposition(const int32_t &source, LayerComposition *target); - inline void SetComposition(const LayerComposition &source, int32_t *target); - inline void SetBlending(const int32_t &source, LayerBlending *target); - int SetFormat(const int32_t &source, const int flags, LayerBufferFormat *target); - void SetLayerS3DMode(const LayerBufferS3DFormat &source, uint32_t *target); - LayerBufferFormat GetSDMFormat(const int32_t &source, const int flags); - const char *GetDisplayString(); - void MarkLayersForGPUBypass(hwc_display_contents_1_t *content_list); - virtual void ApplyScanAdjustment(hwc_rect_t *display_frame); - DisplayError SetCSC(const MetaData_t *meta_data, ColorMetaData *color_metadata); - DisplayError SetIGC(IGC_t source, LayerIGC *target); - DisplayError SetMetaData(const private_handle_t *pvt_handle, Layer *layer); - bool NeedsFrameBufferRefresh(hwc_display_contents_1_t *content_list); - bool IsLayerUpdating(hwc_display_contents_1_t *content_list, const Layer *layer); - bool IsNonIntegralSourceCrop(const hwc_frect_t &source); - uint32_t GetUpdatingLayersCount(uint32_t app_layer_count); - bool SingleVideoLayerUpdating(uint32_t app_layer_count); - bool IsSurfaceUpdated(const std::vector<LayerRect> &dirty_regions); - - enum { - INPUT_LAYER_DUMP, - OUTPUT_LAYER_DUMP, - }; - - CoreInterface *core_intf_; - hwc_procs_t const **hwc_procs_; - DisplayType type_; - int id_; - bool needs_blit_ = false; - DisplayInterface *display_intf_ = NULL; - LayerStack layer_stack_; - bool flush_on_error_ = false; - bool flush_ = false; - uint32_t dump_frame_count_ = 0; - uint32_t dump_frame_index_ = 0; - bool dump_input_layers_ = false; - uint32_t last_power_mode_; - bool swap_interval_zero_ = false; - bool display_paused_ = false; - uint32_t min_refresh_rate_ = 0; - uint32_t max_refresh_rate_ = 0; - uint32_t current_refresh_rate_ = 0; - bool use_metadata_refresh_rate_ = false; - uint32_t metadata_refresh_rate_ = 0; - uint32_t force_refresh_rate_ = 0; - bool boot_animation_completed_ = false; - bool shutdown_pending_ = false; - bool use_blit_comp_ = false; - bool secure_display_active_ = false; - uint32_t skip_prepare_cnt = 0; - bool solid_fill_enable_ = false; - bool disable_animation_ = false; - uint32_t solid_fill_color_ = 0; - LayerRect display_rect_; - std::map<int, LayerBufferS3DFormat> s3d_format_hwc_to_sdm_; - bool animating_ = false; - HWCToneMapper *tone_mapper_ = NULL; - HWCColorMode *color_mode_ = NULL; - int disable_hdr_handling_ = 0; // disables HDR handling. - - private: - void DumpInputBuffers(hwc_display_contents_1_t *content_list); - int PrepareLayerParams(hwc_layer_1_t *hwc_layer, Layer *layer); - void CommitLayerParams(hwc_layer_1_t *hwc_layer, Layer *layer); - BlitEngine *blit_engine_ = NULL; - qService::QService *qservice_ = NULL; - DisplayClass display_class_; -}; - -inline int HWCDisplay::Perform(uint32_t operation, ...) { - return 0; -} - -} // namespace sdm - -#endif // __HWC_DISPLAY_H__ - diff --git a/sdm/libs/hwc/hwc_display_external.h b/sdm/libs/hwc/hwc_display_external.h deleted file mode 100644 index c5ac3d75..00000000 --- a/sdm/libs/hwc/hwc_display_external.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2014, 2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright notice, this list of -* conditions and the following disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its contributors may be used to -* endorse or promote products derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __HWC_DISPLAY_EXTERNAL_H__ -#define __HWC_DISPLAY_EXTERNAL_H__ - -#include "hwc_display.h" - -namespace sdm { - -class HWCDisplayExternal : public HWCDisplay { - public: - static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, uint32_t primary_width, - uint32_t primary_height, qService::QService *qservice, bool use_primary_res, - HWCDisplay **hwc_display); - static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - qService::QService *qservice, HWCDisplay **hwc_display); - static void Destroy(HWCDisplay *hwc_display); - virtual int Prepare(hwc_display_contents_1_t *content_list); - virtual int Commit(hwc_display_contents_1_t *content_list); - virtual void SetSecureDisplay(bool secure_display_active, bool force_flush); - virtual int Perform(uint32_t operation, ...); - - protected: - virtual uint32_t RoundToStandardFPS(float fps); - virtual void PrepareDynamicRefreshRate(Layer *layer); - int drc_enabled_ = 0; - int drc_reset_fps_enabled_ = 0; - - private: - HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - qService::QService *qservice); - void ApplyScanAdjustment(hwc_rect_t *display_frame); - static void GetDownscaleResolution(uint32_t primary_width, uint32_t primary_height, - uint32_t *virtual_width, uint32_t *virtual_height); - void ForceRefreshRate(uint32_t refresh_rate); - uint32_t GetOptimalRefreshRate(bool one_updating_layer); -}; - -} // namespace sdm - -#endif // __HWC_DISPLAY_EXTERNAL_H__ - diff --git a/sdm/libs/hwc/hwc_display_external_test.h b/sdm/libs/hwc/hwc_display_external_test.h deleted file mode 100644 index 050823e2..00000000 --- a/sdm/libs/hwc/hwc_display_external_test.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -* Copyright (c) 2017, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright notice, this list of -* conditions and the following disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its contributors may be used to -* endorse or promote products derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __HWC_DISPLAY_EXTERNAL_TEST_H__ -#define __HWC_DISPLAY_EXTERNAL_TEST_H__ - -#include<bitset> - -#include "hwc_display.h" -#include "hwc_buffer_allocator.h" - -namespace sdm { - -class HWCDisplayExternalTest : public HWCDisplay { - public: - static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - qService::QService *qservice, uint32_t panel_bpp, uint32_t pattern_type, - HWCDisplay **hwc_display); - static void Destroy(HWCDisplay *hwc_display); - virtual int Prepare(hwc_display_contents_1_t *content_list); - virtual int Commit(hwc_display_contents_1_t *content_list); - virtual void SetSecureDisplay(bool secure_display_active, bool force_flush); - virtual int Perform(uint32_t operation, ...); - - protected: - HWCBufferAllocator *buffer_allocator_ = NULL; - BufferInfo buffer_info_ = {}; - uint32_t panel_bpp_ = 0; - uint32_t pattern_type_ = 0; - - enum ColorPatternType { - kPatternNone = 0, - kPatternColorRamp, - kPatternBWVertical, - kPatternColorSquare, - }; - - enum DisplayBpp { - kDisplayBpp18 = 18, - kDisplayBpp24 = 24, - kDisplayBpp30 = 30, - }; - - enum ColorRamp { - kColorRedRamp = 0, - kColorGreenRamp = 1, - kColorBlueRamp = 2, - kColorWhiteRamp = 3, - }; - - enum Colors { - kColorBlack = 0, - kColorWhite = 1, - }; - - private: - HWCDisplayExternalTest(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - qService::QService *qservice, uint32_t panel_bpp, uint32_t pattern_type); - int Init(); - int Deinit(); - void DumpInputBuffer(); - void CalcCRC(uint32_t color_value, std::bitset<16> *crc_data); - int FillBuffer(); - int GetStride(LayerBufferFormat format, uint32_t width, uint32_t *stride); - void PixelCopy(uint32_t red, uint32_t green, uint32_t blue, uint32_t alpha, uint8_t **buffer); - void GenerateColorRamp(uint8_t *buffer); - void GenerateBWVertical(uint8_t *buffer); - void GenerateColorSquare(uint8_t *buffer); - int InitLayer(Layer *layer); - int DeinitLayer(Layer *layer); - int CreateLayerStack(); - int DestroyLayerStack(); - int PostCommit(hwc_display_contents_1_t *content_list); - - static const uint32_t kTestLayerCnt = 1; -}; - -} // namespace sdm - -#endif // __HWC_DISPLAY_EXTERNAL_TEST_H__ - diff --git a/sdm/libs/hwc/hwc_display_null.cpp b/sdm/libs/hwc/hwc_display_null.cpp deleted file mode 100644 index 649f40c3..00000000 --- a/sdm/libs/hwc/hwc_display_null.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -* Copyright (c) 2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright notice, this list of -* conditions and the following disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its contributors may be used to -* endorse or promote products derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include <hardware/hwcomposer_defs.h> -#include <utils/constants.h> -#include <utils/debug.h> -#include "hwc_display_null.h" - -#define __CLASS__ "HWCDisplayNull" - -namespace sdm { - -int HWCDisplayNull::Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - HWCDisplay **hwc_display) { - int status; - - DLOGI("Null display is being created"); - HWCDisplayNull *hwc_display_null = new HWCDisplayNull(core_intf, hwc_procs); - - status = hwc_display_null->Init(); - if (status) { - delete hwc_display_null; - return status; - } - - *hwc_display = hwc_display_null; - - return 0; -} - -void HWCDisplayNull::Destroy(HWCDisplay *hwc_display) { - DLOGI("Null display is being destroyed"); - hwc_display->Deinit(); - delete hwc_display; -} - -// We pass the display type as HWC_DISPLAY_PRIMARY to HWCDisplay, but since we override -// and don't chain to HWCDisplay::Init(), that type does not actually get used. -HWCDisplayNull::HWCDisplayNull(CoreInterface *core_intf, hwc_procs_t const **hwc_procs) - : HWCDisplay(core_intf, hwc_procs, kPrimary, HWC_DISPLAY_PRIMARY, false, NULL, - DISPLAY_CLASS_NULL) { -} - -int HWCDisplayNull::Init() { - // Don't call HWCDisplay::Init() for null display, we don't want the chain of - // DisplayPrimary / HWPrimary etc objects to be created. - return 0; -} - -int HWCDisplayNull::Deinit() { - return 0; -} - -int HWCDisplayNull::Prepare(hwc_display_contents_1_t *content_list) { - for (size_t i = 0; i < content_list->numHwLayers; i++) { - if (content_list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET || - content_list->hwLayers[i].compositionType == HWC_BACKGROUND) { - continue; - } - - content_list->hwLayers[i].compositionType = HWC_OVERLAY; - } - - return 0; -} - -int HWCDisplayNull::Commit(hwc_display_contents_1_t *content_list) { - // HWCSession::Commit (from where this is called) already closes all the acquire - // fences once we return from here. So no need to close acquire fences here. - for (size_t i = 0; i < content_list->numHwLayers; i++) { - content_list->hwLayers[i].releaseFenceFd = -1; - } - - return 0; -} - -#define NULL_DISPLAY_FPS 60 - -int HWCDisplayNull::GetDisplayAttributes(uint32_t config, const uint32_t *display_attributes, - int32_t *values) { - for (int i = 0; display_attributes[i] != HWC_DISPLAY_NO_ATTRIBUTE; i++) { - // We fake display resolution as 1080P by default, though it can be overriden through a call to - // SetResolution(), and DPI as 160, though what the DPI value does is not clear - switch (display_attributes[i]) { - case HWC_DISPLAY_VSYNC_PERIOD: - values[i] = INT32(1000000000L / NULL_DISPLAY_FPS); - break; - case HWC_DISPLAY_WIDTH: - values[i] = static_cast<int32_t>(x_res_); - break; - case HWC_DISPLAY_HEIGHT: - values[i] = static_cast<int32_t>(y_res_); - break; - } - } - return 0; -} - -} // namespace sdm diff --git a/sdm/libs/hwc/hwc_display_null.h b/sdm/libs/hwc/hwc_display_null.h deleted file mode 100644 index f1e0e5e8..00000000 --- a/sdm/libs/hwc/hwc_display_null.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright notice, this list of -* conditions and the following disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its contributors may be used to -* endorse or promote products derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __HWC_DISPLAY_NULL_H__ -#define __HWC_DISPLAY_NULL_H__ - -#include <qdMetaData.h> -#include <gralloc_priv.h> -#include "hwc_display.h" - -namespace sdm { - -class HWCDisplayNull : public HWCDisplay { - public: - static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - HWCDisplay **hwc_display); - static void Destroy(HWCDisplay *hwc_display); - virtual int Init(); - virtual int Deinit(); - virtual int Prepare(hwc_display_contents_1_t *content_list); - virtual int Commit(hwc_display_contents_1_t *content_list); - virtual int EventControl(int event, int enable) { return 0; } - virtual int SetPowerMode(int mode) { return 0; } - - // Framebuffer configurations - virtual int GetDisplayConfigs(uint32_t *configs, size_t *num_configs) { - return HWCDisplay::GetDisplayConfigs(configs, num_configs); - } - - virtual int GetDisplayAttributes(uint32_t config, const uint32_t *display_attributes, - int32_t *values); - virtual int GetActiveConfig() { return 0; } - virtual int SetActiveConfig(int index) { return -1; } - - virtual void SetIdleTimeoutMs(uint32_t timeout_ms) { return; } - virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type) { return; } - virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages) { return kErrorNone; } - virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending) { return kErrorNone; } - virtual uint32_t GetLastPowerMode() { return 0; } - virtual int SetFrameBufferResolution(uint32_t x_pixels, uint32_t y_pixels) { return 0; } - - virtual void GetFrameBufferResolution(uint32_t *x_pixels, uint32_t *y_pixels) { - *x_pixels = x_res_; - *y_pixels = y_res_; - } - - virtual void GetPanelResolution(uint32_t *x_pixels, uint32_t *y_pixels) { - *x_pixels = x_res_; - *y_pixels = y_res_; - } - - virtual int SetDisplayStatus(uint32_t display_status) { return 0; } - virtual int OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) { return 0; } - virtual int Perform(uint32_t operation, ...) { return 0; } - virtual int SetCursorPosition(int x, int y) { return 0; } - virtual void SetSecureDisplay(bool secure_display_active, bool force_flush) { return; } - - // Display Configurations - virtual int SetActiveDisplayConfig(int config) { return 0; } - virtual int GetActiveDisplayConfig(uint32_t *config) { return -1; } - virtual int GetDisplayConfigCount(uint32_t *count) { return -1; } - virtual int GetDisplayAttributesForConfig(int config, - DisplayConfigVariableInfo *display_attributes) { - return -1; - } - virtual bool IsValidContentList(hwc_display_contents_1_t *content_list) { - return true; - } - - void SetResolution(uint32_t x_res, uint32_t y_res) { - x_res_ = x_res; - y_res_ = y_res; - } - - - private: - HWCDisplayNull(CoreInterface *core_intf, hwc_procs_t const **hwc_procs); - uint32_t x_res_ = 1920; - uint32_t y_res_ = 1080; -}; - -} // namespace sdm - -#endif // __HWC_DISPLAY_NULL_H__ - diff --git a/sdm/libs/hwc/hwc_display_virtual.cpp b/sdm/libs/hwc/hwc_display_virtual.cpp deleted file mode 100644 index 0279fc2a..00000000 --- a/sdm/libs/hwc/hwc_display_virtual.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* -* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include <utils/constants.h> -#include <utils/debug.h> -#include <sync/sync.h> -#include <stdarg.h> -#include <gr.h> - -#include "hwc_display_virtual.h" -#include "hwc_debugger.h" - -#define __CLASS__ "HWCDisplayVirtual" - -namespace sdm { - -int HWCDisplayVirtual::Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - uint32_t primary_width, uint32_t primary_height, - hwc_display_contents_1_t *content_list, - HWCDisplay **hwc_display) { - int status = 0; - HWCDisplayVirtual *hwc_display_virtual = new HWCDisplayVirtual(core_intf, hwc_procs); - uint32_t virtual_width = 0, virtual_height = 0; - - status = hwc_display_virtual->Init(); - if (status) { - delete hwc_display_virtual; - return status; - } - - status = hwc_display_virtual->SetPowerMode(HWC_POWER_MODE_NORMAL); - if (status) { - Destroy(hwc_display_virtual); - return status; - } - - // TODO(user): Need to update resolution(and not aligned resolution) on writeback. - status = hwc_display_virtual->SetOutputSliceFromMetadata(content_list); - if (status) { - Destroy(hwc_display_virtual); - return status; - } - - hwc_display_virtual->GetMixerResolution(&virtual_width, &virtual_height); - - if (content_list->numHwLayers < 1) { - Destroy(hwc_display_virtual); - return -1; - } - - hwc_layer_1_t &fb_layer = content_list->hwLayers[content_list->numHwLayers-1]; - int fb_width = fb_layer.displayFrame.right - fb_layer.displayFrame.left; - int fb_height = fb_layer.displayFrame.bottom - fb_layer.displayFrame.top; - - status = hwc_display_virtual->SetFrameBufferResolution(UINT32(fb_width), UINT32(fb_height)); - - if (status) { - Destroy(hwc_display_virtual); - return status; - } - - *hwc_display = static_cast<HWCDisplay *>(hwc_display_virtual); - - return 0; -} - -void HWCDisplayVirtual::Destroy(HWCDisplay *hwc_display) { - hwc_display->Deinit(); - delete hwc_display; -} - -HWCDisplayVirtual::HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs) - : HWCDisplay(core_intf, hwc_procs, kVirtual, HWC_DISPLAY_VIRTUAL, false, NULL, - DISPLAY_CLASS_VIRTUAL) { -} - -int HWCDisplayVirtual::Init() { - output_buffer_ = new LayerBuffer(); - if (!output_buffer_) { - return -ENOMEM; - } - - return HWCDisplay::Init(); -} - -int HWCDisplayVirtual::Deinit() { - int status = 0; - - status = HWCDisplay::Deinit(); - if (status) { - return status; - } - - if (output_buffer_) { - delete output_buffer_; - output_buffer_ = NULL; - } - - return status; -} - -int HWCDisplayVirtual::Prepare(hwc_display_contents_1_t *content_list) { - int status = 0; - - status = SetOutputSliceFromMetadata(content_list); - if (status) { - return status; - } - - if (display_paused_) { - MarkLayersForGPUBypass(content_list); - return status; - } - - status = AllocateLayerStack(content_list); - if (status) { - return status; - } - - status = SetOutputBuffer(content_list); - if (status) { - return status; - } - - status = PrePrepareLayerStack(content_list); - if (status) { - return status; - } - - status = PrepareLayerStack(content_list); - if (status) { - return status; - } - - return 0; -} - -int HWCDisplayVirtual::Commit(hwc_display_contents_1_t *content_list) { - int status = 0; - if (display_paused_) { - DisplayError error = display_intf_->Flush(); - if (error != kErrorNone) { - DLOGE("Flush failed. Error = %d", error); - } - return status; - } - - CommitOutputBufferParams(content_list); - - status = HWCDisplay::CommitLayerStack(content_list); - if (status) { - return status; - } - - if (dump_frame_count_ && !flush_ && dump_output_layer_) { - const private_handle_t *output_handle = (const private_handle_t *)(content_list->outbuf); - if (output_handle && output_handle->base) { - BufferInfo buffer_info; - buffer_info.buffer_config.width = static_cast<uint32_t>(output_handle->width); - buffer_info.buffer_config.height = static_cast<uint32_t>(output_handle->height); - buffer_info.buffer_config.format = GetSDMFormat(output_handle->format, output_handle->flags); - buffer_info.alloc_buffer_info.size = static_cast<uint32_t>(output_handle->size); - DumpOutputBuffer(buffer_info, reinterpret_cast<void *>(output_handle->base), - layer_stack_.retire_fence_fd); - } - } - - status = HWCDisplay::PostCommitLayerStack(content_list); - if (status) { - return status; - } - - return 0; -} - -int HWCDisplayVirtual::SetOutputSliceFromMetadata(hwc_display_contents_1_t *content_list) { - const private_handle_t *output_handle = - static_cast<const private_handle_t *>(content_list->outbuf); - DisplayError error = kErrorNone; - int status = 0; - - if (output_handle) { - int output_handle_format = output_handle->format; - if (output_handle_format == HAL_PIXEL_FORMAT_RGBA_8888) { - output_handle_format = HAL_PIXEL_FORMAT_RGBX_8888; - } - - LayerBufferFormat format = GetSDMFormat(output_handle_format, output_handle->flags); - if (format == kFormatInvalid) { - return -EINVAL; - } - - int active_width; - int active_height; - - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, active_width, - active_height); - - if ((active_width != INT(output_buffer_->width)) || - (active_height!= INT(output_buffer_->height)) || - (format != output_buffer_->format)) { - // Populate virtual display attributes based on displayFrame of FBT. - // For DRC, use width and height populated in metadata (unaligned values) - // for setting attributes of virtual display. This is needed because if - // we use aligned width and height, scaling will be required for FBT layer. - DisplayConfigVariableInfo variable_info; - hwc_layer_1_t &fbt_layer = content_list->hwLayers[content_list->numHwLayers-1]; - hwc_rect_t &frame = fbt_layer.displayFrame; - int fbt_width = frame.right - frame.left; - int fbt_height = frame.bottom - frame.top; - const MetaData_t *meta_data = reinterpret_cast<MetaData_t *>(output_handle->base_metadata); - if (meta_data && meta_data->operation & UPDATE_BUFFER_GEOMETRY) { - variable_info.x_pixels = UINT32(meta_data->bufferDim.sliceWidth); - variable_info.y_pixels = UINT32(meta_data->bufferDim.sliceHeight); - } else { - variable_info.x_pixels = UINT32(fbt_width); - variable_info.y_pixels = UINT32(fbt_height); - } - // TODO(user): Need to get the framerate of primary display and update it. - variable_info.fps = 60; - - error = display_intf_->SetActiveConfig(&variable_info); - if (error != kErrorNone) { - return -EINVAL; - } - - status = SetOutputBuffer(content_list); - if (status) { - return status; - } - } - } - - return 0; -} - -int HWCDisplayVirtual::SetOutputBuffer(hwc_display_contents_1_t *content_list) { - const private_handle_t *output_handle = - static_cast<const private_handle_t *>(content_list->outbuf); - - if (output_handle) { - int output_handle_format = output_handle->format; - - if (output_handle_format == HAL_PIXEL_FORMAT_RGBA_8888) { - output_handle_format = HAL_PIXEL_FORMAT_RGBX_8888; - } - - output_buffer_->format = GetSDMFormat(output_handle_format, output_handle->flags); - - if (output_buffer_->format == kFormatInvalid) { - return -EINVAL; - } - - int aligned_width, aligned_height; - int unaligned_width, unaligned_height; - - AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, aligned_width, - aligned_height); - AdrenoMemInfo::getInstance().getUnalignedWidthAndHeight(output_handle, unaligned_width, - unaligned_height); - - output_buffer_->width = UINT32(aligned_width); - output_buffer_->height = UINT32(aligned_height); - output_buffer_->unaligned_width = UINT32(unaligned_width); - output_buffer_->unaligned_height = UINT32(unaligned_height); - output_buffer_->flags.secure = 0; - output_buffer_->flags.video = 0; - - const MetaData_t *meta_data = reinterpret_cast<MetaData_t *>(output_handle->base_metadata); - if (meta_data && SetCSC(meta_data, &output_buffer_->color_metadata) != kErrorNone) { - return kErrorNotSupported; - } - - // TZ Protected Buffer - L1 - if (output_handle->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER) { - output_buffer_->flags.secure = 1; - } - } - - layer_stack_.output_buffer = output_buffer_; - - return 0; -} - -void HWCDisplayVirtual::CommitOutputBufferParams(hwc_display_contents_1_t *content_list) { - const private_handle_t *output_handle = - static_cast<const private_handle_t *>(content_list->outbuf); - - // Fill output buffer parameters (width, height, format, plane information, fence) - output_buffer_->acquire_fence_fd = content_list->outbufAcquireFenceFd; - - if (output_handle) { - // ToDo: Need to extend for non-RGB formats - output_buffer_->planes[0].fd = output_handle->fd; - output_buffer_->planes[0].offset = output_handle->offset; - output_buffer_->planes[0].stride = UINT32(output_handle->width); - } -} - -void HWCDisplayVirtual::SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type) { - HWCDisplay::SetFrameDumpConfig(count, bit_mask_layer_type); - dump_output_layer_ = ((bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP)) != 0); - - DLOGI("output_layer_dump_enable %d", dump_output_layer_); -} - -} // namespace sdm - diff --git a/sdm/libs/hwc/hwc_display_virtual.h b/sdm/libs/hwc/hwc_display_virtual.h deleted file mode 100644 index 77e16d53..00000000 --- a/sdm/libs/hwc/hwc_display_virtual.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2014,2016 The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright notice, this list of -* conditions and the following disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its contributors may be used to -* endorse or promote products derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __HWC_DISPLAY_VIRTUAL_H__ -#define __HWC_DISPLAY_VIRTUAL_H__ - -#include <qdMetaData.h> -#include <gralloc_priv.h> -#include "hwc_display.h" - -namespace sdm { - -class HWCDisplayVirtual : public HWCDisplay { - public: - static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, - uint32_t primary_width, uint32_t primary_height, - hwc_display_contents_1_t *content_list, HWCDisplay **hwc_display); - static void Destroy(HWCDisplay *hwc_display); - static bool IsValidContentList(hwc_display_contents_1_t *content_list); - virtual int Init(); - virtual int Deinit(); - virtual int Prepare(hwc_display_contents_1_t *content_list); - virtual int Commit(hwc_display_contents_1_t *content_list); - virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type); - - private: - HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs); - int SetOutputBuffer(hwc_display_contents_1_t *content_list); - int SetOutputSliceFromMetadata(hwc_display_contents_1_t *content_list); - void CommitOutputBufferParams(hwc_display_contents_1_t *content_list); - - bool dump_output_layer_ = false; - LayerBuffer *output_buffer_ = NULL; -}; - -inline bool HWCDisplayVirtual::IsValidContentList(hwc_display_contents_1_t *content_list) { - return (content_list && content_list->numHwLayers > 0 && content_list->outbuf); -} - -} // namespace sdm - -#endif // __HWC_DISPLAY_VIRTUAL_H__ - diff --git a/sdm/libs/hwc/hwc_tonemapper.cpp b/sdm/libs/hwc/hwc_tonemapper.cpp deleted file mode 100644 index c09ff9e2..00000000 --- a/sdm/libs/hwc/hwc_tonemapper.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* -* Copyright (c) 2016 - 2017, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include <alloc_controller.h> -#include <gr.h> -#include <gralloc_priv.h> -#include <memalloc.h> -#include <sync/sync.h> - -#include <TonemapFactory.h> - -#include <core/buffer_allocator.h> - -#include <utils/constants.h> -#include <utils/debug.h> -#include <utils/formats.h> -#include <utils/rect.h> -#include <utils/utils.h> - -#include <vector> - -#include "hwc_debugger.h" -#include "hwc_tonemapper.h" - -#define __CLASS__ "HWCToneMapper" - -namespace sdm { - -ToneMapSession::~ToneMapSession() { - delete gpu_tone_mapper_; - gpu_tone_mapper_ = NULL; - FreeIntermediateBuffers(); -} - -DisplayError ToneMapSession::AllocateIntermediateBuffers(int w, int h, int format, int usage) { - for (uint8_t i = 0; i < kNumIntermediateBuffers; i++) { - int status = alloc_buffer(&intermediate_buffer_[i], w, h, format, usage); - if (status < 0) { - FreeIntermediateBuffers(); - return kErrorMemory; - } - } - - return kErrorNone; -} - -void ToneMapSession::FreeIntermediateBuffers() { - for (uint8_t i = 0; i < kNumIntermediateBuffers; i++) { - private_handle_t *buffer = intermediate_buffer_[i]; - if (buffer) { - // Free the valid fence - if (release_fence_fd_[i] >= 0) { - CloseFd(&release_fence_fd_[i]); - } - free_buffer(buffer); - intermediate_buffer_[i] = NULL; - } - } -} - -void ToneMapSession::UpdateBuffer(int acquire_fence, LayerBuffer *buffer) { - // Acquire fence will be closed by HWC Display. - // Fence returned by GPU will be closed in PostCommit. - buffer->acquire_fence_fd = acquire_fence; - buffer->size = intermediate_buffer_[current_buffer_index_]->size; - buffer->planes[0].fd = intermediate_buffer_[current_buffer_index_]->fd; -} - -void ToneMapSession::SetReleaseFence(int fd) { - CloseFd(&release_fence_fd_[current_buffer_index_]); - // Used to give to GPU tonemapper along with input layer fd - release_fence_fd_[current_buffer_index_] = dup(fd); -} - -void ToneMapSession::SetToneMapConfig(Layer *layer) { - // HDR -> SDR is FORWARD and SDR - > HDR is INVERSE - tone_map_config_.type = layer->input_buffer.flags.hdr ? TONEMAP_FORWARD : TONEMAP_INVERSE; - tone_map_config_.colorPrimaries = layer->input_buffer.color_metadata.colorPrimaries; - tone_map_config_.transfer = layer->input_buffer.color_metadata.transfer; - tone_map_config_.secure = layer->request.flags.secure; - tone_map_config_.format = layer->request.format; -} - -bool ToneMapSession::IsSameToneMapConfig(Layer *layer) { - LayerBuffer& buffer = layer->input_buffer; - private_handle_t *handle = intermediate_buffer_[0]; - int tonemap_type = buffer.flags.hdr ? TONEMAP_FORWARD : TONEMAP_INVERSE; - - return ((tonemap_type == tone_map_config_.type) && - (buffer.color_metadata.colorPrimaries == tone_map_config_.colorPrimaries) && - (buffer.color_metadata.transfer == tone_map_config_.transfer) && - (layer->request.flags.secure == tone_map_config_.secure) && - (layer->request.format == tone_map_config_.format) && - (layer->request.width == UINT32(handle->unaligned_width)) && - (layer->request.height == UINT32(handle->unaligned_height))); -} - -int HWCToneMapper::HandleToneMap(hwc_display_contents_1_t *content_list, LayerStack *layer_stack) { - uint32_t gpu_count = 0; - DisplayError error = kErrorNone; - - for (uint32_t i = 0; i < layer_stack->layers.size(); i++) { - uint32_t session_index = 0; - Layer *layer = layer_stack->layers.at(i); - if (layer->composition == kCompositionGPU) { - gpu_count++; - } - - if (layer->request.flags.tone_map) { - switch (layer->composition) { - case kCompositionGPUTarget: - if (!gpu_count) { - // When all layers are on FrameBuffer and if they do not update in the next draw cycle, - // then SDM marks them for SDE Composition because the cached FB layer gets displayed. - // GPU count will be 0 in this case. Try to use the existing tone-mapped frame buffer. - // No ToneMap/Blit is required. Just update the buffer & acquire fence fd of FB layer. - if (!tone_map_sessions_.empty()) { - ToneMapSession *fb_tone_map_session = tone_map_sessions_.at(fb_session_index_); - fb_tone_map_session->UpdateBuffer(-1 /* acquire_fence */, &layer->input_buffer); - fb_tone_map_session->layer_index_ = INT(i); - fb_tone_map_session->acquired_ = true; - return 0; - } - } - error = AcquireToneMapSession(layer, &session_index); - fb_session_index_ = session_index; - break; - default: - error = AcquireToneMapSession(layer, &session_index); - break; - } - - if (error != kErrorNone) { - Terminate(); - return -1; - } - - ToneMapSession *session = tone_map_sessions_.at(session_index); - ToneMap(&content_list->hwLayers[i], layer, session); - session->layer_index_ = INT(i); - } - } - - return 0; -} - -void HWCToneMapper::ToneMap(hwc_layer_1_t *hwc_layer, Layer* layer, ToneMapSession *session) { - int fence_fd = -1; - int acquire_fd = -1; - int merged_fd = -1; - - uint8_t buffer_index = session->current_buffer_index_; - const private_handle_t *dst_hnd = session->intermediate_buffer_[buffer_index]; - const private_handle_t *src_hnd = static_cast<const private_handle_t *>(hwc_layer->handle); - - acquire_fd = dup(layer->input_buffer.acquire_fence_fd); - buffer_sync_handler_.SyncMerge(session->release_fence_fd_[buffer_index], acquire_fd, &merged_fd); - - if (acquire_fd >= 0) { - CloseFd(&acquire_fd); - } - - if (session->release_fence_fd_[buffer_index] >= 0) { - CloseFd(&session->release_fence_fd_[buffer_index]); - } - - DTRACE_BEGIN("GPU_TM_BLIT"); - fence_fd = session->gpu_tone_mapper_->blit(reinterpret_cast<const void *>(dst_hnd), - reinterpret_cast<const void *>(src_hnd), merged_fd); - DTRACE_END(); - - DumpToneMapOutput(session, &fence_fd); - session->UpdateBuffer(fence_fd, &layer->input_buffer); -} - -void HWCToneMapper::PostCommit(LayerStack *layer_stack) { - auto it = tone_map_sessions_.begin(); - while (it != tone_map_sessions_.end()) { - uint32_t session_index = UINT32(std::distance(tone_map_sessions_.begin(), it)); - ToneMapSession *session = tone_map_sessions_.at(session_index); - Layer *layer = layer_stack->layers.at(UINT32(session->layer_index_)); - if (session->acquired_) { - // Close the fd returned by GPU ToneMapper and set release fence. - LayerBuffer &layer_buffer = layer->input_buffer; - CloseFd(&layer_buffer.acquire_fence_fd); - session->SetReleaseFence(layer_buffer.release_fence_fd); - session->acquired_ = false; - it++; - } else { - delete session; - it = tone_map_sessions_.erase(it); - } - } -} - -void HWCToneMapper::Terminate() { - if (tone_map_sessions_.size()) { - while (!tone_map_sessions_.empty()) { - delete tone_map_sessions_.back(); - tone_map_sessions_.pop_back(); - } - fb_session_index_ = 0; - } -} - -void HWCToneMapper::SetFrameDumpConfig(uint32_t count) { - DLOGI("Dump FrameConfig count = %d", count); - dump_frame_count_ = count; - dump_frame_index_ = 0; -} - -void HWCToneMapper::DumpToneMapOutput(ToneMapSession *session, int *acquire_fd) { - if (!dump_frame_count_) { - return; - } - - private_handle_t *target_buffer = session->intermediate_buffer_[session->current_buffer_index_]; - - if (*acquire_fd >= 0) { - int error = sync_wait(*acquire_fd, 1000); - if (error < 0) { - DLOGW("sync_wait error errno = %d, desc = %s", errno, strerror(errno)); - return; - } - } - - size_t result = 0; - char dump_file_name[PATH_MAX]; - snprintf(dump_file_name, sizeof(dump_file_name), "/data/misc/display/frame_dump_primary" - "/tonemap_%dx%d_frame%d.raw", target_buffer->width, target_buffer->height, - dump_frame_index_); - - FILE* fp = fopen(dump_file_name, "w+"); - if (fp) { - DLOGI("base addr = %x", target_buffer->base); - result = fwrite(reinterpret_cast<void *>(target_buffer->base), target_buffer->size, 1, fp); - fclose(fp); - } - dump_frame_count_--; - dump_frame_index_++; - CloseFd(acquire_fd); -} - -DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *session_index) { - Color10Bit *grid_entries = NULL; - int grid_size = 0; - - if (layer->lut_3d.validGridEntries) { - grid_entries = layer->lut_3d.gridEntries; - grid_size = INT(layer->lut_3d.gridSize); - } - - // When the property sdm.disable_hdr_lut_gen is set, the lutEntries and gridEntries in - // the Lut3d will be NULL, clients needs to allocate the memory and set correct 3D Lut - // for Tonemapping. - if (!layer->lut_3d.lutEntries || !layer->lut_3d.dim) { - // Atleast lutEntries must be valid for GPU Tonemapper. - DLOGE("Invalid Lut Entries or lut dimension = %d", layer->lut_3d.dim); - return kErrorParameters; - } - - // Check if we can re-use an existing tone map session. - for (uint32_t i = 0; i < tone_map_sessions_.size(); i++) { - ToneMapSession *tonemap_session = tone_map_sessions_.at(i); - if (!tonemap_session->acquired_ && tonemap_session->IsSameToneMapConfig(layer)) { - tonemap_session->current_buffer_index_ = (tonemap_session->current_buffer_index_ + 1) % - ToneMapSession::kNumIntermediateBuffers; - tonemap_session->acquired_ = true; - *session_index = i; - return kErrorNone; - } - } - - ToneMapSession *session = new ToneMapSession(); - - session->SetToneMapConfig(layer); - session->gpu_tone_mapper_ = TonemapperFactory_GetInstance(session->tone_map_config_.type, - layer->lut_3d.lutEntries, - layer->lut_3d.dim, - grid_entries, grid_size, - session->tone_map_config_.secure); - - if (session->gpu_tone_mapper_ == NULL) { - DLOGE("Get Tonemapper failed!"); - delete session; - return kErrorNotSupported; - } - - int status, format; - DisplayError error = kErrorNone; - int usage = INT(GRALLOC_USAGE_PRIVATE_IOMMU_HEAP | GRALLOC_USAGE_HW_TEXTURE); - - if (layer->request.flags.secure) { - usage = INT(GRALLOC_USAGE_PRIVATE_MM_HEAP); - usage |= INT(GRALLOC_USAGE_PROTECTED); - } - - status = buffer_allocator_.SetBufferInfo(layer->request.format, &format, &usage); - error = session->AllocateIntermediateBuffers(INT(layer->request.width), - INT(layer->request.height), format, usage); - - if (error != kErrorNone) { - DLOGE("Allocation of Intermediate Buffers failed!"); - delete session; - return error; - } - - session->acquired_ = true; - tone_map_sessions_.push_back(session); - *session_index = UINT32(tone_map_sessions_.size() - 1); - - return kErrorNone; -} - -} // namespace sdm diff --git a/sdm/libs/hwc/hwc_tonemapper.h b/sdm/libs/hwc/hwc_tonemapper.h deleted file mode 100644 index 0a463fe3..00000000 --- a/sdm/libs/hwc/hwc_tonemapper.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -* Copyright (c) 2016 - 2017, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __HWC_TONEMAPPER_H__ -#define __HWC_TONEMAPPER_H__ - -#include <fcntl.h> -#include <sys/mman.h> - -#include <hardware/hwcomposer.h> - -#include <core/layer_stack.h> -#include <utils/sys.h> -#include <vector> -#include "hwc_buffer_sync_handler.h" -#include "hwc_buffer_allocator.h" - -class Tonemapper; - -namespace sdm { - -struct ToneMapConfig { - int type = 0; - ColorPrimaries colorPrimaries = ColorPrimaries_Max; - GammaTransfer transfer = Transfer_Max; - LayerBufferFormat format = kFormatRGBA8888; - bool secure = false; -}; - -class ToneMapSession { - public: - ~ToneMapSession(); - DisplayError AllocateIntermediateBuffers(int width, int height, int format, int usage); - void FreeIntermediateBuffers(); - void UpdateBuffer(int acquire_fence, LayerBuffer *buffer); - void SetReleaseFence(int fd); - void SetToneMapConfig(Layer *layer); - bool IsSameToneMapConfig(Layer *layer); - - static const uint8_t kNumIntermediateBuffers = 2; - Tonemapper *gpu_tone_mapper_ = NULL; - ToneMapConfig tone_map_config_ = {}; - uint8_t current_buffer_index_ = 0; - private_handle_t *intermediate_buffer_[kNumIntermediateBuffers] = {NULL, NULL}; - int release_fence_fd_[kNumIntermediateBuffers] = {-1, -1}; - bool acquired_ = false; - int layer_index_ = -1; -}; - -class HWCToneMapper { - public: - HWCToneMapper() {} - ~HWCToneMapper() {} - - int HandleToneMap(hwc_display_contents_1_t *content_list, LayerStack *layer_stack); - bool IsActive() { return !tone_map_sessions_.empty(); } - void PostCommit(LayerStack *layer_stack); - void SetFrameDumpConfig(uint32_t count); - void Terminate(); - - private: - void ToneMap(hwc_layer_1_t *hwc_layer, Layer *layer, ToneMapSession *session); - DisplayError AcquireToneMapSession(Layer *layer, uint32_t *session_index); - void DumpToneMapOutput(ToneMapSession *session, int *acquire_fence); - - std::vector<ToneMapSession*> tone_map_sessions_; - HWCBufferSyncHandler buffer_sync_handler_ = {}; - HWCBufferAllocator buffer_allocator_ = {}; - uint32_t dump_frame_count_ = 0; - uint32_t dump_frame_index_ = 0; - uint32_t fb_session_index_ = 0; -}; - -} // namespace sdm -#endif // __HWC_TONEMAPPER_H__ diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk index 9f1f3c77..782263d3 100644 --- a/sdm/libs/hwc2/Android.mk +++ b/sdm/libs/hwc2/Android.mk @@ -13,8 +13,7 @@ LOCAL_HEADER_LIBRARIES := display_headers LOCAL_CFLAGS := -Wno-missing-field-initializers -Wno-unused-parameter \ -std=c++11 -fcolor-diagnostics\ - -DLOG_TAG=\"SDM\" $(common_flags) \ - -I $(display_top)/sdm/libs/hwc + -DLOG_TAG=\"SDM\" $(common_flags) LOCAL_CLANG := true LOCAL_SHARED_LIBRARIES := libsdmcore libqservice libbinder libhardware libhardware_legacy \ @@ -22,31 +21,22 @@ LOCAL_SHARED_LIBRARIES := libsdmcore libqservice libbinder libhardware li libsdmutils libc++ liblog libgrallocutils libui libgpu_tonemapper \ libhidlbase libhidltransport vendor.display.config@1.0 -ifneq ($(TARGET_USES_GRALLOC1), true) - LOCAL_SHARED_LIBRARIES += libmemalloc -endif - LOCAL_SRC_FILES := hwc_session.cpp \ hwc_session_services.cpp \ hwc_display.cpp \ hwc_display_primary.cpp \ hwc_display_external.cpp \ hwc_display_virtual.cpp \ - ../hwc/hwc_debugger.cpp \ - ../hwc/hwc_buffer_sync_handler.cpp \ + hwc_debugger.cpp \ + hwc_buffer_sync_handler.cpp \ hwc_color_manager.cpp \ hwc_layers.cpp \ hwc_callbacks.cpp \ - ../hwc/cpuhint.cpp \ - ../hwc/hwc_socket_handler.cpp \ + cpuhint.cpp \ hwc_tonemapper.cpp \ - display_null.cpp - -ifneq ($(TARGET_USES_GRALLOC1), true) - LOCAL_SRC_FILES += ../hwc/hwc_buffer_allocator.cpp -else - LOCAL_SRC_FILES += hwc_buffer_allocator.cpp -endif + display_null.cpp \ + hwc_socket_handler.cpp \ + hwc_buffer_allocator.cpp ifeq ($(TARGET_HAS_WIDE_COLOR_DISPLAY), true) LOCAL_CFLAGS += -DFEATURE_WIDE_COLOR diff --git a/sdm/libs/hwc/cpuhint.cpp b/sdm/libs/hwc2/cpuhint.cpp index 551fa247..551fa247 100644 --- a/sdm/libs/hwc/cpuhint.cpp +++ b/sdm/libs/hwc2/cpuhint.cpp diff --git a/sdm/libs/hwc/cpuhint.h b/sdm/libs/hwc2/cpuhint.h index e7587630..e7587630 100644 --- a/sdm/libs/hwc/cpuhint.h +++ b/sdm/libs/hwc2/cpuhint.h diff --git a/sdm/libs/hwc/hwc_buffer_sync_handler.cpp b/sdm/libs/hwc2/hwc_buffer_sync_handler.cpp index 784e91b5..784e91b5 100644 --- a/sdm/libs/hwc/hwc_buffer_sync_handler.cpp +++ b/sdm/libs/hwc2/hwc_buffer_sync_handler.cpp diff --git a/sdm/libs/hwc/hwc_buffer_sync_handler.h b/sdm/libs/hwc2/hwc_buffer_sync_handler.h index 81479d81..81479d81 100644 --- a/sdm/libs/hwc/hwc_buffer_sync_handler.h +++ b/sdm/libs/hwc2/hwc_buffer_sync_handler.h diff --git a/sdm/libs/hwc/hwc_debugger.cpp b/sdm/libs/hwc2/hwc_debugger.cpp index ffbb5c57..ffbb5c57 100644 --- a/sdm/libs/hwc/hwc_debugger.cpp +++ b/sdm/libs/hwc2/hwc_debugger.cpp diff --git a/sdm/libs/hwc/hwc_debugger.h b/sdm/libs/hwc2/hwc_debugger.h index 82ff2f26..82ff2f26 100644 --- a/sdm/libs/hwc/hwc_debugger.h +++ b/sdm/libs/hwc2/hwc_debugger.h diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp index 03314642..0887fbe1 100644 --- a/sdm/libs/hwc2/hwc_display.cpp +++ b/sdm/libs/hwc2/hwc_display.cpp @@ -39,7 +39,6 @@ #include "hwc_display.h" #include "hwc_debugger.h" -#include "blit_engine_c2d.h" #include "hwc_tonemapper.h" #ifndef USE_GRALLOC1 diff --git a/sdm/libs/hwc/hwc_socket_handler.cpp b/sdm/libs/hwc2/hwc_socket_handler.cpp index 7ebaab48..7ebaab48 100644 --- a/sdm/libs/hwc/hwc_socket_handler.cpp +++ b/sdm/libs/hwc2/hwc_socket_handler.cpp diff --git a/sdm/libs/hwc/hwc_socket_handler.h b/sdm/libs/hwc2/hwc_socket_handler.h index 5b2292a2..5b2292a2 100644 --- a/sdm/libs/hwc/hwc_socket_handler.h +++ b/sdm/libs/hwc2/hwc_socket_handler.h |