diff --git a/BoardConfig.mk b/BoardConfig.mk index 3d5ceea..010f0bf 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -64,7 +64,9 @@ TARGET_SCREEN_WIDTH := 1536 TARGET_BOOTANIMATION_HALF_RES := true #Camera shims -TARGET_LD_SHIM_LIBS += /system/vendor/lib/hw/camera.tegra.so|/system/vendor/lib/libcamera_shim.so +TARGET_HAS_LEGACY_CAMERA_HAL1 := true +TARGET_NEEDS_LEGACY_CAMERA_HAL1_DYN_NATIVE_HANDLE := true +TARGET_USES_NON_TREBLE_CAMERA := true # Disable dex pre-opt WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY := false diff --git a/camera/Android.mk b/camera/Android.mk new file mode 100644 index 0000000..ba84cdd --- /dev/null +++ b/camera/Android.mk @@ -0,0 +1,25 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + Camera3Wrapper.cpp \ + CameraWrapper.cpp + +LOCAL_SHARED_LIBRARIES := \ + libhardware liblog libcamera_client libutils libgui libhidltransport libcamera_metadata libsensor android.hidl.token@1.0-utils android.hardware.graphics.bufferqueue@1.0 + +LOCAL_C_INCLUDES += \ + framework/native/include \ + system/core/include \ + system/media/camera/include + +LOCAL_HEADER_LIBRARIES := libnativebase_headers + +LOCAL_32_BIT_ONLY := true +#LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw +LOCAL_MODULE_RELATIVE_PATH := hw + +LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) diff --git a/camera/Camera3Wrapper.cpp b/camera/Camera3Wrapper.cpp new file mode 100644 index 0000000..a52e66d --- /dev/null +++ b/camera/Camera3Wrapper.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2012, The CyanogenMod 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_NDEBUG 0 + +#define LOG_TAG "Camera3Wrapper" +#include + +#include "CameraWrapper.h" +#include "Camera3Wrapper.h" + +typedef struct wrapper_camera3_device { + camera3_device_t base; + int id; + camera3_device_t *vendor; +} wrapper_camera3_device_t; + +#define VENDOR_CALL(device, func, ...) ({ \ + wrapper_camera3_device_t *__wrapper_dev = (wrapper_camera3_device_t*) device; \ + __wrapper_dev->vendor->ops->func(__wrapper_dev->vendor, ##__VA_ARGS__); \ +}) + +#define CAMERA_ID(device) (((wrapper_camera3_device_t *)(device))->id) + +static camera_module_t *gVendorModule = 0; + +static int check_vendor_module() +{ + int rv = 0; + ALOGV("%s", __FUNCTION__); + + if(gVendorModule) + return 0; + + rv = hw_get_module_by_class("camera", "vendor", (const hw_module_t **)&gVendorModule); + if (rv) + ALOGE("failed to open vendor camera module"); + return rv; +} + +/******************************************************************* + * implementation of camera_device_ops functions + *******************************************************************/ + +static int camera3_initialize(const camera3_device_t *device, const camera3_callback_ops_t *callback_ops) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return -1; + + return VENDOR_CALL(device, initialize, callback_ops); +} + +static int camera3_configure_streams(const camera3_device *device, camera3_stream_configuration_t *stream_list) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return -1; + + return VENDOR_CALL(device, configure_streams, stream_list); +} + +static int camera3_register_stream_buffers(const camera3_device *device, const camera3_stream_buffer_set_t *buffer_set) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return -1; + + return VENDOR_CALL(device, register_stream_buffers, buffer_set); +} + +static const camera_metadata_t *camera3_construct_default_request_settings(const camera3_device_t *device, int type) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return NULL; + + return VENDOR_CALL(device, construct_default_request_settings, type); +} + +static int camera3_process_capture_request(const camera3_device_t *device, camera3_capture_request_t *request) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return -1; + + return VENDOR_CALL(device, process_capture_request, request); +} + +static void camera3_get_metadata_vendor_tag_ops(const camera3_device *device, vendor_tag_query_ops_t* ops) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return; + + VENDOR_CALL(device, get_metadata_vendor_tag_ops, ops); +} + +static void camera3_dump(const camera3_device_t *device, int fd) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return; + + VENDOR_CALL(device, dump, fd); +} + +static int camera3_flush(const camera3_device_t* device) +{ + ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, + (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); + + if (!device) + return -1; + + return VENDOR_CALL(device, flush); +} + +static int camera3_device_close(hw_device_t *device) +{ + int ret = 0; + wrapper_camera3_device_t *wrapper_dev = NULL; + + ALOGV("%s", __FUNCTION__); + + android::Mutex::Autolock lock(gCameraWrapperLock); + + if (!device) { + ret = -EINVAL; + goto done; + } + + wrapper_dev = (wrapper_camera3_device_t*) device; + + wrapper_dev->vendor->common.close((hw_device_t*)wrapper_dev->vendor); + if (wrapper_dev->base.ops) + free(wrapper_dev->base.ops); + free(wrapper_dev); +done: + return ret; +} + +/******************************************************************* + * implementation of camera_module functions + *******************************************************************/ + +/* open device handle to one of the cameras + * + * assume camera service will keep singleton of each camera + * so this function will always only be called once per camera instance + */ + +int camera3_device_open(const hw_module_t *module, const char *name, + hw_device_t **device) +{ + int rv = 0; + int num_cameras = 0; + int cameraid; + wrapper_camera3_device_t *camera3_device = NULL; + camera3_device_ops_t *camera3_ops = NULL; + + android::Mutex::Autolock lock(gCameraWrapperLock); + + ALOGV("%s", __FUNCTION__); + + if (name != NULL) { + if (check_vendor_module()) + return -EINVAL; + + cameraid = atoi(name); + num_cameras = gVendorModule->get_number_of_cameras(); + + if (cameraid > num_cameras) { + ALOGE("camera service provided cameraid out of bounds, " + "cameraid = %d, num supported = %d", + cameraid, num_cameras); + rv = -EINVAL; + goto fail; + } + + camera3_device = (wrapper_camera3_device_t*)malloc(sizeof(*camera3_device)); + if (!camera3_device) { + ALOGE("camera3_device allocation fail"); + rv = -ENOMEM; + goto fail; + } + memset(camera3_device, 0, sizeof(*camera3_device)); + camera3_device->id = cameraid; + + rv = gVendorModule->common.methods->open((const hw_module_t*)gVendorModule, name, (hw_device_t**)&(camera3_device->vendor)); + if (rv) + { + ALOGE("vendor camera open fail"); + goto fail; + } + ALOGV("%s: got vendor camera device 0x%08X", __FUNCTION__, (uintptr_t)(camera3_device->vendor)); + + camera3_ops = (camera3_device_ops_t*)malloc(sizeof(*camera3_ops)); + if (!camera3_ops) { + ALOGE("camera3_ops allocation fail"); + rv = -ENOMEM; + goto fail; + } + + memset(camera3_ops, 0, sizeof(*camera3_ops)); + + camera3_device->base.common.tag = HARDWARE_DEVICE_TAG; + camera3_device->base.common.version = CAMERA_DEVICE_API_VERSION_3_0; + camera3_device->base.common.module = (hw_module_t *)(module); + camera3_device->base.common.close = camera3_device_close; + camera3_device->base.ops = camera3_ops; + + camera3_ops->initialize = camera3_initialize; + camera3_ops->configure_streams = camera3_configure_streams; + camera3_ops->register_stream_buffers = camera3_register_stream_buffers; + camera3_ops->construct_default_request_settings = camera3_construct_default_request_settings; + camera3_ops->process_capture_request = camera3_process_capture_request; + camera3_ops->get_metadata_vendor_tag_ops = camera3_get_metadata_vendor_tag_ops; + camera3_ops->dump = camera3_dump; + camera3_ops->flush = camera3_flush; + + *device = &camera3_device->base.common; + } + + return rv; + +fail: + if (camera3_device) { + free(camera3_device); + camera3_device = NULL; + } + if (camera3_ops) { + free(camera3_ops); + camera3_ops = NULL; + } + *device = NULL; + return rv; +} diff --git a/camera/Camera3Wrapper.h b/camera/Camera3Wrapper.h new file mode 100644 index 0000000..bf815ca --- /dev/null +++ b/camera/Camera3Wrapper.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2017, The LineageOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +int camera3_device_open(const hw_module_t *module, const char *name, hw_device_t **device); diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp new file mode 100644 index 0000000..88fd261 --- /dev/null +++ b/camera/CameraWrapper.cpp @@ -0,0 +1,226 @@ +/* + * Copyright (C) 2015, The CyanogenMod 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_NDEBUG 0 +#define LOG_PARAMETERS + +#define LOG_TAG "CameraWrapper" +#include +#include "CameraWrapper.h" +#include "Camera3Wrapper.h" + + +//------------DEBUG----------------- +static int pfd[2]; +static pthread_t thr; + +static void *thread_func(void*) +{ + ssize_t rdsz; + char buf[128]; + while((rdsz = read(pfd[0], buf, sizeof buf - 1)) > 0) { + if(buf[rdsz - 1] == '\n') --rdsz; + buf[rdsz] = 0; /* add null-terminator */ + __android_log_write(ANDROID_LOG_DEBUG, LOG_TAG, buf); + } + return 0; +} + + +int start_logger() +{ + + /* make stdout line-buffered and stderr unbuffered */ + setvbuf(stdout, 0, _IOLBF, 0); + setvbuf(stderr, 0, _IONBF, 0); + + /* create the pipe and redirect stdout and stderr */ + pipe(pfd); + dup2(pfd[1], 1); + dup2(pfd[1], 2); + + /* spawn the logging thread */ + if(pthread_create(&thr, 0, thread_func, 0) == -1) + return -1; + pthread_detach(thr); + return 0; +} + + +//-----------DEBUG------------------------- + + +typedef struct camera_metadata_buffer_entry { + uint32_t tag; + uint32_t count; + union { + uint32_t offset; + uint8_t value[4]; + } data; + uint8_t type; + uint8_t reserved[3]; +} camera_metadata_buffer_entry_t; + +typedef uint32_t metadata_uptrdiff_t; +typedef uint32_t metadata_size_t; + +struct camera_metadata { + metadata_size_t size; + uint32_t version; + uint32_t flags; + metadata_size_t entry_count; + metadata_size_t entry_capacity; + metadata_uptrdiff_t entries_start; // Offset from camera_metadata + metadata_size_t data_count; + metadata_size_t data_capacity; + metadata_uptrdiff_t data_start; // Offset from camera_metadata + uint8_t reserved[]; +}; + +static camera_metadata_buffer_entry_t *get_entries( + const camera_metadata_t *metadata) { + return (camera_metadata_buffer_entry_t*) + ((uint8_t*)metadata + metadata->entries_start); +} + + +static camera_module_t *gVendorModule = 0; +static char prop[PROPERTY_VALUE_MAX]; +static camera_metadata_t* vendorInfo[2] = {0,0}; +static camera_info vendor_camera_info; + +static int check_vendor_module() +{ + int rv = 0; + ALOGV("%s", __FUNCTION__); + + if(gVendorModule) + return 0; + + rv = hw_get_module_by_class("camera", "vendor", (const hw_module_t **)&gVendorModule); + if (rv) + ALOGE("failed to open vendor camera module"); + return rv; +} + +static struct hw_module_methods_t camera_module_methods = { + open: camera_device_open +}; + +camera_module_t HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = CAMERA_MODULE_API_VERSION_2_3, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = CAMERA_HARDWARE_MODULE_ID, + .name = "MI PAD Camera Wrapper", + .author = "The CyanogenMod Project", + .methods = &camera_module_methods, + .dso = NULL, + .reserved = {0}, + }, + .get_number_of_cameras = camera_get_number_of_cameras, + .get_camera_info = camera_get_camera_info, + .set_callbacks = camera_set_callbacks, + .get_vendor_tag_ops = camera_get_vendor_tag_ops, + .open_legacy = camera_open_legacy, + .set_torch_mode = NULL, + .init = NULL, + .reserved = {0}, +}; + +static int camera_device_open(const hw_module_t* module, const char* name, + hw_device_t** device) +{ + int rv = -EINVAL; + start_logger(); //DEBUG + + if (name != NULL) { + if (check_vendor_module()) + return -EINVAL; + + rv = camera3_device_open(module, name, device); + } + + return rv; +} + +static int camera_get_number_of_cameras(void) +{ + ALOGV("%s", __FUNCTION__); + if (check_vendor_module()) + return 0; + return gVendorModule->get_number_of_cameras(); +} + +static int camera_get_camera_info(int camera_id, struct camera_info *info) +{ + ALOGV("%s camera_id: = %d", __FUNCTION__, camera_id); + if (check_vendor_module()) + return 0; +// int ret = gVendorModule->get_camera_info(camera_id, info); + int ret = gVendorModule->get_camera_info(camera_id, &vendor_camera_info); +// fillStaticInfo(); + + info->facing = vendor_camera_info.facing; + info->orientation = vendor_camera_info.orientation; + info->device_version = vendor_camera_info.device_version; + + if (vendorInfo[camera_id] == 0 ) { + vendorInfo[camera_id] = (camera_metadata_t*)vendor_camera_info.static_camera_characteristics; + camera_metadata_entry_t found_entry; + find_camera_metadata_entry(vendorInfo[camera_id], ANDROID_CONTROL_MAX_REGIONS, &found_entry); + size_t del_index = found_entry.index; + delete_camera_metadata_entry(vendorInfo[camera_id], del_index); + + find_camera_metadata_entry(vendorInfo[camera_id], ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS, &found_entry); + del_index = found_entry.index; + delete_camera_metadata_entry(vendorInfo[camera_id], del_index); + + int32_t max_regions[3] = {8,8,8}; + add_camera_metadata_entry(vendorInfo[camera_id], ANDROID_CONTROL_MAX_REGIONS, max_regions, 3); + } + + info->static_camera_characteristics = vendorInfo[camera_id]; + dump_camera_metadata(info->static_camera_characteristics, 1, 2); + + return ret; +} + +static int camera_set_callbacks(const camera_module_callbacks_t *callbacks) +{ + ALOGV("%s", __FUNCTION__); + if (check_vendor_module()) + return 0; + return gVendorModule->set_callbacks(callbacks); +} + +static void camera_get_vendor_tag_ops(vendor_tag_ops_t* ops) +{ + ALOGV("%s", __FUNCTION__); + if (check_vendor_module()) + return; + return gVendorModule->get_vendor_tag_ops(ops); +} + +static int camera_open_legacy(const struct hw_module_t* module, const char* id, uint32_t halVersion, struct hw_device_t** device) +{ + ALOGV("%s", __FUNCTION__); + if (check_vendor_module()) + return 0; + + return gVendorModule->open_legacy(module, id, halVersion, device); +} diff --git a/camera/CameraWrapper.h b/camera/CameraWrapper.h new file mode 100644 index 0000000..417a011 --- /dev/null +++ b/camera/CameraWrapper.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017, The LineageOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +static android::Mutex gCameraWrapperLock; + +static int camera_device_open(const hw_module_t* module, const char* name, + hw_device_t** device); +static int camera_device_close(hw_device_t* device); +static int camera_get_number_of_cameras(void); +static int camera_get_camera_info(int camera_id, struct camera_info *info); +static int camera_set_callbacks(const camera_module_callbacks_t *callbacks); +static void camera_get_vendor_tag_ops(vendor_tag_ops_t* ops); +static int camera_open_legacy(const struct hw_module_t* module, const char* id, uint32_t halVersion, struct hw_device_t** device); +static int camera_set_torch_mode(const char* camera_id, bool enabled); diff --git a/device.mk b/device.mk index c660d6e..edcc1ec 100644 --- a/device.mk +++ b/device.mk @@ -21,6 +21,93 @@ TARGET_TEGRA_VERSION := t124 $(call inherit-product-if-exists, vendor/xiaomi/mocha/mocha-vendor.mk) +# Overlay +DEVICE_PACKAGE_OVERLAYS += \ + device/xiaomi/mocha/overlay + +# Ramdisk +PRODUCT_PACKAGES += \ + fstab.tn8 \ + init.cal.rc \ + init.comms.rc \ + init.icera.rc \ + init.hdcp.rc \ + init.ray_touch.rc \ + init.t124.rc \ + init.tegra.rc \ + init.tlk.rc \ + init.tn8.rc \ + init.tn8.usb.rc \ + init.tn8_common.rc \ + init.ussrd.rc \ + power.tn8.rc \ + power.mocha.rc \ + ueventd.tn8.rc \ + ussrd.conf \ + ussr_setup + +# Permissions +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml \ + frameworks/native/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml \ + frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \ + frameworks/native/data/etc/android.hardware.camera.full.xml:system/etc/permissions/android.hardware.camera.full.xml \ + frameworks/native/data/etc/android.hardware.camera.raw.xml:system/etc/permissions/android.hardware.camera.raw.xml \ + frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml \ + frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \ + frameworks/native/data/etc/android.hardware.opengles.aep.xml:system/etc/permissions/android.hardware.opengles.aep.xml \ + frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:system/etc/permissions/android.hardware.vulkan.compute-0.xml \ + frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:system/etc/permissions/android.hardware.vulkan.level.xml \ + frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:system/etc/permissions/android.hardware.vulkan.version.xml \ + frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml \ + frameworks/native/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.sensor.compass.xml \ + frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:system/etc/permissions/android.hardware.sensor.gyroscope.xml \ + frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \ + frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \ + frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml \ + frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml \ + frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \ + frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \ + frameworks/native/data/etc/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml \ + frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:system/etc/permissions/android.hardware.sensor.stepcounter.xml \ + frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:system/etc/permissions/android.hardware.sensor.stepdetector.xml \ + frameworks/native/data/etc/android.software.freeform_window_management.xml:system/etc/permissions/android.software.freeform_window_management.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/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \ + frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.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 \ + +# Memory Optimizations +PRODUCT_PROPERTY_OVERRIDES += \ + ro.vendor.qti.am.reschedule_service=true \ + ro.vendor.qti.sys.fw.use_trim_settings=true \ + ro.vendor.qti.sys.fw.trim_empty_percent=50 \ + ro.vendor.qti.sys.fw.trim_cache_percent=100 \ + ro.vendor.qti.sys.fw.empty_app_percent=25 + +# NVIDIA +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/permissions/com.nvidia.blakemanager.xml:system/etc/permissions/com.nvidia.blakemanager.xml \ + $(LOCAL_PATH)/permissions/com.nvidia.feature.xml:system/etc/permissions/com.nvidia.feature.xml \ + $(LOCAL_PATH)/permissions/com.nvidia.feature.opengl4.xml:system/etc/permissions/com.nvidia.feature.opengl4.xml \ + $(LOCAL_PATH)/permissions/com.nvidia.nvsi.xml:system/etc/permissions/com.nvidia.nvsi.xml + + +# keylayout +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/keylayout/tegra-kbc.kl:system/usr/keylayout/tegra-kbc.kl \ + $(LOCAL_PATH)/keylayout/gpio-keys.kl:system/usr/keylayout/gpio-keys.kl \ + $(LOCAL_PATH)/keylayout/Vendor_0955_Product_7210.kl:system/usr/keylayout/Vendor_0955_Product_7210.kl + +# Media config +PRODUCT_COPY_FILES += \ + frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_audio.xml \ + frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml \ + $(LOCAL_PATH)/audio/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \ + $(LOCAL_PATH)/audio/media_profiles.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles.xml \ + $(LOCAL_PATH)/audio/media_codecs_performance.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_performance.xml + # Audio PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/audio/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ @@ -34,10 +121,9 @@ PRODUCT_PACKAGES += \ audio.usb.default \ audio.r_submix.default \ audio.primary.tegra \ - sound_trigger.primary.tegra \ + libaudiohalcm \ libaudio-resampler \ libaudiospdif \ - libaudiohalcm \ libstagefrighthw \ libtinycompress \ tinycap_mocha \ @@ -57,7 +143,6 @@ PRODUCT_PACKAGES += \ libbt-vendor # Camera -PRODUCT_PACKAGES += Snap PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/camera/nvcamera.conf:system/etc/nvcamera.conf \ $(LOCAL_PATH)/camera/model_frontal.xml:system/etc/model_frontal.xml @@ -69,152 +154,82 @@ PRODUCT_PACKAGES += \ libpowerservice_client \ libmocha_libc \ libnvomxadaptor_shim - - -# Console Mode -$(call inherit-product-if-exists, vendor/xiaomi/mocha/consolemode-blobs.mk) + -# Comm Permissions -PRODUCT_COPY_FILES += \ - frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \ - frameworks/native/data/etc/android.hardware.sensor.proximity.xml:system/etc/permissions/android.hardware.sensor.proximity.xml \ - frameworks/native/data/etc/android.software.sip.xml:system/etc/permissions/android.software.sip.xml \ - frameworks/native/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml - -# Filesystem management tools +# Custom tiles PRODUCT_PACKAGES += \ - setup_fs - -# Graphics shim -PRODUCT_PACKAGES += libs \ - libshim_zw \ - libshim_atomic + ChargerTile \ + PerformanceTile #GO $(call inherit-product, device/xiaomi/mocha/go_mocha.mk) -# HIDL HALs -$(call inherit-product, device/xiaomi/mocha/hidl.mk) - -# HIDL Manifest -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/configs/manifest.xml:system/vendor/manifest.xml - -# keylayout +# Wifi PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/keylayout/tegra-kbc.kl:system/usr/keylayout/tegra-kbc.kl \ - $(LOCAL_PATH)/keylayout/gpio-keys.kl:system/usr/keylayout/gpio-keys.kl \ - $(LOCAL_PATH)/keylayout/Vendor_0955_Product_7210.kl:system/usr/keylayout/Vendor_0955_Product_7210.kl + $(LOCAL_PATH)/wifi/dhcpcd.conf:system/etc/dhcpcd/dhcpcd.conf \ + -# Media config -PRODUCT_COPY_FILES += \ - frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_audio.xml \ - frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml \ - $(LOCAL_PATH)/audio/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \ - $(LOCAL_PATH)/audio/media_profiles.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles.xml \ - $(LOCAL_PATH)/audio/media_codecs_performance.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_performance.xml +# Wifi +# All Shield devices xurrently use broadcom wifi / bluetooth modules +$(call inherit-product-if-exists, hardware/broadcom/wlan/bcmdhd/config/config-bcm.mk) +$(call inherit-product-if-exists, hardware/broadcom/wlan/bcmdhd/firmware/bcm4354/device-bcm.mk) +PRODUCT_PACKAGES += \ + hostapd \ + wpa_supplicant \ + wpa_supplicant.conf -# Memory Optimizations -PRODUCT_PROPERTY_OVERRIDES += \ - ro.vendor.qti.am.reschedule_service=true \ - ro.vendor.qti.sys.fw.use_trim_settings=true \ - ro.vendor.qti.sys.fw.trim_empty_percent=50 \ - ro.vendor.qti.sys.fw.trim_cache_percent=100 \ - ro.vendor.qti.sys.fw.empty_app_percent=25 +# wifi and bt macs settter +PRODUCT_PACKAGES += \ + conn_init -# NVIDIA -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/permissions/com.nvidia.blakemanager.xml:system/etc/permissions/com.nvidia.blakemanager.xml \ - $(LOCAL_PATH)/permissions/com.nvidia.feature.xml:system/etc/permissions/com.nvidia.feature.xml \ - $(LOCAL_PATH)/permissions/com.nvidia.feature.opengl4.xml:system/etc/permissions/com.nvidia.feature.opengl4.xml \ - $(LOCAL_PATH)/permissions/com.nvidia.nvsi.xml:system/etc/permissions/com.nvidia.nvsi.xml \ - -NV_ANDROID_FRAMEWORK_ENHANCEMENTS := true +PRODUCT_CHARACTERISTICS := tablet -# Overlay -DEVICE_PACKAGE_OVERLAYS += \ - device/xiaomi/mocha/overlay +# Filesystem management tools +PRODUCT_PACKAGES += \ + setup_fs -# Permissions +# Comm Permissions PRODUCT_COPY_FILES += \ - frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml \ - frameworks/native/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml \ - frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \ - frameworks/native/data/etc/android.hardware.camera.full.xml:system/etc/permissions/android.hardware.camera.full.xml \ - frameworks/native/data/etc/android.hardware.camera.raw.xml:system/etc/permissions/android.hardware.camera.raw.xml \ - frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml \ - frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \ - frameworks/native/data/etc/android.hardware.opengles.aep.xml:system/etc/permissions/android.hardware.opengles.aep.xml \ - frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:system/etc/permissions/android.hardware.vulkan.compute-0.xml \ - frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:system/etc/permissions/android.hardware.vulkan.level.xml \ - frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:system/etc/permissions/android.hardware.vulkan.version.xml \ - frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml \ - frameworks/native/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.sensor.compass.xml \ - frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:system/etc/permissions/android.hardware.sensor.gyroscope.xml \ - frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \ - frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \ - frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml \ - frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml \ - frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \ - frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \ - frameworks/native/data/etc/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml \ - frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:system/etc/permissions/android.hardware.sensor.stepcounter.xml \ - frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:system/etc/permissions/android.hardware.sensor.stepdetector.xml + frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \ + frameworks/native/data/etc/android.hardware.sensor.proximity.xml:system/etc/permissions/android.hardware.sensor.proximity.xml \ + frameworks/native/data/etc/android.software.sip.xml:system/etc/permissions/android.software.sip.xml \ + frameworks/native/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml # Power PRODUCT_PACKAGES += power.tegra -# Ramdisk -PRODUCT_PACKAGES += \ - fstab.tn8 \ - init.cal.rc \ - init.comms.rc \ - init.hdcp.rc \ - init.ray_touch.rc \ - init.t124.rc \ - init.tegra.rc \ - init.tlk.rc \ - init.tn8.rc \ - init.tn8.usb.rc \ - init.tn8_common.rc \ - init.ussrd.rc \ - power.tn8.rc \ - power.mocha.rc \ - ueventd.tn8.rc \ - ussrd.conf \ - ussr_setup - # Sensors PRODUCT_PACKAGES += \ sensors.tegra -# System properties --include $(LOCAL_PATH)/system_prop.mk -# Thermal +# Nvidia enhancements +NV_ANDROID_FRAMEWORK_ENHANCEMENTS := true + +# Permissions PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/thermal/thermalhal.tn8.xml:$(TARGET_COPY_OUT_VENDOR)/etc/thermalhal.tn8.xml + frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:system/etc/permissions/android.hardware.sensor.stepcounter.xml \ + frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:system/etc/permissions/android.hardware.sensor.stepdetector.xml + +# System properties +-include $(LOCAL_PATH)/system_prop.mk # Vendor seccomp policy files for media components: PRODUCT_COPY_FILES += \ device/xiaomi/mocha/seccomp/mediacodec.policy:$(TARGET_COPY_OUT_VENDOR)/etc/seccomp_policy/mediacodec.policy \ device/xiaomi/mocha/seccomp/mediaextractor.policy:$(TARGET_COPY_OUT_VENDOR)/etc/seccomp_policy/mediaextractor.policy +# Console Mode +$(call inherit-product-if-exists, vendor/xiaomi/mocha/consolemode-blobs.mk) -# Wifi -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/wifi/dhcpcd.conf:system/etc/dhcpcd/dhcpcd.conf - -# Wifi -# All Shield devices xurrently use broadcom wifi / bluetooth modules -$(call inherit-product-if-exists, hardware/broadcom/wlan/bcmdhd/config/config-bcm.mk) - -PRODUCT_PACKAGES += \ - hostapd \ - wpa_supplicant \ - wpa_supplicant.conf +# Graphics shim +PRODUCT_PACKAGES += libs \ + libshim_zw \ + libshim_atomic -# wifi and bt macs settter -PRODUCT_PACKAGES += \ - conn_init +# HIDL HALs +$(call inherit-product, device/xiaomi/mocha/hidl.mk) +# HIDL Manifest +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/manifest.xml:system/vendor/manifest.xml diff --git a/hidl.mk b/hidl.mk index 27c85f8..71c84fa 100644 --- a/hidl.mk +++ b/hidl.mk @@ -12,8 +12,9 @@ PRODUCT_PACKAGES += \ # Camera HAL PRODUCT_PACKAGES += \ - camera.device@3.2-impl \ - android.hardware.camera.provider@2.4-impl + camera.device@1.0-impl-legacy \ + android.hardware.camera.provider@2.4-impl-legacy \ + camera.tegra # FM Radio HAL PRODUCT_PACKAGES += \ diff --git a/initfiles/init.tegra.rc b/initfiles/init.tegra.rc index fad47a4..25dfe06 100644 --- a/initfiles/init.tegra.rc +++ b/initfiles/init.tegra.rc @@ -17,8 +17,10 @@ on early-init on init export LD_PRELOAD "libshim_zw.so" + mkdir /mnt/shell/emulated 0700 shell shell + mkdir /storage/emulated 0555 root root mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw - + # Support legacy paths symlink /sdcard /mnt/sdcard symlink /sdcard /storage/sdcard0 @@ -69,6 +71,16 @@ on post-fs-data # create directory for mediaserver EGL blob cache mkdir /data/misc/mediaserver 0770 media media + # create directory for runtime calibration data + # remount to rw and set perm to 770 till new diag product is created + mkdir /data/touchscreen 0770 system system + + # create directory for camera calibration data + mkdir /mnt/factory/camera 0666 system system + + # cpu volt cap + mkdir /data/misc/cvc 0774 system system + # Set up HDCP import init.hdcp.rc @@ -81,15 +93,15 @@ on boot chown system system /sys/devices/platform/7000c400.i2c/i2c-1/1-006b/disabled_by_user #dt2w - chown system system /sys/devices/platform/7000c700.i2c/i2c-3/3-004a/wakeup_mode - chown system system /sys/devices/platform/7000c700.i2c/i2c-3/3-0020/input/input0/wake_gesture - chown system system /sys/devices/platform/7000c700.i2c/i2c-3/3-0020/input/input3/wake_gesture + chown system system /sys/devices/platform/tegra12-i2c.3/i2c-3/3-004a/wakeup_mode + chown system system /sys/devices/platform/tegra12-i2c.3.i2c/i2c-3/3-0020/input/input0/wake_gesture + chown system system /sys/devices/platform/tegra12-i2c.3/i2c-3/3-0020/input/input3/wake_gesture ## cmhw permissions # key disabler - chown system system /sys/devices/platform/7000c700.i2c/i2c-3/3-004a/enable_keys - chown system system /sys/devices/platform/7000c700.i2c/i2c-3/3-0020/input/input0/0dbutton - chown system system /sys/devices/platform/7000c700.i2c/i2c-3/3-0020/input/input3/0dbutton + chown system system /sys/devices/platform/tegra12-i2c.3/i2c-3/3-004a/enable_keys + chown system system /sys/devices/platform/tegra12-i2c.3/i2c-3/3-0020/input/input0/0dbutton + chown system system /sys/devices/platform/tegra12-i2c.3/i2c-3/3-0020/input/input3/0dbutton # vibrator intensity chown system system /sys/vibrator/pwmvalue @@ -229,3 +241,6 @@ import init.ussrd.rc service watchdogd /sbin/watchdogd 10 110 class core seclabel u:r:watchdogd:s0 + +# Enabling LZ4 compression algorithm for zram +write /sys/block/zram0/comp_algorithm lz4 diff --git a/initfiles/init.tn8.rc b/initfiles/init.tn8.rc index 65037f1..f066eb8 100644 --- a/initfiles/init.tn8.rc +++ b/initfiles/init.tn8.rc @@ -46,6 +46,7 @@ on init setprop sys.esrd.check_screen_off 1 chown system system /sys/power/sysedp/batmon/esr chown system system /sys/bus/i2c/devices/1-0040/iio_device/running_mode + export LD_SHIM_LIBS "/system/vendor/lib/libnvomxadaptor.so|libmocha_omx.so:/system/lib/hw/camera.vendor.tegra.so|libmocha_camera.so:/system/lib/hw/camera.vendor.tegra.so|libmocha_libc.so" on fs mount_all /fstab.tn8 @@ -67,4 +68,17 @@ on property:sys.boot_completed=1 write /sys/block/mmcblk0/queue/read_ahead_kb 512 write /sys/block/mmcblk0/queue/iostats 1 +service media /system/bin/mediaserver + class main + user media + group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm wakelock + ioprio rt 4 + writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks + +# brcm-uim-sysfs (BT/FM/ANT+) +service uim /system/bin/brcm-uim-sysfs + class late_start + user root + group bluetooth net_bt_admin net_bt + seclabel u:r:uim:s0 diff --git a/mocha/audio_symbols.c b/mocha/audio_symbols.c new file mode 100644 index 0000000..1e59846 --- /dev/null +++ b/mocha/audio_symbols.c @@ -0,0 +1,88 @@ +#include +#include +#include "unicode/ucnv.h" + +int NvRmOpen(void *pHandle, int DeviceId) { + return 0; +} + +U_STABLE UConverter* U_EXPORT2 +ucnv_open_51(const char *converterName, UErrorCode *err) +{ + return ucnv_open(converterName, err); +} + +U_STABLE void U_EXPORT2 +ucnv_close_51(UConverter * converter) +{ + return ucnv_close(converter); +} + +U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP_51( + const void *context, + UConverterToUnicodeArgs *toUArgs, + const char* codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err) +{ + UCNV_TO_U_CALLBACK_STOP(context, toUArgs, codeUnits, length, reason, err); +} + +U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP_51( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err) +{ + UCNV_FROM_U_CALLBACK_STOP (context, fromUArgs, codeUnits, length, codePoint, reason, err); +} + +U_STABLE void U_EXPORT2 +ucnv_setToUCallBack_51(UConverter * converter, + UConverterToUCallback newAction, + const void* newContext, + UConverterToUCallback *oldAction, + const void** oldContext, + UErrorCode * err) +{ + ucnv_setToUCallBack(converter, newAction, newContext, oldAction, oldContext, err); +} + +U_STABLE void U_EXPORT2 +ucnv_setFromUCallBack_51(UConverter * converter, + UConverterFromUCallback newAction, + const void *newContext, + UConverterFromUCallback *oldAction, + const void **oldContext, + UErrorCode * err) +{ + ucnv_setFromUCallBack(converter, newAction, newContext, oldAction, oldContext, err); +} + +U_STABLE void U_EXPORT2 +ucnv_convertEx_51(UConverter *targetCnv, UConverter *sourceCnv, + char **target, const char *targetLimit, + const char **source, const char *sourceLimit, + UChar *pivotStart, UChar **pivotSource, + UChar **pivotTarget, const UChar *pivotLimit, + UBool reset, UBool flush, + UErrorCode *pErrorCode) +{ + ucnv_convertEx(targetCnv, sourceCnv, target, targetLimit, source, sourceLimit, + pivotStart, pivotSource, pivotTarget, pivotLimit, reset, flush, + pErrorCode); +} + +void _ZN7android8MonoPipeC1Ejjb(size_t reqFrames, unsigned format_old, bool writeCanBlock) +{ + +} + +unsigned _ZN7android16Format_from_SR_CEjj(unsigned sampleRate, unsigned channelCount) +{ + return 0; +} diff --git a/mocha/audio_wrapper.c b/mocha/audio_wrapper.c new file mode 100644 index 0000000..1e59846 --- /dev/null +++ b/mocha/audio_wrapper.c @@ -0,0 +1,88 @@ +#include +#include +#include "unicode/ucnv.h" + +int NvRmOpen(void *pHandle, int DeviceId) { + return 0; +} + +U_STABLE UConverter* U_EXPORT2 +ucnv_open_51(const char *converterName, UErrorCode *err) +{ + return ucnv_open(converterName, err); +} + +U_STABLE void U_EXPORT2 +ucnv_close_51(UConverter * converter) +{ + return ucnv_close(converter); +} + +U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP_51( + const void *context, + UConverterToUnicodeArgs *toUArgs, + const char* codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err) +{ + UCNV_TO_U_CALLBACK_STOP(context, toUArgs, codeUnits, length, reason, err); +} + +U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP_51( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err) +{ + UCNV_FROM_U_CALLBACK_STOP (context, fromUArgs, codeUnits, length, codePoint, reason, err); +} + +U_STABLE void U_EXPORT2 +ucnv_setToUCallBack_51(UConverter * converter, + UConverterToUCallback newAction, + const void* newContext, + UConverterToUCallback *oldAction, + const void** oldContext, + UErrorCode * err) +{ + ucnv_setToUCallBack(converter, newAction, newContext, oldAction, oldContext, err); +} + +U_STABLE void U_EXPORT2 +ucnv_setFromUCallBack_51(UConverter * converter, + UConverterFromUCallback newAction, + const void *newContext, + UConverterFromUCallback *oldAction, + const void **oldContext, + UErrorCode * err) +{ + ucnv_setFromUCallBack(converter, newAction, newContext, oldAction, oldContext, err); +} + +U_STABLE void U_EXPORT2 +ucnv_convertEx_51(UConverter *targetCnv, UConverter *sourceCnv, + char **target, const char *targetLimit, + const char **source, const char *sourceLimit, + UChar *pivotStart, UChar **pivotSource, + UChar **pivotTarget, const UChar *pivotLimit, + UBool reset, UBool flush, + UErrorCode *pErrorCode) +{ + ucnv_convertEx(targetCnv, sourceCnv, target, targetLimit, source, sourceLimit, + pivotStart, pivotSource, pivotTarget, pivotLimit, reset, flush, + pErrorCode); +} + +void _ZN7android8MonoPipeC1Ejjb(size_t reqFrames, unsigned format_old, bool writeCanBlock) +{ + +} + +unsigned _ZN7android16Format_from_SR_CEjj(unsigned sampleRate, unsigned channelCount) +{ + return 0; +} diff --git a/mocha/audio_wrapper.h b/mocha/audio_wrapper.h new file mode 100644 index 0000000..d706290 --- /dev/null +++ b/mocha/audio_wrapper.h @@ -0,0 +1,395 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. + * Not a Contribution. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/* common audio stream parameters and operations */ +struct nv_audio_stream { + + /** + * Return the sampling rate in Hz - eg. 44100. + */ + uint32_t (*get_sample_rate)(const struct nv_audio_stream *stream); + + /* currently unused - use set_parameters with key + * AUDIO_PARAMETER_STREAM_SAMPLING_RATE + */ + int (*set_sample_rate)(struct nv_audio_stream *stream, uint32_t rate); + + /** + * Return size of input/output buffer in bytes for this stream - eg. 4800. + * It should be a multiple of the frame size. See also get_input_buffer_size. + */ + size_t (*get_buffer_size)(const struct nv_audio_stream *stream); + + /** + * Return the channel mask - + * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO + */ + audio_channel_mask_t (*get_channels)(const struct nv_audio_stream *stream); + + /** + * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT + */ + audio_format_t (*get_format)(const struct nv_audio_stream *stream); + + /* currently unused - use set_parameters with key + * AUDIO_PARAMETER_STREAM_FORMAT + */ + int (*set_format)(struct nv_audio_stream *stream, audio_format_t format); + + /** + * Put the audio hardware input/output into standby mode. + * Driver should exit from standby mode at the next I/O operation. + * Returns 0 on success and <0 on failure. + */ + int (*standby)(struct nv_audio_stream *stream); + + /** dump the state of the audio input/output device */ + int (*dump)(const struct nv_audio_stream *stream, int fd); + + /** Return the set of device(s) which this stream is connected to */ + audio_devices_t (*get_device)(const struct nv_audio_stream *stream); + + /** + * Currently unused - set_device() corresponds to set_parameters() with key + * AUDIO_PARAMETER_STREAM_ROUTING for both input and output. + * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by + * input streams only. + */ + int (*set_device)(struct nv_audio_stream *stream, audio_devices_t device); + + /** + * set/get audio stream parameters. The function accepts a list of + * parameter key value pairs in the form: key1=value1;key2=value2;... + * + * Some keys are reserved for standard parameters (See AudioParameter class) + * + * If the implementation does not accept a parameter change while + * the output is active but the parameter is acceptable otherwise, it must + * return -ENOSYS. + * + * The audio flinger will put the stream in standby and then change the + * parameter value. + */ + int (*set_parameters)(struct nv_audio_stream *stream, const char *kv_pairs); + + /* + * Returns a pointer to a heap allocated string. The caller is responsible + * for freeing the memory for it using free(). + */ + char * (*get_parameters)(const struct nv_audio_stream *stream, + const char *keys); + int (*add_audio_effect)(const struct nv_audio_stream *stream, + effect_handle_t effect); + int (*remove_audio_effect)(const struct nv_audio_stream *stream, + effect_handle_t effect); +}; +typedef struct nv_audio_stream nv_audio_stream_t; + +struct nv_audio_stream_out { + struct nv_audio_stream common; + + /** + * Return the audio hardware driver estimated latency in milliseconds. + */ + uint32_t (*get_latency)(const struct nv_audio_stream_out *stream); + + /** + * Use this method in situations where audio mixing is done in the + * hardware. This method serves as a direct interface with hardware, + * allowing you to directly set the volume as apposed to via the framework. + * This method might produce multiple PCM outputs or hardware accelerated + * codecs, such as MP3 or AAC. + */ + int (*set_volume)(struct nv_audio_stream_out *stream, float left, float right); + + /** + * Write audio buffer to driver. Returns number of bytes written, or a + * negative status_t. If at least one frame was written successfully prior to the error, + * it is suggested that the driver return that successful (short) byte count + * and then return an error in the subsequent call. + * + * If set_callback() has previously been called to enable non-blocking mode + * the write() is not allowed to block. It must write only the number of + * bytes that currently fit in the driver/hardware buffer and then return + * this byte count. If this is less than the requested write size the + * callback function must be called when more space is available in the + * driver/hardware buffer. + */ + ssize_t (*write)(struct nv_audio_stream_out *stream, const void* buffer, + size_t bytes); + + /* return the number of audio frames written by the audio dsp to DAC since + * the output has exited standby + */ + int (*get_render_position)(const struct nv_audio_stream_out *stream, + uint32_t *dsp_frames); + + /** + * get the local time at which the next write to the audio driver will be presented. + * The units are microseconds, where the epoch is decided by the local audio HAL. + */ + int (*get_next_write_timestamp)(const struct nv_audio_stream_out *stream, + int64_t *timestamp); + + + /** + * set the callback function for notifying completion of non-blocking + * write and drain. + * Calling this function implies that all future write() and drain() + * must be non-blocking and use the callback to signal completion. + */ + int (*set_callback)(struct audio_stream_out *stream, + stream_callback_t callback, void *cookie); + + /** + * Notifies to the audio driver to stop playback however the queued buffers are + * retained by the hardware. Useful for implementing pause/resume. Empty implementation + * if not supported however should be implemented for hardware with non-trivial + * latency. In the pause state audio hardware could still be using power. User may + * consider calling suspend after a timeout. + * + * Implementation of this function is mandatory for offloaded playback. + */ + int (*pause)(struct audio_stream_out* stream); + + /** + * Notifies to the audio driver to resume playback following a pause. + * Returns error if called without matching pause. + * + * Implementation of this function is mandatory for offloaded playback. + */ + int (*resume)(struct audio_stream_out* stream); + + /** + * Requests notification when data buffered by the driver/hardware has + * been played. If set_callback() has previously been called to enable + * non-blocking mode, the drain() must not block, instead it should return + * quickly and completion of the drain is notified through the callback. + * If set_callback() has not been called, the drain() must block until + * completion. + * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written + * data has been played. + * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all + * data for the current track has played to allow time for the framework + * to perform a gapless track switch. + * + * Drain must return immediately on stop() and flush() call + * + * Implementation of this function is mandatory for offloaded playback. + */ + int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type ); + + /** + * Notifies to the audio driver to flush the queued data. Stream must already + * be paused before calling flush(). + * + * Implementation of this function is mandatory for offloaded playback. + */ + int (*flush)(struct audio_stream_out* stream); + + /** + * Return a recent count of the number of audio frames presented to an external observer. + * This excludes frames which have been written but are still in the pipeline. + * The count is not reset to zero when output enters standby. + * Also returns the value of CLOCK_MONOTONIC as of this presentation count. + * The returned count is expected to be 'recent', + * but does not need to be the most recent possible value. + * However, the associated time should correspond to whatever count is returned. + * Example: assume that N+M frames have been presented, where M is a 'small' number. + * Then it is permissible to return N instead of N+M, + * and the timestamp should correspond to N rather than N+M. + * The terms 'recent' and 'small' are not defined. + * They reflect the quality of the implementation. + * + * 3.0 and higher only. + */ + int (*get_presentation_position)(const struct audio_stream_out *stream, + uint64_t *frames, struct timespec *timestamp); +}; +typedef struct nv_audio_stream_out nv_audio_stream_out_t; + +struct nv_audio_stream_in { + struct nv_audio_stream common; + + /** set the input gain for the audio driver. This method is for + * for future use */ + int (*set_gain)(struct nv_audio_stream_in *stream, float gain); + + /** Read audio buffer in from audio driver. Returns number of bytes read, or a + * negative status_t. If at least one frame was read prior to the error, + * read should return that byte count and then return an error in the subsequent call. + */ + ssize_t (*read)(struct nv_audio_stream_in *stream, void* buffer, + size_t bytes); + + /** + * Return the amount of input frames lost in the audio driver since the + * last call of this function. + * Audio driver is expected to reset the value to 0 and restart counting + * upon returning the current value by this function call. + * Such loss typically occurs when the user space process is blocked + * longer than the capacity of audio driver buffers. + * + * Unit: the number of input audio frames + */ + uint32_t (*get_input_frames_lost)(struct nv_audio_stream_in *stream); +}; +typedef struct nv_audio_stream_in nv_audio_stream_in_t; + +struct nv_audio_hw_device { + struct hw_device_t common; + + /** + * used by audio flinger to enumerate what devices are supported by + * each nv_audio_hw_device implementation. + * + * Return value is a bitmask of 1 or more values of audio_devices_t + * + * NOTE: audio HAL implementations starting with + * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. + * All supported devices should be listed in audio_policy.conf + * file and the audio policy manager must choose the appropriate + * audio module based on information in this file. + */ + uint32_t (*get_supported_devices)(const struct nv_audio_hw_device *dev); + + /** + * check to see if the audio hardware interface has been initialized. + * returns 0 on success, -ENODEV on failure. + */ + int (*init_check)(const struct nv_audio_hw_device *dev); + + /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ + int (*set_voice_volume)(struct nv_audio_hw_device *dev, float volume); + + /** + * set the audio volume for all audio activities other than voice call. + * Range between 0.0 and 1.0. If any value other than 0 is returned, + * the software mixer will emulate this capability. + */ + int (*set_master_volume)(struct nv_audio_hw_device *dev, float volume); + + /** + * Get the current master volume value for the HAL, if the HAL supports + * master volume control. AudioFlinger will query this value from the + * primary audio HAL when the service starts and use the value for setting + * the initial master volume across all HALs. HALs which do not support + * this method may leave it set to NULL. + */ + int (*get_master_volume)(struct nv_audio_hw_device *dev, float *volume); + + /** + * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode + * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is + * playing, and AUDIO_MODE_IN_CALL when a call is in progress. + */ + int (*set_mode)(struct nv_audio_hw_device *dev, audio_mode_t mode); + + /* mic mute */ + int (*set_mic_mute)(struct nv_audio_hw_device *dev, bool state); + int (*get_mic_mute)(const struct nv_audio_hw_device *dev, bool *state); + + /* set/get global audio parameters */ + int (*set_parameters)(struct nv_audio_hw_device *dev, const char *kv_pairs); + + /* + * Returns a pointer to a heap allocated string. The caller is responsible + * for freeing the memory for it using free(). + */ + char * (*get_parameters)(const struct nv_audio_hw_device *dev, + const char *keys); + + /* Returns audio input buffer size according to parameters passed or + * 0 if one of the parameters is not supported. + * See also get_buffer_size which is for a particular stream. + */ + size_t (*get_input_buffer_size)(const struct nv_audio_hw_device *dev, + const struct audio_config *config); + + /** This method creates and opens the audio hardware output stream */ + int (*open_output_stream)(struct nv_audio_hw_device *dev, + audio_io_handle_t handle, + audio_devices_t devices, + audio_output_flags_t flags, + struct audio_config *config, + struct nv_audio_stream_out **stream_out); + + void (*close_output_stream)(struct nv_audio_hw_device *dev, + struct nv_audio_stream_out* stream_out); + + /** This method creates and opens the audio hardware input stream */ + int (*open_input_stream)(struct nv_audio_hw_device *dev, + audio_io_handle_t handle, + audio_devices_t devices, + struct audio_config *config, + struct nv_audio_stream_in **stream_in); + + void (*close_input_stream)(struct nv_audio_hw_device *dev, + struct nv_audio_stream_in *stream_in); + + /** This method dumps the state of the audio hardware */ + int (*dump)(const struct nv_audio_hw_device *dev, int fd); + + /** + * set the audio mute status for all audio activities. If any value other + * than 0 is returned, the software mixer will emulate this capability. + */ + int (*set_master_mute)(struct nv_audio_hw_device *dev, bool mute); + + /** + * Get the current master mute status for the HAL, if the HAL supports + * master mute control. AudioFlinger will query this value from the primary + * audio HAL when the service starts and use the value for setting the + * initial master mute across all HALs. HALs which do not support this + * method may leave it set to NULL. + */ + int (*get_master_mute)(struct nv_audio_hw_device *dev, bool *mute); + + /** + * Routing control + */ + + /* Creates an audio patch between several source and sink ports. + * The handle is allocated by the HAL and should be unique for this + * audio HAL module. */ + int (*create_audio_patch)(struct audio_hw_device *dev, + unsigned int num_sources, + const struct audio_port_config *sources, + unsigned int num_sinks, + const struct audio_port_config *sinks, + audio_patch_handle_t *handle); + + /* Release an audio patch */ + int (*release_audio_patch)(struct audio_hw_device *dev, + audio_patch_handle_t handle); + + /* Fills the list of supported attributes for a given audio port. + * As input, "port" contains the information (type, role, address etc...) + * needed by the HAL to identify the port. + * As output, "port" contains possible attributes (sampling rates, formats, + * channel masks, gain controllers...) for this port. + */ + int (*get_audio_port)(struct audio_hw_device *dev, + struct audio_port *port); + + /* Set audio port configuration */ + int (*set_audio_port_config)(struct audio_hw_device *dev, + const struct audio_port_config *config); +}; +typedef struct nv_audio_hw_device nv_audio_hw_device_t;