summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Pundir <amit.pundir@linaro.org>2019-09-27 13:08:24 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-09-27 13:08:24 -0700
commit49b98bfff956c30ae30bb640df08fac8aa9b1e3e (patch)
treeb86f9698ea06f9d11ead04057b845427798ad0cd
parentb7005515dd7ac2faebc6000b36075c116fdeacfa (diff)
parent9e210325b9cc6674a3ed53c15a99fdfda2f2abb4 (diff)
db845c: Add support for AOSP on dragonboard db845c am: 4e37582f32 am: d14fd11389
am: 9e210325b9 Change-Id: I471563e7870bcdf23a60cabd77ce80d5b93e6fc8
-rw-r--r--Android.mk31
-rw-r--r--AndroidProducts.mk16
-rw-r--r--BoardConfigCommon.mk80
-rw-r--r--audio/Android.mk41
-rw-r--r--audio/audio_hw.c691
-rw-r--r--common.kl113
-rw-r--r--compatibility_matrix.xml59
-rw-r--r--db845c.mk10
-rw-r--r--db845c/BoardConfig.mk14
-rw-r--r--db845c/device.mk29
-rw-r--r--device-common.mk169
-rw-r--r--etc/audio_policy_configuration.xml105
-rw-r--r--etc/audio_policy_configuration_bluetooth_legacy_hal.xml108
-rw-r--r--etc/media_codecs.xml81
-rw-r--r--fstab.common6
-rw-r--r--fstab.ramdisk.common3
-rw-r--r--gralloc/Android.mk57
-rw-r--r--gralloc/gralloc.cpp259
-rw-r--r--gralloc/gralloc_drm.h42
-rw-r--r--gralloc/gralloc_gbm.cpp475
-rw-r--r--gralloc/gralloc_gbm_priv.h55
-rw-r--r--init.common.rc57
-rw-r--r--init.common.usb.rc88
-rw-r--r--libmemtrack/Android.mk29
-rw-r--r--libmemtrack/memtrack_dragonboard.c45
-rw-r--r--manifest.xml136
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml89
-rw-r--r--overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml6
-rw-r--r--p2p_supplicant_overlay.conf1
-rw-r--r--sepolicy/app.te4
-rw-r--r--sepolicy/bootanim.te1
-rw-r--r--sepolicy/crash_dump.te7
-rw-r--r--sepolicy/dnsmasq.te3
-rw-r--r--sepolicy/file.te2
-rw-r--r--sepolicy/file_contexts17
-rw-r--r--sepolicy/genfs_contexts3
-rw-r--r--sepolicy/hal_drm_default.te2
-rw-r--r--sepolicy/hal_graphics_allocator_default.te1
-rw-r--r--sepolicy/hal_graphics_composer.te1
-rw-r--r--sepolicy/hal_graphics_composer_default.te3
-rw-r--r--sepolicy/hal_memtrack.te4
-rw-r--r--sepolicy/hal_wifi_supplicant_default.te6
-rw-r--r--sepolicy/kernel.te5
-rw-r--r--sepolicy/netd.te3
-rw-r--r--sepolicy/platform_app.te1
-rw-r--r--sepolicy/priv_app.te1
-rw-r--r--sepolicy/surfaceflinger.te1
-rw-r--r--sepolicy/system_app.te1
-rw-r--r--sepolicy/system_server.te1
-rw-r--r--sepolicy/te_macros8
-rw-r--r--ueventd.common.rc8
-rw-r--r--wpa_supplicant_overlay.conf3
52 files changed, 2981 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..7daa334
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2015 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.
+#
+
+# WARNING: Everything listed here will be built on ALL platforms,
+# including x86, the emulator, and the SDK. Modules must be uniquely
+# named (liblights.panda), and must build everywhere, or limit themselves
+# to only building on ARM if they include assembly. Individual makefiles
+# are responsible for having their own logic, for fine-grained control.
+
+ifneq ($(filter db845c, $(TARGET_BOARD_PLATFORM)),)
+
+LOCAL_PATH := $(call my-dir)
+
+# If some modules are built directly from this directory (not subdirectories),
+# their rules should be written here.
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+endif
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
new file mode 100644
index 0000000..dba29d4
--- /dev/null
+++ b/AndroidProducts.mk
@@ -0,0 +1,16 @@
+#
+# 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)/db845c.mk
+
+COMMON_LUNCH_CHOICES := \
+ db845c-userdebug
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
new file mode 100644
index 0000000..11ffba8
--- /dev/null
+++ b/BoardConfigCommon.mk
@@ -0,0 +1,80 @@
+# 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.
+#
+
+# Primary Arch
+TARGET_ARCH := arm64
+TARGET_ARCH_VARIANT := armv8-2a
+TARGET_CPU_VARIANT := kryo385
+TARGET_CPU_ABI := arm64-v8a
+
+# Secondary Arch
+TARGET_2ND_ARCH := arm
+TARGET_2ND_ARCH_VARIANT := armv8-2a
+TARGET_2ND_CPU_VARIANT := kryo385
+TARGET_2ND_CPU_ABI := armeabi-v7a
+TARGET_2ND_CPU_ABI2 := armeabi
+
+TARGET_USES_64_BIT_BINDER := true
+
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+TARGET_NO_RECOVERY := true
+
+BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE := ext4
+TARGET_USERIMAGES_USE_EXT4 := true
+TARGET_COPY_OUT_VENDOR := vendor
+BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
+TARGET_COPY_OUT_SYSTEM_EXT := system_ext
+BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_USES_METADATA_PARTITION := true
+# Super partition
+TARGET_USE_DYNAMIC_PARTITIONS := true
+BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT := true
+BOARD_SUPER_PARTITION_GROUPS := db_dynamic_partitions
+BOARD_DB_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor system_ext
+
+# Enable Treble
+PRODUCT_FULL_TREBLE := true
+BOARD_VNDK_VERSION := current
+
+# Mesa DRM hwcomposer
+BOARD_USES_DRM_HWCOMPOSER := true
+BOARD_GPU_DRIVERS := freedreno virgl
+TARGET_USES_HWC2 := true
+
+# WiFi
+WPA_SUPPLICANT_VERSION := VER_0_8_X
+BOARD_WPA_SUPPLICANT_DRIVER := NL80211
+BOARD_HOSTAPD_DRIVER := NL80211
+BOARD_WLAN_DEVICE := qcwcn
+BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
+
+# BT
+BOARD_HAVE_BLUETOOTH := true
+
+BOARD_SEPOLICY_DIRS += \
+ device/linaro/dragonboard/sepolicy \
+ system/bt/vendor_libs/linux/sepolicy
+
+DEVICE_MANIFEST_FILE := device/linaro/dragonboard/manifest.xml
+DEVICE_MATRIX_FILE := device/linaro/dragonboard/compatibility_matrix.xml
+
+# Enable dex pre-opt to speed up initial boot
+ifeq ($(HOST_OS),linux)
+ ifeq ($(WITH_DEXPREOPT),)
+ WITH_DEXPREOPT := true
+ WITH_DEXPREOPT_PIC := true
+ endif
+endif
diff --git a/audio/Android.mk b/audio/Android.mk
new file mode 100644
index 0000000..afa804f
--- /dev/null
+++ b/audio/Android.mk
@@ -0,0 +1,41 @@
+# Copyright (C) 2016 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)
+
+# The default audio HAL module, which is a stub, that is loaded if no other
+# device specific modules are present. The exact load order can be seen in
+# libhardware/hardware.c
+#
+# The format of the name is audio.<type>.<hardware/etc>.so where the only
+# required type is 'primary'. Other possibilites are 'a2dp', 'usb', etc.
+include $(CLEAR_VARS)
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
+LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/hw
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/hw
+LOCAL_VENDOR_MODULE := true
+
+LOCAL_SRC_FILES := audio_hw.c
+LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_C_INCLUDES += \
+ external/tinyalsa/include \
+ external/expat/lib \
+ system/media/audio_utils/include \
+ system/media/audio_effects/include
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
new file mode 100644
index 0000000..d601ea8
--- /dev/null
+++ b/audio/audio_hw.c
@@ -0,0 +1,691 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#define LOG_TAG "audio_hw_dragonboard"
+//#define LOG_NDEBUG 0
+
+#include <errno.h>
+#include <malloc.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <log/log.h>
+#include <cutils/str_parms.h>
+#include <cutils/properties.h>
+
+#include <hardware/hardware.h>
+#include <system/audio.h>
+#include <hardware/audio.h>
+
+#include <sound/asound.h>
+#include <tinyalsa/asoundlib.h>
+#include <audio_utils/resampler.h>
+#include <audio_utils/echo_reference.h>
+#include <hardware/audio_effect.h>
+#include <hardware/audio_alsaops.h>
+#include <audio_effects/effect_aec.h>
+
+
+#define CARD_OUT 0
+#define PORT_CODEC 0
+/* Minimum granularity - Arbitrary but small value */
+#define CODEC_BASE_FRAME_COUNT 32
+
+/* number of base blocks in a short period (low latency) */
+#define PERIOD_MULTIPLIER 32 /* 21 ms */
+/* number of frames per short period (low latency) */
+#define PERIOD_SIZE (CODEC_BASE_FRAME_COUNT * PERIOD_MULTIPLIER)
+/* number of pseudo periods for low latency playback */
+#define PLAYBACK_PERIOD_COUNT 2
+#define PLAYBACK_PERIOD_START_THRESHOLD 2
+#define CODEC_SAMPLING_RATE 48000
+#define CHANNEL_STEREO 2
+#define MIN_WRITE_SLEEP_US 5000
+
+struct stub_stream_in {
+ struct audio_stream_in stream;
+};
+
+struct alsa_audio_device {
+ struct audio_hw_device hw_device;
+
+ pthread_mutex_t lock; /* see note below on mutex acquisition order */
+ int devices;
+ struct alsa_stream_in *active_input;
+ struct alsa_stream_out *active_output;
+ bool mic_mute;
+};
+
+struct alsa_stream_out {
+ struct audio_stream_out stream;
+
+ pthread_mutex_t lock; /* see note below on mutex acquisition order */
+ struct pcm_config config;
+ struct pcm *pcm;
+ bool unavailable;
+ int standby;
+ struct alsa_audio_device *dev;
+ int write_threshold;
+ unsigned int written;
+};
+
+
+/* must be called with hw device and output stream mutexes locked */
+static int start_output_stream(struct alsa_stream_out *out)
+{
+ struct alsa_audio_device *adev = out->dev;
+
+ if (out->unavailable)
+ return -ENODEV;
+
+ /* default to low power: will be corrected in out_write if necessary before first write to
+ * tinyalsa.
+ */
+ out->write_threshold = PLAYBACK_PERIOD_COUNT * PERIOD_SIZE;
+ out->config.start_threshold = PLAYBACK_PERIOD_START_THRESHOLD * PERIOD_SIZE;
+ out->config.avail_min = PERIOD_SIZE;
+
+ out->pcm = pcm_open(CARD_OUT, PORT_CODEC, PCM_OUT | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC, &out->config);
+
+ if (!pcm_is_ready(out->pcm)) {
+ ALOGE("cannot open pcm_out driver: %s", pcm_get_error(out->pcm));
+ pcm_close(out->pcm);
+ adev->active_output = NULL;
+ out->unavailable = true;
+ return -ENODEV;
+ }
+
+ adev->active_output = out;
+ return 0;
+}
+
+static uint32_t out_get_sample_rate(const struct audio_stream *stream)
+{
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ return out->config.rate;
+}
+
+static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
+{
+ ALOGV("out_set_sample_rate: %d", 0);
+ return -ENOSYS;
+}
+
+static size_t out_get_buffer_size(const struct audio_stream *stream)
+{
+ ALOGV("out_get_buffer_size: %d", 4096);
+
+ /* return the closest majoring multiple of 16 frames, as
+ * audioflinger expects audio buffers to be a multiple of 16 frames */
+ size_t size = PERIOD_SIZE;
+ size = ((size + 15) / 16) * 16;
+ return size * audio_stream_out_frame_size((struct audio_stream_out *)stream);
+}
+
+static audio_channel_mask_t out_get_channels(const struct audio_stream *stream)
+{
+ ALOGV("out_get_channels");
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ return audio_channel_out_mask_from_count(out->config.channels);
+}
+
+static audio_format_t out_get_format(const struct audio_stream *stream)
+{
+ ALOGV("out_get_format");
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ return audio_format_from_pcm_format(out->config.format);
+}
+
+static int out_set_format(struct audio_stream *stream, audio_format_t format)
+{
+ ALOGV("out_set_format: %d",format);
+ return -ENOSYS;
+}
+
+static int do_output_standby(struct alsa_stream_out *out)
+{
+ struct alsa_audio_device *adev = out->dev;
+
+ if (!out->standby) {
+ pcm_close(out->pcm);
+ out->pcm = NULL;
+ adev->active_output = NULL;
+ out->standby = 1;
+ }
+ return 0;
+}
+
+static int out_standby(struct audio_stream *stream)
+{
+ ALOGV("out_standby");
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ int status;
+
+ pthread_mutex_lock(&out->dev->lock);
+ pthread_mutex_lock(&out->lock);
+ status = do_output_standby(out);
+ pthread_mutex_unlock(&out->lock);
+ pthread_mutex_unlock(&out->dev->lock);
+ return status;
+}
+
+static int out_dump(const struct audio_stream *stream, int fd)
+{
+ ALOGV("out_dump");
+ return 0;
+}
+
+static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
+{
+ ALOGV("out_set_parameters");
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ struct alsa_audio_device *adev = out->dev;
+ struct str_parms *parms;
+ char value[32];
+ int ret, val = 0;
+
+ parms = str_parms_create_str(kvpairs);
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value);
+ pthread_mutex_lock(&adev->lock);
+ pthread_mutex_lock(&out->lock);
+ if (((adev->devices & AUDIO_DEVICE_OUT_ALL) != val) && (val != 0)) {
+ adev->devices &= ~AUDIO_DEVICE_OUT_ALL;
+ adev->devices |= val;
+ }
+ pthread_mutex_unlock(&out->lock);
+ pthread_mutex_unlock(&adev->lock);
+ }
+
+ str_parms_destroy(parms);
+ return ret;
+}
+
+static char * out_get_parameters(const struct audio_stream *stream, const char *keys)
+{
+ ALOGV("out_get_parameters");
+ return strdup("");
+}
+
+static uint32_t out_get_latency(const struct audio_stream_out *stream)
+{
+ ALOGV("out_get_latency");
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ return (PERIOD_SIZE * PLAYBACK_PERIOD_COUNT * 1000) / out->config.rate;
+}
+
+static int out_set_volume(struct audio_stream_out *stream, float left,
+ float right)
+{
+ ALOGV("out_set_volume: Left:%f Right:%f", left, right);
+ return 0;
+}
+
+static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
+ size_t bytes)
+{
+ int ret;
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ struct alsa_audio_device *adev = out->dev;
+ size_t frame_size = audio_stream_out_frame_size(stream);
+ size_t out_frames = bytes / frame_size;
+
+ /* acquiring hw device mutex systematically is useful if a low priority thread is waiting
+ * on the output stream mutex - e.g. executing select_mode() while holding the hw device
+ * mutex
+ */
+ pthread_mutex_lock(&adev->lock);
+ pthread_mutex_lock(&out->lock);
+ if (out->standby) {
+ ret = start_output_stream(out);
+ if (ret != 0) {
+ pthread_mutex_unlock(&adev->lock);
+ goto exit;
+ }
+ out->standby = 0;
+ }
+
+ pthread_mutex_unlock(&adev->lock);
+
+ ret = pcm_mmap_write(out->pcm, buffer, out_frames * frame_size);
+ if (ret == 0) {
+ out->written += out_frames;
+ }
+exit:
+ pthread_mutex_unlock(&out->lock);
+
+ if (ret != 0) {
+ usleep((int64_t)bytes * 1000000 / audio_stream_out_frame_size(stream) /
+ out_get_sample_rate(&stream->common));
+ }
+
+ return bytes;
+}
+
+static int out_get_render_position(const struct audio_stream_out *stream,
+ uint32_t *dsp_frames)
+{
+ *dsp_frames = 0;
+ ALOGV("out_get_render_position: dsp_frames: %p", dsp_frames);
+ return -EINVAL;
+}
+
+static int out_get_presentation_position(const struct audio_stream_out *stream,
+ uint64_t *frames, struct timespec *timestamp)
+{
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ int ret = -1;
+
+ if (out->pcm) {
+ unsigned int avail;
+ if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
+ size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
+ int64_t signed_frames = out->written - kernel_buffer_size + avail;
+ if (signed_frames >= 0) {
+ *frames = signed_frames;
+ ret = 0;
+ }
+ }
+ }
+
+ return ret;
+}
+
+
+static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+{
+ ALOGV("out_add_audio_effect: %p", effect);
+ return 0;
+}
+
+static int out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+{
+ ALOGV("out_remove_audio_effect: %p", effect);
+ return 0;
+}
+
+static int out_get_next_write_timestamp(const struct audio_stream_out *stream,
+ int64_t *timestamp)
+{
+ *timestamp = 0;
+ ALOGV("out_get_next_write_timestamp: %ld", (long int)(*timestamp));
+ return -EINVAL;
+}
+
+/** audio_stream_in implementation **/
+static uint32_t in_get_sample_rate(const struct audio_stream *stream)
+{
+ ALOGV("in_get_sample_rate");
+ return 8000;
+}
+
+static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
+{
+ ALOGV("in_set_sample_rate: %d", rate);
+ return -ENOSYS;
+}
+
+static size_t in_get_buffer_size(const struct audio_stream *stream)
+{
+ ALOGV("in_get_buffer_size: %d", 320);
+ return 320;
+}
+
+static audio_channel_mask_t in_get_channels(const struct audio_stream *stream)
+{
+ ALOGV("in_get_channels: %d", AUDIO_CHANNEL_IN_MONO);
+ return AUDIO_CHANNEL_IN_MONO;
+}
+
+static audio_format_t in_get_format(const struct audio_stream *stream)
+{
+ return AUDIO_FORMAT_PCM_16_BIT;
+}
+
+static int in_set_format(struct audio_stream *stream, audio_format_t format)
+{
+ return -ENOSYS;
+}
+
+static int in_standby(struct audio_stream *stream)
+{
+ return 0;
+}
+
+static int in_dump(const struct audio_stream *stream, int fd)
+{
+ return 0;
+}
+
+static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
+{
+ return 0;
+}
+
+static char * in_get_parameters(const struct audio_stream *stream,
+ const char *keys)
+{
+ return strdup("");
+}
+
+static int in_set_gain(struct audio_stream_in *stream, float gain)
+{
+ return 0;
+}
+
+static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
+ size_t bytes)
+{
+ ALOGV("in_read: bytes %zu", bytes);
+ /* XXX: fake timing for audio input */
+ usleep((int64_t)bytes * 1000000 / audio_stream_in_frame_size(stream) /
+ in_get_sample_rate(&stream->common));
+ memset(buffer, 0, bytes);
+ return bytes;
+}
+
+static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
+{
+ return 0;
+}
+
+static int in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+{
+ return 0;
+}
+
+static int in_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+{
+ return 0;
+}
+
+static int adev_open_output_stream(struct audio_hw_device *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ audio_output_flags_t flags,
+ struct audio_config *config,
+ struct audio_stream_out **stream_out,
+ const char *address __unused)
+{
+ ALOGV("adev_open_output_stream...");
+
+ struct alsa_audio_device *ladev = (struct alsa_audio_device *)dev;
+ struct alsa_stream_out *out;
+ struct pcm_params *params;
+ int ret = 0;
+
+ params = pcm_params_get(CARD_OUT, PORT_CODEC, PCM_OUT);
+ if (!params)
+ return -ENOSYS;
+
+ out = (struct alsa_stream_out *)calloc(1, sizeof(struct alsa_stream_out));
+ if (!out)
+ return -ENOMEM;
+
+ out->stream.common.get_sample_rate = out_get_sample_rate;
+ out->stream.common.set_sample_rate = out_set_sample_rate;
+ out->stream.common.get_buffer_size = out_get_buffer_size;
+ out->stream.common.get_channels = out_get_channels;
+ out->stream.common.get_format = out_get_format;
+ out->stream.common.set_format = out_set_format;
+ out->stream.common.standby = out_standby;
+ out->stream.common.dump = out_dump;
+ out->stream.common.set_parameters = out_set_parameters;
+ out->stream.common.get_parameters = out_get_parameters;
+ out->stream.common.add_audio_effect = out_add_audio_effect;
+ out->stream.common.remove_audio_effect = out_remove_audio_effect;
+ out->stream.get_latency = out_get_latency;
+ out->stream.set_volume = out_set_volume;
+ out->stream.write = out_write;
+ out->stream.get_render_position = out_get_render_position;
+ out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
+ out->stream.get_presentation_position = out_get_presentation_position;
+
+ out->config.channels = CHANNEL_STEREO;
+ out->config.rate = CODEC_SAMPLING_RATE;
+ out->config.format = PCM_FORMAT_S16_LE;
+ out->config.period_size = PERIOD_SIZE;
+ out->config.period_count = PLAYBACK_PERIOD_COUNT;
+
+ if (out->config.rate != config->sample_rate ||
+ audio_channel_count_from_out_mask(config->channel_mask) != CHANNEL_STEREO ||
+ out->config.format != pcm_format_from_audio_format(config->format) ) {
+ config->sample_rate = out->config.rate;
+ config->format = audio_format_from_pcm_format(out->config.format);
+ config->channel_mask = audio_channel_out_mask_from_count(CHANNEL_STEREO);
+ ret = -EINVAL;
+ }
+
+ ALOGI("adev_open_output_stream selects channels=%d rate=%d format=%d",
+ out->config.channels, out->config.rate, out->config.format);
+
+ out->dev = ladev;
+ out->standby = 1;
+ out->unavailable = false;
+
+ config->format = out_get_format(&out->stream.common);
+ config->channel_mask = out_get_channels(&out->stream.common);
+ config->sample_rate = out_get_sample_rate(&out->stream.common);
+
+ *stream_out = &out->stream;
+
+ /* TODO The retry mechanism isn't implemented in AudioPolicyManager/AudioFlinger. */
+ ret = 0;
+
+ return ret;
+}
+
+static void adev_close_output_stream(struct audio_hw_device *dev,
+ struct audio_stream_out *stream)
+{
+ ALOGV("adev_close_output_stream...");
+ free(stream);
+}
+
+static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
+{
+ ALOGV("adev_set_parameters");
+ return -ENOSYS;
+}
+
+static char * adev_get_parameters(const struct audio_hw_device *dev,
+ const char *keys)
+{
+ ALOGV("adev_get_parameters");
+ return strdup("");
+}
+
+static int adev_init_check(const struct audio_hw_device *dev)
+{
+ ALOGV("adev_init_check");
+ return 0;
+}
+
+static int adev_set_voice_volume(struct audio_hw_device *dev, float volume)
+{
+ ALOGV("adev_set_voice_volume: %f", volume);
+ return -ENOSYS;
+}
+
+static int adev_set_master_volume(struct audio_hw_device *dev, float volume)
+{
+ ALOGV("adev_set_master_volume: %f", volume);
+ return -ENOSYS;
+}
+
+static int adev_get_master_volume(struct audio_hw_device *dev, float *volume)
+{
+ ALOGV("adev_get_master_volume: %f", *volume);
+ return -ENOSYS;
+}
+
+static int adev_set_master_mute(struct audio_hw_device *dev, bool muted)
+{
+ ALOGV("adev_set_master_mute: %d", muted);
+ return -ENOSYS;
+}
+
+static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted)
+{
+ ALOGV("adev_get_master_mute: %d", *muted);
+ return -ENOSYS;
+}
+
+static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
+{
+ ALOGV("adev_set_mode: %d", mode);
+ return 0;
+}
+
+static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)
+{
+ ALOGV("adev_set_mic_mute: %d",state);
+ return -ENOSYS;
+}
+
+static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
+{
+ ALOGV("adev_get_mic_mute");
+ return -ENOSYS;
+}
+
+static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
+ const struct audio_config *config)
+{
+ ALOGV("adev_get_input_buffer_size: %d", 320);
+ return 320;
+}
+
+static int adev_open_input_stream(struct audio_hw_device __unused *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ struct audio_config *config,
+ struct audio_stream_in **stream_in,
+ audio_input_flags_t flags __unused,
+ const char *address __unused,
+ audio_source_t source __unused)
+{
+ struct stub_stream_in *in;
+
+ ALOGV("adev_open_input_stream...");
+
+ in = (struct stub_stream_in *)calloc(1, sizeof(struct stub_stream_in));
+ if (!in)
+ return -ENOMEM;
+
+ in->stream.common.get_sample_rate = in_get_sample_rate;
+ in->stream.common.set_sample_rate = in_set_sample_rate;
+ in->stream.common.get_buffer_size = in_get_buffer_size;
+ in->stream.common.get_channels = in_get_channels;
+ in->stream.common.get_format = in_get_format;
+ in->stream.common.set_format = in_set_format;
+ in->stream.common.standby = in_standby;
+ in->stream.common.dump = in_dump;
+ in->stream.common.set_parameters = in_set_parameters;
+ in->stream.common.get_parameters = in_get_parameters;
+ in->stream.common.add_audio_effect = in_add_audio_effect;
+ in->stream.common.remove_audio_effect = in_remove_audio_effect;
+ in->stream.set_gain = in_set_gain;
+ in->stream.read = in_read;
+ in->stream.get_input_frames_lost = in_get_input_frames_lost;
+
+ *stream_in = &in->stream;
+ return 0;
+}
+
+static void adev_close_input_stream(struct audio_hw_device *dev,
+ struct audio_stream_in *in)
+{
+ ALOGV("adev_close_input_stream...");
+ return;
+}
+
+static int adev_dump(const audio_hw_device_t *device, int fd)
+{
+ ALOGV("adev_dump");
+ return 0;
+}
+
+static int adev_close(hw_device_t *device)
+{
+ ALOGV("adev_close");
+ free(device);
+ return 0;
+}
+
+static int adev_open(const hw_module_t* module, const char* name,
+ hw_device_t** device)
+{
+ struct alsa_audio_device *adev;
+
+ ALOGV("adev_open: %s", name);
+
+ if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0)
+ return -EINVAL;
+
+ adev = calloc(1, sizeof(struct alsa_audio_device));
+ if (!adev)
+ return -ENOMEM;
+
+ adev->hw_device.common.tag = HARDWARE_DEVICE_TAG;
+ adev->hw_device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
+ adev->hw_device.common.module = (struct hw_module_t *) module;
+ adev->hw_device.common.close = adev_close;
+ adev->hw_device.init_check = adev_init_check;
+ adev->hw_device.set_voice_volume = adev_set_voice_volume;
+ adev->hw_device.set_master_volume = adev_set_master_volume;
+ adev->hw_device.get_master_volume = adev_get_master_volume;
+ adev->hw_device.set_master_mute = adev_set_master_mute;
+ adev->hw_device.get_master_mute = adev_get_master_mute;
+ adev->hw_device.set_mode = adev_set_mode;
+ adev->hw_device.set_mic_mute = adev_set_mic_mute;
+ adev->hw_device.get_mic_mute = adev_get_mic_mute;
+ adev->hw_device.set_parameters = adev_set_parameters;
+ adev->hw_device.get_parameters = adev_get_parameters;
+ adev->hw_device.get_input_buffer_size = adev_get_input_buffer_size;
+ adev->hw_device.open_output_stream = adev_open_output_stream;
+ adev->hw_device.close_output_stream = adev_close_output_stream;
+ adev->hw_device.open_input_stream = adev_open_input_stream;
+ adev->hw_device.close_input_stream = adev_close_input_stream;
+ adev->hw_device.dump = adev_dump;
+
+ adev->devices = AUDIO_DEVICE_NONE;
+
+ *device = &adev->hw_device.common;
+
+ return 0;
+}
+
+static struct hw_module_methods_t hal_module_methods = {
+ .open = adev_open,
+};
+
+struct audio_module HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = AUDIO_MODULE_API_VERSION_0_1,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = AUDIO_HARDWARE_MODULE_ID,
+ .name = "Generic Audio HAL for dragonboards",
+ .author = "The Android Open Source Project",
+ .methods = &hal_module_methods,
+ },
+};
diff --git a/common.kl b/common.kl
new file mode 100644
index 0000000..a1302da
--- /dev/null
+++ b/common.kl
@@ -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/compatibility_matrix.xml b/compatibility_matrix.xml
new file mode 100644
index 0000000..3082485
--- /dev/null
+++ b/compatibility_matrix.xml
@@ -0,0 +1,59 @@
+<compatibility-matrix version="1.0" type="device">
+ <hal format="hidl" optional="false">
+ <name>android.frameworks.schedulerservice</name>
+ <version>1.0</version>
+ <interface>
+ <name>ISchedulingPolicyService</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl" optional="false">
+ <name>android.frameworks.sensorservice</name>
+ <version>1.0</version>
+ <interface>
+ <name>ISensorManager</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl" optional="false">
+ <name>android.hidl.allocator</name>
+ <version>1.0</version>
+ <interface>
+ <name>IAllocator</name>
+ <instance>ashmem</instance>
+ </interface>
+ </hal>
+ <hal format="hidl" optional="false">
+ <name>android.hidl.manager</name>
+ <version>1.0</version>
+ <interface>
+ <name>IServiceManager</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl" optional="false">
+ <name>android.hidl.memory</name>
+ <version>1.0</version>
+ <interface>
+ <name>IMapper</name>
+ <instance>ashmem</instance>
+ </interface>
+ </hal>
+ <hal format="hidl" optional="false">
+ <name>android.hidl.token</name>
+ <version>1.0</version>
+ <interface>
+ <name>ITokenManager</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl" optional="false">
+ <name>android.system.wifi.keystore</name>
+ <version>1.0</version>
+ <interface>
+ <name>IKeystore</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+
+</compatibility-matrix>
diff --git a/db845c.mk b/db845c.mk
new file mode 100644
index 0000000..48f7875
--- /dev/null
+++ b/db845c.mk
@@ -0,0 +1,10 @@
+# Inherit the full_base and device configurations
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, device/linaro/dragonboard/db845c/device.mk)
+$(call inherit-product, device/linaro/dragonboard/device-common.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+
+# Product overrides
+PRODUCT_NAME := db845c
+PRODUCT_DEVICE := db845c
+PRODUCT_BRAND := Android
diff --git a/db845c/BoardConfig.mk b/db845c/BoardConfig.mk
new file mode 100644
index 0000000..ffc6047
--- /dev/null
+++ b/db845c/BoardConfig.mk
@@ -0,0 +1,14 @@
+include device/linaro/dragonboard/BoardConfigCommon.mk
+
+# Board Information
+TARGET_BOOTLOADER_BOARD_NAME := db845c
+TARGET_BOARD_PLATFORM := db845c
+
+# Image Configuration
+BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864 #64M
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 21474836480 #20G
+BOARD_FLASH_BLOCK_SIZE := 512
+# Super partition
+BOARD_SUPER_PARTITION_SIZE := 10737418240 #10G
+BOARD_DB_DYNAMIC_PARTITIONS_SIZE := 10737418240 #10G
+BOARD_SUPER_PARTITION_METADATA_DEVICE := super
diff --git a/db845c/device.mk b/db845c/device.mk
new file mode 100644
index 0000000..54e0705
--- /dev/null
+++ b/db845c/device.mk
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+
+# setup dalvik vm configs
+$(call inherit-product, frameworks/native/build/tablet-10in-xhdpi-2048-dalvik-heap.mk)
+
+PRODUCT_COPY_FILES := \
+ device/linaro/dragonboard/fstab.ramdisk.common:$(TARGET_COPY_OUT_RAMDISK)/fstab.db845c \
+ device/linaro/dragonboard/fstab.ramdisk.common:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.db845c \
+ device/linaro/dragonboard/fstab.common:$(TARGET_COPY_OUT_VENDOR)/etc/init/fstab.db845c \
+ device/linaro/dragonboard/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.db845c.rc \
+ device/linaro/dragonboard/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.db845c.usb.rc \
+ device/linaro/dragonboard/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/db845c.kl
+
+# Build generic Audio HAL
+PRODUCT_PACKAGES := audio.primary.db845c
diff --git a/device-common.mk b/device-common.mk
new file mode 100644
index 0000000..91f07cc
--- /dev/null
+++ b/device-common.mk
@@ -0,0 +1,169 @@
+#
+# Copyright (C) 2014 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.
+#
+
+# Device overlay
+DEVICE_PACKAGE_OVERLAYS := $(LOCAL_PATH)/overlay
+
+# Build and run only ART
+PRODUCT_RUNTIMES := runtime_libart_default
+
+PRODUCT_SHIPPING_API_LEVEL := 29
+PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := false
+
+# vndk
+PRODUCT_PACKAGES := vndk-sp
+
+# Dynamic partitions
+PRODUCT_BUILD_SUPER_PARTITION := true
+PRODUCT_USE_DYNAMIC_PARTITIONS := true
+PRODUCT_USE_DYNAMIC_PARTITION_SIZE := true
+
+# copied from crosshatch
+# Set lmkd options
+PRODUCT_SYSTEM_DEFAULT_PROPERTIES := \
+ ro.lmk.low=1001 \
+ ro.lmk.medium=800 \
+ ro.lmk.critical=0 \
+ ro.lmk.critical_upgrade=false \
+ ro.lmk.upgrade_pressure=100 \
+ ro.lmk.downgrade_pressure=100 \
+ ro.lmk.kill_heaviest_task=true \
+ ro.lmk.kill_timeout_ms=100 \
+ ro.lmk.use_minfree_levels=true \
+
+# HACK: Avoid usb crash
+PRODUCT_PRODUCT_PROPERTIES := \
+ persist.adb.nonblocking_ffs=0 \
+ ro.adb.nonblocking_ffs=0
+
+# Display
+PRODUCT_PACKAGES += \
+ android.hardware.drm@1.0-impl \
+ android.hardware.drm@1.0-service \
+ android.hardware.graphics.allocator@2.0-impl \
+ android.hardware.graphics.allocator@2.0-service \
+ android.hardware.graphics.composer@2.2-impl \
+ android.hardware.graphics.composer@2.2-service \
+ android.hardware.graphics.mapper@2.0-impl-2.1 \
+ gralloc.gbm \
+ hwcomposer.drm \
+ libGLES_mesa
+
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.hardware.gralloc=gbm \
+ ro.hardware.hwcomposer=drm \
+ debug.sf.no_hw_vsync=1 \
+ hwc.drm.use_framebuffer_target=1 \
+ hwc.drm.use_overlay_planes=0 \
+ ro.sf.lcd_density=160 \
+ ro.opengles.version=196608 \
+ persist.demo.rotationlock=1
+
+# Use Launcher3QuickStep
+PRODUCT_PACKAGES += Launcher3QuickStep
+
+# Enable WiFi
+PRODUCT_PACKAGES += \
+ hostapd \
+ libwpa_client \
+ wpa_supplicant \
+ wpa_supplicant.conf \
+ wificond \
+ wifilogd
+
+PRODUCT_PROPERTY_OVERRIDES += \
+ wifi.interface=wlan0 \
+ wifi.supplicant_scan_interval=15
+
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml \
+ frameworks/native/data/etc/android.hardware.wifi.direct.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.direct.xml \
+ $(LOCAL_PATH)/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf \
+ $(LOCAL_PATH)/p2p_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/p2p_supplicant_overlay.conf
+
+# Enable BT
+PRODUCT_PACKAGES += \
+ android.hardware.bluetooth@1.0-service.btlinux
+
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.bluetooth.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml
+
+# Audio
+PRODUCT_PACKAGES += \
+ android.hardware.audio@4.0-impl:32 \
+ android.hardware.audio.effect@4.0-impl:32 \
+ android.hardware.audio@2.0-service \
+ android.hardware.soundtrigger@2.0-impl
+
+# Build default bluetooth a2dp and usb audio HALs
+PRODUCT_PACKAGES += \
+ audio.a2dp.default \
+ audio.usb.default \
+ audio.r_submix.default
+
+# Build tinyalsa cli tools for debugging
+PRODUCT_PACKAGES += \
+ tinyplay \
+ tinycap \
+ tinymix \
+ tinypcminfo
+
+# audio policy configuration
+USE_XML_AUDIO_POLICY_CONF := 1
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/etc/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \
+ $(LOCAL_PATH)/etc/audio_policy_configuration_bluetooth_legacy_hal.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration_bluetooth_legacy_hal.xml \
+ frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \
+ frameworks/av/services/audiopolicy/config/a2dp_in_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_in_audio_policy_configuration.xml \
+ frameworks/av/services/audiopolicy/config/bluetooth_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/bluetooth_audio_policy_configuration.xml \
+ frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \
+ frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usb_audio_policy_configuration.xml \
+ frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \
+ frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml
+
+# Copy media codecs config file
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/etc/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_audio.xml
+
+# Memtrack
+PRODUCT_PACKAGES += \
+ memtrack.default \
+ android.hardware.memtrack@1.0-service \
+ android.hardware.memtrack@1.0-impl
+
+# Keymaster
+PRODUCT_PACKAGES += \
+ android.hardware.keymaster@3.0-impl \
+ android.hardware.keymaster@3.0-service
+
+# Gatekeeper
+PRODUCT_PACKAGES += \
+ android.hardware.gatekeeper@1.0-service.software
+
+# Copy standard platform config files
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/ueventd.common.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \
+ frameworks/native/data/etc/android.software.cts.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.cts.xml \
+ frameworks/native/data/etc/android.software.app_widgets.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.app_widgets.xml \
+ frameworks/native/data/etc/android.software.backup.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.backup.xml \
+ frameworks/native/data/etc/android.software.voice_recognizers.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.voice_recognizers.xml \
+ frameworks/native/data/etc/android.hardware.ethernet.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.ethernet.xml \
+ frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \
+ frameworks/native/data/etc/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml \
+ frameworks/native/data/etc/android.software.device_admin.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.device_admin.xml
diff --git a/etc/audio_policy_configuration.xml b/etc/audio_policy_configuration.xml
new file mode 100644
index 0000000..c94718e
--- /dev/null
+++ b/etc/audio_policy_configuration.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Copyright (C) 2015 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.
+-->
+
+<audioPolicyConfiguration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
+
+ <globalConfiguration speaker_drc_enabled="false"/>
+
+ <modules>
+ <!-- Primary Audio HAL -->
+ <module name="primary" halVersion="2.0">
+ <attachedDevices>
+ <item>Speaker</item>
+ <item>Built-In Mic</item>
+ </attachedDevices>
+ <defaultOutputDevice>Speaker</defaultOutputDevice>
+ <mixPorts>
+ <mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ </mixPort>
+ <mixPort name="primary input" role="sink">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
+ channelMasks="AUDIO_CHANNEL_IN_MONO"/>
+ </mixPort>
+ </mixPorts>
+ <devicePorts>
+ <!-- Output devices declaration, i.e. Sink DEVICE PORT -->
+ <devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER">
+ </devicePort>
+ <devicePort tagName="Wired Headset" type="AUDIO_DEVICE_OUT_WIRED_HEADSET" role="sink">
+ </devicePort>
+ <devicePort tagName="Wired Headphones" type="AUDIO_DEVICE_OUT_WIRED_HEADPHONE" role="sink">
+ </devicePort>
+ <devicePort tagName="BT SCO" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO" role="sink">
+ </devicePort>
+ <devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink">
+ </devicePort>
+ <devicePort tagName="BT SCO Car Kit" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT" role="sink">
+ </devicePort>
+ <devicePort tagName="Aux Digital" type="AUDIO_DEVICE_OUT_AUX_DIGITAL" role="sink">
+ </devicePort>
+
+ <devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
+ </devicePort>
+ <devicePort tagName="Wired Headset Mic" type="AUDIO_DEVICE_IN_WIRED_HEADSET" role="source">
+ </devicePort>
+ <devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source">
+ </devicePort>
+ </devicePorts>
+ <!-- route declaration, i.e. list all available sources for a given sink -->
+ <routes>
+ <route type="mix" sink="Speaker"
+ sources="primary output"/>
+ <route type="mix" sink="Wired Headset"
+ sources="primary output"/>
+ <route type="mix" sink="Wired Headphones"
+ sources="primary output"/>
+ <route type="mix" sink="Aux Digital"
+ sources="primary output"/>
+ <route type="mix" sink="BT SCO"
+ sources="primary output"/>
+ <route type="mix" sink="BT SCO Headset"
+ sources="primary output"/>
+ <route type="mix" sink="BT SCO Car Kit"
+ sources="primary output"/>
+ <route type="mix" sink="primary input"
+ sources="Built-In Mic,Wired Headset Mic,BT SCO Headset Mic"/>
+ </routes>
+
+ </module>
+
+ <!-- Usb Audio HAL -->
+ <xi:include href="usb_audio_policy_configuration.xml"/>
+
+ <!-- Remote Submix Audio HAL -->
+ <xi:include href="r_submix_audio_policy_configuration.xml"/>
+
+ <!-- Bluetooth Audio HAL -->
+ <xi:include href="bluetooth_audio_policy_configuration.xml"/>
+
+ </modules>
+ <!-- End of Modules section -->
+
+ <!-- Volume section -->
+
+ <xi:include href="audio_policy_volumes.xml"/>
+ <xi:include href="default_volume_tables.xml"/>
+
+ <!-- End of Volume section -->
+
+</audioPolicyConfiguration>
diff --git a/etc/audio_policy_configuration_bluetooth_legacy_hal.xml b/etc/audio_policy_configuration_bluetooth_legacy_hal.xml
new file mode 100644
index 0000000..2d2eca8
--- /dev/null
+++ b/etc/audio_policy_configuration_bluetooth_legacy_hal.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Copyright (C) 2015 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.
+-->
+
+<audioPolicyConfiguration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
+
+ <globalConfiguration speaker_drc_enabled="false"/>
+
+ <modules>
+ <!-- Primary Audio HAL -->
+ <module name="primary" halVersion="2.0">
+ <attachedDevices>
+ <item>Speaker</item>
+ <item>Built-In Mic</item>
+ </attachedDevices>
+ <defaultOutputDevice>Speaker</defaultOutputDevice>
+ <mixPorts>
+ <mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ </mixPort>
+ <mixPort name="primary input" role="sink">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
+ channelMasks="AUDIO_CHANNEL_IN_MONO"/>
+ </mixPort>
+ </mixPorts>
+ <devicePorts>
+ <!-- Output devices declaration, i.e. Sink DEVICE PORT -->
+ <devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER">
+ </devicePort>
+ <devicePort tagName="Wired Headset" type="AUDIO_DEVICE_OUT_WIRED_HEADSET" role="sink">
+ </devicePort>
+ <devicePort tagName="Wired Headphones" type="AUDIO_DEVICE_OUT_WIRED_HEADPHONE" role="sink">
+ </devicePort>
+ <devicePort tagName="BT SCO" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO" role="sink">
+ </devicePort>
+ <devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink">
+ </devicePort>
+ <devicePort tagName="BT SCO Car Kit" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT" role="sink">
+ </devicePort>
+ <devicePort tagName="Aux Digital" type="AUDIO_DEVICE_OUT_AUX_DIGITAL" role="sink">
+ </devicePort>
+
+ <devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
+ </devicePort>
+ <devicePort tagName="Wired Headset Mic" type="AUDIO_DEVICE_IN_WIRED_HEADSET" role="source">
+ </devicePort>
+ <devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source">
+ </devicePort>
+ </devicePorts>
+ <!-- route declaration, i.e. list all available sources for a given sink -->
+ <routes>
+ <route type="mix" sink="Speaker"
+ sources="primary output"/>
+ <route type="mix" sink="Wired Headset"
+ sources="primary output"/>
+ <route type="mix" sink="Wired Headphones"
+ sources="primary output"/>
+ <route type="mix" sink="Aux Digital"
+ sources="primary output"/>
+ <route type="mix" sink="BT SCO"
+ sources="primary output"/>
+ <route type="mix" sink="BT SCO Headset"
+ sources="primary output"/>
+ <route type="mix" sink="BT SCO Car Kit"
+ sources="primary output"/>
+ <route type="mix" sink="primary input"
+ sources="Built-In Mic,Wired Headset Mic,BT SCO Headset Mic"/>
+ </routes>
+
+ </module>
+
+ <!-- A2dp Audio HAL -->
+ <xi:include href="a2dp_audio_policy_configuration.xml"/>
+
+ <!-- A2dp Input Audio HAL -->
+ <xi:include href="a2dp_in_audio_policy_configuration.xml"/>
+
+ <!-- Usb Audio HAL -->
+ <xi:include href="usb_audio_policy_configuration.xml"/>
+
+ <!-- Remote Submix Audio HAL -->
+ <xi:include href="r_submix_audio_policy_configuration.xml"/>
+
+ </modules>
+ <!-- End of Modules section -->
+
+ <!-- Volume section -->
+
+ <xi:include href="audio_policy_volumes.xml"/>
+ <xi:include href="default_volume_tables.xml"/>
+
+ <!-- End of Volume section -->
+
+</audioPolicyConfiguration>
diff --git a/etc/media_codecs.xml b/etc/media_codecs.xml
new file mode 100644
index 0000000..2b00568
--- /dev/null
+++ b/etc/media_codecs.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<!--
+<!DOCTYPE MediaCodecs [
+<!ELEMENT MediaCodecs (Decoders,Encoders)>
+<!ELEMENT Decoders (MediaCodec*)>
+<!ELEMENT Encoders (MediaCodec*)>
+<!ELEMENT MediaCodec (Type*,Quirk*)>
+<!ATTLIST MediaCodec name CDATA #REQUIRED>
+<!ATTLIST MediaCodec type CDATA>
+<!ELEMENT Type EMPTY>
+<!ATTLIST Type name CDATA #REQUIRED>
+<!ELEMENT Quirk EMPTY>
+<!ATTLIST Quirk name CDATA #REQUIRED>
+]>
+
+There's a simple and a complex syntax to declare the availability of a
+media codec:
+
+A codec that properly follows the OpenMax spec and therefore doesn't have any
+quirks and that only supports a single content type can be declared like so:
+
+ <MediaCodec name="OMX.foo.bar" type="something/interesting" />
+
+If a codec has quirks OR supports multiple content types, the following syntax
+can be used:
+
+ <MediaCodec name="OMX.foo.bar" >
+ <Type name="something/interesting" />
+ <Type name="something/else" />
+ ...
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ <Quirk name="output-buffers-are-unreadable" />
+ </MediaCodec>
+
+Only the three quirks included above are recognized at this point:
+
+"requires-allocate-on-input-ports"
+ must be advertised if the component does not properly support specification
+ of input buffers using the OMX_UseBuffer(...) API but instead requires
+ OMX_AllocateBuffer to be used.
+
+"requires-allocate-on-output-ports"
+ must be advertised if the component does not properly support specification
+ of output buffers using the OMX_UseBuffer(...) API but instead requires
+ OMX_AllocateBuffer to be used.
+
+"output-buffers-are-unreadable"
+ must be advertised if the emitted output buffers of a decoder component
+ are not readable, i.e. use a custom format even though abusing one of
+ the official OMX colorspace constants.
+ Clients of such decoders will not be able to access the decoded data,
+ naturally making the component much less useful. The only use for
+ a component with this quirk is to render the output to the screen.
+ Audio decoders MUST NOT advertise this quirk.
+ Video decoders that advertise this quirk must be accompanied by a
+ corresponding color space converter for thumbnail extraction,
+ matching surfaceflinger support that can render the custom format to
+ a texture and possibly other code, so just DON'T USE THIS QUIRK.
+
+-->
+
+<MediaCodecs>
+ <Include href="media_codecs_google_audio.xml" />
+ <Include href="media_codecs_google_video.xml" />
+</MediaCodecs>
diff --git a/fstab.common b/fstab.common
new file mode 100644
index 0000000..7ccfed5
--- /dev/null
+++ b/fstab.common
@@ -0,0 +1,6 @@
+# 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
+LABEL=data /data ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
+/dev/block/by-name/metadata /metadata ext4 noatime,nosuid,nodev,discard wait,formattable
diff --git a/fstab.ramdisk.common b/fstab.ramdisk.common
new file mode 100644
index 0000000..a2dcc4c
--- /dev/null
+++ b/fstab.ramdisk.common
@@ -0,0 +1,3 @@
+system /system ext4 noatime,ro,errors=panic wait,logical,first_stage_mount
+vendor /vendor ext4 noatime,ro,errors=panic wait,logical,first_stage_mount
+system_ext /system_ext ext4 noatime,ro,errors=panic wait,logical,first_stage_mount
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
new file mode 100644
index 0000000..049b019
--- /dev/null
+++ b/gralloc/Android.mk
@@ -0,0 +1,57 @@
+# Copyright (C) 2016 Linaro, Ltd., Rob Herring <robh@kernel.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ gralloc_gbm.cpp \
+ gralloc.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ libdrm \
+ libgbm \
+ liblog \
+ libcutils
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+ $(LOCAL_PATH)
+
+LOCAL_C_INCLUDES += system/core/include hardware/libhardware/include
+LOCAL_C_INCLUDES += system/core/libsystem/include system/core
+
+LOCAL_MODULE := gralloc.gbm
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_PROPRIETARY_MODULE := true
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+ $(LOCAL_PATH)
+
+LOCAL_MODULE := libgralloc_drm
+LOCAL_MODULE_TAGS := optional
+LOCAL_PROPRIETARY_MODULE := true
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/gralloc/gralloc.cpp b/gralloc/gralloc.cpp
new file mode 100644
index 0000000..2753ee9
--- /dev/null
+++ b/gralloc/gralloc.cpp
@@ -0,0 +1,259 @@
+/*
+ * Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright (C) 2010-2011 LunarG Inc.
+ * Copyright (C) 2016 Linaro, Ltd., Rob Herring <robh@kernel.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#define LOG_TAG "GRALLOC-GBM"
+
+#include <cutils/log.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <pthread.h>
+#include <errno.h>
+
+#include <hardware/gralloc.h>
+#include <system/graphics.h>
+
+#include <gbm.h>
+
+#include "gralloc_drm.h"
+#include "gralloc_gbm_priv.h"
+
+struct gbm_module_t {
+ gralloc_module_t base;
+
+ pthread_mutex_t mutex;
+ struct gbm_device *gbm;
+};
+
+/*
+ * Initialize the DRM device object
+ */
+static int gbm_init(struct gbm_module_t *dmod)
+{
+ int err = 0;
+
+ pthread_mutex_lock(&dmod->mutex);
+ if (!dmod->gbm) {
+ dmod->gbm = gbm_dev_create();
+ if (!dmod->gbm)
+ err = -EINVAL;
+ }
+ pthread_mutex_unlock(&dmod->mutex);
+
+ return err;
+}
+
+static int gbm_mod_perform(const struct gralloc_module_t *mod, int op, ...)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
+ va_list args;
+ int err;
+ uint32_t uop = static_cast<uint32_t>(op);
+
+ err = gbm_init(dmod);
+ if (err)
+ return err;
+
+ va_start(args, op);
+ switch (uop) {
+ case GRALLOC_MODULE_PERFORM_GET_DRM_FD:
+ {
+ int *fd = va_arg(args, int *);
+ *fd = gbm_device_get_fd(dmod->gbm);
+ err = 0;
+ }
+ break;
+ default:
+ err = -EINVAL;
+ break;
+ }
+ va_end(args);
+
+ return err;
+}
+
+static int gbm_mod_register_buffer(const gralloc_module_t *mod,
+ buffer_handle_t handle)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
+ int err;
+
+ err = gbm_init(dmod);
+ if (err)
+ return err;
+
+ pthread_mutex_lock(&dmod->mutex);
+ err = gralloc_gbm_handle_register(handle, dmod->gbm);
+ pthread_mutex_unlock(&dmod->mutex);
+
+ return err;
+}
+
+static int gbm_mod_unregister_buffer(const gralloc_module_t *mod,
+ buffer_handle_t handle)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
+ int err;
+
+ pthread_mutex_lock(&dmod->mutex);
+ err = gralloc_gbm_handle_unregister(handle);
+ pthread_mutex_unlock(&dmod->mutex);
+
+ return err;
+}
+
+static int gbm_mod_lock(const gralloc_module_t *mod, buffer_handle_t handle,
+ int usage, int x, int y, int w, int h, void **ptr)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
+ int err;
+
+ pthread_mutex_lock(&dmod->mutex);
+
+ err = gralloc_gbm_bo_lock(handle, usage, x, y, w, h, ptr);
+ ALOGV("buffer %p lock usage = %08x", handle, usage);
+
+ pthread_mutex_unlock(&dmod->mutex);
+ return err;
+}
+
+static int gbm_mod_unlock(const gralloc_module_t *mod, buffer_handle_t handle)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
+ int err;
+
+ pthread_mutex_lock(&dmod->mutex);
+ err = gralloc_gbm_bo_unlock(handle);
+ pthread_mutex_unlock(&dmod->mutex);
+
+ return err;
+}
+
+static int gbm_mod_close_gpu0(struct hw_device_t *dev)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *)dev->module;
+ struct alloc_device_t *alloc = (struct alloc_device_t *) dev;
+
+ gbm_dev_destroy(dmod->gbm);
+ delete alloc;
+
+ return 0;
+}
+
+static int gbm_mod_free_gpu0(alloc_device_t *dev, buffer_handle_t handle)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) dev->common.module;
+
+ pthread_mutex_lock(&dmod->mutex);
+ gbm_free(handle);
+ native_handle_close(handle);
+ delete handle;
+
+ pthread_mutex_unlock(&dmod->mutex);
+ return 0;
+}
+
+static int gbm_mod_alloc_gpu0(alloc_device_t *dev,
+ int w, int h, int format, int usage,
+ buffer_handle_t *handle, int *stride)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) dev->common.module;
+ int err = 0;
+
+ pthread_mutex_lock(&dmod->mutex);
+
+ *handle = gralloc_gbm_bo_create(dmod->gbm, w, h, format, usage, stride);
+ if (!*handle)
+ err = -errno;
+
+ ALOGV("buffer %p usage = %08x", *handle, usage);
+ pthread_mutex_unlock(&dmod->mutex);
+ return err;
+}
+
+static int gbm_mod_open_gpu0(struct gbm_module_t *dmod, hw_device_t **dev)
+{
+ struct alloc_device_t *alloc;
+ int err;
+
+ err = gbm_init(dmod);
+ if (err)
+ return err;
+
+ alloc = new alloc_device_t();
+ if (!alloc)
+ return -EINVAL;
+
+ alloc->common.tag = HARDWARE_DEVICE_TAG;
+ alloc->common.version = 0;
+ alloc->common.module = &dmod->base.common;
+ alloc->common.close = gbm_mod_close_gpu0;
+
+ alloc->alloc = gbm_mod_alloc_gpu0;
+ alloc->free = gbm_mod_free_gpu0;
+
+ *dev = &alloc->common;
+
+ return 0;
+}
+
+static int gbm_mod_open(const struct hw_module_t *mod,
+ const char *name, struct hw_device_t **dev)
+{
+ struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
+ int err;
+
+ if (strcmp(name, GRALLOC_HARDWARE_GPU0) == 0)
+ err = gbm_mod_open_gpu0(dmod, dev);
+ else
+ err = -EINVAL;
+
+ return err;
+}
+
+static struct hw_module_methods_t gbm_mod_methods = {
+ .open = gbm_mod_open
+};
+
+struct gbm_module_t HAL_MODULE_INFO_SYM = {
+ .base = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .version_major = 1,
+ .version_minor = 0,
+ .id = GRALLOC_HARDWARE_MODULE_ID,
+ .name = "GBM Memory Allocator",
+ .author = "Rob Herring - Linaro",
+ .methods = &gbm_mod_methods
+ },
+ .registerBuffer = gbm_mod_register_buffer,
+ .unregisterBuffer = gbm_mod_unregister_buffer,
+ .lock = gbm_mod_lock,
+ .unlock = gbm_mod_unlock,
+ .perform = gbm_mod_perform
+ },
+
+ .mutex = PTHREAD_MUTEX_INITIALIZER,
+ .gbm = NULL,
+};
diff --git a/gralloc/gralloc_drm.h b/gralloc/gralloc_drm.h
new file mode 100644
index 0000000..0ece652
--- /dev/null
+++ b/gralloc/gralloc_drm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright (C) 2010-2011 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _GRALLOC_DRM_H_
+#define _GRALLOC_DRM_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ /* perform(const struct gralloc_module_t *mod,
+ * int op,
+ * int *fd);
+ */
+ GRALLOC_MODULE_PERFORM_GET_DRM_FD = 0x40000002,
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _GRALLOC_DRM_H_ */
diff --git a/gralloc/gralloc_gbm.cpp b/gralloc/gralloc_gbm.cpp
new file mode 100644
index 0000000..ab6c12b
--- /dev/null
+++ b/gralloc/gralloc_gbm.cpp
@@ -0,0 +1,475 @@
+/*
+ * Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright (C) 2010-2011 LunarG Inc.
+ * Copyright (C) 2016 Linaro, Ltd., Rob Herring <robh@kernel.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#define LOG_TAG "GRALLOC-GBM"
+
+#include <cutils/log.h>
+#include <cutils/atomic.h>
+#include <cutils/properties.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <assert.h>
+
+#include <hardware/gralloc.h>
+#include <system/graphics.h>
+
+#include <gbm.h>
+
+#include "gralloc_gbm_priv.h"
+#include <android/gralloc_handle.h>
+
+#include <unordered_map>
+
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+#define unlikely(x) __builtin_expect(!!(x), 0)
+
+static std::unordered_map<buffer_handle_t, struct gbm_bo *> gbm_bo_handle_map;
+
+struct bo_data_t {
+ void *map_data;
+ int lock_count;
+ int locked_for;
+};
+
+void gralloc_gbm_destroy_user_data(struct gbm_bo *bo, void *data)
+{
+ struct bo_data_t *bo_data = (struct bo_data_t *)data;
+ delete bo_data;
+
+ (void)bo;
+}
+
+static struct bo_data_t *gbm_bo_data(struct gbm_bo *bo) {
+ return (struct bo_data_t *)gbm_bo_get_user_data(bo);
+}
+
+
+static uint32_t get_gbm_format(int format)
+{
+ uint32_t fmt;
+
+ switch (format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ fmt = GBM_FORMAT_ABGR8888;
+ break;
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ fmt = GBM_FORMAT_XBGR8888;
+ break;
+ case HAL_PIXEL_FORMAT_RGB_888:
+ fmt = GBM_FORMAT_RGB888;
+ break;
+ case HAL_PIXEL_FORMAT_RGB_565:
+ fmt = GBM_FORMAT_RGB565;
+ break;
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ fmt = GBM_FORMAT_ARGB8888;
+ break;
+ case HAL_PIXEL_FORMAT_YV12:
+ /* YV12 is planar, but must be a single buffer so ask for GR88 */
+ fmt = GBM_FORMAT_GR88;
+ break;
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ default:
+ fmt = 0;
+ break;
+ }
+
+ return fmt;
+}
+
+static int gralloc_gbm_get_bpp(int format)
+{
+ int bpp;
+
+ switch (format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ bpp = 4;
+ break;
+ case HAL_PIXEL_FORMAT_RGB_888:
+ bpp = 3;
+ break;
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ bpp = 2;
+ break;
+ /* planar; only Y is considered */
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ bpp = 1;
+ break;
+ default:
+ bpp = 0;
+ break;
+ }
+
+ return bpp;
+}
+
+static unsigned int get_pipe_bind(int usage)
+{
+ unsigned int bind = 0;
+
+ if (usage & (GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN))
+ bind |= GBM_BO_USE_LINEAR;
+ if (usage & GRALLOC_USAGE_CURSOR)
+ ;//bind |= GBM_BO_USE_CURSOR;
+ if (usage & (GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE))
+ bind |= GBM_BO_USE_RENDERING;
+ if (usage & GRALLOC_USAGE_HW_FB)
+ bind |= GBM_BO_USE_SCANOUT;
+ if (usage & GRALLOC_USAGE_HW_COMPOSER)
+ bind |= GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
+
+ return bind;
+}
+
+static struct gbm_bo *gbm_import(struct gbm_device *gbm,
+ buffer_handle_t _handle)
+{
+ struct gbm_bo *bo;
+ struct gralloc_handle_t *handle = gralloc_handle(_handle);
+ #ifdef GBM_BO_IMPORT_FD_MODIFIER
+ struct gbm_import_fd_modifier_data data;
+ #else
+ struct gbm_import_fd_data data;
+ #endif
+
+ int format = get_gbm_format(handle->format);
+ if (handle->prime_fd < 0)
+ return NULL;
+
+ memset(&data, 0, sizeof(data));
+ data.width = handle->width;
+ data.height = handle->height;
+ data.format = format;
+ /* Adjust the width and height for a GBM GR88 buffer */
+ if (handle->format == HAL_PIXEL_FORMAT_YV12) {
+ data.width /= 2;
+ data.height += handle->height / 2;
+ }
+
+ #ifdef GBM_BO_IMPORT_FD_MODIFIER
+ data.num_fds = 1;
+ data.fds[0] = handle->prime_fd;
+ data.strides[0] = handle->stride;
+ data.modifier = handle->modifier;
+ bo = gbm_bo_import(gbm, GBM_BO_IMPORT_FD_MODIFIER, &data, 0);
+ #else
+ data.fd = handle->prime_fd;
+ data.stride = handle->stride;
+ bo = gbm_bo_import(gbm, GBM_BO_IMPORT_FD, &data, 0);
+ #endif
+
+ return bo;
+}
+
+static struct gbm_bo *gbm_alloc(struct gbm_device *gbm,
+ buffer_handle_t _handle)
+{
+ struct gbm_bo *bo;
+ struct gralloc_handle_t *handle = gralloc_handle(_handle);
+ int format = get_gbm_format(handle->format);
+ int usage = get_pipe_bind(handle->usage);
+ int width, height;
+
+ width = handle->width;
+ height = handle->height;
+ if (usage & GBM_BO_USE_CURSOR) {
+ if (handle->width < 64)
+ width = 64;
+ if (handle->height < 64)
+ height = 64;
+ }
+
+ /*
+ * For YV12, we request GR88, so halve the width since we're getting
+ * 16bpp. Then increase the height by 1.5 for the U and V planes.
+ */
+ if (handle->format == HAL_PIXEL_FORMAT_YV12) {
+ width /= 2;
+ height += handle->height / 2;
+ }
+
+ ALOGV("create BO, size=%dx%d, fmt=%d, usage=%x",
+ handle->width, handle->height, handle->format, usage);
+ bo = gbm_bo_create(gbm, width, height, format, usage);
+ if (!bo) {
+ ALOGE("failed to create BO, size=%dx%d, fmt=%d, usage=%x",
+ handle->width, handle->height, handle->format, usage);
+ return NULL;
+ }
+
+ handle->prime_fd = gbm_bo_get_fd(bo);
+ handle->stride = gbm_bo_get_stride(bo);
+ #ifdef GBM_BO_IMPORT_FD_MODIFIER
+ handle->modifier = gbm_bo_get_modifier(bo);
+ #endif
+
+ return bo;
+}
+
+void gbm_free(buffer_handle_t handle)
+{
+ struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
+
+ if (!bo)
+ return;
+
+ gbm_bo_handle_map.erase(handle);
+ gbm_bo_destroy(bo);
+}
+
+/*
+ * Return the bo of a registered handle.
+ */
+struct gbm_bo *gralloc_gbm_bo_from_handle(buffer_handle_t handle)
+{
+ return gbm_bo_handle_map[handle];
+}
+
+static int gbm_map(buffer_handle_t handle, int x, int y, int w, int h,
+ int enable_write, void **addr)
+{
+ int err = 0;
+ int flags = GBM_BO_TRANSFER_READ;
+ struct gralloc_gbm_handle_t *gbm_handle = gralloc_handle(handle);
+ struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
+ struct bo_data_t *bo_data = gbm_bo_data(bo);
+ uint32_t stride;
+
+ if (bo_data->map_data)
+ return -EINVAL;
+
+ if (gbm_handle->format == HAL_PIXEL_FORMAT_YV12) {
+ if (x || y)
+ ALOGE("can't map with offset for planar %p", bo);
+ w /= 2;
+ h += h / 2;
+ }
+
+ if (enable_write)
+ flags |= GBM_BO_TRANSFER_WRITE;
+
+ *addr = gbm_bo_map(bo, 0, 0, x + w, y + h, flags, &stride, &bo_data->map_data);
+ ALOGV("mapped bo %p (%d, %d)-(%d, %d) at %p", bo, x, y, w, h, *addr);
+ if (*addr == NULL)
+ return -ENOMEM;
+
+ assert(stride == gbm_bo_get_stride(bo));
+
+ return err;
+}
+
+static void gbm_unmap(struct gbm_bo *bo)
+{
+ struct bo_data_t *bo_data = gbm_bo_data(bo);
+
+ gbm_bo_unmap(bo, bo_data->map_data);
+ bo_data->map_data = NULL;
+}
+
+void gbm_dev_destroy(struct gbm_device *gbm)
+{
+ int fd = gbm_device_get_fd(gbm);
+
+ gbm_device_destroy(gbm);
+ close(fd);
+}
+
+struct gbm_device *gbm_dev_create(void)
+{
+ struct gbm_device *gbm;
+ char path[PROPERTY_VALUE_MAX];
+ int fd;
+
+ property_get("gralloc.gbm.device", path, "/dev/dri/renderD128");
+ fd = open(path, O_RDWR | O_CLOEXEC);
+ if (fd < 0) {
+ ALOGE("failed to open %s", path);
+ return NULL;
+ }
+
+ gbm = gbm_create_device(fd);
+ if (!gbm) {
+ ALOGE("failed to create gbm device");
+ close(fd);
+ }
+
+ return gbm;
+}
+
+/*
+ * Register a buffer handle.
+ */
+int gralloc_gbm_handle_register(buffer_handle_t _handle, struct gbm_device *gbm)
+{
+ struct gbm_bo *bo;
+
+ if (!_handle)
+ return -EINVAL;
+
+ if (gbm_bo_handle_map.count(_handle))
+ return -EINVAL;
+
+ bo = gbm_import(gbm, _handle);
+ if (!bo)
+ return -EINVAL;
+
+ gbm_bo_handle_map.emplace(_handle, bo);
+
+ return 0;
+}
+
+/*
+ * Unregister a buffer handle. It is no-op for handles created locally.
+ */
+int gralloc_gbm_handle_unregister(buffer_handle_t handle)
+{
+ gbm_free(handle);
+
+ return 0;
+}
+
+/*
+ * Create a bo.
+ */
+buffer_handle_t gralloc_gbm_bo_create(struct gbm_device *gbm,
+ int width, int height, int format, int usage, int *stride)
+{
+ struct gbm_bo *bo;
+ native_handle_t *handle;
+
+ handle = gralloc_handle_create(width, height, format, usage);
+ if (!handle)
+ return NULL;
+
+ bo = gbm_alloc(gbm, handle);
+ if (!bo) {
+ native_handle_delete(handle);
+ return NULL;
+ }
+
+ gbm_bo_handle_map.emplace(handle, bo);
+
+ /* in pixels */
+ struct gralloc_handle_t *ghandle = gralloc_handle(handle);
+ *stride = ghandle->stride / gralloc_gbm_get_bpp(format);
+
+ return handle;
+}
+
+/*
+ * Lock a bo. XXX thread-safety?
+ */
+int gralloc_gbm_bo_lock(buffer_handle_t handle,
+ int usage, int x, int y, int w, int h,
+ void **addr)
+{
+ struct gralloc_handle_t *gbm_handle = gralloc_handle(handle);
+ struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
+ struct bo_data_t *bo_data;
+
+ if (!bo)
+ return -EINVAL;
+
+ if ((gbm_handle->usage & usage) != (uint32_t)usage) {
+ /* make FB special for testing software renderer with */
+
+ if (!(gbm_handle->usage & GRALLOC_USAGE_SW_READ_OFTEN) &&
+ !(gbm_handle->usage & GRALLOC_USAGE_HW_FB) &&
+ !(gbm_handle->usage & GRALLOC_USAGE_HW_TEXTURE)) {
+ ALOGE("bo.usage:x%X/usage:x%X is not GRALLOC_USAGE_HW_FB or GRALLOC_USAGE_HW_TEXTURE",
+ gbm_handle->usage, usage);
+ return -EINVAL;
+ }
+ }
+
+ bo_data = gbm_bo_data(bo);
+ if (!bo_data) {
+ bo_data = new struct bo_data_t();
+ gbm_bo_set_user_data(bo, bo_data, gralloc_gbm_destroy_user_data);
+ }
+
+ ALOGI("lock bo %p, cnt=%d, usage=%x", bo, bo_data->lock_count, usage);
+
+ /* allow multiple locks with compatible usages */
+ if (bo_data->lock_count && (bo_data->locked_for & usage) != usage)
+ return -EINVAL;
+
+ usage |= bo_data->locked_for;
+
+ if (usage & (GRALLOC_USAGE_SW_WRITE_MASK |
+ GRALLOC_USAGE_SW_READ_MASK)) {
+ /* the driver is supposed to wait for the bo */
+ int write = !!(usage & GRALLOC_USAGE_SW_WRITE_MASK);
+ int err = gbm_map(handle, x, y, w, h, write, addr);
+ if (err)
+ return err;
+ }
+ else {
+ /* kernel handles the synchronization here */
+ }
+
+ bo_data->lock_count++;
+ bo_data->locked_for |= usage;
+
+ return 0;
+}
+
+/*
+ * Unlock a bo.
+ */
+int gralloc_gbm_bo_unlock(buffer_handle_t handle)
+{
+ struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
+ struct bo_data_t *bo_data;
+ if (!bo)
+ return -EINVAL;
+
+ bo_data = gbm_bo_data(bo);
+
+ int mapped = bo_data->locked_for &
+ (GRALLOC_USAGE_SW_WRITE_MASK | GRALLOC_USAGE_SW_READ_MASK);
+
+ if (!bo_data->lock_count)
+ return 0;
+
+ if (mapped)
+ gbm_unmap(bo);
+
+ bo_data->lock_count--;
+ if (!bo_data->lock_count)
+ bo_data->locked_for = 0;
+
+ return 0;
+}
diff --git a/gralloc/gralloc_gbm_priv.h b/gralloc/gralloc_gbm_priv.h
new file mode 100644
index 0000000..7174fb8
--- /dev/null
+++ b/gralloc/gralloc_gbm_priv.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright (C) 2010-2011 LunarG Inc.
+ * Copyright (C) 2016 Linaro, Ltd., Rob Herring <robh@kernel.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _GRALLOC_GBM_PRIV_H_
+#define _GRALLOC_GBM_PRIV_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gbm_device;
+struct gbm_bo;
+
+int gralloc_gbm_handle_register(buffer_handle_t handle, struct gbm_device *gbm);
+int gralloc_gbm_handle_unregister(buffer_handle_t handle);
+
+buffer_handle_t gralloc_gbm_bo_create(struct gbm_device *gbm,
+ int width, int height, int format, int usage, int *stride);
+void gbm_free(buffer_handle_t handle);
+
+struct gbm_bo *gralloc_gbm_bo_from_handle(buffer_handle_t handle);
+buffer_handle_t gralloc_gbm_bo_get_handle(struct gbm_bo *bo);
+int gralloc_gbm_get_gem_handle(buffer_handle_t handle);
+
+int gralloc_gbm_bo_lock(buffer_handle_t handle, int x, int y, int w, int h, int enable_write, void **addr);
+int gralloc_gbm_bo_unlock(buffer_handle_t handle);
+
+struct gbm_device *gbm_dev_create(void);
+void gbm_dev_destroy(struct gbm_device *gbm);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _GRALLOC_GBM_PRIV_H_ */
diff --git a/init.common.rc b/init.common.rc
new file mode 100644
index 0000000..8b8f952
--- /dev/null
+++ b/init.common.rc
@@ -0,0 +1,57 @@
+import init.${ro.hardware}.usb.rc
+import init.${ro.hardware}.power.rc
+
+on fs
+ mount_all /vendor/etc/init/fstab.${ro.hardware}
+ swapon_all /vendor/etc/init/fstab.${ro.hardware}
+
+on init
+ # For legacy support
+ # See storage config details at http://source.android.com/tech/storage/
+ # since /storage is mounted on post-fs in init.rc
+ symlink /sdcard /storage/sdcard0
+
+ # Initialize cpusets to boot-time values
+ write /dev/cpuset/foreground/cpus 0-7
+ write /dev/cpuset/background/cpus 0-7
+ write /dev/cpuset/system-background/cpus 0-7
+ write /dev/cpuset/top-app/cpus 0-7
+
+on early-boot
+ mount debugfs debugfs /sys/kernel/debug
+ chmod 755 /sys/kernel/debug
+ chmod 755 /sys/kernel/debug/sync
+ chown graphics graphics /sys/kernel/debug/sync/sw_sync
+ chmod 777 /sys/kernel/debug/sync/sw_sync
+ chown graphics graphics /sys/kernel/debug/sync/info
+
+on zygote-start
+ mkdir /data/vendor/wifi 0770 wifi wifi
+ mkdir /data/vendor/wifi/wpa 0770 wifi wifi
+ mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi
+
+on property:sys.boot_completed=1
+ # update cpuset now that processors are up
+ # Foreground should contain most cores (7 is reserved for top-app)
+ write /dev/cpuset/foreground/cpus 0-6
+
+ # top-app gets all cpus (including reserved #7)
+ write /dev/cpuset/top-app/cpus 0-7
+
+ #background contains a small subset (generally one little core)
+ write /dev/cpuset/background/cpus 0
+
+ # add system-background cpuset, a new cpuset for system services
+ # that should not run on larger cores
+ # system-background is for system tasks that should only run on
+ # little cores, not on bigs to be used only by init
+ write /dev/cpuset/system-background/cpus 0-3
+
+service wpa_supplicant /vendor/bin/hw/wpa_supplicant \
+ -Dnl80211 -g@android:wpa_wlan0
+ interface android.hardware.wifi.supplicant@1.0::ISupplicant default
+ interface android.hardware.wifi.supplicant@1.1::ISupplicant default
+ socket wpa_wlan0 dgram 660 wifi wifi
+ class main
+ disabled
+ oneshot
diff --git a/init.common.usb.rc b/init.common.usb.rc
new file mode 100644
index 0000000..50a4340
--- /dev/null
+++ b/init.common.usb.rc
@@ -0,0 +1,88 @@
+on boot
+ mount configfs none /config
+ mkdir /config/usb_gadget/g1 0770 shell shell
+ mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell
+ write /config/usb_gadget/g1/bcdUSB 0x0200
+ write /config/usb_gadget/g1/idVendor 0x18d1
+ write /config/usb_gadget/g1/bcdDevice 0x0223
+ write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
+ write /config/usb_gadget/g1/strings/0x409/manufacturer "QUALCOMM"
+ write /config/usb_gadget/g1/strings/0x409/product "Android Gadget"
+ mkdir /config/usb_gadget/g1/functions/accessory.gs2
+ mkdir /config/usb_gadget/g1/functions/audio_source.gs3
+ mkdir /config/usb_gadget/g1/functions/midi.gs5
+ mkdir /config/usb_gadget/g1/functions/ffs.adb
+ mkdir /config/usb_gadget/g1/functions/ffs.mtp
+ mkdir /config/usb_gadget/g1/functions/ffs.ptp
+ mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell
+ mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
+ write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
+ write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
+ write /config/usb_gadget/g1/configs/b.1/MaxPower 500
+ mkdir /dev/usb-ffs 0775 shell shell
+ mkdir /dev/usb-ffs/adb 0770 shell shell
+ mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
+ mkdir /dev/usb-ffs/mtp 0770 mtp mtp
+ mkdir /dev/usb-ffs/ptp 0770 mtp mtp
+ mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
+ mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
+ setprop sys.usb.mtp.device_type 3
+ setprop sys.usb.configfs 1
+ setprop sys.usb.ffs.aio_compat 1
+ symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
+
+on property:sys.usb.config=none && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/os_desc/use 0
+
+on property:sys.usb.config=mtp && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee1
+ write /config/usb_gadget/g1/os_desc/use 1
+ symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=mtp,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee2
+ write /config/usb_gadget/g1/os_desc/use 1
+ symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1
+
+on property:sys.usb.config=rndis && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee3
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee4
+
+on property:sys.usb.config=ptp && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee5
+ write /config/usb_gadget/g1/os_desc/use 1
+ symlink /config/usb_gadget/g1/functions/ffs.ptp /config/usb_gadget/g1/configs/b.1/f1
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=ptp,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee6
+ write /config/usb_gadget/g1/os_desc/use 1
+ symlink /config/usb_gadget/g1/functions/ffs.ptp /config/usb_gadget/g1/configs/b.1/f1
+
+on property:sys.usb.config=adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee7
+
+on property:sys.usb.config=midi && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee8
+
+on property:sys.usb.config=midi,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee9
+
+on property:sys.usb.config=accessory && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d00
+
+on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d01
+
+on property:sys.usb.config=audio_source && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d02
+
+on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d03
+
+on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d04
+
+on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d05
diff --git a/libmemtrack/Android.mk b/libmemtrack/Android.mk
new file mode 100644
index 0000000..913cb22
--- /dev/null
+++ b/libmemtrack/Android.mk
@@ -0,0 +1,29 @@
+# Copyright (C) 2017 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)
+
+# HAL module implemenation stored in
+# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_PROPRIETARY_MODULE := true
+LOCAL_C_INCLUDES += hardware/libhardware/include
+LOCAL_CFLAGS := -Wconversion -Wall -Werror -Wno-sign-conversion
+LOCAL_CLANG := true
+LOCAL_SHARED_LIBRARIES := liblog libhardware
+LOCAL_SRC_FILES := memtrack_dragonboard.c
+LOCAL_MODULE := memtrack.default
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libmemtrack/memtrack_dragonboard.c b/libmemtrack/memtrack_dragonboard.c
new file mode 100644
index 0000000..b7da750
--- /dev/null
+++ b/libmemtrack/memtrack_dragonboard.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 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 <hardware/memtrack.h>
+
+int dragonboard_memtrack_init(const struct memtrack_module *module)
+{
+ if (!module)
+ return -1;
+
+ return 0;
+}
+
+static struct hw_module_methods_t memtrack_module_methods = {
+ .open = NULL,
+};
+
+struct memtrack_module HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = MEMTRACK_MODULE_API_VERSION_0_1,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = MEMTRACK_HARDWARE_MODULE_ID,
+ .name = "Dummy Memory Tracker HAL for Dragonboards",
+ .author = "The Android Open Source Project",
+ .methods = &memtrack_module_methods,
+ },
+
+ .init = dragonboard_memtrack_init,
+};
diff --git a/manifest.xml b/manifest.xml
new file mode 100644
index 0000000..aa55ddc
--- /dev/null
+++ b/manifest.xml
@@ -0,0 +1,136 @@
+<manifest version="1.0" type="device" target-level="2">
+ <hal format="hidl">
+ <name>android.hardware.graphics.allocator</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IAllocator</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.graphics.composer</name>
+ <transport>hwbinder</transport>
+ <version>2.2</version>
+ <interface>
+ <name>IComposer</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.graphics.mapper</name>
+ <transport arch="32+64">passthrough</transport>
+ <version>2.1</version>
+ <interface>
+ <name>IMapper</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.configstore</name>
+ <transport>hwbinder</transport>
+ <version>1.1</version>
+ <interface>
+ <name>ISurfaceFlingerConfigs</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.drm</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>ICryptoFactory</name>
+ <instance>default</instance>
+ </interface>
+ <interface>
+ <name>IDrmFactory</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.media.omx</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IOmx</name>
+ <instance>default</instance>
+ </interface>
+ <interface>
+ <name>IOmxStore</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.soundtrigger</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>ISoundTriggerHw</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.audio</name>
+ <transport>hwbinder</transport>
+ <version>4.0</version>
+ <interface>
+ <name>IDevicesFactory</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.audio.effect</name>
+ <transport>hwbinder</transport>
+ <version>4.0</version>
+ <interface>
+ <name>IEffectsFactory</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.bluetooth</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IBluetoothHci</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.wifi.supplicant</name>
+ <transport>hwbinder</transport>
+ <version>1.2</version>
+ <interface>
+ <name>ISupplicant</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.wifi.hostapd</name>
+ <transport>hwbinder</transport>
+ <version>1.1</version>
+ <interface>
+ <name>IHostapd</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.keymaster</name>
+ <transport>hwbinder</transport>
+ <version>3.0</version>
+ <interface>
+ <name>IKeymasterDevice</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.memtrack</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IMemtrack</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
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..f241581
--- /dev/null
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -0,0 +1,89 @@
+<?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>
+
+ <!-- Integer indicating the framework scan interval in milliseconds. -->
+ <integer translatable="false" name="config_wifi_framework_scan_interval">10000</integer>
+
+ <!-- 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>"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>
+
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ Wifi interfaces. If the device doesn't want to support tethering over Wifi this
+ should be empty. An example would be "softap.*" -->
+ <string-array translatable="false" name="config_tether_wifi_regexs">
+ <item>"wlan0"</item>
+ <item>"softap.*"</item>
+ </string-array>
+
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ USB interfaces. If the device doesn't want to support tethering over USB this should
+ be empty. An example would be "usb.*" -->
+ <string-array translatable="false" name="config_tether_usb_regexs">
+ <item>"usb\\d"</item>
+ <item>"rndis\\d"</item>
+ </string-array>
+
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ bluetooth interfaces. If the device doesn't want to support tethering over bluetooth this
+ should be empty. -->
+ <string-array translatable="false" name="config_tether_bluetooth_regexs">
+ <item>"bt-pan"</item>
+ </string-array>
+
+ <!-- Array of allowable ConnectivityManager network types for tethering -->
+ <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or
+ [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->
+ <integer-array translatable="false" name="config_tether_upstream_types">
+ <item>1</item>
+ <item>7</item>
+ </integer-array>
+
+</resources>
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/p2p_supplicant_overlay.conf b/p2p_supplicant_overlay.conf
new file mode 100644
index 0000000..acbace2
--- /dev/null
+++ b/p2p_supplicant_overlay.conf
@@ -0,0 +1 @@
+disable_scan_offload=1
diff --git a/sepolicy/app.te b/sepolicy/app.te
new file mode 100644
index 0000000..890e6e6
--- /dev/null
+++ b/sepolicy/app.te
@@ -0,0 +1,4 @@
+# Few system/untrusted_app_xx apps eg. deskclock,
+# gallery3d et al. need read-only access to /dev/dri
+# as well, otherwise they don't open and crash.
+gpu_access(appdomain -isolated_app)
diff --git a/sepolicy/bootanim.te b/sepolicy/bootanim.te
new file mode 100644
index 0000000..e8e7494
--- /dev/null
+++ b/sepolicy/bootanim.te
@@ -0,0 +1 @@
+gpu_access(bootanim)
diff --git a/sepolicy/crash_dump.te b/sepolicy/crash_dump.te
new file mode 100644
index 0000000..b575e22
--- /dev/null
+++ b/sepolicy/crash_dump.te
@@ -0,0 +1,7 @@
+# audit2allow
+allow crash_dump bluetooth_data_file:file { getattr map open read };
+allow crash_dump bluetooth_prop:file { getattr map open };
+allow crash_dump device_config_runtime_native_boot_prop:file { getattr map open };
+allow crash_dump device_config_runtime_native_prop:file { getattr map open };
+allow crash_dump hwservicemanager_prop:file { getattr map open };
+allow crash_dump runtime_event_log_tags_file:file getattr;
diff --git a/sepolicy/dnsmasq.te b/sepolicy/dnsmasq.te
new file mode 100644
index 0000000..1154d8a
--- /dev/null
+++ b/sepolicy/dnsmasq.te
@@ -0,0 +1,3 @@
+# audit2allow
+allow dnsmasq netd:fifo_file getattr;
+allow dnsmasq netd:unix_stream_socket getattr;
diff --git a/sepolicy/file.te b/sepolicy/file.te
new file mode 100644
index 0000000..4d9988f
--- /dev/null
+++ b/sepolicy/file.te
@@ -0,0 +1,2 @@
+type sysfs_gpu, fs_type, sysfs_type;
+type dri_device, dev_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
new file mode 100644
index 0000000..ab364f8
--- /dev/null
+++ b/sepolicy/file_contexts
@@ -0,0 +1,17 @@
+/dev/block/by-name/metadata u:object_r:metadata_block_device:s0
+/dev/dri u:object_r:dri_device:s0
+/dev/dri/card0 u:object_r:graphics_device:s0
+/dev/dri/renderD128 u:object_r:gpu_device:s0
+/dev/ttyMSM0 u:object_r:console_device:s0
+
+/sys/devices/platform/soc/ae00000.mdss u:object_r:sysfs_gpu:s0
+/sys/devices/platform/soc/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/rtc u:object_r:sysfs_rtc:s0
+
+/vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service\.software u:object_r:hal_gatekeeper_default_exec:s0
+
+/vendor/lib(64)?/dri/.* u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/gralloc\.gbm\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libdrm\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libdrm_freedreno\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libgbm\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libglapi\.so u:object_r:same_process_hal_file:s0
diff --git a/sepolicy/genfs_contexts b/sepolicy/genfs_contexts
new file mode 100644
index 0000000..52338f0
--- /dev/null
+++ b/sepolicy/genfs_contexts
@@ -0,0 +1,3 @@
+genfscon sysfs /devices/platform/soc/ae00000.mdss u:object_r:sysfs_gpu:s0
+
+genfscon sysfs /devices/platform/soc/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000 u:object_r:sysfs_rtc:s0
diff --git a/sepolicy/hal_drm_default.te b/sepolicy/hal_drm_default.te
new file mode 100644
index 0000000..e783575
--- /dev/null
+++ b/sepolicy/hal_drm_default.te
@@ -0,0 +1,2 @@
+# audit2allow
+allow hal_drm_default vndbinder_device:chr_file rw_file_perms;
diff --git a/sepolicy/hal_graphics_allocator_default.te b/sepolicy/hal_graphics_allocator_default.te
new file mode 100644
index 0000000..00f38cc
--- /dev/null
+++ b/sepolicy/hal_graphics_allocator_default.te
@@ -0,0 +1 @@
+gpu_access(hal_graphics_allocator_default)
diff --git a/sepolicy/hal_graphics_composer.te b/sepolicy/hal_graphics_composer.te
new file mode 100644
index 0000000..40dbe25
--- /dev/null
+++ b/sepolicy/hal_graphics_composer.te
@@ -0,0 +1 @@
+gpu_access(hal_graphics_composer_server)
diff --git a/sepolicy/hal_graphics_composer_default.te b/sepolicy/hal_graphics_composer_default.te
new file mode 100644
index 0000000..9c310f6
--- /dev/null
+++ b/sepolicy/hal_graphics_composer_default.te
@@ -0,0 +1,3 @@
+vndbinder_use(hal_graphics_composer_default)
+
+allow hal_graphics_composer_default self:netlink_kobject_uevent_socket { bind create read };
diff --git a/sepolicy/hal_memtrack.te b/sepolicy/hal_memtrack.te
new file mode 100644
index 0000000..51bd527
--- /dev/null
+++ b/sepolicy/hal_memtrack.te
@@ -0,0 +1,4 @@
+# Memtrack reads proc/<pid>/cmdline to check if process is surfaceflinger.
+# Grant access if that's the case; don't log denials for other processes.
+allow hal_memtrack surfaceflinger:file read;
+dontaudit hal_memtrack { domain -surfaceflinger}:file read;
diff --git a/sepolicy/hal_wifi_supplicant_default.te b/sepolicy/hal_wifi_supplicant_default.te
new file mode 100644
index 0000000..c657db5
--- /dev/null
+++ b/sepolicy/hal_wifi_supplicant_default.te
@@ -0,0 +1,6 @@
+# TODO(b/36657258): Remove data_between_core_and_vendor_violators once
+# hal_wifi_supplicant no longer directly accesses wifi_data_file.
+typeattribute hal_wifi_supplicant_default data_between_core_and_vendor_violators;
+
+allow hal_wifi_supplicant_default wifi_data_file:dir create_dir_perms;
+allow hal_wifi_supplicant_default wifi_data_file:file create_file_perms;
diff --git a/sepolicy/kernel.te b/sepolicy/kernel.te
new file mode 100644
index 0000000..46bfee5
--- /dev/null
+++ b/sepolicy/kernel.te
@@ -0,0 +1,5 @@
+# audit2allow
+allow kernel device:chr_file { create setattr };
+allow kernel device:dir { add_name create write };
+allow kernel self:capability mknod;
+allow kernel vendor_file:file { open read };
diff --git a/sepolicy/netd.te b/sepolicy/netd.te
new file mode 100644
index 0000000..2e954bb
--- /dev/null
+++ b/sepolicy/netd.te
@@ -0,0 +1,3 @@
+# audit2allow
+allow netd kernel:system module_request;
+allow netd self:capability sys_module;
diff --git a/sepolicy/platform_app.te b/sepolicy/platform_app.te
new file mode 100644
index 0000000..775e964
--- /dev/null
+++ b/sepolicy/platform_app.te
@@ -0,0 +1 @@
+gpu_access(platform_app)
diff --git a/sepolicy/priv_app.te b/sepolicy/priv_app.te
new file mode 100644
index 0000000..05c9e47
--- /dev/null
+++ b/sepolicy/priv_app.te
@@ -0,0 +1 @@
+gpu_access(priv_app)
diff --git a/sepolicy/surfaceflinger.te b/sepolicy/surfaceflinger.te
new file mode 100644
index 0000000..17b66a8
--- /dev/null
+++ b/sepolicy/surfaceflinger.te
@@ -0,0 +1 @@
+gpu_access(surfaceflinger)
diff --git a/sepolicy/system_app.te b/sepolicy/system_app.te
new file mode 100644
index 0000000..4a85066
--- /dev/null
+++ b/sepolicy/system_app.te
@@ -0,0 +1 @@
+gpu_access(system_app)
diff --git a/sepolicy/system_server.te b/sepolicy/system_server.te
new file mode 100644
index 0000000..80957cc
--- /dev/null
+++ b/sepolicy/system_server.te
@@ -0,0 +1 @@
+gpu_access(system_server)
diff --git a/sepolicy/te_macros b/sepolicy/te_macros
new file mode 100644
index 0000000..322827a
--- /dev/null
+++ b/sepolicy/te_macros
@@ -0,0 +1,8 @@
+#####################################
+# gpu_access(client_domain)
+# Allow client_domain to communicate with the GPU
+define(`gpu_access', `
+allow $1 dri_device:dir { open read search };
+allow $1 sysfs_gpu:dir search;
+allow $1 sysfs_gpu:file { getattr open read };
+')
diff --git a/ueventd.common.rc b/ueventd.common.rc
new file mode 100644
index 0000000..173b6f4
--- /dev/null
+++ b/ueventd.common.rc
@@ -0,0 +1,8 @@
+/dev/sw_sync 0660 root graphics
+
+# gpu
+/dev/dri/card0 0660 system graphics
+/dev/dri/renderD128 0666 system graphics
+
+# media.codec2
+/dev/ion 0664 system system
diff --git a/wpa_supplicant_overlay.conf b/wpa_supplicant_overlay.conf
new file mode 100644
index 0000000..e1f530d
--- /dev/null
+++ b/wpa_supplicant_overlay.conf
@@ -0,0 +1,3 @@
+disable_scan_offload=1
+p2p_disabled=1
+tdls_external_control=1