diff options
author | Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> | 2015-03-08 16:31:15 +0100 |
---|---|---|
committer | Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> | 2015-03-08 16:31:15 +0100 |
commit | 4f8979a2c1893ca80c9b5ead31cbaaa94098ab72 (patch) | |
tree | 85f3a557a37f6e1f5da2ec157ffbe53633f14779 | |
download | juno32-4f8979a2c1893ca80c9b5ead31cbaaa94098ab72.tar.gz |
Initial attempt at a 32-bit Juno build
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
54 files changed, 4740 insertions, 0 deletions
diff --git a/AndroidProducts.mk b/AndroidProducts.mk new file mode 100644 index 0000000..4423ccb --- /dev/null +++ b/AndroidProducts.mk @@ -0,0 +1,13 @@ +# +# This file should set PRODUCT_MAKEFILES to a list of product makefiles +# to expose to the build system. LOCAL_DIR will already be set to +# the directory containing this file. +# +# This file may not rely on the value of any variable other than +# LOCAL_DIR; do not use any conditionals, and do not look up the +# value of any variable that isn't set in this file or in a file that +# it includes. +# + +PRODUCT_MAKEFILES := \ +$(LOCAL_DIR)/juno32.mk diff --git a/BoardConfig.mk b/BoardConfig.mk new file mode 100644 index 0000000..87b408d --- /dev/null +++ b/BoardConfig.mk @@ -0,0 +1,73 @@ +# Primary Arch +TARGET_ARCH := arm +TARGET_ARCH_VARIANT := armv7-a-neon +TARGET_CPU_VARIANT := cortex-a15 +TARGET_CPU_ABI := armeabi-v7a +TARGET_CPU_ABI2 := armeabi + +TARGET_USES_64_BIT_BINDER := false +TARGET_SUPPORTS_32_BIT_APPS := true +TARGET_SUPPORTS_64_BIT_APPS := false + +TARGET_BOARD_PLATFORM := juno32 +ANDROID_64=true +WITH_DEXPREOPT ?= true +USE_OPENGL_RENDERER := true +BIONIC_TESTS ?= true + +ifeq ($(strip $(USE_LINARO_TOOLCHAIN)),true) +# 64bit toolchain +KERNEL_TOOLS_PREFIX ?= $(realpath $(TOP))/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9-linaro/bin/aarch64-linux-android- +#TARGET_TOOLS_PREFIX ?= $(realpath $(TOP))/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9-linaro/bin/aarch64-linux-android- +# 32bit toolchain +# Linaro 32bit toolchain is disabled because of this bug https://bugs.linaro.org/show_bug.cgi?id=383 +#2ND_TARGET_TOOLCHAIN_ROOT ?= $(realpath $(TOP))/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9-linaro +#2ND_TARGET_TOOLS_PREFIX ?= $(realpath $(TOP))/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9-linaro/bin/arm-linux-androideabi- +else +# 64bit toolchain +KERNEL_TOOLS_PREFIX ?= $(realpath $(TOP))/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- +endif + +# Kernel Config +KERNEL_CONFIG ?= linaro/configs/linaro-base.conf \ + linaro/configs/android.conf \ + linaro/configs/vexpress64.conf \ + linaro/configs/big-LITTLE-MP.conf \ + $(realpath $(TOP))/device/linaro/build/selinux.conf +# Kernel Source and Device Tree +TARGET_KERNEL_SOURCE ?= kernel/linaro/armv8 +DEVICE_TREES := juno:juno.dtb +BUILD_KERNEL_MODULES ?= true + +TARGET_NO_BOOTLOADER := true +TARGET_NO_KERNEL := false +TARGET_NO_RECOVERY := true +TARGET_USE_XLOADER := false +TARGET_USE_UBOOT := false +TARGET_HARDWARE_3D := true +TARGET_SHELL := ash +BOARD_USES_GENERIC_AUDIO := true +USE_CAMERA_STUB := true +TARGET_USERIMAGES_USE_EXT4 := true +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 786432000 +BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 +BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016 +BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 +BOARD_FLASH_BLOCK_SIZE := 512 +TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true + +BOARD_SEPOLICY_DIRS += device/linaro/build/sepolicy +BOARD_SEPOLICY_UNION += \ + gatord.te \ + init.te \ + kernel.te \ + logd.te \ + mediaserver.te \ + netd.te \ + shell.te \ + surfaceflinger.te + +BOARD_SEPOLICY_DIRS += device/linaro/juno32/sepolicy +BOARD_SEPOLICY_UNION += \ + file_contexts \ + init.te diff --git a/device.mk b/device.mk new file mode 100644 index 0000000..fc180e6 --- /dev/null +++ b/device.mk @@ -0,0 +1,126 @@ +# +# Copyright (C) 2011 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Adjust the dalvik heap to be appropriate for a tablet. +$(call inherit-product-if-exists, frameworks/base/build/tablet-dalvik-heap.mk) +$(call inherit-product-if-exists, frameworks/native/build/tablet-dalvik-heap.mk) + +PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\ + $(LOCAL_PATH)/fstab.juno:root/fstab.juno \ + $(LOCAL_PATH)/init.juno.rc:root/init.juno.rc \ + $(LOCAL_PATH)/juno_monkey_blacklist:data/juno_monkey_blacklist \ + $(LOCAL_PATH)/juno.kl:system/usr/keylayout/juno.kl) + +# Copy preboot binaries +PRE_BOOT_FILES := bl1.bin fip.bin +PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\ + $(LOCAL_PATH)/preboot/bl1.bin:boot/bl1.bin \ + $(LOCAL_PATH)/preboot/fip.bin:boot/fip.bin \ + $(LOCAL_PATH)/preboot/startup.nsh:boot/startup.nsh) + +# Set custom settings +DEVICE_PACKAGE_OVERLAYS := device/linaro/juno32/overlay + +# Add openssh support for remote debugging and job submission +PRODUCT_PACKAGES += ssh sftp scp sshd ssh-keygen sshd_config start-ssh + +# Build and run only ART +PRODUCT_RUNTIMES := runtime_libart_default + +# Needed to sync the system clock with the RTC clock +PRODUCT_PACKAGES += hwclock32 + +# Build libion for new double-buffering HDLCD driver +PRODUCT_PACKAGES += libion + +# Build gatord daemon for DS-5/Streamline +PRODUCT_PACKAGES += gatord + +# Build gralloc for Juno +PRODUCT_PACKAGES += gralloc.juno32 + +# Include ION tests +PRODUCT_PACKAGES += iontest \ + ion-unit-tests + +# Copy dhcpcd +PRODUCT_PACKAGES += dhcpcd.conf + +# Set zygote config +PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.zygote=zygote64_32 +PRODUCT_COPY_FILES += system/core/rootdir/init.zygote64_32.rc:root/init.zygote64_32.rc + +#enable consle even built in user mode +ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 + +# set ART to use compilation mode +# ART will now what to pick up for compilation if this setting is not set. +ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dex2oat-filter="" + +# Copy hardware config file(s) +PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\ + device/linaro/build/android.hardware.screen.xml:system/etc/permissions/android.hardware.screen.xml \ + device/linaro/build/disablesuspend.sh:system/bin/disablesuspend.sh \ + frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml \ + frameworks/native/data/etc/android.software.app_widgets.xml:system/etc/permissions/android.software.app_widgets.xml \ + frameworks/native/data/etc/android.software.backup.xml:system/etc/permissions/android.software.backup.xml \ + frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml\ + vexpress-firmware/board_recovery_image.tar.bz2:boot/board_recovery_image.tar.bz2\ + vendor.tar.bz2:vendor.tar.bz2) + +PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\ + device/linaro/build/eth0_dns.sh:system/bin/eth0_dns.sh) + +#Copy Graphics binaries +PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\ + vendor/arm/32b/libGLES_mali.so:system/lib/libGLES_mali.so \ + vendor/arm/32b/libGLES_mali.so:system/lib/egl/libGLES_mali.so) + +# Copy media codecs config file +PRODUCT_COPY_FILES += device/linaro/build/media_codecs.xml:system/etc/media_codecs.xml + +# Include application and binaries needed for test +$(call inherit-product-if-exists, device/linaro/build/extra-and-tests.mk) + +# Include Android userspace tests +$(call inherit-product-if-exists, external/linaro-android-userspace-test/product.mk) + +####### Copy build and install howtos for this build ######## +define copy-howto +ifneq ($(wildcard $(TOP)/device/linaro/juno32/howto/$(LINARO_BUILD_SPEC)/$1),) +PRODUCT_COPY_FILES += \ + device/linaro/juno32/howto/$(LINARO_BUILD_SPEC)/$1:$1 +else +ifneq ($(wildcard $(TOP)/device/juno32/howto/default/$1),) +PRODUCT_COPY_FILES += \ + device/linaro/juno32/howto/default/$1:$1 +endif +endif +endef + +HOWTOS := \ + HOWTO_install.txt \ + HOWTO_getsourceandbuild.txt \ + HOWTO_flashfirmware.txt \ + HOWTO_releasenotes.txt \ + HOWTO_rtsm.txt + +ifneq ($(wildcard $(TOP)/build-info),) +PRODUCT_COPY_FILES += \ + build-info/BUILD-INFO.txt:BUILD-INFO.txt +endif + +$(foreach howto,$(HOWTOS),$(eval $(call copy-howto,$(howto)))) diff --git a/dhcpcd/Android.mk b/dhcpcd/Android.mk new file mode 100644 index 0000000..f9bbbb7 --- /dev/null +++ b/dhcpcd/Android.mk @@ -0,0 +1,9 @@ +ifeq (juno, $(TARGET_PRODUCT)) +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := dhcpcd.conf +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/dhcpcd +LOCAL_SRC_FILES := android_dhcpcd.conf +include $(BUILD_PREBUILT) +endif diff --git a/dhcpcd/android_dhcpcd.conf b/dhcpcd/android_dhcpcd.conf new file mode 100644 index 0000000..b39ad73 --- /dev/null +++ b/dhcpcd/android_dhcpcd.conf @@ -0,0 +1,9 @@ +# dhcpcd configuration for Android Wi-Fi interface +# See dhcpcd.conf(5) for details. + +# Disable solicitation of IPv6 Router Advertisements +noipv6rs + +interface eth0 +# dhcpcd-run-hooks uses these options. +option subnet_mask, routers, domain_name_servers, interface_mtu diff --git a/fstab.juno b/fstab.juno new file mode 100644 index 0000000..84e1a59 --- /dev/null +++ b/fstab.juno @@ -0,0 +1,8 @@ +# Android fstab file. +#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags> +# The filesystem that contains the filesystem checker binary (typically /system) cannot +# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK + +/dev/block/sda2 /system ext4 ro wait +/dev/block/sda3 /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait +/dev/block/sda5 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait diff --git a/gralloc/src/Android.mk b/gralloc/src/Android.mk new file mode 100644 index 0000000..898347a --- /dev/null +++ b/gralloc/src/Android.mk @@ -0,0 +1,94 @@ +# +# Copyright (C) 2010 ARM Limited. All rights reserved. +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +MALI_ARCHITECTURE_UTGARD?=1 +MALI_ION?=1 +GRALLOC_VSYNC_BACKEND?=default + +# HAL module implemenation, not prelinked and stored in +# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so +include $(CLEAR_VARS) +include $(BUILD_SYSTEM)/version_defaults.mk + +ifeq ($(MALI_ARCHITECTURE_UTGARD),1) + # Utgard build settings + GRALLOC_DEPTH?=GRALLOC_32_BITS + GRALLOC_FB_SWAP_RED_BLUE?=1 + ifeq ($(MALI_ION),1) + ALLOCATION_LIB := libion + ALLOCATOR_SPECIFIC_FILES := alloc_ion.cpp gralloc_module_ion.cpp + else + ALLOCATION_LIB := libUMP + ALLOCATOR_SPECIFIC_FILES := alloc_ump.cpp gralloc_module_ump.cpp + endif +else + # Midgard build settings + GRALLOC_DEPTH?=GRALLOC_16_BITS + GRALLOC_FB_SWAP_RED_BLUE?=0 + ifeq ($(MALI_ION),1) + ALLOCATION_LIB := libion + ALLOCATOR_SPECIFIC_FILES := alloc_ion.cpp gralloc_module_ion.cpp + else + ALLOCATION_LIB := libGLES_mali + ALLOCATOR_SPECIFIC_FILES := alloc_ump.cpp gralloc_module_ump.cpp + endif +endif + +ifeq ($(MALI_AFBC_GRALLOC), 1) +AFBC_FILES = gralloc_buffer_priv.cpp +else +MALI_AFBC_GRALLOC := 0 +AFBC_FILES = +endif + +LOCAL_PRELINK_MODULE := false + +LOCAL_SHARED_LIBRARIES := libhardware liblog libcutils libGLESv1_CM $(ALLOCATION_LIB) +LOCAL_C_INCLUDES := $(MALI_LOCAL_PATH) $(MALI_DDK_INCLUDES) +LOCAL_CFLAGS := -DLOG_TAG=\"gralloc\" -DSTANDARD_LINUX_SCREEN -DMALI_ION=$(MALI_ION) -DMALI_AFBC_GRALLOC=$(MALI_AFBC_GRALLOC) -D$(GRALLOC_DEPTH) -DMALI_ARCHITECTURE_UTGARD=$(MALI_ARCHITECTURE_UTGARD) -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) +LOCAL_CPPFLAGS := -std=gnu++98 + +ifeq ($(wildcard system/core/libion/include/ion/ion.h),) +LOCAL_C_INCLUDES += system/core/include +LOCAL_CFLAGS += -DGRALLOC_OLD_ION_API +else +LOCAL_C_INCLUDES += system/core/libion/include +endif + +ifeq ($(GRALLOC_FB_SWAP_RED_BLUE),1) +LOCAL_CFLAGS += -DGRALLOC_FB_SWAP_RED_BLUE +endif + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_MODULE := gralloc.juno32 + +LOCAL_MODULE_TAGS := optional +LOCAL_MULTILIB := both + +LOCAL_SRC_FILES := \ + gralloc_module.cpp \ + alloc_device.cpp \ + $(ALLOCATOR_SPECIFIC_FILES) \ + framebuffer_device.cpp \ + format_chooser.cpp \ + format_chooser_blockinit.cpp \ + $(AFBC_FILES) \ + gralloc_vsync_${GRALLOC_VSYNC_BACKEND}.cpp + +include $(BUILD_SHARED_LIBRARY) diff --git a/gralloc/src/alloc_device.cpp b/gralloc/src/alloc_device.cpp new file mode 100644 index 0000000..b9b1c42 --- /dev/null +++ b/gralloc/src/alloc_device.cpp @@ -0,0 +1,440 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <string.h> +#include <errno.h> +#include <pthread.h> + +#include <cutils/log.h> +#include <cutils/atomic.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include <sys/ioctl.h> + +#include "alloc_device.h" +#include "gralloc_priv.h" +#include "gralloc_helper.h" +#include "framebuffer_device.h" + +#include "alloc_device_allocator_specific.h" +#if MALI_AFBC_GRALLOC == 1 +#include "gralloc_buffer_priv.h" +#endif + +#define AFBC_PIXELS_PER_BLOCK 16 +#define AFBC_BODY_BUFFER_BYTE_ALIGNMENT 1024 +#define AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY 16 + +static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle, int* stride, int* byte_stride) +{ + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + + // allocate the framebuffer + if (m->framebuffer == NULL) + { + // initialize the framebuffer, the framebuffer is mapped once and forever. + int err = init_frame_buffer_locked(m); + if (err < 0) + { + return err; + } + } + + const uint32_t bufferMask = m->bufferMask; + const uint32_t numBuffers = m->numBuffers; + /* framebufferSize is used for allocating the handle to the framebuffer and refers + * to the size of the actual framebuffer. + * alignedFramebufferSize is used for allocating a possible internal buffer and + * thus need to consider internal alignment requirements. */ + const size_t framebufferSize = m->finfo.line_length * m->info.yres; + const size_t alignedFramebufferSize = GRALLOC_ALIGN(m->finfo.line_length, 64) * m->info.yres; + + *stride = m->info.xres; + + if (numBuffers == 1) + { + // If we have only one buffer, we never use page-flipping. Instead, + // we return a regular buffer which will be memcpy'ed to the main + // screen when post is called. + int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D; + AWAR( "fallback to single buffering. Virtual Y-res too small %d", m->info.yres ); + *byte_stride = GRALLOC_ALIGN(m->finfo.line_length, 64); + return alloc_backend_alloc(dev, alignedFramebufferSize, newUsage, pHandle); + } + + if (bufferMask >= ((1LU<<numBuffers)-1)) + { + // We ran out of buffers. + return -ENOMEM; + } + + uintptr_t framebufferVaddr = (uintptr_t)m->framebuffer->base; + // find a free slot + for (uint32_t i=0 ; i<numBuffers ; i++) + { + if ((bufferMask & (1LU<<i)) == 0) + { + m->bufferMask |= (1LU<<i); + break; + } + framebufferVaddr += framebufferSize; + } + + // The entire framebuffer memory is already mapped, now create a buffer object for parts of this memory + private_handle_t* hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, usage, size, + (void*)framebufferVaddr, 0, dup(m->framebuffer->fd), + (framebufferVaddr - (uintptr_t)m->framebuffer->base), 0); + + /* + * Perform allocator specific actions. If these fail we fall back to a regular buffer + * which will be memcpy'ed to the main screen when fb_post is called. + */ + if (alloc_backend_alloc_framebuffer(m, hnd) == -1) + { + delete hnd; + int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D; + AERR( "Fallback to single buffering. Unable to map framebuffer memory to handle:%p", hnd ); + *byte_stride = GRALLOC_ALIGN(m->finfo.line_length, 64); + return alloc_backend_alloc(dev, alignedFramebufferSize, newUsage, pHandle); + } + + *pHandle = hnd; + *byte_stride = m->finfo.line_length; + + return 0; +} + +static int gralloc_alloc_framebuffer(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle, int* stride, int* byte_stride) +{ + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + pthread_mutex_lock(&m->lock); + int err = gralloc_alloc_framebuffer_locked(dev, size, usage, pHandle, stride, byte_stride); + pthread_mutex_unlock(&m->lock); + return err; +} + +/* + * Computes the strides and size for an RGB buffer + * + * width width of the buffer in pixels + * height height of the buffer in pixels + * pixel_size size of one pixel in bytes + * + * pixel_stride (out) stride of the buffer in pixels + * byte_stride (out) stride of the buffer in bytes + * size (out) size of the buffer in bytes + * afbc (in) if buffer should be allocated for afbc + */ +static void get_rgb_stride_and_size(int width, int height, int pixel_size, + int* pixel_stride, int* byte_stride, size_t* size, bool afbc) +{ + int stride; + + stride = width * pixel_size; + + /* Align the lines to 64 bytes. + * It's more efficient to write to 64-byte aligned addresses because it's the burst size on the bus */ + stride = GRALLOC_ALIGN(stride, 64); + + if (size != NULL) + { + *size = stride * height; + } + + if (byte_stride != NULL) + { + *byte_stride = stride; + } + + if (pixel_stride != NULL) + { + *pixel_stride = stride / pixel_size; + } + + if (afbc) + { + int w_aligned = GRALLOC_ALIGN( width, AFBC_PIXELS_PER_BLOCK ); + int h_aligned = GRALLOC_ALIGN( height, AFBC_PIXELS_PER_BLOCK ); + int nblocks = w_aligned / AFBC_PIXELS_PER_BLOCK * h_aligned / AFBC_PIXELS_PER_BLOCK; + + if ( size != NULL ) + { + *size = w_aligned * h_aligned * pixel_size + + GRALLOC_ALIGN( nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, AFBC_BODY_BUFFER_BYTE_ALIGNMENT ); + } + } +} + +/* + * Computes the strides and size for an YV12 buffer + * + * width width of the buffer in pixels + * height height of the buffer in pixels + * + * pixel_stride (out) stride of the buffer in pixels + * byte_stride (out) stride of the buffer in bytes + * size (out) size of the buffer in bytes + * afbc (in) if buffer should be allocated for afbc + */ +static bool get_yv12_stride_and_size(int width, int height, + int* pixel_stride, int* byte_stride, size_t* size, bool afbc) +{ + int luma_stride; + + /* Android assumes the width and height are even withou checking, so we check here */ + if (width % 2 != 0 || height % 2 != 0) + { + return false; + } + + if ( afbc && size != NULL ) + { + width = GRALLOC_ALIGN( width, AFBC_PIXELS_PER_BLOCK ); + height = GRALLOC_ALIGN( height, AFBC_PIXELS_PER_BLOCK ); + } + + /* Android assumes the buffer should be aligned to 16. */ + luma_stride = GRALLOC_ALIGN(width, 16); + + if (size != NULL) + { + int chroma_stride = GRALLOC_ALIGN(luma_stride / 2, 16); + /* Simplification of ((height * luma_stride ) + 2 * ((height / 2) * chroma_stride)). */ + *size = height * (luma_stride + chroma_stride); + } + + if (byte_stride != NULL) + { + *byte_stride = luma_stride; + } + + if (pixel_stride != NULL) + { + *pixel_stride = luma_stride; + } + + if ( afbc && size != NULL ) + { + int nblocks = width / AFBC_PIXELS_PER_BLOCK * height / AFBC_PIXELS_PER_BLOCK; + + /* Just append header block size, width/height alignment done above */ + *size += GRALLOC_ALIGN( nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, AFBC_BODY_BUFFER_BYTE_ALIGNMENT ); + } + + return true; +} + +static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* pHandle, int* pStride) +{ + if (!pHandle || !pStride) + { + return -EINVAL; + } + + size_t size; // Size to be allocated for the buffer + int byte_stride; // Stride of the buffer in bytes + int pixel_stride; // Stride of the buffer in pixels - as returned in pStride + uint64_t internal_format; + bool alloc_for_afbc=false; + +#if defined(GRALLOC_FB_SWAP_RED_BLUE) + /* match the framebuffer format */ + if (usage & GRALLOC_USAGE_HW_FB) + { +#ifdef GRALLOC_16_BITS + format = HAL_PIXEL_FORMAT_RGB_565; +#else + format = HAL_PIXEL_FORMAT_BGRA_8888; +#endif + } +#endif + + internal_format = gralloc_select_format(format, usage); + + alloc_for_afbc = (internal_format & GRALLOC_ARM_INTFMT_AFBC); + + switch (internal_format & GRALLOC_ARM_INTFMT_FMT_MASK) + { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_BGRA_8888: +#if PLATFORM_SDK_VERSION >= 19 + case HAL_PIXEL_FORMAT_sRGB_A_8888: + case HAL_PIXEL_FORMAT_sRGB_X_8888: +#endif + get_rgb_stride_and_size(w, h, 4, &pixel_stride, &byte_stride, &size, alloc_for_afbc ); + break; + case HAL_PIXEL_FORMAT_RGB_888: + get_rgb_stride_and_size(w, h, 3, &pixel_stride, &byte_stride, &size, alloc_for_afbc ); + break; + case HAL_PIXEL_FORMAT_RGB_565: +#if PLATFORM_SDK_VERSION < 19 + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: +#endif + get_rgb_stride_and_size(w, h, 2, &pixel_stride, &byte_stride, &size, alloc_for_afbc ); + break; + + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + case HAL_PIXEL_FORMAT_YV12: + if (!get_yv12_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, alloc_for_afbc)) + { + return -EINVAL; + } + break; + + /* + * Additional custom formats can be added here + * and must fill the variables pixel_stride, byte_stride and size. + */ + + default: + return -EINVAL; + } + + int err; + + if (usage & GRALLOC_USAGE_HW_FB) + { + err = gralloc_alloc_framebuffer(dev, size, usage, pHandle, &pixel_stride, &byte_stride); + } + else + { + err = alloc_backend_alloc(dev, size, usage, pHandle); + } + + if (err < 0) + { + return err; + } + + private_handle_t *hnd = (private_handle_t *)*pHandle; + +#if MALI_AFBC_GRALLOC == 1 + err = gralloc_buffer_attr_allocate( hnd ); + if( err < 0 ) + { + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + + if ( (usage & GRALLOC_USAGE_HW_FB) ) + { + /* + * Having the attribute region is not critical for the framebuffer so let it pass. + */ + err = 0; + } + else + { + alloc_backend_alloc_free( hnd, m ); + return err; + } + } +#endif + + hnd->req_format = format; + hnd->byte_stride = byte_stride; + hnd->internal_format = internal_format; + + + int private_usage = usage & (GRALLOC_USAGE_PRIVATE_0 | + GRALLOC_USAGE_PRIVATE_1); + switch (private_usage) + { + case 0: + hnd->yuv_info = MALI_YUV_BT601_NARROW; + break; + case GRALLOC_USAGE_PRIVATE_1: + hnd->yuv_info = MALI_YUV_BT601_WIDE; + break; + case GRALLOC_USAGE_PRIVATE_0: + hnd->yuv_info = MALI_YUV_BT709_NARROW; + break; + case (GRALLOC_USAGE_PRIVATE_0 | GRALLOC_USAGE_PRIVATE_1): + hnd->yuv_info = MALI_YUV_BT709_WIDE; + break; + } + + hnd->width = w; + hnd->height = h; + hnd->stride = pixel_stride; + + *pStride = pixel_stride; + return 0; +} + +static int alloc_device_free(alloc_device_t* dev, buffer_handle_t handle) +{ + if (private_handle_t::validate(handle) < 0) + { + return -EINVAL; + } + + private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle); + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + + if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) + { + // free this buffer + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + const size_t bufferSize = m->finfo.line_length * m->info.yres; + int index = ((uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base) / bufferSize; + m->bufferMask &= ~(1<<index); + close(hnd->fd); + } + +#if MALI_AFBC_GRALLOC == 1 + gralloc_buffer_attr_free( (private_handle_t *) hnd ); +#endif + alloc_backend_alloc_free(hnd, m); + + delete hnd; + + return 0; +} + +int alloc_device_open(hw_module_t const* module, const char* name, hw_device_t** device) +{ + alloc_device_t *dev; + + dev = new alloc_device_t; + if (NULL == dev) + { + return -1; + } + + /* initialize our state here */ + memset(dev, 0, sizeof(*dev)); + + /* initialize the procs */ + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = const_cast<hw_module_t*>(module); + dev->common.close = alloc_backend_close; + dev->alloc = alloc_device_alloc; + dev->free = alloc_device_free; + + if (0 != alloc_backend_open(dev)) { + delete dev; + return -1; + } + + *device = &dev->common; + + return 0; +} diff --git a/gralloc/src/alloc_device.h b/gralloc/src/alloc_device.h new file mode 100644 index 0000000..23f2066 --- /dev/null +++ b/gralloc/src/alloc_device.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <hardware/hardware.h> + +#ifndef AWAR +#define AWAR(fmt, args...) __android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt,__func__,__LINE__,args) +#endif +#ifndef AINF +#define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt,args) +#endif +#ifndef AERR +#define AERR(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt,__func__,__LINE__,args) +#endif +#ifndef AERR_IF +#define AERR_IF( eq, fmt, args...) if ( (eq) ) AERR( fmt, args ) +#endif + +#define GRALLOC_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1)) + +// Create an alloc device +int alloc_device_open(hw_module_t const* module, const char* name, hw_device_t** device); diff --git a/gralloc/src/alloc_device_allocator_specific.h b/gralloc/src/alloc_device_allocator_specific.h new file mode 100644 index 0000000..73dcac6 --- /dev/null +++ b/gralloc/src/alloc_device_allocator_specific.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2013 ARM Limited. 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. + */ + +int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle); + +int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd); + +void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m); + +int alloc_backend_open(alloc_device_t *dev); + +int alloc_backend_close(struct hw_device_t *device); diff --git a/gralloc/src/alloc_ion.cpp b/gralloc/src/alloc_ion.cpp new file mode 100644 index 0000000..58ff1b9 --- /dev/null +++ b/gralloc/src/alloc_ion.cpp @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2013 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <string.h> +#include <errno.h> +#include <pthread.h> + +#include <cutils/log.h> +#include <cutils/atomic.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include <sys/ioctl.h> + +#include "alloc_device.h" +#include "gralloc_priv.h" +#include "gralloc_helper.h" +#include "framebuffer_device.h" + +#include <linux/ion.h> +#include <ion/ion.h> + +int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle) +{ + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + ion_user_handle_t ion_hnd; + unsigned char *cpu_ptr; + int shared_fd; + int ret; + unsigned int heap_mask; + + /* + * The following switch statement is intended to support the use of + * platform specific ION heaps using the gralloc private usage + * flags. + */ + switch((GRALLOC_USAGE_PRIVATE_2 | GRALLOC_USAGE_PRIVATE_3) & usage) + { + /* Example ion heap choice customization. */ + /* + *case GRALLOC_USAGE_PRIVATE_3: + * heap_mask = ION_HEAP_TYPE_CARVEOUT; + * break; + */ + default: + heap_mask = ION_HEAP_SYSTEM_MASK; + break; + } + + int ion_flags = 0; + + if ( (usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN ) + { + ion_flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC; + } + + ret = ion_alloc(m->ion_client, size, 0, heap_mask, + ion_flags, &ion_hnd ); + + if ( ret != 0) + { + AERR("Failed to ion_alloc from ion_client:%d", m->ion_client); + return -1; + } + + ret = ion_share( m->ion_client, ion_hnd, &shared_fd ); + if ( ret != 0 ) + { + AERR( "ion_share( %d ) failed", m->ion_client ); + if ( 0 != ion_free( m->ion_client, ion_hnd ) ) AERR( "ion_free( %d ) failed", m->ion_client ); + return -1; + } + cpu_ptr = (unsigned char*)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, shared_fd, 0 ); + + if ( MAP_FAILED == cpu_ptr ) + { + AERR( "ion_map( %d ) failed", m->ion_client ); + if ( 0 != ion_free( m->ion_client, ion_hnd ) ) AERR( "ion_free( %d ) failed", m->ion_client ); + close( shared_fd ); + return -1; + } + + private_handle_t *hnd = new private_handle_t( private_handle_t::PRIV_FLAGS_USES_ION, usage, size, cpu_ptr, private_handle_t::LOCK_STATE_MAPPED ); + + if ( NULL != hnd ) + { + hnd->share_fd = shared_fd; + hnd->ion_hnd = ion_hnd; + *pHandle = hnd; + return 0; + } + else + { + AERR( "Gralloc out of mem for ion_client:%d", m->ion_client ); + } + + close( shared_fd ); + ret = munmap( cpu_ptr, size ); + if ( 0 != ret ) AERR( "munmap failed for base:%p size: %zd", cpu_ptr, size ); + ret = ion_free( m->ion_client, ion_hnd ); + if ( 0 != ret ) AERR( "ion_free( %d ) failed", m->ion_client ); + return -1; +} + +int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) +{ + struct fb_dmabuf_export fb_dma_buf; + int res; + res = ioctl( m->framebuffer->fd, FBIOGET_DMABUF, &fb_dma_buf ); + if(res == 0) + { + hnd->share_fd = fb_dma_buf.fd; + return 0; + } + else + { + AINF("FBIOGET_DMABUF ioctl failed(%d). See gralloc_priv.h and the integration manual for vendor framebuffer integration", res); +#if MALI_ARCHITECTURE_UTGARD + /* On Utgard we do not have a strict requirement of DMA-BUF integration */ + return 0; +#else + return -1; +#endif + } +} + +void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m) +{ + if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) + { + return; + } + else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) + { + AERR( "Can't free ump memory for handle:%p. Not supported.", hnd ); + } + else if ( hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION ) + { + /* Buffer might be unregistered already so we need to assure we have a valid handle*/ + if ( 0 != hnd->base ) + { + if ( 0 != munmap( (void*)hnd->base, hnd->size ) ) AERR( "Failed to munmap handle %p", hnd ); + } + close( hnd->share_fd ); + if ( 0 != ion_free( m->ion_client, hnd->ion_hnd ) ) AERR( "Failed to ion_free( ion_client: %d ion_hnd: %p )", m->ion_client, hnd->ion_hnd ); + memset( (void*)hnd, 0, sizeof( *hnd ) ); + } +} + +int alloc_backend_open(alloc_device_t *dev) +{ + private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module); + m->ion_client = ion_open(); + if ( m->ion_client < 0 ) + { + AERR( "ion_open failed with %s", strerror(errno) ); + return -1; + } + + return 0; +} + +int alloc_backend_close(struct hw_device_t *device) +{ + alloc_device_t* dev = reinterpret_cast<alloc_device_t*>(device); + if (dev) + { + private_module_t *m = reinterpret_cast<private_module_t*>(device); + if ( 0 != ion_close(m->ion_client) ) AERR( "Failed to close ion_client: %d", m->ion_client ); + close(m->ion_client); + delete dev; + } + return 0; +} diff --git a/gralloc/src/alloc_ump.cpp b/gralloc/src/alloc_ump.cpp new file mode 100644 index 0000000..ca32cdd --- /dev/null +++ b/gralloc/src/alloc_ump.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2013 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <string.h> +#include <errno.h> +#include <pthread.h> + +#include <cutils/log.h> +#include <cutils/atomic.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include <sys/ioctl.h> + +#include "alloc_device.h" +#include "gralloc_priv.h" +#include "gralloc_helper.h" +#include "framebuffer_device.h" + +#include <ump/ump.h> +#include <ump/ump_ref_drv.h> + +#if GRALLOC_SIMULATE_FAILURES +#include <cutils/properties.h> + +/* system property keys for controlling simulated UMP allocation failures */ +#define PROP_MALI_TEST_GRALLOC_FAIL_FIRST "mali.test.gralloc.fail_first" +#define PROP_MALI_TEST_GRALLOC_FAIL_INTERVAL "mali.test.gralloc.fail_interval" + +static int __ump_alloc_should_fail() +{ + + static unsigned int call_count = 0; + unsigned int first_fail = 0; + int fail_period = 0; + int fail = 0; + + ++call_count; + + /* read the system properties that control failure simulation */ + { + char prop_value[PROPERTY_VALUE_MAX]; + + if (property_get(PROP_MALI_TEST_GRALLOC_FAIL_FIRST, prop_value, "0") > 0) + { + sscanf(prop_value, "%11u", &first_fail); + } + + if (property_get(PROP_MALI_TEST_GRALLOC_FAIL_INTERVAL, prop_value, "0") > 0) + { + sscanf(prop_value, "%11u", &fail_period); + } + } + + /* failure simulation is enabled by setting the first_fail property to non-zero */ + if (first_fail > 0) + { + LOGI("iteration %u (fail=%u, period=%u)\n", call_count, first_fail, fail_period); + + fail = (call_count == first_fail) || + (call_count > first_fail && fail_period > 0 && 0 == (call_count - first_fail) % fail_period); + + if (fail) + { + AERR("failed ump_ref_drv_allocate on iteration #%d\n", call_count); + } + } + return fail; +} +#endif + +int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle) +{ + { + ump_handle ump_mem_handle; + void *cpu_ptr; + ump_secure_id ump_id; + ump_alloc_constraints constraints; + + size = round_up_to_page_size(size); + + if( (usage&GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN ) + { + constraints = UMP_REF_DRV_CONSTRAINT_USE_CACHE; + } + else + { + constraints = UMP_REF_DRV_CONSTRAINT_NONE; + } + +#ifdef GRALLOC_SIMULATE_FAILURES + /* if the failure condition matches, fail this iteration */ + if (__ump_alloc_should_fail()) + { + ump_mem_handle = UMP_INVALID_MEMORY_HANDLE; + } + else +#endif + { + ump_mem_handle = ump_ref_drv_allocate(size, constraints); + + if (UMP_INVALID_MEMORY_HANDLE != ump_mem_handle) + { + cpu_ptr = ump_mapped_pointer_get(ump_mem_handle); + if (NULL != cpu_ptr) + { + ump_id = ump_secure_id_get(ump_mem_handle); + if (UMP_INVALID_SECURE_ID != ump_id) + { + private_handle_t* hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_USES_UMP, + usage, + size, + cpu_ptr, + private_handle_t::LOCK_STATE_MAPPED, + ump_id, + ump_mem_handle); + + if (NULL != hnd) + { + *pHandle = hnd; + return 0; + } + else + { + AERR( "gralloc_alloc_buffer() failed to allocate handle. ump_handle = %p, ump_id = %d", ump_mem_handle, ump_id ); + } + } + else + { + AERR( "gralloc_alloc_buffer() failed to retrieve valid secure id. ump_handle = %p", ump_mem_handle ); + } + + ump_mapped_pointer_release(ump_mem_handle); + } + else + { + AERR( "gralloc_alloc_buffer() failed to map UMP memory. ump_handle = %p", ump_mem_handle ); + } + + ump_reference_release(ump_mem_handle); + } + else + { + AERR( "gralloc_alloc_buffer() failed to allocate UMP memory. size:%d constraints: %d", size, constraints ); + } + } + return -1; + } +} + +int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) +{ + hnd->ump_id = m->framebuffer->ump_id; + /* create a backing ump memory handle if the framebuffer is exposed as a secure ID */ + if ( (int)UMP_INVALID_SECURE_ID != hnd->ump_id ) + { + hnd->ump_mem_handle = ump_handle_create_from_secure_id( hnd->ump_id ); + if ( UMP_INVALID_MEMORY_HANDLE == hnd->ump_mem_handle ) + { + AERR("unable to create UMP handle from secure ID %i\n", hnd->ump_id); + return -1; + } + } + + return 0; +} + +void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m) +{ + if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) + { + if ( UMP_INVALID_MEMORY_HANDLE != hnd->ump_mem_handle ) + { + ump_reference_release((ump_handle)hnd->ump_mem_handle); + } + } + else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) + { + /* Buffer might be unregistered so we need to check for invalid ump handle*/ + if ( UMP_INVALID_MEMORY_HANDLE != hnd->ump_mem_handle ) + { + ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); + ump_reference_release((ump_handle)hnd->ump_mem_handle); + } + } + else if ( hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION ) + { + AERR( "Can't free dma_buf memory for handle:%p. Not supported.", hnd); + } +} + +int alloc_backend_open(alloc_device_t *dev) +{ + ump_result ump_res = ump_open(); + if (UMP_OK != ump_res) + { + AERR( "UMP open failed with %d", ump_res ); + return -1; + } + + return 0; +} + +int alloc_backend_close(struct hw_device_t *device) +{ + alloc_device_t* dev = reinterpret_cast<alloc_device_t*>(device); + if (dev) + { + ump_close(); // Our UMP memory refs will be released automatically here... + } + return 0; +} diff --git a/gralloc/src/format_chooser.cpp b/gralloc/src/format_chooser.cpp new file mode 100644 index 0000000..1310280 --- /dev/null +++ b/gralloc/src/format_chooser.cpp @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <hardware/hardware.h> +#include <cutils/log.h> +#include <hardware/gralloc.h> +#include "format_chooser.h" + +static inline int find_format_index(int format) +{ + int index=-1; + + switch ( format ) + { + case HAL_PIXEL_FORMAT_RGBA_8888: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888; + break; + case HAL_PIXEL_FORMAT_RGBX_8888: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888; + break; + case HAL_PIXEL_FORMAT_RGB_888: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888; + break; + case HAL_PIXEL_FORMAT_RGB_565: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565; + break; + case HAL_PIXEL_FORMAT_BGRA_8888: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888; + break; +#if PLATFORM_SDK_VERSION >= 19 + case HAL_PIXEL_FORMAT_sRGB_A_8888: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888; + break; + case HAL_PIXEL_FORMAT_sRGB_X_8888: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888; + break; +#endif + case HAL_PIXEL_FORMAT_YV12: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12; + break; +#if PLATFORM_SDK_VERSION >= 18 + case HAL_PIXEL_FORMAT_Y8: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8; + break; + case HAL_PIXEL_FORMAT_Y16: + index = GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16; + break; +#endif + } + + return index; +} + +/* + * Define GRALLOC_ARM_FORMAT_SELECTION_DISABLE to disable the format selection completely + */ +uint64_t gralloc_select_format(int req_format, int usage) +{ +#if defined(GRALLOC_ARM_FORMAT_SELECTION_DISABLE) + + (void) usage; + return (uint64_t) req_format; + +#else + uint64_t new_format = req_format; + int intformat_ind; + int n=0; + int largest_weight_ind=-1; + int16_t accum_weights[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST] = {0}; + + ALOGV("gralloc_select_format: req_format=0x%x usage=0x%x\n",req_format,usage); + + if( req_format == 0 ) + { + return 0; + } + + if( (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) != 0 || + usage == 0 ) + { + return new_format; + } + + /* This is currently a limitation with the display and will be removed eventually + * We can't allocate fbdev framebuffer buffers in AFBC format */ + if( usage & GRALLOC_USAGE_HW_FB ) + { + return new_format; + } + + /* if this format can't be classified in one of the groups we + * have pre-defined, ignore it. + */ + intformat_ind = find_format_index( req_format ); + if( intformat_ind < 0 ) + { + return new_format; + } + + while( blklist[n].blk_init != 0 ) + { + if( (blklist[n].hwblkconf.usage & usage) != 0 ) + { + uint32_t m; + + for(m=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST; m<GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST; m++) + { + if( blklist[n].hwblkconf.weights[intformat_ind][m] != DEFAULT_WEIGHT_UNSUPPORTED ) + { + accum_weights[m] += blklist[n].hwblkconf.weights[intformat_ind][m]; + + + if( largest_weight_ind < 0 || + accum_weights[m] > accum_weights[largest_weight_ind]) + { + largest_weight_ind = m; + } + } + else + { + /* Format not supported by this hwblk */ + accum_weights[m] = DEFAULT_WEIGHT_UNSUPPORTED; + } + } + } + n++; + } + + if( largest_weight_ind < 0 ) + { + new_format = 0; + } + else + { + new_format = translate_internal_indexed[largest_weight_ind].internal_extended_format; + } + + ALOGV("Returned iterated format: 0x%llX", new_format); + + return new_format; +#endif +} + +extern "C" +{ +void *gralloc_get_internal_info(int *blkconf_size, int *gpu_conf) +{ + void *blkinit_address = NULL; + +#if !defined(GRALLOC_ARM_FORMAT_SELECTION_DISABLE) + + if(blkconf_size != NULL && gpu_conf != NULL) + { + blkinit_address = (void*) blklist; + *blkconf_size = blklist_array_size; + +/* + * Tests intended to verify gralloc format selection behavior are GPU version aware in runtime. + * They need to know what configuration we built for. For now this is simply AFBC on or off. This + * will likely change in the future to mean something else. + */ +#if MALI_AFBC_GRALLOC == 1 + *gpu_conf = 1; +#else + *gpu_conf = 0; +#endif /* MALI_AFBC_GRALLOC */ + } + +#endif /* GRALLOC_ARM_FORMAT_SELECTION_DISABLE */ + + return blkinit_address; +} + +int gralloc_get_internal_format(int hal_format) +{ + return find_format_index(hal_format); +} +} diff --git a/gralloc/src/format_chooser.h b/gralloc/src/format_chooser.h new file mode 100644 index 0000000..5797ce8 --- /dev/null +++ b/gralloc/src/format_chooser.h @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FORMAT_CHOOSER_H_ +#define FORMAT_CHOOSER_H_ + +#include <hardware/hardware.h> + + +#define GRALLOC_ARM_INTFMT_EXTENSION_BIT_START 32 + +/* This format will be use AFBC */ +#define GRALLOC_ARM_INTFMT_AFBC (1ULL << (GRALLOC_ARM_INTFMT_EXTENSION_BIT_START+0)) + +/* This format uses AFBC split block mode */ +#define GRALLOC_ARM_INTFMT_AFBC_SPLITBLK (1ULL << (GRALLOC_ARM_INTFMT_EXTENSION_BIT_START+1)) + +/* Internal format masks */ +#define GRALLOC_ARM_INTFMT_FMT_MASK 0x00000000ffffffffULL +#define GRALLOC_ARM_INTFMT_EXT_MASK 0xffffffff00000000ULL + +/* Index of the internal formats */ +typedef enum +{ + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_A_8888, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_X_8888, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_Y8, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_Y16, + + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12_AFBC, + + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_SPLITBLK, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK, + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12_AFBC_SPLITBLK, + + /* Add more internal formats here */ + + GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST +} gralloc_arm_internal_index_format; + +typedef enum +{ + /* Having an invalid format catches lists which are initialized with not all entries. */ + GRALLOC_ARM_HAL_FORMAT_INDEXED_INVALID, + GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, + GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, + GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, + GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565, + GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, + GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888, + GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888, + GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12, + GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8, + GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16, + GRALLOC_ARM_HAL_FORMAT_INDEXED_LAST +} gralloc_arm_hal_index_format; + +#define MAX_COMPATIBLE 3 +#define DEFAULT_WEIGHT_SUPPORTED 50 +#define DEFAULT_WEIGHT_MOST_PREFERRED 100 +#define DEFAULT_WEIGHT_UNSUPPORTED -1 + +typedef struct +{ + /* The internal extended format exported outside of gralloc */ + uint64_t internal_extended_format; + + /* Swizzled versions of the requested format for this internal format */ + gralloc_arm_hal_index_format comp_format_list[MAX_COMPATIBLE]; +} internal_fmt_info; + +uint64_t gralloc_select_format(int req_format, int usage); + +struct hwblk +{ + uint32_t usage; + int16_t weights[GRALLOC_ARM_HAL_FORMAT_INDEXED_LAST][GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST]; +}; + + +typedef struct +{ + void (*blk_init)(struct hwblk *format_matrix, int16_t **array); + struct hwblk hwblkconf; +} blkinit; + + +extern void initialize_blk_conf(); +extern const internal_fmt_info translate_internal_indexed[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST]; +extern blkinit blklist[]; +extern uint32_t blklist_array_size; + +extern "C" +{ + int gralloc_get_internal_format(int hal_format); + void *gralloc_get_internal_info(int *blkconf_size, int *gpu_conf); +} + +#endif /* FORMAT_CHOOSER_H_ */ diff --git a/gralloc/src/format_chooser_blockinit.cpp b/gralloc/src/format_chooser_blockinit.cpp new file mode 100644 index 0000000..9eefeeb --- /dev/null +++ b/gralloc/src/format_chooser_blockinit.cpp @@ -0,0 +1,224 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +/* The extension bits are defined for indexed formats when setting + * up the definitions. This define exports them before including + * the block definitions. + */ +#include "format_chooser.h" + +#include "formatdef_files/gpu_default.defs" + +#if MALI_AFBC_GRALLOC == 1 +#include "formatdef_files/gpu_afbc.defs" +#endif + + +/* Defines a translation list of requested formats that are compatible with the internal indexed format */ +const internal_fmt_info translate_internal_indexed[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST] = +{ + { + HAL_PIXEL_FORMAT_RGBA_8888, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888} + }, + + { + HAL_PIXEL_FORMAT_RGBX_8888, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888} + }, + + { + HAL_PIXEL_FORMAT_RGB_888, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888} + }, + + { + HAL_PIXEL_FORMAT_RGB_565, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565} + }, + + { + HAL_PIXEL_FORMAT_BGRA_8888, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888} + }, + +#if PLATFORM_SDK_VERSION >= 19 + {HAL_PIXEL_FORMAT_sRGB_A_8888, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888} }, + {HAL_PIXEL_FORMAT_sRGB_X_8888, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888} }, +#else + {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888} }, + {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888} }, +#endif + + { + HAL_PIXEL_FORMAT_YV12, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12} + }, + +#if PLATFORM_SDK_VERSION >= 18 + {HAL_PIXEL_FORMAT_Y8, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8} }, + {HAL_PIXEL_FORMAT_Y16, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16} }, +#else + {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8} }, + {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16} }, +#endif + + + { + HAL_PIXEL_FORMAT_RGBA_8888 | GRALLOC_ARM_INTFMT_AFBC, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888} + }, + + { + HAL_PIXEL_FORMAT_RGBX_8888 | GRALLOC_ARM_INTFMT_AFBC, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888} + }, + + { + HAL_PIXEL_FORMAT_RGB_888 | GRALLOC_ARM_INTFMT_AFBC, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888} + }, + + { + HAL_PIXEL_FORMAT_RGB_565 | GRALLOC_ARM_INTFMT_AFBC, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565} + }, + + { + HAL_PIXEL_FORMAT_BGRA_8888 | GRALLOC_ARM_INTFMT_AFBC, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888} + }, + + { + HAL_PIXEL_FORMAT_YV12 | GRALLOC_ARM_INTFMT_AFBC, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12} + }, + + { + HAL_PIXEL_FORMAT_RGBA_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888} + }, + + { + HAL_PIXEL_FORMAT_RGBX_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888} + }, + + { + HAL_PIXEL_FORMAT_RGB_888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888} + }, + + { + HAL_PIXEL_FORMAT_RGB_565 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565} + }, + + { + HAL_PIXEL_FORMAT_BGRA_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888} + }, + + { + HAL_PIXEL_FORMAT_YV12 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK, + {GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12} + } +}; + +blkinit blklist[] = +{ +#if MALI_AFBC_GRALLOC == 1 + { + gpu_afbc_write_blkinit,{0,{}} + }, + { + gpu_afbc_read_blkinit,{0,{}} + }, +#else + { + gpu_write_blkinit,{0,{}} + }, + { + gpu_read_blkinit,{0,{}} + }, +#endif + + /* Empty entry */ + { + NULL,{0,{}} + } +}; + +uint32_t blklist_array_size = sizeof(blklist); + +void initialize_blk_conf() +{ + int i,j,k; + + i=0; + while( blklist[i].blk_init != 0 ) + { + int16_t *array=0; + + for(j=0;j<GRALLOC_ARM_HAL_FORMAT_INDEXED_LAST;j++) + { + for(k=0; k<(int) GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST; k++) + { + blklist[i].hwblkconf.weights[j][k] = DEFAULT_WEIGHT_UNSUPPORTED; + } + } + blklist[i].blk_init( &blklist[i].hwblkconf , &array); + if( *array != 0 ) + { + for(k=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST; k<GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST; k++) + { + /* Zero weights are not suppose to be used in the preferred array because that usually means + * uninitialized values. + */ + if( array[k] != DEFAULT_WEIGHT_UNSUPPORTED && array[k] != 0 ) + { + int n; + + /* For this internal format we will for its base format setup matching weights + * for itself as well as swizzled versions of the format. When initializing + * swizzled/compatible formats with same weight, we insert a slight preference + * on the base format(which is listed first) to choose that when the base is selected. + * Other blocks' preference might adjust this. + */ + for(n=0; n<MAX_COMPATIBLE; n++) + { + if( translate_internal_indexed[k].comp_format_list[n] != GRALLOC_ARM_HAL_FORMAT_INDEXED_INVALID ) + { + if(n==0) + { + blklist[i].hwblkconf.weights[translate_internal_indexed[k].comp_format_list[n]][k] = array[k]+1; + } + else + { + blklist[i].hwblkconf.weights[translate_internal_indexed[k].comp_format_list[n]][k] = array[k]; + } + } + } + } + } + } + i++; + } +} diff --git a/gralloc/src/formatdef_files/gpu_afbc.defs b/gralloc/src/formatdef_files/gpu_afbc.defs new file mode 100644 index 0000000..0b8a3b3 --- /dev/null +++ b/gralloc/src/formatdef_files/gpu_afbc.defs @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +static void gpu_afbc_read_blkinit(struct hwblk *blk,int16_t **array) +{ + /* Initialiaze GPU default weight setup */ + gpu_read_blkinit(blk, array); + + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; +} + + +static void gpu_afbc_write_blkinit(struct hwblk *blk,int16_t **array) +{ + /* Initialiaze GPU default weight setup */ + gpu_write_blkinit(blk, array); + + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; + (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED; +} diff --git a/gralloc/src/formatdef_files/gpu_default.defs b/gralloc/src/formatdef_files/gpu_default.defs new file mode 100644 index 0000000..e08e658 --- /dev/null +++ b/gralloc/src/formatdef_files/gpu_default.defs @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <cutils/memory.h> + +static int16_t pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST]; + +static void gpu_read_blkinit(struct hwblk *blk,int16_t **array) +{ + android_memset16((uint16_t*) pref_formats, (uint16_t) DEFAULT_WEIGHT_UNSUPPORTED, sizeof(uint16_t) * GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST); + + blk->usage = GRALLOC_USAGE_HW_TEXTURE; + + /* Compatible internal formats for a specific input format will also be initialized */ + /* Preference on RGBA compared to BGRA because of GLES readback */ + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888] = DEFAULT_WEIGHT_SUPPORTED+10; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888] = DEFAULT_WEIGHT_SUPPORTED; + + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12] = DEFAULT_WEIGHT_SUPPORTED; + + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_A_8888] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_X_8888] = DEFAULT_WEIGHT_SUPPORTED; + + *array = pref_formats; +} + + +static void gpu_write_blkinit(struct hwblk *blk,int16_t **array) +{ + android_memset16((uint16_t*) pref_formats, (uint16_t) DEFAULT_WEIGHT_UNSUPPORTED, sizeof(uint16_t) * GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST); + + blk->usage = GRALLOC_USAGE_HW_RENDER; + + /* Compatible internal formats for a specific input format will also be initialized */ + /* Preference on RGBA compared to BGRA because of GLES readback */ + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888] = DEFAULT_WEIGHT_SUPPORTED+10; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888] = DEFAULT_WEIGHT_SUPPORTED; + + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12] = DEFAULT_WEIGHT_SUPPORTED; + + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_A_8888] = DEFAULT_WEIGHT_SUPPORTED; + pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_X_8888] = DEFAULT_WEIGHT_SUPPORTED; + + *array = pref_formats; +} diff --git a/gralloc/src/framebuffer_device.cpp b/gralloc/src/framebuffer_device.cpp new file mode 100644 index 0000000..ef7a106 --- /dev/null +++ b/gralloc/src/framebuffer_device.cpp @@ -0,0 +1,474 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <string.h> +#include <errno.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <linux/fb.h> + +#include <cutils/log.h> +#include <cutils/atomic.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include <GLES/gl.h> + +#include "alloc_device.h" +#include "gralloc_priv.h" +#include "gralloc_helper.h" +#include "gralloc_vsync.h" + +// numbers of buffers for page flipping +#define NUM_BUFFERS NUM_FB_BUFFERS + +enum +{ + PAGE_FLIP = 0x00000001, +}; + + +static int fb_set_swap_interval(struct framebuffer_device_t* dev, int interval) +{ + if (interval < dev->minSwapInterval) + { + interval = dev->minSwapInterval; + } + else if (interval > dev->maxSwapInterval) + { + interval = dev->maxSwapInterval; + } + + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + m->swapInterval = interval; + + if (0 == interval) gralloc_vsync_disable(dev); + else gralloc_vsync_enable(dev); + + return 0; +} + +static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) +{ + if (private_handle_t::validate(buffer) < 0) + { + return -EINVAL; + } + + private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(buffer); + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + + if (m->currentBuffer) + { + m->base.unlock(&m->base, m->currentBuffer); + m->currentBuffer = 0; + } + + if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) + { + m->base.lock(&m->base, buffer, private_module_t::PRIV_USAGE_LOCKED_FOR_POST, + 0, 0, m->info.xres, m->info.yres, NULL); + + const size_t offset = (uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base; + int interrupt; + m->info.activate = FB_ACTIVATE_VBL; + m->info.yoffset = offset / m->finfo.line_length; + +#ifdef STANDARD_LINUX_SCREEN + if (ioctl(m->framebuffer->fd, FBIOPAN_DISPLAY, &m->info) == -1) + { + AERR( "FBIOPAN_DISPLAY failed for fd: %d", m->framebuffer->fd ); + m->base.unlock(&m->base, buffer); + return -errno; + } +#else /*Standard Android way*/ + if (ioctl(m->framebuffer->fd, FBIOPUT_VSCREENINFO, &m->info) == -1) + { + AERR( "FBIOPUT_VSCREENINFO failed for fd: %d", m->framebuffer->fd ); + m->base.unlock(&m->base, buffer); + return -errno; + } +#endif + if ( 0 != gralloc_wait_for_vsync(dev) ) + { + AERR( "Gralloc wait for vsync failed for fd: %d", m->framebuffer->fd ); + m->base.unlock(&m->base, buffer); + return -errno; + } + m->currentBuffer = buffer; + } + else + { + void* fb_vaddr; + void* buffer_vaddr; + + m->base.lock(&m->base, m->framebuffer, GRALLOC_USAGE_SW_WRITE_RARELY, + 0, 0, m->info.xres, m->info.yres, &fb_vaddr); + + m->base.lock(&m->base, buffer, GRALLOC_USAGE_SW_READ_RARELY, + 0, 0, m->info.xres, m->info.yres, &buffer_vaddr); + + // If buffer's alignment match framebuffer alignment we can do a direct copy. + // If not we must fallback to do an aligned copy of each line. + if ( hnd->byte_stride == (int)m->finfo.line_length ) + { + memcpy(fb_vaddr, buffer_vaddr, m->finfo.line_length * m->info.yres); + } + else + { + uintptr_t fb_offset = 0; + uintptr_t buffer_offset = 0; + unsigned int i; + + for (i = 0; i < m->info.yres; i++) + { + memcpy((void *)((uintptr_t)fb_vaddr + fb_offset), + (void *)((uintptr_t)buffer_vaddr + buffer_offset), + m->finfo.line_length); + + fb_offset += m->finfo.line_length; + buffer_offset += hnd->byte_stride; + } + } + m->base.unlock(&m->base, buffer); + m->base.unlock(&m->base, m->framebuffer); + } + + return 0; +} + +int init_frame_buffer_locked(struct private_module_t* module) +{ + if (module->framebuffer) + { + return 0; // Nothing to do, already initialized + } + + char const * const device_template[] = + { + "/dev/graphics/fb%u", + "/dev/fb%u", + NULL + }; + + int fd = -1; + int i = 0; + char name[64]; + + 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) + { + return -errno; + } + + struct fb_var_screeninfo info; + if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) + { + 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; + +#ifdef GRALLOC_16_BITS + /* + * 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; +#else + /* + * Explicitly request 8/8/8 + */ + info.bits_per_pixel = 32; + info.red.offset = 16; + info.red.length = 8; + info.green.offset = 8; + info.green.length = 8; + info.blue.offset = 0; + info.blue.length = 8; + info.transp.offset = 0; + info.transp.length = 0; +#endif + + /* + * Request NUM_BUFFERS screens (at lest 2 for page flipping) + */ + info.yres_virtual = info.yres * NUM_BUFFERS; + + uint32_t flags = PAGE_FLIP; + if (ioctl(fd, FBIOPUT_VSCREENINFO, &info) == -1) + { + info.yres_virtual = info.yres; + flags &= ~PAGE_FLIP; + AWAR( "FBIOPUT_VSCREENINFO failed, page flipping not supported fd: %d", fd ); + } + + if (info.yres_virtual < info.yres * 2) + { + // we need at least 2 for page-flipping + info.yres_virtual = info.yres; + flags &= ~PAGE_FLIP; + AWAR( "page flipping not supported (yres_virtual=%d, requested=%d)", info.yres_virtual, info.yres*2 ); + } + + if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) + { + return -errno; + } + + int refreshRate = 0; + if ( info.pixclock > 0 ) + { + refreshRate = 1000000000000000LLU / + ( + uint64_t( info.upper_margin + info.lower_margin + info.yres + info.hsync_len ) + * ( info.left_margin + info.right_margin + info.xres + info.vsync_len ) + * info.pixclock + ); + } + else + { + AWAR( "fbdev pixclock is zero for fd: %d", fd ); + } + + if (refreshRate == 0) + { + refreshRate = 60*1000; // 60 Hz + } + + if (int(info.width) <= 0 || int(info.height) <= 0) + { + // the driver doesn't return that information + // default to 160 dpi + info.width = ((info.xres * 25.4f)/160.0f + 0.5f); + info.height = ((info.yres * 25.4f)/160.0f + 0.5f); + } + + float xdpi = (info.xres * 25.4f) / info.width; + float ydpi = (info.yres * 25.4f) / info.height; + float fps = refreshRate / 1000.0f; + + AINF("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); + + AINF("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 (0 == strncmp(finfo.id, "CLCD FB", 7)) + { + module->dpy_type = MALI_DPY_TYPE_CLCD; + } + else if (0 == strncmp(finfo.id, "ARM Mali HDLCD", 14)) + { + module->dpy_type = MALI_DPY_TYPE_HDLCD; + } + else + { + module->dpy_type = MALI_DPY_TYPE_UNKNOWN; + } + + if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) + { + return -errno; + } + + if (finfo.smem_len <= 0) + { + return -errno; + } + + module->flags = flags; + module->info = info; + module->finfo = finfo; + module->xdpi = xdpi; + module->ydpi = ydpi; + module->fps = fps; + module->swapInterval = 1; + + /* + * map the framebuffer + */ + size_t fbSize = round_up_to_page_size(finfo.line_length * info.yres_virtual); + void* vaddr = mmap(0, fbSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + if (vaddr == MAP_FAILED) + { + AERR( "Error mapping the framebuffer (%s)", strerror(errno) ); + return -errno; + } + + memset(vaddr, 0, fbSize); + + + // Create a "fake" buffer object for the entire frame buffer memory, and store it in the module + module->framebuffer = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, GRALLOC_USAGE_HW_FB, fbSize, vaddr, + 0, dup(fd), 0, 0); + + module->numBuffers = info.yres_virtual / info.yres; + module->bufferMask = 0; + +#if GRALLOC_ARM_UMP_MODULE + ioctl(fd, IOCTL_GET_FB_UMP_SECURE_ID, &module->framebuffer->ump_id); + if ( (int)UMP_INVALID_SECURE_ID != module->framebuffer->ump_id ) + { + AERR("framebuffer accessed with UMP secure ID %i\n", module->framebuffer->ump_id); + } +#endif + + return 0; +} + +static int init_frame_buffer(struct private_module_t* module) +{ + pthread_mutex_lock(&module->lock); + int err = init_frame_buffer_locked(module); + pthread_mutex_unlock(&module->lock); + return err; +} + +static int fb_close(struct hw_device_t *device) +{ + framebuffer_device_t* dev = reinterpret_cast<framebuffer_device_t*>(device); + if (dev) + { +#if GRALLOC_ARM_UMP_MODULE + ump_close(); +#endif + delete dev; + } + return 0; +} + +int compositionComplete(struct framebuffer_device_t* dev) +{ + /* By doing a finish here we force the GL driver to start rendering + all the drawcalls up to this point, and to wait for the rendering to be complete.*/ + glFinish(); + /* The rendering of the backbuffer is now completed. + When SurfaceFlinger later does a call to eglSwapBuffer(), the swap will be done + synchronously in the same thread, and not asynchronoulsy in a background thread later. + The SurfaceFlinger requires this behaviour since it releases the lock on all the + SourceBuffers (Layers) after the compositionComplete() function returns. + However this "bad" behaviour by SurfaceFlinger should not affect performance, + since the Applications that render the SourceBuffers (Layers) still get the + full renderpipeline using asynchronous rendering. So they perform at maximum speed, + and because of their complexity compared to the Surface flinger jobs, the Surface flinger + is normally faster even if it does everyhing synchronous and serial. + */ + return 0; +} + +int framebuffer_device_open(hw_module_t const* module, const char* name, hw_device_t** device) +{ + int status = -EINVAL; + + alloc_device_t* gralloc_device; + status = gralloc_open(module, &gralloc_device); + if (status < 0) + { + return status; + } + + private_module_t* m = (private_module_t*)module; + status = init_frame_buffer(m); + if (status < 0) + { + gralloc_close(gralloc_device); + return status; + } + + /* initialize our state here */ + framebuffer_device_t *dev = new framebuffer_device_t(); + memset(dev, 0, sizeof(*dev)); + + /* initialize the procs */ + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = const_cast<hw_module_t*>(module); + dev->common.close = fb_close; + dev->setSwapInterval = fb_set_swap_interval; + dev->post = fb_post; + dev->setUpdateRect = 0; + dev->compositionComplete = &compositionComplete; + + int stride = m->finfo.line_length / (m->info.bits_per_pixel >> 3); + const_cast<uint32_t&>(dev->flags) = 0; + const_cast<uint32_t&>(dev->width) = m->info.xres; + const_cast<uint32_t&>(dev->height) = m->info.yres; + const_cast<int&>(dev->stride) = stride; +#ifdef GRALLOC_16_BITS + const_cast<int&>(dev->format) = HAL_PIXEL_FORMAT_RGB_565; +#else + const_cast<int&>(dev->format) = HAL_PIXEL_FORMAT_BGRA_8888; +#endif + const_cast<float&>(dev->xdpi) = m->xdpi; + const_cast<float&>(dev->ydpi) = m->ydpi; + const_cast<float&>(dev->fps) = m->fps; + const_cast<int&>(dev->minSwapInterval) = 0; + const_cast<int&>(dev->maxSwapInterval) = 1; + *device = &dev->common; + + gralloc_vsync_enable(dev); + + return status; +} diff --git a/gralloc/src/framebuffer_device.h b/gralloc/src/framebuffer_device.h new file mode 100644 index 0000000..7e63d5f --- /dev/null +++ b/gralloc/src/framebuffer_device.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <hardware/hardware.h> + +// Create a framebuffer device +int framebuffer_device_open(hw_module_t const* module, const char* name, hw_device_t** device); + +// Initialize the framebuffer (must keep module lock before calling +int init_frame_buffer_locked(struct private_module_t* module); diff --git a/gralloc/src/gralloc_buffer_priv.cpp b/gralloc/src/gralloc_buffer_priv.cpp new file mode 100644 index 0000000..a357030 --- /dev/null +++ b/gralloc/src/gralloc_buffer_priv.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <cutils/ashmem.h> +#include <cutils/log.h> +#include <sys/mman.h> +#include "gralloc_priv.h" +#include "gralloc_buffer_priv.h" + + +/* + * Allocate shared memory for attribute storage. Only to be + * used by gralloc internally. + * + * Return 0 on success. + */ +int gralloc_buffer_attr_allocate( private_handle_t *hnd ) +{ + int rval = -1; + + if( !hnd ) + goto out; + + if( hnd->share_attr_fd >= 0 ) + { + ALOGW("Warning share attribute fd already exists during create. Closing."); + close( hnd->share_attr_fd ); + } + + hnd->share_attr_fd = ashmem_create_region( "gralloc_shared_attr", PAGE_SIZE ); + if(hnd->share_attr_fd < 0) + { + ALOGE("Failed to allocate page for shared attribute region"); + goto err_ashmem; + } + + /* + * Default protection on the shm region is PROT_EXEC | PROT_READ | PROT_WRITE. + * + * Personality flag READ_IMPLIES_EXEC which is used by some processes, namely gdbserver, + * causes a mmap with PROT_READ to be translated to PROT_READ | PROT_EXEC. + * + * If we were to drop PROT_EXEC here with a call to ashmem_set_prot_region() + * this can potentially cause clients to fail importing this gralloc attribute buffer + * with EPERM error since PROT_EXEC is not allowed. + * + * Because of this we keep the PROT_EXEC flag. + */ + + hnd->attr_base = mmap( NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_attr_fd, 0 ); + if(hnd->attr_base != MAP_FAILED) + { + /* The attribute region contains signed integers only. + * The reason for this is because we can set a value less than 0 for + * not-initialized values. + */ + attr_region *region = (attr_region *) hnd->attr_base; + + memset(hnd->attr_base, 0xff, PAGE_SIZE); + munmap( hnd->attr_base, PAGE_SIZE ); + hnd->attr_base = MAP_FAILED; + } + else + { + ALOGE("Failed to mmap shared attribute region"); + goto err_ashmem; + } + + rval = 0; + goto out; + +err_ashmem: + if( hnd->share_attr_fd >= 0 ) + { + close( hnd->share_attr_fd ); + hnd->share_attr_fd = -1; + } + +out: + return rval; +} + +/* + * Frees the shared memory allocated for attribute storage. + * Only to be used by gralloc internally. + + * Return 0 on success. + */ +int gralloc_buffer_attr_free( private_handle_t *hnd ) +{ + int rval = -1; + + if( !hnd ) + goto out; + + if( hnd->share_attr_fd < 0 ) + { + ALOGE("Shared attribute region not avail to free"); + goto out; + } + if( hnd->attr_base != MAP_FAILED ) + { + ALOGW("Warning shared attribute region mapped at free. Unmapping"); + munmap( hnd->attr_base, PAGE_SIZE ); + hnd->attr_base = MAP_FAILED; + } + + close( hnd->share_attr_fd ); + hnd->share_attr_fd = -1; + rval = 0; + +out: + return rval; +} diff --git a/gralloc/src/gralloc_buffer_priv.h b/gralloc/src/gralloc_buffer_priv.h new file mode 100644 index 0000000..8a0934c --- /dev/null +++ b/gralloc/src/gralloc_buffer_priv.h @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRALLOC_BUFFER_PRIV_H_ +#define GRALLOC_BUFFER_PRIV_H_ + +#include "gralloc_priv.h" +#include <errno.h> +#include <string.h> + +// private gralloc buffer manipulation API + +struct attr_region +{ + int crop_bottom; + int crop_left; + int crop_top; + int crop_right; + int use_yuv_transform; + int use_sparse_alloc; + +} __attribute__ ((packed)); + +typedef struct attr_region attr_region; + +enum +{ + /* CROP and YUV_TRANS are intended to be + * written by producers and read by consumers. + * Producers should write these parameters before + * it queues a buffer to the consumer. + */ + + /* CROP RECT, defined as a uint32_t array of bottom,left,top,right. */ + GRALLOC_ARM_BUFFER_ATTR_CROP_RECT = 1, + + /* Set if the AFBC format used a YUV transform before compressing */ + GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS = 2, + + /* Set if the AFBC format uses sparse allocation */ + GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC = 3, + + GRALLOC_ARM_BUFFER_ATTR_LAST +}; + +typedef uint32_t buf_attr; + +/* + * Allocate shared memory for attribute storage. Only to be + * used by gralloc internally. + * + * Return 0 on success. + */ +int gralloc_buffer_attr_allocate( private_handle_t *hnd ); + +/* + * Frees the shared memory allocated for attribute storage. + * Only to be used by gralloc internally. + + * Return 0 on success. + */ +int gralloc_buffer_attr_free( private_handle_t *hnd ); + +/* + * Map the attribute storage area before attempting to + * read/write from it. + * + * Return 0 on success. + */ +static inline int gralloc_buffer_attr_map( private_handle_t *hnd, bool readwrite) +{ + int rval = -1; + int prot_flags = PROT_READ; + + if( !hnd ) + goto out; + + if( hnd->share_attr_fd < 0 ) + { + ALOGE("Shared attribute region not available to be mapped"); + goto out; + } + + if( readwrite ) + { + prot_flags |= PROT_WRITE; + } + + hnd->attr_base = mmap( NULL, PAGE_SIZE, prot_flags, MAP_SHARED, hnd->share_attr_fd, 0 ); + if(hnd->attr_base == MAP_FAILED) + { + ALOGE("Failed to mmap shared attribute region err=%s",strerror(errno)); + goto out; + } + + rval = 0; + +out: + return rval; +} + +/* + * Unmap the attribute storage area when done with it. + * + * Return 0 on success. + */ +static inline int gralloc_buffer_attr_unmap( private_handle_t *hnd ) +{ + int rval = -1; + + if( !hnd ) + goto out; + + if( hnd->attr_base != MAP_FAILED ) + { + if ( munmap( hnd->attr_base, PAGE_SIZE ) == 0 ) + { + hnd->attr_base = MAP_FAILED; + rval = 0; + } + } + +out: + return rval; +} + +/* + * Read or write an attribute from/to the storage area. + * + * Return 0 on success. + */ +static inline int gralloc_buffer_attr_write( private_handle_t *hnd, buf_attr attr, int *val ) +{ + int rval = -1; + + if( !hnd || !val || attr >= GRALLOC_ARM_BUFFER_ATTR_LAST ) + goto out; + + if( hnd->attr_base != MAP_FAILED ) + { + attr_region *region = (attr_region *) hnd->attr_base; + + switch( attr ) + { + case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT: + memcpy( ®ion->crop_bottom, val, sizeof(int)*4 ); + rval = 0; + break; + + case GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS: + region->use_yuv_transform = *val; + rval = 0; + break; + + case GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC: + region->use_sparse_alloc = *val; + rval = 0; + break; + } + } + +out: + return rval; +} + +static inline int gralloc_buffer_attr_read( private_handle_t *hnd, buf_attr attr, int *val ) +{ + int rval = -1; + + if( !hnd || !val || attr >= GRALLOC_ARM_BUFFER_ATTR_LAST ) + goto out; + + if( hnd->attr_base != MAP_FAILED ) + { + attr_region *region = (attr_region *) hnd->attr_base; + + switch( attr ) + { + case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT: + memcpy( val, ®ion->crop_bottom, sizeof(int)*4 ); + rval = 0; + break; + + case GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS: + *val = region->use_yuv_transform; + rval = 0; + break; + + case GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC: + *val = region->use_sparse_alloc; + rval = 0; + break; + } + } + +out: + return rval; +} + +#endif /* GRALLOC_BUFFER_PRIV_H_ */ diff --git a/gralloc/src/gralloc_helper.h b/gralloc/src/gralloc_helper.h new file mode 100644 index 0000000..277364b --- /dev/null +++ b/gralloc/src/gralloc_helper.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRALLOC_HELPER_H_ +#define GRALLOC_HELPER_H_ + +#include <sys/mman.h> + +inline size_t round_up_to_page_size(size_t x) +{ + return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); +} + +#endif /* GRALLOC_HELPER_H_ */ diff --git a/gralloc/src/gralloc_module.cpp b/gralloc/src/gralloc_module.cpp new file mode 100644 index 0000000..2ec2565 --- /dev/null +++ b/gralloc/src/gralloc_module.cpp @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <errno.h> +#include <pthread.h> + +#include <cutils/log.h> +#include <cutils/atomic.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include "gralloc_priv.h" +#include "alloc_device.h" +#include "framebuffer_device.h" + +#include "gralloc_module_allocator_specific.h" + +#if MALI_AFBC_GRALLOC == 1 +#include "gralloc_buffer_priv.h" +#endif + +#include "format_chooser.h" + +static pthread_mutex_t s_map_lock = PTHREAD_MUTEX_INITIALIZER; + +static int gralloc_device_open(const hw_module_t* module, const char* name, hw_device_t** device) +{ + int status = -EINVAL; + + if (!strncmp(name, GRALLOC_HARDWARE_GPU0, MALI_GRALLOC_HARDWARE_MAX_STR_LEN)) + { + status = alloc_device_open(module, name, device); + } + else if (!strncmp(name, GRALLOC_HARDWARE_FB0, MALI_GRALLOC_HARDWARE_MAX_STR_LEN)) + { + status = framebuffer_device_open(module, name, device); + } + + return status; +} + +static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle_t handle) +{ + if (private_handle_t::validate(handle) < 0) + { + AERR("Registering invalid buffer %p, returning error", handle); + return -EINVAL; + } + + // if this handle was created in this process, then we keep it as is. + private_handle_t* hnd = (private_handle_t*)handle; + + if (hnd->pid == getpid()) + { + // If the handle is created and registered in the same process this is valid, + // but it could also be that application is registering twice which is illegal. + AWAR("Registering handle %p coming from the same process: %d.", hnd, hnd->pid); + } + + int retval = -EINVAL; + + pthread_mutex_lock(&s_map_lock); + + hnd->pid = getpid(); + + if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) + { + AERR( "Can't register buffer %p as it is a framebuffer", handle ); + } + else if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + retval = gralloc_backend_register(hnd); + } + else + { + AERR("registering non-UMP buffer not supported. flags = %d", hnd->flags ); + } + + pthread_mutex_unlock(&s_map_lock); + return retval; +} + +static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) +{ + if (private_handle_t::validate(handle) < 0) + { + AERR("unregistering invalid buffer %p, returning error", handle); + return -EINVAL; + } + + private_handle_t* hnd = (private_handle_t*)handle; + + AERR_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); + + if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) + { + AERR( "Can't unregister buffer %p as it is a framebuffer", handle ); + } + else if (hnd->pid == getpid()) // never unmap buffers that were not created in this process + { + pthread_mutex_lock(&s_map_lock); + + if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + gralloc_backend_unregister(hnd); + } + else + { + AERR("Unregistering unknown buffer is not supported. Flags = %d", hnd->flags); + } + +#if MALI_AFBC_GRALLOC == 1 + /* + * Close shared attribute region file descriptor. It might seem strange to "free" + * this here since this can happen in a client process, but free here is nothing + * but unmapping and closing the duplicated file descriptor. The original ashmem + * fd instance is still open until alloc_device_free() is called. Even sharing + * of gralloc buffers within the same process should have fds dup:ed. + */ + gralloc_buffer_attr_free( hnd ); + +#endif + hnd->base = 0; + hnd->lockState = 0; + hnd->writeOwner = 0; + + pthread_mutex_unlock(&s_map_lock); + } + else + { + AERR( "Trying to unregister buffer %p from process %d that was not created in current process: %d", hnd, hnd->pid, getpid()); + } + + return 0; +} + +static int gralloc_lock(gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr) +{ + if (private_handle_t::validate(handle) < 0) + { + AERR("Locking invalid buffer %p, returning error", handle ); + return -EINVAL; + } + + private_handle_t* hnd = (private_handle_t*)handle; + if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP || hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) + { + hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK; + } + if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) + { + *vaddr = (void*)hnd->base; + } + return 0; +} + +static int gralloc_unlock(gralloc_module_t const* module, buffer_handle_t handle) +{ + if (private_handle_t::validate(handle) < 0) + { + AERR( "Unlocking invalid buffer %p, returning error", handle ); + return -EINVAL; + } + + private_handle_t* hnd = (private_handle_t*)handle; + + if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION) + && hnd->writeOwner) + { + gralloc_backend_sync(hnd); + } + + return 0; +} + +// There is one global instance of the module + +static struct hw_module_methods_t gralloc_module_methods = +{ + open: gralloc_device_open +}; + +private_module_t::private_module_t() +{ +#define INIT_ZERO(obj) (memset(&(obj),0,sizeof((obj)))) + + base.common.tag = HARDWARE_MODULE_TAG; + base.common.version_major = 1; + base.common.version_minor = 0; + base.common.id = GRALLOC_HARDWARE_MODULE_ID; + base.common.name = "Graphics Memory Allocator Module"; + base.common.author = "ARM Ltd."; + base.common.methods = &gralloc_module_methods; + base.common.dso = NULL; + INIT_ZERO(base.common.reserved); + + base.registerBuffer = gralloc_register_buffer; + base.unregisterBuffer = gralloc_unregister_buffer; + base.lock = gralloc_lock; + base.unlock = gralloc_unlock; + base.perform = NULL; + INIT_ZERO(base.reserved_proc); + + framebuffer = NULL; + flags = 0; + numBuffers = 0; + bufferMask = 0; + pthread_mutex_init(&(lock), NULL); + currentBuffer = NULL; + INIT_ZERO(info); + INIT_ZERO(finfo); + xdpi = 0.0f; + ydpi = 0.0f; + fps = 0.0f; + swapInterval = 1; + + initialize_blk_conf(); + +#undef INIT_ZERO +}; + +/* + * HAL_MODULE_INFO_SYM will be initialized using the default constructor + * implemented above + */ +struct private_module_t HAL_MODULE_INFO_SYM; + diff --git a/gralloc/src/gralloc_module_allocator_specific.h b/gralloc/src/gralloc_module_allocator_specific.h new file mode 100644 index 0000000..895f24b --- /dev/null +++ b/gralloc/src/gralloc_module_allocator_specific.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2013 ARM Limited. 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. + */ + +int gralloc_backend_register(private_handle_t* hnd); + +void gralloc_backend_unregister(private_handle_t* hnd); + +void gralloc_backend_sync(private_handle_t* hnd); diff --git a/gralloc/src/gralloc_module_ion.cpp b/gralloc/src/gralloc_module_ion.cpp new file mode 100644 index 0000000..edf83fd --- /dev/null +++ b/gralloc/src/gralloc_module_ion.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2013 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <errno.h> +#include <pthread.h> + +#include <cutils/log.h> +#include <cutils/atomic.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include "gralloc_priv.h" +#include "alloc_device.h" +#include "framebuffer_device.h" + +#include <linux/ion.h> +#include <ion/ion.h> +#include <sys/mman.h> + +int gralloc_backend_register(private_handle_t* hnd) +{ + int retval = -EINVAL; + + switch (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + case private_handle_t::PRIV_FLAGS_USES_UMP: + AERR("Gralloc does not support UMP. Unable to register UMP memory for handle %p", hnd ); + break; + case private_handle_t::PRIV_FLAGS_USES_ION: + unsigned char *mappedAddress; + size_t size = hnd->size; + hw_module_t * pmodule = NULL; + private_module_t *m=NULL; + if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0) + { + m = reinterpret_cast<private_module_t *>(pmodule); + } + else + { + AERR("Could not get gralloc module for handle: %p", hnd); + retval = -errno; + break; + } + /* the test condition is set to m->ion_client <= 0 here, because: + * 1) module structure are initialized to 0 if no initial value is applied + * 2) a second user process should get a ion fd greater than 0. + */ + if (m->ion_client <= 0) + { + /* a second user process must obtain a client handle first via ion_open before it can obtain the shared ion buffer*/ + m->ion_client = ion_open(); + + if (m->ion_client < 0) + { + AERR( "Could not open ion device for handle: %p", hnd ); + retval = -errno; + break; + } + } + + mappedAddress = (unsigned char*)mmap( NULL, size, PROT_READ | PROT_WRITE, + MAP_SHARED, hnd->share_fd, 0 ); + + if ( MAP_FAILED == mappedAddress ) + { + AERR( "mmap( share_fd:%d ) failed with %s", hnd->share_fd, strerror( errno ) ); + retval = -errno; + break; + } + + hnd->base = (void*)(uintptr_t(mappedAddress) + hnd->offset); + retval = 0; + break; + } + + return retval; +} + +void gralloc_backend_unregister(private_handle_t* hnd) +{ + switch (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + case private_handle_t::PRIV_FLAGS_USES_UMP: + AERR( "Can't unregister UMP buffer for handle %p. Not supported", hnd ); + break; + case private_handle_t::PRIV_FLAGS_USES_ION: + void* base = (void*)hnd->base; + size_t size = hnd->size; + + if ( munmap( base,size ) < 0 ) + { + AERR("Could not munmap base:%p size:%zd '%s'", base, size, strerror(errno)); + } + break; + } +} + +void gralloc_backend_sync(private_handle_t* hnd) +{ + switch (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + case private_handle_t::PRIV_FLAGS_USES_UMP: + AERR( "Buffer %p is UMP type but it is not supported", hnd ); + break; + case private_handle_t::PRIV_FLAGS_USES_ION: + hw_module_t * pmodule = NULL; + private_module_t *m=NULL; + if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0) + { + m = reinterpret_cast<private_module_t *>(pmodule); + ion_sync_fd(m->ion_client, hnd->share_fd); + } + else + { + AERR("Could not get gralloc module for handle %p\n", hnd); + } + break; + } +} diff --git a/gralloc/src/gralloc_module_ump.cpp b/gralloc/src/gralloc_module_ump.cpp new file mode 100644 index 0000000..af11491 --- /dev/null +++ b/gralloc/src/gralloc_module_ump.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2013 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <errno.h> +#include <pthread.h> + +#include <cutils/log.h> +#include <cutils/atomic.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include "gralloc_priv.h" +#include "alloc_device.h" +#include "framebuffer_device.h" + +#include <ump/ump_ref_drv.h> +static int s_ump_is_open = 0; + +int gralloc_backend_register(private_handle_t* hnd) +{ + int retval = -EINVAL; + + switch (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + case private_handle_t::PRIV_FLAGS_USES_UMP: + if (!s_ump_is_open) + { + ump_result res = ump_open(); // MJOLL-4012: UMP implementation needs a ump_close() for each ump_open + if (res != UMP_OK) + { + AERR("Failed to open UMP library with res=%d", res); + } + s_ump_is_open = 1; + } + + if (s_ump_is_open) + { + hnd->ump_mem_handle = ump_handle_create_from_secure_id(hnd->ump_id); + if (UMP_INVALID_MEMORY_HANDLE != (ump_handle)hnd->ump_mem_handle) + { + hnd->base = ump_mapped_pointer_get(hnd->ump_mem_handle); + if (0 != hnd->base) + { + hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; + hnd->writeOwner = 0; + hnd->lockState = 0; + + return 0; + } + else + { + AERR("Failed to map UMP handle %p", hnd->ump_mem_handle ); + } + + ump_reference_release((ump_handle)hnd->ump_mem_handle); + } + else + { + AERR("Failed to create UMP handle %p", hnd->ump_mem_handle ); + } + } + break; + case private_handle_t::PRIV_FLAGS_USES_ION: + AERR("Gralloc does not support DMA_BUF. Unable to map memory for handle %p", hnd ); + break; + } + + return retval; +} + +void gralloc_backend_unregister(private_handle_t* hnd) +{ + switch (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + case private_handle_t::PRIV_FLAGS_USES_UMP: + ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); + hnd->base = 0; + ump_reference_release((ump_handle)hnd->ump_mem_handle); + hnd->ump_mem_handle = UMP_INVALID_MEMORY_HANDLE; + break; + case private_handle_t::PRIV_FLAGS_USES_ION: + AERR( "Can't unregister DMA_BUF buffer for hnd %p. Not supported", hnd ); + break; + } +} + +void gralloc_backend_sync(private_handle_t* hnd) +{ + switch (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | + private_handle_t::PRIV_FLAGS_USES_ION)) + { + case private_handle_t::PRIV_FLAGS_USES_UMP: + ump_cpu_msync_now((ump_handle)hnd->ump_mem_handle, UMP_MSYNC_CLEAN_AND_INVALIDATE, (void*)hnd->base, hnd->size); + break; + case private_handle_t::PRIV_FLAGS_USES_ION: + AERR( "Buffer %p is DMA_BUF type but it is not supported", hnd ); + break; + } +} diff --git a/gralloc/src/gralloc_priv.h b/gralloc/src/gralloc_priv.h new file mode 100644 index 0000000..83cafdb --- /dev/null +++ b/gralloc/src/gralloc_priv.h @@ -0,0 +1,393 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRALLOC_PRIV_H_ +#define GRALLOC_PRIV_H_ + +#include <stdint.h> +#include <pthread.h> +#include <errno.h> +#include <linux/fb.h> +#include <sys/types.h> +#include <unistd.h> +#include <sys/mman.h> + +#include <hardware/gralloc.h> +#include <cutils/native_handle.h> +#include "alloc_device.h" +#include <utils/Log.h> + +#include "format_chooser.h" + +#if MALI_ION == 1 +#define GRALLOC_ARM_UMP_MODULE 0 +#define GRALLOC_ARM_DMA_BUF_MODULE 1 +#if !defined(GRALLOC_OLD_ION_API) +/* new libion */ +typedef int ion_user_handle_t; +#define ION_INVALID_HANDLE 0 +#else +typedef struct ion_handle *ion_user_handle_t; +#define ION_INVALID_HANDLE NULL +#endif /* GRALLOC_OLD_ION_API */ +#else +#define GRALLOC_ARM_UMP_MODULE 1 +#define GRALLOC_ARM_DMA_BUF_MODULE 0 +#endif /* MALI_ION */ + +/* NOTE: + * If your framebuffer device driver is integrated with UMP, you will have to + * change this IOCTL definition to reflect your integration with the framebuffer + * device. + * Expected return value is a UMP secure id backing your framebuffer device memory. + */ +#if GRALLOC_ARM_UMP_MODULE +#define IOCTL_GET_FB_UMP_SECURE_ID _IOWR('m', 0xF8, __u32) +#endif + +/* NOTE: + * If your framebuffer device driver is integrated with dma_buf, you will have to + * change this IOCTL definition to reflect your integration with the framebuffer + * device. + * Expected return value is a structure filled with a file descriptor + * backing your framebuffer device memory. + */ +#if GRALLOC_ARM_DMA_BUF_MODULE +struct fb_dmabuf_export +{ + __u32 fd; + __u32 flags; +}; +#define FBIOGET_DMABUF _IOR('F', 0x21, struct fb_dmabuf_export) +#endif + +/* the max string size of GRALLOC_HARDWARE_GPU0 & GRALLOC_HARDWARE_FB0 + * 8 is big enough for "gpu0" & "fb0" currently + */ +#define MALI_GRALLOC_HARDWARE_MAX_STR_LEN 8 +#define NUM_FB_BUFFERS 2 + +/* Define number of shared file descriptors */ +#if MALI_AFBC_GRALLOC == 1 && GRALLOC_ARM_DMA_BUF_MODULE +#define GRALLOC_ARM_NUM_FDS 2 +#elif MALI_AFBC_GRALLOC == 1 || GRALLOC_ARM_DMA_BUF_MODULE +#define GRALLOC_ARM_NUM_FDS 1 +#else +#define GRALLOC_ARM_NUM_FDS 0 +#endif + +#define NUM_INTS_IN_PRIVATE_HANDLE ((sizeof(private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds) + + + +#if GRALLOC_ARM_UMP_MODULE +#include <ump/ump.h> +#endif + +typedef enum +{ + MALI_YUV_NO_INFO, + MALI_YUV_BT601_NARROW, + MALI_YUV_BT601_WIDE, + MALI_YUV_BT709_NARROW, + MALI_YUV_BT709_WIDE +} mali_gralloc_yuv_info; + +typedef enum +{ + MALI_DPY_TYPE_UNKNOWN = 0, + MALI_DPY_TYPE_CLCD, + MALI_DPY_TYPE_HDLCD +} mali_dpy_type; + +struct private_handle_t; + +struct private_module_t +{ + gralloc_module_t base; + + private_handle_t* framebuffer; + uint32_t flags; + uint32_t numBuffers; + uint32_t bufferMask; + pthread_mutex_t lock; + buffer_handle_t currentBuffer; + int ion_client; + mali_dpy_type dpy_type; + + struct fb_var_screeninfo info; + struct fb_fix_screeninfo finfo; + float xdpi; + float ydpi; + float fps; + int swapInterval; + + enum + { + // flag to indicate we'll post this buffer + PRIV_USAGE_LOCKED_FOR_POST = 0x80000000 + }; + + /* default constructor */ + private_module_t(); +}; + +#ifdef __cplusplus +struct private_handle_t : public native_handle +{ +#else +struct private_handle_t +{ + struct native_handle nativeHandle; +#endif + + enum + { + PRIV_FLAGS_FRAMEBUFFER = 0x00000001, + PRIV_FLAGS_USES_UMP = 0x00000002, + PRIV_FLAGS_USES_ION = 0x00000004 + }; + + enum + { + LOCK_STATE_WRITE = 1<<31, + LOCK_STATE_MAPPED = 1<<30, + LOCK_STATE_READ_MASK = 0x3FFFFFFF + }; + +#if GRALLOC_ARM_DMA_BUF_MODULE + /* + * Shared file descriptor for dma_buf sharing. This must be the first element in the + * structure so that binder knows where it is and can properly share it between + * processes. + * DO NOT MOVE THIS ELEMENT! + */ + int share_fd; +#endif + +#if MALI_AFBC_GRALLOC == 1 + int share_attr_fd; +#endif + +#if GRALLOC_ARM_DMA_BUF_MODULE + ion_user_handle_t ion_hnd; +#endif + + // ints + int magic; + int req_format; + uint64_t internal_format; + int byte_stride; + int flags; + int usage; + int size; + int width; + int height; + int stride; + union { + void* base; + uint64_t padding; + }; + int lockState; + int writeOwner; + int pid; + +#if MALI_AFBC_GRALLOC == 1 + // locally mapped shared attribute area + union { + void* attr_base; + uint64_t padding3; + }; +#endif + + mali_gralloc_yuv_info yuv_info; + + // Following members is for framebuffer only + int fd; + union { + off_t offset; + uint64_t padding4; + }; + + // Following members are for UMP memory only +#if GRALLOC_ARM_UMP_MODULE + ump_secure_id ump_id; + union { + void* ump_mem_handle; + uint64_t padding5; + }; +#endif + +#ifdef __cplusplus + /* + * We track the number of integers in the structure. There are 16 unconditional + * integers (magic - pid, yuv_info, fd and offset). Note that the fd element is + * considered an int not an fd because it is not intended to be used outside the + * surface flinger process. The GRALLOC_ARM_NUM_INTS variable is used to track the + * number of integers that are conditionally included. Similar considerations apply + * to the number of fds. + */ + static const int sNumFds = GRALLOC_ARM_NUM_FDS; + static const int sMagic = 0x3141592; + +#if GRALLOC_ARM_UMP_MODULE + private_handle_t(int flags, int usage, int size, void *base, int lock_state, ump_secure_id secure_id, ump_handle handle): +#if MALI_AFBC_GRALLOC == 1 + share_attr_fd(-1), +#endif + magic(sMagic), + flags(flags), + usage(usage), + size(size), + width(0), + height(0), + stride(0), + base(base), + lockState(lock_state), + writeOwner(0), + pid(getpid()), +#if MALI_AFBC_GRALLOC == 1 + attr_base(MAP_FAILED), +#endif + yuv_info(MALI_YUV_NO_INFO), + fd(0), + offset(0), + ump_id(secure_id), + ump_mem_handle(handle) + + { + version = sizeof(native_handle); + numFds = sNumFds; + numInts = NUM_INTS_IN_PRIVATE_HANDLE; + } +#endif + + private_handle_t(int flags, int usage, int size, void *base, int lock_state): +#if GRALLOC_ARM_DMA_BUF_MODULE + share_fd(-1), +#endif +#if MALI_AFBC_GRALLOC == 1 + share_attr_fd(-1), +#endif +#if GRALLOC_ARM_DMA_BUF_MODULE + ion_hnd(ION_INVALID_HANDLE), +#endif + magic(sMagic), + flags(flags), + usage(usage), + size(size), + width(0), + height(0), + stride(0), + base(base), + lockState(lock_state), + writeOwner(0), + pid(getpid()), +#if MALI_AFBC_GRALLOC == 1 + attr_base(MAP_FAILED), +#endif + yuv_info(MALI_YUV_NO_INFO), + fd(0), + offset(0) +#if GRALLOC_ARM_UMP_MODULE + ,ump_id(UMP_INVALID_SECURE_ID), + ump_mem_handle(UMP_INVALID_MEMORY_HANDLE) +#endif + + + { + version = sizeof(native_handle); + numFds = sNumFds; + numInts = NUM_INTS_IN_PRIVATE_HANDLE; + } + + private_handle_t(int flags, int usage, int size, void *base, int lock_state, int fb_file, off_t fb_offset, int unused): +#if GRALLOC_ARM_DMA_BUF_MODULE + share_fd(-1), +#endif +#if MALI_AFBC_GRALLOC == 1 + share_attr_fd(-1), +#endif +#if GRALLOC_ARM_DMA_BUF_MODULE + ion_hnd(ION_INVALID_HANDLE), +#endif + magic(sMagic), + flags(flags), + usage(usage), + size(size), + width(0), + height(0), + stride(0), + base(base), + lockState(lock_state), + writeOwner(0), + pid(getpid()), +#if MALI_AFBC_GRALLOC == 1 + attr_base(MAP_FAILED), +#endif + yuv_info(MALI_YUV_NO_INFO), + fd(fb_file), + offset(fb_offset) + +#if GRALLOC_ARM_UMP_MODULE + ,ump_id(UMP_INVALID_SECURE_ID), + ump_mem_handle(UMP_INVALID_MEMORY_HANDLE) +#endif + + { + version = sizeof(native_handle); + numFds = sNumFds; + numInts = NUM_INTS_IN_PRIVATE_HANDLE; + } + + ~private_handle_t() + { + magic = 0; + } + + bool usesPhysicallyContiguousMemory() + { + return (flags & PRIV_FLAGS_FRAMEBUFFER) ? true : false; + } + + static int validate(const native_handle* h) + { + const private_handle_t* hnd = (const private_handle_t*)h; + if (!h || + h->version != sizeof(native_handle) || + h->numInts != NUM_INTS_IN_PRIVATE_HANDLE || + h->numFds != sNumFds || + hnd->magic != sMagic) + { + return -EINVAL; + } + return 0; + } + + static private_handle_t* dynamicCast(const native_handle* in) + { + if (validate(in) == 0) + { + return (private_handle_t*) in; + } + return NULL; + } +#endif +}; + +#endif /* GRALLOC_PRIV_H_ */ diff --git a/gralloc/src/gralloc_vsync.h b/gralloc/src/gralloc_vsync.h new file mode 100644 index 0000000..6027eda --- /dev/null +++ b/gralloc/src/gralloc_vsync.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GRALLOC_VSYNC_H_ +#define _GRALLOC_VSYNC_H_ + +struct framebuffer_device_t; + +/* Enables vsync interrupt. */ +int gralloc_vsync_enable(struct framebuffer_device_t* dev); +/* Disables vsync interrupt. */ +int gralloc_vsync_disable(struct framebuffer_device_t* dev); +/* Waits for the vsync interrupt. */ +int gralloc_wait_for_vsync(struct framebuffer_device_t* dev); + +#endif /* _GRALLOC_VSYNC_H_ */ diff --git a/gralloc/src/gralloc_vsync_default.cpp b/gralloc/src/gralloc_vsync_default.cpp new file mode 100644 index 0000000..3297d05 --- /dev/null +++ b/gralloc/src/gralloc_vsync_default.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gralloc_priv.h" +#include "gralloc_vsync.h" +#include "gralloc_vsync_report.h" +#include <sys/ioctl.h> +#include <errno.h> + +#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32) + +int gralloc_vsync_enable(framebuffer_device_t *dev) +{ + return 0; +} + +int gralloc_vsync_disable(framebuffer_device_t *dev) +{ + return 0; +} + +int gralloc_wait_for_vsync(framebuffer_device_t *dev) +{ + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + if (MALI_DPY_TYPE_CLCD == m->dpy_type || MALI_DPY_TYPE_HDLCD == m->dpy_type) + { + /* Silently ignore wait for vsync as neither PL111 nor HDLCD implement this IOCTL. */ + return 0; + } + + if ( m->swapInterval ) + { + int crtc = 0; + gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT); + if(ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0) + { + gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT); + return -errno; + } + gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT); + } + return 0; +} diff --git a/gralloc/src/gralloc_vsync_report.h b/gralloc/src/gralloc_vsync_report.h new file mode 100644 index 0000000..9fd5015 --- /dev/null +++ b/gralloc/src/gralloc_vsync_report.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011 ARM Limited. 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_VSYNC_REPORT_H_ +#define GRALLOC_VSYNC_REPORT_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +typedef enum mali_vsync_event +{ + MALI_VSYNC_EVENT_BEGIN_WAIT = 0, + MALI_VSYNC_EVENT_END_WAIT +} mali_vsync_event; + +extern void _mali_base_arch_vsync_event_report(mali_vsync_event); + +inline void gralloc_mali_vsync_report(mali_vsync_event event) +{ + #ifdef MALI_VSYNC_EVENT_REPORT_ENABLE + _mali_base_arch_vsync_event_report(event); + #endif +} + +#ifdef __cplusplus +} +#endif +#endif /* GRALLOC_VSYNC_REPORT_H_ */ diff --git a/gralloc/src/gralloc_vsync_s3cfb.cpp b/gralloc/src/gralloc_vsync_s3cfb.cpp new file mode 100644 index 0000000..5740ea9 --- /dev/null +++ b/gralloc/src/gralloc_vsync_s3cfb.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2014 ARM Limited. All rights reserved. + * + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gralloc_priv.h" +#include "gralloc_vsync.h" +#include "gralloc_vsync_report.h" +#include <sys/ioctl.h> +#include <errno.h> + +#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32) +#define S3CFB_SET_VSYNC_INT _IOW('F', 206, unsigned int) + +int gralloc_vsync_enable(framebuffer_device_t *dev) +{ + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + int interrupt = 1; + if(ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0) return -errno; + return 0; +} + +int gralloc_vsync_disable(framebuffer_device_t *dev) +{ + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + int interrupt = 0; + if(ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0) return -errno; + return 0; +} + +int gralloc_wait_for_vsync(framebuffer_device_t *dev) +{ + private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); + if ( m->swapInterval ) + { + int crtc = 0; + gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT); + if(ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0) + { + gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT); + return -errno; + } + gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT); + } + return 0; +} diff --git a/howto/armv8-android-juno-lsk/HOWTO_getsourceandbuild.txt b/howto/armv8-android-juno-lsk/HOWTO_getsourceandbuild.txt new file mode 100644 index 0000000..21e533f --- /dev/null +++ b/howto/armv8-android-juno-lsk/HOWTO_getsourceandbuild.txt @@ -0,0 +1,69 @@ +Instructions for "https://android-build.linaro.org/builds/~linaro-android-restricted/armv8-android-juno-lsk/":https://android-build.linaro.org/builds/~linaro-android-restricted/armv8-android-juno-lsk/ + +h2. Prerequisites + +To clone the sources you must be able to ssh to git.linaro.org and be part of the big-little-switcher-private group. Contact "Philip Colmer" <philip.colmer@linaro.org> for access requests. + +Install build dependencies on Ubuntu: +<pre> + $ sudo add-apt-repository ppa:linaro-maintainers/tools + $ sudo apt-get update + $ sudo apt-get install gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc uboot-mkimage openjdk-7-jdk openjdk-7-jre vim-common python-parted python-yaml wget uuid-dev iasl +</pre> + +You can also download linaro android build script(linaro_android_build_cmds.sh) from Downloads section at https://android-build.linaro.org/builds/~linaro-android-restricted/armv8-android-juno-lsk to do a complete ARMv8 Android build from scratch. + +h2. Get the source + +<pre> + $ curl "https://android.git.linaro.org/gitweb/tools/repo.git/blob_plain/refs/heads/stable:/repo" >repo + $ chmod +x repo + $ ./repo init -u git://android.git.linaro.org/platform/manifest.git -b armv8-linaro -m baseline_manifest.xml + $ ./repo sync # this may take some time +</pre> + +h2. Build + +<pre> + $ export CPUS=`grep -c processor /proc/cpuinfo` + $ export TARGET_PRODUCT=juno + $ export TARGET_BUILD_VARIANT=eng + $ . build/envsetup.sh + $ make -j${CPUS} boottarball systemtarball userdatatarball +</pre> + +h2. Flash Linaro tarball images on USB drive + +Create MMC image first and dd it to the USB drive: + +Get linaro image tools. Run these commands to get all the dependencies for linaro-image-tools +<pre> + $ sudo add-apt-repository ppa:linaro-maintainers/tools + $ sudo apt-get update + $ sudo apt-get install linaro-image-tools +</pre> +If you're using a "tip" build then we suggest you use the tip of linaro-image-tools from http://git.linaro.org/infrastructure/linaro-image-tools.git + +Create mmc image: + +pre. $ linaro-android-media-create --image_file mmc.img --image_size 2000M --dev vexpress --system system.tar.bz2 --userdata userdata.tar.bz2 --boot boot.tar.bz2 + +If you're using tip of linaro image tools + +pre. $ ./linaro-image-tools/linaro-android-media-create --image_file mmc.img --image_size 2000M --dev vexpress --system system.tar.bz2 --userdata userdata.tar.bz2 --boot boot.tar.bz2 + +Flash the mmc.img to USB drive: + +pre. $ dd if=mmc.img of=/dev/sda(?) bs=4096 conv=notrunc,noerror + +h2. Configure Juno boot time UEFI configuration + +Stop at UEFI prompt and change few parameters shown below + +<pre> +Change kernel in UEFI to "kernel" in the boot partition +Change ramdisk in UEFI to "ramdisk.img" in the boot partition +Change bootargs to "console=ttyAMA0,115200 earlyprintk=pl011,0x7ff80000" +</pre> + +It should get your Juno board up and running. diff --git a/howto/armv8-android-juno-lsk/HOWTO_install.txt b/howto/armv8-android-juno-lsk/HOWTO_install.txt new file mode 100644 index 0000000..4bf0154 --- /dev/null +++ b/howto/armv8-android-juno-lsk/HOWTO_install.txt @@ -0,0 +1,48 @@ +Instructions for "https://android-build.linaro.org/builds/~linaro-android-restricted/armv8-android-juno-lsk/":https://android-build.linaro.org/builds/~linaro-android-restricted/armv8-android-juno-lsk/ + +h2. Prerequisites + +h3. Get artifacts + +To get the build artifacts you must be part of the linaro-android-restricted launchpad group. Contact "Philip Colmer" <philip.colmer@linaro.org> for access requests. + +h3. Run the build + +You'll need the latest ARM FVP Base models and a license to use the models. Follow the instructions at https://collaborate.linaro.org/display/ITS/FlexLM+and+Fast+Models for the same. + +h2. Get artifacts + +Scroll down and click on 'Downloads' + +Click on each link to download: +* boot.tar.bz2 +* system.tar.bz2 +* userdata.tar.bz2 + +h2. Flash Linaro tarball images on USB drive + +Create MMC image first and dd it to the USB drive: + +Get linaro image tools. Run these commands to get all the dependencies for linaro-image-tools +<pre> + $ sudo add-apt-repository ppa:linaro-maintainers/tools + $ sudo apt-get update + $ sudo apt-get install linaro-image-tools +</pre> +If you're using a "tip" build then we suggest you use the tip of linaro-image-tools from http://git.linaro.org/infrastructure/linaro-image-tools.git + +Create mmc image: + +pre. $ linaro-android-media-create --image_file mmc.img --image_size 2000M --dev vexpress --system system.tar.bz2 --userdata userdata.tar.bz2 --boot boot.tar.bz2 + +If you're using tip of linaro image tools + +pre. $ ./linaro-image-tools/linaro-android-media-create --image_file mmc.img --image_size 2000M --dev vexpress --system system.tar.bz2 --userdata userdata.tar.bz2 --boot boot.tar.bz2 + +Flash the mmc.img to USB drive: + +pre. $ dd if=mmc.img of=/dev/sda(?) bs=4096 conv=notrunc,noerror + +h2. Configure Juno boot time UEFI configuration + +Stop at UEFI prompt and select the Shell item, it will boot up directly for you. diff --git a/howto/armv8-android-juno-lsk/HOWTO_prebuilt.txt b/howto/armv8-android-juno-lsk/HOWTO_prebuilt.txt new file mode 100644 index 0000000..f699a3e --- /dev/null +++ b/howto/armv8-android-juno-lsk/HOWTO_prebuilt.txt @@ -0,0 +1,69 @@ +Instructions for https://android-build.linaro.org/builds/~linaro-android/<BUILD_NAME>/ + += Get artifacts = + + Scroll down to the 'Downloads' section + + Click on each link to download: + boot.tar.bz2 + system.tar.bz2 + userdata.tar.bz2 + += Get linaro image tools = + + Run these commands to get all the dependencies for linaro-image-tools and the tip of linaro-image-tools + + $ sudo add-apt-repository ppa:linaro-maintainers/tools + $ sudo apt-get update + $ sudo apt-get install linaro-image-tools + + If you're using a released build (with a -release or from releases.linaro.org), skip this step. + If you're using a "tip" build do not skip the step and do the following: + + $ sudo apt-get install bzr + $ bzr branch lp:linaro-image-tools + += Create media (SD card) = + + Disable automount (instructions provided for Gnome) + + $ TMP1=$(dconf read /org/gnome/desktop/media-handling/automount) + $ TMP2=$(dconf read /org/gnome/desktop/media-handling/automount-open) + $ dconf write /org/gnome/desktop/media-handling/automount false + $ dconf write /org/gnome/desktop/media-handling/automount-open false + + Insert an SD card + + Run 'dmesg' + + $ dmesg + + Look for a line that looks like the following at the end of the log + + [288582.790722] sdc: sdc1 sdc2 sdc3 sdc4 < sdc5 sdc6 > + + WARNING: In the next step, make sure you use /dev/"whatever you see above". + You can erase your hard drive with the wrong parameter. + + Run linaro image tools + + $ linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 + + If you're using tip of linaro image tools + + $ ./linaro-image-tools/linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 + + To find <BOARD> run linaro-android-media-create with a -h and read the help. + + Restore automount + + $ dconf write /org/gnome/desktop/media-handling/automount $TMP1 + $ dconf write /org/gnome/desktop/media-handling/automount-open $TMP2 + + Remove the SD card from the device writer and plug it into the board. + += Check console output = + + Plug in an USB-to-serial converter and run minicom + + $ minicom -D /dev/ttyUSB0 -w -C minicom.txt diff --git a/howto/armv8-android-juno-lsk/OPEN-EULA.txt b/howto/armv8-android-juno-lsk/OPEN-EULA.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/howto/armv8-android-juno-lsk/OPEN-EULA.txt diff --git a/howto/default/HOWTO_getsourceandbuild.txt b/howto/default/HOWTO_getsourceandbuild.txt new file mode 100644 index 0000000..28d20bd --- /dev/null +++ b/howto/default/HOWTO_getsourceandbuild.txt @@ -0,0 +1,91 @@ +Instructions for "https://android-build.linaro.org/builds/~linaro-android/<BUILD_NAME>/":https://android-build.linaro.org/builds/~linaro-android/<BUILD_NAME>/ + +h2. Get artifacts + +Scroll down to the 'Downloads' section + +Save linaro_android_build_cmds.sh to where you'd like to make your build. + +h2. Run the build script + +The linaro_android_build_cmds.sh script will download the source and create the build. + +<pre> + $ chmod +x linaro_android_build_cmds.sh + $ ./linaro_android_build_cmds.sh -h #To print the script usage +</pre> + +Most commonly used build options: + +<pre> + $ ./linaro_android_build_cmds.sh -t #To build from the tip of the branch without overlay + $ ./linaro_android_build_cmds.sh -t -o <overlay> #To build from the tip of the branch with provided overlay + $ ./linaro_android_build_cmds.sh -m <pinned_manifest> -o <overlay> #To reproduce an exact build from pinned manifest + $ ./linaro_android_build_cmds.sh -t -l <login-id> #Provide login/access ID to clone and build code from linaro-private repositories +</pre> + +h2. Get linaro image tools + +Run these commands to get all the dependencies for linaro-image-tools and the tip of linaro-image-tools + +<pre> + $ sudo add-apt-repository ppa:linaro-maintainers/tools + $ sudo apt-get update + $ sudo apt-get install linaro-image-tools +</pre> + + If you're using a released build (with a -release or from releases.linaro.org), skip this step. + If you're using a "tip" build do not skip the step and do the following: + + $ sudo apt-get install bzr + $ bzr branch lp:linaro-image-tools + +h2. Create media (SD card) + +Disable automount (instructions provided for Gnome) + +<pre> + $ TMP1=$(dconf read /org/gnome/desktop/media-handling/automount) + $ TMP2=$(dconf read /org/gnome/desktop/media-handling/automount-open) + $ dconf write /org/gnome/desktop/media-handling/automount false + $ dconf write /org/gnome/desktop/media-handling/automount-open false +</pre> + +Insert an SD card + +Run 'dmesg' + +pre. $ dmesg + +Look for a line that looks like the following at the end of the log + +pre. [288582.790722] sdc: sdc1 sdc2 sdc3 sdc4 < sdc5 sdc6 > + +*WARNING* In the next step, make sure you use /dev/"whatever you see above". +You can erase your hard drive with the wrong parameter. + +Run linaro image tools + +pre. $ linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot out/target/product/<BOARD>/boot.tar.bz2 --system out/target/product/<BOARD>/system.tar.bz2 --userdata out/target/product/<BOARD>/userdata.tar.bz2 + +If you're using tip of linaro image tools + +pre. $ ./linaro-image-tools/linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot out/target/product/<BOARD>/boot.tar.bz2 --system out/target/product/<BOARD>/system.tar.bz2 --userdata +out/target/product/<BOARD>/userdata.tar.bz2 + +Restore automount + +<pre> + $ dconf write /org/gnome/desktop/media-handling/automount $TMP1 + $ dconf write /org/gnome/desktop/media-handling/automount-open $TMP2 +</pre> + +Remove the SD card from the device writer and plug it into the board. + +h2. Check console output + +Plug in an USB-to-serial converter and run minicom + +pre. $ minicom -D /dev/ttyUSB0 -w -C minicom.txt + + diff --git a/howto/default/HOWTO_install.txt b/howto/default/HOWTO_install.txt new file mode 100644 index 0000000..a8017a2 --- /dev/null +++ b/howto/default/HOWTO_install.txt @@ -0,0 +1,77 @@ +Instructions for "https://android-build.linaro.org/builds/~linaro-android/<BUILD_NAME>/":https://android-build.linaro.org/builds/~linaro-android/<BUILD_NAME>/ + +h2. Get artifacts + +Scroll down to the 'Downloads' section + +Click on each link to download: +* boot.tar.bz2 +* system.tar.bz2 +* userdata.tar.bz2 + +h2. Get linaro image tools + +Run these commands to get all the dependencies for linaro-image-tools and the tip of linaro-image-tools + +<pre> + $ sudo add-apt-repository ppa:linaro-maintainers/tools + $ sudo apt-get update + $ sudo apt-get install linaro-image-tools +</pre> + +If you're using a released build (with a -release or from releases.linaro.org), skip this step. +If you're using a "tip" build do not skip the step and do the following: + +<pre> + $ sudo apt-get install bzr + $ bzr branch lp:linaro-image-tools +</pre> + +h2. Create media (SD card) + +Disable automount (instructions provided for Gnome) + +<pre> + $ TMP1=$(dconf read /org/gnome/desktop/media-handling/automount) + $ TMP2=$(dconf read /org/gnome/desktop/media-handling/automount-open) + $ dconf write /org/gnome/desktop/media-handling/automount false + $ dconf write /org/gnome/desktop/media-handling/automount-open false +</pre> + +Insert an SD card + +Run 'dmesg' + +pre. $ dmesg + +Look for a line that looks like the following at the end of the log + +pre. [288582.790722] sdc: sdc1 sdc2 sdc3 sdc4 < sdc5 sdc6 > + +*WARNING* In the next step, make sure you use /dev/"whatever you see above". +You can erase your hard drive with the wrong parameter. + +Run linaro image tools + +pre. $ linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 + +If you're using tip of linaro image tools + +pre. $ ./linaro-image-tools/linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 + +To find <BOARD> run linaro-android-media-create with a -h and read the help. + +Restore automount + +<pre> + $ dconf write /org/gnome/desktop/media-handling/automount $TMP1 + $ dconf write /org/gnome/desktop/media-handling/automount-open $TMP2 +</pre> + +Remove the SD card from the device writer and plug it into the board. + +h2. Check console output + +Plug in an USB-to-serial converter and run minicom + +pre. $ minicom -D /dev/ttyUSB0 -w -C minicom.txt diff --git a/howto/default/HOWTO_prebuilt.txt b/howto/default/HOWTO_prebuilt.txt new file mode 100644 index 0000000..f699a3e --- /dev/null +++ b/howto/default/HOWTO_prebuilt.txt @@ -0,0 +1,69 @@ +Instructions for https://android-build.linaro.org/builds/~linaro-android/<BUILD_NAME>/ + += Get artifacts = + + Scroll down to the 'Downloads' section + + Click on each link to download: + boot.tar.bz2 + system.tar.bz2 + userdata.tar.bz2 + += Get linaro image tools = + + Run these commands to get all the dependencies for linaro-image-tools and the tip of linaro-image-tools + + $ sudo add-apt-repository ppa:linaro-maintainers/tools + $ sudo apt-get update + $ sudo apt-get install linaro-image-tools + + If you're using a released build (with a -release or from releases.linaro.org), skip this step. + If you're using a "tip" build do not skip the step and do the following: + + $ sudo apt-get install bzr + $ bzr branch lp:linaro-image-tools + += Create media (SD card) = + + Disable automount (instructions provided for Gnome) + + $ TMP1=$(dconf read /org/gnome/desktop/media-handling/automount) + $ TMP2=$(dconf read /org/gnome/desktop/media-handling/automount-open) + $ dconf write /org/gnome/desktop/media-handling/automount false + $ dconf write /org/gnome/desktop/media-handling/automount-open false + + Insert an SD card + + Run 'dmesg' + + $ dmesg + + Look for a line that looks like the following at the end of the log + + [288582.790722] sdc: sdc1 sdc2 sdc3 sdc4 < sdc5 sdc6 > + + WARNING: In the next step, make sure you use /dev/"whatever you see above". + You can erase your hard drive with the wrong parameter. + + Run linaro image tools + + $ linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 + + If you're using tip of linaro image tools + + $ ./linaro-image-tools/linaro-android-media-create --mmc /dev/sdc --dev <BOARD> --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 + + To find <BOARD> run linaro-android-media-create with a -h and read the help. + + Restore automount + + $ dconf write /org/gnome/desktop/media-handling/automount $TMP1 + $ dconf write /org/gnome/desktop/media-handling/automount-open $TMP2 + + Remove the SD card from the device writer and plug it into the board. + += Check console output = + + Plug in an USB-to-serial converter and run minicom + + $ minicom -D /dev/ttyUSB0 -w -C minicom.txt diff --git a/hwclock/Android.mk b/hwclock/Android.mk new file mode 100644 index 0000000..6465e69 --- /dev/null +++ b/hwclock/Android.mk @@ -0,0 +1,8 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := hwclock32 + +LOCAL_SRC_FILES := hwclock.c + +include $(BUILD_EXECUTABLE) diff --git a/hwclock/hwclock.c b/hwclock/hwclock.c new file mode 100644 index 0000000..3d374e3 --- /dev/null +++ b/hwclock/hwclock.c @@ -0,0 +1,62 @@ +#include <string.h> +#include <unistd.h> +#include <sys/time.h> +#include <time.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <sys/ioctl.h> +#include <stdlib.h> +#include <errno.h> +#include <linux/rtc.h> + +/* + * This is meant to synchronise the system clock with the RTC at + * startup. If you know a better way of doing this in Android, + * drop me an email at kevin.petit@arm.com + */ + +static time_t read_rtc(void) +{ + struct tm tm_time; + int fd; + + fd = open("/dev/rtc0", O_RDONLY); + printf("Got fd = %d for RTC\n", fd); + + /* Read time from the RTC */ + memset(&tm_time, 0, sizeof(tm_time)); + if (ioctl(fd, RTC_RD_TIME, &tm_time)) { + fprintf(stderr, "error while doing RTC_RD_TIME: %s\n", strerror(errno)); + } + tm_time.tm_isdst = -1; /* "not known" */ + + printf("TIME FROM RTC: %s\n", asctime(&tm_time)); + + close(fd); + + return mktime(&tm_time); +} + +static void rtc_to_sys_clock(void) +{ + struct timeval tv; + uint64_t timelog; + + tv.tv_sec = read_rtc(); + timelog = tv.tv_sec; + printf("Got tv.tv_sec = %llu\n", timelog); + tv.tv_usec = 0; + if (settimeofday(&tv, NULL)) + fprintf(stderr, "settimeofday failed: %s\n", strerror(errno)); +} + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + rtc_to_sys_clock(); + return 0; +} + diff --git a/init.juno.rc b/init.juno.rc new file mode 100644 index 0000000..ce0f35d --- /dev/null +++ b/init.juno.rc @@ -0,0 +1,102 @@ +on init + # mount debugfs + mount debugfs /sys/kernel/debug /sys/kernel/debug + +on init + # disable transparent huge pages + write /sys/kernel/mm/transparent_hugepage/enabled "never" + + # See storage config details at http://source.android.com/tech/storage/ + mkdir /mnt/shell/emulated 0700 shell shell + mkdir /storage/emulated 0555 root root + export EXTERNAL_STORAGE /storage/emulated/legacy + export EMULATED_STORAGE_SOURCE /mnt/shell/emulated + export EMULATED_STORAGE_TARGET /storage/emulated + # Support legacy paths + symlink /storage/emulated/legacy /sdcard + symlink /storage/emulated/legacy /mnt/sdcard + symlink /storage/emulated/legacy /storage/sdcard0 + symlink /mnt/shell/emulated/0 /storage/emulated/legacy + + # Disabled virtual memory randomization + # (if randomization is enabled the AEM-JIT will have a lower cache hit rate) + write /proc/sys/kernel/randomize_va_space 0 + +on fs + mount_all /fstab.juno + setprop ro.crypto.fuse_sdcard true + +on post-fs-data + mkdir /data/media 0770 media_rw media_rw + mkdir /data/misc/gatord 0700 root root + + # Set SELinux security contexts for files used by lava. + restorecon_recursive /data/local/tmp/lava + +on post-fs + # insert gator kernel module for DS-5/Streamline + insmod /system/modules/gator.ko + + chmod 0666 /dev/ump + chmod 0666 /dev/ion + chmod 0666 /dev/mali0 + chmod 0666 /dev/graphics/fb0 + +on boot + + setprop ARGH ARGH + setprop ro.radio.use-ppp no + setprop ro.build.product generic + setprop ro.product.device generic + +# fake some battery state + setprop status.battery.state Slow + setprop status.battery.level 5 + setprop status.battery.level_raw 50 + setprop status.battery.level_scale 9 + +# Set Display density + setprop ro.sf.lcd_density 160 + +# Set supported opengles version + setprop ro.opengles.version 196608 + +# change permissions for process groups +# https://bugs.launchpad.net/bugs/1037611 + chmod 0660 /dev/cpuctl + +# enable Google-specific location features, +# like NetworkLocationProvider and LocationCollector + setprop ro.com.google.locationfeatures 1 + +# enable test harness + setprop ro.test_harness true + + # Setup paths used for socket communication with the dhcp daemon (dhcpd) + mkdir /data/misc/dhcp 0770 dhcp dhcp + chown dhcp dhcp /data/misc/dhcp + +service dhcpcd_eth0 /system/bin/dhcpcd -aABDKL + class main + group dhcp + oneshot + +service iprenew_eth0 /system/bin/dhcpcd -n + class late_start + disabled + oneshot + +service clock-init /system/bin/hwclock32 + class main + user root + group root + oneshot + +service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated + class late_start + +service gatord /system/bin/gatord -c /data/misc/gatord/configuration.xml + class main + user root + oneshot + seclabel u:r:gatord:s0 @@ -0,0 +1,113 @@ +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Generic key layout file for full alphabetic US English PC style external keyboards. +# +# This file is intentionally very generic and is intended to support a broad rang of keyboards. +# Do not edit the generic key layout to support a specific keyboard; instead, create +# a new key layout file with the required keyboard configuration. +# + +key 399 GRAVE +key 1 BACK +key 2 1 +key 3 2 +key 4 3 +key 5 4 +key 6 5 +key 7 6 +key 8 7 +key 9 8 +key 10 9 +key 11 0 +key 158 BACK WAKE_DROPPED +key 230 SOFT_RIGHT WAKE +key 60 SOFT_RIGHT WAKE +key 107 ENDCALL WAKE_DROPPED +key 62 ENDCALL WAKE_DROPPED +key 229 MENU WAKE_DROPPED +key 139 MENU WAKE_DROPPED +key 59 MENU WAKE_DROPPED +key 127 SEARCH WAKE_DROPPED +key 217 SEARCH WAKE_DROPPED +key 228 POUND +key 227 STAR +key 231 CALL WAKE_DROPPED +key 61 CALL WAKE_DROPPED +key 232 DPAD_CENTER WAKE_DROPPED +key 108 DPAD_DOWN WAKE_DROPPED +key 103 DPAD_UP WAKE_DROPPED +key 102 HOME WAKE +key 105 DPAD_LEFT WAKE_DROPPED +key 106 DPAD_RIGHT WAKE_DROPPED +key 115 VOLUME_UP +key 114 VOLUME_DOWN +key 116 POWER WAKE +key 212 CAMERA + +key 16 Q +key 17 W +key 18 E +key 19 R +key 20 T +key 21 Y +key 22 U +key 23 I +key 24 O +key 25 P +key 26 LEFT_BRACKET +key 27 RIGHT_BRACKET +key 43 BACKSLASH + +key 30 A +key 31 S +key 32 D +key 33 F +key 34 G +key 35 H +key 36 J +key 37 K +key 38 L +key 39 SEMICOLON +key 40 APOSTROPHE +key 14 DEL + +key 44 Z +key 45 X +key 46 C +key 47 V +key 48 B +key 49 N +key 50 M +key 51 COMMA +key 52 PERIOD +key 53 SLASH +key 28 ENTER + +key 56 ALT_LEFT +key 100 ALT_RIGHT +key 42 SHIFT_LEFT +key 54 SHIFT_RIGHT +key 15 TAB +key 57 SPACE +key 150 EXPLORER +key 155 ENVELOPE + +key 12 MINUS +key 13 EQUALS +key 215 AT + + +key 82 MENU WAKE diff --git a/juno32.mk b/juno32.mk new file mode 100644 index 0000000..de87211 --- /dev/null +++ b/juno32.mk @@ -0,0 +1,9 @@ +# +# Inherit the full_base and device configurations +$(call inherit-product, device/linaro/juno32/device.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk) + +# +# Overrides +PRODUCT_NAME := juno32 +PRODUCT_DEVICE := juno32 diff --git a/juno_monkey_blacklist b/juno_monkey_blacklist new file mode 100644 index 0000000..f629af4 --- /dev/null +++ b/juno_monkey_blacklist @@ -0,0 +1,5 @@ +com.android.bluetooth +com.android.cts.opengl +com.android.development +com.android.quicksearchbox +com.android.speechrecorder diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml new file mode 100644 index 0000000..029bdec --- /dev/null +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2011, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- These resources are around just to allow their values to be customized + for different hardware and product builds. --> +<resources> + + <!-- This device is not "voice capable"; it's data-only. --> + <bool name="config_voice_capable">false</bool> + + <!-- This device does not allow sms service. --> + <bool name="config_sms_capable">false</bool> + + <!-- Separate software navigation bar required on this device. --> + <bool name="config_showNavigationBar">true</bool> + + <!-- XXXXX NOTE THE FOLLOWING RESOURCES USE THE WRONG NAMING CONVENTION. + Please don't copy them, copy anything else. --> + + <!-- the 5th element "resore-time" indicates the number of milliseconds to delay + before automatically restore the default connection. Set -1 if the connection + does not require auto-restore. --> + <!-- the 6th element indicates boot-time dependency-met value. --> + <string-array translatable="false" name="networkAttributes"> + <item>"wifi,1,1,1,-1,true"</item> + <item>"wifi_p2p,13,1,0,-1,true"</item> + <item>"ethernet,9,9,2,-1,true"</item> + </string-array> + + <!-- This string array should be overridden by the device to present a list of radio + attributes. This is used by the connectivity manager to decide which networks can coexist + based on the hardware --> + <!-- An Array of "[ConnectivityManager connectionType], + [# simultaneous connection types]" --> + <string-array translatable="false" name="radioAttributes"> + <item>"1,1"</item> + <item>"9,1"</item> + </string-array> + + +</resources> diff --git a/overlay/frameworks/base/core/res/res/xml/storage_list.xml b/overlay/frameworks/base/core/res/res/xml/storage_list.xml new file mode 100644 index 0000000..b80fa97 --- /dev/null +++ b/overlay/frameworks/base/core/res/res/xml/storage_list.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2011, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License") +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- The <device> element should contain one or more <storage> elements. + Exactly one of these should have the attribute primary="true". + This storage will be the primary external storage and should have path="/mnt/sdcard". + Each storage should have both a path and description attribute set. + The following boolean attributes are optional: + + primary: this storage is the primary external storage + removable: this is removable storage (for example, a real SD card) + emulated: the storage is emulated via the FUSE sdcard daemon + mtp-reserve: number of megabytes of storage MTP should reserve for free storage + (used for emulated storage that is shared with system's data partition) + + A storage should not have both emulated and removable set to true +--> + +<StorageList xmlns:android="http://schemas.android.com/apk/res/android"> +<storage + android:mountPoint="/storage/sdcard0" + android:storageDescription="@string/storage_internal" + android:primary="true" + android:emulated="true" + android:mtpReserve="100" /> +</StorageList> diff --git a/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml new file mode 100644 index 0000000..34d5433 --- /dev/null +++ b/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <integer name="def_screen_off_timeout">-1</integer> + <bool name="def_lockscreen_disabled">true</bool> + <bool name="def_stay_on_while_plugged_in">true</bool> +</resources> diff --git a/preboot/bl1.bin b/preboot/bl1.bin Binary files differnew file mode 100644 index 0000000..dfd197c --- /dev/null +++ b/preboot/bl1.bin diff --git a/preboot/fip.bin b/preboot/fip.bin Binary files differnew file mode 100644 index 0000000..3511e01 --- /dev/null +++ b/preboot/fip.bin diff --git a/preboot/readme.txt b/preboot/readme.txt new file mode 100644 index 0000000..07a5c33 --- /dev/null +++ b/preboot/readme.txt @@ -0,0 +1 @@ +Board firmware v0.10.1 preboot binaries diff --git a/preboot/startup.nsh b/preboot/startup.nsh new file mode 100644 index 0000000..7114b8c --- /dev/null +++ b/preboot/startup.nsh @@ -0,0 +1 @@ +kernel dtb=juno.dtb initrd=ramdisk.img console=ttyAMA0,115200 earlyprintk=pl011,0x7ff80000 verbose debug diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts new file mode 100644 index 0000000..1393bc1 --- /dev/null +++ b/sepolicy/file_contexts @@ -0,0 +1,2 @@ +/dev/mali0 u:object_r:gpu_device:s0 +/dev/ump u:object_r:gpu_device:s0 diff --git a/system.prop b/system.prop new file mode 100644 index 0000000..70c0009 --- /dev/null +++ b/system.prop @@ -0,0 +1,4 @@ +# This overrides settings in the products/generic/system.prop file +# +# rild.libpath=/system/lib/libreference-ril.so +# rild.libargs=-d /dev/ttyS0 diff --git a/vendorsetup.sh b/vendorsetup.sh new file mode 100755 index 0000000..6fb19c6 --- /dev/null +++ b/vendorsetup.sh @@ -0,0 +1,25 @@ +# +# Copyright (C) 2013 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This file is executed by build/envsetup.sh, and can use anything +# defined in envsetup.sh. +# +# In particular, you can add lunch options with the add_lunch_combo +# function: add_lunch_combo generic-eng + +add_lunch_combo juno32-user +add_lunch_combo juno32-userdebug +add_lunch_combo juno32-eng |