diff options
| author | Mister Oyster <oysterized@gmail.com> | 2017-01-02 12:44:35 +0100 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-01-02 12:44:35 +0100 |
| commit | a184d985bf43d3fe6eeba971bc6b32f79ea38b37 (patch) | |
| tree | 6f6e56e090777cc149bc1ab39e5987cc2b03e867 | |
initial releasecm-13.0
372 files changed, 46470 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..ad6b115 --- /dev/null +++ b/Android.mk @@ -0,0 +1,23 @@ +# +# Copyright (C) 2016 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. +# + +LOCAL_PATH := $(call my-dir) + +ifeq ($(TARGET_DEVICE),m2note) + +include $(call all-makefiles-under,$(LOCAL_PATH)) + +endif diff --git a/AndroidBoard.mk b/AndroidBoard.mk new file mode 100644 index 0000000..837b6f3 --- /dev/null +++ b/AndroidBoard.mk @@ -0,0 +1,5 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET) diff --git a/AndroidProducts.mk b/AndroidProducts.mk new file mode 100644 index 0000000..ae6179f --- /dev/null +++ b/AndroidProducts.mk @@ -0,0 +1,2 @@ +PRODUCT_MAKEFILES := \ + $(LOCAL_DIR)/device_m2note.mk diff --git a/BoardConfig.mk b/BoardConfig.mk new file mode 100644 index 0000000..9108a22 --- /dev/null +++ b/BoardConfig.mk @@ -0,0 +1,74 @@ +# +# Copyright (C) 2016 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. +# + +# Device path +LOCAL_PATH := device/meizu/m2note + +# Device board elements +include $(LOCAL_PATH)/PlatformConfig.mk +include $(LOCAL_PATH)/board/*.mk + +# Headers include +TARGET_SPECIFIC_HEADER_PATH := $(LOCAL_PATH)/include + +TARGET_BOOTLOADER_BOARD_NAME := mt6753 +TARGET_NO_BOOTLOADER := true + +# misc flags +TARGET_GLOBAL_CFLAGS += -mfpu=neon -mfloat-abi=softfp +TARGET_GLOBAL_CPPFLAGS += -mfpu=neon -mfloat-abi=softfp +COMMON_GLOBAL_CFLAGS += -DNO_SECURE_DISCARD +COMMON_GLOBAL_CFLAGS += -DDISABLE_HW_ID_MATCH_CHECK + +# MTK Hardware +BOARD_USES_MTK_HARDWARE := true +BOARD_HAS_MTK_HARDWARE := true +BOARD_USES_LEGACY_MTK_AV_BLOB := true +COMMON_GLOBAL_CFLAGS += -DDISABLE_ASHMEM_TRACKING +# Mtk LP Camera Hal compat +COMMON_GLOBAL_CFLAGS += -DCAMERA_VENDOR_L_COMPAT + +#TODO: rewrite gps hal (libEPOS) +MTK_K64_SUPPORT := yes + +# EGL +BOARD_EGL_CFG := $(LOCAL_PATH)/configs/egl.cfg +USE_OPENGL_RENDERER := true +TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS := true +NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3 +TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK := true +DISABLE_ASHMEM_TRACKING := true +BOARD_EGL_WORKAROUND_BUG_10194508 := true +PRESENT_TIME_OFFSET_FROM_VSYNC_NS := 0 +MTK_HWC_SUPPORT := yes +MTK_HWC_VERSION := 1.4.1 + +# Screen resolution +TARGET_SCREEN_HEIGHT := 1920 +TARGET_SCREEN_WIDTH := 1080 + +# Bootanimation +TARGET_BOOTANIMATION_NAME := 1080 +TARGET_BOOTANIMATION_PRELOAD := true +TARGET_BOOTANIMATION_TEXTURE_CACHE := true +TARGET_BOOTANIMATION_HALF_RES := true + +# system.prop +TARGET_SYSTEM_PROP := $(LOCAL_PATH)/system.prop + +# Vold +TARGET_USE_CUSTOM_LUN_FILE_PATH := /sys/class/android_usb/android0/f_mass_storage/lun/file + diff --git a/PlatformConfig.mk b/PlatformConfig.mk new file mode 100644 index 0000000..d4b1bde --- /dev/null +++ b/PlatformConfig.mk @@ -0,0 +1,26 @@ +# Platform +TARGET_BOARD_PLATFORM := mt6753 + +# LD Preload +TARGET_LDPRELOAD += libmtk_symbols.so + +# Architecture +TARGET_ARCH := arm64 +TARGET_ARCH_VARIANT := armv8-a +TARGET_CPU_ABI := arm64-v8a +TARGET_CPU_ABI2 := +TARGET_CPU_VARIANT := cortex-a53 +TARGET_CPU_CORTEX_A53 := true + +TARGET_2ND_ARCH := arm +TARGET_2ND_ARCH_VARIANT := armv7-a-neon +TARGET_2ND_CPU_ABI := armeabi-v7a +TARGET_2ND_CPU_ABI2 := armeabi +TARGET_2ND_CPU_VARIANT := cortex-a53 + +# Architecture Extensions +TARGET_CPU_SMP := true +ARCH_ARM_HAVE_NEON := true +ARCH_ARM_HAVE_TLS_REGISTER := true +ARCH_ARM_HAVE_VFP := true + diff --git a/README.md b/README.md new file mode 100644 index 0000000..b4cd14b --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Meizu M2 Note - Unofficial CyanogenMod 13.0 + +--- + +This device tree is made for building CyanogenMod 13.0. + +--- + +# About Device + + + +### Specifications + +Component Type | Details +-------:|:------------------------- +CPU | 1.3GHz Octa-Core MT6753 +GPU | Mali-T720 +Memory | 2GB RAM +Shipped Android Version | 5.1.1 +Storage | 16GB +Battery | 3100 mAh +Display | 5.5" 1920 x 1080 px DPI 480 +Rear Camera | 13MP +Front Camera | 5MP + + +# Thanks to : +Cyanogenmod +Xen0n +Team MAD +Deepflex +Visi0nary +Elexogic + +And everyone who contributed :) !
\ No newline at end of file diff --git a/bluetooth/bdroid_buildcfg.h b/bluetooth/bdroid_buildcfg.h new file mode 100644 index 0000000..21b8ae0 --- /dev/null +++ b/bluetooth/bdroid_buildcfg.h @@ -0,0 +1,6 @@ +#ifndef _BDROID_BUILDCFG_H +#define _BDROID_BUILDCFG_H + +#define BTM_DEF_LOCAL_NAME "MEIZU M2 Note" + +#endif diff --git a/board/hardware.mk b/board/hardware.mk new file mode 100644 index 0000000..92ea847 --- /dev/null +++ b/board/hardware.mk @@ -0,0 +1,43 @@ +# CM hardware +BOARD_HARDWARE_CLASS := $(LOCAL_PATH)/cmhw + +# LightHAL +TARGET_PROVIDES_LIBLIGHT := true + +# init.rc +TARGET_PROVIDES_INIT_RC := true + +# RIL +BOARD_RIL_CLASS := ../../../device/meizu/m2note/ril +BOARD_CONNECTIVITY_MODULE := conn_soc + +# GPS +BOARD_GPS_LIBRARIES :=true +BOARD_MEDIATEK_USES_GPS := true + +# Camera +USE_CAMERA_STUB := true + +# Charger +BOARD_CHARGER_SHOW_PERCENTAGE := true + +# Bluetooth +BOARD_HAVE_BLUETOOTH := true +BOARD_HAVE_BLUETOOTH_MTK := true +BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(LOCAL_PATH)/bluetooth + +# WiFi +BOARD_HOSTAPD_DRIVER := NL80211 +BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_mt66xx +BOARD_WPA_SUPPLICANT_DRIVER := NL80211 +BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_mt66xx +WIFI_DRIVER_FW_PATH_PARAM:="/dev/wmtWifi" +WIFI_DRIVER_FW_PATH_STA:= STA +WIFI_DRIVER_FW_PATH_AP:= AP +WIFI_DRIVER_FW_PATH_P2P:= P2P +WPA_SUPPLICANT_VERSION := VER_0_8_X + +# MTK audio +TARGET_CPU_MEMCPY_OPT_DISABLE := true +BOARD_USES_MTK_AUDIO := true + diff --git a/board/kernel.mk b/board/kernel.mk new file mode 100644 index 0000000..7e6b646 --- /dev/null +++ b/board/kernel.mk @@ -0,0 +1,44 @@ +# Kernel informations
+BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb
+BOARD_KERNEL_CMDLINE := bootopt=64S3,32N2,64N2 androidboot.selinux=permissive
+BOARD_NAME := 1473302977
+BOARD_KERNEL_BASE := 0x40078000
+BOARD_KERNEL_OFFSET := 0x00008000
+BOARD_RAMDISK_OFFSET := 0x03f88000
+BOARD_TAGS_OFFSET := 0x0df88000
+BOARD_KERNEL_PAGESIZE := 2048
+BOARD_MKBOOTIMG_ARGS := --board $(BOARD_NAME) --kernel_offset $(BOARD_KERNEL_OFFSET) --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_TAGS_OFFSET) --second_offset 0x00e88000
+MTK_APPENDED_DTB_SUPPORT := yes
+
+# Kernel properties
+TARGET_KERNEL_SOURCE := kernel/meizu/m2note
+TARGET_KERNEL_ARCH := arm64
+TARGET_KERNEL_HEADER_ARCH := arm64
+TARGET_KERNEL_CONFIG := cm13_m2note_defconfig
+TARGET_KERNEL_CROSS_COMPILE_PREFIX := aarch64-linux-android-
+
+TARGET_BOARD_SUFFIX := _64
+TARGET_USES_64_BIT_BINDER := true
+
+# Partitions informations
+BOARD_BOOTIMAGE_PARTITION_SIZE := 16777216
+BOARD_RECOVERYIMAGE_PARTITION_SIZE := 20971520
+BOARD_CACHEIMAGE_PARTITION_SIZE := 419430400
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 12831948800
+
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 131072
+
+# Partitions types
+TARGET_USERIMAGES_USE_EXT4 := true
+
+# Recovery
+TARGET_RECOVERY_PIXEL_FORMAT := "RGBA_8888"
+TARGET_RECOVERY_FSTAB := $(LOCAL_PATH)/rootdir/fstab.mt6735
+
+BOARD_HAS_NO_SELECT_BUTTON := true
+BOARD_RECOVERY_SWIPE := true
+BOARD_SUPPRESS_EMMC_WIPE := true
+BOARD_HAS_LARGE_FILESYSTEM := true
+
diff --git a/cm.dependencies b/cm.dependencies new file mode 100644 index 0000000..4146745 --- /dev/null +++ b/cm.dependencies @@ -0,0 +1,14 @@ +[ + { + "remote": "github", + "repository": "Moyster/android_vendor_meizu_m2note", + "target_path": "vendor/meizu/m2note", + "branch": "cm-13.0" + }, + { + "remote": "github", + "repository": "Moyster/android_kernel_m2note", + "target_path": "kernel/meizu/m2note", + "branch": "mm-6.0" + } +] @@ -0,0 +1,40 @@ +# +# Copyright (C) 2015-2016 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. +# + +# Inherit some common CM stuff. +$(call inherit-product, vendor/cm/config/common_full_phone.mk) + +# Inherit device configuration +$(call inherit-product, $(LOCAL_PATH)/device_m2note.mk) + +TARGET_OTA_ASSERT_DEVICE := m2note,m2n,M2Note,M2N + +# Sign the build with real certs +# PS: if you're not me you need to generate your own certs +PRODUCT_DEFAULT_DEV_CERTIFICATE := vendor/moyster/keys/releasekey + +# Device identifier +PRODUCT_BRAND := MEIZU +PRODUCT_DEVICE := m2note +PRODUCT_MANUFACTURER := MEIZU +PRODUCT_MODEL := M2Note +PRODUCT_NAME := cm_m2note +PRODUCT_RELEASE_NAME := m2note +PRODUCT_RESTRICT_VENDOR_FILES := false + +PRODUCT_DEFAULT_LANGUAGE := en +PRODUCT_DEFAULT_REGION := US + diff --git a/cmactions/AndroidManifest.xml b/cmactions/AndroidManifest.xml new file mode 100644 index 0000000..9dd3bd2 --- /dev/null +++ b/cmactions/AndroidManifest.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.cyanogenmod.settings.device" + android:versionCode="1" + android:versionName="1.0" + android:sharedUserId="android.uid.system" + > + + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> + + <uses-sdk + android:minSdkVersion="22" /> + + <application + android:allowBackup="true" + android:label="CMActions" + android:persistent="true" + android:icon="@mipmap/ic_launcher_settings" + android:theme="@android:style/Theme.Material.Settings" > + + <receiver android:name="com.cyanogenmod.settings.device.BootCompletedReceiver"> + <intent-filter> + <action android:name="android.intent.action.BOOT_COMPLETED" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </receiver> + + <!-- stub to ensure its loaded - DO NOT REMOVE --> + <activity android:name=".KeyHandler"/> + + <activity + android:excludeFromRecents="true" + android:name="CMActions" + android:label="CMActions" + android:launchMode="singleInstance" + android:screenOrientation="portrait" + android:windowAnimationStyle="@null"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + </intent-filter> + </activity> + + <activity + android:name=".TouchscreenGestureSettings" + android:label="@string/screen_gestures_panel_title"> + <intent-filter> + <action android:name="com.cyanogenmod.action.LAUNCH_TOUCHSCREEN_GESTURE_SETTINGS" /> + </intent-filter> + <meta-data + android:name="com.android.settings.title" + android:resource="@string/screen_gestures_panel_title"/> + <meta-data + android:name="com.android.settings.summary" + android:resource="@string/screen_gestures_panel_summary"/> + </activity> + + </application> + +</manifest> diff --git a/cmactions/res/values-es/strings.xml b/cmactions/res/values-es/strings.xml new file mode 100644 index 0000000..894726d --- /dev/null +++ b/cmactions/res/values-es/strings.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Copyright (C) 2013-2014 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. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Gesture shortcuts --> + <string name="screen_gestures_panel_title">Atajos de gestos</string> + <string name="screen_gestures_panel_summary">Usar gestos cuando la pantalla está apagada</string> + + <string name="touchscreen_control_gesture_head">Gestos de Pantalla Apagada</string> + <string name="touchscreen_control_gesture_title">Activar Gestos de Pantalla</string> + <string name="gesture_category_title">Gestos Disponibles</string> + + <string name="touchscreen_dtp_gesture_title">Doble toque</string> + <string name="touchscreen_x_left_gesture_title">Deslizar a la izquierda</string> + <string name="touchscreen_x_right_gesture_title">Deslizar a la derecha</string> + <string name="touchscreen_y_down_gesture_title">Deslizar hacia abajo</string> + <string name="touchscreen_y_up_gesture_title">Deslizar hacia arriba</string> + + <string name="touchscreen_c_gesture_title">Dibujar \"c\"</string> + <string name="touchscreen_z_gesture_title">Dibujar \"z\"</string> + <string name="touchscreen_s_gesture_title">Dibujar \"s\"</string> + <string name="touchscreen_w_gesture_title">Dibujar \"w\"</string> + <string name="touchscreen_o_gesture_title">Dibujar \"o\"</string> + <string name="touchscreen_v_gesture_title">Dibujar \"v\"</string> + <string name="touchscreen_e_gesture_title">Dibujar \"e\"</string> + <string name="touchscreen_m_gesture_title">Dibujar \"m\"</string> + + <!-- unused --> + <!-- < equals to < and > equals to > --> + <string name="touchscreen_v_left_gesture_title">Dibujar \"<\"</string> + <string name="touchscreen_v_right_gesture_title">Dibujar \">\"</string> + <string name="touchscreen_v_down_gesture_title">Dibujar \"?\"</string> + + <!-- haptic feedback --> + <string name="touchscreen_extras">Extras</string> + <string name="haptic_feedback">Señal Táctil</string> + <string name="haptic_feedback_summary">Vibrar cuando se detecta el gesto</string> + + <!-- gesture actions --> + <string name="disabled">Desactivado</string> + <string name="wakeUp">Activar Pantalla</string> + <string name="unlock">Desbloquear</string> + <string name="play">Play/Pausa</string> + <string name="next">Pista Siguiente</string> + <string name="prev">Pista Anterior</string> + <string name="camera">Abrir Cámara</string> + <string name="flashlight">(Des)Activar Linterna</string> + <string name="doNotDisturbMode">Modo No Molestar</string> + <string name="normalMode">Modo Normal</string> + <string name="muteMode">Modo silencio</string> + +</resources> diff --git a/cmactions/res/values-fr/strings.xml b/cmactions/res/values-fr/strings.xml new file mode 100644 index 0000000..92c69ce --- /dev/null +++ b/cmactions/res/values-fr/strings.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Copyright (C) 2013-2014 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. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Gesture shortcuts --> + <string name="screen_gestures_panel_title">Gestes tactiles</string> + <string name="screen_gestures_panel_summary">Utilisez les gestes quand l\'écran est éteint</string> + + <string name="touchscreen_control_gesture_head">Gestes écran éteint</string> + <string name="touchscreen_control_gesture_title">Activer les Gestes</string> + <string name="gesture_category_title">Gestes disponible</string> + + <string name="touchscreen_dtp_gesture_title">Double Tape</string> + <string name="touchscreen_x_left_gesture_title">Glissez vers la gauche</string> + <string name="touchscreen_x_right_gesture_title">Glissez vers la droite</string> + <string name="touchscreen_y_down_gesture_title">Glissez vers le bas</string> + <string name="touchscreen_y_up_gesture_title">Glissez vers le haut</string> + + <string name="touchscreen_c_gesture_title">Dessinez \"c\"</string> + <string name="touchscreen_z_gesture_title">Dessinez \"z\"</string> + <string name="touchscreen_s_gesture_title">Dessinez \"s\"</string> + <string name="touchscreen_w_gesture_title">Dessinez \"w\"</string> + <string name="touchscreen_o_gesture_title">Dessinez \"o\"</string> + <string name="touchscreen_v_gesture_title">Dessinez \"v\"</string> + <string name="touchscreen_e_gesture_title">Dessinez \"e\"</string> + <string name="touchscreen_m_gesture_title">Dessinez \"m\"</string> + + <!-- haptic feedback --> + <string name="touchscreen_extras">Extras</string> + <string name="haptic_feedback">Retour Haptique</string> + <string name="haptic_feedback_summary">Vibrer quand un geste est détecté</string> + + <!-- gesture actions --> + <string name="disabled">Désactivé</string> + <string name="wakeUp">Réveiller</string> + <string name="unlock">Dévérouiller</string> + <string name="play">Lecture/Pause</string> + <string name="next">Piste suivante</string> + <string name="prev">Piste précédente</string> + <string name="camera">Appareil photo</string> + <string name="flashlight">Lampe de poche</string> + <string name="doNotDisturbMode">Do Not Disturb Mode</string> + <string name="normalMode">Normal Mode</string> + <string name="muteMode">Mute Mode</string> + +</resources> diff --git a/cmactions/res/values-ru/strings.xml b/cmactions/res/values-ru/strings.xml new file mode 100644 index 0000000..76ac3f2 --- /dev/null +++ b/cmactions/res/values-ru/strings.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013-2014 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. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Gesture shortcuts --> + <string name="screen_gestures_panel_title">Управление жеÑтами</string> + <string name="screen_gestures_panel_summary">ИÑпользовать жеÑты, когда Ñкран выключен</string> + + <string name="touchscreen_control_gesture_head">ЖеÑты выключенного Ñкрана</string> + <string name="touchscreen_control_gesture_title">Включить управление жеÑтами</string> + <string name="gesture_category_title">ДоÑтупные жеÑты</string> + + <string name="touchscreen_dtp_gesture_title">Двойной тап</string> + <string name="touchscreen_x_left_gesture_title">Проведите влево</string> + <string name="touchscreen_x_right_gesture_title">Проведите вправо</string> + <string name="touchscreen_y_down_gesture_title">Проведите вниз</string> + <string name="touchscreen_y_up_gesture_title">Проведите вверх</string> + + <string name="touchscreen_c_gesture_title">ÐариÑуйте \"c\"</string> + <string name="touchscreen_z_gesture_title">ÐариÑуйте \"z\"</string> + <string name="touchscreen_s_gesture_title">ÐариÑуйте \"s\"</string> + <string name="touchscreen_w_gesture_title">ÐариÑуйте \"w\"</string> + <string name="touchscreen_o_gesture_title">ÐариÑуйте \"o\"</string> + <string name="touchscreen_v_gesture_title">ÐариÑуйте \"v\"</string> + <string name="touchscreen_e_gesture_title">ÐариÑуйте \"e\"</string> + <string name="touchscreen_m_gesture_title">ÐариÑуйте \"m\"</string> + + <!-- haptic feedback --> + <string name="touchscreen_extras">Дополнительные наÑтройки</string> + <string name="haptic_feedback">ВибрациÑ</string> + <string name="haptic_feedback_summary">ИÑпользовать вбирацию при обработке жеÑта</string> + + <!-- gesture actions --> + <string name="disabled">Выключено</string> + <string name="wakeUp">Будить</string> + <string name="unlock">Разблокировать</string> + <string name="play">ВоÑпризв./Пауза</string> + <string name="next">Следующий Трек</string> + <string name="prev">Предыдущий Трек</string> + <string name="camera">ЗапуÑтить камеру</string> + <string name="flashlight">ÐаÑтройка вÑпышки</string> + <string name="doNotDisturbMode">Обычный режим</string> + <string name="normalMode">Обычный режим</string> + <string name="muteMode">Беззвучный режим</string> + +</resources> diff --git a/cmactions/res/values/arrays.xml b/cmactions/res/values/arrays.xml new file mode 100644 index 0000000..8982cb4 --- /dev/null +++ b/cmactions/res/values/arrays.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string-array name="gesture_action_titles"> + <item>@string/wakeUp</item> + <item>@string/unlock</item> + <item>@string/play</item> + <item>@string/next</item> + <item>@string/prev</item> + <item>@string/camera</item> + <item>@string/flashlight</item> + <item>@string/doNotDisturbMode</item> + <item>@string/normalMode</item> + <item>@string/muteMode</item> + </string-array> + + <string-array name="gesture_action_values"> + <item>wakeUp</item> + <item>unlock</item> + <item>play</item> + <item>next</item> + <item>prev</item> + <item>camera</item> + <item>flashlight</item> + <item>doNotDisturb</item> + <item>normal</item> + <item>mute</item> + </string-array> + +</resources> diff --git a/cmactions/res/values/strings.xml b/cmactions/res/values/strings.xml new file mode 100644 index 0000000..a19d76b --- /dev/null +++ b/cmactions/res/values/strings.xml @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Copyright (C) 2013-2014 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. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Gesture shortcuts --> + <string name="screen_gestures_panel_title">Gesture shortcuts</string> + <string name="screen_gestures_panel_summary">Use gestures while the screen is off</string> + + <string name="touchscreen_control_gesture_head">Screen Off Gestures</string> + <string name="touchscreen_control_gesture_title">Enable Screen Gestures</string> + <string name="gesture_category_title">Available Gestures</string> + + <string name="touchscreen_dtp_gesture_title">Double Tap</string> + <string name="touchscreen_x_left_gesture_title">Swipe Left</string> + <string name="touchscreen_x_right_gesture_title">Swipe Right</string> + <string name="touchscreen_y_down_gesture_title">Swipe Down</string> + <string name="touchscreen_y_up_gesture_title">Swipe Up</string> + + <string name="touchscreen_c_gesture_title">Draw \"c\"</string> + <string name="touchscreen_z_gesture_title">Draw \"z\"</string> + <string name="touchscreen_s_gesture_title">Draw \"s\"</string> + <string name="touchscreen_w_gesture_title">Draw \"w\"</string> + <string name="touchscreen_o_gesture_title">Draw \"o\"</string> + <string name="touchscreen_v_gesture_title">Draw \"v\"</string> + <string name="touchscreen_e_gesture_title">Draw \"e\"</string> + <string name="touchscreen_m_gesture_title">Draw \"m\"</string> + + <!-- unused --> + <!-- < equals to < and > equals to > --> + <string name="touchscreen_v_left_gesture_title">Draw \"<\"</string> + <string name="touchscreen_v_right_gesture_title">Draw \">\"</string> + <string name="touchscreen_v_down_gesture_title">Draw \"ÊŒ\"</string> + + <!-- haptic feedback --> + <string name="touchscreen_extras">Extras</string> + <string name="haptic_feedback">Haptic feedback</string> + <string name="haptic_feedback_summary">Vibrate when a gesture is detected</string> + + <!-- gesture actions --> + <string name="disabled">Disabled</string> + <string name="wakeUp">Wake Up</string> + <string name="unlock">Unlock</string> + <string name="play">Play/Pause</string> + <string name="next">Next Track</string> + <string name="prev">Previous Track</string> + <string name="camera">Launch Camera</string> + <string name="flashlight">Toggle Flashlight</string> + <string name="doNotDisturbMode">Do Not Disturb Mode</string> + <string name="normalMode">Normal Mode</string> + <string name="muteMode">Mute Mode</string> + +</resources> + diff --git a/cmactions/res/xml/touchscreen_panel.xml b/cmactions/res/xml/touchscreen_panel.xml new file mode 100644 index 0000000..4ab1481 --- /dev/null +++ b/cmactions/res/xml/touchscreen_panel.xml @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + 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. +--> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + + <PreferenceCategory android:title="@string/touchscreen_control_gesture_head"> + + <SwitchPreference + android:key="touchscreen_gesture_control" + android:title="@string/touchscreen_control_gesture_title" /> + + </PreferenceCategory> + + <PreferenceCategory + android:dependency="touchscreen_gesture_control" + android:key="category_gestures" + android:title="@string/gesture_category_title"> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="wakeUp" + android:key="160_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_dtp_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="prev" + android:key="176_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_x_left_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="next" + android:key="177_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_x_right_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="unlock" + android:key="178_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_y_up_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="flashlight" + android:key="179_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_y_down_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="camera" + android:key="193_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_c_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="wakeUp" + android:key="192_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_e_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="normalMode" + android:key="194_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_w_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="muteMode" + android:key="195_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_m_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="wakeUp" + android:key="196_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_o_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="muteMode" + android:key="197_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_s_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="wakeUp" + android:key="198_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_v_gesture_title" /> + + <com.cyanogenmod.settings.device.SwitchPlusPreference + android:defaultValue="doNotDisturbMode" + android:key="202_enabled" + android:summaryOff=" " + android:title="@string/touchscreen_z_gesture_title" /> + </PreferenceCategory> + + <PreferenceCategory android:title="@string/touchscreen_extras"> + + <SwitchPreference + android:key="touchscreen_gesture_haptic_feedback" + android:summary="@string/haptic_feedback_summary" + android:title="@string/haptic_feedback" /> + + </PreferenceCategory> + +</PreferenceScreen> + diff --git a/cmactions/src/com/cyanogenmod/settings/device/BootCompletedReceiver.java b/cmactions/src/com/cyanogenmod/settings/device/BootCompletedReceiver.java new file mode 100644 index 0000000..c52ca65 --- /dev/null +++ b/cmactions/src/com/cyanogenmod/settings/device/BootCompletedReceiver.java @@ -0,0 +1,48 @@ +/* + * 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. + */ + +package com.cyanogenmod.settings.device; + +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.ServiceConnection; +import android.os.IBinder; +import android.util.Log; + +public class BootCompletedReceiver extends BroadcastReceiver { + static final String TAG = "CMActions"; + + @Override + public void onReceive(final Context context, Intent intent) { + Log.d(TAG, "Booting"); + enableComponent(context, TouchscreenGestureSettings.class.getName()); + GestureController.updateGestureControl(context); + } + + private void enableComponent(Context context, String component) { + ComponentName name = new ComponentName(context, component); + PackageManager pm = context.getPackageManager(); + if (pm.getComponentEnabledSetting(name) + == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { + pm.setComponentEnabledSetting(name, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + } + } +} diff --git a/cmactions/src/com/cyanogenmod/settings/device/GestureController.java b/cmactions/src/com/cyanogenmod/settings/device/GestureController.java new file mode 100644 index 0000000..2cef1a3 --- /dev/null +++ b/cmactions/src/com/cyanogenmod/settings/device/GestureController.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2015 The CyanogenMod Project + * Copyright (C) 2016 faust93 adaptation for Meizu PRO5 FTS Driver + * + * 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. + */ + +package com.cyanogenmod.settings.device; + +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; + +import android.util.Log; +import android.util.SparseIntArray; + +import com.cyanogenmod.settings.device.utils.FileUtils; + +public class GestureController { + private static final String TAG = GestureController.class.getSimpleName(); + + public static final String TOUCHSCREEN_GESTURE_CONTROL_NODE = "/sys/devices/platform/mx-gs/gesture_control"; + public static final String TOUCHSCREEN_GESTURE_CONTROL_KEY = "touchscreen_gesture_control"; + + // M2Note gesture keys + public static final int DOUBLE_TAP = 0xA0; //160 + public static final int SWIPE_X_LEFT = 0xB0; //176 + public static final int SWIPE_X_RIGHT = 0xB1; + public static final int SWIPE_Y_UP = 0xB2; + public static final int SWIPE_Y_DOWN = 0xB3; + + public static final int UNICODE_E = 0xC0; // 192 + public static final int UNICODE_C = 0xC1; + public static final int UNICODE_W = 0xC2; + public static final int UNICODE_M = 0xC3; + public static final int UNICODE_O = 0xC4; + public static final int UNICODE_S = 0xC5; + public static final int UNICODE_V_UP = 0xC6; + public static final int UNICODE_V_DOWN = 0xC7; + public static final int UNICODE_V_L = 0xC8; + public static final int UNICODE_V_R = 0xC9; + public static final int UNICODE_Z = 0xCA; + + + public static final int GESTURES_DISABLED_MASK = 0x100; + public static final int GESTURES_ENABLED_MASK = 0x1000100; + + // Supported gesture keys and masks + public static SparseIntArray keysToMasks = new SparseIntArray(); + + static { + keysToMasks.put(DOUBLE_TAP, 0x000100); + + keysToMasks.put(SWIPE_X_LEFT, 0x000001); + keysToMasks.put(SWIPE_X_RIGHT, 0x000002); + keysToMasks.put(SWIPE_Y_DOWN, 0x000004); + keysToMasks.put(SWIPE_Y_UP, 0x000008); + + keysToMasks.put(UNICODE_E, 0x040000); + keysToMasks.put(UNICODE_C, 0x020000); + keysToMasks.put(UNICODE_M, 0x100000); + keysToMasks.put(UNICODE_O, 0x800000); + keysToMasks.put(UNICODE_S, 0x200000); + keysToMasks.put(UNICODE_V_UP, 0x010000); + keysToMasks.put(UNICODE_W, 0x080000); + keysToMasks.put(UNICODE_Z, 0x400000); + } + + public static void updateGestureControl(Context context) { + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + if (sharedPreferences.getBoolean(TOUCHSCREEN_GESTURE_CONTROL_KEY, false)) { + int gestureMask = 0x000000; + FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_ENABLED_MASK); + for (int i = 0; i < keysToMasks.size(); i++) { + int key = keysToMasks.keyAt(i); + int mask = keysToMasks.get(key); + if (sharedPreferences.getBoolean(key + "_enabled", false)) + gestureMask += mask; + } + byte swipeMask = (byte) (gestureMask & 0xff); + FileUtils.writeByteArray(TOUCHSCREEN_GESTURE_CONTROL_NODE, new byte[]{swipeMask, 0, 4, 0}); + byte doubleTapMask = (byte) ((gestureMask >> 8) & 0xff); + FileUtils.writeByteArray(TOUCHSCREEN_GESTURE_CONTROL_NODE, new byte[]{doubleTapMask, 0, 2, 0}); + byte unicodeMask = (byte) ((gestureMask >> 16) & 0xff); + FileUtils.writeByteArray(TOUCHSCREEN_GESTURE_CONTROL_NODE, new byte[]{unicodeMask, 0, 3, 0}); + } else { + FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_DISABLED_MASK); + } + } + + public static void masterSwitch(boolean enabled) { + if (enabled) { + Log.i(TAG, "Gestures enabled"); + FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_ENABLED_MASK); + } else { + Log.i(TAG, "Gestures disabled"); + FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_DISABLED_MASK); + } + } +} + + diff --git a/cmactions/src/com/cyanogenmod/settings/device/SwitchPlusPreference.java b/cmactions/src/com/cyanogenmod/settings/device/SwitchPlusPreference.java new file mode 100644 index 0000000..acf7843 --- /dev/null +++ b/cmactions/src/com/cyanogenmod/settings/device/SwitchPlusPreference.java @@ -0,0 +1,125 @@ +package com.cyanogenmod.settings.device; + +import android.content.Context; +import android.preference.SwitchPreference; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Switch; + +/** + * Custom preference for handling a switch with a clickable preference area as well + * + * Source: https://gist.github.com/marchold/45e22839eb94aa14dfb5 + */ +public class SwitchPlusPreference extends SwitchPreference { + + // + // Public interface + // + + /** + * Sets listeners for the switch and the background container preference view cell + * + * @param listener A valid SwitchPlusClickListener + */ + public void setSwitchClickListener(SwitchPlusClickListener listener) { + this.listener = listener; + } + + private SwitchPlusClickListener listener = null; + + /** + * Interface gives callbacks in to both parts of the preference + */ + public interface SwitchPlusClickListener { + /** + * Called when the switch is switched + * + * @param preference + * @param isChecked + */ + public void onCheckedChanged(SwitchPlusPreference preference, boolean isChecked); + + /** + * Called when the preference view is clicked + * + * @param view + * @param preference + */ + public void onClick(View view, SwitchPlusPreference preference); + } + + public SwitchPlusPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public SwitchPlusPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public SwitchPlusPreference(Context context) { + super(context); + } + + + // + // Internal Functions + // + + /** + * Recursively go through view tree until we find an android.widget.Switch + * + * @param view Root view to start searching + * @return A Switch class or null + */ + private Switch findSwitchWidget(View view) { + if (view instanceof Switch) { + return (Switch) view; + } + if (view instanceof ViewGroup) { + ViewGroup viewGroup = (ViewGroup) view; + for (int i = 0; i < viewGroup.getChildCount(); i++) { + View child = viewGroup.getChildAt(i); + if (child instanceof ViewGroup) { + Switch result = findSwitchWidget(child); + if (result != null) return result; + } + if (child instanceof Switch) { + return (Switch) child; + } + } + } + return null; + } + + //Get a handle on the 2 parts of the switch preference and assign handlers to them + @Override + protected void onBindView(View view) { + super.onBindView(view); + final SwitchPlusPreference that = this; + + final Switch switchView = findSwitchWidget(view); + if (switchView != null) { + switchView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (listener != null) + listener.onCheckedChanged(that, ((Switch) v).isChecked()); + } + }); + switchView.setChecked(getSharedPreferences().getBoolean(getKey(), false)); + switchView.setFocusable(true); + //switchView.setEnabled(true); + } + + + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (listener != null) listener.onClick(v, that); + } + }); + } +} + diff --git a/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureSettings.java b/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureSettings.java new file mode 100644 index 0000000..2945404 --- /dev/null +++ b/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureSettings.java @@ -0,0 +1,155 @@ +/* + * 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. + */ + +package com.cyanogenmod.settings.device; + +import android.app.ActionBar; +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.PreferenceFragment; +import android.preference.PreferenceManager; +import android.view.MenuItem; +import android.view.View; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class TouchscreenGestureSettings extends Activity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final ActionBar actionBar = getActionBar(); + actionBar.setDisplayHomeAsUpEnabled(true); + + getFragmentManager().beginTransaction() + .replace(android.R.id.content, new GestureFragment()) + .commit(); + } + + @Override + protected void onResume() { + super.onResume(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + onBackPressed(); + return true; + } + return false; + } + + public static class GestureFragment extends PreferenceFragment implements SwitchPlusPreference.SwitchPlusClickListener { + + public static final String TAG = GestureFragment.class.getSimpleName(); + + private SharedPreferences sharedPrefs; + private String[] actionTitles; + private String[] actionValues; + private List<String> actionTitlesList; + private List<String> actionValuesList; + private static final List<String> allowedSystemApps = new ArrayList<>(); + + static { + allowedSystemApps.add("com.android.dialer"); + allowedSystemApps.add("com.android.mms"); + allowedSystemApps.add("com.android.settings"); + allowedSystemApps.add("com.android.deskclock"); + allowedSystemApps.add("com.android.calculator2"); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.touchscreen_panel); + sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + + actionTitlesList = new ArrayList<>(); + actionValuesList = new ArrayList<>(); + actionTitles = this.getResources().getStringArray(R.array.gesture_action_titles); + actionValues = this.getResources().getStringArray(R.array.gesture_action_values); + actionTitlesList.addAll(Arrays.asList(actionTitles)); + actionValuesList.addAll(Arrays.asList(actionValues)); + + List<ApplicationInfo> packages = getActivity().getPackageManager() + .getInstalledApplications(PackageManager.GET_META_DATA); + for (ApplicationInfo appInfo : packages) { + if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 && + allowedSystemApps.indexOf(appInfo.packageName) == -1) + continue; + actionTitlesList.add(appInfo.loadLabel(getActivity().getPackageManager()).toString()); + actionValuesList.add("launch$" + appInfo.packageName); + } + actionTitles = actionTitlesList.toArray(new String[actionTitlesList.size()]); + actionValues = actionValuesList.toArray(new String[actionValuesList.size()]); + for (int x = 0; x < GestureController.keysToMasks.size(); x++) { + int prefKey = GestureController.keysToMasks.keyAt(x); + SwitchPlusPreference preference = (SwitchPlusPreference) findPreference(String.valueOf(prefKey) + "_enabled"); + preference.setSwitchClickListener(this); + String prefValue = sharedPrefs.getString(String.valueOf(prefKey) + "_action", "disabled"); + int i = actionValuesList.indexOf(prefValue); + if (i >= 0) + preference.setSummaryOn(actionTitles[i]); + else + preference.setSummaryOn(" "); + } + + findPreference(GestureController.TOUCHSCREEN_GESTURE_CONTROL_KEY).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object o) { + boolean newValue = (boolean) o; + GestureController.masterSwitch(newValue); + return true; + } + }); + } + + @Override + public void onCheckedChanged(SwitchPlusPreference preference, boolean isChecked) { + GestureController.updateGestureControl(getActivity()); + } + + @Override + public void onClick(View view, final SwitchPlusPreference preference) { + if (!preference.isChecked()) return; + + String prefValue = sharedPrefs.getString(preference.getKey().replace("_enabled", "_action"), "disabled"); + int i = actionValuesList.indexOf(prefValue); + AlertDialog dialog = new AlertDialog.Builder(getActivity()).setSingleChoiceItems(actionTitles, i, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + preference.setSummaryOn(actionTitles[which]); + sharedPrefs.edit().putString(preference.getKey().replace("_enabled", "_action"), + actionValues[which]).apply(); + dialog.dismiss(); + } + }).create(); + dialog.show(); + } + } +} + + diff --git a/cmactions/src/com/cyanogenmod/settings/device/utils/FileUtils.java b/cmactions/src/com/cyanogenmod/settings/device/utils/FileUtils.java new file mode 100644 index 0000000..e0ed400 --- /dev/null +++ b/cmactions/src/com/cyanogenmod/settings/device/utils/FileUtils.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2013 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. + */ + +package com.cyanogenmod.settings.device.utils; + +import android.util.Log; + +import java.io.BufferedReader; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.nio.ByteBuffer; + +public final class FileUtils { + private static final String TAG = "FileUtils"; + + private FileUtils() { + // this class is not supposed to be instantiated + } + + /** + * Reads the first line of text from the given file + */ + public static String readOneLine(String fileName) { + String line = null; + BufferedReader reader = null; + + try { + reader = new BufferedReader(new FileReader(fileName), 512); + line = reader.readLine(); + } catch (IOException e) { + Log.e(TAG, "Could not read from file " + fileName, e); + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (IOException e) { + // ignored, not much we can do anyway + } + } + + return line; + } + + /** + * Writes the given value into the given file + * + * @return true on success, false on failure + */ + public static boolean writeLine(String fileName, String value) { + try { + FileOutputStream fos = new FileOutputStream(fileName); + fos.write(value.getBytes()); + fos.flush(); + fos.close(); + } catch (IOException e) { + Log.e(TAG, "Could not write to file " + fileName, e); + return false; + } + + return true; + } + + /** + * Writes the given value as bytes into the given file + * + * @return true on success, false on failure + */ + public static boolean writeAsByte(String fileName, int value) { + byte[] bytes = ByteBuffer.allocate(4).putInt(value).array(); + try { + FileOutputStream fos = new FileOutputStream(fileName); + fos.write(bytes); + fos.flush(); + fos.close(); + } catch (IOException e) { + Log.e(TAG, "Could not write to file " + fileName, e); + return false; + } + return true; + } + + /** + * Writes the given byte array into the given file + * + * @return true on success, false on failure + */ + public static boolean writeByteArray(String fileName, byte[] bytes) { + try { + FileOutputStream fos = new FileOutputStream(fileName); + fos.write(bytes); + fos.flush(); + fos.close(); + } catch (IOException e) { + Log.e(TAG, "Could not write to file " + fileName, e); + return false; + } + return true; + } +} + diff --git a/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java new file mode 100644 index 0000000..11d3ce1 --- /dev/null +++ b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2016 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. + */ + +package org.cyanogenmod.hardware; + +import java.io.File; +import java.util.Scanner; +import org.cyanogenmod.hardware.util.FileUtils; + +public class DisplayColorCalibration { + private static final String COLOR_FILE = "/sys/devices/platform/mtk_disp_mgr.0/rgb"; + + public static boolean isSupported() { + File f = new File(COLOR_FILE); + return f.exists(); + } + + public static int getMaxValue() { + return 2000; + } + + public static int getMinValue() { + return 0; + } + + public static int getDefValue() { + return getMaxValue(); + } + + public static String getCurColors() { + return FileUtils.readOneLine(COLOR_FILE); + } + + public static boolean setColors(String colors) { + return FileUtils.writeLine(COLOR_FILE, colors); + } +} diff --git a/cmhw/org/cyanogenmod/hardware/KeyDisabler.java b/cmhw/org/cyanogenmod/hardware/KeyDisabler.java new file mode 100644 index 0000000..b101869 --- /dev/null +++ b/cmhw/org/cyanogenmod/hardware/KeyDisabler.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2014 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. + */ + +package org.cyanogenmod.hardware; + +import android.util.Log; +/* + * Disable capacitive keys + * + * This is intended for use on devices in which the capacitive keys + * can be fully disabled for replacement with a soft navbar. You + * really should not be using this on a device with mechanical or + * otherwise visible-when-inactive keys + */ + +public class KeyDisabler { + + private static boolean isActive = false; + /* + * All HAF classes should export this boolean. + * Real implementations must, of course, return true + */ + + public static boolean isSupported() { return true; } + + /* + * Are the keys currently blocked? + */ + + public static boolean isActive() { + return isActive; + } + + /* + * Disable capacitive keys + */ + + public static boolean setActive(boolean state) { + //throw new UnsupportedOperationException(); + isActive = state; + Log.i("KeyDisabler", "setActive " + state); + return isActive; + } + +} diff --git a/cmhw/org/cyanogenmod/hardware/VibratorHW.java b/cmhw/org/cyanogenmod/hardware/VibratorHW.java new file mode 100644 index 0000000..6da130f --- /dev/null +++ b/cmhw/org/cyanogenmod/hardware/VibratorHW.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2013 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. + */ + +package org.cyanogenmod.hardware; + +import org.cyanogenmod.internal.util.FileUtils; + +/* + * Vibrator intensity adjustment + * + * Exports methods to get the valid value boundaries, the + * default and current intensities, and a method to set + * the vibrator. + * + * Values exported by min/max can be the direct values required + * by the hardware, or a local (to VibratorHW) abstraction that's + * internally converted to something else prior to actual use. The + * Settings user interface will normalize these into a 0-100 (percentage) + * scale before showing them to the user, but all values passed to/from + * the client (Settings) are in this class' scale. + */ + +/* This would be just "Vibrator", but it conflicts with android.os.Vibrator */ +public class VibratorHW { + + // Keep this synced to immvibe impl + private static final String INTENSITY_FILE = "/data/.libimmvibeclient_force"; + + public static boolean isSupported() { + return true; + } + + public static boolean setIntensity(int intensity) { + return FileUtils.writeLine(INTENSITY_FILE, Integer.toString(intensity)); + } + + public static int getMaxIntensity() { + return 127; + } + + public static int getMinIntensity() { + return 3; + } + + public static int getWarningThreshold() { + // actually this is rather arbitrary + return 115; + } + + public static int getCurIntensity() { + final String result = FileUtils.readOneLine(INTENSITY_FILE); + if (result == null) { + return 96; + } + + try { + return Integer.parseInt(result.trim()); + } catch (final NumberFormatException ignored) { + return 96; + } + } + + public static int getDefaultIntensity() { + return 96; + } +} diff --git a/configs/android.hardware.microphone.xml b/configs/android.hardware.microphone.xml new file mode 100755 index 0000000..364e4ee --- /dev/null +++ b/configs/android.hardware.microphone.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- This is the standard feature indicating that the device includes microphone. --> +<permissions> + <feature name="android.hardware.microphone" /> +</permissions> diff --git a/configs/audio/audio_device.xml b/configs/audio/audio_device.xml new file mode 100755 index 0000000..921af1d --- /dev/null +++ b/configs/audio/audio_device.xml @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<mixercontrol> + <versioncontrol value="1.01"> + </versioncontrol> + <!-- These are the initial mixer settings --> + <kctl name="Audio_Speaker_class_Switch" value="CLASSAB" /> + <kctl name="Audio_Amp_R_Switch" value="Off" /> + <kctl name="Audio_Amp_L_Switch" value="Off" /> + <kctl name="Voice_Amp_Switch" value="Off" /> + <kctl name="Speaker_Amp_Switch" value="Off" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Ext_Speaker_Amp_Switch" value="Off" /> + <kctl name="Audio_Sidetone_Switch" value="Off" /> + <kctl name="Headset_Speaker_Amp_Switch" value="Off" /> + <!--headphone output--> + <path name="headphone_output" value="turnon"> + <kctl name="Audio_Amp_R_Switch" value="On" /> + <kctl name="Audio_Amp_L_Switch" value="On" /> + </path> + <path name="headphone_output" value="turnoff"> + <kctl name="Audio_Amp_R_Switch" value="Off" /> + <kctl name="Audio_Amp_L_Switch" value="Off" /> + </path> + <!--receiver output--> + <path name="receiver_output" value="turnon"> + <kctl name="Voice_Amp_Switch" value="On" /> + </path> + <path name="receiver_output" value="turnoff"> + <kctl name="Voice_Amp_Switch" value="Off" /> + </path> + <!-- 2-in-1 speaker output--> + <path name="two_in_one_speaker_output" value="turnon"> + <kctl name="Speaker_Amp_Switch" value="On" /> + <kctl name="Audio_Speaker_class_Switch" value="CLASSAB" /> + </path> + <path name="two_in_one_speaker_output" value="turnoff"> + <kctl name="Audio_Speaker_class_Switch" value="RECEIVER" /> + <kctl name="Speaker_Amp_Switch" value="Off" /> + </path> + <!--speaker output--> + <path name="speaker_output" value="turnon"> + <kctl name="Speaker_Amp_Switch" value="On" /> + </path> + <path name="speaker_output" value="turnoff"> + <kctl name="Speaker_Amp_Switch" value="Off" /> + </path> + <!--headhpone_speaker output--> + <path name="headphoneSpeaker_output" value="turnon"> + <kctl name="Headset_Speaker_Amp_Switch" value="On" /> + </path> + <path name="headphoneSpeaker_output" value="turnoff"> + <kctl name="Headset_Speaker_Amp_Switch" value="Off" /> + </path> + <!--external_speaker output--> + <path name="ext_speaker_output" value="turnon"> + <kctl name="Ext_Speaker_Amp_Switch" value="On" /> + </path> + <path name="ext_speaker_output" value="turnoff"> + <kctl name="Ext_Speaker_Amp_Switch" value="Off" /> + </path> + <!--mic setting--> + <path name="builtin_Mic_Mic1" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC1" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC1" /> + </path> + <path name="builtin_Mic_Mic1" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="builtin_Mic_Mic1_Inverse" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC3" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC3" /> + </path> + <path name="builtin_Mic_Mic1_Inverse" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="builtin_Mic_Mic2" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC3" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC3" /> + </path> + <path name="builtin_Mic_Mic2" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="builtin_Mic_Mic2_Inverse" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC1" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC1" /> + </path> + <path name="builtin_Mic_Mic2_Inverse" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="builtin_Mic_SingleMic" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC1" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC1" /> + </path> + <path name="builtin_Mic_SingleMic" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + </path> + <path name="builtin_Mic_DualMic" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC1" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC3" /> + </path> + <path name="builtin_Mic_DualMic" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="builtin_Mic_BackMic" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC3" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC3" /> + </path> + <path name="builtin_Mic_BackMic" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="builtin_Mic_BackMic_Inverse" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC1" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC1" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC1" /> + </path> + <path name="builtin_Mic_BackMic_Inverse" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="headset_mic_input" value="turnon"> + <kctl name="Audio_MicSource1_Setting" value="ADC2" /> + <kctl name="Audio_ADC_1_Switch" value="On" /> + <kctl name="Audio_ADC_2_Switch" value="On" /> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC2" /> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC2" /> + </path> + <path name="headset_mic_input" value="turnoff"> + <kctl name="Audio_Preamp1_Switch" value="OPEN" /> + <kctl name="Audio_Preamp2_Switch" value="OPEN" /> + <kctl name="Audio_ADC_1_Switch" value="Off" /> + <kctl name="Audio_ADC_2_Switch" value="Off" /> + </path> + <path name="sidetone_switch" value="turnon"> + <kctl name="Audio_Sidetone_Switch" value="On" /> + </path> + <path name="sidetone_switch" value="turnoff"> + <kctl name="Audio_Sidetone_Switch" value="Off" /> + </path> + <!--mic1 type setting--> + <path name="Mic1TypeACCMode" value="setting"> + <kctl name="Audio_MIC1_Mode_Select" value="ACCMODE" />> + </path> + <path name="Mic1TypeDCCMode" value="setting"> + <kctl name="Audio_MIC1_Mode_Select" value="DCCMODE" />> + </path> + <path name="Mic1TypeDMICMode" value="setting"> + <kctl name="Audio_MIC1_Mode_Select" value="DMIC" />> + </path> + <path name="Mic1TypeDCCECMDIFFMode" value="setting"> + <kctl name="Audio_MIC1_Mode_Select" value="DCCECMDIFFMODE" />> + </path> + <path name="Mic1TypeDCCECMSINGLEMode" value="setting"> + <kctl name="Audio_MIC1_Mode_Select" value="DCCECMSINGLEMODE" />> + </path> + <!--mic2 type setting--> + <path name="Mic2TypeACCMode" value="setting"> + <kctl name="Audio_MIC2_Mode_Select" value="ACCMODE" />> + </path> + <path name="Mic2TypeDCCMode" value="setting"> + <kctl name="Audio_MIC2_Mode_Select" value="DCCMODE" />> + </path> + <path name="Mic2TypeDMICMode" value="setting"> + <kctl name="Audio_MIC2_Mode_Select" value="DMIC" />> + </path> + <path name="Mic2TypeDCCECMDIFFMode" value="setting"> + <kctl name="Audio_MIC2_Mode_Select" value="DCCECMDIFFMODE" />> + </path> + <path name="Mic2TypeDCCECMSINGLEMode" value="setting"> + <kctl name="Audio_MIC2_Mode_Select" value="DCCECMSINGLEMODE" />> + </path> + <!--mic3 type setting--> + <path name="Mic3TypeACCMode" value="setting"> + <kctl name="Audio_MIC3_Mode_Select" value="ACCMODE" />> + </path> + <path name="Mic3TypeDCCMode" value="setting"> + <kctl name="Audio_MIC3_Mode_Select" value="DCCMODE" />> + </path> + <path name="Mic3TypeDMICMode" value="setting"> + <kctl name="Audio_MIC3_Mode_Select" value="DMIC" />> + </path> + <path name="Mic3TypeDCCECMDIFFMode" value="setting"> + <kctl name="Audio_MIC3_Mode_Select" value="DCCECMDIFFMODE" />> + </path> + <path name="Mic3TypeDCCECMSINGLEMode" value="setting"> + <kctl name="Audio_MIC3_Mode_Select" value="DCCECMSINGLEMODE" />> + </path> + <!--mic4 type setting--> + <path name="Mic4TypeACCMode" value="setting"> + <kctl name="Audio_MIC4_Mode_Select" value="ACCMODE" />> + </path> + <path name="Mic4TypeDCCMode" value="setting"> + <kctl name="Audio_MIC4_Mode_Select" value="DCCMODE" />> + </path> + <path name="Mic4TypeDMICMode" value="setting"> + <kctl name="Audio_MIC4_Mode_Select" value="DMIC" />> + </path> + <path name="Mic4TypeDCCECMDIFFMode" value="setting"> + <kctl name="Audio_MIC4_Mode_Select" value="DCCECMDIFFMODE" />> + </path> + <path name="Mic4TypeDCCECMSINGLEMode" value="setting"> + <kctl name="Audio_MIC4_Mode_Select" value="DCCECMSINGLEMODE" />> + </path> + <path name="Mic_Setting_Inverse" value="setting"> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC3" />> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC1" />> + </path> + <path name="Mic_Setting_NoInverse" value="setting"> + <kctl name="Audio_Preamp1_Switch" value="IN_ADC1" />> + <kctl name="Audio_Preamp2_Switch" value="IN_ADC3" />> + </path> +</mixercontrol> diff --git a/configs/audio/audio_effects.conf b/configs/audio/audio_effects.conf new file mode 100644 index 0000000..bd5e4c0 --- /dev/null +++ b/configs/audio/audio_effects.conf @@ -0,0 +1,186 @@ +# List of effect libraries to load. Each library element must contain a "path" element +# giving the full path of the library .so file. +# libraries { +# <lib name> { +# path <lib path> +# } +# } +libraries { +# This is a proxy library that will be an abstraction for +# the HW and SW effects + + #proxy { + #path /system/lib/soundfx/libeffectproxy.so + #} + +# This is the SW implementation library of the effect + #libSW { + #path /system/lib/soundfx/libswwrapper.so + #} + +# This is the HW implementation library for the effect + #libHW { + #path /system/lib/soundfx/libhwwrapper.so + #} + + bundle { + path /system/lib/soundfx/libbundlewrapper.so + } + reverb { + path /system/lib/soundfx/libreverbwrapper.so + } + visualizer { + path /system/lib/soundfx/libvisualizer.so + } + downmix { + path /system/lib/soundfx/libdownmix.so + } + loudness_enhancer { + path /system/lib/soundfx/libldnhncr.so + } + pre_processing { + path /system/lib/soundfx/libaudiopreprocessing.so + } +} + +# Default pre-processing library. Add to audio_effect.conf "libraries" section if +# audio HAL implements support for default software audio pre-processing effects +# +# pre_processing { +# path /system/lib/soundfx/libaudiopreprocessing.so +# } + +# list of effects to load. Each effect element must contain a "library" and a "uuid" element. +# The value of the "library" element must correspond to the name of one library element in the +# "libraries" element. +# The name of the effect element is indicative, only the value of the "uuid" element +# designates the effect. +# The uuid is the implementation specific UUID as specified by the effect vendor. This is not the +# generic effect type UUID. +# effects { +# <fx name> { +# library <lib name> +# uuid <effect uuid> +# } +# ... +# } + +effects { + +# additions for the proxy implementation +# Proxy implementation + #effectname { + #library proxy + #uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + + # SW implemetation of the effect. Added as a node under the proxy to + # indicate this as a sub effect. + #libsw { + #library libSW + #uuid yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy + #} End of SW effect + + # HW implementation of the effect. Added as a node under the proxy to + # indicate this as a sub effect. + #libhw { + #library libHW + #uuid zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz + #}End of HW effect + #} End of effect proxy + + bassboost { + library bundle + uuid 8631f300-72e2-11df-b57e-0002a5d5c51b + } + virtualizer { + library bundle + uuid 1d4033c0-8557-11df-9f2d-0002a5d5c51b + } + equalizer { + library bundle + uuid ce772f20-847d-11df-bb17-0002a5d5c51b + } + volume { + library bundle + uuid 119341a0-8469-11df-81f9-0002a5d5c51b + } + reverb_env_aux { + library reverb + uuid 4a387fc0-8ab3-11df-8bad-0002a5d5c51b + } + reverb_env_ins { + library reverb + uuid c7a511a0-a3bb-11df-860e-0002a5d5c51b + } + reverb_pre_aux { + library reverb + uuid f29a1400-a3bb-11df-8ddc-0002a5d5c51b + } + reverb_pre_ins { + library reverb + uuid 172cdf00-a3bc-11df-a72f-0002a5d5c51b + } + visualizer { + library visualizer + uuid d069d9e0-8329-11df-9168-0002a5d5c51b + } + downmix { + library downmix + uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f + } + loudness_enhancer { + library loudness_enhancer + uuid fa415329-2034-4bea-b5dc-5b381c8d1e2c + } + agc { + library pre_processing + uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b + } + aec { + library pre_processing + uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b + } + ns { + library pre_processing + uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b + } +} +# Audio preprocessor configurations. +# The pre processor configuration consists in a list of elements each describing +# pre processor settings for a given input source. Valid input source names are: +# "mic", "camcorder", "voice_recognition", "voice_communication" +# Each input source element contains a list of effects elements. The name of the effect +# element must be the name of one of the effects in the "effects" list of the file. +# Each effect element may optionally contain a list of parameters and their +# default value to apply when the pre processor effect is created. +# A parameter is defined by a "param" element and a "value" element. Each of these elements +# consists in one or more elements specifying a type followed by a value. +# The types defined are: "int", "short", "float", "bool" and "string" +# When both "param" and "value" are a single int, a simple form is allowed where just +# the param and value pair is present in the parameter description +# pre_processing { +# <input source name> { +# <fx name> { +# <param 1 name> { +# param { +# int|short|float|bool|string <value> +# [ int|short|float|bool|string <value> ] +# ... +# } +# value { +# int|short|float|bool|string <value> +# [ int|short|float|bool|string <value> ] +# ... +# } +# } +# <param 2 name > {<param> <value>} +# ... +# } +# ... +# } +# ... +# } + +# +# TODO: add default audio pre processor configurations after debug and tuning phase +# diff --git a/configs/audio/audio_policy.conf b/configs/audio/audio_policy.conf new file mode 100644 index 0000000..a304c2b --- /dev/null +++ b/configs/audio/audio_policy.conf @@ -0,0 +1,167 @@ +# +# Audio policy configuration for generic device builds (goldfish audio HAL - emulator) +# + +# Global configuration section: lists input and output devices always present on the device +# as well as the output device selected by default. +# Devices are designated by a string that corresponds to the enum in audio.h + +#global_configuration { +# attached_output_devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE +# default_output_device AUDIO_DEVICE_OUT_SPEAKER +# attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_FM +#} + +# audio hardware module section: contains descriptors for all audio hw modules present on the +# device. Each hw module node is named after the corresponding hw module library base name. +# For instance, "primary" corresponds to audio.primary.<device>.so. +# The "primary" module is mandatory and must include at least one output with +# AUDIO_OUTPUT_FLAG_PRIMARY flag. +# Each module descriptor contains one or more output profile descriptors and zero or more +# input profile descriptors. Each profile lists all the parameters supported by a given output +# or input stream category. +# The "channel_masks", "formats", "devices" and "flags" are specified using strings corresponding +# to enums in audio.h and audio_policy.h. They are concatenated by use of "|" without space or "\n". + +audio_hw_modules { + primary { + global_configuration { + attached_output_devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE + default_output_device AUDIO_DEVICE_OUT_SPEAKER + attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_FM|AUDIO_DEVICE_IN_VOICE_CALL + audio_hal_version 3.0 + } + devices { + headset { + type AUDIO_DEVICE_OUT_WIRED_HEADSET + gains { + gain_1 { + mode AUDIO_GAIN_MODE_JOINT + channel_mask AUDIO_CHANNEL_OUT_STEREO + min_value_mB -6400 + max_value_mB 0 + default_value_mB 0 + step_value_mB 100 + min_ramp_ms 0 + max_ramp_ms 0 + } + } + } + headphone { + type AUDIO_DEVICE_OUT_WIRED_HEADPHONE + gains { + gain_1 { + mode AUDIO_GAIN_MODE_JOINT + channel_mask AUDIO_CHANNEL_OUT_STEREO + min_value_mB -6400 + max_value_mB 0 + default_value_mB 0 + step_value_mB 100 + min_ramp_ms 0 + max_ramp_ms 0 + } + } + } + } + outputs { + primary { + sampling_rates 44100 + channel_masks AUDIO_CHANNEL_OUT_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_FM_TX|AUDIO_DEVICE_OUT_DEFAULT + flags AUDIO_OUTPUT_FLAG_PRIMARY + gains { + gain_1 { + mode AUDIO_GAIN_MODE_JOINT + channel_mask AUDIO_CHANNEL_OUT_STEREO + min_value_mB -6400 + max_value_mB 0 + default_value_mB 0 + step_value_mB 100 + min_ramp_ms 0 + max_ramp_ms 0 + } + } + } + } + inputs { + primary { + # MTK ;-) + sampling_rates 48000 + channel_masks AUDIO_CHANNEL_IN_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_IN_COMMUNICATION|AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_AMBIENT|AUDIO_DEVICE_IN_WIRED_HEADSET|AUDIO_DEVICE_IN_AUX_DIGITAL|AUDIO_DEVICE_IN_MATV|AUDIO_DEVICE_IN_VOICE_CALL|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_ALL_SCO|AUDIO_DEVICE_IN_FM|AUDIO_DEVICE_IN_DEFAULT + } + } + } + a2dp { + global_configuration { + audio_hal_version 2.0 + } + outputs { + a2dp { + sampling_rates 44100 + channel_masks AUDIO_CHANNEL_OUT_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_OUT_ALL_A2DP + } + } + inputs { + a2dp { + sampling_rates 44100 + channel_masks AUDIO_CHANNEL_IN_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_IN_BLUETOOTH_A2DP + } + } + } + usb { + global_configuration { + audio_hal_version 2.0 + } + outputs { + usb_accessory { + sampling_rates 44100 + channel_masks AUDIO_CHANNEL_OUT_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_OUT_USB_ACCESSORY + } + usb_device { + sampling_rates 44100 + channel_masks AUDIO_CHANNEL_OUT_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_OUT_USB_DEVICE + } + } + inputs { + usb_device { + sampling_rates 44100 + channel_masks AUDIO_CHANNEL_IN_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_IN_USB_DEVICE + } + } + } + r_submix { + global_configuration { + attached_input_devices AUDIO_DEVICE_IN_REMOTE_SUBMIX + audio_hal_version 2.0 + } + outputs { + r_submix { + sampling_rates 48000 + channel_masks AUDIO_CHANNEL_OUT_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_OUT_REMOTE_SUBMIX + } + } + inputs { + r_submix { + sampling_rates 48000 + channel_masks AUDIO_CHANNEL_IN_STEREO + formats AUDIO_FORMAT_PCM_16_BIT + devices AUDIO_DEVICE_IN_REMOTE_SUBMIX + } + } + } +} diff --git a/configs/bluetooth/auto_pair_devlist.conf b/configs/bluetooth/auto_pair_devlist.conf new file mode 100644 index 0000000..2b5ccb1 --- /dev/null +++ b/configs/bluetooth/auto_pair_devlist.conf @@ -0,0 +1,27 @@ +# Do NOT change this file format without updating the parsing logic in +# BT IF module implementation (btif_storage.c) + +# This file contains information to prevent auto pairing with Bluetooth devices. +# Blacklisting by vendor prefix address: +# The following companies are included in the list below: +# ALPS (lexus), Murata (Prius 2007, Nokia 616), TEMIC SDS (Porsche, Audi), +# Parrot, Zhongshan General K-mate Electronics, Great Well +# Electronics, Flaircomm Electronics, Jatty Electronics, Delphi, +# Clarion, Novero, Denso (Lexus, Toyota), Johnson Controls (Acura), +# Continental Automotive, Harman/Becker, Panasonic/Kyushu Ten, +# BMW (Motorola PCS), Visteon, Peugeot, BMW (MINI10013), Venza (Toyota) +AddressBlacklist=00:02:C7,00:16:FE,00:19:C1,00:1B:FB,00:1E:3D,00:21:4F,00:23:06,00:24:33,00:A0:79,00:0E:6D,00:13:E0,00:21:E8,00:60:57,00:0E:9F,00:12:1C,00:18:91,00:18:96,00:13:04,00:16:FD,00:22:A0,00:0B:4C,00:60:6F,00:23:3D,00:C0:59,00:0A:30,00:1E:AE,00:1C:D7,00:80:F0,00:12:8A,00:09:93,00:80:37,00:26:7E,00:26:e8 + +# Blacklisting by Exact Name: +ExactNameBlacklist=Motorola IHF1000,i.TechBlueBAND,X5 Stereo v1.3,KML_CAN + +# Blacklisting by Partial Name (if name starts with) +PartialNameBlacklist=BMW,Audi,Parrot,Car + +# Fixed PIN keyboard blacklist. Keyboards should have variable PIN +# The keyboards below have a fixed PIN of 0000, so we will auto pair. +# Note the reverse logic in this case compared to other's in this file +# where its a blacklist for not auto pairing. +FixedPinZerosKeyboardBlacklist=00:0F:F6 + +# Blacklisting by addition of the address during usage diff --git a/configs/bluetooth/bt_did.conf b/configs/bluetooth/bt_did.conf new file mode 100644 index 0000000..ea89c06 --- /dev/null +++ b/configs/bluetooth/bt_did.conf @@ -0,0 +1,85 @@ +# Device ID (DID) configuration +[DID1] + +# Primary Record - true or false (default) +# There can be only one primary record +primaryRecord = true + +# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device +# 0x000F = Broadcom Corporation (default) +#vendorId = 0x000F + +# Vendor ID Source +# 0x0001 = Bluetooth SIG assigned Device ID Vendor ID value (default) +# 0x0002 = USB Implementer’s Forum assigned Device ID Vendor ID value +#vendorIdSource = 0x0001 + +# Product ID & Product Version +# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N +# JJ: major version number, M: minor version number, N: sub-minor version number +# For example: 1200, v14.3.6 +productId = 0x1200 +version = 0x1436 + +# Optional attributes +#clientExecutableURL = +#serviceDescription = +#documentationURL = + +#=================================================================================================# +# Device ID (DID) configuration +[DID2] + +# Primary Record - true or false (default) +# There can be only one primary record +#primaryRecord = false + +# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device +# 0x000F = Broadcom Corporation (default) +#vendorId = 0x000F + +# Vendor ID Source +# 0x0001 = Bluetooth SIG assigned Device ID Vendor ID value (default) +# 0x0002 = USB Implementer’s Forum assigned Device ID Vendor ID value +#vendorIdSource = 0x0001 + +# Product ID & Product Version +# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N +# JJ: major version number, M: minor version number, N: sub-minor version number +# Default: 0x0000, v00.0.0 +#productId = 0x0000 +#version = 0x0000 + +# Optional attributes +#clientExecutableURL = +#serviceDescription = +#documentationURL = + +#=================================================================================================# +# Device ID (DID) configuration +[DID3] + +# Primary Record - true or false (default) +# There can be only one primary record +#primaryRecord = false + +# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device +# 0x000F = Broadcom Corporation (default) +#vendorId = 0x000F + +# Vendor ID Source +# 0x0001 = Bluetooth SIG assigned Device ID Vendor ID value (default) +# 0x0002 = USB Implementer’s Forum assigned Device ID Vendor ID value +#vendorIdSource = 0x0001 + +# Product ID & Product Version +# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N +# JJ: major version number, M: minor version number, N: sub-minor version number +# Default: 0x0000, v00.0.0 +#productId = 0x0000 +#version = 0x0000 + +# Optional attributes +#clientExecutableURL = +#serviceDescription = +#documentationURL = diff --git a/configs/bluetooth/bt_stack.conf b/configs/bluetooth/bt_stack.conf new file mode 100644 index 0000000..e42309e --- /dev/null +++ b/configs/bluetooth/bt_stack.conf @@ -0,0 +1,294 @@ +# Enable BtSnoop logging function +# valid value : true, false +BtSnoopLogOutput=false + +# BtSnoop log output file +BtSnoopFileName=/sdcard/mtklog/btlog/btsnoop_hci.log + +# Preserve existing BtSnoop log before overwriting +BtSnoopSaveLog=false + +# Enable trace level reconfiguration function +# Must be present before any TRC_ trace level settings +TraceConf=true + +# Trace level configuration +# BT_TRACE_LEVEL_NONE 0 ( No trace messages to be generated ) +# BT_TRACE_LEVEL_ERROR 1 ( Error condition trace messages ) +# BT_TRACE_LEVEL_WARNING 2 ( Warning condition trace messages ) +# BT_TRACE_LEVEL_API 3 ( API traces ) +# BT_TRACE_LEVEL_EVENT 4 ( Debug messages for events ) +# BT_TRACE_LEVEL_DEBUG 5 ( Full debug messages ) +# BT_TRACE_LEVEL_VERBOSE 6 ( Verbose messages ) - Currently supported for TRC_BTAPP only. +TRC_BTM=2 +TRC_HCI=2 +TRC_L2CAP=2 +TRC_RFCOMM=2 +TRC_OBEX=2 +TRC_AVCT=2 +TRC_AVDT=2 +TRC_AVRC=2 +TRC_AVDT_SCB=2 +TRC_AVDT_CCB=2 +TRC_A2D=2 +TRC_SDP=2 +TRC_GATT=2 +TRC_SMP=2 +TRC_BTAPP=2 +TRC_BTIF=2 +TRC_GAP=2 +TRC_BNEP=2 +TRC_PAN=2 +TRC_B3DS=2 + +################################### +# # +# Must enable MTK_STACK_CONFIG # +# # +################################### + +[MtkBtConf] +MtkStackConfigOverride=/sdcard/btsc + +# +# Control FW Log +# +[MtkBtFWLog] +# FCBE switch +# Ex. Disable FWlog to set C1 = 01 BE FC 01 00 / Enable FWlog to set C1 = 01 BE FC 01 05 +C1 = 01 BE FC 01 00 +# FC5F filter +C2 = 01 5F FC 2A 50 01 09 00 00 00 +# FC5F group filter bitmap +# SYS +C201 = 00 00 00 00 +# TIM +C202 = 00 00 00 00 +# PKV +C203 = 00 00 00 00 +# LC +C204 = 00 00 00 00 +# LL +C205 = 00 00 00 00 +# ANT +C206 = 00 00 00 00 +# LMP +C207 = 00 00 00 00 +# CO +C208 = 00 00 00 00 +# VOICE +C209 = 00 00 00 00 + +# +# Role Switch Blacklisting +# +[MtkRoleSwitchBlacklist] + +# Blacklisting by vendor prefix address: +# Example: AddressBlacklist=12:34:56,22:22:22 +AddressBlacklist= + +# Blacklisting by Exact Name: +# Example: ExactNameBlacklist=This is an example,MT-1234,T1 +ExactNameBlacklist= + +# Blacklisting by Partial Name (if name starts with) +# Example: PartialNameBlacklist=Test,MT +PartialNameBlacklist= + +# +# Sniff Subrating Blacklisting +# +[MtkSniffSubratingBlacklist] + +# Blacklisting by vendor prefix address: +# Example: AddressBlacklist=12:34:56,22:22:22 +# {0x54, 0x46, 0x6b}, /* JW MT002 Bluetooth Mouse */ /*LMP version&subversion - 5, 8721 & LMP Manufacturer - 15*/ +AddressBlacklist=54:46:6b + +# Blacklisting by Exact Name: +# Example: ExactNameBlacklist=This is an example,MT-1234,T1 +ExactNameBlacklist= + +# Blacklisting by Partial Name (if name starts with) +# Example: PartialNameBlacklist=Test,MT +PartialNameBlacklist= + +# +# Hogp Conn Update Blacklisting +# +[MtkHogpConnUpdateBlacklist] + +# Blacklisting by vendor prefix address: +# Example: AddressBlacklist=12:34:56,22:22:22 +AddressBlacklist=00:1b:dc + +# Blacklisting by Exact Name: +# Example: ExactNameBlacklist=This is an example,MT-1234,T1 +ExactNameBlacklist=BSMBB09DS + +# Blacklisting by Partial Name (if name starts with) +# Example: PartialNameBlacklist=Test,MT +PartialNameBlacklist= + +# +# BLE Conn Minimum Interval limit Blacklisting +# +[MtkBleConnIntMinLimitBlacklist] + +# Blacklisting by vendor prefix address: +# Example: AddressBlacklist=12:34:56,22:22:22 +AddressBlacklist=00:15:9e + +# Blacklisting by Exact Name: +# Example: ExactNameBlacklist=This is an example,MT-1234,T1 +ExactNameBlacklist=Mad Catz M.O.U.S.9,Designer Mouse + +# Blacklisting by Partial Name (if name starts with) +# Example: PartialNameBlacklist=Test,MT +PartialNameBlacklist= + +# +# BLE Conn timeout Blacklisting +# +[MtkBleConnTimeoutBlacklist] + +# Blacklisting by vendor prefix address: +AddressBlacklist=FF:40:3A,DA:58:98,C2:80:29,FF:74:E1,D9:E6:EA + +# Blacklisting by Exact Name: +ExactNameBlacklist=CASIO GB-6900A* + +# +# Avrcp 1.5 Blacklisting +# +[MtkAvrcp15BackTo13Blacklist] + +# Some CT devices have IOT issue with AVRCP 1.5 device +# Send the AVRCP version as 1.3 for these devices +# {0x00, 0x1D, 0xBA}, /* JVC carkit */ +# {0x00, 0x1E, 0xB2}, /* AVN 3.0 Hyundai */ +# {0x00, 0x0E, 0x9F}, /* Porshe car kit */ +# {0x00, 0x13, 0x7B}, /* BYOM Opel */ +# {0x68, 0x84, 0x70}, /* KIA MOTOR */ +# {0x00, 0x21, 0xCC}, /* FORD FIESTA */ +# {0x30, 0x14, 0x4A}, /* Mini Cooper */ +# {0x38, 0xC0, 0x96}, /* Seat Leon */ +# {0x00, 0x54, 0xAF}, /* Chrysler */ +# {0x04, 0x88, 0xE2}, /* BeatsStudio Wireless */ +# {0x9C, 0xDF, 0x03}, /* BMW 2012 carkit */ +# {0xA8, 0x54, 0xB2}, /* BMW 2015 carkit */ +# {0x94, 0x44, 0x44}, /* AVN1.0 K9 */ +# {0x00, 0x05, 0xC9}, /* FS AVN */ +# {0xA0, 0x14, 0x3D}, /* VW Sharen */ +# {0xE0, 0x75, 0x0A}, /* VW GOLF */ +# {0x10, 0x08, 0xC1}, /* Hyundai SantaFe */ +# {0x00, 0x21, 0xCC}, /* FORD SYNC TDK */ +# {0x00, 0x0A, 0x30}, /* Honda TFT */ +# {0x00, 0x1E, 0x43}, /* AUDI MMI 3G+ */ +# {0x00, 0x18, 0x09}, /* AT-PHA05BT */ +# {0xC8, 0x02, 0x10}, /* KIA SportageR 2015 */ +# {0x34, 0xB1, 0xF7}, /* G-BOOK 2013 */ +# {0x7C, 0x66, 0x9D}, /* G-BOOK 2014 */ +# {0x00, 0x09, 0x93}, /* Nissan Altima 2014 */ +# {0x04, 0XF8, 0XC2} /* HAVAL H2 */ +AddressBlacklist=00:1D:BA,00:1E:B2,00:0E:9F,00:13:7B,68:84:70,00:21:CC,30:14:4A,38:C0:96,00:54:AF,04:88:E2,9C:DF:03,A8:54:B2,94:44:44,00:05:C9,A0:14:3D,E0:75:0A,10:08:C1,00:21:CC,00:0A:30,00:1E:43,00:18:09,C8:02:10,34:B1:F7,7C:66:9D,00:09:93,04:F8:C2 + +[MtkAvrcp15BackTo14Blacklist] + +# Some CT devices support AVRCP version 1.4 instead of 1.5 +# Send the AVRCP version as 1.4 for these devices +# {0x34, 0xC7, 0x31}, /* AUDI MIB Standard */ +# {0x00, 0x07, 0x04}, /* VW MIB Standard */ +# {0x00, 0x26, 0xB4}, /* MyFord Touch Gen2 */ +# {0x10, 0x08, 0xC1}, /* GEN 2.0 PREM */ +# {0x04, 0x98, 0xF3}, /* VW MIB Entry */ +# {0x64, 0xD4, 0xBD}, /* HONDA CAN2BENCH */ +# {0x0C, 0xD9, 0xC1}, /* HONDA CAN2BENCH-02 */ +# {0x18, 0x6D, 0x99}, /* GRANDUER MTS */ +# {0xFC, 0x62, 0xB9}, /* VW Golf VII */ +# {0x90, 0x03, 0xB7}, /* VW Jetta TSI 2013 */ +# {0x00, 0x26, 0x7E} /* VW Jetta TSI 2012 */ +AddressBlacklist=34:C7:31,00:07:04,00:26:B4,10:08:C1,04:98:F3,64:D4:BD,0C:D9:C1,18:6D:99,FC:62:B9,90:03:B7,00:26:7E + + +# +# SCMS-T Blacklisting +# +[MtkSCMSTBlacklist] + +# Some IOT devices can not work with SCSM-T normmaly +# Do not select SCMS-T as set configurate +# {0x00, 0x12, 0x6F} /* Bury CC9060 */ +AddressBlacklist=00:12:6f +[MtkHfp15eSCOBlacklist] +# Some devices support hfp 1.5 but not use eSCO connection +# {0x00, 0x58, 0x76}, /* BT800 */ +AddressBlacklist=00:58:76 + +ExactNameBlacklist=BT800 + +[MtkSecureConnectionsBlacklist] +# Some devices cannot compatible with secure connections +PartialNameBlacklist=honor zero- + +[MtkSongPositionBlacklist] + +# Blacklisting by vendor prefix address: +# Example: AddressBlacklist=12:34:56,22:22:22 +#{0x00, 0x0e, 0x9f}, /* Toyota Touch&Go */ +AddressBlacklist=00:0e:9f + +# Blacklisting by Exact Name: +# Example: ExactNameBlacklist=This is an example,MT-1234,T1 +ExactNameBlacklist=Toyota Touch&Go + +[MtkA2DPDelayStartCMDBlicklist] + +# +# Some special device want perform START cmd itself first +# If it not send START cmd, will close current link. +# So for this special device, we need delay send A2DP START cmd +# which from DUT to receive the special device cmd. +# {0x00, 0x17, 0x53} /* Tiggo5 */ +AddressBlacklist=00:17:53 + +[MtkAvrcpReleaseKeyBlacklist] +# Blacklisting by vendor prefix address: +# Example: AddressBlacklist=12:34:56,22:22:22 +#{0x00, 0x1e, 0xb2}, /* MTS255 */ +AddressBlacklist=00:1e:b2 + +[MtkAvConnectOnSdpFail] +#{00:1e:3d}, // ALPS ELECTRIC CO.,LTD. +#{00:1b:fb}, // ALPS ELECTRIC CO.,LTD. +#{00:26:7e}, // Parrot SA +AddressBlacklist=00:1e:3d,00:1b:fb,00:26:7e + +[MtkAVDTPDiscoverBlacklist] +# Some headset have IOT issue if DUT trigger DISCOVER procedure while act as an A2DP acceptor role +# Do not trigger DISCOVER procedure + +# Blacklisting by vendor prefix address: +#{0xa0, 0xb4, 0xa5}, /* Gear Circle */ +AddressBlacklist=a0:b4:a5 + +# Blacklisting by Exact Name: +ExactNameBlacklist=Gear Circle + + +[MtkHfp15eSCOMsbcBlacklist] +# Some devices can't use MSBC codec +ExactNameBlacklist=Parrot ASTEROID Smart + +[MtkHIDDisableSDPBlacklist] +# Some HID devices have issue if SDP is initiated while HID connection is in progress +# {0x04, 0x0C, 0xCE}, /* Apple Magic Mouse */ +# {0x00, 0x07, 0x61}, /* Bluetooth Laser Travel Mouse */ +# {0x00, 0x1d, 0xd8}, /* Microsoft Bluetooth Notebook Mouse 5000 */ +# {0x00, 0x1f, 0x20}, /* Logitech MX Revolution Mouse */ +# {0x6c, 0x5d, 0x63}, /* Rapoo 6080 mouse */ +# {0x28, 0x18, 0x78} /* Microsoft Sculpt Touch Mouse */ +AddressBlacklist=04:0c:ce,00:07:61,00:1d:d8,00:1f:20,6c:5d:63,28:18:78 +ExactNameBlacklist=Apple Magic Mouse,Bluetooth Laser Travel Mouse,Microsoft Bluetooth Notebook Mouse 5000,Logitech MX Revolution Mouse,Microsoft Sculpt Touch Mouse + diff --git a/configs/bluetooth/bt_stack.conf.debug b/configs/bluetooth/bt_stack.conf.debug new file mode 100644 index 0000000..13847b3 --- /dev/null +++ b/configs/bluetooth/bt_stack.conf.debug @@ -0,0 +1,78 @@ +# Enable BtSnoop logging function
+# valid value : true, false
+BtSnoopLogOutput=true
+
+# BtSnoop log output file
+BtSnoopFileName=/sdcard/mtklog/btlog/btsnoop_hci.log
+
+# Preserve existing BtSnoop log before overwriting
+BtSnoopSaveLog=true
+
+# Enable trace level reconfiguration function
+# Must be present before any TRC_ trace level settings
+TraceConf=true
+
+# Trace level configuration
+# BT_TRACE_LEVEL_NONE 0 ( No trace messages to be generated )
+# BT_TRACE_LEVEL_ERROR 1 ( Error condition trace messages )
+# BT_TRACE_LEVEL_WARNING 2 ( Warning condition trace messages )
+# BT_TRACE_LEVEL_API 3 ( API traces )
+# BT_TRACE_LEVEL_EVENT 4 ( Debug messages for events )
+# BT_TRACE_LEVEL_DEBUG 5 ( Full debug messages )
+# BT_TRACE_LEVEL_VERBOSE 6 ( Verbose messages ) - Currently supported for TRC_BTAPP only.
+TRC_BTM=6
+TRC_HCI=6
+TRC_L2CAP=6
+TRC_RFCOMM=6
+TRC_OBEX=6
+TRC_AVCT=6
+TRC_AVDT=6
+TRC_AVRC=6
+TRC_AVDT_SCB=6
+TRC_AVDT_CCB=6
+TRC_A2D=6
+TRC_SDP=6
+TRC_GATT=6
+TRC_SMP=6
+TRC_BTAPP=6
+TRC_BTIF=6
+TRC_GAP=6
+TRC_BNEP=6
+TRC_PAN=6
+TRC_B3DS=6
+
+###################################
+# #
+# Must enable MTK_STACK_CONFIG #
+# #
+###################################
+
+#
+# Control FW Log
+#
+[MtkBtFWLog]
+# FCBE switch - Enable
+# Ex. Disable FWlog to set C1 = 01 BE FC 01 00 / Enable FWlog to set C1 = 01 BE FC 01 05
+C1 = 01 BE FC 01 05
+# FC5F filter
+C2 = 01 5F FC 2A 50 01 09 00 00 00
+# FC5F group filter bitmap
+# SYS
+C201 = 01 00 00 00
+# TIM
+C202 = 00 00 00 00
+# PKV
+C203 = 01 00 00 00
+# LC
+C204 = 01 00 00 00
+# LL
+C205 = 01 00 00 00
+# ANT
+C206 = 01 00 00 00
+# LMP
+C207 = 01 00 01 00
+# CO
+C208 = 03 38 00 00
+# VOICE
+C209 = 01 00 00 00
+
diff --git a/configs/bluetooth/bt_stack.conf.sqc b/configs/bluetooth/bt_stack.conf.sqc new file mode 100644 index 0000000..55cac8f --- /dev/null +++ b/configs/bluetooth/bt_stack.conf.sqc @@ -0,0 +1,78 @@ +# Enable BtSnoop logging function
+# valid value : true, false
+BtSnoopLogOutput=true
+
+# BtSnoop log output file
+BtSnoopFileName=/sdcard/mtklog/btlog/btsnoop_hci.log
+
+# Preserve existing BtSnoop log before overwriting
+BtSnoopSaveLog=true
+
+# Enable trace level reconfiguration function
+# Must be present before any TRC_ trace level settings
+TraceConf=true
+
+# Trace level configuration
+# BT_TRACE_LEVEL_NONE 0 ( No trace messages to be generated )
+# BT_TRACE_LEVEL_ERROR 1 ( Error condition trace messages )
+# BT_TRACE_LEVEL_WARNING 2 ( Warning condition trace messages )
+# BT_TRACE_LEVEL_API 3 ( API traces )
+# BT_TRACE_LEVEL_EVENT 4 ( Debug messages for events )
+# BT_TRACE_LEVEL_DEBUG 5 ( Full debug messages )
+# BT_TRACE_LEVEL_VERBOSE 6 ( Verbose messages ) - Currently supported for TRC_BTAPP only.
+TRC_BTM=6
+TRC_HCI=6
+TRC_L2CAP=6
+TRC_RFCOMM=6
+TRC_OBEX=6
+TRC_AVCT=6
+TRC_AVDT=6
+TRC_AVRC=6
+TRC_AVDT_SCB=6
+TRC_AVDT_CCB=6
+TRC_A2D=6
+TRC_SDP=6
+TRC_GATT=6
+TRC_SMP=6
+TRC_BTAPP=6
+TRC_BTIF=6
+TRC_GAP=6
+TRC_BNEP=6
+TRC_PAN=6
+TRC_B3DS=6
+
+###################################
+# #
+# Must enable MTK_STACK_CONFIG #
+# #
+###################################
+
+#
+# Control FW Log
+#
+[MtkBtFWLog]
+# FCBE switch - Disable
+# Ex. Disable FWlog to set C1 = 01 BE FC 01 00 / Enable FWlog to set C1 = 01 BE FC 01 05
+C1 = 01 BE FC 01 00
+# FC5F filter
+C2 = 01 5F FC 2A 50 01 09 00 00 00
+# FC5F group filter bitmap
+# SYS
+C201 = 00 00 00 00
+# TIM
+C202 = 00 00 00 00
+# PKV
+C203 = 00 00 00 00
+# LC
+C204 = 00 00 00 00
+# LL
+C205 = 00 00 00 00
+# ANT
+C206 = 00 00 00 00
+# LMP
+C207 = 00 00 00 00
+# CO
+C208 = 00 00 00 00
+# VOICE
+C209 = 00 00 00 00
+
diff --git a/configs/dhcpcd/dhcpcd.conf b/configs/dhcpcd/dhcpcd.conf new file mode 100644 index 0000000..426f756 --- /dev/null +++ b/configs/dhcpcd/dhcpcd.conf @@ -0,0 +1,8 @@ +# dhcpcd configuration for Android Wi-Fi interface + +# Disable solicitation of IPv6 Router Advertisements +noipv6rs + +interface wlan0 +# dhcpcd-run-hooks uses these options. +option subnet_mask, routers, domain_name_servers, interface_mtu diff --git a/configs/egl.cfg b/configs/egl.cfg new file mode 100644 index 0000000..9438b87 --- /dev/null +++ b/configs/egl.cfg @@ -0,0 +1,2 @@ +0 0 android +0 1 mali diff --git a/configs/gps/agps_profiles_conf2.xml b/configs/gps/agps_profiles_conf2.xml new file mode 100644 index 0000000..279d1a2 --- /dev/null +++ b/configs/gps/agps_profiles_conf2.xml @@ -0,0 +1,471 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<mtk_agps_profiles maj_ver="1" min_ver="2"> + + <!-- cur_supl_profile and supl_profile + + name: + SLP name will be displayed on LocatioEM2 - SLP Template list + + addr: + SLP address + + port: + SLP port + + tls: + enable/disable TLS connection + available value: true (default), false + + ===== load SLP profile automatically based on PLMN ===== + mcc (optional): + auto configure the supl_profile if the current MCC on DUT are the same as mcc parameter you specified and auto_profile_enable is enabled + + mcc_mnc (optional): + auto configure the supl_profile if the current MCC and MNC on DUT are the same as mcc_mnc paramter you specified and auto_profile_enable is enabled + + supl_version (optional): + auto configure supl_version if above mcc_mnc condition is met + available value: 1 -> SUPL1.0 (default) + available value: 2 -> SUPL2.0 + + tls_version (optional): + auto configure tls_version if above mcc_mnc condition is met + available value: 0 -> TLS1.0 (default) + available value: 1 -> TLS1.1 + available value: 2 -> TLS1.2 + + sha_version (optional): + auto configure sha_version if above mcc_mnc condition is met + available value: 0 -> SHA1 for SUPL1.0 and SHA256 for SUPL2.0 (default) + available value: 1 -> SHA1 for SUPL1.0 and SUPL2.0 + available value: 2 -> SHA256 for SUPL1.0 and SUPL2.0 + + ===== other parameters are used for DM ===== + app_id (optional): + "ap0004" + + provider_id (optional): + "221.176.0.55" + + default_apn (optional): + "XXX WAP" + + optional_apn (optional): + "internet" + + optional_apn_2 (optional): + "" + + address_type (optional): + "IPv4address:port" + --> + + <cur_supl_profile name="GOOGLE" + addr="supl.google.com" + port="7275" + tls="true" + /> + + <!-- GOOGLE--> + <supl_profile name="GOOGLE" + addr="supl.google.com" + port="7275" + tls="true" + /> + + <!-- GOOGLE--> + <supl_profile name="GOOGLE nonTLS" + addr="supl.google.com" + port="7276" + tls="false" + /> + + <!-- GOOGLE--> + <supl_profile name="GOOGLE IP" + addr="173.194.72.192" + port="7276" + tls="false" + /> + + <!-- Spirent Lab --> + <supl_profile name="Spirent" + addr="www.spirent-lcs.com" + port="7275" + tls="true" + /> + + <!-- R&S Lab --> + <supl_profile name="RnS" + addr="slp.rs.de" + port="7275" + tls="true" + /> + + <!-- CMCC Lab --> + <supl_profile name="CMCC Lab" + addr="218.206.176.50" + port="7275" + tls="true" + /> + + <!-- Andrew Lab --> + <supl_profile name="Andrew" + addr="slp1acva.andrew.com" + port="7275" + tls="true" + /> + + <!-- Ericsson Lab --> + <supl_profile name="Ericsson" + addr="172.22.1.100" + port="7275" + tls="true" + /> + + <!-- Ericsson Lab FQDN --> + <supl_profile name="Ericsson FQDN" + addr="mvtvltegmpc.naladmz.ericsson.ca" + port="7275" + tls="true" + /> + + <!-- Ericsson Lab FQDN 2 --> + <supl_profile name="Ericsson FQDN 2" + addr="mvtv-broadcom.naladmz.ericsson.ca" + port="7275" + tls="true" + /> + + <!-- ORANGE --> + <supl_profile name="ORANGE" + addr="agpss.orange.fr" + port="7275" + tls="true" + /> + + <!-- CMCC--> + <supl_profile name="CMCC" + addr="221.176.0.55" + port="7275" + tls="true" + app_id="ap0004" + provider_id="221.176.0.55" + default_apn="CMCC WAP" + optional_apn="CMNET" + optional_apn_2="" + address_type="IPv4address:port" + /> + + <!-- Telstra --> + <supl_profile name="Telstra" + addr="agps.supl.telstra.com" + port="7275" + tls="true" + /> + + <!-- CHUAN HWA --> + <supl_profile name="Chunghwa" + addr="10.1.101.137" + port="8025" + tls="false" + /> + + <!-- T-Mobile --> + <supl_profile name="T-Mobile" + addr="lbs.geo.t-mobile.com" + port="7275" + tls="true" + /> + + <!-- Vodafone --> + <supl_profile name="Vodafone" + addr="supl.vodafone.com" + port="7275" + tls="true" + mcc_mnc="22010" + supl_version="2" + tls_version="1" + sha_version="0" + /> + + <!-- Test 1 --> + <supl_profile name="Test 1" + addr="127.0.0.1" + port="7276" + tls="false" + mcc_mnc="999998" + supl_version="1" + tls_version="0" + sha_version="2" + /> + + <!-- Test 2 --> + <supl_profile name="Test 2" + addr="127.0.0.1" + port="7276" + tls="false" + mcc_mnc="999999" + supl_version="2" + tls_version="1" + sha_version="0" + /> + + <!-- Test 3 --> + <supl_profile name="Test 3" + addr="127.0.0.1" + port="7276" + tls="false" + mcc="998" + supl_version="1" + tls_version="2" + sha_version="1" + /> + + <!-- cdma_profile + + name: + SLP name + + mcp_enable: + enable/disable MCP parameters + available value: true, false (default) + + mcp_addr: + MCP address + + mcp_port: + MCP port + + pde_addr_valid: + PDE address is valid or invalid + available value: true, false (default) + + pde_ip_type: + PDE's address type + available value: 0 -> IPv4 (default) + available value: 1 -> IPv6 + + pde_addr: + PDE IP address + + pde_port: + PDE port + + pde_url_valid: + PDE URL is valid or invalid + available value: true, false (default) + + pde_url_addr: + PDE URL + --> + + <!-- CDMA profile template --> + <cdma_profile name="CDMA1" + mcp_enable="true" + mcp_addr="10.199.22.165" + mcp_port="6066" + pde_addr_valid="false" + pde_ip_type="0" + pde_addr="11.11.11.11" + pde_port="1111" + pde_url_valid="false" + pde_url_addr="www.mediatek.com" + /> + + + <!-- agps_setting + + agps_enable: + enable/disable A-GPS + available value: true (default), false + + agps_protocol: + choose which A-GPS you want to use for SET Initiated + available value: 0 -> User Plane (default) + available value: 1 -> Control Plane + + gpevt: + enable/disable GPEVT report + available value: true, false (default) + --> + <agps_setting + agps_enable="true" + agps_protocol="0" + gpevt="false" + /> + + + <!-- cp_setting + + molr_pos_method: + available value: 0 (Location Estimate) (default) + available value: 1 (Assistance Data) + + external_addr_enable: + enable/disable the external address + available value: true, false (default) + + external_addr: + external_address + + mlc_number_enable: + enable/disable the mlc number + available value: true, false (default) + + mlc_number: + MLC number + + cp_auto_reset: + enable/disable to send PMTK997_5 + available value: true, false (default) + + epc_molr_lpp_payload_enable: + enable/disable to send LPP payload in the EPC-MOLR message + available value: true, false (default) + + epc_molr_lpp_payload: + specify the LPP payload in the EPC-MOLR message in hexString format (ex: "010203ff" = { 0x01, 0x02, 0x03, 0xff } + the purpose of this parameter is used for LAB testing only, please do not change it. + + --> + <cp_setting + molr_pos_method="0" + external_addr_enable="false" + external_addr="0123456789*#+" + mlc_number_enable="false" + mlc_number="0123456789*#+" + cp_auto_reset="false" + epc_molr_lpp_payload_enable="false" + epc_molr_lpp_payload="D2000010237B2026404FB8007202BFFFFFFFF80000000020C0000100940FB9001202B7FFFFF8000000000061800002018A00" + /> + + <!-- up_setting + + ca_enable: + enable/disable the certificate verification + available value: true, false (default) + + ni_request: + enable/disable Network Initiated (NI) functionality + available value: true (default), false + + roaming: + enable/disable to use A-GPS when device is under roaming state + available value: true (default), false + + cdma_preferred: + when CDMA network and WCDMA network are available, which AGPS protocol you prefer? + available value: 0 (WCDMA AGPS protocol is preferred) (default) + available value: 2 (FORCE CDMA AGPS protocol) + + pref_method: + the preferred method in SUPL_START and SUPL_POS_INIT + available value: 0 -> SET assisted Preferred + available value: 1 -> SET Based Preferred (default) + available value: 2 -> no Preference + + supl_version: + SUPL version for ULP + available value: 1 -> SUPL1.0 (default) + available value: 2 -> SUPL2.0 + + tls_version: + TLS version for TLS connection + available value: 0 -> TLS1.0 (default) + available value: 1 -> TLS1.1 + available value: 2 -> TLS1.2 + + sha_version: + SHA version for calculating VER + available value: 0 -> SHA1 for SUPL1.0 and SHA256 for SUPL2.0 (default) + available value: 1 -> SHA1 for SUPL1.0 and SUPL2.0 + available value: 2 -> SHA256 for SUPL1.0 and SUPL2.0 + + supl_log: + enable or disable the AGPS log + available value: true, false (default) + + msa_enable: + enable/disable the MSA capability + available value: true (default), false + + msb_enable: + enable/disable the MSB capability + available value: true (default), false + + ecid_enable: + enable/disable the eCID capability + available value: true (default), false + + otdoa_enable: + enable/disable the OTDOA capability + available value: true, false (default) + + udp_port_enable: + enable/disable the UDP 7275 port by default, if you enable it, you may cause Android/CTS failure for checking netstat + available value: true, false (default) + + dedicated_apn_enable: + enable/disable the dedicated SUPL APN flow + available value: true, false (default) + + preferred_2g3g_cell_age: + max age of 2G / 3G cell info in history is OK to send to SLP server instead if the latest cell is of 3G or 4G. + available value: non-negative integer, from 0 ~ 1800, unit in second + 0 (always use the latest cell info) + 300 (prefer to use 2G / 3G cell if its age is less than 5 mins) + + lpp_enable: + enable/disable the LPP capability + available value: true (default), false + + cert_from_sdcard: + enable/disable the AGPS certification installation from SDCard + available value: true (default), false + + auto_profile_enable: + enable/disable the auto profile configuration based on current mcc or mcc_mnc specified in cur_supl_profile or supl_profile + available value: true (default), false + + ut2: + customize the SUPL UT2 timer + available value: 1~60, default value is 11 (OMA spec) + + ut3: + customize the SUPL UT3 timer + available value: 1~60, default value is 10 (OMA spec) + + sync_to_slp: + sync the AGPS setting (ex: SUPL profile, SUPL version, TLS version) from AGPSD to SLPD in runtime + available value: true, false (default) + --> + <up_setting + ca_enable="false" + ni_request="true" + roaming="true" + cdma_preferred="0" + pref_method="1" + supl_version="1" + tls_version="0" + sha_version="0" + supl_log="false" + msa_enable="true" + msb_enable="true" + ecid_enable="true" + otdoa_enable="false" + qop_hacc="22" + qop_vacc="0" + qop_loc_age="0" + qop_delay="0" + udp_port_enable="false" + dedicated_apn_enable="false" + preferred_2g3g_cell_age="300" + lpp_enable="true" + cert_from_sdcard="true" + auto_profile_enable="true" + ut2="11" + ut3="10" + sync_to_slp="false" + /> + +</mtk_agps_profiles> diff --git a/configs/gps/slp_conf b/configs/gps/slp_conf new file mode 100644 index 0000000..431ec60 --- /dev/null +++ b/configs/gps/slp_conf @@ -0,0 +1,8 @@ +SUPL_ADDR=supl.google.com
+SUPL_PORT=7276
+//SUPL_TLS can be 0 (disable) or 1 (enable)
+SUPL_TLS=0
+//SUPL_VERSION can be 1 or 2
+SUPL_VERSION=2
+//TLS_VERSION can be 0 (TLS1.0), 1 (TLS1.1), and 2 (TLS1.2)
+TLS_VERSION=1
\ No newline at end of file diff --git a/configs/hostapd/hostapd.accept b/configs/hostapd/hostapd.accept new file mode 100644 index 0000000..6b167e0 --- /dev/null +++ b/configs/hostapd/hostapd.accept @@ -0,0 +1,3 @@ +# List of MAC addresses that are allowed to authenticate (IEEE 802.11) +# with the AP. Optional VLAN ID can be assigned for clients based on the +# MAC address if dynamic VLANs (hostapd.conf dynamic_vlan option) are used.
\ No newline at end of file diff --git a/configs/hostapd/hostapd.deny b/configs/hostapd/hostapd.deny new file mode 100644 index 0000000..c37336b --- /dev/null +++ b/configs/hostapd/hostapd.deny @@ -0,0 +1,2 @@ +# List of MAC addresses that are not allowed to authenticate (IEEE 802.11) +# with the AP.
\ No newline at end of file diff --git a/configs/hostapd/hostapd_default.conf b/configs/hostapd/hostapd_default.conf new file mode 100644 index 0000000..da942f6 --- /dev/null +++ b/configs/hostapd/hostapd_default.conf @@ -0,0 +1,81 @@ +##### hostapd configuration file ############################################## +# Empty lines and lines starting with # are ignored + +# AP netdevice name (without 'ap' postfix, i.e., wlan0 uses wlan0ap for +# management frames); ath0 for madwifi +interface=wlan0 + +# Driver interface type (hostap/wired/madwifi/prism54/test/none/nl80211/bsd); +# default: hostap). nl80211 is used with all Linux mac80211 drivers. +# Use driver=none if building hostapd as a standalone RADIUS server that does +# not control any wireless/wired driver. +driver=nl80211 + +# hostapd event logger configuration +# +# Two output method: syslog and stdout (only usable if not forking to +# background). +# +# Module bitfield (ORed bitfield of modules that will be logged; -1 = all +# modules): +# bit 0 (1) = IEEE 802.11 +# bit 1 (2) = IEEE 802.1X +# bit 2 (4) = RADIUS +# bit 3 (8) = WPA +# bit 4 (16) = driver interface +# bit 5 (32) = IAPP +# bit 6 (64) = MLME +# +# Levels (minimum value for logged events): +# 0 = verbose debugging +# 1 = debugging +# 2 = informational messages +# 3 = notification +# 4 = warning +# +logger_syslog=-1 +logger_syslog_level=2 +logger_stdout=-1 +logger_stdout_level=2 + +#DEPRECATED: DONT UNCOMMENT -- Dump file for state information (on SIGUSR1) +#dump_file=/tmp/hostapd.dump + +# Interface for separate control program. If this is specified, hostapd +# will create this directory and a UNIX domain socket for listening to requests +# from external programs (CLI/GUI, etc.) for status information and +# configuration. The socket file will be named based on the interface name, so +# multiple hostapd processes/interfaces can be run at the same time if more +# than one interface is used. +# /var/run/hostapd is the recommended directory for sockets and by default, +# hostapd_cli will use it when trying to connect with hostapd. +ctrl_interface=/data/misc/wifi/hostapd + +##### IEEE 802.11 related configuration ####################################### + +# SSID to be used in IEEE 802.11 management frames +ssid=AndroidAP + +# Operation mode (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g, +# n = IEEE 802.11n, g_only = IEEE 802.11g_only, n_only = IEEE 802.11n_only, +# Default: IEEE 802.11n +hw_mode=g + +# Channel number (IEEE 802.11) +# (default: 0, i.e., not set) +# Please note that some drivers (e.g., madwifi) do not use this value from +# hostapd and the channel will need to be configuration separately with +# iwconfig. +channel=6 + +# ieee80211n: Whether IEEE 802.11n (HT) is enabled +# 0 = disabled (default) +# 1 = enabled +# Note: You will also need to enable WMM for full HT functionality. +ieee80211n=1 + +# Accept/deny lists are read from separate files (containing list of +# MAC addresses, one per line). Use absolute path name to make sure that the +# files can be read on SIGHUP configuration reloads. +accept_mac_file=/data/hostapd/hostapd.accept +deny_mac_file=/data/hostapd/hostapd.deny diff --git a/configs/media/media_codecs.xml b/configs/media/media_codecs.xml new file mode 100644 index 0000000..95f8841 --- /dev/null +++ b/configs/media/media_codecs.xml @@ -0,0 +1,304 @@ +<?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. + + 2012/07/13 config for MTK OMX Media Codecs, created by Morris Yang (mtk03147) +--> + +<MediaCodecs> + + <Include href="media_codecs_ffmpeg.xml" /> + + <Decoders> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.MP3" type="audio/mpeg" > + <Quirk name="decoder-lies-about-number-of-channels" /> + <Quirk name="supports-multiple-frames-per-input-buffer" /> + </MediaCodec> + <MediaCodec name="OMX.google.opus.decoder" type="audio/opus"> + <Limit name="channel-count" max="8" /> + <Limit name="sample-rate" ranges="8000-96000" /> + <Limit name="bitrate" range="1-10000000" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.ADPCM.MS" type="audio/x-adpcm-ms" /> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.ADPCM.DVI" type="audio/x-adpcm-dvi-ima" /> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.GSM" type="audio/gsm" /> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.RAW" type="audio/raw" /> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.G711.ALAW" type="audio/g711-alaw" > + <Quirk name="decoder-lies-about-number-of-channels" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.G711.MLAW" type="audio/g711-mlaw" > + <Quirk name="decoder-lies-about-number-of-channels" /> + </MediaCodec> + <!-- <MediaCodec name="OMX.MTK.AUDIO.DECODER.FLAC" type="audio/flac" /> --> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.WMA" type="audio/x-ms-wma" /> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.WMAPRO" type="audio/x-ms-wmapro" /> + <!--<MediaCodec name="OMX.MTK.AUDIO.DECODER.APE" type="audio/ape" > + <Quirk name="decoder-lies-about-number-of-channels" /> + <Quirk name="supports-multiple-frames-per-input-buffer" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.AUDIO.DECODER.ALAC" type="audio/alac" />--> + + <MediaCodec name="OMX.google.amrnb.decoder" type="audio/3gpp"> + <Limit name="channel-count" max="1" /> + <Limit name="sample-rate" ranges="8000" /> + <Limit name="bitrate" range="4750-12200" /> + </MediaCodec> + <MediaCodec name="OMX.google.amrwb.decoder" type="audio/amr-wb"> + <Limit name="channel-count" max="1" /> + <Limit name="sample-rate" ranges="16000" /> + <Limit name="bitrate" range="6600-23850" /> + </MediaCodec> + <!-- <MediaCodec name="OMX.google.aac.decoder" type="audio/mp4a-latm" /> --> + <MediaCodec name="OMX.google.vorbis.decoder" type="audio/vorbis"> + <Limit name="channel-count" max="8" /> + <Limit name="sample-rate" ranges="8000-96000" /> + <Limit name="bitrate" range="32000-500000" /> + </MediaCodec> + + <MediaCodec name="OMX.MTK.VIDEO.DECODER.MPEG2" > + <Type name="video/mpeg2" /> + <Type name="video/mpeg1" /> + <Limit name="size" min="16x16" max="4096x2176" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.HEVC" type="video/hevc" > + <Limit name="size" min="129x65" max="4096x2176" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + <Feature name="adaptive-playback"/> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.MPEG4" type="video/mp4v-es" > + <Limit name="size" min="16x16" max="4096x2176" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + <Feature name="adaptive-playback"/> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.H263" type="video/3gpp" > + <Limit name="size" min="128x96" max="1408x1152" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + <Feature name="adaptive-playback"/> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.AVC" type="video/avc" > + <Limit name="size" min="64x64" max="4096x3120" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + <Feature name="adaptive-playback"/> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.VPX" type="video/x-vnd.on2.vp8" > + <Limit name="size" min="16x16" max="1920x1088" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + <Feature name="adaptive-playback"/> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.VP9" type="video/x-vnd.on2.vp9" > + <Limit name="size" min="16x16" max="1920x1088" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="64x64" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + <Feature name="adaptive-playback"/> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.VC1" > + <Type name="video/x-ms-wmv" /> + <Type name="video/wmv" /> + <Limit name="size" min="16x16" max="1920x1088" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.DIVX" type="video/divx" > + <Limit name="size" min="16x16" max="4096x2176" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.DIVX3" type="video/divx3" > + <Limit name="size" min="16x16" max="4096x2176" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.XVID" type="video/xvid" > + <Limit name="size" min="16x16" max="4096x2176" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.DECODER.S263" type="video/flv1" > + <Limit name="size" min="16x16" max="4096x2176" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + + <!-- + <MediaCodec name="OMX.google.vp8.decoder" type="video/x-vnd.on2.vp8"> + <Limit name="size" min="2x2" max="1920x1088" /> + <Limit name="alignment" value="2x2" /> + <Limit name="block-size" value="16x16" /> + <Limit name="blocks-per-second" range="1-1000000" /> + <Limit name="bitrate" range="1-40000000" /> + <Feature name="adaptive-playback" /> + </MediaCodec> + + <MediaCodec name="OMX.google.h264.decoder" type="video/avc"> + + <Limit name="size" min="2x2" max="1920x1088" /> + <Limit name="alignment" value="2x2" /> + <Limit name="block-size" value="16x16" /> + <Limit name="blocks-per-second" range="1-983040" /> + <Limit name="bitrate" range="1-40000000" /> + <Feature name="adaptive-playback" /> + </MediaCodec> + --> + </Decoders> + + <Encoders> + <MediaCodec name="OMX.MTK.VIDEO.ENCODER.MPEG4" type="video/mp4v-es" > + <Limit name="size" min="64x64" max="640x480" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.ENCODER.H263" type="video/3gpp" > + <Limit name="size" min="64x64" max="640x480" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.ENCODER.AVC" type="video/avc" > + <Limit name="size" min="160x128" max="1920x1080" /> + <Limit name="alignment" value="16x16" /> + <Limit name="block-size" value="16x16" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + <MediaCodec name="OMX.MTK.VIDEO.ENCODER.HEVC" type="video/hevc" > + <Limit name="size" min="160x128" max="3840x2176" /> + <Limit name="alignment" value="32x32" /> + <Limit name="block-size" value="32x32" /> + <Quirk name="requires-allocate-on-input-ports" /> + <Quirk name="requires-allocate-on-output-ports" /> + </MediaCodec> + + <MediaCodec name="OMX.MTK.AUDIO.ENCODER.VORBIS" type="audio/vorbis" /> + <MediaCodec name="OMX.MTK.AUDIO.ENCODER.ADPCM.MS" type="audio/x-adpcm-ms" /> + <MediaCodec name="OMX.MTK.AUDIO.ENCODER.ADPCM.DVI" type="audio/x-adpcm-dvi-ima" /> + <MediaCodec name="OMX.google.aac.encoder" type="audio/mp4a-latm"> + <Limit name="channel-count" max="6" /> + <Limit name="sample-rate" ranges="8000,11025,12000,16000,22050,24000,32000,44100,48000" /> + <!-- also may support 64000, 88200 and 96000 Hz --> + <Limit name="bitrate" range="8000-960000" /> + </MediaCodec> + <MediaCodec name="OMX.google.amrnb.encoder" type="audio/3gpp"> + <Limit name="channel-count" max="1" /> + <Limit name="sample-rate" ranges="8000" /> + <Limit name="bitrate" range="4750-12200" /> + <Feature name="bitrate-modes" value="CBR" /> + </MediaCodec> + <MediaCodec name="OMX.google.amrwb.encoder" type="audio/amr-wb"> + <Limit name="channel-count" max="1" /> + <Limit name="sample-rate" ranges="16000" /> + <Limit name="bitrate" range="6600-23850" /> + <Feature name="bitrate-modes" value="CBR" /> + </MediaCodec> + <MediaCodec name="OMX.google.flac.encoder" type="audio/flac"> + <Limit name="channel-count" max="2" /> + <Limit name="sample-rate" ranges="1-655350" /> + <Limit name="bitrate" range="1-21000000" /> + <Limit name="complexity" range="0-8" default="5" /> + <Feature name="bitrate-modes" value="CQ" /> + </MediaCodec> + <MediaCodec name="OMX.google.vp8.encoder" type="video/x-vnd.on2.vp8"> + <!-- profiles and levels: ProfileMain : Level_Version0-3 --> + <Limit name="size" min="2x2" max="1920x1080" /> + <Limit name="alignment" value="2x2" /> + <Limit name="bitrate" range="1-40000000" /> + <Feature name="bitrate-modes" value="VBR,CBR" /> + </MediaCodec> + </Encoders> +</MediaCodecs> diff --git a/configs/media/media_profiles.xml b/configs/media/media_profiles.xml new file mode 100644 index 0000000..5a3217a --- /dev/null +++ b/configs/media/media_profiles.xml @@ -0,0 +1,1200 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> +<!DOCTYPE MediaSettings [ + <!ELEMENT MediaSettings (CamcorderProfiles, + EncoderOutputFileFormat+, + VideoEncoderCap+, + AudioEncoderCap+, + VideoDecoderCap, + AudioDecoderCap, + VideoEditorCap, + ExportVideoProfile+)> + <!ELEMENT CamcorderProfiles (EncoderProfile+, ImageEncoding+, ImageDecoding, Camera)> + <!ELEMENT EncoderProfile (Video, Audio)> + <!ATTLIST EncoderProfile quality (timelapse1080p|timelapse720p|timelapse480p|timelapsehigh|timelapselow|480p|qcif|high|low|1080p) #REQUIRED> + <!ATTLIST EncoderProfile fileFormat (mp4|3gp) #REQUIRED> + <!ATTLIST EncoderProfile duration (30|60) #REQUIRED> + <!ELEMENT Video EMPTY> + <!ATTLIST Video codec (h264|h263|m4v) #REQUIRED> + <!ATTLIST Video bitRate CDATA #REQUIRED> + <!ATTLIST Video width CDATA #REQUIRED> + <!ATTLIST Video height CDATA #REQUIRED> + <!ATTLIST Video frameRate CDATA #REQUIRED> + <!ELEMENT Audio EMPTY> + <!ATTLIST Audio codec (amrnb|amrwb|aac) #REQUIRED> + <!ATTLIST Audio bitRate CDATA #REQUIRED> + <!ATTLIST Audio sampleRate CDATA #REQUIRED> + <!ATTLIST Audio channels (1|2) #REQUIRED> + <!ELEMENT ImageEncoding EMPTY> + <!ATTLIST ImageEncoding quality (90|80|70|60|50|40) #REQUIRED> + <!ELEMENT ImageDecoding EMPTY> + <!ATTLIST ImageDecoding memCap CDATA #REQUIRED> + <!ELEMENT Camera EMPTY> + <!ATTLIST Camera previewFrameRate CDATA #REQUIRED> + <!ELEMENT EncoderOutputFileFormat EMPTY> + <!ATTLIST EncoderOutputFileFormat name (mp4|3gp) #REQUIRED> + <!ELEMENT VideoEncoderCap EMPTY> + <!ATTLIST VideoEncoderCap name (h264|h263|m4v|wmv) #REQUIRED> + <!ATTLIST VideoEncoderCap enabled (true|false) #REQUIRED> + <!ATTLIST VideoEncoderCap minBitRate CDATA #REQUIRED> + <!ATTLIST VideoEncoderCap maxBitRate CDATA #REQUIRED> + <!ATTLIST VideoEncoderCap minFrameWidth CDATA #REQUIRED> + <!ATTLIST VideoEncoderCap maxFrameWidth CDATA #REQUIRED> + <!ATTLIST VideoEncoderCap minFrameHeight CDATA #REQUIRED> + <!ATTLIST VideoEncoderCap maxFrameHeight CDATA #REQUIRED> + <!ATTLIST VideoEncoderCap minFrameRate CDATA #REQUIRED> + <!ATTLIST VideoEncoderCap maxFrameRate CDATA #REQUIRED> + <!ELEMENT AudioEncoderCap EMPTY> + <!ATTLIST AudioEncoderCap name (amrnb|amrwb|aac|wma) #REQUIRED> + <!ATTLIST AudioEncoderCap enabled (true|false) #REQUIRED> + <!ATTLIST AudioEncoderCap minBitRate CDATA #REQUIRED> + <!ATTLIST AudioEncoderCap maxBitRate CDATA #REQUIRED> + <!ATTLIST AudioEncoderCap minSampleRate CDATA #REQUIRED> + <!ATTLIST AudioEncoderCap maxSampleRate CDATA #REQUIRED> + <!ATTLIST AudioEncoderCap minChannels (1|2) #REQUIRED> + <!ATTLIST AudioEncoderCap maxChannels (1|2) #REQUIRED> + <!ELEMENT VideoDecoderCap EMPTY> + <!ATTLIST VideoDecoderCap name (wmv) #REQUIRED> + <!ATTLIST VideoDecoderCap enabled (true|false) #REQUIRED> + <!ELEMENT AudioDecoderCap EMPTY> + <!ATTLIST AudioDecoderCap name (wma) #REQUIRED> + <!ATTLIST AudioDecoderCap enabled (true|false) #REQUIRED> + <!ATTLIST VideoEditorCap maxInputFrameWidth CDATA #REQUIRED> + <!ATTLIST VideoEditorCap maxInputFrameHeight CDATA #REQUIRED> + <!ATTLIST VideoEditorCap maxOutputFrameWidth CDATA #REQUIRED> + <!ATTLIST VideoEditorCap maxOutputFrameHeight CDATA #REQUIRED> + <!ATTLIST VideoEditorCap maxPrefetchYUVFrames CDATA #REQUIRED> + <!ELEMENT ExportVideoProfile EMPTY> + <!ATTLIST ExportVideoProfile name (h264|h263|m4v) #REQUIRED> + <!ATTLIST ExportVideoProfile profile CDATA #REQUIRED> + <!ATTLIST ExportVideoProfile level CDATA #REQUIRED> +]> +<!-- + This file is used to declare the multimedia profiles and capabilities + on an android-powered device. +--> +<MediaSettings> + <!-- Each camcorder profile defines a set of predefined configuration parameters --> + <!-- Back Camera --> + <CamcorderProfiles cameraId="0"> + + <EncoderProfile quality="low" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="high" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="qcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="cif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapselow" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsecif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <ImageEncoding quality="90" /> + <ImageEncoding quality="80" /> + <ImageEncoding quality="70" /> + <ImageDecoding memCap="20000000" /> + + </CamcorderProfiles> + + <!-- Front Camera --> + <CamcorderProfiles cameraId="1"> + + <EncoderProfile quality="low" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="high" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="qcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="cif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapselow" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsecif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="44100" + channels="1" /> + </EncoderProfile> + + <ImageEncoding quality="90" /> + <ImageEncoding quality="80" /> + <ImageEncoding quality="70" /> + <ImageDecoding memCap="20000000" /> + + </CamcorderProfiles> + + <!-- Camera 2 --> + <CamcorderProfiles cameraId="2"> + + <EncoderProfile quality="low" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="high" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="qcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="cif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapselow" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsecif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <ImageEncoding quality="90" /> + <ImageEncoding quality="80" /> + <ImageEncoding quality="70" /> + <ImageDecoding memCap="20000000" /> + + </CamcorderProfiles> + + <!-- Camera 3 --> + <CamcorderProfiles cameraId="3"> + + <EncoderProfile quality="low" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="high" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="qcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="cif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapselow" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsecif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <ImageEncoding quality="90" /> + <ImageEncoding quality="80" /> + <ImageEncoding quality="70" /> + <ImageDecoding memCap="20000000" /> + + </CamcorderProfiles> + + <CamcorderProfiles cameraId="4"> + + <EncoderProfile quality="low" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="high" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="qcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="cif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapselow" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="384000" + width="176" + height="144" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapsecif" fileFormat="3gp" duration="30"> + <Video codec="h264" + bitRate="1536000" + width="352" + height="288" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="amrnb" + bitRate="12200" + sampleRate="8000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="4000000" + width="640" + height="480" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="8000000" + width="1280" + height="720" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <EncoderProfile quality="timelapse1080p" fileFormat="mp4" duration="30"> + <Video codec="h264" + bitRate="14000000" + width="1920" + height="1080" + frameRate="30" /> + + <!-- + The Audio part of the profile will not be used since time lapse mode + does not capture audio + --> + <Audio codec="aac" + bitRate="96000" + sampleRate="16000" + channels="1" /> + </EncoderProfile> + + <ImageEncoding quality="90" /> + <ImageEncoding quality="80" /> + <ImageEncoding quality="70" /> + <ImageDecoding memCap="20000000" /> + + </CamcorderProfiles> + + <EncoderOutputFileFormat name="3gp" /> + + <!-- + If a codec is not enabled, it is invisible to the applications + In other words, the applications won't be able to use the codec + or query the capabilities of the codec at all if it is disabled + --> + <VideoEncoderCap name="h264" enabled="true" + minBitRate="64000" maxBitRate="20000000" + minFrameWidth="176" maxFrameWidth="1920" + minFrameHeight="144" maxFrameHeight="1080" + minFrameRate="5" maxFrameRate="30" /> + + <VideoEncoderCap name="h263" enabled="true" + minBitRate="64000" maxBitRate="8000000" + minFrameWidth="176" maxFrameWidth="704" + minFrameHeight="144" maxFrameHeight="576" + minFrameRate="5" maxFrameRate="30" /> + + <VideoEncoderCap name="m4v" enabled="true" + minBitRate="64000" maxBitRate="10000000" + minFrameWidth="176" maxFrameWidth="1280" + minFrameHeight="144" maxFrameHeight="720" + minFrameRate="5" maxFrameRate="30" /> + + <AudioEncoderCap name="aac" enabled="true" + minBitRate="8000" maxBitRate="320000" + minSampleRate="8000" maxSampleRate="48000" + minChannels="1" maxChannels="2" /> + + <AudioEncoderCap name="amrwb" enabled="true" + minBitRate="6600" maxBitRate="23050" + minSampleRate="16000" maxSampleRate="16000" + minChannels="1" maxChannels="1" /> + + <AudioEncoderCap name="amrnb" enabled="true" + minBitRate="4750" maxBitRate="12200" + minSampleRate="8000" maxSampleRate="8000" + minChannels="1" maxChannels="1" /> + + <VideoDecoderCap name="wmv" enabled="true"/> + <AudioDecoderCap name="wma" enabled="true"/> + <VideoEditorCap maxInputFrameWidth="1920" + maxInputFrameHeight="1080" + maxOutputFrameWidth="1920" + maxOutputFrameHeight="1080" + maxPrefetchYUVFrames="10" /> + <!-- + The VideoEditor Export codec profile and level values + correspond to the values in OMX_Video.h. + E.g. for h264, profile value 1 means OMX_VIDEO_AVCProfileBaseline + and level 512 means OMX_VIDEO_AVCLevel31. + Please note that the values are in decimal. + These values are for video encoder. + --> + <!-- + Codec = h.263, Baseline profile, level 1 + --> + <ExportVideoProfile name="h263" profile="1" + level="1" /> + <!-- + Codec = h.264, Baseline profile, level 4 + --> + <ExportVideoProfile name="h264" profile="1" + level="2048" /> + <!-- + Codec = mpeg4, Simple profile, level 5 + --> + <ExportVideoProfile name="m4v" profile="1" + level="128" /> +</MediaSettings> diff --git a/configs/telephony/ecc_list.xml b/configs/telephony/ecc_list.xml new file mode 100644 index 0000000..3cdf677 --- /dev/null +++ b/configs/telephony/ecc_list.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<EccTable> + <!-- + The attribute definition for tag EccEntry: + - Ecc: the emergnecy number + - Category: the service category + - Condition: there are following values: + - 0: ecc only when no sim + - 1: ecc always + - 2: MMI will show ecc but send to nw as normal call + --> + <EccEntry Ecc="112" Category="0" Condition="1" /> + <EccEntry Ecc="911" Category="0" Condition="1" /> + <EccEntry Ecc="000" Category="0" Condition="0" /> + <EccEntry Ecc="08" Category="0" Condition="0" /> + <EccEntry Ecc="110" Category="0" Condition="0" /> + <EccEntry Ecc="118" Category="0" Condition="0" /> + <EccEntry Ecc="119" Category="0" Condition="0" /> + <EccEntry Ecc="999" Category="0" Condition="1" /> + <EccEntry Ecc="998" Category="0" Condition="1" /> + <EccEntry Ecc="997" Category="0" Condition="1" /> + <EccEntry Ecc="986" Category="0" Condition="1" /> + +</EccTable> diff --git a/configs/telephony/spn-conf.xml b/configs/telephony/spn-conf.xml new file mode 100644 index 0000000..618dd89 --- /dev/null +++ b/configs/telephony/spn-conf.xml @@ -0,0 +1,1099 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<spnOverrides version="1"> +<spnOverride numeric="3100" spn="NEPW"/> +<spnOverride numeric="3102" spn="NEPW"/> +<spnOverride numeric="3109" spn="NEPW"/> +<spnOverride numeric="3500" spn="CELLONE"/> +<spnOverride numeric="7081" spn="ClaroHND"/> +<spnOverride numeric="20201" spn="GR COSMOTE"/> +<spnOverride numeric="20205" spn="vodafone GR"/> +<spnOverride numeric="20209" spn="Q-TELCOM"/> +<spnOverride numeric="20210" spn="WIND"/> +<spnOverride numeric="20404" spn="vodafone NL"/> +<spnOverride numeric="20408" spn="NL KPN"/> +<spnOverride numeric="20409" spn="Lyca mobile"/> +<spnOverride numeric="20412" spn="NL Telfort"/> +<spnOverride numeric="20416" spn="T-Mobile NL"/> +<spnOverride numeric="20420" spn="Orange"/> +<spnOverride numeric="20601" spn="Proximus"/> +<spnOverride numeric="20605" spn="Telenet"/> +<spnOverride numeric="20610" spn="Mobistar"/> +<spnOverride numeric="20620" spn="BASE"/> +<spnOverride numeric="20800" spn="Orange F"/> +<spnOverride numeric="20801" spn="Orange F"/> +<spnOverride numeric="20802" spn="F - Contact"/> +<spnOverride numeric="20810" spn="SFR"/> +<spnOverride numeric="20813" spn="F - Contact"/> +<spnOverride numeric="20815" spn="Free"/> +<spnOverride numeric="20820" spn="BYTEL"/> +<spnOverride numeric="20826" spn="NRJ Mobile"/> +<spnOverride numeric="20888" spn="F - Contact"/> +<spnOverride numeric="21201" spn="vala"/> +<spnOverride numeric="21210" spn="Monaco"/> +<spnOverride numeric="21303" spn="STA-MOBILAND"/> +<spnOverride numeric="21401" spn="vodafone ES"/> +<spnOverride numeric="21403" spn="Orange"/> +<spnOverride numeric="21404" spn="Yoigo"/> +<spnOverride numeric="21407" spn="movistar"/> +<spnOverride numeric="21601" spn="TelenorH"/> +<spnOverride numeric="21630" spn="T-Mobile H"/> +<spnOverride numeric="21670" spn="vodafone HU"/> +<spnOverride numeric="21803" spn="Eronet"/> +<spnOverride numeric="21805" spn="m:tel"/> +<spnOverride numeric="21890" spn="BHMobile"/> +<spnOverride numeric="21901" spn="T-Mobile"/> +<spnOverride numeric="21902" spn="Tele2"/> +<spnOverride numeric="21910" spn="HR VIP"/> +<spnOverride numeric="22001" spn="Telenor"/> +<spnOverride numeric="22002" spn="ProMonte"/> +<spnOverride numeric="22003" spn="Telekom Srbija"/> +<spnOverride numeric="22004" spn="T-Mobile CG"/> +<spnOverride numeric="22005" spn="Vip SRB"/> +<spnOverride numeric="22201" spn="I TIM"/> +<spnOverride numeric="22210" spn="vodafone IT"/> +<spnOverride numeric="22288" spn="I WIND"/> +<spnOverride numeric="22299" spn="3 ITA"/> +<spnOverride numeric="22601" spn="RO Vodafone RO"/> +<spnOverride numeric="22603" spn="RO COSMOTE"/> +<spnOverride numeric="22605" spn="Digi"/> +<spnOverride numeric="22610" spn="RO ORANGE"/> +<spnOverride numeric="22801" spn="Swisscom"/> +<spnOverride numeric="22802" spn="Sunrise"/> +<spnOverride numeric="22803" spn="Orange"/> +<spnOverride numeric="22807" spn="In Phone"/> +<spnOverride numeric="22808" spn="T2"/> +<spnOverride numeric="23001" spn="T-Mobile CZ"/> +<spnOverride numeric="23002" spn="O2 - CZ"/> +<spnOverride numeric="23003" spn="Vodafone CZ"/> +<spnOverride numeric="23101" spn="Orange SK"/> +<spnOverride numeric="23102" spn="T-Mobile SK"/> +<spnOverride numeric="23106" spn="O2 - SK"/> +<spnOverride numeric="23201" spn="A1"/> +<spnOverride numeric="23203" spn="T-Mobile A"/> +<spnOverride numeric="23205" spn="Orange AT"/> +<spnOverride numeric="23207" spn="telering"/> +<spnOverride numeric="23210" spn="3 AT"/> +<spnOverride numeric="23212" spn="Orange AT"/> +<spnOverride numeric="23401" spn="UK01"/> +<spnOverride numeric="23402" spn="O2 -UK"/> +<spnOverride numeric="23403" spn="Jersey Telenet"/> +<spnOverride numeric="23407" spn="Cable Wireless UK"/> +<spnOverride numeric="23410" spn="O2 -UK"/> +<spnOverride numeric="23411" spn="O2 -UK"/> +<spnOverride numeric="23415" spn="vodafone UK"/> +<spnOverride numeric="23419" spn="PMN UK"/> +<spnOverride numeric="23420" spn="3 UK"/> +<spnOverride numeric="23430" spn="T-Mobile UK"/> +<spnOverride numeric="23431" spn="T-Mobile UK"/> +<spnOverride numeric="23432" spn="T-Mobile UK"/> +<spnOverride numeric="23433" spn="Orange"/> +<spnOverride numeric="23434" spn="Orange"/> +<spnOverride numeric="23450" spn="JT-Wave"/> +<spnOverride numeric="23455" spn="Sure"/> +<spnOverride numeric="23458" spn="Manx"/> +<spnOverride numeric="23801" spn="TDC MOBIL"/> +<spnOverride numeric="23802" spn="Telenor"/> +<spnOverride numeric="23806" spn="3 DK"/> +<spnOverride numeric="23820" spn="TELIA DK"/> +<spnOverride numeric="23877" spn="Sonofon"/> +<spnOverride numeric="23892" spn="TelenoDK"/> +<spnOverride numeric="24001" spn="TELIA"/> +<spnOverride numeric="24002" spn="3 SE"/> +<spnOverride numeric="24004" spn="Sweden"/> +<spnOverride numeric="24005" spn="Sweden 3G"/> +<spnOverride numeric="24007" spn="Tele2"/> +<spnOverride numeric="24008" spn="Telenor SE"/> +<spnOverride numeric="24010" spn="SpringMobil SE"/> +<spnOverride numeric="24024" spn="MobileS"/> +<spnOverride numeric="24201" spn="N Telenor"/> +<spnOverride numeric="24202" spn="N NetCom"/> +<spnOverride numeric="24205" spn="Mobile Norway"/> +<spnOverride numeric="24403" spn="DNA"/> +<spnOverride numeric="24405" spn="FI Elisa"/> +<spnOverride numeric="24412" spn="DNA"/> +<spnOverride numeric="24414" spn="FI AMT"/> +<spnOverride numeric="24491" spn="FI SONERA"/> +<spnOverride numeric="24601" spn="OMNITEL LT"/> +<spnOverride numeric="24602" spn="LT BITE GSM"/> +<spnOverride numeric="24603" spn="TELE2"/> +<spnOverride numeric="24701" spn="LMT GSM"/> +<spnOverride numeric="24702" spn="TELE2"/> +<spnOverride numeric="24705" spn="BITE LV"/> +<spnOverride numeric="24801" spn="EE EMT"/> +<spnOverride numeric="24802" spn="EE elisa"/> +<spnOverride numeric="24803" spn="TELE2"/> +<spnOverride numeric="25001" spn="MTS"/> +<spnOverride numeric="25002" spn="MegaFon"/> +<spnOverride numeric="25004" spn="RUS_SCN"/> +<spnOverride numeric="25005" spn="ETK"/> +<spnOverride numeric="25007" spn="BMT"/> +<spnOverride numeric="25010" spn="DTC"/> +<spnOverride numeric="25012" spn="Baykalwestcom"/> +<spnOverride numeric="25013" spn="KUGSM"/> +<spnOverride numeric="25015" spn="SMARTS"/> +<spnOverride numeric="25016" spn="NTC"/> +<spnOverride numeric="25017" spn="Utel"/> +<spnOverride numeric="25019" spn="INDIGO"/> +<spnOverride numeric="25020" spn="TELE2"/> +<spnOverride numeric="25028" spn="Beeline"/> +<spnOverride numeric="25035" spn="MOTIV"/> +<spnOverride numeric="25037" spn="KODOTEL"/> +<spnOverride numeric="25039" spn="Utel"/> +<spnOverride numeric="25099" spn="Beeline"/> +<spnOverride numeric="25501" spn="MTS UKR"/> +<spnOverride numeric="25502" spn="Beeline"/> +<spnOverride numeric="25503" spn="Kyivstar"/> +<spnOverride numeric="25505" spn="GT"/> +<spnOverride numeric="25506" spn="life:)"/> +<spnOverride numeric="25507" spn="Utel"/> +<spnOverride numeric="25701" spn="Velcom"/> +<spnOverride numeric="25702" spn="MTS"/> +<spnOverride numeric="25704" spn="life:)"/> +<spnOverride numeric="25901" spn="Orange MD"/> +<spnOverride numeric="25902" spn="MDCELL"/> +<spnOverride numeric="25903" spn="UNITE"/> +<spnOverride numeric="25904" spn="EVENTIS"/> +<spnOverride numeric="25905" spn="UNITE"/> +<spnOverride numeric="26001" spn="Plus"/> +<spnOverride numeric="26002" spn="Era"/> +<spnOverride numeric="26003" spn="Orange PL"/> +<spnOverride numeric="26006" spn="Play"/> +<spnOverride numeric="26010" spn="Sferia"/> +<spnOverride numeric="26012" spn="Cyfrowy Polsat"/> +<spnOverride numeric="26015" spn="CenterNet S.A."/> +<spnOverride numeric="26016" spn="Mobyland Sp. z o.o."/> +<spnOverride numeric="26017" spn="Aero 2 Sp. z o.o."/> +<spnOverride numeric="26201" spn="T-Mobile D"/> +<spnOverride numeric="26202" spn="Vodafone.de"/> +<spnOverride numeric="26203" spn="E-Plus"/> +<spnOverride numeric="26207" spn="o2 - de"/> +<spnOverride numeric="26208" spn="o2 - de"/> +<spnOverride numeric="26601" spn="GIBTEL"/> +<spnOverride numeric="26606" spn="CTS"/> +<spnOverride numeric="26801" spn="vodafone P"/> +<spnOverride numeric="26803" spn="P OPTIMUS"/> +<spnOverride numeric="26806" spn="P TMN"/> +<spnOverride numeric="27001" spn="L LUXGSM"/> +<spnOverride numeric="27077" spn="L TANGO"/> +<spnOverride numeric="27099" spn="L Orange-LU"/> +<spnOverride numeric="27201" spn="vodafone IE"/> +<spnOverride numeric="27202" spn="O2 IRL"/> +<spnOverride numeric="27203" spn="IRL - METEOR"/> +<spnOverride numeric="27205" spn="3 IRL"/> +<spnOverride numeric="27211" spn="Tesco Mobile"/> +<spnOverride numeric="27401" spn="Siminn"/> +<spnOverride numeric="27402" spn="Vodafone"/> +<spnOverride numeric="27404" spn="Viking"/> +<spnOverride numeric="27407" spn="IceCell"/> +<spnOverride numeric="27408" spn="On-waves"/> +<spnOverride numeric="27411" spn="NOVA"/> +<spnOverride numeric="27412" spn="Siminn"/> +<spnOverride numeric="27601" spn="AMC - AL"/> +<spnOverride numeric="27602" spn="vodafone AL"/> +<spnOverride numeric="27603" spn="EAGLE AL"/> +<spnOverride numeric="27604" spn="PLUS AL"/> +<spnOverride numeric="27801" spn="vodafone MT"/> +<spnOverride numeric="27821" spn="go mobile"/> +<spnOverride numeric="27877" spn="3GT MT"/> +<spnOverride numeric="28001" spn="Cytamobile-Vodafone "/> +<spnOverride numeric="28010" spn="MTN"/> +<spnOverride numeric="28201" spn="GCELL"/> +<spnOverride numeric="28202" spn="MAGTI"/> +<spnOverride numeric="28204" spn="BEELINE"/> +<spnOverride numeric="28300" spn="MTS Armenia"/> +<spnOverride numeric="28301" spn="Beeline AM"/> +<spnOverride numeric="28305" spn="MTS Armenia"/> +<spnOverride numeric="28310" spn="Orange"/> +<spnOverride numeric="28401" spn="M-Tel BG"/> +<spnOverride numeric="28403" spn="vivatel"/> +<spnOverride numeric="28405" spn="BG GLOBUL"/> +<spnOverride numeric="28601" spn="TR TURKCELL"/> +<spnOverride numeric="28602" spn="VODAFONE TR"/> +<spnOverride numeric="28603" spn="AVEA"/> +<spnOverride numeric="28801" spn="FT-GSM"/> +<spnOverride numeric="28802" spn="VODAFONE"/> +<spnOverride numeric="29001" spn="TELE GRL"/> +<spnOverride numeric="29266" spn="SMT"/> +<spnOverride numeric="29340" spn="Si.mobil"/> +<spnOverride numeric="29341" spn="Mobitel"/> +<spnOverride numeric="29364" spn="T-2"/> +<spnOverride numeric="29370" spn="Tusmobil"/> +<spnOverride numeric="29401" spn="T-Mobile MK"/> +<spnOverride numeric="29402" spn="ONE"/> +<spnOverride numeric="29403" spn="Vip MKD"/> +<spnOverride numeric="29501" spn="SwisscomFL"/> +<spnOverride numeric="29502" spn="Orange FL"/> +<spnOverride numeric="29505" spn="FL1"/> +<spnOverride numeric="29577" spn="LI TANGO"/> +<spnOverride numeric="30272" spn="Rogers"/> +<spnOverride numeric="30286" spn="Telus"/> +<spnOverride numeric="30801" spn="AMERIS"/> +<spnOverride numeric="31000" spn="Verizon"/> +<spnOverride numeric="31031" spn="T-Mobile "/> +<spnOverride numeric="31046" spn="SIMMETRY"/> +<spnOverride numeric="31100" spn="WILKES"/> +<spnOverride numeric="31101" spn="WILKES"/> +<spnOverride numeric="31105" spn="WILKES"/> +<spnOverride numeric="33403" spn="movistar"/> +<spnOverride numeric="33805" spn="DIGICEL"/> +<spnOverride numeric="34001" spn="F-Orange"/> +<spnOverride numeric="34002" spn="ONLY"/> +<spnOverride numeric="34003" spn="CHIPPIE"/> +<spnOverride numeric="34008" spn="DAUPHIN"/> +<spnOverride numeric="34020" spn="DIGICEL"/> +<spnOverride numeric="35001" spn="Digicel"/> +<spnOverride numeric="35002" spn="M3 WIRELESS"/> +<spnOverride numeric="35010" spn="Cingular"/> +<spnOverride numeric="36251" spn="Telcell GSM"/> +<spnOverride numeric="36269" spn="CT GSM"/> +<spnOverride numeric="36291" spn="CHIPPIE"/> +<spnOverride numeric="36301" spn="SETAR GSM"/> +<spnOverride numeric="36320" spn="Digicel"/> +<spnOverride numeric="36439" spn="BaTelCel"/> +<spnOverride numeric="36801" spn="Cubacel"/> +<spnOverride numeric="37001" spn="orange"/> +<spnOverride numeric="37002" spn="CLARO DOM"/> +<spnOverride numeric="37004" spn="Viva"/> +<spnOverride numeric="37201" spn="COMCEL"/> +<spnOverride numeric="37412" spn="TSTT"/> +<spnOverride numeric="40001" spn="ACELL"/> +<spnOverride numeric="40002" spn="BKCELL"/> +<spnOverride numeric="40004" spn="Nar"/> +<spnOverride numeric="40101" spn="Beeline KZ"/> +<spnOverride numeric="40102" spn="KZ KCELL"/> +<spnOverride numeric="40177" spn="NEO-KZ"/> +<spnOverride numeric="40211" spn="B-Mobile"/> +<spnOverride numeric="40277" spn="TashiCell"/> +<spnOverride numeric="40401" spn="Vodafone"/> +<spnOverride numeric="40400" spn="Reliance"/> +<spnOverride numeric="40402" spn="Airtel"/> +<spnOverride numeric="40403" spn="Airtel"/> +<spnOverride numeric="40404" spn="IDEA"/> +<spnOverride numeric="40405" spn="Vodafone"/> +<spnOverride numeric="40407" spn="IDEA"/> +<spnOverride numeric="40409" spn="Reliance"/> +<spnOverride numeric="40410" spn="Airtel"/> +<spnOverride numeric="40411" spn="Vodafone"/> +<spnOverride numeric="40412" spn="IDEA"/> +<spnOverride numeric="40413" spn="Vodafone"/> +<spnOverride numeric="40414" spn="IDEA"/> +<spnOverride numeric="40415" spn="Vodafone"/> +<spnOverride numeric="40416" spn="Airtel"/> +<spnOverride numeric="40417" spn="Aircel"/> +<spnOverride numeric="40418" spn="Reliance"/> +<spnOverride numeric="40419" spn="IDEA"/> +<spnOverride numeric="40420" spn="Vodafone"/> +<spnOverride numeric="40421" spn="LoopMobile"/> +<spnOverride numeric="40422" spn="IDEA"/> +<spnOverride numeric="40424" spn="IDEA"/> +<spnOverride numeric="40425" spn="Aircel"/> +<spnOverride numeric="40427" spn="Vodafone"/> +<spnOverride numeric="40428" spn="Aircel"/> +<spnOverride numeric="40429" spn="Aircel"/> +<spnOverride numeric="40430" spn="Vodafone"/> +<spnOverride numeric="40431" spn="AirTel"/> +<spnOverride numeric="40433" spn="Aircel"/> +<spnOverride numeric="40434" spn="CellOne"/> +<spnOverride numeric="40435" spn="Aircel"/> +<spnOverride numeric="40436" spn="Reliance"/> +<spnOverride numeric="40437" spn="Aircel"/> +<spnOverride numeric="40438" spn="CellOne"/> +<spnOverride numeric="40440" spn="Airtel"/> +<spnOverride numeric="40441" spn="Aircel"/> +<spnOverride numeric="40442" spn="Aircel"/> +<spnOverride numeric="40443" spn="Vodafone"/> +<spnOverride numeric="40444" spn="IDEA"/> +<spnOverride numeric="40445" spn="Airtel"/> +<spnOverride numeric="40446" spn="Vodafone"/> +<spnOverride numeric="40449" spn="AirTel"/> +<spnOverride numeric="40450" spn="Reliance"/> +<spnOverride numeric="40451" spn="CellOne"/> +<spnOverride numeric="40452" spn="Reliance"/> +<spnOverride numeric="40453" spn="CellOne"/> +<spnOverride numeric="40454" spn="CellOne"/> +<spnOverride numeric="40455" spn="CellOne"/> +<spnOverride numeric="40456" spn="IDEA"/> +<spnOverride numeric="40457" spn="CellOne"/> +<spnOverride numeric="40458" spn="CellOne"/> +<spnOverride numeric="40459" spn="CellOne"/> +<spnOverride numeric="40460" spn="Vodafone"/> +<spnOverride numeric="40462" spn="CellOne"/> +<spnOverride numeric="40464" spn="CellOne"/> +<spnOverride numeric="40466" spn="CellOne"/> +<spnOverride numeric="40467" spn="Reliance"/> +<spnOverride numeric="40468" spn="Dolphin"/> +<spnOverride numeric="40469" spn="Dolphin"/> +<spnOverride numeric="40470" spn="Airtel"/> +<spnOverride numeric="40471" spn="CellOne"/> +<spnOverride numeric="40472" spn="CellOne"/> +<spnOverride numeric="40473" spn="CellOne"/> +<spnOverride numeric="40474" spn="CellOne"/> +<spnOverride numeric="40475" spn="CellOne"/> +<spnOverride numeric="40476" spn="CellOne"/> +<spnOverride numeric="40477" spn="CellOne"/> +<spnOverride numeric="40478" spn="IDEA"/> +<spnOverride numeric="40479" spn="CellOne"/> +<spnOverride numeric="40480" spn="CellOne"/> +<spnOverride numeric="40481" spn="CellOne"/> +<spnOverride numeric="40482" spn="IDEA"/> +<spnOverride numeric="40483" spn="Reliance"/> +<spnOverride numeric="40484" spn="Vodafone"/> +<spnOverride numeric="40485" spn="Reliance"/> +<spnOverride numeric="40486" spn="Vodafone"/> +<spnOverride numeric="40487" spn="IDEA"/> +<spnOverride numeric="40488" spn="Vodafone"/> +<spnOverride numeric="40489" spn="IDEA"/> +<spnOverride numeric="40490" spn="AirTel"/> +<spnOverride numeric="40491" spn="Aircel"/> +<spnOverride numeric="40492" spn="Airtel"/> +<spnOverride numeric="40493" spn="Airtel"/> +<spnOverride numeric="40494" spn="Airtel"/> +<spnOverride numeric="40495" spn="Airtel"/> +<spnOverride numeric="40496" spn="Airtel"/> +<spnOverride numeric="40497" spn="Airtel"/> +<spnOverride numeric="40498" spn="Airtel"/> +<spnOverride numeric="40501" spn="Reliance"/> +<spnOverride numeric="40505" spn="Reliance"/> +<spnOverride numeric="40506" spn="Reliance"/> +<spnOverride numeric="40507" spn="Reliance"/> +<spnOverride numeric="40509" spn="Reliance"/> +<spnOverride numeric="40510" spn="Reliance"/> +<spnOverride numeric="40511" spn="Reliance"/> +<spnOverride numeric="40513" spn="Reliance"/> +<spnOverride numeric="40515" spn="Reliance"/> +<spnOverride numeric="40518" spn="Reliance"/> +<spnOverride numeric="40519" spn="Reliance"/> +<spnOverride numeric="40520" spn="Reliance"/> +<spnOverride numeric="40521" spn="Reliance"/> +<spnOverride numeric="40522" spn="Reliance"/> +<spnOverride numeric="40548" spn="Indian Railways"/> +<spnOverride numeric="40551" spn="AirTel"/> +<spnOverride numeric="40552" spn="Airtel"/> +<spnOverride numeric="40553" spn="Airtel"/> +<spnOverride numeric="40554" spn="Airtel"/> +<spnOverride numeric="40555" spn="Airtel"/> +<spnOverride numeric="40556" spn="Airtel"/> +<spnOverride numeric="40566" spn="Vodafone"/> +<spnOverride numeric="40567" spn="Vodafone"/> +<spnOverride numeric="40570" spn="IDEA"/> +<spnOverride numeric="41001" spn="Mobilink"/> +<spnOverride numeric="41003" spn="PK-UFONE"/> +<spnOverride numeric="41004" spn="ZONG"/> +<spnOverride numeric="41006" spn="Telenor PK"/> +<spnOverride numeric="41007" spn="WaridTel"/> +<spnOverride numeric="41201" spn="AF AWCC"/> +<spnOverride numeric="41220" spn="ROSHAN"/> +<spnOverride numeric="41240" spn="MTN AF"/> +<spnOverride numeric="41250" spn="Etisalat Af"/> +<spnOverride numeric="41301" spn="Mobitel"/> +<spnOverride numeric="41302" spn="SRI DIALOG"/> +<spnOverride numeric="41303" spn="ETISALAT "/> +<spnOverride numeric="41305" spn="SRI AIRTEL"/> +<spnOverride numeric="41308" spn="Hutch"/> +<spnOverride numeric="41401" spn="MPTGSM"/> +<spnOverride numeric="41501" spn="Alfa"/> +<spnOverride numeric="41503" spn="MTC-Touch"/> +<spnOverride numeric="41505" spn="Ogero Mobile (OM)"/> +<spnOverride numeric="41601" spn="zain JO"/> +<spnOverride numeric="41603" spn="Umniah"/> +<spnOverride numeric="41677" spn="Orange"/> +<spnOverride numeric="41701" spn="SYRIATEL"/> +<spnOverride numeric="41702" spn="MTN"/> +<spnOverride numeric="41709" spn="MOBILE"/> +<spnOverride numeric="41800" spn="ASIACELL"/> +<spnOverride numeric="41805" spn="ASIACELL"/> +<spnOverride numeric="41820" spn="zain IQ"/> +<spnOverride numeric="41830" spn="IRAQNA"/> +<spnOverride numeric="41840" spn="KOREK"/> +<spnOverride numeric="41902" spn="zain KW"/> +<spnOverride numeric="41903" spn="Wataniya Telecom"/> +<spnOverride numeric="41904" spn="VIVA"/> +<spnOverride numeric="42001" spn="STC"/> +<spnOverride numeric="42101" spn="SabaFon"/> +<spnOverride numeric="42102" spn="MTN"/> +<spnOverride numeric="42202" spn="OMAN MOBILE"/> +<spnOverride numeric="42203" spn="nawras"/> +<spnOverride numeric="42402" spn="ETISALAT"/> +<spnOverride numeric="42403" spn="du"/> +<spnOverride numeric="42501" spn="IL ORANGE"/> +<spnOverride numeric="42502" spn="Cellcom Israel"/> +<spnOverride numeric="42503" spn="Pelephone"/> +<spnOverride numeric="42505" spn="JAWWAL"/> +<spnOverride numeric="42506" spn="Wataniya Mobile "/> +<spnOverride numeric="42601" spn="BATELCO"/> +<spnOverride numeric="42602" spn="zain BH"/> +<spnOverride numeric="42604" spn="VIVA BH"/> +<spnOverride numeric="42701" spn="Qat - Qtel"/> +<spnOverride numeric="42702" spn="vodafone"/> +<spnOverride numeric="42888" spn="Unitel"/> +<spnOverride numeric="42899" spn="MobiCom"/> +<spnOverride numeric="42901" spn="NTC"/> +<spnOverride numeric="42902" spn="Ncell"/> +<spnOverride numeric="43211" spn="MCI"/> +<spnOverride numeric="43214" spn="IR KISH"/> +<spnOverride numeric="43219" spn="MTCE"/> +<spnOverride numeric="43232" spn="Taliya"/> +<spnOverride numeric="43235" spn="MTN Irancell"/> +<spnOverride numeric="43404" spn="Beeline UZ"/> +<spnOverride numeric="43405" spn="UZB Ucell"/> +<spnOverride numeric="43407" spn="UZB MTS"/> +<spnOverride numeric="43601" spn="TCELL"/> +<spnOverride numeric="43602" spn="TCELL"/> +<spnOverride numeric="43603" spn="MLT"/> +<spnOverride numeric="43604" spn="Babilon"/> +<spnOverride numeric="43605" spn="BEELINE"/> +<spnOverride numeric="43612" spn="INDIGO-T"/> +<spnOverride numeric="43701" spn="Beeline KG"/> +<spnOverride numeric="43705" spn="MEGACOM"/> +<spnOverride numeric="43709" spn="O!"/> +<spnOverride numeric="43801" spn="MTS TM"/> +<spnOverride numeric="44000" spn="eMobile"/> +<spnOverride numeric="44007" spn="KDDI"/> +<spnOverride numeric="44010" spn="DOCOMO"/> +<spnOverride numeric="44020" spn="SoftBank"/> +<spnOverride numeric="44050" spn="KDDI"/> +<spnOverride numeric="45002" spn="KTF"/> +<spnOverride numeric="45005" spn="SK Telecom"/> +<spnOverride numeric="45008" spn="KTF"/> +<spnOverride numeric="45201" spn="Mobifone"/> +<spnOverride numeric="45202" spn="VINAPHONE"/> +<spnOverride numeric="45204" spn="Viettel Mobile"/> +<spnOverride numeric="45205" spn="VNMOBILE"/> +<spnOverride numeric="45207" spn="Beeline"/> +<spnOverride numeric="45208" spn="EVNTelecom"/> +<spnOverride numeric="45400" spn="CSL"/> +<spnOverride numeric="45402" spn="CSL"/> +<spnOverride numeric="45403" spn="3 HK"/> +<spnOverride numeric="45404" spn="3(2G)"/> +<spnOverride numeric="45406" spn="SmarToneVodafone"/> +<spnOverride numeric="45429" spn="PCCW"/> +<spnOverride numeric="45410" spn="CSL"/> +<spnOverride numeric="45412" spn="CMCC"/> +<spnOverride numeric="45413" spn="CMCC HK"/> +<spnOverride numeric="45415" spn="SmarToneVodafone"/> +<spnOverride numeric="45416" spn="PCCW"/> +<spnOverride numeric="45418" spn="CSL"/> +<spnOverride numeric="45419" spn="PCCW"/> +<spnOverride numeric="45500" spn="SmarTone"/> +<spnOverride numeric="45501" spn="CTM"/> +<spnOverride numeric="45502" spn="CT Macao"/> +<spnOverride numeric="45503" spn="HT Macau"/> +<spnOverride numeric="45504" spn="CTM"/> +<spnOverride numeric="45505" spn="3 Macau"/> +<spnOverride numeric="45601" spn="CELLCARD"/> +<spnOverride numeric="45602" spn="hello"/> +<spnOverride numeric="45604" spn="QB"/> +<spnOverride numeric="45605" spn="STARCELL"/> +<spnOverride numeric="45606" spn="SMART"/> +<spnOverride numeric="45608" spn="Metfone"/> +<spnOverride numeric="45609" spn="Beeline"/> +<spnOverride numeric="45618" spn="Mfone"/> +<spnOverride numeric="45701" spn="LAO GSM"/> +<spnOverride numeric="45702" spn="ETL MOBILE"/> +<spnOverride numeric="45703" spn="UNITEL"/> +<spnOverride numeric="45708" spn="TIGO LAO"/> +<spnOverride numeric="46000" spn="CMCC"/> +<spnOverride numeric="46001" spn="UNICOM"/> +<spnOverride numeric="46002" spn="CMCC(02)"/> +<spnOverride numeric="46007" spn="CMCC(07)"/> +<spnOverride numeric="46601" spn="Far EasTone"/> +<spnOverride numeric="46605" spn="APTG"/> +<spnOverride numeric="46668" spn="ACeS"/> +<spnOverride numeric="46688" spn="KG Telecom"/> +<spnOverride numeric="46689" spn="VIBO"/> +<spnOverride numeric="46692" spn="Chunghwa Telecom"/> +<spnOverride numeric="46693" spn="MobiTai"/> +<spnOverride numeric="46697" spn="Taiwan Mobile"/> +<spnOverride numeric="46699" spn="TransAsia"/> +<spnOverride numeric="46703" spn="SUNNET"/> +<spnOverride numeric="47001" spn="Grameenphone"/> +<spnOverride numeric="47002" spn="Robi"/> +<spnOverride numeric="47003" spn="Banglalink"/> +<spnOverride numeric="47004" spn="Teletalk"/> +<spnOverride numeric="47007" spn="Airtel"/> +<spnOverride numeric="47201" spn="Dhiraagu"/> +<spnOverride numeric="47202" spn="WATANIYA"/> +<spnOverride numeric="50212" spn="MY MAXIS"/> +<spnOverride numeric="50213" spn="MY CELCOM 3G"/> +<spnOverride numeric="50216" spn="MY DiGi"/> +<spnOverride numeric="50218" spn="U MOBILE"/> +<spnOverride numeric="50219" spn="MY CELCOM"/> +<spnOverride numeric="50501" spn="Telstra Mobile"/> +<spnOverride numeric="50502" spn="Optus"/> +<spnOverride numeric="50503" spn="vodafone AU"/> +<spnOverride numeric="50506" spn="3TELSTRA"/> +<spnOverride numeric="50510" spn="NT"/> +<spnOverride numeric="50519" spn="Lycamobile"/> +<spnOverride numeric="51000" spn="ACeS"/> +<spnOverride numeric="51001" spn="INDOSAT"/> +<spnOverride numeric="51008" spn="axis"/> +<spnOverride numeric="51010" spn="TELKOMSEL"/> +<spnOverride numeric="51011" spn="XL"/> +<spnOverride numeric="51021" spn="INDOSAT"/> +<spnOverride numeric="51089" spn="3"/> +<spnOverride numeric="51402" spn="TLS-TT"/> +<spnOverride numeric="51501" spn="ISLACOM"/> +<spnOverride numeric="51502" spn="Globe Telecom"/> +<spnOverride numeric="51503" spn="SMART"/> +<spnOverride numeric="51505" spn="SUN"/> +<spnOverride numeric="51511" spn="ACeS"/> +<spnOverride numeric="51518" spn="CURE"/> +<spnOverride numeric="515034" spn="SUN"/> +<spnOverride numeric="515035" spn="SUN"/> +<spnOverride numeric="515036" spn="SUN"/> +<spnOverride numeric="515037" spn="SUN"/> +<spnOverride numeric="515038" spn="SUN"/> +<spnOverride numeric="515039" spn="SUN"/> +<spnOverride numeric="52001" spn="AIS GSM"/> +<spnOverride numeric="52010" spn="TRUE"/> +<spnOverride numeric="52015" spn="ACT-1900"/> +<spnOverride numeric="52018" spn="DTAC"/> +<spnOverride numeric="52020" spn="ACeS"/> +<spnOverride numeric="52023" spn="TH GSM 1800"/> +<spnOverride numeric="52099" spn="TRUE"/> +<spnOverride numeric="52501" spn="SingTel"/> +<spnOverride numeric="52502" spn="SingTel"/> +<spnOverride numeric="52503" spn="M1-3GSM"/> +<spnOverride numeric="52505" spn="STARHUB"/> +<spnOverride numeric="52507" spn="SingTel"/> +<spnOverride numeric="52802" spn="B-mobile"/> +<spnOverride numeric="52811" spn="DSTCom"/> +<spnOverride numeric="53001" spn="vodafone NZ"/> +<spnOverride numeric="53005" spn="Telecom NZ"/> +<spnOverride numeric="53024" spn="2degrees"/> +<spnOverride numeric="53701" spn="BMobile"/> +<spnOverride numeric="53901" spn="U-CALL"/> +<spnOverride numeric="53988" spn="Digicel Tonga"/> +<spnOverride numeric="54001" spn="BREEZE"/> +<spnOverride numeric="54101" spn="VUT SMILE"/> +<spnOverride numeric="54105" spn="DIGICEL"/> +<spnOverride numeric="54201" spn="VODAFONE"/> +<spnOverride numeric="54509" spn="KI-FRIG"/> +<spnOverride numeric="54601" spn="MOBILIS"/> +<spnOverride numeric="54720" spn="VINI"/> +<spnOverride numeric="54801" spn="KOKANET"/> +<spnOverride numeric="54927" spn="Samoatel GO"/> +<spnOverride numeric="55001" spn="FSM Telecom"/> +<spnOverride numeric="55280" spn="Palau Mobile"/> +<spnOverride numeric="60201" spn="EGY MobiNiL"/> +<spnOverride numeric="60202" spn="vodafone EG"/> +<spnOverride numeric="60203" spn="Etisalat"/> +<spnOverride numeric="60301" spn="Mobilis"/> +<spnOverride numeric="60302" spn="Djezzy"/> +<spnOverride numeric="60303" spn="Nedjma"/> +<spnOverride numeric="60400" spn="MEDITEL"/> +<spnOverride numeric="60401" spn="IAM"/> +<spnOverride numeric="60402" spn="Wan Mobile"/> +<spnOverride numeric="60501" spn="Orange"/> +<spnOverride numeric="60502" spn="TUNTEL"/> +<spnOverride numeric="60503" spn="TUNISIANA"/> +<spnOverride numeric="60600" spn="Libyana"/> +<spnOverride numeric="60601" spn="ALMADAR"/> +<spnOverride numeric="60701" spn="GAMCEL"/> +<spnOverride numeric="60702" spn="Africell"/> +<spnOverride numeric="60703" spn="GMCOMIUM"/> +<spnOverride numeric="60704" spn="QC"/> +<spnOverride numeric="60801" spn="ALIZE"/> +<spnOverride numeric="60802" spn="SENTEL"/> +<spnOverride numeric="60803" spn="Expresso Senegal"/> +<spnOverride numeric="60901" spn="MATTEL"/> +<spnOverride numeric="60902" spn="Chinguitel"/> +<spnOverride numeric="60910" spn="Mauritel"/> +<spnOverride numeric="61001" spn="MALITEL ML"/> +<spnOverride numeric="61002" spn="ORANGE ML"/> +<spnOverride numeric="61101" spn="Orange GN"/> +<spnOverride numeric="61102" spn="LAGUI"/> +<spnOverride numeric="61104" spn="GNAreeba"/> +<spnOverride numeric="61105" spn="CellcomGN"/> +<spnOverride numeric="61202" spn="MOOV"/> +<spnOverride numeric="61203" spn="Orange"/> +<spnOverride numeric="61204" spn="KoZ"/> +<spnOverride numeric="61205" spn="MTN CI"/> +<spnOverride numeric="61301" spn="Telmob"/> +<spnOverride numeric="61302" spn="celtel"/> +<spnOverride numeric="61401" spn="SAHELCOM"/> +<spnOverride numeric="61402" spn="CELTEL"/> +<spnOverride numeric="61403" spn="TELECEL"/> +<spnOverride numeric="61404" spn="Orange"/> +<spnOverride numeric="61501" spn="TOGO CELL"/> +<spnOverride numeric="61503" spn="Telecel Togo"/> +<spnOverride numeric="61602" spn="TLCL-BEN"/> +<spnOverride numeric="61603" spn="MTN"/> +<spnOverride numeric="61605" spn="GloBenin"/> +<spnOverride numeric="61701" spn="CELL +"/> +<spnOverride numeric="61710" spn="EMTEL"/> +<spnOverride numeric="61801" spn="LoneStar"/> +<spnOverride numeric="61807" spn="Celcom"/> +<spnOverride numeric="61901" spn="CELTEL"/> +<spnOverride numeric="61902" spn="MILLICOM"/> +<spnOverride numeric="61903" spn="Datatel"/> +<spnOverride numeric="61904" spn="SLE COMIUM"/> +<spnOverride numeric="61905" spn="Africell"/> +<spnOverride numeric="61907" spn="GreenN "/> +<spnOverride numeric="61925" spn="Mobitel"/> +<spnOverride numeric="62001" spn="MTN"/> +<spnOverride numeric="62002" spn="Vodafone"/> +<spnOverride numeric="62003" spn="Tigo"/> +<spnOverride numeric="62006" spn="Airtel"/> +<spnOverride numeric="62120" spn="AIrtelNG"/> +<spnOverride numeric="62130" spn="MTN-NG"/> +<spnOverride numeric="62140" spn="Mtel"/> +<spnOverride numeric="62150" spn="Glo Mobile"/> +<spnOverride numeric="62160" spn="EMTS NGA"/> +<spnOverride numeric="62201" spn="CELTEL"/> +<spnOverride numeric="62302" spn="Telecel"/> +<spnOverride numeric="62303" spn="Orange RCA"/> +<spnOverride numeric="62304" spn="NationLink"/> +<spnOverride numeric="62401" spn="Zain SD"/> +<spnOverride numeric="62402" spn="Orange CAM"/> +<spnOverride numeric="62501" spn="CPV MOVEL"/> +<spnOverride numeric="62502" spn="CPV T+"/> +<spnOverride numeric="62601" spn="CSTmovel"/> +<spnOverride numeric="62701" spn="GETESA"/> +<spnOverride numeric="62703" spn="HiTs-GE"/> +<spnOverride numeric="62801" spn="LIBERTIS"/> +<spnOverride numeric="62802" spn="TELECEL"/> +<spnOverride numeric="62803" spn="ZAIN"/> +<spnOverride numeric="62901" spn="CELTEL RC"/> +<spnOverride numeric="62902" spn="Azur-Congo"/> +<spnOverride numeric="62907" spn="WARIDRC"/> +<spnOverride numeric="62910" spn="MTN-CG"/> +<spnOverride numeric="63001" spn="Vodacom CD"/> +<spnOverride numeric="63002" spn="CELTEL"/> +<spnOverride numeric="63005" spn="SCELL CD"/> +<spnOverride numeric="63086" spn="CCT"/> +<spnOverride numeric="63089" spn="OASIS"/> +<spnOverride numeric="63102" spn="Unitel"/> +<spnOverride numeric="63202" spn="MTN"/> +<spnOverride numeric="63203" spn="ORANGE BS"/> +<spnOverride numeric="63207" spn="GTM"/> +<spnOverride numeric="63301" spn="C W SEY"/> +<spnOverride numeric="63310" spn="AIRTEL"/> +<spnOverride numeric="63401" spn="MobiTel"/> +<spnOverride numeric="63402" spn="MTN"/> +<spnOverride numeric="63405" spn="Vivacell"/> +<spnOverride numeric="63510" spn="RCELL"/> +<spnOverride numeric="63512" spn="RWTEL"/> +<spnOverride numeric="63513" spn="TIGO"/> +<spnOverride numeric="63601" spn="ET-MTN"/> +<spnOverride numeric="63701" spn="Tele"/> +<spnOverride numeric="63704" spn="SOMAFONE"/> +<spnOverride numeric="63730" spn="Golis"/> +<spnOverride numeric="63740" spn="MONTYSOM"/> +<spnOverride numeric="63771" spn="SOMTEL"/> +<spnOverride numeric="63782" spn="Telsom"/> +<spnOverride numeric="63801" spn="EVATIS"/> +<spnOverride numeric="63902" spn="Safaricom"/> +<spnOverride numeric="63903" spn="Airtel"/> +<spnOverride numeric="63905" spn="Yu"/> +<spnOverride numeric="63907" spn="Orange Kenya "/> +<spnOverride numeric="64002" spn="TIGO"/> +<spnOverride numeric="64003" spn="ZANTEL"/> +<spnOverride numeric="64004" spn="VodaCom"/> +<spnOverride numeric="64005" spn="celtel"/> +<spnOverride numeric="64009" spn="Hits TZ"/> +<spnOverride numeric="64101" spn="CELTEL"/> +<spnOverride numeric="64110" spn="MTN-UG"/> +<spnOverride numeric="64111" spn="UTL"/> +<spnOverride numeric="64114" spn="OUL"/> +<spnOverride numeric="64122" spn="WaridTel"/> +<spnOverride numeric="64201" spn="EWB"/> +<spnOverride numeric="64202" spn="TEMPO-AF"/> +<spnOverride numeric="64203" spn="ONATEL"/> +<spnOverride numeric="64207" spn="SMART"/> +<spnOverride numeric="64282" spn="TELECEL-BDI"/> +<spnOverride numeric="64301" spn="mCel"/> +<spnOverride numeric="64304" spn="VodaCom"/> +<spnOverride numeric="64501" spn="CELTEL"/> +<spnOverride numeric="64502" spn="MTN ZM"/> +<spnOverride numeric="64601" spn="Airtel"/> +<spnOverride numeric="64602" spn="OrangeMG"/> +<spnOverride numeric="64604" spn="TELMA"/> +<spnOverride numeric="64700" spn="Orange "/> +<spnOverride numeric="64702" spn="OUTREMER"/> +<spnOverride numeric="64710" spn="SFR RU"/> +<spnOverride numeric="64801" spn="NetOne"/> +<spnOverride numeric="64803" spn="TELECEL"/> +<spnOverride numeric="64804" spn="ECONET"/> +<spnOverride numeric="64901" spn="MTC"/> +<spnOverride numeric="64903" spn="leoâ„¢"/> +<spnOverride numeric="65010" spn="CELTEL"/> +<spnOverride numeric="65101" spn="Vodacom-LS"/> +<spnOverride numeric="65102" spn="EZI-CEL"/> +<spnOverride numeric="65201" spn="MASCOM"/> +<spnOverride numeric="65202" spn="Orange"/> +<spnOverride numeric="65310" spn="SwaziMTN"/> +<spnOverride numeric="65501" spn="VodaCom-SA"/> +<spnOverride numeric="65502" spn="8ta"/> +<spnOverride numeric="65507" spn="Cell C"/> +<spnOverride numeric="65510" spn="MTN-SA"/> +<spnOverride numeric="70267" spn="BTL"/> +<spnOverride numeric="70401" spn="ClaroGTM"/> +<spnOverride numeric="70402" spn="COMCEL"/> +<spnOverride numeric="70403" spn="movistar"/> +<spnOverride numeric="70601" spn="CLARO SLV"/> +<spnOverride numeric="70602" spn="Digicel"/> +<spnOverride numeric="70603" spn="TELEMOVIL"/> +<spnOverride numeric="70604" spn="movistar"/> +<spnOverride numeric="70802" spn="CELTELHND"/> +<spnOverride numeric="70830" spn="HT - 200"/> +<spnOverride numeric="71021" spn="ClaroNIC"/> +<spnOverride numeric="71073" spn="ClaroNIC"/> +<spnOverride numeric="71200" spn="I.C.E. "/> +<spnOverride numeric="71201" spn="I.C.E. "/> +<spnOverride numeric="71202" spn="I.C.E. "/> +<spnOverride numeric="71401" spn="PANCW"/> +<spnOverride numeric="71403" spn="CLARO PA"/> +<spnOverride numeric="71606" spn="movistar"/> +<spnOverride numeric="71610" spn="CLARO PER"/> +<spnOverride numeric="71617" spn="NXT3"/> +<spnOverride numeric="72207" spn="movistar"/> +<spnOverride numeric="72234" spn="AR TP"/> +<spnOverride numeric="72236" spn="Telecom Personal SA"/> +<spnOverride numeric="72402" spn="TIM BRASIL"/> +<spnOverride numeric="72403" spn="TIM BRASIL"/> +<spnOverride numeric="72404" spn="TIM BRASIL"/> +<spnOverride numeric="72405" spn="Claro"/> +<spnOverride numeric="72406" spn="VIVO"/> +<spnOverride numeric="72410" spn="VIVO"/> +<spnOverride numeric="72411" spn="VIVO"/> +<spnOverride numeric="72415" spn="Sercomtel"/> +<spnOverride numeric="72416" spn="Oi"/> +<spnOverride numeric="72423" spn="VIVO"/> +<spnOverride numeric="72424" spn="AMAZONIA"/> +<spnOverride numeric="72431" spn="Oi"/> +<spnOverride numeric="72432" spn="CTBC"/> +<spnOverride numeric="72433" spn="CTBC"/> +<spnOverride numeric="72434" spn="CTBC"/> +<spnOverride numeric="73001" spn="ENTEL"/> +<spnOverride numeric="73002" spn="movistar"/> +<spnOverride numeric="73003" spn="CLARO CHL"/> +<spnOverride numeric="73008" spn="VTR"/> +<spnOverride numeric="73009" spn="Nextel"/> +<spnOverride numeric="73010" spn="ENTEL"/> +<spnOverride numeric="73401" spn="DIGITEL "/> +<spnOverride numeric="73402" spn="DIGITEL "/> +<spnOverride numeric="73403" spn="DIGITEL "/> +<spnOverride numeric="73404" spn="movistar"/> +<spnOverride numeric="73406" spn="Movilnet"/> +<spnOverride numeric="73601" spn="VIVA"/> +<spnOverride numeric="73602" spn="EMOVIL"/> +<spnOverride numeric="73603" spn="Telecel"/> +<spnOverride numeric="73801" spn="DIGICEL"/> +<spnOverride numeric="74000" spn="movistar"/> +<spnOverride numeric="74001" spn="PORTA GSM"/> +<spnOverride numeric="74401" spn="VOX"/> +<spnOverride numeric="74402" spn="CLARO PY"/> +<spnOverride numeric="74404" spn="Telecel"/> +<spnOverride numeric="74405" spn="Personal"/> +<spnOverride numeric="74602" spn="TeleG"/> +<spnOverride numeric="74603" spn="DIGICEL"/> +<spnOverride numeric="74604" spn="UNIQA"/> +<spnOverride numeric="74807" spn="Movistar"/> +<spnOverride numeric="74810" spn="CLARO UY"/> +<spnOverride numeric="79502" spn="TM CELL"/> +<spnOverride numeric="90105" spn="Thuraya"/> +<spnOverride numeric="90106" spn="Thuraya"/> +<spnOverride numeric="90112" spn="MCP"/> +<spnOverride numeric="90114" spn="AeroMob"/> +<spnOverride numeric="90115" spn="OnAir"/> +<spnOverride numeric="90117" spn="Navitas"/> +<spnOverride numeric="90118" spn="WMS"/> +<spnOverride numeric="90121" spn="Seanet"/> +<spnOverride numeric="284001" spn="M-Tel"/> +<spnOverride numeric="302220" spn="TELUS"/> +<spnOverride numeric="302350" spn="FIRST"/> +<spnOverride numeric="302370" spn="Fido"/> +<spnOverride numeric="302380" spn="DMTS"/> +<spnOverride numeric="302490" spn="WIND"/> +<spnOverride numeric="302610" spn="Bell"/> +<spnOverride numeric="302654" spn="SaskTel Mobility"/> +<spnOverride numeric="302660" spn="MTS "/> +<spnOverride numeric="302702" spn="MT&T Mobility"/> +<spnOverride numeric="302703" spn="NewTel Mobility"/> +<spnOverride numeric="302720" spn="ROGERS"/> +<spnOverride numeric="302730" spn="TStarSol"/> +<spnOverride numeric="310000" spn="NEP Wireless"/> +<spnOverride numeric="310002" spn="NEP Wireless"/> +<spnOverride numeric="310009" spn="NEP Wireless"/> +<spnOverride numeric="310010" spn="Verizon"/> +<spnOverride numeric="310016" spn="Cricket"/> +<spnOverride numeric="310020" spn="UnionTel"/> +<spnOverride numeric="310030" spn="CENT USA"/> +<spnOverride numeric="310032" spn="IT E"/> +<spnOverride numeric="310050" spn="ACS Wireless"/> +<spnOverride numeric="310070" spn="Cingular Wireless"/> +<spnOverride numeric="310080" spn="Corr"/> +<spnOverride numeric="310090" spn="Edge"/> +<spnOverride numeric="310100" spn="PLATEAU"/> +<spnOverride numeric="310120" spn="Sprint"/> +<spnOverride numeric="310130" spn="Carolina West Wireless"/> +<spnOverride numeric="310140" spn="GTA Wireless"/> +<spnOverride numeric="310150" spn="AT&T"/> +<spnOverride numeric="310160" spn="T-Mobile "/> +<spnOverride numeric="310170" spn="AT&T"/> +<spnOverride numeric="310180" spn="West Central Wireless"/> +<spnOverride numeric="310190" spn="D-HARBOR"/> +<spnOverride numeric="310200" spn="T-Mobile "/> +<spnOverride numeric="310210" spn="T-Mobile "/> +<spnOverride numeric="310220" spn="T-Mobile "/> +<spnOverride numeric="310230" spn="T-Mobile "/> +<spnOverride numeric="310240" spn="T-Mobile "/> +<spnOverride numeric="310250" spn="T-Mobile "/> +<spnOverride numeric="310260" spn="T-Mobile "/> +<spnOverride numeric="310260" spn="T-Mobile "/> +<spnOverride numeric="310270" spn="T-Mobile "/> +<spnOverride numeric="310300" spn="BigSkyUS"/> +<spnOverride numeric="310310" spn="T-Mobile "/> +<spnOverride numeric="310320" spn="Cell"/> +<spnOverride numeric="310330" spn="Cell One"/> +<spnOverride numeric="310340" spn="WestLink"/> +<spnOverride numeric="310350" spn="Mohave Cellular"/> +<spnOverride numeric="310380" spn="AT&T"/> +<spnOverride numeric="310390" spn="CELL 1 ET"/> +<spnOverride numeric="310400" spn="iCAN_GSM"/> +<spnOverride numeric="310410" spn="AT&T"/> +<spnOverride numeric="310420" spn="CBW"/> +<spnOverride numeric="310450" spn="NECCI"/> +<spnOverride numeric="310460" spn="SIMMETRY"/> +<spnOverride numeric="310470" spn="DOCOMOPA"/> +<spnOverride numeric="310490" spn="T-Mobile USA"/> +<spnOverride numeric="310500" spn="Alltel"/> +<spnOverride numeric="310530" spn="IWS"/> +<spnOverride numeric="310540" spn="Oklahoma Western Telephone"/> +<spnOverride numeric="310570" spn="Chinook"/> +<spnOverride numeric="310590" spn="ROAMING"/> +<spnOverride numeric="310630" spn="AMERLINK"/> +<spnOverride numeric="310640" spn="ARDGMC"/> +<spnOverride numeric="310650" spn="Jasper"/> +<spnOverride numeric="310660" spn="T-Mobile "/> +<spnOverride numeric="310690" spn="IMMIX"/> +<spnOverride numeric="310700" spn="BIGFOOT"/> +<spnOverride numeric="310710" spn="ASTAC"/> +<spnOverride numeric="310730" spn="U.S.Cellular"/> +<spnOverride numeric="310740" spn="OTZ"/> +<spnOverride numeric="310770" spn="IWS"/> +<spnOverride numeric="310790" spn="Pinpoint"/> +<spnOverride numeric="310860" spn="Five Star Wireless"/> +<spnOverride numeric="310870" spn="PACE"/> +<spnOverride numeric="310880" spn="ACSIAC"/> +<spnOverride numeric="310890" spn="UNICEL"/> +<spnOverride numeric="310950" spn="XIT"/> +<spnOverride numeric="310980" spn="AT&T"/> +<spnOverride numeric="311000" spn="Mid-Tex"/> +<spnOverride numeric="311030" spn="Indigo"/> +<spnOverride numeric="311040" spn="Commnet"/> +<spnOverride numeric="311050" spn="Thumb Cellular"/> +<spnOverride numeric="311080" spn="PINECell"/> +<spnOverride numeric="311090" spn="SXLP"/> +<spnOverride numeric="311130" spn="Amarillo Cellular"/> +<spnOverride numeric="311150" spn="Wilkes Cellular"/> +<spnOverride numeric="311170" spn="PetroCom"/> +<spnOverride numeric="311180" spn="AT&T"/> +<spnOverride numeric="311190" spn="C1ECI"/> +<spnOverride numeric="311210" spn="FARMERS"/> +<spnOverride numeric="311240" spn="CWCI"/> +<spnOverride numeric="311260" spn="SLO Cellular"/> +<spnOverride numeric="311310" spn="LamarCel"/> +<spnOverride numeric="311330" spn="BTW"/> +<spnOverride numeric="311350" spn="Sagebrush Cellular"/> +<spnOverride numeric="311360" spn="STELERA"/> +<spnOverride numeric="311370" spn="GCI"/> +<spnOverride numeric="311420" spn="Northwest Missouri Cellular"/> +<spnOverride numeric="311430" spn="Cellular 29 Plus"/> +<spnOverride numeric="311440" spn="Bluegrass Cellular"/> +<spnOverride numeric="311500" spn="MOSAIC"/> +<spnOverride numeric="311530" spn="NCW"/> +<spnOverride numeric="311540" spn="ProxMo"/> +<spnOverride numeric="311590" spn="Golden State Cellular"/> +<spnOverride numeric="311720" spn="MainePCS"/> +<spnOverride numeric="330110" spn="Claro"/> +<spnOverride numeric="334020" spn="TELCEL"/> +<spnOverride numeric="334030" spn="movistar"/> +<spnOverride numeric="334050" spn="Iusacell"/> +<spnOverride numeric="334090" spn="Nextel"/> +<spnOverride numeric="338050" spn="Digicel"/> +<spnOverride numeric="338070" spn="ClaroJam"/> +<spnOverride numeric="338180" spn="C W"/> +<spnOverride numeric="342600" spn="C W"/> +<spnOverride numeric="342750" spn="DIGICEL"/> +<spnOverride numeric="344030" spn="APUA-PCS"/> +<spnOverride numeric="344920" spn="C W"/> +<spnOverride numeric="344930" spn="Cingular"/> +<spnOverride numeric="346140" spn="LIME"/> +<spnOverride numeric="348170" spn="C W"/> +<spnOverride numeric="348570" spn="CCTBVI"/> +<spnOverride numeric="350000" spn="CellularOne"/> +<spnOverride numeric="350010" spn="Cingular"/> +<spnOverride numeric="352030" spn="DIGICEL"/> +<spnOverride numeric="352110" spn="C W"/> +<spnOverride numeric="354860" spn="LIME"/> +<spnOverride numeric="356110" spn="LIME"/> +<spnOverride numeric="358050" spn="DIGICEL"/> +<spnOverride numeric="358110" spn="C W"/> +<spnOverride numeric="360070" spn="DIGICEL"/> +<spnOverride numeric="360110" spn="C W"/> +<spnOverride numeric="362951" spn="CHIPPIE"/> +<spnOverride numeric="365840" spn="C W"/> +<spnOverride numeric="366020" spn="Cingular"/> +<spnOverride numeric="366110" spn="C W"/> +<spnOverride numeric="376350" spn="C W"/> +<spnOverride numeric="376352" spn="ICOM TCI"/> +<spnOverride numeric="376360" spn="ICOM TCI"/> +<spnOverride numeric="404030" spn="Vodafone"/> +<spnOverride numeric="405025" spn="TATA DOCOMO"/> +<spnOverride numeric="405027" spn="TATA DOCOMO"/> +<spnOverride numeric="405029" spn="TATA DOCOMO"/> +<spnOverride numeric="405030" spn="TATA DOCOMO"/> +<spnOverride numeric="405031" spn="TATA DOCOMO"/> +<spnOverride numeric="405032" spn="TATA DOCOMO"/> +<spnOverride numeric="405034" spn="TATA DOCOMO"/> +<spnOverride numeric="405035" spn="TATA DOCOMO"/> +<spnOverride numeric="405036" spn="TATA DOCOMO"/> +<spnOverride numeric="405037" spn="TATA DOCOMO"/> +<spnOverride numeric="405038" spn="TATA DOCOMO"/> +<spnOverride numeric="405039" spn="TATA DOCOMO"/> +<spnOverride numeric="405041" spn="TATA DOCOMO"/> +<spnOverride numeric="405042" spn="TATA DOCOMO"/> +<spnOverride numeric="405043" spn="TATA DOCOMO"/> +<spnOverride numeric="405044" spn="TATA DOCOMO"/> +<spnOverride numeric="405045" spn="TATA DOCOMO"/> +<spnOverride numeric="405046" spn="TATA DOCOMO"/> +<spnOverride numeric="405047" spn="TATA DOCOMO"/> +<spnOverride numeric="405750" spn="Vodafone"/> +<spnOverride numeric="405751" spn="Vodafone"/> +<spnOverride numeric="405752" spn="Vodafone"/> +<spnOverride numeric="405753" spn="Vodafone"/> +<spnOverride numeric="405754" spn="Vodafone"/> +<spnOverride numeric="405755" spn="Vodafone"/> +<spnOverride numeric="405756" spn="Vodafone"/> +<spnOverride numeric="405799" spn="IDEA"/> +<spnOverride numeric="405800" spn="Aircel"/> +<spnOverride numeric="405801" spn="Aircel"/> +<spnOverride numeric="405802" spn="Aircel"/> +<spnOverride numeric="405803" spn="Aircel"/> +<spnOverride numeric="405804" spn="Aircel"/> +<spnOverride numeric="405805" spn="Aircel"/> +<spnOverride numeric="405806" spn="Aircel"/> +<spnOverride numeric="405807" spn="Aircel"/> +<spnOverride numeric="405808" spn="Aircel"/> +<spnOverride numeric="405809" spn="Aircel "/> +<spnOverride numeric="405810" spn="Aircel"/> +<spnOverride numeric="405811" spn="Aircel"/> +<spnOverride numeric="405812" spn="Aircel"/> +<spnOverride numeric="405813" spn="uninor"/> +<spnOverride numeric="405814" spn="uninor"/> +<spnOverride numeric="405815" spn="uninor"/> +<spnOverride numeric="405816" spn="uninor"/> +<spnOverride numeric="405817" spn="uninor"/> +<spnOverride numeric="405818" spn="uninor"/> +<spnOverride numeric="405819" spn="uninor"/> +<spnOverride numeric="405820" spn="uninor"/> +<spnOverride numeric="405821" spn="uninor"/> +<spnOverride numeric="405822" spn="uninor"/> +<spnOverride numeric="405823" spn="Videocon"/> +<spnOverride numeric="405824" spn="Videocon"/> +<spnOverride numeric="405825" spn="Videocon"/> +<spnOverride numeric="405827" spn="Videocon"/> +<spnOverride numeric="405827" spn="Videocon"/> +<spnOverride numeric="405828" spn="Videocon"/> +<spnOverride numeric="405829" spn="Videocon"/> +<spnOverride numeric="405830" spn="Videocon"/> +<spnOverride numeric="405831" spn="Videocon"/> +<spnOverride numeric="405832" spn="Videocon"/> +<spnOverride numeric="405833" spn="Videocon"/> +<spnOverride numeric="405834" spn="Videocon"/> +<spnOverride numeric="405835" spn="Videocon"/> +<spnOverride numeric="405836" spn="Videocon"/> +<spnOverride numeric="405837" spn="Videocon"/> +<spnOverride numeric="405838" spn="Videocon"/> +<spnOverride numeric="405839" spn="Videocon"/> +<spnOverride numeric="405840" spn="Videocon"/> +<spnOverride numeric="405840" spn="Videocon"/> +<spnOverride numeric="405841" spn="Videocon"/> +<spnOverride numeric="405842" spn="Videocon"/> +<spnOverride numeric="405843" spn="Videocon"/> +<spnOverride numeric="405844" spn="uninor"/> +<spnOverride numeric="405845" spn="IDEA"/> +<spnOverride numeric="405846" spn="IDEA"/> +<spnOverride numeric="405848" spn="IDEA"/> +<spnOverride numeric="405849" spn="IDEA"/> +<spnOverride numeric="405850" spn="IDEA"/> +<spnOverride numeric="405852" spn="IDEA"/> +<spnOverride numeric="405853" spn="IDEA"/> +<spnOverride numeric="405854" spn="LoopMobile"/> +<spnOverride numeric="405855" spn="LoopMobile"/> +<spnOverride numeric="405856" spn="LoopMobile"/> +<spnOverride numeric="405857" spn="LoopMobile"/> +<spnOverride numeric="405858" spn="LoopMobile"/> +<spnOverride numeric="405859" spn="LoopMobile"/> +<spnOverride numeric="405860" spn="LoopMobile"/> +<spnOverride numeric="405861" spn="LoopMobile"/> +<spnOverride numeric="405862" spn="LoopMobile"/> +<spnOverride numeric="405863" spn="LoopMobile"/> +<spnOverride numeric="405864" spn="LoopMobile"/> +<spnOverride numeric="405865" spn="LoopMobile"/> +<spnOverride numeric="405866" spn="LoopMobile"/> +<spnOverride numeric="405867" spn="LoopMobile"/> +<spnOverride numeric="405868" spn="LoopMobile"/> +<spnOverride numeric="405869" spn="LoopMobile"/> +<spnOverride numeric="405870" spn="LoopMobile"/> +<spnOverride numeric="405871" spn="LoopMobile"/> +<spnOverride numeric="405872" spn="LoopMobile"/> +<spnOverride numeric="405873" spn="LoopMobile"/> +<spnOverride numeric="405874" spn="LoopMobile"/> +<spnOverride numeric="405875" spn="uninor"/> +<spnOverride numeric="405876" spn="uninor"/> +<spnOverride numeric="405877" spn="uninor"/> +<spnOverride numeric="405878" spn="uninor"/> +<spnOverride numeric="405879" spn="uninor"/> +<spnOverride numeric="405880" spn="uninor"/> +<spnOverride numeric="405881" spn="STEL"/> +<spnOverride numeric="405882" spn="STEL"/> +<spnOverride numeric="405883" spn="STEL"/> +<spnOverride numeric="405884" spn="STEL"/> +<spnOverride numeric="405885" spn="STEL"/> +<spnOverride numeric="405886" spn="STEL"/> +<spnOverride numeric="405912" spn="Cheers"/> +<spnOverride numeric="405913" spn="Cheers"/> +<spnOverride numeric="405914" spn="Cheers"/> +<spnOverride numeric="405915" spn="Cheers"/> +<spnOverride numeric="405916" spn="Cheers"/> +<spnOverride numeric="405917" spn="Cheers"/> +<spnOverride numeric="405918" spn="Cheers"/> +<spnOverride numeric="405919" spn="Cheers"/> +<spnOverride numeric="405920" spn="Cheers"/> +<spnOverride numeric="405921" spn="Cheers"/> +<spnOverride numeric="405922" spn="Cheers"/> +<spnOverride numeric="405923" spn="Cheers"/> +<spnOverride numeric="405924" spn="Cheers"/> +<spnOverride numeric="405925" spn="uninor"/> +<spnOverride numeric="405926" spn="uninor"/> +<spnOverride numeric="405927" spn="uninor"/> +<spnOverride numeric="405928" spn="uninor"/> +<spnOverride numeric="405929" spn="uninor"/> +<spnOverride numeric="405932" spn="Videocon"/> +<spnOverride numeric="420003" spn="mobily"/> +<spnOverride numeric="421700" spn="YemYY"/> +<spnOverride numeric="472002" spn="WATANIYA"/> +<spnOverride numeric="510510" spn="Mobile-8"/> +<spnOverride numeric="537030" spn="Digicel"/> +<spnOverride numeric="544110" spn="BLUESKY"/> +<spnOverride numeric="616004" spn="BBCOM"/> +<spnOverride numeric="654001" spn="HURI"/> +<spnOverride numeric="704030" spn="movistar"/> +<spnOverride numeric="708001" spn="ClaroHND"/> +<spnOverride numeric="708030" spn="HND"/> +<spnOverride numeric="710300" spn="movistar"/> +<spnOverride numeric="714020" spn="movistar"/> +<spnOverride numeric="722070" spn="Movistar"/> +<spnOverride numeric="722310" spn="CLARO AR"/> +<spnOverride numeric="722340" spn="AR PERSONAL"/> +<spnOverride numeric="732101" spn="COMCEL"/> +<spnOverride numeric="732102" spn="COL_TEMC"/> +<spnOverride numeric="732103" spn="TIGO COL"/> +<spnOverride numeric="732111" spn="TIGO COL"/> +<spnOverride numeric="732123" spn="movistar"/> +<spnOverride numeric="738002" spn="CLNK PLS"/> +<spnOverride numeric="750001" spn="C W FLK"/> +</spnOverrides> diff --git a/configs/wide-dhcpv6/dhcp6c.conf b/configs/wide-dhcpv6/dhcp6c.conf new file mode 100644 index 0000000..820dc86 --- /dev/null +++ b/configs/wide-dhcpv6/dhcp6c.conf @@ -0,0 +1,11 @@ + +interface wlan0 { + send ia-na 234883274; + # information-only; + request domain-name-servers; + request domain-name; + script "/etc/wide-dhcpv6/dhcp6c.script"; +}; + +id-assoc na 234883274{ +}; diff --git a/configs/wide-dhcpv6/dhcp6c.script b/configs/wide-dhcpv6/dhcp6c.script new file mode 100644 index 0000000..ebd9347 --- /dev/null +++ b/configs/wide-dhcpv6/dhcp6c.script @@ -0,0 +1,61 @@ +#!/system/bin/sh + +# Set dhcp.ipv6.<iface>.dnsN properties that contain the +# DNS server addresses given by the DHCPv6 server. +set_dns_props() +{ + case "${new_domain_name_servers}" in + "") return 0;; + esac + + count=1 + for i in 1 2; do + setprop dhcp.ipv6.${interface}.dns${i} "" + done + + count=1 + for dnsaddr in ${new_domain_name_servers}; do + case "$count" in + 1|2) + setprop dhcp.ipv6.${interface}.dns${count} ${dnsaddr} + ;; + esac + count=$(($count + 1)) + done +} + +unset_dns_props() +{ + for i in 1 2; do + setprop dhcp.ipv6.${interface}.dns${i} "" + setprop net.dns.ipv6_${i} "" + done +} + +unset_iana_props() +{ + setprop dhcp.ipv6.${interface}.leasetime "" + setprop dhcp.ipv6.${interface}.ipaddress "" +} + +# For debugging: +setprop dhcp.ipv6.${interface}.reason "${REASON}" + +case "${REASON}" in + REQUEST|CONFIRM|INFOREQ) + set_dns_props + setprop dhcp.ipv6.${interface}.result "ok" + ;; + RENEW|REBIND) + set_dns_props + setprop dhcp.ipv6.${interface}.renewresult "ok" + ;; + RELEASE) + unset_dns_props + unset_iana_props + setprop dhcp.ipv6.${interface}.result "released" + ;; + *) + setprop dhcp.ipv6.${interface}.result "failed" + ;; +esac diff --git a/configs/wide-dhcpv6/dhcp6cDNS.conf b/configs/wide-dhcpv6/dhcp6cDNS.conf new file mode 100644 index 0000000..b4e0ee8 --- /dev/null +++ b/configs/wide-dhcpv6/dhcp6cDNS.conf @@ -0,0 +1,7 @@ + +interface wlan0 { + request domain-name-servers; + request domain-name; + information-only; + script "/etc/wide-dhcpv6/dhcp6c.script"; +}; diff --git a/configs/wide-dhcpv6/dhcp6cPD.conf b/configs/wide-dhcpv6/dhcp6cPD.conf new file mode 100644 index 0000000..86662f1 --- /dev/null +++ b/configs/wide-dhcpv6/dhcp6cPD.conf @@ -0,0 +1,9 @@ + +interface wlan0 { + # information-only; + script "/etc/wide-dhcpv6/dhcp6cPD.script"; + send ia-pd 1234; +}; + +id-assoc pd 1234 { +}; diff --git a/configs/wide-dhcpv6/dhcp6cPD.script b/configs/wide-dhcpv6/dhcp6cPD.script new file mode 100644 index 0000000..f57f43c --- /dev/null +++ b/configs/wide-dhcpv6/dhcp6cPD.script @@ -0,0 +1,20 @@ +#!/system/bin/sh + +# For debugging: +setprop dhcp.pd.${interface}.reason "${REASON}" + +case "${REASON}" in + REQUEST|CONFIRM|INFOREQ) + setprop dhcp.pd.${interface}.result "ok" + ;; + RENEW|REBIND) + set_dns_props + setprop dhcp.pd.${interface}.renewresult "ok" + ;; + RELEASE) + setprop dhcp.pd.${interface}.result "released" + ;; + *) + setprop dhcp.pd.${interface}.result "failed" + ;; +esac diff --git a/configs/wide-dhcpv6/dhcp6cctlkey b/configs/wide-dhcpv6/dhcp6cctlkey new file mode 100644 index 0000000..3f75992 --- /dev/null +++ b/configs/wide-dhcpv6/dhcp6cctlkey @@ -0,0 +1 @@ +i7srdxZshUB7sGd2Ln1w4Q== diff --git a/configs/wide-dhcpv6/dhcp6s.conf b/configs/wide-dhcpv6/dhcp6s.conf new file mode 100644 index 0000000..1ada17e --- /dev/null +++ b/configs/wide-dhcpv6/dhcp6s.conf @@ -0,0 +1,9 @@ +# The followings are a sample configuration to provide an IPv6 address +# from an address pool 2001:db8:1:2::1000-2000 for 3600[s]. +# Note. You have to send an RA to fxp0; otherwise a client cannot be sure +# about the prefix-length and the default router. If you want to prevent +# stateless address configuration via RA, please set the autonomous-flag to +# OFF in your RA configuration. + +option domain-name-servers 2001:4860:4860::8888; +option domain-name-servers 2001:4860:4860::8844; diff --git a/copy-files.sh b/copy-files.sh new file mode 100755 index 0000000..74f8d69 --- /dev/null +++ b/copy-files.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +SYSDIR=$1 +if [ "x$SYSDIR" = "x" ]; then +echo "You must specify system directory as first argument"; +exit +fi + +VENDOR=meizu +DEVICE=m2note + +BASE=../../../vendor/$VENDOR/$DEVICE/proprietary + +rm -rf $BASE/* + +for FILE in `cat proprietary-files.txt | grep -v ^# | grep -v ^$`; do + DIR=`dirname $FILE` + if [ ! -d $BASE/$DIR ]; then + mkdir -p $BASE/$DIR + fi + cp $SYSDIR/$FILE $BASE/$FILE +done + +./setup-makefiles.sh diff --git a/device_m2note.mk b/device_m2note.mk new file mode 100644 index 0000000..295d7c8 --- /dev/null +++ b/device_m2note.mk @@ -0,0 +1,52 @@ +# +# Copyright (C) 2015-2016 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. +# + +# Screen density +# Device uses high-density artwork where available +PRODUCT_AAPT_CONFIG := normal +PRODUCT_AAPT_PREF_CONFIG := xxhdpi + +# Lots of fonts +EXTENDED_FONT_FOOTPRINT := true +USE_MINIKIN := true + +# Device specific overlays +DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay + +# Device product elements +include $(LOCAL_PATH)/product/*.mk + +# Dalvik heap configurations +$(call inherit-product-if-exists, frameworks/native/build/phone-xxhdpi-2048-dalvik-heap.mk) + +# Call hwui memory config +$(call inherit-product-if-exists, frameworks/native/build/phone-xxhdpi-2048-hwui-memory.mk) + +# Product common configurations +$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk) + +# Vendor product configurations +$(call inherit-product-if-exists, vendor/meizu/m2note/m2note-vendor.mk) + +# The gps config appropriate for this device +$(call inherit-product, device/common/gps/gps_us_supl.mk) + +# SELinux +BOARD_SEPOLICY_DIRS := \ + $(LOCAL_PATH)/sepolicy + diff --git a/extract-files.sh b/extract-files.sh new file mode 100755 index 0000000..b3aaf54 --- /dev/null +++ b/extract-files.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +VENDOR=meizu +DEVICE=m2note + +BASE=../../../vendor/$VENDOR/$DEVICE/proprietary + +echo "Pulling $DEVICE files..." +for FILE in `cat proprietary-files.txt | grep -v ^# | grep -v ^$`; do + DIR=`dirname $FILE` + if [ ! -d $BASE/$DIR ]; then + mkdir -p $BASE/$DIR + fi + adb pull /system/$FILE $BASE/$FILE +done + +./setup-makefiles.sh diff --git a/include/cutils/alelog.h b/include/cutils/alelog.h new file mode 100644 index 0000000..294c7a9 --- /dev/null +++ b/include/cutils/alelog.h @@ -0,0 +1,59 @@ +#if !defined(__ALE_H__) +#define __ALE_H__ + +#if defined(__cplusplus) +extern "C" { +#endif + +#define LOGGER_ALE_MASK 0xf0 + +#define LOGGER_ALE_MSG_RAW 0x00 +#define LOGGER_ALE_MSG_K 0x10 +#define LOGGER_ALE_MSG_N 0x20 +#define LOGGER_ALE_MSG_J 0x30 +#define LOGGER_ALE_XMSG_K 0x40 +#define LOGGER_ALE_XMSG_N 0x50 +#define LOGGER_ALE_XMSG_J 0x60 + +#define LOGGER_ALE_MSG_SIZE 768 + +#define LOGGER_ALE_ARGS_MAX 16 +struct ale_convert { + const char *tag_str; + const char *fmt_ptr; + const char *file; + int lineno; + unsigned int hash; + char params[LOGGER_ALE_ARGS_MAX]; +}; + +int ale_log_output_binary(int prio, const char *tag, const void *payload, size_t len); + +int ale_log_output(int bufid, int prio, const struct ale_convert *convert, ...); + +#define ale_log_print(bufid, prio, tag, fmt, ...) \ + ({ \ + if (__builtin_constant_p(tag) && __builtin_constant_p(fmt)) { \ + static const struct ale_convert ____ale_rec____ = \ + { \ + __builtin_constant_p(tag) ? tag : NULL, \ + __builtin_constant_p(fmt) ? fmt : NULL, \ + __FILE__, \ + __builtin_constant_p(prio) ? prio : 0, \ + 0, \ + "" }; \ + ale_log_output(bufid, prio, &____ale_rec____, ##__VA_ARGS__); \ + } \ + else { \ + struct ale_convert ale = \ + {tag, fmt, NULL, \ + 0, 0, ""}; \ + ale_log_output(bufid, prio, &ale, ##__VA_ARGS__); \ + } \ + }) + +#if defined(__cplusplus) +}; +#endif + +#endif diff --git a/include/cutils/xlog.h b/include/cutils/xlog.h new file mode 100644 index 0000000..a8089b7 --- /dev/null +++ b/include/cutils/xlog.h @@ -0,0 +1,185 @@ +#if !defined(_XLOG_H) +#define _XLOG_H + +#include <cutils/log.h> +#include <cutils/alelog.h> + +#ifdef __cplusplus +extern "C" { +#endif + +int xlogf_java_tag_is_on(const char *name, int level); +int xlogf_native_tag_is_on(const char *name, int level); + +int xlogf_java_xtag_is_on(const char *name, int level); +int xlogf_native_xtag_is_on(const char *name, int level); + +#ifndef XLOG_TAG +#define XLOG_TAG NULL +#endif + +#ifndef SXLOGV +#define SXLOGV(...) ((void)SXLOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGD +#define SXLOGD(...) ((void)SXLOG_PRI(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGI +#define SXLOGI(...) ((void)SXLOG_PRI(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGW +#define SXLOGW(...) ((void)SXLOG_PRI(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGE +#define SXLOGE(...) ((void)SXLOG_PRI(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGF +#define SXLOGF(...) ((void)SXLOG_PRI(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__)) +#endif +#if LOG_NDEBUG +#define SXLOG_ASSERT(cond, ...) \ + ( (CONDITION(cond)) \ + ? ((void)SXLOGF(LOG_TAG, __VA_ARGS__)) \ + : (void)0 ) +#else +#define SXLOG_ASSERT(cond, ...) ((void)0) +#endif + +#define SXLOG_ALWAYS_ASSERT(cond,...) \ + ( (CONDITION(cond)) \ + ? ((void)SXLOGF(LOG_TAG, __VA_ARGS__)) \ + : (void)0 ) + +#ifndef XLOGV +#define XLOGV(...) ((void)XLOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGD +#define XLOGD(...) ((void)XLOG_PRI(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGI +#define XLOGI(...) ((void)XLOG_PRI(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGW +#define XLOGW(...) ((void)XLOG_PRI(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGE +#define XLOGE(...) ((void)XLOG_PRI(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGF +#define XLOGF(...) ((void)XLOG_PRI(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__)) +#endif + +#if LOG_NDEBUG +#define XLOG_ASSERT(cond, ...) \ + (!(cond) \ + ? ((void)XLOGF(__VA_ARGS__)) \ + : (void)0) +#else +#define XLOG_ASSERT(cond, ...) ((void)0) +#endif + +#define XLOG_ALWAY_ASSERT(cond, ...) \ + (!(cond) \ + ? ((void)XLOGF(__VA_ARGS__)) \ + : (void)0) + + +#ifndef SXLOGV2 +#define SXLOGV2(...) ((void)SXLOG_PRI(ANDROID_LOG_VERBOSE, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGD2 +#define SXLOGD2(...) ((void)SXLOG_PRI(ANDROID_LOG_DEBUG, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGI2 +#define SXLOGI2(...) ((void)SXLOG_PRI(ANDROID_LOG_INFO, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGW2 +#define SXLOGW2(...) ((void)SXLOG_PRI(ANDROID_LOG_WARN, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGE2 +#define SXLOGE2(...) ((void)SXLOG_PRI(ANDROID_LOG_ERROR, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef SXLOGF2 +#define SXLOGF2(...) ((void)SXLOG_PRI(ANDROID_LOG_FATAL, XLOG_TAG, __VA_ARGS__)) +#endif + +#ifndef XLOGV2 +#define XLOGV2(...) ((void)XLOG_PRI(ANDROID_LOG_VERBOSE, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGD2 +#define XLOGD2(...) ((void)XLOG_PRI(ANDROID_LOG_DEBUG, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGI2 +#define XLOGI2(...) ((void)XLOG_PRI(ANDROID_LOG_INFO, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGW2 +#define XLOGW2(...) ((void)XLOG_PRI(ANDROID_LOG_WARN, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGE2 +#define XLOGE2(...) ((void)XLOG_PRI(ANDROID_LOG_ERROR, XLOG_TAG, __VA_ARGS__)) +#endif +#ifndef XLOGF2 +#define XLOGF2(...) ((void)XLOG_PRI(ANDROID_LOG_FATAL, XLOG_TAG, __VA_ARGS__)) +#endif + +struct xlog_record { + const char *tag_str; + const char *fmt_str; + int prio; +}; + +#if defined(__cplusplus) +extern "C" { +#endif + +int __xlog_buf_printf(int bufid, const struct xlog_record *rec, ...); + +#if defined(__cplusplus) +} +#endif + +#if !defined(HAVE_ALE_FEATURE) + +#define xlog_buf_printf(bufid, prio, tag, fmt, ...) \ + ({ \ + static const struct xlog_record _xlog_rec = \ + {tag, fmt, prio}; \ + __xlog_buf_printf(bufid, &_xlog_rec, ##__VA_ARGS__); \ + }) + +#else + +#define xlog_buf_printf(bufid, prio, tag, fmt, ...) \ + ({ \ + static const struct ale_convert ____xlog_ale_rec____ = \ + { tag, fmt, __FILE__, prio, 0, "" }; \ + ale_log_output(bufid, prio, &____xlog_ale_rec____, \ + ##__VA_ARGS__); \ + }) + +#endif + +#ifdef HAVE_XLOG_FEATURE +#define XLOG_PRI(priority, tag, ...) \ + xlog_buf_printf(LOG_ID_MAIN, priority, tag, __VA_ARGS__) + +#define SXLOG_PRI(priority, tag, ...) \ + xlog_buf_printf(LOG_ID_MAIN, priority, tag, __VA_ARGS__) + +#define xlog_printf(priority, tag, ...) \ + xlog_buf_printf(LOG_ID_MAIN, priority, tag, __VA_ARGS__) + +#define sxlog_printf(priority, tag, ...) \ + xlog_buf_printf(LOG_ID_SYSTEM, priority, tag, __VA_ARGS__) +#else //HAVE_XLOG_FEATURE +#define XLOG_PRI(priority, tag, ...) ((void)0) +#define SXLOG_PRI(priority, tag, ...) ((void)0) +#define xlog_printf(priority, tag, ...) ((void)0) +#define sxlog_printf(priority, tag, ...) ((void)0) +#endif //HAVE_XLOG_FEATURE + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/kernel-headers/bits_api.h b/kernel-headers/bits_api.h new file mode 100644 index 0000000..845b6d1 --- /dev/null +++ b/kernel-headers/bits_api.h @@ -0,0 +1,314 @@ +#ifndef _BITS_API_H_ +#define _BITS_API_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" +#include "hal_api.h" + +typedef VAL_UINT32_T(*fgPrepare32FN)(VAL_HANDLE_T * a_phBitsHandle); + +/** + * @par Structure + * VBITS_HANDLE_T + * @par Description + * This is a parameter for bitstream parsing utility related function + */ +typedef struct __VBITS_HANDLE_T { + VAL_HANDLE_T hHALHandle; /* /< HAL Handle */ + VAL_HANDLE_T hVALHandle; /* /< VAL Handle */ + VAL_MEM_ADDR_T BitsStart; /* /< Bits Start */ + VAL_MEMORY_T rHandleMem; /* /< Handle memory */ + VAL_UINT32_T nReadingMode; /* /< 0 for software, 1 for mmap, 2 for hardware */ + VAL_ULONG_T StartAddr; /* /< used for software mode fast access */ + VAL_ULONG_T nSize; /* /< Size */ + VAL_UINT32_T nBitCnt; /* /< bits count */ + VAL_UINT32_T nZeroCnt; /* /< zero count */ + VAL_UINT32_T Cur32Bits; /* /< current 32 bits */ + VAL_UINT32_T CurBitCnt; /* /< current bits count */ + VAL_UINT32_T n03RemoveCount; /* /< 03 Remove Count */ + VAL_UINT32_T n03CountBit; /* /< 03 Count Bit */ + VAL_INT32_T n03FirstIndex; /* /< 03 First Index */ + VAL_INT32_T n03SecondIndex; /* /< 03 Second Index */ + VAL_UINT32_T n03RemoveIgnore; /* /< 03 Remove Ignore */ + VAL_BOOL_T bFirstCheck; /* /< First Check */ + VAL_BOOL_T bEverRemove; /* /< Ever Remove */ + VAL_BOOL_T bIgnoreByBS; /* /< Ignore By BS */ + VAL_BOOL_T bEOF; /* /< EOF */ + fgPrepare32FN Prepare32Bits; /* /< Prepare 32 Bits */ + VAL_DRIVER_TYPE_T vFormat; /* /< Format */ + VAL_UINT32_T value; /* /< value */ +} VBITS_HANDLE_T; + + +/** + * @par Enumeration + * VBITS_READTYPE_T + * @par Description + * This is the item used for bits read type + */ +typedef enum VBITS_READTYPE_T { + VBITS_SOFTWARE = 0, /* /< software */ + VBITS_MMAP, /* /< mmap */ + VBITS_HARDWARE, /* /< hardware */ + VBITS_MAX /* /< MAX value */ +} VBITS_READTYPE_T; +/*============================================================================= + * Function Declaration + *===========================================================================*/ + + +/** + * @par Function + * eBufEnable + * @par Description + * The hal init & HW enable function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * hHALHandle [IN/OUT] The hal handle + * @param + * nMode [IN] VBITS_READTYPE_T + * @param + * vFormat [IN] VAL_DRIVER_TYPE_T + * @par Returns + * VAL_UINT32_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_UINT32_T eBufEnable( + VAL_HANDLE_T *a_phBitsHandle, + VAL_HANDLE_T hHALHandle, + VAL_UINT32_T nMode, + VAL_DRIVER_TYPE_T vFormat +); + + +/** + * @par Function + * eBufEnable + * @par Description + * The HW disable function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * hHALHandle [IN/OUT] The hal handle + * @param + * nMode [IN] VBITS_READTYPE_T + * @param + * vFormat [IN] VAL_DRIVER_TYPE_T + * @par Returns + * VAL_UINT32_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_UINT32_T eBufDisable( + VAL_HANDLE_T *a_phBitsHandle, + VAL_HANDLE_T hHALHandle, + VAL_UINT32_T nMode, + VAL_DRIVER_TYPE_T vFormat +); + + +/** + * @par Function + * eBufInit + * @par Description + * The common init function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * hVALHandle [IN/OUT] The val handle + * @param + * hHALHandle [IN/OUT] The hal handle + * @param + * rBufAddrStart [IN] The buffer start address + * @param + * nMode [IN] VBITS_READTYPE_T + * @param + * vFormat [IN] VAL_DRIVER_TYPE_T + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return others if failed + */ +VAL_RESULT_T eBufInit( + VAL_HANDLE_T *a_phBitsHandle, + VAL_HANDLE_T hVALHandle, + VAL_HANDLE_T hHALHandle, + VAL_MEM_ADDR_T rBufAddrStart, + VAL_UINT32_T nMode, + VAL_DRIVER_TYPE_T vFormat +); + + +/** + * @par Function + * eBufDeinit + * @par Description + * The common deinit function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return others if failed + */ +VAL_RESULT_T eBufDeinit(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetBitCnt + * @par Description + * The function is used to get current bit count + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_UINT32_T, return current bit count + */ +VAL_UINT32_T eBufGetBitCnt(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetBits + * @par Description + * The function is used to get current bits by numBits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * numBits [IN] The number bits + * @par Returns + * VAL_UINT32_T, return current bits by numBits + */ +VAL_UINT32_T eBufGetBits(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T numBits); + + +/** + * @par Function + * eBufNextBits + * @par Description + * The function is used to show current bits by numBits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * numBits [IN] The number bits + * @par Returns + * VAL_UINT32_T, return current bits by numBits + */ +VAL_UINT32_T eBufNextBits(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T numBits); + + +/** + * @par Function + * eBufGetUEGolomb + * @par Description + * The function is used to get unsigned EGolomb bits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_UINT32_T, return current unsigned EGolomb bits + */ +VAL_UINT32_T eBufGetUEGolomb(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetSEGolomb + * @par Description + * The function is used to get signed EGolomb bits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_INT32_T, return current signed EGolomb bits + */ +VAL_INT32_T eBufGetSEGolomb(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufCheckEOF + * @par Description + * The function is used to check EOF bitstream + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_BOOL_T, return EOF or not + */ +VAL_BOOL_T eBufCheckEOF(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetBufSize + * @par Description + * The function is used to get buffer size + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_BOOL_T, return buffer size + */ +VAL_UINT32_T eBufGetBufSize(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * NextBytesAlignment + * @par Description + * The function is used to jump bitstream pointer to next bytesalignment + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * nBytesAlignment [IN] BytesAlignment + * @par Returns + * void + */ +void NextBytesAlignment(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T nBytesAlignment); + + +/** + * @par Function + * eBufInitBS + * @par Description + * The function is used to init bit stream + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * cmd_queue [IN] command queue + * @param + * pIndex [IN] command queue index + * @par Returns + * VAL_BOOL_T, return VAL_TRUE if success, return VAL_FALSE if failed + */ +VAL_BOOL_T eBufInitBS(VAL_HANDLE_T *a_phBitsHandle, P_VCODEC_DRV_CMD_T cmd_queue, VAL_UINT32_T *pIndex); + + +/** + * @par Function + * eBufGetPAddr + * @par Description + * The function is used to get physical address + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_UINT32_T, return physical address + */ +VAL_UINT32_T eBufGetPAddr(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetPAddr + * @par Description + * The function is used to re init + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * nBytes [IN] The Bytes + * @param + * nBits [IN] The Bits + * @par Returns + * VAL_BOOL_T, return VAL_TRUE if success, return VAL_FALSE if failed + */ +VAL_BOOL_T eBufReInite(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T nBytes, VAL_UINT32_T nBits); + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VAL_API_H_ */ diff --git a/kernel-headers/cmdq_def.h b/kernel-headers/cmdq_def.h new file mode 100644 index 0000000..3bc347f --- /dev/null +++ b/kernel-headers/cmdq_def.h @@ -0,0 +1,317 @@ +#ifndef __CMDQ_DEF_H__ +#define __CMDQ_DEF_H__ + +#include <linux/kernel.h> + +#define CMDQ_DRIVER_DEVICE_NAME "mtk_cmdq" + +/* Load HW event from device tree */ +#define CMDQ_DVENT_FROM_DTS + +/* #define CMDQ_COMMON_ENG_SUPPORT */ +#ifdef CMDQ_COMMON_ENG_SUPPORT +#include "cmdq_engine_common.h" +#else +#include "cmdq_engine.h" +#endif + +#define CMDQ_SPECIAL_SUBSYS_ADDR (99) + +#define CMDQ_GPR_SUPPORT +#define CMDQ_PROFILE_MARKER_SUPPORT + +#ifdef CMDQ_PROFILE_MARKER_SUPPORT +#define CMDQ_MAX_PROFILE_MARKER_IN_TASK (5) +#endif + +#define CMDQ_INVALID_THREAD (-1) + +#define CMDQ_MAX_THREAD_COUNT (16) +#define CMDQ_MAX_TASK_IN_THREAD (16) +#define CMDQ_MAX_READ_SLOT_COUNT (4) +#define CMDQ_INIT_FREE_TASK_COUNT (8) + +#define CMDQ_MAX_HIGH_PRIORITY_THREAD_COUNT (7) /* Thread that are high-priority (display threads) */ +#define CMDQ_MIN_SECURE_THREAD_ID (12) +#define CMDQ_MAX_SECURE_THREAD_COUNT (3) +typedef enum CMDQ_SCENARIO_ENUM { + CMDQ_SCENARIO_JPEG_DEC = 0, + CMDQ_SCENARIO_PRIMARY_DISP = 1, + CMDQ_SCENARIO_PRIMARY_MEMOUT = 2, + CMDQ_SCENARIO_PRIMARY_ALL = 3, + CMDQ_SCENARIO_SUB_DISP = 4, + CMDQ_SCENARIO_SUB_MEMOUT = 5, + CMDQ_SCENARIO_SUB_ALL = 6, + CMDQ_SCENARIO_MHL_DISP = 7, + CMDQ_SCENARIO_RDMA0_DISP = 8, + CMDQ_SCENARIO_RDMA0_COLOR0_DISP = 9, + CMDQ_SCENARIO_RDMA1_DISP = 10, + + /* Trigger loop scenario does not enable HWs */ + CMDQ_SCENARIO_TRIGGER_LOOP = 11, + + /* client from user space, so the cmd buffer is in user space. */ + CMDQ_SCENARIO_USER_MDP = 12, + + CMDQ_SCENARIO_DEBUG = 13, + CMDQ_SCENARIO_DEBUG_PREFETCH = 14, + + /* ESD check */ + CMDQ_SCENARIO_DISP_ESD_CHECK = 15, + /* for screen capture to wait for RDMA-done without blocking config thread */ + CMDQ_SCENARIO_DISP_SCREEN_CAPTURE = 16, + + /* notifiy there are some tasks exec done in secure path */ + CMDQ_SCENARIO_SECURE_NOTIFY_LOOP = 17, + + CMDQ_SCENARIO_DISP_PRIMARY_DISABLE_SECURE_PATH = 18, + CMDQ_SCENARIO_DISP_SUB_DISABLE_SECURE_PATH = 19, + + /* color path request from kernel */ + CMDQ_SCENARIO_DISP_COLOR = 20, + /* color path request from user sapce */ + CMDQ_SCENARIO_USER_DISP_COLOR = 21, + + /* [phased out]client from user space, so the cmd buffer is in user space. */ + CMDQ_SCENARIO_USER_SPACE = 22, + + CMDQ_SCENARIO_DISP_MIRROR_MODE = 23, + + CMDQ_SCENARIO_DISP_CONFIG_AAL = 24, + CMDQ_SCENARIO_DISP_CONFIG_PRIMARY_GAMMA = 25, + CMDQ_SCENARIO_DISP_CONFIG_SUB_GAMMA = 26, + CMDQ_SCENARIO_DISP_CONFIG_PRIMARY_DITHER = 27, + CMDQ_SCENARIO_DISP_CONFIG_SUB_DITHER = 28, + CMDQ_SCENARIO_DISP_CONFIG_PRIMARY_PWM = 29, + CMDQ_SCENARIO_DISP_CONFIG_SUB_PWM = 30, + CMDQ_SCENARIO_DISP_CONFIG_PRIMARY_PQ = 31, + CMDQ_SCENARIO_DISP_CONFIG_SUB_PQ = 32, + CMDQ_SCENARIO_DISP_CONFIG_OD = 33, + + CMDQ_SCENARIO_RDMA2_DISP = 34, + + CMDQ_SCENARIO_HIGHP_TRIGGER_LOOP = 35, /* for primary trigger loop enable pre-fetch usage */ + CMDQ_SCENARIO_LOWP_TRIGGER_LOOP = 36, /* for low priority monitor loop to polling bus status*/ + + CMDQ_SCENARIO_KERNEL_CONFIG_GENERAL = 37, + + CMDQ_MAX_SCENARIO_COUNT /* ALWAYS keep at the end */ +} CMDQ_SCENARIO_ENUM; + +typedef enum CMDQ_DATA_REGISTER_ENUM { + /* Value Reg, we use 32-bit */ + /* Address Reg, we use 64-bit */ + /* Note that R0-R15 and P0-P7 actullay share same memory */ + /* and R1 cannot be used. */ + + CMDQ_DATA_REG_JPEG = 0x00, /* R0 */ + CMDQ_DATA_REG_JPEG_DST = 0x11, /* P1 */ + + CMDQ_DATA_REG_PQ_COLOR = 0x04, /* R4 */ + CMDQ_DATA_REG_PQ_COLOR_DST = 0x13, /* P3 */ + + CMDQ_DATA_REG_2D_SHARPNESS_0 = 0x05, /* R5 */ + CMDQ_DATA_REG_2D_SHARPNESS_0_DST = 0x14, /* P4 */ + + CMDQ_DATA_REG_2D_SHARPNESS_1 = 0x0a, /* R10 */ + CMDQ_DATA_REG_2D_SHARPNESS_1_DST = 0x16, /* P6 */ + + CMDQ_DATA_REG_DEBUG = 0x0b, /* R11 */ + CMDQ_DATA_REG_DEBUG_DST = 0x17, /* P7 */ + + /* sentinel value for invalid register ID */ + CMDQ_DATA_REG_INVALID = -1, +} CMDQ_DATA_REGISTER_ENUM; + +typedef enum CMDQ_MDP_PA_BASE_ENUM { + CMDQ_MDP_PA_BASE_MM_MUTEX, + CMDQ_MAX_MDP_PA_BASE_COUNT, /* ALWAYS keep at the end */ +} CMDQ_MDP_PA_BASE_ENUM; + +/* CMDQ Events */ +#undef DECLARE_CMDQ_EVENT +#ifdef CMDQ_DVENT_FROM_DTS +#define DECLARE_CMDQ_EVENT(name_struct, val, dts_name) name_struct = val, +typedef enum CMDQ_EVENT_ENUM { +#include "cmdq_event_common.h" +} CMDQ_EVENT_ENUM; +#else +#define DECLARE_CMDQ_EVENT(name_struct, val) name_struct = val, +typedef enum CMDQ_EVENT_ENUM { +#if CMDQ_D1_EVENT +#include "cmdq_event_D1.h" +#elif CMDQ_D2_EVENT +#include "cmdq_event_D2.h" +#elif CMDQ_D3_EVENT +#include "cmdq_event_D3.h" +#else +#include "cmdq_event.h" +#endif +} CMDQ_EVENT_ENUM; +#endif +#undef DECLARE_CMDQ_EVENT + +/* CMDQ subsys */ +#undef DECLARE_CMDQ_SUBSYS +#define DECLARE_CMDQ_SUBSYS(name_struct, val, grp, dts_name) name_struct = val, +typedef enum CMDQ_SUBSYS_ENUM { +#include "cmdq_subsys_common.h" + + /* ALWAYS keep at the end */ + CMDQ_SUBSYS_MAX_COUNT +} CMDQ_SUBSYS_ENUM; +#undef DECLARE_CMDQ_SUBSYS + +#define CMDQ_SUBSYS_GRPNAME_MAX (30) +/* GCE subsys information */ +typedef struct SubsysStruct { + uint32_t msb; + int32_t subsysID; + uint32_t mask; + char grpName[CMDQ_SUBSYS_GRPNAME_MAX]; +} SubsysStruct; + +typedef struct cmdqDTSDataStruct { + /* [Out] GCE event table */ + int32_t eventTable[CMDQ_SYNC_TOKEN_MAX]; + /* [Out] GCE subsys ID table */ + SubsysStruct subsys[CMDQ_SUBSYS_MAX_COUNT]; + /* [Out] MDP Base address */ + uint32_t MDPBaseAddress[CMDQ_MAX_MDP_PA_BASE_COUNT]; +} cmdqDTSDataStruct; + +/* Custom "wide" pointer type for 64-bit job handle (pointer to VA) */ +typedef unsigned long long cmdqJobHandle_t; +/* Custom "wide" pointer type for 64-bit compatibility. Always cast from uint32_t*. */ +typedef unsigned long long cmdqU32Ptr_t; + +#define CMDQ_U32_PTR(x) ((uint32_t *)(unsigned long)x) + +typedef struct cmdqReadRegStruct { + uint32_t count; /* number of entries in regAddresses */ + cmdqU32Ptr_t regAddresses; /* an array of 32-bit register addresses (uint32_t) */ +} cmdqReadRegStruct; + +typedef struct cmdqRegValueStruct { + /* number of entries in result */ + uint32_t count; + + /* array of 32-bit register values (uint32_t). */ + /* in the same order as cmdqReadRegStruct */ + cmdqU32Ptr_t regValues; +} cmdqRegValueStruct; + +typedef struct cmdqReadAddressStruct { + uint32_t count; /* [IN] number of entries in result. */ + + /* [IN] array of physical addresses to read. */ + /* these value must allocated by CMDQ_IOCTL_ALLOC_WRITE_ADDRESS ioctl */ + /* */ + /* indeed param dmaAddresses should be UNSIGNED LONG type for 64 bit kernel. */ + /* Considering our plartform supports max 4GB RAM(upper-32bit don't care for SW) */ + /* and consistent common code interface, remain uint32_t type. */ + cmdqU32Ptr_t dmaAddresses; + + cmdqU32Ptr_t values; /* [OUT] uint32_t values that dmaAddresses point into */ +} cmdqReadAddressStruct; + +/* + * Secure address metadata: + * According to handle type, translate handle and replace (_d)th instruciton to + * 1. sec_addr = hadnle_sec_base_addr(baseHandle) + offset(_b) + * 2. sec_mva = mva( hadnle_sec_base_addr(baseHandle) + offset(_b) ) + * 3. secure world normal mva = map(baseHandle) + * . pass normal mva to parameter baseHandle + * . use case: OVL reads from secure and normal buffers at the same time) + */ +typedef enum CMDQ_SEC_ADDR_METADATA_TYPE { + CMDQ_SAM_H_2_PA = 0, /* sec handle to sec PA */ + CMDQ_SAM_H_2_MVA = 1, /* sec handle to sec MVA */ + CMDQ_SAM_NMVA_2_MVA = 2, /* map normal MVA to secure world */ +} CMDQ_SEC_ADDR_METADATA_TYPE; + +typedef struct cmdqSecAddrMetadataStruct { + /* [IN]_d, index of instruction. Update its argB value to real PA/MVA in secure world */ + uint32_t instrIndex; + + CMDQ_SEC_ADDR_METADATA_TYPE type; /* [IN] addr handle type */ + uint32_t baseHandle; /* [IN]_h, secure address handle */ + uint32_t offset; /* [IN]_b, buffser offset to secure handle */ + uint32_t size; /* buffer size */ + uint32_t port; /* hw port id (i.e. M4U port id) */ +} cmdqSecAddrMetadataStruct; + +typedef struct cmdqSecDataStruct { + bool isSecure; /* [IN]true for secure command */ + + /* address metadata, used to translate secure buffer PA related instruction in secure world */ + uint32_t addrMetadataCount; /* [IN] count of element in addrList */ + cmdqU32Ptr_t addrMetadatas; /* [IN] array of cmdqSecAddrMetadataStruct */ + uint32_t addrMetadataMaxCount; /*[Reserved] */ + + uint64_t enginesNeedDAPC; + uint64_t enginesNeedPortSecurity; + + /* [Reserved] This is for CMDQ driver usage itself. Not for client. */ + int32_t waitCookie; /* task index in thread's tasklist. -1 for not in tasklist. */ + bool resetExecCnt; /* reset HW thread in SWd */ +} cmdqSecDataStruct; + +#ifdef CMDQ_PROFILE_MARKER_SUPPORT +typedef struct cmdqProfileMarkerStruct { + uint32_t count; + long long hSlot; /* i.e. cmdqBackupSlotHandle, physical start address of backup slot */ + cmdqU32Ptr_t tag[CMDQ_MAX_PROFILE_MARKER_IN_TASK]; +} cmdqProfileMarkerStruct; +#endif + +typedef struct cmdqCommandStruct { + /* [IN] deprecated. will remove in the future. */ + uint32_t scenario; + /* [IN] task schedule priority. this is NOT HW thread priority. */ + uint32_t priority; + /* [IN] bit flag of engines used. */ + uint64_t engineFlag; + /* [IN] pointer to instruction buffer. Use 64-bit for compatibility. */ + /* This must point to an 64-bit aligned uint32_t array */ + cmdqU32Ptr_t pVABase; + /* [IN] size of instruction buffer, in bytes. */ + uint32_t blockSize; + /* [IN] request to read register values at the end of command */ + cmdqReadRegStruct regRequest; + /* [OUT] register values of regRequest */ + cmdqRegValueStruct regValue; + /* [IN/OUT] physical addresses to read value */ + cmdqReadAddressStruct readAddress; + /*[IN] secure execution data */ + cmdqSecDataStruct secData; + /* [IN] set to non-zero to enable register debug dump. */ + uint32_t debugRegDump; + /* [Reserved] This is for CMDQ driver usage itself. Not for client. Do not access this field from User Space */ + cmdqU32Ptr_t privateData; +#ifdef CMDQ_PROFILE_MARKER_SUPPORT + cmdqProfileMarkerStruct profileMarker; +#endif +} cmdqCommandStruct; + +typedef enum CMDQ_CAP_BITS { + /* bit 0: TRUE if WFE instruction support is ready. FALSE if we need to POLL instead. */ + CMDQ_CAP_WFE = 0, +} CMDQ_CAP_BITS; + + +/** + * reply struct for cmdq_sec_cancel_error_task + */ + +typedef struct { + /* [OUT] */ + bool throwAEE; + bool hasReset; + int32_t irqFlag; + uint32_t errInstr[2]; + uint32_t regValue; + uint32_t pc; +} cmdqSecCancelTaskResultStruct; + +#endif /* __CMDQ_DEF_H__ */ diff --git a/kernel-headers/cmdq_driver.h b/kernel-headers/cmdq_driver.h new file mode 100644 index 0000000..97c7228 --- /dev/null +++ b/kernel-headers/cmdq_driver.h @@ -0,0 +1,80 @@ +#ifndef __CMDQ_DRIVER_H__ +#define __CMDQ_DRIVER_H__ + +#include <linux/kernel.h> +#include "cmdq_def.h" + +typedef struct cmdqUsageInfoStruct { + uint32_t count[CMDQ_MAX_ENGINE_COUNT]; /* [OUT] current engine ref count */ +} cmdqUsageInfoStruct; + +typedef struct cmdqJobStruct { + struct cmdqCommandStruct command; /* [IN] the job to perform */ + cmdqJobHandle_t hJob; /* [OUT] handle to resulting job */ +} cmdqJobStruct; + +typedef struct cmdqJobResultStruct { + cmdqJobHandle_t hJob; /* [IN] Job handle from CMDQ_IOCTL_ASYNC_JOB_EXEC */ + uint64_t engineFlag; /* [OUT] engine flag passed down originally */ + + /* [IN/OUT] read register values, if any. */ + /* as input, the "count" field must represent */ + /* buffer space pointed by "regValues". */ + /* Upon return, CMDQ driver fills "count" with */ + /* actual requested register count. */ + /* However, if the input "count" is too small, */ + /* -ENOMEM is returned, and "count" is filled */ + /* with requested register count. */ + cmdqRegValueStruct regValue; + + cmdqReadAddressStruct readAddress; /* [IN/OUT] physical address to read */ +} cmdqJobResultStruct; + +typedef struct cmdqWriteAddressStruct { + /* [IN] count of the writable buffer (unit is # of uint32_t, NOT in byte) */ + uint32_t count; + + /* [OUT] When Alloc, this is the resulting PA. It is guaranteed to be continuous. */ + /* [IN] When Free, please pass returned address down to ioctl. */ + /* */ + /* indeed param startPA should be UNSIGNED LONG type for 64 bit kernel. */ + /* Considering our plartform supports max 4GB RAM(upper-32bit don't care for SW) */ + /* and consistent common code interface, remain uint32_t type. */ + uint32_t startPA; +} cmdqWriteAddressStruct; + +#define CMDQ_IOCTL_MAGIC_NUMBER 'x' + +#define CMDQ_IOCTL_LOCK_MUTEX _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 1, int) +#define CMDQ_IOCTL_UNLOCK_MUTEX _IOR(CMDQ_IOCTL_MAGIC_NUMBER, 2, int) +#define CMDQ_IOCTL_EXEC_COMMAND _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 3, cmdqCommandStruct) +#define CMDQ_IOCTL_QUERY_USAGE _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 4, cmdqUsageInfoStruct) + +/* */ +/* Async operations */ +/* */ +#define CMDQ_IOCTL_ASYNC_JOB_EXEC _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 5, cmdqJobStruct) +#define CMDQ_IOCTL_ASYNC_JOB_WAIT_AND_CLOSE _IOR(CMDQ_IOCTL_MAGIC_NUMBER, 6, cmdqJobResultStruct) + +#define CMDQ_IOCTL_ALLOC_WRITE_ADDRESS _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 7, cmdqWriteAddressStruct) +#define CMDQ_IOCTL_FREE_WRITE_ADDRESS _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 8, cmdqWriteAddressStruct) +#define CMDQ_IOCTL_READ_ADDRESS_VALUE _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 9, cmdqReadAddressStruct) + +/* */ +/* Chip capability query. output parameter is a bit field. */ +/* Bit definition is CMDQ_CAP_BITS. */ +/* */ +#define CMDQ_IOCTL_QUERY_CAP_BITS _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 10, int) + +/* */ +/* HW info. from DTS */ +/* */ +#define CMDQ_IOCTL_QUERY_DTS _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 11, cmdqDTSDataStruct) + +/* */ +/* Notify MDP will use specified engine before really use. */ +/* input int is same as EngineFlag. */ +/* */ +#define CMDQ_IOCTL_NOTIFY_ENGINE _IOW(CMDQ_IOCTL_MAGIC_NUMBER, 12, uint64_t) + +#endif /* __CMDQ_DRIVER_H__ */ diff --git a/kernel-headers/cmdq_engine_common.h b/kernel-headers/cmdq_engine_common.h new file mode 100644 index 0000000..bfb211d --- /dev/null +++ b/kernel-headers/cmdq_engine_common.h @@ -0,0 +1,71 @@ +#ifndef __CMDQ_ENGINE_COMMON_H__ +#define __CMDQ_ENGINE_COMMON_H__ + +typedef enum CMDQ_ENG_ENUM { + /* ISP */ + CMDQ_ENG_ISP_IMGI = 0, + CMDQ_ENG_ISP_IMGO, /* 1 */ + CMDQ_ENG_ISP_IMG2O, /* 2 */ + + /* MDP */ + CMDQ_ENG_MDP_CAMIN, /* 3 */ + CMDQ_ENG_MDP_RDMA0, /* 4 */ + CMDQ_ENG_MDP_RDMA1, /* 5 */ + CMDQ_ENG_MDP_RSZ0, /* 6 */ + CMDQ_ENG_MDP_RSZ1, /* 7 */ + CMDQ_ENG_MDP_RSZ2, /* 8 */ + CMDQ_ENG_MDP_TDSHP0, /* 9 */ + CMDQ_ENG_MDP_TDSHP1, /* 10 */ + CMDQ_ENG_MDP_COLOR0, /* 11 */ + CMDQ_ENG_MDP_MOUT0, /* 12 */ + CMDQ_ENG_MDP_MOUT1, /* 13 */ + CMDQ_ENG_MDP_WROT0, /* 14 */ + CMDQ_ENG_MDP_WROT1, /* 15 */ + CMDQ_ENG_MDP_WDMA, /* 16 */ + + /* JPEG & VENC */ + CMDQ_ENG_JPEG_ENC, /* 17 */ + CMDQ_ENG_VIDEO_ENC, /* 18 */ + CMDQ_ENG_JPEG_DEC, /* 19 */ + CMDQ_ENG_JPEG_REMDC, /* 20 */ + + /* DISP */ + CMDQ_ENG_DISP_UFOE, /* 21 */ + CMDQ_ENG_DISP_AAL, /* 22 */ + CMDQ_ENG_DISP_COLOR0, /* 23 */ + CMDQ_ENG_DISP_COLOR1, /* 24 */ + CMDQ_ENG_DISP_RDMA0, /* 25 */ + CMDQ_ENG_DISP_RDMA1, /* 26 */ + CMDQ_ENG_DISP_RDMA2, /* 27 */ + CMDQ_ENG_DISP_WDMA0, /* 28 */ + CMDQ_ENG_DISP_WDMA1, /* 29 */ + CMDQ_ENG_DISP_OVL0, /* 30 */ + CMDQ_ENG_DISP_OVL1, /* 31 */ + CMDQ_ENG_DISP_OVL2, /* 32 */ + CMDQ_ENG_DISP_2L_OVL0, /* 33 */ + CMDQ_ENG_DISP_2L_OVL1, /* 34 */ + CMDQ_ENG_DISP_2L_OVL2, /* 35 */ + CMDQ_ENG_DISP_GAMMA, /* 36 */ + CMDQ_ENG_DISP_MERGE, /* 37 */ + CMDQ_ENG_DISP_SPLIT0, /* 38 */ + CMDQ_ENG_DISP_SPLIT1, /* 39 */ + CMDQ_ENG_DISP_DSI0_VDO, /* 40 */ + CMDQ_ENG_DISP_DSI1_VDO, /* 41 */ + CMDQ_ENG_DISP_DSI0_CMD, /* 42 */ + CMDQ_ENG_DISP_DSI1_CMD, /* 43 */ + CMDQ_ENG_DISP_DSI0, /* 44 */ + CMDQ_ENG_DISP_DSI1, /* 45 */ + CMDQ_ENG_DISP_DPI, /* 46 */ + + /* DPE */ + CMDQ_ENG_DPE, /* 47 */ + + /* temp: CMDQ internal usage */ + CMDQ_ENG_CMDQ, + CMDQ_ENG_DISP_MUTEX, + CMDQ_ENG_MMSYS_CONFIG, + + CMDQ_MAX_ENGINE_COUNT /* ALWAYS keep at the end */ +} CMDQ_ENG_ENUM; + +#endif /* __CMDQ_ENGINE_COMMON_H__ */ diff --git a/kernel-headers/cmdq_event_common.h b/kernel-headers/cmdq_event_common.h new file mode 100644 index 0000000..b185888 --- /dev/null +++ b/kernel-headers/cmdq_event_common.h @@ -0,0 +1,272 @@ +/* MDP start frame */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA0_SOF, 0, mdp_rdma0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA1_SOF, 1, mdp_rdma1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ0_SOF, 2, mdp_rsz0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ1_SOF, 3, mdp_rsz1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ2_SOF, 4, mdp_rsz2_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP_SOF, 5, mdp_tdshp_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP0_SOF, 6, mdp_tdshp0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP1_SOF, 7, mdp_tdshp1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WDMA_SOF, 8, mdp_wdma_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT_SOF, 9, mdp_wrot_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_SOF, 10, mdp_wrot0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_SOF, 11, mdp_wrot1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_COLOR_SOF, 12, mdp_color_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_MVW_SOF, 13, mdp_mvw_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_CROP_SOF, 14, mdp_crop_sof) + +/* Display start frame */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL0_SOF, 15, disp_ovl0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL1_SOF, 16, disp_ovl1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_2L_OVL0_SOF, 17, disp_2l_ovl0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_2L_OVL1_SOF, 18, disp_2l_ovl1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA0_SOF, 19, disp_rdma0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA1_SOF, 20, disp_rdma1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA2_SOF, 21, disp_rdma2_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA0_SOF, 22, disp_wdma0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA1_SOF, 23, disp_wdma1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR_SOF, 24, disp_color_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR0_SOF, 25, disp_color0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR1_SOF, 26, disp_color1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_CCORR_SOF, 27, disp_ccorr_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_AAL_SOF, 28, disp_aal_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_GAMMA_SOF, 29, disp_gamma_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DITHER_SOF, 30, disp_dither_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_UFOE_SOF, 31, disp_ufoe_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_PWM0_SOF, 32, disp_pwm0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_PWM1_SOF, 33, disp_pwm1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OD_SOF, 34, disp_od_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DSC_SOF, 35, disp_dsc_sof) + +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L0_SOF, 36, ufod_rdma0_l0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L1_SOF, 37, ufod_rdma0_l1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L2_SOF, 38, ufod_rdma0_l2_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L3_SOF, 39, ufod_rdma0_l3_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L0_SOF, 40, ufod_rdma1_l0_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L1_SOF, 41, ufod_rdma1_l1_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L2_SOF, 42, ufod_rdma1_l2_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L3_SOF, 43, ufod_rdma1_l3_sof) + +/* MDP frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA0_EOF, 44, mdp_rdma0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA1_EOF, 45, mdp_rdma1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ0_EOF, 46, mdp_rsz0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ1_EOF, 47, mdp_rsz1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ2_EOF, 48, mdp_rsz2_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP_EOF, 49, mdp_tdshp_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP0_EOF, 50, mdp_tdshp0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP1_EOF, 51, mdp_tdshp1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WDMA_EOF, 52, mdp_wdma_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT_WRITE_EOF, 53, mdp_wrot_write_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT_READ_EOF, 54, mdp_wrot_read_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_WRITE_EOF, 55, mdp_wrot0_write_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_READ_EOF, 56, mdp_wrot0_read_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_WRITE_EOF, 57, mdp_wrot1_write_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_READ_EOF, 58, mdp_wrot1_read_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_W_EOF, 59, mdp_wrot0_write_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_R_EOF, 60, mdp_wrot0_read_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_W_EOF, 61, mdp_wrot1_write_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_R_EOF, 62, mdp_wrot1_read_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_COLOR_EOF, 63, mdp_color_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_CROP_EOF, 64, mdp_crop_frame_done) + +/* Display frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL0_EOF, 65, disp_ovl0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL1_EOF, 66, disp_ovl1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_2L_OVL0_EOF, 67, disp_2l_ovl0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_2L_OVL1_EOF, 68, disp_2l_ovl1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA0_EOF, 69, disp_rdma0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA1_EOF, 70, disp_rdma1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA2_EOF, 71, disp_rdma2_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA0_EOF, 72, disp_wdma0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA1_EOF, 73, disp_wdma1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR_EOF, 74, disp_color_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR0_EOF, 75, disp_color0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR1_EOF, 76, disp_color1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_CCORR_EOF, 77, disp_ccorr_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_AAL_EOF, 78, disp_aal_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_GAMMA_EOF, 79, disp_gamma_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DITHER_EOF, 80, disp_dither_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_UFOE_EOF, 81, disp_ufoe_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OD_EOF, 82, disp_od_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DSC_EOF, 83, disp_dsc_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DSI0_EOF, 84, disp_dsi0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DSI1_EOF, 85, disp_dsi1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DPI0_EOF, 86, disp_dpi0_frame_done) + +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L0_EOF, 87, ufod_rdma0_l0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L1_EOF, 88, ufod_rdma0_l1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L2_EOF, 89, ufod_rdma0_l2_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA0_L3_EOF, 90, ufod_rdma0_l3_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L0_EOF, 91, ufod_rdma1_l0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L1_EOF, 92, ufod_rdma1_l1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L2_EOF, 93, ufod_rdma1_l2_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_UFOD_RAMA1_L3_EOF, 94, ufod_rdma1_l3_frame_done) + +/* Mutex frame done */ +/* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX0_STREAM_EOF, 95, stream_done_0) +/* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX1_STREAM_EOF, 96, stream_done_1) +/* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX2_STREAM_EOF, 97, stream_done_2) +/* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX3_STREAM_EOF, 98, stream_done_3) +/* DISPSYS, please refer to disp_hal.h */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX4_STREAM_EOF, 99, stream_done_4) +/* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX5_STREAM_EOF, 100, stream_done_5) +/* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX6_STREAM_EOF, 101, stream_done_6) +/* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX7_STREAM_EOF, 102, stream_done_7) +/* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX8_STREAM_EOF, 103, stream_done_8) +/* DpFramework via CMDQ_IOCTL_LOCK_MUTEX */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX9_STREAM_EOF, 104, stream_done_9) + +/* Display underrun */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA0_UNDERRUN, 105, buf_underrun_event_0) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA1_UNDERRUN, 106, buf_underrun_event_1) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA2_UNDERRUN, 107, buf_underrun_event_2) + +/* Display TE */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DSI_TE, 108, dsi0_te_event) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DSI0_TE, 109, dsi0_te_event) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DSI1_TE, 110, dsi1_te_event) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_DSI0_TE_SOF, 111, mdp_dsi0_te_sof) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_DSI1_TE_SOF, 112, mdp_dsi1_te_sof) + +/* ISP frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS2_2_EOF, 113, isp_frame_done_p2_2) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS2_1_EOF, 114, isp_frame_done_p2_1) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS2_0_EOF, 115, isp_frame_done_p2_0) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS1_1_EOF, 116, isp_frame_done_p1_1) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS1_0_EOF, 117, isp_frame_done_p1_0) + +/* ISP (IMGSYS) frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD0_EOF, 118, dip_cq_thread0_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD1_EOF, 119, dip_cq_thread1_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD2_EOF, 120, dip_cq_thread2_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD3_EOF, 121, dip_cq_thread3_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD4_EOF, 122, dip_cq_thread4_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD5_EOF, 123, dip_cq_thread5_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD6_EOF, 124, dip_cq_thread6_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD7_EOF, 125, dip_cq_thread7_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD8_EOF, 126, dip_cq_thread8_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD9_EOF, 127, dip_cq_thread9_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD10_EOF, 128, dip_cq_thread10_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD11_EOF, 129, dip_cq_thread11_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD12_EOF, 130, dip_cq_thread12_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD13_EOF, 131, dip_cq_thread13_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DIP_CQ_THREAD14_EOF, 132, dip_cq_thread14_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DPE_EOF, 133, dpe_frame_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_WMF_EOF, 134, wmf_frame_done) + +/* ISP (IMGSYS) engine events */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_SENINF_CAM1_2_3_FULL, 135, seninf_cam1_2_3_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_SENINF_CAM0_FULL, 136, seninf_cam0_fifo_full) + +/* VENC frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_VENC_EOF, 137, venc_done) + +/* JPEG frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_JPEG_ENC_EOF, 138, jpgenc_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_JPEG_ENC_PASS2_EOF, 139, jpgenc_pass2_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_JPEG_ENC_PASS1_EOF, 140, jpgenc_pass1_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_JPEG_DEC_EOF, 141, jpgdec_done) + +/* VENC engine events */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_VENC_MB_DONE, 142, venc_mb_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_VENC_128BYTE_CNT_DONE, 143, venc_128byte_cnt_done) + +/* ISP (CAMSYS) frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_FRAME_DONE_A, 144, isp_frame_done_a) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_FRAME_DONE_B, 145, isp_frame_done_b) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_CAMSV_0_PASS1_DONE, 146, camsv_0_pass1_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_CAMSV_1_PASS1_DONE, 147, camsv_1_pass1_done) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_CAMSV_2_PASS1_DONE, 148, camsv_2_pass1_done) + +/* ISP (CAMSYS) engine events */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_0_FIFO_FULL, 149, seninf_0_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_1_FIFO_FULL, 150, seninf_1_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_2_FIFO_FULL, 151, seninf_2_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_3_FIFO_FULL, 152, seninf_3_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_4_FIFO_FULL, 153, seninf_4_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_5_FIFO_FULL, 154, seninf_5_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_6_FIFO_FULL, 155, seninf_6_fifo_full) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_SENINF_7_FIFO_FULL, 156, seninf_7_fifo_full) + +/* Keep this at the end of HW events */ +DECLARE_CMDQ_EVENT(CMDQ_MAX_HW_EVENT_COUNT, 400, hw_event_conunt) + +/* SW Sync Tokens (Pre-defined) */ +/* Config thread notify trigger thread */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_CONFIG_DIRTY, 401, sw_token) +/* Trigger thread notify config thread */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_STREAM_EOF, 402, sw_token) +/* Block Trigger thread until the ESD check finishes. */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_ESD_EOF, 403, sw_token) +/* check CABC setup finish */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_CABC_EOF, 404, sw_token) +/* Block Trigger thread until the path freeze finishes */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_FREEZE_EOF, 405, sw_token) +/* Pass-2 notifies VENC frame is ready to be encoded */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_VENC_INPUT_READY, 406, sw_token) +/* VENC notifies Pass-2 encode done so next frame may start */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_VENC_EOF, 407, sw_token) + +/* Notify normal CMDQ there are some secure task done */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_SECURE_THR_EOF, 408, sw_token) +/* Lock WSM resource */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_SECURE_WSM_LOCK, 409, sw_token) + +/* SW Sync Tokens (User-defined) */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_USER_0, 410, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_USER_1, 411, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_POLL_MONITOR, 412, sw_token) + +/* Event for CMDQ to block executing command when append command +* Plz sync CMDQ_SYNC_TOKEN_APPEND_THR(id) in cmdq_core source file. */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR0, 422, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR1, 423, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR2, 424, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR3, 425, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR4, 426, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR5, 427, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR6, 428, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR7, 429, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR8, 430, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR9, 431, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR10, 432, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR11, 433, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR12, 434, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR13, 435, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR14, 436, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_APPEND_THR15, 437, sw_token) + +/* GPR access tokens (for HW register backup) */ +/* There are 15 32-bit GPR, 3 GPR form a set (64-bit for address, 32-bit for value) */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_0, 450, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_1, 451, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_2, 452, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_3, 453, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_4, 454, sw_token) + +/* Resource lock event to control resource in GCE thread */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_RESOURCE_WROT0, 460, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_RESOURCE_WROT1, 461, sw_token) + +/* Secure video path notify SW token */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_OVL0_2NONSEC_END, 470, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_OVL1_2NONSEC_END, 471, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_2LOVL0_2NONSEC_END, 472, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_2LOVL1_2NONSEC_END, 473, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_RDMA0_2NONSEC_END, 474, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_RDMA1_2NONSEC_END, 475, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_WDMA0_2NONSEC_END, 476, sw_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_DISP_WDMA1_2NONSEC_END, 477, sw_token) + +/* event id is 9 bit */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_MAX, (0x1FF), max_token) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_INVALID, (-1), invalid_token) diff --git a/kernel-headers/cmdq_subsys_common.h b/kernel-headers/cmdq_subsys_common.h new file mode 100644 index 0000000..1872b80 --- /dev/null +++ b/kernel-headers/cmdq_subsys_common.h @@ -0,0 +1,32 @@ +/* GCE subsys */ +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_G3D_CONFIG_BASE, 0, MFG, g3d_config_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_MMSYS_CONFIG, 1, MMSYS, mmsys_config_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_DISP_DITHER, 2, MMSYS, disp_dither_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_NA, 3, MMSYS, mm_na_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_IMGSYS, 4, CAM, imgsys_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_VDEC_GCON, 5, VDEC, vdec_gcon_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_VENC_GCON, 6, VENC, venc_gcon_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_CONN_PERIPHERALS, 7, PERISYS, conn_peri_base) + +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_TOPCKGEN, 8, TOP_AO_3, topckgen_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_KP, 9, INFRA_AO, kp_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_SCP_SRAM, 10, INFRA_AO, scp_sram_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_INFRA_NA3, 11, NA, infra_na3_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_INFRA_NA4, 12, NA, infra_na4_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_SCP, 13, SCP, scp_base) + +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_MCUCFG, 14, INFRASYS, mcucfg_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_GCPU, 15, INFRASYS, gcpu_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_USB0, 16, PERISYS, usb0_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_USB_SIF, 17, PERISYS, usb_sif_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_AUDIO, 18, PERISYS, audio_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_MSDC0, 19, PERISYS, msdc0_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_MSDC1, 20, PERISYS, msdc1_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_MSDC2, 21, PERISYS, msdc2_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_MSDC3, 22, PERISYS, msdc3_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_AP_DMA, 23, INFRASYS, ap_dma_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_CAMSYS, 24, CAMSYS, camsys_base) + +/* Special subsys */ +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_PWM_SW, 25, SPECIAL, pwm_sw_base) +DECLARE_CMDQ_SUBSYS(CMDQ_SUBSYS_DIP_A0_SW, 26, SPECIAL, dip_a0_sw_base) diff --git a/kernel-headers/hal_api.h b/kernel-headers/hal_api.h new file mode 100644 index 0000000..f4b45d5 --- /dev/null +++ b/kernel-headers/hal_api.h @@ -0,0 +1,229 @@ +#ifndef _HAL_API_H_ +#define _HAL_API_H_ +#include "val_types_public.h" + +#define DumpReg__ /* /< Dump Reg for debug */ +#ifdef DumpReg__ +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define ADD_QUEUE(queue, index, q_type, q_address, q_offset, q_value, q_mask) \ + { \ + queue[index].type = q_type; \ + queue[index].address = q_address; \ + queue[index].offset = q_offset; \ + queue[index].value = q_value; \ + queue[index].mask = q_mask; \ + index = index + 1; \ + } /* /< ADD QUEUE command */ + + +/** + * @par Enumeration + * HAL_CODEC_TYPE_T + * @par Description + * This is the item used for codec type + */ +typedef enum __HAL_CODEC_TYPE_T { + HAL_CODEC_TYPE_VDEC, /* /< VDEC */ + HAL_CODEC_TYPE_VENC, /* /< VENC */ + HAL_CODEC_TYPE_MAX = 0xFFFFFFFF /* /< MAX Value */ +} +HAL_CODEC_TYPE_T; + + +/** + * @par Enumeration + * HAL_CMD_T + * @par Description + * This is the item used for hal command type + */ +typedef enum _HAL_CMD_T { + HAL_CMD_SET_CMD_QUEUE, /* /< set command queue */ + HAL_CMD_SET_POWER, /* /< set power */ + HAL_CMD_SET_ISR, /* /< set ISR */ + HAL_CMD_GET_CACHE_CTRL_ADDR, /* /< get cahce control address */ + HAL_CMD_MAX = 0xFFFFFFFF /* /< MAX value */ +} HAL_CMD_T; + + +/** + * @par Enumeration + * REGISTER_GROUP_T + * @par Description + * This is the item used for register group + */ + +typedef enum _REGISTER_GROUP_T { + VDEC_SYS, /* /< VDEC_SYS */ + VDEC_MISC, /* /< VDEC_MISC */ + VDEC_VLD, /* /< VDEC_VLD */ + VDEC_VLD_TOP, /* /< VDEC_VLD_TOP */ + VDEC_MC, /* /< VDEC_MC */ + VDEC_AVC_VLD, /* /< VDEC_AVC_VLD */ + VDEC_AVC_MV, /* /< VDEC_AVC_MV */ + VDEC_HEVC_VLD, /* /< VDEC_HEVC_VLD */ + VDEC_HEVC_MV, /* /< VDEC_HEVC_MV */ + VDEC_PP, /* /< VDEC_PP */ + /* VDEC_SQT, */ + VDEC_VP8_VLD, /* /< VDEC_VP8_VLD */ + VDEC_VP6_VLD, /* /< VDEC_VP6_VLD */ + VDEC_VP8_VLD2, /* /< VDEC_VP8_VLD2 */ + VENC_HW_BASE, /* /< VENC_HW_BASE */ + VENC_LT_HW_BASE, /* /< VENC_HW_LT_BASE */ + VENC_MP4_HW_BASE, /* /< VENC_MP4_HW_BASE */ + VDEC_VP9_VLD, /*/< VDEC_VP9_VLD*/ + VCODEC_MAX /* /< VCODEC_MAX */ +} REGISTER_GROUP_T; + + +/** + * @par Enumeration + * REGISTER_GROUP_T + * @par Description + * This is the item used for driver command type + */ +typedef enum _VCODEC_DRV_CMD_TYPE { + ENABLE_HW_CMD, /* /< ENABLE_HW_CMD */ + DISABLE_HW_CMD, /* /< DISABLE_HW_CMD */ + WRITE_REG_CMD, /* /< WRITE_REG_CMD */ + READ_REG_CMD, /* /< READ_REG_CMD */ + WRITE_SYSRAM_CMD, /* /< WRITE_SYSRAM_CMD */ + READ_SYSRAM_CMD, /* /< READ_SYSRAM_CMD */ + MASTER_WRITE_CMD, /* /< MASTER_WRITE_CMD */ + WRITE_SYSRAM_RANGE_CMD, /* /< WRITE_SYSRAM_RANGE_CMD */ + READ_SYSRAM_RANGE_CMD, /* /< READ_SYSRAM_RANGE_CMD */ + SETUP_ISR_CMD, /* /< SETUP_ISR_CMD */ + WAIT_ISR_CMD, /* /< WAIT_ISR_CMD */ + TIMEOUT_CMD, /* /< TIMEOUT_CMD */ + MB_CMD, /* /< MB_CMD */ + POLL_REG_STATUS_CMD, /* /< POLL_REG_STATUS_CMD */ + END_CMD /* /< END_CMD */ +} VCODEC_DRV_CMD_TYPE; + + +/** + * @par Structure + * P_VCODEC_DRV_CMD_T + * @par Description + * Pointer of VCODEC_DRV_CMD_T + */ +typedef struct __VCODEC_DRV_CMD_T *P_VCODEC_DRV_CMD_T; + + +/** + * @par Structure + * VCODEC_DRV_CMD_T + * @par Description + * driver command information + */ +typedef struct __VCODEC_DRV_CMD_T { + VAL_UINT32_T type; /* /< type */ + VAL_ULONG_T address; /* /< address */ + VAL_ULONG_T offset; /* /< offset */ + VAL_ULONG_T value; /* /< value */ + VAL_ULONG_T mask; /* /< mask */ +} VCODEC_DRV_CMD_T; + + +/** + * @par Structure + * HAL_HANDLE_T + * @par Description + * hal handle information + */ +typedef struct _HAL_HANDLE_T_ { + VAL_INT32_T fd_vdec; /* /< fd_vdec */ + VAL_INT32_T fd_venc; /* /< fd_venc */ + VAL_MEMORY_T rHandleMem; /* /< rHandleMem */ + VAL_ULONG_T mmap[VCODEC_MAX]; /* /< mmap[VCODEC_MAX] */ + VAL_DRIVER_TYPE_T driverType; /* /< driverType */ + VAL_UINT32_T u4TimeOut; /* /< u4TimeOut */ + VAL_UINT32_T u4FrameCount; /* /< u4FrameCount */ +#ifdef DumpReg__ + FILE *pf_out; +#endif + VAL_BOOL_T bProfHWTime; /* /< bProfHWTime */ + VAL_UINT64_T u8HWTime[2]; /* /< u8HWTime */ +} HAL_HANDLE_T; + + +/** + * @par Function + * eHalInit + * @par Description + * The init hal driver function + * @param + * a_phHalHandle [IN/OUT] The hal handle + * @param + * a_eHalCodecType [IN] VDEC or VENC + * @par Returns + * VAL_RESULT_T, + * return VAL_RESULT_NO_ERROR if success, + * return VAL_RESULT_INVALID_DRIVER or VAL_RESULT_INVALID_MEMORY if failed + */ +VAL_RESULT_T eHalInit(VAL_HANDLE_T *a_phHalHandle, HAL_CODEC_TYPE_T a_eHalCodecType); + + +/** + * @par Function + * eHalDeInit + * @par Description + * The deinit hal driver function + * @param + * a_phHalHandle [IN/OUT] The hal handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return else if failed + */ +VAL_RESULT_T eHalDeInit(VAL_HANDLE_T *a_phHalHandle); + + +/** + * @par Function + * eHalGetMMAP + * @par Description + * The get hw register memory map to vitural address function + * @param + * a_hHalHandle [IN/OUT] The hal handle + * @param + * RegAddr [IN] hw register address + * @par Returns + * VAL_UINT32_T, vitural address of hw register memory mapping + */ +VAL_ULONG_T eHalGetMMAP(VAL_HANDLE_T *a_hHalHandle, VAL_UINT32_T RegAddr); + + +/** + * @par Function + * eHalCmdProc + * @par Description + * The hal command processing function + * @param + * a_hHalHandle [IN/OUT] The hal handle + * @param + * a_eHalCmd [IN] The hal command structure + * @param + * a_pvInParam [IN] The hal input parameter + * @param + * a_pvOutParam [OUT] The hal output parameter + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return else if failed + */ +VAL_RESULT_T eHalCmdProc( + VAL_HANDLE_T *a_hHalHandle, + HAL_CMD_T a_eHalCmd, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _HAL_API_H_ */ diff --git a/kernel-headers/hal_types_private.h b/kernel-headers/hal_types_private.h new file mode 100644 index 0000000..a713ef6 --- /dev/null +++ b/kernel-headers/hal_types_private.h @@ -0,0 +1,15 @@ +#ifndef _HAL_TYPES_PRIVATE_H_ +#define _HAL_TYPES_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "hal_types_public.h" + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _HAL_TYPES_PRIVATE_H_ */ diff --git a/kernel-headers/hal_types_public.h b/kernel-headers/hal_types_public.h new file mode 100644 index 0000000..e976e7d --- /dev/null +++ b/kernel-headers/hal_types_public.h @@ -0,0 +1,44 @@ +#ifndef _HAL_TYPES_PUBLIC_H_ +#define _HAL_TYPES_PUBLIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" + +/** + * @par Structure + * HAL_POWER_T + * @par Description + * This is a parameter for power related function + */ +typedef struct _HAL_POWER_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_DRIVER_TYPE_T eDriverType; /* /< [IN] The driver type */ + VAL_BOOL_T fgEnable; /* /< [IN] Enable or not */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} HAL_POWER_T; + +/** + * @par Structure + * HAL_ISR_T + * @par Description + * This is a parameter for ISR related function + */ +typedef struct _HAL_ISR_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_DRIVER_TYPE_T eDriverType; /* /< [IN] The driver type */ + VAL_BOOL_T fgRegister; /* /< [IN] Register or un-register */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} HAL_ISR_T; + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _HAL_TYPES_PUBLIC_H_ */ diff --git a/kernel-headers/hevcd_if.h b/kernel-headers/hevcd_if.h new file mode 100644 index 0000000..871e45a --- /dev/null +++ b/kernel-headers/hevcd_if.h @@ -0,0 +1,98 @@ +#ifndef _HEVC_DECODE_IF_H_ +#define _HEVC_DECODE_IF_H_ + +/* #include "hevcd.h" */ +/* #include "hevc_common_if.h" */ +#include "vcodec_if_v2.h" +#include "vcodec_dec_demuxer_if_v2.h" +#define MAX_DECODE_BUFFERS 15 +#define _FILE_IO_ +/* extern int frame_num; */ +typedef struct { + + void (*hevc_pfnMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + IN VCODEC_MEMORY_TYPE_T /* fgCacheable */, + OUT VCODEC_BUFFER_T * /* prBuf */ + ); /* buffer address must cache line align */ + + void (*pfnFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuf */ + ); /* same memory type with malloc */ + +} hevcd_callback_t; + +typedef struct { + unsigned char *buffer_origin; + unsigned char *luma; + unsigned char *cb, *cr; + int y_stride, uv_stride; + int width, height; + int ref_count; +} decode_picture_buffer_info_t; + + +typedef struct { + unsigned char *start_address; + int length; +} HEVC_ACCESS_UNIT_T; + +#define MAX_ACCESS_UNIT_NUMBER 32 + +typedef struct { + HEVC_ACCESS_UNIT_T au_list[MAX_ACCESS_UNIT_NUMBER]; + int au_number; + +} HEVC_DECODE_INP_T; + +typedef struct { + unsigned char *y; + unsigned char *u; + unsigned char *v; + + int y_stride; + int uv_stride; + + int width; + int height; +} HEVC_DECODE_PICTURE_T; + +typedef struct { + int width; + int height; +} HEVC_PICTURE_INFO_T; + + +VCODEC_DEC_ERROR_T HEVCDecoderGetMemoryRequired( + VCODEC_DEC_INPUT_T * prInput, + VCODEC_MEMORY_SIZE_T *prMemeorySize, + VCODEC_DEC_OUTPUT_BUFFER_PARAM_T *prYUVBufferParameter, + VCODEC_MEMORY_TYPE_T * prBitStreamBufferMemType +); +VCODEC_DEC_ERROR_T HEVCDecoderGetMemoryRequiredExtend( + VCODEC_DEC_INPUT_T * prInput, + VCODEC_MEMORY_SIZE_T *prMemeorySize, + VCODEC_DEC_OUTPUT_BUFFER_PARAM_T *prYUVBufferParameter, + OUT VCODEC_DEC_INPUT_BUFFER_PARAM_T * prBitStreamParam, + INOUT void *prExtra +); +VCODEC_DEC_ERROR_T HEVCDecoderInitAdapt(IN HANDLE hCodec); +VCODEC_DEC_ERROR_T HEVCDecoderDeInitAdapt(IN HANDLE hCodec); +VCODEC_DEC_ERROR_T HEVCDecoderOpenAdapt( + IN HANDLE hDrv , + IN VCODEC_DEC_CALLBACK_T * pfnCallback, + IN void *prOpenSetting, OUT HANDLE * hCodec +); +VCODEC_DEC_ERROR_T HEVCDecoderStartAdapt(IN HANDLE hCodec, IN VCODEC_DEC_INPUT_T * prBufferHeader); +VCODEC_DEC_ERROR_T HEVCDecoderCloseAdapt(IN HANDLE hCodec); +VCODEC_DEC_ERROR_T HEVCDecoderGetNextDisplay(IN HANDLE hCodec, OUT VCODEC_DEC_PRIVATE_OUTPUT_T * prPrivateOutput); +VCODEC_DEC_ERROR_T HEVCDecoderGetParameterAdapt(IN HANDLE hCodec, IN VCODEC_DEC_PARAM_TYPE_T eCmd, INOUT void *pParam); +VCODEC_DEC_ERROR_T HEVCDecoderSetParameterAdapt(IN HANDLE hCodec, IN VCODEC_DEC_PARAM_TYPE_T eCmd, INOUT void *pParam); + +extern VCODEC_DEC_API_T *GetHEVCDecoderAPI(void); + +VCODEC_DEC_API_T *GetHEVCDecoderAPI(void); + + +#endif diff --git a/kernel-headers/kd_camera_feature.h b/kernel-headers/kd_camera_feature.h new file mode 100644 index 0000000..3286da1 --- /dev/null +++ b/kernel-headers/kd_camera_feature.h @@ -0,0 +1,38 @@ +#ifndef _KD_CAMERA_FEATURE_H_ +#define _KD_CAMERA_FEATURE_H_ + + +#ifndef FTYPE_ENUM +#define FTYPE_ENUM(_enums...) _enums +#endif /* FTYPE_ENUM */ + +#ifndef FID_TO_TYPE_ENUM +#define FID_TO_TYPE_ENUM(_fid, _enums) \ + typedef enum { _enums/*, OVER_NUM_OF_##_fid*/ } +#endif /* FID_TO_TYPE_ENUM */ + +#include "kd_camera_feature_id.h" +#include "kd_camera_feature_enum.h" + + +typedef enum { + ORIENTATION_ANGLE_0 = 0, + ORIENTATION_ANGLE_90 = 90, + ORIENTATION_ANGLE_180 = 180, + ORIENTATION_ANGLE_270 = 270 +} ORIENTATION_ANGLE; + + +typedef enum { + DUAL_CAMERA_NONE_SENSOR = 0, + DUAL_CAMERA_MAIN_SENSOR = 1, + DUAL_CAMERA_SUB_SENSOR = 2, + DUAL_CAMERA_MAIN_2_SENSOR = 4, + /* for backward compatible */ + DUAL_CAMERA_MAIN_SECOND_SENSOR = 4, + /* DUAL_CAMERA_SUB_2_SENSOR = 16, */ + DUAL_CAMERA_SENSOR_MAX +} CAMERA_DUAL_CAMERA_SENSOR_ENUM; + + +#endif /* _KD_IMGSENSOR_DATA_H */ diff --git a/kernel-headers/kd_camera_feature_enum.h b/kernel-headers/kd_camera_feature_enum.h new file mode 100644 index 0000000..98d4e3a --- /dev/null +++ b/kernel-headers/kd_camera_feature_enum.h @@ -0,0 +1,594 @@ +#ifndef _KD_CAMERA_FEATURE_ENUM_H_ +#define _KD_CAMERA_FEATURE_ENUM_H_ + + +/* Scene Mode */ +FID_TO_TYPE_ENUM( + FID_SCENE_MODE, + FTYPE_ENUM( + SCENE_MODE_BEGIN = 0, + SCENE_MODE_OFF = SCENE_MODE_BEGIN, /* Disable scene mode equal Auto mode */ + SCENE_MODE_NORMAL, /* Normal mode */ + SCENE_MODE_ACTION, /* Action mode */ + SCENE_MODE_PORTRAIT, /* Portrait mode */ + SCENE_MODE_LANDSCAPE, /* Landscape */ + SCENE_MODE_NIGHTSCENE, /* Night Scene */ + SCENE_MODE_NIGHTPORTRAIT, /* Night Portrait */ + SCENE_MODE_THEATRE, /* Theatre mode */ + SCENE_MODE_BEACH, /* Beach mode */ + SCENE_MODE_SNOW, /* Snow mode */ + SCENE_MODE_SUNSET, /* Sunset mode */ + SCENE_MODE_STEADYPHOTO, /* Steady photo mode */ + SCENE_MODE_FIREWORKS, /* Fireworks mode */ + SCENE_MODE_SPORTS, /* Sports mode */ + SCENE_MODE_PARTY, /* Party mode */ + SCENE_MODE_CANDLELIGHT, /* Candle light mode */ + /* (Unsupported legacy symbol; don't use this symbol if possible) */ + SCENE_MODE_ISO_ANTI_SHAKE, /* ISO Anti Shake mode */ + /* (Unsupported legacy symbol; don't use this symbol if possible) */ + SCENE_MODE_BRACKET_AE, /* Bracket AE */ + SCENE_MODE_HDR, + SCENE_MODE_FACE_PRIORITY, + SCENE_MODE_BARCODE, + SCENE_MODE_NUM + ) +)SCENE_MODE_T; + + +/* Effect */ +FID_TO_TYPE_ENUM( + FID_COLOR_EFFECT, + FTYPE_ENUM( + MEFFECT_BEGIN = 0, + MEFFECT_OFF = MEFFECT_BEGIN, + MEFFECT_MONO, + MEFFECT_SEPIA, + MEFFECT_NEGATIVE, + MEFFECT_SOLARIZE, + MEFFECT_POSTERIZE, + MEFFECT_AQUA, + MEFFECT_BLACKBOARD, + MEFFFECT_BLACKBOARD = MEFFECT_BLACKBOARD, /* legacy symbol (don't use if possible) */ + MEFFECT_WHITEBOARD, + MEFFECT_SEPIAGREEN, + MEFFECT_SEPIABLUE, + MEFFECT_NASHVILLE, + MEFFECT_HEFE, + MEFFECT_VALENCIA, + MEFFECT_XPROII, + MEFFECT_LOFI, + MEFFECT_SIERRA, + MEFFECT_KELVIN, + MEFFECT_WALDEN, + MEFFECT_F1977, + MEFFECT_NUM + ) +)MCOLOR_EFFECT; + + +/* AWB Mode */ +FID_TO_TYPE_ENUM( + FID_AWB_MODE, + FTYPE_ENUM( + AWB_MODE_BEGIN = 0, + AWB_MODE_OFF = AWB_MODE_BEGIN, + AWB_MODE_AUTO, + AWB_MODE_DAYLIGHT, + AWB_MODE_CLOUDY_DAYLIGHT, + AWB_MODE_SHADE, + AWB_MODE_TWILIGHT, + AWB_MODE_FLUORESCENT, + AWB_MODE_WARM_FLUORESCENT, + AWB_MODE_INCANDESCENT, + AWB_MODE_TUNGSTEN, + /* (Unsupported legacy symbol; don't use this symbol if possible) */ + AWB_MODE_GRAYWORLD, /* Gray world mode for CCT use */ + AWB_MODE_NUM + ) +)AWB_MODE_T; + + +/* AE Flicker */ +FID_TO_TYPE_ENUM( + FID_AE_FLICKER, + FTYPE_ENUM( + AE_FLICKER_MODE_BEGIN = 0, + AE_FLICKER_MODE_60HZ = AE_FLICKER_MODE_BEGIN, + AE_FLICKER_MODE_50HZ, + AE_FLICKER_MODE_AUTO, + AE_FLICKER_MODE_OFF, + AE_FLICKER_MODE_TOTAL_NUM + ) +)AE_FLICKER_MODE_T; + + +/* AE EV */ +FID_TO_TYPE_ENUM( + FID_AE_EV, + FTYPE_ENUM( + AE_EV_COMP_BEGIN = 0, + AE_EV_COMP_00 = AE_EV_COMP_BEGIN, /* Disable EV compenate */ + AE_EV_COMP_03, /* EV compensate 0.3 */ + AE_EV_COMP_05, /* EV compensate 0.5 */ + AE_EV_COMP_07, /* EV compensate 0.7 */ + AE_EV_COMP_10, /* EV compensate 1.0 */ + AE_EV_COMP_13, /* EV compensate 1.3 */ + AE_EV_COMP_15, /* EV compensate 1.5 */ + AE_EV_COMP_17, /* EV compensate 1.7 */ + AE_EV_COMP_20, /* EV compensate 2.0 */ + AE_EV_COMP_23, /* EV compensate 2.3 */ + AE_EV_COMP_25, /* EV compensate 2.5 */ + AE_EV_COMP_27, /* EV compensate 2.7 */ + AE_EV_COMP_30, /* EV compensate 3.0 */ + AE_EV_COMP_n03, /* EV compensate -0.3 */ + AE_EV_COMP_n05, /* EV compensate -0.5 */ + AE_EV_COMP_n07, /* EV compensate -0.7 */ + AE_EV_COMP_n10, /* EV compensate -1.0 */ + AE_EV_COMP_n13, /* EV compensate -1.3 */ + AE_EV_COMP_n15, /* EV compensate -1.5 */ + AE_EV_COMP_n17, /* EV compensate -1.7 */ + AE_EV_COMP_n20, /* EV compensate -2.0 */ + AE_EV_COMP_n23, /* EV compensate -2.3 */ + AE_EV_COMP_n25, /* EV compensate -2.5 */ + AE_EV_COMP_n27, /* EV compensate -2.7 */ + AE_EV_COMP_n30, /* EV compensate -3.0 */ + AE_EV_COMP_TOTAL_NUM + ) +)AE_EVCOMP_T; + + +/* AE Mode */ +FID_TO_TYPE_ENUM( + FID_AE_SCENE_MODE, + FTYPE_ENUM( + AE_MODE_BEGIN = 0, + AE_MODE_OFF = AE_MODE_BEGIN, /* disable AE */ + AE_MODE_AUTO, /* auto mode full auto ,EV ISO LCE .. is inactive */ + AE_MODE_PROGRAM, /* AE program mode , allow set EV ISO LCE .... */ + AE_MODE_TV, /* AE TV mode */ + AE_MODE_AV, /* AE AV mode */ + AE_MODE_SV, /* AE SV mode */ + AE_MODE_VIDEO, /* Video mode AE */ + AE_MODE_NIGHT, /* Night Scene mode */ + AE_MODE_ACTION, /* AE Action mode */ + AE_MODE_BEACH, /* AE beach mode */ + AE_MODE_CANDLELIGHT, /* AE Candlelight mode */ + AE_MODE_FIREWORKS, /* AE firework mode */ + AE_MODE_LANDSCAPE, /* AE landscape mode */ + AE_MODE_PORTRAIT, /* AE portrait mode */ + AE_MODE_NIGHT_PORTRAIT, /* AE night portrait mode */ + AE_MODE_PARTY, /* AE party mode */ + AE_MODE_SNOW, /* AE snow mode */ + AE_MODE_SPORTS, /* AE sport mode */ + AE_MODE_STEADYPHOTO, /* AE steadyphoto mode */ + AE_MODE_SUNSET, /* AE sunset mode */ + AE_MODE_THEATRE, /* AE theatre mode */ + AE_MODE_ISO_ANTI_SHAKE, /* AE ISO anti shake mode */ + AE_MODE_BRACKET_AE, + AE_MODE_AUTO_PANORAMA, + AE_MODE_HDR, + AE_MODE_TOTAL_NUM + ) +)AE_MODE_T; + + +/* AE Metering */ +FID_TO_TYPE_ENUM( + FID_AE_METERING, + FTYPE_ENUM( + AE_METERING_BEGIN = 0, + AE_METERING_MODE_CENTER_WEIGHT = AE_METERING_BEGIN, /* CENTER WEIGHTED MODE */ + AE_METERING_MODE_SOPT, /* SPOT MODE */ + AE_METERING_MODE_AVERAGE, /* AVERAGE MODE */ + NUM_OF_AE_METER + ) +)AE_METERING_T; + + +/* AE ISO */ +FID_TO_TYPE_ENUM( + FID_AE_ISO, + FTYPE_ENUM( + AE_ISO_BEGIN = 0, + AE_ISO_AUTO = AE_ISO_BEGIN, + AE_ISO_100, + AE_ISO_200, + AE_ISO_400, + AE_ISO_800, + AE_ISO_1600, + NUM_OF_AE_ISO + ) +)AE_ISO_T; + + +/* AE Strobe / Flashlight */ +FID_TO_TYPE_ENUM( + FID_AE_STROBE, + FTYPE_ENUM( + FLASHLIGHT_BEGIN = 0, + FLASHLIGHT_AUTO = FLASHLIGHT_BEGIN, + FLASHLIGHT_FORCE_ON, + FLASHLIGHT_FORCE_OFF, + FLASHLIGHT_REDEYE, + FLASHLIGHT_TORCH, + NUM_OF_FLASHLIGHT + ) +)AE_STROBE_T; + +/* AF Mode */ +FID_TO_TYPE_ENUM( + FID_AF_MODE, + FTYPE_ENUM( + AF_MODE_BEGIN = 0, + AF_MODE_AFS = AF_MODE_BEGIN, /* (AF-Single Shot Mode) */ + AF_MODE_AFC, /* AF-Continuous Mode */ + AF_MODE_AFC_VIDEO, /* AF-Continuous Mode (Video) */ + AF_MODE_MACRO, /* AF Macro Mode */ + AF_MODE_INFINITY, /* Focus is set at infinity. */ + AF_MODE_MF, /* Manual Focus Mode */ + AF_MODE_FULLSCAN, /* AF Full Scan Mode */ + NUM_OF_AF_MODE + ) +)AF_MODE_T; + + +/* AF Metering */ +FID_TO_TYPE_ENUM( + FID_AF_METERING, + FTYPE_ENUM( + AF_METERING_BEGIN = 0, + AF_METER_SPOT = AF_METERING_BEGIN, /* Spot Window */ + AF_METER_MATRIX, /* Matrix Window */ + AF_METER_MOVESPOT, + NUM_OF_AF_METER + ) +)_AF_METERING_T; + +/* ISP Edge */ +FID_TO_TYPE_ENUM( + FID_ISP_EDGE, + FTYPE_ENUM( + ISP_EDGE_BEGIN = 0, + ISP_EDGE_LOW = ISP_EDGE_BEGIN, + ISP_EDGE_MIDDLE, + ISP_EDGE_HIGH, + NUM_OF_ISP_EDGE + ) +)ISP_EDGE_T; + + +/* ISP Hue */ +FID_TO_TYPE_ENUM( + FID_ISP_HUE, + FTYPE_ENUM( + ISP_HUE_BEGIN = 0, + ISP_HUE_LOW = ISP_HUE_BEGIN, + ISP_HUE_MIDDLE, + ISP_HUE_HIGH, + NUM_OF_ISP_HUE + ) +)ISP_HUE_T; + + +/* ISP Saturation */ +FID_TO_TYPE_ENUM( + FID_ISP_SAT, + FTYPE_ENUM( + ISP_SAT_BEGIN = 0, + ISP_SAT_LOW = ISP_SAT_BEGIN, + ISP_SAT_MIDDLE, + ISP_SAT_HIGH, + NUM_OF_ISP_SAT + ) +)ISP_SAT_T; + + +/* ISP Brightness */ +FID_TO_TYPE_ENUM( + FID_ISP_BRIGHT, + FTYPE_ENUM( + ISP_BRIGHT_BEGIN = 0, + ISP_BRIGHT_LOW = ISP_BRIGHT_BEGIN, + ISP_BRIGHT_MIDDLE, + ISP_BRIGHT_HIGH, + NUM_OF_ISP_BRIGHT + ) +)ISP_BRIGHT_T; + + +/* ISP Contrast */ +FID_TO_TYPE_ENUM( + FID_ISP_CONTRAST, + FTYPE_ENUM( + ISP_CONTRAST_BEGIN = 0, + ISP_CONTRAST_LOW = ISP_CONTRAST_BEGIN, + ISP_CONTRAST_MIDDLE, + ISP_CONTRAST_HIGH, + NUM_OF_ISP_CONTRAST + ) +)ISP_CONTRAST_T; + +/* Capture Mode */ +FID_TO_TYPE_ENUM( + FID_CAPTURE_MODE, + FTYPE_ENUM( + CAPTURE_MODE_BEGIN = 0, + CAPTURE_MODE_NORMAL = CAPTURE_MODE_BEGIN, + CAPTURE_MODE_BURST_SHOT, + CAPTURE_MODE_SMILE_SHOT, + CAPTURE_MODE_PANORAMA, + CAPTURE_MODE_AUTORAMA, + CAPTURE_MODE_BEST_SHOT, + CAPTURE_MODE_EV_BRACKET, + CAPTURE_MODE_MAV, + CAPTURE_MODE_HDR, + CAPTURE_MODE_ASD, + CAPTURE_MODE_ZSD, /* Zero-shutter-delay Shot */ + CAPTURE_MODE_PANO_3D, + CAPTURE_MODE_SINGLE_3D, + CAPTURE_MODE_FACE_BEAUTY, + CAPTURE_MODE_CONTINUOUS_SHOT, + CAPTURE_MODE_MULTI_MOTION, + NUM_OF_CAPTURE_MODE + ) +)CAPTURE_MODE_T; + + +/* Capture Size */ +FID_TO_TYPE_ENUM( + FID_CAP_SIZE, + FTYPE_ENUM( + CAPTURE_SIZE_BEGIN = 0, + CAPTURE_SIZE_320_240 = CAPTURE_SIZE_BEGIN, + CAPTURE_SIZE_640_480, + CAPTURE_SIZE_1024_768, + CAPTURE_SIZE_1280_960, + CAPTURE_SIZE_1600_1200, + CAPTURE_SIZE_2048_1536, + CAPTURE_SIZE_2560_1920, + CAPTURE_SIZE_3264_2448, + CAPTURE_SIZE_4000_3000, + NUM_OF_CAPTURE_SIZE + ) +)CAPTURE_SIZE_T; + + +/* Preview Size */ +FID_TO_TYPE_ENUM( + FID_PREVIEW_SIZE, + FTYPE_ENUM( + PREVIEW_SIZE_BEGIN = 0, + PREVIEW_SIZE_160_120 = PREVIEW_SIZE_BEGIN, + PREVIEW_SIZE_176_144, + PREVIEW_SIZE_320_240, + PREVIEW_SIZE_352_288, + PREVIEW_SIZE_480_320, + PREVIEW_SIZE_480_368, + PREVIEW_SIZE_640_480, + PREVIEW_SIZE_720_480, + PREVIEW_SIZE_800_480, + PREVIEW_SIZE_864_480, + PREVIEW_SIZE_800_600, + PREVIEW_SIZE_1280_720, + PREVIEW_SIZE_1920_1080, + NUM_OF_PREVIEW_SIZE + ) +)PREVIEW_SIZE_T; + +/* Video Preview Size */ +FID_TO_TYPE_ENUM( + FID_VIDEO_PREVIEW_SIZE, + FTYPE_ENUM( + VIDEO_PREVIEW_SIZE_BEGIN = 0, + VIDEO_PREVIEW_SIZE_640_480 = VIDEO_PREVIEW_SIZE_BEGIN, + VIDEO_PREVIEW_SIZE_800_600, + NUM_OF_VIDEO_PREVIEW_SIZE + ) +)VIDEO_PREVIEW_SIZE_T; + + +/* Frame Rate */ +FID_TO_TYPE_ENUM( + FID_FRAME_RATE, + FTYPE_ENUM( + FRAME_RATE_BEGIN = 0, + FRAME_RATE_000FPS = FRAME_RATE_BEGIN, /* 0.0fps */ + FRAME_RATE_010FPS, + FRAME_RATE_020FPS, + FRAME_RATE_030FPS, + FRAME_RATE_040FPS, + FRAME_RATE_050FPS, + FRAME_RATE_060FPS, + FRAME_RATE_070FPS, + FRAME_RATE_075FPS = FRAME_RATE_070FPS, /* legacy definition. */ + FRAME_RATE_080FPS, + FRAME_RATE_090FPS, + FRAME_RATE_100FPS, /* 10 fps */ + FRAME_RATE_110FPS, + FRAME_RATE_120FPS, + FRAME_RATE_125FPS = FRAME_RATE_120FPS, /* legacy definition. */ + FRAME_RATE_130FPS, + FRAME_RATE_140FPS, + FRAME_RATE_150FPS, + FRAME_RATE_160FPS, + FRAME_RATE_170FPS, + FRAME_RATE_180FPS, + FRAME_RATE_190FPS, + FRAME_RATE_200FPS, /* 20 fps */ + FRAME_RATE_210FPS, + FRAME_RATE_220FPS, + FRAME_RATE_230FPS, + FRAME_RATE_240FPS, + FRAME_RATE_250FPS, + FRAME_RATE_260FPS, + FRAME_RATE_270FPS, + FRAME_RATE_280FPS, + FRAME_RATE_290FPS, + FRAME_RATE_300FPS, /* 30 fps */ + NUM_OF_FRAME_RATE + ) +)FRAME_RATE_T; + +/* Frame Rate Range */ +FID_TO_TYPE_ENUM( + FID_FRAME_RATE_RANGE, + FTYPE_ENUM( + FRAME_RATE_RANGE_BEGIN = 0, + FRAME_RATE_RANGE_5_30_FPS = FRAME_RATE_RANGE_BEGIN, /* 5-30fps */ + NUM_OF_FRAME_RATE_RANGE + ) +)FRAME_RATE_RANGE_T; + + +/* Focus Distance Normal */ +FID_TO_TYPE_ENUM( + FID_FOCUS_DIST_NORMAL, + FTYPE_ENUM( + FOCUS_DIST_N_BEGIN = 0, + FOCUS_DIST_N_INFINITE = FOCUS_DIST_N_BEGIN, /* Infinite */ + FOCUS_DIST_N_10CM, + NUM_OF_FOCUS_DIST_N + ) +)FOCUS_DIST_NORMAL_T; + + +/* Focus Distance Macro */ +FID_TO_TYPE_ENUM( + FID_FOCUS_DIST_MACRO, + FTYPE_ENUM( + FOCUS_DIST_M_BEGIN = 0, + FOCUS_DIST_M_INFINITE = FOCUS_DIST_M_BEGIN, /* Infinite */ + FOCUS_DIST_M_5CM, + FOCUS_DIST_M_10CM, + NUM_OF_FOCUS_DIST_M + ) +)FOCUS_DIST_MACRO_T; + + +/* Face Detection */ +FID_TO_TYPE_ENUM( + FID_FD_ON_OFF, + FTYPE_ENUM( + FD_BEGIN = 0, + FD_OFF = FD_BEGIN, + FD_ON, + NUM_OF_FD + ) +)FD_MODE_T; + + +/* EIS */ +FID_TO_TYPE_ENUM( + FID_EIS, + FTYPE_ENUM( + EIS_BEGIN = 0, + EIS_OFF = EIS_BEGIN, + EIS_ON, + NUM_OF_EIS + ) +)EIS_T; + +/* ZSD */ +FID_TO_TYPE_ENUM( + FID_ZSD, + FTYPE_ENUM( + ZSD_BEGIN = 0, + ZSD_OFF = ZSD_BEGIN, + ZSD_ON, + NUM_OF_ZSD + ) +)ZSD_T; + +/* AF LAMP */ +FID_TO_TYPE_ENUM( + FID_AF_LAMP, + FTYPE_ENUM( + AF_LAMP_BEGIN = 0, + AF_LAMP_OFF = AF_LAMP_BEGIN, + AF_LAMP_ON, + AF_LAMP_AUTO, + AF_LAMP_FLASH, + NUM_OF_AF_LAMP + ) +)AF_LAMP_T; + +/* Stereo 3D Capture Size */ +FID_TO_TYPE_ENUM( + FID_STEREO_3D_CAP_SIZE, + FTYPE_ENUM( + STEREO_3D_CAPTURE_SIZE_BEGIN = 0, + STEREO_3D_CAPTURE_SIZE_2560_720 = STEREO_3D_CAPTURE_SIZE_BEGIN, + STEREO_3D_CAPTURE_SIZE_3840_1080, + NUM_OF_STEREO_3D_CAPTURE_SIZE + ) +)STEREO_3D_CAPTURE_SIZE_T; + +/* Stereo 3D Preview Size */ +FID_TO_TYPE_ENUM( + FID_STEREO_3D_PREVIEW_SIZE, + FTYPE_ENUM( + STEREO_3D_PREVIEW_SIZE_BEGIN = 0, + STEREO_3D_PREVIEW_SIZE_640_360 = STEREO_3D_PREVIEW_SIZE_BEGIN, + STEREO_3D_PREVIEW_SIZE_854_480, + STEREO_3D_PREVIEW_SIZE_960_540, + STEREO_3D_PREVIEW_SIZE_1280_720, + NUM_OF_STEREO_3D_PREVIEW_SIZE + ) +)STEREO_3D_PREVIEW_SIZE_T; + +/* Stereo 3D Type */ +FID_TO_TYPE_ENUM( + FID_STEREO_3D_TYPE, + FTYPE_ENUM( + STEREO_3D_TYPE_BEGIN = 0, + STEREO_3D_NOT_SUPPORT = STEREO_3D_TYPE_BEGIN, + STEREO_3D_FRAME_SEQ, + STEREO_3D_SIDE_BY_SIDE, + STEREO_3D_TOP_BOTTOM, + NUM_OF_STEREO_3D_TYPE + ) +)STEREO_3D_TYPE_T; + +/* Stereo 3D Mode */ +FID_TO_TYPE_ENUM( + FID_STEREO_3D_MODE, + FTYPE_ENUM( + STEREO_3D_MODE_BEGIN = 0, + STEREO_3D_OFF = STEREO_3D_MODE_BEGIN, + STEREO_3D_ON, + NUM_OF_STEREO_3D_MODE + ) +)STEREO_3D_MODE_T; + +/* Stereo 3D Image Format */ +FID_TO_TYPE_ENUM( + FID_STEREO_3D_IMAGE_FORMAT, + FTYPE_ENUM( + STEREO_3D_IMAGE_FORMAT_BEGIN = 0, + STEREO_3D_JPS = STEREO_3D_IMAGE_FORMAT_BEGIN, + STEREO_3D_MPO, + NUM_OF_STEREO_3D_IMAGE_FORMAT + ) +)STEREO_3D_IMAGE_FORMAT_T; + +/* YUV Auto test */ +FID_TO_TYPE_ENUM( + FID_YUV_AUTOTEST, + FTYPE_ENUM( + YUV_AUTOTEST_BEGIN = 0, + YUV_AUTOTEST_SET_SHADDING = YUV_AUTOTEST_BEGIN, + YUV_AUTOTEST_SET_GAMMA, + YUV_AUTOTEST_SET_AE, + YUV_AUTOTEST_SET_SHUTTER, + YUV_AUTOTEST_SET_GAIN, + YUV_AUTOTEST_GET_SHUTTER_RANGE, + YUV_AUTOTEST_GET_SHADDING, + YUV_AUTOTEST_GET_GAMMA, + YUV_AUTOTEST_GET_AE, + YUV_AUTOTEST_GET_SHUTTER, + YUV_AUTOTEST_GET_GAIN, + NUM_OF_YUV_AUTOTEST + ) +)YUV_AUTOTEST_T; + +#endif /* _KD_CAMERA_FEATURE_ENUM_H_ */ diff --git a/kernel-headers/kd_camera_feature_id.h b/kernel-headers/kd_camera_feature_id.h new file mode 100644 index 0000000..c44c496 --- /dev/null +++ b/kernel-headers/kd_camera_feature_id.h @@ -0,0 +1,92 @@ +#ifndef _KD_CAMERA_FEATURE_ID_H_ +#define _KD_CAMERA_FEATURE_ID_H_ + + + +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* Definition of Feature ID. */ +/* ps: FID = 0 is reserved. */ +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +typedef enum { + FID_PRE_BEGIN = 0, + /* //////////////////////////////////////////////////////////////////////////// */ + /* Scene-Independent (SI) feature id. */ + FID_PRE_BEGIN_SI = FID_PRE_BEGIN, + /* ---------------------------------------------------------------------------- */ + /* Misc. feature id. */ + FID_PRE_BEGIN_MISC_SI = FID_PRE_BEGIN_SI, + FID_ZOOM_FACTOR, /* Legacy symbol (Remove if possible) */ + FID_AE_STROBE, + FID_EIS, + FID_ZSD, + FID_AWB2PASS, + FID_AF_LAMP, + FID_FAST_CONTINUOUS_SHOT, + FID_OVER_LAST_MISC_SI, + FID_PRE_BEGIN_RAW_ONLY_SI = FID_OVER_LAST_MISC_SI - 1, + FID_OVER_LAST_RAW_ONLY_SI, + FID_PRE_BEGIN_RAW_YUV_SI = FID_OVER_LAST_RAW_ONLY_SI - 1, + FID_SCENE_MODE, + FID_COLOR_EFFECT, + FID_CAPTURE_MODE, + FID_CAP_SIZE, + FID_PREVIEW_SIZE, + FID_VIDEO_PREVIEW_SIZE, + FID_FRAME_RATE, + FID_FRAME_RATE_RANGE, + FID_AE_FLICKER, + FID_FOCUS_DIST_NORMAL, + FID_FOCUS_DIST_MACRO, + FID_STEREO_3D_CAP_SIZE, + FID_STEREO_3D_PREVIEW_SIZE, + FID_STEREO_3D_TYPE, + FID_STEREO_3D_MODE, + FID_STEREO_3D_IMAGE_FORMAT, + FID_OVER_LAST_RAW_YUV_SI, + /* YUV-only feature id. */ + FID_PRE_BEGIN_YUV_ONLY_SI = FID_OVER_LAST_RAW_YUV_SI - 1, + FID_OVER_LAST_YUV_ONLY_SI, + + /* ---------------------------------------------------------------------------- */ + FID_OVER_LAST_SI = FID_OVER_LAST_YUV_ONLY_SI, + /* //////////////////////////////////////////////////////////////////////////// */ + /* Scene-Dependent (SD) feature id. */ + FID_PRE_BEGIN_SD = FID_OVER_LAST_SI - 1, + /* ---------------------------------------------------------------------------- */ + /* Misc. feature id. */ + FID_PRE_BEGIN_MISC_SD = FID_PRE_BEGIN_SD, + FID_FD_ON_OFF, + FID_OVER_LAST_MISC_SD, + /* RAW-only feature id. */ + FID_PRE_BEGIN_RAW_ONLY_SD = FID_OVER_LAST_MISC_SD - 1, + FID_OVER_LAST_RAW_ONLY_SD, + /* RAW-YUV-shared feature id. */ + FID_PRE_BEGIN_RAW_YUV_SD = FID_OVER_LAST_RAW_ONLY_SD - 1, + FID_AE_SCENE_MODE, + FID_AE_METERING, + FID_AE_ISO, + FID_AE_EV, + FID_AF_MODE, + FID_AF_METERING, + FID_AWB_MODE, + FID_ISP_EDGE, + FID_ISP_HUE, + FID_ISP_SAT, + FID_ISP_BRIGHT, + FID_ISP_CONTRAST, + FID_OVER_LAST_RAW_YUV_SD, + /* YUV-only feature id. */ + FID_PRE_BEGIN_YUV_ONLY_SD = FID_OVER_LAST_RAW_YUV_SD - 1, + FID_YUV_AUTOTEST, + FID_OVER_LAST_YUV_ONLY_SD, + + /* ---------------------------------------------------------------------------- */ + FID_OVER_LAST_SD = FID_OVER_LAST_YUV_ONLY_SD, + /* //////////////////////////////////////////////////////////////////////////// */ + FID_OVER_LAST = FID_OVER_LAST_SD +/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ + +} FEATURE_ID; + + +#endif /* _KD_CAMERA_FEATURE_ID_H_ */ diff --git a/kernel-headers/kd_imgsensor.h b/kernel-headers/kd_imgsensor.h new file mode 100644 index 0000000..98ace23 --- /dev/null +++ b/kernel-headers/kd_imgsensor.h @@ -0,0 +1,462 @@ +#ifndef _KD_IMGSENSOR_H +#define _KD_IMGSENSOR_H + +#include <linux/ioctl.h> +/* #define CONFIG_COMPAT */ +#ifdef CONFIG_COMPAT +/* 64 bit */ +#include <linux/fs.h> +#include <linux/compat.h> +#endif + +#ifndef ASSERT +#define ASSERT(expr) BUG_ON(!(expr)) +#endif + +#define IMGSENSORMAGIC 'i' +/* IOCTRL(inode * ,file * ,cmd ,arg ) */ +/* S means "set through a ptr" */ +/* T means "tell by a arg value" */ +/* G means "get by a ptr" */ +/* Q means "get by return a value" */ +/* X means "switch G and S atomically" */ +/* H means "switch T and Q atomically" */ + +/******************************************************************************* +* +********************************************************************************/ +#define YUV_INFO(_id, name, getCalData)\ + { \ + _id, name, \ +NSFeature : : YUVSensorInfo < _id > : : createInstance(name, #name), \ + (NSFeature : : SensorInfoBase*(*)()) \ +NSFeature : : YUVSensorInfo < _id > : : getInstance, \ +NSFeature : : YUVSensorInfo < _id > : : getDefaultData, \ + getCalData, \ +NSFeature : : YUVSensorInfo < _id > : : getNullFlickerPara \ + } +#define RAW_INFO(_id, name, getCalData)\ + { \ + _id, name, \ +NSFeature : : RAWSensorInfo < _id > : : createInstance(name, #name), \ + (NSFeature : : SensorInfoBase*(*)()) \ +NSFeature : : RAWSensorInfo < _id > : : getInstance, \ +NSFeature : : RAWSensorInfo < _id > : : getDefaultData, \ + getCalData, \ +NSFeature : : RAWSensorInfo < _id > : : getFlickerPara \ + } +/******************************************************************************* +* +********************************************************************************/ + +/* sensorOpen */ +#define KDIMGSENSORIOC_T_OPEN _IO(IMGSENSORMAGIC, 0) +/* sensorGetInfo */ +#define KDIMGSENSORIOC_X_GETINFO _IOWR(IMGSENSORMAGIC, 5, ACDK_SENSOR_GETINFO_STRUCT) +/* sensorGetResolution */ +#define KDIMGSENSORIOC_X_GETRESOLUTION _IOWR(IMGSENSORMAGIC, 10, ACDK_SENSOR_RESOLUTION_INFO_STRUCT) +/* For kernel 64-bit */ +#define KDIMGSENSORIOC_X_GETRESOLUTION2 _IOWR(IMGSENSORMAGIC, 10, ACDK_SENSOR_PRESOLUTION_STRUCT) +/* sensorFeatureControl */ +#define KDIMGSENSORIOC_X_FEATURECONCTROL _IOWR(IMGSENSORMAGIC, 15, ACDK_SENSOR_FEATURECONTROL_STRUCT) +/* sensorControl */ +#define KDIMGSENSORIOC_X_CONTROL _IOWR(IMGSENSORMAGIC, 20, ACDK_SENSOR_CONTROL_STRUCT) +/* sensorClose */ +#define KDIMGSENSORIOC_T_CLOSE _IO(IMGSENSORMAGIC, 25) +/* sensorSearch */ +#define KDIMGSENSORIOC_T_CHECK_IS_ALIVE _IO(IMGSENSORMAGIC, 30) +/* set sensor driver */ +#define KDIMGSENSORIOC_X_SET_DRIVER _IOWR(IMGSENSORMAGIC, 35, SENSOR_DRIVER_INDEX_STRUCT) +/* get socket postion */ +#define KDIMGSENSORIOC_X_GET_SOCKET_POS _IOWR(IMGSENSORMAGIC, 40, u32) +/* set I2C bus */ +#define KDIMGSENSORIOC_X_SET_I2CBUS _IOWR(IMGSENSORMAGIC, 45, u32) +/* set I2C bus */ +#define KDIMGSENSORIOC_X_RELEASE_I2C_TRIGGER_LOCK _IO(IMGSENSORMAGIC, 50) +/* Set Shutter Gain Wait Done */ +#define KDIMGSENSORIOC_X_SET_SHUTTER_GAIN_WAIT_DONE _IOWR(IMGSENSORMAGIC, 55, u32) +/* set mclk */ +#define KDIMGSENSORIOC_X_SET_MCLK_PLL _IOWR(IMGSENSORMAGIC, 60, ACDK_SENSOR_MCLK_STRUCT) +#define KDIMGSENSORIOC_X_GETINFO2 _IOWR(IMGSENSORMAGIC, 65, IMAGESENSOR_GETINFO_STRUCT) +/* set open/close sensor index */ +#define KDIMGSENSORIOC_X_SET_CURRENT_SENSOR _IOWR(IMGSENSORMAGIC, 70, u32) +/* set GPIO */ +#define KDIMGSENSORIOC_X_SET_GPIO _IOWR(IMGSENSORMAGIC, 75, IMGSENSOR_GPIO_STRUCT) +/* Get ISP CLK */ +#define KDIMGSENSORIOC_X_GET_ISP_CLK _IOWR(IMGSENSORMAGIC, 80, u32) + +#ifdef CONFIG_COMPAT +#define COMPAT_KDIMGSENSORIOC_X_GETINFO _IOWR(IMGSENSORMAGIC, 5, COMPAT_ACDK_SENSOR_GETINFO_STRUCT) +#define COMPAT_KDIMGSENSORIOC_X_FEATURECONCTROL _IOWR(IMGSENSORMAGIC, 15, COMPAT_ACDK_SENSOR_FEATURECONTROL_STRUCT) +#define COMPAT_KDIMGSENSORIOC_X_CONTROL _IOWR(IMGSENSORMAGIC, 20, COMPAT_ACDK_SENSOR_CONTROL_STRUCT) +#define COMPAT_KDIMGSENSORIOC_X_GETINFO2 _IOWR(IMGSENSORMAGIC, 65, COMPAT_IMAGESENSOR_GETINFO_STRUCT) +#define COMPAT_KDIMGSENSORIOC_X_GETRESOLUTION2 _IOWR(IMGSENSORMAGIC, 10, COMPAT_ACDK_SENSOR_PRESOLUTION_STRUCT) +#endif + +/******************************************************************************* +* +********************************************************************************/ +/* SENSOR CHIP VERSION */ +/*IMX*/ +#define IMX220_SENSOR_ID 0x0220 +#define IMX145_SENSOR_ID 0x0145 +#define IMX219_SENSOR_ID 0x0219 +#define IMX215_SENSOR_ID 0x0215 +#define IMX214_SENSOR_ID 0x0214 +#define IMX179_SENSOR_ID 0x0179 +#define IMX175_SENSOR_ID 0x0175 +#define IMX178_SENSOR_ID 0x0178 +#define IMX164_SENSOR_ID 0x0164 +#define IMX135_SENSOR_ID 0x0135 +#define IMX132MIPI_SENSOR_ID 0x0132 +#define IMX119_SENSOR_ID 0x0119 +#define IMX105_SENSOR_ID 0x0105 +#define IMX091_SENSOR_ID 0x0091 +#define IMX073_SENSOR_ID 0x0046 +#define IMX058_SENSOR_ID 0x0058 +#define IMX166_SENSOR_ID 0x0152 +/*OV*/ +#define OV23850_SENSOR_ID 0x023850 +#define OV16825MIPI_SENSOR_ID 0x016820 +#define OV13850_SENSOR_ID 0xD850 +#define OV12830_SENSOR_ID 0xC830 +#define OV9760MIPI_SENSOR_ID 0x9760 +#define OV9762MIPI_SENSOR_ID 0x9762 +#define OV9762SUBMIPI_SENSOR_ID 0x9763 +#define OV9740MIPI_SENSOR_ID 0x9740 +#define OV9726_SENSOR_ID 0x9726 +#define OV9726MIPI_SENSOR_ID 0x9726 +#define OV8865_SENSOR_ID 0x8865 +#define OV8858_SENSOR_ID 0x8858 +#define OV8858S_SENSOR_ID (0x8858+1) +#define OV8858TRULY_SENSOR_ID 0x885a +#define OV8858SUNNY_SENSOR_ID 0x8859 +#define OV8830_SENSOR_ID 0x8830 +#define OV8825_SENSOR_ID 0x8825 +#define OV7675_SENSOR_ID 0x7673 +#define OV5693_SENSOR_ID 0x5690 +#define OV5670MIPI_SENSOR_ID 0x5670 +#define OV5670SUBMIPI_SENSOR_ID 0x5672 +#define OV5671MIPI_SENSOR_ID 0x5671 +#define OV5650_SENSOR_ID 0x5651 +#define OV5650MIPI_SENSOR_ID 0x5651 +#define OV5648MIPI_SENSOR_ID 0x5648 +#define OV5647_SENSOR_ID 0x5647 +#define OV5647MIPI_SENSOR_ID 0x5647 +#define OV5645MIPI_SENSOR_ID 0x5645 +#define OV5642_SENSOR_ID 0x5642 +#define OV4688MIPI_SENSOR_ID 0x4688 +#define OV3640_SENSOR_ID 0x364C +#define OV2724MIPI_SENSOR_ID 0x2724 +#define OV2722MIPI_SENSOR_ID 0x2722 +#define OV2680MIPI_SENSOR_ID 0x2680 +#define OV2680_SENSOR_ID 0x2680 +#define OV2659_SENSOR_ID 0x2656 +#define OV2655_SENSOR_ID 0x2656 +#define OV2650_SENSOR_ID 0x2652 +#define OV2650_SENSOR_ID_1 0x2651 +#define OV2650_SENSOR_ID_2 0x2652 +#define OV2650_SENSOR_ID_3 0x2655 +/*S5K*/ +#define S5K2X8_SENSOR_ID 0x2188 +#define S5K2P8_SENSOR_ID 0x2108 +#define S5K3M2_SENSOR_ID 0x30D2 +#define S5K3M2TRULY_SENSOR_ID 0x30D4 +#define S5K3M2SUNNY_SENSOR_ID 0x30D3 +#define S5K3AAEA_SENSOR_ID 0x07AC +#define S5K3BAFB_SENSOR_ID 0x7070 +#define S5K3H7Y_SENSOR_ID 0x3087 +#define S5K3H2YX_SENSOR_ID 0x382b +#define S5KA3DFX_SENSOR_ID 0x00AB +#define S5K3E2FX_SENSOR_ID 0x3E2F +#define S5K4B2FX_SENSOR_ID 0x5080 +#define S5K4E1GA_SENSOR_ID 0x4E10 +#define S5K4ECGX_SENSOR_ID 0x4EC0 +#define S5K53BEX_SENSOR_ID 0x45A8 +#define S5K53BEB_SENSOR_ID 0x87A8 +#define S5K5BAFX_SENSOR_ID 0x05BA +#define S5K4E2GX_SENSOR_ID 0x4e20 +#define S5K5E2YA_SENSOR_ID 0x5e20 +#define S5K5E2YASUB_SENSOR_ID 0x5e21 +#define S5K4H5YX_2LANE_SENSOR_ID 0x485B +#define S5K4H5YC_SENSOR_ID 0x485B +#define S5K4H5YC_2LANE_SENSOR_ID 0x485b +#define S5K83AFX_SENSOR_ID 0x01C4 +#define S5K5CAGX_SENSOR_ID 0x05ca +#define S5K8AAYX_MIPI_SENSOR_ID 0x08aa +#define S5K8AAYX_SENSOR_ID 0x08aa +#define S5K3L2_SENSOR_ID 0x30c2 +#define S5K3H5XA_SENSOR_ID 0x3085 +/*HI*/ +#define HI841_SENSOR_ID 0x0841 +#define HI707_SENSOR_ID 0x00b8 +#define HI704_SENSOR_ID 0x0096 +#define HI551_SENSOR_ID 0x0551 +#define HI545MIPI_SENSOR_ID 0x0545 +#define HI544MIPI_SENSOR_ID 0x0544 +#define HI542_SENSOR_ID 0x00B1 +#define HI542MIPI_SENSOR_ID 0x00B1 +#define HI253_SENSOR_ID 0x0092 +#define HI251_SENSOR_ID 0x0084 +#define HI191MIPI_SENSOR_ID 0x0191 +#define HIVICF_SENSOR_ID 0x0081 +/*MT*/ +#define MT9D011_SENSOR_ID 0x1511 +#define MT9D111_SENSOR_ID 0x1511 +#define MT9D112_SENSOR_ID 0x1580 +#define MT9M011_SENSOR_ID 0x1433 +#define MT9M111_SENSOR_ID 0x143A +#define MT9M112_SENSOR_ID 0x148C +#define MT9M113_SENSOR_ID 0x2480 +#define MT9P012_SENSOR_ID 0x2800 +#define MT9P012_SENSOR_ID_REV7 0x2801 +#define MT9T012_SENSOR_ID 0x1600 +#define MT9T013_SENSOR_ID 0x2600 +#define MT9T113_SENSOR_ID 0x4680 +#define MT9V112_SENSOR_ID 0x1229 +#define MT9DX11_SENSOR_ID 0x1519 +#define MT9D113_SENSOR_ID 0x2580 +#define MT9D115_SENSOR_ID 0x2580 +#define MT9D115MIPI_SENSOR_ID 0x2580 +#define MT9V113_SENSOR_ID 0x2280 +#define MT9V114_SENSOR_ID 0x2283 +#define MT9V115_SENSOR_ID 0x2284 +#define MT9P015_SENSOR_ID 0x2803 +#define MT9P017_SENSOR_ID 0x4800 +#define MT9P017MIPI_SENSOR_ID 0x4800 +#define MT9T113MIPI_SENSOR_ID 0x4680 +/*GC*/ +#define GC2755_SENSOR_ID 0x2655 +#define GC2355_SENSOR_ID 0x2355 +#define GC2365_SENSOR_ID 0x2365 +#define GC2355SUB_SENSOR_ID 0x2356 +#define GC2235_SENSOR_ID 0x2235 + +#define GC2235MIPI_SENSOR_ID 0x2235 + +#define GC2035_SENSOR_ID 0x2035 +#define GC2145_SENSOR_ID 0x2145 +#define GC0330_SENSOR_ID 0xC1 +#define GC0329_SENSOR_ID 0xC0 +#define GC0310_SENSOR_ID 0xa310 +#define GC0310MAIN_SENSOR_ID 0xa311 +#define GC2155MIPI_SENSOR_ID 0x2155 +#define GC0313MIPI_YUV_SENSOR_ID 0xD0 +#define GC0409_SENSOR_ID 0x0409 +#define GC5004MIPI_SENSOR_ID 0x5004 +#define GC5005MIPI_SENSOR_ID 0x5005 +#define GC5005SUBMIPI_SENSOR_ID 0x5006 +#define GC5024MIPI_SENSOR_ID 0x5024 +#define GC8024MIPI_SENSOR_ID 0x8024 +#define GC8003MIPI_SENSOR_ID 0x8003 +/*SP*/ +#define SP0A19_YUV_SENSOR_ID 0xA6 +#define SP0A20_SENSOR_ID 0x2b +#define SP2508_SENSOR_ID 0x2508 +#define SP2509MIPI_SENSOR_ID 0x2509 +#define SP2518_YUV_SENSOR_ID 0x53 +#define SP5409MIPI_SENSOR_ID 0x5409 +#define SP5409SUBMIPI_SENSOR_ID 0x540a +#define SP8408MIPI_SENSOR_ID 0x1490 +/*A*/ +#define A5141MIPI_SENSOR_ID 0x4800 +#define A5142MIPI_SENSOR_ID 0x4800 +/*HM*/ +#define HM3451_SENSOR_ID 0x345 +#define HM5040_SENSOR_ID 0x3bb +/*AR*/ +#define AR0833_SENSOR_ID 0x4B03 +/*SIV*/ +#define SID020A_SENSOR_ID 0x12B4 +#define SIV100B_SENSOR_ID 0x0C11 +#define SIV100A_SENSOR_ID 0x0C10 +#define SIV120A_SENSOR_ID 0x1210 +#define SIV120B_SENSOR_ID 0x0012 +#define SIV121D_SENSOR_ID 0xDE +#define SIM101B_SENSOR_ID 0x09A0 +#define SIM120C_SENSOR_ID 0x0012 +#define SID130B_SENSOR_ID 0x001b +#define SIC110A_SENSOR_ID 0x000D +#define SIV120B_SENSOR_ID 0x0012 +/*PAS (PixArt Image)*/ +#define PAS105_SENSOR_ID 0x0065 +#define PAS302_SENSOR_ID 0x0064 +#define PAS5101_SENSOR_ID 0x0067 +#define PAS6180_SENSOR_ID 0x6179 +/*Panasoic*/ +#define MN34152_SENSOR_ID 0x01 +/*Toshiba*/ +#define T4KA7_SENSOR_ID 0x2c30 +/*Others*/ +#define SHARP3D_SENSOR_ID 0x003d +#define T8EV5_SENSOR_ID 0x1011 + +/* CAMERA DRIVER NAME */ +#define CAMERA_HW_DEVNAME "kd_camera_hw" +/* SENSOR DEVICE DRIVER NAME */ +/*IMX*/ +#define SENSOR_DRVNAME_IMX220_MIPI_RAW "imx220mipiraw" +#define SENSOR_DRVNAME_IMX145_MIPI_RAW "imx145mipiraw" +#define SENSOR_DRVNAME_IMX219_MIPI_RAW "imx219mipiraw" +#define SENSOR_DRVNAME_IMX215_MIPI_RAW "imx215mipiraw" +#define SENSOR_DRVNAME_IMX214_MIPI_RAW "imx214mipiraw" +#define SENSOR_DRVNAME_IMX179_MIPI_RAW "imx179mipiraw" +#define SENSOR_DRVNAME_IMX179_MIPI_RAW_4LANE "imx179mipiraw4lane" +#define SENSOR_DRVNAME_IMX175_MIPI_RAW "imx175mipiraw" +#define SENSOR_DRVNAME_IMX178_MIPI_RAW "imx178mipiraw" +#define SENSOR_DRVNAME_IMX164_MIPI_RAW "imx164mipiraw" +#define SENSOR_DRVNAME_IMX135_MIPI_RAW "imx135mipiraw" +#define SENSOR_DRVNAME_IMX132_MIPI_RAW "imx132mipiraw" +#define SENSOR_DRVNAME_IMX119_MIPI_RAW "imx119mipiraw" +#define SENSOR_DRVNAME_IMX105_MIPI_RAW "imx105mipiraw" +#define SENSOR_DRVNAME_IMX091_MIPI_RAW "imx091mipiraw" +#define SENSOR_DRVNAME_IMX073_MIPI_RAW "imx073mipiraw" +#define SENSOR_DRVNAME_IMX166_MIPI_RAW "imx166mipiraw" +/*OV*/ +#define SENSOR_DRVNAME_OV16825_MIPI_RAW "ov16825mipiraw" +#define SENSOR_DRVNAME_OV13850_MIPI_RAW "ov13850mipiraw" +#define SENSOR_DRVNAME_OV12830_MIPI_RAW "ov12830mipiraw" +#define SENSOR_DRVNAME_OV9760_MIPI_RAW "ov9760mipiraw" +#define SENSOR_DRVNAME_OV9762_MIPI_RAW "ov9762mipiraw" +#define SENSOR_DRVNAME_OV9762SUB_MIPI_RAW "ov9762submipiraw" +#define SENSOR_DRVNAME_OV9740_MIPI_YUV "ov9740mipiyuv" +#define SENSOR_DRVNAME_0V9726_RAW "ov9726raw" +#define SENSOR_DRVNAME_OV9726_MIPI_RAW "ov9726mipiraw" +#define SENSOR_DRVNAME_OV8865_MIPI_RAW "ov8865mipiraw" +#define SENSOR_DRVNAME_OV8858_MIPI_RAW "ov8858mipiraw" +#define SENSOR_DRVNAME_OV8858S_MIPI_RAW "ov8858smipiraw" +#define SENSOR_DRVNAME_OV8858TRULY_MIPI_RAW "ov8858trulymipiraw" +#define SENSOR_DRVNAME_OV8858SUNNY_MIPI_RAW "ov8858sunnymipiraw" +#define SENSOR_DRVNAME_OV8830_RAW "ov8830" +#define SENSOR_DRVNAME_OV8825_MIPI_RAW "ov8825mipiraw" +#define SENSOR_DRVNAME_OV7675_YUV "ov7675yuv" +#define SENSOR_DRVNAME_OV5693_MIPI_RAW "ov5693mipi" +#define SENSOR_DRVNAME_OV5670_MIPI_RAW "ov5670mipiraw" +#define SENSOR_DRVNAME_OV5670SUB_MIPI_RAW "ov5670submipiraw" +#define SENSOR_DRVNAME_OV5671_MIPI_RAW "ov5671mipiraw" +#define SENSOR_DRVNAME_OV5647MIPI_RAW "ov5647mipiraw" +#define SENSOR_DRVNAME_OV5645_MIPI_YUV "ov5645_mipi_yuv" +#define SENSOR_DRVNAME_OV5650MIPI_RAW "ov5650mipiraw" +#define SENSOR_DRVNAME_OV5650_RAW "ov5650raw" +#define SENSOR_DRVNAME_OV5648_MIPI_RAW "ov5648mipi" +#define SENSOR_DRVNAME_OV5647_RAW "ov5647" +#define SENSOR_DRVNAME_OV5642_RAW "ov5642raw" +#define SENSOR_DRVNAME_OV5642_MIPI_YUV "ov5642mipiyuv" +#define SENSOR_DRVNAME_OV5642_MIPI_RGB "ov5642mipirgb" +#define SENSOR_DRVNAME_OV5642_MIPI_JPG "ov5642mipijpg" +#define SENSOR_DRVNAME_OV5642_YUV "ov5642yuv" +#define SENSOR_DRVNAME_OV5642_YUV_SWI2C "ov5642yuvswi2c" +#define SENSOR_DRVNAME_OV4688_MIPI_RAW "ov4688mipiraw" +#define SENSOR_DRVNAME_OV3640_RAW "ov3640" +#define SENSOR_DRVNAME_OV3640_YUV "ov3640yuv" +#define SENSOR_DRVNAME_OV2722_MIPI_RAW "ov2722mipiraw" +#define SENSOR_DRVNAME_OV2680_MIPI_RAW "ov2680mipiraw" +#define SENSOR_DRVNAME_OV2659_YUV "ov2659yuv" +#define SENSOR_DRVNAME_OV2655_YUV "ov2655yuv" +#define SENSOR_DRVNAME_OV2650_RAW "ov265x" +/*S5K*/ +#define SENSOR_DRVNAME_S5K2P8_MIPI_RAW "s5k2p8mipiraw" +#define SENSOR_DRVNAME_S5K3M2_MIPI_RAW "s5k3m2mipiraw" +#define SENSOR_DRVNAME_S5K3M2TRULY_MIPI_RAW "s5k3m2trulymipiraw" +#define SENSOR_DRVNAME_S5K3M2SUNNY_MIPI_RAW "s5k3m2sunnymipiraw" +#define SENSOR_DRVNAME_S5K3H2YX_MIPI_RAW "s5k3h2yxmipiraw" +#define SENSOR_DRVNAME_S5K3H7Y_MIPI_RAW "s5k3h7ymipiraw" +#define SENSOR_DRVNAME_S5K4H5YC_MIPI_RAW "s5k4h5ycmipiraw" +#define SENSOR_DRVNAME_S5K4E1GA_MIPI_RAW "s5k4e1gamipiraw" +#define SENSOR_DRVNAME_S5K4ECGX_MIPI_YUV "s5k4ecgxmipiyuv" +#define SENSOR_DRVNAME_S5K5CAGX_YUV "s5k5cagxyuv" +#define SENSOR_DRVNAME_S5K4H5YX_2LANE_MIPI_RAW "s5k4h5yx2lanemipiraw" +#define SENSOR_DRVNAME_S5K4E2GX_MIPI_RAW "s5k4e2gxmipiraw" +#define SENSOR_DRVNAME_S5K5E2YA_MIPI_RAW "s5k5e2yamipiraw" +#define SENSOR_DRVNAME_S5K5E2YASUB_MIPI_RAW "s5k5e2yasubmipiraw" +#define SENSOR_DRVNAME_S5K8AAYX_MIPI_YUV "s5k8aayxmipiyuv" +#define SENSOR_DRVNAME_S5K8AAYX_YUV "s5k8aayxyuv" +#define SENSOR_DRVNAME_S5K3L2_MIPI_RAW "s5k3l2mipiraw" +#define SENSOR_DRVNAME_S5K3H5XA_MIPI_RAW "s5k3h5xamipiraw" +#define SENSOR_DRVNAME_S5K4H5YC_MIPI_RAW_2LANE "s5k4h5ycmipiraw2lane" +/*HI*/ +#define SENSOR_DRVNAME_HI841_MIPI_RAW "hi841mipiraw" +#define SENSOR_DRVNAME_HI707_YUV "hi707yuv" +#define SENSOR_DRVNAME_HI704_YUV "hi704yuv" +#define SENSOR_DRVNAME_HI551_MIPI_RAW "hi551mipiraw" +#define SENSOR_DRVNAME_HI545_MIPI_RAW "hi545mipiraw" +#define SENSOR_DRVNAME_HI542_RAW "hi542raw" +#define SENSOR_DRVNAME_HI542MIPI_RAW "hi542mipiraw" +#define SENSOR_DRVNAME_HI544_MIPI_RAW "hi544mipiraw" +#define SENSOR_DRVNAME_HI253_YUV "hi253yuv" +#define SENSOR_DRVNAME_HI191_MIPI_RAW "hi191mipiraw" +/*MT*/ +#define SENSOR_DRVNAME_MT9P012_RAW "mt9p012" +#define SENSOR_DRVNAME_MT9P015_RAW "mt9p015" +#define SENSOR_DRVNAME_MT9P017_RAW "mt9p017" +#define SENSOR_DRVNAME_MT9P017_MIPI_RAW "mt9p017mipi" +#define SENSOR_DRVNAME_MT9D115_MIPI_RAW "mt9d115mipiraw" +#define SENSOR_DRVNAME_MT9V114_YUV "mt9v114" +#define SENSOR_DRVNAME_MT9V115_YUV "mt9v115yuv" +#define SENSOR_DRVNAME_MT9T113_YUV "mt9t113yuv" +#define SENSOR_DRVNAME_MT9V113_YUV "mt9v113yuv" +#define SENSOR_DRVNAME_MT9T113_MIPI_YUV "mt9t113mipiyuv" +/*GC*/ +#define SENSOR_DRVNAME_GC2035_YUV "gc2035_yuv" +#define SENSOR_DRVNAME_GC2235_RAW "gc2235_raw" +#define SENSOR_DRVNAME_GC2235_MIPI_RAW "gc2235mipiraw" +#define SENSOR_DRVNAME_GC2755_MIPI_RAW "gc2755mipiraw" +#define SENSOR_DRVNAME_GC2355_MIPI_RAW "gc2355mipiraw" +#define SENSOR_DRVNAME_GC2365_MIPI_RAW "gc2365mipiraw" +#define SENSOR_DRVNAME_GC2355SUB_MIPI_RAW "gc2356submipiraw" +#define SENSOR_DRVNAME_GC0330_YUV "gc0330_yuv" +#define SENSOR_DRVNAME_GC0329_YUV "gc0329yuv" +#define SENSOR_DRVNAME_GC2145_MIPI_YUV "gc2145mipiyuv" +#define SENSOR_DRVNAME_GC0310_MIPI_YUV "gc0310mipiyuv" +#define SENSOR_DRVNAME_GC0310MAIN_MIPI_YUV "gc0310mainmipiyuv" +#define SENSOR_DRVNAME_GC0310_YUV "gc0310yuv" +#define SENSOR_DRVNAME_GC2155_MIPI_YUV "gc2155mipiyuv" +#define SENSOR_DRVNAME_GC0313MIPI_YUV "gc0313mipiyuv" +#define SENSOR_DRVNAME_GC0409MIPI_RAW "gc0409mipiraw" +#define SENSOR_DRVNAME_GC5004_MIPI_RAW "gc5004mipiraw" +#define SENSOR_DRVNAME_GC5005_MIPI_RAW "gc5005mipiraw" +#define SENSOR_DRVNAME_GC5005SUB_MIPI_RAW "gc5005submipiraw" +#define SENSOR_DRVNAME_GC5024_MIPI_RAW "gc5024mipiraw" +#define SENSOR_DRVNAME_GC8024_MIPI_RAW "gc8024mipiraw" +#define SENSOR_DRVNAME_GC8003_MIPI_RAW "gc8003mipiraw" +/*SP*/ +#define SENSOR_DRVNAME_SP0A19_YUV "sp0a19yuv" +#define SENSOR_DRVNAME_SP0A20_YUV "sp0a20yuv" +#define SENSOR_DRVNAME_SP2508_MIPI_RAW "sp2508mipiraw" +#define SENSOR_DRVNAME_SP2509_MIPI_RAW "sp2509mipiraw" +#define SENSOR_DRVNAME_SP2518_YUV "sp2518yuv" +#define SENSOR_DRVNAME_SP5409_MIPI_RAW "sp5409_mipi_raw" +#define SENSOR_DRVNAME_SP5409SUB_MIPI_RAW "sp5409sub_mipi_raw" +#define SENSOR_DRVNAME_SP8408_MIPI_RAW "sp8408_mipi_raw" +/*A*/ +#define SENSOR_DRVNAME_A5141_MIPI_RAW "a5141mipiraw" +#define SENSOR_DRVNAME_A5142_MIPI_RAW "a5142mipiraw" +/*HM*/ +#define SENSOR_DRVNAME_HM3451_RAW "hm3451raw" +#define SENSOR_DRVNAME_HM5040_MIPI_RAW "hm5040mipiraw" +/*AR*/ +#define SENSOR_DRVNAME_AR0833_MIPI_RAW "ar0833mipiraw" +/*SIV*/ +#define SENSOR_DRVNAME_SIV121D_YUV "siv121dyuv" +#define SENSOR_DRVNAME_SIV120B_YUV "siv120byuv" +/*PAS (PixArt Image)*/ +#define SENSOR_DRVNAME_PAS6180_SERIAL_YUV "pas6180serialyuv" +/*Panasoic*/ +#define SENSOR_DRVNAME_MN34152_MIPI_RAW "mn34152mipiraw" +/*Toshiba*/ +#define SENSOR_DRVNAME_T4KA7_MIPI_RAW "t4ka7mipiraw" +/*Others*/ +#define SENSOR_DRVNAME_SHARP3D_MIPI_YUV "sharp3dmipiyuv" +#define SENSOR_DRVNAME_T8EV5_YUV "t8ev5_yuv" +/*Test*/ +#define SENSOR_DRVNAME_IMX135_MIPI_RAW_5MP "imx135mipiraw5mp" + +/******************************************************************************* +* +********************************************************************************/ +void KD_IMGSENSOR_PROFILE_INIT(void); +void KD_IMGSENSOR_PROFILE(char *tag); + +#define mDELAY(ms) mdelay(ms) +#define uDELAY(us) udelay(us) +#endif /* _KD_IMGSENSOR_H */ diff --git a/kernel-headers/kd_imgsensor_define.h b/kernel-headers/kd_imgsensor_define.h new file mode 100644 index 0000000..8eab108 --- /dev/null +++ b/kernel-headers/kd_imgsensor_define.h @@ -0,0 +1,1108 @@ +#ifndef _KD_IMGSENSOR_DATA_H +#define _KD_IMGSENSOR_DATA_H + +/* #include "../camera/kd_camera_hw.h" */ +#include "kd_camera_feature.h" + +#define SENSOR_CLOCK_POLARITY_HIGH 0 +#define SENSOR_CLOCK_POLARITY_LOW 1 +/* #define CONFIG_COMPAT */ +#ifdef CONFIG_COMPAT +/* 64 bit */ +#include <linux/fs.h> +#include <linux/compat.h> +#endif + + + +/************************************************* +* +**************************************************/ +/* In KERNEL mode,SHOULD be sync with mediatype.h */ +/* CHECK before remove or modify */ +/* #undef BOOL */ +/* #define BOOL signed int */ +#ifndef _MEDIA_TYPES_H +typedef unsigned char MUINT8; +typedef unsigned short MUINT16; +typedef unsigned int MUINT32; +typedef signed char MINT8; +typedef signed short MINT16; +typedef signed int MINT32; +#endif + +/******************************************************************************* +* +********************************************************************************/ +/* */ +/* msdk_isp_exp.h */ +/* */ +#define BASEGAIN 0x40 +#define BASEGAIN_SHIFT 6 + +typedef enum { + ISP_DRIVING_2MA = 0, + ISP_DRIVING_4MA, + ISP_DRIVING_6MA, + ISP_DRIVING_8MA +} ISP_DRIVING_CURRENT_ENUM; + + + +enum { + IMAGE_NORMAL = 0, + IMAGE_H_MIRROR, + IMAGE_V_MIRROR, + IMAGE_HV_MIRROR +}; + + +typedef enum { + MSDK_SCENARIO_ID_CAMERA_PREVIEW = 0, + MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG, + MSDK_SCENARIO_ID_VIDEO_PREVIEW, + MSDK_SCENARIO_ID_HIGH_SPEED_VIDEO, + MSDK_SCENARIO_ID_CAMERA_ZSD, + MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW, + MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE, + MSDK_SCENARIO_ID_CAMERA_3D_VIDEO, + MSDK_SCENARIO_ID_TV_OUT, + MSDK_SCENARIO_ID_SLIM_VIDEO, + MSDK_SCENARIO_ID_CUSTOM1, + MSDK_SCENARIO_ID_CUSTOM2, + MSDK_SCENARIO_ID_CUSTOM3, + MSDK_SCENARIO_ID_CUSTOM4, + MSDK_SCENARIO_ID_CUSTOM5, + MSDK_SCENARIO_ID_MAX, +} MSDK_SCENARIO_ID_ENUM; + + +typedef enum { + MSDK_CAMERA_OPERATION_NORMAL_MODE = 0, + MSDK_CAMERA_OPERATION_META_MODE +} ACDK_CAMERA_OPERATION_MODE_ENUM; + + +/******************************************************************************* +* +********************************************************************************/ + +/* */ +#define MAX_NUM_OF_SUPPORT_SENSOR 16 +/* */ +#define SENSOR_CLOCK_POLARITY_HIGH 0 +#define SENSOR_CLOCK_POLARITY_LOW 1 +/* */ +#define LENS_DRIVER_ID_DO_NOT_CARE 0xFFFFFFFF +#define SENSOR_DOES_NOT_EXIST 0x00FFFFFF +#define SENSOR_DOES_NOT_KNOW 0xFFFFFFFF + +#define SENSOR_FEATURE_START 3000 +typedef enum { + SENSOR_FEATURE_BEGIN = SENSOR_FEATURE_START, + SENSOR_FEATURE_GET_RESOLUTION, + SENSOR_FEATURE_GET_PERIOD, + SENSOR_FEATURE_GET_PIXEL_CLOCK_FREQ, + SENSOR_FEATURE_SET_ESHUTTER, + SENSOR_FEATURE_SET_NIGHTMODE, + SENSOR_FEATURE_SET_GAIN, + SENSOR_FEATURE_SET_GAIN_AND_ESHUTTER, + SENSOR_FEATURE_SET_FLASHLIGHT, + SENSOR_FEATURE_SET_ISP_MASTER_CLOCK_FREQ, + SENSOR_FEATURE_SET_REGISTER, + SENSOR_FEATURE_GET_REGISTER, + SENSOR_FEATURE_SET_CCT_REGISTER, + SENSOR_FEATURE_GET_CCT_REGISTER, + SENSOR_FEATURE_SET_ENG_REGISTER, + SENSOR_FEATURE_GET_ENG_REGISTER, + SENSOR_FEATURE_GET_REGISTER_DEFAULT, + SENSOR_FEATURE_GET_CONFIG_PARA, + SENSOR_FEATURE_CAMERA_PARA_TO_SENSOR, + SENSOR_FEATURE_SENSOR_TO_CAMERA_PARA, + SENSOR_FEATURE_GET_GROUP_COUNT, + SENSOR_FEATURE_GET_GROUP_INFO, + SENSOR_FEATURE_GET_ITEM_INFO, + SENSOR_FEATURE_SET_ITEM_INFO, + SENSOR_FEATURE_GET_ENG_INFO, + SENSOR_FEATURE_GET_LENS_DRIVER_ID, + SENSOR_FEATURE_SET_YUV_CMD, + SENSOR_FEATURE_SET_VIDEO_MODE, + SENSOR_FEATURE_SET_TARGET_FRAME_RATE, + SENSOR_FEATURE_SET_CALIBRATION_DATA, + SENSOR_FEATURE_SET_SENSOR_SYNC, + SENSOR_FEATURE_INITIALIZE_AF, + SENSOR_FEATURE_CONSTANT_AF, + SENSOR_FEATURE_INFINITY_AF, + SENSOR_FEATURE_MOVE_FOCUS_LENS, + SENSOR_FEATURE_GET_AF_STATUS, + SENSOR_FEATURE_GET_AE_STATUS, + SENSOR_FEATURE_GET_AWB_STATUS, + SENSOR_FEATURE_GET_AF_INF, + SENSOR_FEATURE_GET_AF_MACRO, + SENSOR_FEATURE_CHECK_SENSOR_ID, + SENSOR_FEATURE_SET_AUTO_FLICKER_MODE, + SENSOR_FEATURE_SET_TEST_PATTERN, + SENSOR_FEATURE_SET_SOFTWARE_PWDN, + SENSOR_FEATURE_SINGLE_FOCUS_MODE, + SENSOR_FEATURE_CANCEL_AF, + SENSOR_FEATURE_SET_AF_WINDOW, + SENSOR_FEATURE_GET_EV_AWB_REF, + SENSOR_FEATURE_GET_SHUTTER_GAIN_AWB_GAIN, + SENSOR_FEATURE_GET_AF_MAX_NUM_FOCUS_AREAS, + SENSOR_FEATURE_GET_AE_MAX_NUM_METERING_AREAS, + SENSOR_FEATURE_SET_AE_WINDOW, + SENSOR_FEATURE_GET_EXIF_INFO, + SENSOR_FEATURE_GET_DELAY_INFO, + SENSOR_FEATURE_SET_SLAVE_I2C_ID, + SENSOR_FEATURE_SUSPEND, + SENSOR_FEATURE_RESUME, + SENSOR_FEATURE_SET_MAX_FRAME_RATE_BY_SCENARIO, + SENSOR_FEATURE_GET_DEFAULT_FRAME_RATE_BY_SCENARIO, + SENSOR_FEATURE_GET_AE_AWB_LOCK_INFO, + SENSOR_FEATURE_AUTOTEST_CMD, + SENSOR_FEATURE_GET_TEST_PATTERN_CHECKSUM_VALUE, + SENSOR_FEATURE_GET_TEMPERATURE_VALUE, + SENSOR_FEATURE_GET_SENSOR_CURRENT_TEMPERATURE, + SENSOR_FEATURE_GET_AE_FLASHLIGHT_INFO, + SENSOR_FEATURE_GET_TRIGGER_FLASHLIGHT_INFO, /* Trigger flashlight or not */ + SENSOR_FEATURE_SET_YUV_3A_CMD, + SENSOR_FEATURE_SET_N3D_I2C_STREAM_REGDATA, + SENSOR_FEATURE_SET_N3D_STOP_STREAMING, + SENSOR_FEATURE_SET_N3D_START_STREAMING, + SENSOR_FEATURE_GET_SENSOR_N3D_STREAM_TO_VSYNC_TIME, + SENSOR_FEATURE_SET_ESHUTTER_GAIN, + SENSOR_FEATURE_SET_OB_LOCK, + SENSOR_FEATURE_SET_SENSOR_OTP_AWB_CMD, + SENSOR_FEATURE_SET_SENSOR_OTP_LSC_CMD, + SENSOR_FEATURE_GET_YUV_CAPTURE_OUTPUT_JPEG, + SENSOR_FEATURE_SET_YUV_JPEG_PARA, + SENSOR_FEATURE_GET_YUV_JPEG_INFO, + SENSOR_FEATURE_SET_FRAMERATE, + SENSOR_FEATURE_SET_HDR, + SENSOR_FEATURE_GET_CROP_INFO, + SENSOR_FEATURE_GET_VC_INFO, + SENSOR_FEATURE_SET_IHDR_SHUTTER_GAIN, + SENSOR_FEATURE_SET_AWB_GAIN, + SENSOR_FEATURE_SET_MIN_MAX_FPS, + SENSOR_FEATURE_GET_PDAF_INFO, + SENSOR_FEATURE_GET_PDAF_DATA, + SENSOR_FEATURE_GET_SENSOR_PDAF_CAPACITY, + SENSOR_FEATURE_DEBUG_IMGSENSOR, + SENSOR_FEATURE_SET_HDR_SHUTTER, + SENSOR_FEATURE_SET_ISO, + SENSOR_FEATURE_SET_PDAF, + SENSOR_FEATURE_MAX +} ACDK_SENSOR_FEATURE_ENUM; + +typedef enum { + SENSOR_AF_IDLE = 0, + SENSOR_AF_FOCUSING, + SENSOR_AF_FOCUSED, + SENSOR_AF_ERROR, + SENSOR_AF_SCENE_DETECTING, + SENSOR_AF_STATUS_MAX +} ACDK_SENSOR_AF_STATUS_ENUM; + +typedef enum { + SENSOR_AE_IDLE = 0, + SENSOR_AE_EXPOSING, + SENSOR_AE_EXPOSED, + SENSOR_AE_ERROR, + SENSOR_AE_LOCKED +} ACDK_SENSOR_AE_STATUS_ENUM; + +typedef enum { + SENSOR_AWB_IDLE = 0, + SENSOR_AWB_BALANCING, + SENSOR_AWB_BALANCED, + SENSOR_AWB_ERROR, + SENSOR_AWB_LOCKED +} ACDK_SENSOR_AWB_STATUS_ENUM; + + + +typedef enum { + SENSOR_INTERFACE_TYPE_PARALLEL = 0, + SENSOR_INTERFACE_TYPE_MIPI, + SENSOR_INTERFACE_TYPE_SERIAL, /* add for 72 ATV using serial interface */ + SENSOR_INTERFACE_TYPE_MAX +} ACDK_SENSOR_INTERFACE_TYPE_ENUM; + +typedef enum { + SENSOR_OUTPUT_FORMAT_RAW_B = 0, + SENSOR_OUTPUT_FORMAT_RAW_Gb, + SENSOR_OUTPUT_FORMAT_RAW_Gr, + SENSOR_OUTPUT_FORMAT_RAW_R, + SENSOR_OUTPUT_FORMAT_UYVY, + SENSOR_OUTPUT_FORMAT_VYUY, + SENSOR_OUTPUT_FORMAT_YUYV, + SENSOR_OUTPUT_FORMAT_YVYU, + SENSOR_OUTPUT_FORMAT_CbYCrY, + SENSOR_OUTPUT_FORMAT_CrYCbY, + SENSOR_OUTPUT_FORMAT_YCbYCr, + SENSOR_OUTPUT_FORMAT_YCrYCb, + SENSOR_OUTPUT_FORMAT_RAW8_B, + SENSOR_OUTPUT_FORMAT_RAW8_Gb, + SENSOR_OUTPUT_FORMAT_RAW8_Gr, + SENSOR_OUTPUT_FORMAT_RAW8_R, + SENSOR_OUTPUT_FORMAT_RAW_RWB_B, + SENSOR_OUTPUT_FORMAT_RAW_RWB_Wb, + SENSOR_OUTPUT_FORMAT_RAW_RWB_Wr, + SENSOR_OUTPUT_FORMAT_RAW_RWB_R, + SENSOR_OUTPUT_FORMAT_RAW_MONO +} ACDK_SENSOR_OUTPUT_DATA_FORMAT_ENUM; + +typedef enum { + SENSOR_MIPI_1_LANE = 0, + SENSOR_MIPI_2_LANE, + SENSOR_MIPI_3_LANE, + SENSOR_MIPI_4_LANE +} ACDK_SENSOR_MIPI_LANE_NUMBER_ENUM; + +typedef enum { + SCAM_1_DATA_CHANNEL = 0, + SCAM_2_DATA_CHANNEL, + SCAM_3_DATA_CHANNEL, + SCAM_4_DATA_CHANNEL, +} SENSOR_SCAM_DATA_CHANNEL_ENUM; + +typedef enum { + MIPI_OPHY_NCSI2 = 0, + MIPI_OPHY_CSI2 = 1, +} SENSOR_MIPI_TYPE_ENUM; + +typedef enum { + MIPI_SETTLEDELAY_AUTO = 0, + MIPI_SETTLEDELAY_MANUAL = 1, +} SENSOR_SETTLEDELAY_MODE_ENUM; + +typedef enum { + COMP8_NONE = 0, + COMP8_DI_30 = 0x30, + COMP8_DI_31 = 0x31, + COMP8_DI_32 = 0x32, + COMP8_DI_33 = 0x33, + COMP8_DI_34 = 0x34, + COMP8_DI_35 = 0x35, + COMP8_DI_36 = 0x36, + COMP8_DI_37 = 0x37, + COMP8_DI_2A = 0x2A, +} SENSOR_DPCM_TYPE_ENUM; + +typedef struct { + MUINT16 SensorPreviewWidth; + MUINT16 SensorPreviewHeight; + MUINT16 SensorFullWidth; + MUINT16 SensorFullHeight; + MUINT16 SensorVideoWidth; + MUINT16 SensorVideoHeight; + MUINT16 SensorHighSpeedVideoWidth; + MUINT16 SensorHighSpeedVideoHeight; + MUINT16 SensorSlimVideoWidth; + MUINT16 SensorSlimVideoHeight; + MUINT16 SensorCustom1Width; + MUINT16 SensorCustom1Height; + MUINT16 SensorCustom2Width; + MUINT16 SensorCustom2Height; + MUINT16 SensorCustom3Width; + MUINT16 SensorCustom3Height; + MUINT16 SensorCustom4Width; + MUINT16 SensorCustom4Height; + MUINT16 SensorCustom5Width; + MUINT16 SensorCustom5Height; + MUINT16 Sensor3DPreviewWidth; + MUINT16 Sensor3DPreviewHeight; + MUINT16 Sensor3DFullWidth; + MUINT16 Sensor3DFullHeight; + MUINT16 Sensor3DVideoWidth; + MUINT16 Sensor3DVideoHeight; + MUINT16 SensorEffectivePreviewWidth; + MUINT16 SensorEffectivePreviewHeight; + MUINT16 SensorEffectiveFullWidth; + MUINT16 SensorEffectiveFullHeight; + MUINT16 SensorEffectiveVideoWidth; + MUINT16 SensorEffectiveVideoHeight; + MUINT16 SensorEffectiveHighSpeedVideoWidth; + MUINT16 SensorEffectiveHighSpeedVideoHeight; + MUINT16 SensorEffective3DPreviewWidth; + MUINT16 SensorEffective3DPreviewHeight; + MUINT16 SensorEffective3DFullWidth; + MUINT16 SensorEffective3DFullHeight; + MUINT16 SensorEffective3DVideoWidth; + MUINT16 SensorEffective3DVideoHeight; + MUINT16 SensorPreviewWidthOffset; /* from effective width to output width */ + MUINT16 SensorPreviewHeightOffset; /* from effective height to output height */ + MUINT16 SensorFullWidthOffset; /* from effective width to output width */ + MUINT16 SensorFullHeightOffset; /* from effective height to output height */ + MUINT16 SensorVideoWidthOffset; /* from effective width to output width */ + MUINT16 SensorVideoHeightOffset; /* from effective height to output height */ + MUINT16 SensorHighSpeedVideoWidthOffset; /* from effective width to output width */ + MUINT16 SensorHighSpeedVideoHeightOffset; /* from effective height to output height */ + MUINT16 Sensor3DPreviewWidthOffset; /* from effective width to output width */ + MUINT16 Sensor3DPreviewHeightOffset; /* from effective height to output height */ + MUINT16 Sensor3DFullWidthOffset; /* from effective width to output width */ + MUINT16 Sensor3DFullHeightOffset; /* from effective height to output height */ + MUINT16 Sensor3DVideoWidthOffset; /* from effective width to output width */ + MUINT16 Sensor3DVideoHeightOffset; /* from effective height to output height */ +} ACDK_SENSOR_RESOLUTION_INFO_STRUCT, *PACDK_SENSOR_RESOLUTION_INFO_STRUCT; + + +typedef struct { + MUINT16 SensorPreviewResolutionX; + MUINT16 SensorPreviewResolutionY; + MUINT16 SensorFullResolutionX; + MUINT16 SensorFullResolutionY; + MUINT8 SensorClockFreq; /* MHz */ + MUINT8 SensorCameraPreviewFrameRate; + MUINT8 SensorVideoFrameRate; + MUINT8 SensorStillCaptureFrameRate; + MUINT8 SensorWebCamCaptureFrameRate; + MUINT8 SensorClockPolarity; /* SENSOR_CLOCK_POLARITY_HIGH/SENSOR_CLOCK_POLARITY_Low */ + MUINT8 SensorClockFallingPolarity; + MUINT8 SensorClockRisingCount; /* 0..15 */ + MUINT8 SensorClockFallingCount; /* 0..15 */ + MUINT8 SensorClockDividCount; /* 0..15 */ + MUINT8 SensorPixelClockCount; /* 0..15 */ + MUINT8 SensorDataLatchCount; /* 0..15 */ + MUINT8 SensorHsyncPolarity; + MUINT8 SensorVsyncPolarity; + MUINT8 SensorInterruptDelayLines; + MINT32 SensorResetActiveHigh; + MUINT32 SensorResetDelayCount; + ACDK_SENSOR_INTERFACE_TYPE_ENUM SensroInterfaceType; + ACDK_SENSOR_OUTPUT_DATA_FORMAT_ENUM SensorOutputDataFormat; + ACDK_SENSOR_MIPI_LANE_NUMBER_ENUM SensorMIPILaneNumber; + MUINT32 CaptureDelayFrame; + MUINT32 PreviewDelayFrame; + MUINT32 VideoDelayFrame; + MUINT32 HighSpeedVideoDelayFrame; + MUINT32 SlimVideoDelayFrame; + MUINT32 YUVAwbDelayFrame; + MUINT32 YUVEffectDelayFrame; + MUINT32 Custom1DelayFrame; + MUINT32 Custom2DelayFrame; + MUINT32 Custom3DelayFrame; + MUINT32 Custom4DelayFrame; + MUINT32 Custom5DelayFrame; + MUINT16 SensorGrabStartX; + MUINT16 SensorGrabStartY; + MUINT16 SensorDrivingCurrent; + MUINT8 SensorMasterClockSwitch; + MUINT8 AEShutDelayFrame; /* The frame of setting shutter default 0 for TG int */ + MUINT8 AESensorGainDelayFrame; /* The frame of setting sensor gain */ + MUINT8 AEISPGainDelayFrame; + MUINT8 MIPIDataLowPwr2HighSpeedTermDelayCount; + MUINT8 MIPIDataLowPwr2HighSpeedSettleDelayCount; + MUINT8 MIPICLKLowPwr2HighSpeedTermDelayCount; + MUINT8 SensorWidthSampling; + MUINT8 SensorHightSampling; + MUINT8 SensorPacketECCOrder; + SENSOR_MIPI_TYPE_ENUM MIPIsensorType; + MUINT8 SensorCaptureOutputJPEG; /* JPEG file or not? */ + MUINT8 SensorModeNum; + MUINT8 IHDR_Support; + MUINT16 IHDR_LE_FirstLine; + SENSOR_SETTLEDELAY_MODE_ENUM SettleDelayMode; + MUINT8 PDAF_Support; + MUINT8 DPCM_INFO; + MUINT8 PerFrameCTL_Support; + SENSOR_SCAM_DATA_CHANNEL_ENUM SCAM_DataNumber; + MUINT8 SCAM_DDR_En; + MUINT8 SCAM_CLK_INV; + MUINT8 SCAM_DEFAULT_DELAY; + MUINT8 SCAM_CRC_En; + MUINT8 SCAM_SOF_src; + MUINT32 SCAM_Timout_Cali; +} ACDK_SENSOR_INFO_STRUCT, *PACDK_SENSOR_INFO_STRUCT; + +typedef struct { + MUINT16 SensorPreviewResolutionX; + MUINT16 SensorPreviewResolutionY; + MUINT16 SensorFullResolutionX; + MUINT16 SensorFullResolutionY; + MUINT8 SensorClockFreq; /* MHz */ + MUINT8 SensorCameraPreviewFrameRate; + MUINT8 SensorVideoFrameRate; + MUINT8 SensorStillCaptureFrameRate; + MUINT8 SensorWebCamCaptureFrameRate; + MUINT8 SensorClockPolarity; /* SENSOR_CLOCK_POLARITY_HIGH/SENSOR_CLOCK_POLARITY_Low */ + MUINT8 SensorClockFallingPolarity; + MUINT8 SensorClockRisingCount; /* 0..15 */ + MUINT8 SensorClockFallingCount; /* 0..15 */ + MUINT8 SensorClockDividCount; /* 0..15 */ + MUINT8 SensorPixelClockCount; /* 0..15 */ + MUINT8 SensorDataLatchCount; /* 0..15 */ + MUINT8 SensorHsyncPolarity; + MUINT8 SensorVsyncPolarity; + MUINT8 SensorInterruptDelayLines; + MINT32 SensorResetActiveHigh; + MUINT32 SensorResetDelayCount; + ACDK_SENSOR_INTERFACE_TYPE_ENUM SensroInterfaceType; + ACDK_SENSOR_OUTPUT_DATA_FORMAT_ENUM SensorOutputDataFormat; + ACDK_SENSOR_MIPI_LANE_NUMBER_ENUM SensorMIPILaneNumber; + MUINT32 CaptureDelayFrame; + MUINT32 PreviewDelayFrame; + MUINT32 VideoDelayFrame; + MUINT32 HighSpeedVideoDelayFrame; + MUINT32 SlimVideoDelayFrame; + MUINT32 YUVAwbDelayFrame; + MUINT32 YUVEffectDelayFrame; + MUINT32 Custom1DelayFrame; + MUINT32 Custom2DelayFrame; + MUINT32 Custom3DelayFrame; + MUINT32 Custom4DelayFrame; + MUINT32 Custom5DelayFrame; + MUINT16 SensorGrabStartX_PRV; + MUINT16 SensorGrabStartY_PRV; + MUINT16 SensorGrabStartX_CAP; + MUINT16 SensorGrabStartY_CAP; + MUINT16 SensorGrabStartX_VD; + MUINT16 SensorGrabStartY_VD; + MUINT16 SensorGrabStartX_VD1; + MUINT16 SensorGrabStartY_VD1; + MUINT16 SensorGrabStartX_VD2; + MUINT16 SensorGrabStartY_VD2; + MUINT16 SensorGrabStartX_CST1; + MUINT16 SensorGrabStartY_CST1; + MUINT16 SensorGrabStartX_CST2; + MUINT16 SensorGrabStartY_CST2; + MUINT16 SensorGrabStartX_CST3; + MUINT16 SensorGrabStartY_CST3; + MUINT16 SensorGrabStartX_CST4; + MUINT16 SensorGrabStartY_CST4; + MUINT16 SensorGrabStartX_CST5; + MUINT16 SensorGrabStartY_CST5; + MUINT16 SensorDrivingCurrent; + MUINT8 SensorMasterClockSwitch; + MUINT8 AEShutDelayFrame; /* The frame of setting shutter default 0 for TG int */ + MUINT8 AESensorGainDelayFrame; /* The frame of setting sensor gain */ + MUINT8 AEISPGainDelayFrame; + MUINT8 MIPIDataLowPwr2HighSpeedTermDelayCount; + MUINT8 MIPIDataLowPwr2HighSpeedSettleDelayCount; + MUINT8 MIPIDataLowPwr2HSSettleDelayM0; + MUINT8 MIPIDataLowPwr2HSSettleDelayM1; + MUINT8 MIPIDataLowPwr2HSSettleDelayM2; + MUINT8 MIPIDataLowPwr2HSSettleDelayM3; + MUINT8 MIPIDataLowPwr2HSSettleDelayM4; + MUINT8 MIPICLKLowPwr2HighSpeedTermDelayCount; + MUINT8 SensorWidthSampling; + MUINT8 SensorHightSampling; + MUINT8 SensorPacketECCOrder; + SENSOR_MIPI_TYPE_ENUM MIPIsensorType; + MUINT8 SensorCaptureOutputJPEG; /* JPEG file or not? */ + MUINT8 SensorModeNum; + MUINT8 IHDR_Support; + MUINT16 IHDR_LE_FirstLine; + SENSOR_SETTLEDELAY_MODE_ENUM SettleDelayMode; + MUINT8 PDAF_Support; + MUINT8 DPCM_INFO; + MUINT8 IMGSENSOR_DPCM_TYPE_PRE; + MUINT8 IMGSENSOR_DPCM_TYPE_CAP; + MUINT8 IMGSENSOR_DPCM_TYPE_VD; + MUINT8 IMGSENSOR_DPCM_TYPE_VD1; + MUINT8 IMGSENSOR_DPCM_TYPE_VD2; + MUINT8 PerFrameCTL_Support; + SENSOR_SCAM_DATA_CHANNEL_ENUM SCAM_DataNumber; + MUINT8 SCAM_DDR_En; + MUINT8 SCAM_CLK_INV; + MUINT8 SCAM_DEFAULT_DELAY; + MUINT8 SCAM_CRC_En; + MUINT8 SCAM_SOF_src; + MUINT32 SCAM_Timout_Cali; +} ACDK_SENSOR_INFO2_STRUCT, *PACDK_SENSOR_INFO2_STRUCT; + + +typedef enum { + ACDK_CCT_REG_ISP = 0, + ACDK_CCT_REG_CMOS, + ACDK_CCT_REG_CCD +} ACDK_CCT_REG_TYPE_ENUM; + + +/* R/W ISP/Sensor Register */ +typedef struct { + ACDK_CCT_REG_TYPE_ENUM Type; + MUINT32 RegAddr; + MUINT32 RegData; +} ACDK_CCT_REG_RW_STRUCT, *PACDK_CCT_REG_RW_STRUCT; + +typedef struct { + ACDK_CCT_REG_TYPE_ENUM Type; /* ISP, CMOS_SENSOR, CCD_SENSOR */ + MUINT32 DeviceId; + ACDK_SENSOR_OUTPUT_DATA_FORMAT_ENUM StartPixelBayerPtn; + MUINT16 GrabXOffset; + MUINT16 GrabYOffset; +} ACDK_CCT_SENSOR_INFO_STRUCT, *PACDK_CCT_SENSOR_INFO_STRUCT; + + + +typedef enum { + CMOS_SENSOR = 0, + CCD_SENSOR +} SENSOR_TYPE_ENUM; + +typedef struct { + MUINT16 SensorId; + SENSOR_TYPE_ENUM SensorType; + ACDK_SENSOR_OUTPUT_DATA_FORMAT_ENUM SensorOutputDataFormat; +} ACDK_SENSOR_ENG_INFO_STRUCT; + +typedef struct { + MUINT32 RegAddr; + MUINT32 RegData; +} ACDK_SENSOR_REG_INFO_STRUCT; + +typedef struct { + MUINT8 debugStruct[32]; + MUINT8 debugSubstruct[32]; + MUINT32 isGet; /* 1 means get, 0 means set */ + MUINT32 value; +} ACDK_SENSOR_DBG_IMGSENSOR_STRUCT; + +typedef struct { + MUINT32 GroupIdx; + MUINT32 ItemCount; + MUINT8 *GroupNamePtr; +} ACDK_SENSOR_GROUP_INFO_STRUCT; + +typedef struct { + MUINT32 GroupIdx; + MUINT32 ItemIdx; + MUINT8 ItemNamePtr[50]; /* item name */ + MUINT32 ItemValue; /* item value */ + MINT32 IsTrueFalse; /* is this item for enable/disable functions */ + MINT32 IsReadOnly; /* is this item read only */ + MINT32 IsNeedRestart; /* after set this item need restart */ + MUINT32 Min; /* min value of item value */ + MUINT32 Max; /* max value of item value */ +} ACDK_SENSOR_ITEM_INFO_STRUCT; + +typedef enum { + ACDK_SENSOR_IMAGE_NORMAL = 0, + ACDK_SENSOR_IMAGE_H_MIRROR, + ACDK_SENSOR_IMAGE_V_MIRROR, + ACDK_SENSOR_IMAGE_HV_MIRROR +} ACDK_SENSOR_IMAGE_MIRROR_ENUM; + +typedef enum { + ACDK_SENSOR_OPERATION_MODE_CAMERA_PREVIEW = 0, + ACDK_SENSOR_OPERATION_MODE_VIDEO, + ACDK_SENSOR_OPERATION_MODE_STILL_CAPTURE, + ACDK_SENSOR_OPERATION_MODE_HIGHSP_VIDEO1, + ACDK_SENSOR_OPERATION_MODE_HIGHSP_VIDEO2, + ACDK_SENSOR_OPERATION_MODE_WEB_CAPTURE, + ACDK_SENSOR_OPERATION_MODE_CUSTOM1, + ACDK_SENSOR_OPERATION_MODE_CUSTOM2, + ACDK_SENSOR_OPERATION_MODE_CUSTOM3, + ACDK_SENSOR_OPERATION_MODE_CUSTOM4, + ACDK_SENSOR_OPERATION_MODE_CUSTOM5, + ACDK_SENSOR_OPERATION_MODE_MAX +} ACDK_SENSOR_OPERATION_MODE_ENUM; + +typedef struct { + MUINT16 GrabStartX; /* The first grabed column data of the image sensor in pixel clock count */ + MUINT16 GrabStartY; /* The first grabed row data of the image sensor in pixel clock count */ + MUINT16 ExposureWindowWidth; /* Exposure window width of image sensor */ + MUINT16 ExposureWindowHeight; /* Exposure window height of image sensor */ + MUINT16 ImageTargetWidth; /* image captured width */ + MUINT16 ImageTargetHeight; /* image captuerd height */ + MUINT16 ExposurePixel; /* exposure window width of image sensor + dummy pixel */ + MUINT16 CurrentExposurePixel; /* exposure window width of image sensor + dummy pixel */ + MUINT16 ExposureLine; /* exposure window width of image sensor + dummy line */ + MUINT16 ZoomFactor; /* digital zoom factor */ +} ACDK_SENSOR_EXPOSURE_WINDOW_STRUCT; + +typedef struct { + ACDK_SENSOR_IMAGE_MIRROR_ENUM SensorImageMirror; + MINT32 EnableShutterTansfer; /* capture only */ + MINT32 EnableFlashlightTansfer; /* flash light capture only */ + ACDK_SENSOR_OPERATION_MODE_ENUM SensorOperationMode; + MUINT16 ImageTargetWidth; /* image captured width */ + MUINT16 ImageTargetHeight; /* image captuerd height */ + MUINT16 CaptureShutter; /* capture only */ + MUINT16 FlashlightDuty; /* flash light capture only */ + MUINT16 FlashlightOffset; /* flash light capture only */ + MUINT16 FlashlightShutFactor; /* flash light capture only */ + MUINT16 FlashlightMinShutter; + ACDK_CAMERA_OPERATION_MODE_ENUM MetaMode; /* capture only */ + MUINT32 DefaultPclk; /* Sensor pixel clock(Ex:24000000) */ + MUINT32 Pixels; /* Sensor active pixel number */ + MUINT32 Lines; /* Sensor active line number */ + MUINT32 Shutter; /* Sensor current shutter */ + MUINT32 FrameLines; /* valid+dummy lines for minimum shutter */ +} ACDK_SENSOR_CONFIG_STRUCT; + +typedef enum { + MCLK_48MHZ_GROUP = 0x1, + MCLK_52MHZ_GROUP = 0x2, +} ACKD_SENSOR_MCLK_ENUM; + +typedef struct { + MUINT8 on; + ACKD_SENSOR_MCLK_ENUM freq; +} ACDK_SENSOR_MCLK_STRUCT; + +typedef struct { + MUINT16 full_w; + MUINT16 full_h; + MUINT16 x0_offset; + MUINT16 y0_offset; + MUINT16 w0_size; + MUINT16 h0_size; + MUINT16 scale_w; + MUINT16 scale_h; + MUINT16 x1_offset; + MUINT16 y1_offset; + MUINT16 w1_size; + MUINT16 h1_size; + MUINT16 x2_tg_offset; + MUINT16 y2_tg_offset; + MUINT16 w2_tg_size; + MUINT16 h2_tg_size; +} SENSOR_WINSIZE_INFO_STRUCT; + +typedef struct { + MUINT32 SensorId; + SENSOR_WINSIZE_INFO_STRUCT SensorWinSize; +} SENSOR_WINSIZE_STRUCT, *pSENSOR_WINSIZE_STRUCT; + +typedef struct { + MUINT16 VC_Num; + MUINT16 VC_PixelNum; + MUINT16 ModeSelect; /* 0: auto mode, 1:direct mode */ + MUINT16 EXPO_Ratio; /* 1/1, 1/2, 1/4, 1/8 */ + MUINT16 ODValue; /* OD Vaule */ + MUINT16 RG_STATSMODE; /* STATS divistion mdoe 0: 16x16, 1:8x8, 2:4x4, 3:1x1*/ + MUINT16 VC0_ID; + MUINT16 VC0_DataType; + MUINT16 VC0_SIZEH; + MUINT16 VC0_SIZEV; + MUINT16 VC1_ID; + MUINT16 VC1_DataType; + MUINT16 VC1_SIZEH; + MUINT16 VC1_SIZEV; + MUINT16 VC2_ID; + MUINT16 VC2_DataType; + MUINT16 VC2_SIZEH; + MUINT16 VC2_SIZEV; + MUINT16 VC3_ID; + MUINT16 VC3_DataType; + MUINT16 VC3_SIZEH; + MUINT16 VC3_SIZEV; +} SENSOR_VC_INFO_STRUCT, *pSENSOR_VC_INFO_STRUCT; +typedef struct { + MUINT32 ABS_GAIN_GR; + MUINT32 ABS_GAIN_R; + MUINT32 ABS_GAIN_B; + MUINT32 ABS_GAIN_GB; +} SET_SENSOR_AWB_GAIN, *PSET_SENSOR_AWB_GAIN; + +typedef struct { + MUINT32 SENSOR_MODE; + MUINT32 ISO; + +} SET_SENSOR_ISO, *PSET_SENSOR_ISO; + +typedef struct { + MUINT32 i4OffsetX; /* start offset of first PD block */ + MUINT32 i4OffsetY; + MUINT32 i4PitchX; /* PD block pitch */ + MUINT32 i4PitchY; + MUINT32 i4PairNum; /* PD pair num in one block */ + MUINT32 i4SubBlkW; /* sub block width (one PD pair in one sub block) */ + MUINT32 i4SubBlkH; /* sub block height */ + MUINT32 i4PosL[16][2]; /* left pd pixel position in one block*/ + MUINT32 i4PosR[16][2]; /* right pd pixel position in one block*/ +} SET_PD_BLOCK_INFO_T, *PSET_PD_BLOCK_INFO_T; + + +typedef enum { + SENSORIF_PARALLEL = 0, + SENSORIF_SERIAL, + SENSORIF_MIPI_DHY0, + SENSORIF_MIPI_DHY1, + SENSORIF_MIPI_DHY2 +} SENSOR_PHY_TYPE_ENUM; + +typedef enum { + DATA_8BIT_FMT = 0x0, + DATA_10BIT_FMT = 0x1, + DATA_12BIT_FMT = 0x2, + DATA_YUV422_FMT = 0x3, +} INDATA_FORMAT_ENUM; + +typedef struct { + MINT32 mSensorDev; + MUINT8 GpioEnable; + SENSOR_PHY_TYPE_ENUM SensroInterfaceType; + INDATA_FORMAT_ENUM SensorIndataformat; +} IMGSENSOR_GPIO_STRUCT; +/******************************************************************************* +* +********************************************************************************/ + +#define MAXIMUM_NVRAM_CAMERA_SENSOR_FILE_SIZE_KERNEL 4096 + +#define NVRAM_CAMERA_SENSOR_FILE_VERSION 1 + + + +/* Sensor table */ +#define MAXIMUM_SENSOR_CCT_REG_NUMBER 100 +#define MAXIMUM_SENSOR_ENG_REG_NUMBER 100 + +typedef struct { + MUINT32 Addr; + MUINT32 Para; +} SENSOR_REG_STRUCT; + +typedef struct { + MUINT32 Version; + MUINT32 SensorId; /* ID of sensor module */ + SENSOR_REG_STRUCT SensorEngReg[MAXIMUM_SENSOR_ENG_REG_NUMBER]; + SENSOR_REG_STRUCT SensorCCTReg[MAXIMUM_SENSOR_CCT_REG_NUMBER]; + MUINT8 CameraData[MAXIMUM_NVRAM_CAMERA_SENSOR_FILE_SIZE_KERNEL / 2 - 8 - sizeof(SENSOR_REG_STRUCT) * (MAXIMUM_SENSOR_ENG_REG_NUMBER + MAXIMUM_SENSOR_CCT_REG_NUMBER)]; +} NVRAM_SENSOR_DATA_STRUCT, *PNVRAM_SENSOR_DATA_STRUCT; + +#define MAX_SENSOR_CAL_SIZE_KERNEL (1024) /* Byte */ +#define MAX_SHADING_DATA_TBL ((MAX_SENSOR_CAL_SIZE_KERNEL-8)/4) +typedef struct { + MUINT32 DataFormat; + MUINT32 DataSize; + MUINT32 ShadingData[MAX_SHADING_DATA_TBL]; +} SET_SENSOR_CALIBRATION_DATA_STRUCT, *PSET_SENSOR_CALIBRATION_DATA_STRUCT; + + + +typedef struct { + MSDK_SCENARIO_ID_ENUM ScenarioId[2]; + ACDK_SENSOR_INFO_STRUCT * pInfo[2]; + ACDK_SENSOR_CONFIG_STRUCT * pConfig[2]; +} ACDK_SENSOR_GETINFO_STRUCT, *PACDK_SENSOR_GETINFO_STRUCT; + +typedef struct { + MUINT32 SensorId; + ACDK_SENSOR_INFO2_STRUCT *pInfo; + ACDK_SENSOR_RESOLUTION_INFO_STRUCT *pSensorResolution; +} IMAGESENSOR_GETINFO_STRUCT, *PIMAGESENSOR_GETINFO_STRUCT; + +typedef struct { + CAMERA_DUAL_CAMERA_SENSOR_ENUM InvokeCamera; + ACDK_SENSOR_FEATURE_ENUM FeatureId; + MUINT8 *pFeaturePara; + MUINT32 *pFeatureParaLen; +} ACDK_SENSOR_FEATURECONTROL_STRUCT, *PACDK_SENSOR_FEATURECONTROL_STRUCT; + +typedef struct { + CAMERA_DUAL_CAMERA_SENSOR_ENUM InvokeCamera; + MSDK_SCENARIO_ID_ENUM ScenarioId; + ACDK_SENSOR_EXPOSURE_WINDOW_STRUCT *pImageWindow; + ACDK_SENSOR_CONFIG_STRUCT *pSensorConfigData; +} ACDK_SENSOR_CONTROL_STRUCT; + +typedef struct { + ACDK_SENSOR_RESOLUTION_INFO_STRUCT *pResolution[2]; +} ACDK_SENSOR_PRESOLUTION_STRUCT; + + + +typedef struct regval_list { + MUINT32 reg_addr; + MUINT32 value; + MUINT32 bytes; +} REGVAL_LIST_STRUCT; + +#define KDIMGSENSOR_REGVAL_LIST_MAX_NUM 256 + +typedef struct format_struct { + MUINT8 *desc; + MUINT32 pixelformat; + /* REGVAL_LIST_STRUCT regs[KDIMGSENSOR_REGVAL_LIST_MAX_NUM]; */ + int (*pfInitCfg)(void); +} IMGSENSOR_FORMAT_STRUCT; + +typedef struct { + IMGSENSOR_FORMAT_STRUCT format; + MUINT32 u4InClk; /* Common part //hard coded */ + MUINT32 u4OutClk; /* Common part // */ + MUINT32 u4TotalPixelPerLine; /* By modes */ + MUINT32 u4TotalLinesPerFrame; /* By modes and frame rate setting */ + MUINT32 u4ActualWidth; /* By modes */ + MUINT32 u4ActualHeight; /* By modes */ + MUINT32 u4Width; /* By modes */ + MUINT32 u4Height; /* By modes */ + MUINT32 u4FrameTimeInus; /* By modes and frame rate setting */ + MUINT32 u4MinFrameTimeInus; /* By modes */ + MUINT32 u4LineTimeInus; /* By modes */ + MUINT32 u4FinePixCntPerus; /* Common part */ + MUINT32 u4MinFineTimeInus; /* By modes */ + MUINT32 u4MaxFineTimeInus; /* By modes */ + MUINT32 u4XStart; + MUINT32 u4XEnd; + MUINT32 u4YStart; + MUINT32 u4YEnd; +} stImgSensorFormat; + +#ifdef CONFIG_COMPAT +/* Redifne structures for compat_ioctl */ +typedef struct { + MSDK_SCENARIO_ID_ENUM ScenarioId[2]; + compat_uptr_t pInfo[2]; + compat_uptr_t pConfig[2]; +} COMPAT_ACDK_SENSOR_GETINFO_STRUCT; + +typedef struct { + MUINT32 SensorId; + compat_uptr_t pInfo; + compat_uptr_t pSensorResolution; +} COMPAT_IMAGESENSOR_GETINFO_STRUCT; + +typedef struct { + CAMERA_DUAL_CAMERA_SENSOR_ENUM InvokeCamera; + ACDK_SENSOR_FEATURE_ENUM FeatureId; + compat_uptr_t pFeaturePara; + compat_uptr_t pFeatureParaLen; +} COMPAT_ACDK_SENSOR_FEATURECONTROL_STRUCT; + +typedef struct { + CAMERA_DUAL_CAMERA_SENSOR_ENUM InvokeCamera; + MSDK_SCENARIO_ID_ENUM ScenarioId; + compat_uptr_t pImageWindow; + compat_uptr_t pSensorConfigData; +} COMPAT_ACDK_SENSOR_CONTROL_STRUCT; + +typedef struct { + compat_uptr_t pResolution[2]; +} COMPAT_ACDK_SENSOR_PRESOLUTION_STRUCT; + +#endif + + +/******************************************************************************* +* +********************************************************************************/ +/* */ +/* adoption to winmo driver files */ +/* */ + +/* typedef */ +/* #define kal_uint8 u8 */ + +/* #define MSDK_SCENARIO_ID_ENUM ACDK_SCENARIO_ID_ENUM */ +#define MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT ACDK_SENSOR_EXPOSURE_WINDOW_STRUCT +#define MSDK_SENSOR_CONFIG_STRUCT ACDK_SENSOR_CONFIG_STRUCT + +#define MSDK_SENSOR_FEATURE_ENUM ACDK_SENSOR_FEATURE_ENUM +#define MSDK_SENSOR_REG_INFO_STRUCT ACDK_SENSOR_REG_INFO_STRUCT +#define MSDK_SENSOR_GROUP_INFO_STRUCT ACDK_SENSOR_GROUP_INFO_STRUCT +#define MSDK_SENSOR_ITEM_INFO_STRUCT ACDK_SENSOR_ITEM_INFO_STRUCT +#define MSDK_SENSOR_ENG_INFO_STRUCT ACDK_SENSOR_ENG_INFO_STRUCT +#define MSDK_SENSOR_INFO_STRUCT ACDK_SENSOR_INFO_STRUCT +#define MSDK_SENSOR_RESOLUTION_INFO_STRUCT ACDK_SENSOR_RESOLUTION_INFO_STRUCT +#define MSDK_SENSOR_DBG_IMGSENSOR_INFO_STRUCT ACDK_SENSOR_DBG_IMGSENSOR_STRUCT + +/* MSDK_SCENARIO_ID_ENUM => ACDK_SCENARIO_ID_ENUM */ +/* #define MSDK_SCENARIO_ID_CAMERA_PREVIEW ACDK_SCENARIO_ID_CAMERA_PREVIEW */ +/* #define MSDK_SCENARIO_ID_VIDEO_PREVIEW ACDK_SCENARIO_ID_VIDEO_PREVIEW */ +/* #define MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG */ +#define MSDK_SENSOR_OPERATION_MODE_VIDEO ACDK_SENSOR_OPERATION_MODE_VIDEO +/* #define MSDK_SCENARIO_ID_CAMERA_ZSD ACDK_SCENARIO_ID_CAMERA_ZSD */ +/* #define MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW ACDK_SCENARIO_ID_CAMERA_3D_PREVIEW */ +/* #define MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE ACDK_SCENARIO_ID_CAMERA_3D_CAPTURE */ +/* #define MSDK_SCENARIO_ID_CAMERA_3D_VIDEO ACDK_SCENARIO_ID_CAMERA_3D_VIDEO */ +/******************************************************************************* +* +********************************************************************************/ + +/******************************************************************************* +* +********************************************************************************/ +/* for new simplifed sensor driver */ +typedef struct { + MUINT32(*SensorOpen)(void); + MUINT32(*SensorGetInfo)(MUINT32 *pScenarioId[2], MSDK_SENSOR_INFO_STRUCT * pSensorInfo[2], MSDK_SENSOR_CONFIG_STRUCT * pSensorConfigData[2]); + MUINT32(*SensorGetResolution)(MSDK_SENSOR_RESOLUTION_INFO_STRUCT * pSensorResolution[2]); + MUINT32(*SensorFeatureControl)(CAMERA_DUAL_CAMERA_SENSOR_ENUM InvokeCamera, MSDK_SENSOR_FEATURE_ENUM FeatureId, MUINT8 *pFeaturePara, MUINT32 *pFeatureParaLen); + MUINT32(*SensorControl)(MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *pImageWindow, MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData); + MUINT32(*SensorClose)(void); +} MULTI_SENSOR_FUNCTION_STRUCT, *PMULTI_SENSOR_FUNCTION_STRUCT; + +typedef struct { + MUINT32(*SensorOpen)(void); + MUINT32(*SensorGetInfo)(MUINT32 *pScenarioId[2], MSDK_SENSOR_INFO_STRUCT * pSensorInfo[2], MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData[2]); + MUINT32(*SensorGetResolution)(MSDK_SENSOR_RESOLUTION_INFO_STRUCT * pSensorResolution[2]); + MUINT32(*SensorFeatureControl)(CAMERA_DUAL_CAMERA_SENSOR_ENUM InvokeCamera, MSDK_SENSOR_FEATURE_ENUM FeatureId, MUINT8 *pFeaturePara, MUINT32 *pFeatureParaLen); + MUINT32(*SensorControl)(CAMERA_DUAL_CAMERA_SENSOR_ENUM InvokeCamera, MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *pImageWindow, MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData); + MUINT32(*SensorClose)(void); +} MULTI_SENSOR_FUNCTION_STRUCT2, *PMULTI_SENSOR_FUNCTION_STRUCT2; + + +typedef struct { + MUINT32(*SensorOpen)(void); + MUINT32(*SensorGetInfo)(MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_INFO_STRUCT *pSensorInfo, + MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData); + MUINT32(*SensorGetResolution)(MSDK_SENSOR_RESOLUTION_INFO_STRUCT *pSensorResolution); + MUINT32(*SensorFeatureControl)(MSDK_SENSOR_FEATURE_ENUM FeatureId, MUINT8 *pFeaturePara, MUINT32 *pFeatureParaLen); + MUINT32(*SensorControl)(MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *pImageWindow, MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData); + MUINT32(*SensorClose)(void); +#if 1 /* isp suspend resume patch */ + MSDK_SCENARIO_ID_ENUM ScenarioId; + MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT imageWindow; + MSDK_SENSOR_CONFIG_STRUCT sensorConfigData; +#endif +} SENSOR_FUNCTION_STRUCT, *PSENSOR_FUNCTION_STRUCT; + +typedef struct { + MUINT32 SensorId; + MUINT8 drvname[32]; + MUINT32(*SensorInit)(PSENSOR_FUNCTION_STRUCT *pfFunc); +} ACDK_KD_SENSOR_INIT_FUNCTION_STRUCT, *PACDK_KD_SENSOR_INIT_FUNCTION_STRUCT; + +#define KDIMGSENSOR_DUAL_SHIFT 16 +#define KDIMGSENSOR_DUAL_MASK_MSB 0xFFFF0000 +#define KDIMGSENSOR_DUAL_MASK_LSB 0x0000FFFF + +#define KDIMGSENSOR_NOSENSOR "non_sensor" + +#define KDIMGSENSOR_MAX_INVOKE_DRIVERS (2) +#define KDIMGSENSOR_INVOKE_DRIVER_0 (0) +#define KDIMGSENSOR_INVOKE_DRIVER_1 (1) + +/* For sensor synchronize the exposure time / sensor gain and isp gain. */ +typedef struct { + MUINT16 u2ISPNewRGain; + MUINT16 u2ISPNewGrGain; + MUINT16 u2ISPNewGbGain; + MUINT16 u2ISPNewBGain; + MUINT16 u2SensorNewExpTime; + MUINT16 u2SensorNewGain; + MUINT8 uSensorExpDelayFrame; + MUINT8 uSensorGainDelayFrame; + MUINT8 uISPGainDelayFrame; + MUINT8 uDummy; +} ACDK_KD_SENSOR_SYNC_STRUCT, *PACDK_KD_SENSOR_SYNC_STRUCT; + + +typedef struct { + MUINT16 AeRefLV05Shutter; /* Sensor AE Shutter under Lv05 */ + MUINT16 AeRefLV13Shutter; /* Sensor AE Shutter under Lv13 */ + MUINT16 AeRefLV05Gain; /* Sensor AE Gain under Lv05 */ + MUINT16 AeRefLV13Gain; /* Sensor AE Gain under Lv13 */ +} SENSOR_AE_REF_STRUCT, *PSENSOR_AE_REF_STRUCT; + + +typedef struct { + MUINT16 AwbRefD65Rgain; /* Sensor AWB R Gain under D65 */ + MUINT16 AwbRefD65Bgain; /* Sensor AWB B Gain under D65 */ + MUINT16 AwbRefCWFRgain; /* Sensor AWB R Gain under CWF */ + MUINT16 AwbRefCWFBgain; /* Sensor AWB B Gain under CWF */ +} SENSOR_AWB_GAIN_REF_STRUCT, *PSENSOR_AWB_GAIN_REF_STRUCT; + + +typedef struct { + SENSOR_AE_REF_STRUCT SensorAERef; /* AE Ref information for ASD usage */ + SENSOR_AWB_GAIN_REF_STRUCT SensorAwbGainRef; /* AWB Gain Ref information for ASD usage */ + MUINT32 SensorLV05LV13EVRef; /* EV calculate for ASD usage */ +} SENSOR_AE_AWB_REF_STRUCT, *PSENSOR_AE_AWB_REF_STRUCT; + + + +typedef struct { + MUINT16 AeCurShutter; /* Current Sensor AE Shutter */ + MUINT16 AeCurGain; /* Current Sensor AE Gain */ +} SENSOR_AE_CUR_STRUCT, *PSENSOR_AE_CUR_STRUCT; + + +typedef struct { + MUINT16 AwbCurRgain; /* Current Sensor AWB R Gain */ + MUINT16 AwbCurBgain; /* Current Sensor AWB R Gain */ +} SENSOR_AWB_GAIN_CUR_STRUCT, *PSENSOR_AWB_GAIN_CUR_STRUCT; + + +typedef struct { + SENSOR_AE_CUR_STRUCT SensorAECur; /* AE Current information for ASD usage */ + SENSOR_AWB_GAIN_CUR_STRUCT SensorAwbGainCur; /* AWB Gain Current information for ASD usage */ +} SENSOR_AE_AWB_CUR_STRUCT, *PSENSOR_AE_AWB_CUR_STRUCT; + + +typedef struct { + MUINT32 FNumber; + MUINT32 AEISOSpeed; + MUINT32 AWBMode; + MUINT32 CapExposureTime; + MUINT32 FlashLightTimeus; + MUINT32 RealISOValue; +} SENSOR_EXIF_INFO_STRUCT, *PSENSOR_EXIF_INFO_STRUCT; + +typedef struct { + MUINT32 InitDelay; + MUINT32 EffectDelay; + MUINT32 AwbDelay; + MUINT32 AFSwitchDelayFrame; + MUINT32 EvDelay; + MUINT32 SatDelay; + MUINT32 BrightDelay; + MUINT32 ContrastDelay; +} SENSOR_DELAY_INFO_STRUCT, *PSENSOR_DELAY_INFO_STRUCT; + +typedef struct { + MUINT32 u4Fno; + MUINT32 Exposuretime; + MUINT32 Gain; + MUINT32 GAIN_BASE; +} SENSOR_FLASHLIGHT_AE_INFO_STRUCT, *PSENSOR_FLASHLIGHT_AE_INFO_STRUCT; + +/* multisensor driver */ + +typedef struct { + MUINT32 drvIndex[KDIMGSENSOR_MAX_INVOKE_DRIVERS]; /* max 2 driver sumultaneously */ +} SENSOR_DRIVER_INDEX_STRUCT, *PSENSOR_DRIVER_INDEX_STRUCT; + +/* hardcode by GPIO module, should be sync with.(cust_gpio_usage.h) */ +#define GPIO_CAMERA_INVALID 0xFF +/* */ +typedef enum { + IMGSENSOR_SOCKET_POS_NONE = 0xFFFFFFFF, + IMGSENSOR_SOCKET_POS_RIGHT = 0x1, + IMGSENSOR_SOCKET_POS_LEFT = 0x2, +} IMGSENSOR_SOCKET_POSITION_ENUM; +/* */ +typedef enum { + IMGSENSOR_SET_I2C_ID_STATE = 0x00, + IMGSENSOR_SET_I2C_ID_FORCE +} IMGSENSOR_SET_I2C_ID_ENUM; + + + +typedef enum { + SENSOR_3A_AE_LOCK = 0, + SENSOR_3A_AE_UNLOCK, + SENSOR_3A_AWB_LOCK, + SENSOR_3A_AWB_UNLOCK, + SENSOR_3A_AE_ON, + SENSOR_3A_AE_OFF, + SENSOR_3A_AWB_ON, + SENSOR_3A_AWB_OFF, + SENSOR_3A_AF_INFINITY, + /* SENSOR_3A_AF_LOCK, */ + /* SENSOR_3A_AF_UNLOCK, */ +} ACDK_SENSOR_3A_LOCK_ENUM; + + +typedef struct { + MUINT32 tgtWidth; + MUINT32 tgtHeight; + MUINT32 quality; + +} ACDK_SENSOR_JPEG_OUTPUT_PARA; + + +/* for JPEG Sensor Info */ +typedef struct { + MUINT32 u4FileSize; /* For input sensor width */ + MUINT32 u4SrcW; /* For input sensor width */ + MUINT32 u4SrcH; /* For input sensor height */ +} ACDK_SENSOR_JPEG_INFO; + + +#endif /* _KD_IMGSENSOR_DATA_H */ diff --git a/kernel-headers/kd_imgsensor_errcode.h b/kernel-headers/kd_imgsensor_errcode.h new file mode 100644 index 0000000..0f97b10 --- /dev/null +++ b/kernel-headers/kd_imgsensor_errcode.h @@ -0,0 +1,41 @@ +#ifndef _KD_IMGSENSOR_ERRCODE_H_ +#define _KD_IMGSENSOR_ERRCODE_H_ + +/* @ the same as camera_custom_errocode.h */ +typedef enum { + ERROR_NONE = 0, + ERROR_MSDK_IS_ACTIVED, + ERROR_INVALID_DRIVER_MOD_ID, + ERROR_INVALID_FEATURE_ID, + ERROR_INVALID_SCENARIO_ID, + ERROR_INVALID_CTRL_CODE, + ERROR_VIDEO_ENCODER_BUSY, + ERROR_INVALID_PARA, + ERROR_OUT_OF_BUFFER_NUMBER, + ERROR_INVALID_ISP_STATE, + ERROR_INVALID_MSDK_STATE, + ERROR_PHY_VIR_MEM_MAP_FAIL, + ERROR_ENQUEUE_BUFFER_NOT_FOUND, + ERROR_MSDK_BUFFER_ALREADY_INIT, + ERROR_MSDK_BUFFER_OUT_OF_MEMORY, + ERROR_SENSOR_POWER_ON_FAIL, + ERROR_SENSOR_CONNECT_FAIL, + ERROR_SENSOR_FEATURE_NOT_IMPLEMENT, + ERROR_MSDK_IO_CONTROL_CODE, + ERROR_MSDK_IO_CONTROL_MSG_QUEUE_OPEN_FAIL, + ERROR_DRIVER_INIT_FAIL, + ERROR_WRONG_NVRAM_CAMERA_VERSION, + ERROR_NVRAM_CAMERA_FILE_FAIL, + ERROR_IMAGE_DECODE_FAIL, + ERROR_IMAGE_ENCODE_FAIL, + ERROR_LED_FLASH_POWER_ON_FAIL, + ERROR_MSDK_NOT_ALLOW_BY_MM_APP_MGR, + ERROR_LENS_NOT_SUPPORT, + ERROR_FLASH_LIGHT_NOT_SUPPORT, + ERROR_FACE_DETECTION_NOT_SUPPORT, + ERROR_PANORAMA_NOT_SUPPORT, + ERROR_MAX +} CUSTOM_CAMERA_ERROR_CODE_ENUM; + + +#endif diff --git a/kernel-headers/libmtk_cipher_export.h b/kernel-headers/libmtk_cipher_export.h new file mode 100644 index 0000000..575671f --- /dev/null +++ b/kernel-headers/libmtk_cipher_export.h @@ -0,0 +1,83 @@ +#ifndef _LIBMTK_CIPHER_EXPORT_H +#define _LIBMTK_CIPHER_EXPORT_H + +#define HEVC_BLK_LEN (20480) /* bytes */ +#define HEVC_MOD "HEVC_MOD" +#define HEVC_NANO 1000000000ULL +#define HEVC_CIPHER_LEN (102400) /* bytes */ + + +typedef struct { + unsigned char buf[HEVC_BLK_LEN]; + unsigned int len; +} HEVC_BLK; + +typedef enum { + VIDEO_ENCRYPT_CODEC_NONE = 0x0, + VIDEO_ENCRYPT_CODEC_HEVC_ENC = 0x1, + VIDEO_ENCRYPT_CODEC_HEVC_DEC = 0x2, + VIDEO_ENCRYPT_CODEC_MAX = 0xffffffff +} VIDEO_ENCRYPT_CODEC_T; + + +typedef int (*hevc_api_funp)(HEVC_BLK *p_hevc_blk); +typedef int (*hevc_api_initk_funp)(unsigned char *key, unsigned int klen); + + +#define SEC_OK 0x0 +#define SEC_FAIL 0x1 + +/* HEVC shared lib*/ +#define ERR_HEVC_NOT_CORRECT_MODE 0x10000 +#define ERR_HEVC_DATA_NOT_ALIGNED 0x10001 +#define ERR_HEVC_ENC_IOCTL_FAIL 0x10002 +#define ERR_HEVC_DEC_IOCTL_FAIL 0x10002 +#define ERR_HEVC_CIPHER_UT_FAIL 0x10003 +#define ERR_HEVC_DATA_IS_NULL 0x10004 +#define ERR_HEVC_DATA_LENGTH_NOT_VALID 0x10005 +#define ERR_HEVC_SW_ENC_ERROR 0x10006 +#define ERR_HEVC_SW_DEC_ERROR 0x10007 +#define ERR_HEVC_INIT_SW_KEY_ERROR 0x10008 + + +/* HEVC sample*/ +#define ERR_HEVC_CIPHER_LIB_NOT_FOUND 0x20001 +#define ERR_HEVC_SW_DEC_BLOCK_SYM_NOT_FOUND 0x20002 +#define ERR_HEVC_HW_ENC_BLOCK_SYM_NOT_FOUND 0x20003 +#define ERR_HEVC_INIT_SW_KEY_SYM_NOT_FOUND 0x20004 +#define ERR_HEVC_INPUT_FILE_NOT_FOUND 0x20005 +#define ERR_HEVC_OUTPUT_FILE_NOT_FOUND 0x20006 +#define ERR_HEVC_SW_DEC_FILE_SYM_NOT_FOUND 0x20007 +#define ERR_HEVC_SW_DEC_FILE_FAILED 0x20008 +#define ERR_HEVC_UNKNOWN 0x2FFFF + + +/* Define LOG LEVEL*/ +#define SEC_LOG_TRACE 0 /* For source code trace */ +#define SEC_LOG_DEBUG 0 /* For debug purpose */ +#define SEC_LOG_ERROR 1 /* For critical error dump */ +#define SEC_LOG_INFO 1 /* For information to know when processing in normal */ + +/* DEBUG MACRO */ +#define SMSG_TRACE(...) \ + do { if (SEC_LOG_TRACE) printf(__VA_ARGS__); } while (0) + +#define SMSG_DEBUG(...) \ + do { if (SEC_LOG_DEBUG) printf(__VA_ARGS__); } while (0) + +#define SMSG_ERROR(...) \ + do { if (SEC_LOG_ERROR) printf(__VA_ARGS__); } while (0) + +#define SMSG_INFO(...) \ + do { if (SEC_LOG_INFO) printf(__VA_ARGS__); } while (0) + + +#define HEVC_ENCRYTP_FILE_PATH "/data/mediaserver" +#define HEVC_ENC_SW_ENCRYPT_FILE_PATH "/system/lib/libhevce_sb.ca7.android.so" +#define HEVC_ENC_HW_ENCRYPT_FILE_PATH "/data/mediaserver/sb.ca7.android_hwenc.so" +#define HEVC_ENC_HW_DECRYPT_FILE_PATH "/data/mediaserver/sb.ca7.android_hwdec.so" +#define HEVC_DEC_SW_ENCRYTP_FILE_PATH "/system/lib/libHEVCdec_sa.ca7.android.so" +#define HEVC_DEC_HW_ENCRYPT_FILE_PATH "/data/mediaserver/dec_sa.ca7.android_hwenc.so" +#define HEVC_DEC_HW_DECRYPT_FILE_PATH "/data/mediaserver/dec_sa.ca7.android_hwdec.so" + +#endif /*_LIBMTK_CIPHER_EXPORT_H*/ diff --git a/kernel-headers/linux/almk_drv.h b/kernel-headers/linux/almk_drv.h new file mode 100644 index 0000000..1c1cc6c --- /dev/null +++ b/kernel-headers/linux/almk_drv.h @@ -0,0 +1,31 @@ +#include <linux/ioctl.h> + +#ifndef __ALMK_DRV_H__ +#define __ALMK_DRV_H__ + + +typedef struct +{ + unsigned int pid; + unsigned int *maxSafeSize; + //unsigned int *result; + +} ALMK_DRV_DATA; + + + + +#define ALMK_IOCTL_MAGIC 'x' + +//#define JPEG_DEC_IOCTL_INIT _IO (ALMK_IOCTL_MAGIC, 1) +//#define JPEG_DEC_IOCTL_CONFIG _IOW (ALMK_IOCTL_MAGIC, 2, JPEG_DEC_DRV_IN) +//#define JPEG_DEC_IOCTL_START _IO (ALMK_IOCTL_MAGIC, 3) +//#define JPEG_DEC_IOCTL_WAIT _IOWR(ALMK_IOCTL_MAGIC, 6, JPEG_DEC_DRV_OUT) +//#define JPEG_DEC_IOCTL_DEINIT _IO (ALMK_IOCTL_MAGIC, 8) + +#define ALMK_IOCTL_CMD_INIT _IO (ALMK_IOCTL_MAGIC, 11) +#define ALMK_IOCTL_CMD_GET_MAX_SIZE _IOWR(ALMK_IOCTL_MAGIC, 12, ALMK_DRV_DATA) +#define ALMK_IOCTL_CMD_DEINIT _IO (ALMK_IOCTL_MAGIC, 13) + +#endif + diff --git a/kernel-headers/linux/cache.h b/kernel-headers/linux/cache.h new file mode 100644 index 0000000..dca5a3c --- /dev/null +++ b/kernel-headers/linux/cache.h @@ -0,0 +1,58 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __LINUX_CACHE_H +#define __LINUX_CACHE_H +#include <linux/kernel.h> +#include <asm/cache.h> +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#ifndef L1_CACHE_ALIGN +#define L1_CACHE_ALIGN(x) ALIGN(x, L1_CACHE_BYTES) +#endif +#ifndef SMP_CACHE_BYTES +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#define SMP_CACHE_BYTES L1_CACHE_BYTES +#endif +#ifndef __read_mostly +#define __read_mostly +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#endif +#ifndef ____cacheline_aligned +#define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES))) +#endif +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#ifndef ____cacheline_aligned_in_smp +#define ____cacheline_aligned_in_smp +#endif +#ifndef __cacheline_aligned +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#define __cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES), __section__(".data.cacheline_aligned"))) +#endif +#ifndef __cacheline_aligned_in_smp +#define __cacheline_aligned_in_smp +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#endif +#ifndef INTERNODE_CACHE_SHIFT +#define INTERNODE_CACHE_SHIFT L1_CACHE_SHIFT +#endif +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#ifndef ____cacheline_internodealigned_in_smp +#define ____cacheline_internodealigned_in_smp +#endif +#endif +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ diff --git a/kernel-headers/linux/ccci_ipc_task_ID.h b/kernel-headers/linux/ccci_ipc_task_ID.h new file mode 100644 index 0000000..3f9909e --- /dev/null +++ b/kernel-headers/linux/ccci_ipc_task_ID.h @@ -0,0 +1,40 @@ +#ifndef __CCCI_IPC_TASK_ID_H__ +#define __CCCI_IPC_TASK_ID_H__ +// Priority --> Local module ID --> External ID --> Max sent message +// X_IPC_MODULE_CONF(1,M_SSDBG1,0,1) //TASK_ID_1 +// X_IPC_MODULE_CONF(1,AP_SSDBG2,1,1) //TASK_ID_2 +#ifdef __IPC_ID_TABLE +#define X_IPC_MODULE_CONF(a,b,c,d) {c,b}, +#else +#define X_IPC_MODULE_CONF(a,b,c,d) +#endif + + +#define AP_UNIFY_ID_FLAG (1<<31) +#define MD_UNIFY_ID_FLAG (0<<31) + +//---------------------------------------------------------- +#define AGPS_MD_MOD_L4C 0 +#define AGPS_MD_MOD_L4C_2 1 +#define AGPS_MD_MOD_L4C_3 2 +#define AGPS_MD_MOD_L4C_4 3 +//agps MD begin task_id +//Wait to add + +#define AGPS_AP_MOD_MMI 0 +//agps AP begin task_id +//Wait to add +#define GPS_AP_MOD 2 +//-------------------------------------------------------------------------- +X_IPC_MODULE_CONF(1, AGPS_MD_MOD_L4C, MD_UNIFY_ID_FLAG|0, 1) +X_IPC_MODULE_CONF(1, AGPS_MD_MOD_L4C_2, MD_UNIFY_ID_FLAG|1, 1) +X_IPC_MODULE_CONF(1, AGPS_MD_MOD_L4C_3, MD_UNIFY_ID_FLAG|2, 1) +X_IPC_MODULE_CONF(1, AGPS_MD_MOD_L4C_4, MD_UNIFY_ID_FLAG|3, 1) +//Wait to add +//-------------------------------------------------------------------------- +X_IPC_MODULE_CONF(1, AGPS_AP_MOD_MMI, AP_UNIFY_ID_FLAG|0, 1) +X_IPC_MODULE_CONF(1, GPS_AP_MOD, AP_UNIFY_ID_FLAG|2, 1) +//Wait to add +//------------------------------------------------------------------------- + +#endif diff --git a/kernel-headers/linux/cmdq/cmdq_event.h b/kernel-headers/linux/cmdq/cmdq_event.h new file mode 100644 index 0000000..4b71514 --- /dev/null +++ b/kernel-headers/linux/cmdq/cmdq_event.h @@ -0,0 +1,125 @@ + +/* MDP start frame */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA0_SOF, 0) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA1_SOF, 1) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_DSI0_TE_SOF, 2) /* DISPSYS TE event */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_DSI1_TE_SOF, 3) /* DISPSYS TE event */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_MVW_SOF, 4) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP0_SOF, 5) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP1_SOF, 6) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WDMA_SOF, 7) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_SOF, 8) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_SOF, 9) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_CROP_SOF, 10) +/* Display start frame */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL0_SOF, 11) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL1_SOF, 12) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA0_SOF, 13) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA1_SOF, 14) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA2_SOF, 15) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA0_SOF, 16) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA1_SOF, 17) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR0_SOF, 18) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR1_SOF, 19) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_AAL_SOF, 20) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_GAMMA_SOF, 21) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_UFOE_SOF, 22) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_PWM0_SOF, 23) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_PWM1_SOF, 24) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OD_SOF, 25) +/* MDP frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA0_EOF, 26) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RDMA1_EOF, 27) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ0_EOF, 28) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ1_EOF, 29) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_RSZ2_EOF, 30) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP0_EOF, 31) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_TDSHP1_EOF, 32) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WDMA_EOF, 33) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_W_EOF, 34) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT0_R_EOF, 35) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_W_EOF, 36) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_WROT1_R_EOF, 37) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MDP_CROP_EOF, 38) +/* Display frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL0_EOF, 39) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_OVL1_EOF, 40) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA0_EOF, 41) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA1_EOF, 42) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA2_EOF, 43) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA0_EOF, 44) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_WDMA1_EOF, 45) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR0_EOF, 46) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_COLOR1_EOF, 47) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_AAL_EOF, 48) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_GAMMA_EOF, 49) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_UFOE_EOF, 50) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_DPI0_EOF, 51) +/* Mutex frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX0_STREAM_EOF, 53) /* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX1_STREAM_EOF, 54) /* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX2_STREAM_EOF, 55) /* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX3_STREAM_EOF, 56) /* DISPSYS */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX4_STREAM_EOF, 57) /* DISPSYS, please refer to disp_hal.h */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX5_STREAM_EOF, 58) /* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX6_STREAM_EOF, 59) /* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX7_STREAM_EOF, 60) /* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX8_STREAM_EOF, 61) /* DpFramework */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_MUTEX9_STREAM_EOF, 62) +/* DpFramework via CMDQ_IOCTL_LOCK_MUTEX */ +/* Display underrun */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA0_UNDERRUN, 63) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA1_UNDERRUN, 64) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_DISP_RDMA2_UNDERRUN, 65) +/* ISP frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS2_2_EOF, 129) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS2_1_EOF, 130) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS2_0_EOF, 131) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS1_1_EOF, 132) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_PASS1_0_EOF, 133) +/* Engine events */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_CAMSV_2_PASS1_DONE, 134) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_CAMSV_1_PASS1_DONE, 135) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_SENINF_CAM1_2_3_FULL, 136) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_ISP_SENINF_CAM0_FULL, 137) +/* JPEG frame done */ +DECLARE_CMDQ_EVENT(CMDQ_EVENT_JPEG_ENC_PASS2_EOF, 257) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_JPEG_ENC_PASS1_EOF, 258) +DECLARE_CMDQ_EVENT(CMDQ_EVENT_JPEG_DEC_EOF, 259) + +DECLARE_CMDQ_EVENT(CMDQ_MAX_HW_EVENT_COUNT, 260) + + + +/* Keep this at the end of HW events */ +/* SW Sync Tokens (Pre-defined) */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_CONFIG_DIRTY, 261) +/* Config thread notify trigger thread */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_STREAM_EOF, 262) +/* Trigger thread notify config thread */ +/* ESD check state. Trigger thread will be blocked until the check finishes. */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_ESD_EOF, 263) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_CABC_EOF, 264) +/* check CABC setup finish */ +/* Block Trigger thread until the path freeze finishes */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_FREEZE_EOF, 265) +/* Pass-2 notifies VENC frame is ready to be encoded */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_VENC_INPUT_READY, 270) +/* VENC notifies Pass-2 encoding completion so next frame may start */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_VENC_EOF, 271) +/* Notify normal CMDQ there are some secure task done */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_SECURE_THR_EOF, 299) +/* SW Sync Tokens (User-defined) */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_USER_0, 300) +/* SW-defined sync token */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_USER_1, 301) +/* GPR access tokens (for HW register backup) */ +/* There are 15 32-bit GPR, 3 GPR form a set (64-bit for address, 32-bit for value) */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_0, 400) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_1, 401) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_2, 402) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_3, 403) +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_GPR_SET_4, 404) + +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_MAX, (0x1FF)) /* event id is 9 bit */ +DECLARE_CMDQ_EVENT(CMDQ_SYNC_TOKEN_INVALID, (-1)) diff --git a/kernel-headers/linux/cmdq/cmdq_subsys.h b/kernel-headers/linux/cmdq/cmdq_subsys.h new file mode 100644 index 0000000..1bef2d8 --- /dev/null +++ b/kernel-headers/linux/cmdq/cmdq_subsys.h @@ -0,0 +1,25 @@ + +/* msb id group reg-base-name */ +DECLARE_CMDQ_SUBSYS(0x1300, 0, MFG, HAN_BASE) +DECLARE_CMDQ_SUBSYS(0x1400, 1, MMSYS, MMSYS_CONFIG_BASE) +DECLARE_CMDQ_SUBSYS(0x1401, 2, DISP, DISP_RDMA2_BASE) +DECLARE_CMDQ_SUBSYS(0x1402, 3, DISP, MM_MUTEX_BASE) +DECLARE_CMDQ_SUBSYS(0x1500, 4, CAM, IMGSYS_BASE) +DECLARE_CMDQ_SUBSYS(0x1600, 5, VDEC, VDEC_GCON_BASE) +DECLARE_CMDQ_SUBSYS(0x1700, 6, MJC, MJC_CONFIG_BASE) +DECLARE_CMDQ_SUBSYS(0x1800, 7, VENC, VENC_GCON_BASE) +DECLARE_CMDQ_SUBSYS(0x1000, 8, INFRA_AO, CKSYS_BASE) +DECLARE_CMDQ_SUBSYS(0x1001, 9, INFRA_AO, KP_BASE) +DECLARE_CMDQ_SUBSYS(0x1002, 10, MD32, MD32_BASE) +DECLARE_CMDQ_SUBSYS(0x1003, 11, MD32, MD32_BASE) +DECLARE_CMDQ_SUBSYS(0x1004, 12, MD32, MD32_BASE) +DECLARE_CMDQ_SUBSYS(0x1005, 13, MD32, MD32_BASE) +DECLARE_CMDQ_SUBSYS(0x1020, 14, INFRASYS, MCUCFG_BASE) +DECLARE_CMDQ_SUBSYS(0x1021, 15, INFRASYS, GCPU_BASE) +DECLARE_CMDQ_SUBSYS(0x1120, 16, PERISYS, USB0_BASE) +DECLARE_CMDQ_SUBSYS(0x1121, 17, PERISYS, USB_SIF_BASE) +DECLARE_CMDQ_SUBSYS(0x1122, 18, PERISYS, AUDIO_BASE) +DECLARE_CMDQ_SUBSYS(0x1123, 19, PERISYS, MSDC0_BASE) +DECLARE_CMDQ_SUBSYS(0x1124, 20, PERISYS, MSDC1_BASE) +DECLARE_CMDQ_SUBSYS(0x1125, 21, PERISYS, MSDC2_BASE) +DECLARE_CMDQ_SUBSYS(0x1126, 22, PERISYS, MSDC3_BASE) diff --git a/kernel-headers/linux/ddp_od.h b/kernel-headers/linux/ddp_od.h new file mode 100644 index 0000000..8c7ebbe --- /dev/null +++ b/kernel-headers/linux/ddp_od.h @@ -0,0 +1,39 @@ +#ifndef __DDP_OD_H__ +#define __DDP_OD_H__ + +#include <linux/ioctl.h> + +/* OD */ +typedef struct { + unsigned int size; + unsigned int type; + unsigned int ret; + unsigned int param0; + unsigned int param1; + unsigned int param2; + unsigned int param3; +} DISP_OD_CMD; + +typedef enum{ + OD_CTL_READ_REG, + OD_CTL_WRITE_REG, + OD_CTL_ENABLE_DEMO_MODE, + OD_CTL_RUN_TEST, + OD_CTL_WRITE_TABLE, + OD_CTL_CMD_NUM, + OD_CTL_ENABLE +} DISP_OD_CMD_TYPE; + +typedef enum{ + OD_CTL_ENABLE_OFF, + OD_CTL_ENABLE_ON +} DISP_OD_ENABLE_STAGE; + +#define OD_CTL_ENABLE_DELAY 3 + +/* OD */ +#define DISP_IOCTL_MAGIC 'x' +#define DISP_IOCTL_OD_CTL _IOWR (DISP_IOCTL_MAGIC, 80 , DISP_OD_CMD) +#define DISP_IOCTL_OD_SET_ENABLED _IOWR (DISP_IOCTL_MAGIC, 81 , int) + +#endif diff --git a/kernel-headers/linux/disp_session.h b/kernel-headers/linux/disp_session.h new file mode 100644 index 0000000..5044708 --- /dev/null +++ b/kernel-headers/linux/disp_session.h @@ -0,0 +1,400 @@ +#ifndef __DISP_SESSION_H +#define __DISP_SESSION_H + +#define DISP_SESSION_DEVICE "mtk_disp_mgr" + + +#define DISP_NO_ION_FD ((int)(~0U>>1)) +#define DISP_NO_USE_LAEYR_ID ((int)(~0U>>1)) + +/* sync with define in ddp_ovl.h */ +#define OVL_CASCADE_SUPPORT +#ifdef OVL_CASCADE_SUPPORT +#define MAX_INPUT_CONFIG 8 +#else +#define MAX_INPUT_CONFIG 4 +#endif + +#define MAKE_DISP_FORMAT_ID(id, bpp) (((id) << 8) | (bpp)) +#define DISP_SESSION_MODE(id) (((id)>>24)&0xff) +#define DISP_SESSION_TYPE(id) (((id)>>16)&0xff) +#define DISP_SESSION_DEV(id) ((id)&0xff) +#define MAKE_DISP_SESSION(type, dev) (unsigned int)((type)<<16 | (dev)) + + + +/* /============================================================================= */ +/* structure declarations */ +/* /=========================== */ + +typedef enum { + DISP_IF_TYPE_DBI = 0, + DISP_IF_TYPE_DPI, + DISP_IF_TYPE_DSI0, + DISP_IF_TYPE_DSI1, + DISP_IF_TYPE_DSIDUAL, + DISP_IF_HDMI = 7, + DISP_IF_HDMI_SMARTBOOK, + DISP_IF_MHL, + DISP_IF_EPD +} DISP_IF_TYPE; + +typedef enum { + DISP_IF_FORMAT_RGB565 = 0, + DISP_IF_FORMAT_RGB666, + DISP_IF_FORMAT_RGB888 +} DISP_IF_FORMAT; + +typedef enum { + DISP_IF_MODE_VIDEO = 0, + DISP_IF_MODE_COMMAND +} DISP_IF_MODE; + + +typedef enum { + DISP_ORIENTATION_0 = 0, + DISP_ORIENTATION_90 = 1, + DISP_ORIENTATION_180 = 2, + DISP_ORIENTATION_270 = 3, +} DISP_ORIENTATION; + +typedef enum { + DISP_FORMAT_UNKNOWN = 0, + + DISP_FORMAT_RGB565 = MAKE_DISP_FORMAT_ID(1, 2), + DISP_FORMAT_RGB888 = MAKE_DISP_FORMAT_ID(2, 3), + DISP_FORMAT_BGR888 = MAKE_DISP_FORMAT_ID(3, 3), + DISP_FORMAT_ARGB8888 = MAKE_DISP_FORMAT_ID(4, 4), + DISP_FORMAT_ABGR8888 = MAKE_DISP_FORMAT_ID(5, 4), + DISP_FORMAT_RGBA8888 = MAKE_DISP_FORMAT_ID(6, 4), + DISP_FORMAT_BGRA8888 = MAKE_DISP_FORMAT_ID(7, 4), + DISP_FORMAT_YUV422 = MAKE_DISP_FORMAT_ID(8, 2), + DISP_FORMAT_XRGB8888 = MAKE_DISP_FORMAT_ID(9, 4), + DISP_FORMAT_XBGR8888 = MAKE_DISP_FORMAT_ID(10, 4), + DISP_FORMAT_RGBX8888 = MAKE_DISP_FORMAT_ID(11, 4), + DISP_FORMAT_BGRX8888 = MAKE_DISP_FORMAT_ID(12, 4), + DISP_FORMAT_UYVY = MAKE_DISP_FORMAT_ID(13, 2), + DISP_FORMAT_YUV420_P = MAKE_DISP_FORMAT_ID(14, 2), + DISP_FORMAT_YV12 = MAKE_DISP_FORMAT_ID(16, 1), /* BPP = 1.5 */ + DISP_FORMAT_BPP_MASK = 0xFF, +} DISP_FORMAT; + +typedef enum { + DISP_LAYER_2D = 0, + DISP_LAYER_3D_SBS_0 = 0x1, + DISP_LAYER_3D_SBS_90 = 0x2, + DISP_LAYER_3D_SBS_180 = 0x3, + DISP_LAYER_3D_SBS_270 = 0x4, + DISP_LAYER_3D_TAB_0 = 0x10, + DISP_LAYER_3D_TAB_90 = 0x20, + DISP_LAYER_3D_TAB_180 = 0x30, + DISP_LAYER_3D_TAB_270 = 0x40, +} DISP_LAYER_TYPE; + +typedef enum { + /* normal memory */ + DISP_NORMAL_BUFFER = 0, + /* normal memory but should not be dumpped within screenshot */ + DISP_PROTECT_BUFFER = 1, + /* secure memory */ + DISP_SECURE_BUFFER = 2, + DISP_SECURE_BUFFER_SHIFT = 0x10002 +} DISP_BUFFER_TYPE; + +typedef enum { + /* ion buffer */ + DISP_BUFFER_ION = 0, + /* dim layer, const alpha */ + DISP_BUFFER_ALPHA = 1, + /* mva buffer */ + DISP_BUFFER_MVA = 2, +} DISP_BUFFER_SOURCE; + +typedef enum { + DISP_ALPHA_ONE = 0, + DISP_ALPHA_SRC = 1, + DISP_ALPHA_SRC_INVERT = 2, + DISP_ALPHA_INVALID = 3, +} DISP_ALPHA_TYPE; + +typedef enum { + DISP_SESSION_PRIMARY = 1, + DISP_SESSION_EXTERNAL = 2, + DISP_SESSION_MEMORY = 3 +} DISP_SESSION_TYPE; + +typedef enum { + DISP_YUV_BT601_FULL = 0, + DISP_YUV_BT601 = 1, + DISP_YUV_BT709 = 2 +} DISP_YUV_RANGE_ENUM; + +typedef enum { + DISP_INVALID_SESSION_MODE = 0, + /* single output */ + DISP_SESSION_DIRECT_LINK_MODE = 1, + DISP_SESSION_DECOUPLE_MODE = 2, + + /* two ouputs */ + DISP_SESSION_DIRECT_LINK_MIRROR_MODE = 3, + DISP_SESSION_DECOUPLE_MIRROR_MODE = 4, + + DISP_SESSION_RDMA_MODE, + DISP_SESSION_MODE_NUM, + +} DISP_MODE; + +typedef enum { + SESSION_USER_INVALID = -1, + SESSION_USER_HWC = 0, + SESSION_USER_GUIEXT = 1, + SESSION_USER_AEE = 2, + SESSION_USER_PANDISP = 3, + SESSION_USER_CNT, +} DISP_SESSION_USER; + +typedef enum { + DISP_OUTPUT_UNKNOWN = 0, + DISP_OUTPUT_MEMORY = 1, + DISP_OUTPUT_DECOUPLE = 2, +} DISP_DC_TYPE; + +typedef enum { + TRIGGER_NORMAL, + TRIGGER_SUSPEND, + TRIGGER_RESUME, + + TRIGGER_MODE_MAX_NUM +} EXTD_TRIGGER_MODE; + +typedef struct disp_session_config_t { + DISP_SESSION_TYPE type; + unsigned int device_id; + DISP_MODE mode; + unsigned int session_id; + DISP_SESSION_USER user; + unsigned int present_fence_idx; + DISP_DC_TYPE dc_type; + int need_merge; + EXTD_TRIGGER_MODE tigger_mode; +} disp_session_config; + +typedef struct { + unsigned int session_id; + unsigned int vsync_cnt; + unsigned long long vsync_ts; + int lcm_fps; +} disp_session_vsync_config; + +typedef struct disp_input_config_t { + unsigned int layer_id; + unsigned int layer_enable; + DISP_BUFFER_SOURCE buffer_source; + void *src_base_addr; + void *src_phy_addr; + unsigned int src_direct_link; + DISP_FORMAT src_fmt; + unsigned int src_use_color_key; + unsigned int src_color_key; + unsigned int src_pitch; + unsigned int src_offset_x, src_offset_y; + unsigned int src_width, src_height; + + unsigned int tgt_offset_x, tgt_offset_y; + unsigned int tgt_width, tgt_height; + DISP_ORIENTATION layer_rotation; + DISP_LAYER_TYPE layer_type; + DISP_ORIENTATION video_rotation; + + unsigned int isTdshp; /* set to 1, will go through tdshp first, then layer blending, then to color */ + + unsigned int next_buff_idx; + int identity; + int connected_type; + DISP_BUFFER_TYPE security; + unsigned int alpha_enable; + unsigned int alpha; + unsigned int sur_aen; + DISP_ALPHA_TYPE src_alpha; + DISP_ALPHA_TYPE dst_alpha; + unsigned int frm_sequence; + DISP_YUV_RANGE_ENUM yuv_range; +} disp_input_config; + +typedef struct disp_output_config_t { + void *va; + void *pa; + DISP_FORMAT fmt; + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + unsigned int pitch; + unsigned int pitchUV; + DISP_BUFFER_TYPE security; + unsigned int buff_idx; + unsigned int interface_idx; + unsigned int frm_sequence; +} disp_output_config; + +typedef struct disp_session_input_config_t { + DISP_SESSION_USER setter; + unsigned int session_id; + unsigned int config_layer_num; + disp_input_config config[8]; +} disp_session_input_config; + +typedef struct disp_session_output_config_t { + unsigned int session_id; + disp_output_config config; +} disp_session_output_config; + +typedef struct disp_session_layer_num_config_t { + unsigned int session_id; + unsigned int max_layer_num; +} disp_session_layer_num_config; + +struct disp_frame_cfg_t { + DISP_SESSION_USER setter; + unsigned int session_id; + + /* input config */ + unsigned int input_layer_num; + disp_input_config input_cfg[8]; + unsigned int overlap_layer_num; + + /* constant layer */ + unsigned int const_layer_num; + disp_input_config const_layer[1]; + + /* output config */ + int output_en; + disp_output_config output_cfg; + + /* trigger config */ + DISP_MODE mode; + unsigned int present_fence_idx; + EXTD_TRIGGER_MODE tigger_mode; + DISP_SESSION_USER user; +}; + +typedef struct disp_session_info_t { + unsigned int session_id; + unsigned int maxLayerNum; + unsigned int isHwVsyncAvailable; + DISP_IF_TYPE displayType; + unsigned int displayWidth; + unsigned int displayHeight; + unsigned int displayFormat; + DISP_IF_MODE displayMode; + unsigned int vsyncFPS; + unsigned int physicalWidth; + unsigned int physicalHeight; + unsigned int isConnected; + unsigned int isHDCPSupported; + unsigned int isOVLDisabled; + unsigned int is3DSupport; + unsigned int const_layer_num; + /* updateFPS: fps of HWC trigger display */ + /* notes: for better Accuracy, updateFPS = real_fps*100 */ + unsigned int updateFPS; + unsigned int is_updateFPS_stable; +} disp_session_info; + +typedef struct disp_buffer_info_t { + /* Session */ + unsigned int session_id; + /* Input */ + unsigned int layer_id; + unsigned int layer_en; + int ion_fd; + unsigned int cache_sync; + /* Output */ + unsigned int index; + int fence_fd; + unsigned int interface_index; + int interface_fence_fd; +} disp_buffer_info; + +typedef struct disp_present_fence_info_t { + /* input */ + unsigned int session_id; + /* output */ + unsigned int present_fence_fd; + unsigned int present_fence_index; +} disp_present_fence; + +typedef struct disp_present_fence_t { + /* Session */ + unsigned int session_id; + + /* Output */ + unsigned int index; + int fence_fd; +} disp_present_fence_info; + +typedef enum { + DISP_OUTPUT_CAP_DIRECT_LINK = 0, + DISP_OUTPUT_CAP_DECOUPLE, + DISP_OUTPUT_CAP_SWITCHABLE, +} DISP_CAP_OUTPUT_MODE; + +typedef enum { + DISP_OUTPUT_CAP_SINGLE_PASS = 0, + DISP_OUTPUT_CAP_MULTI_PASS, +} DISP_CAP_OUTPUT_PASS; + +typedef enum { + DISP_FEATURE_TIME_SHARING = 0x00000001, +} DISP_FEATURE; + +typedef struct disp_caps_t { + DISP_CAP_OUTPUT_MODE output_mode; + DISP_CAP_OUTPUT_PASS output_pass; + unsigned int max_layer_num; +#ifdef CONFIG_FOR_SOURCE_PQ + unsigned int max_pq_num; +#endif + unsigned int disp_feature; + int is_support_frame_cfg_ioctl; + int is_output_rotated; +} disp_caps_info; + +typedef struct disp_session_buf_t { + unsigned int session_id; + unsigned int buf_hnd[3]; +} disp_session_buf_info; + +/* IOCTL commands. */ +#define DISP_IOW(num, dtype) _IOW('O', num, dtype) +#define DISP_IOR(num, dtype) _IOR('O', num, dtype) +#define DISP_IOWR(num, dtype) _IOWR('O', num, dtype) +#define DISP_IO(num) _IO('O', num) + + +#define DISP_IOCTL_CREATE_SESSION DISP_IOW(201, disp_session_config) +#define DISP_IOCTL_DESTROY_SESSION DISP_IOW(202, disp_session_config) +#define DISP_IOCTL_TRIGGER_SESSION DISP_IOW(203, disp_session_config) +#define DISP_IOCTL_PREPARE_INPUT_BUFFER DISP_IOW(204, disp_buffer_info) +#define DISP_IOCTL_PREPARE_OUTPUT_BUFFER DISP_IOW(205, disp_buffer_info) +#define DISP_IOCTL_SET_INPUT_BUFFER DISP_IOW(206, disp_session_input_config) +#define DISP_IOCTL_SET_OUTPUT_BUFFER DISP_IOW(207, disp_session_output_config) +#define DISP_IOCTL_GET_SESSION_INFO DISP_IOW(208, disp_session_info) + + +#define DISP_IOCTL_SET_SESSION_MODE DISP_IOW(209, disp_session_config) +#define DISP_IOCTL_GET_SESSION_MODE DISP_IOW(210, disp_session_config) +#define DISP_IOCTL_SET_SESSION_TYPE DISP_IOW(211, disp_session_config) +#define DISP_IOCTL_GET_SESSION_TYPE DISP_IOW(212, disp_session_config) +#define DISP_IOCTL_WAIT_FOR_VSYNC DISP_IOW(213, disp_session_vsync_config) +#define DISP_IOCTL_SET_MAX_LAYER_NUM DISP_IOW(214, disp_session_layer_num_config) +#define DISP_IOCTL_SET_VSYNC_FPS DISP_IOW(215, unsigned int) + +#define DISP_IOCTL_GET_PRESENT_FENCE DISP_IOW(216, disp_present_fence) + +#define DISP_IOCTL_GET_IS_DRIVER_SUSPEND DISP_IOW(217, unsigned int) +#define DISP_IOCTL_GET_DISPLAY_CAPS DISP_IOW(218, disp_caps_info) +#define DISP_IOCTL_INSERT_SESSION_BUFFERS DISP_IOW(219, disp_session_buf_info) +#define DISP_IOCTL_FRAME_CONFIG DISP_IOW(220, disp_session_output_config) + +#endif /* __DISP_SESSION_H */ diff --git a/kernel-headers/linux/disp_svp.h b/kernel-headers/linux/disp_svp.h new file mode 100644 index 0000000..3b8310f --- /dev/null +++ b/kernel-headers/linux/disp_svp.h @@ -0,0 +1,266 @@ +/** + * NOTICE: + * MUST BE consistent with bionic/libc/kernel/common/linux/disp_svp.h + */ +#ifndef __DISP_SVP_H +#define __DISP_SVP_H + +#define DISP_NO_ION_FD ((int)(~0U>>1)) +#define DISP_NO_USE_LAEYR_ID ((int)(~0U>>1)) + +#define MAX_INPUT_CONFIG 4 +#define MAKE_DISP_FORMAT_ID(id, bpp) (((id) << 8) | (bpp)) + +///============================================================================= +// structure declarations +///=========================== + +typedef enum +{ + DISP_IF_TYPE_DBI = 0, + DISP_IF_TYPE_DPI, + DISP_IF_TYPE_DSI0, + DISP_IF_TYPE_DSI1, + DISP_IF_TYPE_DSIDUAL, + DISP_IF_HDMI, + DISP_IF_HDMI_SMARTBOOK +} DISP_IF_TYPE; + +typedef enum +{ + DISP_IF_FORMAT_RGB565 = 0, + DISP_IF_FORMAT_RGB666, + DISP_IF_FORMAT_RGB888 +} DISP_IF_FORMAT; + +typedef enum +{ + DISP_IF_MODE_VIDEO = 0, + DISP_IF_MODE_COMMAND +} DISP_IF_MODE; + + +typedef enum +{ + DISP_ORIENTATION_0 = 0, + DISP_ORIENTATION_90 = 1, + DISP_ORIENTATION_180 = 2, + DISP_ORIENTATION_270 = 3, +} DISP_ORIENTATION; + +typedef enum +{ + DISP_FORMAT_UNKNOWN = 0, + + DISP_FORMAT_RGB565 = MAKE_DISP_FORMAT_ID(1, 2), + DISP_FORMAT_RGB888 = MAKE_DISP_FORMAT_ID(2, 3), + DISP_FORMAT_BGR888 = MAKE_DISP_FORMAT_ID(3, 3), + DISP_FORMAT_ARGB8888 = MAKE_DISP_FORMAT_ID(4, 4), + DISP_FORMAT_ABGR8888 = MAKE_DISP_FORMAT_ID(5, 4), + DISP_FORMAT_RGBA8888 = MAKE_DISP_FORMAT_ID(6, 4), + DISP_FORMAT_BGRA8888 = MAKE_DISP_FORMAT_ID(7, 4), + DISP_FORMAT_XRGB8888 = MAKE_DISP_FORMAT_ID(8, 4), + DISP_FORMAT_XBGR8888 = MAKE_DISP_FORMAT_ID(9, 4), + //Packed YUV Formats + DISP_FORMAT_YUV444 = MAKE_DISP_FORMAT_ID(10, 3), + DISP_FORMAT_YVYU = MAKE_DISP_FORMAT_ID(11, 2), //Same as UYVY, but replace Y/U/V + DISP_FORMAT_VYUY = MAKE_DISP_FORMAT_ID(12, 2), + DISP_FORMAT_UYVY = MAKE_DISP_FORMAT_ID(13, 2), + DISP_FORMAT_Y422 = MAKE_DISP_FORMAT_ID(13, 2), + DISP_FORMAT_YUYV = MAKE_DISP_FORMAT_ID(14, 2), //Same as UYVY but replace U/V + DISP_FORMAT_YUY2 = MAKE_DISP_FORMAT_ID(14, 2), + DISP_FORMAT_YUV422 = MAKE_DISP_FORMAT_ID(14, 2), //Will be removed + DISP_FORMAT_GREY = MAKE_DISP_FORMAT_ID(15, 1), //Single Y plane + DISP_FORMAT_Y800 = MAKE_DISP_FORMAT_ID(15, 1), + DISP_FORMAT_Y8 = MAKE_DISP_FORMAT_ID(15, 1), + //Planar YUV Formats + DISP_FORMAT_YV12 = MAKE_DISP_FORMAT_ID(16, 1), //BPP = 1.5 + DISP_FORMAT_I420 = MAKE_DISP_FORMAT_ID(17, 1), //Same as YV12 but replace U/V + DISP_FORMAT_IYUV = MAKE_DISP_FORMAT_ID(17, 1), + DISP_FORMAT_NV12 = MAKE_DISP_FORMAT_ID(18, 1), //BPP = 1.5 + DISP_FORMAT_NV21 = MAKE_DISP_FORMAT_ID(19, 1), //Same as NV12 but replace U/V + + DISP_FORMAT_BPP_MASK = 0xFFFF, +} DISP_FORMAT; + +typedef enum +{ + DISP_LAYER_2D = 0, + DISP_LAYER_3D_SBS_0 = 0x1, + DISP_LAYER_3D_SBS_90 = 0x2, + DISP_LAYER_3D_SBS_180 = 0x3, + DISP_LAYER_3D_SBS_270 = 0x4, + DISP_LAYER_3D_TAB_0 = 0x10, + DISP_LAYER_3D_TAB_90 = 0x20, + DISP_LAYER_3D_TAB_180 = 0x30, + DISP_LAYER_3D_TAB_270 = 0x40, +} DISP_LAYER_TYPE; + +typedef enum +{ + // normal memory + DISP_NORMAL_BUFFER = 0, + // secure memory + DISP_SECURE_BUFFER = 1, + // normal memory but should not be dumpped within screenshot + DISP_PROTECT_BUFFER = 2, + DISP_SECURE_BUFFER_SHIFT = 0x10001 +} DISP_BUFFER_TYPE; + +typedef enum +{ + DISP_SESSION_PRIMARY = 1, + DISP_SESSION_EXTERNAL = 2, + DISP_SESSION_MEMORY = 3 +}DISP_SESSION_TYPE; + +typedef enum +{ + // single output + DISP_SESSION_DIRECT_LINK_MODE = 1, + DISP_SESSION_DECOUPLE_MODE = 2, + + // two ouputs + DISP_SESSION_DIRECT_LINK_MIRROR_MODE = 3, + DISP_SESSION_DECOUPLE_MIRROR_MODE = 4, +}DISP_MODE; + +typedef struct disp_session_config_t +{ + DISP_SESSION_TYPE type; + unsigned int device_id; + DISP_MODE mode; + unsigned int session_id; +}disp_session_config; + +typedef struct +{ + unsigned int session_id; + unsigned int vsync_cnt; + long int vsync_ts; +}disp_session_vsync_config; + +typedef struct disp_input_config_t +{ + unsigned int layer_id; + unsigned int layer_enable; + + void* src_base_addr; + void* src_phy_addr; + unsigned int src_direct_link; + DISP_FORMAT src_fmt; + unsigned int src_use_color_key; + unsigned int src_color_key; + unsigned int src_pitch; + unsigned int src_offset_x, src_offset_y; + unsigned int src_width, src_height; + + unsigned int tgt_offset_x, tgt_offset_y; + unsigned int tgt_width, tgt_height; + DISP_ORIENTATION layer_rotation; + DISP_LAYER_TYPE layer_type; + DISP_ORIENTATION video_rotation; + + unsigned int isTdshp; // set to 1, will go through tdshp first, then layer blending, then to color + + unsigned int next_buff_idx; + int identity; + int connected_type; + DISP_BUFFER_TYPE security; + unsigned int alpha_enable; + unsigned int alpha; + unsigned int frm_sequence; +}disp_input_config; + + +typedef struct disp_output_config_t +{ + unsigned int va; + unsigned int pa; + DISP_FORMAT fmt; + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + unsigned int pitch; + unsigned int pitchUV; + DISP_BUFFER_TYPE security; + unsigned int buff_idx; + unsigned int frm_sequence; +}disp_output_config; + +#define MAX_INPUT_CONFIG 4 + +typedef struct disp_session_input_config_t +{ + unsigned int session_id; + unsigned int config_layer_num; + disp_input_config config[MAX_INPUT_CONFIG]; +}disp_session_input_config; + +typedef struct disp_session_output_config_t +{ + unsigned int session_id; + disp_output_config config; +}disp_session_output_config; + +typedef struct disp_session_layer_num_config_t +{ + unsigned int session_id; + unsigned int max_layer_num; +}disp_session_layer_num_config; + +typedef struct disp_session_info_t +{ + unsigned int session_id; + unsigned int maxLayerNum; + unsigned int isHwVsyncAvailable; + DISP_IF_TYPE displayType; + unsigned int displayWidth; + unsigned int displayHeight; + unsigned int displayFormat; + DISP_IF_MODE displayMode; + unsigned int vsyncFPS; + unsigned int physicalWidth; + unsigned int physicalHeight; + unsigned int isConnected; +} disp_session_info; + +typedef struct disp_buffer_info_t +{ + // Session + unsigned int session_id; + // Input + unsigned int layer_id; + unsigned int layer_en; + int ion_fd; + unsigned int cache_sync; + // Output + unsigned int index; + int fence_fd; +}disp_buffer_info; +/* IOCTL commands. */ +#define DISP_IOW(num, dtype) _IOW('O', num, dtype) +#define DISP_IOR(num, dtype) _IOR('O', num, dtype) +#define DISP_IOWR(num, dtype) _IOWR('O', num, dtype) +#define DISP_IO(num) _IO('O', num) + + +#define DISP_IOCTL_CREATE_SESSION DISP_IOW(201, disp_session_config) +#define DISP_IOCTL_DESTROY_SESSION DISP_IOW(202, disp_session_config) +#define DISP_IOCTL_TRIGGER_SESSION DISP_IOW(203, disp_session_config) +#define DISP_IOCTL_PREPARE_INPUT_BUFFER DISP_IOW(204, disp_buffer_info) +#define DISP_IOCTL_PREPARE_OUTPUT_BUFFER DISP_IOW(205, disp_buffer_info) +#define DISP_IOCTL_SET_INPUT_BUFFER DISP_IOW(206, disp_session_input_config) +#define DISP_IOCTL_SET_OUTPUT_BUFFER DISP_IOW(207, disp_session_output_config) +#define DISP_IOCTL_GET_SESSION_INFO DISP_IOW(208, disp_session_info) + +#define DISP_IOCTL_SET_SESSION_MODE DISP_IOW(209, disp_session_config) +#define DISP_IOCTL_GET_SESSION_MODE DISP_IOW(210, disp_session_config) +#define DISP_IOCTL_SET_SESSION_TYPE DISP_IOW(211, disp_session_config) +#define DISP_IOCTL_GET_SESSION_TYPE DISP_IOW(212, disp_session_config) +#define DISP_IOCTL_WAIT_FOR_VSYNC DISP_IOW(213, disp_session_vsync_config) +#define DISP_IOCTL_SET_MAX_LAYER_NUM DISP_IOW(214, disp_session_layer_num_config) + + +#endif //__DISP_SVP_H diff --git a/kernel-headers/linux/fm.h b/kernel-headers/linux/fm.h new file mode 100644 index 0000000..91ed0bf --- /dev/null +++ b/kernel-headers/linux/fm.h @@ -0,0 +1,631 @@ +#ifndef __FM_H__ +#define __FM_H__ + +//#define FMDEBUG + +#include <linux/ioctl.h> +#include <linux/time.h> +//fm type define +typedef signed char fm_s8; +typedef signed short fm_s16; +typedef signed int fm_s32; +typedef signed long long fm_s64; +typedef unsigned char fm_u8; +typedef unsigned short fm_u16; +typedef unsigned int fm_u32; +typedef unsigned long long fm_u64; +typedef enum fm_bool { + fm_false = 0, + fm_true = 1 +} fm_bool; + +// scan sort algorithm +enum { + FM_SCAN_SORT_NON = 0, + FM_SCAN_SORT_UP, + FM_SCAN_SORT_DOWN, + FM_SCAN_SORT_MAX +}; + +// scan methods +enum { + FM_SCAN_SEL_HW = 0, // select hardware scan, advantage: fast + FM_SCAN_SEL_SW, // select software scan, advantage: more accurate + FM_SCAN_SEL_MAX +}; + + //***************************************************************************************** +//***********************************FM config for customer *********************************** +//***************************************************************************************** +//RX +#define FMR_RSSI_TH_LONG 0x0301 //FM radio long antenna RSSI threshold(11.375dBuV) +#define FMR_RSSI_TH_SHORT 0x02E0 //FM radio short antenna RSSI threshold(-1dBuV) +#define FMR_CQI_TH 0x00E9 //FM radio Channel quality indicator threshold(0x0000~0x00FF) +#define FMR_SEEK_SPACE 1 //FM radio seek space,1:100KHZ; 2:200KHZ +#define FMR_SCAN_CH_SIZE 80 //FM radio scan max channel size +#define FMR_BAND 1 //FM radio band, 1:87.5MHz~108.0MHz; 2:76.0MHz~90.0MHz; 3:76.0MHz~108.0MHz; 4:special +#define FMR_BAND_FREQ_L 875 //FM radio special band low freq(Default 87.5MHz) +#define FMR_BAND_FREQ_H 1080 //FM radio special band high freq(Default 108.0MHz) +#define FM_SCAN_SORT_SELECT FM_SCAN_SORT_NON +#define FM_SCAN_SELECT FM_SCAN_SEL_HW +#define FM_SCAN_SOFT_MUTE_GAIN_TH 3 //soft-mute threshold when software scan, rang: 0~3, 0 means better audio quality but less channel +#define FM_CHIP_DESE_RSSI_TH (-102) // rang: -102 ~ -72 + +//TX +#define FMTX_PWR_LEVEL_MAX 120 //FM transmitter power level, rang: 85db~120db, default 120db + +//***************************************************************************************** +//***********************************FM config for engineer *********************************** +//***************************************************************************************** +//RX +#define FMR_MR_TH 0x01BD //FM radio MR threshold +#define ADDR_SCAN_TH 0xE0 //scan thrshold register +#define ADDR_CQI_TH 0xE1 //scan CQI register + +//TX +#define FMTX_SCAN_HOLE_LOW 923 //92.3MHz~95.4MHz should not show to user +#define FMTX_SCAN_HOLE_HIGH 954 //92.3MHz~95.4MHz should not show to user +//***************************************************************************************** + +#define FM_NAME "fm" +#define FM_DEVICE_NAME "/dev/fm" + +// errno +#define FM_SUCCESS 0 +#define FM_FAILED 1 +#define FM_EPARM 2 +#define FM_BADSTATUS 3 +#define FM_TUNE_FAILED 4 +#define FM_SEEK_FAILED 5 +#define FM_BUSY 6 +#define FM_SCAN_FAILED 7 + +// band +#define FM_BAND_UNKNOWN 0 +#define FM_BAND_UE 1 // US/Europe band 87.5MHz ~ 108MHz (DEFAULT) +#define FM_BAND_JAPAN 2 // Japan band 76MHz ~ 90MHz +#define FM_BAND_JAPANW 3 // Japan wideband 76MHZ ~ 108MHz +#define FM_BAND_SPECIAL 4 // special band between 76MHZ and 108MHz +#define FM_BAND_DEFAULT FM_BAND_UE + +#define FM_UE_FREQ_MIN 875 +#define FM_UE_FREQ_MAX 1080 +#define FM_JP_FREQ_MIN 760 +#define FM_JP_FREQ_MAX 1080 +#define FM_FREQ_MIN FMR_BAND_FREQ_L +#define FM_FREQ_MAX FMR_BAND_FREQ_H +#define FM_RAIDO_BAND FM_BAND_UE + +// space +#define FM_SPACE_UNKNOWN 0 +#define FM_SPACE_100K 1 +#define FM_SPACE_200K 2 +#define FM_SPACE_50K 5 + +#define FM_SEEK_SPACE FMR_SEEK_SPACE + +// max scan channel num +#define FM_MAX_CHL_SIZE FMR_SCAN_CH_SIZE +// auto HiLo +#define FM_AUTO_HILO_OFF 0 +#define FM_AUTO_HILO_ON 1 + +// seek direction +#define FM_SEEK_UP 0 +#define FM_SEEK_DOWN 1 + +#define FM_CHIP_AR1000 0x1000 +#define FM_CHIP_MT5192 0x91 +#define FM_CHIP_MT5193 0x92 +#define FM_CHIP_MT6616 0x6616 +#define FM_CHIP_MT6620 0x6620 +#define FM_CHIP_MT6626 0x6626 +#define FM_CHIP_MT6628 0x6628 +#define FM_CHIP_MT6627 0x6627 +#define FM_CHIP_MT6580 0x6580 +#define FM_CHIP_MT6630 0x6630 + +#define FM_CHIP_UNSUPPORTED -1 + +// seek threshold +#define FM_SEEKTH_LEVEL_DEFAULT 4 + +struct fm_tune_parm { + uint8_t err; + uint8_t band; + uint8_t space; + uint8_t hilo; + uint16_t freq; // IN/OUT parameter +}; + +struct fm_seek_parm { + uint8_t err; + uint8_t band; + uint8_t space; + uint8_t hilo; + uint8_t seekdir; + uint8_t seekth; + uint16_t freq; // IN/OUT parameter +}; + +struct fm_scan_parm { + uint8_t err; + uint8_t band; + uint8_t space; + uint8_t hilo; + uint16_t freq; // OUT parameter + uint16_t ScanTBL[26]; //need no less than the chip + uint16_t ScanTBLSize; //IN/OUT parameter +}; + +struct fm_ch_rssi { + uint16_t freq; + int rssi; +}; + +enum fm_scan_cmd_t { + FM_SCAN_CMD_INIT = 0, + FM_SCAN_CMD_START, + FM_SCAN_CMD_GET_NUM, + FM_SCAN_CMD_GET_CH, + FM_SCAN_CMD_GET_RSSI, + FM_SCAN_CMD_GET_CH_RSSI, + FM_SCAN_CMD_MAX +}; + +struct fm_scan_t { + enum fm_scan_cmd_t cmd; + int ret; // 0, success; else error code + uint16_t lower; // lower band, Eg, 7600 -> 76.0Mhz + uint16_t upper; // upper band, Eg, 10800 -> 108.0Mhz + int space; // 5: 50KHz, 10: 100Khz, 20: 200Khz + int num; // valid channel number + void *priv; + int sr_size; // scan result buffer size in bytes + union { + uint16_t *ch_buf; // channel buffer + int *rssi_buf; // rssi buffer + struct fm_ch_rssi *ch_rssi_buf; //channel and RSSI buffer + } sr; +}; + +struct fm_seek_t { + int ret; // 0, success; else error code + uint16_t freq; + uint16_t lower; // lower band, Eg, 7600 -> 76.0Mhz + uint16_t upper; // upper band, Eg, 10800 -> 108.0Mhz + int space; // 5: 50KHz, 10: 100Khz, 20: 200Khz + int dir; // 0: up; 1: down + int th; // seek threshold in dbm(Eg, -95dbm) + void *priv; +}; + +struct fm_tune_t { + int ret; // 0, success; else error code + uint16_t freq; + uint16_t lower; // lower band, Eg, 7600 -> 76.0Mhz + uint16_t upper; // upper band, Eg, 10800 -> 108.0Mhz + int space; // 5: 50KHz, 10: 100Khz, 20: 200Khz + void *priv; +}; + +struct fm_softmute_tune_t { + fm_s32 rssi; // RSSI of current channel + fm_u16 freq; // current frequency + fm_bool valid; // current channel is valid(true) or not(false) +}; + +struct fm_rssi_req { + uint16_t num; + uint16_t read_cnt; + struct fm_ch_rssi cr[26*16]; +}; + +struct fm_hw_info { + int chip_id; //chip ID, eg. 6620 + int eco_ver; //chip ECO version, eg. E3 + int rom_ver; //FM DSP rom code version, eg. V2 + int patch_ver; //FM DSP patch version, eg. 1.11 + int reserve; +}; + +struct fm_search_threshold_t { + fm_s32 th_type;// 0, RSSI. 1,desense RSSI. 2,SMG. + fm_s32 th_val; //threshold value + fm_s32 reserve; +}; + +#if 1 +#define NEED_DEF_RDS 1 +#else +#define NEED_DEF_RDS 0 +#endif + +#if NEED_DEF_RDS +//For RDS feature +typedef struct { + uint8_t TP; + uint8_t TA; + uint8_t Music; + uint8_t Stereo; + uint8_t Artificial_Head; + uint8_t Compressed; + uint8_t Dynamic_PTY; + uint8_t Text_AB; + uint32_t flag_status; +} RDSFlag_Struct; + +typedef struct { + uint16_t Month; + uint16_t Day; + uint16_t Year; + uint16_t Hour; + uint16_t Minute; + uint8_t Local_Time_offset_signbit; + uint8_t Local_Time_offset_half_hour; +} CT_Struct; + +typedef struct { + int16_t AF_Num; + int16_t AF[2][25]; //100KHz + uint8_t Addr_Cnt; + uint8_t isMethod_A; + uint8_t isAFNum_Get; +} AF_Info; + +typedef struct { + uint8_t PS[4][8]; + uint8_t Addr_Cnt; +} PS_Info; + +typedef struct { + uint8_t TextData[4][64]; + uint8_t GetLength; + uint8_t isRTDisplay; + uint8_t TextLength; + uint8_t isTypeA; + uint8_t BufCnt; + uint16_t Addr_Cnt; +} RT_Info; + +struct rds_raw_data { + int dirty; //indicate if the data changed or not + int len; //the data len form chip + uint8_t data[146]; +}; + +struct rds_group_cnt { + unsigned int total; + unsigned int groupA[16]; // RDS groupA counter + unsigned int groupB[16]; // RDS groupB counter +}; + +enum rds_group_cnt_opcode { + RDS_GROUP_CNT_READ = 0, + RDS_GROUP_CNT_WRITE, + RDS_GROUP_CNT_RESET, + RDS_GROUP_CNT_MAX +}; + +struct rds_group_cnt_req { + int err; + enum rds_group_cnt_opcode op; + struct rds_group_cnt gc; +}; + +typedef struct { + CT_Struct CT; + RDSFlag_Struct RDSFlag; + uint16_t PI; + uint8_t Switch_TP; + uint8_t PTY; + AF_Info AF_Data; + AF_Info AFON_Data; + uint8_t Radio_Page_Code; + uint16_t Program_Item_Number_Code; + uint8_t Extend_Country_Code; + uint16_t Language_Code; + PS_Info PS_Data; + uint8_t PS_ON[8]; + RT_Info RT_Data; + uint16_t event_status; //will use RDSFlag_Struct RDSFlag->flag_status to check which event, is that ok? + struct rds_group_cnt gc; +} RDSData_Struct; + + +//Need care the following definition. +//valid Rds Flag for notify +typedef enum { + RDS_FLAG_IS_TP = 0x0001, // Program is a traffic program + RDS_FLAG_IS_TA = 0x0002, // Program currently broadcasts a traffic ann. + RDS_FLAG_IS_MUSIC = 0x0004, // Program currently broadcasts music + RDS_FLAG_IS_STEREO = 0x0008, // Program is transmitted in stereo + RDS_FLAG_IS_ARTIFICIAL_HEAD = 0x0010, // Program is an artificial head recording + RDS_FLAG_IS_COMPRESSED = 0x0020, // Program content is compressed + RDS_FLAG_IS_DYNAMIC_PTY = 0x0040, // Program type can change + RDS_FLAG_TEXT_AB = 0x0080 // If this flag changes state, a new radio text string begins +} RdsFlag; + +typedef enum { + RDS_EVENT_FLAGS = 0x0001, // One of the RDS flags has changed state + RDS_EVENT_PI_CODE = 0x0002, // The program identification code has changed + RDS_EVENT_PTY_CODE = 0x0004, // The program type code has changed + RDS_EVENT_PROGRAMNAME = 0x0008, // The program name has changed + RDS_EVENT_UTCDATETIME = 0x0010, // A new UTC date/time is available + RDS_EVENT_LOCDATETIME = 0x0020, // A new local date/time is available + RDS_EVENT_LAST_RADIOTEXT = 0x0040, // A radio text string was completed + RDS_EVENT_AF = 0x0080, // Current Channel RF signal strength too weak, need do AF switch + RDS_EVENT_AF_LIST = 0x0100, // An alternative frequency list is ready + RDS_EVENT_AFON_LIST = 0x0200, // An alternative frequency list is ready + RDS_EVENT_TAON = 0x0400, // Other Network traffic announcement start + RDS_EVENT_TAON_OFF = 0x0800, // Other Network traffic announcement finished. + RDS_EVENT_RDS = 0x2000, // RDS Interrupt had arrived durint timer period + RDS_EVENT_NO_RDS = 0x4000, // RDS Interrupt not arrived durint timer period + RDS_EVENT_RDS_TIMER = 0x8000 // Timer for RDS Bler Check. ---- BLER block error rate +} RdsEvent; +#endif + +struct fm_rds_tx_parm { + uint8_t err; + uint16_t pi; + uint16_t ps[12]; // 4 ps + uint16_t other_rds[87]; // 0~29 other groups + uint8_t other_rds_cnt; // # of other group +}; + +typedef struct fm_rds_tx_req { + unsigned char pty; // 0~31 integer + unsigned char rds_rbds; // 0:RDS, 1:RBDS + unsigned char dyn_pty; // 0:static, 1:dynamic + unsigned short pi_code; // 2-byte hex + unsigned char ps_buf[8]; // hex buf of PS + unsigned char ps_len; // length of PS, must be 0 / 8" + unsigned char af; // 0~204, 0:not used, 1~204:(87.5+0.1*af)MHz + unsigned char ah; // Artificial head, 0:no, 1:yes + unsigned char stereo; // 0:mono, 1:stereo + unsigned char compress; // Audio compress, 0:no, 1:yes + unsigned char tp; // traffic program, 0:no, 1:yes + unsigned char ta; // traffic announcement, 0:no, 1:yes + unsigned char speech; // 0:music, 1:speech +} fm_rds_tx_req; + +#define TX_SCAN_MAX 10 +#define TX_SCAN_MIN 1 +struct fm_tx_scan_parm { + uint8_t err; + uint8_t band; //87.6~108MHz + uint8_t space; + uint8_t hilo; + uint16_t freq; // start freq, if less than band min freq, then will use band min freq + uint8_t scandir; + uint16_t ScanTBL[TX_SCAN_MAX]; //need no less than the chip + uint16_t ScanTBLSize; //IN: desired size, OUT: scan result size +}; + +struct fm_gps_rtc_info { + int err; //error number, 0: success, other: err code + int retryCnt; //GPS mnl can decide retry times + int ageThd; //GPS 3D fix time diff threshold + int driftThd; //GPS RTC drift threshold + struct timeval tvThd; //time value diff threshold + int age; //GPS 3D fix time diff + int drift; //GPS RTC drift + union{ + unsigned long stamp; //time stamp in jiffies + struct timeval tv; //time stamp value in RTC + }; + int flag; //rw flag +}; + +typedef enum { + FM_I2S_ON = 0, + FM_I2S_OFF, + FM_I2S_STATE_ERR +} fm_i2s_state_e; + +typedef enum { + FM_I2S_MASTER = 0, + FM_I2S_SLAVE, + FM_I2S_MODE_ERR +} fm_i2s_mode_e; + +typedef enum { + FM_I2S_32K = 0, + FM_I2S_44K, + FM_I2S_48K, + FM_I2S_SR_ERR +} fm_i2s_sample_e; + +struct fm_i2s_setting { + int onoff; + int mode; + int sample; +}; + +typedef enum { + FM_RX = 0, + FM_TX = 1 +} FM_PWR_T; + +typedef struct fm_i2s_info { + int status; /*0:FM_I2S_ON, 1:FM_I2S_OFF,2:error*/ + int mode; /*0:FM_I2S_MASTER, 1:FM_I2S_SLAVE,2:error*/ + int rate; /*0:FM_I2S_32K:32000,1:FM_I2S_44K:44100,2:FM_I2S_48K:48000,3:error*/ +} fm_i2s_info_t; + +typedef enum { + FM_AUD_ANALOG = 0, + FM_AUD_I2S = 1, + FM_AUD_MRGIF = 2, + FM_AUD_ERR +} fm_audio_path_e; + +typedef enum { + FM_I2S_PAD_CONN = 0, //sco fm chip: e.g.6627 + FM_I2S_PAD_IO = 1, //combo fm chip: e.g.6628 + FM_I2S_PAD_ERR +} fm_i2s_pad_sel_e; + +typedef struct fm_audio_info { + fm_audio_path_e aud_path; + fm_i2s_info_t i2s_info; + fm_i2s_pad_sel_e i2s_pad; +} fm_audio_info_t; + +struct fm_cqi { + int ch; + int rssi; + int reserve; +}; + +struct fm_cqi_req { + uint16_t ch_num; + int buf_size; + char *cqi_buf; +}; + +typedef struct { + int freq; + int rssi; +} fm_desense_check_t; + +typedef struct { + uint16_t lower; // lower band, Eg, 7600 -> 76.0Mhz + uint16_t upper; // upper band, Eg, 10800 -> 108.0Mhz + int space; // 0x1: 50KHz, 0x2: 100Khz, 0x4: 200Khz + int cycle; // repeat times +} fm_full_cqi_log_t; + +typedef struct { + int which; + bool stat; +} fm_status_t; + +// ********** ***********FM IOCTL define start ******************************* + +#define FM_IOC_MAGIC 0xf5 // FIXME: any conflict? +#define FM_IOCTL_POWERUP _IOWR(FM_IOC_MAGIC, 0, struct fm_tune_parm*) +#define FM_IOCTL_POWERDOWN _IOWR(FM_IOC_MAGIC, 1, int32_t*) +#define FM_IOCTL_TUNE _IOWR(FM_IOC_MAGIC, 2, struct fm_tune_parm*) +#define FM_IOCTL_SEEK _IOWR(FM_IOC_MAGIC, 3, struct fm_seek_parm*) +#define FM_IOCTL_SETVOL _IOWR(FM_IOC_MAGIC, 4, uint32_t*) +#define FM_IOCTL_GETVOL _IOWR(FM_IOC_MAGIC, 5, uint32_t*) +#define FM_IOCTL_MUTE _IOWR(FM_IOC_MAGIC, 6, uint32_t*) +#define FM_IOCTL_GETRSSI _IOWR(FM_IOC_MAGIC, 7, int32_t*) +#define FM_IOCTL_SCAN _IOWR(FM_IOC_MAGIC, 8, struct fm_scan_parm*) +#define FM_IOCTL_STOP_SCAN _IO(FM_IOC_MAGIC, 9) + +//IOCTL and struct for test +#define FM_IOCTL_GETCHIPID _IOWR(FM_IOC_MAGIC, 10, uint16_t*) +#define FM_IOCTL_EM_TEST _IOWR(FM_IOC_MAGIC, 11, struct fm_em_parm*) +#define FM_IOCTL_RW_REG _IOWR(FM_IOC_MAGIC, 12, struct fm_ctl_parm*) +#define FM_IOCTL_GETMONOSTERO _IOWR(FM_IOC_MAGIC, 13, uint16_t*) +#define FM_IOCTL_GETCURPAMD _IOWR(FM_IOC_MAGIC, 14, uint16_t*) +#define FM_IOCTL_GETGOODBCNT _IOWR(FM_IOC_MAGIC, 15, uint16_t*) +#define FM_IOCTL_GETBADBNT _IOWR(FM_IOC_MAGIC, 16, uint16_t*) +#define FM_IOCTL_GETBLERRATIO _IOWR(FM_IOC_MAGIC, 17, uint16_t*) + +//IOCTL for RDS +#define FM_IOCTL_RDS_ONOFF _IOWR(FM_IOC_MAGIC, 18, uint16_t*) +#define FM_IOCTL_RDS_SUPPORT _IOWR(FM_IOC_MAGIC, 19, int32_t*) + +#define FM_IOCTL_POWERUP_TX _IOWR(FM_IOC_MAGIC, 20, struct fm_tune_parm*) +#define FM_IOCTL_TUNE_TX _IOWR(FM_IOC_MAGIC, 21, struct fm_tune_parm*) +#define FM_IOCTL_RDS_TX _IOWR(FM_IOC_MAGIC, 22, struct fm_rds_tx_parm*) + +#define FM_IOCTL_RDS_SIM_DATA _IOWR(FM_IOC_MAGIC, 23, uint32_t*) +#define FM_IOCTL_IS_FM_POWERED_UP _IOWR(FM_IOC_MAGIC, 24, uint32_t*) + +//IOCTL for FM Tx +#define FM_IOCTL_TX_SUPPORT _IOWR(FM_IOC_MAGIC, 25, int32_t*) +#define FM_IOCTL_RDSTX_SUPPORT _IOWR(FM_IOC_MAGIC, 26, int32_t*) +#define FM_IOCTL_RDSTX_ENABLE _IOWR(FM_IOC_MAGIC, 27, int32_t*) +#define FM_IOCTL_TX_SCAN _IOWR(FM_IOC_MAGIC, 28, struct fm_tx_scan_parm*) + +//IOCTL for FM over BT +#define FM_IOCTL_OVER_BT_ENABLE _IOWR(FM_IOC_MAGIC, 29, int32_t*) + +//IOCTL for FM ANTENNA SWITCH +#define FM_IOCTL_ANA_SWITCH _IOWR(FM_IOC_MAGIC, 30, int32_t*) +#define FM_IOCTL_GETCAPARRAY _IOWR(FM_IOC_MAGIC, 31, int32_t*) + +//IOCTL for FM compensation by GPS RTC +#define FM_IOCTL_GPS_RTC_DRIFT _IOWR(FM_IOC_MAGIC, 32, struct fm_gps_rtc_info*) + +//IOCTL for FM I2S Setting +#define FM_IOCTL_I2S_SETTING _IOWR(FM_IOC_MAGIC, 33, struct fm_i2s_setting*) + +#define FM_IOCTL_RDS_GROUPCNT _IOWR(FM_IOC_MAGIC, 34, struct rds_group_cnt_req*) +#define FM_IOCTL_RDS_GET_LOG _IOWR(FM_IOC_MAGIC, 35, struct rds_raw_data*) + +#define FM_IOCTL_SCAN_GETRSSI _IOWR(FM_IOC_MAGIC, 36, struct fm_rssi_req*) +#define FM_IOCTL_SETMONOSTERO _IOWR(FM_IOC_MAGIC, 37, int32_t) +#define FM_IOCTL_RDS_BC_RST _IOWR(FM_IOC_MAGIC, 38, int32_t*) +#define FM_IOCTL_CQI_GET _IOWR(FM_IOC_MAGIC, 39, struct fm_cqi_req*) +#define FM_IOCTL_GET_HW_INFO _IOWR(FM_IOC_MAGIC, 40, struct fm_hw_info*) +#define FM_IOCTL_GET_I2S_INFO _IOWR(FM_IOC_MAGIC, 41, fm_i2s_info_t*) +#define FM_IOCTL_IS_DESE_CHAN _IOWR(FM_IOC_MAGIC, 42, int32_t*) +#define FM_IOCTL_TOP_RDWR _IOWR(FM_IOC_MAGIC, 43, struct fm_top_rw_parm*) +#define FM_IOCTL_HOST_RDWR _IOWR(FM_IOC_MAGIC, 44, struct fm_host_rw_parm*) + +#define FM_IOCTL_PRE_SEARCH _IOWR(FM_IOC_MAGIC, 45,int32_t) +#define FM_IOCTL_RESTORE_SEARCH _IOWR(FM_IOC_MAGIC, 46,int32_t) + +#define FM_IOCTL_SET_SEARCH_THRESHOLD _IOWR(FM_IOC_MAGIC, 47, fm_search_threshold_t*) + +#define FM_IOCTL_GET_AUDIO_INFO _IOWR(FM_IOC_MAGIC, 48, fm_audio_info_t*) +#define FM_IOCTL_FM_SET_STATUS _IOWR(FM_IOC_MAGIC, 49, fm_status_t) +#define FM_IOCTL_FM_GET_STATUS _IOWR(FM_IOC_MAGIC, 50, fm_status_t) + +#define FM_IOCTL_SCAN_NEW _IOWR(FM_IOC_MAGIC, 60, struct fm_scan_t*) +#define FM_IOCTL_SEEK_NEW _IOWR(FM_IOC_MAGIC, 61, struct fm_seek_t*) +#define FM_IOCTL_TUNE_NEW _IOWR(FM_IOC_MAGIC, 62, struct fm_tune_t*) + +#define FM_IOCTL_SOFT_MUTE_TUNE _IOWR(FM_IOC_MAGIC, 63, struct fm_softmute_tune_t*)/*for soft mute tune*/ +#define FM_IOCTL_DESENSE_CHECK _IOWR(FM_IOC_MAGIC, 64, fm_desense_check_t*) + +//IOCTL for EM +#define FM_IOCTL_FULL_CQI_LOG _IOWR(FM_IOC_MAGIC, 70, fm_full_cqi_log_t *) + +#define FM_IOCTL_DUMP_REG _IO(FM_IOC_MAGIC, 0xFF) + +// ********** ***********FM IOCTL define end ******************************* + + +enum group_idx { + mono = 0, + stereo, + RSSI_threshold, + HCC_Enable, + PAMD_threshold, + Softmute_Enable, + De_emphasis, + HL_Side, + Demod_BW, + Dynamic_Limiter, + Softmute_Rate, + AFC_Enable, + Softmute_Level, + Analog_Volume, + GROUP_TOTAL_NUMS +}; + +enum item_idx { + Sblend_OFF = 0, + Sblend_ON, + ITEM_TOTAL_NUMS +}; + +struct fm_ctl_parm { + uint8_t err; + uint8_t addr; + uint16_t val; + uint16_t rw_flag;//0:write, 1:read +}; + +struct fm_em_parm { + uint16_t group_idx; + uint16_t item_idx; + uint32_t item_value; +}; +#endif // __FM_H__ diff --git a/kernel-headers/linux/hdmitx.h b/kernel-headers/linux/hdmitx.h new file mode 100644 index 0000000..58103b5 --- /dev/null +++ b/kernel-headers/linux/hdmitx.h @@ -0,0 +1,361 @@ +// --------------------------------------------------------------------------- + +#ifndef HDMITX_H +#define HDMITX_H + + +#define HDMI_DEV_DRV "/dev/hdmitx" + + +typedef enum +{ + HDMI_STATUS_OK = 0, + HDMI_STATUS_NOT_IMPLEMENTED, + HDMI_STATUS_ALREADY_SET, + HDMI_STATUS_ERROR, +} HDMI_STATUS; + +typedef enum +{ + SMART_BOOK_DISCONNECTED = 0, + SMART_BOOK_CONNECTED, +} SMART_BOOK_STATE; + +typedef enum +{ + HDMI_POWER_STATE_OFF = 0, + HDMI_POWER_STATE_ON, + HDMI_POWER_STATE_STANDBY, +} HDMI_POWER_STATE; + +typedef enum +{ + HDMI_MAX_CHANNEL_2 = 0x2, + HDMI_MAX_CHANNEL_3 = 0x3, + HDMI_MAX_CHANNEL_4 = 0x4, + HDMI_MAX_CHANNEL_5 = 0x5, + HDMI_MAX_CHANNEL_6 = 0x6, + HDMI_MAX_CHANNEL_7 = 0x7, + HDMI_MAX_CHANNEL_8 = 0x8, +}AUDIO_MAX_CHANNEL; + +typedef enum +{ + HDMI_MAX_SAMPLERATE_32 = 0x1, + HDMI_MAX_SAMPLERATE_44 = 0x2, + HDMI_MAX_SAMPLERATE_48 = 0x3, + HDMI_MAX_SAMPLERATE_96 = 0x4, + HDMI_MAX_SAMPLERATE_192 = 0x5, +}AUDIO_MAX_SAMPLERATE; + +typedef enum +{ + HDMI_MAX_BITWIDTH_16 = 0x1, + HDMI_MAX_BITWIDTH_24 = 0x2, +}AUDIO_MAX_BITWIDTH; + +typedef enum +{ + HDMI_SCALE_ADJUSTMENT_SUPPORT = 0x01, + HDMI_ONE_RDMA_LIMITATION = 0x02, + HDMI_PHONE_GPIO_REUSAGE = 0x04, +} HDMI_CAPABILITY; + +typedef enum +{ + HDMI_TO_TV = 0x0, + HDMI_TO_SMB, +} hdmi_device_type; + +typedef enum +{ + HDMI_IS_DISCONNECTED = 0, + HDMI_IS_CONNECTED = 1, + HDMI_IS_RES_CHG = 0x11, +} hdmi_connect_status; + +#define MAKE_MTK_HDMI_FORMAT_ID(id, bpp) (((id) << 8) | (bpp)) +typedef enum +{ + MTK_HDMI_FORMAT_UNKNOWN = 0, + + MTK_HDMI_FORMAT_RGB565 = MAKE_MTK_HDMI_FORMAT_ID(1, 2), + MTK_HDMI_FORMAT_RGB888 = MAKE_MTK_HDMI_FORMAT_ID(2, 3), + MTK_HDMI_FORMAT_BGR888 = MAKE_MTK_HDMI_FORMAT_ID(3, 3), + MTK_HDMI_FORMAT_ARGB8888 = MAKE_MTK_HDMI_FORMAT_ID(4, 4), + MTK_HDMI_FORMAT_ABGR8888 = MAKE_MTK_HDMI_FORMAT_ID(5, 4), + MTK_HDMI_FORMAT_YUV422 = MAKE_MTK_HDMI_FORMAT_ID(6, 2), + MTK_HDMI_FORMAT_XRGB8888 = MAKE_MTK_HDMI_FORMAT_ID(7, 4), + MTK_HDMI_FORMAT_XBGR8888 = MAKE_MTK_HDMI_FORMAT_ID(8, 4), + MTK_HDMI_FORMAT_BPP_MASK = 0xFF, +} MTK_HDMI_FORMAT; + +typedef struct +{ + bool is_audio_enabled; + bool is_video_enabled; +} hdmi_device_status; + +typedef struct +{ + void *src_base_addr; + void *src_phy_addr; + int src_fmt; + unsigned int src_pitch; + unsigned int src_offset_x, src_offset_y; + unsigned int src_width, src_height; + + int next_buff_idx; + int identity; + int connected_type; + unsigned int security; + +} hdmi_video_buffer_info; + + +typedef struct +{ + // Input + int ion_fd; + // Output + unsigned int index; //fence count + int fence_fd; //fence fd +} hdmi_buffer_info; + +#define MTK_HDMI_NO_FENCE_FD ((int)(-1)) //((int)(~0U>>1)) +#define MTK_HDMI_NO_ION_FD ((int)(-1)) //((int)(~0U>>1)) + +typedef struct +{ + unsigned int u4Addr; + unsigned int u4Data; +} hdmi_device_write; + +typedef struct +{ + unsigned int u4Data1; + unsigned int u4Data2; +} hdmi_para_setting; + +typedef struct +{ + unsigned char u1Hdcpkey[287]; +} hdmi_hdcp_key; + +typedef struct +{ + unsigned char u1Hdcpkey[384]; +} hdmi_hdcp_drmkey; + +typedef struct +{ + unsigned char u1sendsltdata[15]; +} send_slt_data; + +typedef struct _HDMI_EDID_T +{ + unsigned int ui4_ntsc_resolution;//use EDID_VIDEO_RES_T, there are many resolution + unsigned int ui4_pal_resolution;// use EDID_VIDEO_RES_T + unsigned int ui4_sink_native_ntsc_resolution;//use EDID_VIDEO_RES_T, only one NTSC resolution, Zero means none native NTSC resolution is avaiable + unsigned int ui4_sink_native_pal_resolution; //use EDID_VIDEO_RES_T, only one resolution, Zero means none native PAL resolution is avaiable + unsigned int ui4_sink_cea_ntsc_resolution;//use EDID_VIDEO_RES_T + unsigned int ui4_sink_cea_pal_resolution;//use EDID_VIDEO_RES_T + unsigned int ui4_sink_dtd_ntsc_resolution;//use EDID_VIDEO_RES_T + unsigned int ui4_sink_dtd_pal_resolution;//use EDID_VIDEO_RES_T + unsigned int ui4_sink_1st_dtd_ntsc_resolution;//use EDID_VIDEO_RES_T + unsigned int ui4_sink_1st_dtd_pal_resolution;//use EDID_VIDEO_RES_T + unsigned short ui2_sink_colorimetry;//use EDID_VIDEO_COLORIMETRY_T + unsigned char ui1_sink_rgb_color_bit;//color bit for RGB + unsigned char ui1_sink_ycbcr_color_bit; // color bit for YCbCr + unsigned short ui2_sink_aud_dec;// use EDID_AUDIO_DECODER_T + unsigned char ui1_sink_is_plug_in;//1: Plug in 0:Plug Out + unsigned int ui4_hdmi_pcm_ch_type;//use EDID_A_FMT_CH_TYPE + unsigned int ui4_hdmi_pcm_ch3ch4ch5ch7_type;//use EDID_A_FMT_CH_TYPE1 + unsigned int ui4_dac_pcm_ch_type;//use EDID_A_FMT_CH_TYPE + unsigned char ui1_sink_i_latency_present; + unsigned char ui1_sink_p_audio_latency; + unsigned char ui1_sink_p_video_latency; + unsigned char ui1_sink_i_audio_latency; + unsigned char ui1_sink_i_video_latency; + unsigned char ui1ExtEdid_Revision; + unsigned char ui1Edid_Version; + unsigned char ui1Edid_Revision; + unsigned char ui1_Display_Horizontal_Size; + unsigned char ui1_Display_Vertical_Size; + unsigned int ui4_ID_Serial_Number; + unsigned int ui4_sink_cea_3D_resolution; + unsigned char ui1_sink_support_ai;//0: not support AI, 1:support AI + unsigned short ui2_sink_cec_address; + unsigned short ui1_sink_max_tmds_clock; + unsigned short ui2_sink_3D_structure; + unsigned int ui4_sink_cea_FP_SUP_3D_resolution; + unsigned int ui4_sink_cea_TOB_SUP_3D_resolution; + unsigned int ui4_sink_cea_SBS_SUP_3D_resolution; + unsigned short ui2_sink_ID_manufacturer_name;//(08H~09H) + unsigned short ui2_sink_ID_product_code; //(0aH~0bH) + unsigned int ui4_sink_ID_serial_number; //(0cH~0fH) + unsigned char ui1_sink_week_of_manufacture; //(10H) + unsigned char ui1_sink_year_of_manufacture; //(11H) base on year 1990 +} HDMI_EDID_T; + +typedef struct +{ + unsigned int ui4_sink_FP_SUP_3D_resolution; + unsigned int ui4_sink_TOB_SUP_3D_resolution; + unsigned int ui4_sink_SBS_SUP_3D_resolution; +} MHL_3D_SUPP_T; + +typedef struct +{ + unsigned char ui1_la_num; + unsigned char e_la[3]; + unsigned short ui2_pa; + unsigned short h_cecm_svc; +} CEC_DRV_ADDR_CFG; + +typedef struct +{ + unsigned char destination : 4; + unsigned char initiator : 4; +} CEC_HEADER_BLOCK_IO; + +typedef struct +{ + CEC_HEADER_BLOCK_IO header; + unsigned char opcode; + unsigned char operand[15]; +} CEC_FRAME_BLOCK_IO; + +typedef struct +{ + unsigned char size; + unsigned char sendidx; + unsigned char reTXcnt; + void *txtag; + CEC_FRAME_BLOCK_IO blocks; +} CEC_FRAME_DESCRIPTION_IO; + +typedef struct _CEC_FRAME_INFO +{ + unsigned char ui1_init_addr; + unsigned char ui1_dest_addr; + unsigned short ui2_opcode; + unsigned char aui1_operand[14]; + unsigned int z_operand_size; +} CEC_FRAME_INFO; + +typedef struct _CEC_SEND_MSG +{ + CEC_FRAME_INFO t_frame_info; + unsigned char b_enqueue_ok; +} CEC_SEND_MSG; + +typedef struct +{ + unsigned char ui1_la; + unsigned short ui2_pa; +} CEC_ADDRESS_IO; + +typedef struct +{ + unsigned char u1Size; + unsigned char au1Data[14]; +} CEC_GETSLT_DATA; + +typedef struct +{ + unsigned int u1adress; + unsigned int pu1Data; +} READ_REG_VALUE; + +typedef struct +{ + unsigned char e_hdmi_aud_in; + unsigned char e_iec_frame; + unsigned char e_hdmi_fs; + unsigned char e_aud_code; + unsigned char u1Aud_Input_Chan_Cnt; + unsigned char e_I2sFmt; + unsigned char u1HdmiI2sMclk; + unsigned char bhdmi_LCh_status[5]; + unsigned char bhdmi_RCh_status[5]; +} HDMITX_AUDIO_PARA; + + +#define HDMI_IOW(num, dtype) _IOW('H', num, dtype) +#define HDMI_IOR(num, dtype) _IOR('H', num, dtype) +#define HDMI_IOWR(num, dtype) _IOWR('H', num, dtype) +#define HDMI_IO(num) _IO('H', num) + +#define MTK_HDMI_AUDIO_VIDEO_ENABLE HDMI_IO(1) +#define MTK_HDMI_AUDIO_ENABLE HDMI_IO(2) +#define MTK_HDMI_VIDEO_ENABLE HDMI_IO(3) +#define MTK_HDMI_GET_CAPABILITY HDMI_IOWR(4, HDMI_CAPABILITY) +#define MTK_HDMI_GET_DEVICE_STATUS HDMI_IOWR(5, hdmi_device_status) +#define MTK_HDMI_VIDEO_CONFIG HDMI_IOWR(6, int) +#define MTK_HDMI_AUDIO_CONFIG HDMI_IOWR(7, int) +#define MTK_HDMI_FORCE_FULLSCREEN_ON HDMI_IOWR(8, int) +#define MTK_HDMI_FORCE_FULLSCREEN_OFF HDMI_IOWR(9, int) +#define MTK_HDMI_IPO_POWEROFF HDMI_IOWR(10, int) +#define MTK_HDMI_IPO_POWERON HDMI_IOWR(11, int) +#define MTK_HDMI_POWER_ENABLE HDMI_IOW(12, int) +#define MTK_HDMI_PORTRAIT_ENABLE HDMI_IOW(13, int) +#define MTK_HDMI_FORCE_OPEN HDMI_IOWR(14, int) +#define MTK_HDMI_FORCE_CLOSE HDMI_IOWR(15, int) +#define MTK_HDMI_IS_FORCE_AWAKE HDMI_IOWR(16, int) + +#define MTK_HDMI_POST_VIDEO_BUFFER HDMI_IOW(20, hdmi_video_buffer_info) +#define MTK_HDMI_AUDIO_SETTING HDMI_IOWR(21, HDMITX_AUDIO_PARA) + + +#define MTK_HDMI_FACTORY_MODE_ENABLE HDMI_IOW(30, int) +#define MTK_HDMI_FACTORY_GET_STATUS HDMI_IOWR(31, int) +#define MTK_HDMI_FACTORY_DPI_TEST HDMI_IOWR(32, int) + +#define MTK_HDMI_USBOTG_STATUS HDMI_IOWR(33, int) +#define MTK_HDMI_GET_DRM_ENABLE HDMI_IOWR(34, int) + +#define MTK_HDMI_GET_DEV_INFO HDMI_IOWR(35, mtk_dispif_info_t) +#define MTK_HDMI_PREPARE_BUFFER HDMI_IOW(36, hdmi_buffer_info) +#define MTK_HDMI_SCREEN_CAPTURE HDMI_IOW(37, unsigned long) + +#define MTK_HDMI_WRITE_DEV HDMI_IOWR(52, hdmi_device_write) +#define MTK_HDMI_READ_DEV HDMI_IOWR(53, unsigned int) +#define MTK_HDMI_ENABLE_LOG HDMI_IOWR(54, unsigned int) +#define MTK_HDMI_CHECK_EDID HDMI_IOWR(55, unsigned int) +#define MTK_HDMI_INFOFRAME_SETTING HDMI_IOWR(56, hdmi_para_setting) +#define MTK_HDMI_COLOR_DEEP HDMI_IOWR(57, hdmi_para_setting) +#define MTK_HDMI_ENABLE_HDCP HDMI_IOWR(58, unsigned int) +#define MTK_HDMI_STATUS HDMI_IOWR(59, unsigned int) +#define MTK_HDMI_HDCP_KEY HDMI_IOWR(60, hdmi_hdcp_key) +#define MTK_HDMI_GET_EDID HDMI_IOWR(61, HDMI_EDID_T) +#define MTK_HDMI_SETLA HDMI_IOWR(62, CEC_DRV_ADDR_CFG) +#define MTK_HDMI_GET_CECCMD HDMI_IOWR(63, CEC_FRAME_DESCRIPTION_IO) +#define MTK_HDMI_SET_CECCMD HDMI_IOWR(64, CEC_SEND_MSG) +#define MTK_HDMI_CEC_ENABLE HDMI_IOWR(65, unsigned int) +#define MTK_HDMI_GET_CECADDR HDMI_IOWR(66, CEC_ADDRESS_IO) +#define MTK_HDMI_CECRX_MODE HDMI_IOWR(67, unsigned int) +#define MTK_HDMI_SENDSLTDATA HDMI_IOWR(68, send_slt_data) +#define MTK_HDMI_GET_SLTDATA HDMI_IOWR(69, CEC_GETSLT_DATA) +#define MTK_HDMI_VIDEO_MUTE HDMI_IOWR(70, int) + +#define MTK_HDMI_READ HDMI_IOWR(81, unsigned int) +#define MTK_HDMI_WRITE HDMI_IOWR(82, unsigned int) +#define MTK_HDMI_CMD HDMI_IOWR(83, unsigned int) +#define MTK_HDMI_DUMP HDMI_IOWR(84, unsigned int) +#define MTK_HDMI_DUMP6397 HDMI_IOWR(85, unsigned int) +#define MTK_HDMI_DUMP6397_W HDMI_IOWR(86, unsigned int) +#define MTK_HDMI_CBUS_STATUS HDMI_IOWR(87, unsigned int) +#define MTK_HDMI_CONNECT_STATUS HDMI_IOWR(88, unsigned int) +#define MTK_HDMI_DUMP6397_R HDMI_IOWR(89, unsigned int) +#define MTK_MHL_GET_DCAP HDMI_IOWR(90, unsigned int) +#define MTK_MHL_GET_3DINFO HDMI_IOWR(91, unsigned int) +#define MTK_HDMI_HDCP HDMI_IOWR(92, unsigned int) +#define MTK_HDMI_AUDIO_FORMAT HDMI_IOWR(93, unsigned int) + +#define MTK_HDMI_FACTORY_CHIP_INIT HDMI_IOWR(94, int) +#define MTK_HDMI_FACTORY_JUDGE_CALLBACK HDMI_IOWR(95, int) +#define MTK_HDMI_FACTORY_START_DPI_AND_CONFIG HDMI_IOWR(96, int) +#define MTK_HDMI_FACTORY_DPI_STOP_AND_POWER_OFF HDMI_IOWR(97, int) + +#endif diff --git a/kernel-headers/linux/hwmsensor.h b/kernel-headers/linux/hwmsensor.h new file mode 100644 index 0000000..c14611d --- /dev/null +++ b/kernel-headers/linux/hwmsensor.h @@ -0,0 +1,308 @@ +/* alps + * + * (C) Copyright 2009 + * MediaTek <www.MediaTek.com> + * + * MT6516 Sensor IOCTL & data structure + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __HWMSENSOR_H__ +#define __HWMSENSOR_H__ + +#include <linux/ioctl.h> + +#define SENSOR_TYPE_ACCELEROMETER 1 +#define SENSOR_TYPE_MAGNETIC_FIELD 2 +#define SENSOR_TYPE_ORIENTATION 3 +#define SENSOR_TYPE_GYROSCOPE 4 +#define SENSOR_TYPE_LIGHT 5 +#define SENSOR_TYPE_PRESSURE 6 +#define SENSOR_TYPE_TEMPERATURE 7 +#define SENSOR_TYPE_PROXIMITY 8 +#define SENSOR_TYPE_GRAVITY 9 +#define SENSOR_TYPE_LINEAR_ACCELERATION 10 +#define SENSOR_TYPE_ROTATION_VECTOR 11 +#define SENSOR_TYPE_HUMIDITY 12 +#define SENSOR_TYPE_GAME_ROTATION_VECTOR 15 +#define SENSOR_TYPE_SIGNIFICANT_MOTION 17 +#define SENSOR_TYPE_STEP_DETECTOR 18 +#define SENSOR_TYPE_STEP_COUNTER 19 + +#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR 20 + +#define SENSOR_TYPE_HEART_RATE 21 +#define SENSOR_TYPE_TILT_DETECTOR 22 +#define SENSOR_TYPE_WAKE_GESTURE 23 +#define SENSOR_TYPE_GLANCE_GESTURE 24 +#define SENSOR_TYPE_PICK_UP_GESTURE 25 + +#define SENSOR_TYPE_PEDOMETER (26) +#define SENSOR_STRING_TYPE_PEDOMETER "android.sensor.pedometer" +#define SENSOR_TYPE_IN_POCKET (27) +#define SENSOR_STRING_TYPE_IN_POCKET "android.sensor.in_pocket" +#define SENSOR_TYPE_ACTIVITY (28) +#define SENSOR_STRING_TYPE_ACTIVITY "android.sensor.activity" +#define SENSOR_TYPE_FACE_DOWN (29) +#define SENSOR_STRING_TYPE_FACE_DOWN "android.sensor.face_down" +#define SENSOR_TYPE_SHAKE (30) +#define SENSOR_STRING_TYPE_SHAKE "android.sensor.shake" +#define SENSOR_TYPE_BRINGTOSEE (31) +#define SENSOR_STRING_TYPE_BRINGTOSEE "android.sensor.bring_to_see" + +/*---------------------------------------------------------------------------*/ +#define ID_BASE 0 +#define ID_ORIENTATION (ID_BASE+SENSOR_TYPE_ORIENTATION-1) +#define ID_MAGNETIC (ID_BASE+SENSOR_TYPE_MAGNETIC_FIELD-1) +#define ID_ACCELEROMETER (ID_BASE+SENSOR_TYPE_ACCELEROMETER-1) +#define ID_LINEAR_ACCELERATION (ID_BASE+SENSOR_TYPE_LINEAR_ACCELERATION-1) +#define ID_ROTATION_VECTOR (ID_BASE+SENSOR_TYPE_ROTATION_VECTOR-1) +#define ID_GAME_ROTATION_VECTOR (ID_BASE+SENSOR_TYPE_GAME_ROTATION_VECTOR-1) +#define ID_GRAVITY (ID_BASE+SENSOR_TYPE_GRAVITY-1) +#define ID_GYROSCOPE (ID_BASE+SENSOR_TYPE_GYROSCOPE-1) +#define ID_PROXIMITY (ID_BASE+SENSOR_TYPE_PROXIMITY-1) +#define ID_LIGHT (ID_BASE+SENSOR_TYPE_LIGHT-1) +#define ID_PRESSURE (ID_BASE+SENSOR_TYPE_PRESSURE-1) +#define ID_TEMPRERATURE (ID_BASE+SENSOR_TYPE_TEMPERATURE-1) +#define ID_HUMIDITY (ID_BASE+SENSOR_TYPE_HUMIDITY-1) +#define ID_SIGNIFICANT_MOTION (ID_BASE+SENSOR_TYPE_SIGNIFICANT_MOTION-1) +#define ID_STEP_DETECTOR (ID_BASE+SENSOR_TYPE_STEP_DETECTOR-1) +#define ID_STEP_COUNTER (ID_BASE+SENSOR_TYPE_STEP_COUNTER-1) +#define ID_GEOMAGNETIC_ROTATION_VECTOR (ID_BASE+SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR-1) +#define ID_HEART_RATE (ID_BASE+SENSOR_TYPE_HEART_RATE-1) +#define ID_TILT_DETECTOR (ID_BASE+SENSOR_TYPE_TILT_DETECTOR-1) +#define ID_WAKE_GESTURE (ID_BASE+SENSOR_TYPE_WAKE_GESTURE-1) +#define ID_GLANCE_GESTURE (ID_BASE+SENSOR_TYPE_GLANCE_GESTURE-1) +#define ID_PICK_UP_GESTURE (ID_BASE+SENSOR_TYPE_PICK_UP_GESTURE-1) +#define ID_PEDOMETER (ID_BASE+SENSOR_TYPE_PEDOMETER-1) +#define ID_ACTIVITY (ID_BASE+SENSOR_TYPE_ACTIVITY-1) +#define ID_IN_POCKET (ID_BASE+SENSOR_TYPE_IN_POCKET-1) +#define ID_FACE_DOWN (ID_BASE+SENSOR_TYPE_FACE_DOWN-1) +#define ID_SHAKE (ID_BASE+SENSOR_TYPE_SHAKE-1) +#define ID_BRINGTOSEE (ID_BASE+SENSOR_TYPE_BRINGTOSEE-1) +#define ID_SENSOR_MAX_HANDLE (ID_BASE+SENSOR_TYPE_BRINGTOSEE) +#define ID_NONE (ID_SENSOR_MAX_HANDLE+1) + +#define ID_OFFSET (1) + +#define MAX_ANDROID_SENSOR_NUM (ID_SENSOR_MAX_HANDLE +1) +#define MAX_SENSOR_DATA_UPDATE_ONCE (20) + +/*---------------------------------------------------------------------------*/ +#define SENSOR_ORIENTATION (1 << ID_ORIENTATION) +#define SENSOR_MAGNETIC (1 << ID_MAGNETIC) +#define SENSOR_ACCELEROMETER (1 << ID_ACCELEROMETER) +#define SENSOR_GYROSCOPE (1 << ID_GYROSCOPE) +#define SENSOR_PROXIMITY (1 << ID_PROXIMITY) +#define SENSOR_LIGHT (1 << ID_LIGHT) +#define SENSOR_PRESSURE (1 << ID_PRESSURE) +#define SENSOR_TEMPRERATURE (1 << ID_TEMPRERATURE) +#define SENSOR_GRAVITY (1 << ID_GRAVITY) +#define SENSOR_LINEAR_ACCELERATION (1 << ID_LINEAR_ACCELERATION) +#define SENSOR_ROTATION_VECTOR (1 << ID_ROTATION_VECTOR) + +#define SENSOR_SIGNIFICANT_MOTION (1 << ID_SIGNIFICANT_MOTION) +#define SENSOR_STEP_DETECTOR (1 << ID_STEP_DETECTOR) +#define SENSOR_STEP_COUNTER (1 << ID_STEP_COUNTER) +#define SENSOR_GEOMAGNETIC_ROTATION_VECTOR (1 << ID_GEOMAGNETIC_ROTATION_VECTOR) + +#define SENSOR_HEART_RATE (1 << ID_HEART_RATE) +#define SENSOR_TILT_DETECTOR (1 << ID_TILT_DETECTOR) +#define SENSOR_WAKE_GESTURE (1 << ID_WAKE_GESTURE) +#define SENSOR_GLANCE_GESTURE (1 << ID_GLANCE_GESTURE) +#define SENSOR_PICK_UP_GESTURE (1 << ID_PICK_UP_GESTURE) + +#define SENSOR_PEDOMETER (1 << ID_PEDOMETER) +#define SENSOR_IN_POCKET (1 << ID_IN_POCKET) +#define SENSOR_ACTIVITY (1 << ID_ACTIVITY) +#define SENSOR_FACE_DOWN (1 << ID_FACE_DOWN) +#define SENSOR_SHAKE (1 << ID_SHAKE) +#define SENSOR_BRINGTOSEE (1 << ID_BRINGTOSEE) + +/*----------------------------------------------------------------------------*/ +#define HWM_INPUTDEV_NAME "hwmdata" +#define HWM_SENSOR_DEV_NAME "hwmsensor" +#define HWM_SENSOR_DEV "/dev/hwmsensor" +#define C_MAX_HWMSEN_EVENT_NUM 4 +/*----------------------------------------------------------------------------*/ +#define ACC_PL_DEV_NAME "m_acc_pl" +#define ACC_INPUTDEV_NAME "m_acc_input" +#define ACC_MISC_DEV_NAME "m_acc_misc" +#define MAG_PL_DEV_NAME "m_mag_pl" +#define MAG_INPUTDEV_NAME "m_mag_input" +#define MAG_MISC_DEV_NAME "m_mag_misc" +#define GYRO_PL_DEV_NAME "m_gyro_pl" +#define GYRO_INPUTDEV_NAME "m_gyro_input" +#define GYRO_MISC_DEV_NAME "m_gyro_misc" +#define ALSPS_PL_DEV_NAME "m_alsps_pl" +#define ALSPS_INPUTDEV_NAME "m_alsps_input" +#define ALSPS_MISC_DEV_NAME "m_alsps_misc" +#define BARO_PL_DEV_NAME "m_baro_pl" +#define BARO_INPUTDEV_NAME "m_baro_input" +#define BARO_MISC_DEV_NAME "m_baro_misc" + +#define STEP_C_PL_DEV_NAME "m_step_c_pl" +#define STEP_C_INPUTDEV_NAME "m_step_c_input" +#define STEP_C_MISC_DEV_NAME "m_step_c_misc" + +#define INPK_PL_DEV_NAME "m_inpk_pl" +#define INPK_INPUTDEV_NAME "m_inpk_input" +#define INPK_MISC_DEV_NAME "m_inpk_misc" + +#define SHK_PL_DEV_NAME "m_shk_pl" +#define SHK_INPUTDEV_NAME "m_shk_input" +#define SHK_MISC_DEV_NAME "m_shk_misc" + +#define FDN_PL_DEV_NAME "m_fdn_pl" +#define FDN_INPUTDEV_NAME "m_fdn_input" +#define FDN_MISC_DEV_NAME "m_fdn_misc" + +#define PKUP_PL_DEV_NAME "m_pkup_pl" +#define PKUP_INPUTDEV_NAME "m_pkup_input" +#define PKUP_MISC_DEV_NAME "m_pkup_misc" + +#define ACT_PL_DEV_NAME "m_act_pl" +#define ACT_INPUTDEV_NAME "m_act_input" +#define ACT_MISC_DEV_NAME "m_act_misc" + +#define PDR_PL_DEV_NAME "m_pdr_pl" +#define PDR_INPUTDEV_NAME "m_pdr_input" +#define PDR_MISC_DEV_NAME "m_pdr_misc" + +#define HRM_PL_DEV_NAME "m_hrm_pl" +#define HRM_INPUTDEV_NAME "m_hrm_input" +#define HRM_MISC_DEV_NAME "m_hrm_misc" + +#define TILT_PL_DEV_NAME "m_tilt_pl" +#define TILT_INPUTDEV_NAME "m_tilt_input" +#define TILT_MISC_DEV_NAME "m_tilt_misc" + +#define WAG_PL_DEV_NAME "m_wag_pl" +#define WAG_INPUTDEV_NAME "m_wag_input" +#define WAG_MISC_DEV_NAME "m_wag_misc" + +#define GLG_PL_DEV_NAME "m_glg_pl" +#define GLG_INPUTDEV_NAME "m_glg_input" +#define GLG_MISC_DEV_NAME "m_glg_misc" + +#define TEMP_PL_DEV_NAME "m_temp_pl" +#define TEMP_INPUTDEV_NAME "m_temp_input" +#define TEMP_MISC_DEV_NAME "m_temp_misc" + +#define BATCH_PL_DEV_NAME "m_batch_pl" +#define BATCH_INPUTDEV_NAME "m_batch_input" +#define BATCH_MISC_DEV_NAME "m_batch_misc" + +#define BTS_PL_DEV_NAME "m_bts_pl" +#define BTS_INPUTDEV_NAME "m_bts_input" +#define BTS_MISC_DEV_NAME "m_bts_misc" + +#define GRV_PL_DEV_NAME "m_grv_pl" +#define GRV_INPUTDEV_NAME "m_grv_input" +#define GRV_MISC_DEV_NAME "m_grv_misc" + +#define GMRV_PL_DEV_NAME "m_gmrv_pl" +#define GMRV_INPUTDEV_NAME "m_gmrv_input" +#define GMRV_MISC_DEV_NAME "m_gmrv_misc" + +#define GRAV_PL_DEV_NAME "m_grav_pl" +#define GRAV_INPUTDEV_NAME "m_grav_input" +#define GRAV_MISC_DEV_NAME "m_grav_misc" + +#define LA_PL_DEV_NAME "m_la_pl" +#define LA_INPUTDEV_NAME "m_la_input" +#define LA_MISC_DEV_NAME "m_la_misc" + +#define RV_PL_DEV_NAME "m_rv_pl" +#define RV_INPUTDEV_NAME "m_rv_input" +#define RV_MISC_DEV_NAME "m_rv_misc" + +#define EVENT_TYPE_SENSOR 0x01 +#define EVENT_TYPE_SENSOR_EXT 0x02 +#define EVENT_SENSOR_ACCELERATION SENSOR_ACCELEROMETER +#define EVENT_SENSOR_MAGNETIC SENSOR_MAGNETIC +#define EVENT_SENSOR_ORIENTATION SENSOR_ORIENTATION +#define EVENT_SENSOR_GYROSCOPE SENSOR_GYROSCOPE +#define EVENT_SENSOR_LIGHT SENSOR_LIGHT +#define EVENT_SENSOR_PRESSURE SENSOR_PRESSURE +#define EVENT_SENSOR_TEMPERATURE SENSOR_TEMPRERATURE +#define EVENT_SENSOR_PROXIMITY SENSOR_PROXIMITY +#define EVENT_SENSOR_GRAVITY SENSOR_PRESSURE +#define EVENT_SENSOR_LINEAR_ACCELERATION SENSOR_TEMPRERATURE +#define EVENT_SENSOR_ROTATION_VECTOR SENSOR_PROXIMITY +/*-----------------------------------------------------------------------------*/ + +enum { + HWM_MODE_DISABLE = 0, + HWM_MODE_ENABLE = 1, +}; + +/*------------sensors data----------------------------------------------------*/ +typedef struct { + /* sensor identifier */ + int sensor; + /* sensor values */ + int values[6]; + /* sensor values divide */ + uint32_t value_divide; + /* sensor accuracy*/ + int8_t status; + /* whether updata? */ + int update; + /* time is in nanosecond */ + int64_t time; + + uint32_t reserved; +}hwm_sensor_data; + +typedef struct { + hwm_sensor_data data[MAX_SENSOR_DATA_UPDATE_ONCE]; + uint64_t data_type; +}hwm_trans_data; + +#define MAX_BATCH_DATA_PER_QUREY 18 +typedef struct { + int numOfDataReturn; + int numOfDataLeft; + hwm_sensor_data data[MAX_BATCH_DATA_PER_QUREY]; +}batch_trans_data; + +/*----------------------------------------------------------------------------*/ +#define HWM_IOC_MAGIC 0x91 + +/* set delay */ +#define HWM_IO_SET_DELAY _IOW(HWM_IOC_MAGIC, 0x01, uint32_t) + +/* wake up */ +#define HWM_IO_SET_WAKE _IO(HWM_IOC_MAGIC, 0x02) + +/* Enable/Disable sensor */ +#define HWM_IO_ENABLE_SENSOR _IOW(HWM_IOC_MAGIC, 0x03, uint32_t) +#define HWM_IO_DISABLE_SENSOR _IOW(HWM_IOC_MAGIC, 0x04, uint32_t) + +/* Enable/Disable sensor */ +#define HWM_IO_ENABLE_SENSOR_NODATA _IOW(HWM_IOC_MAGIC, 0x05, uint32_t) +#define HWM_IO_DISABLE_SENSOR_NODATA _IOW(HWM_IOC_MAGIC, 0x06, uint32_t) +/* Get sensors data */ +#define HWM_IO_GET_SENSORS_DATA _IOWR(HWM_IOC_MAGIC, 0x07, hwm_trans_data) + +/*----------------------------------------------------------------------------*/ +#define BATCH_IOC_MAGIC 0x92 + +/* Get sensor data */ +#define BATCH_IO_GET_SENSORS_DATA _IOWR(BATCH_IOC_MAGIC, 0x01, batch_trans_data) + +#endif // __HWMSENSOR_H__ diff --git a/kernel-headers/linux/ion_debugger.h b/kernel-headers/linux/ion_debugger.h new file mode 100644 index 0000000..e396839 --- /dev/null +++ b/kernel-headers/linux/ion_debugger.h @@ -0,0 +1,193 @@ +#ifndef ION_DEBUGGER_DEF +#define ION_DEBUGGER_DEF +#define BACKTRACE_SIZE 10 +//#include <linux/mutex.h> +typedef enum +{ + ION_FUNCTION_OPEN, + ION_FUNCTION_CLOSE, + ION_FUNCTION_CREATE_CLIENT, + ION_FUNCTION_DESTROY_CLIENT, + ION_FUNCTION_ALLOC, + ION_FUNCTION_ALLOC_MM, + ION_FUNCTION_ALLOC_CONT, + ION_FUNCTION_FREE, + ION_FUNCTION_IMPORT, + ION_FUNCTION_MMAP, + ION_FUNCTION_MUNMAP, + ION_FUNCTION_SHARE, + ION_FUNCTION_SHARE_CLOSE +}ION_FUNCTION_TYPE; + +typedef enum +{ + BUFFER_ALLOCATION_LIST, + BUFFER_FREE_LIST, + ADDRESS_ALLOCATION_LIST, + ADDRESS_FREE_LIST, + FD_ALLOCATION_LIST, + FD_FREE_LIST +}ION_DEBUGGER_LIST_TYPE; +typedef enum +{ + ADDRESS_USER_VIRTUAL, + ADDRESS_KERNEL_VIRTUAL, + ADDRESS_KERNEL_PHYSICAL, + ADDRESS_MAX +}ION_MAPPING_ADDRESS_TYPE; +typedef enum +{ + RECORD_ID, + RECORD_CLIENT, + RECORD_HANDLE, + RECORD_ALLOCATE_BACKTRACE_NUM, + RECORD_FREED_BACKTRACE_NUM, + RECORD_ALLOCATE_MAPPING_NUM, + RECORD_FREED_MAPPING_NUM, + RECORD_FD, + RECORD_ADDRESS, + RECORD_SIZE, + RECORD_NEXT +}ION_DEBUGGDER_RECORD_DATA; +typedef enum +{ + SEARCH_PID, + SEARCH_PID_CLIENT, + SEARCH_PROCESS_PID, + SEARCH_BUFFER, + SEARCH_MAX +}ION_SEARCH_METHOD; +typedef enum +{ + LIST_BUFFER, + LIST_PROCESS, + NODE_BUFFER, + NODE_FD, + NODE_CLIENT, + NODE_MMAP, + NODE_MAX +}ION_RECORD_TYPE; +typedef enum +{ + HASH_NODE_CLIENT, + HASH_NODE_HANDLE, + HASH_NODE_BUFFER, + HASH_NODE_USER_BACKTRACE, + HASH_NODE_KERNEL_BACKTRACE, + HASH_NODE_USER_MAPPING, + HASH_NODE_KERNEL_SYMBOL, + HASH_NODE_MAX +}ION_HASH_NODE_TYPE; +typedef enum +{ + ALLOCATE_BACKTRACE_INFO, + RELEASE_BACKTRACE_INFO, + KERNEL_BACKTRACE, + USER_BACKTRACE, + BACKTRACE_MAX +}BACKTRACE_INFO; +struct mapping +{ + char *name; + unsigned int address; + unsigned int size; +}; +typedef struct ion_sys_record_param +{ + pid_t group_id; + pid_t pid; + unsigned int action; + unsigned int address_type; + unsigned int address; + unsigned int length; + unsigned int backtrace[BACKTRACE_SIZE]; + unsigned int kernel_symbol[BACKTRACE_SIZE]; + struct mapping mapping_record[BACKTRACE_SIZE]; + unsigned int backtrace_num; + struct ion_handle *handle; + struct ion_client *client; + struct ion_buffer *buffer; + int fd; +}ion_sys_record_t; + +typedef struct ion_record_ID +{ + pid_t pid; + pid_t group_pid; + unsigned int client_address; + struct ion_client *client; + union{ + struct ion_buffer_record *buffer; + struct ion_process_record *process_record; +}; +}ion_record_ID_t; +typedef struct ion_record_basic_info +{ + struct ion_record_ID recordID; + unsigned int record_type; + unsigned int from_kernel; + unsigned int allocate_backtrace_type; + unsigned int *allocate_backtrace; + unsigned int *allocate_map; + unsigned int release_backtrace_type; + unsigned int *release_backtrace; + unsigned int *release_map; +}ion_record_basic_info_t; +typedef struct ion_buffer_usage_record +{ + struct ion_buffer_usage_record *next; + struct ion_record_basic_info tracking_info; + struct ion_handle *handle; + unsigned int function_type; +}ion_buffer_usage_record_t; +typedef struct ion_address_usage_record +{ + struct ion_address_usage_record *next; + struct ion_record_basic_info tracking_info; + unsigned int address_type; + unsigned int mapping_address; + unsigned int size; + int fd; + struct ion_buffer *buffer; +}ion_address_usage_record_t; +typedef struct ion_fd_usage_record +{ + struct ion_fd_usage_reocrd *next; + struct ion_record_basic_info tracking_info; + int fd; + struct ion_handle *handle; + struct ion_buffer *buffer; +}ion_fd_usage_record_t; + +typedef struct ion_client_usage_record +{ + struct ion_client_usage_recrod *next; + struct ion_record_basic_info tracking_info; + int fd; +}ion_client_usage_record_t; +#if 0 +struct ion_buffer_record +{ + struct ion_buffer_record *next; + struct ion_buffer *buffer; + unsigned int heap_type; + union{ + void *priv_virt; + unsigned long priv_phys; + }; + struct ion_buffer_usage_record *buffer_using_list; + struct ion_buffer_usage_record *buffer_freed_list; + struct mutex ion_buffer_usage_mutex; + struct ion_address_usage_record *address_using_list; + struct ion_address_usage_record *address_freed_list; + struct mutex ion_address_usage_mutex; + struct ion_fd_usage_record *fd_using_list; + struct ion_fd_usage_record *fd_freed_list; + struct mutex ion_fd_usage_mutex; +}; +extern void *ion_get_list(struct ion_buffer_record *buffer, unsigned int list_type); +extern struct ion_buffer_usage_record *ion_get_inuse_buffer_record(); +extern struct ion_buffer_usage_record *ion_get_freed_buffer_record(); +extern unsigned int ion_get_data_from_record(void *record,unsigned int data_type); +#endif +#endif diff --git a/kernel-headers/linux/ion_drv.h b/kernel-headers/linux/ion_drv.h new file mode 100644 index 0000000..970d0ff --- /dev/null +++ b/kernel-headers/linux/ion_drv.h @@ -0,0 +1,169 @@ +#ifndef __ION_DRV_H__ +#define __ION_DRV_H__ +#include <linux/ion.h> + +#define BACKTRACE_SIZE 10 + +/* Structure definitions */ + +typedef enum { + ION_CMD_SYSTEM, + ION_CMD_MULTIMEDIA, +} ION_CMDS; + +typedef enum { + ION_MM_CONFIG_BUFFER, + ION_MM_SET_DEBUG_INFO, + ION_MM_GET_DEBUG_INFO, + ION_MM_SET_SF_BUF_INFO, + ION_MM_GET_SF_BUF_INFO +} ION_MM_CMDS; + +typedef enum { + ION_SYS_CACHE_SYNC, + ION_SYS_GET_PHYS, + ION_SYS_GET_CLIENT, + ION_SYS_SET_HANDLE_BACKTRACE, + ION_SYS_SET_CLIENT_NAME, + ION_SYS_DMA_OP, +} ION_SYS_CMDS; + +typedef enum { + ION_CACHE_CLEAN_BY_RANGE, + ION_CACHE_INVALID_BY_RANGE, + ION_CACHE_FLUSH_BY_RANGE, + ION_CACHE_CLEAN_BY_RANGE_USE_VA, + ION_CACHE_INVALID_BY_RANGE_USE_VA, + ION_CACHE_FLUSH_BY_RANGE_USE_VA, + ION_CACHE_CLEAN_ALL, + ION_CACHE_INVALID_ALL, + ION_CACHE_FLUSH_ALL +} ION_CACHE_SYNC_TYPE; + +typedef enum { + ION_ERROR_CONFIG_LOCKED = 0x10000 +} ION_ERROR_E; + +typedef struct ion_sys_cache_sync_param { + union { + ion_user_handle_t handle; + void *kernel_handle; + }; + void *va; + unsigned int size; + ION_CACHE_SYNC_TYPE sync_type; +} ion_sys_cache_sync_param_t; + +typedef enum { + ION_DMA_MAP_AREA, + ION_DMA_UNMAP_AREA, + ION_DMA_MAP_AREA_VA, + ION_DMA_UNMAP_AREA_VA, + ION_DMA_CACHE_FLUSH_ALL +} ION_DMA_TYPE; + +typedef enum { + ION_DMA_FROM_DEVICE, + ION_DMA_TO_DEVICE, + ION_DMA_BIDIRECTIONAL, +} ION_DMA_DIR; + +typedef struct ion_dma_param { + union { + ion_user_handle_t handle; + void *kernel_handle; + }; + void *va; + unsigned int size; + ION_DMA_TYPE dma_type; + ION_DMA_DIR dma_dir; +} ion_sys_dma_param_t; + +typedef struct ion_sys_get_phys_param { + union { + ion_user_handle_t handle; + void *kernel_handle; + }; + unsigned int phy_addr; + unsigned long len; +} ion_sys_get_phys_param_t; + +#define ION_MM_DBG_NAME_LEN 16 +#define ION_MM_SF_BUF_INFO_LEN 16 + +typedef struct __ion_sys_client_name { + char name[ION_MM_DBG_NAME_LEN]; +} ion_sys_client_name_t; + +typedef struct ion_sys_get_client_param { + unsigned int client; +} ion_sys_get_client_param_t; + +typedef struct ion_sys_record_param { + pid_t group_id; + pid_t pid; + unsigned int action; + unsigned int address_type; + unsigned int address; + unsigned int length; + unsigned int backtrace[BACKTRACE_SIZE]; + unsigned int backtrace_num; + struct ion_handle *handle; + struct ion_client *client; + struct ion_buffer *buffer; + struct file *file; + int fd; +} ion_sys_record_t; + +typedef struct ion_sys_data { + ION_SYS_CMDS sys_cmd; + union { + ion_sys_cache_sync_param_t cache_sync_param; + ion_sys_get_phys_param_t get_phys_param; + ion_sys_get_client_param_t get_client_param; + ion_sys_client_name_t client_name_param; + ion_sys_record_t record_param; + ion_sys_dma_param_t dma_param; + }; +} ion_sys_data_t; + +typedef struct ion_mm_config_buffer_param { + union { + ion_user_handle_t handle; + void *kernel_handle; + }; + int eModuleID; + unsigned int security; + unsigned int coherent; +} ion_mm_config_buffer_param_t; + +typedef struct __ion_mm_buf_debug_info { + union { + ion_user_handle_t handle; + void *kernel_handle; + }; + char dbg_name[ION_MM_DBG_NAME_LEN]; + unsigned int value1; + unsigned int value2; + unsigned int value3; + unsigned int value4; +} ion_mm_buf_debug_info_t; + +typedef struct __ion_mm_sf_buf_info { + union { + ion_user_handle_t handle; + void *kernel_handle; + }; + unsigned int info[ION_MM_SF_BUF_INFO_LEN]; +} ion_mm_sf_buf_info_t; + +typedef struct ion_mm_data { + ION_MM_CMDS mm_cmd; + union { + ion_mm_config_buffer_param_t config_buffer_param; + ion_mm_buf_debug_info_t buf_debug_info_param; + ion_mm_sf_buf_info_t sf_buf_info_param; + }; +} ion_mm_data_t; + +#endif diff --git a/kernel-headers/linux/kpd.h b/kernel-headers/linux/kpd.h new file mode 100644 index 0000000..7eb1728 --- /dev/null +++ b/kernel-headers/linux/kpd.h @@ -0,0 +1,46 @@ +#ifndef KPD_IO_H +#define KPD_IO_H + +#include <linux/ioctl.h> + +struct kpd_ledctl { + int onoff; + int div; /* 0 ~ 15 */ + int duty; /* 0 ~ 31 */ +}; + +#if 0 +#define PRESS_OK_KEY _IO('k', 1) +#define RELEASE_OK_KEY _IO('k', 2) +#define PRESS_MENU_KEY _IO('k', 3) +#define RELEASE_MENU_KEY _IO('k', 4) +#define PRESS_UP_KEY _IO('k', 5) +#define RELEASE_UP_KEY _IO('k', 6) +#define PRESS_DOWN_KEY _IO('k', 7) +#define RELEASE_DOWN_KEY _IO('k', 8) +#define PRESS_LEFT_KEY _IO('k', 9) +#define RELEASE_LEFT_KEY _IO('k', 10) +#define PRESS_RIGHT_KEY _IO('k', 11) +#define RELEASE_RIGHT_KEY _IO('k', 12) +#define PRESS_HOME_KEY _IO('k', 13) +#define RELEASE_HOME_KEY _IO('k', 14) +#define PRESS_BACK_KEY _IO('k', 15) +#define RELEASE_BACK_KEY _IO('k', 16) +#define PRESS_CALL_KEY _IO('k', 17) +#define RELEASE_CALL_KEY _IO('k', 18) +#define PRESS_ENDCALL_KEY _IO('k', 19) +#define RELEASE_ENDCALL_KEY _IO('k', 20) +#define PRESS_VLUP_KEY _IO('k', 21) +#define RELEASE_VLUP_KEY _IO('k', 22) +#define PRESS_VLDOWN_KEY _IO('k', 23) +#define RELEASE_VLDOWN_KEY _IO('k', 24) +#define PRESS_FOCUS_KEY _IO('k', 25) +#define RELEASE_FOCUS_KEY _IO('k', 26) +#define PRESS_CAMERA_KEY _IO('k', 27) +#define RELEASE_CAMERA_KEY _IO('k', 28) +#endif +#define SET_KPD_BACKLIGHT _IOW('k', 29, struct kpd_ledctl) +#define SET_KPD_KCOL _IO('k', 29) + + +#endif diff --git a/kernel-headers/linux/libmtk_cipher_export.h b/kernel-headers/linux/libmtk_cipher_export.h new file mode 100644 index 0000000..34a85d3 --- /dev/null +++ b/kernel-headers/linux/libmtk_cipher_export.h @@ -0,0 +1,86 @@ +#ifndef _LIBMTK_CIPHER_EXPORT_H +#define _LIBMTK_CIPHER_EXPORT_H + +#define HEVC_BLK_LEN (20480) // bytes +#define HEVC_MOD "HEVC_MOD" +#define HEVC_NANO 1000000000ULL +#define HEVC_CIPHER_LEN (102400) // bytes + + +typedef struct +{ + unsigned char buf[HEVC_BLK_LEN]; + unsigned int len; +} HEVC_BLK; + +typedef enum +{ + VIDEO_ENCRYPT_CODEC_NONE = 0x0, + VIDEO_ENCRYPT_CODEC_HEVC_ENC = 0x1, + VIDEO_ENCRYPT_CODEC_HEVC_DEC = 0x2, + VIDEO_ENCRYPT_CODEC_MAX = 0xffffffff +} VIDEO_ENCRYPT_CODEC_T; + + +typedef int (*hevc_api_funp)(HEVC_BLK *p_hevc_blk); +typedef int (*hevc_api_initk_funp)(unsigned char *key, unsigned int klen); + + +#define SEC_OK 0x0 +#define SEC_FAIL 0x1 + +/* HEVC shared lib*/ +#define ERR_HEVC_NOT_CORRECT_MODE 0x10000 +#define ERR_HEVC_DATA_NOT_ALIGNED 0x10001 +#define ERR_HEVC_ENC_IOCTL_FAIL 0x10002 +#define ERR_HEVC_DEC_IOCTL_FAIL 0x10002 +#define ERR_HEVC_CIPHER_UT_FAIL 0x10003 +#define ERR_HEVC_DATA_IS_NULL 0x10004 +#define ERR_HEVC_DATA_LENGTH_NOT_VALID 0x10005 +#define ERR_HEVC_SW_ENC_ERROR 0x10006 +#define ERR_HEVC_SW_DEC_ERROR 0x10007 +#define ERR_HEVC_INIT_SW_KEY_ERROR 0x10008 + + +/* HEVC sample*/ +#define ERR_HEVC_CIPHER_LIB_NOT_FOUND 0x20001 +#define ERR_HEVC_SW_DEC_BLOCK_SYM_NOT_FOUND 0x20002 +#define ERR_HEVC_HW_ENC_BLOCK_SYM_NOT_FOUND 0x20003 +#define ERR_HEVC_INIT_SW_KEY_SYM_NOT_FOUND 0x20004 +#define ERR_HEVC_INPUT_FILE_NOT_FOUND 0x20005 +#define ERR_HEVC_OUTPUT_FILE_NOT_FOUND 0x20006 +#define ERR_HEVC_SW_DEC_FILE_SYM_NOT_FOUND 0x20007 +#define ERR_HEVC_SW_DEC_FILE_FAILED 0x20008 +#define ERR_HEVC_UNKNOWN 0x2FFFF + + +/* Define LOG LEVEL*/ +#define SEC_LOG_TRACE 0 //For source code trace +#define SEC_LOG_DEBUG 0 //For debug purpose +#define SEC_LOG_ERROR 1 //For critical error dump +#define SEC_LOG_INFO 1 //For information to know when processing in normal + +/* DEBUG MACRO */ +#define SMSG_TRACE(...) \ + do { if (SEC_LOG_TRACE) printf(__VA_ARGS__); } while (0) + +#define SMSG_DEBUG(...) \ + do { if (SEC_LOG_DEBUG) printf(__VA_ARGS__); } while (0) + +#define SMSG_ERROR(...) \ + do { if (SEC_LOG_ERROR) printf(__VA_ARGS__); } while (0) + +#define SMSG_INFO(...) \ + do { if (SEC_LOG_INFO) printf(__VA_ARGS__); } while (0) + + +#define HEVC_ENCRYTP_FILE_PATH "/data/mediaserver" +#define HEVC_ENC_SW_ENCRYPT_FILE_PATH "/system/lib/libhevce_sb.ca7.android.so" +#define HEVC_ENC_HW_ENCRYPT_FILE_PATH "/data/mediaserver/sb.ca7.android_hwenc.so" +#define HEVC_ENC_HW_DECRYPT_FILE_PATH "/data/mediaserver/sb.ca7.android_hwdec.so" +#define HEVC_DEC_SW_ENCRYTP_FILE_PATH "/system/lib/libHEVCdec_sa.ca7.android.so" +#define HEVC_DEC_HW_ENCRYPT_FILE_PATH "/data/mediaserver/dec_sa.ca7.android_hwenc.so" +#define HEVC_DEC_HW_DECRYPT_FILE_PATH "/data/mediaserver/dec_sa.ca7.android_hwdec.so" + +#endif /*_LIBMTK_CIPHER_EXPORT_H*/ + diff --git a/kernel-headers/linux/matv.h b/kernel-headers/linux/matv.h new file mode 100644 index 0000000..dcae5a7 --- /dev/null +++ b/kernel-headers/linux/matv.h @@ -0,0 +1,58 @@ +#ifndef __MATV_H__ +#define __MATV_H__ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/device.h> +#include <linux/kdev_t.h> +#include <linux/fs.h> +#include <linux/cdev.h> +#include <linux/platform_device.h> +#include <linux/dma-mapping.h> +#include <linux/mm_types.h> +#include <linux/mm.h> +#include <linux/jiffies.h> +#include <linux/sched.h> +#include <asm/uaccess.h> +#include <linux/vmalloc.h> +#include <linux/interrupt.h> +#include <mach/irqs.h> +#include <linux/wait.h> +#include <linux/spinlock.h> +#include <linux/delay.h> +#include <linux/semaphore.h> +#include <linux/platform_device.h> +#include <linux/i2c.h> +#include <linux/slab.h> +#include <linux/xlog.h> + +#include "cust_matv.h" + + + +#define MATV_DEVNAME "MATV" +#define MATV_IOC_MAGIC 'a' + +//below is control message +#define TEST_MATV_PRINT _IO(MATV_IOC_MAGIC, 0x00) +#define MATV_READ _IOW(MATV_IOC_MAGIC, 0x01, unsigned int) +#define MATV_WRITE _IOW(MATV_IOC_MAGIC, 0x02, unsigned int) +#define MATV_SET_PWR _IOW(MATV_IOC_MAGIC, 0x03, unsigned int) +#define MATV_SET_RST _IOW(MATV_IOC_MAGIC, 0x04, unsigned int) +#define MATV_SET_STRAP _IOW(MATV_IOC_MAGIC, 0x05, unsigned int) +#define MATV_SLEEP _IOW(MATV_IOC_MAGIC, 0x06, unsigned int) +#define MATV_SET_TP_MODE _IOW(MATV_IOC_MAGIC, 0x07, unsigned int) + +typedef struct matv_i2s_info +{ + int status; + int mode; + int rate; +} matv_i2s_info_t; + +#define MATV_QUERY_I2S_INFO _IOW(MATV_IOC_MAGIC, 0x08, struct matv_i2s_info*) + + +#endif //__MATV_H__ diff --git a/kernel-headers/linux/mman-proprietary.h b/kernel-headers/linux/mman-proprietary.h new file mode 100644 index 0000000..c989967 --- /dev/null +++ b/kernel-headers/linux/mman-proprietary.h @@ -0,0 +1,21 @@ +/* +* Copyright (C) 2011-2014 MediaTek Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __MM_PROPRIETARY_H__ + +#define PROT_NOCACHE 0x10 + +#endif diff --git a/kernel-headers/linux/mmc/sd_misc.h b/kernel-headers/linux/mmc/sd_misc.h new file mode 100644 index 0000000..0668273 --- /dev/null +++ b/kernel-headers/linux/mmc/sd_misc.h @@ -0,0 +1,201 @@ +#ifndef SD_MISC_H +#define SD_MISC_H + +#ifdef __KERNEL__ +#include <linux/bitops.h> +#include <linux/mmc/host.h> +#include <linux/mmc/card.h> +#include <linux/mmc/core.h> +#include <linux/mmc/mmc.h> +#include <linux/mmc/sd.h> +#endif + + + +struct msdc_ioctl { + int opcode; + int host_num; + int iswrite; + int trans_type; + unsigned int total_size; + unsigned int address; + unsigned int *buffer; + int cmd_pu_driving; + int cmd_pd_driving; + int dat_pu_driving; + int dat_pd_driving; + int clk_pu_driving; + int clk_pd_driving; + int ds_pu_driving; + int ds_pd_driving; + int rst_pu_driving; + int rst_pd_driving; + int clock_freq; + int partition; + int hopping_bit; + int hopping_time; + int result; + int sd30_mode; + int sd30_max_current; + int sd30_drive; + int sd30_power_control; +}; + +/**************for msdc_ssc***********************/ +#define AUDPLL_CTL_REG12 (0xF0007070) +#define AUDPLL_CTL_REG01 (0xF00071E0) +#define AUDPLL_CTL_REG02 (0xF100000C) + +#define AUDPLL_TSEL_MASK (1792) /* MASK = 00000111 00000000 */ +#define AUDPLL_TSEL_RESULT1 (0) /* REG = 00000000 00000000 30.5us */ +#define AUDPLL_TSEL_RESULT2 (256) /* REG = 00000001 00000000 61.0us */ +#define AUDPLL_TSEL_RESULT3 (512) /* REG = 00000010 00000000 122.1us */ +#define AUDPLL_TSEL_RESULT4 (768) /* REG = 00000011 00000000 244.1us */ +#define AUDPLL_TSEL_RESULT5 (1024) /* REG = 00000100 00000000 448.3us */ + +#define AUDPLL_BSEL_MASK (7) /* MASK = 00000000 00000111 */ +#define AUDPLL_BSEL_RESULT0 (0) /* REG = 00000000 00000000 REG init val */ +#define AUDPLL_BSEL_RESULT1 (1) /* REG = 00000000 00000001 2.26MHz */ +#define AUDPLL_BSEL_RESULT2 (2) /* REG = 00000000 00000010 4.52MHz */ +#define AUDPLL_BSEL_RESULT3 (4) /* REG = 00000000 00000100 9.04MHz */ + +#define SET_HOP_BIT_NONE (0) +#define SET_HOP_BIT1 (1) +#define SET_HOP_BIT2 (2) +#define SET_HOP_BIT3 (3) + +#define SET_HOP_TIME0 (0) +#define SET_HOP_TIME1 (1) +#define SET_HOP_TIME2 (2) +#define SET_HOP_TIME3 (3) +#define SET_HOP_TIME4 (4) + + +/**************for msdc_ssc***********************/ + +#define MSDC_DRIVING_SETTING (0) +#define MSDC_CLOCK_FREQUENCY (1) +#define MSDC_SINGLE_READ_WRITE (2) +#define MSDC_MULTIPLE_READ_WRITE (3) +#define MSDC_GET_CID (4) +#define MSDC_GET_CSD (5) +#define MSDC_GET_EXCSD (6) +#define MSDC_ERASE_PARTITION (7) +#define MSDC_HOPPING_SETTING (8) + +#define MSDC_REINIT_SDCARD _IOW('r', 9, int) + +#define MSDC_SD30_MODE_SWITCH (10) +#define MSDC_GET_BOOTPART (11) +#define MSDC_SET_BOOTPART (12) +#define MSDC_GET_PARTSIZE (13) +#define MSDC_ERASE_SELECTED_AREA (0x20) +#define MSDC_CARD_DUNM_FUNC (0xff) + +typedef enum { + USER_PARTITION = 0, + BOOT_PARTITION_1, + BOOT_PARTITION_2, + RPMB_PARTITION, + GP_PARTITION_1, + GP_PARTITION_2, + GP_PARTITION_3, + GP_PARTITION_4, +} PARTITON_ACCESS_T; + +typedef enum { + SDHC_HIGHSPEED = 0, /* 0 Host supports HS mode */ + UHS_SDR12, /* 1 Host supports UHS SDR12 mode */ + UHS_SDR25, /* 2 Host supports UHS SDR25 mode */ + UHS_SDR50, /* 3 Host supports UHS SDR50 mode */ + UHS_SDR104, /* 4 Host supports UHS SDR104 mode */ + UHS_DDR50, /* 5 Host supports UHS DDR50 mode */ +} SD3_MODE; + +typedef enum { + DRIVER_TYPE_A = 0, /* 0 Host supports Driver Type A */ + DRIVER_TYPE_B, /* 1 Host supports Driver Type B */ + DRIVER_TYPE_C, /* 2 Host supports Driver Type C */ + DRIVER_TYPE_D, /* 3 Host supports Driver Type D */ +} SD3_DRIVE; + +typedef enum { + MAX_CURRENT_200 = 0, /* 0 Host max current limit is 200mA */ + MAX_CURRENT_400, /* 1 Host max current limit is 400mA */ + MAX_CURRENT_600, /* 2 Host max current limit is 600mA */ + MAX_CURRENT_800, /* 3 Host max current limit is 800mA */ +} SD3_MAX_CURRENT; + +typedef enum { + SDXC_NO_POWER_CONTROL = 0, /* 0 Host not supports >150mA current at 3.3V /3.0V/1.8V */ + SDXC_POWER_CONTROL, /* 1 Host supports >150mA current at 3.3V /3.0V/1.8V */ +} SD3_POWER_CONTROL; + +typedef enum { + DUMP_INTO_BOOT_CARD_IPANIC = 0, + DUMP_INTO_BOOT_CARD_KDUMP = 1, + DUMP_INTO_EXTERN_CARD = 2, +} DUMP_STORAGE_TYPE; + +typedef enum { + EMMC_CARD_BOOT = 0, + SD_CARD_BOOT, + EMMC_CARD, + SD_CARD, +} STORAGE_TPYE; + +#define EXT_CSD_BOOT_SIZE_MULT (226) /* R */ +#define EXT_CSD_HC_ERASE_GRP_SIZE (224) /* RO */ +#define EXT_CSD_HC_WP_GPR_SIZE (221) /* RO */ +#define EXT_CSD_RPMB_SIZE_MULT (168) /* R */ +#define EXT_CSD_GP1_SIZE_MULT (143) /* R/W 3 bytes */ +#define EXT_CSD_GP2_SIZE_MULT (146) /* R/W 3 bytes */ +#define EXT_CSD_GP3_SIZE_MULT (149) /* R/W 3 bytes */ +#define EXT_CSD_GP4_SIZE_MULT (152) /* R/W 3 bytes */ +#define EXT_CSD_PART_CFG (179) /* R/W/E & R/W/E_P */ +#define EXT_CSD_CACHE_FLUSH (32) +#define EXT_CSD_CACHE_CTRL (33) +#define CAPACITY_2G (2 * 1024 * 1024 * 1024ULL) + +typedef enum { + EMMC_BOOT_NO_EN = 0, + EMMC_BOOT1_EN, + EMMC_BOOT2_EN, + EMMC_BOOT_USER = 7, + EMMC_BOOT_END +} BOOT_PARTITION_EN; + +#ifdef CONFIG_MTK_GPT_SCHEME_SUPPORT +typedef enum { + EMMC_PART_UNKNOWN=0 + ,EMMC_PART_BOOT1 + ,EMMC_PART_BOOT2 + ,EMMC_PART_RPMB + ,EMMC_PART_GP1 + ,EMMC_PART_GP2 + ,EMMC_PART_GP3 + ,EMMC_PART_GP4 + ,EMMC_PART_USER + ,EMMC_PART_END +} Region; +#endif + +typedef enum { + CARD_INFO = 0, + DISK_INFO, + EMMC_USER_CAPACITY, + EMMC_CAPACITY, + EMMC_RESERVE, +} GET_STORAGE_INFO; + +struct storage_info { + struct mmc_card *card; + struct gendisk *disk; + unsigned long long emmc_user_capacity; + unsigned long long emmc_capacity; + int emmc_reserve; +}; + +int msdc_get_info(STORAGE_TPYE storage_type, GET_STORAGE_INFO info_type, struct storage_info *info); + +#endif /* end of SD_MISC_H */ diff --git a/kernel-headers/linux/mmprofile.h b/kernel-headers/linux/mmprofile.h new file mode 100644 index 0000000..866022c --- /dev/null +++ b/kernel-headers/linux/mmprofile.h @@ -0,0 +1,102 @@ +#ifndef __MMPROFILE_H__ +#define __MMPROFILE_H__ +#include "mmprofile_static_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MMProfileEventNameMaxLen 31 + +typedef unsigned int MMP_Event; + +typedef enum { + MMProfileFlagStart = 1, + MMProfileFlagEnd = 2, + MMProfileFlagPulse = 4, + MMProfileFlagEventSeparator = 8, + MMProfileFlagSystrace = 0x80000000, + MMProfileFlagMax = 0xFFFFFFFF +} MMP_LogType; + +typedef enum { + MMProfileMetaStringMBS = 1, + MMProfileMetaStringWCS, + MMProfileMetaStructure, + MMProfileMetaBitmap, + MMProfileMetaRaw, + MMProfileMetaUser = 0x10000000, + MMProfileMetaUserM4UReg, + MMProfileMetaMax = 0xFFFFFFFF +} MMP_MetaDataType; + +typedef enum { + MMProfileBitmapRGB565 = 1, + MMProfileBitmapRGB888, + MMProfileBitmapRGBA8888, + MMProfileBitmapBGR888, + MMProfileBitmapBGRA8888, + MMProfileBitmapMax = 0xFFFFFFFF +} MMP_PixelFormat; + +typedef struct { + unsigned int data1; // data1 (user defined) + unsigned int data2; // data2 (user defined) + MMP_MetaDataType data_type; // meta data type + unsigned int size; // meta data size + void *pData; // meta data pointer +} MMP_MetaData_t; + +typedef struct { + unsigned int data1; // data1 (user defined) + unsigned int data2; // data2 (user defined) + unsigned int struct_size; // structure size (bytes) + void *pData; // structure pointer + char struct_name[32]; // structure name +} MMP_MetaDataStructure_t; + +typedef struct { + unsigned int data1; // data1 (user defined) + unsigned int data2; // data2 (user defined) + unsigned int width; // image width + unsigned int height; // image height + MMP_PixelFormat format; // image pixel format + unsigned int start_pos; // start offset of image data (base on pData) + unsigned int bpp; // bits per pixel + int pitch; // image pitch (bytes per line) + unsigned int data_size; // image data size (bytes) + unsigned int down_sample_x; // horizontal down sample rate (>=1) + unsigned int down_sample_y; // vertical down sample rate (>=1) + void *pData; // image buffer address +} MMP_MetaDataBitmap_t; + +MMP_Event MMProfileRegisterEvent(MMP_Event parent, const char *name); +MMP_Event MMProfileFindEvent(MMP_Event parent, const char *name); +void MMProfileEnableEvent(MMP_Event event, long enable); +void MMProfileEnableFTraceEvent(MMP_Event event, long enable, long ftrace); +void MMProfileEnableEventRecursive(MMP_Event event, long enable); +void MMProfileEnableFTraceEventRecursive(MMP_Event event, long enable, long ftrace); +long MMProfileQueryEnable(MMP_Event event); +void MMProfileLog(MMP_Event event, MMP_LogType type); +void MMProfileLogEx(MMP_Event event, MMP_LogType type, unsigned long data1, unsigned long data2); +long MMProfileLogMeta(MMP_Event event, MMP_LogType type, MMP_MetaData_t *pMetaData); +long MMProfileLogMetaString(MMP_Event event, MMP_LogType type, const char *str); +long MMProfileLogMetaStringEx(MMP_Event event, MMP_LogType type, unsigned long data1, unsigned long data2, const char *str); +long MMProfileLogMetaStructure(MMP_Event event, MMP_LogType type, MMP_MetaDataStructure_t *pMetaData); +long MMProfileLogMetaBitmap(MMP_Event event, MMP_LogType type, MMP_MetaDataBitmap_t *pMetaData); + +#define MMProfileLogStructure(event, type, pStruct, struct_type) \ +{ \ + MMP_MetaDataStructure_t MetaData; \ + MetaData.data1 = 0; \ + MetaData.data2 = 0; \ + strcpy(MetaData.struct_name, #struct_type); \ + MetaData.struct_size = sizeof(struct_type); \ + MetaData.pData = (void *)(pStruct); \ + MMProfileLogMetaStructure(event, type, &MetaData); \ +} + +#ifdef __cplusplus +} +#endif +#endif diff --git a/kernel-headers/linux/mmprofile_internal.h b/kernel-headers/linux/mmprofile_internal.h new file mode 100644 index 0000000..9cc6f0f --- /dev/null +++ b/kernel-headers/linux/mmprofile_internal.h @@ -0,0 +1,100 @@ +#ifndef __MMPROFILE_INTERNAL_H__ +#define __MMPROFILE_INTERNAL_H__ + +#include <linux/mmprofile.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define MMProfileMaxEventCount 1000 + +#define MMP_EVENT_STATE_ENABLED (1 << 0) +#define MMP_EVENT_STATE_FTRACE (1 << 1) + +typedef struct { + unsigned int parentId; + char name[MMProfileEventNameMaxLen + 1]; +} MMProfile_EventInfo_t; + +typedef struct { + unsigned int lock; + unsigned int id; + unsigned int timeLow; + unsigned int timeHigh; + unsigned int flag; +#if 0 //#ifdef MMPROFILE_KERNEL_64 + unsigned long long data1; + unsigned long long data2; + unsigned long long meta_data_cookie; +#else + unsigned int data1; + unsigned int data2; + unsigned int meta_data_cookie; +#endif +} MMProfile_Event_t; + +typedef struct { + unsigned int enable; + unsigned int start; + unsigned int write_pointer; + unsigned int reg_event_index; + unsigned int buffer_size_record; + unsigned int buffer_size_bytes; + unsigned int record_size; + unsigned int meta_buffer_size; + unsigned int new_buffer_size_record; + unsigned int new_meta_buffer_size; + unsigned int selected_buffer; + unsigned int max_event_count; + unsigned int event_state[MMProfileMaxEventCount]; +} MMProfile_Global_t; + +typedef struct { + unsigned int cookie; + MMP_MetaDataType data_type; + unsigned int data_size; + unsigned int data_offset; +} MMProfile_MetaData_t; + +typedef struct { + unsigned int id; + MMP_LogType type; + MMP_MetaData_t meta_data; +} MMProfile_MetaLog_t; + + +#define MMProfileGlobalsSize ((sizeof(MMProfile_Global_t)+(PAGE_SIZE-1))&(~(PAGE_SIZE-1))) + +#define CONFIG_MMPROFILE_PATH "/data/MMProfileConfig.dat" + +#define MMProfilePrimaryBuffer 1 +#define MMProfileGlobalsBuffer 2 +#define MMProfileMetaDataBuffer 3 + +#define MMP_IOC_MAGIC 'M' + +#define MMP_IOC_ENABLE _IOW(MMP_IOC_MAGIC, 1, int) +#define MMP_IOC_START _IOW(MMP_IOC_MAGIC, 2, int) +#define MMP_IOC_TIME _IOW(MMP_IOC_MAGIC, 3, int) +#define MMP_IOC_REGEVENT _IOWR(MMP_IOC_MAGIC, 4, int) +#define MMP_IOC_FINDEVENT _IOWR(MMP_IOC_MAGIC, 5, int) +#define MMP_IOC_ENABLEEVENT _IOW(MMP_IOC_MAGIC, 6, int) +#define MMP_IOC_LOG _IOW(MMP_IOC_MAGIC, 7, int) +#define MMP_IOC_DUMPEVENTINFO _IOR(MMP_IOC_MAGIC, 8, int) +#define MMP_IOC_METADATALOG _IOW(MMP_IOC_MAGIC, 9, int) +#define MMP_IOC_DUMPMETADATA _IOR(MMP_IOC_MAGIC, 10, int) +#define MMP_IOC_SELECTBUFFER _IOW(MMP_IOC_MAGIC, 11, int) +#define MMP_IOC_TRYLOG _IOWR(MMP_IOC_MAGIC, 12, int) +#define MMP_IOC_ISENABLE _IOR(MMP_IOC_MAGIC, 13, int) +#define MMP_IOC_REMOTESTART _IOR(MMP_IOC_MAGIC, 14, int) +#define MMP_IOC_TEST _IOWR(MMP_IOC_MAGIC, 100, int) + +// fix build warning: unused +//static void MMProfileInitBuffer(void); +//static void MMProfileResetBuffer(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/kernel-headers/linux/mmprofile_static_event.h b/kernel-headers/linux/mmprofile_static_event.h new file mode 100644 index 0000000..6744bfa --- /dev/null +++ b/kernel-headers/linux/mmprofile_static_event.h @@ -0,0 +1,31 @@ +#ifndef __MMPROFILE_STATIC_EVENT_H__ +#define __MMPROFILE_STATIC_EVENT_H__ + + +typedef enum +{ + MMP_InvalidEvent = 0, + MMP_RootEvent = 1, + // User defined static events begin + MMP_TouchPanelEvent, + // User defined static events end. + MMP_MaxStaticEvent +} MMP_StaticEvents; + +#ifdef MMPROFILE_INTERNAL +typedef struct +{ + MMP_StaticEvents event; + char* name; + MMP_StaticEvents parent; +} MMP_StaticEvent_t; + +static MMP_StaticEvent_t MMProfileStaticEvents[] = +{ + {MMP_RootEvent, "Root_Event", MMP_InvalidEvent}, + {MMP_TouchPanelEvent, "TouchPanel_Event", MMP_RootEvent}, +}; + +#endif + +#endif diff --git a/kernel-headers/linux/mt_sched.h b/kernel-headers/linux/mt_sched.h new file mode 100644 index 0000000..11bf8c2 --- /dev/null +++ b/kernel-headers/linux/mt_sched.h @@ -0,0 +1,21 @@ +#ifndef _MTK_SCHED_H +#define _MTK_SCHED_H + +#define __USE_GNU +#include <linux/ioctl.h> +#include <sched.h> +#include <linux/mt_sched_ioctl.h> + +#ifdef __cplusplus +extern "C"{ +#endif + +int mt_sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask); +int mt_sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask, cpu_set_t *mt_mask); +int mt_sched_exitaffinity(pid_t pid); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/kernel-headers/linux/mt_sched_ioctl.h b/kernel-headers/linux/mt_sched_ioctl.h new file mode 100644 index 0000000..580caac --- /dev/null +++ b/kernel-headers/linux/mt_sched_ioctl.h @@ -0,0 +1,17 @@ +#ifndef _MT_SCHED_IOCTL_H +#define _MT_SCHED_IOCTL_H + +struct ioctl_arg { + pid_t pid; + unsigned int len; + unsigned long *mask; + unsigned long *mt_mask; +}; + +#define IOC_MAGIC '\x66' + +#define IOCTL_SETAFFINITY _IOW(IOC_MAGIC, 0, struct ioctl_arg) +#define IOCTL_EXITAFFINITY _IOW(IOC_MAGIC, 1, pid_t) +#define IOCTL_GETAFFINITY _IOR(IOC_MAGIC, 2, struct ioctl_arg) + +#endif
\ No newline at end of file diff --git a/kernel-headers/linux/mtcombo.h b/kernel-headers/linux/mtcombo.h new file mode 100644 index 0000000..67dd58e --- /dev/null +++ b/kernel-headers/linux/mtcombo.h @@ -0,0 +1,18 @@ +#ifndef __MTCOMBO_H__ +#define __MTCOMBO_H__ + +#include <linux/ioctl.h> + +typedef enum _ENUM_WMTHWVER_TYPE_T{ + WMTHWVER_MT6620_E1 = 0x0, + WMTHWVER_MT6620_E2 = 0x1, + WMTHWVER_MT6620_E3 = 0x2, + WMTHWVER_MT6620_E4 = 0x3, + WMTHWVER_MT6620_MAX, + WMTHWVER_INVALID = 0xff +} ENUM_WMTHWVER_TYPE_T, *P_ENUM_WMTHWVER_TYPE_T; + +#define COMBO_IOC_MAGIC 0x90 +#define COMBO_IOC_GPS_HWVER 6 + +#endif // __MTCOMBO_H__ diff --git a/kernel-headers/linux/mtgpio.h b/kernel-headers/linux/mtgpio.h new file mode 100644 index 0000000..050a792 --- /dev/null +++ b/kernel-headers/linux/mtgpio.h @@ -0,0 +1,54 @@ +/* alps/ALPS_SW/TRUNK/MAIN/alps/kernel/arch/arm/mach-mt6516/include/mach/fm.h + * + * (C) Copyright 2009 + * MediaTek <www.MediaTek.com> + * William Chung <William.Chung@MediaTek.com> + * + * MT6516 AR10x0 FM Radio Driver + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MTGPIO_H__ +#define __MTGPIO_H__ + +#include <linux/ioctl.h> + +#define GPIO_IOC_MAGIC 0x90 + +#define GPIO_IOCQMODE _IOR(GPIO_IOC_MAGIC, 0x01, uint32_t) +#define GPIO_IOCTMODE0 _IOW(GPIO_IOC_MAGIC, 0x02, uint32_t) +#define GPIO_IOCTMODE1 _IOW(GPIO_IOC_MAGIC, 0x03, uint32_t) +#define GPIO_IOCTMODE2 _IOW(GPIO_IOC_MAGIC, 0x04, uint32_t) +#define GPIO_IOCTMODE3 _IOW(GPIO_IOC_MAGIC, 0x05, uint32_t) +#define GPIO_IOCQDIR _IOR(GPIO_IOC_MAGIC, 0x06, uint32_t) +#define GPIO_IOCSDIRIN _IOW(GPIO_IOC_MAGIC, 0x07, uint32_t) +#define GPIO_IOCSDIROUT _IOW(GPIO_IOC_MAGIC, 0x08, uint32_t) +#define GPIO_IOCQPULLEN _IOR(GPIO_IOC_MAGIC, 0x09, uint32_t) +#define GPIO_IOCSPULLENABLE _IOW(GPIO_IOC_MAGIC, 0x0A, uint32_t) +#define GPIO_IOCSPULLDISABLE _IOW(GPIO_IOC_MAGIC, 0x0B, uint32_t) +#define GPIO_IOCQPULL _IOR(GPIO_IOC_MAGIC, 0x0C, uint32_t) +#define GPIO_IOCSPULLDOWN _IOW(GPIO_IOC_MAGIC, 0x0D, uint32_t) +#define GPIO_IOCSPULLUP _IOW(GPIO_IOC_MAGIC, 0x0E, uint32_t) +#define GPIO_IOCQINV _IOR(GPIO_IOC_MAGIC, 0x0F, uint32_t) +#define GPIO_IOCSINVENABLE _IOW(GPIO_IOC_MAGIC, 0x10, uint32_t) +#define GPIO_IOCSINVDISABLE _IOW(GPIO_IOC_MAGIC, 0x11, uint32_t) +#define GPIO_IOCQDATAIN _IOR(GPIO_IOC_MAGIC, 0x12, uint32_t) +#define GPIO_IOCQDATAOUT _IOR(GPIO_IOC_MAGIC, 0x13, uint32_t) +#define GPIO_IOCSDATALOW _IOW(GPIO_IOC_MAGIC, 0x14, uint32_t) +#define GPIO_IOCSDATAHIGH _IOW(GPIO_IOC_MAGIC, 0x15, uint32_t) + + +#endif // __MTGPIO_H__ diff --git a/kernel-headers/linux/mtk_agps_common.h b/kernel-headers/linux/mtk_agps_common.h new file mode 100644 index 0000000..325295a --- /dev/null +++ b/kernel-headers/linux/mtk_agps_common.h @@ -0,0 +1,157 @@ +/***************************************************************************** + * + * Filename: + * --------- + * mtk_agps_common.h + * + * Project: + * -------- + * DUMA + * + * Description: + * ------------ + * Data types used by MTK AGPS + * + * Author: + * ------- + * Chunhui Li(MTK80143) + * + *============================================================================ + * HISTORY + * Below this line, this part is controlled by CC/CQ. DO NOT MODIFY!! + *------------------------------------------------------------------------------ + * $Revision:$ + * $Modtime:$ + * $Log:$ + * + * 12 05 2012 archilis.wang + * [ALPS00393352] Please help analzye the root cause of failed item of ASSET + * Review: http://mtksap20:8080/go?page=NewReview&reviewid=49629 + * + * 04 24 2011 nina.hsu + * [ALPS00043332] [MT6573][AGPS] Add GPS_MNL_PROCESS_STATUS definition + * [MT6573][AGPS] + * Add GPS_MNL_PROCESS_STATUS definition for reporting GPS status + * . + * + * 08 20 2010 qiuhuan.zhao + * [ALPS00123522] [GPS] Android 2.2 porting + * Android 2.2 Gps driver porting. + * + *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by CC/CQ. DO NOT MODIFY!! + *============================================================================ + ****************************************************************************/ + +#ifndef MTK_AGPS_COMMON_H +#define MTK_AGPS_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if ( defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 200000 )) +#else +#pragma pack(1) +#endif + +//AGPS socket port +#define MTK_MNL2SUPL "/data/agps_supl/mnl2supl" +#define MTK_PROFILE2MNL "/data/agps_supl/profile2mnl" + +//System_property for SUPL_Enable, SUPL_SI_Enable +#define GPS_MNL_SUPL_NAME "gps.supl.status" +#define GPS_MNL_PROCESS_STATUS "gps.mnl_process.status" + +// AGPS Module Enum +typedef enum +{ + MTK_MOD_GPS = 0, + MTK_MOD_SUPL, + MTK_MOD_WIFI, + MTK_MOD_CELLID, + MTK_MOD_CNT, +} MTK_AGPS_MOD_E; + +// AGPS Msg type +typedef enum +{ + MTK_AGPS_SUPL_ASSIST_REQ= 0, + MTK_AGPS_SUPL_NI_REQ, + MTK_AGPS_SUPL_PMTK_DATA, + MTK_AGPS_SUPL_END, + MTK_AGPS_SUPL_MNL_STATUS, + MTK_AGPS_SUPL_GPEVT, + MTK_AGPS_SUPL_CNT, + MTK_AGPS_AIDING_CELLINFO, + MTK_AGPS_AIDING_WIFIIFNO, + MTK_AGPS_SUPL_RAW_DBG, +} MTK_AGPS_SUPL_MSG_T; + +// GPEVT msg data enum +typedef enum +{ + GPEVT_TYPE_UNKNOWN = 0, // 0 + GPEVT_SUPL_SLP_CONNECT_BEGIN, // 1 + GPEVT_SUPL_SLP_CONNECTED, // 2 + GPEVT_SUPL_SSL_CONNECT_BEGIN, // 3 + GPEVT_SUPL_SSL_CONNECTED, // 4 + GPEVT_SUPL_ASSIST_DATA_RECEIVED, // 5 + GPEVT_SUPL_ASSIST_DATA_VALID, // 6 + GPEVT_SUPL_FIRST_POS_FIX, // 7 + GPEVT_SUPL_MEAS_TIME_OUT, // 8 + GPEVT_SUPL_MEAS_RESPONSE_SENT, // 9 + GPEVT_SUPL_SSL_CLOSED, // 10 + GPEVT_SUPL_SLP_DISCONNECTED, // 11 + + GPEVT_CP_MOLR_SENT, // 12 + GPEVT_CP_MTLR_RECEIVED, // 13 + GPEVT_CP_ASSIST_DATA_RECEIVED, // 14 + GPEVT_CP_ASSIST_DATA_VALID, // 15 + GPEVT_CP_FIRST_POS_FIX, // 16 + GPEVT_CP_MEAS_TIME_OUT, // 17 + GPEVT_CP_MEAS_RESPONSE_SENT, // 18 + + GPEVT_GNSS_HW_START, // 19 + GPEVT_GNSS_HW_STOP, // 20 + GPEVT_GNSS_RESET_STORED_SATELLITE_DATA, // 21 + + GPEVT_EPO_SERVER_CONNECT_BEGIN, // 22 + GPEVT_EPO_SERVER_CONNECTED, // 23 + GPEVT_EPO_DATA_RECEIVED, // 24 + GPEVT_EPO_SERVER_DISCONNECTED, // 25 + GPEVT_EPO_DATA_VALID, // 26 + + GPEVT_HOT_STILL_DATA_VALID, // 27 + + GPEVT_TYPE_MAX // 28 +}gpevt_type; + +// AGPS data struct +typedef struct +{ + unsigned char srcMod; + unsigned char dstMod; + unsigned short type; + unsigned short length; + char data[1]; +} mtk_agps_msg, *pmtk_agps_msg, MTK_AGPS_MSG_T, *PMTK_AGPS_MSG_T; + +#define MAX_AGPS_MAX_MESSAGES 72 +#define MTK_AGPS_PMTK_MAX_SIZE (256+sizeof(mtk_agps_msg)) +#define MTK_AGPS_PMTK_MAX_LEN (256+sizeof(mtk_agps_msg)) +#define MTK_AGPS_PMTK_HDR_LEN sizeof(MTK_AGPS_MSG_T) +#define MTK_AGPS_MSG_MAX_LEN (MTK_AGPS_PMTK_MAX_LEN + MTK_AGPS_PMTK_HDR_LEN) + +#define MTK_AGPS_SUPLMSG_TIMEOUT 6000 + +#if ( defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 200000 )) +#else +#pragma pack() +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* MTK_AGPS_COMMON_H */ diff --git a/kernel-headers/linux/mtk_ion.h b/kernel-headers/linux/mtk_ion.h new file mode 100644 index 0000000..514701e --- /dev/null +++ b/kernel-headers/linux/mtk_ion.h @@ -0,0 +1,28 @@ +/* +* Copyright (C) 2011-2014 MediaTek Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef _MTK_LINUX_ION_H +#define _MTK_LINUX_ION_H +enum mtk_ion_heap_type { + ION_HEAP_TYPE_MULTIMEDIA = 10, + ION_HEAP_TYPE_FB = 11, +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +}; +#define ION_HEAP_MULTIMEDIA_MASK (1 << ION_HEAP_TYPE_MULTIMEDIA) +#define ION_HEAP_FB_MASK (1 << ION_HEAP_TYPE_FB) +#define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8 +#endif +/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ diff --git a/kernel-headers/linux/mtkfb.h b/kernel-headers/linux/mtkfb.h new file mode 100644 index 0000000..bbd85ed --- /dev/null +++ b/kernel-headers/linux/mtkfb.h @@ -0,0 +1,389 @@ +#ifndef __MTKFB_H +#define __MTKFB_H + +#include "mtkfb_info.h" + + +/**NOTICE: + * Must be consistent with bionic/libc/kernel/linux/common/mtkfb.h + */ +#define MTK_FB_NO_ION_FD ((int)(~0U>>1)) +#define MTK_FB_NO_USE_LAEYR_ID ((int)(~0U>>1)) +#define FBCAPS_GENERIC_MASK (0x00000fff) +#define FBCAPS_LCDC_MASK (0x00fff000) +#define FBCAPS_PANEL_MASK (0xff000000) +#define FBCAPS_MANUAL_UPDATE (0x00001000) +#define FBCAPS_SET_BACKLIGHT (0x01000000) +#define MTKFB_ERROR_IS_EARLY_SUSPEND (0x12000000) +//--------------------------------------------------------------------------- +/* IOCTL commands. */ +#define MTK_IOW(num, dtype) _IOW('O', num, dtype) +#define MTK_IOR(num, dtype) _IOR('O', num, dtype) +#define MTK_IOWR(num, dtype) _IOWR('O', num, dtype) +#define MTK_IO(num) _IO('O', num) + +#define MTKFB_QUEUE_OVERLAY_CONFIG MTK_IOW(137, struct fb_overlay_config) +// -------------------------------------------------------------------------- +#define MTKFB_SET_OVERLAY_LAYER MTK_IOW(0, struct fb_overlay_layer) +#define MTKFB_TRIG_OVERLAY_OUT MTK_IO(1) +#define MTKFB_SET_VIDEO_LAYERS MTK_IOW(2, struct fb_overlay_layer) +#define MTKFB_CAPTURE_FRAMEBUFFER MTK_IOW(3, unsigned long) +#define MTKFB_CONFIG_IMMEDIATE_UPDATE MTK_IOW(4, unsigned long) +#define MTKFB_SET_MULTIPLE_LAYERS MTK_IOW(5, struct fb_overlay_layer) +#define MTKFB_REGISTER_OVERLAYBUFFER MTK_IOW(6, struct fb_overlay_buffer_info) +#define MTKFB_UNREGISTER_OVERLAYBUFFER MTK_IOW(7, unsigned int) +#define MTKFB_SET_ORIENTATION MTK_IOW(8, unsigned long) +#define MTKFB_FBLAYER_ENABLE MTK_IOW(9,unsigned int) +#define MTKFB_LOCK_FRONT_BUFFER MTK_IO(10) +#define MTKFB_UNLOCK_FRONT_BUFFER MTK_IO(11) +#define MTKFB_POWERON MTK_IO(12) +#define MTKFB_POWEROFF MTK_IO(13) + +// Fence/Ion, OVL decoupling +#define MTKFB_PREPARE_OVERLAY_BUFFER MTK_IOW(14, struct fb_overlay_buffer) + +// S3D control +#define MTKFB_SET_COMPOSING3D MTK_IOW(15, unsigned long) +#define MTKFB_SET_S3D_FTM MTK_IOW(16, unsigned long) + +//FM De-sense for EM and Normal mode +#define MTKFB_GET_DEFAULT_UPDATESPEED MTK_IOR(17, unsigned long) +#define MTKFB_GET_CURR_UPDATESPEED MTK_IOR(18, unsigned long) +#define MTKFB_CHANGE_UPDATESPEED MTK_IOW(19, unsigned long) //for EM, not called change writecycle because DPI change pll ckl +#define MTKFB_GET_INTERFACE_TYPE MTK_IOR(20, unsigned long) ///0 DBI, 1 DPI, 2 MIPI +#define MTKFB_GET_POWERSTATE MTK_IOR(21, unsigned long) ///0: power off 1: power on +#define MTKFB_GET_DISPLAY_IF_INFORMATION MTK_IOR(22, mtk_dispif_info_t) +#define MTKFB_AEE_LAYER_EXIST MTK_IOR(23, unsigned long) //called before SET_OVERLAY each time, if true, hwc will not use FB_LAYER again +#define MTKFB_GET_OVERLAY_LAYER_INFO MTK_IOR(24, struct fb_overlay_layer_info) +#define MTKFB_FACTORY_AUTO_TEST MTK_IOR(25, unsigned long) +#define MTKFB_GET_FRAMEBUFFER_MVA MTK_IOR(26, unsigned int) +#define MTKFB_SLT_AUTO_CAPTURE MTK_IOWR(27, struct fb_slt_catpure) + +/* Wearable */ +#define MTKFB_LCM_ALWAYS_ON_ENABLE MTK_IOW(80, unsigned int) +#define MTKFB_SET_DISPLAY_POWER_MODE MTK_IOW(81, unsigned int) + +//error handling +#define MTKFB_META_RESTORE_SCREEN MTK_IOW(101, unsigned long) +#define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT MTK_IO(103) +#define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT_AEE MTK_IO(104) + +/*restore bootlogo and charater in meta mode*/ +#define MTKFB_META_SHOW_BOOTLOGO MTK_IO(105) + +//Extension FB active option +#define FB_ACTIVATE_NO_UPDATE 512 /* Skip frame update */ + +//---------------------------------------------------------------------- + +// -------------------------------------------------------------------------- +/** + * Just for mt6589 Platform + * @{ + */ +#define MTKFB_GETVFRAMEPHYSICAL MTK_IOW(41, unsigned long) +#define MTKFB_WAIT_OVERLAY_READY MTK_IO(42) +#define MTKFB_GET_OVERLAY_LAYER_COUNT MTK_IOR(43, unsigned long) +#define MTKFB_GET_VIDEOLAYER_SIZE MTK_IOR(44, struct fb_overlay_layer) +#define MTKFB_CAPTURE_VIDEOBUFFER MTK_IOW(45, unsigned long) + +// -------------------------------------------------------------------------- +// Video Playback Mode +#define MTKFB_TV_POST_VIDEO_BUFFER MTK_IOW(46, unsigned long) +#define MTKFB_TV_LEAVE_VIDEO_PLAYBACK_MODE MTK_IOW(47, unsigned long) +// For Factory Mode +#define MTKFB_IS_TV_CABLE_PLUG_IN MTK_IOW(48, unsigned long) + +// -------------------------------------------------------------------------- +#define MTKFB_BOOTANIMATION MTK_IO(49) +#define MTKFB_GETFPS MTK_IOW(50, unsigned long) +#define MTKFB_VSYNC MTK_IO(51) + +//----------------------------------------------------------------------FM De-sense for EM and Normal mode +#define MTKFB_FM_NOTIFY_FREQ MTK_IOW(52, unsigned long) //for Normal mode +#define MTKFB_RESET_UPDATESPEED MTK_IO(53) +#define MTKFB_SET_UI_LAYER_ALPHA MTK_IOW(54, unsigned long) +#define MTKFB_SET_UI_LAYER_SRCKEY MTK_IOW(55, unsigned long) + +#define MTKFB_GET_MAX_DISPLAY_COUNT MTK_IOR(56, unsigned int) +#define MTKFB_SET_FB_LAYER_SECURE MTK_IOW(57, int) +/** + * @} + */ +//---------------------------------------------------------------------- + +// -------------------------------------------------------------------------- + +typedef enum +{ + MTK_FB_ORIENTATION_0 = 0, + MTK_FB_ORIENTATION_90 = 1, + MTK_FB_ORIENTATION_180 = 2, + MTK_FB_ORIENTATION_270 = 3, +} MTK_FB_ORIENTATION; + + +typedef enum +{ + MTK_FB_TV_SYSTEM_NTSC = 0, + MTK_FB_TV_SYSTEM_PAL = 1, +} MTK_FB_TV_SYSTEM; + + +typedef enum +{ + MTK_FB_TV_FMT_RGB565 = 0, + MTK_FB_TV_FMT_YUV420_SEQ = 1, + MTK_FB_TV_FMT_UYUV422 = 2, + MTK_FB_TV_FMT_YUV420_BLK = 3, +} MTK_FB_TV_SRC_FORMAT; + +typedef enum +{ + LAYER_NORMAL_BUFFER = 0, + LAYER_SECURE_BUFFER = 1, + LAYER_PROTECTED_BUFFER = 2, + LAYER_SECURE_BUFFER_WITH_ALIGN = 0x10001, // the higher 16 bits =1 for adding 64 bytes alignment +} MTK_FB_OVL_LAYER_SECURE_MODE; + +typedef struct _disp_dfo_item +{ + char name[32]; + int value; +} disp_dfo_item_t; + +// -------------------------------------------------------------------------- +struct fb_slt_catpure +{ + MTK_FB_FORMAT format; + volatile char* outputBuffer; + unsigned int wdma_width; + unsigned int wdma_height; +}; + +struct fb_scale +{ + unsigned int xscale, yscale; +}; + +struct fb_frame_offset +{ + unsigned int idx; + unsigned long offset; +}; + +struct fb_update_window +{ + unsigned int x, y; + unsigned int width, height; +}; + +typedef enum +{ + LAYER_2D = 0, + LAYER_3D_SBS_0 = 0x1, + LAYER_3D_SBS_90 = 0x2, + LAYER_3D_SBS_180 = 0x3, + LAYER_3D_SBS_270 = 0x4, + LAYER_3D_TAB_0 = 0x10, + LAYER_3D_TAB_90 = 0x20, + LAYER_3D_TAB_180 = 0x30, + LAYER_3D_TAB_270 = 0x40, +} MTK_FB_LAYER_TYPE; + +typedef enum +{ + DISP_DIRECT_LINK_MODE, + DISP_DECOUPLE_MODE +} MTK_DISP_MODE; + +struct fb_overlay_mode +{ + MTK_DISP_MODE mode; +}; + +typedef enum // map sessions to scenairos in kernel driver +{ + DISP_SESSION_LCM = 1<<0, // DSI0 + DISP_SESSION_MEM = 1<<1, // OVL0->WDMA0 + DISP_SESSION_WFD = 1<<2, // Extention mode, Dst buf is provided by user, for Wifi Display or other purpose + DISP_SESSION_MHL = 1<<3, // DPI + DISP_SESSION_LCM1 = 1<<4, // DSI1 + DISP_SESSION_MEM1 = 1<<5, // OVL1->WDMA1 + //TODO:can be extended with other Session Id + SESSION_MASK = 0xff&~(1<<6) +} MTK_DISP_SESSION; + +struct fb_overlay_session +{ + unsigned int session; // one or more @MTK_DISP_SESSION combined +}; + +struct fb_overlay_decouple +{ + MTK_DISP_MODE mode; + unsigned int session; +}; + +struct fb_overlay_buffer +{ + // Input + int layer_id; + unsigned int layer_en; + int ion_fd; + unsigned int cache_sync; + // Output + unsigned int index; + int fence_fd; +}; + +struct fb_overlay_layer +{ + unsigned int layer_id; + unsigned int layer_enable; + + void* src_base_addr; + void* src_phy_addr; + unsigned int src_direct_link; + MTK_FB_FORMAT src_fmt; + unsigned int src_use_color_key; + unsigned int src_color_key; + unsigned int src_pitch; + unsigned int src_offset_x, src_offset_y; + unsigned int src_width, src_height; + + unsigned int tgt_offset_x, tgt_offset_y; + unsigned int tgt_width, tgt_height; + MTK_FB_ORIENTATION layer_rotation; + MTK_FB_LAYER_TYPE layer_type; + MTK_FB_ORIENTATION video_rotation; + + unsigned int isTdshp; // set to 1, will go through tdshp first, then layer blending, then to color + + int next_buff_idx; + int identity; + int connected_type; + unsigned int security; + unsigned int alpha_enable; + unsigned int alpha; + int fence_fd; + int ion_fd; //CL 2340210 +}; + +struct fb_overlay_config +{ + int fence; + int time; + struct fb_overlay_layer layers[4]; +}; + +struct fb_overlay_buffer_info +{ + unsigned int src_vir_addr; + unsigned int size; +}; + +struct fb_overlay_layer_info +{ + unsigned int layer_id; + unsigned int layer_enabled; // TO BE DEL + unsigned int curr_en; + unsigned int next_en; + unsigned int hw_en; + int curr_idx; + int next_idx; + int hw_idx; + int curr_identity; + int next_identity; + int hw_identity; + int curr_conn_type; + int next_conn_type; + int hw_conn_type; + MTK_FB_ORIENTATION layer_rotation; +}; +// -------------------------------------------------------------------------- + +struct fb_post_video_buffer +{ + void* phy_addr; + void* vir_addr; + MTK_FB_TV_SRC_FORMAT format; + unsigned int width, height; +}; + +#ifdef __KERNEL__ + +#include <linux/completion.h> +#include <linux/interrupt.h> +#include <linux/workqueue.h> + +#include <linux/version.h> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)) +#include <linux/sw_sync.h> +#else +#include <../drivers/staging/android/sw_sync.h> +#endif + + +#define MTKFB_DRIVER "mtkfb" + +enum mtkfb_state +{ + MTKFB_DISABLED = 0, + MTKFB_SUSPENDED = 99, + MTKFB_ACTIVE = 100 +}; + +typedef enum +{ + MTKFB_LAYER_ENABLE_DIRTY = (1 << 0), + MTKFB_LAYER_FORMAT_DIRTY = (1 << 1), + MTKFB_LAYER_SET_DIRTY = (1 << 2), +} MTKFB_LAYER_CONFIG_DIRTY; + +typedef struct +{ + struct work_struct work; + struct list_head list; + struct fb_overlay_config config; + struct sync_fence *fences[4]; + struct ion_handle *ion_handles[4]; + void *dev; +} update_ovls_work_t; + +struct mtkfb_device +{ + int state; + void *fb_va_base; /* MPU virtual address */ + dma_addr_t fb_pa_base; /* Bus physical address */ + unsigned long fb_size_in_byte; + void *ovl_va_base; /* MPU virtual address */ + dma_addr_t ovl_pa_base; /* Bus physical address */ + unsigned long ovl_size_in_byte; + + unsigned long layer_enable; + MTK_FB_FORMAT *layer_format; + unsigned int layer_config_dirty; + + int xscale, yscale, mirror; /* transformations. + rotate is stored in fb_info->var */ + u32 pseudo_palette[17]; + + struct fb_info *fb_info; /* Linux fbdev framework data */ + struct device *dev; + + /* Android native fence support */ + struct workqueue_struct *update_ovls_wq; + struct mutex timeline_lock; + struct sw_sync_timeline *timeline; + int timeline_max; + struct list_head pending_configs; //CL2340210 + struct ion_client *ion_client; +}; + +#endif /* __KERNEL__ */ + +extern long hdmi_handle_cmd(unsigned int cmd, unsigned long arg); + + +#endif /* __MTKFB_H */ diff --git a/kernel-headers/linux/mtkfb_info.h b/kernel-headers/linux/mtkfb_info.h new file mode 100644 index 0000000..574c6fc --- /dev/null +++ b/kernel-headers/linux/mtkfb_info.h @@ -0,0 +1,90 @@ +#ifndef __MTKFB_INFO_H__ +#define __MTKFB_INFO_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef enum +{ + DISPIF_TYPE_DBI = 0, + DISPIF_TYPE_DPI, + DISPIF_TYPE_DSI, + DISPIF_TYPE_DPI0, + DISPIF_TYPE_DPI1, + DISPIF_TYPE_DSI0, + DISPIF_TYPE_DSI1, + HDMI = 7, + HDMI_SMARTBOOK, + MHL, + DISPIF_TYPE_EPD +} MTKFB_DISPIF_TYPE; + +typedef enum +{ + MTKFB_DISPIF_PRIMARY_LCD = 0, + MTKFB_DISPIF_HDMI, + MTKFB_DISPIF_EPD, + MTKFB_MAX_DISPLAY_COUNT +} MTKFB_DISPIF_DEVICE_TYPE; + +typedef enum +{ + DISPIF_FORMAT_RGB565 = 0, + DISPIF_FORMAT_RGB666, + DISPIF_FORMAT_RGB888 +} MTKFB_DISPIF_FORMAT; + + +typedef enum +{ + DISPIF_MODE_VIDEO = 0, + DISPIF_MODE_COMMAND +} MTKFB_DISPIF_MODE; + +typedef struct mtk_dispif_info { + unsigned int display_id; + unsigned int isHwVsyncAvailable; + MTKFB_DISPIF_TYPE displayType; + unsigned int displayWidth; + unsigned int displayHeight; + unsigned int displayFormat; + MTKFB_DISPIF_MODE displayMode; + unsigned int vsyncFPS; + unsigned int physicalWidth; + unsigned int physicalHeight; + unsigned int isConnected; + unsigned int lcmOriginalWidth; // this value is for DFO Multi-Resolution feature, which stores the original LCM Wdith + unsigned int lcmOriginalHeight; // this value is for DFO Multi-Resolution feature, which stores the original LCM Height +} mtk_dispif_info_t; + +#define MAKE_MTK_FB_FORMAT_ID(id, bpp) (((id) << 8) | (bpp)) + +typedef enum +{ + MTK_FB_FORMAT_UNKNOWN = 0, + + MTK_FB_FORMAT_RGB565 = MAKE_MTK_FB_FORMAT_ID(1, 2), + MTK_FB_FORMAT_RGB888 = MAKE_MTK_FB_FORMAT_ID(2, 3), + MTK_FB_FORMAT_BGR888 = MAKE_MTK_FB_FORMAT_ID(3, 3), + MTK_FB_FORMAT_ARGB8888 = MAKE_MTK_FB_FORMAT_ID(4, 4), + MTK_FB_FORMAT_ABGR8888 = MAKE_MTK_FB_FORMAT_ID(5, 4), + MTK_FB_FORMAT_YUV422 = MAKE_MTK_FB_FORMAT_ID(6, 2), + MTK_FB_FORMAT_XRGB8888 = MAKE_MTK_FB_FORMAT_ID(7, 4), + MTK_FB_FORMAT_XBGR8888 = MAKE_MTK_FB_FORMAT_ID(8, 4), + MTK_FB_FORMAT_UYVY = MAKE_MTK_FB_FORMAT_ID(9, 2), + MTK_FB_FORMAT_YUV420_P = MAKE_MTK_FB_FORMAT_ID(10, 2), + MTK_FB_FORMAT_YUY2 = MAKE_MTK_FB_FORMAT_ID(11, 2), + MTK_FB_FORMAT_BPP_MASK = 0xFF, +} MTK_FB_FORMAT; + +#define GET_MTK_FB_FORMAT_BPP(f) ((f) & MTK_FB_FORMAT_BPP_MASK) + + +#ifdef __cplusplus +} +#endif + +#endif // __DISP_DRV_H__ + diff --git a/kernel-headers/linux/mtkfb_vsync.h b/kernel-headers/linux/mtkfb_vsync.h new file mode 100644 index 0000000..f0802da --- /dev/null +++ b/kernel-headers/linux/mtkfb_vsync.h @@ -0,0 +1,17 @@ +#ifndef __MTKFB_VSYNC_H__ +#define __MTKFB_VSYNC_H__ + + +#define MTKFB_VSYNC_DEVNAME "mtkfb_vsync" + +#define MTKFB_VSYNC_IOCTL_MAGIC 'V' + +typedef enum +{ + MTKFB_VSYNC_SOURCE_LCM = 0, + MTKFB_VSYNC_SOURCE_HDMI = 1, +} vsync_src; + +#define MTKFB_VSYNC_IOCTL _IOW(MTKFB_VSYNC_IOCTL_MAGIC, 1, vsync_src) + +#endif //MTKFB_VSYNC_H diff --git a/kernel-headers/linux/rrc_drv.h b/kernel-headers/linux/rrc_drv.h new file mode 100644 index 0000000..3b7ff83 --- /dev/null +++ b/kernel-headers/linux/rrc_drv.h @@ -0,0 +1,74 @@ +#include <linux/ioctl.h> + +#ifndef __RRC_DRV_H__ +#define __RRC_DRV_H__ + + + +typedef struct { + + unsigned int scenario; + unsigned int enable; + /* unsigned int pid; */ + /* unsigned int *maxSafeSize; */ + /* unsigned int *result; */ + +} RRC_DRV_DATA; + + +typedef enum { + + RRC_DRV_TYPE_NONE = 0, + RRC_DRV_TYPE_CAMERA_PREVIEW , + RRC_DRV_TYPE_CAMERA_ZSD , + RRC_DRV_TYPE_CAMERA_CAPTURE , + RRC_DRV_TYPE_CAMERA_ICFP , + RRC_DRV_TYPE_VIDEO_NORMAL , + RRC_DRV_TYPE_VIDEO_SWDEC_PLAYBACK , + RRC_DRV_TYPE_VIDEO_PLAYBACK , + RRC_DRV_TYPE_VIDEO_TELEPHONY , + RRC_DRV_TYPE_VIDEO_RECORD , + RRC_DRV_TYPE_VIDEO_RECORD_CAMERA , + RRC_DRV_TYPE_VIDEO_RECORD_SLOWMOTION , + RRC_DRV_TYPE_VIDEO_SNAPSHOT , + RRC_DRV_TYPE_VIDEO_LIVE_PHOTO , + RRC_DRV_TYPE_VIDEO_WIFI_DISPLAY , + + /* touch event */ + RRC_DRV_TYPE_TOUCH_EVENT , + + RRC_DRV_TYPE_MAX_SIZE + + +} RRC_DRV_SCENARIO_TYPE; + + +typedef enum { + RRC_DRV_NONE = 0, + RRC_DRV_60Hz , + RRC_DRV_120Hz + + +} RRC_DRV_REFRESH_RATE; + + + + +#define RRC_IOCTL_MAGIC 'x' + +/* #define JPEG_DEC_IOCTL_INIT _IO (ALMK_IOCTL_MAGIC, 1) */ +/* #define JPEG_DEC_IOCTL_CONFIG _IOW (ALMK_IOCTL_MAGIC, 2, JPEG_DEC_DRV_IN) */ +/* #define JPEG_DEC_IOCTL_START _IO (ALMK_IOCTL_MAGIC, 3) */ +/* #define JPEG_DEC_IOCTL_WAIT _IOWR(ALMK_IOCTL_MAGIC, 6, JPEG_DEC_DRV_OUT) */ +/* #define JPEG_DEC_IOCTL_DEINIT _IO (ALMK_IOCTL_MAGIC, 8) */ + +#define RRC_IOCTL_CMD_INIT _IO(RRC_IOCTL_MAGIC, 11) +#define RRC_IOCTL_CMD_SET_SCENARIO_TYPE _IOWR(RRC_IOCTL_MAGIC, 12, RRC_DRV_DATA) +#define RRC_IOCTL_CMD_DEINIT _IO(RRC_IOCTL_MAGIC, 13) + + + + + +#endif + diff --git a/kernel-headers/linux/rtpm_prio.h b/kernel-headers/linux/rtpm_prio.h new file mode 100644 index 0000000..70aa10e --- /dev/null +++ b/kernel-headers/linux/rtpm_prio.h @@ -0,0 +1,83 @@ +#ifndef __KERNEL_RTPM_PRIO__ +#define __KERNEL_RTPM_PRIO__ + +#define CONFIG_MT_RT_MONITOR +#ifdef CONFIG_MT_RT_MONITOR +#define MT_ALLOW_RT_PRIO_BIT 0x10000000 +#else +#define MT_ALLOW_RT_PRIO_BIT 0x0 +#endif + +#define REG_RT_PRIO(x) ((x) | MT_ALLOW_RT_PRIO_BIT) + +/*********************************************************************** + * Processes scheduled under one of the real-time policies (SCHED_FIFO, SCHED_RR) + * have a sched_priority value in the range: + * 1 (low) to 99 (high). +************************************************************************/ +//////////////////////////////////////////////////////////////////////// +//DEFINE MM GROUP PRIORITY +#define RTPM_PRIO_MM_GROUP_BASE (10) +#define RTPM_PRIO_MM_GROUP_A (RTPM_PRIO_MM_GROUP_BASE+0) +#define RTPM_PRIO_MM_GROUP_B (RTPM_PRIO_MM_GROUP_BASE+10) +#define RTPM_PRIO_MM_GROUP_C (RTPM_PRIO_MM_GROUP_BASE+20) +#define RTPM_PRIO_MM_GROUP_D (RTPM_PRIO_MM_GROUP_BASE+30) +#define RTPM_PRIO_MM_GROUP_E (RTPM_PRIO_MM_GROUP_BASE+40) +#define RTPM_PRIO_MM_GROUP_F (RTPM_PRIO_MM_GROUP_BASE+50) +#define RTPM_PRIO_MM_GROUP_G (RTPM_PRIO_MM_GROUP_BASE+60) +#define RTPM_PRIO_MM_GROUP_H (RTPM_PRIO_MM_GROUP_BASE+70) +#define RTPM_PRIO_MM_GROUP_I (RTPM_PRIO_MM_GROUP_BASE+80) + +//////////////////////////////////////////////////////////////////////// +// DEFIN MTK RT PRIORITY + +#define RTPM_PRIO_CPU_CALLBACK REG_RT_PRIO(98) +#define RTPM_PRIO_SWLOCKUP REG_RT_PRIO(98) +#define RTPM_PRIO_AED REG_RT_PRIO(28) +#define RTPM_PRIO_WDT REG_RT_PRIO(99) + +#define RTPM_PRIO_TPD REG_RT_PRIO(4) +#define RTPM_PRIO_KSDIOIRQ REG_RT_PRIO(1) + +#define RTPM_PRIO_AUDIO_PLAYBACK REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+5) +#define RTPM_PRIO_VIDEO_PLAYBACK_THREAD REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+5) //TimeEventQueue +#define RTPM_PRIO_SCRN_UPDATE REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+4) +#define RTPM_PRIO_AUDIO_COMMAND REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+2) +#define RTPM_PRIO_AUDIO_CCCI_THREAD REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+2) + +#define RTPM_PRIO_CAMERA_TOPBASE REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+1) +#define RTPM_PRIO_CAMERA_PREVIEW REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+1) +#define RTPM_PRIO_CAMERA_COMPRESS REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+0) + +#define RTPM_PRIO_MATV_AUDIOPLAYER REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+0) +#define RTPM_PRIO_FM_AUDIOPLAYER REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+0) +#define RTPM_PRIO_AUDIO_I2S REG_RT_PRIO(RTPM_PRIO_MM_GROUP_I+0) + +#define RTPM_PRIO_CAMERA_DISPLAY REG_RT_PRIO(RTPM_PRIO_MM_GROUP_H+9) +#define RTPM_PRIO_CAMERA_SHUTTER REG_RT_PRIO(RTPM_PRIO_MM_GROUP_H+9) +#define RTPM_PRIO_CAMERA_RECORD REG_RT_PRIO(RTPM_PRIO_MM_GROUP_H+9) +#define RTPM_PRIO_FB_THREAD REG_RT_PRIO(RTPM_PRIO_MM_GROUP_H+7) +#define RTPM_PRIO_VSYNC_THREAD REG_RT_PRIO(RTPM_PRIO_MM_GROUP_H+5) +#define RTPM_PRIO_SURFACEFLINGER REG_RT_PRIO(RTPM_PRIO_MM_GROUP_H+4) + +#define RTPM_PRIO_VIDEO_YUV_BUFFER REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+8) +#define RTPM_PRIO_AUDIO_RECORD REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+7) +#define RTPM_PRIO_OMX_AUDIO REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+6) +#define RTPM_PRIO_OMX_CMD_AUDIO REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+6) +#define RTPM_PRIO_OMX_VIDEO_ENCODE REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+5) +#define RTPM_PRIO_OMX_VIDEO REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+5) +#define RTPM_PRIO_OMX_VIDEO_DECODE REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+4) + +#define RTPM_PRIO_VIDEO_BS_BUFFER REG_RT_PRIO(RTPM_PRIO_MM_GROUP_G+3) +#define RTPM_PRIO_MIDI_FILE REG_RT_PRIO(RTPM_PRIO_MM_GROUP_C+0) + +#define RTPM_PRIO_AUDIOTRACK_THREAD REG_RT_PRIO(1) +#define RTPM_PRIO_GPS_DRIVER REG_RT_PRIO(1) +// Total +#define RTPM_PRIO_NUM 30 +//////////////////////////////////////////////////////////////////////////////// +//Removed +//#define RTPM_PRIO_FB_THREAD REG_RT_PRIO(87) +//#define RTPM_PRIO_SURFACE_OUT REG_RT_PRIO(80) + +#endif diff --git a/kernel-headers/linux/sensors_io.h b/kernel-headers/linux/sensors_io.h new file mode 100644 index 0000000..a84e5ff --- /dev/null +++ b/kernel-headers/linux/sensors_io.h @@ -0,0 +1,166 @@ +/* +* +* (C) Copyright 2008 +* MediaTek <www.mediatek.com> +* +* Sensors IO command file for MT6516 +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef SENSORS_IO_H +#define SENSORS_IO_H + +#include <linux/ioctl.h> + +typedef struct { + unsigned short x; /**< X axis */ + unsigned short y; /**< Y axis */ + unsigned short z; /**< Z axis */ +} GSENSOR_VECTOR3D; + +typedef struct{ + int x; + int y; + int z; +}SENSOR_DATA; + + +#define GSENSOR 0x85 +#define GSENSOR_IOCTL_INIT _IO(GSENSOR, 0x01) +#define GSENSOR_IOCTL_READ_CHIPINFO _IOR(GSENSOR, 0x02, int) +#define GSENSOR_IOCTL_READ_SENSORDATA _IOR(GSENSOR, 0x03, int) +#define GSENSOR_IOCTL_READ_OFFSET _IOR(GSENSOR, 0x04, GSENSOR_VECTOR3D) +#define GSENSOR_IOCTL_READ_GAIN _IOR(GSENSOR, 0x05, GSENSOR_VECTOR3D) +#define GSENSOR_IOCTL_READ_RAW_DATA _IOR(GSENSOR, 0x06, int) +#define GSENSOR_IOCTL_SET_CALI _IOW(GSENSOR, 0x06, SENSOR_DATA) +#define GSENSOR_IOCTL_GET_CALI _IOW(GSENSOR, 0x07, SENSOR_DATA) +#define GSENSOR_IOCTL_CLR_CALI _IO(GSENSOR, 0x08) + + + + +/* IOCTLs for Msensor misc. device library */ +#define MSENSOR 0x83 +#define MSENSOR_IOCTL_INIT _IO(MSENSOR, 0x01) +#define MSENSOR_IOCTL_READ_CHIPINFO _IOR(MSENSOR, 0x02, int) +#define MSENSOR_IOCTL_READ_SENSORDATA _IOR(MSENSOR, 0x03, int) +#define MSENSOR_IOCTL_READ_POSTUREDATA _IOR(MSENSOR, 0x04, int) +#define MSENSOR_IOCTL_READ_CALIDATA _IOR(MSENSOR, 0x05, int) +#define MSENSOR_IOCTL_READ_CONTROL _IOR(MSENSOR, 0x06, int) +#define MSENSOR_IOCTL_SET_CONTROL _IOW(MSENSOR, 0x07, int) +#define MSENSOR_IOCTL_SET_MODE _IOW(MSENSOR, 0x08, int) +#define MSENSOR_IOCTL_SET_POSTURE _IOW(MSENSOR, 0x09, int) +#define MSENSOR_IOCTL_SET_CALIDATA _IOW(MSENSOR, 0x0a, int) +#define MSENSOR_IOCTL_SENSOR_ENABLE _IOW(MSENSOR, 0x51, int) +#define MSENSOR_IOCTL_READ_FACTORY_SENSORDATA _IOW(MSENSOR, 0x52, int) + + +/* IOCTLs for AKM library */ +#define ECS_IOCTL_WRITE _IOW(MSENSOR, 0x0b, char*) +#define ECS_IOCTL_READ _IOWR(MSENSOR, 0x0c, char*) +#define ECS_IOCTL_RESET _IO(MSENSOR, 0x0d) /* NOT used in AK8975 */ +#define ECS_IOCTL_SET_MODE _IOW(MSENSOR, 0x0e, short) +#define ECS_IOCTL_GETDATA _IOR(MSENSOR, 0x0f, char[SENSOR_DATA_SIZE]) +#define ECS_IOCTL_SET_YPR _IOW(MSENSOR, 0x10, short[12]) +#define ECS_IOCTL_GET_OPEN_STATUS _IOR(MSENSOR, 0x11, int) +#define ECS_IOCTL_GET_CLOSE_STATUS _IOR(MSENSOR, 0x12, int) +#define ECS_IOCTL_GET_OSENSOR_STATUS _IOR(MSENSOR, 0x13, int) +#define ECS_IOCTL_GET_DELAY _IOR(MSENSOR, 0x14, short) +#define ECS_IOCTL_GET_PROJECT_NAME _IOR(MSENSOR, 0x15, char[64]) +#define ECS_IOCTL_GET_MATRIX _IOR(MSENSOR, 0x16, short [4][3][3]) +#define ECS_IOCTL_GET_LAYOUT _IOR(MSENSOR, 0x17, int[3]) + +#define ECS_IOCTL_GET_OUTBIT _IOR(MSENSOR, 0x23, char) +#define ECS_IOCTL_GET_ACCEL _IOR(MSENSOR, 0x24, short[3]) +#define MMC31XX_IOC_RM _IO(MSENSOR, 0x25) +#define MMC31XX_IOC_RRM _IO(MSENSOR, 0x26) +/* IOCTLs for akm09911 device */ +#define ECS_IOCTL_GET_INFO _IOR(MSENSOR, 0x27, unsigned char[AKM_SENSOR_INFO_SIZE]) +#define ECS_IOCTL_GET_CONF _IOR(MSENSOR, 0x28, unsigned char[AKM_SENSOR_CONF_SIZE]) +#define ECS_IOCTL_SET_YPR_09911 _IOW(MSENSOR, 0x29, int[26]) +#define ECS_IOCTL_GET_DELAY_09911 _IOR(MSENSOR, 0x30, int64_t[3]) +#define ECS_IOCTL_GET_LAYOUT_09911 _IOR(MSENSOR, 0x31, char) + +/* IOCTLs for MMC31XX device */ +#define MMC31XX_IOC_TM _IO(MSENSOR, 0x18) +#define MMC31XX_IOC_SET _IO(MSENSOR, 0x19) +#define MMC31XX_IOC_RESET _IO(MSENSOR, 0x1a) +#define MMC31XX_IOC_READ _IOR(MSENSOR, 0x1b, int[3]) +#define MMC31XX_IOC_READXYZ _IOR(MSENSOR, 0x1c, int[3]) + +#define ECOMPASS_IOC_GET_DELAY _IOR(MSENSOR, 0x1d, int) +#define ECOMPASS_IOC_GET_MFLAG _IOR(MSENSOR, 0x1e, short) +#define ECOMPASS_IOC_GET_OFLAG _IOR(MSENSOR, 0x1f, short) +#define ECOMPASS_IOC_GET_OPEN_STATUS _IOR(MSENSOR, 0x20, int) +#define ECOMPASS_IOC_SET_YPR _IOW(MSENSOR, 0x21, int[12]) +#define ECOMPASS_IOC_GET_LAYOUT _IOR(MSENSOR, 0X22, int) + + + + +#define ALSPS 0X84 +#define ALSPS_SET_PS_MODE _IOW(ALSPS, 0x01, int) +#define ALSPS_GET_PS_MODE _IOR(ALSPS, 0x02, int) +#define ALSPS_GET_PS_DATA _IOR(ALSPS, 0x03, int) +#define ALSPS_GET_PS_RAW_DATA _IOR(ALSPS, 0x04, int) +#define ALSPS_SET_ALS_MODE _IOW(ALSPS, 0x05, int) +#define ALSPS_GET_ALS_MODE _IOR(ALSPS, 0x06, int) +#define ALSPS_GET_ALS_DATA _IOR(ALSPS, 0x07, int) +#define ALSPS_GET_ALS_RAW_DATA _IOR(ALSPS, 0x08, int) +/*-------------------yucong add-------------------------------------------*/ +#define ALSPS_GET_PS_TEST_RESULT _IOR(ALSPS, 0x09, int) +#define ALSPS_GET_ALS_TEST_RESULT _IOR(ALSPS, 0x0A, int) +#define ALSPS_GET_PS_THRESHOLD_HIGH _IOR(ALSPS, 0x0B, int) +#define ALSPS_GET_PS_THRESHOLD_LOW _IOR(ALSPS, 0x0C, int) +#define ALSPS_GET_ALS_THRESHOLD_HIGH _IOR(ALSPS, 0x0D, int) +#define ALSPS_GET_ALS_THRESHOLD_LOW _IOR(ALSPS, 0x0E, int) +#define ALSPS_IOCTL_CLR_CALI _IOW(ALSPS, 0x0F, int) +#define ALSPS_IOCTL_GET_CALI _IOR(ALSPS, 0x10, int) +#define ALSPS_IOCTL_SET_CALI _IOW(ALSPS, 0x11, int) +#define ALSPS_SET_PS_THRESHOLD _IOW(ALSPS, 0x12, int) +#define ALSPS_SET_ALS_THRESHOLD _IOW(ALSPS, 0x13, int) +#define AAL_SET_ALS_MODE _IOW(ALSPS, 0x14,int) +#define AAL_GET_ALS_MODE _IOR(ALSPS, 0x15,int) +#define AAL_GET_ALS_DATA _IOR(ALSPS, 0x16,int) + +#define GYROSCOPE 0X86 +#define GYROSCOPE_IOCTL_INIT _IO(GYROSCOPE, 0x01) +#define GYROSCOPE_IOCTL_SMT_DATA _IOR(GYROSCOPE, 0x02, int) +#define GYROSCOPE_IOCTL_READ_SENSORDATA _IOR(GYROSCOPE, 0x03, int) +#define GYROSCOPE_IOCTL_SET_CALI _IOW(GYROSCOPE, 0x04, SENSOR_DATA) +#define GYROSCOPE_IOCTL_GET_CALI _IOW(GYROSCOPE, 0x05, SENSOR_DATA) +#define GYROSCOPE_IOCTL_CLR_CALI _IO(GYROSCOPE, 0x06) +#define GYROSCOPE_IOCTL_READ_SENSORDATA_RAW _IOR(GYROSCOPE, 0x07, int) +#define GYROSCOPE_IOCTL_READ_TEMPERATURE _IOR(GYROSCOPE, 0x08, int) +#define GYROSCOPE_IOCTL_GET_POWER_STATUS _IOR(GYROSCOPE, 0x09, int) + +#define BROMETER 0X87 +#define BAROMETER_IOCTL_INIT _IO(BROMETER, 0x01) +#define BAROMETER_GET_PRESS_DATA _IOR(BROMETER, 0x02, int) +#define BAROMETER_GET_TEMP_DATA _IOR(BROMETER, 0x03, int) +#define BAROMETER_IOCTL_READ_CHIPINFO _IOR(BROMETER, 0x04, int) + +#define HEARTMONITOR 0x88 +#define HRM_IOCTL_INIT _IO(HEARTMONITOR, 0x01) +#define HRM_READ_SENSOR_DATA _IOR(HEARTMONITOR, 0x02, int) + +#define HUMIDITY 0X89 +#define HUMIDITY_IOCTL_INIT _IO(HUMIDITY, 0x01) +#define HUMIDITY_GET_HMDY_DATA _IOR(HUMIDITY, 0x02, int) +#define HUMIDITY_GET_TEMP_DATA _IOR(HUMIDITY, 0x03, int) +#define HUMIDITY_IOCTL_READ_CHIPINFO _IOR(HUMIDITY, 0x04, int) + +#endif + diff --git a/kernel-headers/linux/slab.h b/kernel-headers/linux/slab.h new file mode 100644 index 0000000..f3c1408 --- /dev/null +++ b/kernel-headers/linux/slab.h @@ -0,0 +1,21 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _LINUX_SLAB_H +#define _LINUX_SLAB_H +#endif diff --git a/kernel-headers/linux/vow.h b/kernel-headers/linux/vow.h new file mode 100644 index 0000000..4b9a310 --- /dev/null +++ b/kernel-headers/linux/vow.h @@ -0,0 +1,108 @@ +#ifndef __VOW_H__ +#define __VOW_H__ + +/*********************************************************************************** +** VOW Control Message +************************************************************************************/ +#define VOW_DEVNAME "vow" +#define VOW_IOC_MAGIC 'a' + +static char const *const kVOWDeviceName = "/dev/vow"; + +#if 0 +//below is control message +#define TEST_VOW_PRINT _IO(VOW_IOC_MAGIC, 0x00) +#define VOWEINT_GET_BUFSIZE _IOW(VOW_IOC_MAGIC, 0x01, unsigned long) +#define VOW_GET_STATUS _IOW(VOW_IOC_MAGIC, 0x02, unsigned long) +#define VOW_SET_CONTROL _IOW(VOW_IOC_MAGIC, 0x03, unsigned long) +#define VOW_SET_SPEAKER_MODEL _IOW(VOW_IOC_MAGIC, 0x04, unsigned long) +#define VOW_CLR_SPEAKER_MODEL _IOW(VOW_IOC_MAGIC, 0x05, unsigned long) +#define VOW_SET_INIT_MODEL _IOW(VOW_IOC_MAGIC, 0x06, unsigned long) +#define VOW_SET_FIR_MODEL _IOW(VOW_IOC_MAGIC, 0x07, unsigned long) +#define VOW_SET_NOISE_MODEL _IOW(VOW_IOC_MAGIC, 0x08, unsigned long) +#define VOW_SET_APREG_INFO _IOW(VOW_IOC_MAGIC, 0x09, unsigned long) +#define VOW_SET_REG_MODE _IOW(VOW_IOC_MAGIC, 0x0A, unsigned long) +#define VOW_FAKE_WAKEUP _IOW(VOW_IOC_MAGIC, 0x0B, unsigned long) +#else + + +//below is control message +#define TEST_VOW_PRINT 0x00 +#define VOWEINT_GET_BUFSIZE 0x01 +#define VOW_GET_STATUS 0x02 +#define VOW_SET_CONTROL 0x03 +#define VOW_SET_SPEAKER_MODEL 0x04 +#define VOW_CLR_SPEAKER_MODEL 0x05 +#define VOW_SET_INIT_MODEL 0x06 +#define VOW_SET_FIR_MODEL 0x07 +#define VOW_SET_NOISE_MODEL 0x08 +#define VOW_SET_APREG_INFO 0x09 +#define VOW_SET_REG_MODE 0x0A +#define VOW_FAKE_WAKEUP 0x0B + +#endif + + + +/*********************************************************************************** +** Type Define +************************************************************************************/ +enum VOW_Control_Cmd +{ + VOWControlCmd_Init = 0, + VOWControlCmd_ReadVoiceData, + VOWControlCmd_EnableDebug, + VOWControlCmd_DisableDebug, +}; + +typedef enum VOW_REG_MODE_T { + VOW_MODE_MD32_VOW = 0, + VOW_MODE_VOICECOMMAND, + VOW_MODE_MULTIPLE_KEY, + VOW_MODE_MULTIPLE_KEY_VOICECOMMAND +}VOW_REG_MODE_T; + +typedef enum VOW_EINT_STATUS{ + VOW_EINT_DISABLE = -2, + VOW_EINT_FAIL = -1, + VOW_EINT_PASS = 0, + VOW_EINT_RETRY = 1, + NUM_OF_VOW_EINT_STATUS +}VOW_EINT_STATUS; + +typedef enum VOW_FLAG_TYPE{ + VOW_FLAG_DEBUG, + VOW_FLAG_PRE_LEARN, + VOW_FLAG_DMIC_LOWPOWER, + NUM_OF_VOW_FLAG_TYPE +}VOW_FLAG_TYPE; + +typedef enum VOW_PWR_STATUS{ + VOW_PWR_OFF = 0, + VOW_PWR_ON = 1, + NUM_OF_VOW_PWR_STATUS +}VOW_PWR_STATUS; + +typedef enum VOW_IPI_RESULT +{ + VOW_IPI_SUCCESS = 0, + VOW_IPI_CLR_SMODEL_ID_NOTMATCH, + VOW_IPI_SET_SMODEL_NO_FREE_SLOT, +}VOW_IPI_RESULT; +/* +struct VOW_EINT_DATA_STRUCT{ + int size; // size of data section + int eint_status; // eint status + int id; + char *data; // reserved for future extension +}VOW_EINT_DATA_STRUCT; +*/ + +typedef struct{ + long id; + long addr; + long size; + void *data; +}VOW_MODEL_INFO_T; + +#endif //__VOW_H__ diff --git a/kernel-headers/sync_write.h b/kernel-headers/sync_write.h new file mode 100644 index 0000000..e4c6e85 --- /dev/null +++ b/kernel-headers/sync_write.h @@ -0,0 +1,80 @@ +#ifndef __MT65XX_SYNC_WRITE_H__ +#define __MT65XX_SYNC_WRITE_H__ + +#define mt_reg_sync_writel(v, a) mt65xx_reg_sync_writel(v, a) +#define mt_reg_sync_writew(v, a) mt65xx_reg_sync_writew(v, a) +#define mt_reg_sync_writeb(v, a) mt65xx_reg_sync_writeb(v, a) + +#if defined(__KERNEL__) + +#include <linux/io.h> +#include <asm/cacheflush.h> +#include <asm/system.h> + +/* + * Define macros. + */ + +#define mt65xx_reg_sync_writel(v, a) \ + do { \ + writel((v), (a)); \ + dsb(); \ + } while (0) + +#define mt65xx_reg_sync_writew(v, a) \ + do { \ + writew((v), (a)); \ + dsb(); \ + } while (0) + +#define mt65xx_reg_sync_writeb(v, a) \ + do { \ + writeb((v), (a)); \ + dsb(); \ + } while (0) + +#else /* __KERNEL__ */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <string.h> + +#define dsb() \ + do { \ + __asm__ __volatile__ ("dsb sy" : : : "memory"); \ + } while (0) + +#define outer_sync() \ + do { \ + int fd; \ + char buf[] = "1"; \ + fd = open("/sys/bus/platform/drivers/outercache/outer_sync", O_WRONLY); \ + if (fd != -1) { \ + write(fd, buf, strlen(buf)); \ + close(fd); \ + } \ + } while (0) + +#define mt65xx_reg_sync_writel(v, a) \ + do { \ + *(volatile unsigned int *)(a) = (v); \ + dsb(); \ + } while (0) + +#define mt65xx_reg_sync_writew(v, a) \ + do { \ + *(volatile unsigned short *)(a) = (v); \ + dsb(); \ + } while (0) + +#define mt65xx_reg_sync_writeb(v, a) \ + do { \ + *(volatile unsigned char *)(a) = (v); \ + dsb(); \ + } while (0) + +#endif /* __KERNEL__ */ + +#endif /* !__MT65XX_SYNC_WRITE_H__ */ diff --git a/kernel-headers/val_api_private.h b/kernel-headers/val_api_private.h new file mode 100644 index 0000000..4e41082 --- /dev/null +++ b/kernel-headers/val_api_private.h @@ -0,0 +1,57 @@ +#ifndef _VAL_API_PRIVATE_H_ +#define _VAL_API_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "val_api_public.h" +#include "libmtk_cipher_export.h" + + +VAL_RESULT_T eValInit(VAL_HANDLE_T *a_phHalHandle); +VAL_RESULT_T eValDeInit(VAL_HANDLE_T *a_phHalHandle); + +VAL_RESULT_T eVideoIntMemAlloc(VAL_INTMEM_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoIntMemFree(VAL_INTMEM_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoCreateEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoSetEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoCloseEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoWaitEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoCreateMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoCloseMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoWaitMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoReleaseMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoMMAP(VAL_MMAP_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoUnMMAP(VAL_MMAP_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoInitLockHW(VAL_VCODEC_OAL_HW_REGISTER_T *prParam, int size); +VAL_RESULT_T eVideoDeInitLockHW(VAL_VCODEC_OAL_HW_REGISTER_T *prParam, int size); + +VAL_RESULT_T eVideoVCodecCoreLoading(int CPUid, int *Loading); +VAL_RESULT_T eVideoVCodecCoreNumber(int *CPUNums); + +VAL_RESULT_T eVideoConfigMCIPort(VAL_UINT32_T u4PortConfig, VAL_UINT32_T *pu4PortResult, VAL_MEM_CODEC_T eMemCodec); + +VAL_UINT32_T eVideoHwM4UEnable(VAL_BOOL_T bEnable); /* MTK_SEC_VIDEO_PATH_SUPPORT */ +VAL_UINT32_T eVideoLibDecrypt(VIDEO_ENCRYPT_CODEC_T a_eVIDEO_ENCRYPT_CODEC); + +/* for DirectLink Meta Mode + */ +VAL_RESULT_T eVideoAllocMetaHandleList(VAL_HANDLE_T *a_MetaHandleList); +VAL_RESULT_T eVideoGetBufInfoFromMetaHandle( + VAL_HANDLE_T a_MetaHandleList, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); +VAL_RESULT_T eVideoFreeMetaHandleList(VAL_HANDLE_T a_MetaHandleList); +/* for DirectLink Meta Mode - */ + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VAL_API_PRIVATE_H_ */ diff --git a/kernel-headers/val_api_public.h b/kernel-headers/val_api_public.h new file mode 100644 index 0000000..9af8887 --- /dev/null +++ b/kernel-headers/val_api_public.h @@ -0,0 +1,402 @@ +#ifndef _VAL_API_PUBLIC_H_ +#define _VAL_API_PUBLIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" + + +/** + * @par Function + * eVideoInitMVA + * @par Description + * Alloc the handle for MVA usage + * @param + * a_pvHandle [IN] The handle for MVA usage + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoInitMVA(VAL_VOID_T **a_pvHandle); + + +/** + * @par Function + * eVideoAllocMVA + * @par Description + * Use the given va and size, to get the MVA + * @param + * a_pvHandle [IN] The handle for MVA usage + * @param + * a_u4Va [IN] The given va used to get MVA + * @param + * ap_u4Pa [OUT] The MVA + * @param + * a_u4Size [IN] The given size used to get MVA + * @param + * a_pvM4uConfig [IN] The MVA config info + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoAllocMVA( + VAL_VOID_T *a_pvHandle, + VAL_UINT32_T a_u4Va, + VAL_UINT32_T *ap_u4Pa, + VAL_UINT32_T a_u4Size, + VAL_VCODEC_M4U_BUFFER_CONFIG_T * a_pvM4uConfig +); + +/** + * @par Function + * eVideoFreeMVA + * @par Description + * Use the given va, MVA and size, to free the MVA + * @param + * a_pvHandle [IN] The handle for MVA usage + * @param + * a_u4Va [IN] The given va used to free MVA + * @param + * a_u4Pa [IN] The given MVA used to free MVA + * @param + * a_u4Size [IN] The given size used to get MVA + * @param + * a_pvM4uConfig [IN] The MVA config info + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoFreeMVA( + VAL_VOID_T *a_pvHandle, + VAL_UINT32_T a_u4Va, + VAL_UINT32_T a_u4Pa, + VAL_UINT32_T a_u4Size, + VAL_VCODEC_M4U_BUFFER_CONFIG_T * a_pvM4uConfig +); + + +/** + * @par Function + * eVideoDeInitMVA + * @par Description + * Free the handle for MVA usage + * @param + * a_pvHandle [IN] The handle for MVA usage + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoDeInitMVA(VAL_VOID_T *a_pvHandle); + + +/** + * @par Function + * eVideoGetM4UModuleID + * @par Description + * Get the M4U module port ID + * @param + * u4MemType [IN] The memory usage for VENC or VDEC + * @par Returns + * VAL_UINT32_T [OUT] The M4U module port ID for VENC or VDEC + */ +VAL_INT32_T eVideoGetM4UModuleID(VAL_UINT32_T u4MemType); + + +/** + * @par Function + * eVideoAtoi + * @par Description + * The abstraction layer for atoi() function + * @param + * a_prParam [IN] The structure contains used info for atoi() + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoAtoi(VAL_ATOI_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoStrStr + * @par Description + * The abstraction layer for strstr() function + * @param + * a_prParam [IN] The structure contains used info for strstr() + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoStrStr(VAL_STRSTR_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoFlushCache + * @par Description + * The flush cache usage function + * @param + * a_prParam [IN] The structure contains used info for flush cache + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @param + * optype [IN] 0 for flush all, 1 for flush by page + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_MEMORY for fail + */ +VAL_RESULT_T eVideoFlushCache(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize, VAL_UINT32_T optype); + + +/** + * @par Function + * eVideoInvalidateCache + * @par Description + * The invalidate cache usage function + * @param + * a_prParam [IN] The structure contains used info for invalidate cache + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @param + * optype [IN] 0 for flush all, 1 for invalidate by page + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_MEMORY for fail + */ +VAL_RESULT_T eVideoInvalidateCache(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize, VAL_UINT32_T optype); + + +/** + * @par Function + * eVideoMemAlloc + * @par Description + * The memory allocate usage function + * @param + * a_prParam [IN] The structure contains used info for allocate memory + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] + * VAL_RESULT_NO_ERROR for success, + * VAL_RESULT_INVALID_MEMORY or VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemAlloc(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoMemFree + * @par Description + * The memory free usage function + * @param + * a_prParam [IN] The structure contains used info for free memory + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemFree(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoMemSet + * @par Description + * The memory set usage function + * @param + * a_prParam [IN] The structure contains used info for set memory + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @param + * a_u4Value [IN] The value for set to memory + * @param + * a_u4Size [IN] The size of "memory" want to be set + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemSet( + VAL_MEMORY_T *a_prParam, + VAL_UINT32_T a_u4ParamSize, + VAL_INT32_T a_u4Value, + VAL_UINT32_T a_u4Size +); + + +/** + * @par Function + * eVideoMemCpy + * @par Description + * The memory copy usage function + * @param + * a_prParamDst [IN] The structure contains destination memory info for copy memory + * @param + * a_u4ParamDstSize [IN] The size of a_prParamDst structure + * @param + * a_prParamSrc [IN] The structure contains source memory info for copy memory + * @param + * a_u4ParamSrcSize [IN] The size of a_prParamSrc structure + * @param + * a_u4Size [IN] The size of "source memory" and "destination memory" want to be copied + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemCpy( + VAL_MEMORY_T *a_prParamDst, + VAL_UINT32_T a_u4ParamDstSize, + VAL_MEMORY_T *a_prParamSrc, + VAL_UINT32_T a_u4ParamSrcSize, + VAL_UINT32_T a_u4Size +); + + +/** + * @par Function + * eVideoMemCmp + * @par Description + * The memory compare usage function + * @param + * a_prParamSrc1 [IN] The structure contains memory 1 info for compare memory + * @param + * a_u4ParamSrc1Size [IN] The size of a_prParamSrc1 structure + * @param + * a_prParamSrc2 [IN] The structure contains memory 2 info for compare memory + * @param + * a_u4ParamSrc2Size [IN] The size of a_prParamSrc2 structure + * @param + * a_u4Size [IN] The size of "memory 1" and "memory 2" want to be compared + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemCmp( + VAL_MEMORY_T *a_prParamSrc1, + VAL_UINT32_T a_u4ParamSrc1Size, + VAL_MEMORY_T *a_prParamSrc2, + VAL_UINT32_T a_u4ParamSrc2Size, + VAL_UINT32_T a_u4Size +); + + +/** + * @par Function + * WaitISR + * @par Description + * The ISR usage related function, whene trigger HW, we will use to wait HW complete + * @param + * a_prParam [IN] The structure contains used info for ISR usage + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_ISR_TIMEOUT for fail + */ +VAL_RESULT_T WaitISR(VAL_ISR_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoLockHW + * @par Description + * The single/multiple instance usage function, to allow using HW + * @param + * a_prParam [IN] The structure contains used info for Lock HW + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_UNKNOWN_ERROR for fail + */ +VAL_RESULT_T eVideoLockHW(VAL_HW_LOCK_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoLockHW + * @par Description + * The single/multiple instance usage function, to release HW for another instance + * @param + * a_prParam [IN] The structure contains used info for unLock HW + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_UNKNOWN_ERROR for fail + */ +VAL_RESULT_T eVideoUnLockHW(VAL_HW_LOCK_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoGetTimeOfDay + * @par Description + * The timing usage function, used to performance profiling + * @param + * a_prParam [IN] The structure contains used info for timing usage + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoGetTimeOfDay(VAL_TIME_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eHalEMICtrlForRecordSize + * @par Description + * The recording info function, to get the record size for setting to EMI controller + * @param + * a_prDrvRecordSize [IN] The structure contains used info for recording size + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eHalEMICtrlForRecordSize(VAL_RECORD_SIZE_T *a_prDrvRecordSize); + + +/** + * @par Function + * eVideoVcodecSetThreadID + * @par Description + * The thread info function, to set thread ID for used to lock/unlock HW and priority adjustment + * @param + * a_prThreadID [IN] The structure contains used info for thread info + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoVcodecSetThreadID(VAL_VCODEC_THREAD_ID_T *a_prThreadID); + + +/** + * @par Function + * eVideoGetParam + * @par Description + * The parameter info function, to get val parameter + * @param + * a_eType [IN] The VAL_GET_TYPE_T enum + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoGetParam(VAL_GET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); + +/** + * @par Function + * eVideoSetParam + * @par Description + * The parameter info function, to set val parameter + * @param + * a_eType [IN] The VAL_SET_TYPE_T enum + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoSetParam(VAL_SET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); + +VAL_RESULT_T eVideoE3TCMPowerON(VAL_UINT32_T a_u4E3TCMClk); +VAL_RESULT_T eVideoE3TCMPowerOFF(VAL_UINT32_T a_u4E3TCMClk); + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VAL_API_PUBLIC_H_ */ diff --git a/kernel-headers/val_log.h b/kernel-headers/val_log.h new file mode 100644 index 0000000..bbf4a84 --- /dev/null +++ b/kernel-headers/val_log.h @@ -0,0 +1,56 @@ +#ifndef _VAL_LOG_H_ +#define _VAL_LOG_H_ + +#include <utils/Log.h> +#include <cutils/log.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef MTK_LOG_ENABLE +#undef MTK_LOG_ENABLE +#endif +#define MTK_LOG_ENABLE 1 + +#define MFV_LOG_ERROR /* /< error */ +#ifdef MFV_LOG_ERROR +#define MFV_LOGE(...) LOG_PRI(ANDROID_LOG_ERROR, "VDO_LOG", __VA_ARGS__); /* /< show error log */ +#define VDO_LOGE(...) LOG_PRI(ANDROID_LOG_ERROR, "VDO_LOG", __VA_ARGS__); /* /< show error log */ +#else +#define MFV_LOGE(...) /* /< NOT show error log */ +#define VDO_LOGE(...) /* /< NOT show error log */ +#endif + +#define MFV_LOG_WARNING /* /< warning */ +#ifdef MFV_LOG_WARNING +#define MFV_LOGW(...) LOG_PRI(ANDROID_LOG_WARN, "VDO_LOG", __VA_ARGS__); /* /< show warning log */ +#define VDO_LOGW(...) LOG_PRI(ANDROID_LOG_WARN, "VDO_LOG", __VA_ARGS__); /* /< show warning log */ +#else +#define MFV_LOGW(...) /* /< NOT show warning log */ +#define VDO_LOGW(...) /* /< NOT show warning log */ +#endif + +/* #define MFV_LOG_DEBUG ///< debug information */ +#ifdef MFV_LOG_DEBUG +#define MFV_LOGD(...) LOG_PRI(ANDROID_LOG_DEBUG, "VDO_LOG", __VA_ARGS__); /* /< show debug information log */ +#define VDO_LOGD(...) LOG_PRI(ANDROID_LOG_DEBUG, "VDO_LOG", __VA_ARGS__); /* /< show debug information log */ +#else +#define MFV_LOGD(...) /* /< NOT show debug information log */ +#define VDO_LOGD(...) /* /< NOT show debug information log */ +#endif + +#define MFV_LOG_INFO /* /< information */ +#ifdef MFV_LOG_INFO +#define MFV_LOGI(...) LOG_PRI(ANDROID_LOG_INFO, "VDO_LOG", __VA_ARGS__); /* /< show information log */ +#define VDO_LOGI(...) LOG_PRI(ANDROID_LOG_INFO, "VDO_LOG", __VA_ARGS__); /* /< show information log */ +#else +#define MFV_LOGI(...) /* /< NOT show information log */ +#define VDO_LOGI(...) /* /< NOT show information log */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VAL_LOG_H_ */ diff --git a/kernel-headers/val_oal.h b/kernel-headers/val_oal.h new file mode 100644 index 0000000..56f7711 --- /dev/null +++ b/kernel-headers/val_oal.h @@ -0,0 +1,1419 @@ +#ifndef _SP5_OAL_H_ +#define _SP5_OAL_H_ + +/* SP5 interface */ +#include "vcodec_OAL_v2.h" + +/* ME1 interface */ +#include "val_types_private.h" + +/** + * @par Enumeration + * __VAL_OAL_TYPE + * @par Description + * This is the item used to set OAL type + */ +typedef enum ___VAL_OAL_TYPE { + _BYTE_ = 0x5000, /* /< BYTE */ + _WORD_, /* /< WORD */ + _LONG_ /* /< LONG */ +} __VAL_OAL_TYPE; + +/* /< VCodecDrvQueryMemType definition for SW/hybrid codec */ +#define SP5_VCodecQueryMemType VCodecDrvQueryMemType +/* /< VCodecDrvQueryPhysicalAddr definition for SW/hybrid codec */ +#define SP5_VCodecQueryPhysicalAddr VCodecDrvQueryPhysicalAddr +/* /< VCodecDrvSwitchMemType definition for SW/hybrid codec */ +#define SP5_VCodecSwitchMemType VCodecDrvSwitchMemType +/* /< VCodecDrvFlushCachedBuffer definition for SW/hybrid codec */ +#define SP5_VCodecFlushCachedBuffer VCodecDrvFlushCachedBuffer +/* /< VCodecDrvInvalidateCachedBuffer definition for SW/hybrid codec */ +#define SP5_VCodecInvalidateCachedBuffer VCodecDrvInvalidateCachedBuffer +/* /< VCodecDrvFlushCachedBufferAll definition for SW/hybrid codec */ +#define SP5_VCodecFlushCachedBufferAll VCodecDrvFlushCachedBufferAll +/* /< VCodecDrvInvalidateCachedBufferAll definition for SW/hybrid codec */ +#define SP5_VCodecInvalidateCachedBufferAll VCodecDrvInvalidateCachedBufferAll +/* /< VCodecDrvFlushInvalidateCacheBufferAll definition for SW/hybrid codec */ +#define SP5_VCodecFlushInvalidateCacheBufferAll VCodecDrvFlushInvalidateCacheBufferAll +/* /< VCodecDrvMemSet definition for SW/hybrid codec */ +#define SP5_VCodecMemSet VCodecDrvMemSet +/* /< VCodecDrvMemCopy definition for SW/hybrid codec */ +#define SP5_VCodecMemCopy VCodecDrvMemCopy +/* /< VCodecDrvAssertFail definition for SW/hybrid codec */ +#define SP5_VCodecAssertFail VCodecDrvAssertFail +/* /< VCodecDrvMMAP definition for SW/hybrid codec */ +#define SP5_VCodecMMAP VCodecDrvMMAP +/* /< VCodecDrvUnMMAP definition for SW/hybrid codec */ +#define SP5_VCodecUnMMAP VCodecDrvUnMMAP +/* /< VCodecDrvWaitISR definition for SW/hybrid codec */ +#define SP5_VCodecWaitISR VCodecDrvWaitISR +/* /< VCodecDrvLockHW definition for SW/hybrid codec */ +#define SP5_VCodecLockHW VCodecDrvLockHW +/* /< VCodecDrvUnLockHW definition for SW/hybrid codec */ +#define SP5_VCodecUnLockHW VCodecDrvUnLockHW +/* /< VCodecDrvInitHWLock definition for SW/hybrid codec */ +#define SP5_VCodecInitHWLock VCodecDrvInitHWLock +/* /< VCodecDrvDeInitHWLock definition for SW/hybrid codec */ +#define SP5_VCodecDeInitHWLock VCodecDrvDeInitHWLock +#if 0 +/* /< VCodecDrvTraceLog0 definition for SW/hybrid codec */ +#define SP5_VcodecTraceLog0 VCodecDrvTraceLog0 +/* /< VCodecDrvTraceLog1 definition for SW/hybrid codec */ +#define SP5_VcodecTraceLog1 VCodecDrvTraceLog1 +/* /< VCodecDrvTraceLog2 definition for SW/hybrid codec */ +#define SP5_VcodecTraceLog2 VCodecDrvTraceLog2 +/* /< VCodecDrvTraceLog4 definition for SW/hybrid codec */ +#define SP5_VcodecTraceLog4 VCodecDrvTraceLog4 +/* /< VCodecDrvTraceLog8 definition for SW/hybrid codec */ +#define SP5_VcodecTraceLog8 VCodecDrvTraceLog8 +#else +/* /< VCodecPrintf definition for SW/hybrid codec */ +#define SP5_VCodecPrintf VCodecPrintf +#endif +/* /< VCodecDrvMemAllocAligned definition for SW/hybrid codec */ +#define SP5_VdoMemAllocAligned VCodecDrvMemAllocAligned +/* /< VCodecDrvMemFree definition for SW/hybrid codec */ +#define SP5_VdoMemFree VCodecDrvMemFree +/* /< VCodecDrvIntMalloc definition for SW/hybrid codec */ +#define SP5_VdoIntMalloc VCodecDrvIntMalloc +/* /< VCodecDrvIntFree definition for SW/hybrid codec */ +#define SP5_VdoIntFree VCodecDrvIntFree +/* /< VCodecDrvRegSync definition for SW/hybrid codec */ +#define SP5_RegSync VCodecDrvRegSync +/* /< VCodecDrvRegSyncWriteB definition for SW/hybrid codec */ +#define SP5_RegSyncWriteB VCodecDrvRegSyncWriteB +/* /< VCodecDrvRegSyncWriteW definition for SW/hybrid codec */ +#define SP5_RegSyncWriteW VCodecDrvRegSyncWriteW +/* /< VCodecDrvRegSyncWriteL definition for SW/hybrid codec */ +#define SP5_RegSyncWriteL VCodecDrvRegSyncWriteL +/* /< VMPEG4EncCodecDrvWaitISR definition for SW/hybrid codec */ +#define SP5_VMPEG4EncCodecWaitISR VMPEG4EncCodecDrvWaitISR +/* /< VMPEG4EncCodecDrvLockHW definition for SW/hybrid codec */ +#define SP5_VMPEG4EncCodecLockHW VMPEG4EncCodecDrvLockHW +/* /< VMPEG4EncCodecDrvUnLockHW definition for SW/hybrid codec */ +#define SP5_VMPEG4EncCodecUnLockHW VMPEG4EncCodecDrvUnLockHW +/* /< VH264DecCodecDrvWaitISR definition for SW/hybrid codec */ +#define SP5_VH264DecCodecWaitISR VH264DecCodecDrvWaitISR +/* /< VH264DecCodecDrvLockHW definition for SW/hybrid codec */ +#define SP5_VH264DecCodecLockHW VH264DecCodecDrvLockHW +/* /< VH264DecCodecDrvUnLockHW definition for SW/hybrid codec */ +#define SP5_VH264DecCodecUnLockHW VH264DecCodecDrvUnLockHW + + +/** + * @par Function + * SP5_VCodecQueryMemType + * @par Description + * The function used to query memory type for SW/hybrid codec + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @param + * peMemType [OUT] The memory type + * @par Returns + * void + */ +void SP5_VCodecQueryMemType( + IN void *pBuffer_VA, + IN unsigned int u4Size, + OUT VCODEC_MEMORY_TYPE_T * peMemType); + + +/** + * @par Function + * SP5_VCodecQueryPhysicalAddr + * @par Description + * The function used to query physical address + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * pBufferOut_PA [OUT] The physical address + * @par Returns + * void + */ +void SP5_VCodecQueryPhysicalAddr(IN void *pBuffer_VA, + OUT void **pBufferOut_PA); + + +/** + * @par Function + * SP5_VCodecSwitchMemType + * @par Description + * The function used to switch memory type for SW/hybrid codec + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @param + * eMemType [IN] The memory type + * @param + * pBufferOut_VA [OUT] The pointer of buffer address + * @par Returns + * int, return 0 if success, return -1 if failed + */ +int SP5_VCodecSwitchMemType(IN void *pBuffer_VA, + IN unsigned int u4Size, + IN VCODEC_MEMORY_TYPE_T eMemType, + OUT void **pBufferOut_VA); + + +/** + * @par Function + * SP5_VCodecFlushCachedBuffer + * @par Description + * The function used to flush cache by size + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @par Returns + * void + */ +void SP5_VCodecFlushCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size); + + +/** + * @par Function + * SP5_VCodecInvalidateCachedBuffer + * @par Description + * The function used to invalidate cache by size + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @par Returns + * void + */ +void SP5_VCodecInvalidateCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size); + + +/** + * @par Function + * SP5_VCodecFlushCachedBufferAll + * @par Description + * The function used to flush all cache + * @par Returns + * void + */ +void SP5_VCodecFlushCachedBufferAll(void); + + +/** + * @par Function + * SP5_VCodecInvalidateCachedBufferAll + * @par Description + * The function used to invalidate all cache + * @par Returns + * void + */ +void SP5_VCodecInvalidateCachedBufferAll(void); + + +/** + * @par Function + * SP5_VCodecFlushInvalidateCacheBufferAll + * @par Description + * The function used to flush & invalidate all cache + * @par Returns + * void + */ +void SP5_VCodecFlushInvalidateCacheBufferAll(void); + + +/** + * @par Function + * SP5_VCodecMemSet + * @par Description + * The function used to memory set + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * cValue [IN] The value will be set to memory + * @param + * u4Length [IN] The length of memory will be set + * @par Returns + * void + */ +void SP5_VCodecMemSet(IN void *pBuffer_VA, + IN char cValue, + IN unsigned int u4Length); + + +/** + * @par Function + * SP5_VCodecMemCopy + * @par Description + * The function used to memory copy + * @param + * pvDest [IN] The pointer of destination memory + * @param + * pvSrc [IN] The pointer of source memory + * @param + * u4Length [IN] The length of memory will be copied + * @par Returns + * void + */ +void SP5_VCodecMemCopy(IN void *pvDest , + IN const void *pvSrc , + IN unsigned int u4Length); + + +/** + * @par Function + * SP5_VCodecAssertFail + * @par Description + * The function used to assert when occur error + * @param + * ptr [IN] The name of error source file + * @param + * i4Line [IN] The line of error source file + * @param + * i4Arg [IN] The argumnet of error source file + * @par Returns + * void + */ +void SP5_VCodecAssertFail(IN char *ptr, + IN int i4Line, + IN int i4Arg); + + +/** + * @par Function + * SP5_VCodecMMAP + * @par Description + * The function used to memory map + * @param + * prParam [IN/OUT] The structure contains memory info for memory map + * @par Returns + * void + */ +void SP5_VCodecMMAP(VCODEC_OAL_MMAP_T *prParam); + + +/** + * @par Function + * SP5_VCodecUnMMAP + * @par Description + * The function used to memory unmap + * @param + * prParam [IN/OUT] The structure contains memory info for memory unmap + * @par Returns + * void + */ +void SP5_VCodecUnMMAP(VCODEC_OAL_MMAP_T *prParam); + + +/** + * @par Function + * SP5_VCodecWaitISR + * @par Description + * The ISR usage related function, whene trigger HW, we will use to wait HW complete + * @param + * prParam [IN/OUT] The structure contains used info for ISR usage + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VCodecWaitISR(VCODEC_OAL_ISR_T *prParam); + + +/** + * @par Function + * SP5_VCodecLockHW + * @par Description + * The single/multiple instance usage function, to allow using HW + * @param + * prParam [IN/OUT] The structure contains used info for Lock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VCodecLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VCodecUnLockHW + * @par Description + * The single/multiple instance usage function, to release HW for another instance + * @param + * prParam [IN/OUT] The structure contains used info for unLock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VCodecUnLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VCodecInitHWLock + * @par Description + * The function used to init HW lock + * @param + * prParam [IN/OUT] The structure contains used info for init HW lock + * @par Returns + * void + */ +void SP5_VCodecInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + + +/** + * @par Function + * SP5_VCodecDeInitHWLock + * @par Description + * The function used to deinit HW lock + * @param + * prParam [IN/OUT] The structure contains used info for deinit HW lock + * @par Returns + * void + */ +void SP5_VCodecDeInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + + +#if 0 +/** + * @par Function + * SP5_VcodecTraceLog0 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @par Returns + * void + */ +void SP5_VcodecTraceLog0(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex + ); + + +/** + * @par Function + * SP5_VcodecTraceLog1 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg [IN] The input argument + * @par Returns + * void + */ +void SP5_VcodecTraceLog1(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg + ); + + +/** + * @par Function + * SP5_VcodecTraceLog2 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg1 [IN] The input argument1 + * @param + * arg2 [IN] The input argument2 + * @par Returns + * void + */ +void SP5_VcodecTraceLog2(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg1, + IN UINT64 arg2 + ); + + +/** + * @par Function + * SP5_VcodecTraceLog4 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg1 [IN] The input argument1 + * @param + * arg2 [IN] The input argument2 + * @param + * arg3 [IN] The input argument3 + * @param + * arg4 [IN] The input argument4 + * @par Returns + * void + */ +void SP5_VcodecTraceLog4(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg1, + IN UINT64 arg2, IN UINT64 arg3, + IN UINT64 arg4 + ); + + +/** + * @par Function + * SP5_VcodecTraceLog4 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg1 [IN] The input argument1 + * @param + * arg2 [IN] The input argument2 + * @param + * arg3 [IN] The input argument3 + * @param + * arg4 [IN] The input argument4 + * @param + * arg5 [IN] The input argument5 + * @param + * arg6 [IN] The input argument6 + * @param + * arg7 [IN] The input argument7 + * @param + * arg8 [IN] The input argument8 + * @par Returns + * void + */ +void SP5_VcodecTraceLog8(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg1, + IN UINT64 arg2, + IN UINT64 arg3, + IN UINT64 arg4, + IN UINT64 arg5, + IN UINT64 arg6, + IN UINT64 arg7, + IN UINT64 arg8 + ); +#else +/** + * @par Function + * SP5_VCodecPrintf + * @par Description + * The function used to trace log for debug + * @param + * format [IN] log string + * @param + * ... [IN] log argument + */ +VCODEC_OAL_ERROR_T SP5_VCodecPrintf(IN const char *_Format, ...); +#endif + + +/** + * @par Function + * SP5_VdoMemAllocAligned + * @par Description + * The function used to alloc external working memry + * @param + * handle [IN] codec/driver handle + * @param + * size [IN] allocated memory size + * @param + * u4AlignSize [IN] allocated memory byte alignment + * @param + * cachable [IN] memory type + * @param + * pBuf [OUT] allocated memory buffer info + * @param + * eMemCodec [IN] allocated memory used for venc/vdec + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoMemAllocAligned( + VAL_VOID_T * handle, + VAL_UINT32_T size, + unsigned int u4AlignSize, + VCODEC_MEMORY_TYPE_T cachable, + VCODEC_BUFFER_T * pBuf, + VAL_MEM_CODEC_T eMemCodec +); + + +/** + * @par Function + * SP5_VdoMemFree + * @par Description + * The function used to free external working memry + * @param + * handle [IN] codec/driver handle + * @param + * pBuf [IN] allocated memory buffer info + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoMemFree(VAL_VOID_T *handle, VCODEC_BUFFER_T *pBuf); + + +/** + * @par Function + * SP5_VdoIntMalloc + * @par Description + * The function used to alloc internal working memry + * @param + * handle [IN] codec/driver handle + * @param + * size [IN] allocated memory size + * @param + * alignedsize [IN] allocated memory byte alignment + * @param + * prBuffer_adr [OUT] allocated memory buffer info + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoIntMalloc(HANDLE handle, unsigned int size, unsigned int alignedsize, VCODEC_BUFFER_T *prBuffer_adr); + + +/** + * @par Function + * SP5_VdoIntFree + * @par Description + * The function used to free internal working memry + * @param + * handle [IN] codec/driver handle + * @param + * prBuffer_adr [IN] allocated memory buffer info + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoIntFree(HANDLE handle, VCODEC_BUFFER_T *prBuffer_adr); + + +/** + * @par Function + * SP5_RegSync + * @par Description + * The function used to set register sync + * @param + * type [IN] BYTE/WORD/LONG + * @param + * v [IN] register value + * @param + * a [IN] register address + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_RegSync(int type, unsigned int v, unsigned int a); + + +/** + * @par Function + * SP5_VMPEG4EncCodecWaitISR + * @par Description + * The ISR usage related function, whene trigger HW, we will use to wait HW complete + * @param + * prParam [IN/OUT] The structure contains used info for ISR usage + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VMPEG4EncCodecWaitISR(VCODEC_OAL_ISR_T *prParam); + + +/** + * @par Function + * SP5_VMPEG4EncCodecLockHW + * @par Description + * The single/multiple instance usage function, to allow using HW + * @param + * prParam [IN/OUT] The structure contains used info for Lock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VMPEG4EncCodecLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VMPEG4EncCodecUnLockHW + * @par Description + * The single/multiple instance usage function, to release HW for another instance + * @param + * prParam [IN/OUT] The structure contains used info for unLock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VMPEG4EncCodecUnLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VH264DecCodecWaitISR + * @par Description + * The ISR usage related function, whene trigger HW, we will use to wait HW complete + * @param + * prParam [IN/OUT] The structure contains used info for ISR usage + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VH264DecCodecWaitISR(VCODEC_OAL_ISR_T *prParam); + + +/** + * @par Function + * SP5_VH264DecCodecLockHW + * @par Description + * The single/multiple instance usage function, to allow using HW + * @param + * prParam [IN/OUT] The structure contains used info for Lock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VH264DecCodecLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VH264DecCodecUnLockHW + * @par Description + * The single/multiple instance usage function, to release HW for another instance + * @param + * prParam [IN/OUT] The structure contains used info for unLock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VH264DecCodecUnLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * eValInit + * @par Description + * The init driver function + * @param + * a_phHalHandle [IN/OUT] The codec/driver handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_RESULT_T eValInit(VAL_HANDLE_T *a_phHalHandle); + + +/** + * @par Function + * eValDeInit + * @par Description + * The deinit driver function + * @param + * a_phHalHandle [IN/OUT] The codec/driver handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_RESULT_T eValDeInit(VAL_HANDLE_T *a_phHalHandle); + + +/** + * @par Function + * VCodecDrvCheck_Version + * @par Description + * The function used to check codec library version + * @param + * version [IN/OUT] The codec library version + * @par Returns + * int, return 0 if success, return -1 if failed + */ +int VCodecDrvCheck_Version(int version); + +/************ Multi-thread function ***********/ + +/***** Thread Management Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_attr_init + * @par Description + * The pthread_attr_init wrapper function + * @param + * attr [OUT] attr + * @par Returns + * int, pthread_attr_init((pthread_attr_t *)attr); + */ +int VCodecDrvPthread_attr_init(OUT VCODEC_PTHREAD_ATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_attr_destroy + * @par Description + * The pthread_attr_destroy wrapper function + * @param + * attr [IN] attr + * @par Returns + * int, pthread_attr_destroy((pthread_attr_t *)attr); + */ +int VCodecDrvPthread_attr_destroy(IN VCODEC_PTHREAD_ATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_attr_getdetachstate + * @par Description + * The pthread_attr_getdetachstate wrapper function + * @param + * attr [IN] attr + * @param + * detachstate [OUT] detachstate + * @par Returns + * int, pthread_attr_getdetachstate((pthread_attr_t const *)attr, detachstate); + */ +int VCodecDrvPthread_attr_getdetachstate(IN const VCODEC_PTHREAD_ATTR_T * attr, OUT int *detachstate); + + +/** + * @par Function + * VCodecDrvPthread_attr_getdetachstate + * @par Description + * The pthread_attr_getdetachstate wrapper function + * @param + * attr [IN] attr + * @param + * detachstate [OUT] detachstate + * @par Returns + * int, pthread_attr_getdetachstate((pthread_attr_t const *)attr, detachstate); + */ +int VCodecDrvPthread_attr_setdetachstate(IN VCODEC_PTHREAD_ATTR_T * attr, IN int detachstate); + + +/** + * @par Function + * VCodecDrvPthread_create + * @par Description + * The pthread_create wrapper function + * @param + * thread [OUT] thread + * @param + * attr [IN] attr + * @param + * start_routine [IN] start_routine + * @param + * arg [IN] arg + * @par Returns + * int, pthread_create((pthread_t *)thread, (pthread_attr_t const *)attr, start_routine, arg); + */ +int VCodecDrvPthread_create( + OUT VCODEC_PTHREAD_T * thread, + IN const VCODEC_PTHREAD_ATTR_T * attr, + IN void * (*start_routine)(void *), + IN void *arg +); + + +/** + * @par Function + * VCodecDrvPthread_kill + * @par Description + * The pthread_kill wrapper function + * @param + * tid [IN] tid + * @param + * sig [IN] sig + * @par Returns + * int, pthread_kill((pthread_t)tid, SIGUSR1); + */ +int VCodecDrvPthread_kill(IN VCODEC_PTHREAD_T tid, IN int sig); + + +/** + * @par Function + * VCodecDrvPthread_exit + * @par Description + * The pthread_exit wrapper function + * @param + * retval [OUT] retval + * @par Returns + * void + */ +void VCodecDrvPthread_exit(OUT void *retval); + + +/** + * @par Function + * VCodecDrvPthread_join + * @par Description + * The pthread_join wrapper function + * @param + * thid [IN] thid + * @param + * ret_val [OUT] ret_val + * @par Returns + * int, pthread_join((pthread_t)thid, ret_val); + */ +int VCodecDrvPthread_join(IN VCODEC_PTHREAD_T thid, OUT void **ret_val); + +/* int VCodecDrvPthread_detach(IN VCODEC_PTHREAD_T thid); */ + + +/** + * @par Function + * VCodecDrvPthread_once + * @par Description + * The pthread_once wrapper function + * @param + * once_control [IN] once_control + * @param + * init_routine [IN] init_routine + * @par Returns + * int, pthread_once((pthread_once_t *)once_control, init_routine); + */ +int VCodecDrvPthread_once(IN VCODEC_PTHREAD_ONCE_T * once_control, IN void (*init_routine)(void)); + + +/** + * @par Function + * VCodecDrvPthread_self + * @par Description + * The pthread_self wrapper function + * @par Returns + * VCODEC_PTHREAD_T, (VCODEC_PTHREAD_T)pthread_self() + */ +VCODEC_PTHREAD_T VCodecDrvPthread_self(void); + +/* VCODEC_OAL_ERROR_T VCodecDrvPthread_equal(IN VCODEC_PTHREAD_T one,IN VCODEC_PTHREAD_T two); */ + +/***** Mutex Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_mutexattr_init + * @par Description + * The pthread_mutexattr_init wrapper function + * @param + * attr [OUT] attr + * @par Returns + * int, pthread_mutexattr_init((pthread_mutexattr_t *)attr); + */ +int VCodecDrvPthread_mutexattr_init(OUT VCODEC_PTHREAD_MUTEXATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_mutexattr_destroy + * @par Description + * The pthread_mutexattr_destroy wrapper function + * @param + * attr [IN] attr + * @par Returns + * int, pthread_mutexattr_destroy((pthread_mutexattr_t *)attr); + */ +int VCodecDrvPthread_mutexattr_destroy(IN VCODEC_PTHREAD_MUTEXATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_mutex_init + * @par Description + * The pthread_mutex_init wrapper function + * @param + * mutex [OUT] mutex + * @param + * attr [IN] attr + * @par Returns + * int, pthread_mutex_init((pthread_mutex_t *)mutex, (const pthread_mutexattr_t *)attr); + */ +int VCodecDrvPthread_mutex_init(OUT VCODEC_PTHREAD_MUTEX_T * mutex, IN const VCODEC_PTHREAD_MUTEXATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_mutex_destroy + * @par Description + * The pthread_mutex_destroy wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_destroy((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_destroy(IN VCODEC_PTHREAD_MUTEX_T * mutex); + + +/** + * @par Function + * VCodecDrvPthread_mutex_lock + * @par Description + * The pthread_mutex_lock wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_lock((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_lock(IN VCODEC_PTHREAD_MUTEX_T * mutex); + + +/** + * @par Function + * VCodecDrvPthread_mutex_unlock + * @par Description + * The pthread_mutex_unlock wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_unlock((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_unlock(IN VCODEC_PTHREAD_MUTEX_T * mutex); + + +/** + * @par Function + * VCodecDrvPthread_mutex_trylock + * @par Description + * The pthread_mutex_trylock wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_trylock((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_trylock(IN VCODEC_PTHREAD_MUTEX_T * mutex); + +/***** Spin Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_spin_init + * @par Description + * The pthread_spin_init wrapper function + * @param + * lock [OUT] lock + * @param + * pshared [IN] pshared + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_init(OUT VCODEC_PTHREAD_SPINLOCK_T * lock, IN int pshared); + + +/** + * @par Function + * VCodecDrvPthread_spin_destroy + * @par Description + * The pthread_spin_destroy wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_destroy(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + + +/** + * @par Function + * VCodecDrvPthread_spin_lock + * @par Description + * The pthread_spin_lock wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_lock(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + + +/** + * @par Function + * VCodecDrvPthread_spin_trylock + * @par Description + * The pthread_spin_trylock wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_trylock(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + + +/** + * @par Function + * VCodecDrvPthread_spin_unlock + * @par Description + * The pthread_spin_unlock wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_unlock(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + +/***** Condition Variable Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_condattr_init + * @par Description + * The pthread_condattr_init wrapper function + * @param + * attr [OUT] attr + * @par Returns + * int, pthread_condattr_init((pthread_condattr_t *)attr); + */ +int VCodecDrvPthread_condattr_init(OUT VCODEC_PTHREAD_CONDATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_condattr_destroy + * @par Description + * The pthread_condattr_destroy wrapper function + * @param + * attr [IN] attr + * @par Returns + * int, pthread_condattr_destroy((pthread_condattr_t *)attr); + */ +int VCodecDrvPthread_condattr_destroy(IN VCODEC_PTHREAD_CONDATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_cond_init + * @par Description + * The pthread_cond_init wrapper function + * @param + * cond [OUT] cond + * @param + * attr [IN] attr + * @par Returns + * int, pthread_cond_init((pthread_cond_t *)cond, (const pthread_condattr_t *)attr); + */ +int VCodecDrvPthread_cond_init(OUT VCODEC_PTHREAD_COND_T * cond, IN const VCODEC_PTHREAD_CONDATTR_T * attr); + + +/** + * @par Function + * VCodecDrvPthread_cond_destroy + * @par Description + * The pthread_cond_destroy wrapper function + * @param + * cond [IN] cond + * @par Returns + * int, pthread_cond_destroy((pthread_cond_t *)cond); + */ +int VCodecDrvPthread_cond_destroy(IN VCODEC_PTHREAD_COND_T * cond); + + +/** + * @par Function + * VCodecDrvPthread_cond_broadcast + * @par Description + * The pthread_cond_broadcast wrapper function + * @param + * cond [IN] cond + * @par Returns + * int, pthread_cond_broadcast((pthread_cond_t *)cond); + */ +int VCodecDrvPthread_cond_broadcast(IN VCODEC_PTHREAD_COND_T * cond); + + +/** + * @par Function + * VCodecDrvPthread_cond_signal + * @par Description + * The pthread_cond_signal wrapper function + * @param + * cond [IN] cond + * @par Returns + * int, pthread_cond_signal((pthread_cond_t *)cond); + */ +int VCodecDrvPthread_cond_signal(IN VCODEC_PTHREAD_COND_T * cond); + + +/** + * @par Function + * VCodecDrvPthread_cond_signal + * @par Description + * The pthread_cond_wait wrapper function + * @param + * cond [IN] cond + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_cond_wait((pthread_cond_t *)cond, (pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_cond_wait(IN VCODEC_PTHREAD_COND_T * cond, IN VCODEC_PTHREAD_MUTEX_T * mutex); + +/************ End of Multi-thread function ***********/ + +/***** Semaphore Functions ******/ + + +/** + * @par Function + * VCodecDrv_sem_init + * @par Description + * The sem_init wrapper function + * @param + * sem [IN] sem + * @param + * pshared [IN] pshared + * @param + * value [IN] value + * @par Returns + * int, sem_init((sem_t*)sem, pshared, value); + */ +int VCodecDrv_sem_init(IN VCODEC_OAL_SEM_T * sem, IN int pshared, IN unsigned int value); + + +/** + * @par Function + * VCodecDrv_sem_destroy + * @par Description + * The sem_destroy wrapper function + * @param + * sem [IN] sem + * @par Returns + * int, sem_destroy((sem_t*)sem); + */ +int VCodecDrv_sem_destroy(IN VCODEC_OAL_SEM_T * sem); + + +/** + * @par Function + * VCodecDrv_sem_post + * @par Description + * The sem_post wrapper function + * @param + * sem [IN] sem + * @par Returns + * int, sem_post((sem_t*)sem); + */ +int VCodecDrv_sem_post(IN VCODEC_OAL_SEM_T * sem); + + +/** + * @par Function + * VCodecDrv_sem_wait + * @par Description + * The sem_wait wrapper function + * @param + * sem [IN] sem + * @par Returns + * int, sem_wait((sem_t*)sem); + */ +int VCodecDrv_sem_wait(IN VCODEC_OAL_SEM_T * sem); + +/***** Binding Functions ******/ + + +/** + * @par Function + * VCodecDrvBindingCore + * @par Description + * The function used to set given thread to binding specific CPU Core + * @param + * ThreadHandle [IN] given thread + * @param + * u4Mask [IN] specific CPU Core + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvBindingCore(IN VCODEC_PTHREAD_T ThreadHandle, IN unsigned int u4Mask); + + +/** + * @par Function + * VCodecDrvDeBindingCore + * @par Description + * The function used to set given thread to debinding specific CPU Core + * @param + * ThreadHandle [IN] given thread + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvDeBindingCore(IN VCODEC_PTHREAD_T ThreadHandle); + + +/** + * @par Function + * VCodecDrvGetAffinity + * @par Description + * The function used to set given thread to get specific CPU Core affinity + * @param + * ThreadHandle [IN] given thread + * @param + * pu4Mask [OUT] CPU mask + * @param + * pu4SetMask [OUT] Set CPU mask + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvGetAffinity( + IN VCODEC_PTHREAD_T ThreadHandle, + OUT unsigned int *pu4Mask, + OUT unsigned int *pu4SetMask +); + + +/** + * @par Function + * VCodecDrvGetAffinity + * @par Description + * The function used to get specific CPU Core loading + * @param + * s4CPUid [IN] COU id + * @param + * ps4Loading [OUT] CPU loading + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvCoreLoading(IN int s4CPUid, OUT int *ps4Loading); + + +/** + * @par Function + * VCodecDrvGetAffinity + * @par Description + * The function used to get total CPU Core number + * @param + * ps4CPUNums [OUT] CPU number + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvCoreNumber(OUT int *ps4CPUNums); + + +/** + * @par Function + * VCodecDrvSleep + * @par Description + * The function used to sleep a while + * @param + * u4Tick [IN] unit: us + * @par Returns + * void + */ +void VCodecDrvSleep(IN unsigned int u4Tick); + + +/** + * @par Function + * OAL_SMP_BindingCore + * @par Description + * The function used to set given thread to binding specific CPU Core (only for test) + * @param + * aCurrentTid [IN] given thread id + * @param + * aCPUid [IN] specific CPU Core + * @par Returns + * int, return 0 if success, return -1 if failed + */ +int OAL_SMP_BindingCore(int aCurrentTid, int aCPUid); /* ONLY used for TEST in main.c */ + +/***** MCI Functions ******/ + + +/** + * @par Function + * VCodecConfigMCIPort + * @par Description + * The function used to config MCI port + * @param + * u4PortConfig [IN] port config + * @param + * pu4PortResult [OUT] port result + * @param + * eCodecType [OUT] VDEC or VENC + * @par Returns + * VCODEC_OAL_ERROR_T, + * return VCODEC_OAL_ERROR_NONE if success, + * return VCODEC_OAL_ERROR_ERROR or VAL_RESULT_UNKNOWN_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecConfigMCIPort( + IN unsigned int u4PortConfig, + OUT unsigned int *pu4PortResult, + IN VCODEC_CODEC_TYPE_T eCodecType +); + + +/***** Software vdec lib Functions ******/ + + +/** + * @par Function + * VCodecDrvMemAllocAligned_NC + * @par Description + * The function used to alloc external working memry for non-cacheable + * @param + * hDrv [IN] codec/driver handle + * @param + * u4Size [IN] allocated memory size + * @param + * u4AlignSize [IN] allocated memory byte alignment + * @param + * fgCacheable [IN] memory type + * @param + * prBuf [OUT] allocated memory buffer info + * @par Returns + * void + */ +void VCodecDrvMemAllocAligned_NC( + IN HANDLE hDrv, + IN unsigned int u4Size, + unsigned int u4AlignSize, + IN VCODEC_MEMORY_TYPE_T fgCacheable, + OUT VCODEC_BUFFER_T *prBuf +); + + +/** + * @par Function + * VCodecDrvMemFree_NC + * @par Description + * The function used to free external working memry + * @param + * hDrv [IN] codec/driver handle + * @param + * prBuf [IN] allocated memory buffer info + * @par Returns + * void + */ +void VCodecDrvMemFree_NC(IN HANDLE hDrv, IN VCODEC_BUFFER_T *prBuf); + + +/** + * @par Function + * VDecCodecQueryInfo + * @par Description + * The function used to query info + * @param + * hDrv [IN] codec/driver handle + * @param + * ID [IN] query info type + * @param + * pvQueryData [OUT] query data + * @par Returns + * void + */ +VCODEC_DEC_ERROR_T VDecCodecQueryInfo(IN HANDLE hDrv, IN VCODEC_DEC_QUERY_INFO_TYPE_T ID, OUT void *pvQueryData); +#if 0 +/* MACRO */ + +#include "mach/sync_write.h" + +#define SP5_REGSYNC_WriteB(v, a) \ + mt65xx_reg_sync_writeb(v, a); + +#define SP5_REGSYNC_WriteW(v, a) \ + mt65xx_reg_sync_writew(v, a); + +#define SP5_REGSYNC_WriteL(v, a) \ + mt65xx_reg_sync_writel(v, a); + + +VAL_VOID_T SP5_RegSyncWriteB(VAL_UINT32_T v, VAL_UINT32_T a); +VAL_VOID_T SP5_RegSyncWriteW(VAL_UINT32_T v, VAL_UINT32_T a); +VAL_VOID_T SP5_RegSyncWriteL(VAL_UINT32_T v, VAL_UINT32_T a); +#endif +#endif diff --git a/kernel-headers/val_types_private.h b/kernel-headers/val_types_private.h new file mode 100644 index 0000000..0675703 --- /dev/null +++ b/kernel-headers/val_types_private.h @@ -0,0 +1,235 @@ +#ifndef _VAL_TYPES_PRIVATE_H_ +#define _VAL_TYPES_PRIVATE_H_ + +#include "val_types_public.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* #define __EARLY_PORTING__ */ + +#define OALMEM_STATUS_NUM 16 + +/** + * @par Enumeration + * VAL_HW_COMPLETE_T + * @par Description + * This is polling or interrupt for waiting for HW done + */ +typedef enum _VAL_HW_COMPLETE_T { + VAL_POLLING_MODE = 0, /* /< polling */ + VAL_INTERRUPT_MODE, /* /< interrupt */ + VAL_MODE_MAX = 0xFFFFFFFF /* /< Max result */ +} +VAL_HW_COMPLETE_T; + + +/** + * @par Enumeration + * VAL_CODEC_TYPE_T + * @par Description + * This is the item in VAL_OBJECT_T for open driver type and + * in VAL_CLOCK_T for clock setting and + * in VAL_ISR_T for irq line setting + */ +typedef enum _VAL_CODEC_TYPE_T { + VAL_CODEC_TYPE_NONE = 0, /* /< None */ + VAL_CODEC_TYPE_MP4_ENC, /* /< MP4 encoder */ + VAL_CODEC_TYPE_MP4_DEC, /* /< MP4 decoder */ + VAL_CODEC_TYPE_H263_ENC, /* /< H.263 encoder */ + VAL_CODEC_TYPE_H263_DEC, /* /< H.263 decoder */ + VAL_CODEC_TYPE_H264_ENC, /* /< H.264 encoder */ + VAL_CODEC_TYPE_H264_DEC, /* /< H.264 decoder */ + VAL_CODEC_TYPE_SORENSON_SPARK_DEC, /* /< Sorenson Spark decoder */ + VAL_CODEC_TYPE_VC1_SP_DEC, /* /< VC-1 simple profile decoder */ + VAL_CODEC_TYPE_RV9_DEC, /* /< RV9 decoder */ + VAL_CODEC_TYPE_MP1_MP2_DEC, /* /< MPEG1/2 decoder */ + VAL_CODEC_TYPE_XVID_DEC, /* /< Xvid decoder */ + VAL_CODEC_TYPE_DIVX4_DIVX5_DEC, /* /< Divx4/5 decoder */ + VAL_CODEC_TYPE_VC1_MP_WMV9_DEC, /* /< VC-1 main profile (WMV9) decoder */ + VAL_CODEC_TYPE_RV8_DEC, /* /< RV8 decoder */ + VAL_CODEC_TYPE_WMV7_DEC, /* /< WMV7 decoder */ + VAL_CODEC_TYPE_WMV8_DEC, /* /< WMV8 decoder */ + VAL_CODEC_TYPE_AVS_DEC, /* /< AVS decoder */ + VAL_CODEC_TYPE_DIVX_3_11_DEC, /* /< Divx3.11 decoder */ + VAL_CODEC_TYPE_H264_DEC_MAIN, /* /< H.264 main profile decoder (due to different packet) == 20 */ + VAL_CODEC_TYPE_MAX = 0xFFFFFFFF /* /< Max driver type */ +} VAL_CODEC_TYPE_T; + + +typedef enum _VAL_CACHE_TYPE_T { + + VAL_CACHE_TYPE_CACHABLE = 0, + VAL_CACHE_TYPE_NONCACHABLE, + VAL_CACHE_TYPE_MAX = 0xFFFFFFFF + +} VAL_CACHE_TYPE_T; + + +/** + * @par Structure + * VAL_INTMEM_T + * @par Description + * This is a parameter for eVideoIntMemUsed() + */ +typedef struct _VAL_INTMEM_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_UINT32_T u4MemSize; /* /< [OUT] The size of internal memory */ + VAL_VOID_T *pvMemVa; /* /< [OUT] The internal memory start virtual address */ + VAL_VOID_T *pvMemPa; /* /< [OUT] The internal memory start physical address */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} VAL_INTMEM_T; + + +/** + * @par Structure + * VAL_EVENT_T + * @par Description + * This is a parameter for eVideoWaitEvent() and eVideoSetEvent() + */ +typedef struct _VAL_EVENT_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_VOID_T *pvWaitQueue; /* /< [IN] The waitqueue discription */ + VAL_VOID_T *pvEvent; /* /< [IN] The event discription */ + VAL_UINT32_T u4TimeoutMs; /* /< [IN] The timeout ms */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} VAL_EVENT_T; + + +/** + * @par Structure + * VAL_MUTEX_T + * @par Description + * This is a parameter for eVideoWaitMutex() and eVideoReleaseMutex() + */ +typedef struct _VAL_MUTEX_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_VOID_T *pvMutex; /* /< [IN] The Mutex discriptor */ + VAL_UINT32_T u4TimeoutMs; /* /< [IN] The timeout ms */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} VAL_MUTEX_T; + + +/** + * @par Structure + * VAL_POWER_T + * @par Description + * This is a parameter for eVideoHwPowerCtrl() + */ +typedef struct _VAL_POWER_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_DRIVER_TYPE_T eDriverType; /* /< [IN] The driver type */ + VAL_BOOL_T fgEnable; /* /< [IN] Enable or not. */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ + /* VAL_UINT32_T u4L2CUser; ///< [OUT] The number of power user right now */ +} VAL_POWER_T; + + +/** + * @par Structure + * VAL_MMAP_T + * @par Description + * This is a parameter for eVideoMMAP() and eVideoUNMAP() + */ +typedef struct _VAL_MMAP_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_VOID_T *pvMemPa; /* /< [IN] The physical memory address */ + VAL_UINT32_T u4MemSize; /* /< [IN] The memory size */ + VAL_VOID_T *pvMemVa; /* /< [IN] The mapped virtual memory address */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} VAL_MMAP_T; + + +typedef struct { + VAL_ULONG_T u4ReadAddr; /* / [IN] memory source address in VA */ + VAL_UINT32_T u4ReadData; /* / [OUT] memory data */ +} VAL_VCODEC_OAL_MEM_STAUTS_T; + + +typedef struct { + /* + /< [IN/OUT] HW is Completed or not, set by driver & clear by codec + (0: not completed or still in lock status; + 1: HW is completed or in unlock status) + */ + VAL_UINT32_T u4HWIsCompleted; + /* + /< [OUT] HW is Timeout or not, set by driver & clear by codec + (0: not in timeout status; + 1: HW is in timeout status) + */ + VAL_UINT32_T u4HWIsTimeout; + VAL_UINT32_T u4NumOfRegister; /* /< [IN] Number of HW register need to store; */ + VAL_VCODEC_OAL_MEM_STAUTS_T *pHWStatus; +} VAL_VCODEC_OAL_HW_REGISTER_T; + + +typedef struct { + VAL_VCODEC_OAL_HW_REGISTER_T *Oal_HW_reg; + VAL_UINT32_T *Oal_HW_mem_reg; + VAL_UINT32_T *kva_Oal_HW_mem_reg; + VAL_ULONG_T pa_Oal_HW_mem_reg; + VAL_ULONG_T ObjId; + VAL_EVENT_T IsrEvent; + VAL_UINT32_T slotindex; + VAL_UINT32_T u4VCodecThreadNum; + VAL_UINT32_T u4VCodecThreadID[VCODEC_THREAD_MAX_NUM]; + VAL_HANDLE_T pvHandle; /* physical address of the owner handle */ + VAL_UINT32_T u4NumOfRegister; + /* MAX 16 items could be read; //kernel space access register */ + VAL_VCODEC_OAL_MEM_STAUTS_T oalmem_status[OALMEM_STATUS_NUM]; + VAL_ULONG_T kva_u4HWIsCompleted; + VAL_ULONG_T kva_u4HWIsTimeout; + VAL_UINT32_T tid1; + VAL_UINT32_T tid2; + + /* record VA, PA */ + VAL_UINT32_T *va1; + VAL_UINT32_T *va2; + VAL_UINT32_T *va3; + VAL_UINT32_T pa1; + VAL_UINT32_T pa2; + VAL_UINT32_T pa3; + +} VAL_VCODEC_OAL_HW_CONTEXT_T; + + +typedef struct { + int CPUid; /* [in] */ + int Loading; /* [out] */ +} VAL_VCODEC_CORE_LOADING_T; + +typedef void (*ena)(int); +typedef void (*disa)(int); +typedef void (*ena_timeout)(int, int); +typedef int (*user_reg)(int, int); +typedef void (*user_unreg)(int); +typedef void (*user_enable)(int); +typedef void (*user_disable)(int); +typedef void (*user_enable_timeout)(int, int); +typedef int (*user_reg_scn)(void); +typedef void (*user_reg_scn_config)(int, int, int, int, int, int); +typedef void (*user_unreg_scn)(int); + + + +typedef struct _VAL_INIT_HANDLE { + int i4DriverType; + int i4VENCLivePhoto; +} VAL_INIT_HANDLE; +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VAL_TYPES_PRIVATE_H_ */ diff --git a/kernel-headers/val_types_public.h b/kernel-headers/val_types_public.h new file mode 100644 index 0000000..ed407ac --- /dev/null +++ b/kernel-headers/val_types_public.h @@ -0,0 +1,581 @@ +#ifndef _VAL_TYPES_PUBLIC_H_ +#define _VAL_TYPES_PUBLIC_H_ + +#include <sys/types.h> +#include <linux/ion.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define IRQ_STATUS_MAX_NUM 16 /* /< support max 16 return register values when HW done */ + +#define VCODEC_THREAD_MAX_NUM 16 /* /< support max 16 multiple thread currently */ + +/*============================================================================= + * Type definition + *===========================================================================*/ + +typedef void VAL_VOID_T; /* /< void type definition */ +typedef char VAL_BOOL_T; /* /< char type definition */ +typedef char VAL_CHAR_T; /* /< char type definition */ +typedef signed char VAL_INT8_T; /* /< signed char type definition */ +typedef signed short VAL_INT16_T; /* /< signed short type definition */ +typedef signed int VAL_INT32_T; /* /< signed int type definition */ +typedef unsigned char VAL_UCHAR_T; /* /< unsigned char type definition */ +typedef unsigned char VAL_UINT8_T; /* /< unsigned char type definition */ +typedef unsigned short VAL_UINT16_T; /* /< unsigned short definition */ +typedef unsigned int VAL_UINT32_T; /* /< unsigned int type definition */ +typedef unsigned long long VAL_UINT64_T; /* /< unsigned long long type definition */ +typedef long long VAL_INT64_T; /* /< long long type definition */ +typedef unsigned long VAL_HANDLE_T; /* /< unsigned int (handle) type definition */ +typedef signed long VAL_LONG_T; /* / */ +typedef unsigned long VAL_ULONG_T; /* / */ + +#define VAL_NULL (0) /* /< VAL_NULL = 0 */ +#define VAL_TRUE (1) /* /< VAL_TRUE = 1 */ +#define VAL_FALSE (0) /* /< VAL_FALSE = 0 */ + +/* /< VAL_RESOLUTION_CHANGED = 2, used to video resolution changed during playback */ +#define VAL_RESOLUTION_CHANGED (2) + +/** + * @par Enumeration + * VAL_MEM_CODEC_T + * @par Description + * This is the item used to memory usage for video encoder or video decoder + */ +typedef enum _VAL_MEM_CODEC_T { + VAL_MEM_CODEC_FOR_VENC = 0, /* /< Memory for Video Encoder */ + VAL_MEM_CODEC_FOR_VDEC, /* /< Memory for Video Decoder */ + VAL_MEM_CODEC_MAX = 0xFFFFFFFF /* /< Max Value */ +} VAL_MEM_CODEC_T; + + +/** + * @par Enumeration + * VAL_CHIP_NAME_T + * @par Description + * This is the item for query chip name for HAL interface + */ +typedef enum _VAL_CHIP_NAME_T { + VAL_CHIP_NAME_MT6516 = 0, /* /< MT6516 */ + VAL_CHIP_NAME_MT6571, /* /< MT6571 */ + VAL_CHIP_NAME_MT6572, /* /< MT6572 */ + VAL_CHIP_NAME_MT6573, /* /< MT6573 */ + VAL_CHIP_NAME_MT6575, /* /< MT6575 */ + VAL_CHIP_NAME_MT6577, /* /< MT6577 */ + VAL_CHIP_NAME_MT6589, /* /< MT6589 */ + VAL_CHIP_NAME_MT6582, /* /< MT6582 */ + VAL_CHIP_NAME_MT8135, /* /< MT8135 */ + VAL_CHIP_NAME_ROME, /* /< ROME */ + VAL_CHIP_NAME_MT6592, /* /< MT6592 */ + VAL_CHIP_NAME_MT8127, /* /< MT8127 */ + VAL_CHIP_NAME_MT6752, /* /< MT6752 */ + VAL_CHIP_NAME_MT6795, /* /< MT6795 */ + VAL_CHIP_NAME_DENALI_1, /* /< Denali-1 */ + VAL_CHIP_NAME_DENALI_2, /* /< Denali-2 */ + VAL_CHIP_NAME_DENALI_3, /* /< Denali-3 */ + VAL_CHIP_NAME_MT6570, /* /< Rainier (2 core) */ + VAL_CHIP_NAME_MT6580, /* /< Rainier (4 core) */ + VAL_CHIP_NAME_MT8163, + VAL_CHIP_NAME_MT8173, /* / <8173 */ + VAL_CHIP_NAME_MT6755, /* / <Jade */ + VAL_CHIP_NAME_MT6797, /* / <Everest */ + VAL_CHIP_NAME_MAX = 0xFFFFFFFF /* /< Max Value */ +} VAL_CHIP_NAME_T; + +/** + * @par Enumeration + * VAL_CHIP_VARIANT_T + * @par Description + * This is the item for query chip variant for HAL interface + */ +typedef enum _VAL_CHIP_VARIANT_T { + VAL_CHIP_VARIANT_MT6571L = 0, /* /< MT6571L */ + VAL_CHIP_VARIANT_MAX = 0xFFFFFFFF /* /< Max Value */ +} VAL_CHIP_VARIANT_T; + + +/** + * @par Enumeration + * VAL_CHIP_VERSION_T + * @par Description + * This is the item used to GetChipVersionAPI() + */ +typedef enum _VAL_CHIP_VERSION_T { + /* /< The data will be "6595" for 6595 series; "6795" for 6795 series, ... */ + VAL_CHIP_VERSION_HW_CODE = 0, + /* /< The data will be "0000" for E1; "0001" for E2, ... */ + VAL_CHIP_VERSION_SW_VER, + /* /< Max Value */ + VAL_CHIP_VERSION_MAX = 0xFFFFFFFF +} VAL_CHIP_VERSION_T; + + +/** + * @par Enumeration + * VAL_DRIVER_TYPE_T + * @par Description + * This is the item for driver type + */ +typedef enum _VAL_DRIVER_TYPE_T { + VAL_DRIVER_TYPE_NONE = 0, /* /< None */ + VAL_DRIVER_TYPE_MP4_ENC, /* /< MP4 encoder */ + VAL_DRIVER_TYPE_MP4_DEC, /* /< MP4 decoder */ + VAL_DRIVER_TYPE_H263_ENC, /* /< H.263 encoder */ + VAL_DRIVER_TYPE_H263_DEC, /* /< H.263 decoder */ + VAL_DRIVER_TYPE_H264_ENC, /* /< H.264 encoder */ + VAL_DRIVER_TYPE_H264_DEC, /* /< H.264 decoder */ + VAL_DRIVER_TYPE_SORENSON_SPARK_DEC, /* /< Sorenson Spark decoder */ + VAL_DRIVER_TYPE_VC1_SP_DEC, /* /< VC-1 simple profile decoder */ + VAL_DRIVER_TYPE_RV9_DEC, /* /< RV9 decoder */ + VAL_DRIVER_TYPE_MP1_MP2_DEC, /* /< MPEG1/2 decoder */ + VAL_DRIVER_TYPE_XVID_DEC, /* /< Xvid decoder */ + VAL_DRIVER_TYPE_DIVX4_DIVX5_DEC, /* /< Divx4/5 decoder */ + VAL_DRIVER_TYPE_VC1_MP_WMV9_DEC, /* /< VC-1 main profile (WMV9) decoder */ + VAL_DRIVER_TYPE_RV8_DEC, /* /< RV8 decoder */ + VAL_DRIVER_TYPE_WMV7_DEC, /* /< WMV7 decoder */ + VAL_DRIVER_TYPE_WMV8_DEC, /* /< WMV8 decoder */ + VAL_DRIVER_TYPE_AVS_DEC, /* /< AVS decoder */ + VAL_DRIVER_TYPE_DIVX_3_11_DEC, /* /< Divx3.11 decoder */ + VAL_DRIVER_TYPE_H264_DEC_MAIN, /* /< H.264 main profile decoder (due to different packet) == 20 */ + /* /< H.264 main profile decoder for CABAC type but packet is the same, just for reload. */ + VAL_DRIVER_TYPE_H264_DEC_MAIN_CABAC, + VAL_DRIVER_TYPE_VP8_DEC, /* /< VP8 decoder */ + VAL_DRIVER_TYPE_MP2_DEC, /* /< MPEG2 decoder */ + VAL_DRIVER_TYPE_VP9_DEC, /* /< VP9 decoder */ + VAL_DRIVER_TYPE_VP8_ENC, /* /< VP8 encoder */ + VAL_DRIVER_TYPE_VC1_ADV_DEC, /* /< VC1 advance decoder */ + VAL_DRIVER_TYPE_VC1_DEC, /* /< VC1 simple/main/advance decoder */ + VAL_DRIVER_TYPE_JPEG_ENC, /* /< JPEG encoder */ + VAL_DRIVER_TYPE_HEVC_ENC, /* /< HEVC encoder */ + VAL_DRIVER_TYPE_HEVC_DEC, /* /< HEVC decoder */ + VAL_DRIVER_TYPE_H264_ENC_LIVEPHOTO, /* LivePhoto type */ + VAL_DRIVER_TYPE_MAX = 0xFFFFFFFF /* /< Max driver type */ +} VAL_DRIVER_TYPE_T; + + +/** + * @par Enumeration + * VAL_RESULT_T + * @par Description + * This is the return status of each OSAL function + */ +typedef enum _VAL_RESULT_T { + VAL_RESULT_NO_ERROR = 0, /* /< The function work successfully */ + VAL_RESULT_INVALID_DRIVER, /* /< Error due to invalid driver */ + VAL_RESULT_INVALID_PARAMETER, /* /< Error due to invalid parameter */ + VAL_RESULT_INVALID_MEMORY, /* /< Error due to invalid memory */ + VAL_RESULT_INVALID_ISR, /* /< Error due to invalid isr request */ + VAL_RESULT_ISR_TIMEOUT, /* /< Error due to invalid isr request */ + VAL_RESULT_UNKNOWN_ERROR, /* /< Unknown error */ + VAL_RESULT_RESTARTSYS, /* /< Restart sys */ + VAL_RESULT_MAX = 0xFFFFFFFF /* /< Max result */ +} VAL_RESULT_T; + + +/** + * @par Enumeration + * VAL_MEM_ALIGN_T + * @par Description + * This is the item for allocation memory byte alignment + */ +typedef enum _VAL_MEM_ALIGN_T { + VAL_MEM_ALIGN_1 = 1, /* /< 1 byte alignment */ + VAL_MEM_ALIGN_2 = (1 << 1), /* /< 2 byte alignment */ + VAL_MEM_ALIGN_4 = (1 << 2), /* /< 4 byte alignment */ + VAL_MEM_ALIGN_8 = (1 << 3), /* /< 8 byte alignment */ + VAL_MEM_ALIGN_16 = (1 << 4), /* /< 16 byte alignment */ + VAL_MEM_ALIGN_32 = (1 << 5), /* /< 32 byte alignment */ + VAL_MEM_ALIGN_64 = (1 << 6), /* /< 64 byte alignment */ + VAL_MEM_ALIGN_128 = (1 << 7), /* /< 128 byte alignment */ + VAL_MEM_ALIGN_256 = (1 << 8), /* /< 256 byte alignment */ + VAL_MEM_ALIGN_512 = (1 << 9), /* /< 512 byte alignment */ + VAL_MEM_ALIGN_1K = (1 << 10), /* /< 1K byte alignment */ + VAL_MEM_ALIGN_2K = (1 << 11), /* /< 2K byte alignment */ + VAL_MEM_ALIGN_4K = (1 << 12), /* /< 4K byte alignment */ + VAL_MEM_ALIGN_8K = (1 << 13), /* /< 8K byte alignment */ + VAL_MEM_ALIGN_MAX = 0xFFFFFFFF /* /< Max memory byte alignment */ +} VAL_MEM_ALIGN_T; + + +/** + * @par Enumeration + * VAL_MEM_TYPE_T + * @par Description + * This is the item for allocation memory type + */ +typedef enum _VAL_MEM_TYPE_T { + VAL_MEM_TYPE_FOR_SW = 0, /* /< External memory foe SW */ + VAL_MEM_TYPE_FOR_HW_CACHEABLE, /* /< External memory for HW Cacheable */ + VAL_MEM_TYPE_FOR_HW_CACHEABLE_MCI, /* /< External memory for HW Cacheable, with MCI port config */ + VAL_MEM_TYPE_FOR_HW_NONCACHEABLE, /* /< External memory for HW Non-Cacheable */ + VAL_MEM_TYPE_MAX = 0xFFFFFFFF /* /< Max memory type */ +} VAL_MEM_TYPE_T; + + +/** + * @par Structure + * VAL_MEM_ADDR_T + * @par Description + * This is a structure for memory address + */ +typedef struct _VAL_MEM_ADDR_T { /* union extend 64bits for TEE*/ + union { + VAL_ULONG_T u4VA; /* /< [IN/OUT] virtual address */ + VAL_UINT64_T u4VA_ext64; + }; + union { + VAL_ULONG_T u4PA; /* /< [IN/OUT] physical address */ + VAL_UINT64_T u4PA_ext64; + }; + union { + VAL_ULONG_T u4Size; /* /< [IN/OUT] size */ + VAL_UINT64_T u4Size_ext64; + }; +} VAL_MEM_ADDR_T; + + +/** + * @par Structure + * VAL_VCODEC_THREAD_ID_T + * @par Description + * This is a structure for thread info + */ +typedef struct _VAL_VCODEC_THREAD_ID_T { + VAL_UINT32_T u4tid1; /* /< [IN/OUT] thread id for single core */ + VAL_UINT32_T u4tid2; /* /< [IN/OUT] thread id for single core */ + VAL_UINT32_T u4VCodecThreadNum; /* /< [IN/OUT] thread num */ + VAL_UINT32_T u4VCodecThreadID[VCODEC_THREAD_MAX_NUM]; /* /< [IN/OUT] thread id for each thread */ +} VAL_VCODEC_THREAD_ID_T; + + +/** + * @par Structure + * VAL_VCODEC_CPU_LOADING_INFO_T + * @par Description + * This is a structure for CPU loading info + */ +typedef struct _VAL_VCODEC_CPU_LOADING_INFO_T { + unsigned long long _cpu_idle_time; /* /< [OUT] cpu idle time */ + unsigned long long _thread_cpu_time; /* /< [OUT] thread cpu time */ + unsigned long long _sched_clock; /* /< [OUT] sched clock */ + unsigned int _inst_count; /* /< [OUT] inst count */ +} VAL_VCODEC_CPU_LOADING_INFO_T; + + +/** + * @par Structure + * VAL_VCODEC_CPU_OPP_LIMIT_T + * @par Description + * This is a structure for CPU opp limit info + */ +typedef struct _VAL_VCODEC_CPU_OPP_LIMIT_T { + int limited_freq; /* /< [IN] limited freq */ + int limited_cpu; /* /< [IN] limited cpu */ + int enable; /* /< [IN] enable */ +} VAL_VCODEC_CPU_OPP_LIMIT_T; + + +/** + * @par Structure + * VAL_VCODEC_M4U_BUFFER_CONFIG_T + * @par Description + * This is a structure for m4u buffer config + */ +typedef struct _VAL_VCODEC_M4U_BUFFER_CONFIG_T { + VAL_MEM_CODEC_T eMemCodec; /* /< [IN] memory usage for encoder or decoder */ + VAL_UINT32_T cache_coherent; /* /< [IN] cache coherent or not */ + VAL_UINT32_T security; /* /< [IN] security or not */ +} VAL_VCODEC_M4U_BUFFER_CONFIG_T; + + +/** + * @par Structure + * VAL_MEMORY_T + * @par Description + * This is a parameter for memory usaged function + */ +typedef struct _VAL_MEMORY_T { /* union extend 64bits for TEE*/ + VAL_MEM_TYPE_T eMemType; /* /< [IN] The allocation memory type */ + union { + VAL_ULONG_T u4MemSize; /* /< [IN] The size of memory allocation */ + VAL_UINT64_T u4MemSize_ext64; + }; + union { + VAL_VOID_T *pvMemVa; + VAL_UINT64_T pvMemVa_ext64; + }; + union { + VAL_VOID_T *pvMemPa; + VAL_UINT64_T pvMemPa_ext64; + }; + VAL_MEM_ALIGN_T eAlignment; /* /< [IN] The memory byte alignment setting */ + union { + VAL_VOID_T *pvAlignMemVa; + VAL_UINT64_T pvAlignMemVa_ext64; + }; + union { + VAL_VOID_T *pvAlignMemPa; + VAL_UINT64_T pvAlignMemPa_ext64; + }; + VAL_MEM_CODEC_T eMemCodec; /* /< [IN] The memory codec for VENC or VDEC */ + VAL_UINT32_T i4IonShareFd; + + union { + ion_user_handle_t pIonBufhandle; + VAL_UINT64_T pIonBufhandle_ext64; + }; + union { + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT64_T pvReserved_ext64; + }; + union { + VAL_ULONG_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ + VAL_UINT64_T u4ReservedSize_ext64; + }; +#ifdef __EARLY_PORTING__ + union { + VAL_VOID_T *pvReservedPmem; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT64_T pvReservedPmem_ext64; + }; +#endif +} VAL_MEMORY_T; + +/** + * @par Structure + * VAL_RECORD_SIZE_T + * @par Description + * This is a parameter for setting record size to EMI controller + */ +typedef struct __VAL_RECORD_SIZE_T { + VAL_UINT32_T u4FrmWidth; /* /< [IN] Frame Width, (may not 16 byte-align) */ + VAL_UINT32_T u4FrmHeight; /* /< [IN] Frame Height, (may not 16 byte-align) */ + VAL_UINT32_T u4BufWidth; /* /< [IN] Buffer Width, (must 16 byte-align) */ + VAL_UINT32_T u4BufHeight; /* /< [IN] Buffer Height, (must 16 byte-align) */ +} VAL_RECORD_SIZE_T; + + +/** + * @par Structure + * VAL_ATOI_T + * @par Description + * This is a parameter for eVideoAtoi() + */ +typedef struct _VAL_ATOI_T { + VAL_VOID_T *pvStr; /* /< [IN] Null-terminated String to be converted */ + /* /< [Out] returns the int value produced by interpreting the input characters as a number. */ + VAL_INT32_T i4Result; + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} VAL_ATOI_T; + + +/** + * @par Structure + * VAL_STRSTR_T + * @par Description + * This is a parameter for eVideoStrStr() + */ +typedef struct _VAL_STRSTR_T { + VAL_VOID_T *pvStr; /* /< [IN] Null-terminated string to search. */ + VAL_VOID_T *pvStrSearch; /* /< [IN] Null-terminated string to search for */ + /* + /< [Out] Returns a pointer to the first occurrence of strSearch in str, + or NULL if strSearch does not appear in str. + */ + VAL_VOID_T *pvStrResult; + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ +} VAL_STRSTR_T; + + +/** + * @par Structure + * VAL_ISR_T + * @par Description + * This is a parameter for ISR related function + */ +typedef struct _VAL_ISR_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_DRIVER_TYPE_T eDriverType; /* /< [IN] The driver type */ + VAL_VOID_T *pvIsrFunction; /* /< [IN] The isr function */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ + VAL_UINT32_T u4TimeoutMs; /* /< [IN] The timeout in ms */ + /* /< [IN] The num of return registers when HW done */ + VAL_UINT32_T u4IrqStatusNum; + /* /< [IN/OUT] The value of return registers when HW done */ + VAL_UINT32_T u4IrqStatus[IRQ_STATUS_MAX_NUM]; +} VAL_ISR_T; + + +/** + * @par Structure + * VAL_HW_LOCK_T + * @par Description + * This is a parameter for HW Lock/UnLock related function + */ +typedef struct _VAL_HW_LOCK_T { + VAL_VOID_T *pvHandle; /* /< [IN] The video codec driver handle */ + VAL_UINT32_T u4HandleSize; /* /< [IN] The size of video codec driver handle */ + VAL_VOID_T *pvLock; /* /< [IN/OUT] The Lock discriptor */ + VAL_UINT32_T u4TimeoutMs; /* /< [IN] The timeout ms */ + VAL_VOID_T *pvReserved; /* /< [IN/OUT] The reserved parameter */ + VAL_UINT32_T u4ReservedSize; /* /< [IN] The size of reserved parameter structure */ + VAL_DRIVER_TYPE_T eDriverType; /* /< [IN] The driver type */ + /* /< [IN] True if this is a secure instance // MTK_SEC_VIDEO_PATH_SUPPORT */ + VAL_BOOL_T bSecureInst; +} VAL_HW_LOCK_T; + + +/** + * @par Structure + * VAL_TIME_T + * @par Description + * This is a structure for system time. + */ +typedef struct _VAL_TIME_T { + VAL_UINT32_T u4Sec; /* /< [IN/OUT] second */ + VAL_UINT32_T u4uSec; /* /< [IN/OUT] micro second */ +} VAL_TIME_T; + + +/** + * @par Enumeration + * VAL_SET_TYPE_T + * @par Description + * This is the item for setting val parameter + */ +typedef enum _VAL_SET_TYPE_T { + VAL_SET_TYPE_CURRENT_SCENARIO, /* /< Set current scenario */ + VAL_SET_TYPE_MCI_PORT_CONFIG, /* /< Set MCI port config */ + VAL_SET_TYPE_M4U_PORT_CONFIG, /* /< Set M4U port config */ + VAL_SET_TYPE_SET_TCM_ON, /* /< Set TCM on */ + VAL_SET_TYPE_SET_TCM_OFF, /* /< Set TCM off */ +} VAL_SET_TYPE_T; + +/** + * @par Enumeration + * VAL_GET_TYPE_T + * @par Description + * This is the item for getting val parameter + */ +typedef enum _VAL_GET_TYPE_T { + VAL_GET_TYPE_CURRENT_SCENARIO_CNT, /* /< Get current scenario reference count */ + VAL_GET_TYPE_LCM_INFO, /* /< Get LCM info */ +} VAL_GET_TYPE_T; + +/** + * @par Enumeration + * VAL_VCODEC_SCENARIO + * @par Description + * This is the item for get/setting current vcodec scenario + */ +typedef enum _VAL_VCODEC_SCENARIO_T { + VAL_VCODEC_SCENARIO_VENC_1080P = 0x1, /* /< Camera recording 1080P */ + VAL_VCODEC_SCENARIO_VDEC_1080P = 0x2, /* /< Playback 1080P */ + VAL_VCODEC_SCENARIO_VENC_WFD = 0x4, /* /< Wifi-display encoding */ +} VAL_VCODEC_SCENARIO_T; + +/** + * @par Structure + * VAL_CURRENT_SCENARIO_T + * @par Description + * This is a structure for set/get current scenario + */ +typedef struct _VAL_CURRENT_SCENARIO_T { + VAL_UINT32_T u4Scenario; /* /< [IN/OUT] set/get current scenario */ + VAL_UINT32_T u4OnOff; /* /< [IN] set on/off (increment/decrement) 1 = inc, 0 = dec */ +} VAL_CURRENT_SCENARIO_T; + +/** + * @par Structure + * VAL_CURRENT_SCENARIO_CNT_T + * @par Description + * This is a structure for set/get current scenario reference count + */ +typedef struct _VAL_CURRENT_SCENARIO_CNT_T { + VAL_UINT32_T u4Scenario; /* /< [IN] current scenario type */ + VAL_UINT32_T u4ScenarioRefCount; /* /< [OUT] current scenario reference count */ +} VAL_CURRENT_SCENARIO_CNT_T; + + +/** + * @par Structure + * VAL_MCI_PORT_CONFIG_T + * @par Description + * This is a structure for set/get MCI port config + */ +typedef struct _VAL_MCI_PORT_CONFIG_T { + VAL_MEM_CODEC_T eMemCodecType; /* /< [IN] memory type - decoder/encoder */ + VAL_UINT32_T u4Config; /* /< [IN] set port config */ +} VAL_MCI_PORT_CONFIG_T; + +/** + * @par Structure + * VAL_LCM_INFO_T + * @par Description + * This is a structure for get LCM info + */ +typedef struct _VAL_LCM_INFO_T { + VAL_UINT32_T u4Width; /* /< [OUT] width */ + VAL_UINT32_T u4Height; /* /< [OUT] height */ +} VAL_LCM_INFO_T; + +#define VAL_M4U_PORT_ALL (-1) /* /< VAL_M4UPORT_DEFAULT_ALL = 1, config all M4U port for VENC or VDEC */ + +/** + * @par Structure + * VAL_M4U_MPORT_CONFIG_T + * @par Description + * This is a parameter for eVideoSetParam() input structure + */ +typedef struct _VAL_M4U_MPORT_CONFIG_T { + /* /< [IN] The memory codec for VENC or VDEC */ + VAL_MEM_CODEC_T eMemCodec; + /* /< [IN] config port ID (VAL_M4U_PORT_ALL[-1] = config all VENC or VDEC) */ + VAL_UINT32_T i4M4UPortID; + /* /< [IN] config port security */ + VAL_BOOL_T bSecurity; + /* /< [IN] config port virtuality */ + VAL_BOOL_T bVirtuality; +} VAL_M4U_MPORT_CONFIG_T; + + +/* for DirectLink Meta Mode + */ +#define META_HANDLE_LIST_MAX 50 + +typedef struct _VAL_MetaBufInfo { + void *pNativeHandle; + VAL_ULONG_T u4VA; + VAL_ULONG_T u4PA; + VAL_UINT32_T u4BuffSize; + VAL_BOOL_T bUseION; + int fd; + ion_user_handle_t pIonBufhandle; +} VAL_MetaBufInfo; + +typedef struct _VAL_MetaHandleList { + int mIonDevFd; + VAL_MetaBufInfo rMetaBufInfo[META_HANDLE_LIST_MAX]; + VAL_BOOL_T fgSeqHdrEncoded; +} VAL_MetaHandleList; + +typedef struct _VAL_BufInfo { + VAL_UINT8_T fgIsConfigData; + VAL_ULONG_T u4BSVA; + VAL_UINT8_T fgBSStatus; + VAL_UINT8_T fgIsKeyFrame; + VAL_UINT32_T u4BSSize; +} VAL_BufInfo; +/* for DirectLink Meta Mode - */ + + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VAL_TYPES_PUBLIC_H_ */ diff --git a/kernel-headers/val_vcodec_utility.h b/kernel-headers/val_vcodec_utility.h new file mode 100644 index 0000000..99ea8e9 --- /dev/null +++ b/kernel-headers/val_vcodec_utility.h @@ -0,0 +1,79 @@ +#ifndef _VAL_VCODEC_UTILITY_H_ +#define _VAL_VCODEC_UTILITY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" +#include "hal_api.h" + +/* for hardware vc1_dec + */ + +/** + * @par Function + * BPDec + * @par Description + * The function used to BP dec + * @param + * hHandle [IN/OUT] handle + * @param + * hBitHandle [IN/OUT] bits nandle + * @param + * bpType [IN] WMV_BP_TYPE + * @par Returns + * VDDRV_MRESULT_T, return VDDRV_MRESULT_SUCCESS is success, return others if fail + */ +VDDRV_MRESULT_T BPDec(VAL_HANDLE_T hHandle, VAL_HANDLE_T *hBitHandle, WMV_BP_TYPE bpType); + + +/** + * @par Function + * GetReadBSPt + * @par Description + * The function used to get bitstream pointer + * @param + * hHandle [IN/OUT] handle + * @param + * hBitsHandle [IN/OUT] bits nandle + * @param + * pBits [IN] Bits + * @par Returns + * VAL_UINT32_T, return bitstream pointer + */ +VAL_UINT32_T GetReadBSPt(VAL_HANDLE_T hHandle, VAL_HANDLE_T hBitsHandle, VAL_UINT32_T *pBits); + + +/** + * @par Function + * GetBPDecBits + * @par Description + * The function used to get decode bits + * @param + * hHandle [IN/OUT] handle + * @par Returns + * VAL_UINT32_T, return decode bits + */ +VAL_UINT32_T GetBPDecBits(VAL_HANDLE_T hHandle); + + +/** + * @par Function + * WMVDecode_HW + * @par Description + * The function used to decode WMV + * @param + * hHandle [IN/OUT] handle + * @param + * hBitHandle [IN/OUT] bits nandle + * @par Returns + * VDDRV_MRESULT_T, return VDDRV_MRESULT_SUCCESS is success, return others if fail + */ +VDDRV_MRESULT_T WMVDecode_HW(VAL_HANDLE_T hHandle, VAL_HANDLE_T *hBitHandle); +/* for hardware vc1_dec - */ + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VAL_VCODEC_UTILITY_H_ */ diff --git a/kernel-headers/vcodec_OAL_v2.h b/kernel-headers/vcodec_OAL_v2.h new file mode 100644 index 0000000..fa4ef40 --- /dev/null +++ b/kernel-headers/vcodec_OAL_v2.h @@ -0,0 +1,497 @@ +#ifndef VCODEC_OAL_V2_H +#define VCODEC_OAL_V2_H +#define IN +#define OUT + +#ifndef NULL +#define NULL 0 +#endif + +#include "vcodec_if_v2.h" + +#ifdef WIN32 +#include <windows.h> + +#endif +#define VCODEC_OAL_VERSION 20140812 +#define VCODEC_ASSERT(expr, a) \ + do {if (!(expr)) rVCODEC_OAL_Function.VCodecAssertFail(__FILE__, __LINE__, a); } while (0) + +typedef enum { + VCODEC_OAL_CODEC_NONE = 0, + VCODEC_OAL_H264_DEC, + VCODEC_OAL_HEVC_DEC, + VCODEC_OAL_VP8_DEC, + VCODEC_OAL_VP9_DEC, + VCODEC_OAL_RMVB_DEC, + VCODEC_OAL_MPEG2_DEC, + VCODEC_OAL_MPEG4_DEC, + VCODEC_OAL_VC1_DEC, + VCODEC_OAL_H264_ENC, + VCODEC_OAL_HEVC_ENC, + VCODEC_OAL_VP8_ENC, + VCODEC_OAL_VP9_ENC, + VCODEC_OAL_MPEG4_ENC, + NUM_OF_VCODEC_OAL_CODEC_TYP, +} VCODEC_OAL_CODEC_TYPE; + +typedef struct { + VCODEC_OAL_CODEC_TYPE eCodec; + void *reserve1; + void *reserve2; + void *reserve3; + void *reserve4; +} VCODEC_OAL_HW_CTR_INFO_T; + +void VCodecQueryMemType(IN void *pBuffer_VA, IN unsigned int u4Size, OUT VCODEC_MEMORY_TYPE_T * peMemType); + +void VCodecQueryPhysicalAddr(IN void *pBuffer_VA, + OUT void **pBufferOut_PA + ); + +/* VCodecSwitchMemType - return 0 if success. */ +/* return -1 if failed, but pBufferOut_VA will be assigned with pBuffer_VA */ +int VCodecSwitchMemType(IN void *pBuffer_VA, + IN unsigned int u4Size, + IN VCODEC_MEMORY_TYPE_T eMemType, + OUT void **pBufferOut_VA + ); + +/* VCodecFlushCachedBuffer - u4Size is in byte */ +void VCodecFlushCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size + ); + +/* VCodecInvalidateCachedBuffer - u4Size is in byte */ +void VCodecInvalidateCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size + ); + +void VCodecFlushCachedBufferAll(void); + +void VCodecInvalidateCachedBufferAll(void); + +void VCodecFlushInvalidateCacheBufferAll(void); + +void VCodecMemSet(IN void *pBuffer_VA, + IN char cValue, + IN unsigned int u4Length + ); + +void VCodecMemCopy(IN void *pvDest , + IN const void *pvSrc , + IN unsigned int u4Length + ); +typedef struct { + void *pBuffer_PA; /* /< [IN] The physical memory address */ + unsigned int u4MemSize; /* /< [IN] The memory size to be mapped */ + void *pBuffer_VA; /* /< [OUT] The mapped virtual memory address */ +} VCODEC_OAL_MMAP_T; + +void VCodecMMAP(VCODEC_OAL_MMAP_T *prParam); +void VCodecUnMMAP(VCODEC_OAL_MMAP_T *prParam); + + +typedef enum { + VCODEC_OAL_VDEC, + VCODEC_OAL_VENC +} VCODEC_OAL_CODEC; + +typedef struct { + unsigned int u4ReadAddr; /* / [IN] memory source address in VA */ + unsigned int u4ReadData; /* / [OUT] memory data */ +} VCODEC_OAL_MEM_STAUTS_T; + +typedef struct { + /* /< [IOUT] HW is Completed or not, set by driver & clear by codec + (0: not completed or still in lock status; + 1: HW is completed or in unlock status) + */ + unsigned int u4HWIsCompleted; + /* /< [OUT] HW is Timeout or not, set by driver & clear by codec + (0: not in timeout status; + 1: HW is in timeout status) + */ + unsigned int u4HWIsTimeout; + unsigned int u4NumOfRegister; /* /< [IN] Number of HW register need to store; */ + VCODEC_OAL_MEM_STAUTS_T *pHWStatus; +} VCODEC_OAL_HW_REGISTER_T; + +typedef struct { + void *pvHandle; /* /< [IN] The video codec handle */ + void *pvIsrFunction; /* /< [IN] The isr function */ + unsigned int u4TimeoutMs; /* /< [IN] The timeout in ms */ + VCODEC_OAL_CODEC eCodec; /* /< [IN] VDEC or VENC interrupt */ +} VCODEC_OAL_ISR_T; + +/* return value: HW is completed (1) or not (0) when function return */ +int VCodecWaitISR(VCODEC_OAL_ISR_T *prParam); + + +typedef struct { + void *pvHandle; /* /< [IN] The video codec handle */ + unsigned int u4TimeoutMs; /* /< [IN] The timeout ms */ +} VCODEC_OAL_HW_LOCK_T; + +/* return value: HW is completed (1) or not (0) when function return */ +int VCodecLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + +/* return value: HW is completed (1) or not (0) when function return */ +int VCodecUnLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +void VCodecInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + +void VCodecDeInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + + +/****** Pthread define******/ +#ifdef WIN32 +#define VCODEC_PTHREAD_PROCESS_PRIVATE 0 +#define VCODEC_PTHREAD_PROCESS_SHARED 1 +#define VCODEC_PTHREAD_CREATE_JOINABLE 0 +#define VCODEC_PTHREAD_CREATE_DETACHED 1 +#define VCODEC_PTHREAD_SCOPE_PROCESS 0 +#define VCODEC_PTHREAD_SCOPE_SYSTEM 1 +#define VCODEC_PTHREAD_ONCE_INIT 0 +typedef volatile int VCODEC_PTHREAD_ONCE_T; + +typedef int VCODEC_PTHREAD_ATTR_T; + +typedef int VCODEC_PTHREAD_MUTEXATTR_T; +typedef int VCODEC_PTHREAD_CONDATTR_T; +typedef CRITICAL_SECTION VCODEC_PTHREAD_MUTEX_T; + +typedef struct { + void *handle; + void *(*func)(void *arg); + void *arg; + void *ret; +} VCODEC_PTHREAD_T; + + +typedef struct { + int interlock; + VCODEC_PTHREAD_MUTEX_T mutex; +} VCODEC_PTHREAD_SPINLOCK_T; +typedef struct { + void *ptr; +} VCODEC_PTHREAD_COND_T; +#elif defined(ANDROID) +#define VCODEC_PTHREAD_PROCESS_PRIVATE 0 +#define VCODEC_PTHREAD_PROCESS_SHARED 1 +#define VCODEC_PTHREAD_CREATE_JOINABLE 0 +#define VCODEC_PTHREAD_CREATE_DETACHED 1 +#define VCODEC_PTHREAD_SCOPE_PROCESS 0 +#define VCODEC_PTHREAD_SCOPE_SYSTEM 1 +#define VCODEC_PTHREAD_ONCE_INIT 0 +typedef long VCODEC_PTHREAD_T; +typedef volatile int VCODEC_PTHREAD_ONCE_T; +typedef long VCODEC_PTHREAD_MUTEXATTR_T; +typedef long VCODEC_PTHREAD_CONDATTR_T; +typedef struct { + unsigned int flags; + void *stack_base; + unsigned int stack_size; + unsigned int guard_size; + unsigned int sched_policy; + unsigned int sched_priority; +} VCODEC_PTHREAD_ATTR_T; + +typedef struct { + int volatile value; +} VCODEC_PTHREAD_MUTEX_T; + +typedef struct { + int volatile value; +} VCODEC_PTHREAD_COND_T; + +typedef struct { + int interlock; + VCODEC_PTHREAD_MUTEX_T mutex; +} VCODEC_PTHREAD_SPINLOCK_T; +/****** End of Pthread define******/ +#elif defined(LINUX) +#define VCODEC_PTHREAD_CREATE_JOINABLE 0 +#define VCODEC_PTHREAD_CREATE_DETACHED 1 +#define VCODEC_SIZEOF_PTHREAD_ATTR_T 36 +#define VCODEC_SIZEOF_PTHREAD_MUTEX_T 24 +#define VCODEC_SIZEOF_PTHREAD_MUTEXATTR_T 4 +#define VCODEC_SIZEOF_PTHREAD_COND_T 48 +#define VCODEC_SIZEOF_PTHREAD_COND_COMPAT_T 12 +#define VCODEC_SIZEOF_PTHREAD_CONDATTR_T 4 +typedef unsigned long int VCODEC_PTHREAD_T; +typedef union { + char __size[VCODEC_SIZEOF_PTHREAD_ATTR_T]; + long int _align; +} VCODEC_PTHREAD_ATTR_T; +typedef struct VCODEC_PTHREAD_INTERNAL_SLIST { + struct VCODEC_PTHREAD_INTERNAL_SLIST *__next; +} VCODEC_PTHREAD_SLIST_T; +typedef union { + struct VCODEC_PTHREAD_MUTEX_S { + int __lock; + unsigned int __count; + int __owner; + int __kind; + unsigned int __nusers; + __extension__ union { + int __spins; + VCODEC_PTHREAD_SLIST_T __list; + }; + } __data; + char __size[VCODEC_SIZEOF_PTHREAD_MUTEX_T]; + long int _align; +} VCODEC_PTHREAD_MUTEX_T; +typedef union { + char __size[VCODEC_SIZEOF_PTHREAD_MUTEXATTR_T]; + long int _align; +} VCODEC_PTHREAD_MUTEXATTR_T; +typedef union { + struct { + int __lock; + unsigned int __futex; + __extension__ unsigned long long int __total_seq; + __extension__ unsigned long long int __wakeup_seq; + __extension__ unsigned long long int __woken_seq; + void *__mutex; + unsigned int __nwaiters; + unsigned int __broadcast_seq; + } __data; + char __size[VCODEC_SIZEOF_PTHREAD_COND_T]; + __extension__ long long int _align; +} VCODEC_PTHREAD_COND_T; +typedef union { + char __size[VCODEC_SIZEOF_PTHREAD_CONDATTR_T]; + long int _align; +} VCODEC_PTHREAD_CONDATTR_T; +typedef int VCODEC_PTHREAD_ONCE_T; +typedef volatile int VCODEC_PTHREAD_SPINLOCK_T; +#else +#error "platform undefined. @ vcodec_OAL.h" +#endif /* endif WIN32 */ + + +typedef enum { + VCODEC_OAL_ERROR_NONE, + VCODEC_OAL_ERROR_ERROR, + VCODEC_OAL_ERROR_ASSERT_FAIL, + VCODEC_OAL_ERROR_ATTR_NOT_SUPPORT, + NUM_OF_VCODEC_OAL_ERROR_TYPE +} VCODEC_OAL_ERROR_T; + +/* Semaphore */ + +typedef struct { + volatile unsigned int count; +} VCODEC_OAL_SEM_T; + + +int VCodecPthread_attr_init(OUT VCODEC_PTHREAD_ATTR_T * attr); +int VCodecPthread_attr_destroy(IN VCODEC_PTHREAD_ATTR_T * attr); +int VCodecPthread_attr_getdetachstate(IN const VCODEC_PTHREAD_ATTR_T * attr, + OUT int *detachstate); +int VCodecPthread_attr_setdetachstate(IN VCODEC_PTHREAD_ATTR_T * attr, + IN int detachstate); +int VCodecPthread_create( + OUT VCODEC_PTHREAD_T * thread, + IN const VCODEC_PTHREAD_ATTR_T * attr, + IN void * (*start_routine)(void *), + IN void *arg +); +int VCodecPthread_kill(IN VCODEC_PTHREAD_T tid, IN int sig); +void VCodecPthread_exit(OUT void *retval); +int VCodecPthread_join(IN VCODEC_PTHREAD_T thid, OUT void **ret_val); +int VCodecPthread_once(IN VCODEC_PTHREAD_ONCE_T * once_control, IN void (*init_routine)(void)); +VCODEC_PTHREAD_T VCodecPthread_self(void); +int VCodecPthread_mutexattr_init(OUT VCODEC_PTHREAD_MUTEXATTR_T * attr); +int VCodecPthread_mutexattr_destroy(IN VCODEC_PTHREAD_MUTEXATTR_T * attr); +int VCodecPthread_mutex_init(OUT VCODEC_PTHREAD_MUTEX_T *mutex, IN const VCODEC_PTHREAD_MUTEXATTR_T * attr); +int VCodecPthread_mutex_destroy(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_mutex_lock(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_mutex_unlock(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_mutex_trylock(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_spin_init(OUT VCODEC_PTHREAD_SPINLOCK_T * lock, IN int pshared); +int VCodecPthread_spin_destroy(IN VCODEC_PTHREAD_SPINLOCK_T * lock); +int VCodecPthread_spin_lock(IN VCODEC_PTHREAD_SPINLOCK_T * lock); +int VCodecPthread_spin_trylock(IN VCODEC_PTHREAD_SPINLOCK_T * lock); +int VCodecPthread_spin_unlock(IN VCODEC_PTHREAD_SPINLOCK_T * lock); +int VCodecPthread_condattr_init(OUT VCODEC_PTHREAD_CONDATTR_T * attr); +int VCodecPthread_condattr_destroy(IN VCODEC_PTHREAD_CONDATTR_T * attr); +int VCodecPthread_cond_init(OUT VCODEC_PTHREAD_COND_T * cond, IN const VCODEC_PTHREAD_CONDATTR_T * attr); +int VCodecPthread_cond_destroy(IN VCODEC_PTHREAD_COND_T * cond); +int VCodecPthread_cond_broadcast(IN VCODEC_PTHREAD_COND_T * cond); +int VCodecPthread_cond_signal(IN VCODEC_PTHREAD_COND_T * cond); +int VCodecPthread_cond_wait(IN VCODEC_PTHREAD_COND_T * cond, IN VCODEC_PTHREAD_MUTEX_T *mutex); + +VCODEC_OAL_ERROR_T VCodecBindingCore(IN VCODEC_PTHREAD_T tid, + IN unsigned int u4Mask); +VCODEC_OAL_ERROR_T VCodecDeBindingCore(IN VCODEC_PTHREAD_T tid); +VCODEC_OAL_ERROR_T VCodecGetAffinity(IN VCODEC_PTHREAD_T tid, + OUT unsigned int *pu4Mask, + OUT unsigned int *pu4SetMask); +VCODEC_OAL_ERROR_T VCodecCoreLoading(IN int s4CPUid, + OUT int *ps4Loading); +VCODEC_OAL_ERROR_T VCodecCoreNumber(OUT int *ps4CPUNums); +void VCodecSleep(IN unsigned int u4Tick); +int VCodec_sem_init(IN VCODEC_OAL_SEM_T * sem, + IN int pshared, + IN unsigned int value); +int VCodec_sem_destroy(IN VCODEC_OAL_SEM_T * sem); +int VCodec_sem_post(IN VCODEC_OAL_SEM_T * sem); +int VCodec_sem_wait(IN VCODEC_OAL_SEM_T * sem); + +int VCodecCheck_Version(IN int version); + +#define VCodecOALPrintf(...) {rVCODEC_OAL_Function.VCodecPrintf(__VA_ARGS__); } + +VCODEC_OAL_ERROR_T VCodecConfigMCIPort( + IN unsigned int u4PortConfig, + OUT unsigned int *pu4PortResult, + IN VCODEC_CODEC_TYPE_T eCodecType +); +typedef struct { + + void (*VCodecQueryMemType)(IN void *pBuffer_VA, IN unsigned int u4Size, OUT VCODEC_MEMORY_TYPE_T * peMemType); + + void (*VCodecQueryPhysicalAddr)(IN void *pBuffer_VA, + OUT void **pBufferOut_PA); + + /* VCodecSwitchMemType - return 0 if success. */ + /* return -1 if failed, but pBufferOut_VA will be assigned with pBuffer_VA */ + int (*VCodecSwitchMemType)(IN void *pBuffer_VA, + IN unsigned int u4Size, + IN VCODEC_MEMORY_TYPE_T eMemType, + OUT void **pBufferOut_VA); + + /* VCodecFlushCachedBuffer - u4Size is in byte */ + void (*VCodecFlushCachedBuffer)(IN void *pBuffer_VA, + IN unsigned int u4Size); + + /* VCodecInvalidateCachedBuffer - u4Size is in byte */ + void (*VCodecInvalidateCachedBuffer)(IN void *pBuffer_VA, + IN unsigned int u4Size); + + void (*VCodecFlushCachedBufferAll)(void); + + void (*VCodecInvalidateCachedBufferAll)(void); + + void (*VCodecFlushInvalidateCacheBufferAll)(void); + + void (*VCodecMemSet)(IN void *pBuffer_VA, + IN char cValue, + IN unsigned int u4Length); + + void (*VCodecMemCopy)(IN void *pvDest , + IN const void *pvSrc , + IN unsigned int u4Length); + + void (*VCodecAssertFail)(IN char *ptr, + IN int i4Line, + IN int i4Arg); + + void (*VCodecMMAP)(VCODEC_OAL_MMAP_T *prParam); + void (*VCodecUnMMAP)(VCODEC_OAL_MMAP_T *prParam); + int (*VCodecWaitISR)(VCODEC_OAL_ISR_T *prParam); + int (*VCodecLockHW)(VCODEC_OAL_HW_LOCK_T *prParam); + int (*VCodecUnLockHW)(VCODEC_OAL_HW_LOCK_T *prParam); + + void (*VCodecInitHWLock)(IN VCODEC_OAL_HW_REGISTER_T *prParam); + + void (*VCodecDeInitHWLock)(IN VCODEC_OAL_HW_REGISTER_T *prParam); + int (*VCodecCheck_Version)(IN int version); + /************ Multi-thread function ***********/ + + /***** Thread Management Functions ******/ + int (*VCodecPthread_attr_init)(OUT VCODEC_PTHREAD_ATTR_T * attr); + int (*VCodecPthread_attr_destroy)(IN VCODEC_PTHREAD_ATTR_T * attr); + int (*VCodecPthread_attr_getdetachstate)(IN const VCODEC_PTHREAD_ATTR_T * attr, + OUT int *detachstate); + int (*VCodecPthread_attr_setdetachstate)(IN VCODEC_PTHREAD_ATTR_T * attr, + IN int detachstate); + int (*VCodecPthread_create)( + OUT VCODEC_PTHREAD_T *thread, + IN const VCODEC_PTHREAD_ATTR_T * attr, + IN void * (*start_routine)(void *), + IN void *arg + ); + int (*VCodecPthread_kill)(IN VCODEC_PTHREAD_T tid, + IN int sig); + void (*VCodecPthread_exit)(OUT void *retval); + int (*VCodecPthread_join)(IN VCODEC_PTHREAD_T thid, + OUT void **ret_val); + int (*VCodecPthread_once)(IN VCODEC_PTHREAD_ONCE_T * once_control, + IN void (*init_routine)(void)); + VCODEC_PTHREAD_T(*VCodecPthread_self)(void); + + /***** Mutex Functions ******/ + int (*VCodecPthread_mutexattr_init)(OUT VCODEC_PTHREAD_MUTEXATTR_T * attr); + int (*VCodecPthread_mutexattr_destroy)(IN VCODEC_PTHREAD_MUTEXATTR_T * attr); + int (*VCodecPthread_mutex_init)(OUT VCODEC_PTHREAD_MUTEX_T *mutex, IN const VCODEC_PTHREAD_MUTEXATTR_T * attr); + int (*VCodecPthread_mutex_destroy)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + int (*VCodecPthread_mutex_lock)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + int (*VCodecPthread_mutex_unlock)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + int (*VCodecPthread_mutex_trylock)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + + /***** Spin Functions ******/ + int (*VCodecPthread_spin_init)(OUT VCODEC_PTHREAD_SPINLOCK_T * lock, + IN int pshared); + int (*VCodecPthread_spin_destroy)(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + int (*VCodecPthread_spin_lock)(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + int (*VCodecPthread_spin_trylock)(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + int (*VCodecPthread_spin_unlock)(IN VCODEC_PTHREAD_SPINLOCK_T * lock); + + /***** Condition Variable Functions ******/ + int (*VCodecPthread_condattr_init)(OUT VCODEC_PTHREAD_CONDATTR_T * attr); + int (*VCodecPthread_condattr_destroy)(IN VCODEC_PTHREAD_CONDATTR_T * attr); + int (*VCodecPthread_cond_init)(OUT VCODEC_PTHREAD_COND_T * cond, IN const VCODEC_PTHREAD_CONDATTR_T * attr); + int (*VCodecPthread_cond_destroy)(IN VCODEC_PTHREAD_COND_T * cond); + int (*VCodecPthread_cond_broadcast)(IN VCODEC_PTHREAD_COND_T * cond); + int (*VCodecPthread_cond_signal)(IN VCODEC_PTHREAD_COND_T * cond); + int (*VCodecPthread_cond_wait)(IN VCODEC_PTHREAD_COND_T * cond, + IN VCODEC_PTHREAD_MUTEX_T *mutex); + + /************ End of Multi-thread function ***********/ + + /***** Semaphore Functions ******/ + + int (*VCodec_sem_init)(IN VCODEC_OAL_SEM_T * sem, + IN int pshared, + IN unsigned int value); + + int (*VCodec_sem_destroy)(IN VCODEC_OAL_SEM_T * sem); + + int (*VCodec_sem_post)(IN VCODEC_OAL_SEM_T * sem); + + int (*VCodec_sem_wait)(IN VCODEC_OAL_SEM_T * sem); + + /***** Binding Functions ******/ + + VCODEC_OAL_ERROR_T(*VCodecBindingCore)(IN VCODEC_PTHREAD_T tid, + IN unsigned int u4SetMask); + VCODEC_OAL_ERROR_T(*VCodecDeBindingCore)(IN VCODEC_PTHREAD_T tid); + + VCODEC_OAL_ERROR_T(*VCodecGetAffinity)(IN VCODEC_PTHREAD_T tid, + OUT unsigned int *pu4CPUMask, + OUT unsigned int *pu4SetMask); + + VCODEC_OAL_ERROR_T(*VCodecCoreLoading)(IN int s4CPUid, + OUT int *ps4Loading); + VCODEC_OAL_ERROR_T(*VCodecCoreNumber)(OUT int *ps4CPUNums); + /***** Others Functions ******/ + void (*VCodecSleep)(IN unsigned int u4Tick); + + VCODEC_OAL_ERROR_T(*VCodecConfigMCIPort)( + IN unsigned int u4PortConfig, + OUT unsigned int *pu4PortResult, + IN VCODEC_CODEC_TYPE_T eCodecType + ); + + VCODEC_OAL_ERROR_T(*VCodecPrintf)(IN const char *_Format, ...); + +} VCODEC_OAL_CALLBACK_T; + +extern VCODEC_OAL_CALLBACK_T rVCODEC_OAL_Function; +int VCodecOALInit(IN VCODEC_OAL_CALLBACK_T *prVCODEC_OAL_Function); + +#endif /* VCODEC_OAL_H */ diff --git a/kernel-headers/vcodec_customization.h b/kernel-headers/vcodec_customization.h new file mode 100644 index 0000000..b8e22b9 --- /dev/null +++ b/kernel-headers/vcodec_customization.h @@ -0,0 +1,19 @@ +#ifndef VCODEC_CUSTOMIZATION_H +#define VCODEC_CUSTOMIZATION_H + +#include "vcodec_if_v2.h" + + + + + +extern VCODEC_DEC_API_T *GetH264DecoderAPI(void); +/* VCODEC_DEC_API_T *GetRMDecoderAPI(void); //RV8,RV9,RV10 */ +/* VCODEC_DEC_API_T *GetMPEG4DecoderAPI(void); */ +/* VCODEC_DEC_API_T *GetMPEG4VTDecoderAPI(void); */ +/* VCODEC_DEC_API_T *GetVP8DecoderAPI(void); */ + +/* VCODEC_ENC_API_T *GetMPEG4EncoderAPI(void); */ +/* VCODEC_ENC_API_T *GetMPEG4SWVTEncoderAPI(void); */ + +#endif /* VCODEC_CUSTOMIZATION_H */ diff --git a/kernel-headers/vcodec_dec_demuxer_if_v2.h b/kernel-headers/vcodec_dec_demuxer_if_v2.h new file mode 100644 index 0000000..057b778 --- /dev/null +++ b/kernel-headers/vcodec_dec_demuxer_if_v2.h @@ -0,0 +1,98 @@ + +#ifndef VCODEC_DEC_DEMUXER_V2_IF_H +#define VCODEC_DEC_DEMUXER_V2_IF_H + + +typedef struct { + unsigned char *u4Address; + unsigned int u4Length; + int fgValid; +} RM_DECODER_PAYLOAD_INFO_T; + +typedef struct { + unsigned int u4PayloadNumber; + RM_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} RM_DECODER_INPUT_PARAM_T; + +typedef enum { + RV8 = 0, + RV9, + RV10 +} RM_CODEC_VERSION_T; + +#define MAX_NUM_RPR_SIZES 8 +typedef struct { + RM_CODEC_VERSION_T eDecoderVersion; + unsigned int u4MaxDimWidth; + unsigned int u4MaxDimHeight; + unsigned int u4NumRPRSizes; + unsigned int au4RPRSizes[2 * MAX_NUM_RPR_SIZES]; +} RM_DECODER_INIT_PARAM_T; + +typedef struct { + unsigned int MaxSupportWidthForYUV420_ASP; + unsigned int MaxSupportHeightForYUV420_ASP; + unsigned short u2FrameWidthInContainer; + unsigned short u2FrameHeightInContainer; +} MPEG4_DECODER_PRIVATE_PARAM_T; + +/* The H264 uses the private data to transfer NAL units */ +/* The related data structure informations are defined as below */ +/* */ + +typedef struct { + unsigned char *u4Address; + unsigned int u4Length; +} H264_DECODER_PAYLOAD_INFO_T; + +typedef struct { + unsigned int u4PayloadNumber; + H264_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} H264_DECODER_INPUT_PARAM_T; + +typedef struct { + unsigned char *u4Address; + unsigned int u4Length; +} VC1_DECODER_PAYLOAD_INFO_T; + +typedef struct { + unsigned int u4PayloadNumber; + VC1_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} VC1_DECODER_INPUT_PARAM_T; + +typedef struct { + unsigned char *u4Address; + unsigned int u4Length; + unsigned short u2FrameWidthInContainer; + unsigned short u2FrameHeightInContainer; +} MPEG4_DECODER_PAYLOAD_INFO_T; + +typedef struct { + unsigned int u4PayloadNumber; + MPEG4_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} MPEG4_DECODER_INPUT_PARAM_T; +typedef struct { + unsigned char *u4Address; + unsigned int u4Length; +} MPEG4VT_DECODER_PAYLOAD_INFO_T; + +typedef struct { + unsigned int u4PayloadNumber; + MPEG4VT_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} MPEG4VT_DECODER_INPUT_PARAM_T; + +typedef struct { + VCODEC_BUFFER_T rPayload; + unsigned int u4Length; +} VP8_DECODER_INPUT_UNIT_T; + +typedef struct { + unsigned char *u4Address; + unsigned int u4Length; +} HEVC_DECODER_PAYLOAD_INFO_T; + +typedef struct { + unsigned int u4PayloadNumber; + HEVC_DECODER_PAYLOAD_INFO_T *pu1Payload; +} HEVC_DECODER_INPUT_PARAM_T; +#endif /* VCODEC_DEC_DEMUXER_IF_H */ diff --git a/kernel-headers/vcodec_if_v2.h b/kernel-headers/vcodec_if_v2.h new file mode 100644 index 0000000..72f1bcd --- /dev/null +++ b/kernel-headers/vcodec_if_v2.h @@ -0,0 +1,991 @@ + +#ifndef VCODEC_IF_V2_H +#define VCODEC_IF_V2_H + +/*************************************************** +* +* Chip definitions and Series definitions +* +***************************************************/ + + +#ifndef TRUE +#define TRUE 1 +#elif TRUE != 1 +#error TRUE is not equal to 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#elif FALSE != 0 +#error FALSE is not equal to 0 +#endif +#define IN +#define OUT +#define INOUT +typedef void *HANDLE; +#ifdef WIN32 +typedef unsigned __int64 UINT64; +#else +typedef unsigned long long UINT64; +#endif + +typedef enum { + VCODEC_DECODER, + VCODEC_ENCODER, + NUM_OF_CODEC_TYPE +} VCODEC_CODEC_TYPE_T; + +typedef struct { + unsigned int u4YStride; + unsigned int u4UVStride; +} VCODEC_YUV_STRIDE_T; + +typedef enum { + VCODEC_COLOR_FORMAT_YUV420, + VCODEC_COLOR_FORMAT_YV12, +} VCODEC_COLOR_FORMAT_T; + +typedef struct { + unsigned int MaxSupportWidth; + unsigned int MaxSupportHeight; + unsigned int eFlag; /* VCODEC_DEC_INPUT_FLAG_T */ + unsigned int ExternalMEMSize; + int OutBufferNum; /* -1: .inf */ + VCODEC_YUV_STRIDE_T stride; + VCODEC_COLOR_FORMAT_T eColorFormat; + void *PrivateData[4]; +} VCODEC_OPEN_SETTING_T; + +typedef struct { + unsigned int MaxSupportWidthForYUV420_BP; + unsigned int MaxSupportHeightForYUV420_BP; + unsigned int MaxSupportWidthForYUV420_MPHP; + unsigned int MaxSupportHeightForYUV420_MPHP; + unsigned int ExternalMEMSize; + unsigned int DPBSize; +} H264_DEC_CUSTOM_SETTING_T; + +typedef struct { + unsigned int MaxSupportWidthForYUV420_MPHP; + unsigned int MaxSupportHeightForYUV420_MPHP; + unsigned int NormalMaxWidthForYUV420_MPHP; + unsigned int NormalMaxHeightForYUV420_MPHP; + unsigned int u4dpbSizes; + void *reserved[4]; +} H264_DECODER_PRIVATE_PARAM_T; +/* +typedef struct +{ + unsigned int MaxSupportWidthForYUV420_SP; + unsigned int MaxSupportHeightForYUV420_SP; + unsigned int MaxSupportWidthForYUV420_ASP; + unsigned int MaxSupportHeightForYUV420_ASP; + unsigned int ExternalMEMSize; +} MPEG4_DEC_CUSTOM_SETTING_T; + +typedef struct +{ + unsigned int MaxSupportWidthForYUV420; + unsigned int MaxSupportHeightForYUV420; + unsigned int eFlag; //VCODEC_DEC_INPUT_FLAG_T + unsigned int ExternalMEMSize; + void *PrivateData[4]; +} VC1_DEC_CUSTOM_SETTING_T; +*/ + +typedef enum { + VCODEC_FRAMETYPE_I, + VCODEC_FRAMETYPE_NS_I, /* non-seek I, non-IDR frame */ + VCODEC_FRAMETYPE_P, + VCODEC_FRAMETYPE_B, + VCODEC_HEADER, + VCODEC_FRM_DROPPED, + VCODEC_UNKNOWN_TYPE, + NUM_OF_FRAME_TYPE +} VCODEC_FRAME_TYPE_T; + + + +typedef enum { + VA_NON_CACHED = 0x0, + VA_CACHED = 0x1, +} VCODEC_BUFFER_ATTRIBUTE_T; + +typedef enum { + VCODEC_BUFFER_CACHEABLE = 0, + VCODEC_BUFFER_NON_CACHEABLE = 1, + VCODEC_BUFFER_MCI_SHARABLE = 2 +} VCODEC_MEMORY_TYPE_T; +typedef struct { + unsigned int u4InternalSize; + unsigned int u4ExternalSize; +} VCODEC_MEMORY_SIZE_T; + +typedef struct { + unsigned char *pu1Buffer_VA; + unsigned char *pu1Buffer_PA; + unsigned int eBufferStatus;/* VCODEC_BUFFER_ATTRIBUTE_T */ +} VCODEC_BUFFER_T; + +typedef enum { + VCODEC_DEC_ERROR_NONE, + VCODEC_DEC_ERROR_DECODE_ERROR, + VCODEC_DEC_ERROR_ASSERT_FAIL, + VCODEC_DEC_ERROR_FATAL_ERROR, + VCODEC_DEC_ERROR_NOT_SUPPORT, + VCODEC_DEC_ERROR_NOT_ENOUGH_MEM, + VCODEC_DEC_ERROR_PAYLOAD_DATA_ERROR, + VCODEC_DEC_ERROR_OAL_CHECK_VERSION_FAIL, + VCODEC_DEC_ERROR_DIMENSION_CHANGE, + NUM_OF_DEC_ERROR_TYPE +} VCODEC_DEC_ERROR_T; + + +typedef enum { + CUSTOM_SETTING, /* custom setting */ + BEST_QUALITY, /* standard mode */ + FAVOR_QUALITY, /* adaptive control decode mode , quality first */ + FAVOR_FLUENCY, /* adaptive control decode mode , fluency first */ + BEST_FLUENCY, /* fast mode */ + NUM_OF_DECODE_MODE, +} VCODEC_DEC_DECODE_MODE_T; + + + +typedef enum { + VCODEC_DEC_PARAM_EOF, + VCODEC_DEC_PARAM_QUERY_RESOLUTION_AHEAD, + VCODEC_DEC_PARAM_QUERY_RESOLUTION, + VCODEC_DEC_PARAM_QUERY_PREDICATION_TIME, + VCODEC_DEC_PARAM_MEMORY_REQUIREMENT, + VCODEC_DEC_PARAM_CAPABILITY, + VCODEC_DEC_PARAM_NOT_BUFFERING, + VCODEC_DEC_PARAM_BUFFERING, + VCODEC_DEC_PARAM_BITRATE, + VCODEC_DEC_PARAM_FRAMERATE, + VCODEC_DEC_PARAM_EXCLUDE_BUF_NUM, + VCODEC_DEC_PARAM_NO_OUTPUT_REORDERING, + VCODEC_DEC_PARAM_FLUSH_BUFFER, + VCODEC_DEC_PARAM_SET_DECRYPTION_MODE, + VCODEC_DEC_PARAM_SET_DECODE_MODE, + VCODEC_DEC_PARAM_GET_DECODE_MODE, + VCODEC_DEC_PARAM_CTRL_VOS, + VCODEC_DEC_PARAM_GET_SBSFLAG, + VCODEC_DEC_PARAM_CONCEAL_LEVEL, + VCODEC_DEC_PARAM_NUM_OF_HW_CTRL_THID, + /*Get registered HW control thread id , output structure : VCODEC_REG_HW_CTRL_THID_T*/ + VCODEC_DEC_PARAM_GET_REG_HW_CTRL_THID, + VCODEC_DEC_PARAM_SET_COLOR_FORMAT, + /* VCODEC_DEC_PARAM_SET_STRIDE_ALIGNMENT, */ + VCODEC_DEC_PARAM_SET_AVAILABLE_CPU_NUM, + VCODEC_DEC_PARAM_SET_MCI, /* enable or disable MCI mechanism */ + NUM_OF_DEC_PARAM_TYPE, +} VCODEC_DEC_PARAM_TYPE_T; + +typedef enum { + VCODEC_DEC_DISPLAY_CONCEALED_FRAME_DURING_PLAYBACK = 0x01, + VCODEC_DEC_DISPLAY_CONCEALED_FRAME_BEFORE_FIRST_I = 0X02, + VCODEC_DEC_DISPLAY_CONCEALED_FRAME_AFTER_FIRST_I = 0X04, + NUM_OF_DEC_CONCEAL_LEVEL_TYPE, +} VCODEC_DEC_CONCEAL_LEVEL_TYPE_T; +typedef enum { + /* VCODEC_DEC_QUERY_INFO_AVAILABLE_YUV, //Total available YUV buffer */ + /* VCODEC_DEC_QUERY_INFO_TOTAL_YUV, //Total number of YUV buffer */ + /* //Total available display frame(without frame repeat) */ + /* VCODEC_DEC_QUERY_INFO_AVAILABLE_DISPLAY_FRAME, */ + /* //Total real available display frame(including frame repeat) */ + /* VCODEC_DEC_QUERY_INFO_REAL_AVAILABLE_DISPLAY_FRAME, */ + VCODEC_DEC_QUERY_INFO_OAL_FUNCTION, /* Query OAL Function pointer */ + VCODEC_DEC_QUERY_INFO_CURRENT_TIME, /* Current play time */ + VCODEC_DEC_QUERY_INFO_LAST_VIDEO_TIME, /* Last delivered frame time */ + /* VCODEC_DEC_QUERY_INFO_OAL_FUNCTION_SMP, //Query OAL Function pointer */ + NUM_OF_QUERY_INFO_TYPE +} VCODEC_DEC_QUERY_INFO_TYPE_T; + +typedef struct { + VCODEC_COLOR_FORMAT_T eColorFormat; + unsigned int u4MaxWidth; + unsigned int u4MaxHeight; + unsigned int MaxVideoCodingResolution; +} VCODEC_ENC_GENERAL_SETTING_T; + +typedef struct { + VCODEC_COLOR_FORMAT_T eColorFormat; + unsigned int u4MaxWidth; + unsigned int u4MaxHeight; + unsigned int MaxVideoCodingResolution; + unsigned int complexityIndex; +} VCODEC_ENC_MPEG4_SETTING_T; + +typedef union { + VCODEC_ENC_MPEG4_SETTING_T rMPEG4; + VCODEC_ENC_GENERAL_SETTING_T rVT; + VCODEC_ENC_GENERAL_SETTING_T rH264; + VCODEC_ENC_GENERAL_SETTING_T rHEVC; + VCODEC_ENC_GENERAL_SETTING_T rVP9; + VCODEC_ENC_GENERAL_SETTING_T rVP8; +} VCODEC_ENC_SETTING_T; + +typedef struct { + unsigned char *pu1ParamStream; + unsigned int u4ParamLength; + unsigned int u4Width; + unsigned int u4Height; +} VCODEC_DEC_QUERY_FRAME_SIZE_TYPE_T; + +typedef enum { + DISPLAY_CURRENT, /* Normal dispaly */ + REPEAT_LAST, /* Frame skipping , error handling */ + NOT_DISPLAY, /* for vp8, error handling */ + LAST_FRAME, /* EOF */ + NO_PIC, /* buffering */ + NOT_USED, /* H.264 multi-slice */ + DISPLAY_CURRENT_INTERLACE, /* interlace dispaly */ + NUM_OF_DISPLAY_FRAME_STATUS +} VCODEC_DEC_DISPLAY_FRAME_STATUS; + +typedef struct { + int i4AspectRatioWidth; /* width aspect ratio */ + int i4AspectRatioHeight; /* height aspect ratio */ + /* unsigned int u4IntraMBNum; */ + /* unsigned int u4InterFMBNum; */ + /* unsigned int u4InterBMBNum; */ + /* unsigned int u4SkipMBNum; */ + void *prExtra; +} VCODEC_DEC_PRIVATE_OUTPUT_EXTRA_T; + +typedef struct { + UINT64 u8TimeStamp; + int fgUpdateTime; /* update time stamp */ + unsigned short u2FrameWidth; /* Full Frame Size */ + unsigned short u2FrameHeight; /* Full Frame Size */ + unsigned short u2ClipTop; + unsigned short u2ClipBottom; + unsigned short u2ClipLeft; + unsigned short u2ClipRight; + VCODEC_FRAME_TYPE_T eFrameType; + VCODEC_BUFFER_T rYStartAddr; /*YUV buffer start address, include padding up and left*/ + VCODEC_BUFFER_T rUStartAddr; + VCODEC_BUFFER_T rVStartAddr; + VCODEC_DEC_DISPLAY_FRAME_STATUS eDisplayFrameStatus; + void *prExtra; +} VCODEC_DEC_PRIVATE_OUTPUT_T; + + + +typedef void VCODEC_DEC_INPUT_DATA_T; + +typedef enum { + INPUT_FLAG_STREAM_DATA_TYPE = 0x01, /* Bit 0 = 1: Slice base data(non-frame base) ; 0: Frame base data*/ + INPUT_FLAG_STARTTIME = 0x02, /* seek start time at end of seek */ + INPUT_FLAG_DECODEONLY = 0x04, /* seek */ + /* H.264 for SPS,PPS issue, send first frame bitstream for set parameter*/ + INPUT_FLAG_PARAMETERSET = 0x08, + INPUT_FLAG_CUSTOM_SETTING = 0x10, /* Get max external memory size(VE)*/ + INPUT_FLAG_DECODE_INTRA_ONLY = 0x20, /* Only Decode Intra Frame */ + INPUT_FLAG_OPENAPI = 0x40, /* OPENAPI */ + INPUT_FLAG_DECODE_MODE = 0x80, /* Decode Mode */ + INPUT_FLAG_LEGACY_MODE = 0x100, /* legacy Mode */ + INPUT_FLAG_MAX_DEC +} VCODEC_DEC_INPUT_FLAG_T; + +typedef struct { + UINT64 u8TimeStamp; + unsigned int eFlags; /* VCODEC_DEC_INPUT_FLAG_T */ + VCODEC_DEC_INPUT_DATA_T *prInputData; + VCODEC_BUFFER_T *prBuffer; /* Input data address */ + unsigned int u4BuffSize; /* Input buffer total size */ + void *prExtra; +} VCODEC_DEC_INPUT_T; + + + + + + +typedef struct { + unsigned int u4Width; /* Full size 16 byte align */ + unsigned int u4Height; /* Full size 16 byte align */ + unsigned short u2ClipTop; + unsigned short u2ClipBottom; + unsigned short u2ClipLeft; + unsigned short u2ClipRight; + unsigned int u4Offset; /* Offset of YUV buffer start address */ + unsigned int u4ReduceLength; /* Padding size(End of YUV buffer pool) */ + unsigned char u1Alignment; /* YUV buffer address alignment */ + VCODEC_MEMORY_TYPE_T rYUVBUfferMemType; /* YUV buffer memory type */ + unsigned int u4MaxBufferNum; + unsigned int u4ExtraBufferNum; + void *prExtra; +} VCODEC_DEC_OUTPUT_BUFFER_PARAM_T; + +typedef struct { + VCODEC_MEMORY_TYPE_T rBitStreamBufferMemType; /* bitstream buffer memory type */ + unsigned int u4MaxBufferNum; + void *PrivateData[4]; +} VCODEC_DEC_INPUT_BUFFER_PARAM_T; + +typedef struct { + VCODEC_BUFFER_T rYBuffer; + VCODEC_BUFFER_T rUBuffer; + VCODEC_BUFFER_T rVBuffer; +} VCODEC_DEC_INPUT_YUV_INFO_T; + +/* non-callback */ +#define MAX_BITSTREAM_BUFFER_INFO_NUM 10 +#define MAX_REF_FREE_YUV_BUFFER_NUM 19 +typedef struct { + VCODEC_BUFFER_T *prRetBitsBuf; /* for mt6575, mt6577 */ + unsigned int u4ReturnInputCnt; + VCODEC_BUFFER_T rReturnInput[MAX_BITSTREAM_BUFFER_INFO_NUM]; + unsigned int u4RefFreeYUVBufCnt; + VCODEC_DEC_INPUT_YUV_INFO_T parRefFreeYUVBuf[MAX_REF_FREE_YUV_BUFFER_NUM]; +} VCODEC_DEC_OUTPUT_PARAM_T; +/* ~non-callback */ + +typedef struct { + unsigned int u4SupportWidth; + unsigned int u4SupportHeight; + unsigned int u4SupportResolution; + unsigned int u4SupportProfile; + unsigned int u4SupportLevel; +} VCODEC_DEC_CAPABILITY_T; + +typedef struct { + void (*pfnMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + IN VCODEC_MEMORY_TYPE_T /* fgCacheable */, + OUT VCODEC_BUFFER_T * /* prBuf */ + ); /* buffer address must cache line align */ + + void (*pfnIntMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + OUT VCODEC_BUFFER_T * /* pBuffer_adr */ + ); + + void (*pfnFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuf */ + ); /* same memory type with malloc */ + + void (*pfnIntFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* pBuffer_adr */ + ); + + VCODEC_DEC_ERROR_T(*pfnSetYUVBuffer)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_OUTPUT_BUFFER_PARAM_T * /* prYUVParam */ + ); + + VCODEC_DEC_ERROR_T(*pfnGetYUVBuffer)(IN HANDLE /* hDrv */, + OUT VCODEC_DEC_INPUT_YUV_INFO_T * /* prYUVBuf */ + ); + + void (*pfnRefFreeYUVBuffer)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_INPUT_YUV_INFO_T * /* prYUVBuf */ + ); + + VCODEC_DEC_ERROR_T(*pfnQueryInfo)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_QUERY_INFO_TYPE_T /* query id*/, + OUT void * /* pvParamData*/ /* */ + ); + + void (*pfnReturnBitstream)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuffer */ /* Input buffer address */, + IN unsigned int /* u4BuffSize */ /* Input buffer total size */ + ); + +} VCODEC_DEC_CALLBACK_T; + + +/* non-callback */ +typedef struct { + VCODEC_DEC_INPUT_T *prInputData; + VCODEC_DEC_INPUT_YUV_INFO_T *prYUVBufAddr; /* prYUVBuf */ +} VIDEO_DECODER_INPUT_NC_T; + + + +typedef struct { + VCODEC_DEC_ERROR_T(*pfnGetCodecRequired)(IN VCODEC_DEC_INPUT_T * /* prInput */ , + OUT VCODEC_MEMORY_SIZE_T * /* prMemSize */, + OUT VCODEC_DEC_OUTPUT_BUFFER_PARAM_T * /* prBufferParameter*/, + OUT VCODEC_DEC_INPUT_BUFFER_PARAM_T * /* prBitStreamParameter */, + INOUT void * /* reserve */ + ); + + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnOpen)(IN HANDLE, /* hDrv */ + IN VCODEC_DEC_CALLBACK_T *, /* pfnCallback */ + IN void *, /* open setting */ + OUT HANDLE * , /* hCodec */ + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnClose)(IN HANDLE , /* hCodec */ + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnInit)(IN HANDLE , /* hCodec */ + INOUT void * /* reserve */ + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnDeInit)( + IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + OUT VCODEC_DEC_OUTPUT_PARAM_T * *, /* for smart phone */ + INOUT void * /* reserve */); + + VCODEC_DEC_ERROR_T(*pfnGetParameter)(IN HANDLE, /* hCodec */ + IN VCODEC_DEC_PARAM_TYPE_T, + INOUT void * /* pvParamData */ + ); + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnSetParameter)(IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + IN VCODEC_DEC_PARAM_TYPE_T, /* eParamType */ + IN void * , /* pvParamData */ + INOUT void * /* reserve */ + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnDecodeOneUnit)( + IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + IN VIDEO_DECODER_INPUT_NC_T *, /* prInput */ + OUT VCODEC_DEC_OUTPUT_PARAM_T * *, /* for smart phone */ + INOUT void * /* reserve */ + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnGetNextDisplay)(IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + OUT VCODEC_DEC_PRIVATE_OUTPUT_T * , /* prPrivOutput */ + INOUT void * /* reserve */ + ); +} VIDEO_DEC_API_T; +/* ~non-callback */ + + + + + + + +typedef struct { + + VCODEC_DEC_ERROR_T(*pfnGetCodecRequired)(IN VCODEC_DEC_INPUT_T * /* prInput */ , + OUT VCODEC_MEMORY_SIZE_T * /* prMemSize */, + /* prBufferParameter*/ + OUT VCODEC_DEC_OUTPUT_BUFFER_PARAM_T * , + /*prBitStreamParameter */ + OUT VCODEC_DEC_INPUT_BUFFER_PARAM_T * , + INOUT void * /* reserve */ + ); + + + VCODEC_DEC_ERROR_T(*pfnOpen)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_CALLBACK_T * /* pfnCallback */, + IN void * /* prOpenSetting */, + OUT HANDLE * /* hCodec */ , + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnClose)(IN HANDLE /* hCodec */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnInit)(IN HANDLE /* hCodec */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnDeInit)(IN HANDLE /* hCodec */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnGetParameter)(IN HANDLE /* hCodec */, + IN VCODEC_DEC_PARAM_TYPE_T /* eParamType */, + INOUT void * /* pvParamData */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnSetParameter)(IN HANDLE /* hCodec */, + IN VCODEC_DEC_PARAM_TYPE_T /* eParamType */, + IN void * /* pvParamData */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnDecodeOneUnit)(IN HANDLE /* hCodec */, + IN VCODEC_DEC_INPUT_T * /* prInput */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnGetNextDisplay)(IN HANDLE /* hCodec */, + OUT VCODEC_DEC_PRIVATE_OUTPUT_T * /* prPrivOutput */, + INOUT void * /* reserve */ + ); + + + + +} VCODEC_DEC_API_T; + +typedef struct { + VIDEO_DEC_API_T rVideoDecAPI; + VCODEC_DEC_API_T *pfnVcodecDecAPI; + VCODEC_DEC_INPUT_YUV_INFO_T rGetYUVBuf; + VCODEC_BUFFER_T rRetBitsBuf; + VCODEC_DEC_OUTPUT_PARAM_T rDecoderOutputParam; + unsigned int fgTookYUVBuff; + HANDLE hDriver; +} VIDEO_WRAP_HANDLE_T; + + +#define VCODEC_ENC_MAX_PKTS_IN_SET 99 +#define VCODEC_ENC_MAX_NALS_IN_SET 10 + +typedef struct { + void *u4Addr; + unsigned int u4Size; +} VCODEC_ENC_CODEC_PACKET_INFO_T; + + +/* Note the first two items in the next structure must be (in order): */ +/* 1. number of Packets */ +/* 2. pointer to the packet info */ +typedef struct { + unsigned int u4NumOfPkts; + VCODEC_ENC_CODEC_PACKET_INFO_T arPktInfo[VCODEC_ENC_MAX_PKTS_IN_SET]; +} VCODEC_ENC_PACKET_SET_T; + + +typedef struct { + int u4NalUnitType; + void *u4Addr; /* p_payload */ + unsigned int u4Size; /* i_payload */ +} VCODEC_ENC_CODEC_NAL_INFO_T; + +typedef struct { + unsigned int u4NumOfNals; + VCODEC_ENC_CODEC_NAL_INFO_T arNalInfo[VCODEC_ENC_MAX_NALS_IN_SET]; +} VCODEC_ENC_NAL_SET_T; + +typedef enum { + MPEG4_RECODER, + MPEG4_VT, + H264_RECODER, + H264_VT, + NUM_OF_ENC_CODEC_TYPE +} VCODEC_ENC_CODEC_TYPE_T; + +typedef struct { + VCODEC_FRAME_TYPE_T eFrameType; + /* added to merge remained individual parameters in the phototype */ + VCODEC_BUFFER_T rBitstreamAddr; + unsigned int u4BitstreamLength; + int fgEndOfFrame; + void *prChassis; + VCODEC_ENC_CODEC_TYPE_T eCodecType; + UINT64 u8TimeStamp; + void *reserved[4]; +} VCODEC_ENC_GENERAL_OUTPUT_T; + +typedef struct { + VCODEC_BUFFER_T rStartAddr; + VCODEC_BUFFER_T rEndAddr; + VCODEC_BUFFER_T rWriteAddr; + VCODEC_BUFFER_T rReadAddr; + unsigned int u4BufferLength; +} VCODEC_ENC_BUFFER_INFO_T; + + +typedef enum { + INPUT_FLAG_YUVBUFFER = 0x01, + INPUT_FLAG_NO_INPUT = 0x02, + INPUT_FLAG_NO_MORE_INPUT = 0x03, + INPUT_FLAG_MAX_ENC +} VCODEC_ENC_INPUT_FLAG_T; + +typedef struct { + VCODEC_BUFFER_T rYUVBuffer; + unsigned int u4Length; +} VCODEC_ENC_INPUT_INFO_T; + +typedef struct { + VCODEC_BUFFER_T rYBuffer; + VCODEC_BUFFER_T rUBuffer; + VCODEC_BUFFER_T rVBuffer; + unsigned int u4Length; +} VCODEC_ENC_INPUT_YUV_INFO_T; + + + +typedef struct { + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_INFO_T rInput; +} VCODEC_ENC_INPUT_PARAM_T; + +typedef struct { + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_YUV_INFO_T rInput; + void *prExtra; +} VCODEC_ENC_INPUT_YUV_PARAM_T; + +typedef struct { + VCODEC_BUFFER_T rWp; + int fgSliceContained; +} VCODEC_ENC_UPDATE_WP_INTO_T; + +typedef enum { + VCODEC_ENC_ERROR_NONE, + VCODEC_ENC_ERROR, + VCODEC_ENC_ASSERT_FAIL, + VCODEC_ENC_BS_BUFFER_NOT_ENOUGH, + VCODEC_ENC_INPUT_REJECT, + VCODEC_ENC_PARAM_NOT_SUPPORT, + NUM_OF_ENC_ERROR_TYPE +} VCODEC_ENC_ERROR_T; + + +typedef enum { + /* Query ext/int memory requirement for adaptation */ + VCODEC_ENC_PARAM_MEMORY_REQUIREMENT, + /* Query the prefer memory type of bitstream buffer, return true means cacheable buffer is preferred */ + VCODEC_ENC_PARAM_BITSTREAM_IN_CACHE, + /* Query the alignment needed on frame buffer for codec */ + VCODEC_ENC_PARAM_FRM_BUFFER_ALIGNMENT, + VCODEC_ENC_PARAM_HOLD_RES_TILL_RELEASE_FRM, + VCODEC_ENC_PARAM_IS_BLOCKBASED_YUV, + VCODEC_ENC_PARAM_DECODER_CONFIGURATION_RECORD, + VCODEC_ENC_PARAM_IF_ADAPTOR_MODIFY_TIMESTAMP, + VCODEC_ENC_PARAM_WIDTH, + VCODEC_ENC_PARAM_HEIGHT, + VCODEC_ENC_PARAM_BITRATE, + VCODEC_ENC_PARAM_FRAME_RATE, + VCODEC_ENC_PARAM_FRAME_RATE_NUM, + VCODEC_ENC_PARAM_FRAME_RATE_DEN, + VCDOEC_ENC_PARAM_AUD, + VCODEC_ENC_PARAM_REPEAD_HEADERS, + VCODEC_ENC_PARAM_ANNEXB, + VCODEC_ENC_PARAM_GEN_HEADER_FRM_RATE, + VCODEC_ENC_PARAM_SHORT_HEADER, + VCODEC_ENC_PARAM_SYNC_INTERVAL, + VCODEC_ENC_PARAM_MAX_PKG_SIZE, + VCODEC_ENC_PARAM_FORCE_ENCODE_I, + VCODEC_ENC_PARAM_QUALITY, + VCODEC_ENC_PARAM_SCENARIO, + VCODEC_ENC_PARAM_CODEC_TYPE, + VCODEC_ENC_PARAM_VT_RESTART, + VCODEC_ENC_PARAM_ROTATE, + VCODEC_ENC_PARAM_SET_CALLBACK, + VCODEC_ENC_PARAM_SET_NO_MORE_INPUT, + VCODEC_ENC_PARAM_NUM_OF_HW_CTRL_THID, + /* Get registered HW control thread id , output structure : VCODEC_REG_HW_CTRL_THID_T */ + VCODEC_ENC_PARAM_GET_REG_HW_CTRL_THID, + VCODEC_ENC_PARAM_SET_COLOR_FORMAT, + VCODEC_ENC_PARAM_SET_YUV_STRIDE_ALIGNMENT, + VCODEC_ENC_PARAM_SET_AVAILABLE_CPU_NUM, + /* enable or disable MCI mechanism */ + VCODEC_ENC_PARAM_SET_MCI, + VCODEC_ENC_PARAM_WPP, + VCODEC_ENC_PARAM_CONSTQ, + VCODEC_ENC_PARAM_RC_VERSION, + VCODEC_ENC_PARAM_INIT_QP, + VCODEC_ENC_PARAM_MAX_QP, + VCODEC_ENC_PARAM_MIN_QP, + VCODEC_ENC_PARAM_NUM_OF_SLICE, + VCODEC_ENC_PARAM_PROFILE, + VCODEC_ENC_PARAM_LEVEL, + VCODEC_ENC_PARAM_THREADS, + VCODEC_ENC_PARAM_VP8_TOKEN_PARTITIONS, + VCODEC_ENC_PARAM_VP9_ENABLE_TILES, + VCODEC_ENC_PARAM_VPX_ERR_RESILIENT, + VCODEC_ENC_PARAM_VPX_NUMBER_OF_LAYERS, + VCODEC_ENC_PARAM_VPX_MODE, + VCODEC_ENC_PARAM_VPX_CPU_USED, + VCODEC_ENC_PARAM_YUV_STRIDE, + NUM_OF_ENC_PARAM_TYPE +} VCODEC_ENC_PARAM_TYPE_T; + +typedef enum { + VCODEC_ENC_QUERY_INFO_TOTAL_FRAME_BUFFER, /* Total frame buffer size */ + VCODEC_ENC_QUERY_INFO_FRAMES_QUEUED, /* Number of frames waited to encoder */ + VCODEC_ENC_QUERY_INFO_VTBUFFER_FULLNESS_DENOM, /* Denominator of VT buffer fullness */ + VCODEC_ENC_QUERY_INFO_VTBUFFER_FULLNESS_NUM, /* Numerator of VT buffer fullness */ + VCODEC_ENC_QUERY_INFO_INIT_Q, /* Used by codec */ + VCODEC_ENC_QUERY_INFO_MIN_QP, /* Used by codec */ + VCODEC_ENC_QUERY_INFO_MAX_QP, /* Used by codec */ + VCODEC_ENC_QUERY_INFO_INTRA_VOP_RATE, /* Used by MED/codec */ + VCODEC_ENC_QUERY_INFO_ALGORITHM, /* Used by codec */ + VCODEC_ENC_QUERY_INFO_BIT_RATE, /* Used by MED/codec */ + VCODEC_ENC_QUERY_INFO_RATE_HARD_LIMIT, /* Used by codec */ + VCODEC_ENC_QUERY_INFO_RATE_BALANCE, /* Used by codec */ + VCODEC_ENC_QUERY_INFO_DYNAMIC_RANGE_REDUCTION, + VCODEC_ENC_QUERY_INFO_IF_CUSTOMER_SET_TABLE, + VCODEC_ENC_QUERY_INFO_DYNAMIC_RANGE_TABLE, + VCODEC_ENC_QUERY_INFO_OAL_FUNCTION, + VCODEC_ENC_QUERY_INFO_ENCODER_FRAME_RATE, /* Used by H.264 recoder */ + VCODEC_ENC_QUERY_INFO_TARGET_COMPLEXITY, /* Used by H.264 recoder */ + VCODEC_ENC_QUERY_INFO_THRESHOLD_AVG_LOW, /* Used by H.264 recoder */ + VCODEC_ENC_QUERY_INFO_THRESHOLD_AVG_HIGH, /* Used by H.264 recoder */ + VCODEC_ENC_QUERY_INFO_THRESHOLD_CUR_LOW, /* Used by H.264 recoder */ + VCODEC_ENC_QUERY_INFO_THRESHOLD_CUR_HIGH, /* Used by H.264 recoder */ + /* VCODEC_ENC_QUERY_INFO_OAL_FUNCTION_SMP, */ + VCODEC_ENC_QUERY_INFO_VPX_CPU_USED, + VCODEC_ENC_QUERY_INFO_VPX_MODE, + VCODEC_ENC_QUERY_INFO_FIXED_QP, + VCODEC_ENC_QUERY_INFO_SCENARIO, + NUM_OF_ENC_QUERY_INFO_TYPE +} VCODEC_ENC_QUERY_INFO_TYPE_T; + +/********************************************************************** + + + Encoder enumerations + + **********************************************************************/ + +/* clock-wise */ +typedef enum { + VCODEC_ENC_ROTATE_0 = 0, + VCODEC_ENC_ROTATE_90 = 1, + VCODEC_ENC_ROTATE_180 = 2, + VCODEC_ENC_ROTATE_270 = 3 +} VCODEC_ENC_ROTATE_ANGLE_T; + +typedef enum { + VCODEC_ENC_QUALITY_NONE, + VCODEC_ENC_QUALITY_LOW, + VCODEC_ENC_QUALITY_NORMAL, + VCODEC_ENC_QUALITY_GOOD, + VCODEC_ENC_QUALITY_FINE, + VCODEC_ENC_QUALITY_CUSTOM +} VCODEC_ENC_QUALITY_T; + +typedef enum { + VCODEC_ENC_CODEC_TYPE_NONE, + VCODEC_ENC_CODEC_TYPE_MPEG4, + VCODEC_ENC_CODEC_TYPE_H263, + VCODEC_ENC_CODEC_TYPE_H264 +} VCODEC_ENC_CODEC_T; + +typedef struct { + + void (*pfnMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + IN VCODEC_MEMORY_TYPE_T /* fgCacheable */, + OUT VCODEC_BUFFER_T * /* prBuf */ + ); /*buffer address must cache line align */ + + void (*pfnIntMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + OUT VCODEC_BUFFER_T * /* prBuffer_adr */ + ); + + + void (*pfnFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuf */ + ); /* same memory type with malloc */ + + + void (*pfnIntFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuffer_adr */ + ); + + void (*pfnReleaseYUV)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prYUVBuf */ + ); + + void (*pfnPaused)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBitstreamBuf */ + ); + + void (*pfnAllocateBitstreamBuffer)(IN HANDLE /* hDrv */, + OUT VCODEC_ENC_BUFFER_INFO_T * /* prBitstreamBuf */ + ); + + void (*pfnUpdateBitstreamWP)(IN HANDLE /* hDrv */, + IN VCODEC_ENC_UPDATE_WP_INTO_T * /* prUpdateWritePointer */ + ); + VCODEC_ENC_ERROR_T(*pfnQueryInfo)(IN HANDLE /* hDrv */, + IN VCODEC_ENC_QUERY_INFO_TYPE_T /* query id*/, + OUT void * /* pvParamData*/ + ); + + +} VCODEC_ENC_CALLBACK_T; + +/* non-callback */ +typedef struct { + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_INFO_T rInput; + VCODEC_ENC_BUFFER_INFO_T pBuffInfo; + VCODEC_COLOR_FORMAT_T eVEncFormat; + unsigned int u4Width; + unsigned int u4Height; + unsigned int u4YStride; + unsigned int u4UVStride; + unsigned int u4SliceHeight; + void *reserved[4]; +} VIDEO_ENCODER_INPUT_PARAM_NC_T; +/* non-callback */ +typedef struct { + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_YUV_INFO_T rInput; + VCODEC_ENC_BUFFER_INFO_T pBuffInfo; + VCODEC_COLOR_FORMAT_T eVEncFormat; + unsigned int u4Width; + unsigned int u4Height; + unsigned int u4YStride; + unsigned int u4UVStride; + unsigned int u4SliceHeight; + void *reserved[4]; +} VIDEO_ENCODER_INPUT_YUV_PARAM_NC_T; + +typedef struct { + VCODEC_ENC_ERROR_T(*pfnGetMemoryRequired)( + IN VCODEC_ENC_SETTING_T * rCodecFormat, + OUT VCODEC_MEMORY_SIZE_T * prExternalSize + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_ENC_ERROR_T(*pfnOpen)(IN HANDLE hDrv, + IN HANDLE hWrapper, + IN VCODEC_ENC_CALLBACK_T * , + OUT HANDLE *hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnInit)(IN HANDLE hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnGetParameter)(IN HANDLE hCodec, + OUT VCODEC_ENC_PARAM_TYPE_T, /*VIDEO_ENC_MEMORY_T,*/ + void * + ); + + VCODEC_ENC_ERROR_T(*pfnSetParameter)(IN HANDLE hCodec, + /*VIDEO_ENCODER_QUALITY_T, + VIDEO_ENCODER_CODEC_T, + VIDEO_CODEC_ROTATE_ANGLE_T,*/ + IN VCODEC_ENC_PARAM_TYPE_T, + void * + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_ENC_ERROR_T(*pfnGenerateHeader)(IN HANDLE hCodec, + IN HANDLE hWrapper, + IN VCODEC_ENC_BUFFER_INFO_T *prBufferInfo /* for smart phone */ + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_ENC_ERROR_T(*pfnEncodeOneUnit)(IN HANDLE hCodec, + IN HANDLE hWrapper, + IN VIDEO_ENCODER_INPUT_YUV_PARAM_NC_T * prEncoderInputParamNC); + + VCODEC_ENC_ERROR_T(*pfnDeInit)(IN HANDLE hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnClose)(IN HANDLE hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnGetNextBitstream)(IN HANDLE hCodec, + OUT VCODEC_ENC_GENERAL_OUTPUT_T * + ); +} VIDEO_ENC_API_T; + + +/* ~non-callback */ + +typedef struct { + VCODEC_ENC_ERROR_T(*pfnGetMemoryRequired)(IN VCODEC_ENC_SETTING_T *, /*prInput*/ + OUT VCODEC_MEMORY_SIZE_T * /*prExternalSize*/ + ); + + VCODEC_ENC_ERROR_T(*pfnOpen)(IN HANDLE /* hDrv */, + IN VCODEC_ENC_CALLBACK_T * /* pfnCallback */, + OUT HANDLE * /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnInit)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnGetParameter)(IN HANDLE /* hCodec */, + IN VCODEC_ENC_PARAM_TYPE_T /*VIDEO_ENC_MEMORY_T,*/, + OUT void * /* pvParamData */ + ); + + VCODEC_ENC_ERROR_T(*pfnSetParameter)(IN HANDLE /* hCodec */, + /*VCODEC_ENC_QUALITY_T,VCODEC_ENC_CODEC_T,VIDEO_CODEC_ROTATE_ANGLE_T,*/ + IN VCODEC_ENC_PARAM_TYPE_T /* rEncodeParam*/, + IN void * /* pvParamData */ + ); + + VCODEC_ENC_ERROR_T(*pfnGenerateHeader)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnEncodeOneUnit)(IN HANDLE /* hCodec */, + /*prInput*/ /*VCODEC_ENC_INPUT_YUV_INFO_T , VCODEC_ENC_INPUT_INFO_T*/ + IN void * + ); + VCODEC_ENC_ERROR_T(*pfnDeInit)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnClose)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnGetNextBitstream)(IN HANDLE /* hCodec */, + OUT VCODEC_ENC_GENERAL_OUTPUT_T * /* prPrivOutput*/ + ); +} VCODEC_ENC_API_T; + +typedef struct { + VIDEO_ENC_API_T rVideoEncAPI; + VCODEC_ENC_API_T *pfnVcodecEncAPI; + HANDLE hDriver; + VCODEC_BUFFER_T rReleaseYUV; + VCODEC_ENC_BUFFER_INFO_T rEncoderBuffInfoNC; + unsigned int u4EncType;// for sw venc type +} VIDEO_ENC_WRAP_HANDLE_T; + +typedef struct { + unsigned int u4TimeIncrResolution; + unsigned int u4BufferSize; + VCODEC_BUFFER_T *prBuffer; +} MPEG4_VT_ENCODER_GEN_VT_HEADER_INPUT_T; + +VCODEC_ENC_ERROR_T MPEG4EncoderGenerateVTHeader( + IN MPEG4_VT_ENCODER_GEN_VT_HEADER_INPUT_T * prInput, + OUT unsigned int *pu4EncodedSize +); + + + + + + +#endif /* VCODEC_IF_H */ diff --git a/kernel-headers/vcodec_log.h b/kernel-headers/vcodec_log.h new file mode 100644 index 0000000..ac4abf1 --- /dev/null +++ b/kernel-headers/vcodec_log.h @@ -0,0 +1,134 @@ +#ifndef VCODEC_LOG_H +#define VCODEC_LOG_H + +#include "vcodec_if_v2.h" + +#define lmx_prt(a, b, c) + +/* Add your index here */ +typedef enum { + /* MPEG4 ENCODER */ + VCODEC_LOG_INDEX_MP4ENC_ENCODE_ERROR, + VCODEC_LOG_INDEX_MP4ENC_ERROR_GET_BITSTREAM, + VCODEC_LOG_INDEX_MP4ENC_ALLOCATE_EXT_MEMORY, + VCODEC_LOG_INDEX_MP4ENC_FREE_EXT_MEMORY, + VCODEC_LOG_INDEX_MP4ENC_QPHDR, + VCODEC_LOG_INDEX_MP4ENC_FRAMETYPE, + VCODEC_LOG_INDEX_MP4ENC_SETTING, + VCODEC_LOG_INDEX_MP4ENC_GET_BITSTREAM, + + /* MPEG4 DECODER */ + VCODEC_LOG_INDEX_MP4DEC_DECODE_ERROR, + VCODEC_LOG_INDEX_MP4DEC_DECODE_FIRST_FRAME, + VCODEC_LOG_INDEX_MP4DEC_DECODE_VOP_TYPE, + VCODEC_LOG_INDEX_MP4DEC_DECODE_RESOLUTION, + VCODEC_LOG_INDEX_MP4DEC_DECODE_EOF, + VCODEC_LOG_INDEX_MP4DEC_SET_FRAME_RATE, + VCODEC_LOG_INDEX_MP4DEC_SET_BIT_RATE, + VCODEC_LOG_INDEX_SWMP4DEC_LOSSY_INIT_QTY, + VCODEC_LOG_INDEX_SWMP4DEC_LOSSY_INIT_DSWITCH, + VCODEC_LOG_INDEX_SWMP4DEC_LOSSY_SWITCH_QTY, + + /* RMVB DECODER */ + VCODEC_LOG_INDEX_RMDEC_DECODE_RESULT1, + VCODEC_LOG_INDEX_RMDEC_DECODE_RESULT2, + VCODEC_LOG_INDEX_RMDEC_ERROR_FRM, + VCODEC_LOG_INDEX_RMDEC_DECODE_ERROR, + VCODEC_LOG_INDEX_RMDEC_HOLD_PIC_TYPE_ERROR, + VCODEC_LOG_INDEX_RMDEC_UNKNOW_ERROR, + VCODEC_LOG_INDEX_RMDEC_TIMESTAMP1, + VCODEC_LOG_INDEX_RMDEC_TIMESTAMP2, + VCODEC_LOG_INDEX_RMDEC_SKIP_FRM, + VCODEC_LOG_INDEX_RMDEC_SKIP_SETTING2, + VCODEC_LOG_INDEX_RMDEC_STANDARD_DEC, + VCODEC_LOG_INDEX_RMDEC_LOSSY_DEC, + VCODEC_LOG_INDEX_RMDEC_OPEN, + VCODEC_LOG_INDEX_RMDEC_CLOSE, + VCODEC_LOG_INDEX_RMDEC_UNSUPPORT, + + /* H.264 DECODER */ + VCODEC_LOG_INDEX_H264DEC_INIT, + VCODEC_LOG_INDEX_H264DEC_DEINIT, + VCODEC_LOG_INDEX_H264DEC_OPEN, + VCODEC_LOG_INDEX_H264DEC_CLOSE, + VCODEC_LOG_INDEX_H264DEC_INIT_ERROR, + VCODEC_LOG_INDEX_H264DEC_DECODE_RESULT, + VCODEC_LOG_INDEX_H264DEC_DECODE_ERROR, + VCODEC_LOG_INDEX_H264DEC_ARGUMENT_ERROR, + VCODEC_LOG_INDEX_H264DEC_SUPPORT_ERROR, + VCODEC_LOG_INDEX_H264DEC_DECODING_CONCEAL, + VCODEC_LOG_INDEX_H264DEC_DISPLAY_INFO, + VCODEC_LOG_INDEX_H264DEC_CROP_INFO, + VCODEC_LOG_INDEX_H264DEC_BITSTREAM_INFO, + VCODEC_LOG_INDEX_H264DEC_PAYLOAD_INFO, + VCODEC_LOG_INDEX_H264DEC_CHANGE_SPS, + VCODEC_LOG_INDEX_H264DEC_ABNORMAL_NALU_SIZE, + VCODEC_LOG_INDEX_H264DEC_HEADER_ERROR, + VCODEC_LOG_INDEX_H264DEC_OUTPUT_IDR, + VCODEC_LOG_INDEX_H264DEC_ALIGN_ERROR, + VCODEC_LOG_INDEX_H264DEC_ALLOCATE_ERROR, + VCODEC_LOG_INDEX_SWH264DEC_LOSSY_INIT_QTY, + VCODEC_LOG_INDEX_SWH264DEC_LOSSY_INIT_DSWITCH, + VCODEC_LOG_INDEX_SWH264DEC_LOSSY_SWITCH_QTY, + VCODEC_LOG_INDEX_SWH264DEC_MEM_ALLOCATE, + VCODEC_LOG_INDEX_SWH264DEC_DPB_INIT, + VCODEC_LOG_INDEX_SWH264DEC_DPB_MARK_REFPIC, + VCODEC_LOG_INDEX_SWH264DEC_CONCEAL, + VCODEC_LOG_INDEX_SWH264DEC_OUTPIC1, + VCODEC_LOG_INDEX_SWH264DEC_OUTPIC2, + VCODEC_LOG_INDEX_SWH264DEC_SPSDPB_CHECK, + VCODEC_LOG_INDEX_H264DEC_SKIPB, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_INIT, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_INFO, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_BP, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_MPHP, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_STATUS, + VCODEC_LOG_INDEX_H264ENC_STREAMBUFFER_ALLOC, + VCODEC_LOG_INDEX_H264ENC_STREAMBUFFER_UPDATE, + VCODEC_LOG_INDEX_MAX +} VCODEC_LOG_INDEX_T; + +typedef enum { + VCODEC_LOG_GROUP_HIGH, + VCODEC_LOG_GROUP_MEDIUM, + VCODEC_LOG_GROUP_LOW, + VCODEC_LOG_GROUP_MAX +} VCODEC_LOG_GROUP_T; + +void VcodecTraceLog0( + VCODEC_LOG_GROUP_T eGroup, + VCODEC_LOG_INDEX_T eIndex +); +void VcodecTraceLog1( + VCODEC_LOG_GROUP_T eGroup, + VCODEC_LOG_INDEX_T eIndex, + UINT64 arg +); +void VcodecTraceLog2( + VCODEC_LOG_GROUP_T eGroup, + VCODEC_LOG_INDEX_T eIndex, + UINT64 arg1, + UINT64 arg2 +); +void VcodecTraceLog4( + VCODEC_LOG_GROUP_T eGroup, + VCODEC_LOG_INDEX_T eIndex, + UINT64 arg1, + UINT64 arg2, + UINT64 arg3, + UINT64 arg4 +); +void VcodecTraceLog8( + VCODEC_LOG_GROUP_T eGroup, + VCODEC_LOG_INDEX_T eIndex, + UINT64 arg1, + UINT64 arg2, + UINT64 arg3, + UINT64 arg4, + UINT64 arg5, + UINT64 arg6, + UINT64 arg7, + UINT64 arg8 +); +#endif /* VCODEC_LOG_H */ diff --git a/kernel-headers/vdec_drv_base.h b/kernel-headers/vdec_drv_base.h new file mode 100644 index 0000000..3bd80d2 --- /dev/null +++ b/kernel-headers/vdec_drv_base.h @@ -0,0 +1,128 @@ +#define DumpInput__ +#ifdef DumpInput__ +#include <stdio.h> +#endif +#include "vdec_drv_if_private.h" + +#ifndef _VDEC_DRV_BASE_ +#define _VDEC_DRV_BASE_ +#define MAX_BUFFER_SIZE 37 + +#if 1 +#define WAITING_MODE VAL_INTERRUPT_MODE +#else +#define WAITING_MODE VAL_POLLING_MODE +#endif + +#define DO_VCODEC_RESET(cmd, index) \ + { \ + ADD_QUEUE(cmd, index, WRITE_REG_CMD, MT6589_VDEC_MISC, VDEC_INT_CFG, 0 , WAITING_MODE); \ + } + +typedef enum __VDDRV_MRESULT_T { + VDDRV_MRESULT_SUCCESS = VAL_TRUE, /* /< Represent success */ + VDDRV_MRESULT_FAIL = VAL_FALSE, /* /< Represent failure */ + VDDRV_MRESULT_RESOLUTION_CHANGED = VAL_RESOLUTION_CHANGED, /* /< Represent resoluion changed */ + VDDRV_MRESULT_NEED_MORE_OUTPUT_BUFFER, /* /< Represent need more output buffer */ + VDDRV_MRESULT_FATAL +} VDDRV_MRESULT_T; + +typedef struct __VDEC_DRV_BASE_T { + VAL_UINT32_T(*Init)( + VAL_HANDLE_T * handle, + VAL_HANDLE_T halhandle, + VAL_HANDLE_T valhandle, + P_VDEC_DRV_RINGBUF_T pBitstream, + P_VDEC_DRV_SEQINFO_T pSeqinfo, + VDEC_DRV_VIDEO_FORMAT_T eFormat + ); + VAL_UINT32_T(*Decode)( + VAL_HANDLE_T handle, + P_VDEC_DRV_RINGBUF_T pBitstream, + P_VDEC_DRV_FRAMEBUF_T pFrame + ); /* /< Driver Decode Main Funciton */ + P_VDEC_DRV_FRAMEBUF_T(*GetDisplayBuffer)( + VAL_HANDLE_T handle + ); /* /< Get Buffer ready to display */ + P_VDEC_DRV_FRAMEBUF_T(*GetFreeBuffer)( + VAL_HANDLE_T handle + ); /* /< Get Buffer ready to release */ + VAL_UINT32_T(*GetParam)( + VAL_HANDLE_T handle, + VDEC_DRV_GET_TYPE_T a_eType, + VAL_VOID_T * a_pvInParam, + VAL_VOID_T * a_pvOutParam + ); + VAL_UINT32_T(*SetParam)( + VAL_HANDLE_T handle, + VDEC_DRV_SET_TYPE_T a_eType, + VAL_VOID_T * a_pvInParam, + VAL_VOID_T * a_pvOutParam + ); + VAL_UINT32_T(*DeInit)( + VAL_HANDLE_T handle + ); /* /< Function to do driver de-initialization */ + P_VDEC_DRV_RINGBUF_T(*GetFreeInputBuffer)( + VAL_HANDLE_T handle + ); + VAL_UINT32_T(*Init_ex)( + VAL_HANDLE_T * handle, + VAL_HANDLE_T halhandle, + VAL_HANDLE_T valhandle, + P_VDEC_DRV_RINGBUF_T pBitstream, + P_VDEC_DRV_SEQINFO_T pSeqinfo, + VDEC_DRV_VIDEO_FORMAT_T eFormat, + VAL_VOID_T * pConfig + ); + VAL_UINT32_T(*DecodeEx)( + VAL_HANDLE_T handle, + P_VDEC_DRV_RINGBUF_T pBitstream, + VAL_UINT32_T u4Flag, + VAL_VOID_T * pExtra + ); /* /< Driver Decode Main Funciton */ + + +} VDEC_DRV_BASE_T; + +typedef struct __VDEC_DRV_BUF_STATUS_T { + VAL_BOOL_T bDisplay; + VAL_BOOL_T bFree; + VDEC_DRV_FRAMEBUF_T *pFrameBuf; +} VDEC_DRV_BUF_STATUS_T, *P_VDEC_DRV_BUF_STATUS_T; + +typedef struct __VDEC_DRV_INPUT_BUF_STATUS_T { + VDEC_DRV_RINGBUF_T *pInputBuf; + VAL_UINT32_T u4RefCnt; +} VDEC_DRV_INPUT_BUF_STATUS_T, *P_VDEC_DRV_INPUT_BUF_STATUS_T; + +typedef struct __VDEC_HANDLE_T { + VDEC_DRV_VIDEO_FORMAT_T CodecFormat; + VDEC_DRV_BASE_T rFuncPtr; /* /< Point to driver's proprietary function. */ + VAL_HANDLE_T hDrvHandle; /* /< Handle of each format driver */ + VAL_BOOL_T fgDrvInitFlag; /* /< hDrvHandle is available or not */ + VAL_HANDLE_T hHalHandle; /* /< HAL handle */ + VAL_BOOL_T fgHalInitFlag; /* /< hHalHandle is available or not */ + VAL_HANDLE_T hValHandle; /* /< VAL handle */ + VAL_BOOL_T fgValInitFlag; /* /< hValHandle is available or not */ + VAL_MEMORY_T rHandleMem; /* /< Memory for vdec handle */ + P_VDEC_DRV_FRAMEBUF_T pDispFrameBuf; + P_VDEC_DRV_FRAMEBUF_T pFreeFrameBuf; + P_VDEC_DRV_RINGBUF_T pInputFreeBuf; + VDEC_DRV_BUF_STATUS_T pFrameBufArray[MAX_BUFFER_SIZE]; + VDEC_DRV_INPUT_BUF_STATUS_T pInputBufArray[MAX_BUFFER_SIZE]; + VAL_BOOL_T bFlushAll; + VAL_BOOL_T bInputFlushAll; + /* for no VOS header when MPEG4 */ + VAL_UINT16_T nDefWidth; + VAL_UINT16_T nDefHeight; + VDEC_DRV_SET_DECODE_MODE_T rSetDecodeMode; + VAL_INT32_T nPerfServiceHandle; +#ifdef DumpInput__ + FILE *pf_out; + VAL_MEM_ADDR_T rDumpBase; +#endif + VAL_UINT32_T nOmxTids; + VDEC_DRV_CALLBACK_T rCallbackHook; +} VDEC_HANDLE_T; + +#endif diff --git a/kernel-headers/vdec_drv_if_dep.h b/kernel-headers/vdec_drv_if_dep.h new file mode 100644 index 0000000..52be8f4 --- /dev/null +++ b/kernel-headers/vdec_drv_if_dep.h @@ -0,0 +1,152 @@ +#ifndef VDEC_DRV_IF_DEP_H /* for 6572 only */ +#define VDEC_DRV_IF_DEP_H + +/*============================================================================= + * Include Files + *===========================================================================*/ + +#include "val_types_private.h" +#include "vcodec_if_v2.h" +/* #include "rv_format_info.h" */ +#include "wmc_type.h" +/* #include "strm_iem.h" */ +#include "vcodec_dec_demuxer_if_v2.h" +/* #include "ts_vcodec_common.h" */ +#define DumpInput__ +#ifdef DumpInput__ +#include <stdio.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*============================================================================= + * Definition + *===========================================================================*/ +#define MAX_BUFFER_SIZE 21 +/*typedef struct +{ + // for speedy mode + VAL_UINT32_T nBufferStatus; + VAL_INT64_T llLastVideoTime; + VAL_INT64_T llCurrentPlayTime; +} DRIVER_HANDLER_T; +*/ +/* +typedef struct __RV9_DRV_DATA_T +{ + VAL_UINT32_T uStreamHdrWidth; + VAL_UINT32_T uStreamHdrHeight; + RM_DECODER_INPUT_PARAM_T rRM_INPUT_Data; + payload_inf_st payload_inf_tab_rv9[200]; //set up 200 + RM_DECODER_PAYLOAD_INFO_T payload_inf_tab_rv9_MAUI[200]; //set up 200 +} RV9_DRV_DATA_T, *P_RV9_DRV_DATA_T; +*/ + +typedef struct __H264_DRV_DATA_T { + H264_DECODER_PAYLOAD_INFO_T prH264Payload; + H264_DECODER_INPUT_PARAM_T prInputData; + H264_DECODER_PRIVATE_PARAM_T rPrivateData; +} H264_DRV_DATA_T, *P_H264_DRV_DATA_T; + +typedef struct __MPEG4_DRV_DATA_T { + MPEG4_DECODER_PAYLOAD_INFO_T prMPEG4Payload; + MPEG4_DECODER_INPUT_PARAM_T prInputData; + MPEG4_DECODER_PRIVATE_PARAM_T rPrivateData; +} MPEG4_DRV_DATA_T, *P_MPEG4_DRV_DATA_T; + +typedef struct __VP8_DRV_DATA_T { + /* VP8_DEC_CUSTOM_SETTING_T VP8CustSetting; */ +} VP8_DRV_DATA_T, *P_VP8_DRV_DATA_T; + +typedef struct __VP9_DRV_DATA_T { + /* VP9_DEC_CUSTOM_SETTING_T VP9CustSetting; */ +} VP9_DRV_DATA_T, *P_VP9_DRV_DATA_T; + +typedef struct __VC1_DRV_DATA_T { + VAL_BOOL_T bVC1FirstDecode; + VC1_DECODER_PAYLOAD_INFO_T prVC1Payload; + VC1_DECODER_INPUT_PARAM_T prInputData; + TEMP_INTERFACE VC1TempInterface; +} VC1_DRV_DATA_T, *P_VC1_DRV_DATA_T; + +typedef struct __VDEC_DRV_BUF_STATUS_T { + VAL_BOOL_T bDisplay; + VAL_BOOL_T bFree; + VDEC_DRV_FRAMEBUF_T *pFrameBuf; +} VDEC_DRV_BUF_STATUS_T, *P_VDEC_DRV_BUF_STATUS_T; + +typedef enum { + VDEC_DRV_STATUS_OPEN_DONE = 0x00000001, + VDEC_DRV_STATUS_INIT_DONE = 0x00000002, + VDEC_DRV_STATUS_DECODE_EVER = 0x00000004 +} VDEC_DRV_STATUS; + + +typedef struct __VDEC_HANDLE_T { + VAL_HANDLE_T hHalHandle; /* /< HAL data. */ + VAL_HANDLE_T vHandle; /* /< for MMSYS power on/off */ + VAL_MEMORY_T rHandleMem; /* /< Save handle memory information to be used in release. */ + VAL_BOOL_T bFirstDecoded; /* / < already pass first video data to codec */ + VAL_BOOL_T bHeaderPassed; /* / < already pass video header to codec */ + VAL_BOOL_T bFlushAll; + VAL_BOOL_T bNewMemory; /* / allocate buffer for first DOU */ + VAL_MEMORY_T HeaderBuf; + VAL_MEMORY_T HeaderBufwithFrame; + VAL_HANDLE_T hCodec; + DRIVER_HANDLER_T hDrv; + VIDEO_WRAP_HANDLE_T hWrapper; + VAL_UINT32_T CustomSetting; + VCODEC_BUFFER_T rVideoBitBuf; + VCODEC_DEC_INPUT_YUV_INFO_T rVideoFrameBuf; + VCODEC_MEMORY_TYPE_T rVideoDecMemType; + VAL_UINT32_T YUVBuffer[MAX_BUFFER_SIZE]; + VAL_UINT32_T nYUVBufferIndex; + VAL_UINT32_T nDrvStatus; + VDEC_DRV_BUF_STATUS_T pFrameBufArray[MAX_BUFFER_SIZE]; + VDEC_DRV_FRAMEBUF_T *DispFrameBuf, *FreeFrameBuf; + VCODEC_OPEN_SETTING_T codecOpenSetting; + VCODEC_DEC_INPUT_T rInputUnit; + VIDEO_DECODER_INPUT_NC_T rVideoDecInputNC; + VCODEC_DEC_OUTPUT_PARAM_T *rVideoDecOutputParam; + VCODEC_DEC_PRIVATE_OUTPUT_T rVideoDecOutput; + VCODEC_DEC_OUTPUT_BUFFER_PARAM_T rVideoDecYUVBufferParameter; + VCODEC_DEC_INPUT_BUFFER_PARAM_T rBitStreamParam; + /* for seek and thumbnail mode optimization */ + VAL_BOOL_T bFirstDecodeForThumbnail; + VAL_BOOL_T bThumbnailModeOK; + VDEC_DRV_SET_DECODE_MODE_T rSetDecodeMode; + /* for no VOS header when MPEG4 */ + VAL_UINT16_T nDefWidth; + VAL_UINT16_T nDefHeight; + + VDEC_DRV_VIDEO_FORMAT_T CodecFormat; + VAL_VOID_T *prExtraData; /* /< Driver private data pointer. */ + VAL_MEMORY_T rExtraDataMem; /* /< Save extra data memory information to be used in release. */ + VCODEC_DEC_PRIVATE_OUTPUT_EXTRA_T prExtraDecOutput; +#ifdef DumpInput__ + FILE *pf_out; + VAL_MEM_ADDR_T rDumpBase; +#endif + + /* Morris Yang 20111101 [ */ + VAL_UINT32_T nOmxTids; + /* ] */ +#if 1 /* defined(MT6572) //VCODEC_MULTI_THREAD */ + /* Jackal Chen [ */ + VAL_VOID_T *pDrvModule; /* /< used for dlopen and dlclose */ + /* ] */ +#endif + VAL_BOOL_T fgValInitFlag; /* /< hValHandle is available or not */ +} VDEC_HANDLE_T; + +/*============================================================================= + * Function Declaration + *===========================================================================*/ + +#ifdef __cplusplus +} +#endif + +#endif /* VDEC_DRV_IF_DEP_H */ diff --git a/kernel-headers/vdec_drv_if_private.h b/kernel-headers/vdec_drv_if_private.h new file mode 100644 index 0000000..4e27516 --- /dev/null +++ b/kernel-headers/vdec_drv_if_private.h @@ -0,0 +1,437 @@ +#ifndef _VDEC_DRV_IF_PRIVATE_H_ +#define _VDEC_DRV_IF_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "vdec_drv_if_public.h" + + +typedef enum { + UNKNOWN_FBTYPE = 0, /* /< Unknown type */ + VDEC_DRV_FBTYPE_YUV420_BK_16x1 = (1 << 0), /* /< YCbCr 420 block in three planar */ + VDEC_DRV_FBTYPE_YUV420_BK_8x2 = (1 << 1), /* /< YCbCr 420 block in three planar */ + VDEC_DRV_FBTYPE_YUV420_BK_4x4 = (1 << 2), /* /< YCbCr 420 block in three planar */ + VDEC_DRV_FBTYPE_YUV420_RS = (1 << 3), /* /< YCbCr 420 raster scan in three planar */ + VDEC_DRV_FBTYPE_RGB565_RS = (1 << 4) /* /< RGB565 in one planar */ +} +VDEC_DRV_FBTYPE_T; + + +/** + * @par Structure + * VDEC_DRV_BUFFER_CONTROL_T + * @par Description + * Type of buffer control + * - Here are two types of buffer + * - 1.Reference buffer + * - 2.Display buffer + * - Buffer can be fixed size or derived from memory pool. + * - Buffer can be created from internal or external memory. + */ +typedef enum { + /* /< Unknown Type */ + VDEC_DRV_BUFFER_CONTROL_UNKNOWN = 0, + + /* /< Reference frame and Display frame share the same external buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_EXT = (1 << 0), + + /* /< Reference frame and Display frame share the same internal buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_INT = (1 << 1), + + /* /< Reference frame and Display frame share the same external memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_EXT_POOL = (1 << 2), + + /* /< Reference frame and Display frame share the same internal memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_INT_POOL = (1 << 3), + + /* /< Reference frame uses external buffer and Display frame use another external buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_EXT = (1 << 4), + + /* /< Reference frame uses external buffer and Display frame uses internal buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_INT = (1 << 5), + + /* /< Reference frame uses external buffer and Display frame uses external memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_EXT_POOL = (1 << 6), + + /* /< Reference frame uses external buffer and Display frame uses internal memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_INT_POOL = (1 << 7), + + /* /< Reference frame uses external memory pool and Display frame use external buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_EXT = (1 << 8), + + /* /< Reference frame uses external memory pool and Display frame uses internal buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_INT = (1 << 9), + + /* /< Reference frame uses external memory pool and Display frame uses external memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_EXT_POOL = (1 << 10), + + /* /< Reference frame uses external memory pool and Display frame uses internal memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_INT_POOL = (1 << 11), + + /* /< Reference frame uses internal buffer and Display frame use external buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_EXT = (1 << 12), + + /* /< Reference frame uses internal buffer and Display frame uses internal buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_INT = (1 << 13), + + /* /< Reference frame uses internal buffer and Display frame uses external memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_EXT_POOL = (1 << 14), + + /* /< Reference frame uses internal buffer and Display frame uses internal memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_INT_POOL = (1 << 15), + + /* /< Reference frame uses internal memory pool and Display frame use external buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_EXT = (1 << 16), + + /* /< Reference frame uses internal memory pool and Display frame uses internal buffer */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_INT = (1 << 17), + + /* /< Reference frame uses internal memory pool and Display frame uses external memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_EXT_POOL = (1 << 18), + + /* /< Reference frame uses external memory pool and Display frame uses another internal memory pool */ + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_INT_POOL = (1 << 19) +} VDEC_DRV_BUFFER_CONTROL_T; + + +/** + * @par Structure + * VDEC_DRV_DOWNSIZE_RATIO_T + * @par Description + * DownSize Ratio + * - The aspect ratio of frame is kept after downsizing. + */ +typedef enum { + VDEC_DRV_DOWNSIZE_RATIO_UNKNOWN = 0, /* /< Unknown ratio */ + VDEC_DRV_DOWNSIZE_RATIO_1_1 = (1 << 0), /* /< Original ratio */ + VDEC_DRV_DOWNSIZE_RATIO_1_2 = (1 << 1), /* /< ratio = 1/2 */ + VDEC_DRV_DOWNSIZE_RATIO_1_3 = (1 << 2), /* /< ratio = 1/3 */ + VDEC_DRV_DOWNSIZE_RATIO_1_4 = (1 << 3), /* /< ratio = 1/4 */ + VDEC_DRV_DOWNSIZE_RATIO_1_5 = (1 << 4), /* /< ratio = 1/5 */ + VDEC_DRV_DOWNSIZE_RATIO_1_6 = (1 << 5), /* /< ratio = 1/6 */ + VDEC_DRV_DOWNSIZE_RATIO_1_7 = (1 << 6), /* /< ratio = 1/7 */ + VDEC_DRV_DOWNSIZE_RATIO_1_8 = (1 << 7) /* /< ratio = 1/8 */ +} VDEC_DRV_DOWNSIZE_RATIO_T; + + +/** + * @par Structure + * VDEC_DRV_PIC_STRUCT_T + * @par Description + * [Unused]Picture Struct + * - Consecutive Frame or filed + * - Separated top/bottom field + */ +typedef enum { + VDEC_DRV_PIC_STRUCT_UNKNOWN = 0, /* /< Unknown */ + VDEC_DRV_PIC_STRUCT_CONSECUTIVE_FRAME, /* /< Consecutive Frame */ + VDEC_DRV_PIC_STRUCT_CONSECUTIVE_TOP_FIELD, /* /< Consecutive top field */ + VDEC_DRV_PIC_STRUCT_CONSECUTIVE_BOT_FIELD, /* /< Consecutive bottom field */ + VDEC_DRV_PIC_STRUCT_SEPARATED_TOP_FIELD, /* /< Separated top field */ + VDEC_DRV_PIC_STRUCT_SEPARATED_BOT_FIELD, /* /< Separated bottom field */ + VDEC_DRV_PIC_STRUCT_FIELD, +} VDEC_DRV_PIC_STRUCT_T; + + +/** + * @par Structure + * VDEC_DRV_FRAME_RATE_T + * @par Description + * Frame rate types + */ +typedef enum { + VDEC_DRV_FRAME_RATE_UNKNOWN = 0, /* /< Unknown fps */ + VDEC_DRV_FRAME_RATE_23_976, /* /< fps = 24000/1001 (23.976...) */ + VDEC_DRV_FRAME_RATE_24, /* /< fps = 24 */ + VDEC_DRV_FRAME_RATE_25, /* /< fps = 25 */ + VDEC_DRV_FRAME_RATE_29_97, /* /< fps = 30000/1001 (29.97...) */ + VDEC_DRV_FRAME_RATE_30, /* /< fps = 30 */ + VDEC_DRV_FRAME_RATE_50, /* /< fps = 50 */ + VDEC_DRV_FRAME_RATE_59_94, /* /< fps = 60000/1001 (59.94...) */ + VDEC_DRV_FRAME_RATE_60, /* /< fps = 60 */ + VDEC_DRV_FRAME_RATE_120, /* /< fps = 120 */ + VDEC_DRV_FRAME_RATE_1, /* /< fps = 1 */ + VDEC_DRV_FRAME_RATE_5, /* /< fps = 5 */ + VDEC_DRV_FRAME_RATE_8, /* /< fps = 8 */ + VDEC_DRV_FRAME_RATE_10, /* /< fps = 10 */ + VDEC_DRV_FRAME_RATE_12, /* /< fps = 12 */ + VDEC_DRV_FRAME_RATE_15, /* /< fps = 15 */ + VDEC_DRV_FRAME_RATE_16, /* /< fps = 16 */ + VDEC_DRV_FRAME_RATE_17, /* /< fps = 17 */ + VDEC_DRV_FRAME_RATE_18, /* /< fps = 18 */ + VDEC_DRV_FRAME_RATE_20, /* /< fps = 20 */ + VDEC_DRV_FRAME_RATE_2, /* /< fps = 2 */ + VDEC_DRV_FRAME_RATE_6, /* /< fps = 6 */ + VDEC_DRV_FRAME_RATE_48, /* /< fps = 48 */ + VDEC_DRV_FRAME_RATE_70, /* /< fps = 70 */ + VDEC_DRV_FRAME_RATE_VARIABLE /* /< fps = VBR */ +} VDEC_DRV_FRAME_RATE_T; + + +/** + * @par Structure + * VDEC_DRV_POST_PROC_T + * @par Description + * input of type SET_POST_PROC (output is NULL, use return value) + */ +typedef enum { + VDEC_DRV_POST_PROC_UNKNOWN = 0, /* /< Unknown */ + VDEC_DRV_POST_PROC_DISABLE, /* /< Do not do post-processing */ + VDEC_DRV_POST_PROC_DOWNSIZE, /* /< Do downsize */ + VDEC_DRV_POST_PROC_RESIZE, /* /< Do resize */ + VDEC_DRV_POST_PROC_DEBLOCK, /* /< Do deblocking */ + VDEC_DRV_POST_PROC_DEINTERLACE /* /< Do deinterlace */ +} VDEC_DRV_POST_PROC_T; + + +/** + * @par Structure + * VDEC_DRV_NALU_T + * @par Description + * Buffer Structure + * - Store NALU buffer base address + * - Store length of NALU buffer + */ + +typedef struct { + VAL_UINT32_T u4AddrOfNALu; /* /< NALU buffer base address */ + VAL_UINT32_T u4LengthOfNALu; /* /< Length of NALU buffer */ + void *pReseved; /* /< reserved */ +} VDEC_DRV_NALU_T; + + +/** + * @par Structure + * VDEC_DRV_STATISTIC_T + * @par Description + * VDecDrv Statistic information + */ +typedef struct __VDEC_DRV_STATISTIC_T { + VAL_UINT32_T u4DecTimeMax; /* /< [Out] Decode one frame period, Max. */ + VAL_UINT32_T u4DecTimeMin; /* /< [Out] Decode one frame period, Min. */ + VAL_UINT32_T u4DecTimeAvg; /* /< [Out] Decode one frame period, Average. */ +} VDEC_DRV_STATISTIC_T; + +/** + * @par Structure + * P_VDEC_DRV_STATISTIC_T + * @par Description + * Pointer of VDEC_DRV_STATISTIC_T + */ +typedef VDEC_DRV_STATISTIC_T * P_VDEC_DRV_STATISTIC_T; + + +/** + * @par Structure + * VDEC_DRV_FBTYPE_T + * @par Description + * Supported frame buffer type in driver layer + */ +typedef struct { + /* for speedy mode */ + VAL_UINT32_T nBufferStatus; + VAL_INT64_T llLastVideoTime; + VAL_INT64_T llCurrentPlayTime; +} DRIVER_HANDLER_T; + + +/** + * @par Structure + * VDEC_DRV_VIDEO_FBTYPE_T + * @par Description + * Both input and output of type QUERY_FBTYPE + */ +typedef struct __VDEC_DRV_VIDEO_FBTYPE_T { + VAL_UINT32_T u4FBType; /* /< VDEC_DRV_FBTYPE */ +} VDEC_DRV_VIDEO_FBTYPE_T; + +/** + * @par Structure + * P_VDEC_DRV_VIDEO_FBTYPE_T + * @par Description + * Pointer of VDEC_DRV_VIDEO_FBTYPE_T + */ +typedef VDEC_DRV_VIDEO_FBTYPE_T * P_VDEC_DRV_VIDEO_FBTYPE_T; + + +/** + * @par Structure + * VDEC_DRV_QUERY_BUFFER_MODE_T + * @par Description + * Both input and output of type QUERY_BUFFER_CONTROL + */ +typedef struct __VDEC_DRV_QUERY_BUFFER_MODE_T { + VAL_UINT32_T u4BufCtrl; /* /< VDEC_DRV_BUFFER_CONTROL */ +} VDEC_DRV_QUERY_BUFFER_MODE_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_BUFFER_MODE_T + * @par Description + * Pointer of VDEC_DRV_QUERY_BUFFER_MODE_T + */ +typedef VDEC_DRV_QUERY_BUFFER_MODE_T * P_VDEC_DRV_QUERY_BUFFER_MODE_T; + + +/** + * @par Structure + * VDEC_DRV_QUERY_POOL_SIZE_T + * @par Description + * output of type QUERY_REF_POOL_SIZE and QUERY_DISP_POOL_SIZE (input is NULL) + */ +typedef struct __VDEC_DRV_QUERY_POOL_SIZE_T { + VAL_UINT32_T u4Size; /* /< buffer size of the memory pool */ +} VDEC_DRV_QUERY_POOL_SIZE_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_POOL_SIZE_T + * @par Description + * Pointer of VDEC_DRV_QUERY_POOL_SIZE_T + */ +typedef VDEC_DRV_QUERY_POOL_SIZE_T * P_VDEC_DRV_QUERY_POOL_SIZE_T; + +/* output of type DISP_FRAME_BUFFER and FREE_FRAME_BUFFER is P_VDEC_DRV_FRAMEBUF_T (input is NULL) */ +/* output of type GET_PICTURE_INFO is P_VDEC_DRV_PICINFO_T (input is NULL) */ +/* both input and output of type QUERY_REORDER_ABILITY are NULL (use return value) */ + + +/** + * @par Structure + * VDEC_DRV_QUERY_POOL_DOWNSIZE_T + * @par Description + * output of type QUERY_DOWNSIZE_ABILITY (input is NULL) + */ +typedef struct __VDEC_DRV_QUERY_POOL_DOWNSIZE_T { + VAL_UINT32_T u4Ratio; /* /< VDEC_DRV_DOWNSIZE_RATIO */ +} VDEC_DRV_QUERY_POOL_DOWNSIZE_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_POOL_DOWNSIZE_T + * @par Description + * Pointer of VDEC_DRV_QUERY_POOL_DOWNSIZE_T + */ +typedef VDEC_DRV_QUERY_POOL_DOWNSIZE_T * P_VDEC_DRV_QUERY_POOL_DOWNSIZE_T; + + +/** + * @par Structure + * VDEC_DRV_QUERY_POOL_RESIZE_T + * @par Description + * input of type QUERY_RESIZE_ABILITY (output is NULL, use return value) + */ +typedef struct __VDEC_DRV_QUERY_POOL_RESIZE_T { + VAL_UINT32_T u4OutWidth; /* /<Width of buffer */ + VAL_UINT32_T u4OutHeight; /* /<Height of buffer */ +} VDEC_DRV_QUERY_POOL_RESIZE_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_POOL_RESIZE_T + * @par Description + * Pointer of VDEC_DRV_QUERY_POOL_RESIZE_T + */ +typedef VDEC_DRV_QUERY_POOL_RESIZE_T * P_VDEC_DRV_QUERY_POOL_RESIZE_T; + +/* both input and output of type QUERY_DEBLOCK_ABILITY are NULL (use return value) */ +/* both input and output of type QUERY_DERING_ABILITY are NULL (use return value) */ +/* both input and output of type QUERY_DEINTERLACE_ABILITY are NULL (use return value) */ +/* both input and output of type QUERY_DROPFRAME_ABILITY are NULL (use return value) */ + + +/** + * @par Structure + * VDEC_DRV_SET_BUFFER_MODE_T + * @par Description + * input of type VDEC_DRV_SET_BUFFER_MODE_T (output is NULL, use return value) + */ +typedef struct __VDEC_DRV_SET_BUFFER_MODE_T { + VAL_UINT32_T u4BufferMode; /* /< VDEC_DRV_BUFFER_CONTROL */ +} VDEC_DRV_SET_BUFFER_MODE_T; + +/* input of type SET_FRAME_BUFFER_TYPE is VDEC_DRV_VIDEO_FBTYPE_T (output is NULL, use return value) */ + +/** + * @par Structure + * P_VDEC_DRV_SET_BUFFER_MODE_T + * @par Description + * Pointer of VDEC_DRV_SET_BUFFER_MODE_T + */ +typedef VDEC_DRV_SET_BUFFER_MODE_T * P_VDEC_DRV_SET_BUFFER_MODE_T; + +/* input of type SET_FRAME_BUFFER_TYPE is VDEC_DRV_VIDEO_FBTYPE_T (output is NULL, use return value) */ + + +/** + * @par Structure + * VDEC_DRV_SET_BUFFER_ADDR_T + * @par Description + * input of type FREE_FRAME_BFFER (buffer_len=NULL, output is NULL, use return value) + */ +typedef struct __VDEC_DRV_SET_BUFFER_ADDR_T { + VAL_MEM_ADDR_T rBufferAddr; /* /< buffer memory base address */ +} VDEC_DRV_SET_BUFFER_ADDR_T; + +/** + * @par Structure + * P_VDEC_DRV_SET_BUFFER_ADDR_T + * @par Description + * Pointer of VDEC_DRV_SET_BUFFER_ADDR_T + */ +typedef VDEC_DRV_SET_BUFFER_ADDR_T * P_VDEC_DRV_SET_BUFFER_ADDR_T; + +/* input of type SET_REF_EXT_POOL_ADDR and SET_DISP_EXT_POOL_ADDR is + VDEC_DRV_SET_BUFFER_ADDR_T (output is NULL, use return value) */ + + +/** + * @par Structure + * VDEC_DRV_SET_POST_PROC_MODE_T + * @par Description + * Parameters of set post process mode + */ +typedef struct __VDEC_DRV_SET_POST_PROC_MODE_T { + VAL_UINT32_T u4PostProcMode; /* /< one of VDEC_DRV_POST_PROC */ + VAL_UINT32_T u4DownsizeRatio; /* /< if mode is POST_PROC_DOWNSIZE */ + VAL_UINT32_T u4ResizeWidth; /* /< if mode is POST_PROC_RESIZE */ + VAL_UINT32_T u4ResizeHeight; /* /< if mode is POST_PROC_RESIZE */ +} VDEC_DRV_SET_POST_PROC_MODE_T; + +/** + * @par Structure + * P_VDEC_DRV_SET_POST_PROC_MODE_T + * @par Description + * Pointer of VDEC_DRV_SET_POST_PROC_MODE_T + */ +typedef VDEC_DRV_SET_POST_PROC_MODE_T * P_VDEC_DRV_SET_POST_PROC_MODE_T; + + + +typedef struct _VDEC_DRV_HW_REG_T { + VAL_UINT32_T u4VdecHWBase; + VAL_UINT32_T u4VdecHWSYS; + VAL_UINT32_T u4VdecMISC; + VAL_UINT32_T u4VdecVLD; + VAL_UINT32_T u4VdecVLDTOP; + VAL_UINT32_T u4VdecMC; + VAL_UINT32_T u4VdecAVCVLD; + VAL_UINT32_T u4VdecAVCMV; + VAL_UINT32_T u4VdecPP; + VAL_UINT32_T u4VdecSQT; + VAL_UINT32_T u4VdecVP8VLD; + VAL_UINT32_T u4VdecVP6VLD; + VAL_UINT32_T u4VdecVP8VLD2; +} VDEC_DRV_HW_REG_T; + +typedef VDEC_DRV_HW_REG_T * P_VDEC_DRV_HW_REG_T; + + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VDEC_DRV_IF_PRIVATE_H_ */ diff --git a/kernel-headers/vdec_drv_if_public.h b/kernel-headers/vdec_drv_if_public.h new file mode 100644 index 0000000..8a141a3 --- /dev/null +++ b/kernel-headers/vdec_drv_if_public.h @@ -0,0 +1,943 @@ +#ifndef _VDEC_DRV_IF_PUBLIC_H_ +#define _VDEC_DRV_IF_PUBLIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" + +#define MTK_VDEC_PROP_WAITKEYFRAME "mtk.vdec.waitkeyframeforplayback" +#define MTK_VDEC_VALUE_WAITKEYFRAME_AT_START (1) +#define MTK_VDEC_VALUE_WAITKEYFRAME_FOR_SEEK (1 << 1) + +/** + * @par Enumeration + * VDEC_DRV_FBSTSTUS + * @par Description + * This is the item for frame buffer status + */ +typedef enum _VDEC_DRV_FBSTSTUS { + VDEC_DRV_FBSTSTUS_NORMAL = 0, /* /< normal type */ + VDEC_DRV_FBSTSTUS_REPEAT_LAST = (1 << 0), /* /< repeat last frame */ + VDEC_DRV_FBSTSTUS_NOT_DISPLAY = (1 << 1), /* /< not displayed */ + VDEC_DRV_FBSTSTUS_NOT_USED = (1 << 2), /* /< not used */ + VDEC_DRV_FBSTSTUS_INVALID_TIMESTAMP = (1 << 3), /* /< invalid timestamp */ +} +VDEC_DRV_FBSTSTUS; + + +/** + * @par Enumeration + * VDEC_DRV_VIDEO_FORMAT_T + * @par Description + * video_format of VDecDrvCreate() + */ + +typedef enum _VDEC_DRV_VIDEO_FORMAT_T { + VDEC_DRV_VIDEO_FORMAT_UNKNOWN_VIDEO_FORMAT = 0, /* /< Unknown video format */ + VDEC_DRV_VIDEO_FORMAT_DIVX311 = (1 << 0), /* /< Divix 3.11 */ + VDEC_DRV_VIDEO_FORMAT_DIVX4 = (1 << 1), /* /< Divix 4 */ + VDEC_DRV_VIDEO_FORMAT_DIVX5 = (1 << 2), /* /< Divix 5 */ + VDEC_DRV_VIDEO_FORMAT_XVID = (1 << 3), /* /< Xvid */ + VDEC_DRV_VIDEO_FORMAT_MPEG1 = (1 << 4), /* /< MPEG-1 */ + VDEC_DRV_VIDEO_FORMAT_MPEG2 = (1 << 5), /* /< MPEG-2 */ + VDEC_DRV_VIDEO_FORMAT_MPEG4 = (1 << 6), /* /< MPEG-4 */ + VDEC_DRV_VIDEO_FORMAT_H263 = (1 << 7), /* /< H263 */ + VDEC_DRV_VIDEO_FORMAT_H264 = (1 << 8), /* /< H264 */ + VDEC_DRV_VIDEO_FORMAT_H265 = (1 << 9), /* /< H265 */ + VDEC_DRV_VIDEO_FORMAT_WMV7 = (1 << 10), /* /< WMV7 */ + VDEC_DRV_VIDEO_FORMAT_WMV8 = (1 << 11), /* /< WMV8 */ + VDEC_DRV_VIDEO_FORMAT_WMV9 = (1 << 12), /* /< WMV9 */ + VDEC_DRV_VIDEO_FORMAT_VC1 = (1 << 13), /* /< VC1 */ + VDEC_DRV_VIDEO_FORMAT_REALVIDEO8 = (1 << 14), /* /< RV8 */ + VDEC_DRV_VIDEO_FORMAT_REALVIDEO9 = (1 << 15), /* /< RV9 */ + VDEC_DRV_VIDEO_FORMAT_VP6 = (1 << 16), /* /< VP6 */ + VDEC_DRV_VIDEO_FORMAT_VP7 = (1 << 17), /* /< VP7 */ + VDEC_DRV_VIDEO_FORMAT_VP8 = (1 << 18), /* /< VP8 */ + VDEC_DRV_VIDEO_FORMAT_VP8_WEBP_PICTURE_MODE = (1 << 19), /* /< VP8 WEBP PICTURE MODE */ + VDEC_DRV_VIDEO_FORMAT_VP8_WEBP_MB_ROW_MODE = (1 << 20), /* /< VP8 WEBP ROW MODE */ + VDEC_DRV_VIDEO_FORMAT_VP9 = (1 << 21), /* /< VP9 */ + VDEC_DRV_VIDEO_FORMAT_VP9_WEBP_PICTURE_MODE = (1 << 22), /* /< VP9 WEBP PICTURE MODE */ + VDEC_DRV_VIDEO_FORMAT_VP9_WEBP_MB_ROW_MODE = (1 << 23), /* /< VP9 WEBP ROW MODE */ + VDEC_DRV_VIDEO_FORMAT_AVS = (1 << 24), /* /< AVS */ + VDEC_DRV_VIDEO_FORMAT_MJPEG = (1 << 25), /* /< Motion JPEG */ + VDEC_DRV_VIDEO_FORMAT_S263 = (1 << 26), /* /< Sorenson Spark */ + VDEC_DRV_VIDEO_FORMAT_H264HP = (1 << 27), + VDEC_DRV_VIDEO_FORMAT_H264SEC = (1 << 28), + VDEC_DRV_VIDEO_FORMAT_H265SEC = (1 << 29) +} VDEC_DRV_VIDEO_FORMAT_T; + + +/** + * @par Enumeration + * VDEC_DRV_H265_VIDEO_PROFILE_T + * @par Description + * video profile for H.265 + */ +typedef enum _VDEC_DRV_H265_VIDEO_PROFILE_T { + VDEC_DRV_H265_VIDEO_PROFILE_UNKNOWN = 0, /* /< Unknown video profile */ + VDEC_DRV_H265_VIDEO_PROFILE_H265_MAIN = (1 << 0), /* /< H265 main profile */ + VDEC_DRV_H265_VIDEO_PROFILE_H265_MAIN_10 = (1 << 1), /* /< H265 main 10 profile */ + VDEC_DRV_H265_VIDEO_PROFILE_H265_STILL_IMAGE = (1 << 2) /* /< H265 still image profile */ +} VDEC_DRV_H265_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VDEC_DRV_H264_VIDEO_PROFILE_T + * @par Description + * video profile for H.264 + */ +typedef enum _VDEC_DRV_H264_VIDEO_PROFILE_T { + VDEC_DRV_H264_VIDEO_PROFILE_UNKNOWN = 0, /* /< Unknown video profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_BASELINE = (1 << 0), /* /< H264 baseline profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE = (1 << 1), /* /< H264 constrained baseline profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_MAIN = (1 << 2), /* /< H264 main profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_EXTENDED = (1 << 3), /* /< H264 extended profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH = (1 << 4), /* /< H264 high profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH_10 = (1 << 5), /* /< H264 high 10 profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH422 = (1 << 6), /* /< H264 high 422 profile */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH444 = (1 << 7), /* /< H264 high 444 profile */ + + /* /< H264 high 10 intra profile in Amendment 2 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH_10_INTRA = (1 << 8), + + /* /< H264 high 422 intra profile in Amendment 2 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH422_INTRA = (1 << 9), + + /* /< H264 high 444 intra profile in Amendment 2 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH444_INTRA = (1 << 10), + + /* /< H264 CAVLC 444 intra profile in Amendment 2 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_CAVLC444_INTRA = (1 << 11), + + /* /< H264 high 444 predictive profile in Amendment 2 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_HIGH444_PREDICTIVE = (1 << 12), + + /* /< H264 scalable baseline profile in Amendment 3 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_SCALABLE_BASELINE = (1 << 13), + + /* /< H264 scalable high profile in Amendment 3 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_SCALABLE_HIGH = (1 << 14), + + /* /< H264 scalable high intra profile in Amendment 3 */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_SCALABLE_HIGH_INTRA = (1 << 15), + + /* /< Corrigendum 1 (2009) */ + VDEC_DRV_H264_VIDEO_PROFILE_H264_MULTIVIEW_HIGH = (1 << 16) +} VDEC_DRV_H264_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VDEC_DRV_MPEG_VIDEO_PROFILE_T + * @par Description + * video profile for H263, MPEG2, MPEG4 + */ +typedef enum _VDEC_DRV_MPEG_VIDEO_PROFILE_T { + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_0 = (1 << 0), /* /< H263 Profile 0 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_1 = (1 << 1), /* /< H263 Profile 1 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_2 = (1 << 2), /* /< H263 Profile 2 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_3 = (1 << 3), /* /< H263 Profile 3 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_4 = (1 << 4), /* /< H263 Profile 4 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_5 = (1 << 5), /* /< H263 Profile 5 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_6 = (1 << 6), /* /< H263 Profile 6 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_7 = (1 << 7), /* /< H263 Profile 7 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_H263_8 = (1 << 8), /* /< H263 Profile 8 */ + VDEC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SIMPLE = (1 << 9), /* /< MPEG2 Simple Profile */ + VDEC_DRV_MPEG_VIDEO_PROFILE_MPEG2_MAIN = (1 << 10), /* /< MPEG2 Main Profile */ + VDEC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SNR = (1 << 11), /* /< MPEG2 SNR Profile */ + VDEC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SPATIAL = (1 << 12), /* /< MPEG2 Spatial Profile */ + VDEC_DRV_MPEG_VIDEO_PROFILE_MPEG2_HIGH = (1 << 13), /* /< MPEG2 High Profile */ + VDEC_DRV_MPEG_VIDEO_PROFILE_MPEG4_SIMPLE = (1 << 14), /* /< MPEG4 Simple Profile */ + VDEC_DRV_MPEG_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE = (1 << 15) /* /< MPEG4 Advanced Simple Profile */ +} VDEC_DRV_MPEG_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VDEC_DRV_MS_VIDEO_PROFILE_T + * @par Description + * video profile for VC1, WMV9 + */ +typedef enum _VDEC_DRV_MS_VIDEO_PROFILE_T { + VDEC_DRV_MS_VIDEO_PROFILE_VC1_SIMPLE = (1 << 0), /* /< VC-1 Simple Profile */ + VDEC_DRV_MS_VIDEO_PROFILE_VC1_MAIN = (1 << 1), /* /< VC-1 Main Profile */ + VDEC_DRV_MS_VIDEO_PROFILE_VC1_ADVANCED = (1 << 2), /* /< VC-1 Advanced Profile */ + VDEC_DRV_MS_VIDEO_PROFILE_WMV9_SIMPLE = (1 << 3), /* /< WMV9 Simple Profile */ + VDEC_DRV_MS_VIDEO_PROFILE_WMV9_MAIN = (1 << 4), /* /< WMV9 Main Profile */ + VDEC_DRV_MS_VIDEO_PROFILE_WMV9_COMPLEX = (1 << 5) /* /< WMV9 Complex Profile */ +} VDEC_DRV_MS_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VDEC_DRV_VIDEO_LEVEL_T + * @par Description + * video level + */ +typedef enum _VDEC_DRV_VIDEO_LEVEL_T { + VDEC_DRV_VIDEO_LEVEL_UNKNOWN = 0, /* /< Unknown level */ + VDEC_DRV_VIDEO_LEVEL_0, /* /< Specified by VC1 */ + VDEC_DRV_VIDEO_LEVEL_1, /* /< Specified by H264, VC1, MPEG4, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_1, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_1b, /* /< Specified by H264 */ + VDEC_DRV_VIDEO_LEVEL_1_1, /* /< Specified by H264 */ + VDEC_DRV_VIDEO_LEVEL_1_2, /* /< Specified by H264 */ + VDEC_DRV_VIDEO_LEVEL_1_3, /* /< Specified by H264 */ + VDEC_DRV_VIDEO_LEVEL_2, /* /< Specified by H264, VC1, MPEG4, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_2, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_2_1, /* /< Specified by H264, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_2_1, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_2_2, /* /< Specified by H264 */ + VDEC_DRV_VIDEO_LEVEL_3, /* /< Specified by H264, VC1, MPEG4, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_3, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_3_1, /* /< Specified by H264, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_3_1, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_3_2, /* /< Specified by H264 */ + VDEC_DRV_VIDEO_LEVEL_4, /* /< Specified by H264, VC1, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_4, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_4_1, /* /< Specified by H264, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_4_1, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_4_2, /* /< Specified by H264 */ + VDEC_DRV_VIDEO_LEVEL_5, /* /< Specified by H264, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_5, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_5_1, /* /< Specified by H264, HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_5_1, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_5_2, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_5_2, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_6, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_6, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_6_1, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_6_1, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_6_2, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_HIGH_TIER_LEVEL_6_2, /* /< Specified by HEVC */ + VDEC_DRV_VIDEO_LEVEL_LOW, /* /< Specified by MPEG2, VC1 */ + VDEC_DRV_VIDEO_LEVEL_MEDIUM, /* /< Specified by MPEG2, VC1 */ + VDEC_DRV_VIDEO_LEVEL_HIGH1440, /* /< Specified by MPEG2 */ + VDEC_DRV_VIDEO_LEVEL_HIGH /* /< Specified by MPEG2, VC1 */ + +} VDEC_DRV_VIDEO_LEVEL_T; + + +/** + * @par Enumeration + * VDEC_DRV_RESOLUTION_T + * @par Description + * video resolution support + */ +typedef enum _VDEC_DRV_RESOLUTION_T { + VDEC_DRV_RESOLUTION_UNKNOWN = 0, /* /< Unknown resolution */ + VDEC_DRV_RESOLUTION_SUPPORT_QCIF, /* /< QCIF */ + VDEC_DRV_RESOLUTION_SUPPORT_QVGA, /* /< QVGA */ + VDEC_DRV_RESOLUTION_SUPPORT_CIF, /* /< CIF */ + VDEC_DRV_RESOLUTION_SUPPORT_480I, /* /< 720x480 interlace */ + VDEC_DRV_RESOLUTION_SUPPORT_480P, /* /< 720x480 progressive */ + VDEC_DRV_RESOLUTION_SUPPORT_576I, /* /< 720x576 interlace */ + VDEC_DRV_RESOLUTION_SUPPORT_576P, /* /< 720x576 progressive */ + VDEC_DRV_RESOLUTION_SUPPORT_720P, /* /< 1280x720 progressive */ + VDEC_DRV_RESOLUTION_SUPPORT_1080I, /* /< 1920x1080 interlace */ + VDEC_DRV_RESOLUTION_SUPPORT_1080P, /* /< 1920x1080 progressive */ + VDEC_DRV_RESOLUTION_SUPPORT_2160P /* /< 4096x2160 progressive */ +} VDEC_DRV_RESOLUTION_T; + + +/** + * @par Enumeration + * VDEC_DRV_QUERY_TYPE_T + * @par Description + * video driver used to query different info + */ +typedef enum _VDEC_DRV_QUERY_TYPE_T { + VDEC_DRV_QUERY_TYPE_FBTYPE, /* /< Query VDEC_DRV_QUERY_TYPE_FBTYPE */ + VDEC_DRV_QUERY_TYPE_VIDEO_FORMAT, /* /< Query VDEC_DRV_QUERY_TYPE_VIDEO_FORMAT */ + VDEC_DRV_QUERY_TYPE_PROPERTY, /* /< Query VDEC_DRV_PROPERTY_T */ + VDEC_DRV_QUERY_TYPE_CHIP_NAME, /* /< Query VDEC_DRV_QUERY_TYPE_CHIP_NAME */ + VDEC_DRV_QUERY_TYPE_BUFFER_CONTROL, /* /< Query VDEC_DRV_QUERY_TYPE_BUFFER_CONTROL */ + VDEC_DRV_QUERY_TYPE_FEATURE_SUPPORTED, /* /< Query VDEC_DRV_QUERY_TYPE_FEATURE_SUPPORTED */ + VDEC_DRV_QUERY_TYPE_CPUCORE_FREQUENCY, /* /< Query VDEC_DRV_QUERY_TYPE_CPUCORE_FREQUENCY */ +} VDEC_DRV_QUERY_TYPE_T; + + +/** + * @par Enumeration + * VDEC_DRV_QUERY_TYPE_T + * @par Description + * video driver used to queue multiple input buffers + */ +typedef enum _VDEC_DRV_FEATURE_TYPE_T { + VDEC_DRV_FEATURE_TYPE_NONE = 0, /* /< Empty */ + VDEC_DRV_FEATURE_TYPE_QUEUE_INPUT_BUFFER = (1 << 0), /* /< Driver will queue multiple input buffers */ +} VDEC_DRV_FEATURE_TYPE_T; + + +/** + * @par Enumeration + * VDEC_DRV_GET_TYPE_T + * @par Description + * video driver used to get/query different info + */ +typedef enum _VDEC_DRV_GET_TYPE_T { + /* /< how many buffer size of the reference pool needs in driver */ + VDEC_DRV_GET_TYPE_QUERY_REF_POOL_SIZE, + + /* /< how many buffer size of the display pool needs in driver */ + VDEC_DRV_GET_TYPE_QUERY_DISP_POOL_SIZE, + + /* /< return a P_VDEC_DRV_FRAMEBUF_T address (especially in display order != decode order) */ + VDEC_DRV_GET_TYPE_DISP_FRAME_BUFFER, + + /* + /< return a frame didn't be a reference more + (when buffer_mode = REF_IS_DISP_EXT, REF_INT_DISP_EXT or REF_INT_POOL_DISP_EXT) + */ + VDEC_DRV_GET_TYPE_FREE_FRAME_BUFFER, + VDEC_DRV_GET_TYPE_GET_PICTURE_INFO, /* /< return a pointer address point to P_VDEC_DRV_PICINFO_T */ + VDEC_DRV_GET_TYPE_GET_STATISTIC_INFO, /* /< return statistic information. */ + VDEC_DRV_GET_TYPE_GET_FRAME_MODE, /* /< return frame mode parameter. */ + VDEC_DRV_GET_TYPE_GET_FRAME_CROP_INFO, /* /< return frame crop information. */ + + /* /< query if driver can re-order the decode order to display order */ + VDEC_DRV_GET_TYPE_QUERY_REORDER_ABILITY, + VDEC_DRV_GET_TYPE_QUERY_DOWNSIZE_ABILITY, /* /< query if driver can downsize decoded frame */ + VDEC_DRV_GET_TYPE_QUERY_RESIZE_ABILITY, /* /< query if driver can resize decoded frame */ + VDEC_DRV_GET_TYPE_QUERY_DEBLOCK_ABILITY, /* /< query if driver can do deblocking */ + VDEC_DRV_GET_TYPE_QUERY_DEINTERLACE_ABILITY, /* /< query if driver can do deinterlace */ + VDEC_DRV_GET_TYPE_QUERY_DROPFRAME_ABILITY, /* /< query if driver can drop frame */ + + /* /< query if driver finish decode one frame but no output (main profile with B frame case.) */ + VDEC_DRV_GET_TYPE_GET_DECODE_STATUS_INFO, + VDEC_DRV_GET_TYPE_GET_PIXEL_FORMAT, /* /< query the driver output pixel format */ + VDEC_DRV_GET_TYPE_GET_CPU_LOADING_INFO, /* /< query the cpu loading info from kernel driver */ + VDEC_DRV_GET_TYPE_GET_HW_CRC, /* /< query the hw CRC */ + VDEC_DRV_GET_TYPE_GET_CODEC_TIDS, /* /< query the thread ids from the codec lib */ + VDEC_DRV_GET_TYPE_GET_FRAME_INTERVAL, /* /< query frame interval from the codec lib */ + VDEC_DRV_GET_TYPE_FREE_INPUT_BUFFER, /* /< free input buffer */ + VDEC_DRV_GET_TYPE_QUERY_VIDEO_INTERLACING, /* /< query video interlace information */ + VDEC_DRV_GET_TYPE_QUERY_VIDEO_DPB_SIZE, /* /< query video DPB size */ + VDEC_DRV_SET_TYPE_SET_WAIT_KEYFRAME, ///< set wait keyframe mode, default 0, 1 = wait at start/flush, 2 = wait at seek mode, 3 = always wait + VDEC_DRV_GET_TYPE_CODEC_PROPERTY /* /< get teh codec specific property for decode flow*/ +} VDEC_DRV_GET_TYPE_T; + +typedef enum _VDEC_DRV_CODEC_PROPERTY_T { + VDEC_CODEC_NONE = 0x00000000, + VDEC_CODEC_SUPPORT_DPB_SIZE = 0x00000001, +} VDEC_DRV_CODEC_PROPERTY_T; + + +/** + * @par Enumeration + * VDEC_DRV_PIXEL_FORMAT_T + * @par Description + * pixel format + */ +typedef enum _VDEC_DRV_PIXEL_FORMAT_T { + VDEC_DRV_PIXEL_FORMAT_NONE = 0, /* /< None */ + VDEC_DRV_PIXEL_FORMAT_YUV_420_PLANER, /* /< YUV 420 planer */ + VDEC_DRV_PIXEL_FORMAT_YUV_420_PLANER_MTK, /* /< YUV 420 planer MTK mode */ + VDEC_DRV_PIXEL_FORMAT_YUV_420_PLANER_UFO, /* /< YUV 420 planer MTK UFO mode */ + VDEC_DRV_PIXEL_FORMAT_YUV_YV12 /* /< YUV YV12 */ +} VDEC_DRV_PIXEL_FORMAT_T; + + +/** + * @par Enumeration + * VDEC_DRV_DECODER_TYPE_T + * @par Description + * decoder type + */ +typedef enum _VDEC_DRV_DECODER_TYPE_T { + VDEC_DRV_DECODER_MTK_HARDWARE = 0, /* /< MTK software */ + VDEC_DRV_DECODER_MTK_SOFTWARE, /* /< MTK hardware */ + VDEC_DRV_DECODER_GOOGLE_SOFTWARE /* /< google software (default) */ +} VDEC_DRV_DECODER_TYPE_T; + + +/** + * @par Enumeration + * VDEC_DRV_SET_TYPE_T + * @par Description + * video driver used to set different info + */ +typedef enum _VDEC_DRV_SET_TYPE_T { + /* /< =1, use timestamp in sVDEC_DRV_FRAMEBUF_T for the picture */ + VDEC_DRV_SET_TYPE_USE_EXT_TIMESTAMP, + VDEC_DRV_SET_TYPE_SET_BUFFER_MODE, /* /< value is one of VDEC_DRV_BUFFER_MODE */ + + /* /< one of VDEC_DRV_FBTYPE, if output type is the same as decode type, buffer mode can be REF_IS_DISP */ + VDEC_DRV_SET_TYPE_SET_FRAME_BUFFER_TYPE, + VDEC_DRV_SET_TYPE_FREE_FRAME_BFFER, /* /< release buffer if DISP BUFFER is allocated from driver */ + VDEC_DRV_SET_TYPE_SET_REF_EXT_POOL_ADDR, /* /< if use REF_EXT_POOL in SET_BUFFER_MODE */ + VDEC_DRV_SET_TYPE_SET_DISP_EXT_POOL_ADDR, /* /< if use DISP_EXT_POOL in SET_BUFFER_MODE */ + VDEC_DRV_SET_TYPE_SET_DECODE_MODE, /* /< set if drop frame */ + + /* /< buffer mode cannot set to REF_IS_DISP when using post-processing */ + VDEC_DRV_SET_TYPE_SET_POST_PROC, + VDEC_DRV_SET_TYPE_SET_STATISTIC_ON, /* /< enable statistic function. */ + VDEC_DRV_SET_TYPE_SET_STATISTIC_OFF, /* /< disable statistic function. */ + VDEC_DRV_SET_TYPE_SET_FRAME_MODE, /* /< set frame mode */ + VDEC_DRV_SET_TYPE_SET_BUF_STATUS_FOR_SPEEDY, /* /< set buffer status for speedy mode */ + VDEC_DRV_SET_TYPE_SET_LAST_DISPLAY_TIME, /* /< set the last display time */ + VDEC_DRV_SET_TYPE_SET_CURRENT_PLAY_TIME, /* /< set the current play time */ + VDEC_DRV_SET_TYPE_SET_CONCEAL_LEVEL, /* /< error conceal level for decoder */ + VDEC_DRV_SET_TYPE_SET_OMX_TIDS, /* /< set omx thread ids */ + VDEC_DRV_SET_TYPE_SET_SWITCH_TVOUT, /* /< set ot switch to TV OUT */ + VDEC_DRV_SET_TYPE_SET_CODEC_COLOR_FORAMT, /* /< set codec color format */ + VDEC_DRV_SET_TYPE_SET_CODEC_YUV_STRIDE, /* /< set codec yuv stride */ + VDEC_DRV_SET_TYPE_SET_FRAMESIZE, /* /< set frame size from caller for MPEG4 decoder */ + + /* /< use the max suppoerted size as output buffer size. for smooth */ + VDEC_DRV_SET_TYPE_SET_FIXEDMAXOUTPUTBUFFER, + VDEC_DRV_SET_TYPE_SET_UFO_DECODE, + VDEC_DRV_SET_TYPE_SET_CALLBACK, + VDEC_DRV_SET_TYPE_SET_FULL_SPEED, +} VDEC_DRV_SET_TYPE_T; + + +/** + * @par Enumeration + * VDEC_DRV_DECODE_MODE_T + * @par Description + * video driver decode mode + */ +typedef enum _VDEC_DRV_DECODE_MODE_T { + VDEC_DRV_DECODE_MODE_UNKNOWN = 0, /* /< Unknown */ + VDEC_DRV_DECODE_MODE_NORMAL, /* /< decode all frames (no drop) */ + VDEC_DRV_DECODE_MODE_I_ONLY, /* /< skip P and B frame */ + VDEC_DRV_DECODE_MODE_B_SKIP, /* /< skip B frame */ + VDEC_DRV_DECODE_MODE_DROPFRAME, /* /< display param1 frames & drop param2 frames */ + VDEC_DRV_DECODE_MODE_NO_REORDER, /* /< output display ASAP without reroder */ + VDEC_DRV_DECODE_MODE_THUMBNAIL, /* /< thumbnail mode */ + + /* /< skip reference check mode - force decode and display from first frame */ + VDEC_DRV_DECODE_MODE_SKIP_REFERENCE_CHECK, + + /* /< decode immediately no check. (parser should make sure the completed frame) */ + VDEC_DRV_DECODE_MODE_LOW_LATENCY_DECODE, +} VDEC_DRV_DECODE_MODE_T; + + +/** + * @par Enumeration + * VDEC_DRV_MRESULT_T + * @par Description + * Driver return type + */ +typedef enum __VDEC_DRV_MRESULT_T { + VDEC_DRV_MRESULT_OK = 0, /* /< OK */ + VDEC_DRV_MRESULT_FAIL, /* /< Fail */ + VDEC_DRV_MRESULT_FATAL, /* /< Fatal error to stop. */ + VDEC_DRV_MRESULT_RESOLUTION_CHANGED, /* /< Represent resoluion changed */ + VDEC_DRV_MRESULT_NEED_MORE_OUTPUT_BUFFER, /* /< Represent need more output buffer */ + VDEC_DRV_MRESULT_MAX = 0x0FFFFFFF /* /< Max Value */ +} VDEC_DRV_MRESULT_T; + +/** + * @par Enumeration + * VDEC_DRV_INPUTBUF_T + * @par Description + * Description the input buffer property + */ + +typedef enum _VDEC_DRV_INPUTBUF_T { + VDEC_DRV_INPUT_BUF_INIT_CONFIG_DATA = (1 << 0), /*/ < init data, most case this is video header only*/ + VDEC_DRV_INPUT_BUF_EOS = (1 << 1), /*/ < input buffer with EOS flag*/ + VDEC_DRV_INPUT_BUF_INVALID_TIMESTAMP = (1 << 2), /*/ < input buffer with invalid timestamp flag*/ +} VDEC_DRV_INPUTBUF_T; + +/** + * @par Structure + * VDEC_DRV_RINGBUF_T + * @par Description + * Ring Buffer Structure + * - Store buffer base address + * - Store read/write pointer address + */ +typedef struct __VDEC_DRV_RINGBUF_T { // union extend 64bits for TEE + VAL_MEM_ADDR_T rBase; /* /< [IN] Base address of ring buffer */ + union { + VAL_ULONG_T u4Read; /* /< [IN/OUT] Virtual address of read pointer */ + VAL_UINT64_T u4Read_ext64; + }; + union { + VAL_ULONG_T u4Write; /* /< [IN] Virtual address of write pointer */ + VAL_UINT64_T u4Write_ext64; + }; + VAL_UINT32_T u4Timestamp; /* /< [IN/OUT] store timestamp */ + VAL_UINT32_T rSecMemHandle; /* /< [IN/OUT] security memory handle // MTK_SEC_VIDEO_PATH_SUPPORT */ + VAL_UINT32_T u4InputFlag; /*/ < [IN] the property of input buffer */ +} VDEC_DRV_RINGBUF_T; + +/** + * @par Structure + * P_VDEC_DRV_RINGBUF_T + * @par Description + * Pointer of VDEC_DRV_RINGBUF_T + */ +typedef VDEC_DRV_RINGBUF_T * P_VDEC_DRV_RINGBUF_T; + + +/** + * @par Structure + * VDEC_DRV_FRAMEBUF_T + * @par Description + * Frame buffer information + */ +typedef struct __VDEC_DRV_FRAMEBUF_T { + VAL_MEM_ADDR_T rBaseAddr; /* /< [IN/OUT] Base address */ + VAL_MEM_ADDR_T rPostProcAddr; /* /< [IN/OUT] Post process address */ + VAL_UINT32_T u4BufWidth; /* /< [IN/OUT] Buffer width */ + VAL_UINT32_T u4BufHeight; /* /< [IN/OUT] Buffer height */ + VAL_UINT32_T u4DispWidth; /* /< [OUT] Display width */ + VAL_UINT32_T u4DispHeight; /* /< [OUT] Display width */ + VAL_UINT32_T u4DispPitch; /* /< [OUT] Display pitch */ + VAL_UINT32_T u4Timestamp; /* /< [IN/OUT] Timestamp for last decode picture */ + VAL_UINT32_T u4AspectRatioW; /* /< [OUT] The horizontal size of the sample aspect ratio. */ + VAL_UINT32_T u4AspectRatioH; /* /< [OUT] The vertical size of the sample aspect ratio. */ + VAL_UINT32_T u4FrameBufferType; /* /< [OUT] One of VDEC_DRV_FBTYPE */ + VAL_UINT32_T u4PictureStructure; /* /< [OUT] One of VDEC_DRV_PIC_STRUCT */ + VAL_UINT32_T u4FrameBufferStatus; /* /< [OUT] One of VDEC_DRV_FBSTSTUS */ + VAL_UINT32_T u4IsUFOEncoded; /* /< [OUT] FB Is UFO Encoded */ + VAL_UINT32_T u4Reserved1; /* /< [IN/OUT] Reserved */ + VAL_UINT32_T u4Reserved2; /* /< [IN/OUT] Reserved */ + VAL_UINT32_T u4Reserved3; /* /< [IN/OUT] Reserved */ + + /* /< [IN/OUT] security memory handle // MTK_SEC_VIDEO_PATH_SUPPORT */ + VAL_UINT32_T rSecMemHandle; + VAL_UINT32_T u4ReeVA; /* /< [IN/OUT] Ree Va // MTK_SEC_VIDEO_PATH_SUPPORT */ + + /* /< [IN/OUT] share handle of rBaseAddr.u4VA (for UT only) // MTK_SEC_VIDEO_PATH_SUPPORT */ + VAL_UINT32_T rFrameBufVaShareHandle; +} VDEC_DRV_FRAMEBUF_T; + +/** + * @par Structure + * P_VDEC_DRV_FRAMEBUF_T + * @par Description + * Pointer of VDEC_DRV_FRAMEBUF_T + */ +typedef VDEC_DRV_FRAMEBUF_T * P_VDEC_DRV_FRAMEBUF_T; + + +/** + * @par Structure + * VDEC_DRV_CROPINFO_T + * @par Description + * Frame cropping information + */ +typedef struct __VDEC_DRV_CROPINFO_T { + VAL_UINT32_T u4CropLeft; /* /< Frame cropping left index */ + VAL_UINT32_T u4CropRight; /* /< Frame cropping right index */ + VAL_UINT32_T u4CropTop; /* /< Frame cropping top index */ + VAL_UINT32_T u4CropBottom; /* /< Frame cropping bottom index */ +} VDEC_DRV_CROPINFO_T; + + +/** + * @par Structure + * P_VDEC_DRV_CROPINFO_T + * @par Description + * Pointer of VDEC_DRV_CROPINFO_T + */ +typedef VDEC_DRV_CROPINFO_T * P_VDEC_DRV_CROPINFO_T; + +/** + * @par Structure + * VDEC_DRV_PICINFO_T + * @par Description + * Picture information + */ +typedef struct __VDEC_DRV_PICINFO_T { + VAL_UINT32_T u4Width; /* /< [OUT] Frame width */ + VAL_UINT32_T u4Height; /* /< [OUT] Frame height */ + VAL_UINT32_T u4RealWidth; /* /< [OUT] Frame real width (allocate buffer size) */ + VAL_UINT32_T u4RealHeight; /* /< [OUT] Frame real height (allocate buffer size) */ + VAL_UINT32_T u4Timestamp; /* /< [OUT] Timestamp for last decode picture */ + VAL_UINT32_T u4AspectRatioW; /* /< [OUT] The horizontal size of the sample aspect ratio */ + VAL_UINT32_T u4AspectRatioH; /* /< [OUT] The vertical size of the sample aspect ratio */ + VAL_UINT32_T u4FrameRate; /* /< [OUT] One of VDEC_DRV_FRAME_RATE */ + VAL_UINT32_T u4PictureStructure; /* /< [OUT] One of VDEC_DRV_PIC_STRUCT */ + VAL_UINT32_T u4IsProgressiveOnly; /* /< [OUT] 1: Progressive only. 0: Not progressive only. */ + VAL_INT32_T u4BitDepthLuma; /* /< [OUT] Sequence luma bitdepth */ + VAL_INT32_T u4BitDepthChroma; /* /< [OUT] Sequence chroma bitdepth */ + VAL_BOOL_T bIsHorizontalScaninLSB; /* /< [OUT] Scan direction in 10bit LSB 2 bit */ +} VDEC_DRV_PICINFO_T; + +/** + * @par Structure + * P_VDEC_DRV_PICINFO_T + * @par Description + * Pointer of VDEC_DRV_PICINFO_T + */ +typedef VDEC_DRV_PICINFO_T * P_VDEC_DRV_PICINFO_T; + + +/** + * @par Structure + * VDEC_DRV_SEQINFO_T + * @par Description + * Sequence information. + * - Including Width/Height + */ +typedef struct __VDEC_DRV_SEQINFO_T { + VAL_UINT32_T u4Width; /* /< [OUT] Sequence buffer width */ + VAL_UINT32_T u4Height; /* /< [OUT] Sequence buffer height */ + VAL_UINT32_T u4PicWidth; /* /< [OUT] Sequence display width */ + VAL_UINT32_T u4PicHeight; /* /< [OUT] Sequence display height */ + VAL_INT32_T i4AspectRatioWidth; /* /< [OUT] Sequence aspect ratio width */ + VAL_INT32_T i4AspectRatioHeight; /* /< [OUT] Sequence aspect ratio height */ + VAL_BOOL_T bIsThumbnail; /* /< [OUT] check thumbnail */ + VAL_INT32_T u4BitDepthLuma; /* /< [OUT] Sequence luma bitdepth */ + VAL_INT32_T u4BitDepthChroma; /* /< [OUT] Sequence chroma bitdepth */ + VAL_BOOL_T bIsHorizontalScaninLSB; /* /< [OUT] Scan direction in 10bit LSB 2 bit */ +} VDEC_DRV_SEQINFO_T; + +/** + * @par Structure + * P_VDEC_DRV_SEQINFO_T + * @par Description + * Pointer of VDEC_DRV_SEQINFO_T + */ +typedef VDEC_DRV_SEQINFO_T * P_VDEC_DRV_SEQINFO_T; + + +/** + * @par Structure + * VDEC_DRV_YUV_STRIDE_T + * @par Description + * Y/UV Stride information + */ +typedef struct __VDEC_DRV_YUV_STRIDE_T { + unsigned int u4YStride; /* /< [IN] Y Stride */ + unsigned int u4UVStride; /* /< [IN] UV Stride */ +} VDEC_DRV_YUV_STRIDE_T; + +/** + * @par Structure + * P_VDEC_DRV_YUV_STRIDE_T + * @par Description + * Pointer of VDEC_DRV_YUV_STRIDE_T + */ +typedef VDEC_DRV_YUV_STRIDE_T * P_VDEC_DRV_YUV_STRIDE_T; + +#define VDEC_DRV_CONCURRENCE_LIMIT_WFD 0x00000001 +#define VDEC_DRV_CONCURRENCE_LIMIT_MHL 0x00000002 +#define VDEC_DRV_CONCURRENCE_LIMIT_BLUETOOTH 0x00000004 +#define VDEC_DRV_CONCURRENCE_LIMIT_MASK 0x00000007 +/** + * @par Structure + * VDEC_DRV_QUERY_VIDEO_FORMAT_T + * @par Description + * Both input and output of type QUERY_VIDEO_FORMAT + */ +typedef struct __VDEC_DRV_QUERY_VIDEO_FORMAT_T { + VAL_UINT32_T u4VideoFormat; /* /< [OUT] VDEC_DRV_VIDEO_FORMAT */ + VAL_UINT32_T u4Profile; /* /< [OUT] VDEC_DRV_VIDEO_PROFILE */ + VAL_UINT32_T u4Level; /* /< [OUT] VDEC_DRV_VIDEO_LEVEL */ + VAL_UINT32_T u4Resolution; /* /< [OUT] VDEC_DRV_RESOLUTION */ + VAL_UINT32_T u4Width; /* /< [OUT] Frame Width */ + VAL_UINT32_T u4Height; /* /< [OUT] Frame Height */ + VAL_UINT32_T u4StrideAlign; /* /< [OUT] Frame Stride Alignment */ + VAL_UINT32_T u4SliceHeightAlign; /* /< [OUT] Frame Slice Height Alignment */ + VDEC_DRV_PIXEL_FORMAT_T ePixelFormat; /* /< [OUT] Frame Format */ + VDEC_DRV_DECODER_TYPE_T eDecodeType; /* /< [OUT] Decoder type */ + VAL_UINT32_T u4CompatibleFlag; /* /< [OUT] CompatibleFlag */ +} VDEC_DRV_QUERY_VIDEO_FORMAT_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_VIDEO_FORMAT_T + * @par Description + * Pointer of VDEC_DRV_QUERY_VIDEO_FORMAT_T + */ +typedef VDEC_DRV_QUERY_VIDEO_FORMAT_T * P_VDEC_DRV_QUERY_VIDEO_FORMAT_T; + + +/** + * @par Structure + * VDEC_DRV_SET_DECODE_MODE_T + * @par Description + * [Unused]Set Decode Mode + */ +typedef struct __VDEC_DRV_SET_DECODE_MODE_T { + VDEC_DRV_DECODE_MODE_T eDecodeMode; /* /< [IN/OUT] one of VDEC_DRV_DECODE_MODE */ + VAL_UINT32_T u4DisplayFrameNum; /* /< [IN/OUT] 0 8 7 6 5 4 3 2 1 1 1 1 1 1 1 1 */ + VAL_UINT32_T u4DropFrameNum; /* /< [IN/OUT] 0 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 */ +} VDEC_DRV_SET_DECODE_MODE_T; + +/** + * @par Structure + * P_VDEC_DRV_SET_DECODE_MODE_T + * @par Description + * Pointer of VDEC_DRV_SET_DECODE_MODE_T + */ +typedef VDEC_DRV_SET_DECODE_MODE_T * P_VDEC_DRV_SET_DECODE_MODE_T; + + +/** + * @par Structure + * VDEC_DRV_PROPERTY_T + * @par Description + * VDecDrv property information + */ +typedef struct __VDEC_DRV_PROPERTY_T { + /* /< [OUT] buffer alignment requirement. */ + VAL_UINT32_T u4BufAlign; + + /* /< [OUT] buffer unit size is N bytes . (e.g., 8, 16, or 64 bytes per unit.) */ + VAL_UINT32_T u4BufUnitSize; + + /* /< [OUT] support post-process. */ + VAL_BOOL_T fgPostprocessSupport; + + /* /< [IN/OUT] Post process property */ + struct { + VAL_UINT32_T fgOverlay:1; + VAL_UINT32_T fgRotate:1; + VAL_UINT32_T fgResize:1; + VAL_UINT32_T fgCrop:1; + } PostProcCapability; +} VDEC_DRV_PROPERTY_T; + +/** + * @par Structure + * P_VDEC_DRV_PROPERTY_T + * @par Description + * Pointer of VDEC_DRV_PROPERTY_T + */ +typedef VDEC_DRV_PROPERTY_T * P_VDEC_DRV_PROPERTY_T; + +/** +* @par Structure +* VDEC_DRV_CALLBACK_T +* @par Description +* VDEC callback function +*/ +typedef struct __VDEC_DRV_CALLBACK_T_ { // union extend 64bits for TEE + union { + VAL_HANDLE_T u4hHandle; + VAL_UINT64_T u4hHandle_ext64; + }; + union { + VAL_UINT32_T (*pfnGetOutputBuffer)(VAL_HANDLE_T, P_VDEC_DRV_FRAMEBUF_T *, VAL_UINT32_T, VAL_BOOL_T, VAL_VOID_T *); + VAL_UINT64_T pfnGetOutputBuffer_ext64; + }; +} VDEC_DRV_CALLBACK_T; + +typedef VDEC_DRV_CALLBACK_T * P_VDEC_DRV_CALLBACK_T; + + +/** + * @par Function: + * eVDecDrvQueryCapability + * @par Description: + * - Query Decode Driver Capability + * - Input argument will be compare with driver's capability to check if the query is successful or not. + * @param + * a_eType [IN] Driver query type, such as FBType, Video Format, etc. + * @param + * a_pvInParam [IN] Input parameter for each type of query. + * @param + * a_pvOutParam [OUT] Store query result, such as FBType, Video Format, etc. + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Query Success + * - VDEC_DRV_MRESULT_FAIL: Query Fail + */ +VDEC_DRV_MRESULT_T eVDecDrvQueryCapability( + VDEC_DRV_QUERY_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function: + * eVDecDrvCreate + * @par Description: + * - Create handle + * - Allocate extra data for each driver + * - According to the input parameter, "a_eVideoFormat." + * @param + * a_phHandle [IN/OUT] Driver handle + * @param + * a_eVideoFormat [IN] Video format, such as MPEG4, H264, etc. + * @par Returns: + * Reason for return value. Show the default returned value at which condition. + * - VDEC_DRV_MRESULT_OK: Create handle successfully + * - VDEC_DRV_MRESULT_FAIL: Failed to create handle + */ +VDEC_DRV_MRESULT_T eVDecDrvCreate(VAL_HANDLE_T *a_phHandle, VDEC_DRV_VIDEO_FORMAT_T a_eVideoFormat); + + +/** + * @par Function: + * eVDecDrvRelease + * @par Description: + * - Release Decode Driver + * - Need to perform driver deinit before driver release. + * - Procedure of release + * - Release extra data + * - Release handle + * @param + * a_hHandle [IN] Handle needed to be released. + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Release handle successfully. + * - VDEC_DRV_MRESULT_FAIL: Failed to release handle. + */ +VDEC_DRV_MRESULT_T eVDecDrvRelease(VAL_HANDLE_T a_hHandle); + + +/** + * @par Function: + * eVDecDrvInit + * @par Description: + * - Initialize Decode Driver + * - Get width and height of bitstream + * @param + * a_hHandle [IN] Driver handle + * @param + * a_prBitstream [IN] Input bitstream for driver initialization + * @param + * a_prSeqinfo [OUT] Return width and height of bitstream + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Init driver successfully. + * - VDEC_DRV_MRESULT_FAIL: Failed to init driver. + */ +VDEC_DRV_MRESULT_T eVDecDrvInit( + VAL_HANDLE_T a_hHandle, + VDEC_DRV_RINGBUF_T *a_prBitstream, + VDEC_DRV_SEQINFO_T * a_prSeqinfo +); + + +/** + * @par Function: + * eVDecDrvDeInit + * @par Description: + * - Deinitialize driver + * - Have to deinit driver before release driver + * @param + * a_hHandle [IN] Driver handle + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Deinit driver successfully. + * - VDEC_DRV_MRESULT_FAIL: Failed to deinit driver. + */ +VDEC_DRV_MRESULT_T eVDecDrvDeInit(VAL_HANDLE_T a_hHandle); + + +/** + * @par Function: + * eVDecDrvGetParam + * @par Description: + * - Get driver's parameter + * - Type of parameter can be referred to VDEC_DRV_GET_TYPE_T. + * @param + * a_hHandle [IN] Driver handle + * @param + * a_eType [IN] Parameter type + * @param + * a_pvInParam [OUT] Input argument for query parameter. + * @param + * a_pvOutParam [OUT] Store output parameter + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Get parameter successfully. + * - VDEC_DRV_MRESULT_FAIL: Failed to get parameter. + * - Fail reason might be + * - wrong or unsupported parameter type + * - fail to get reference memory pool size. + */ +VDEC_DRV_MRESULT_T eVDecDrvGetParam( + VAL_HANDLE_T a_hHandle, + VDEC_DRV_GET_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function: + * eVDecDrvSetParam + * @par Description: + * - Set driver's parameters + * @param + * a_hHandle [IN] driver handle + * @param + * a_eType [IN] parameter type + * @param + * a_pvInParam [IN] input parameter + * @param + * a_pvOutParam [OUT] output parameter + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Get parameter successfully. + * - VDEC_DRV_MRESULT_FAIL: Failed to get parameter. + * - Fail reason might be + * - wrong or unsupported parameter type + * - fail to set parameter + */ +VDEC_DRV_MRESULT_T eVDecDrvSetParam( + VAL_HANDLE_T a_hHandle, + VDEC_DRV_SET_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function: + * eVDecDrvDecode + * @par Description: + * - Trigger Decode + * - Need to Provide frame buffer to store unused buffer + * - The procedure of decode including: + * - Header parsing + * - trigger hw decode + * - While we want to decode the last frame, + * we need to set input bitstream as VAL_NULL and still give free frame buffer. + * @param + * a_hHandle [IN] driver handle + * @param + * a_prBitstream [IN] input bitstream + * @param + * a_prFramebuf [IN] free frame buffer + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Decode successfully. + * - VDEC_DRV_MRESULT_FAIL: Failed to decode. + */ +VDEC_DRV_MRESULT_T eVDecDrvDecode( + VAL_HANDLE_T a_hHandle, + VDEC_DRV_RINGBUF_T *a_prBitstream, + VDEC_DRV_FRAMEBUF_T * a_prFramebuf +); + +/** + * @par Function: + * eVDecDrvDecodeEx + * @par Description: + * - Trigger Decode + * - Need to Provide frame buffer to store unused buffer + * - The procedure of decode including: + * - Header parsing + * - trigger hw decode + * - While we want to decode the last frame, + * we need to set input bitstream as VAL_NULL and still give free frame buffer. + * @param + * a_hHandle [IN] driver handle + * @param + * a_prBitstream [IN] input bitstream + * @par Returns: + * - VDEC_DRV_MRESULT_OK: Decode successfully. + * - VDEC_DRV_MRESULT_FAIL: Failed to decode. + */ +VDEC_DRV_MRESULT_T eVDecDrvDecodeEx( + VAL_HANDLE_T a_hHandle, + VDEC_DRV_RINGBUF_T *a_prBitstream, + VAL_UINT32_T u4Flag, + VAL_VOID_T * pExtra +); + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VDEC_DRV_IF_PUBLIC_H_ */ diff --git a/kernel-headers/venc_drv_base.h b/kernel-headers/venc_drv_base.h new file mode 100644 index 0000000..ff02e7b --- /dev/null +++ b/kernel-headers/venc_drv_base.h @@ -0,0 +1,102 @@ +#include "venc_drv_if_private.h" +#include "vcodec_if_v2.h" + +#include <sys/time.h> + +#ifndef _VENC_DRV_BASE_ +#define _VENC_DRV_BASE_ + +#define DO_VCODEC_RESET(cmd, index) \ + { \ + } + +typedef enum __VDDRV_MRESULT_T { + VDDRV_MRESULT_SUCCESS = VAL_TRUE, /* /< Represent success */ + VDDRV_MRESULT_FAIL = VAL_FALSE /* /< Represent failure */ +} VDDRV_MRESULT_T; + +typedef struct __VENC_DRV_BASE_T { + VAL_UINT32_T(*Init)( + VAL_HANDLE_T * handle, + VAL_HANDLE_T halhandle, + VAL_HANDLE_T valhandle + ); + VAL_UINT32_T(*Encode)( + VAL_HANDLE_T handle, + VENC_DRV_START_OPT_T eOpt, + P_VENC_DRV_PARAM_FRM_BUF_T pFrameBuf, + P_VENC_DRV_PARAM_BS_BUF_T pBitstreamBuf, + VENC_DRV_DONE_RESULT_T * pResult + ); + VAL_UINT32_T(*GetParam)( + VAL_HANDLE_T handle, + VENC_DRV_GET_TYPE_T a_eType, + VAL_VOID_T * a_pvInParam, + VAL_VOID_T * a_pvOutParam + ); + VAL_UINT32_T(*SetParam)( + VAL_HANDLE_T handle, + VENC_DRV_SET_TYPE_T a_eType, + VAL_VOID_T * a_pvInParam, + VAL_VOID_T * a_pvOutParam + ); + VAL_UINT32_T(*DeInit)( + VAL_HANDLE_T handle + ); /* /< Function to do driver de-initialization */ +} VENC_DRV_BASE_T; + +/** + * @par Structure + * mhalVdoDrv_t + * @par Description + * This is a structure which store common video enc driver information + */ +typedef struct mhalVdoDrv_s { + VAL_VOID_T *prCodecHandle; + VAL_UINT32_T u4EncodedFrameCount; + VCODEC_ENC_CALLBACK_T rCodecCb; + VIDEO_ENC_API_T *prCodecAPI; + VENC_BS_T pBSBUF; + + VCODEC_ENC_BUFFER_INFO_T EncoderInputParamNC; + VENC_DRV_PARAM_BS_BUF_T BSout; + VENC_HYBRID_ENCSETTING rVencSetting; + VAL_UINT8_T *ptr; +} mhalVdoDrv_t; + + +typedef struct __VENC_HYBRID_HANDLE_T { + mhalVdoDrv_t rMhalVdoDrv; + VAL_MEMORY_T rBSDrvWorkingMem; + VAL_UINT32_T nOmxTids; + VAL_VCODEC_THREAD_ID_T rThreadID; + VIDEO_ENC_WRAP_HANDLE_T hWrapper; + VAL_VOID_T *pDrvModule; /* /< used for dlopen and dlclose */ +} VENC_HYBRID_HANDLE_T; + + +typedef struct __VENC_HANDLE_T { + VENC_DRV_VIDEO_FORMAT_T CodecFormat; + VENC_DRV_BASE_T rFuncPtr; /* /< Point to driver's proprietary function. */ + VAL_HANDLE_T hDrvHandle; /* /< Handle of each format driver */ + VAL_HANDLE_T hHalHandle; /* /< HAL handle */ + VAL_HANDLE_T hValHandle; /* /< VAL handle */ + VAL_MEMORY_T rHandleMem; /* /< Memory for venc handle */ + VAL_VOID_T *prExtraData; /* /< Driver private data pointer. */ + VAL_MEMORY_T rExtraDataMem; /* /< Save extra data memory information to be used in release. */ + VENC_HYBRID_HANDLE_T rHybridHandle; /* /< Hybrid handle */ + FILE *pfDump; + VAL_UINT32_T u4ShowInfo; /* /< Flag for show FPS and BitRate */ + VAL_UINT32_T u4FPS; /* /< FPS */ + VAL_UINT32_T u4Bitrate; /* /< Bitrate */ + struct timeval tStart; /* /< Start time counting FPS and bitrate */ + VENC_DRV_SCENARIO_T eScenario; /* /< VENC Senario */ + VAL_INT32_T nPerfServiceHandle; /* /< Used by performace service */ + VAL_UINT32_T u4RecFrmWidth; /* /< Recoded frame width, (may not 16 byte-align) */ + VAL_UINT32_T u4RecFrmHeight; /* /< Recoded frame height, (may not 16 byte-align) */ +} VENC_HANDLE_T; + +VENC_DRV_MRESULT_T ParseConfig(const char *cfgFileName, const char *ParameterItem, VAL_UINT32_T *val); + + +#endif diff --git a/kernel-headers/venc_drv_if_dep.h b/kernel-headers/venc_drv_if_dep.h new file mode 100644 index 0000000..a3976b6 --- /dev/null +++ b/kernel-headers/venc_drv_if_dep.h @@ -0,0 +1,75 @@ +#ifndef VENC_DRV_IF_DEP_H +#define VENC_DRV_IF_DEP_H + +/*============================================================================= + * Include Files + *===========================================================================*/ + +#include "val_types_private.h" +#include "vcodec_if_v2.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*============================================================================= + * Type definition + *===========================================================================*/ + +/** + * @par Structure + * mhalVdoDrv_t + * @par Description + * This is a structure which store common video enc driver information + */ +typedef struct mhalVdoDrv_s { + VAL_VOID_T *prCodecHandle; + VAL_UINT32_T u4EncodedFrameCount; + VCODEC_ENC_CALLBACK_T rCodecCb; + VIDEO_ENC_API_T *prCodecAPI; + VENC_BS_T pBSBUF; + + VCODEC_ENC_BUFFER_INFO_T EncoderInputParamNC; + VENC_DRV_PARAM_BS_BUF_T BSout; + VENC_HYBRID_ENCSETTING rVencSetting; + VAL_UINT8_T *ptr; +} mhalVdoDrv_t; + +typedef struct __VENC_HANDLE_T { + VAL_HANDLE_T hHalHandle; /* /< HAL data. */ + VAL_HANDLE_T vdriver_Handle; /* /< for MMSYS power on/off */ + VAL_MEMORY_T rHandleMem; /* /< Save handle memory information to be used in release. */ + VAL_BOOL_T bFirstDecoded; /* / < already pass first video data to codec */ + VAL_BOOL_T bHeaderPassed; /* / < already pass video header to codec */ + VAL_BOOL_T bFlushAll; + VAL_MEMORY_T HeaderBuf; + VAL_HANDLE_T hCodec; + /* DRIVER_HANDLER_T hDrv; */ + VAL_UINT32_T CustomSetting; + VCODEC_MEMORY_TYPE_T rVideoDecMemType; + VAL_UINT32_T nYUVBufferIndex; + VCODEC_OPEN_SETTING_T codecOpenSetting; + + mhalVdoDrv_t rMhalVdoDrv; + VAL_MEMORY_T bs_driver_workingmem; + + /* Morris Yang 20110411 [ */ + VENC_DRV_VIDEO_FORMAT_T CodecFormat; + VAL_VOID_T *prExtraData; /* /< Driver private data pointer. */ + VAL_MEMORY_T rExtraDataMem; /* /< Save extra data memory information to be used in release. */ + /* ] */ + VAL_UINT32_T nOmxTids; +#if 1 /* defined(MT6572) //VCODEC_MULTI_THREAD */ + /* Jackal Chen [ */ + VAL_VOID_T *pDrvModule; /* /< used for dlopen and dlclose */ + /* ] */ +#endif + VIDEO_ENC_WRAP_HANDLE_T hWrapper; +} VENC_HANDLE_T; + + +#ifdef __cplusplus +} +#endif + +#endif /* VENC_DRV_IF_DEP_H */ diff --git a/kernel-headers/venc_drv_if_private.h b/kernel-headers/venc_drv_if_private.h new file mode 100644 index 0000000..4cff833 --- /dev/null +++ b/kernel-headers/venc_drv_if_private.h @@ -0,0 +1,129 @@ +#ifndef _VENC_DRV_IF_PRIVATE_H_ +#define _VENC_DRV_IF_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "venc_drv_if_public.h" + + +typedef enum __VENC_DRV_COLOR_FORMAT_T { + VENC_DRV_COLOR_FORMAT_YUV420, + VENC_DRV_COLOR_FORMAT_YV12, +} +VENC_DRV_COLOR_FORMAT_T; + + +typedef struct __VENC_DRV_YUV_STRIDE_T { + unsigned int u4YStride; + unsigned int u4UVStride; +} VENC_DRV_YUV_STRIDE_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_EIS_T + * @par Description + * This is the EIS information and used as input or output parameter for\n + * eVEncDrvSetParam() or eVEncDrvGetParam()\n + */ +typedef struct __VENC_DRV_PARAM_EIS_T { + VAL_BOOL_T fgEISEnable; /* /<: EIS Enable/disable. */ + VAL_UINT32_T u4EISFrameWidth; /* /<: EIS FrameWidth */ + VAL_UINT32_T u4EISFrameHeight; /* /<: EIS FrameHeight */ + VAL_UINT32_T u4GMV_X; /* /<: Golbal Motion Vector (GMV) of the VOP Frame used for EIS */ + VAL_UINT32_T u4GMV_Y; /* /<: Golbal Motion Vector (GMV) of the VOP Frame used for EIS */ +} VENC_DRV_PARAM_EIS_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_EIS_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_EIS_T + */ +typedef VENC_DRV_PARAM_EIS_T * P_VENC_DRV_PARAM_EIS_T; + + +/** + * @par Structure + * VENC_DRV_STATISTIC_T + * @par Description + * This is statistic information and used as output parameter for\n + * eVEncDrvGetParam()\n + */ +typedef struct __VENC_DRV_STATISTIC_T { + VAL_UINT32_T u4EncTimeMax; /* /<: Encode one frame time. Max */ + VAL_UINT32_T u4EncTimeMin; /* /<: Encode one frame time. Min */ + VAL_UINT32_T u4EncTimeAvg; /* /<: Encode one frame time. Average */ + VAL_UINT32_T u4EncTimeSum; /* /<: Encode one frame time. Sum */ +} VENC_DRV_STATISTIC_T; + +/** + * @par Structure + * P_VENC_DRV_STATISTIC_T + * @par Description + * This is the pointer of VENC_DRV_STATISTIC_T + */ +typedef VENC_DRV_STATISTIC_T * P_VENC_DRV_STATISTIC_T; + + +typedef struct __VENC_HYB_ENCSETTING { + + /* used in SetParameter */ + VAL_UINT32_T u4Width; + VAL_UINT32_T u4Height; + VAL_UINT32_T u4IntraVOPRate; /* u4NumPFrm; */ + VAL_UINT32_T eFrameRate; + VAL_UINT32_T u4VEncBitrate; + VAL_UINT32_T u4QualityLevel; + VAL_UINT32_T u4ShortHeaderMode; + VAL_UINT32_T u4CodecType; /* mepg4, h263, h264... */ + VAL_UINT32_T u4RotateAngle; + + /* used in QueryFunctions */ + VENC_DRV_COLOR_FORMAT_T eVEncFormat; /* YUV420, I420 ..... */ + VENC_DRV_YUV_STRIDE_T rVCodecYUVStride; + VAL_UINT32_T u4Profile; + VAL_UINT32_T u4Level; + VAL_UINT32_T u4BufWidth; + VAL_UINT32_T u4BufHeight; + VAL_UINT32_T u4NumBFrm; + VAL_UINT32_T fgInterlace; + + /* used in Query */ + VAL_UINT32_T u4InitQ; + VAL_UINT32_T u4MinQ; + VAL_UINT32_T u4MaxQ; + VAL_UINT32_T u4Algorithm; + VAL_UINT32_T u4_Rate_Hard_Limit; + VAL_UINT32_T u4RateBalance; + VAL_UINT32_T u4ForceIntraEnable; + VAL_UINT32_T u4VEncMinBitrate; /* Min bit-rate */ + + /* hardware dependent function settings */ + VAL_BOOL_T fgUseMCI; + VAL_UINT32_T u4VEncThreadNum; + VAL_UINT32_T u4LivePhoto; +} VENC_HYBRID_ENCSETTING; + + +typedef struct VENC_BS_s { + VAL_UINT8_T *u4BS_addr; + VAL_UINT8_T *u4BS_addr_PA; + VAL_UINT32_T u4BSSize; + VAL_UINT32_T u4BS_frmSize; + VAL_UINT32_T u4BS_frmCount; + VAL_UINT32_T u4BS_index; + VAL_UINT32_T u4BS_preindex; + VAL_UINT32_T u4Fillcnt; + VAL_UINT32_T Handle; +} VENC_BS_T; + + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VENC_DRV_IF_PRIVATE_H_ */ diff --git a/kernel-headers/venc_drv_if_public.h b/kernel-headers/venc_drv_if_public.h new file mode 100644 index 0000000..7035dde --- /dev/null +++ b/kernel-headers/venc_drv_if_public.h @@ -0,0 +1,861 @@ +#ifndef _VENC_DRV_IF_PUBLIC_H_ +#define _VENC_DRV_IF_PUBLIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" + + +/** + * @par Enumeration + * VENC_DRV_QUERY_TYPE_T + * @par Description + * This is the item used for query driver + */ +typedef enum __VENC_DRV_QUERY_TYPE_T { + VENC_DRV_QUERY_TYPE_NONE, /* /< Default value (not used) */ + VENC_DRV_QUERY_TYPE_VIDEO_FORMAT, /* /< Query the driver capability */ + VENC_DRV_QUERY_TYPE_VIDEO_PROPERTY, /* /< Query the video property */ + VENC_DRV_QUERY_TYPE_VIDEO_PROPERTY_LIST, /* /< Query the video property list */ + VENC_DRV_QUERY_TYPE_PROPERTY, /* /< Get the driver property */ + VENC_DRV_QUERY_TYPE_MCI_SUPPORTED, /* /< Query if the codec support MCI */ + VENC_DRV_QUERY_TYPE_CHIP_NAME, /* /< Query chip name */ + VENC_DRV_QUERY_TYPE_INPUT_BUF_LIMIT, /* /< Query input buffer stride and sliceheight */ + VENC_DRV_QUERY_TYPE_NORMAL_PRIO, /* /< Query if recorder scenario adjust to normal priority, for 6571. */ + VENC_DRV_QUERY_TYPE_VIDEO_CAMCORDER_CAP, /* /< Query spec. for MediaProfile */ + VENC_DRV_QUERY_TYPE_CHIP_VARIANT, /* /< Query chip variant */ + VENC_DRV_QUERY_TYPE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_QUERY_TYPE_T value */ +} +VENC_DRV_QUERY_TYPE_T; + + +/** + * @par Enumeration + * VENC_DRV_YUV_FORMAT_T + * @par Description + * This is the item used for input YUV buffer format + */ +typedef enum __VENC_DRV_YUV_FORMAT_T { + VENC_DRV_YUV_FORMAT_NONE, /* /< Default value (not used) */ + VENC_DRV_YUV_FORMAT_GRAY, /* /< GRAY YUV format */ + VENC_DRV_YUV_FORMAT_422, /* /< 422 YUV format */ + VENC_DRV_YUV_FORMAT_420, /* /< 420 YUV format */ + VENC_DRV_YUV_FORMAT_411, /* /< 411 YUV format */ + VENC_DRV_YUV_FORMAT_YV12, /* /< Android YV12 (16/16/16) YUV format */ + VENC_DRV_YUV_FORMAT_NV12, /* /< NV12 YUV format */ + VENC_DRV_YUV_FORMAT_NV21, /* /< NV21 YUV format */ + VENC_DRV_YUV_FORMAT_BLK16X32, /* /< Block 16x32 YUV format */ + VENC_DRV_YUV_FORMAT_BLK64X32, /* /< Block 64x32 YUV format */ + VENC_DRV_YUV_FORMAT_YV12_1688, /* /< YV12 YUV format */ + VENC_DRV_YUV_FORMAT_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_YUV_FORMAT_T value */ +} VENC_DRV_YUV_FORMAT_T; + + +/** + * @par Enumeration + * VENC_DRV_VIDEO_FORMAT_T + * @par Description + * This is the item used for encode video format + */ +typedef enum __VENC_DRV_VIDEO_FORMAT_T { + VENC_DRV_VIDEO_FORMAT_NONE, /* /< Default value (not used) */ + VENC_DRV_VIDEO_FORMAT_MPEG4, /* /< MPEG4 video format */ + VENC_DRV_VIDEO_FORMAT_MPEG4_1080P, /* /< MPEG4 video format for 1080p */ + VENC_DRV_VIDEO_FORMAT_MPEG4_SHORT, /* /< MPEG4_SHORT (H.263 baseline profile) video format */ + VENC_DRV_VIDEO_FORMAT_H263, /* /< H.263 video format */ + VENC_DRV_VIDEO_FORMAT_H264, /* /< H.264 video format */ + VENC_DRV_VIDEO_FORMAT_H264_VGA, /* /< H.264 video format for VGA */ + VENC_DRV_VIDEO_FORMAT_WMV9, /* /< WMV9 video format */ + VENC_DRV_VIDEO_FORMAT_VC1, /* /< VC1 video format */ + VENC_DRV_VIDEO_FORMAT_VP8, /* /< VP8 video format */ + VENC_DRV_VIDEO_FORMAT_JPEG, /* /< JPEG picture format */ + VENC_DRV_VIDEO_FORMAT_HEVC, /* /< HEVC video format */ + VENC_DRV_VIDEO_FORMAT_H264SEC, /* /<: Secure H.264 */ + VENC_DRV_VIDEO_FORMAT_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_VIDEO_FORMAT_T value */ +} VENC_DRV_VIDEO_FORMAT_T; + + +/** + * @par Enumeration + * VENC_DRV_FRAME_RATE_T + * @par Description + * This is the item used for encode frame rate + */ +typedef enum __VENC_DRV_FRAME_RATE_T { + VENC_DRV_FRAME_RATE_NONE = 0, /* /< Default value (not used) */ + VENC_DRV_FRAME_RATE_7_5 = 75, /* /< 7.5 */ + VENC_DRV_FRAME_RATE_10 = 10, /* /< 10 */ + VENC_DRV_FRAME_RATE_15 = 15, /* /< 15 */ + VENC_DRV_FRAME_RATE_20 = 20, /* /< 20 */ + VENC_DRV_FRAME_RATE_24 = 24, /* /< 24 */ + VENC_DRV_FRAME_RATE_25 = 25, /* /< 25 */ + VENC_DRV_FRAME_RATE_29_97 = 2997, /* /< 29.97 */ + VENC_DRV_FRAME_RATE_30 = 30, /* /< 30 */ + VENC_DRV_FRAME_RATE_60 = 60, /* /< 60 */ + VENC_DRV_FRAME_RATE_120 = 120, /* /< 120 */ + VENC_DRV_FRAME_RATE_180 = 180, /* /< 180 */ + VENC_DRV_FRAME_RATE_240 = 240, /* /< 240 */ + VENC_DRV_FRAME_RATE_480 = 480, /* /< 480 */ + VENC_DRV_FRAME_RATE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_FRAME_RATE_T value */ +} VENC_DRV_FRAME_RATE_T; + + +/** + * @par Enumeration + * VENC_DRV_START_OPT_T + * @par Description + * This is the item used for encode frame type + */ +typedef enum __VENC_DRV_START_OPT_T { + VENC_DRV_START_OPT_NONE, /* /< Default value (not used) */ + VENC_DRV_START_OPT_ENCODE_SEQUENCE_HEADER, /* /< Encode a Sequence header */ + VENC_DRV_START_OPT_ENCODE_SEQUENCE_HEADER_H264_SPS, /* /< Encode a Sequence header H264 SPS */ + VENC_DRV_START_OPT_ENCODE_SEQUENCE_HEADER_H264_PPS, /* /< Encode a Sequence header H264 PPS */ + VENC_DRV_START_OPT_ENCODE_FRAME, /* /< Encode a frame */ + VENC_DRV_START_OPT_ENCODE_KEY_FRAME, /* /< Encode a key frame */ + VENC_DRV_START_OPT_ENCODE_FINAL, /* /< Final encode (Only use to encode final frame) */ + VENC_DRV_START_OPT_ENCODE_DUMMY_NAL, /* /< Encode a dummy NAL for WFD */ + VENC_DRV_START_OPT_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_START_OPT_T value */ +} VENC_DRV_START_OPT_T; + + +/** + * @par Enumeration + * VENC_DRV_MESSAGE_T + * @par Description + * This is the item used for encode frame status + */ +typedef enum __VENC_DRV_MESSAGE_T { + VENC_DRV_MESSAGE_NONE, /* /< Default value (not used) */ + VENC_DRV_MESSAGE_OK, /* /< Encode ok */ + VENC_DRV_MESSAGE_ERR, /* /< Encode error */ + VENC_DRV_MESSAGE_TIMEOUT, /* /< Encode timeout */ + VENC_DRV_MESSAGE_PARTIAL, /* /< Encode partial frame (ok means EOF) */ + VENC_DRV_MESSAGE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_MESSAGE_T value */ +} VENC_DRV_MESSAGE_T; + + +/** + * @par Enumeration + * VENC_DRV_H264_VIDEO_PROFILE_T + * @par Description + * This is the item used for h.264 encoder profile capability + */ +typedef enum __VENC_DRV_H264_VIDEO_PROFILE_T { + VENC_DRV_H264_VIDEO_PROFILE_UNKNOWN = 0, /* /< Default value (not used) */ + VENC_DRV_H264_VIDEO_PROFILE_BASELINE = (1 << 0), /* /< Baseline */ + VENC_DRV_H264_VIDEO_PROFILE_CONSTRAINED_BASELINE = (1 << 1), /* /< Constrained Baseline */ + VENC_DRV_H264_VIDEO_PROFILE_MAIN = (1 << 2), /* /< Main */ + VENC_DRV_H264_VIDEO_PROFILE_EXTENDED = (1 << 3), /* /< Extended */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH = (1 << 4), /* /< High */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH_10 = (1 << 5), /* /< High 10 */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH422 = (1 << 6), /* /< High 422 */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH444 = (1 << 7), /* /< High 444 */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH_10_INTRA = (1 << 8), /* /< High 10 Intra (Amendment 2) */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH422_INTRA = (1 << 9), /* /< High 422 Intra (Amendment 2) */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH444_INTRA = (1 << 10), /* /< High 444 Intra (Amendment 2) */ + VENC_DRV_H264_VIDEO_PROFILE_CAVLC444_INTRA = (1 << 11), /* /< CAVLC 444 Intra (Amendment 2) */ + VENC_DRV_H264_VIDEO_PROFILE_HIGH444_PREDICTIVE = (1 << 12), /* /< High 444 Predictive (Amendment 2) */ + VENC_DRV_H264_VIDEO_PROFILE_SCALABLE_BASELINE = (1 << 13), /* /< Scalable Baseline (Amendment 3) */ + VENC_DRV_H264_VIDEO_PROFILE_SCALABLE_HIGH = (1 << 14), /* /< Scalable High (Amendment 3) */ + VENC_DRV_H264_VIDEO_PROFILE_SCALABLE_HIGH_INTRA = (1 << 15), /* /< Scalable High Intra (Amendment 3) */ + VENC_DRV_H264_VIDEO_PROFILE_MULTIVIEW_HIGH = (1 << 16), /* /< Multiview High (Corrigendum 1 (2009)) */ + VENC_DRV_H264_VIDEO_PROFILE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_H264_VIDEO_PROFILE_T value */ +} VENC_DRV_H264_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_HEVC_VIDEO_PROFILE_T + * @par Description + * This is the item used for hevc encoder profile capability + */ +typedef enum __VENC_DRV_HEVC_VIDEO_PROFILE_T { + VENC_DRV_HEVC_VIDEO_PROFILE_UNKNOWN = 0, /* /< Default value (not used) */ + VENC_DRV_HEVC_VIDEO_PROFILE_BASELINE = (1 << 0), /* /< Baseline */ + VENC_DRV_HEVC_VIDEO_PROFILE_CONSTRAINED_BASELINE = (1 << 1), /* /< Constrained Baseline */ + VENC_DRV_HEVC_VIDEO_PROFILE_MAIN = (1 << 2), /* /< Main */ + VENC_DRV_HEVC_VIDEO_PROFILE_EXTENDED = (1 << 3), /* /< Extended */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH = (1 << 4), /* /< High */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH_10 = (1 << 5), /* /< High 10 */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH422 = (1 << 6), /* /< High 422 */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH444 = (1 << 7), /* /< High 444 */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH_10_INTRA = (1 << 8), /* /< High 10 Intra (Amendment 2) */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH422_INTRA = (1 << 9), /* /< High 422 Intra (Amendment 2) */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH444_INTRA = (1 << 10), /* /< High 444 Intra (Amendment 2) */ + VENC_DRV_HEVC_VIDEO_PROFILE_CAVLC444_INTRA = (1 << 11), /* /< CAVLC 444 Intra (Amendment 2) */ + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH444_PREDICTIVE = (1 << 12), /* /< High 444 Predictive (Amendment 2) */ + VENC_DRV_HEVC_VIDEO_PROFILE_SCALABLE_BASELINE = (1 << 13), /* /< Scalable Baseline (Amendment 3) */ + VENC_DRV_HEVC_VIDEO_PROFILE_SCALABLE_HIGH = (1 << 14), /* /< Scalable High (Amendment 3) */ + VENC_DRV_HEVC_VIDEO_PROFILE_SCALABLE_HIGH_INTRA = (1 << 15), /* /< Scalable High Intra (Amendment 3) */ + VENC_DRV_HEVC_VIDEO_PROFILE_MULTIVIEW_HIGH = (1 << 16), /* /< Multiview High (Corrigendum 1 (2009)) */ + VENC_DRV_HEVC_VIDEO_PROFILE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_HEVC_VIDEO_PROFILE_T value */ +} VENC_DRV_HEVC_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_MPEG_VIDEO_PROFILE_T + * @par Description + * This is the item used for h.263, mpeg2, mpeg4 encoder profile capability + */ +typedef enum __VENC_DRV_MPEG_VIDEO_PROFILE_T { + VENC_DRV_MPEG_VIDEO_PROFILE_UNKNOWN = 0, /* /< Default value (not used) */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_0 = (1 << 0), /* /< H.263 0 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_1 = (1 << 1), /* /< H.263 1 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_2 = (1 << 2), /* /< H.263 2 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_3 = (1 << 3), /* /< H.263 3 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_4 = (1 << 4), /* /< H.263 4 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_5 = (1 << 5), /* /< H.263 5 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_6 = (1 << 6), /* /< H.263 6 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_7 = (1 << 7), /* /< H.263 7 */ + VENC_DRV_MPEG_VIDEO_PROFILE_H263_8 = (1 << 8), /* /< H.263 8 */ + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SIMPLE = (1 << 9), /* /< MPEG2 Simple */ + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_MAIN = (1 << 10), /* /< MPEG2 Main */ + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SNR = (1 << 11), /* /< MPEG2 SNR */ + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SPATIAL = (1 << 12), /* /< MPEG2 Spatial */ + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_HIGH = (1 << 13), /* /< MPEG2 High */ + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG4_SIMPLE = (1 << 14), /* /< MPEG4 Simple */ + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE = (1 << 15), /* /< MPEG4 Advanced Simple */ + VENC_DRV_MPEG_VIDEO_PROFILE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_MPEG_VIDEO_PROFILE_T value */ +} VENC_DRV_MPEG_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_MS_VIDEO_PROFILE_T + * @par Description + * This is the item used for MS encoder profile capability + */ +typedef enum __VENC_DRV_MS_VIDEO_PROFILE_T { + VENC_DRV_MS_VIDEO_PROFILE_UNKNOWN = 0, /* /< Default value (not used) */ + VENC_DRV_MS_VIDEO_PROFILE_VC1_SIMPLE = (1 << 0), /* /< VC1 Simple */ + VENC_DRV_MS_VIDEO_PROFILE_VC1_MAIN = (1 << 1), /* /< VC1 Main */ + VENC_DRV_MS_VIDEO_PROFILE_VC1_ADVANCED = (1 << 2), /* /< VC1 Advanced */ + VENC_DRV_MS_VIDEO_PROFILE_WMV9_SIMPLE = (1 << 3), /* /< WMV9 Simple */ + VENC_DRV_MS_VIDEO_PROFILE_WMV9_MAIN = (1 << 4), /* /< WMV9 Main */ + VENC_DRV_MS_VIDEO_PROFILE_WMV9_COMPLEX = (1 << 5), /* /< WMV9 Complex */ + VENC_DRV_MS_VIDEO_PROFILE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_MS_VIDEO_PROFILE_T value */ +} VENC_DRV_MS_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_VIDEO_LEVEL_T + * @par Description + * This is the item used for encoder level capability + */ +typedef enum __VENC_DRV_VIDEO_LEVEL_T { + VENC_DRV_VIDEO_LEVEL_UNKNOWN = 0, /* /< Default value (not used) */ + VENC_DRV_VIDEO_LEVEL_0, /* /< VC1 */ + VENC_DRV_VIDEO_LEVEL_1, /* /< H264, HEVC, VC1, MPEG4 */ + VENC_DRV_VIDEO_LEVEL_1b, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_1_1, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_1_2, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_1_3, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_2, /* /< H264, HEVC, VC1, MPEG4 */ + VENC_DRV_VIDEO_LEVEL_2_1, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_2_2, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_3, /* /< H264, HEVC, VC1, MPEG4 */ + VENC_DRV_VIDEO_LEVEL_3_1, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_3_2, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_4, /* /< H264, HEVC, VC1 */ + VENC_DRV_VIDEO_LEVEL_4_1, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_4_2, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_5, /* /< H264, HEVC, HEVC */ + VENC_DRV_VIDEO_LEVEL_5_1, /* /< H264, HEVC */ + VENC_DRV_VIDEO_LEVEL_LOW, /* /< VC1, MPEG2 */ + VENC_DRV_VIDEO_LEVEL_MEDIUM, /* /< VC1, MPEG2 */ + VENC_DRV_VIDEO_LEVEL_HIGH1440, /* /< MPEG2 */ + VENC_DRV_VIDEO_LEVEL_HIGH, /* /< VC1, MPEG2 */ + VENC_DRV_VIDEO_LEVEL_6, /* /< H263 */ + VENC_DRV_VIDEO_LEVEL_7, /* /< H263 */ + VENC_DRV_VIDEO_LEVEL_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_VIDEO_LEVEL_T value */ +} VENC_DRV_VIDEO_LEVEL_T; + + +/** + * @par Enumeration + * VENC_DRV_RESOLUTION_T + * @par Description + * This is the item used for encoder resolution capability + */ +typedef enum __VENC_DRV_RESOLUTION_T { + VENC_DRV_RESOLUTION_UNKNOWN = 0, /* /< Default value (not used) */ + VENC_DRV_RESOLUTION_SUPPORT_QCIF, /* /< CIF */ + VENC_DRV_RESOLUTION_SUPPORT_QVGA, /* /< QVGA */ + VENC_DRV_RESOLUTION_SUPPORT_CIF, /* /< QCIF */ + VENC_DRV_RESOLUTION_SUPPORT_HVGA, /* /< HVGA: 480x320 */ + VENC_DRV_RESOLUTION_SUPPORT_VGA, /* /< VGA: 640x480 */ + VENC_DRV_RESOLUTION_SUPPORT_480I, /* /< 480I */ + VENC_DRV_RESOLUTION_SUPPORT_480P, /* /< 480P */ + VENC_DRV_RESOLUTION_SUPPORT_576I, /* /< 576I */ + VENC_DRV_RESOLUTION_SUPPORT_576P, /* /< 480P */ + VENC_DRV_RESOLUTION_SUPPORT_FWVGA, /* /< FWVGA: 864x480 */ + VENC_DRV_RESOLUTION_SUPPORT_720I, /* /< 720I */ + VENC_DRV_RESOLUTION_SUPPORT_720P, /* /< 720P */ + VENC_DRV_RESOLUTION_SUPPORT_1080I, /* /< 1080I */ + VENC_DRV_RESOLUTION_SUPPORT_1080P, /* /< 1080P */ + VENC_DRV_RESOLUTION_SUPPORT_2160P, /* /< 2160P */ + VENC_DRV_RESOLUTION_SUPPORT_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_RESOLUTION_T value */ +} VENC_DRV_RESOLUTION_T; + + +/** + * @par Enumeration + * VENC_DRV_SET_TYPE_T + * @par Description + * This is the input parameter for eVEncDrvSetParam() + */ +typedef enum __VENC_DRV_SET_TYPE_T { + VENC_DRV_SET_TYPE_UNKONW = 0, /* /< Default value (not used) */ + VENC_DRV_SET_TYPE_RST, /* /< Set reset */ + VENC_DRV_SET_TYPE_CB, /* /< Set callback function */ + VENC_DRV_SET_TYPE_PARAM_RC, /* /< Set rate control parameter */ + VENC_DRV_SET_TYPE_PARAM_ME, /* /< Set motion estimation parameter */ + VENC_DRV_SET_TYPE_PARAM_EIS, /* /< Set EIS parameter */ + VENC_DRV_SET_TYPE_PARAM_ENC, /* /< Set encoder parameters such as I-frame period, etc. */ + VENC_DRV_SET_TYPE_STATISTIC_ON, /* /< Enable statistic function */ + VENC_DRV_SET_TYPE_STATISTIC_OFF, /* /< Disable statistic function */ + VENC_DRV_SET_TYPE_SET_OMX_TIDS, /* /< Set OMX thread IDs */ + VENC_DRV_SET_TYPE_MPEG4_SHORT, /* /< Set MPEG4 short header mode */ + VENC_DRV_SET_TYPE_FORCE_INTRA_ON, /* /< Set Force Intra Frame on */ + VENC_DRV_SET_TYPE_FORCE_INTRA_OFF, /* /< Set Force Intra Frame off */ + VENC_DRV_SET_TYPE_TIME_LAPSE, /* /< Set time lapse */ + VENC_DRV_SET_TYPE_ALLOC_WORK_BUF, /* /< Set to alloc working buffer */ + VENC_DRV_SET_TYPE_DUMP_WORK_BUF, /* /< Set to dump working buffer */ + VENC_DRV_SET_TYPE_FREE_WORK_BUF, /* /< Set to free working buffer */ + VENC_DRV_SET_TYPE_ADJUST_BITRATE, /* /< Set to adjust bitrate */ + VENC_DRV_SET_TYPE_I_FRAME_INTERVAL, /* /< Set I Frame interval */ + VENC_DRV_SET_TYPE_WFD_MODE, /* /< Set Wifi-Display Mode */ + VENC_DRV_SET_TYPE_RECORD_SIZE, /* /< Ser record size */ + VENC_DRV_SET_TYPE_USE_MCI_BUF, /* /< Set to use MCI buffer */ + VENC_DRV_SET_TYPE_ADJUST_FRAMERATE, /* /< Set frame rate */ + VENC_DRV_SET_TYPE_INIT_QP, /* /< Set init QP */ + VENC_DRV_SET_TYPE_SKIP_FRAME, /* /< Set skip one frame */ + VENC_DRV_SET_TYPE_SCENARIO, /* /< Set VENC Scenario */ + VENC_DRV_SET_TYPE_PREPEND_HEADER, /* /< Set prepend SPS/PPS before IDR */ + VENC_DRV_SET_TYPE_SLOW_MOTION_ENCODE, /* /< Set to Slow Motion Video Recording for header or frame */ + VENC_DRV_SET_TYPE_SLOW_MOTION_POST_PROC, /* /< Set to Slow Motion Video Recording for encoded bs with post processing */ + VENC_DRV_SET_TYPE_SLOW_MOTION_LOCK_HW, /* /< Set to Slow Motion Video Recording for Lock HW */ + VENC_DRV_SET_TYPE_SLOW_MOTION_UNLOCK_HW, /* /< Set to Slow Motion Video Recording for UnLock HW */ + VENC_DRV_SET_TYPE_NONREFP, /* /< Set Enable/Disable Non reference P frame */ + VENC_DRV_SET_TYPE_CONFIG_QP, /* /< Set init QP */ + VENC_DRV_SET_TYPE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_SET_TYPE_T value */ +} VENC_DRV_SET_TYPE_T; + + +/** + * @par Enumeration + * VENC_DRV_GET_TYPE_T + * @par Description + * This is the input parameter for eVEncDrvGetParam() + */ +typedef enum __VENC_DRV_GET_TYPE_T { + VENC_DRV_GET_TYPE_UNKONW = 0, /* /< Default value (not used) */ + VENC_DRV_GET_TYPE_PARAM_RC, /* /< Get rate control parameter */ + VENC_DRV_GET_TYPE_PARAM_ME, /* /< Get motion estimation parameter */ + VENC_DRV_GET_TYPE_PARAM_EIS, /* /< Get EIS parameter */ + VENC_DRV_GET_TYPE_PARAM_ENC, /* /< Get encoder parameters such as I-frame period, etc. */ + VENC_DRV_GET_TYPE_STATISTIC, /* /< Get statistic. */ + VENC_DRV_GET_TYPE_GET_CPU_LOADING_INFO, /* /< query the cpu loading info from kernel driver */ + VENC_DRV_GET_TYPE_GET_YUV_FORMAT, /* /< Get YUV format */ + VENC_DRV_GET_TYPE_GET_CODEC_TIDS, + /* for DirectLink Meta Mode + */ + VENC_DRV_GET_TYPE_ALLOC_META_HANDLE_LIST, /* /< Alloc a handle to store meta handle list */ + VENC_DRV_GET_TYPE_GET_BUF_INFO_FROM_META_HANDLE, /* /< Get buffer virtual address from meta buffer handle */ + VENC_DRV_GET_TYPE_FREE_META_HANDLE_LIST, /* /< free a handle allocated from VENC_DRV_GET_TYPE_ALLOC_META_HANDLE_LIST */ + /* for DirectLink Meta Mode - */ + VENC_DRV_GET_TYPE_MAX = 0xFFFFFFFF /* /< Max VENC_DRV_GET_TYPE_MAX value */ +} VENC_DRV_GET_TYPE_T; + + +/** + * @par Enumeration + * VENC_DRV_MRESULT_T + * @par Description + * This is the return value for eVEncDrvXXX() + */ +typedef enum __VENC_DRV_MRESULT_T { + VENC_DRV_MRESULT_OK = 0, /* /< Return Success */ + VENC_DRV_MRESULT_FAIL, /* /< Return Fail */ + VENC_DRV_MRESULT_MAX = 0x0FFFFFFF /* /< Max VENC_DRV_MRESULT_T value */ +} VENC_DRV_MRESULT_T; + + +/** + * @par Enumeration + * VENC_DRV_SCENARIO_T + * @par Description + * This is the scenario for VENC scenario + */ +typedef enum __VENC_DRV_SCENARIO_T { + VENC_DRV_SCENARIO_CAMERA_REC = 1, /* /< Camera recording */ + VENC_DRV_SCENARIO_LIVEPHOTO_CAPTURE = (1 << 1), /* /< LivePhoto recording */ + VENC_DRV_SCENARIO_LIVEPHOTO_EFFECT = (1 << 2), /* /< LivePhoto effect transcoding */ + VENC_DRV_SCENARIO_CAMERA_REC_SLOW_MOTION = (1 << 3), /* /< Camera recording with slow motion */ + VENC_DRV_SCENARIO_SCREEN_REC = (1 << 4), /* /< Screen recording */ +} VENC_DRV_SCENARIO_T; + + +/** + * @par Structure + * VENC_DRV_QUERY_VIDEO_FORMAT_T + * @par Description + * This is a input parameter for eVEncDrvQueryCapability() + */ +typedef struct __VENC_DRV_QUERY_VIDEO_FORMAT_T { + VENC_DRV_VIDEO_FORMAT_T eVideoFormat; /* /< [OUT] video format capability */ + VAL_UINT32_T u4Profile; /* /< [OUT] video profile capability (VENC_DRV_H264_VIDEO_PROFILE_T, VENC_DRV_MPEG_VIDEO_PROFILE_T, VENC_DRV_MS_VIDEO_PROFILE_T) */ + VENC_DRV_VIDEO_LEVEL_T eLevel; /* /< [OUT] video level capability */ + VENC_DRV_RESOLUTION_T eResolution; /* /< [OUT] video resolution capability */ + VAL_UINT32_T u4Width; /* /< [OUT] video width capability */ + VAL_UINT32_T u4Height; /* /< [OUT] video height capability */ + VAL_UINT32_T u4Bitrate; /* /< [OUT] video bitrate capability */ + VAL_UINT32_T u4FrameRate; /* /< [OUT] video FrameRate capability, 15, 30,... */ +} VENC_DRV_QUERY_VIDEO_FORMAT_T; + +/** + * @par Structure + * P_VENC_DRV_QUERY_VIDEO_FORMAT_T + * @par Description + * This is the pointer of VENC_DRV_QUERY_VIDEO_FORMAT_T + */ +typedef VENC_DRV_QUERY_VIDEO_FORMAT_T * P_VENC_DRV_QUERY_VIDEO_FORMAT_T; + + +/** + * @par Structure + * VENC_DRV_QUERY_INPUT_BUF_LIMIT + * @par Description + * This is a input parameter for eVEncDrvQueryCapability() + */ +typedef struct __VENC_DRV_QUERY_INPUT_BUF_LIMIT { + VENC_DRV_VIDEO_FORMAT_T eVideoFormat; /* /< [IN] video format */ + VAL_UINT32_T u4Width; /* /< [IN] video width */ + VAL_UINT32_T u4Height; /* /< [IN] video height */ + VAL_UINT32_T u4Stride; /* /< [OUT] video stride */ + VAL_UINT32_T u4SliceHeight; /* /< [OUT] video sliceheight */ + VENC_DRV_SCENARIO_T eScenario; /* /< [IN] venc scenario */ +} VENC_DRV_QUERY_INPUT_BUF_LIMIT; + + +/** + * @par Structure + * VENC_DRV_PARAM_ENC_T + * @par Description + * This is the encoder settings and used as input or output parameter for eVEncDrvSetParam() or eVEncDrvGetParam() + */ +typedef struct __VENC_DRV_PARAM_ENC_T { /*union extend 64bits for TEE*/ + VENC_DRV_YUV_FORMAT_T eVEncFormat; /* /< [IN/OUT] YUV format */ + VAL_UINT32_T u4Profile; /* /< [IN/OUT] Profile */ + VAL_UINT32_T u4Level; /* /< [IN/OUT] Level */ + VAL_UINT32_T u4Width; /* /< [IN/OUT] Image Width */ + VAL_UINT32_T u4Height; /* /< [IN/OUT] Image Height */ + VAL_UINT32_T u4BufWidth; /* /< [IN/OUT] Buffer Width */ + VAL_UINT32_T u4BufHeight; /* /< [IN/OUT] Buffer Heigh */ + VAL_UINT32_T u4NumPFrm; /* /< [IN/OUT] The number of P frame between two I frame. */ + VAL_UINT32_T u4NumBFrm; /* /< [IN/OUT] The number of B frame between two reference frame. */ + VENC_DRV_FRAME_RATE_T eFrameRate; /* /< [IN/OUT] Frame rate */ + VAL_BOOL_T fgInterlace; /* /< [IN/OUT] Interlace coding. */ + union { + VAL_VOID_T *pvExtraEnc; + VAL_UINT64_T pvExtraEnc_ext64; + }; + VAL_MEMORY_T rExtraEncMem; /* /< [IN/OUT] Extra Encoder Memory Info */ + VAL_BOOL_T fgUseMCI; /* /< [IN/OUT] Use MCI */ + VAL_BOOL_T fgMultiSlice; /* /< [IN/OUT] Is multi-slice bitstream ? */ + VAL_BOOL_T fgMBAFF; +} VENC_DRV_PARAM_ENC_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_ENC_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_ENC_T + */ +typedef VENC_DRV_PARAM_ENC_T * P_VENC_DRV_PARAM_ENC_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_ENC_EXTRA_T + * @par Description + * This is the encoder settings and used as input or output parameter for eVEncDrvSetParam() or eVEncDrvGetParam() + */ +typedef struct __VENC_DRV_PARAM_ENC_EXTRA_T { + VAL_UINT32_T u4IntraFrameRate; /* /< [IN/OUT] Intra frame rate */ + VAL_UINT32_T u4BitRate; /* /< [IN/OUT] BitRate kbps */ + VAL_UINT32_T u4FrameRateQ16; /* /< [IN/OUT] Frame rate in Q16 format */ + VAL_UINT32_T u4UseMBAFF; /* /< [IN/OUT] Use MBAFF */ +} VENC_DRV_PARAM_ENC_EXTRA_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_ENC_EXTRA_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_ENC_EXTRA_T + */ +typedef VENC_DRV_PARAM_ENC_EXTRA_T * pVENC_DRV_PARAM_ENC_EXTRA_T; + + +#define VENC_DRV_VDO_PROP_LIST_MAX (64) + +/** + * @par Structure + * VENC_DRV_VIDEO_PROPERTY_T + * @par Description + * This is used to get the "target bitrate" according to "resolution and frame rate" + */ +typedef struct __VENC_DRV_VIDEO_PROPERTY_T { + VENC_DRV_VIDEO_FORMAT_T eVideoFormat; + VAL_UINT32_T u4Width; + VAL_UINT32_T u4Height; + VAL_UINT32_T u4FrameRate; + VAL_UINT32_T u4BitRate; /* used for query table */ + VAL_BOOL_T fgPropIsValid; +} VENC_DRV_VIDEO_PROPERTY_T; + +/** + * @par Structure + * P_VENC_DRV_VIDEO_PROPERTY_T + * @par Description + * This is the pointer of VENC_DRV_VIDEO_PROPERTY_T + */ +typedef VENC_DRV_VIDEO_PROPERTY_T * P_VENC_DRV_VIDEO_PROPERTY_T; + + +/** + * @par Structure + * VENC_DRV_TIMESTAMP_T + * @par Description + * This is timestamp information and used as items for VENC_DRV_PARAM_FRM_BUF_T and VENC_DRV_PARAM_BS_BUF_T + */ +typedef struct __VENC_DRV_TIMESTAMP_T { + VAL_UINT32_T u4TimeStamp[2]; /* /< [IN] Timestamp information */ +} VENC_DRV_TIMESTAMP_T; + +/** + * @par Structure + * P_VENC_DRV_TIMESTAMP_T + * @par Description + * This is the pointer of VENC_DRV_TIMESTAMP_T + */ +typedef VENC_DRV_TIMESTAMP_T * P_VENC_DRV_TIMESTAMP_T; + + +/** + * @par Structure + * VENC_DRV_EIS_INPUT_T + * @par Description + * This is EIS information and used as items for VENC_DRV_PARAM_FRM_BUF_T + */ +typedef struct __VENC_DRV_EIS_INPUT_T { + VAL_UINT32_T u4X; /* /< [IN] Start coordination X */ + VAL_UINT32_T u4Y; /* /< [IN] Start coordination Y */ +} VENC_DRV_EIS_INPUT_T; + +/** + * @par Structure + * P_VENC_DRV_EIS_INPUT_T + * @par Description + * This is the pointer of VENC_DRV_EIS_INPUT_T + */ +typedef VENC_DRV_EIS_INPUT_T * P_VENC_DRV_EIS_INPUT_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_FRM_BUF_T + * @par Description + * This is frame buffer information and used as input parameter for eVEncDrvEncode() + */ +typedef struct __VENC_DRV_PARAM_FRM_BUF_T { + VAL_MEM_ADDR_T rFrmBufAddr; /* /< [IN] Frame buffer address */ + VAL_MEM_ADDR_T rCoarseAddr; /* /< [IN] Coarse address */ + VENC_DRV_TIMESTAMP_T rTimeStamp; /* /< [IN] Timestamp information */ + VENC_DRV_EIS_INPUT_T rEISInput; /* /< [IN] EIS information */ + VAL_UINT32_T rSecMemHandle; /* /< [IN/OUT] security memory handle for SVP */ +} VENC_DRV_PARAM_FRM_BUF_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_FRM_BUF_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_FRM_BUF_T + */ +typedef VENC_DRV_PARAM_FRM_BUF_T * P_VENC_DRV_PARAM_FRM_BUF_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_BS_BUF_T + * @par Description + * This is bitstream buffer information and used as input parameter for\n + * eVEncDrvEncode()\n + */ +typedef struct __VENC_DRV_PARAM_BS_BUF_T {/*union extend 64bits for TEE */ + VAL_MEM_ADDR_T rBSAddr; /* /< [IN] Bitstream buffer address */ + union { + VAL_ULONG_T u4BSStartVA; /* /< [IN] Bitstream fill start address */ + VAL_UINT64_T u4BSStartVA_ext64; + }; + union { + VAL_ULONG_T u4BSSize; /* /< [IN] Bitstream size (filled bitstream in bytes) */ + VAL_UINT64_T u4BSSize_ext64; + }; + VENC_DRV_TIMESTAMP_T rTimeStamp; /* /< [IN] Time stamp information */ + VAL_UINT32_T rSecMemHandle; /* /< [IN/OUT] security memory handle for SVP */ +} VENC_DRV_PARAM_BS_BUF_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_BS_BUF_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_BS_BUF_T + */ +typedef VENC_DRV_PARAM_BS_BUF_T * P_VENC_DRV_PARAM_BS_BUF_T; + + +/** + * @par Structure + * VENC_DRV_DONE_RESULT_T + * @par Description + * This is callback and return information and used as output parameter for eVEncDrvEncode() + */ +typedef struct __VENC_DRV_DONE_RESULT_T { /*union extend 64bits for TEE */ + VENC_DRV_MESSAGE_T eMessage; /* /< [OUT] Message, such as success or error code */ + union { + P_VENC_DRV_PARAM_BS_BUF_T prBSBuf; /* /< [OUT] Bitstream information */ + VAL_UINT64_T prBSBuf_ext64; + }; + union { + P_VENC_DRV_PARAM_FRM_BUF_T prFrmBuf; /* /< [OUT] Input frame buffer information. if address is null, don't use this buffer, else reuse */ + VAL_UINT64_T prFrmBuf_ext64; + }; + VAL_BOOL_T fgIsKeyFrm; /* /< [OUT] output is key frame or not */ + VAL_UINT32_T u4HWEncodeTime; /* /< [OUT] HW encode Time */ +} VENC_DRV_DONE_RESULT_T; + +/** + * @par Structure + * P_VENC_DRV_DONE_RESULT_T + * @par Description + * This is the pointer of VENC_DRV_DONE_RESULT_T + */ +typedef VENC_DRV_DONE_RESULT_T * P_VENC_DRV_DONE_RESULT_T; + + +/** + * @par Structure + * VENC_DRV_PROPERTY_T + * @par Description + * This is property information and used as output parameter for eVEncDrvQueryCapability() + */ +typedef struct __VENC_DRV_PROPERTY_T { + VAL_UINT32_T u4BufAlign; /* /< [OUT] Buffer alignment requirement */ + VAL_UINT32_T u4BufUnitSize; /* /< [OUT] Buffer unit size is N bytes (e.g., 8, 16, or 64 bytes per unit.) */ + VAL_UINT32_T u4ExtraBufSize; /* /< [OUT] Extra buffer size in initial stage */ + VAL_BOOL_T fgOutputRingBuf; /* /< [OUT] Output is ring buffer */ + VAL_BOOL_T fgCoarseMESupport; /* /< [OUT] Support ME coarse search */ + VAL_BOOL_T fgEISSupport; /* /< [OUT] Support EIS */ +} VENC_DRV_PROPERTY_T; + +/** + * @par Structure + * P_VENC_DRV_PROPERTY_T + * @par Description + * This is the pointer of VENC_DRV_PROPERTY_T + */ +typedef VENC_DRV_PROPERTY_T * P_VENC_DRV_PROPERTY_T; + +/** + * @par Structure + * SEC_VENC_INIT_CONFIG + * @par Description + * This is the structure for initial Venc TLC + */ +typedef struct sec_venc_init_config { + int width; + int height; + void *pVencHandle; + uint32_t uVencHandleLen; + unsigned char *pRCCode; +} SEC_VENC_INIT_CONFIG; + +/** + * @par Structure + * SEC_VENC_INIT_CONFIG + * @par Description + * This is the structure for setting Venc TLC + */ +typedef struct sec_venc_enc_parameter { + uint32_t bitstreamSecHandle; + uint32_t uBitstreamBufSize; + uint32_t uBitstreamDataLen; + + uint32_t frameSecHandle; + uint32_t uFrameBufSize; + uint32_t uFrameDataLen; +} SEC_VENC_ENC_PARAM; + +/** + * @par Function + * eVEncDrvQueryCapability + * @par Description + * Query the driver capability + * @param + * a_eType [IN/OUT] The VENC_DRV_QUERY_TYPE_T structure + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvQueryCapability( + VENC_DRV_QUERY_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function + * eVEncDrvCreate + * @par Description + * Create the driver handle + * @param + * a_phHandle [OUT] The driver handle + * @param + * a_eVideoFormat [IN] The VENC_DRV_VIDEO_FORMAT_T structure + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvCreate(VAL_HANDLE_T *a_phHandle, VENC_DRV_VIDEO_FORMAT_T a_eVideoFormat + ); + + +/** + * @par Function + * eVEncDrvRelease + * @par Description + * Release the driver handle + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eVideoFormat [IN] The VENC_DRV_VIDEO_FORMAT_T structure + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvRelease( + VAL_HANDLE_T a_hHandle, + VENC_DRV_VIDEO_FORMAT_T a_eVideoFormat +); + + +/** + * @par Function + * eVEncDrvInit + * @par Description + * Init the driver setting, alloc working memory ... etc. + * @param + * a_hHandle [IN] The driver handle + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvInit( + VAL_HANDLE_T a_hHandle +); + +/** + * @par Function + * eVEncDrvDeInit + * @par Description + * DeInit the driver setting, free working memory ... etc. + * @param + * a_hHandle [IN] The driver handle + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvDeInit( + VAL_HANDLE_T a_hHandle +); + + +/** + * @par Function + * eVEncDrvSetParam + * @par Description + * Set parameter to driver + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eType [IN] The VENC_DRV_SET_TYPE_T structure + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvSetParam( + VAL_HANDLE_T a_hHandle, + VENC_DRV_SET_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function + * eVEncDrvGetParam + * @par Description + * Get parameter from driver + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eType [IN] The VENC_DRV_SET_TYPE_T structure + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvGetParam( + VAL_HANDLE_T a_hHandle, + VENC_DRV_GET_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function + * eVEncDrvEncode + * @par Description + * Encode frame + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eOpt [IN] The VENC_DRV_START_OPT_T structure + * @param + * a_prFrmBuf [IN] The input frame buffer with VENC_DRV_PARAM_FRM_BUF_T structure + * @param + * a_prBSBuf [IN] The input bitstream buffer with VENC_DRV_PARAM_BS_BUF_T structure + * @param + * a_prResult [OUT] The output result with VENC_DRV_DONE_RESULT_T structure + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvEncode(VAL_HANDLE_T a_hHandle, VENC_DRV_START_OPT_T a_eOpt, VENC_DRV_PARAM_FRM_BUF_T *a_prFrmBuf, VENC_DRV_PARAM_BS_BUF_T *a_prBSBuf, VENC_DRV_DONE_RESULT_T *a_prResult); + + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _VENC_DRV_IF_PUBLIC_H_ */ diff --git a/kernel-headers/video_custom_sp.h b/kernel-headers/video_custom_sp.h new file mode 100644 index 0000000..933267f --- /dev/null +++ b/kernel-headers/video_custom_sp.h @@ -0,0 +1,121 @@ +#ifndef VIDEO_CUSTOM_SP_H +#define VIDEO_CUSTOM_SP_H + +/* #include "video_codec_if_sp.h" */ +#include "vcodec_if_v2.h" + +#define ASSERT(expr) \ + do { \ + if (!(expr)) \ + AssertionFailed(__func__, __FILE__, __LINE__); \ + } while (0) /* /< ASSERT definition */ + +/****************************************************************************** + * + * + * decode + * + * +******************************************************************************/ + + +/** + * @par Enumeration + * VIDEO_DECODER_T + * @par Description + * This is the item for video decoder format + */ +typedef enum _VIDEO_DECODER_T { + CODEC_DEC_NONE = 0, /* /< NONE */ + CODEC_DEC_H263 = (0x1 << 0), /* /< H263 */ + CODEC_DEC_MPEG4 = (0x1 << 1), /* /< MPEG4 */ + CODEC_DEC_H264 = (0x1 << 2), /* /< H264 */ + CODEC_DEC_RV = (0x1 << 3), /* /< RV */ + CODEC_DEC_VC1 = (0x1 << 4), /* /< VC1 */ + CODEC_DEC_VP8 = (0x1 << 5), /* /< VP8 */ + CODEC_DEC_VP9 = (0x1 << 6), /* /< VP9 */ + CODEC_DEC_HEVC = (0x1 << 7), /* /< HEVC */ + CODEC_DEC_MPEG2 = (0x1 << 8), /* /< MPEG2 */ + CODEC_DEC_MAX = (0x1 << 9) /* /< MAX */ +} VIDEO_DECODER_T; + +#if 1 /* defined(MT6572) //VCODEC_MULTI_THREAD */ + + +/** + * @par Function + * GetDecoderAPI + * @par Description + * The function used to get decoder API for codec library + * @param + * eDecType [IN] decoder type + * @param + * hWrapper [IN] wrapper + * @param + * ppDrvModule [IN/OUT] driver module + * @param + * bUseMultiCoreCodec [IN] multi core codec flag + * @par Returns + * VIDEO_DEC_API_T, the decoder API + */ +VIDEO_DEC_API_T *GetDecoderAPI(VIDEO_DECODER_T eDecType, HANDLE hWrapper, void **ppDrvModule, unsigned int bUseMultiCoreCodec); +#else +VIDEO_DEC_API_T *GetDecoderAPI(VIDEO_DECODER_T, HANDLE); /* HANDLE : wrapper's handle */ +#endif +/* VCODEC_DEC_API_T *GetMPEG4DecoderAPI(void); */ +/* VCODEC_DEC_API_T *GetH264DecoderAPI(void); */ +/* VCODEC_DEC_API_T *GetRVDecoderAPI(void); */ +/* VCODEC_DEC_API_T *GetVP8DecoderAPI(void); */ +/* VCODEC_DEC_API_T *GetVC1DecoderAPI(void); */ + + +/****************************************************************************** +* +* +* encode +* +* +******************************************************************************/ + + +/** + * @par Enumeration + * VIDEO_ENCODER_T + * @par Description + * This is the item for video decoder format + */ +typedef enum _VIDEO_ENCODER_T { + CODEC_ENC_NONE = 0, /* /< NONE */ + CODEC_ENC_H263 = (0x1 << 0), /* /< H263 */ + CODEC_ENC_MPEG4 = (0x1 << 1), /* /< MPEG4 */ + CODEC_ENC_H264 = (0x1 << 2), /* /< H264 */ + CODEC_ENC_HEVC = (0x1 << 3), /* /< HEVC */ + CODEC_ENC_VP8 = (0x1 << 5), /* /< VP8 */ + CODEC_ENC_VP9 = (0x1 << 6), /* /< VP9 */ + CODEC_ENC_MAX = (0x1 << 7) /* /< MAX */ +} VIDEO_ENCODER_T; + + +/** + * @par Function + * GetEncoderAPI + * @par Description + * The function used to get encoder API for codec library + * @param + * eEncType [IN] encoder type + * @param + * hWrapper [IN] wrapper + * @param + * ppDrvModule [IN/OUT] driver module + * @param + * bUseMultiCoreCodec [IN] multi core codec flag + * @par Returns + * VIDEO_DEC_API_T, the encoder API + */ +VIDEO_ENC_API_T *GetEncoderAPI(VIDEO_ENCODER_T eEncType, HANDLE hWrapper, void **ppDrvModule, unsigned int bUseMultiCoreCodec); +/* VCODEC_ENC_API_T *GetMPEG4EncoderAPI(void); */ +/* VCODEC_ENC_API_T* GetH264EncoderAPI(void); */ +/* VIDEO_ENCODER_API_T *GetVP8EncoderAPI(void); */ + + +#endif /* VIDEO_CUSTOM_SP_H */ diff --git a/keyhandler/Android.mk b/keyhandler/Android.mk new file mode 100644 index 0000000..9a18426 --- /dev/null +++ b/keyhandler/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := com.cyanogenmod.keyhandler +LOCAL_SRC_FILES := $(call all-java-files-under,src) +LOCAL_MODULE_TAGS := optional +LOCAL_DEX_PREOPT := false + +LOCAL_STATIC_JAVA_LIBRARIES := org.cyanogenmod.platform.internal +include $(BUILD_JAVA_LIBRARY) + diff --git a/keyhandler/src/com/cyanogenmod/settings/device/KeyHandler.java b/keyhandler/src/com/cyanogenmod/settings/device/KeyHandler.java new file mode 100644 index 0000000..d4dcfe8 --- /dev/null +++ b/keyhandler/src/com/cyanogenmod/settings/device/KeyHandler.java @@ -0,0 +1,449 @@ +/* + * 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. + */ + +package com.cyanogenmod.settings.device; + +import android.app.ActivityManagerNative; +import android.app.KeyguardManager; +import android.content.ActivityNotFoundException; +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; +//import android.hardware.camera2.CameraManager; +//import android.hardware.camera2.CameraCharacteristics; +//import android.hardware.camera2.CameraAccessException; +import android.media.session.MediaSessionLegacyHelper; +import android.net.Uri; +import android.os.Handler; +import android.os.Message; +import android.os.PowerManager; +import android.os.PowerManager.WakeLock; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.os.SystemClock; +import android.os.UserHandle; +import android.os.Vibrator; +import android.provider.MediaStore; +import android.provider.Settings; +import android.provider.Settings.Global; +import android.util.Log; +import android.view.KeyEvent; +import android.view.WindowManagerGlobal; + +import cyanogenmod.providers.CMSettings; + +import com.android.internal.os.DeviceKeyHandler; +import com.android.internal.util.ArrayUtils; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import android.app.Instrumentation; +import android.content.SharedPreferences; +import android.content.ContextWrapper; + +public class KeyHandler implements DeviceKeyHandler { + + private static final String TAG = KeyHandler.class.getSimpleName(); + private static final int GESTURE_REQUEST = 1; + + private static final String MEIZU_GESTURE_DATA = + "/sys/devices/platform/mx-gs/gesture_data"; + + private static final String KEY_GESTURE_HAPTIC_FEEDBACK = + "touchscreen_gesture_haptic_feedback"; + + private static final String TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK = + "touchscreen_gesture_haptic_feedback"; + + private static final String ACTION_DISMISS_KEYGUARD = + "com.android.keyguard.action.DISMISS_KEYGUARD_SECURELY"; + + // M2Note gesture codes + public static final int DOUBLE_TAP = 0xA0; //160 + public static final int SWIPE_X_LEFT = 0xB0; //176 + public static final int SWIPE_X_RIGHT = 0xB1; + public static final int SWIPE_Y_UP = 0xB2; + public static final int SWIPE_Y_DOWN = 0xB3; + + public static final int UNICODE_E = 0xC0; // 192 + public static final int UNICODE_C = 0xC1; + public static final int UNICODE_W = 0xC2; + public static final int UNICODE_M = 0xC3; + public static final int UNICODE_O = 0xC4; + public static final int UNICODE_S = 0xC5; + public static final int UNICODE_V_UP = 0xC6; + public static final int UNICODE_V_DOWN = 0xC7; + public static final int UNICODE_V_L = 0xC8; + public static final int UNICODE_V_R = 0xC9; + public static final int UNICODE_Z = 0xCA; + + private static final int GESTURE_WAKELOCK_DURATION = 3000; + + private final Context mContext; + + private final PowerManager mPowerManager; + private KeyguardManager mKeyguardManager; + private EventHandler mEventHandler; + private SensorManager mSensorManager; + private PackageManager mPackageManager; + private Sensor mProximitySensor; + private Vibrator mVibrator; + //private CameraManager mCameraManager; + //private String mRearCameraId; + private WakeLock mProximityWakeLock; + private WakeLock mGestureWakeLock; + private int mProximityTimeOut; + private boolean mProximityWakeSupported; + private Instrumentation m_Instrumentation; + private Context cmaContext = null; + + private boolean isLastPressHomeButton = false; + //private boolean mTorchEnabled; + //private boolean mNotificationSliderVibrate; + + public KeyHandler(Context context) { + mContext = context; + mPackageManager = context.getPackageManager(); + mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + mEventHandler = new EventHandler(); + m_Instrumentation = new Instrumentation(); + mGestureWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, + "GestureWakeLock"); + + try { + cmaContext = mContext.createPackageContext("com.cyanogenmod.settings.device", Context.CONTEXT_RESTRICTED); + } catch (Exception e) { + e.printStackTrace(); + } + + final Resources resources = mContext.getResources(); + mProximityTimeOut = resources.getInteger( + org.cyanogenmod.platform.internal.R.integer.config_proximityCheckTimeout); + mProximityWakeSupported = resources.getBoolean( + org.cyanogenmod.platform.internal.R.bool.config_proximityCheckOnWake); + + if (mProximityWakeSupported) { + mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); + mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); + mProximityWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, + "ProximityWakeLock"); + } + + mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); + if (mVibrator == null || !mVibrator.hasVibrator()) { + mVibrator = null; + } + +// mCameraManager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE); +// mCameraManager.registerTorchCallback(new MyTorchCallback(), mEventHandler); +// } +// +// private class MyTorchCallback extends CameraManager.TorchCallback { +// @Override +// public void onTorchModeChanged(String cameraId, boolean enabled) { +// if (!cameraId.equals(mRearCameraId)) +// return; +// mTorchEnabled = enabled; +// } +// +// @Override +// public void onTorchModeUnavailable(String cameraId) { +// if (!cameraId.equals(mRearCameraId)) +// return; +// mTorchEnabled = false; +// } +// } +// +// private String getRearCameraId() { +// if (mRearCameraId == null) { +// try { +// for (final String cameraId : mCameraManager.getCameraIdList()) { +// CameraCharacteristics characteristics = +// mCameraManager.getCameraCharacteristics(cameraId); +// int cOrientation = characteristics.get(CameraCharacteristics.LENS_FACING); +// if (cOrientation == CameraCharacteristics.LENS_FACING_BACK) { +// mRearCameraId = cameraId; +// break; +// } +// } +// } catch (CameraAccessException e) { +// // Ignore +// } +// } +// return mRearCameraId; + } + + private void ensureKeyguardManager() { + if (mKeyguardManager == null) { + mKeyguardManager = + (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); + } + } + + private class EventHandler extends Handler { + @Override + public void handleMessage(Message msg) { + try { + boolean gestureHandled = true; + int gestureData = (int) msg.obj; + String prefValue = getCMAStringPref(String.valueOf(gestureData) + "_action"); + Log.i(TAG, "Handling gesture: " + gestureData + " with action: " + prefValue); + switch (prefValue) { + case "wakeUp": + mPowerManager.wakeUp(SystemClock.uptimeMillis()); + break; + case "unlock": + ensureKeyguardManager(); + mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION); + mContext.sendBroadcastAsUser(new Intent(ACTION_DISMISS_KEYGUARD), + UserHandle.CURRENT); + mPowerManager.wakeUp(SystemClock.uptimeMillis()); + break; + case "camera": + ensureKeyguardManager(); + final String action; + mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION); + if (mKeyguardManager.isKeyguardSecure() && mKeyguardManager.isKeyguardLocked()) { + action = MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE; + } else { + mContext.sendBroadcastAsUser(new Intent(ACTION_DISMISS_KEYGUARD), + UserHandle.CURRENT); + action = MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA; + } + mPowerManager.wakeUp(SystemClock.uptimeMillis()); + Intent intent = new Intent(action, null); + startActivitySafely(intent); + break; + case "play": + dispatchMediaKeyWithWakeLockToMediaSession(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE); + break; + case "flashlight": + //String rearCameraId = getRearCameraId(); + //if (rearCameraId != null) { + // mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION); + // try { + // mCameraManager.setTorchMode(rearCameraId, !mTorchEnabled); + // mTorchEnabled = !mTorchEnabled; + // } catch (CameraAccessException e) { + // // Ignore + // } + // //doHapticFeedback(); + //} + break; + case "prev": + dispatchMediaKeyWithWakeLockToMediaSession(KeyEvent.KEYCODE_MEDIA_PREVIOUS); + break; + case "next": + dispatchMediaKeyWithWakeLockToMediaSession(KeyEvent.KEYCODE_MEDIA_NEXT); + break; + case "doNotDisturb": + Global.putInt(mContext.getContentResolver(), Global.ZEN_MODE, + Global.ZEN_MODE_NO_INTERRUPTIONS); + break; + case "normal": + Global.putInt(mContext.getContentResolver(), Global.ZEN_MODE, + Global.ZEN_MODE_OFF); + break; + case "mute": + Global.putInt(mContext.getContentResolver(), Global.ZEN_MODE, + Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS); + break; + default: + if (prefValue.startsWith("launch$")) { + String packageName = prefValue.replace("launch$", ""); + ensureKeyguardManager(); + mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION); + if (!mKeyguardManager.isKeyguardSecure() && mKeyguardManager.isKeyguardLocked()) { + mContext.sendBroadcastAsUser(new Intent(ACTION_DISMISS_KEYGUARD), + UserHandle.CURRENT); + } + mPowerManager.wakeUp(SystemClock.uptimeMillis()); + Intent appIntent = mPackageManager.getLaunchIntentForPackage(packageName); + startActivitySafely(appIntent); + } else { + gestureHandled = false; + } + break; + } + if (gestureHandled) + doHapticFeedback(); + } catch (Exception e) { + Log.e(TAG, "Gesture EventHandler", e); + } + } + } + + public boolean handleKeyEvent(KeyEvent event) { + boolean isHandled = false; + + + switch (event.getScanCode()) { + case 102: // Home button event + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && isLastPressHomeButton) { + isHandled = true; + } + isLastPressHomeButton = mPowerManager.isInteractive() + && event.getKeyCode() == KeyEvent.KEYCODE_HOME; + } + break; + case 195: // Gesture event + isHandled = true; + if (event.getAction() == KeyEvent.ACTION_DOWN) { + try { + int gestureData = readGestureData(); + + if (gestureData != 0 && !mEventHandler.hasMessages(GESTURE_REQUEST)) { + Message msg = getGestureMessage(gestureData); + boolean defaultProximity = mContext.getResources().getBoolean( + org.cyanogenmod.platform.internal.R.bool.config_proximityCheckOnWakeEnabledByDefault); + boolean proximityWakeCheckEnabled = CMSettings.System.getInt(mContext.getContentResolver(), + CMSettings.System.PROXIMITY_ON_WAKE, defaultProximity ? 1 : 0) == 1; + if (mProximityWakeSupported && proximityWakeCheckEnabled && mProximitySensor != null) { + mEventHandler.sendMessageDelayed(msg, mProximityTimeOut); + processEvent(event); + } else { + mEventHandler.sendMessage(msg); + } + } + } catch (Exception e) { + Log.e(TAG, "Gesture handling failed.", e); + isHandled = false; + } + } + } + return isHandled; + } + + private Message getGestureMessage(int gestureData) { + Message msg = mEventHandler.obtainMessage(GESTURE_REQUEST); + msg.obj = gestureData; + return msg; + } + + private Message getMessageForKeyEvent(KeyEvent keyEvent) { + Message msg = mEventHandler.obtainMessage(GESTURE_REQUEST); + msg.obj = keyEvent; + return msg; + } + + private void processEvent(final KeyEvent keyEvent) { + mProximityWakeLock.acquire(); + mSensorManager.registerListener(new SensorEventListener() { + @Override + public void onSensorChanged(SensorEvent event) { + mProximityWakeLock.release(); + mSensorManager.unregisterListener(this); + if (!mEventHandler.hasMessages(GESTURE_REQUEST)) { + // The sensor took to long, ignoring. + return; + } + mEventHandler.removeMessages(GESTURE_REQUEST); + if (event.values[0] == mProximitySensor.getMaximumRange()) { + Message msg = getMessageForKeyEvent(keyEvent); + mEventHandler.sendMessage(msg); + } + } + + @Override + public void onAccuracyChanged(Sensor sensor, int accuracy) { + } + + }, mProximitySensor, SensorManager.SENSOR_DELAY_FASTEST); + } + + private void dispatchMediaKeyWithWakeLockToMediaSession(int keycode) { + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext); + if (helper != null) { + KeyEvent event = new KeyEvent(SystemClock.uptimeMillis(), + SystemClock.uptimeMillis(), KeyEvent.ACTION_DOWN, keycode, 0); + helper.sendMediaButtonEvent(event, true); + event = KeyEvent.changeAction(event, KeyEvent.ACTION_UP); + helper.sendMediaButtonEvent(event, true); + } else { + Log.w(TAG, "Unable to send media key event"); + } + } + + private void startActivitySafely(Intent intent) { + intent.addFlags( + Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_SINGLE_TOP + | Intent.FLAG_ACTIVITY_CLEAR_TOP); + try { + UserHandle user = new UserHandle(UserHandle.USER_CURRENT); + mContext.startActivityAsUser(intent, null, user); + } catch (ActivityNotFoundException e) { + // Ignore + } + } + + // TODO implement it more graceful way + private boolean getCMApref(String prefKey, boolean defVal) { + SharedPreferences cmaPrefs = null; + cmaPrefs = cmaContext.getSharedPreferences("com.cyanogenmod.settings.device_preferences", Context.MODE_MULTI_PROCESS); + return cmaPrefs.getBoolean(prefKey, defVal); + } + + private String getCMAStringPref(String prefKey) { + SharedPreferences cmaPrefs = null; + cmaPrefs = cmaContext.getSharedPreferences("com.cyanogenmod.settings.device_preferences", Context.MODE_MULTI_PROCESS); + return cmaPrefs.getString(prefKey, "disabled"); + } + + private void doHapticFeedback() { + if (mVibrator == null) { + return; + } + boolean enabled = getCMApref(TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK, false); + if (enabled) { + mVibrator.vibrate(50); + } + } + + public String readSingleLine(File f) throws IOException { + BufferedReader reader = null; + try { + reader = new BufferedReader(new FileReader(f)); + String line = reader.readLine(); + reader.close(); + return line; + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException ignored) { + } + } + } + } + + private int readGestureData() throws Exception { + File f = new File(MEIZU_GESTURE_DATA); + return Integer.valueOf(readSingleLine(f)); + } +} + diff --git a/mtk/Android.mk b/mtk/Android.mk new file mode 100644 index 0000000..5053e7d --- /dev/null +++ b/mtk/Android.mk @@ -0,0 +1 @@ +include $(call all-subdir-makefiles) diff --git a/mtk/gps/Android.mk b/mtk/gps/Android.mk new file mode 100644 index 0000000..5053e7d --- /dev/null +++ b/mtk/gps/Android.mk @@ -0,0 +1 @@ +include $(call all-subdir-makefiles) diff --git a/mtk/gps/hal/Android.mk b/mtk/gps/hal/Android.mk new file mode 100644 index 0000000..aa55eca --- /dev/null +++ b/mtk/gps/hal/Android.mk @@ -0,0 +1,76 @@ +# Copyright Statement: +# +# This software/firmware and related documentation ("MediaTek Software") are +# protected under relevant copyright laws. The information contained herein +# is confidential and proprietary to MediaTek Inc. and/or its licensors. +# Without the prior written permission of MediaTek inc. and/or its licensors, +# any reproduction, modification, use or disclosure of MediaTek Software, +# and information contained herein, in whole or in part, shall be strictly prohibited. +# +# MediaTek Inc. (C) 2014. All rights reserved. +# +# BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON +# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH +# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES +# THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES +# CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK +# SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR +# STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND +# CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO +# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +# +# The following software/firmware and/or related documentation ("MediaTek Software") +# have been modified by MediaTek Inc. All revisions are subject to any receiver's +# applicable license agreements with MediaTek Inc. + +#ifeq ($(BOARD_GPS_LIBRARIES), true) +LOCAL_PATH := $(call my-dir) + +# HAL module implemenation, not prelinked and stored in +# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +ifeq ($(MTK_K64_SUPPORT), yes) +LOCAL_CFLAGS:= -DHAVE_GPS_HARDWARE_64BIT +endif + +#ifneq ($(MTK_OPEN_PACKAGE), yes) +#LOCAL_STATIC_LIBRARIES := libepos +#LOCAL_CFLAGS:= -DEPO_SUPPORT +#endif + +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libcutils \ + libhardware \ + libcurl \ + libandroid_runtime \ + libnativehelper \ + libcrypto \ + libssl \ + libz +ifeq ($(MTK_TC1_FEATURE), yes) +LOCAL_CFLAGS:= -DGPS_AT_COMMAND +endif +LOCAL_SRC_FILES := gps_mtk_aosp.c + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/inc \ + $(LOCAL_PATH)/../../kernel-headers \ + +LOCAL_MODULE := gps.$(TARGET_BOARD_PLATFORM) +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) +#include $(LOCAL_PATH)/libs/Android.mk +#endif diff --git a/mtk/gps/hal/NOTICE b/mtk/gps/hal/NOTICE new file mode 100644 index 0000000..38fb1bb --- /dev/null +++ b/mtk/gps/hal/NOTICE @@ -0,0 +1,34 @@ +/* Copyright Statement: + * + * This software/firmware and related documentation ("MediaTek Software") are + * protected under relevant copyright laws. The information contained herein + * is confidential and proprietary to MediaTek Inc. and/or its licensors. + * Without the prior written permission of MediaTek inc. and/or its licensors, + * any reproduction, modification, use or disclosure of MediaTek Software, + * and information contained herein, in whole or in part, shall be strictly prohibited. + * + * MediaTek Inc. (C) 2010. All rights reserved. + * + * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES + * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") + * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON + * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. + * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE + * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR + * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH + * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES + * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES + * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK + * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR + * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND + * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, + * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, + * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO + * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. + * + * The following software/firmware and/or related documentation ("MediaTek Software") + * have been modified by MediaTek Inc. All revisions are subject to any receiver's + * applicable license agreements with MediaTek Inc. + */
\ No newline at end of file diff --git a/mtk/gps/hal/README b/mtk/gps/hal/README new file mode 100644 index 0000000..2ccab13 --- /dev/null +++ b/mtk/gps/hal/README @@ -0,0 +1,43 @@ +This directory contains GPS HAL layer code. + +WHAT IT DOES? +============= +It provide GPS interfaces for gps provider on frameworks,which allow init/open/close/cleanup gps +when mnld daemon is launched. + +HOW IT WAS BUILT? +================== + +It needs the following libs from AOSP: +1. libc.so +2. libcutils +3. libnetutils +4. libhardware +5. libandroid_runtime +6. libnativehelper +7. libcrypto +8. libssl +9. libz + +and the following libs from MediaTek: +1. liblog.so +2. libepos.a +3. libcurl + +All source/dependency modules of this module are already put in +'vendor/mediatek/libs' folder. + + +HOW TO USE IT? +============== + +Files in this directory is used to +generate a library which's name is 'gps.default.so' + + +gps.default +The lib 'gps.default' is loaded by system_server, +GPS Location provider will call gps_module_methods API, if system_server is launched. + +All the source code of this library were written by MediaTek co.. + diff --git a/mtk/gps/hal/gps_mtk_aosp.c b/mtk/gps/hal/gps_mtk_aosp.c new file mode 100644 index 0000000..82ffbec --- /dev/null +++ b/mtk/gps/hal/gps_mtk_aosp.c @@ -0,0 +1,5715 @@ +/* Copyright Statement: + * + * This software/firmware and related documentation ("MediaTek Software") are + * protected under relevant copyright laws. The information contained herein + * is confidential and proprietary to MediaTek Inc. and/or its licensors. + * Without the prior written permission of MediaTek inc. and/or its licensors, + * any reproduction, modification, use or disclosure of MediaTek Software, + * and information contained herein, in whole or in part, shall be strictly prohibited. + * + * MediaTek Inc. (C) 2010. All rights reserved. + * + * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES + * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") + * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON + * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. + * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE + * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR + * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH + * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES + * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES + * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK + * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR + * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND + * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, + * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, + * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO + * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. + * + * The following software/firmware and/or related documentation ("MediaTek Software") + * have been modified by MediaTek Inc. All revisions are subject to any receiver's + * applicable license agreements with MediaTek Inc. + */ +#define MTK_LOG_ENABLE 1 +#include <errno.h> +#include <pthread.h> +#include <fcntl.h> +#include <sys/epoll.h> +#include <math.h> +#include <time.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <arpa/inet.h> +#include <netinet/in.h> +#include <netdb.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <semaphore.h> + +#include <sys/ioctl.h> +#include <sys/time.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <signal.h> +#include <linux/mtk_agps_common.h> +#include <private/android_filesystem_config.h> +// #include <linux/mtgpio.h> + +#if EPO_SUPPORT + // for EPO file +// xen0n: fix build +#include <curl/curl.h> +#include <curl/easy.h> + +#define EPO_FILE "/data/misc/gps/EPO.DAT" +#define EPO_FILE_HAL "/data/misc/gps/EPOHAL.DAT" +#define MTK_EPO_SET_PER_DAY 4 +#define MTK_EPO_MAX_DAY 30 +#define MTK_EPO_ONE_SV_SIZE 72 +#define MTK_EPO_SET_MAX_SIZE 2304 // 72*32, One SET +#define MTK_EPO_MAX_SET (MTK_EPO_MAX_DAY * MTK_EPO_SET_PER_DAY) +#define MTK_EPO_EXPIRED 3*24*60*60 // 7 days(s) +#define BUF_SIZE MTK_EPO_SET_MAX_SIZE +#define GPS_CONF_FILE_SIZE 100 +#define EPO_CONTROL_FILE_PATH "/data/misc/gps.conf" +#define IS_SPACE(ch) ((ch == ' ') || (ch == '\t') || (ch == '\n')) +#endif + +#define LOCATION_NLP_FIX "/data/misc/gps/LOCATION.DAT" +#define C_INVALID_FD -1 +#define LOG_TAG "gps_mtk" +#include <cutils/log.h> +#include <cutils/sockets.h> +#include <cutils/properties.h> +#ifdef HAVE_LIBC_SYSTEM_PROPERTIES +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include <sys/_system_properties.h> +#endif + +#include <hardware/gps_mtk.h> + +/* the name of the controlled socket */ +#define GPS_CHANNEL_NAME "/dev/gps" +#define GPS_MNL_DAEMON_NAME "mnld" +#define GPS_MNL_DAEMON_PROP "init.svc.mnld" + +#define GPS_AT_COMMAND_SOCK "/data/server" +#define MNL_CONFIG_STATUS "persist.radio.mnl.prop" + +#define GPS_OP "AT%GPS" +#define GNSS_OP "AT%GNSS" +#define GPS_AT_ACK_SIZE 60 + +#define GPS_DEBUG 0 +#define NEMA_DEBUG 0 /*the flag works if GPS_DEBUG is defined*/ +#if GPS_DEBUG +#define TRC(f) ALOGD("%s", __func__) +#define ERR(f, ...) ALOGE("%s: line = %d" f, __func__, __LINE__, ##__VA_ARGS__) +#define WAN(f, ...) ALOGW("%s: line = %d" f, __func__, __LINE__, ##__VA_ARGS__) +#define DBG(f, ...) ALOGD("%s: line = %d" f, __func__, __LINE__, ##__VA_ARGS__) +#define VER(f, ...) ((void)0) // ((void)0) // +#else +# define TRC(...) ((void)0) +# define ERR(...) ((void)0) +# define WAN(...) ((void)0) +# define DBG(...) ((void)0) +# define VER(...) ((void)0) +#endif +#define SEM 0 +#define NEED_IPC_WITH_CODEC 1 +#if (NEED_IPC_WITH_CODEC) +#include <private/android_filesystem_config.h> +#define EVDO_CODEC_SOC "/data/misc/codec_sock" +#endif +static int flag_unlock = 0; +GpsStatus sta; + +#define GPS_AOSP_MODE +#define GPS_AT_COMMAND_SOCK "/data/server" // For receive AT command +#define MTK_HAL2MNLD "/data/gps_mnl/hal2mnld" // HAL forward AGPS Info to MNLD, FWK->JNI->HAL->MNLD +#define MTK_MNLD2HAL "/data/gps_mnl/mnld2hal" // MNLD forward AGPS Info to HAL, MNLD->HAL->JNI->FWK + +typedef struct { + int send_fd; + AGpsCallbacks* agps_callbacks; + GpsNiCallbacks* gps_ni_callbacks; + AGpsRilCallbacks* agps_ril_callbacks; +} agps_context; + +typedef unsigned int UINT4; +typedef signed int INT4; + +typedef unsigned char UINT8; +typedef signed char INT8; + +typedef unsigned short int UINT16; +typedef signed short int INT16; + +typedef unsigned int UINT32; +typedef signed int INT32; + +typedef signed long long INT64; + +#pragma pack(4) // Align by 4 byte +typedef struct +{ + UINT32 size; + UINT32 flag; + INT8 PRN; + double TimeOffsetInNs; + UINT16 state; + INT64 ReGpsTowInNs; // Re: Received + INT64 ReGpsTowUnInNs; // Re: Received, Un:Uncertainty + double Cn0InDbHz; + double PRRateInMeterPreSec; // PR: Pseuderange + double PRRateUnInMeterPreSec; // PR: Pseuderange Un:Uncertainty + UINT16 AcDRState10; // Ac:Accumulated, DR:Delta Range + double AcDRInMeters; // Ac:Accumulated, DR:Delta Range + double AcDRUnInMeters; // Ac:Accumulated, DR:Delta Range, Un:Uncertainty + double PRInMeters; // PR: Pseuderange + double PRUnInMeters; + double CPInChips; // CP: Code Phase + double CPUnInChips; // CP: Code Phase + float CFInhZ; // CP: Carrier Frequency + INT64 CarrierCycle; + double CarrierPhase; + double CarrierPhaseUn; // Un:Uncertainty + UINT8 LossOfLock; + INT32 BitNumber; + INT16 TimeFromLastBitInMs; + double DopperShiftInHz; + double DopperShiftUnInHz; // Un:Uncertainty + UINT8 MultipathIndicater; + double SnrInDb; + double ElInDeg; // El: elevation + double ElUnInDeg; // El: elevation, Un:Uncertainty + double AzInDeg; // Az: Azimuth + double AzUnInDeg; // Az: Azimuth + char UsedInFix; +}MTK_GPS_MEASUREMENT; + +typedef struct +{ + UINT32 size; + UINT16 flag; + INT16 leapsecond; + UINT8 type; + INT64 TimeInNs; + double TimeUncertaintyInNs; + INT64 FullBiasInNs; + double BiasInNs; + double BiasUncertaintyInNs; + double DriftInNsPerSec; + double DriftUncertaintyInNsPerSec; +}MTK_GPS_CLOCK; +typedef struct +{ + UINT32 size; + INT8 type; + UINT8 prn; + INT16 messageID; + INT16 submessageID; + UINT32 length; + UINT8 data[40]; +} MTK_GPS_NAVIGATION_EVENT; +#pragma pack() +typedef struct{ + GpsUtcTime time; + int64_t timeReference; + int uncertainty; +} ntp_context; + +typedef struct{ + double latitude; + double longitude; + float accuracy; + struct timespec ts; + unsigned char type; + unsigned char started; +} nlp_context; + + +agps_context g_agps_ctx; + +#if EPO_SUPPORT +#define GPS_EPO_FILE_LEN 20 +#define C_INVALID_TIMER -1 /*invalid timer */ +static int gps_epo_period = 3; +static int wifi_epo_period = 1; +static int gps_epo_download_days = 30; +static int gps_epo_enable = 1; +static int gps_epo_wifi_trigger = 0; +static int gps_epo_file_count = 0; +static char gps_epo_file_name[GPS_EPO_FILE_LEN] = {0}; +static char gps_epo_md_file_name[GPS_EPO_FILE_LEN] = {0}; +static int gps_epo_type = 0; // o for G+G;1 for GPS only, default is G+G +static int gnss_mode = 2; +const char *mnl_prop_path[] = { + "/data/misc/gps/mnl.prop", /*mainly for target*/ + "/sbin/mnl.prop", /*mainly for emulator*/ +}; +typedef struct retry_alarm +{ + struct itimerspec expire; + struct sigevent evt; + timer_t fd; +}RETRY_ALARM_T; +static RETRY_ALARM_T retry_timer; +#endif +/*****************************************************************************/ +/* MTK device control */ +/*****************************************************************************/ +enum { + MNL_CMD_UNKNOWN = -1, + /*command send from GPS HAL*/ + MNL_CMD_INIT = 0x00, + MNL_CMD_CLEANUP = 0x01, + MNL_CMD_STOP = 0x02, + MNL_CMD_START = 0x03, + MNL_CMD_RESTART = 0x04, /*restart MNL process*/ + MNL_CMD_RESTART_HOT = 0x05, /*restart MNL by PMTK command: hot start*/ + MNL_CMD_RESTART_WARM = 0x06, /*restart MNL by PMTK command: warm start*/ + MNL_CMD_RESTART_COLD = 0x07, /*restart MNL by PMTK command: cold start*/ + MNL_CMD_RESTART_FULL = 0x08, /*restart MNL by PMTK command: full start*/ + MNL_CMD_RESTART_AGPS = 0x09, /*restart MNL by PMTK command: AGPS start*/ + MNL_CMD_GPSMEASUREMENT_INIT = 0x15, + MNL_CMD_GPSMEASUREMENT_CLOSE = 0x16, + + MNL_CMD_GPSNAVIGATION_INIT = 0x17, + MNL_CMD_GPSNAVIGATION_CLOSE = 0x18, + +#if EPO_SUPPORT + MNL_CMD_READ_EPO_TIME = 0x33, + MNL_CMD_UPDATE_EPO_FILE = 0x34, +#endif + MNL_CMD_GPS_LOG_WRITE = 0x40, + + MNL_CMD_ENABLE_AGPS_DEBUG = 0x42, + MNL_CMD_DISABLE_AGPS_DEBUG = 0x43, + + /*please see mnld.c for other definition*/ +}; + +enum { + HAL_CMD_STOP_UNKNOWN = -1, +#if EPO_SUPPORT + HAL_CMD_READ_EPO_TIME_DONE = 0x35, + HAL_CMD_UPDATE_EPO_FILE_DONE = 0x36, + + HAL_CMD_READ_EPO_TIME_FAIL = 0x37, + HAL_CMD_UPDATE_EPO_FILE_FAIL = 0x38, +#endif + HAL_CMD_MNL_DIE = 0x41, + HAL_CMD_GPS_ICON = 0x42, + + MNL_CMD_GPS_INJECT_TIME = 0x46, + MNL_CMD_GPS_INJECT_LOCATION = 0x47, + MNL_CMD_GPS_INJECT_TIME_REQ = 0x48, + MNL_CMD_GPS_INJECT_LOCATION_REQ = 0x49, + + MNL_CMD_GPS_NLP_LOCATION_REQ = 0x4a, + HAL_CMD_MEASUREMENT= 0x76, + HAL_CMD_NAVIGATION= 0x77, + HAL_CMD_SWITCH_AGPS_DEBUG_DONE = 0x44, + HAL_CMD_SWITCH_AGPS_DEBUG_FAIL = 0X45, +}; + + // HAL->MNLD->AGPSD +enum { + AGPS_FRAMEWORK_INFO_DATA_CONN_OPEN = 125, + AGPS_FRAMEWORK_INFO_DATA_CONN_FAILED, + AGPS_FRAMEWORK_INFO_DATA_CONN_CLOSED, + AGPS_FRAMEWORK_INFO_NI_MESSAGE, + AGPS_FRAMEWORK_INFO_NI_RESPOND, + AGPS_FRAMEWORK_INFO_SET_REF_LOC, + AGPS_FRAMEWORK_INFO_SET_SET_ID, + AGPS_FRAMEWORK_INFO_SET_SERVER, + AGPS_FRAMEWORK_INFO_UPDATE_NETWORK_STATE, + AGPS_FRAMEWORK_INFO_UPDATE_NETWORK_AVAILABILITY, + AGPS_FRAMEWORK_INFO_DATA_CONN_OPEN_IP_TYPE, + AGPS_FRAMEWORK_INFO_INSTALL_CERTIFICATES, + AGPS_FRAMEWORK_INFO_REVOKE_CERTIFICATES, + AGPS_FRAMEWORK_INFO_COUNT, +}; + + // AGPSD->MNLD->HAL +enum { + MNL_AGPS_CMD_NOTIFICATION = 230, + MNL_AGPS_CMD_DATA_CONN_REQ, + MNL_AGPS_CMD_DATA_CONN_RELEASE, + MNL_AGPS_CMD_REQUEST_SET_ID, + MNL_AGPS_CMD_REQUEST_REFLOC, + MNL_AGPS_CMD_AGPS_LOC, + MNL_AGPS_CMD_NOTIFICATION_2, + MNL_AGPS_CMD_DATA_CONN_REQ2, +}; + + +typedef enum +{ + AGPS_SUPL_NOTIFY_ONLY = 1, + AGPS_SUPL_NOTIFY_ALLOW_NO_ANSWER, + AGPS_SUPL_NOTIFY_DENY_NO_ANSWER, + AGPS_SUPL_NOTIFY_PRIVACY, + AGPS_SUPL_NOTIFY_END +} agps_supl_notify_enum; + + +typedef struct { + double latitude; // Represents latitude in degrees + double longitude; // Represents longitude in degrees + char altitude_used; // 0=disabled 1=enabled + double altitude; // Represents altitude in meters above the WGS 84 reference + char speed_used; // 0=disabled 1=enabled + float speed; // Represents speed in meters per second + char bearing_used; // 0=disabled 1=enabled + float bearing; // Represents heading in degrees + char accuracy_used; // 0=disabled 1=enabled + float accuracy; // Represents expected accuracy in meters + char timestamp_used; // 0=disabled 1=enabled + long long timestamp; // Milliseconds since January 1, 1970 +} mnl_agps_agps_location; + + +#define M_START 0 +#define M_STOP 1 +#define M_CLEANUP 2 +#define M_INIT 3 +#define M_THREAD_EXIT 4 +#define M_MNLDIE 5 +typedef struct sync_lock +{ + pthread_mutex_t mutx; + pthread_cond_t con; + int condtion; +}SYNC_LOCK_T; +static SYNC_LOCK_T lock_for_sync[] = {{PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0}, + {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0}, + {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0}, + {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0}, + {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0}, + {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0}}; + +const char* gps_native_thread = "GPS NATIVE THREAD"; +static GpsCallbacks_mtk callback_backup_mtk; +static GpsMeasurementCallbacks measurement_callbacks; +static GpsNavigationMessageCallbacks navigation_callbacks; +static int start_flag = 0; + // for different SV parse +typedef enum{ + GPS_SV = 0, + GLONASS_SV, + BDS_SV, + GALILEO_SV, +}SV_TYPE; +static float report_time_interval = 0; +static int started = 0; +static int nw_connected = 0; +static int nw_type = 0; +#define nw_wifi 0x00000001 +#define nw_data 0x00000000 + +#if EPO_SUPPORT + // zqh: download EPO by request +static GpsXtraCallbacks mGpsXtraCallbacks; +typedef struct +{ + int length; + char* data; +}EpoData; +EpoData epo_data; +static int epo_download_failed = 0; +static int epo_download_retry = 1; +char chip_id[PROPERTY_VALUE_MAX]; + +#endif +/*---------------------------------------------------------------------------*/ +typedef struct { + int sock; +} MTK_GPS; +static void measurement_callback(GpsData* data) { + DBG("measurement_callback is called"); +} + +GpsMeasurementCallbacks sGpsMeasurementCallbacks = { + sizeof(GpsMeasurementCallbacks), + measurement_callback, +}; + +static void navigation_message_callback(GpsNavigationMessage* message) { + DBG("navigation_message_callback is called"); +} + +GpsNavigationMessageCallbacks sGpsNavigationMessageCallbacks = { + sizeof(GpsNavigationMessageCallbacks), + navigation_message_callback, +}; +/*****************************************************************************/ + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** C O N N E C T I O N S T A T E *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ + +/* commands sent to the gps thread */ +enum { + CMD_QUIT = 0, + CMD_START = 1, + CMD_STOP = 2, + CMD_RESTART = 3, + CMD_DOWNLOAD = 4, + + CMD_TEST_START = 10, + CMD_TEST_STOP = 11, + CMD_TEST_SMS_NO_RESULT = 12, +}; + +static MTK_GPS mtk_gps = { + .sock = -1, +}; +static int gps_nmea_end_tag = 0; +struct sockaddr_un cmd_local; +struct sockaddr_un remote; +socklen_t remotelen; + + +/*****************************************************************************/ +/*AT command test state*/ +static int MNL_AT_TEST_FLAG = 0; +#define GPS_TEST_PRN 1 +#ifdef GPS_AT_COMMAND +static int MNL_AT_SIGNAL_MODE = 0; +static int MNL_AT_SIGNAL_TEST_BEGIN = 0; + +int MNL_AT_SET_ALARM = 0; +int MNL_AT_CANCEL_ALARM = 0; + + +enum { + MNL_AT_TEST_UNKNOWN = -1, + MNL_AT_TEST_START = 0x00, + MNL_AT_TEST_STOP = 0x01, + MNL_AT_TEST_INPROGRESS = 0x02, + MNL_AT_TEST_DONE = 0x03, + MNL_AT_TEST_RESULT_DONE = 0x04, +}; +int MNL_AT_TEST_STATE = MNL_AT_TEST_UNKNOWN; +typedef struct { + int test_num; + int prn_num; + int time_delay; +}HAL_AT_TEST_T; + +static HAL_AT_TEST_T hal_test_data = { + .test_num = 0, + .prn_num = 0, + .time_delay = 0, +}; +#endif + +static time_t start_time; +static time_t end_time; +#ifdef GPS_AT_COMMAND +int* Dev_CNr = NULL; +int prn[32] = {0}; +int snr[32] = {0}; +int cn = 0; +/* +* Test result array: error_code, theta(0), phi(0), Success_Num, +* Complete_Num, Avg_CNo, Dev_CNo, Avg_Speed(0) +*/ +static int result[8] = {1, 0, 0, 0, 0, 0, 0, 0}; +static int test_num = 0; +static int CNo, DCNo; +static int Avg_CNo = 0; +static int Dev_CNo = 0; +static int Completed_Num = 0; +static int Success_Num = 0; +static int Failure_Num = 0; +static int Wait_Num = 0; +static int sig_suc_num = 0; +static int Err_Code = 1; +#define MAX_VALID_STATUS_WAIT_COUNT 20 // 12 +int test_mode_flag = 1; // 0: USB mode, 1: SMS mode +#endif +static int gpsmeasurement_init_flag = 0; /*1:init, 0:close*/ +static int gpsnavigation_init_flag = 0; /*1:init, 0:close*/ +int sv_used_in_fix[256] = {0}; // for multiple sv display +static int get_prop() +{ + // Read property + char result[PROPERTY_VALUE_MAX] = {0}; + int ret = 0; + if (property_get(MNL_CONFIG_STATUS, result, NULL)) { + ret = result[6] - '0'; + DBG("gps.log: %s, %d\n", &result[6], ret); + } else { + ret = 0; + DBG("Config is not set yet, use default value"); + } + + return ret; +} + +static void get_condition(SYNC_LOCK_T *lock) +{ + int ret = 0; + + ret = pthread_mutex_lock(&(lock->mutx)); + DBG("ret mutex lock = %d\n", ret); + + while (!lock->condtion) { + ret = pthread_cond_wait(&(lock->con), &(lock->mutx)); + DBG("ret cond wait = %d\n" , ret); + } + + lock->condtion = 0; + ret = pthread_mutex_unlock(&(lock->mutx)); + DBG("ret mutex unlock = %d\n", ret); + + return; +} + +static void release_condition(SYNC_LOCK_T *lock) +{ + int ret = 0; + + + ret = pthread_mutex_lock(&(lock->mutx)); + DBG("ret mutex lock = %d\n", ret); + + lock->condtion = 1; + ret = pthread_cond_signal(&(lock->con)); + DBG("ret cond_signal = %d\n", ret); + + ret = pthread_mutex_unlock(&(lock->mutx)); + DBG("ret unlock= %d\n", ret); + + return; +} + + // -1 means failure +int bind_udp_socket(char* path) { + int sockfd; + struct sockaddr_un soc_addr; + socklen_t addr_len; + + sockfd = socket(PF_LOCAL, SOCK_DGRAM, 0); + if (sockfd < 0) { + ERR("ERR: socket failed reason=[%s]\n", strerror(errno)); + return -1; + } + + strcpy(soc_addr.sun_path, path); + soc_addr.sun_family = AF_UNIX; + addr_len = (offsetof(struct sockaddr_un, sun_path) + strlen(soc_addr.sun_path) + 1); + + unlink(soc_addr.sun_path); + if (bind(sockfd, (struct sockaddr *)&soc_addr, addr_len) < 0) { + ERR("ERR: bind failed path=[%s] reason=[%s]\n", path, strerror(errno)); + close(sockfd); + return -1; + } + if (chmod(path, 0660) < 0) + ERR("chmod error: %s", strerror(errno)); + if (chown(path, -1, AID_INET)) + ERR("chown error: %s", strerror(errno)); + + return sockfd; +} + + // -1 means failure +int safe_read(int fd, void* buf, int len) { + int n, retry = 10; + + if (fd < 0 || buf == NULL || len < 0) { + ERR("ERR: safe_read fd=%d buf=%p len=%d\n", fd, buf, len); + return -1; + } + + if (len == 0) { + return 0; + } + + if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) { + ERR("ERR: safe_read fcntl failure reason=[%s]\n", strerror(errno)); + } + + while ((n = read(fd, buf, len)) <= 0) { + if (errno == EINTR) continue; + if (errno == EAGAIN) { + if (retry-- > 0) { + usleep(100 * 1000); + continue; + } + goto exit; + } + goto exit; + } + return n; + +exit: + ERR("ERR: safe_read reason=[%s]\n", strerror(errno)); + return -1; +} + + // -1 means failed, 0 means success +int mtk_daemon_send(int sockfd, void* dest, char* buf, int size) { + int ret = 0; + int len = 0; + struct sockaddr_un soc_addr; + socklen_t addr_len; + int retry = 10; + + strcpy(soc_addr.sun_path, dest); + soc_addr.sun_family = AF_UNIX; + addr_len = (offsetof(struct sockaddr_un, sun_path) + strlen(soc_addr.sun_path) + 1); + + DBG("mtk_daemon_send %d", sockfd); + while ((len = sendto(sockfd, buf, size, 0, + (const struct sockaddr *)&soc_addr, (socklen_t)addr_len)) == -1) { + if (errno == EINTR) continue; + if (errno == EAGAIN) { + if (retry-- > 0) { + usleep(100 * 1000); + continue; + } + } + ERR("[hal2mnld] ERR: sendto dest=[%s] len=%d reason =[%s]\n", + (char *)dest, size, strerror(errno)); + ret = -1; + break; + } + // unlink(soc_addr.sun_path); + return ret; +} +static void mtk_gps_update_location(nlp_context * location) +{ + FILE *fp = NULL; + + fp = fopen(LOCATION_NLP_FIX, "w"); + if (fp != NULL) + { + size_t count = 0; + count = fwrite(location, sizeof(nlp_context), 1, fp); + if (count != 1) + { + DBG("write count:%d, errno:%s\n", count, strerror(errno)); + } + fclose(fp); + } +} + +void buff_put_int(int input, char* buff, int* offset) { + *((int*)&buff[*offset]) = input; + *offset += 4; +} + +void buff_put_string(const char* str, char* buff, int* offset) { + int len = strlen(str) + 1; + + *((int*)&buff[*offset]) = len; + *offset += 4; + + memcpy(&buff[*offset], str, len); + *offset += len; +} +void buff_put_binary(void* input, int len, char* buff, int* offset) { + *((int*)&buff[*offset]) = len; + *offset += 4; + + memcpy(&buff[*offset], input, len); + *offset += len; +} + +void buff_put_struct(void* input, int size, char* buff, int* offset) { + memcpy(&buff[*offset], input, size); + *offset += size; +} + + +int buff_get_int(char* buff, int* offset) { + int ret = *((int*)&buff[*offset]); + *offset += 4; + return ret; +} + +int buff_get_string(char* str, char* buff, int* offset) { + int len = *((int*)&buff[*offset]); + *offset += 4; + + memcpy(str, &buff[*offset], len); + *offset += len; + return len; +} +void buff_get_struct(char* output, int size, char* buff, int* offset) { + memcpy(output, &buff[*offset], size); + *offset += size; +} + +int buff_get_binary(void* output, char* buff, int* offset) { + int len = *((int*)&buff[*offset]); + *offset += 4; + + memcpy(output, &buff[*offset], len); + *offset += len; + return len; +} + +static void mtk_gps_send_location_to_mnl(void) { + FILE *fp = NULL; + + fp = fopen(LOCATION_NLP_FIX, "r"); + if (fp != NULL) { + nlp_context nlp_location; + char buff[1024] = {0}; + int offset = 0; + size_t count = 0; + memset(&nlp_location, 0, sizeof(nlp_context)); + count = fread(&nlp_location, sizeof(nlp_context), 1, fp); + if (count != 1) { + DBG("read count:%d, errno:%s\n", count, strerror(errno)); + } + nlp_location.started = started; + buff_put_int(MNL_CMD_GPS_INJECT_LOCATION, buff, &offset); + buff_put_struct(&nlp_location, sizeof(nlp_context), buff, &offset); + if (g_agps_ctx.send_fd >= 0) { + int res = mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + DBG("send location to mnl successfully\n"); + } else { + ERR("g_agps_ctx.send_fd is not initialized\n"); + } + fclose(fp); + } +} + +// return strlen without ending character +int asc_str_to_usc2_str(char* output, char* input) { + int len = 2; + + output[0] = 0xfe; + output[1] = 0xff; + + while (*input != 0) { + output[len++] = 0; + output[len++] = *input; + input++; + } + + output[len+1] = 0; + output[len+2] = 0; + return len; +} + +void raw_data_to_hex_string(char* output, char* input, int input_len) { + int i = 0; + for (i = 0; i < input_len; i++) { + int tmp = (input[i] >> 4) & 0xf; + + if (tmp >= 0 && tmp <= 9) { + output[i*2] = tmp + '0'; + } else { + output[i*2] = (tmp - 10) + 'A'; + } + + tmp = input[i] & 0xf; + if (tmp >= 0 && tmp <= 9) { + output[(i*2)+1] = tmp + '0'; + } else { + output[(i*2)+1] = (tmp - 10) + 'A'; + } + } +} + +void agps_init(AGpsCallbacks* callbacks) { + DBG("agps_init\n"); + g_agps_ctx.agps_callbacks = callbacks; +} +int agps_data_conn_open(const char* apn) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_data_conn_open\n"); + + buff_put_int(AGPS_FRAMEWORK_INFO_DATA_CONN_OPEN, buff, &offset); + buff_put_string(apn, buff, &offset); + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + return 0; +} +int agps_data_conn_open_with_apn_ip_type(const char* apn, ApnIpType apnIpType) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_data_conn_open_with_apn_ip_type"); + buff_put_int(AGPS_FRAMEWORK_INFO_DATA_CONN_OPEN_IP_TYPE, buff, &offset); + buff_put_string(apn, buff, &offset); + buff_put_int(apnIpType, buff, &offset); + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); +return 0; +} +int agps_data_conn_closed() { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_data_conn_closed\n"); + + buff_put_int(AGPS_FRAMEWORK_INFO_DATA_CONN_CLOSED, buff, &offset); + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + return 0; +} +int agps_data_conn_failed() { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_data_conn_failed\n"); + + buff_put_int(AGPS_FRAMEWORK_INFO_DATA_CONN_FAILED, buff, &offset); + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + return 0; +} +int agps_set_server(AGpsType type, const char* hostname, int port) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_set_server type=%d hostname=[%s] port=%d\n", type, hostname, port); + + buff_put_int(AGPS_FRAMEWORK_INFO_SET_SERVER, buff, &offset); + buff_put_int(type, buff, &offset); + buff_put_string(hostname, buff, &offset); + buff_put_int(port, buff, &offset); + + int res = mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + return res; +} +static const AGpsInterface mtkAGpsInterface = { + sizeof(AGpsInterface), + agps_init, + agps_data_conn_open, + agps_data_conn_closed, + agps_data_conn_failed, + agps_set_server, + agps_data_conn_open_with_apn_ip_type, +}; + +int agps_install_certificates(const DerEncodedCertificate* certificates, size_t length) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_install_certificates"); + + buff_put_int(AGPS_FRAMEWORK_INFO_INSTALL_CERTIFICATES, buff, &offset); + buff_put_int(length, buff, &offset); + buff_put_struct(certificates, length, buff, &offset); + + int res = mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + return res; +} +int agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints, size_t length) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_revoke_certificates"); + + buff_put_int(AGPS_FRAMEWORK_INFO_REVOKE_CERTIFICATES, buff, &offset); + buff_put_int(length, buff, &offset); + buff_put_struct(fingerprints, length, buff, &offset); + int res = mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + return res; +} + +static const SuplCertificateInterface mtkSuplCertificateInterface = { + sizeof(SuplCertificateInterface), + agps_install_certificates, + agps_revoke_certificates, +}; + +void gps_ni_init(GpsNiCallbacks *callbacks) { + DBG("gps_ni_init\n"); + g_agps_ctx.gps_ni_callbacks = callbacks; +} +void gps_ni_respond(int notif_id, GpsUserResponseType user_response) { + char buff[1024] = {0}; + int offset = 0; + DBG("gps_ni_respond notif_id=%d user_response=%d\n", notif_id, user_response); + + buff_put_int(AGPS_FRAMEWORK_INFO_NI_RESPOND, buff, &offset); + buff_put_int(notif_id, buff, &offset); + buff_put_int(user_response, buff, &offset); + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); +} + + + +static const GpsNiInterface mtkGpsNiInterface = { + sizeof(GpsNiInterface), + gps_ni_init, + gps_ni_respond, +}; + + +void agps_ril_init(AGpsRilCallbacks* callbacks) { + DBG("agps_ril_init\n"); + g_agps_ctx.agps_ril_callbacks = callbacks; +} +void agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_ril_set_ref_location\n"); + + buff_put_int(AGPS_FRAMEWORK_INFO_SET_REF_LOC, buff, &offset); + buff_put_struct((void *)agps_reflocation, sizeof(AGpsRefLocation), buff, &offset); + buff_put_int(sz_struct, buff, &offset); + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + +} +void agps_ril_set_set_id(AGpsSetIDType type, const char* setid) { + char buff[1024] = {0}; + int offset = 0; + // DBG("agps_ril_set_set_id type=%d setid=[%s]\n", type, setid); + + buff_put_int(AGPS_FRAMEWORK_INFO_SET_SET_ID, buff, &offset); + buff_put_int(type, buff, &offset); + buff_put_string(setid, buff, &offset); + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); +} +void agps_ril_ni_message(uint8_t *msg, size_t len) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_ril_ni_message len=%d\n", len); + + buff_put_int(AGPS_FRAMEWORK_INFO_NI_MESSAGE, buff, &offset); + buff_put_binary(msg, len, buff, &offset); + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); +} +void agps_network_connected_wifi_tragger_nlp(void) +{ + char buff[1024] = {0}; + int offset = 0; + + TRC(); + buff_put_int(MNL_CMD_GPS_NLP_LOCATION_REQ, buff, &offset); + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + +} +void agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) { + char buff[1024] = {0}; + int offset = 0; + DBG("agps_ril_update_network_state connected=%d type=%d roaming=%d extra=%s\n", + connected, type, roaming, extra_info); + DBG("nw_connected =%d\n", nw_connected); + if (nw_connected == 0 && connected == 1 && type == nw_wifi) + { + /*send nlp request to mnld */ + agps_network_connected_wifi_tragger_nlp(); + } + nw_connected = connected; + nw_type = type; + buff_put_int(AGPS_FRAMEWORK_INFO_UPDATE_NETWORK_STATE, buff, &offset); + buff_put_int(connected, buff, &offset); + buff_put_int(type, buff, &offset); + buff_put_int(roaming, buff, &offset); + if (extra_info == NULL) { + buff_put_string("", buff, &offset); + } else { + buff_put_string(extra_info, buff, &offset); + } + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); +} +void agps_ril_update_network_availability(int avaiable, const char* apn) { + char buff[1024] = {0}; + int offset = 0; + + if (apn == NULL) { + DBG("The apn is NULL"); + } else { + DBG("agps_ril_update_network_availability avaiable=%d apn=[%s]\n", + avaiable, apn); + } + + buff_put_int(AGPS_FRAMEWORK_INFO_UPDATE_NETWORK_AVAILABILITY, buff, &offset); + buff_put_int(avaiable, buff, &offset); + + if (apn == NULL) { + buff_put_string("", buff, &offset); + } else { + buff_put_string(apn, buff, &offset); + } + + mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); +} + +static const AGpsRilInterface mtkAGpsRilInterface = { + sizeof(AGpsRilInterface), + agps_ril_init, + agps_ril_set_ref_location, + agps_ril_set_set_id, + agps_ril_ni_message, + agps_ril_update_network_state, + agps_ril_update_network_availability, +}; + +struct prop_info { + unsigned volatile serial; + char value[PROP_VALUE_MAX]; + char name[0]; +}; + +typedef struct prop_info prop_info; +/*****************************************************************************/ +int mtk_start_daemon() { /*gps driver must exist before running the function*/ +#ifndef GPS_AOSP_MODE + int start = 0; + char status[PROPERTY_VALUE_MAX] = {0}; + int count = 100, len; +#ifdef HAVE_LIBC_SYSTEM_PROPERTIES + const prop_info *pi = NULL; + unsigned serial = 0; +#endif + TRC(); + +#ifdef HAVE_LIBC_SYSTEM_PROPERTIES + pi = __system_property_find(GPS_MNL_DAEMON_PROP); + if (pi != NULL) + serial = pi->serial; +#endif + + property_set("ctl.start", GPS_MNL_DAEMON_NAME); + sched_yield(); + + while (count-- > 0) { + #ifdef HAVE_LIBC_SYSTEM_PROPERTIES + if (pi == NULL) { + pi = __system_property_find(GPS_MNL_DAEMON_PROP); + } + if (pi != NULL) { + __system_property_read(pi, NULL, status); + if (strcmp(status, "running") == 0) { + DBG("running\n"); + return 0; + } else if (pi->serial != serial && + strcmp(status, "stopped") == 0) { + return -1; + } + } +#else + if (property_get(GPS_MNL_DAEMON_PROP, status, NULL)) { + if (strcmp(status, "running") == 0) + return 0; + } +#endif + WAN("[%02d] '%s'\n", count, status); + usleep(100000); + } + ERR("start daemon timeout!!\n"); + return -1; +#else + return 0; +#endif +} +/*****************************************************************************/ +int mtk_stop_daemon() { +#ifndef GPS_AOSP_MODE + char status[PROPERTY_VALUE_MAX] = {0}; + int count = 50; + + TRC(); + if (property_get(GPS_MNL_DAEMON_PROP, status, NULL) && + strcmp (status, "stopped") == 0) { + property_set(GPS_MNL_PROCESS_STATUS, "0000"); + DBG("daemon is already stopped!!"); + return 0; + } + + property_set("ctl.stop", GPS_MNL_DAEMON_NAME); + sched_yield(); + + while (count-- > 0) { + if (property_get(GPS_MNL_DAEMON_PROP, status, NULL)) { + if (strcmp(status, "stopped") == 0) { + property_set(GPS_MNL_PROCESS_STATUS, "0000"); + DBG("daemon is stopped, set %s 0000", GPS_MNL_PROCESS_STATUS); + return 0; + } + } + usleep(100000); + } + ERR("stop daemon timeout!!\n"); + return -1; +#else + return 0; +#endif +} +/*****************************************************************************/ +int mtk_daemon_init() { +#if 0 + int err = -1, lsocket; + int count = 10; + + if (mtk_start_daemon() < 0) { + ERR("start daemon fail: %s\n", strerror(errno)); + return -1; + } + + lsocket = socket(PF_UNIX, SOCK_STREAM, 0); + if (lsocket < 0) { + ERR("fail to create socket: %s\n", strerror(errno)); + return -1; + } + + while (count-- > 0) { + err = socket_local_client_connect(lsocket, GPS_MNL_DAEMON_NAME, + ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); + /*connect success*/ + if (err >= 0) + break; + /*connect retry*/ + WAN("[%02d] retry\n", count); + err = mt3326_start_daemon(); + if (err < 0) + break; + usleep(100000); + } + if (err < 0) { + ERR("socket_local_client_connect fail: %s\n", strerror(errno)); + close(lsocket); + return -1; + } + + mtk_gps.sock = lsocket; + DBG("socket : %d\n", lsocket); +#endif + return 0; +} +/*****************************************************************************/ +int mtk_daemon_cleanup() { + TRC(); + +/* for received NI message when GPS is disabled + if (mtk_gps.sock != -1) + close(mtk_gps.sock); +*/ + return mtk_stop_daemon(); +} +/*****************************************************************************/ +int mtk_init() +{ + int err; + char buf[] = {MNL_CMD_INIT}; + TRC(); + return mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); +} +/*****************************************************************************/ +int mtk_cleanup() +{ + int err, res; + char buf[] = {MNL_CMD_CLEANUP}; + TRC(); + if ((err = mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)))) + ERR("mtk_cleanup send cleanup fails\n"); + DBG("let MNLD die\n"); + usleep(100000); + res = mtk_daemon_cleanup(); + // DBG("cleanup: %d, %d\n", err, res); + return 0; +} +/*****************************************************************************/ +int mtk_start() +{ + char buf[] = {MNL_CMD_START}; + int err; + int idx = 0, max = 5; + TRC(); + err = mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); + /*sometimes, the mnld is restarted, so */ + while (err && (errno == EPIPE) && (idx++ < max)) { + sleep(1); + err = mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); + } + return err; +} +/*****************************************************************************/ +int mtk_stop() +{ + char buf[] = {MNL_CMD_STOP}; + TRC(); + return mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); +} +/*****************************************************************************/ +int mtk_restart(unsigned char cmd) +{ + char buf[] = {cmd}; + TRC(); + return mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); +} +/*****************************************************************************/ +int mtk_measurement_init() +{ + char buf[] = {MNL_CMD_GPSMEASUREMENT_INIT}; + TRC(); + DBG("Hal send MNL_CMD_GPSMEASUREMENT_INIT"); + return mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); +} +/*****************************************************************************/ +int mtk_measurement_close() +{ + char buf[] = {MNL_CMD_GPSMEASUREMENT_CLOSE}; + TRC(); + DBG("Hal send MNL_CMD_GPSMEASUREMENT_CLOSE"); + return mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); +} +/*****************************************************************************/ +int mtk_navigation_init() +{ + char buf[] = {MNL_CMD_GPSNAVIGATION_INIT}; + TRC(); + DBG("Hal send MNL_CMD_GPSNAVIGATION_INIT"); + return mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); +} +/*****************************************************************************/ +int mtk_navigation_close() +{ + char buf[] = {MNL_CMD_GPSNAVIGATION_CLOSE}; + TRC(); + DBG("Hal send MNL_CMD_GPSNAVIGATION_CLOSE"); + return mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buf, sizeof(buf)); +} + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** N M E A T O K E N I Z E R *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ + +typedef struct { + const char* p; + const char* end; +} Token; + +#define MAX_NMEA_TOKENS 24 + +typedef struct { + int count; + Token tokens[ MAX_NMEA_TOKENS ]; +} NmeaTokenizer; + +static int +nmea_tokenizer_init(NmeaTokenizer* t, const char* p, const char* end) +{ + int count = 0; + char* q; + + // the initial '$' is optional + if (p < end && p[0] == '$') + p += 1; + + // remove trailing newline + if (end > p && (*(end-1) == '\n')) { + end -= 1; + if (end > p && (*(end-1) == '\r')) + end -= 1; + } + + // get rid of checksum at the end of the sentecne + if (end >= p+3 && (*(end-3) == '*')) { + end -= 3; + } + + while (p < end) { + const char* q = p; + + q = memchr(p, ',', end-p); + if (q == NULL) + q = end; + + if (q >= p) { + if (count < MAX_NMEA_TOKENS) { + t->tokens[count].p = p; + t->tokens[count].end = q; + count += 1; + } + } + if (q < end) + q += 1; + + p = q; + } + + t->count = count; + return count; +} + +static Token +nmea_tokenizer_get(NmeaTokenizer* t, int index) +{ + Token tok; + static const char* dummy = ""; + + if (index < 0 || index >= t->count) { + tok.p = tok.end = dummy; + } else + tok = t->tokens[index]; + + return tok; +} + + +static int +str2int(const char* p, const char* end) +{ + int result = 0; + int len = end - p; + int sign = 1; + + if (*p == '-') + { + sign = -1; + p++; + len = end - p; + } + + for (; len > 0; len--, p++) + { + int c; + + if (p >= end) + goto Fail; + + c = *p - '0'; + if ((unsigned)c >= 10) + goto Fail; + + result = result*10 + c; + } + return sign*result; + +Fail: + return -1; +} + +static double +str2float(const char* p, const char* end) +{ + int result = 0; + int len = end - p; + char temp[16]; + + if (len >= (int)sizeof(temp)) + return 0.; + + memcpy(temp, p, len); + temp[len] = 0; + return strtod(temp, NULL); +} + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** N M E A P A R S E R *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ + + // #define NMEA_MAX_SIZE 83 +#define NMEA_MAX_SIZE 128 +/*maximum number of SV information in GPGSV*/ +#define NMEA_MAX_SV_INFO 4 +#define LOC_FIXED(pNmeaReader) ((pNmeaReader->fix_mode == 2) || (pNmeaReader->fix_mode ==3)) +typedef struct { + int pos; + int overflow; + int utc_year; + int utc_mon; + int utc_day; + int utc_diff; + GpsLocation fix; + + /* + * The fix flag extracted from GPGSA setence: 1: No fix; 2 = 2D; 3 = 3D + * if the fix mode is 0, no location will be reported via callback + * otherwise, the location will be reported via callback + */ + int fix_mode; + /* + * Indicate that the status of callback handling. + * The flag is used to report GPS_STATUS_SESSION_BEGIN or GPS_STATUS_SESSION_END: + * (0) The flag will be set as true when callback setting is changed via nmea_reader_set_callback + * (1) GPS_STATUS_SESSION_BEGIN: receive location fix + flag set + callback is set + * (2) GPS_STATUS_SESSION_END: receive location fix + flag set + callback is null + */ + int cb_status_changed; + int sv_count; /*used to count the number of received SV information*/ + GpsSvStatus sv_status_gps; + GnssSvStatus sv_status_gnss; + GpsCallbacks callbacks; +#ifdef GPS_AT_COMMAND + // GpsTestResult test_result; +#endif + char in[ NMEA_MAX_SIZE+1 ]; +} NmeaReader; + + +static void +nmea_reader_update_utc_diff(NmeaReader* const r) +{ + time_t now = time(NULL); + struct tm tm_local; + struct tm tm_utc; + unsigned long time_local, time_utc; + + gmtime_r(&now, &tm_utc); + localtime_r(&now, &tm_local); + + + time_local = mktime(&tm_local); + + + time_utc = mktime(&tm_utc); + + r->utc_diff = time_utc - time_local; +} + + +static void +nmea_reader_init(NmeaReader* const r) +{ + memset(r, 0, sizeof(*r)); + + r->pos = 0; + r->overflow = 0; + r->utc_year = -1; + r->utc_mon = -1; + r->utc_day = -1; + r->utc_diff = 0; + r->callbacks.location_cb= NULL; + r->callbacks.status_cb= NULL; + r->callbacks.sv_status_cb= NULL; + r->sv_count = 0; + r->fix_mode = 0; /*no fix*/ + r->cb_status_changed = 0; + memset((void*)&r->sv_status_gps, 0x00, sizeof(r->sv_status_gps)); + memset((void*)&r->sv_status_gnss, 0x00, sizeof(r->sv_status_gnss)); + memset((void*)&r->in, 0x00, sizeof(r->in)); + + nmea_reader_update_utc_diff(r); +} + +GpsStatus sta; +static void +nmea_reader_set_callback(NmeaReader* const r, GpsCallbacks* const cbs) +{ + if (!r) { /*this should not happen*/ + return; + } else if (!cbs) { /*unregister the callback */ +#ifdef GPS_AT_COMMAND + if (MNL_AT_TEST_FLAG) { + DBG("**GPS AT Command test mode, unregister the test_cb!!"); + /* if (r->callbacks.test_cb != NULL) { + DBG("**Unregister test_callback!!"); + r->callbacks.test_cb = NULL; + } else { + DBG("**test_callback is NULL"); + }*/ + } +#endif + return; + } else {/*register the callback*/ + + if (MNL_AT_TEST_FLAG) { +#ifdef GPS_AT_COMMAND + // r->callbacks.test_cb = cbs->test_cb; + DBG("**GPS AT Command test mode!"); +#endif + } + + else + { + r->fix.flags = 0; + r->sv_count = 0; + r->sv_status_gps.num_svs = 0; + r->sv_status_gnss.num_svs = 0; + } + } +} + + +static int +nmea_reader_update_time(NmeaReader* const r, Token tok) +{ + int hour, minute; + double seconds; + struct tm tm; + struct tm tm_local; + time_t fix_time; + + if (tok.p + 6 > tok.end) + return -1; + + memset((void*)&tm, 0x00, sizeof(tm)); + if (r->utc_year < 0) { + // no date yet, get current one + time_t now = time(NULL); + gmtime_r(&now, &tm); + r->utc_year = tm.tm_year + 1900; + r->utc_mon = tm.tm_mon + 1; + r->utc_day = tm.tm_mday; + } + + hour = str2int(tok.p, tok.p+2); + minute = str2int(tok.p+2, tok.p+4); + seconds = str2float(tok.p+4, tok.end); + + tm.tm_hour = hour; + tm.tm_min = minute; + tm.tm_sec = (int) seconds; + tm.tm_year = r->utc_year - 1900; + tm.tm_mon = r->utc_mon - 1; + tm.tm_mday = r->utc_day; + tm.tm_isdst = -1; + + if (mktime(&tm) == (time_t)-1) + ERR("mktime error: %d %s\n", errno, strerror(errno)); + + fix_time = mktime(&tm); + localtime_r(&fix_time, &tm_local); + + fix_time += tm_local.tm_gmtoff; + DBG("fix_time: %d\n", fix_time); + r->fix.timestamp = (long long)fix_time * 1000; + return 0; +} + +static int +nmea_reader_update_date(NmeaReader* const r, Token date, Token time) +{ + Token tok = date; + int day, mon, year; + + if (tok.p + 6 != tok.end) { + ERR("date not properly formatted: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + day = str2int(tok.p, tok.p+2); + mon = str2int(tok.p+2, tok.p+4); + year = str2int(tok.p+4, tok.p+6) + 2000; + + if ((day|mon|year) < 0) { + ERR("date not properly formatted: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + + r->utc_year = year; + r->utc_mon = mon; + r->utc_day = day; + + return nmea_reader_update_time(r, time); +} + + +static double +convert_from_hhmm(Token tok) +{ + double val = str2float(tok.p, tok.end); + int degrees = (int)(floor(val) / 100); + double minutes = val - degrees*100.; + double dcoord = degrees + minutes / 60.0; + return dcoord; +} + + +static int +nmea_reader_update_latlong(NmeaReader* const r, + Token latitude, + char latitudeHemi, + Token longitude, + char longitudeHemi) +{ + double lat, lon; + Token tok; + + tok = latitude; + if (tok.p + 6 > tok.end) { + ERR("latitude is too short: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + lat = convert_from_hhmm(tok); + if (latitudeHemi == 'S') + lat = -lat; + + tok = longitude; + if (tok.p + 6 > tok.end) { + ERR("longitude is too short: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + lon = convert_from_hhmm(tok); + if (longitudeHemi == 'W') + lon = -lon; + + r->fix.flags |= GPS_LOCATION_HAS_LAT_LONG; + r->fix.latitude = lat; + r->fix.longitude = lon; + return 0; +} +/* this is the state of our connection to the daemon */ +typedef struct { + int init; + int fd; + GpsCallbacks callbacks; + pthread_t thread; +#if EPO_SUPPORT + pthread_t thread_epo; +#endif + int control[2]; + int sockfd; + int test_time; + int epoll_hd; + int flag; + int start_flag; + // int thread_exit_flag; +#if NEED_IPC_WITH_CODEC + int sock_codec; +#endif +#if EPO_SUPPORT + int epo_data_updated; + int thread_epo_exit_flag; +#endif +} GpsState; + +static GpsState _gps_state[1]; +#ifdef GPS_AT_COMMAND +/* +static int +nmea_reader_update_at_test_result(NmeaReader* const r, + int Err_Code, + int Success_Num, + int Completed_Num, + int Avg_CNo, + int Dev_CNo) +{ + if (r==NULL) { + DBG("**NmeaReader is NULL !!"); + return 0; + } + + r->test_result.error_code = Err_Code; + r->test_result.theta = 0; + r->test_result.phi = 0; + r->test_result.success_num = Success_Num; + r->test_result.completed_num = Completed_Num; + r->test_result.avg_cno = Avg_CNo; + r->test_result.dev_cno = Dev_CNo; + r->test_result.avg_speed = 0; + /* if (r->callbacks.test_cb) { + r->callbacks.test_cb(&r->test_result); + DBG("**AT command test set callback!!"); + } else { + VER("**AT Command test: no test result callback !!"); + } + return 0; +} +*/ +static void +sms_airtest_no_signal_report(int Err_Code, + int Success_Num, + int Completed_Num, + int Avg_CNo, + int Dev_CNo) +{ + GpsState* s = _gps_state; + // GpsTestResult result={0, }; + + if (test_mode_flag == 0) { + DBG("**Not SMS AirTest Mode, return!!"); + return; + } + +/* + result.error_code = Err_Code; + result.theta = 0; + result.phi = 0; + result.success_num = Success_Num; + result.completed_num = Completed_Num; + result.avg_cno = Avg_CNo; + result.dev_cno = Dev_CNo; + result.avg_speed = 0; */ + // s->callbacks.test_cb(&result); + + return; +} +#endif + +static int +nmea_reader_update_altitude(NmeaReader* const r, + Token altitude, + Token units) +{ + double alt; + Token tok = altitude; + + if (tok.p >= tok.end) + return -1; + + r->fix.flags |= GPS_LOCATION_HAS_ALTITUDE; + r->fix.altitude = str2float(tok.p, tok.end); + return 0; +} + + +static int +nmea_reader_update_bearing(NmeaReader* const r, + Token bearing) +{ + double alt; + Token tok = bearing; + + if (tok.p >= tok.end) + return -1; + + r->fix.flags |= GPS_LOCATION_HAS_BEARING; + r->fix.bearing = str2float(tok.p, tok.end); + return 0; +} + + +static int +nmea_reader_update_speed(NmeaReader* const r, + Token speed) +{ + double alt; + Token tok = speed; + + if (tok.p >= tok.end) + return -1; + + r->fix.flags |= GPS_LOCATION_HAS_SPEED; + + // Modify by ZQH to convert the speed unit from knot to m/s + // r->fix.speed = str2float(tok.p, tok.end); + r->fix.speed = str2float(tok.p, tok.end) / 1.942795467; + return 0; +} + + // Add by LCH for accuracy +static int +nmea_reader_update_accuracy(NmeaReader* const r, + Token accuracy) +{ + double alt; + Token tok = accuracy; + + if (tok.p >= tok.end) + return -1; + + r->fix.flags |= GPS_LOCATION_HAS_ACCURACY; + r->fix.accuracy = str2float(tok.p, tok.end); + return 0; +} +#ifdef GPS_AT_COMMAND +static void +gps_state_test_sms_airtest_no_result_report() +{ + char cmd = CMD_TEST_SMS_NO_RESULT; + GpsState* s = _gps_state; + int ret; + + do {ret = write(s->control[0], &cmd, 1);} + while (ret < 0 && errno == EINTR); + + if (ret != 1) + ERR("%s: could not send CMD_TEST_STOP command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} + +// No use now +void alarm_handler() { + DBG("Cannot detect GPS signal in 12s, stop test"); + if (MNL_AT_TEST_STATE != MNL_AT_TEST_UNKNOWN) { + mtk_gps_test_stop(); + Err_Code = (1 << 5); // 12secs timer timeout error bit. Brian test + result[0] = (1 << 5); // 12secs timer timeout error bit. + if (test_mode_flag) { + // soolim.you@lge.com, [SMSAirTest] + // In a weak GPS signal, If there is no CN measurement(alarming), + // null string should be reported using test_cb() + gps_state_test_sms_airtest_no_result_report(); + } + } +} + +static void +gps_at_command_search_satellite(NmeaReader* r) +{ + int i = 0, j = 0; + for (i = 0; i < r->sv_count; i++) { + if (prn[i] == hal_test_data.prn_num) { + DBG("**AT Command test SvID: %d", prn[i]); + if (snr[i] != 0) { + if (MNL_AT_SIGNAL_MODE && (!MNL_AT_SIGNAL_TEST_BEGIN)) { + DBG("Set state to MNL_AT_TEST_INPROGRESS for read result"); + MNL_AT_TEST_STATE = MNL_AT_TEST_INPROGRESS; + } + + if (MNL_AT_SIGNAL_MODE && MNL_AT_SIGNAL_TEST_BEGIN) { + DBG("Set state to MNL_AT_TEST_RESULT_DONE for read result"); + MNL_AT_TEST_STATE = MNL_AT_TEST_RESULT_DONE; + sig_suc_num = 1; + // sig_com_num = 1; + } + + if (MNL_AT_TEST_FLAG) { + Err_Code = 0; + DBG("cn = %d", cn); + CNo += snr[i]*10; + Dev_CNr[Success_Num] = snr[i]*10; + Success_Num++; + Avg_CNo = CNo / Success_Num; + // test_num++; + DBG("CNo = %d, Avg_CNo /= %d, Success_Num = %d", CNo, Avg_CNo, Success_Num); + } + cn = snr[i]*10; + DBG("cn = %d", cn); + } else { + DBG("**SNR is 0, ignore!!!"); + if (MNL_AT_CANCEL_ALARM == 1) { // It's not timeout, just no signal after 12s + if (MNL_AT_TEST_FLAG == 1) + test_num++; + } + sig_suc_num = 0; + } + + if (Success_Num != 0) { + for (j = 0; j < Success_Num; j++) { + DCNo += (Dev_CNr[j]-Avg_CNo) * (Dev_CNr[j]-Avg_CNo); + DBG("Dev_CNr[%d] = %d, Dev_CNo2 += %d", j, Dev_CNr[j], DCNo); + } + Dev_CNo = DCNo / Success_Num; + DCNo = 0; + Dev_CNo = sqrt(Dev_CNo); + } + DBG("**AT Command find SvID: %d, exit", prn[i]); + break; + } else { + DBG("**AT Command ignore SvID: %d", prn[i]); + } + } +} + +static void +gps_at_command_test_proc(NmeaReader* const r) { + // For AT command test + int i = 0; + int j = 0; + int time_diff; + time_t current_time; + + if (MNL_AT_TEST_STATE != MNL_AT_TEST_DONE) { + DBG("**AT Command test mode!!"); + + if (MNL_AT_SIGNAL_MODE == 1) { + if (MNL_AT_SIGNAL_TEST_BEGIN) { + gps_at_command_search_satellite(r); + DBG("Update test result per second"); + result[0] = 0; + result[3] = sig_suc_num; + result[4] = 1; + result[5]= cn; + DBG("result[5] = %d", result[5]); + result[6] = 0; + } else { + DBG("Wait AT%%%GNSS=1..."); + return; + } + } else { + DBG("Not in MNL_AT_SIGNAL_MODE"); + DBG("**AT Command Continue, search satellites..."); + // Search satellites + gps_at_command_search_satellite(r); + } + + } else { + DBG("**AT Command test, test mode is MNL_AT_TEST_DONE"); + } +} +#endif + +static int +nmea_reader_update_sv_status_gps(NmeaReader* r, int sv_index, + int id, Token elevation, + Token azimuth, Token snr) +{ + // int prn = str2int(id.p, id.end); + int prn = id; + if ((prn <= 0) || (prn < 65 && prn > GPS_MAX_SVS)|| (prn > 96) || (r->sv_count >= GPS_MAX_SVS)) { + VER("sv_status_gps: ignore (%d)", prn); + return 0; + } + sv_index = r->sv_count+r->sv_status_gps.num_svs; + if (GPS_MAX_SVS <= sv_index) { + ERR("ERR: sv_index=[%d] is larger than GPS_MAX_SVS.\n", sv_index); + return 0; + } + r->sv_status_gps.sv_list[sv_index].prn = prn; + r->sv_status_gps.sv_list[sv_index].snr = str2float(snr.p, snr.end); + r->sv_status_gps.sv_list[sv_index].elevation = str2int(elevation.p, elevation.end); + r->sv_status_gps.sv_list[sv_index].azimuth = str2int(azimuth.p, azimuth.end); + r->sv_count++; + VER("sv_status_gps(%2d): %2d, %2f, %3f, %2f", sv_index, + r->sv_status_gps.sv_list[sv_index].prn, r->sv_status_gps.sv_list[sv_index].elevation, + r->sv_status_gps.sv_list[sv_index].azimuth, r->sv_status_gps.sv_list[sv_index].snr); + return 0; +} + +static int +nmea_reader_update_sv_status_gnss(NmeaReader* r, int sv_index, + int id, Token elevation, + Token azimuth, Token snr) +{ + // int prn = str2int(id.p, id.end); + int prn = id; + + if ((prn <= 0) || (prn < 65 && prn > GPS_MAX_SVS)|| ((prn > 96) && (prn < 200)) + || (prn > 232) || (r->sv_count >= GNSS_MAX_SVS)) { + VER("sv_status_gnss: ignore (%d)", prn); + return 0; + } + sv_index = r->sv_count+r->sv_status_gnss.num_svs; + if (GNSS_MAX_SVS <= sv_index) { + ERR("ERR: sv_index=[%d] is larger than GNSS_MAX_SVS.\n", sv_index); + return 0; + } + r->sv_status_gnss.sv_list[sv_index].prn = prn; + r->sv_status_gnss.sv_list[sv_index].snr = str2float(snr.p, snr.end); + r->sv_status_gnss.sv_list[sv_index].elevation = str2int(elevation.p, elevation.end); + r->sv_status_gnss.sv_list[sv_index].azimuth = str2int(azimuth.p, azimuth.end); + if (1 == sv_used_in_fix[prn]) { + r->sv_status_gnss.sv_list[sv_index].used_in_fix = true; + } else { + r->sv_status_gnss.sv_list[sv_index].used_in_fix = false; + } + r->sv_count++; + VER("sv_status_gnss(%2d): %2d, %2f, %3f, %2f, %2d", + sv_index, r->sv_status_gnss.sv_list[sv_index].prn, + r->sv_status_gnss.sv_list[sv_index].elevation, + r->sv_status_gnss.sv_list[sv_index].azimuth, + r->sv_status_gnss.sv_list[sv_index].snr, + r->sv_status_gnss.sv_list[sv_index].used_in_fix); + return 0; +} + +static void +nmea_reader_parse(NmeaReader* const r) +{ + /* we received a complete sentence, now parse it to generate + * a new GPS fix... + */ +#ifdef GPS_AT_COMMAND + int time_diff; + time_t current_time; + static int prev_success_num = 0; + + if ((1 == MNL_AT_TEST_FLAG) ||(1 == MNL_AT_SIGNAL_TEST_BEGIN)) { + // (1 == MNL_AT_SIGNAL_MODE)) { + DBG("MNL_AT_TEST_FLAG = %d, MNL_AT_SIGNAL_TEST_BEGIN = %d", MNL_AT_TEST_FLAG, MNL_AT_SIGNAL_TEST_BEGIN); + time(¤t_time); + time_diff = current_time - start_time; + if (time_diff >= hal_test_data.time_delay) { + DBG("MNL_AT_SET_ALARM == 1, gps_nmea_end_tag(%d)", gps_nmea_end_tag); + if (gps_nmea_end_tag == 1) { + int test_stopped = 0; + DBG("Success_Num = %d, Prev_Success_Num = %d, Wait_Num = %d, \ + Failure_Num = %d, Completed_Num = %d, Avg_CNo = %d, \ + Dev_CNo = %d, Err_Code = %d, MNL_AT_TEST_STATE = %d", + Success_Num, prev_success_num, Wait_Num, Failure_Num, Completed_Num, + Avg_CNo, Dev_CNo, Err_Code, MNL_AT_TEST_STATE); + if (Success_Num > 0) { + if (prev_success_num == Success_Num) { + Failure_Num++; + } + Completed_Num = Success_Num + Failure_Num; + if (Completed_Num == hal_test_data.test_num) { + // 1. Call reportTestResult callback with detected SNR info + sms_airtest_no_signal_report(Err_Code, Success_Num, Completed_Num, Avg_CNo, Dev_CNo); + // 2. Test Stop + test_stopped = 1; + } + } + else { + Wait_Num++; + if (Wait_Num == MAX_VALID_STATUS_WAIT_COUNT) { + // 1. Call reportTestResult callback with <32, 0, 0, 0, 0, 0> + DBG("TimeOut!! Wait_Num = %d", Wait_Num); + Completed_Num = hal_test_data.test_num; + Err_Code = (1 << 5); + Completed_Num = 1; + sms_airtest_no_signal_report(Err_Code, Success_Num, Completed_Num, 0, 0); + // 2. Test Stop + test_stopped = 1; + } + } + prev_success_num = Success_Num; + + if (test_stopped == 1) { + result[0] = Err_Code; + result[3] = Success_Num; + result[4] = Completed_Num; + result[5] = Avg_CNo; + result[6] = Dev_CNo; + Wait_Num = 0; + MNL_AT_TEST_STATE = MNL_AT_TEST_DONE; + + DBG("**AT Command test_start done, Success_Num = %d, Completed_Num = %d, \ + Avg_CNo = %d, Dev_CNo = %d, Err_Code = %d, test_num = %d, MNL_AT_TEST_STATE = %d", + Success_Num, Completed_Num, Avg_CNo, Dev_CNo, Err_Code, test_num, MNL_AT_TEST_STATE); + Err_Code = 1; + if ((MNL_AT_TEST_STATE == MNL_AT_TEST_DONE) && (1 == MNL_AT_TEST_FLAG)) { + DBG("** AT Command test done, stop GPS driver **"); + mtk_gps_test_stop(); + Failure_Num = 0; + prev_success_num = 0; + } + } + } + + } else { // 2sec waiting + DBG("static time, return..."); + return; + } + } +#endif + NmeaTokenizer tzer[1]; + Token tok; + Token mtok; + SV_TYPE sv_type = 0; + +#if NEMA_DEBUG + DBG("Received: '%.*s'", r->pos, r->in); +#endif + if (r->pos < 9) { + ERR("Too short. discarded. '%.*s'", r->pos, r->in); + return; + } + if (r->pos < sizeof(r->in)) { + nmea_tokenizer_init(tzer, r->in, r->in + r->pos); + } +#if NEMA_DEBUG + { + int n; + DBG("Found %d tokens", tzer->count); + for (n = 0; n < tzer->count; n++) { + Token tok = nmea_tokenizer_get(tzer, n); + DBG("%2d: '%.*s'", n, tok.end-tok.p, tok.p); + } + } +#endif + + tok = nmea_tokenizer_get(tzer, 0); + if (tok.p + 5 > tok.end) { + ERR("sentence id '%.*s' too short, ignored.", tok.end-tok.p, tok.p); + return; + } + + // ignore first two characters. + mtok.p = tok.p; // Mark the first two char for GPS, GLONASS, BDS SV parse. + if (!memcmp(mtok.p, "BD", 2)) { + sv_type = BDS_SV; + DBG("BDS SV type"); + } + tok.p += 2; + if (!memcmp(tok.p, "GGA", 3)) { + // GPS fix + Token tok_time = nmea_tokenizer_get(tzer, 1); + Token tok_latitude = nmea_tokenizer_get(tzer, 2); + Token tok_latitudeHemi = nmea_tokenizer_get(tzer, 3); + Token tok_longitude = nmea_tokenizer_get(tzer, 4); + Token tok_longitudeHemi = nmea_tokenizer_get(tzer, 5); + Token tok_altitude = nmea_tokenizer_get(tzer, 9); + Token tok_altitudeUnits = nmea_tokenizer_get(tzer, 10); + + nmea_reader_update_time(r, tok_time); + nmea_reader_update_latlong(r, tok_latitude, + tok_latitudeHemi.p[0], + tok_longitude, + tok_longitudeHemi.p[0]); + nmea_reader_update_altitude(r, tok_altitude, tok_altitudeUnits); + + } else if ((callback_backup_mtk.base.size == sizeof(GpsCallbacks_mtk)) && + (!memcmp(mtok.p, "GPGSA", 5)||!memcmp(mtok.p, "BDGSA", 5)||!memcmp(mtok.p, "GLGSA", 5))) { + Token tok_fix = nmea_tokenizer_get(tzer, 2); + int idx, max = 12; /*the number of satellites in GPGSA*/ + + r->fix_mode = str2int(tok_fix.p, tok_fix.end); + + if (LOC_FIXED(r)) { /* 1: No fix; 2: 2D; 3: 3D*/ + for (idx = 0; idx < max; idx++) { + Token tok_satellite = nmea_tokenizer_get(tzer, idx+3); + if (tok_satellite.p == tok_satellite.end) { + DBG("GSA: found %d active satellites\n", idx); + break; + } + int sate_id = str2int(tok_satellite.p, tok_satellite.end); + if (sv_type == BDS_SV) { + sate_id += 200; + } + if (sate_id >= 1 && sate_id <= 32) { // GP + sv_used_in_fix[sate_id] = 1; + } else if (sate_id >= 193 && sate_id <= 197) { + sv_used_in_fix[sate_id] = 0; + DBG("[debug mask]QZSS, just ignore. satellite id is %d\n ", sate_id); + continue; + } else if (sate_id >= 65 && sate_id <= 96) { // GL + sv_used_in_fix[sate_id] = 1; + } else if (sate_id >= 201 && sate_id <= 232) { // BD + sv_used_in_fix[sate_id] = 1; + + } + else { + VER("GSA: invalid sentence, ignore!!"); + break; + } + DBG("GSA:sv_used_in_fix[%d] = %d\n", sate_id, sv_used_in_fix[sate_id]); + } + } + } else if ((callback_backup_mtk.base.size == sizeof(GpsCallbacks)) && + (!memcmp(mtok.p, "GPGSA", 5))) { + Token tok_fix = nmea_tokenizer_get(tzer, 2); + int idx, max = 12; /*the number of satellites in GPGSA*/ + + r->fix_mode = str2int(tok_fix.p, tok_fix.end); + r->sv_status_gps.used_in_fix_mask = 0; + if (LOC_FIXED(r)) { /* 1: No fix; 2: 2D; 3: 3D*/ + for (idx = 0; idx < max; idx++) { + Token tok_satellite = nmea_tokenizer_get(tzer, idx+3); + if (tok_satellite.p == tok_satellite.end) { + DBG("GSA: found %d active satellites\n", idx); + break; + } + int sate_id = str2int(tok_satellite.p, tok_satellite.end); + if (sate_id >= 1 && sate_id <= 32) { + r->sv_status_gps.used_in_fix_mask |= (1 << (sate_id-1)); + } else { + if (sate_id >= 193 && sate_id <= 197) { + DBG("[debug mask]QZSS, just ignore. satellite id is %d\n ", sate_id); + continue; + } /*else { + r->sv_status_gps.used_in_fix_mask = 0; + DBG("[debug mask] satellite is invalid & mask = %d\n", + r->sv_status_gps.used_in_fix_mask); + }*/ + VER("GPGSA: invalid sentence, ignore!!"); + break; + } + } + } + } + // VER("GPGSA: mask 0x%x", r->sv_status_gps.used_in_fix_mask); + else if (!memcmp(tok.p, "RMC", 3)) { + Token tok_time = nmea_tokenizer_get(tzer, 1); + Token tok_fixStatus = nmea_tokenizer_get(tzer, 2); + Token tok_latitude = nmea_tokenizer_get(tzer, 3); + Token tok_latitudeHemi = nmea_tokenizer_get(tzer, 4); + Token tok_longitude = nmea_tokenizer_get(tzer, 5); + Token tok_longitudeHemi = nmea_tokenizer_get(tzer, 6); + Token tok_speed = nmea_tokenizer_get(tzer, 7); + Token tok_bearing = nmea_tokenizer_get(tzer, 8); + Token tok_date = nmea_tokenizer_get(tzer, 9); + + VER("in RMC, fixStatus=%c", tok_fixStatus.p[0]); + if (tok_fixStatus.p[0] == 'A') + { + nmea_reader_update_date(r, tok_date, tok_time); + + nmea_reader_update_latlong(r, tok_latitude, + tok_latitudeHemi.p[0], + tok_longitude, + tok_longitudeHemi.p[0]); + + nmea_reader_update_bearing(r, tok_bearing); + nmea_reader_update_speed(r, tok_speed); + } + } else if ((callback_backup_mtk.base.size == sizeof(GpsCallbacks_mtk)) && + (!memcmp(tok.p, "GSV", 3))) { + Token tok_num = nmea_tokenizer_get(tzer, 1); // number of messages + Token tok_seq = nmea_tokenizer_get(tzer, 2); // sequence number + Token tok_cnt = nmea_tokenizer_get(tzer, 3); // Satellites in view + int num = str2int(tok_num.p, tok_num.end); + int seq = str2int(tok_seq.p, tok_seq.end); + int cnt = str2int(tok_cnt.p, tok_cnt.end); + int sv_base = (seq - 1)*NMEA_MAX_SV_INFO; + int sv_num = cnt - sv_base; + int idx, base = 4, base_idx; + if (sv_num > NMEA_MAX_SV_INFO) + sv_num = NMEA_MAX_SV_INFO; + if (seq == 1) /*if sequence number is 1, a new set of GSV will be parsed*/ + r->sv_count = 0; + for (idx = 0; idx < sv_num; idx++) { + base_idx = base*(idx+1); + Token tok_id = nmea_tokenizer_get(tzer, base_idx+0); + int sv_id = str2int(tok_id.p, tok_id.end); + if (sv_type == BDS_SV) { + sv_id += 200; + DBG("It is BDS SV: %d", sv_id); + } + Token tok_ele = nmea_tokenizer_get(tzer, base_idx+1); + Token tok_azi = nmea_tokenizer_get(tzer, base_idx+2); + Token tok_snr = nmea_tokenizer_get(tzer, base_idx+3); +#ifdef GPS_AT_COMMAND + prn[r->sv_count] = str2int(tok_id.p, tok_id.end); + snr[r->sv_count] = (int)str2float(tok_snr.p, tok_snr.end); +#endif + nmea_reader_update_sv_status_gnss(r, sv_base+idx, sv_id, tok_ele, tok_azi, tok_snr); + } + if (seq == num) { + if (r->sv_count <= cnt) { + DBG("r->sv_count = %d", r->sv_count); + r->sv_status_gnss.num_svs += r->sv_count; + + +#ifdef GPS_AT_COMMAND + if ((1 == MNL_AT_TEST_FLAG) || (1 == MNL_AT_SIGNAL_MODE)) { + DBG("MNL_AT_TEST_FLAG = %d, MNL_AT_SIGNAL_MODE = %d", MNL_AT_TEST_FLAG, MNL_AT_SIGNAL_MODE); + gps_at_command_test_proc(r); + } +#endif + } else { + ERR("GPGSV incomplete (%d/%d), ignored!", r->sv_count, cnt); + r->sv_count = r->sv_status_gnss.num_svs = 0; + } + } + } else if ((callback_backup_mtk.base.size == sizeof(GpsCallbacks)) && + (!memcmp(mtok.p, "GPGSV", 5)||!memcmp(mtok.p, "GLGSV", 5))) { + Token tok_num = nmea_tokenizer_get(tzer, 1); // number of messages + Token tok_seq = nmea_tokenizer_get(tzer, 2); // sequence number + Token tok_cnt = nmea_tokenizer_get(tzer, 3); // Satellites in view + int num = str2int(tok_num.p, tok_num.end); + int seq = str2int(tok_seq.p, tok_seq.end); + int cnt = str2int(tok_cnt.p, tok_cnt.end); + int sv_base = (seq - 1)*NMEA_MAX_SV_INFO; + int sv_num = cnt - sv_base; + int idx, base = 4, base_idx; + if (sv_num > NMEA_MAX_SV_INFO) + sv_num = NMEA_MAX_SV_INFO; + if (seq == 1) /*if sequence number is 1, a new set of GSV will be parsed*/ + r->sv_count = 0; + for (idx = 0; idx < sv_num; idx++) { + base_idx = base*(idx+1); + Token tok_id = nmea_tokenizer_get(tzer, base_idx+0); + int sv_id = str2int(tok_id.p, tok_id.end); + if (sv_type == BDS_SV) { + sv_id += 200; + DBG("It is BDS SV: %d", sv_id); + } + Token tok_ele = nmea_tokenizer_get(tzer, base_idx+1); + Token tok_azi = nmea_tokenizer_get(tzer, base_idx+2); + Token tok_snr = nmea_tokenizer_get(tzer, base_idx+3); +#ifdef GPS_AT_COMMAND + prn[r->sv_count] = str2int(tok_id.p, tok_id.end); + snr[r->sv_count] = (int)str2float(tok_snr.p, tok_snr.end); +#endif + nmea_reader_update_sv_status_gps(r, sv_base+idx, sv_id, tok_ele, tok_azi, tok_snr); + } + if (seq == num) { + if (r->sv_count <= cnt) { + r->sv_status_gps.num_svs += r->sv_count; + r->sv_status_gps.almanac_mask = 0; + r->sv_status_gps.ephemeris_mask = 0; +#ifdef GPS_AT_COMMAND + if ((1 == MNL_AT_TEST_FLAG) || (1 == MNL_AT_SIGNAL_MODE)) { + DBG("MNL_AT_TEST_FLAG = %d, MNL_AT_SIGNAL_MODE = %d", MNL_AT_TEST_FLAG, MNL_AT_SIGNAL_MODE); + gps_at_command_test_proc(r); + } +#endif + } else { + ERR("GPGSV incomplete (%d/%d), ignored!", r->sv_count, cnt); + r->sv_count = r->sv_status_gps.num_svs = 0; + } + } + } + // Add for Accuracy + else if (!memcmp(tok.p, "ACCURACY", 8)) { + if ((r->fix_mode == 3) || (r->fix_mode == 2)) { + Token tok_accuracy = nmea_tokenizer_get(tzer, 1); + nmea_reader_update_accuracy(r, tok_accuracy); + DBG("GPS get accuracy from driver:%f\n", r->fix.accuracy); + } + else { + DBG("GPS get accuracy failed, fix mode:%d\n", r->fix_mode); + } + } + else { + tok.p -= 2; + VER("unknown sentence '%.*s", tok.end-tok.p, tok.p); + } + if (!LOC_FIXED(r)) { + VER("Location is not fixed, ignored callback\n"); + } else if (r->fix.flags != 0 && gps_nmea_end_tag) { +#if NEMA_DEBUG + char temp[256]; + char* p = temp; + char* end = p + sizeof(temp); + struct tm utc; + + p += snprintf(p, end-p, "sending fix"); + if (r->fix.flags & GPS_LOCATION_HAS_LAT_LONG) { + p += snprintf(p, end-p, " lat=%g lon=%g", r->fix.latitude, r->fix.longitude); + } + if (r->fix.flags & GPS_LOCATION_HAS_ALTITUDE) { + p += snprintf(p, end-p, " altitude=%g", r->fix.altitude); + } + if (r->fix.flags & GPS_LOCATION_HAS_SPEED) { + p += snprintf(p, end-p, " speed=%g", r->fix.speed); + } + if (r->fix.flags & GPS_LOCATION_HAS_BEARING) { + p += snprintf(p, end-p, " bearing=%g", r->fix.bearing); + } + if (r->fix.flags & GPS_LOCATION_HAS_ACCURACY) { + p += snprintf(p, end-p, " accuracy=%g", r->fix.accuracy); + DBG("GPS accuracy=%g\n", r->fix.accuracy); + } + gmtime_r((time_t*) &r->fix.timestamp, &utc); + p += snprintf(p, end-p, " time=%s", asctime(&utc)); + VER(temp); +#endif + if (get_prop()) { + char pos[64] = {0}; + sprintf(pos, "%lf, %lf", r->fix.latitude, r->fix.longitude); + DBG("gps postion str = %s", pos); + char buff[1024] = {0}; + int offset = 0; + DBG("gps postion lati= %f, longi = %f", r->fix.latitude, r->fix.longitude); + buff_put_int(MNL_CMD_GPS_LOG_WRITE, buff, &offset); + buff_put_string(pos, buff, &offset); + mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buff, sizeof(buff)); + } + callback_backup_mtk.base.location_cb(&r->fix); + nlp_context fix_location; + fix_location.latitude = r->fix.latitude; + fix_location.longitude = r->fix.longitude; + fix_location.accuracy = r->fix.accuracy; + fix_location.type = 1; + fix_location.started = started; + fix_location.ts.tv_sec = r->fix.timestamp/1000; + fix_location.ts.tv_nsec = (r->fix.timestamp%1000) * 1000*1000; + mtk_gps_update_location(&fix_location); + + r->fix.flags = 0; + } + + if (callback_backup_mtk.base.size == sizeof(GpsCallbacks_mtk)) { + if (r->sv_status_gnss.num_svs != 0 && gps_nmea_end_tag) { + DBG("r->sv_status_gnss.num_svs = %d, gps_nmea_end_tag = %d", r->sv_status_gnss.num_svs, gps_nmea_end_tag); + r->sv_status_gnss.size = sizeof(GnssSvStatus); + callback_backup_mtk.base.gnss_sv_status_cb(&r->sv_status_gnss); + r->sv_count = r->sv_status_gnss.num_svs = 0; + memset(sv_used_in_fix, 0, 256*sizeof(int)); + } + } else { + if (r->sv_status_gps.num_svs != 0 && gps_nmea_end_tag) { + int idx; + DBG("r->sv_status_gps.num_svs = %d, gps_nmea_end_tag = %d", r->sv_status_gps.num_svs, gps_nmea_end_tag); + for (idx = 0; idx < r->sv_status_gps.num_svs; idx++) { + int prn = r->sv_status_gps.sv_list[idx].prn; + if (prn < 1 || ((prn > 32) && (prn < 65))|| prn > 96) { + ERR("Satellite invalid id: %d", prn); + } else { + DBG("Satellite (%2d) = %2f, %3f, %2f", r->sv_status_gps.sv_list[idx].prn, + r->sv_status_gps.sv_list[idx].elevation, r->sv_status_gps.sv_list[idx].azimuth, + r->sv_status_gps.sv_list[idx].snr); + } + callback_backup_mtk.base.sv_status_cb(&r->sv_status_gps); + r->sv_count = r->sv_status_gps.num_svs = 0; + r->sv_status_gps.used_in_fix_mask = 0; + } + } + } +} + + +static void +nmea_reader_addc(NmeaReader* const r, int c) +{ + if (r->overflow) { + r->overflow = (c != '\n'); + return; + } + + if ((r->pos >= (int) sizeof(r->in)-1 ) || (r->pos < 0)) { + r->overflow = 1; + r->pos = 0; + DBG("nmea sentence overflow\n"); + return; + } + + r->in[r->pos] = (char)c; + r->pos += 1; + + if (c == '\n') { + nmea_reader_parse(r); + + DBG("start nmea_cb\n"); + callback_backup_mtk.base.nmea_cb(r->fix.timestamp, r->in, r->pos); + r->pos = 0; + } +} + + +static void +gps_state_done(GpsState* s) +{ + char cmd = CMD_QUIT; + + write(s->control[0], &cmd, 1); + get_condition(&lock_for_sync[M_CLEANUP]); + close(s->control[0]); s->control[0] = -1; + close(s->control[1]); s->control[1] = -1; + close(s->fd); s->fd = -1; + close(s->sockfd); s->sockfd = -1; + close(s->epoll_hd); s->epoll_hd = -1; +#if NEED_IPC_WITH_CODEC + close(s->sock_codec); s->sock_codec = -1; +#endif + s->init = 0; + s->test_time -= 1; + return; +} + + +static void +gps_state_start(GpsState* s) +{ + char cmd = CMD_START; + int ret; + + do { ret = write(s->control[0], &cmd, 1); } + while (ret < 0 && errno == EINTR); + + if (ret != 1) + ERR("%s: could not send CMD_START command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} +#ifdef GPS_AT_COMMAND +static void +gps_state_test_start(GpsState* s) +{ + char cmd = CMD_TEST_START; + int ret; + + do { ret = write(s->control[0], &cmd, 1); } + while (ret < 0 && errno == EINTR); + + if (ret != 1) + ERR("%s: could not send CMD_TEST_START command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} +static void +gps_state_test_stop(GpsState* s) +{ + char cmd = CMD_TEST_STOP; + int ret; + + do { ret = write(s->control[0], &cmd, 1); } + while (ret < 0 && errno == EINTR); + + if (ret != 1) + ERR("%s: could not send CMD_TEST_STOP command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} +#endif + +static void +gps_state_stop(GpsState* s) +{ + char cmd = CMD_STOP; + int ret; + + do { ret = write(s->control[0], &cmd, 1); } + while (ret < 0 && errno == EINTR); + + if (ret != 1) + ERR("%s: could not send CMD_STOP command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} + +static void +gps_state_restart(GpsState* s) +{ + char cmd = CMD_RESTART; + int ret; + + do {ret = write(s->control[0], &cmd, 1);} + while (ret < 0 && errno == EINTR); + + if (ret != 1) + ERR("%s: could not send CMD_RESTART command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} +#if EPO_SUPPORT +int get_val(char *pStr, char** ppKey, char** ppVal) +{ + int len = (int)strlen(pStr); + char *end = pStr + len; + char *key = NULL, *val = NULL; + int stage = 0; + + DBG("pStr = %s, len=%d!!\n", pStr, len); + + if (!len) { + return -1; // no data + } else if (pStr[0] == '#') { /*ignore comment*/ + *ppKey = *ppVal = NULL; + return 0; + } + else if (pStr[len-1] != '\n') { + if (len >= GPS_CONF_FILE_SIZE-1) { + DBG("buffer is not enough!!\n"); + return -1; + } else { + pStr[len] = '\n'; + } + } + key = pStr; + + DBG("key = %s!!\n", key); + while ((*pStr != '=') && (pStr < end)) pStr++; + if (pStr >= end) { + DBG("'=' is not found!!\n"); + return -1; // format error + } + + *pStr++ = '\0'; + while (IS_SPACE(*pStr) && (pStr < end)) pStr++; // skip space chars + val = pStr; + while (!IS_SPACE(*pStr) && (pStr < end)) pStr++; + *pStr = '\0'; + *ppKey = key; + *ppVal = val; + + DBG("val = %s!!\n", val); + return 0; + +} + +static int +gps_download_epo_enable(void) +{ + char result[GPS_CONF_FILE_SIZE] = {0}; + + FILE *fp = fopen(EPO_CONTROL_FILE_PATH, "r"); + char *key, *val; + if (!fp) { + // DBG("%s: open %s fail!\n", __FUNCTION__, EPO_CONTROL_FILE_PATH); + return 1; + } + + while (fgets(result, sizeof(result), fp)) { + if (get_val(result, &key, &val)) { + DBG("%s: Get data fails!!\n", __FUNCTION__); + fclose(fp); + return 1; + } + if (!key || !val) + continue; + if (!strcmp(key, "EPO_ENABLE")) { + int len = strlen(val)-1; + + DBG("gps_epo_enablebg = %d, len =%d\n", gps_epo_enable, len); + gps_epo_enable = str2int(val, val+len); // *val-'0'; + if ((gps_epo_enable != 1) && (gps_epo_enable != 0)) { + gps_epo_enable = 1; + } + DBG("gps_epo_enableend = %d\n", gps_epo_enable); + } + if (!strcmp(key, "DW_DAYS")) { + int len = strlen(val)-1; + gps_epo_download_days = str2int(val, val+len); // *val-'0'; + if (gps_epo_download_days > 30 || gps_epo_download_days < 0) { + gps_epo_download_days = 30; + } + } + if (!strcmp(key, "GPS_EPO_PERIOD")) { + int len = strlen(val)-1; + gps_epo_period = str2int(val, val+len); // *val-'0'; + if ((gps_epo_period != 30) && (gps_epo_period != 3) && (gps_epo_period != 15)) { + gps_epo_period = 3; + } + } + if (!strcmp(key, "WIFI_EPO_PERIOD")) { + int len = strlen(val)-1; + wifi_epo_period = str2int(val, val+len); // *val-'0'; + if ((wifi_epo_period != 30) && (wifi_epo_period != 3) && (wifi_epo_period != 15)) { + wifi_epo_period = 1; + } + } + if (!strcmp(key, "EPO_WIFI_TRIGGER")) { + int len = strlen(val)-1; + DBG("gps_epo_wifi_triggerbg = %d, len =%d\n", gps_epo_wifi_trigger, len); + gps_epo_wifi_trigger = str2int(val, val+len); // *val-'0'; + if ((gps_epo_wifi_trigger != 1) && (gps_epo_wifi_trigger != 0)) { + gps_epo_wifi_trigger = 1; + } + DBG("gps_epo_wifi_triggerend = %d\n", gps_epo_wifi_trigger); + } + DBG("gps_epo_enable = %d, gps_epo_period = %d, \ + wifi_epo_period = %d, gps_epo_wifi_trigger = %d\n", gps_epo_enable, gps_epo_period, + wifi_epo_period, gps_epo_wifi_trigger); + } + fclose(fp); + return gps_epo_enable; +} + +static void +gps_download_epo_file_name(int count) +{ + // DBG("count is %d\n", count); + if (gps_epo_type == 1) { + if (count == 0) { + strcpy(gps_epo_file_name, "EPO_GPS_3_1.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_1.MD5"); + } else if (count == 1) { + strcpy(gps_epo_file_name, "EPO_GPS_3_2.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_2.MD5"); + } else if (count == 2) { + strcpy(gps_epo_file_name, "EPO_GPS_3_3.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_3.MD5"); + } else if (count == 3) { + strcpy(gps_epo_file_name, "EPO_GPS_3_4.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_4.MD5"); + } else if (count == 4) { + strcpy(gps_epo_file_name, "EPO_GPS_3_5.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_5.MD5"); + } else if (count == 5) { + strcpy(gps_epo_file_name, "EPO_GPS_3_6.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_6.MD5"); + } else if (count == 6) { + strcpy(gps_epo_file_name, "EPO_GPS_3_7.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_7.MD5"); + } else if (count == 7) { + strcpy(gps_epo_file_name, "EPO_GPS_3_8.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_8.MD5"); + } else if (count == 8) { + strcpy(gps_epo_file_name, "EPO_GPS_3_9.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_9.MD5"); } + else if (count == 9) { + strcpy(gps_epo_file_name, "EPO_GPS_3_10.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GPS_3_10.MD5"); + } + DBG("download request for file %d, gps_epo_file_name=%s\n", gps_epo_file_count, gps_epo_file_name); + } + else if (gps_epo_type == 0) { + if (count == 0) { + strcpy(gps_epo_file_name, "EPO_GR_3_1.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_1.MD5"); + } else if (count == 1) { + strcpy(gps_epo_file_name, "EPO_GR_3_2.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_2.MD5"); + } else if (count == 2) { + strcpy(gps_epo_file_name, "EPO_GR_3_3.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_3.MD5"); + } else if (count == 3) { + strcpy(gps_epo_file_name, "EPO_GR_3_4.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_4.MD5"); + } else if (count == 4) { + strcpy(gps_epo_file_name, "EPO_GR_3_5.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_5.MD5"); + } else if (count == 5) { + strcpy(gps_epo_file_name, "EPO_GR_3_6.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_6.MD5"); + } else if (count == 6) { + strcpy(gps_epo_file_name, "EPO_GR_3_7.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_7.MD5"); + } else if (count == 7) { + strcpy(gps_epo_file_name, "EPO_GR_3_8.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_8.MD5"); + } else if (count == 8) { + strcpy(gps_epo_file_name, "EPO_GR_3_9.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_9.MD5"); + } else if (count == 9) { + strcpy(gps_epo_file_name, "EPO_GR_3_10.DAT"); + strcpy(gps_epo_md_file_name, "EPO_GR_3_10.MD5"); + } + DBG("download request for file %d, gps_epo_file_name=%s, gps_epo_md_file_name=%s\n", + gps_epo_file_count, gps_epo_file_name, gps_epo_md_file_name); + } +} + +static void +gps_download_epo(GpsState* s) +{ +#if 0 + char cmd = CMD_DOWNLOAD; + int ret; + + do { ret = write(s->control[0], &cmd, 1); } + while (ret < 0 && errno == EINTR); + + if (ret != 1) + ERR("%s: could not send CMD_STOP command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +#else + s->epo_data_updated = 1; + gps_epo_file_count = 0; +#endif +} +#endif +#ifdef GPS_AT_COMMAND +void +at_command_send_ack(char* ack, int len) { + GpsState* s = _gps_state; + + remotelen = sizeof(remote); + if (sendto(s->sockfd, ack, len, 0, (struct sockaddr*)&remote, remotelen) < 0) { + DBG("** AT Command send ack to USB failed: %s**", strerror(errno)); + } else { + DBG("** AT Command send ack to USB sucess **"); + } +} + +void +at_command_send_cno(char* cmdline) { + GpsState* s = _gps_state; + char* command = cmdline; + /* + if (MNL_AT_SIGNAL_MODE && MNL_AT_SIGNAL_TEST_BEGIN) { + DBG("** AT signal mode, report SNR **"); + char buff[10]; + sprintf(buff, "%d, NA", CNo); + DBG("** result = %s**", buff); + at_command_send_ack(buff, sizeof(buff)); + return; + }*/ + int ret = mtk_gps_test_inprogress(); + if (MNL_AT_TEST_INPROGRESS == ret) { + DBG("** AT Command test is inprogress **"); + char buff[] = "GNSS Test In Progress"; + at_command_send_ack(buff, sizeof(buff)); + return; + } + + + if (MNL_AT_SIGNAL_MODE == 1) { + if (0 == cn) { + DBG("** AT Command, cn is invalid **"); + char buff[] = "0, NA"; + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT Command, CN is valid **"); + char buff[10]; + // sprintf(buff, "%d", Avg_CNo/10); // unit of AT%GNSS, AT%GNSS=? is 1dB + sprintf(buff, "%d", cn/10); + if (!memcmp(command, GNSS_OP, 7)) { + DBG("** GNSS test, report CN and NA**"); + int size = strlen(buff); + strcpy(buff+size, ", NA"); + DBG("** result = %s**", buff); + } + at_command_send_ack(buff, sizeof(buff)); + } + } else { + if (0 == Avg_CNo) { + DBG("** AT Command, cn is invalid **"); + char buff[] = "0, NA"; + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT Command, CN is valid **"); + char buff[10]; + sprintf(buff, "%d", Avg_CNo/10); // unit of AT%GNSS, AT%GNSS=? is 1dB + // sprintf(buff, "%d", cn/10); + if (!memcmp(command, GNSS_OP, 7)) { + DBG("** GNSS test, report CN and NA**"); + int size = strlen(buff); + strcpy(buff+size, ", NA"); + DBG("** result = %s**", buff); + } + at_command_send_ack(buff, sizeof(buff)); + } + } +} + +void +at_command_send_test_result() +{ + int ret = mtk_gps_test_inprogress(); + if (MNL_AT_TEST_INPROGRESS == ret) { + DBG("** AT Command test is inprogress **"); + char buff[] = "GNSS Test In Progress"; + at_command_send_ack(buff, sizeof(buff)); + } else if (MNL_AT_TEST_DONE == ret || MNL_AT_TEST_RESULT_DONE == ret) { + DBG("** AT Command test done"); + char buff[GPS_AT_ACK_SIZE]; + sprintf(buff, "[%d, %d, %d, %d, %d, %d, %d, %d][0, 0, 0, 0, 0, 0, 0, 0]", + result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7]); + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT Command test status unknown"); + if (result[0] !=0) { // Brian test + char buff[GPS_AT_ACK_SIZE]={0}; + DBG("Normal: Return the result"); + sprintf(buff, "[%d, %d, %d, %d, %d, %d, %d, %d][0, 0, 0, 0, 0, 0, 0, 0]", + result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7]); + DBG("** result =[%s] **\n", buff); + at_command_send_ack(buff, sizeof(buff)); + } else if ((result[5] != 0) && (!(MNL_AT_SIGNAL_MODE || MNL_AT_SIGNAL_TEST_BEGIN))) { + DBG("Normal: Return the result"); + char buff[GPS_AT_ACK_SIZE]={0}; + sprintf(buff, "[%d, %d, %d, %d, %d, %d, %d, %d][0, 0, 0, 0, 0, 0, 0, 0]", + result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7]); + DBG("** result =[%s] **\n", buff); + at_command_send_ack(buff, sizeof(buff)); + } else { + char buff[] = "[0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0]"; + at_command_send_ack(buff, sizeof(buff)); + } + } +} + +int +at_command_parse_test_num(char* cmdline) { + unsigned long int res; + char* command = cmdline; + char** pos = (char**)malloc(sizeof(char)*strlen(command)); + + if (!memcmp(command, GNSS_OP, 7)) { + // AT%GNSS=n + res = strtoul(command+8, pos, 10); + } else { + // AT%GPS=n + res = strtoul(command+7, pos, 10); + } + + if ((res != 0) && ((**pos) =='\0')) { + DBG("** AT Command Parse: get test_num = %d success!**", res); + return res; + } else { + DBG("** AT Command Parse: the test num may incorrect**"); + return -1; + } + + if (NULL != pos) { + DBG("free pos!!"); + free(pos); + } + +} +#endif +#if 0 + // TO-DO +int +send_cmd_to_agpsd(UINT16 type, UINT16 length, char *data) +{ + int sock2supl = -1; + struct sockaddr_un local; + mtk_agps_msg *pMsg = NULL; + UINT16 total_length = length + sizeof(mtk_agps_msg); + pMsg = (mtk_agps_msg *)malloc(total_length); + if (pMsg) { + if (type == MTK_AGPS_SUPL_RAW_DBG) { + pMsg->type = MTK_AGPS_SUPL_RAW_DBG; + pMsg->srcMod = MTK_MOD_GPS; + pMsg->dstMod = MTK_MOD_SUPL; + pMsg->length = length; + + + if (pMsg->length != 0) { + memcpy(pMsg->data, data, length); + DBG("SendMsg (%d %d %d %d %s)\r\n", pMsg->srcMod, pMsg->dstMod, pMsg->type, pMsg->length, pMsg->data); + } else { + DBG("SendMsg (%d %d %d %d) no data\r\n", pMsg->srcMod, pMsg->dstMod, pMsg->type, pMsg->length); + } + + if ((sock2supl = socket(AF_LOCAL, SOCK_DGRAM, 0)) == -1) { + ERR("SendMsg:open sock2supl fails\r\n"); + free(pMsg); + pMsg = NULL; + return -1; + } + memset(&local, 0, sizeof(local)); + local.sun_family = AF_LOCAL; + strcpy(local.sun_path, MTK_MNL2SUPL); + if (sendto(sock2supl, (void *)pMsg, total_length, 0, (struct sockaddr*)&local, sizeof(local)) < 0) { + ERR("send message fail:%s\r\n", strerror(errno)); + return -1; + } + close(sock2supl); + } + } + + if (pMsg) { + free(pMsg); + pMsg = NULL; + } + + return 0; +} + +void +at_command_debug_switch(int state) { + int status = state; + int ret; + char cmd = HAL_CMD_STOP_UNKNOWN; + +if (sta.status == GPS_STATUS_ENGINE_ON || sta.status == GPS_STATUS_SESSION_BEGIN + || MNL_AT_SIGNAL_MODE || MNL_AT_TEST_FLAG) { + if (1 == status) { + char buff[] = {MNL_CMD_ENABLE_AGPS_DEBUG}; + ret == mt3326_daemon_send(buff, sizeof(buff)); + } else if (0 == status) { + char buff[] = {MNL_CMD_DISABLE_AGPS_DEBUG}; + ret == mt3326_daemon_send(buff, sizeof(buff)); + } + + if (-1 == ret) { + DBG("send MNL_CMD_ENABLE_AGPS_DEBUG fail"); + char res[] = "Failed"; + at_command_send_ack(res, sizeof(res)); + } else { + char res[] = "Success"; + at_command_send_ack(res, sizeof(res)); + + + // read result here + /* + ret = read(mt3326_gps.sock, &cmd, sizeof(cmd)); + + if (-1 == ret) { + DBG("Read fail"); + char res[] = "Failed"; + at_command_send_ack(res, sizeof(res)); + } + + if (cmd == HAL_CMD_SWITCH_AGPS_DEBUG_DONE) { + DBG("send MNL_CMD_ENABLE_AGPS_DEBUG success"); + char buff[] = "Success"; + at_command_send_ack(buff, sizeof(buff)); + } else if (cmd == HAL_CMD_SWITCH_AGPS_DEBUG_FAIL) { + DBG("send MNL_CMD_ENABLE_AGPS_DEBUG fail"); + char buff[] = "Fail"; + at_command_send_ack(buff, sizeof(buff)); + } + */ + } +} else { + + // send to AGPSD directly + DBG("Send command to AGPSD directly"); + if (status == 1) { + ret = send_cmd_to_agpsd(MTK_AGPS_SUPL_RAW_DBG, 1, "1"); + } else if (status == 0) { + ret = send_cmd_to_agpsd(MTK_AGPS_SUPL_RAW_DBG, 1, "0"); + } else { + DBG("Unknown status: %d", status); + ret = -1; + } + + if (-1 == ret) { + char res[] = "Failed"; + at_command_send_ack(res, sizeof(res)); + } else { + char res[] = "Success"; + at_command_send_ack(res, sizeof(res)); + } + + } +} +#endif + +#ifdef GPS_AT_COMMAND +void +at_gps_command_parser(char* cmdline) +{ + char* command = cmdline; + test_mode_flag = 0; + + if (!memcmp(command+6, "=", 1)) { + if ((!memcmp(command+7, "?", 1)) && (!memcmp(command+8, "\0", 1))) { + // AT%GPS=? + DBG("** AT Command Parse: AT%%GPS=?**"); + at_command_send_cno(command); + } else if (((!memcmp(command+7, "E", 1)) ||(!memcmp(command+7, "e", 1))) && (!memcmp(command+8, "\0", 1))) { + // AT%GPS=E + DBG("Open AGPS raw data"); + #if 0 // TO-DO + at_command_debug_switch(0); + #endif + } else if (((!memcmp(command+7, "D", 1)) ||(!memcmp(command+7, "d", 1))) && (!memcmp(command+8, "\0", 1))) { + // AT%GNS=D + DBG("Close AGPS raw data"); + #if 0 // TO-DO + at_command_debug_switch(0); + #endif + } else { + // AT%GPS=n + DBG("** AT Command Parse: AT%%GPS=num**"); + int test_num = at_command_parse_test_num(command); + if (test_num >= 0) { + int ret = mtk_gps_test_start(test_num, GPS_TEST_PRN, 2, 0); + if (0 == ret) { + DBG("** AT Command gps test start success **"); + char buff[] = "GPS TEST START OK"; + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT Command gps test start fail **"); + char buff[] = "GPS ERROR"; + at_command_send_ack(buff, sizeof(buff)); + } + } else { + char buff[] = "Invalid Test Num =0"; + at_command_send_ack(buff, sizeof(buff)); + } + } + } else if (!memcmp(command+6, "?", 1) && (!memcmp(command+7, "\0", 1))) { + // AT%GPS? + DBG("** AT Command Parse: AT%%GPS? **"); + int ret = mtk_gps_test_inprogress(); + + if (MNL_AT_TEST_INPROGRESS == ret) { + DBG("** AT Command test is inprogress **"); + char buff[] = "GPS Test In Progress"; + at_command_send_ack(buff, sizeof(buff)); + } else if (MNL_AT_TEST_DONE == ret) { + DBG("** AT Command test done"); + char buff[GPS_AT_ACK_SIZE]; + sprintf(buff, "<%d, %d, %d, %d, %d, %d, %d, %d>", + result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7]); + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT Command test status unknown"); + char buff[] = "ERROR"; + at_command_send_ack(buff, sizeof(buff)); + } + } else if (!memcmp(command+6, "\0", 1)) { + // AT%GPS + DBG("** AT Command Parse: AT%%GPS **"); + at_command_send_cno(command); + } else { + DBG("** AT Command Parse: illegal command **"); + char buff[] = "GPS ERROR"; + at_command_send_ack(buff, sizeof(buff)); + } +} + +void +at_gnss_command_parser(char* cmdline) +{ + char* command = cmdline; + test_mode_flag = 0; + + if (!memcmp(command+7, "=", 1)) { + if ((!memcmp(command+8, "?", 1)) && (!memcmp(command+9, "\0", 1))) { + // AT%GNSS=? + DBG("** AT Command Parse: AT%%GNSS=?**"); + // at_command_send_cno(command); + at_command_send_test_result(); + } else if (((!memcmp(command+8, "S", 1)) || (!memcmp(command+8, "s", 1))) && (!memcmp(command+9, "\0", 1))) { + DBG("AT%%GNSS=S is set!!"); + int ret = 0; + if (0 == MNL_AT_TEST_FLAG) { + DBG("Open GPS and set signal test mode"); + ret = mtk_gps_test_start(0, 1, 2, 1); + } else { + DBG("GPS driver is opened, change mode"); + MNL_AT_SIGNAL_MODE = 1; + MNL_AT_TEST_FLAG = 0; + // Cancel alarm if needed + if (0 == MNL_AT_CANCEL_ALARM) { + DBG("Cancel alarm!!"); + alarm(0); + MNL_AT_CANCEL_ALARM = 0; + MNL_AT_SET_ALARM = 0; + } + } + + if (0 == ret) { + DBG("** AT%%GNSS=S set success ! **"); + char buff[] = "GNSS START START OK"; + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT%%GNSS=S set fail **"); + char buff[] = "GNSS START START FAIL"; + at_command_send_ack(buff, sizeof(buff)); + } + } else if (((!memcmp(command+8, "E", 1)) || (!memcmp(command+8, "e", 1))) && (!memcmp(command+9, "\0", 1))) { + DBG("AT%%GNSS=E is set, stop test!!"); + if (MNL_AT_TEST_STATE == MNL_AT_TEST_UNKNOWN) { + DBG("** MNL_AT_TEST_UNKNOWN **"); + char buff[] = "GNSS Test is Not In Progress"; + at_command_send_ack(buff, sizeof(buff)); + } else { + // if (MNL_AT_TEST_STATE != MNL_AT_TEST_UNKNOWN) { // To avoid close gps driver many times + int ret = mtk_gps_test_stop(); + if (0 == ret) { + DBG("** AT%%GNSS=E set success ! **"); + char buff[] = "GNSS TEST END OK"; + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT%GNSS=E set fail **"); + char buff[] = "GNSS TEST END FAIL"; + at_command_send_ack(buff, sizeof(buff)); + } + // } + } + } else { + // AT%GNSS = n + DBG("** AT Command Parse: AT%%GNSS=n**"); + int test_num = at_command_parse_test_num(command); + // initialzation of result whenever starting test again. + memset(result, 0, sizeof(int)*8); + result[0] = 1; + Avg_CNo = 0; + Success_Num = 0; + Completed_Num = 0; + CNo = 0; + DCNo = 0; + Dev_CNo = 0; + cn = 0; + // initialzation of result whenever starting test again. + + if (MNL_AT_SIGNAL_MODE == 1) { // && (test_num != 0)) { + if (test_num <= 0) { + char buff[] = "Invalid Test Num = 0"; + at_command_send_ack(buff, sizeof(buff)); + if (MNL_AT_TEST_STATE != MNL_AT_TEST_UNKNOWN) + mtk_gps_test_stop(); + } else { + DBG("MNL_AT_SIGNAL_MODE_BEGIN"); + MNL_AT_SIGNAL_TEST_BEGIN = 1; + MNL_AT_TEST_STATE = MNL_AT_TEST_INPROGRESS; // Brian test + char buff[] = "GNSS TEST START OK"; + at_command_send_ack(buff, sizeof(buff)); + time(&start_time); + } + } else { + if (test_num >= 0) { + int ret = mtk_gps_test_start(test_num, GPS_TEST_PRN, 2, 0); + if (0 == ret) { + DBG("** AT Command gps test start success **"); + char buff[] = "GNSS TEST START OK"; + at_command_send_ack(buff, sizeof(buff)); + } else { + DBG("** AT Command gps test start fail **"); + char buff[] = "GNSS ERROR"; + at_command_send_ack(buff, sizeof(buff)); + } + } else { + char buff[] = "Invalid Test Num =0"; + at_command_send_ack(buff, sizeof(buff)); + } + } + } + } else if (!memcmp(command+7, "?", 1) && (!memcmp(command+8, "\0", 1))) { + // AT%GNSS? + DBG("** AT Command Parse: AT%%GNSS? **"); + at_command_send_test_result(); + + } else if (!memcmp(command+7, "\0", 1)) { + // AT%GNSS + DBG("** AT Command Parse: AT%%GNSS **"); + at_command_send_cno(command); + } else { + DBG("** AT Command Parse: illegal command **"); + char buff[] = "GNSS ERROR"; + at_command_send_ack(buff, sizeof(buff)); + } +} + + + +static void +at_command_parser(char* cmdline) +{ + char* command = cmdline; + DBG("** AT Command, receive command %s**", command); + /* begin to parse the command */ + if (!memcmp(command, GPS_OP, 6)) { + at_gps_command_parser(command); + } else if (!memcmp(command, GNSS_OP, 7)) { + at_gnss_command_parser(command); + } else { + DBG("** AT Command Parse: Not GPS/GNSS AT Command **"); + char buff[] = "GPS ERROR"; + at_command_send_ack(buff, sizeof(buff)); + } +} +#endif + +void mnld_to_gps_handler(int fd, GpsState* s) { // from AGPSD->MNLD->HAL->FWK + int ret; + int type; + int offset = 0; + char buff[9000] = {0}; + + ret = safe_read(fd, buff, sizeof(buff)); + type = buff_get_int(buff, &offset); + DBG("WARNING: mnld_to_gps_handler ret=%d type=%d\n", ret, type); + + switch (type) { + case MNL_AGPS_CMD_NOTIFICATION: { + int usc2_len; + char ucs2_buff[1024]; + char requestor_id[1024]; + char client_name[1024]; + + GpsNiNotification notify; + memset(¬ify, 0, sizeof(notify)); + + notify.notification_id = buff_get_int(buff, &offset); // session_id + notify.ni_type = GPS_NI_TYPE_UMTS_SUPL; + int type = buff_get_int(buff, &offset); // mnl_agps_notify_type + switch (type) { + case AGPS_SUPL_NOTIFY_ONLY: + notify.notify_flags = GPS_NI_NEED_NOTIFY; + break; + case AGPS_SUPL_NOTIFY_ALLOW_NO_ANSWER: + notify.notify_flags = GPS_NI_NEED_NOTIFY|GPS_NI_NEED_VERIFY; + break; + case AGPS_SUPL_NOTIFY_DENY_NO_ANSWER: + notify.notify_flags = GPS_NI_NEED_NOTIFY|GPS_NI_NEED_VERIFY; + break; + case AGPS_SUPL_NOTIFY_PRIVACY: + notify.notify_flags = GPS_NI_PRIVACY_OVERRIDE; + break; + default: + notify.notify_flags = 0; + break; + } + notify.default_response = GPS_NI_RESPONSE_NORESP; + notify.timeout = 8; + notify.requestor_id_encoding = GPS_ENC_SUPL_UCS2; + notify.text_encoding = GPS_ENC_SUPL_UCS2; + + buff_get_string(requestor_id, buff, &offset); + buff_get_string(client_name, buff, &offset); + + memset(ucs2_buff, 0, sizeof(ucs2_buff)); + usc2_len = asc_str_to_usc2_str(ucs2_buff, requestor_id); + raw_data_to_hex_string(notify.requestor_id, ucs2_buff, usc2_len); + + memset(ucs2_buff, 0, sizeof(ucs2_buff)); + usc2_len = asc_str_to_usc2_str(ucs2_buff, client_name); + raw_data_to_hex_string(notify.text, ucs2_buff, usc2_len); + + notify.size = sizeof(GpsNiNotification); + g_agps_ctx.gps_ni_callbacks->notify_cb(¬ify); + break; + } + case MNL_AGPS_CMD_NOTIFICATION_2: { + GpsNiNotification notify; + memset(¬ify, 0, sizeof(notify)); + + notify.notification_id = buff_get_int(buff, &offset); // session_id + notify.ni_type = GPS_NI_TYPE_UMTS_SUPL; + + int type = buff_get_int(buff, &offset); // mnl_agps_notify_type + switch (type) { + case AGPS_SUPL_NOTIFY_ONLY: + notify.notify_flags = GPS_NI_NEED_NOTIFY; + break; + case AGPS_SUPL_NOTIFY_ALLOW_NO_ANSWER: + notify.notify_flags = GPS_NI_NEED_NOTIFY|GPS_NI_NEED_VERIFY; + break; + case AGPS_SUPL_NOTIFY_DENY_NO_ANSWER: + notify.notify_flags = GPS_NI_NEED_NOTIFY|GPS_NI_NEED_VERIFY; + break; + case AGPS_SUPL_NOTIFY_PRIVACY: + notify.notify_flags = GPS_NI_PRIVACY_OVERRIDE; + break; + default: + notify.notify_flags = 0; + break; + } + + buff_get_string(notify.requestor_id, buff, &offset); + buff_get_string(notify.text, buff, &offset); + + notify.default_response = GPS_NI_RESPONSE_NORESP; + notify.timeout = 8; + notify.requestor_id_encoding = buff_get_int(buff, &offset); + notify.text_encoding = buff_get_int(buff, &offset); + notify.size = sizeof(GpsNiNotification); + g_agps_ctx.gps_ni_callbacks->notify_cb(¬ify); + break; + } + case MNL_AGPS_CMD_DATA_CONN_REQ: { + AGpsStatus_v2 agps_status; + agps_status.type = AGPS_TYPE_SUPL; + agps_status.status = GPS_REQUEST_AGPS_DATA_CONN; + agps_status.ipaddr = buff_get_int(buff, &offset); + // no need currently + int is_emergency = buff_get_int(buff, &offset); + agps_status.size = sizeof(AGpsStatus_v2); + g_agps_ctx.agps_callbacks->status_cb(&agps_status); + break; + } + case MNL_AGPS_CMD_DATA_CONN_REQ2: { + AGpsStatus agps_status; + memset(&agps_status, 0, sizeof(AGpsStatus)); + agps_status.size = sizeof(AGpsStatus); + agps_status.type = AGPS_TYPE_SUPL; + agps_status.status = GPS_REQUEST_AGPS_DATA_CONN; + buff_get_struct(&agps_status.addr, sizeof(struct sockaddr_storage), buff, &offset); + // no need currently + int is_emergency = buff_get_int(buff, &offset); + g_agps_ctx.agps_callbacks->status_cb(&agps_status); + break; + } + case MNL_AGPS_CMD_DATA_CONN_RELEASE: { + AGpsStatus_v1 agps_status; + agps_status.type = AGPS_TYPE_SUPL; + agps_status.status = GPS_RELEASE_AGPS_DATA_CONN; + // agps_status.ipaddr = buff_get_int(buff, &offset); + agps_status.size = sizeof(AGpsStatus_v1); + DBG("AGPS data connection release with AGpsStatus_v1"); + g_agps_ctx.agps_callbacks->status_cb(&agps_status); + break; + } + case MNL_AGPS_CMD_REQUEST_SET_ID: { + int flags = buff_get_int(buff, &offset); + g_agps_ctx.agps_ril_callbacks->request_setid(flags); + break; + } + case MNL_AGPS_CMD_REQUEST_REFLOC: { + int flags = buff_get_int(buff, &offset); + g_agps_ctx.agps_ril_callbacks->request_refloc(flags); + break; + } + case MNL_AGPS_CMD_AGPS_LOC: { // 235 + mnl_agps_agps_location location; + GpsLocation mlocation; + memset(&location, 0, sizeof(mnl_agps_agps_location)); + memset(&mlocation, 0, sizeof(GpsLocation)); + + buff_get_struct((char *)&location, sizeof(mnl_agps_agps_location), buff, &offset); + + DBG("latitude = %lf, longitude= %lf, altitude_used = %d, altitude = %lf, accuracy = %d", location.latitude, + location.longitude, location.altitude_used, location.altitude, location.accuracy_used); + + mlocation.flags |= GPS_LOCATION_HAS_LAT_LONG; + mlocation.latitude = location.latitude; + mlocation.longitude = location.longitude; + + if (location.altitude_used) { + mlocation.flags |= GPS_LOCATION_HAS_ALTITUDE; + mlocation.altitude = location.altitude; + } + + if (location.speed_used) { + mlocation.flags |= GPS_LOCATION_HAS_SPEED; + mlocation.speed = location.speed; + } + + if (location.bearing_used) { + mlocation.flags |= GPS_LOCATION_HAS_BEARING; + mlocation.bearing = location.bearing; + } + + if (location.accuracy_used) { + mlocation.flags |= GPS_LOCATION_HAS_ACCURACY; + mlocation.accuracy = location.accuracy; + } + + if (location.timestamp_used) + mlocation.timestamp = location.timestamp; + + mlocation.size = sizeof(GpsLocation); + + if (callback_backup_mtk.base.location_cb) { + DBG("Update location data to UI"); + callback_backup_mtk.base.location_cb(&mlocation); + } else { + DBG("Location CB is null"); + } + break; + } +#if EPO_SUPPORT + case HAL_CMD_UPDATE_EPO_FILE_DONE: { + ERR("Update EPO file ok\n"); + if ((epo_download_failed == 0) && (gps_epo_file_count == 0)) { + unlink(EPO_FILE_HAL); + } + // epo_download_failed = 0; + break; + } + case HAL_CMD_UPDATE_EPO_FILE_FAIL: { + ERR("Update EPO file fail\n"); + break; + } +#endif + case MNL_CMD_GPS_INJECT_TIME_REQ:{ + if (callback_backup_mtk.base.request_utc_time_cb) { + DBG("request_utc_time_cb\n"); + callback_backup_mtk.base.request_utc_time_cb(); + } + break; + } + case MNL_CMD_GPS_INJECT_LOCATION_REQ:{ + DBG("mnl request location\n"); + mtk_gps_send_location_to_mnl(); + break; + } + case HAL_CMD_MNL_DIE:{ + DBG("MNLD died!!"); + flag_unlock = 0; + // GpsStatus sta; + // Modify to global + sta.status = GPS_STATUS_SESSION_END; + callback_backup_mtk.base.status_cb(&sta); + DBG("sta.status = GPS_STATUS_SESSION_END\n"); + sta.status = GPS_STATUS_ENGINE_OFF; + DBG("sta.status = GPS_STATUS_ENGINE_OFF\n"); + callback_backup_mtk.base.status_cb(&sta); + release_condition(&lock_for_sync[M_STOP]); + callback_backup_mtk.base.release_wakelock_cb(); + s->start_flag = 0; + DBG("s->start_flag = 0\n"); + DBG("HAL_CMD_MNL_DIE has been receiving from MNLD, release lock let stop done\n"); + break; + } + case HAL_CMD_GPS_ICON:{ + int status = buff_get_int(buff, &offset); + DBG("ICON STATUS = %d", status); + if (status == 1) { // start + if (started == 0) { + sta.status = GPS_STATUS_ENGINE_ON; + DBG("sta.status = GPS_STATUS_ENGINE_ON\n"); + callback_backup_mtk.base.status_cb(&sta); + sta.status = GPS_STATUS_SESSION_BEGIN; + DBG("sta.status = GPS_STATUS_SESSION_BEGIN\n"); + callback_backup_mtk.base.status_cb(&sta); + } + } else if (status == 0) { // stop + if (started == 0) { + sta.status = GPS_STATUS_ENGINE_OFF; + DBG("sta.status = GPS_STATUS_ENGINE_OFF\n"); + callback_backup_mtk.base.status_cb(&sta); + sta.status = GPS_STATUS_SESSION_END; + DBG("sta.status = GPS_STATUS_SESSION_END\n"); + callback_backup_mtk.base.status_cb(&sta); + } + } + break; + } + case HAL_CMD_MEASUREMENT: { + DBG("HAL_CMD_MEASUREMENT message recieved\n"); + if (gpsmeasurement_init_flag == 1) { + int i = 0; + MTK_GPS_MEASUREMENT mtk_gps_measurement[32]; + buff_get_struct(mtk_gps_measurement, 32*sizeof(MTK_GPS_MEASUREMENT), buff, &offset); + MTK_GPS_CLOCK mtk_gps_clock; + buff_get_struct(&mtk_gps_clock, sizeof(MTK_GPS_CLOCK), buff, &offset); + GpsClock gpsclock; + memset(&gpsclock, 0, sizeof(GpsClock)); + gpsclock.size = sizeof(GpsClock); + gpsclock.bias_ns = mtk_gps_clock.BiasInNs; + gpsclock.bias_uncertainty_ns = mtk_gps_clock.BiasUncertaintyInNs; + gpsclock.drift_nsps = mtk_gps_clock.DriftInNsPerSec; + gpsclock.flags = mtk_gps_clock.flag; + gpsclock.leap_second = mtk_gps_clock.leapsecond; + gpsclock.time_ns = mtk_gps_clock.TimeInNs; + gpsclock.time_uncertainty_ns = mtk_gps_clock.TimeUncertaintyInNs; + gpsclock.type = mtk_gps_clock.type; + gpsclock.full_bias_ns = mtk_gps_clock.FullBiasInNs; + gpsclock.drift_uncertainty_nsps = mtk_gps_clock.DriftUncertaintyInNsPerSec; + + GpsData gpsdata; + memset(&gpsdata, 0, sizeof(GpsData)); + gpsdata.size = sizeof(GpsData); + + for (i = 0; i < 1; i++) { + DBG("gpsdata measurements[%d] memcpy completed", i); + gpsdata.measurements[i].size = sizeof(GpsMeasurement); + gpsdata.measurements[i].accumulated_delta_range_m = mtk_gps_measurement[i].AcDRInMeters; + gpsdata.measurements[i].accumulated_delta_range_state = mtk_gps_measurement[i].AcDRState10; + gpsdata.measurements[i].accumulated_delta_range_uncertainty_m = mtk_gps_measurement[i].AcDRUnInMeters; + gpsdata.measurements[i].azimuth_deg = mtk_gps_measurement[i].AzInDeg; + gpsdata.measurements[i].azimuth_uncertainty_deg = mtk_gps_measurement[i].AzUnInDeg; + gpsdata.measurements[i].bit_number = mtk_gps_measurement[i].BitNumber; + gpsdata.measurements[i].carrier_cycles = mtk_gps_measurement[i].CarrierCycle; + gpsdata.measurements[i].carrier_phase = mtk_gps_measurement[i].CarrierPhase; + gpsdata.measurements[i].carrier_phase_uncertainty = mtk_gps_measurement[i].CarrierPhaseUn; + gpsdata.measurements[i].carrier_frequency_hz = mtk_gps_measurement[i].CFInhZ; + gpsdata.measurements[i].c_n0_dbhz = mtk_gps_measurement[i].Cn0InDbHz; + gpsdata.measurements[i].code_phase_chips = mtk_gps_measurement[i].CPInChips; + gpsdata.measurements[i].code_phase_uncertainty_chips = mtk_gps_measurement[i].CPUnInChips; + gpsdata.measurements[i].doppler_shift_hz = mtk_gps_measurement[i].DopperShiftInHz; + gpsdata.measurements[i].doppler_shift_uncertainty_hz = mtk_gps_measurement[i].DopperShiftUnInHz; + gpsdata.measurements[i].elevation_deg = mtk_gps_measurement[i].ElInDeg; + gpsdata.measurements[i].elevation_uncertainty_deg = mtk_gps_measurement[i].ElUnInDeg; + gpsdata.measurements[i].flags = mtk_gps_measurement[i].flag; + gpsdata.measurements[i].loss_of_lock = mtk_gps_measurement[i].LossOfLock; + gpsdata.measurements[i].multipath_indicator = mtk_gps_measurement[i].MultipathIndicater; + gpsdata.measurements[i].pseudorange_m = mtk_gps_measurement[i].PRInMeters; + gpsdata.measurements[i].prn = mtk_gps_measurement[i].PRN; + gpsdata.measurements[i].pseudorange_rate_mps = mtk_gps_measurement[i].PRRateInMeterPreSec; + gpsdata.measurements[i].pseudorange_rate_uncertainty_mps = mtk_gps_measurement[i].PRRateUnInMeterPreSec; + gpsdata.measurements[i].pseudorange_uncertainty_m = mtk_gps_measurement[i].PRUnInMeters; + gpsdata.measurements[i].received_gps_tow_ns = mtk_gps_measurement[i].ReGpsTowInNs; + gpsdata.measurements[i].received_gps_tow_uncertainty_ns = mtk_gps_measurement[i].ReGpsTowUnInNs; + gpsdata.measurements[i].snr_db = mtk_gps_measurement[i].SnrInDb; + gpsdata.measurements[i].state = mtk_gps_measurement[i].state; + gpsdata.measurements[i].time_from_last_bit_ms = mtk_gps_measurement[i].TimeFromLastBitInMs; + gpsdata.measurements[i].time_offset_ns = mtk_gps_measurement[i].TimeOffsetInNs; + gpsdata.measurements[i].used_in_fix = mtk_gps_measurement[i].UsedInFix; + if (gpsdata.measurements[i].prn != 0) { + gpsdata.measurement_count++; + } + } + memcpy(&gpsdata.clock , &gpsclock, sizeof(gpsclock)); + + #if 0 + DBG("clock.size = %d, clock.bias_ns = %lf, clock.bias_uncertainty_ns = %lf, + clock.drift_nsps = %lf, clock.flags = %d, clock.leap_second = %d, \ + clock.time_ns = %d, clock.time_uncertainty_ns = %lf, clock.type = %d, \ + clock.full_bias_ns = %d, clock.drift_uncertainty_nsps = %lf", + gpsdata.clock.size, gpsdata.clock.bias_ns, gpsdata.clock.bias_uncertainty_ns, + gpsdata.clock.drift_nsps, gpsdata.clock.flags, gpsdata.clock.leap_second, + gpsdata.clock.time_ns, gpsdata.clock.time_uncertainty_ns, gpsdata.clock.type, + gpsdata.clock.full_bias_ns, gpsdata.clock.drift_uncertainty_nsps); + + for (i = 0; i < 32; i++) { + if (gpsdata.measurements[i].size > 0) { + DBG("i = %d, measurements.CFInhZ = %f, measurements.Cn0InDbHz = %lf, \ + measurements.size = %d, measurements.prn = %d, \ + measurements.time_offset_ns = %lf, measurements.used_in_fix = %d", + i, gpsdata.measurements[i].carrier_frequency_hz, + gpsdata.measurements[i].c_n0_dbhz, gpsdata.measurements[i].size, + gpsdata.measurements[i].prn, gpsdata.measurements[i].time_offset_ns, + gpsdata.measurements[i].used_in_fix); + } + } + #endif + + DBG("if measurement_count = %d > 0 , Send measurement_callback data to FWK", gpsdata.measurement_count); + if (gpsdata.measurement_count > 0) { + measurement_callbacks.measurement_callback(&gpsdata); + DBG("Send measurement_callback data to FWK success\n"); + } + } + break; + } + case HAL_CMD_NAVIGATION: { + DBG("HAL_CMD_NAVIGATION message recieved1\n"); + if (gpsnavigation_init_flag == 1) { + int i; + MTK_GPS_NAVIGATION_EVENT *gps_navigation_event = + (MTK_GPS_NAVIGATION_EVENT*)malloc(sizeof(MTK_GPS_NAVIGATION_EVENT)); + if (gps_navigation_event == NULL) { + DBG("point gps_navigation_event is null, return!"); + break; + } + buff_get_struct(gps_navigation_event, sizeof(MTK_GPS_NAVIGATION_EVENT), buff, &offset); + + GpsNavigationMessage gpsnavigation; + memset(&gpsnavigation, 0, sizeof(GpsNavigationMessage)); + gpsnavigation.size = sizeof(GpsNavigationMessage); + gpsnavigation.prn = gps_navigation_event->prn; + gpsnavigation.type = gps_navigation_event->type; + gpsnavigation.message_id = gps_navigation_event->messageID; + gpsnavigation.submessage_id = gps_navigation_event->submessageID; + gpsnavigation.data_length = (size_t)gps_navigation_event->length; + gpsnavigation.data = (char*)malloc(sizeof(char)*gps_navigation_event->length); + memcpy(gpsnavigation.data, gps_navigation_event->data, gps_navigation_event->length); + + #if 0 + DBG("size_t = %d, gpsnavigation.size = %d, %p, gpsnavigation.prn = %d, %p, \ + gpsnavigation.type = %d, %p, gpsnavigation.message_id = %d, %p, \ + gpsnavigation.submessage_id = %d, %p, gpsnavigation.data_length = %d, %p, data = %p", + sizeof(size_t), gpsnavigation.size, &gpsnavigation.size, gpsnavigation.prn, + &gpsnavigation.prn, gpsnavigation.type, &gpsnavigation.type, + gpsnavigation.message_id, &gpsnavigation.message_id, gpsnavigation.submessage_id, + &gpsnavigation.submessage_id, gpsnavigation.data_length, + &gpsnavigation.data_length, gpsnavigation.data); + for (i = 0; i < 40; i++) { + DBG("HAL: gpsnavigation.data[%d] = %x", i, gpsnavigation.data[i]); + } + #endif + navigation_callbacks.navigation_message_callback(&gpsnavigation); + DBG("navigation_message_callback done\n"); + free(gpsnavigation.data); + free(gps_navigation_event); + } + break; + } + + default: { + ERR("ERR: unknown type=%d\n", type); + break; + } + } +} + +static int +epoll_register(int epoll_fd, int fd) +{ + struct epoll_event ev; + int ret, flags; + + /* important: make the fd non-blocking */ + flags = fcntl(fd, F_GETFL); + fcntl(fd, F_SETFL, flags | O_NONBLOCK); + + ev.events = EPOLLIN; + ev.data.fd = fd; + do { + ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev); + } while (ret < 0 && errno == EINTR); + if (ret < 0) + ERR("epoll ctl error, error num is %d\n, message is %s\n", errno, strerror(errno)); + return ret; +} + + +static int +epoll_deregister(int epoll_fd, int fd) +{ + int ret; + do { + ret = epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, NULL); + } while (ret < 0 && errno == EINTR); + return ret; +} + +/*for reducing the function call to get data from kernel*/ +static char buff[2048]; +/* this is the main thread, it waits for commands from gps_state_start/stop and, + * when started, messages from the GPS daemon. these are simple NMEA sentences + * that must be parsed to be converted into GPS fixes sent to the framework + */ +void +gps_state_thread(void* arg) +{ + static float count = 0; + GpsState* state = (GpsState*) arg; + state->test_time += 1; + // state->thread_exit_flag=0; + NmeaReader reader[1]; +#if NEED_IPC_WITH_CODEC + char buf_for_codec[2048]; +#endif +#ifdef GPS_AT_COMMAND + // int started = 0; +#endif + int gps_fd = state->fd; + int control_fd = state->control[1]; + int atc_fd = state->sockfd; + + int epoll_fd = state->epoll_hd; + int test_started = 0; + + nmea_reader_init(reader); + + int mnld_fd = bind_udp_socket(MTK_MNLD2HAL); + DBG("WARNING: mnld_fd=%d\n", mnld_fd); + if (mnld_fd >= 0) { + if (epoll_register(epoll_fd, mnld_fd) < 0) + ERR("ERR: epoll register control_fd error, error num is %d\n, message is %s\n", errno, strerror(errno)); + else + DBG("WARNING: epoll_register successfully\n"); + } + +#if NEED_IPC_WITH_CODEC + int sock_codec, size_codec; + struct sockaddr_un un; + socklen_t client_addr_len; + memset(&un, 0, sizeof(un)); + un.sun_family = AF_UNIX; + strcpy(un.sun_path, EVDO_CODEC_SOC); + if ((state->sock_codec = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { + ERR("create socket for communicate with codec error, message %s\n", strerror(errno)); + if (mnld_fd != C_INVALID_FD) + close(mnld_fd); + return; + } + unlink(EVDO_CODEC_SOC); + size_codec = sizeof(un.sun_family)+strlen(un.sun_path); + if (bind(state->sock_codec, (struct sockaddr *)&un, size_codec) < 0) { + ERR("bind fail, message = %s\n", strerror(errno)); + if (mnld_fd != C_INVALID_FD) + close(mnld_fd); + return; + } + if (listen(state->sock_codec, 5) == -1) { + ERR("listern error, message is %s\n", strerror(errno)); + if (mnld_fd != C_INVALID_FD) + close(mnld_fd); + return; + } + DBG("listen done\n"); + int a = chmod(EVDO_CODEC_SOC, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP); + DBG("chmod res = %d\n", a); // 770<--mode + + if (chown(EVDO_CODEC_SOC, -1, AID_INET)) { + ERR("chown error: %s", strerror(errno)); + } + + if (epoll_register(epoll_fd, state->sock_codec) < 0) + ERR("epoll register state->sock_codec error, error num is %d\n, message is %s\n", + errno, strerror(errno)); +#endif + // register control file descriptors for polling + if (epoll_register(epoll_fd, control_fd) < 0) + ERR("epoll register control_fd error, error num is %d\n, message is %s\n", errno, strerror(errno)); + if (epoll_register(epoll_fd, gps_fd) < 0) + ERR("epoll register control_fd error, error num is %d\n, message is %s\n", errno, strerror(errno)); + if (epoll_register(epoll_fd, atc_fd) < 0) + ERR("epoll register control_fd error, error num is %d\n, message is %s\n", errno, strerror(errno)); + + DBG("gps thread running: PPID[%d], PID[%d]\n", getppid(), getpid()); + release_condition(&lock_for_sync[M_INIT]); + DBG("HAL thread is ready, realease lock, and CMD_START can be handled\n"); +#if SEM + sem_t *sem; + sem = sem_open("/data/misc/gps/read_dev_gps", O_CREAT, S_IRWXU|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, 1); + if (sem == SEM_FAILED) { + ERR("init semaphore FAIL, error message is %s \n", strerror(errno)); + return; + } else + DBG("create semaphore ok\n"); +#endif + // now loop + for (;;) { +#if NEED_IPC_WITH_CODEC + struct epoll_event events[3]; +#else + struct epoll_event events[4]; +#endif + int ne, nevents; +#if NEED_IPC_WITH_CODEC + nevents = epoll_wait(epoll_fd, events, 3, -1); +#else + nevents = epoll_wait(epoll_fd, events, 4, -1); +#endif + if (nevents < 0) { + if (errno != EINTR) + ERR("epoll_wait() unexpected error: %s", strerror(errno)); + continue; + } + VER("gps thread received %d events", nevents); + for (ne = 0; ne < nevents; ne++) { + if ((events[ne].events & (EPOLLERR|EPOLLHUP)) != 0) { + ERR("EPOLLERR or EPOLLHUP after epoll_wait() !?"); + goto Exit; + } + if ((events[ne].events & EPOLLIN) != 0) { + int fd = events[ne].data.fd; + + if (fd == control_fd) { + char cmd = 255; + int ret; + DBG("gps control fd event"); + do { + ret = read(fd, &cmd, 1); + } while (ret < 0 && errno == EINTR); + + if (cmd == CMD_QUIT) { + DBG("gps thread quitting on demand"); + goto Exit; + } + else if (cmd == CMD_START) { + if (!started) { + DBG("gps thread starting location_cb=%p", &callback_backup_mtk.base); + started = 1; + nmea_reader_set_callback(reader, &state->callbacks); + } + } + #ifdef GPS_AT_COMMAND + else if (cmd == CMD_TEST_START) { + if ((!test_started) && (1 == test_mode_flag)) { + // DBG("**AT Command test_start: test_cb=%p", state->callbacks.test_cb); + test_started = 1; + nmea_reader_set_callback(reader, &state->callbacks); + } + } + else if (cmd == CMD_TEST_STOP) { + if (test_started) { + DBG("**AT Command test_stop"); + test_started = 0; + nmea_reader_set_callback(reader, NULL); + } + } + else if (cmd == CMD_TEST_SMS_NO_RESULT) { + DBG("**CMD_TEST_SMS_NO_RESULT, update result!!"); + sms_airtest_no_signal_report(Err_Code, 0, 0, 0, 0); + // nmea_reader_update_at_test_result(reader, Err_Code, 0, 0, 0, 0); + } + #endif +#if EPO_SUPPORT + else if (cmd == CMD_DOWNLOAD) { + DBG("Send download request in HAL."); + mGpsXtraCallbacks.download_request_cb(); + } +#endif + else if (cmd == CMD_STOP) { + if (started) { + DBG("gps thread stopping"); + started = 0; + nmea_reader_set_callback(reader, NULL); + DBG("CMD_STOP has been receiving from HAL thread, release lock so can handle CLEAN_UP\n"); + } + } + else if (cmd == CMD_RESTART) { + reader->fix_mode = 0; + } + } + else if (fd == gps_fd) { + if (!flag_unlock) { + release_condition(&lock_for_sync[M_START]); + flag_unlock = 1; + DBG("got first NMEA sentence, release lock to set state ENGINE ON, SESSION BEGIN"); + } + VER("gps fd event"); + if (report_time_interval > ++count) { + DBG("[trace]count is %f\n", count); + int ret = read(fd, buff, sizeof(buff)); + continue; + } + count = 0; + for (;;) { + int nn, ret; +#if SEM + if (sem_wait(sem) != 0) { + ERR("sem wait error, message is %s \n", strerror(errno)); + close(fd); + return; + } else + DBG("get semaphore, can read now\n"); +#endif + ret = read(fd, buff, sizeof(buff)); +#if NEED_IPC_WITH_CODEC + memset(buf_for_codec, 0, sizeof(buf_for_codec)); + memcpy(buf_for_codec, buff, sizeof(buff)); +#endif +#if SEM + if (sem_post(sem) != 0) { + ERR("sem post error, message is %s\n", strerror(errno)); + close(fd); + return; + } else + DBG("post semaphore, read done\n"); +#endif + if (ret < 0) { + if (errno == EINTR) + continue; + if (errno != EWOULDBLOCK) + ERR("error while reading from gps daemon socket: %s: %p", strerror(errno), buff); + break; + } + DBG("received %d bytes:\n", ret); + gps_nmea_end_tag = 0; + for (nn = 0; nn < ret; nn++) + { + if (nn == (ret-1)) + gps_nmea_end_tag = 1; + + nmea_reader_addc(reader, buff[nn]); + } + } + VER("gps fd event end"); + } + #ifdef GPS_AT_COMMAND + else if (fd == atc_fd) { + char cmd[20]; + DBG("** AT Command received **"); + /* receive and parse ATCM here */ + for (;;) { + int i, ret; + + remotelen = sizeof(remote); + ret = recvfrom(fd, cmd, sizeof(cmd), 0, (struct sockaddr *)&remote, &remotelen); + if (ret < 0) { + if (errno == EINTR) + continue; + if (errno != EWOULDBLOCK) + ERR("error while reading AT Command socket: %s: %p", strerror(errno), cmd); + break; + } + DBG("received %d bytes: %.*s", ret, ret, cmd); + cmd[ret] = 0x00; + at_command_parser(cmd); // need redefine + } + DBG("** AT Command event done **"); + + } + #endif + else if (fd == mnld_fd) { + mnld_to_gps_handler(mnld_fd, state); + } +#if NEED_IPC_WITH_CODEC + else if (fd == state->sock_codec) { + client_addr_len = sizeof(un); + int accept_ret = accept(state->sock_codec, (struct sockaddr*)&un, &client_addr_len); + if (accept_ret == -1) { + ERR("accept error, message is %s\n", strerror(errno)); + continue; + } + DBG("accept done\n"); + int cmd = 0, write_len; + GpsLocation tLocation; + + if (recv(accept_ret, &cmd, sizeof(cmd), 0) < 0) { + ERR("read from codec error, message = %s\n", strerror(errno)); + close(accept_ret); + continue; + } + DBG("read done, cmd: %d\n", cmd); + switch (cmd) { + case 1: // need NMEA sentences + memset(buf_for_codec, 0, sizeof(buf_for_codec)); + write_len = send(accept_ret, buf_for_codec, sizeof(buff), 0); + DBG("write %d bytes to codec\n", write_len); + break; + case 2: // For AGPS location froward + DBG("Snd to UI"); + char ack_buf[10] = {0}; + strcpy(ack_buf, "cmd2_ack"); + write_len = send(accept_ret, ack_buf, sizeof(ack_buf), 0); + DBG("wait rcv location data"); + if (recv(accept_ret, &tLocation, sizeof(tLocation), 0) < 0) { + ERR("read from codec error, message = %s\n", strerror(errno)); + } else { + if (callback_backup_mtk.base.location_cb) { + DBG("Update location data to UI"); + callback_backup_mtk.base.location_cb(&tLocation); + } else { + DBG("Location CB is null"); + } + } + break; + default: + ERR("unknonwn codec message, codec send %d to me\n", cmd); + break; + } + close(accept_ret); + } +#endif + else + { + ERR("epoll_wait() returned unkown fd %d ?", fd); + } + } + } + } +Exit: + DBG("HAL thread is exiting, release lock to clean resources\n"); + if (mnld_fd != C_INVALID_FD) + close(mnld_fd); + release_condition(&lock_for_sync[M_CLEANUP]); + return; +} + + +static void +gps_state_init(GpsState* state) +{ + state->control[0] = -1; + state->control[1] = -1; + state->fd = -1; + + state->fd = open(GPS_CHANNEL_NAME, O_RDONLY); // support poll behavior + int epoll_fd = epoll_create(2); + state->epoll_hd = epoll_fd; + + if (state->fd < 0) { + ERR("no gps hardware detected: %s:%d, %s", GPS_CHANNEL_NAME, state->fd, strerror(errno)); + return; + } + + if (mtk_init() != 0) { + ERR("could not initiaize mtk !!"); + goto Fail; + } + + if (socketpair(AF_LOCAL, SOCK_STREAM, 0, state->control) < 0) { + ERR("could not create thread control socket pair: %s", strerror(errno)); + goto Fail; + } + #ifdef GPS_AT_COMMAND + /* Create socket with generic service for AT Command */ + if ((state->sockfd = socket(AF_LOCAL, SOCK_DGRAM, 0)) == -1) + { + ERR("gps_state_init: hal2usb socket create failed\n"); + goto Fail; + } + + unlink(GPS_AT_COMMAND_SOCK); + memset(&cmd_local, 0, sizeof(cmd_local)); + cmd_local.sun_family = AF_LOCAL; + strcpy(cmd_local.sun_path, GPS_AT_COMMAND_SOCK); + + if (bind(state->sockfd, (struct sockaddr *)&cmd_local, sizeof(cmd_local)) < 0) + { + ERR("gps_state_init: hal2usb socket bind failed\n"); + state->sockfd = -1; + goto Fail; + } + + int res = chmod(GPS_AT_COMMAND_SOCK, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP); + DBG("chmod res = %d, %s", res, strerror(errno)); + #endif + state->thread = callback_backup_mtk.base.create_thread_cb(gps_native_thread, gps_state_thread, state); + if (!state->thread) { + ERR("could not create gps thread: %s", strerror(errno)); + goto Fail; + } + + DBG("gps state initialized, the thread is %d\n", (int)state->thread); + return; + +Fail: + gps_state_done(state); +} + + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** I N T E R F A C E *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ +#if EPO_SUPPORT +static int +read_prop(char* name) +{ + char result[GPS_CONF_FILE_SIZE] = {0}; + + FILE *fp = fopen(name, "r"); + char *key, *val; + if (!fp) { + DBG("%s: open %s fail!\n", __FUNCTION__, EPO_CONTROL_FILE_PATH); + return -1; + } + + while (fgets(result, sizeof(result), fp)) { + if (get_val(result, &key, &val)) { + DBG("%s: Get data fails!!\n", __FUNCTION__); + fclose(fp); + return -1; + } + if (!key || !val) + continue; + if (!strcmp(key, "GNSS_MODE")) { + gnss_mode = atoi(val); + DBG("gnss_mode =%d\n", gnss_mode); + } + } + fclose(fp); + return 0; + +} +#endif + +static int +copy_GpsCallbacks_mtk(GpsCallbacks_mtk* dst, GpsCallbacks_mtk* src) +{ + if (src->base.size == sizeof(GpsCallbacks_mtk)) { + *dst = *src; + DBG("Use GpsCallbacks_mtk\n"); + return 0; + } +// xen0n: this is unnecessary as the callback is already in GpsCallbacks +#if 0 + if (src->base.size == sizeof(GpsCallbacks)) { + dst->base = src->base; + dst->gnss_sv_status_cb = NULL; + DBG("Use GpsCallbacks\n"); + return 0; + } +#endif + ERR("Bad callback, size: %d, expected: %d or %d", src->base.size, sizeof(GpsCallbacks_mtk), sizeof(GpsCallbacks)); + return -1; // error +} + +static int +mtk_gps_init(GpsCallbacks* callbacks) +{ + GpsState* s = _gps_state; + int get_time = 20; + int res = 0; +#if EPO_SUPPORT + int cnt = sizeof(mnl_prop_path)/sizeof(mnl_prop_path[0]); + int idx; +#endif + if (s->init) + return 0; + + if (copy_GpsCallbacks_mtk(&callback_backup_mtk, (GpsCallbacks_mtk*)callbacks) != 0) { + return -1; // error + } + s->callbacks = callback_backup_mtk.base; + + gps_state_init(s); + get_condition(&lock_for_sync[M_INIT]); + usleep(1000*1); + s->init = 1; + DBG("Set GPS_CAPABILITY_SCHEDULING \n"); + callback_backup_mtk.base.set_capabilities_cb(GPS_CAPABILITY_SCHEDULING); +#if EPO_SUPPORT + // get chipid here + while ((get_time--!= 0) && ((res = property_get("persist.mtk.wcn.combo.chipid", chip_id, NULL)) < 6)) { + ERR("get chip id fail, retry"); + usleep(200000); + } + DBG("get chip id is:%s\n", chip_id); + if (strcmp(chip_id, "0x6572") == 0 || strcmp(chip_id, "0x6582") == 0 || + strcmp(chip_id, "0x6580") == 0 || strcmp(chip_id, "0x6592") == 0 || strcmp(chip_id, "0x6571") == 0 || + strcmp(chip_id, "0x8127") == 0 || strcmp(chip_id, "0x0335") == 0 ||strcmp(chip_id, "0x8163") == 0) { + gps_epo_type = 1; // GPS only + } else if (strcmp(chip_id, "0x6630") == 0 || strcmp(chip_id, "0x6752") == 0 || strcmp(chip_id, "0x6755") == 0) { + gps_epo_type = 0; // G+G + } else { + gps_epo_type = 0; // Default is G+G + } + if (gps_epo_type == 0) { + for (idx = 0; idx < cnt; idx++) { + if (!read_prop(mnl_prop_path[idx])) + break; + } + if ((gnss_mode != 0) && (gnss_mode != 2)) { + gps_epo_type = 1; + } + } +#endif + return 0; +} + +static void +mtk_gps_cleanup(void) +{ + GpsState* s = _gps_state; + TRC(); + + if (mtk_cleanup() != 0) + ERR("mtk cleanup error!!"); + // make sure gps_stop has set state to GPS_STATUS_ENGINE_OFF by callback function + if (s->start_flag) + get_condition(&lock_for_sync[M_STOP]); + if (lock_for_sync[M_STOP].condtion == 1) { + // make sure gps_stop has set state to GPS_STATUS_ENGINE_OFF in next time + lock_for_sync[M_STOP].condtion = 0; + } + if (s->init) + gps_state_done(s); +#if EPO_SUPPORT + s->thread_epo_exit_flag = 1; + get_condition(&lock_for_sync[M_THREAD_EXIT]); +#endif + DBG("mtk_gps_cleanup done"); + // return NULL; +} +#if EPO_SUPPORT +int mtk_gps_epo_file_time_hal(long long uTime[]); +int +mtk_epo_is_expired(int wifi_tragger) { + long long uTime[3]; + memset(uTime, 0, sizeof(uTime)); + // time_t time_st; + time_t now = time(NULL); + struct tm tm_utc; + unsigned long time_utc; + long long etime = gps_epo_period*24*60*60; + long long expired_set = 0; + int download_day = 0; + + // time(&time_st); + gmtime_r(&now, &tm_utc); + time_utc = mktime(&tm_utc); + mtk_gps_epo_file_time_hal(uTime); + + if (wifi_tragger) { + expired_set = (long long)wifi_epo_period*24*60*60; // for wifi tragger we change checking expired time to 1 day. + } else if ((uTime[2] - uTime[0]) < etime) { + download_day = (uTime[2] - uTime[0])/(24*60*60); + // DBG("epo data downloaded dat: %d\n", download_day); + if (download_day < 3) { + expired_set = 0; + } else if (download_day < 6) { + expired_set = 2*24*60*60; + } else if ((6 <= download_day) && (download_day < 9)) { + expired_set = 5*24*60*60; + } else if ((9 <= download_day) && (download_day < 12)) { + expired_set = 7*24*60*60; + } else if ((12 <= download_day) && (download_day < 15)) { + expired_set = 7*24*60*60; + } else if ((15 <= download_day) && (download_day < 18)) { + expired_set = 7*24*60*60; + } else if (download_day >= 18) { + expired_set = 7*24*60*60; + } + } else { + expired_set = etime; + } + + DBG("current time: %ld, current time:%s", time_utc, ctime(&time_utc)); + DBG("EPO start time: %lld, EPO start time: %s", uTime[0], ctime(&uTime[0])); + // DBG("EPO expired_set: %lld", expired_set); + if (time_utc >= (expired_set + uTime[0])) { + DBG("EPO file is expired"); + gps_epo_file_count = 0; + return 1; + } else { + DBG("EPO file is valid, no need update"); + return 0; + } +} +#endif +int +mtk_gps_start() +{ + GpsState* s = _gps_state; + int err; + int count=0; + + if (!s->init) { + ERR("%s: called with uninitialized state !!", __FUNCTION__); + return -1; + } + + DBG("mtk_gps_start enter while loop"); + while (s->start_flag == 1) { + usleep(100000); + count++; + DBG("mtk_gps_start:start_flag = %d delay=%d \n", s->start_flag, count*100); + } + + if ((err = mtk_start())) { + ERR("mtk_start err = %d", err); + return -1; + } +#if EPO_SUPPORT + gps_download_epo_enable(); + DBG("gps_epo_enable=%d, s->epo_data_updated=%d\n", gps_epo_enable, s->epo_data_updated); + DBG("nw_type=%d, nw_connected=%d\n", nw_type, nw_connected, epo_download_failed); + if (gps_epo_enable) { // && (s->epo_data_updated == 0)) + if (access(EPO_FILE_HAL, 0) == -1) { + DBG("no EPOHAL file, the EPO.DAT is not exsited, or is the latest one\n"); + // check if EPO.DAT existed + if (access(EPO_FILE, 0) == -1) { + // request download + DBG("Both EPOHAL.DAT and EPO.DAT are not existed, download request 1"); + gps_download_epo(s); + } + else { + // check if EPO.DAT is expired + if (mtk_epo_is_expired(0)) { + DBG("EPOHAL.DAT is not existed and EPO.DAT expired, download request 2"); + gps_download_epo(s); + } + } + } else { + if (((nw_type == nw_data) && (nw_connected == 1) && epo_download_failed) + || ((nw_connected == 0) && epo_download_failed)|| (epo_download_failed == 0)) { + // to check if EPOHAL.DAT is expired. + if (mtk_epo_is_expired(0)) { + DBG("EPOHAL is expired, download request 3"); + unlink(EPO_FILE_HAL); + gps_download_epo(s); + } else { + DBG("EPOHAL is existed and no expired, tell agent to update"); + // char buf[] = {MNL_CMD_UPDATE_EPO_FILE}; + // char cmd = HAL_CMD_STOP_UNKNOWN; + int offset = 0; + char buff[1024] = {0}; + + unlink(EPO_FILE); + buff_put_int(MNL_CMD_UPDATE_EPO_FILE, buff, &offset); + err = mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buff, sizeof(buff)); + if (-1 == err) { + ERR("Request update epo file fail\n"); + } else { + DBG("Request update epo file successfully\n"); + } + } + } + } + } +#endif + get_condition(&lock_for_sync[M_START]); + DBG("HAL thread has initialiazed\n"); + gps_state_start(s); + + sta.status = GPS_STATUS_ENGINE_ON; + DBG("sta.status = GPS_STATUS_ENGINE_ON\n"); + callback_backup_mtk.base.status_cb(&sta); + sta.status = GPS_STATUS_SESSION_BEGIN; + DBG("sta.status = GPS_STATUS_SESSION_BEGIN\n"); + callback_backup_mtk.base.status_cb(&sta); + + callback_backup_mtk.base.acquire_wakelock_cb(); // avoid cpu to sleep + if (lock_for_sync[M_STOP].condtion == 1) { + lock_for_sync[M_STOP].condtion = 0; // make sure gps_stop has set state to GPS_STATUS_ENGINE_OFF in next time + } + s->start_flag = 1; + DBG("s->start_flag = 1\n"); + return 0; +} + +#ifdef GPS_AT_COMMAND +/*for GPS AT command test*/ +int mtk_gps_test_start(int test_num, int prn_num, int time_delay, int test_mode) { + + GpsState* s = _gps_state; + int err; + + if ((MNL_AT_TEST_STATE != MNL_AT_TEST_UNKNOWN) && test_mode_flag) { + DBG("[SMS test mode] Timeout, test_stop() before test_start()"); + mtk_gps_test_stop(); + } + + hal_test_data.test_num = test_num; + hal_test_data.prn_num = prn_num; + hal_test_data.time_delay = time_delay; + time(&start_time); + + // ithis code is moved from stop function to here to keep avg value for AT%GPS(GNSS) or AT%GPS=?(GNSS=?) + Avg_CNo = 0; + Dev_CNr = (int*)malloc(sizeof(int)*hal_test_data.test_num); + memset(Dev_CNr, 0, test_num*sizeof(int)); + + if ((0 == hal_test_data.test_num) && (0 == test_mode)) { + ERR("%s: test number is 0!!", __FUNCTION__); + return -1; + } + if (1 == test_mode) { + DBG("Signal test mode"); + MNL_AT_SIGNAL_MODE = 1; + } else { + DBG("Normal test mode"); + MNL_AT_TEST_FLAG = 1; + } + + if (!s->init) { + ERR("%s: called with uninitialized state !!", __FUNCTION__); + return -1; + } + + MNL_AT_TEST_STATE = MNL_AT_TEST_INPROGRESS; + + if ((err = mtk_start())) { + ERR("mtk_start err = %d", err); + MNL_AT_TEST_STATE = MNL_AT_TEST_UNKNOWN; + MNL_AT_TEST_FLAG = 0; + return -1; + } + + TRC(); + gps_state_test_start(s); + return 0; +} +int +mtk_gps_test_stop() +{ + GpsState* s = _gps_state; + int err; + test_mode_flag = 1; + + if (!s->init) { + ERR("%s: called with uninitialized state !!", __FUNCTION__); + return -1; + } + if ((err = mtk_stop())) { + ERR("mtk_stop err = %d", err); + return -1; + } + + TRC(); + gps_state_test_stop(s); + + hal_test_data.test_num = 0; + hal_test_data.prn_num = 0; + hal_test_data.time_delay = 0; + MNL_AT_TEST_FLAG = 0; + MNL_AT_SIGNAL_MODE = 0; + MNL_AT_TEST_STATE = MNL_AT_TEST_UNKNOWN; + + MNL_AT_SET_ALARM = 0; + MNL_AT_CANCEL_ALARM = 0; + MNL_AT_SIGNAL_TEST_BEGIN = 0; + + // release the variable + Success_Num = 0; + Completed_Num = 0; + Wait_Num = 0; + CNo = 0; + DCNo = 0; + Dev_CNo = 0; + Err_Code = 1; + test_num = 0; + + if (NULL != Dev_CNr) { + DBG("Free Dev_CNr"); + free(Dev_CNr); + } + return 0; +} + +int +mtk_gps_test_inprogress() +{ + int ret = -1; + + if ((MNL_AT_TEST_STATE == MNL_AT_TEST_DONE) || (MNL_AT_TEST_STATE == MNL_AT_TEST_RESULT_DONE)) { + DBG("**AT Command test done!!"); + ret = MNL_AT_TEST_DONE; + } else if (MNL_AT_TEST_STATE == MNL_AT_TEST_INPROGRESS) { + DBG("**AT Command test is in progress!!"); + ret = MNL_AT_TEST_INPROGRESS; + } else { + DBG("**AT Command test status unknown!!"); + ret = MNL_AT_TEST_UNKNOWN; + } + return ret; +} +#endif +int +mtk_gps_stop() +{ + GpsState* s = _gps_state; + int err; + int count=0; + + if (!s->init) { + ERR("%s: called with uninitialized state !!", __FUNCTION__); + return -1; + } + + DBG("mtk_gps_stop enter while loop"); + while (s->start_flag == 0) { + usleep(100000); + count++; + DBG("mtk_gps_stop:start_flag = %d delay=%d \n", s->start_flag, count*100); + } + + if ((err = mtk_stop())) { + ERR("mtk_stop err = %d", err); + return -1; + } + + TRC(); + gps_state_stop(s); + return 0; +} + +static int +mtk_gps_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) +{ + ntp_context inject_ntp; + long long time_s = 0; + char buff[1024] = {0}; + int offset = 0; + + TRC(); + time_s = time/1000; + DBG("inject time= %lld, ctime = %s, timeReference = %lld, uncertainty =%d\n", + time, ctime(&time_s), timeReference, uncertainty); + memcpy(&(inject_ntp.time), &time, sizeof(GpsUtcTime)); + inject_ntp.timeReference = timeReference; + inject_ntp.uncertainty = uncertainty; + + buff_put_int(MNL_CMD_GPS_INJECT_TIME, buff, &offset); + buff_put_struct(&inject_ntp, sizeof(ntp_context), buff, &offset); + if (g_agps_ctx.send_fd >= 0) { + int res = mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + } else { + ERR("g_agps_ctx.send_fd is not initialized\n"); + } + return 0; +} + +static int +mtk_gps_inject_location(double latitude, double longitude, float accuracy) +{ + nlp_context nlp_location; + char buff[1024] = {0}; + int offset = 0; + + if (clock_gettime(CLOCK_MONOTONIC , &nlp_location.ts) == -1) { + ERR("clock_gettime failed reason=[%s]\n", strerror(errno)); + return -1; + } + DBG("ts.tv_sec= %lld, ts.tv_nsec = %lld\n", nlp_location.ts.tv_sec, nlp_location.ts.tv_nsec); + DBG("inject location lati= %f, longi = %f, accuracy =%f\n", latitude, longitude, accuracy); + + nlp_location.latitude = latitude; + nlp_location.longitude = longitude; + nlp_location.accuracy = accuracy; + nlp_location.type= 0; + nlp_location.started = started; + mtk_gps_update_location(&nlp_location); + buff_put_int(MNL_CMD_GPS_INJECT_LOCATION, buff, &offset); + buff_put_struct(&nlp_location, sizeof(nlp_context), buff, &offset); + if (g_agps_ctx.send_fd >= 0) { + int res = mtk_daemon_send(g_agps_ctx.send_fd, MTK_HAL2MNLD, buff, sizeof(buff)); + } + else { + ERR("g_agps_ctx.send_fd is not initialized\n"); + } + return 0; +} + +static void +mtk_gps_delete_aiding_data(GpsAidingData flags) +{ + /*workaround to trigger hot/warm/cold/full start*/ + #define FLAG_HOT_START GPS_DELETE_RTI + #define FLAG_WARM_START GPS_DELETE_EPHEMERIS + #define FLAG_COLD_START (GPS_DELETE_EPHEMERIS | GPS_DELETE_POSITION | GPS_DELETE_TIME | GPS_DELETE_IONO | GPS_DELETE_UTC | GPS_DELETE_HEALTH) + #define FLAG_FULL_START (GPS_DELETE_ALL) + #define FLAG_AGPS_START (GPS_DELETE_EPHEMERIS | GPS_DELETE_ALMANAC | GPS_DELETE_POSITION | GPS_DELETE_TIME | GPS_DELETE_IONO | GPS_DELETE_UTC) + GpsState* s = _gps_state; + + DBG("%s:0x%X\n", __FUNCTION__, flags); + + gps_state_restart(s); + + if (flags == FLAG_HOT_START) { + DBG("Send MNL_CMD_RESTART_HOT in HAL\n"); + mtk_restart(MNL_CMD_RESTART_HOT); + } else if (flags == FLAG_WARM_START) { + DBG("Send MNL_CMD_RESTART_WARM in HAL\n"); + mtk_restart(MNL_CMD_RESTART_WARM); + } else if (flags == FLAG_COLD_START) { + DBG("Send MNL_CMD_RESTART_AGPS/COLD in HAL\n"); + mtk_restart(MNL_CMD_RESTART_COLD); + } else if (flags == FLAG_FULL_START) { + DBG("Send MNL_CMD_RESTART_FULL in HAL\n"); + mtk_restart(MNL_CMD_RESTART_FULL); + } else if (flags == FLAG_AGPS_START) { + DBG("Send MNL_CMD_RESTART_AGPS in HAL\n"); + mtk_restart(MNL_CMD_RESTART_AGPS); + } +} + +static int mtk_gps_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, + uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time) +{ + // FIXME - support fix_frequency + // only standalone supported for now. + DBG("set report location time interval is %d\n", min_interval); + if (min_interval <= 1000) + report_time_interval = 1; + else + report_time_interval = (float)min_interval/1000; + DBG("set report location time interval is %f s\n", report_time_interval); + TRC(); + return 0; +} + +#if EPO_SUPPORT +void retry_alarm_handler(sigval_t v) +{ + int timeout = (int)v.sival_int; + + // DBG("timeout =%d\n", timeout); + epo_download_retry = 1; + DBG("epo_download_retry is =%d\n", epo_download_retry); +} + +static int set_retry_alarm_handler(int timeout) +{ + int err = 0; + + if (retry_timer.fd != C_INVALID_TIMER) { + if (err = timer_delete(retry_timer.fd)) { + DBG("timer_delete(%d) = %d (%s)\n", retry_timer.fd, errno, strerror(errno)); + return -1; + } + retry_timer.fd = C_INVALID_TIMER; + } + if (retry_timer.fd == C_INVALID_TIMER) { + memset(&retry_timer.evt, 0x00, sizeof(retry_timer.evt)); + retry_timer.evt.sigev_value.sival_ptr = &retry_timer.fd; + retry_timer.evt.sigev_value.sival_int = timeout; + retry_timer.evt.sigev_notify = SIGEV_THREAD; + retry_timer.evt.sigev_notify_function = retry_alarm_handler; + if ((err = timer_create(CLOCK_REALTIME, &retry_timer.evt, &retry_timer.fd))) { + DBG("timer_create = %d(%s)\n", errno, strerror(errno)); + return -1; + } + } + retry_timer.expire.it_interval.tv_sec = 0; + retry_timer.expire.it_interval.tv_nsec = 0; + retry_timer.expire.it_value.tv_sec = timeout; + retry_timer.expire.it_value.tv_nsec = 0; + if ((err = timer_settime(retry_timer.fd, 0, &retry_timer.expire, NULL))) { + DBG("timer_settime = %d(%s)\n", errno, strerror(errno)); + return -1; + } + DBG("(%d, %d)\n", retry_timer.fd, retry_timer.expire); + return 0; +} +int mtk_gps_epo_file_update(); +static void *thread_epo_file_update(void* arg) { + + GpsState* s = (GpsState *)arg; + int schedule_delay = 100; + DBG("EPO thread start"); + while (1) { + usleep(schedule_delay*1000); + if (s->thread_epo_exit_flag == 1) { + DBG("EPO thread exit\n"); + break; + } + gps_download_epo_enable(); + if (s->epo_data_updated == 1) { + DBG("EPO data download begin..."); + epo_download_failed = 0; + // s->epo_data_updated = 0; + gps_download_epo_file_name(gps_epo_file_count); + mtk_gps_epo_file_update(); + if (epo_download_failed == 1) { + s->epo_data_updated = 0; + } + } + // DBG("epo_download_retry =%d, started=%d\n", epo_download_retry, started); + if (started || (nw_type == nw_wifi)) { + if (nw_connected && epo_download_failed && epo_download_retry) { + // if download has failed last time, we should complete downloading. + long long uTime[3] ={0}; + // time_t time_st; + time_t now = time(NULL); + struct tm tm_utc; + unsigned long time_utc; + int file_count_temp = 0; + static int file_retrying = 50; // 50 for first restore + static int retry_time = 0; + + if (file_retrying == 50) { + file_retrying = gps_epo_file_count; + } + file_count_temp = gps_epo_file_count; + DBG("EPO data download resume...file_count_temp=%d\n", file_count_temp); + // time(&time_st); + gmtime_r(&now, &tm_utc); + time_utc = mktime(&tm_utc); + mtk_gps_epo_file_time_hal(uTime); + + if (time_utc >= (uTime[0] + 24*60*60)) { + // if epo date is expired > 1 day, we should begin with first file. + epo_download_failed = 0; + gps_epo_file_count = 0; + s->epo_data_updated = 1; + unlink(EPO_FILE_HAL); + } else { // if epo data is expired < 1 day, we can begin with failed file last time. + gps_download_epo_file_name(gps_epo_file_count); + mtk_gps_epo_file_update(); + } + DBG("gps_epo_file_count=%d\n", gps_epo_file_count); + if (file_count_temp == gps_epo_file_count) { + int time_out = 15; // delay 15 s + + if (file_retrying == gps_epo_file_count) { + retry_time++; + } + else { + file_retrying = gps_epo_file_count; + retry_time = 0; + } + DBG("retry_time=%d, time_out=%d\n", retry_time, time_out); + if (retry_time < 10) { + epo_download_retry = 0; + set_retry_alarm_handler(time_out); + } + else { + epo_download_failed = 0; + retry_time = 0; + file_retrying = 50; + } + } + } + } + // if wifi connection, we trigger epo download. + if ((s->epo_data_updated == 0) && gps_epo_wifi_trigger && gps_epo_enable) { + if ((epo_download_failed == 0) && nw_connected && (nw_type == nw_wifi)) { + if (mtk_epo_is_expired(1)) { + DBG("EPO data download wifi tragger..."); + gps_download_epo(s); + unlink(EPO_FILE_HAL); + } + } + } + if ((s->epo_data_updated == 0) && (epo_download_failed == 0)) + { + schedule_delay = 2000; + } + else + { + schedule_delay = 100; + } + } + // pthread_exit(NULL); + release_condition(&lock_for_sync[M_THREAD_EXIT]); + DBG("EPO thread exit done"); + return NULL; +} + + // zqh: download EPO by request +int mtk_gps_epo_interface_init(GpsXtraCallbacks* callbacks) { + TRC(); + int ret = -1; + GpsState* s = _gps_state; + if (s->init) { + mGpsXtraCallbacks = *callbacks; + ret = 0; + } + retry_timer.fd = C_INVALID_TIMER; + + // start thread to write data to file + ret = pthread_create(&s->thread_epo, NULL, thread_epo_file_update, s); + if (0 != ret) { + ERR("EPO thread create fail: %s\n", strerror(errno)); + return ret; + } + s->thread_epo_exit_flag = 0; + DBG("mtk_gps_epo_interface_init done"); + return ret; +} + + +int mtk_gps_inject_epo_data(char* data, int length) { +#if 0 + GpsState* s = _gps_state; + if (length <= 0) { + ERR("EPO data lengh error!!"); + return -1; + } + + epo_data.length = length; + epo_data.data = data; + + s->epo_data_updated = 1; + DBG("length = %d, epo_data.length = %d", length, epo_data.length); + DBG("EPO download done, epo_data_updated = %d\n", s->epo_data_updated); +#endif + TRC(); + return 0; +} + +static const GpsXtraInterface mtkGpsXtraInterface = { + sizeof(GpsXtraInterface), + mtk_gps_epo_interface_init, + mtk_gps_inject_epo_data, +}; +#endif + +// download EPO by request end +int mtk_gps_measurement_init(GpsMeasurementCallbacks* callbacks) { + DBG("mtk_gps_measurement_init\n"); + int err = -1; + GpsState* s = _gps_state; + if ((err = mtk_measurement_init())) { + ERR("mtk_measurement_init err = %d", err); + return -1; + } + measurement_callbacks = *callbacks; + gpsmeasurement_init_flag = 1; + DBG("mtk_gps_measurement_init done\n"); + return 0; +} +void mtk_gps_measurement_close() { + DBG("mtk_gps_measurement_close\n"); + + int err = -1; + GpsState* s = _gps_state; + + if ((err = mtk_measurement_close())) { + ERR("mtk_measurement_close err = %d", err); + } + + gpsmeasurement_init_flag = 0; + DBG("mtk_gps_measurement_close done\n"); + return; +} + +static const GpsMeasurementInterface mtkGpsMeasurementInterface = { + sizeof(GpsMeasurementInterface), + mtk_gps_measurement_init, + mtk_gps_measurement_close, +}; + +int mtk_gps_navigation_init(GpsNavigationMessageCallbacks* callbacks) { + DBG("mtk_gps_navigation_init\n"); + int err = -1; + GpsState* s = _gps_state; + if ((err = mtk_navigation_init())) { + ERR("mtk_navigation_init err = %d", err); + return -1; + } + navigation_callbacks = *callbacks; + gpsnavigation_init_flag = 1; + DBG("mtk_gps_navigation_init done"); + return 0; +} + +void mtk_gps_navigation_close() { + DBG("mtk_gps_navigation_close\n"); + + int err = -1; + GpsState* s = _gps_state; + if ((err = mtk_navigation_close())) { + ERR("mtk_navigation_close err = %d", err); + } + + gpsnavigation_init_flag = 0; + DBG("mtk_gps_navigation_close done\n"); + return NULL; +} + +static const GpsNavigationMessageInterface mtkGpsNavigationMessageInterface = { + sizeof(GpsNavigationMessageInterface), + mtk_gps_navigation_init, + mtk_gps_navigation_close, +}; + +static const void* +mtk_gps_get_extension(const char* name) +{ + TRC(); + DBG("mtk_gps_get_extension name=[%s]\n", name); +#if EPO_SUPPORT + if (!strcmp(name, GPS_XTRA_INTERFACE)) + return (void*)(&mtkGpsXtraInterface); +#endif + if (strncmp(name, "agps", strlen(name)) == 0) { + return &mtkAGpsInterface; + } + if (strncmp(name, "gps-ni", strlen(name)) == 0) { + return &mtkGpsNiInterface; + } + if (strncmp(name, "agps_ril", strlen(name)) == 0) { + return &mtkAGpsRilInterface; + } + if (strncmp(name, "supl-certificate", strlen(name)) == 0) { + return &mtkSuplCertificateInterface; + } + if (strncmp(name, GPS_MEASUREMENT_INTERFACE, strlen(name)) == 0) { + return &mtkGpsMeasurementInterface; + } + if (strncmp(name, GPS_NAVIGATION_MESSAGE_INTERFACE, strlen(name)) == 0) { + return &mtkGpsNavigationMessageInterface; + } + return NULL; +} +#if EPO_SUPPORT +int +mtk_gps_sys_read_lock(int fd, off_t offset, int whence, off_t len) { + + struct flock lock; + + lock.l_type = F_RDLCK; + lock.l_start = offset; + lock.l_whence = whence; + lock.l_len = len; + + if (fcntl(fd, F_SETLK, &lock) < 0) { + return -1; + } + + return 0; +} + +int +mtk_gps_sys_write_lock(int fd, off_t offset, int whence, off_t len) { + struct flock lock; + + lock.l_type = F_WRLCK; + lock.l_start = offset; + lock.l_whence = whence; + lock.l_len = len; + if (fcntl(fd, F_SETLK, &lock) < 0) { + return -1; + } + + return 0; +} + +static unsigned int +mtk_gps_sys_get_file_size() { + unsigned int fileSize; + int res_epo, res_epo_hal; + struct stat st; + char *epo_file = EPO_FILE; + char *epo_file_hal = EPO_FILE_HAL; + char epofile[32] = {0}; + res_epo = access(EPO_FILE, F_OK); + res_epo_hal = access(EPO_FILE_HAL, F_OK); + if (res_epo < 0 && res_epo_hal < 0) { + DBG("no EPO data yet\n"); + return -1; + } + if (res_epo_hal == 0) { /*EPOHAL.DAT is here*/ + // DBG("find EPOHAL.DAT here\n"); + strcpy(epofile, epo_file_hal); + } + else if (res_epo == 0) { /*EPO.DAT is here*/ + // DBG("find EPO.DAT here\n"); + strcpy(epofile, epo_file); + } + else + ERR("unknown error happened\n"); + if (stat(epofile, &st) < 0) { + ERR("Get file size error, return\n"); + return 0; + } + + fileSize = st.st_size; + // DBG("EPO file size: %d\n", fileSize); + return fileSize; +} +void GpsToUtcTime(int i2Wn, double dfTow, time_t* uSecond) +{ + struct tm target_time; + int iYearsElapsed; // Years since 1980. + unsigned int iDaysElapsed; // Days elapsed since Jan 1, 1980. + double dfSecElapsed; + unsigned int fgLeapYear; + int pi2Yr; + int pi2Mo; + int pi2Day = 0; + int pi2Hr; + int pi2Min; + double pdfSec; + int i; + + + // Number of days into the year at the start of each month (ignoring leap + // years). + unsigned int doy[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + + // Convert time to GPS weeks and seconds + iDaysElapsed = i2Wn * 7 + ((int)dfTow / 86400) + 5; + dfSecElapsed = dfTow - ((int)dfTow / 86400) * 86400; + + + // decide year + iYearsElapsed = 0; // from 1980 + while (iDaysElapsed >= 365) + { + if ((iYearsElapsed % 100) == 20) { // if year % 100 == 0 + if ((iYearsElapsed % 400) == 20) { // if year % 400 == 0 + if (iDaysElapsed >= 366) { + iDaysElapsed -= 366; + } else { + break; + } + } else { + iDaysElapsed -= 365; + } + } else if ((iYearsElapsed % 4) == 0) { // if year % 4 == 0 + if (iDaysElapsed >= 366) { + iDaysElapsed -= 366; + } else { + break; + } + } else { + iDaysElapsed -= 365; + } + iYearsElapsed++; + } + pi2Yr = 1980 + iYearsElapsed; + + + // decide month, day + fgLeapYear = 0; + if ((iYearsElapsed % 100) == 20) { // if year % 100 == 0 + if ((iYearsElapsed % 400) == 20) { // if year % 400 == 0 + fgLeapYear = 1; + } + } + else if ((iYearsElapsed % 4) == 0) { // if year % 4 == 0 + fgLeapYear = 1; + } + + if (fgLeapYear) { + for (i = 2; i < 12; i++) { + doy[i] += 1; + } + } + for (i = 0; i < 12; i++) + { + if (iDaysElapsed < doy[i]) { + break; + } + } + pi2Mo = i; + if (i > 0) { + pi2Day = iDaysElapsed - doy[i-1] + 1; + } + + // decide hour, min, sec + pi2Hr = dfSecElapsed / 3600; + pi2Min = ((int)dfSecElapsed % 3600) / 60; + pdfSec = dfSecElapsed - ((int)dfSecElapsed / 60) * 60; + + // change the UTC time to seconds + memset(&target_time, 0, sizeof(target_time)); + target_time.tm_year = pi2Yr - 1900; + target_time.tm_mon = pi2Mo - 1; + target_time.tm_mday = pi2Day; + target_time.tm_hour = pi2Hr; + target_time.tm_min = pi2Min; + target_time.tm_sec = pdfSec; + target_time.tm_isdst = -1; + *uSecond = mktime(&target_time); + if (*uSecond < 0) { + ERR("Convert UTC time to seconds fail, return\n"); + } + +} + + +static int +mtk_gps_sys_epo_period_start(int fd, unsigned int* u4GpsSecs, time_t* uSecond) { // no file lock + char szBuf[MTK_EPO_ONE_SV_SIZE]; + int pi2WeekNo; + unsigned int pu4Tow; + + // if (fread(szBuf, 1, MTK_EPO_ONE_SV_SIZE, pFile) != MTK_EPO_ONE_SV_SIZE) { + if (read(fd, szBuf, MTK_EPO_ONE_SV_SIZE) != MTK_EPO_ONE_SV_SIZE) { + return -1; + } + + *u4GpsSecs = (((*(unsigned int*)(&szBuf[0])) & 0x00FFFFFF) *3600); + pi2WeekNo = (*u4GpsSecs) / 604800; + pu4Tow = (*u4GpsSecs) % 604800; + + // TRC(); + // DBG("pi2WeekNo = %d, pu4Tow = %d\n", pi2WeekNo, pu4Tow); + GpsToUtcTime(pi2WeekNo, pu4Tow, uSecond); // to get UTC second + return 0; +} + + +static int +mtk_gps_sys_epo_period_end(int fd, unsigned int *u4GpsSecs, time_t* uSecond) { // no file lock + int fileSize; + char szBuf[MTK_EPO_ONE_SV_SIZE]; + int pi2WeekNo; + unsigned int pu4Tow; + + fileSize = mtk_gps_sys_get_file_size(); + if (fileSize < MTK_EPO_ONE_SV_SIZE) { + return -1; + } + + if (lseek(fd, (fileSize - MTK_EPO_ONE_SV_SIZE), SEEK_SET) == -1) + ERR("lseek error: %s\n", strerror(errno)); + if (read(fd, szBuf, MTK_EPO_ONE_SV_SIZE) != MTK_EPO_ONE_SV_SIZE) { + return -1; + } + + *u4GpsSecs = (((*(unsigned int*)(&szBuf[0])) & 0x00FFFFFF) *3600); + (*u4GpsSecs) += 21600; + + pi2WeekNo = (*u4GpsSecs) / 604800; + pu4Tow = (*u4GpsSecs) % 604800; + + // TRC(); + // DBG("pi2WeekNo = %d, pu4Tow = %d\n", pi2WeekNo, pu4Tow); + GpsToUtcTime(pi2WeekNo, pu4Tow, uSecond); + + return 0; +} + +int +mtk_gps_epo_file_time_hal(long long uTime[]) { + + TRC(); + struct stat filestat; + int fd = 0; + int addLock, res_epo, res_epo_hal; + unsigned int u4GpsSecs_start; // GPS seconds + unsigned int u4GpsSecs_expire; + char *epo_file = EPO_FILE; + char *epo_file_hal = EPO_FILE_HAL; + char epofile[32] = {0}; + time_t uSecond_start; // UTC seconds + time_t uSecond_expire; + int ret = 0; + pthread_mutex_t mutx = PTHREAD_MUTEX_INITIALIZER; + + ret = pthread_mutex_lock(&mutx); + res_epo = access(EPO_FILE, F_OK); + res_epo_hal = access(EPO_FILE_HAL, F_OK); + if (res_epo < 0 && res_epo_hal < 0) { + DBG("no EPO data yet\n"); + ret = pthread_mutex_unlock(&mutx); + return -1; + } + if (res_epo_hal== 0) { /*EPOHAL.DAT is here*/ + // DBG("find EPOHAL.DAT here\n"); + strcpy(epofile, epo_file_hal); + } else if (res_epo == 0) { /*EPO.DAT is here*/ + // DBG("find EPO.DAT here\n"); + strcpy(epofile, epo_file); + } else + ERR("unknown error happened\n"); + + // open file + fd = open(epofile, O_RDONLY); + if (fd < 0) { + ERR("Open EPO fail, return\n"); + ret = pthread_mutex_unlock(&mutx); + return -1; + } + + // Add file lock + if (mtk_gps_sys_read_lock(fd, 0, SEEK_SET, 0) < 0) { + ERR("Add read lock failed, return\n"); + close(fd); + ret = pthread_mutex_unlock(&mutx); + return -1; + } + + // EPO start time + if (mtk_gps_sys_epo_period_start(fd, &u4GpsSecs_start, &uSecond_start)) { + ERR("Get EPO file start time error, return\n"); + close(fd); + ret = pthread_mutex_unlock(&mutx); + return -1; + } else { + uTime[0] = (long long)uSecond_start; + // DBG("The Start time of EPO file is %lld", uTime[0]); + // DBG("The start time of EPO file is %s", ctime(&uTime[0])); + } + + // download time + stat(epofile, &filestat); + uTime[1] = (long long)(filestat.st_mtime); + // uTime[1] = uTime[1] - 8 * 3600; + // DBG("Download time of EPO file is %lld", uTime[1]); + // DBG("Download time of EPO file is %s\n", ctime(&uTime[1])); + + // EPO file expire time + if (mtk_gps_sys_epo_period_end(fd, &u4GpsSecs_expire, &uSecond_expire)) { + ERR("Get EPO file expire time error, return\n"); + close(fd); + ret = pthread_mutex_unlock(&mutx); + return -1; + } else { + uTime[2] = (long long)uSecond_expire; + // DBG("The expire time of EPO file is %lld", uTime[2]); + // DBG("The expire time of EPO file is %s", ctime(&uTime[2])); + } + + close(fd); + ret = pthread_mutex_unlock(&mutx); + return 0; +} + +size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { + size_t written; + written = fwrite(ptr, size, nmemb, stream); + return written; +} +CURLcode curl_easy_download(char* url, char* filename) +{ + CURL *curl = NULL; + FILE *fp = NULL; + CURLcode res; + TRC(); + + curl_global_init(CURL_GLOBAL_DEFAULT); + curl = curl_easy_init(); + if (curl) { + fp = fopen(filename, "w+"); + if (fp == NULL) { + curl_easy_cleanup(curl); + return CURLE_FAILED_INIT; + } + + curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); + // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + fclose(fp); + return res; + } else { + return CURLE_FAILED_INIT; + } + +} +extern char* getEpoUrl(char* filename, char* key); +static int counter = 1; +CURLcode curl_easy_download_epo(void) +{ + int res_val; + CURLcode res; + char gps_epo_md_file_temp[60] = {0}; + char gps_epo_md_key[70] = {0}; + char gps_epo_data_file_name[60] = {0}; + char* url = NULL; + char* key = NULL; + char* md_url = NULL; + char count_str[5]={0}; + TRC(); + + strcat(gps_epo_md_file_temp, "/data/misc/gps/"); + strcat(gps_epo_md_file_temp, gps_epo_md_file_name); + // DBG("gps_epo_md_file_name = %s\n", gps_epo_md_file_name); + strcpy(gps_epo_md_key, "0000000000000000"); + memset(count_str,0,sizeof(count_str)); + sprintf(count_str,"%d", counter); + strcat(gps_epo_md_key, "&counter="); + strcat(gps_epo_md_key, count_str); + md_url = getEpoUrl(gps_epo_md_file_name, gps_epo_md_key); + // DBG("md_url = %s\n", md_url); + if (md_url == NULL) { + DBG("getEpoUrl failed!\n"); + return CURLE_FAILED_INIT; + } + res = curl_easy_download(md_url, gps_epo_md_file_temp); + // DBG("md file curl_easy_download res = %d\n", res); + free(md_url); + memset(gps_epo_md_key, 0 , sizeof(gps_epo_md_key)); + if (res == 0) { + FILE *fp = NULL; + char* key_temp = NULL; + int len = 0; + fp = fopen(gps_epo_md_file_temp, "r"); + if (fp != NULL) { + len = fread(gps_epo_md_key, sizeof(char), sizeof(char)*48, fp); + key_temp = gps_epo_md_key; + fclose(fp); + unlink(gps_epo_md_file_temp); + DBG("gps_epo_md_key before cpy= %s, len=%d\n", gps_epo_md_key, len); + memcpy(gps_epo_md_key, key_temp+32, 16); // comment by rayjf li + gps_epo_md_key[16] = '\0'; + } + else { + strcpy(gps_epo_md_key, "0000000000000000"); + } + counter = 1; + } + else { + strcpy(gps_epo_md_key, "0000000000000000"); + counter ++; + } + // DBG("gps_epo_md_key = %s\n", gps_epo_md_key); + memset(count_str,0,sizeof(count_str)); + sprintf(count_str,"%d", counter); + strcat(gps_epo_md_key, "&counter="); + strcat(gps_epo_md_key, count_str); + url = getEpoUrl(gps_epo_file_name, gps_epo_md_key); + + DBG("url = %s\n", url); + if (url == NULL) { + DBG("getEpoUrl failed!\n"); + return CURLE_FAILED_INIT; + } + strcat(gps_epo_data_file_name, "/data/misc/gps/"); + strcat(gps_epo_data_file_name, gps_epo_file_name); + res = curl_easy_download(url, gps_epo_data_file_name); + DBG("'epo' epo file curl_easy_download res = %d\n", res); + free(url); + if (res == CURLE_OK) { + FILE *fp_temp = NULL; + FILE *fp = NULL; + + counter = 1; + if (gps_epo_file_count == 0) { + unlink(EPO_FILE_HAL); + } + res_val = chmod(gps_epo_data_file_name, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH); + DBG("chmod res_val = %d, %s\n", res_val, strerror(errno)); + fp_temp = fopen(EPO_FILE_HAL, "at"); + if (fp_temp != NULL) { + fp = fopen(gps_epo_data_file_name, "r"); + if (fp != NULL) { + #define buf_size 256 + char data[buf_size] = {0}; + int bytes_in = 0, bytes_out = 0; + int len = 0; + + while ((bytes_in = fread(data, 1, sizeof(data), fp)) > 0 && (bytes_in <= (buf_size* sizeof(char)))) { + bytes_out = fwrite(data, 1, bytes_in, fp_temp); + if (bytes_in != bytes_out) { + DBG("bytes_in = %d,bytes_out = %d\n", bytes_in, bytes_out); + } + len += bytes_out; + // DBG("copying file...%d bytes copied\n",len); + } + fclose(fp); + } else { + ERR("Open merged file fp=NULL\n"); + } + fclose(fp_temp); + } + else { + ERR("Open merged file failed\n"); + } + res_val = chmod(EPO_FILE_HAL, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH); + DBG("chmod res_val = %d, %s\n", res_val, strerror(errno)); + } else { + unlink(gps_epo_data_file_name); + counter ++; + } + return res; +} + +int +mtk_gps_epo_file_update_hal() { + // TRC(); +#if 0 + int fd_write, res; + ssize_t bytes_read; + ssize_t bytes_write; + char* data = epo_data.data; + int length = epo_data.length; + + int result; + DBG("length = %d", length); + DBG("Update EPO HAL file...\n"); + + fd_write = open(EPO_FILE_HAL, O_WRONLY | O_TRUNC | O_CREAT | O_NONBLOCK | O_APPEND, 0641); + if (fd_write < 0) { + ERR("open /data/misc/EPOHAL.DAT error!\n"); + return -1; + } + + if (mtk_gps_sys_write_lock(fd_write, 0, SEEK_SET, 0) < 0) { + ERR("Add read lock failed, return\n"); + close(fd_write); + return -1; + } + + // start copy new data from framework to EPOHAL.DAT + while (length > 0) { + bytes_write = write(fd_write, data, length); + if (bytes_write < 0) { + ERR("Write EPOHAL.DAT error: %s\n", strerror(errno)); + length = 0; + data = NULL; + close(fd_write); + return -1; + } + + DBG("bytes_write = %d\n", bytes_write); + DBG("EPO data: %s", data); + + if (bytes_write <= length) { + data = data + length; + length = length - bytes_write; + DBG("Remain length: %d\n", length); + } + } + + data = NULL; + length = 0; + + // release write lock + close(fd_write); +#else + CURLcode res; + + res = curl_easy_download_epo(); + // DBG("curl_easy_download_epo res = %d\n", res); + if (res != CURLE_OK) { + epo_download_failed = 1; + return -1; + } else { + DBG("download piece file%d done\n", (gps_epo_file_count+1)); + return 0; + } + #endif +} +static unsigned int mtk_gps_epo_get_piece_file_size() +{ + struct stat st; + unsigned int fileSize; + char gps_epo_data_file_name[60] = {0}; + + strcat(gps_epo_data_file_name, "/data/misc/gps/"); + strcat(gps_epo_data_file_name, gps_epo_file_name); + + if (stat(gps_epo_data_file_name, &st) < 0) { + ERR("Get file size error, return\n"); + return 0; + } + fileSize = st.st_size; + DBG("EPO piece file size: %d\n", fileSize); + return fileSize; +} +static int +mtk_gps_epo_piece_data_start(int fd, unsigned int* u4GpsSecs, time_t* uSecond) { + char szBuf[MTK_EPO_ONE_SV_SIZE]; + int pi2WeekNo; + unsigned int pu4Tow; + + // if (fread(szBuf, 1, MTK_EPO_ONE_SV_SIZE, pFile) != MTK_EPO_ONE_SV_SIZE) { + if (read(fd, szBuf, MTK_EPO_ONE_SV_SIZE) != MTK_EPO_ONE_SV_SIZE) { + return -1; + } + + *u4GpsSecs = (((*(unsigned int*)(&szBuf[0])) & 0x00FFFFFF) *3600); + pi2WeekNo = (*u4GpsSecs) / 604800; + pu4Tow = (*u4GpsSecs) % 604800; + + TRC(); + DBG("pi2WeekNo = %d, pu4Tow = %d\n", pi2WeekNo, pu4Tow); + GpsToUtcTime(pi2WeekNo, pu4Tow, uSecond); // to get UTC second + return 0; +} + +static int +mtk_gps_epo_piece_data_end(int fd, unsigned int *u4GpsSecs, time_t* uSecond) { + + int fileSize = 0; + char szBuf[MTK_EPO_ONE_SV_SIZE] = {0}; + int pi2WeekNo; + unsigned int pu4Tow; + + if (-1 != fd) { + + fileSize = mtk_gps_epo_get_piece_file_size(); + if (fileSize < MTK_EPO_ONE_SV_SIZE) { + ERR("Get file size is error\n"); + return -1; + } + if (lseek(fd, (fileSize - MTK_EPO_ONE_SV_SIZE), SEEK_SET) == -1) + ERR("lseek error: %s\n", strerror(errno)); + + if (read(fd, szBuf, MTK_EPO_ONE_SV_SIZE) != MTK_EPO_ONE_SV_SIZE) { + ERR("read epo file end data faied\n"); + return -1; + } + + *u4GpsSecs = (((*(unsigned int*)(&szBuf[0])) & 0x00FFFFFF) *3600); + (*u4GpsSecs) += 21600; + + pi2WeekNo = (*u4GpsSecs) / 604800; + pu4Tow = (*u4GpsSecs) % 604800; + + TRC(); + DBG("pi2WeekNo = %d, pu4Tow = %d\n", pi2WeekNo, pu4Tow); + GpsToUtcTime(pi2WeekNo, pu4Tow, uSecond); + } + return 0; +} +int mtk_gps_epo_server_data_is_changed() +{ + long long uTime_end = 0; + long long uTime_start = 0; + int fd_end = -1; + int fd_start = -1; + char gps_epo_data_file_name_end[60] = {0}; + char gps_epo_data_file_name_start[60] = {0}; + time_t uSecond_start; + time_t uSecond_end; + unsigned int u4GpsSecs_start; + unsigned int u4GpsSecs_end; + int ret = 0; + + strcat(gps_epo_data_file_name_start, "/data/misc/gps/"); + strcat(gps_epo_data_file_name_start, gps_epo_file_name); + + fd_start = open(gps_epo_data_file_name_start, O_RDONLY); + if (fd_start >= 0) { + int res = 0; + res = mtk_gps_epo_piece_data_start(fd_start, &u4GpsSecs_start, &uSecond_start); + if (res == 0) { + uTime_start = (long long)uSecond_start; + } + else { + epo_download_failed = 1; + ret = 1; + ERR("Get start time failed\n"); + } + close(fd_start); + } else { + ERR("Open start file failed\n"); + } + if (gps_epo_file_count > 0) { + gps_download_epo_file_name(gps_epo_file_count - 1); + strcat(gps_epo_data_file_name_end, "/data/misc/gps/"); + strcat(gps_epo_data_file_name_end, gps_epo_file_name); + // open file + fd_end = open(gps_epo_data_file_name_end, O_RDONLY); + if (fd_end >= 0) { + int res = 0; + res = mtk_gps_epo_piece_data_end(fd_end, &u4GpsSecs_end, &uSecond_end); + if (res == 0) { + uTime_end = (long long)uSecond_end; + } else { + epo_download_failed = 1; + ERR("Get end time failed\n"); + ret = 1; + } + close(fd_end); + } else { + ERR("Open end file failed\n"); + } + } else if (gps_epo_file_count == 0) { + uTime_end = uTime_start; + } + + // DBG("gps_epo_data_file_start =%s, end =%s\n", gps_epo_data_file_name_start, gps_epo_data_file_name_end); + DBG("The end time of EPO file is %s, The start time of EPO file is %s\n", + ctime(&uTime_end), ctime(&uTime_start)); + if ((uTime_start - uTime_end) >= (24*60*60)) { + int i; + DBG("The epo data is updated on the server!!!\n"); + for (i = gps_epo_file_count; 0 <= i; i--) { + char gps_epo_piece_file_name[40] = {0}; + + gps_download_epo_file_name(i); + strcat(gps_epo_piece_file_name, "/data/misc/gps/"); + strcat(gps_epo_piece_file_name, gps_epo_file_name); + unlink(gps_epo_piece_file_name); + } + unlink(EPO_FILE_HAL); + gps_epo_file_count = 0; + return 1; + } + return ret; +} + +int mtk_gps_epo_file_update() { + GpsState* s = _gps_state; + int ret; + int res; + int is_changed = 0; + int count_temp = 10; + int count_mini = 0; + DBG("sta.status = %d\n", sta.status); + + // update framework downlaod data to EPOHAL.DAT + ret = mtk_gps_epo_file_update_hal(); + if (ret < 0) { + ERR("Update EPOHAL.DAT error\n"); + return -1; + } + is_changed = mtk_gps_epo_server_data_is_changed(); + if (is_changed == 1) { + return -1; + } + gps_epo_file_count++; + count_temp = gps_epo_download_days/3; + count_mini = gps_epo_download_days%3; + if (count_mini > 0) { + count_temp++; + } + if (gps_epo_file_count < 10 && gps_epo_file_count < count_temp) { + // gps_download_epo_file_name(); + // gps_download_epo(s); + DBG("Download next epo file continue...\n"); + return 0; + } + else { + int i = 0; + DBG("download epo file completed!file count=%d, epo_download_failed=%d, epo_data_updated=%d\n", + gps_epo_file_count, epo_download_failed, s->epo_data_updated); + + for (i = 0; i < count_temp; i++) { + char gps_epo_data_file_name[60] = {0}; + + gps_download_epo_file_name(i); + strcat(gps_epo_data_file_name, "/data/misc/gps/"); + strcat(gps_epo_data_file_name, gps_epo_file_name); + unlink(gps_epo_data_file_name); + } + s->epo_data_updated = 0; + gps_epo_file_count = 0; + if (epo_download_failed == 1) { + epo_download_failed = 0; + } + if (started) { + // send cmd to MNLD + char cmd = HAL_CMD_STOP_UNKNOWN; + + DBG("GPS driver is running, update epo file via GPS driver\n"); + char buff[1024] = {0}; + int offset = 0; + + unlink(EPO_FILE); + buff_put_int(MNL_CMD_UPDATE_EPO_FILE, buff, &offset); + ret = mtk_daemon_send(mtk_gps.sock, MTK_HAL2MNLD, buff, sizeof(buff)); + + if (-1 == ret) { + ERR("Request update epo file fail\n"); + } else { + DBG("Request update epo file successfully\n"); + } + } + } + return ret; +} +#endif +static const GpsInterface mtkGpsInterface = { + sizeof(GpsInterface), + mtk_gps_init, + mtk_gps_start, + mtk_gps_stop, + mtk_gps_cleanup, + mtk_gps_inject_time, + mtk_gps_inject_location, + mtk_gps_delete_aiding_data, + mtk_gps_set_position_mode, + mtk_gps_get_extension, +#ifdef GPS_AT_COMMAND + mtk_gps_test_start, + mtk_gps_test_stop, + mtk_gps_test_inprogress, +#endif +}; + +const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev) +{ + DBG("gps__get_gps_interface HAL\n"); + /*send message(start, stop, restart, agps info) to MNLD*/ + mtk_gps.sock = socket(PF_LOCAL, SOCK_DGRAM, 0); // for gps message + g_agps_ctx.send_fd = mtk_gps.sock; // for agps message + DBG("HAL<->MNLD sock_fd: %d\n", mtk_gps.sock); + + return &mtkGpsInterface; +} + +static int open_gps(const struct hw_module_t* module, char const* name, + struct hw_device_t** device) { + DBG("open_gps HAL 1\n"); + struct gps_device_t *dev = malloc(sizeof(struct gps_device_t)); + if (dev != NULL) { + memset(dev, 0, sizeof(*dev)); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = (struct hw_module_t*)module; + // dev->common.close = (int (*)(struct hw_device_t*))close_lights; + DBG("open_gps HAL 2\n"); + dev->get_gps_interface = gps__get_gps_interface; + DBG("open_gps HAL 3\n"); + *device = (struct hw_device_t*)dev; + } else { + DBG("malloc failed dev = NULL!\n"); + } + return 0; +} + + +static struct hw_module_methods_t gps_module_methods = { + .open = open_gps +}; + + +struct hw_module_t HAL_MODULE_INFO_SYM = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = GPS_HARDWARE_MODULE_ID, + .name = "Hardware GPS Module", + .author = "The MTK GPS Source Project", + .methods = &gps_module_methods, +}; diff --git a/mtk/gps/hal/inc/hardware/gps_mtk.h b/mtk/gps/hal/inc/hardware/gps_mtk.h new file mode 100644 index 0000000..8a29317 --- /dev/null +++ b/mtk/gps/hal/inc/hardware/gps_mtk.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#ifndef ANDROID_INCLUDE_HARDWARE_GPS_MTK_H +#define ANDROID_INCLUDE_HARDWARE_GPS_MTK_H + +#include <hardware/gps.h> + +__BEGIN_DECLS + +// xen0n: the required bits are already included, don't re-define them. + +/** GPS callback structure with Mediatek extension. */ +typedef struct _GpsCallbacks_mtk { + GpsCallbacks base; + +// gnss_sv_status_callback gnss_sv_status_cb; +} GpsCallbacks_mtk; + +__END_DECLS + +#endif /* ANDROID_INCLUDE_HARDWARE_GPS_MTK_H */ + diff --git a/mtk/gps/libepos/Android.mk b/mtk/gps/libepos/Android.mk new file mode 100644 index 0000000..fea4032 --- /dev/null +++ b/mtk/gps/libepos/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_IS_HOST_MODULE = +LOCAL_MODULE = libepos +LOCAL_MODULE_CLASS = STATIC_LIBRARIES +LOCAL_MODULE_PATH = +LOCAL_MODULE_RELATIVE_PATH = +LOCAL_MODULE_SUFFIX = .a +LOCAL_MULTILIB = 32 +LOCAL_SRC_FILES_32 = libepos.a +include $(BUILD_PREBUILT) diff --git a/mtk/gps/libepos/README b/mtk/gps/libepos/README new file mode 100644 index 0000000..5c1b60c --- /dev/null +++ b/mtk/gps/libepos/README @@ -0,0 +1,23 @@ +Library of EPO feature, it provides secure URL services. + + +WHAT IT DOES? +============= +it provides secure URL services. + +HOW IT WAS BUILT? +================== +It needs the following library from AOSP: +1. libcutils +2. libcrypto +3. libssl +4. libz + +All source/dependency modules of this module are already put in +'vendor\mediatek\proprietary\protect\frameworks\base\epos' folder. + +HOW TO USE IT? +============== +It is proprietary library only for EPO services. And not opened interfaces to other modules. + +All the source code of this library were written by MediaTek co.. diff --git a/mtk/gps/libepos/libepos.a b/mtk/gps/libepos/libepos.a Binary files differnew file mode 100644 index 0000000..d4d5315 --- /dev/null +++ b/mtk/gps/libepos/libepos.a diff --git a/mtk/gralloc_extra/Android.mk b/mtk/gralloc_extra/Android.mk new file mode 100755 index 0000000..07b8c6d --- /dev/null +++ b/mtk/gralloc_extra/Android.mk @@ -0,0 +1,23 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + GraphicBufferExtra.cpp \ + GraphicBufferExtra_hal.cpp + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/../include + +LOCAL_SHARED_LIBRARIES := \ + libhardware \ + libcutils \ + libutils + +LOCAL_EXPORT_C_INCLUDE_DIRS := \ + $(LOCAL_PATH)/include + +LOCAL_MODULE := libgralloc_extra + +include $(BUILD_SHARED_LIBRARY) diff --git a/mtk/gralloc_extra/GraphicBufferExtra.cpp b/mtk/gralloc_extra/GraphicBufferExtra.cpp new file mode 100644 index 0000000..d1cbffc --- /dev/null +++ b/mtk/gralloc_extra/GraphicBufferExtra.cpp @@ -0,0 +1,49 @@ +#define LOG_TAG "GraphicBufferExtra" +#define ATRACE_TAG ATRACE_TAG_GRAPHICS +#include <cutils/log.h> +#include <ui/GraphicBufferExtra.h> +#include <graphics_mtk_defs.h> + +namespace android { +// --------------------------------------------------------------------------- + +ANDROID_SINGLETON_STATIC_INSTANCE( GraphicBufferExtra ) + +static GraphicBufferExtra * s_singleton_obj = NULL; + +GraphicBufferExtra::GraphicBufferExtra() + : mExtraDev(0) +{ + hw_module_t const* module; + int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); + + ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); + if (err == 0) + { + gralloc_extra_open(module, &mExtraDev); + } + + s_singleton_obj = this; +} + +// dlclose +static void __attribute__((destructor)) gralloc_extra_dlclose(void) +{ + if (s_singleton_obj) + { + delete s_singleton_obj; + s_singleton_obj = NULL; + } +} + +GraphicBufferExtra::~GraphicBufferExtra() +{ + if (mExtraDev) + { + gralloc_extra_close(mExtraDev); + } + s_singleton_obj = NULL; +} + +// --------------------------------------------------------------------------- +}; // namespace android diff --git a/mtk/gralloc_extra/GraphicBufferExtra_hal.cpp b/mtk/gralloc_extra/GraphicBufferExtra_hal.cpp new file mode 100755 index 0000000..eba0ab3 --- /dev/null +++ b/mtk/gralloc_extra/GraphicBufferExtra_hal.cpp @@ -0,0 +1,224 @@ + +#define LOG_TAG "GraphicBufferExtra_hal" +#define ATRACE_TAG ATRACE_TAG_GRAPHICS + +#include <stdint.h> +#include <errno.h> + +#include <utils/Errors.h> +#include <utils/Log.h> +#include <utils/Trace.h> + +#include <system/graphics.h> +#include <graphics_mtk_defs.h> + +#include <hardware/gralloc.h> +#include <hardware/gralloc_extra.h> + +#include <ui/GraphicBufferExtra.h> + +/* ---- IMPLEMENTATION macro ---- */ + +#define GRALLOC_EXTRA_PROTOTYPE_(...) ( __VA_ARGS__ ) +#define GRALLOC_EXTRA_ARGS_(...) ( __VA_ARGS__ ) +#define GRALLOC_EXTRA_ARGS_2(...) ( mExtraDev, __VA_ARGS__ ) +#define GRALLOC_EXTRA_CHECK_FAIL_RETURN_(API, ERR) \ +do { \ + if (!mExtraDev) \ + { \ + ALOGD("gralloc extra device is not supported"); \ + return ERR; \ + } \ + \ + if (!mExtraDev->API) \ + { \ + ALOGW("gralloc extra device " #API "(...) is not supported"); \ + return ERR; \ + } \ +} while(0) + + +#define GRALLOC_EXTRA_IMPLEMENTATION_(RET, ERR, API, PROTOTYPE, ARGS) \ +RET android::GraphicBufferExtra:: API PROTOTYPE \ +{ \ + ATRACE_CALL(); \ + RET err; \ + \ + GRALLOC_EXTRA_CHECK_FAIL_RETURN_(API, ERR); \ + \ + err = mExtraDev-> API GRALLOC_EXTRA_ARGS_2 ARGS ; \ + \ + if (err < 0) ALOGW(#API"(...) failed %d", err); \ + \ + return err; \ +} \ +extern "C" RET gralloc_extra_##API PROTOTYPE \ +{ \ + return android::GraphicBufferExtra::get(). API ARGS; \ +} + +/* ---- IMPLEMENTATION start ---- */ + +GRALLOC_EXTRA_IMPLEMENTATION_(int, -1, getIonFd, + GRALLOC_EXTRA_PROTOTYPE_(buffer_handle_t handle, int *idx, int *num), + GRALLOC_EXTRA_ARGS_(handle, idx, num) +) + +GRALLOC_EXTRA_IMPLEMENTATION_(int, -1, getSecureBuffer, + GRALLOC_EXTRA_PROTOTYPE_(buffer_handle_t handle, int *type, int *hBuffer), + GRALLOC_EXTRA_ARGS_(handle, type, hBuffer) +) + +GRALLOC_EXTRA_IMPLEMENTATION_(int, -1, getBufInfo, + GRALLOC_EXTRA_PROTOTYPE_(buffer_handle_t handle, gralloc_buffer_info_t* bufInfo), + GRALLOC_EXTRA_ARGS_(handle, bufInfo) +) + +GRALLOC_EXTRA_IMPLEMENTATION_(int, -1, setBufParameter, + GRALLOC_EXTRA_PROTOTYPE_(buffer_handle_t handle, int mask, int value), + GRALLOC_EXTRA_ARGS_(handle, mask, value) +) + +GRALLOC_EXTRA_IMPLEMENTATION_(int, -1, getMVA, + GRALLOC_EXTRA_PROTOTYPE_(buffer_handle_t handle, int *mvaddr), + GRALLOC_EXTRA_ARGS_(handle, mvaddr) +) + +GRALLOC_EXTRA_IMPLEMENTATION_(int, -1, setBufInfo, + GRALLOC_EXTRA_PROTOTYPE_(buffer_handle_t handle, const char * str), + GRALLOC_EXTRA_ARGS_(handle, str) +) + +/* ---- IMPLEMENTATION start end ---- */ + +#undef GRALLOC_EXTRA_CHECK_FAIL_RETURN_ +#undef GRALLOC_EXTRA_IMPLEMENTATION_ +#undef GRALLOC_EXTRA_PROTOTYPE_ +#undef GRALLOC_EXTRA_ARGS_ +#undef GRALLOC_EXTRA_ARGS_2 + +int android::GraphicBufferExtra::query( + buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_QUERY attribute, void * out_pointer) +{ + ATRACE_CALL(); + int err; + if (!mExtraDev || !mExtraDev->query) + { + ALOGW("gralloc extra device query(...) is not supported"); + return -GRALLOC_EXTRA_NOT_SUPPORTED; + } + err = mExtraDev->query(mExtraDev, handle, attribute, out_pointer); + if (err < 0) + ALOGW("query(0x%x) failed %d", attribute, err); + return err; +} + +int android::GraphicBufferExtra::perform( + buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_PERFORM attribute, void * in_pointer) +{ + ATRACE_CALL(); + int err; + if (!mExtraDev || !mExtraDev->perform) + { + ALOGW("gralloc extra device perform(...) is not supported"); + return -GRALLOC_EXTRA_NOT_SUPPORTED; + } + err = mExtraDev->perform(mExtraDev, handle, attribute, in_pointer); + if (err < 0) + ALOGW("perform(0x%x) failed %d", attribute, err); + return err; +} + + +#if 0 +int android::GraphicBufferExtra::free_sec( + buffer_handle_t handle) +{ + ATRACE_CALL(); + int err; + if (!mExtraDev || !mExtraDev->perform) + { + ALOGW("gralloc extra device perform(...) is not supported"); + return -GRALLOC_EXTRA_NOT_SUPPORTED; + } + err = mExtraDev->free_sec(mExtraDev, handle); + if (err < 0) + ALOGW("free_sec failed %d", err); + return err; +} +#endif + + +extern "C" int gralloc_extra_query( + buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_QUERY attribute, void * out_pointer) +{ + return android::GraphicBufferExtra::get().query(handle, attribute, out_pointer); +} + +extern "C" int gralloc_extra_perform( + buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_PERFORM attribute, void * in_pointer) +{ + return android::GraphicBufferExtra::get().perform(handle, attribute, in_pointer); +} + +#if 0 +extern "C" int gralloc_extra_free_sec(buffer_handle_t handle ) +{ + return android::GraphicBufferExtra::get().free_sec(handle); +} +#endif + + +static int __gralloc_extra_sf_set_int(int *data, int32_t mask, int32_t value) +{ + int32_t old_status; + int32_t new_status; + + old_status = *data; + new_status = ( old_status & (~mask) ); + new_status |= ( value & mask ); + + /* Force modify the const member */ + *data = new_status; + + return GRALLOC_EXTRA_OK; +} + +extern "C" int gralloc_extra_sf_set_status(gralloc_extra_ion_sf_info_t *sf_info, int32_t mask, int32_t value) +{ + return __gralloc_extra_sf_set_int(&sf_info->status, mask, value); +} + +extern "C" int gralloc_extra_sf_set_status2(gralloc_extra_ion_sf_info_t *sf_info, int32_t mask, int32_t value) +{ + return __gralloc_extra_sf_set_int(&sf_info->status2, mask, value); +} + +/* init the sf_info */ +extern "C" int gralloc_extra_sf_init(buffer_handle_t handle, gralloc_extra_ion_sf_info_t * sf_info) +{ + int32_t mask = 0; + int32_t value = 0; + int format; + + memset(sf_info, 0, sizeof(gralloc_extra_ion_sf_info_t)); + + if (GRALLOC_EXTRA_OK == gralloc_extra_query(handle, GRALLOC_EXTRA_GET_FORMAT, &format)) + { + if (format == HAL_PIXEL_FORMAT_YV12 || + format == HAL_PIXEL_FORMAT_I420 || + format == HAL_PIXEL_FORMAT_YUV_PRIVATE || + format == HAL_PIXEL_FORMAT_NV12_BLK || + format == HAL_PIXEL_FORMAT_NV12_BLK_FCM || + format == HAL_PIXEL_FORMAT_YUYV || + 0 ) + { + mask |= GRALLOC_EXTRA_MASK_YUV_COLORSPACE; + value |= GRALLOC_EXTRA_BIT_YUV_BT601_NARROW; + } + } + + gralloc_extra_sf_set_status(sf_info, mask, value); + return 0; +} + diff --git a/mtk/gralloc_extra/NOTICE b/mtk/gralloc_extra/NOTICE new file mode 100644 index 0000000..268fe09 --- /dev/null +++ b/mtk/gralloc_extra/NOTICE @@ -0,0 +1,22 @@ + * (C) COPYRIGHT 2014 ARM Limited, ALL RIGHTS RESERVED:
+
+
+
+/*
+* Copyright (C) 2011-2014 MediaTek Inc.
+*
+* 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.
+*/
+
+
+
\ No newline at end of file diff --git a/mtk/gralloc_extra/README b/mtk/gralloc_extra/README new file mode 100755 index 0000000..4500bab --- /dev/null +++ b/mtk/gralloc_extra/README @@ -0,0 +1,19 @@ +A gralloc extra HAL to retrive buffer detail information. + +WHAT IT DOES? +============= +libgralloc_extra.so provide a convenience API for retriving the buffer_t +information, such as width, height, real format, raw buffer handle and more +extra share space for MTK's HWC, Video, and Camera. + +HOW IT WAS BUILT? +================== +It needs the following library from AOSP: +1. libhardware +2. libcutils +3. libutils + +HOW TO USE IT? +============== +See the usage of gralloc_extra_* at ./tests/ +gralloc_test.cpp
\ No newline at end of file diff --git a/mtk/gralloc_extra/include/gralloc_mtk_defs.h b/mtk/gralloc_extra/include/gralloc_mtk_defs.h new file mode 100644 index 0000000..85edf8b --- /dev/null +++ b/mtk/gralloc_extra/include/gralloc_mtk_defs.h @@ -0,0 +1,95 @@ +#ifndef __GRALLOC_MTK_DEFS_H__ +#define __GRALLOC_MTK_DEFS_H__ + +#include <stdint.h> +#include <hardware/gralloc.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + [Important] + Define the MTK specific enumeration values for gralloc usage in order to avoid "polute" AOSP file + (hardware/libhardware/include/hardware/gralloc.h) + The enumeration value definition must not be conflict with the gralloc.h in original AOSP file +*/ +enum { + +#if 0 + /* buffer is never read in software */ + GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, + /* buffer is rarely read in software */ + GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, + /* buffer is often read in software */ + GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, + /* mask for the software read values */ + GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, + + /* buffer is never written in software */ + GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, + /* buffer is rarely written in software */ + GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, + /* buffer is often written in software */ + GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, + /* mask for the software write values */ + GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, + + /* buffer will be used as an OpenGL ES texture */ + GRALLOC_USAGE_HW_TEXTURE = 0x00000100, + /* buffer will be used as an OpenGL ES render target */ + GRALLOC_USAGE_HW_RENDER = 0x00000200, + /* buffer will be used by the 2D hardware blitter */ + GRALLOC_USAGE_HW_2D = 0x00000400, + /* buffer will be used by the HWComposer HAL module */ + GRALLOC_USAGE_HW_COMPOSER = 0x00000800, + /* buffer will be used with the framebuffer device */ + GRALLOC_USAGE_HW_FB = 0x00001000, + /* buffer will be used with the HW video encoder */ + GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, + /* buffer will be written by the HW camera pipeline */ + GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, + /* buffer will be read by the HW camera pipeline */ + GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, + /* buffer will be used as part of zero-shutter-lag queue */ + GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, + /* mask for the camera access values */ + GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, + /* mask for the software usage bit-mask */ + GRALLOC_USAGE_HW_MASK = 0x00071F00, + + /* buffer will be used as a RenderScript Allocation */ + GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, + + /* buffer should be displayed full-screen on an external display when + * possible + */ + GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, + + /* Must have a hardware-protected path to external display sink for + * this buffer. If a hardware-protected path is not available, then + * either don't composite only this buffer (preferred) to the + * external sink, or (less desirable) do not route the entire + * composition to the external sink. + */ + GRALLOC_USAGE_PROTECTED = 0x00004000, + + /* implementation-specific private usage flags */ + GRALLOC_USAGE_PRIVATE_0 = 0x10000000, + GRALLOC_USAGE_PRIVATE_1 = 0x20000000, + GRALLOC_USAGE_PRIVATE_2 = 0x40000000, + GRALLOC_USAGE_PRIVATE_3 = 0x80000000, + GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000, +#endif /// #if 0 + + /// the following define the extended gralloc enumeration value of + GRALLOC_USAGE_NULL_BUFFER = GRALLOC_USAGE_PRIVATE_3, + GRALLOC_USAGE_SECURE = 0x01000000, + GRALLOC_USAGE_CAMERA_ORIENTATION = 0x02000000, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* __GRALLOC_MTK_DEFS_H__ */ diff --git a/mtk/gralloc_extra/include/graphics_mtk_defs.h b/mtk/gralloc_extra/include/graphics_mtk_defs.h new file mode 100644 index 0000000..6374984 --- /dev/null +++ b/mtk/gralloc_extra/include/graphics_mtk_defs.h @@ -0,0 +1,69 @@ +#ifndef __GRAPHICS_MTK_DEFS_H__ +#define __GRAPHICS_MTK_DEFS_H__ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + [Important] + Define the OMX MTK specific enum values in order to avoid "polute" AOSP files(system/core/graphics.h) + The format enum value definition must be align to the enum value in the following file + frameworks\av\media\libstagefright\include\omx_core\OMX_IVCommon.h +*/ +#define OMX_COLOR_FormatVendorMTKYUV 0x7F000001 +#define OMX_COLOR_FormatVendorMTKYUV_FCM 0x7F000002 +#define OMX_COLOR_FormatVendorMTKYUV_10BIT_H 0x7F000004 +#define OMX_COLOR_FormatVendorMTKYUV_10BIT_V 0x7F000005 +#define OMX_COLOR_FormatVendorMTKYUV_UFO_10BIT_H 0x7F000006 +#define OMX_COLOR_FormatVendorMTKYUV_UFO_10BIT_V 0x7F000007 + +/** + * MTK pixel format definitions + */ +enum { +#ifndef MTK_BUILD_IMG_DDK + HAL_PIXEL_FORMAT_BGRX_8888 = 0xFFFF0002, +#endif + + HAL_PIXEL_FORMAT_I420 = 0x32315659 + 0x10, /// MTK I420 + HAL_PIXEL_FORMAT_YUV_PRIVATE = 0x32315659 + 0x20, /// I420 or NV12_BLK or NV12_BLK_FCM + HAL_PIXEL_FORMAT_YUV_PRIVATE_10BIT = 0x32315659 + 0x30, /// I420 or NV12_BLK or NV12_BLK_FCM - 10bit + + HAL_PIXEL_FORMAT_NV12_BLK = OMX_COLOR_FormatVendorMTKYUV, /// MTK NV12 block progressive mode + HAL_PIXEL_FORMAT_NV12_BLK_FCM = OMX_COLOR_FormatVendorMTKYUV_FCM, /// MTK NV12 block field mode + HAL_PIXEL_FORMAT_NV12_BLK_10BIT_H = OMX_COLOR_FormatVendorMTKYUV_10BIT_H, /// MTK NV12 10 bit horizontal mode + HAL_PIXEL_FORMAT_NV12_BLK_10BIT_V = OMX_COLOR_FormatVendorMTKYUV_10BIT_V, /// MTK NV12 10 bit vertical mode + HAL_PIXEL_FORMAT_UFO_10BIT_H = OMX_COLOR_FormatVendorMTKYUV_UFO_10BIT_H, /// MTK NV12 10 bit UFO horizontal mode + HAL_PIXEL_FORMAT_UFO_10BIT_V = OMX_COLOR_FormatVendorMTKYUV_UFO_10BIT_V, /// MTK NV12 10 bit UFO vertical mode + +/** + * IMG Driver use 0x1X0-0x1X6 as they "vendor formats" + */ + HAL_PIXEL_FORMAT_IMG0 = 0x00000100, + HAL_PIXEL_FORMAT_IMG1_BGRX_8888 = 0x00000101, + HAL_PIXEL_FORMAT_IMG2 = 0x00000102, + HAL_PIXEL_FORMAT_IMG3 = 0x00000103, + HAL_PIXEL_FORMAT_IMG4 = 0x00000105, + HAL_PIXEL_FORMAT_IMG5 = 0x00000106, + + HAL_PIXEL_FORMAT_YUYV = 0x0000010c, /// for HWC output (bpp=2) + HAL_PIXEL_FORMAT_I420_DI = 0x0000010d, /// MTK I420 for deinterlace + HAL_PIXEL_FORMAT_YV12_DI = 0x0000010e, /// MTK YV12 for deinterlace + HAL_PIXEL_FORMAT_UFO = 0x0000010f, /// MTK UFO + HAL_PIXEL_FORMAT_NV12 = 0x00000110, /// NV12 + +/** + * Sapphire Driver use 0x120-0x121 as their "vendor formats" + */ + HAL_PIXEL_FORMAT_SPH0 = 0x00000120, + HAL_PIXEL_FORMAT_SPH1 = 0x00000121, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* __GRAPHICS_MTK_DEFS_H__ */ diff --git a/mtk/gralloc_extra/include/hardware/gralloc_extra.h b/mtk/gralloc_extra/include/hardware/gralloc_extra.h new file mode 100755 index 0000000..653ba0f --- /dev/null +++ b/mtk/gralloc_extra/include/hardware/gralloc_extra.h @@ -0,0 +1,60 @@ +#ifndef MTK_GRALLOC_EXTRA_DEVICE_H +#define MTK_GRALLOC_EXTRA_DEVICE_H + +#include <system/window.h> +#include <hardware/hardware.h> +#include <hardware/gralloc.h> + +#include <stdint.h> +#include <sys/cdefs.h> +#include <sys/types.h> + +#include <ui/gralloc_extra.h> + +__BEGIN_DECLS + +#define GRALLOC_HARDWARE_EXTRA "extra" + +typedef struct extra_device_t { + struct hw_device_t common; + + /** Deprecated methods and struct. START */ + int (*getIonFd)(struct extra_device_t* dev, buffer_handle_t handle, int *idx, int *num); + int (*getBufInfo)(struct extra_device_t *dev, buffer_handle_t handle, gralloc_buffer_info_t* bufInfo); + int (*getSecureBuffer)(struct extra_device_t* dev, buffer_handle_t handle, int *type, int *hBuffer); + int (*setBufParameter)(struct extra_device_t* dev, buffer_handle_t handle, int mask, int value); + int (*getMVA)(struct extra_device_t* dev, buffer_handle_t handle, int32_t *mvaddr); + int (*setBufInfo)(struct extra_device_t* dev, buffer_handle_t handle, const char* str); + /** Deprecated methods and struct. END */ + + int (*query)(struct extra_device_t* dev, + buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_QUERY attribute, void * out_pointer); + + int (*perform)(struct extra_device_t* dev, + buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_PERFORM attribute, void * in_pointer); + #if 0 + int (*free_sec)(struct extra_device_t* dev, buffer_handle_t handle); + #endif + + void* reserved_proc[2]; +} extra_device_t; + + +/** convenience API for opening and closing a supported device */ + +static inline int gralloc_extra_open(const struct hw_module_t* module, + struct extra_device_t** device) { + return module->methods->open(module, + GRALLOC_HARDWARE_EXTRA, (struct hw_device_t**)device); +} + +static inline int gralloc_extra_close(struct extra_device_t* device) { + return device->common.close(&device->common); +} + +/* common function to init sf_info */ +int gralloc_extra_sf_init(buffer_handle_t handle, gralloc_extra_ion_sf_info_t * sf_info); + +__END_DECLS + +#endif // MTK_GRALLOC_EXTRA_DEVICE_H diff --git a/mtk/gralloc_extra/include/ui/GraphicBufferExtra.h b/mtk/gralloc_extra/include/ui/GraphicBufferExtra.h new file mode 100755 index 0000000..ebe1654 --- /dev/null +++ b/mtk/gralloc_extra/include/ui/GraphicBufferExtra.h @@ -0,0 +1,54 @@ +#ifndef MTK_GRALLOC_EXTRA_GRAPHIC_BUFFER_EXTRA_H +#define MTK_GRALLOC_EXTRA_GRAPHIC_BUFFER_EXTRA_H + +#include <stdint.h> +#include <sys/types.h> + +#include <system/window.h> + +#include <utils/Singleton.h> +#include <utils/RefBase.h> + +#include <hardware/gralloc_extra.h> + +namespace android { +// --------------------------------------------------------------------------- +class GraphicBuffer; + +class GraphicBufferExtra : public Singleton<GraphicBufferExtra> +{ +public: + static inline GraphicBufferExtra& get() { return getInstance(); } + + int query(buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_QUERY attribute, void *out_pointer); + + int perform(buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_PERFORM attribute, void *in_pointer); +#if 0 + int free_sec(buffer_handle_t handle); +#endif + + + /** Deprecated methods + * please use query/perform instead of using the following get/set methods. + */ + int getIonFd(buffer_handle_t handle, int *idx, int *num); + int getBufInfo(buffer_handle_t handle, gralloc_buffer_info_t* bufInfo); + int getSecureBuffer(buffer_handle_t handle, int *type, int *hBuffer); + int setBufParameter(buffer_handle_t handle, int mask, int value); + int getMVA(buffer_handle_t handle, int32_t *mvaddr); + int setBufInfo(buffer_handle_t handle, const char * str); + + ~GraphicBufferExtra(); + +private: + friend class Singleton<GraphicBufferExtra>; + + GraphicBufferExtra(); + + extra_device_t *mExtraDev; +}; + +// --------------------------------------------------------------------------- +}; // namespace android + +#endif // MTK_GRALLOC_EXTRA_GRAPHIC_BUFFER_EXTRA_H diff --git a/mtk/gralloc_extra/include/ui/gralloc_extra.h b/mtk/gralloc_extra/include/ui/gralloc_extra.h new file mode 100755 index 0000000..8f7402e --- /dev/null +++ b/mtk/gralloc_extra/include/ui/gralloc_extra.h @@ -0,0 +1,337 @@ +#ifndef MTK_GRALLOC_EXTRA_H +#define MTK_GRALLOC_EXTRA_H + +#include <stdint.h> +#include <sys/cdefs.h> +#include <sys/types.h> + +#include <system/window.h> + +#include <hardware/gralloc.h> + +__BEGIN_DECLS + +enum { + GRALLOC_EXTRA_OK, + GRALLOC_EXTRA_UNKNOWN, + GRALLOC_EXTRA_NOT_SUPPORTED, + GRALLOC_EXTRA_NO_IMPLEMENTATION, + GRALLOC_EXTRA_NOT_INIT, + GRALLOC_EXTRA_INVALIDE_PARAMS, + GRALLOC_EXTRA_INVALIDE_OPERATION, + GRALLOC_EXTRA_ERROR, +}; + +typedef int GRALLOC_EXTRA_RESULT; + +/* enum for query() */ +typedef enum { + GRALLOC_EXTRA_GET_ION_FD = 1, /* int */ + GRALLOC_EXTRA_GET_FB_MVA, /* uintptr_t, deprecated */ + GRALLOC_EXTRA_GET_SECURE_HANDLE, /* uint32_t */ + + /* output: int */ + GRALLOC_EXTRA_GET_WIDTH = 10, + GRALLOC_EXTRA_GET_HEIGHT, + GRALLOC_EXTRA_GET_STRIDE, + GRALLOC_EXTRA_GET_VERTICAL_STRIDE, + GRALLOC_EXTRA_GET_ALLOC_SIZE, + GRALLOC_EXTRA_GET_FORMAT, + GRALLOC_EXTRA_GET_USAGE, + GRALLOC_EXTRA_GET_VERTICAL_2ND_STRIDE, + GRALLOC_EXTRA_GET_BYTE_2ND_STRIDE, + + /* output: gralloc_extra_sf_info_t */ + GRALLOC_EXTRA_GET_IOCTL_ION_SF_INFO = 100, + + /* output: gralloc_extra_buf_debug_t */ + GRALLOC_EXTRA_GET_IOCTL_ION_DEBUG, + + /* output: uint32_t */ + GRALLOC_EXTRA_GET_SECURE_HANDLE_HWC, + + /* output: gralloc_rotate_info_t */ + GRALLOC_EXTRA_GET_ROTATE_INFO, + + /* output: gralloc_gpu_compression_info_t */ + GRALLOC_EXTRA_GET_GPU_COMPRESSION_INFO, + + /* output: gralloc_gpu_yuyv rotation */ + GRALLOC_EXTRA_GET_ORIENTATION, + +} GRALLOC_EXTRA_ATTRIBUTE_QUERY; + +/* enum for perform() */ +typedef enum { + /* input: gralloc_extra_sf_info_t * */ + GRALLOC_EXTRA_SET_IOCTL_ION_SF_INFO = 100, + + /* input: gralloc_extra_buf_debug_t * */ + GRALLOC_EXTRA_SET_IOCTL_ION_DEBUG, + + /* input: NULL */ + GRALLOC_EXTRA_ALLOC_SECURE_BUFFER_HWC, + GRALLOC_EXTRA_FREE_SEC_BUFFER_HWC, + + /* input: gralloc_gpu_yuyv rotation */ + GRALLOC_EXTRA_SET_ORIENTATION, +} GRALLOC_EXTRA_ATTRIBUTE_PERFORM; + +int gralloc_extra_query(buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_QUERY attribute, void *out_pointer); + +int gralloc_extra_perform(buffer_handle_t handle, GRALLOC_EXTRA_ATTRIBUTE_PERFORM attribute, void *in_pointer); + +int gralloc_extra_free_sec(buffer_handle_t handle); + + +#define GRALLOC_EXTRA_MAKE_BIT(start_bit, index) ( (index) << (start_bit) ) +#define GRALLOC_EXTRA_MAKE_MASK(start_bit, end_bit) ( ( ((unsigned int)-1) >> (sizeof(int) * __CHAR_BIT__ - 1 - (end_bit) + (start_bit) ) ) << (start_bit) ) + +#define GRALLOC_EXTRA_UNMAKE_BIT(start_bit, index) ( (index) >> (start_bit) ) + + +/* bits in sf_info.status */ +enum { + /* TYPE: bit 0~1 */ + GRALLOC_EXTRA_BIT_TYPE_CPU = GRALLOC_EXTRA_MAKE_BIT(0,0), + GRALLOC_EXTRA_BIT_TYPE_GPU = GRALLOC_EXTRA_MAKE_BIT(0,1), + GRALLOC_EXTRA_BIT_TYPE_VIDEO = GRALLOC_EXTRA_MAKE_BIT(0,2), + GRALLOC_EXTRA_BIT_TYPE_CAMERA = GRALLOC_EXTRA_MAKE_BIT(0,3), + GRALLOC_EXTRA_MASK_TYPE = GRALLOC_EXTRA_MAKE_MASK(0,1), + + /* UFO alignment: bit 2~3 Temporary add back to prevent 6795 build fail. + Remove after 6795 SF/HWC finishes porting + */ + GRALLOC_EXTRA_BIT_UFO_16_32 = GRALLOC_EXTRA_MAKE_BIT(2,1), + GRALLOC_EXTRA_BIT_UFO_32_32 = GRALLOC_EXTRA_MAKE_BIT(2,2), + GRALLOC_EXTRA_BIT_UFO_64_64 = GRALLOC_EXTRA_MAKE_BIT(2,3), + GRALLOC_EXTRA_MASK_UFO_ALIGN = GRALLOC_EXTRA_MAKE_MASK(2,3), + + /* ColorFormat: bit 2~6 */ + GRALLOC_EXTRA_BIT_CM_YV12 = GRALLOC_EXTRA_MAKE_BIT(2,0), + GRALLOC_EXTRA_BIT_CM_YUYV = GRALLOC_EXTRA_MAKE_BIT(2,1), + GRALLOC_EXTRA_BIT_CM_I420 = GRALLOC_EXTRA_MAKE_BIT(2,2), + GRALLOC_EXTRA_BIT_CM_NV12 = GRALLOC_EXTRA_MAKE_BIT(2,3), + GRALLOC_EXTRA_BIT_CM_YUV420_FLEX = GRALLOC_EXTRA_MAKE_BIT(2,4), + GRALLOC_EXTRA_BIT_CM_NV12_BLK = GRALLOC_EXTRA_MAKE_BIT(2,5), + GRALLOC_EXTRA_BIT_CM_NV12_BLK_FCM = GRALLOC_EXTRA_MAKE_BIT(2,6), + GRALLOC_EXTRA_BIT_CM_UFO = GRALLOC_EXTRA_MAKE_BIT(2,7), + GRALLOC_EXTRA_BIT_CM_PRIVATE = GRALLOC_EXTRA_MAKE_BIT(2,8), + GRALLOC_EXTRA_BIT_CM_YV12_10BIT = GRALLOC_EXTRA_MAKE_BIT(2,9), + GRALLOC_EXTRA_BIT_CM_YUYV_10BIT = GRALLOC_EXTRA_MAKE_BIT(2,10), + GRALLOC_EXTRA_BIT_CM_I420_10BIT = GRALLOC_EXTRA_MAKE_BIT(2,11), + GRALLOC_EXTRA_BIT_CM_YUV420_FLEX_10BIT = GRALLOC_EXTRA_MAKE_BIT(2,12), + GRALLOC_EXTRA_BIT_CM_NV12_BLK_10BIT_H = GRALLOC_EXTRA_MAKE_BIT(2,13), + GRALLOC_EXTRA_BIT_CM_NV12_BLK_10BIT_V = GRALLOC_EXTRA_MAKE_BIT(2,14), + GRALLOC_EXTRA_BIT_CM_UFO_10BIT_H = GRALLOC_EXTRA_MAKE_BIT(2,15), + GRALLOC_EXTRA_BIT_CM_UFO_10BIT_V = GRALLOC_EXTRA_MAKE_BIT(2,16), + GRALLOC_EXTRA_BIT_CM_NV12_PRIVATE_10BIT = GRALLOC_EXTRA_MAKE_BIT(2,17), + GRALLOC_EXTRA_MASK_CM = GRALLOC_EXTRA_MAKE_MASK(2,6), + + /* Secure switch: bit 7 */ + GRALLOC_EXTRA_BIT_NORMAL = GRALLOC_EXTRA_MAKE_BIT(7,0), + GRALLOC_EXTRA_BIT_SECURE = GRALLOC_EXTRA_MAKE_BIT(7,1), + GRALLOC_EXTRA_MASK_SECURE = GRALLOC_EXTRA_MAKE_MASK(7,7), + + /* S3D Mode: bit 8~9 */ + GRALLOC_EXTRA_BIT_S3D_2D = GRALLOC_EXTRA_MAKE_BIT(8,0), + GRALLOC_EXTRA_BIT_S3D_SBS = GRALLOC_EXTRA_MAKE_BIT(8,1), + GRALLOC_EXTRA_BIT_S3D_TAB = GRALLOC_EXTRA_MAKE_BIT(8,2), + GRALLOC_EXTRA_MASK_S3D = GRALLOC_EXTRA_MAKE_MASK(8,9), + + /* DIRTY: bit 10, 11 */ + GRALLOC_EXTRA_BIT_UNDIRTY = GRALLOC_EXTRA_MAKE_BIT(10,0), + GRALLOC_EXTRA_BIT_DIRTY = GRALLOC_EXTRA_MAKE_MASK(10,11), + GRALLOC_EXTRA_MASK_DIRTY = GRALLOC_EXTRA_MAKE_MASK(10,11), + /* DIRTY: SF, 10 */ + GRALLOC_EXTRA_BIT_SF_DIRTY = GRALLOC_EXTRA_MAKE_MASK(10,10), + GRALLOC_EXTRA_MASK_SF_DIRTY = GRALLOC_EXTRA_MAKE_MASK(10,10), + /* DIRTY: AUX, 11 */ + GRALLOC_EXTRA_BIT_AUX_DIRTY = GRALLOC_EXTRA_MAKE_MASK(11,11), + GRALLOC_EXTRA_MASK_AUX_DIRTY = GRALLOC_EXTRA_MAKE_MASK(11,11), + + /* Orientation: bit 12~15 */ + GRALLOC_EXTRA_MASK_ORIENT = GRALLOC_EXTRA_MAKE_MASK(12,15), + + /* Alpha: bit 16~23 */ + GRALLOC_EXTRA_MASK_ALPHA = GRALLOC_EXTRA_MAKE_MASK(16,23), + + /* Blending: bit 24~25 */ + GRALLOC_EXTRA_MASK_BLEND = GRALLOC_EXTRA_MAKE_MASK(24,25), + + /* Dirty Param: bit 26 */ + GRALLOC_EXTRA_MASK_DIRTY_PARAM = GRALLOC_EXTRA_MAKE_MASK(26,26), + + /* FLUSH: bit 27 */ + GRALLOC_EXTRA_BIT_FLUSH = GRALLOC_EXTRA_MAKE_BIT(27,0), + GRALLOC_EXTRA_BIT_NOFLUSH = GRALLOC_EXTRA_MAKE_BIT(27,1), + GRALLOC_EXTRA_MASK_FLUSH = GRALLOC_EXTRA_MAKE_MASK(27,27), + + /* YUV Color SPACE: bit 29~31 */ + GRALLOC_EXTRA_BIT_YUV_NOT_SET = GRALLOC_EXTRA_MAKE_BIT(29,0), + GRALLOC_EXTRA_BIT_YUV_BT601_NARROW = GRALLOC_EXTRA_MAKE_BIT(29,1), + GRALLOC_EXTRA_BIT_YUV_BT601_FULL = GRALLOC_EXTRA_MAKE_BIT(29,2), + GRALLOC_EXTRA_BIT_YUV_BT709_NARROW = GRALLOC_EXTRA_MAKE_BIT(29,3), + GRALLOC_EXTRA_BIT_YUV_BT709_FULL = GRALLOC_EXTRA_MAKE_BIT(29,4), + GRALLOC_EXTRA_BIT_YUV_BT2020_NARROW = GRALLOC_EXTRA_MAKE_BIT(29,5), + GRALLOC_EXTRA_MASK_YUV_COLORSPACE = GRALLOC_EXTRA_MAKE_MASK(29,31), +}; + +/* bits in sf_info.status2 */ +enum { + /* TYPE: bit 0~2 */ + GRALLOC_EXTRA_BIT2_LAYER_NORMAL = 0x0, + GRALLOC_EXTRA_BIT2_LAYER_NAV = 0x1, // Navigation bar + GRALLOC_EXTRA_MASK2_LAYER_TYPE = GRALLOC_EXTRA_MAKE_MASK(0,2), + + /* YUY2 for Camera Rotation : bit 3~5 */ + GRALLOC_EXTRA_BIT2_YUY2_ROT0 = GRALLOC_EXTRA_MAKE_BIT(3,0), + GRALLOC_EXTRA_BIT2_YUY2_R1_FLIP_H = GRALLOC_EXTRA_MAKE_BIT(3,1), + GRALLOC_EXTRA_BIT2_YUY2_R2_FLIP_V = GRALLOC_EXTRA_MAKE_BIT(3,2), + GRALLOC_EXTRA_BIT2_YUY2_R3_ROT180 = GRALLOC_EXTRA_MAKE_BIT(3,3), + GRALLOC_EXTRA_BIT2_YUY2_R4_ROT90 = GRALLOC_EXTRA_MAKE_BIT(3,4), + GRALLOC_EXTRA_BIT2_YUY2_R5 = GRALLOC_EXTRA_MAKE_BIT(3,5), + GRALLOC_EXTRA_BIT2_YUY2_R6 = GRALLOC_EXTRA_MAKE_BIT(3,6), + GRALLOC_EXTRA_BIT2_YUY2_R7_ROT270 = GRALLOC_EXTRA_MAKE_BIT(3,7), + GRALLOC_EXTRA_MASK2_YUY2_ROT = GRALLOC_EXTRA_MAKE_MASK(3,5), + +}; + +typedef enum { + /* normal secure buffer */ + GRALLOC_EXTRA_SECURE_BUFFER_TYPE_NORMAL, + + /* zero-initialized secure buffer */ + GRALLOC_EXTRA_SECURE_BUFFER_TYPE_ZERO +} GRALLOC_EXTRA_SECURE_BUFFER_TYPE; + +typedef struct _crop_t { + int32_t x, y, w, h; + +#ifdef __cplusplus + _crop_t():x(0),y(0),w(0),h(0) {} +#endif +} _crop_t; + +/* extension data */ +typedef struct gralloc_extra_ion_sf_info_t { + /* magic number to make sure that obj is created by query() */ + uint32_t magic; + + /* used by SurfaceFlinger*/ + _crop_t src_crop; + _crop_t dst_crop; + + /* buffer flags, please change this value by sf_set_status() */ + int32_t status; + + /* used for pre-allocate buffer */ + int32_t pool_id; + + /* used for profiling latency */ + uint32_t sequence; + + /* secure handle allocated by GRALLOC_EXTRA_GET_SECURE_HANDLE_HWC */ + uint32_t secure_handle_hwc; + + /* used for video frame */ + uint32_t timestamp; + + /* buffer flags, please change this value by sf_set_status2() */ + int32_t status2; + + /* video buffer status + bit 31: valid bit, 0 = invalid (default), 1 = valid + + bit 30-25: Y stride alignment + bit 24-19: CbCr stride alignment + bit 18-13: height alignment + alignment interpretation + + Y: + y_align = (videobuffer_status & 0x7FFFFFFF) >> 25; + if (0 == y_align) y_align = 1; + else y_align *= 2; + CbCr: + cbcr_align = (videobuffer_status & 0x01FFFFFF) >> 19; + if (0 == cbcr_align) cbcr_align = 1; + else cbcr_align *= 2; + Height: + h_align = (videobuffer_status & 0x0007FFFF) >> 13; + if (0 == h_align) h_align = 1; + else h_align *= 2; + + bit 12: deinterlace 0 = no, 1 = yes + */ + int32_t videobuffer_status; + +#ifdef __cplusplus + gralloc_extra_ion_sf_info_t(): + magic(0),src_crop(),dst_crop(), + status(0),pool_id(0),sequence(0), + secure_handle_hwc(0), + timestamp(0), status2(0) + {} +#endif +} gralloc_extra_ion_sf_info_t; + +int gralloc_extra_sf_set_status(gralloc_extra_ion_sf_info_t *sf_info, int32_t mask, int32_t value); + +int gralloc_extra_sf_set_status2(gralloc_extra_ion_sf_info_t *sf_info, int32_t mask, int32_t value); + +/* debug data, to facilitate information while debugging */ +typedef struct gralloc_extra_ion_debug_t { + int data[4]; + char name[16]; + +#ifdef __cplusplus + gralloc_extra_ion_debug_t(): + data(), + name() + {} +#endif +} gralloc_extra_ion_debug_t; + +typedef struct gralloc_rotate_info_t { + //rotate + int rotate_mode; + int rotate_dx; + int rotate_dy; +} gralloc_rotate_info_t; + +typedef struct gralloc_gpu_compression_info_t { + /* GPU info */ + //UFO + unsigned char ufo_enable; + //unsigned int ufo_format; + //unsigned char ufo_is_linear; + unsigned int ufo_length_buffer_base; + unsigned char ufo_pattern_replace_en; + unsigned int ufo_pattern; +} gralloc_gpu_compression_info_t; + +/* Deprecated methods and struct. START */ +typedef struct gralloc_buffer_info_t { + /* static number, never change */ + int width; + int height; + int stride; + int format; + int vertical_stride; + int usage; + + /* change by setBufParameter() */ + int status; +} gralloc_buffer_info_t; + +int gralloc_extra_getIonFd(buffer_handle_t handle, int *idx, int *num); +int gralloc_extra_getBufInfo(buffer_handle_t handle, gralloc_buffer_info_t* bufInfo); +int gralloc_extra_getSecureBuffer(buffer_handle_t handle, int *type, int *hBuffer); +int gralloc_extra_setBufParameter(buffer_handle_t handle, int mask, int value); +int gralloc_extra_getMVA(buffer_handle_t handle, int32_t *mvaddr); +int gralloc_extra_setBufInfo(buffer_handle_t handle, const char * str); +/* Deprecated methods and struct. END */ + +__END_DECLS + +#endif /* MTK_GRALLOC_EXTRA_H */ diff --git a/mtk/libmtk_symbols/Android.mk b/mtk/libmtk_symbols/Android.mk new file mode 100644 index 0000000..efb6fb8 --- /dev/null +++ b/mtk/libmtk_symbols/Android.mk @@ -0,0 +1,17 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + mtk_gui.cpp \ + mtk_ui.cpp + +# only for 32bit libraries +LOCAL_SRC_FILES_32 := mtk_string.cpp +# only for 64bit libraries +LOCAL_SRC_FILES_64 := mtk_parcel.cpp + +LOCAL_SHARED_LIBRARIES := libbinder libutils liblog libgui libui +LOCAL_MODULE := libmtk_symbols +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) diff --git a/mtk/libmtk_symbols/mtk_gui.cpp b/mtk/libmtk_symbols/mtk_gui.cpp new file mode 100644 index 0000000..8cc75ba --- /dev/null +++ b/mtk/libmtk_symbols/mtk_gui.cpp @@ -0,0 +1,9 @@ +#include <stdint.h> + +extern "C" { + void _ZN7android14SurfaceControl8setLayerEj(uint32_t); + + void _ZN7android14SurfaceControl8setLayerEi(int32_t layer){ + _ZN7android14SurfaceControl8setLayerEj(static_cast<uint32_t>(layer)); + } +}
\ No newline at end of file diff --git a/mtk/libmtk_symbols/mtk_parcel.cpp b/mtk/libmtk_symbols/mtk_parcel.cpp new file mode 100644 index 0000000..03ba718 --- /dev/null +++ b/mtk/libmtk_symbols/mtk_parcel.cpp @@ -0,0 +1,7 @@ +extern "C" { + void _ZN7android6Parcel13writeString16EPKDsm(char16_t const*, unsigned long); + + void _ZN7android6Parcel13writeString16EPKtm(unsigned short const* str, unsigned long len){ + _ZN7android6Parcel13writeString16EPKDsm((char16_t const*)str, len); + } +}
\ No newline at end of file diff --git a/mtk/libmtk_symbols/mtk_string.cpp b/mtk/libmtk_symbols/mtk_string.cpp new file mode 100644 index 0000000..f5f61ec --- /dev/null +++ b/mtk/libmtk_symbols/mtk_string.cpp @@ -0,0 +1,13 @@ +extern "C" { + void _ZN7android8String165setToEPKDsj(char16_t const*, unsigned int); + + void _ZN7android8String165setToEPKtj(unsigned short const* str, unsigned int len){ + _ZN7android8String165setToEPKDsj((char16_t const*)str, len); + } + + void _ZN7android8String16C1EPKDsj(char16_t const*, unsigned int); + + void _ZN7android8String16C1EPKtj(unsigned short const* o, unsigned int len){ + _ZN7android8String16C1EPKDsj((char16_t const*)o, len); + } +}
\ No newline at end of file diff --git a/mtk/libmtk_symbols/mtk_ui.cpp b/mtk/libmtk_symbols/mtk_ui.cpp new file mode 100644 index 0000000..4492852 --- /dev/null +++ b/mtk/libmtk_symbols/mtk_ui.cpp @@ -0,0 +1,22 @@ +#include <ui/GraphicBufferMapper.h> +#include <ui/Rect.h> + +extern "C" { + void _ZN7android19GraphicBufferMapper9lockYCbCrEPK13native_handlejRKNS_4RectEP13android_ycbcr(buffer_handle_t, uint32_t, const android::Rect&, android_ycbcr*); + + void _ZN7android19GraphicBufferMapper9lockYCbCrEPK13native_handleiRKNS_4RectEP13android_ycbcr(buffer_handle_t handle, int usage, const android::Rect& bounds, android_ycbcr *ycbcr) { + _ZN7android19GraphicBufferMapper9lockYCbCrEPK13native_handlejRKNS_4RectEP13android_ycbcr(handle, static_cast<uint32_t>(usage), bounds, ycbcr); + } + + void _ZN7android19GraphicBufferMapper4lockEPK13native_handlejRKNS_4RectEPPv(buffer_handle_t, uint32_t, const android::Rect&, void**); + + void _ZN7android19GraphicBufferMapper4lockEPK13native_handleiRKNS_4RectEPPv(buffer_handle_t handle, int usage, const android::Rect& bounds, void** vaddr) { + _ZN7android19GraphicBufferMapper4lockEPK13native_handlejRKNS_4RectEPPv(handle, static_cast<uint32_t>(usage), bounds, vaddr); + } + + void _ZN7android5Fence4waitEi(int); + + void _ZN7android5Fence4waitEj(unsigned int timeout) { + _ZN7android5Fence4waitEi(static_cast<int>(timeout)); + } +}
\ No newline at end of file diff --git a/mtk/rrc/Android.mk b/mtk/rrc/Android.mk new file mode 100644 index 0000000..f452639 --- /dev/null +++ b/mtk/rrc/Android.mk @@ -0,0 +1,82 @@ +# Copyright Statement: +# +# This software/firmware and related documentation ("MediaTek Software") are +# protected under relevant copyright laws. The information contained herein +# is confidential and proprietary to MediaTek Inc. and/or its licensors. +# Without the prior written permission of MediaTek inc. and/or its licensors, +# any reproduction, modification, use or disclosure of MediaTek Software, +# and information contained herein, in whole or in part, shall be strictly prohibited. +# +# MediaTek Inc. (C) 2010. All rights reserved. +# +# BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON +# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH +# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES +# THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES +# CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK +# SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR +# STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND +# CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO +# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +# +# The following software/firmware and/or related documentation ("MediaTek Software") +# have been modified by MediaTek Inc. All revisions are subject to any receiver's +# applicable license agreements with MediaTek Inc. + + +# +# librrc +# +LOCAL_PATH:= $(call my-dir) + + +COMMON_PATH:= common +INCLUDE_PATH:= $(LOCAL_PATH)/inc + +include $(CLEAR_VARS) + +ifeq ($(MTK_DISPLAY_120HZ_SUPPORT), yes) +LOCAL_CFLAGS += -DMTK_RRC_ENABLE +endif + +ifneq ($(TARGET_BUILD_VARIANT), user) +LOCAL_CFLAGS += -DMTK_RRC_ENABLE_PROP +endif + + +LOCAL_SRC_FILES:= \ + $(COMMON_PATH)/refresh_rate_control.cpp \ + +LOCAL_C_INCLUDES:= \ + $(INCLUDE_PATH) \ + + + +LOCAL_STATIC_LIBRARIES := \ + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + +LOCAL_MODULE:= librrc + + +LOCAL_SHARED_LIBRARIES := \ + libutils \ + libcutils \ + liblog \ + +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) + +include $(call all-makefiles-under,$(LOCAL_PATH)) + + diff --git a/mtk/rrc/NOTICE b/mtk/rrc/NOTICE new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/mtk/rrc/NOTICE @@ -0,0 +1 @@ + diff --git a/mtk/rrc/README b/mtk/rrc/README new file mode 100644 index 0000000..c6a4c0a --- /dev/null +++ b/mtk/rrc/README @@ -0,0 +1,24 @@ +This directory contains RRC HAL interface, which defines the interface of +Refresh Rate Controller and is used to build a RRC shared library. + +This library is pre-built by MediaTek internal. + +WHAT IT DOES? +============= +librrc.so provides api for notify multimedia scenarios. + +HOW IT WAS BUILT? +================== +It needs the following library from AOSP: +1. liblog.so +2. libutils.so +3. libcutils.so + +All source/dependency modules of this module are already put in +'vendor/mediatek/libs' folder. + +HOW TO USE IT? +============== +Provide api for user notify the active scenarios to decide proper display refresh rate. + +All the source code of this library were written by MediaTek co.. diff --git a/mtk/rrc/common/refresh_rate_control.cpp b/mtk/rrc/common/refresh_rate_control.cpp new file mode 100644 index 0000000..76efaad --- /dev/null +++ b/mtk/rrc/common/refresh_rate_control.cpp @@ -0,0 +1,256 @@ +/* Copyright Statement: + * + * This software/firmware and related documentation ("MediaTek Software") are + * protected under relevant copyright laws. The information contained herein + * is confidential and proprietary to MediaTek Inc. and/or its licensors. + * Without the prior written permission of MediaTek inc. and/or its licensors, + * any reproduction, modification, use or disclosure of MediaTek Software, + * and information contained herein, in whole or in part, shall be strictly prohibited. + */ +/* MediaTek Inc. (C) 2010. All rights reserved. + * + * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES + * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") + * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON + * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. + * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE + * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR + * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH + * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES + * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES + * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK + * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR + * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND + * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, + * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, + * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO + * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. + * + * The following software/firmware and/or related documentation ("MediaTek Software") + * have been modified by MediaTek Inc. All revisions are subject to any receiver's + * applicable license agreements with MediaTek Inc. + */ + +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2009 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include <stdio.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <errno.h> + +#include <linux/ioctl.h> +#include <string.h> + + +#include <cutils/log.h> + +#ifdef MTK_RRC_ENABLE + #define MTK_RRC_INC_DRV +#endif + +#ifdef MTK_RRC_INC_DRV + #include <linux/rrc_drv.h> +#endif + +#include <utils/Errors.h> + +#include <refresh_rate_control.h> + +#include <utils/Log.h> + +#include <cutils/properties.h> + + + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "RefreshRateControl" + + + +#define RRC_DRV_NAME "/dev/mtk_rrc" + +static int currentID; + +static unsigned int allocated; + + +RefreshRateControl::RefreshRateControl() +{ +} + + +RefreshRateControl::~RefreshRateControl() +{ +} + + +int RefreshRateControl::setScenario(int scenario, bool enable){ + +#ifdef MTK_RRC_INC_DRV + + int drvID ; + + RRC_DRV_DATA rrc_data ; + unsigned int result = 0; + int config_enable = enable ; + + if(!(scenario > RRC_TYPE_NONE && scenario < RRC_TYPE_MAX_SIZE)){ + ALOGW("[RRC] setScenario RRC Driver scenario error range (%d)", scenario); + return -1; + } + + + +#ifdef MTK_RRC_ENABLE_PROP + + { + char value[PROPERTY_VALUE_MAX]; + unsigned long u4PQOpt; + + property_get("persist.rrc", value, "0"); + u4PQOpt = atol(value); + if(0 != u4PQOpt) + { + + if(u4PQOpt == 1){ + /* skip all event */ + //ALOGW("[RRC] skip all event!!\n"); + return 0; + } else if( u4PQOpt == 2 ) { + /* skip video event */ + if((scenario >= RRC_TYPE_VIDEO_NORMAL && scenario <= RRC_TYPE_VIDEO_WIFI_DISPLAY)){ + return 0; + } + } else if (u4PQOpt == 3) { + /* always keep HIGH */ + if((scenario >= RRC_TYPE_VIDEO_NORMAL && scenario <= RRC_TYPE_VIDEO_WIFI_DISPLAY)){ + return 0; + } + /* skip touch leave */ + if( scenario == RRC_DRV_TYPE_TOUCH_EVENT && enable == 0){ + return 0; + } + } else if (u4PQOpt == 4) { + /* always keep LOW */ + if((scenario >= RRC_TYPE_VIDEO_NORMAL && scenario <= RRC_TYPE_VIDEO_WIFI_DISPLAY)){ + return 0; + } + /* skip touch down */ + if( scenario == RRC_DRV_TYPE_TOUCH_EVENT && enable == 1){ + return 0; + } + } + } + } +#endif + + + ALOGW("[RRC] setScenario %d, config_enable %d!!\n", scenario, config_enable); + + + if(scenario == RRC_TYPE_VIDEO_120HZ) + { + scenario = RRC_DRV_TYPE_VIDEO_PLAYBACK ; + if ( config_enable ){ + config_enable = 2 ; + } + ALOGW("[RRC] Video120Hz setScenario %d, config_enable %d!!\n", scenario, config_enable); + } + + + + drvID = open(RRC_DRV_NAME, O_RDONLY, 0); + + if( drvID == -1 ) + { + ALOGW("Open RRC Driver Error (%s)", strerror(errno)); + return -1; + } + + + if(ioctl(drvID, RRC_IOCTL_CMD_INIT)<0) + { + ALOGW("RefreshRateControl Driver->RRC_IOCTL_CMD_INIT Error (%s)", strerror(errno)); + close(drvID); + drvID = -1; + return -1; + } + + + rrc_data.scenario = scenario ; + rrc_data.enable = config_enable ; + + if(ioctl(drvID, RRC_IOCTL_CMD_SET_SCENARIO_TYPE, &rrc_data) < 0) + { + ALOGW("RefreshRateControl Driver->RRC_IOCTL_CMD_SET_SCENARIO_TYPE Error (%s)", strerror(errno)); + close(drvID); + return -1; + } + + if(ioctl(drvID, RRC_IOCTL_CMD_DEINIT) < 0) + { + return -1; + } + + close(drvID); + +#endif + + return 0; +} + + + + + + + + + + + + + + + diff --git a/mtk/rrc/inc/refresh_rate_control.h b/mtk/rrc/inc/refresh_rate_control.h new file mode 100644 index 0000000..ecf084a --- /dev/null +++ b/mtk/rrc/inc/refresh_rate_control.h @@ -0,0 +1,66 @@ +#ifndef __REFRESH_RATE_CONTROL_H__ +#define __REFRESH_RATE_CONTROL_H__ + + +/*----------------------------------------------------------------------------- + Refresh Rate Control Scenario + -----------------------------------------------------------------------------*/ +typedef enum { + + RRC_TYPE_NONE = 0, + RRC_TYPE_VIDEO_NORMAL , + RRC_TYPE_CAMERA_PREVIEW , + RRC_TYPE_CAMERA_ZSD , + RRC_TYPE_CAMERA_CAPTURE , + RRC_TYPE_CAMERA_ICFP , + RRC_TYPE_VIDEO_SWDEC_PLAYBACK , + RRC_TYPE_VIDEO_PLAYBACK , + RRC_TYPE_VIDEO_TELEPHONY , + RRC_TYPE_VIDEO_RECORD , + RRC_TYPE_VIDEO_RECORD_CAMERA , + RRC_TYPE_VIDEO_RECORD_SLOWMOTION , + RRC_TYPE_VIDEO_SNAPSHOT , + RRC_TYPE_VIDEO_LIVE_PHOTO , + RRC_TYPE_VIDEO_WIFI_DISPLAY , + + /* touch event */ + RRC_TYPE_TOUCH_EVENT , + RRC_TYPE_VIDEO_120HZ , + + RRC_TYPE_MAX_SIZE + + +} RRC_SCENARIO_TYPE; + + +typedef enum { + + RRC_60Hz = 0, + RRC_120Hz , + + +} RRC_REFRESH_RATE; + + + +class RefreshRateControl { + + +public: + + RefreshRateControl(); + ~RefreshRateControl(); + + int setScenario(int scenario, bool enable); + + int getRefreshRate(); + +private: + + int getScenario(); + + int setRefreshRate(int refresh); + +}; + +#endif diff --git a/mtk/wifi/Android.mk b/mtk/wifi/Android.mk new file mode 100644 index 0000000..7210415 --- /dev/null +++ b/mtk/wifi/Android.mk @@ -0,0 +1,39 @@ +# Copyright (C) 2016 Cyanogenmod +# +# 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) + +ifeq ($(MTKPATH),) + +include $(CLEAR_VARS) +LOCAL_MODULE = libwifi-hal-mt66xx +LOCAL_MODULE_CLASS = STATIC_LIBRARIES +LOCAL_MODULE_PATH = +LOCAL_MODULE_RELATIVE_PATH = +LOCAL_MODULE_SUFFIX = .a +LOCAL_MULTILIB = 64 +LOCAL_SRC_FILES_64 = arm64/libwifi-hal-mt66xx.a +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE = libwifi-hal-mt66xx +LOCAL_MODULE_CLASS = STATIC_LIBRARIES +LOCAL_MODULE_PATH = +LOCAL_MODULE_RELATIVE_PATH = +LOCAL_MODULE_SUFFIX = .a +LOCAL_MULTILIB = 32 +LOCAL_SRC_FILES_32 = arm/libwifi-hal-mt66xx.a +include $(BUILD_PREBUILT) + +endif diff --git a/mtk/wifi/arm/libwifi-hal-mt66xx.a b/mtk/wifi/arm/libwifi-hal-mt66xx.a Binary files differnew file mode 100644 index 0000000..4bb43d3 --- /dev/null +++ b/mtk/wifi/arm/libwifi-hal-mt66xx.a diff --git a/mtk/wifi/arm64/libwifi-hal-mt66xx.a b/mtk/wifi/arm64/libwifi-hal-mt66xx.a Binary files differnew file mode 100644 index 0000000..fb699f1 --- /dev/null +++ b/mtk/wifi/arm64/libwifi-hal-mt66xx.a diff --git a/mtk/wpa_supplicant_8_lib/Android.mk b/mtk/wpa_supplicant_8_lib/Android.mk new file mode 100644 index 0000000..115997a --- /dev/null +++ b/mtk/wpa_supplicant_8_lib/Android.mk @@ -0,0 +1,68 @@ +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +LOCAL_PATH := $(call my-dir) + +##### For Google SUPPLICANT ##### +ifeq ($(MTKPATH),) + $(warning build BASIC wpa_supplicant) + WPA_SUPPL_DIR = external/wpa_supplicant_8 + WPA_SRC_FILE := + +ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),) + CONFIG_DRIVER_$(BOARD_WPA_SUPPLICANT_DRIVER) := y +endif +ifneq ($(BOARD_HOSTAPD_DRIVER),) + CONFIG_DRIVER_$(BOARD_HOSTAPD_DRIVER) := y +endif + +include $(WPA_SUPPL_DIR)/wpa_supplicant/android.config + +WPA_SUPPL_DIR_INCLUDE = $(WPA_SUPPL_DIR)/src \ + $(WPA_SUPPL_DIR)/src/common \ + $(WPA_SUPPL_DIR)/src/drivers \ + $(WPA_SUPPL_DIR)/src/l2_packet \ + $(WPA_SUPPL_DIR)/src/utils \ + $(WPA_SUPPL_DIR)/src/wps \ + $(WPA_SUPPL_DIR)/wpa_supplicant + +ifdef CONFIG_DRIVER_NL80211 +WPA_SUPPL_DIR_INCLUDE += external/libnl/include +WPA_SRC_FILE += mediatek_driver_cmd_nl80211.c +endif + +ifdef CONFIG_DRIVER_WEXT +#error doesn't support CONFIG_DRIVER_WEXT +endif + +# To force sizeof(enum) = 4 +ifeq ($(TARGET_ARCH),arm) +L_CFLAGS += -mabi=aapcs-linux +endif + +ifdef CONFIG_ANDROID_LOG +L_CFLAGS += -DCONFIG_ANDROID_LOG +endif + +######################## +include $(CLEAR_VARS) +LOCAL_MODULE := lib_driver_cmd_mt66xx +LOCAL_SHARED_LIBRARIES := libc libcutils +LOCAL_CFLAGS := $(L_CFLAGS) +LOCAL_SRC_FILES := $(WPA_SRC_FILE) +LOCAL_C_INCLUDES := $(WPA_SUPPL_DIR_INCLUDE) +include $(BUILD_STATIC_LIBRARY) +######################## +endif diff --git a/mtk/wpa_supplicant_8_lib/mediatek_driver_cmd_nl80211.c b/mtk/wpa_supplicant_8_lib/mediatek_driver_cmd_nl80211.c new file mode 100644 index 0000000..c59bcb5 --- /dev/null +++ b/mtk/wpa_supplicant_8_lib/mediatek_driver_cmd_nl80211.c @@ -0,0 +1,266 @@ +/* + * Driver interaction with extended Linux CFG8021 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + */ +#include "includes.h" +#include <linux/wireless.h> +#include "netlink/genl/genl.h" + +#include "common.h" +#include "driver_nl80211.h" +#include "linux_ioctl.h" +#include "wpa_supplicant_i.h" +#include "config.h" +#ifdef ANDROID +#include "android_drv.h" +#endif + +#include "driver_i.h" + +#include "eloop.h" + +/********************************************************************** +* OVERLAPPED functins, previous defination is in driver_nl80211.c, +* it will be modified +***********************************************************************/ + +/**********************************************************************/ +static int wpa_driver_mediatek_set_country(void *priv, const char *alpha2_arg) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + int ioctl_sock = -1; + struct iwreq iwr; + int ret = -1; + char buf[11]; +#ifdef MTK_TC1_FEATURE + char replace_ifname[IFNAMSIZ+1]; + + memset(replace_ifname, 0, IFNAMSIZ+1); + os_strlcpy(replace_ifname, "wlan0", os_strlen("wlan0")+1); +#endif + + wpa_printf(MSG_DEBUG, "wpa_driver_nl80211_set_country"); + ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); + if (ioctl_sock < 0) { + wpa_printf(MSG_ERROR, "%s: socket(PF_INET,SOCK_DGRAM)", __func__); + return -1; + } + os_memset(&iwr, 0, sizeof(iwr)); +#ifdef MTK_TC1_FEATURE + // convert 'p2p0' -> 'wlan0' : + // when iface name is p2p0, COUNTRY driver command doesn't support in MTK solution. + if (os_strncmp(drv->first_bss->ifname, "p2p0", os_strlen("p2p0")) == 0) { + wpa_printf(MSG_DEBUG, "Change interface name : p2p0->wlan0"); + os_strlcpy(iwr.ifr_name, replace_ifname, IFNAMSIZ ); + } else { + os_strlcpy(iwr.ifr_name, drv->first_bss->ifname, IFNAMSIZ); + } +#else + os_strlcpy(iwr.ifr_name, drv->first_bss->ifname, IFNAMSIZ); +#endif + sprintf(buf, "COUNTRY %s", alpha2_arg); + iwr.u.data.pointer = buf; + iwr.u.data.length = strlen(buf); + if ((ret = ioctl(ioctl_sock, 0x8B0C, &iwr)) < 0) { // SIOCSIWPRIV + wpa_printf(MSG_DEBUG, "ioctl[SIOCSIWPRIV]: %s", buf); + close(ioctl_sock); + return ret; + } + else { + close(ioctl_sock); + return 0; + } + +} + +/* +* update channel list in wpa_supplicant +* if coutry code chanaged +*/ +static void wpa_driver_notify_country_change(void *ctx, char *cmd) +{ + if (os_strncasecmp(cmd, "COUNTRY", 7) == 0) { + union wpa_event_data event; + + os_memset(&event, 0, sizeof(event)); + event.channel_list_changed.initiator = REGDOM_SET_BY_USER; + if (os_strncasecmp(cmd, "COUNTRY", 7) == 0) { + event.channel_list_changed.type = REGDOM_TYPE_COUNTRY; + if (os_strlen(cmd) > 9) { + event.channel_list_changed.alpha2[0] = cmd[8]; + event.channel_list_changed.alpha2[1] = cmd[9]; + } + } else + event.channel_list_changed.type = REGDOM_TYPE_UNKNOWN; + wpa_supplicant_event(ctx, EVENT_CHANNEL_LIST_CHANGED, &event); + } +} + +int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf, + size_t buf_len ) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + struct ifreq ifr; + struct wpa_supplicant *wpa_s; + struct hostapd_data *hapd; + int handled = 0; + int cmd_len = 0; + union wpa_event_data event; + static int user_force_band = 0; + int ret = -1; + + if (drv == NULL) { + wpa_printf(MSG_ERROR, "%s: drv is NULL. Exiting", __func__); + return -1; + } + if (drv->ctx == NULL) { + wpa_printf(MSG_ERROR, "%s: drv->ctx is NULL. Exiting", __func__); + return -1; + } + + if (os_strcmp(bss->ifname, "ap0") == 0) { + hapd = (struct hostapd_data *)(drv->ctx); + } + else { + wpa_s = (struct wpa_supplicant *)(drv->ctx); + if (wpa_s->conf == NULL) { + wpa_printf(MSG_ERROR, "%s: wpa_s->conf is NULL. Exiting", __func__); + return -1; + } + } + + wpa_printf(MSG_DEBUG, "iface %s recv cmd %s", bss->ifname, cmd); + handled = 1; + + if (os_strncasecmp(cmd, "POWERMODE ", 10) == 0) { + int state; + state = atoi(cmd + 10); + wpa_printf(MSG_DEBUG, "POWERMODE=%d", state); + } else if (os_strncmp(cmd, "MACADDR", os_strlen("MACADDR")) == 0) { + u8 macaddr[ETH_ALEN] = {}; + os_memcpy(&macaddr, wpa_s->own_addr, ETH_ALEN); + ret = snprintf(buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr)); + wpa_printf(MSG_DEBUG, "%s", buf); + } else if(os_strncasecmp(cmd, "COUNTRY", os_strlen("COUNTRY"))==0) { + if (os_strlen(cmd) != os_strlen("COUNTRY") + 3) { + wpa_printf(MSG_DEBUG, "Ignore COUNTRY cmd %s", cmd); + ret = 0; + } else { + wpa_printf(MSG_INFO, "set country: %s", cmd+8); + // ret = wpa_drv_set_country(wpa_s, cmd+8); + ret = wpa_driver_mediatek_set_country(priv, cmd+8); + if (ret == 0) { + wpa_printf(MSG_DEBUG, "Update channel list after country code changed"); + wpa_driver_notify_country_change(wpa_s, cmd); + } + } + } else if (os_strcasecmp(cmd, "start") == 0) { + if (ret = linux_set_iface_flags(drv->global->ioctl_sock, + drv->first_bss->ifname, 1)) { + wpa_printf(MSG_INFO, "nl80211: Could not set interface UP, ret=%d \n", ret); + } else { + wpa_msg(drv->ctx, MSG_INFO, "CTRL-EVENT-DRIVER-STATE STARTED"); + } + } else if (os_strcasecmp(cmd, "stop") == 0) { + if (drv->associated) { + ret = wpa_drv_deauthenticate(wpa_s, drv->bssid, WLAN_REASON_DEAUTH_LEAVING); + if (ret != 0) + wpa_printf(MSG_DEBUG, "DRIVER-STOP error, ret=%d", ret); + } else { + wpa_printf(MSG_INFO, "nl80211: not associated, no need to deauthenticate \n"); + } + + if (ret = linux_set_iface_flags(drv->global->ioctl_sock, + drv->first_bss->ifname, 0)) { + wpa_printf(MSG_INFO, "nl80211: Could not set interface Down, ret=%d \n", ret); + } else { + wpa_msg(drv->ctx, MSG_INFO, "CTRL-EVENT-DRIVER-STATE STOPPED"); + } + } else if (os_strncasecmp(cmd, "getpower", 8) == 0) { + u32 mode; + // ret = wpa_driver_wext_driver_get_power(drv, &mode); + if (ret == 0) { + ret = snprintf(buf, buf_len, "powermode = %u\n", mode); + wpa_printf(MSG_DEBUG, "%s", buf); + if (ret < (int)buf_len) + return ret; + } + } else if (os_strncasecmp(cmd, "get-rts-threshold", 17) == 0) { + u32 thd; + // ret = wpa_driver_wext_driver_get_rts(drv, &thd); + if (ret == 0) { + ret = snprintf(buf, buf_len, "rts-threshold = %u\n", thd); + wpa_printf(MSG_DEBUG, "%s", buf); + if (ret < (int)buf_len) + return ret; + } + } else if (os_strncasecmp(cmd, "set-rts-threshold", 17) == 0) { + u32 thd = 0; + char *cp = cmd + 17; + char *endp; + if (*cp != '\0') { + thd = (u32)strtol(cp, &endp, 0); + // if (endp != cp) + // ret = wpa_driver_wext_driver_set_rts(drv, thd); + } + } else if (os_strcasecmp(cmd, "btcoexscan-start") == 0) { + ret = 0; /* mt5921 linux driver not implement yet */ + } else if (os_strcasecmp(cmd, "btcoexscan-stop") == 0) { + ret = 0; /* mt5921 linux driver not implement yet */ + } else if (os_strncasecmp(cmd, "btcoexmode", 10) == 0) { + ret = 0; /* mt5921 linux driver not implement yet */ + } else { + handled = 0; + wpa_printf(MSG_INFO, "Unsupported command"); + } + + return ret; +} + +int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s P2P_SET_NOA %d %d %d, ignored", bss->ifname, count, start, duration); + return -1; +} + +int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s P2P_GET_NOA, ignored", bss->ifname); + return -1; +} + +int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s P2P_SET_PS, ignored", bss->ifname); + return -1; +} + +int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon, + const struct wpabuf *proberesp, + const struct wpabuf *assocresp) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "iface %s set_ap_wps_p2p_ie, ignored", bss->ifname); + return 0; +} + diff --git a/overlay/frameworks/base/core/res/res/values-mcc262-mnc03/config.xml b/overlay/frameworks/base/core/res/res/values-mcc262-mnc03/config.xml new file mode 100644 index 0000000..4c36018 --- /dev/null +++ b/overlay/frameworks/base/core/res/res/values-mcc262-mnc03/config.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 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. +*/ +--> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- O2 Germany (26207) and former E-Plus (26203) are merging their networks, consider non roaming --> + <string-array translatable="false" name="config_operatorConsideredNonRoaming"> + <item>26207</item> + </string-array> +</resources> diff --git a/overlay/frameworks/base/core/res/res/values-mcc262-mnc07/config.xml b/overlay/frameworks/base/core/res/res/values-mcc262-mnc07/config.xml new file mode 100644 index 0000000..b19c0dc --- /dev/null +++ b/overlay/frameworks/base/core/res/res/values-mcc262-mnc07/config.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 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. +*/ +--> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- O2 Germany (26207) and former E-Plus (26203) are merging their networks, consider non roaming --> + <string-array translatable="false" name="config_operatorConsideredNonRoaming"> + <item>26203</item> + </string-array> +</resources> diff --git a/overlay/frameworks/base/core/res/res/values/arrays.xml b/overlay/frameworks/base/core/res/res/values/arrays.xml new file mode 100644 index 0000000..5fa5e36 --- /dev/null +++ b/overlay/frameworks/base/core/res/res/values/arrays.xml @@ -0,0 +1,37 @@ +<?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. +*/ +--> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Defines the shutdown options shown in the reboot dialog. --> + <array name="shutdown_reboot_options" translatable="false"> + <item>@string/reboot_reboot</item> + <item>@string/reboot_soft</item> + <item>@string/reboot_recovery</item> + </array> + + <!-- Do not translate. Defines the shutdown actions passed to the kernel. + The first item should be empty for regular reboot. --> + <string-array name="shutdown_reboot_actions" translatable="false"> + <item></item> + <item>soft_reboot</item> + <item>recovery</item> + </string-array> +</resources> 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..ae33c87 --- /dev/null +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -0,0 +1,402 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Remote server that can provide NTP responses. -->
+ <string translatable="false" name="config_ntpServer">2.android.pool.ntp.org</string>
+
+ <!-- Enable the electron beam -->
+ <bool name="config_animateScreenLights">true</bool>
+
+ <!-- Device configuration setting the minfree tunable in the lowmemorykiller in the
+ kernel. A high value will cause the lowmemorykiller to fire earlier, keeping more
+ memory in the file cache and preventing I/O thrashing, but allowing fewer processes
+ to stay in memory. A low value will keep more processes in memory but may cause
+ thrashing if set too low. Overrides the default value chosen by ActivityManager based
+ on screen size and total memory for the largest lowmemorykiller bucket, and scaled
+ proportionally to the smaller buckets. -1 keeps the default. -->
+ <integer name="config_lowMemoryKillerMinFreeKbytesAbsolute">-1</integer>
+
+ <!-- This string array should be overridden by the device to present a list of network
+ attributes. This is used by the connectivity manager to decide which networks can coexist
+ based on the hardware -->
+ <!-- An Array of "[Connection name],[ConnectivityManager.TYPE_xxxx],
+ [associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet] -->
+ <!-- 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>"mobile,0,0,0,-1,true"</item>
+ <item>"mobile_mms,2,0,2,60000,true"</item>
+ <item>"mobile_supl,3,0,2,60000,true"</item>
+ <item>"mobile_dun,4,0,2,60000,true"</item>
+ <item>"mobile_hipri,5,0,3,60000,true"</item>
+ <item>"mobile_fota,10,0,2,60000,true"</item>
+ <item>"mobile_cbs,12,0,2,60000,true"</item>
+ <item>"mobile_ia,14,0,2,-1,true"</item>
+ <item>"bluetooth,7,7,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>"0,1"</item>
+ <item>"7,1"</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>"rndis\\d"</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 name="config_tether_wifi_regexs">
+ <item>"ap\\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>
+ <item>"bt-dun"</item>
+ </string-array>
+
+ <!-- Array of allowable ConnectivityManager network types for tethering -->
+ <integer-array name="config_tether_upstream_types">
+ <item>0</item>
+ <item>1</item>
+ <item>5</item>
+ <item>7</item>
+ <item>9</item>
+ </integer-array>
+
+ <!-- Boolean indicating whether the wifi chipset has dual frequency band support -->
+ <bool translatable="false" name="config_wifi_dual_band_support">true</bool>
+
+ <!-- Boolean indicating whether the wifi chipset has background scan support -->
+ <bool translatable="false" name="config_wifi_background_scan_support">true</bool>
+
+ <!-- Flag indicating whether the we should enable the automatic brightness in Settings.
+ Software implementation will be used if config_hardware_auto_brightness_available is not set -->
+ <bool name="config_automatic_brightness_available">true</bool>
+
+ <!-- If this is true, the screen will come on when you plug/unplug usb/power/whatever. -->
+ <bool name="config_unplugTurnsOnScreen">true</bool>
+
+ <!-- Indicate whether the SD card is accessible without removing the battery. -->
+ <bool name="config_batterySdCardAccessibility">true</bool>
+
+ <!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
+ <bool name="config_intrusiveNotificationLed">true</bool>
+
+ <!-- Is the battery LED intrusive? Used to decide if there should be a disable option -->
+ <bool name="config_intrusiveBatteryLed">true</bool>
+
+ <!-- Does the battery LED support multiple colors? Used to decide if the user can change the colors -->
+ <bool name="config_multiColorBatteryLed">false</bool>
+
+ <!-- Does the notification LED support multiple colors? Used to decide if the user can change the colors -->
+ <bool name="config_multiColorNotificationLed">false</bool>
+
+ <!-- Default color for notification LED. -->
+ <color name="config_defaultNotificationColor">#ffffffff</color>
+
+ <!-- Default LED on time for notification LED in milliseconds. -->
+ <integer name="config_defaultNotificationLedOn">500</integer>
+
+ <!-- Default LED off time for notification LED in milliseconds. -->
+ <integer name="config_defaultNotificationLedOff">2000</integer>
+
+ <!-- Is the device capable of hot swapping an UICC Card -->
+ <bool name="config_hotswapCapable">true</bool>
+
+ <!-- Control the behavior when the user long presses the home button.
+ 0 - Nothing
+ 1 - Menu key
+ 2 - Recent apps view in SystemUI
+ 3 - Launch assist intent
+ 4 - Voice Search
+ 5 - In-app Search
+ This needs to match the constants in
+ policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+ -->
+ <integer name="config_longPressOnHomeBehavior">2</integer>
+
+ <!-- Control the behavior when the user double-taps the home button.
+ 0 - Nothing
+ 1 - Menu
+ 2 - Recent apps view in SystemUI
+ 3 - Launch assist intent
+ 4 - Voice Search
+ 5 - In-app Search
+ This needs to match the constants in
+ policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+ -->
+ <integer name="config_doubleTapOnHomeBehavior">0</integer>
+
+ <!-- Minimum screen brightness setting allowed by the power manager.
+ The user is forbidden from setting the brightness below this level. -->
+ <integer name="config_screenBrightnessSettingMinimum">3</integer>
+
+ <!-- Default screen brightness setting.
+ Must be in the range specified by minimum and maximum. -->
+ <integer name="config_screenBrightnessSettingDefault">87</integer>
+
+ <!-- Screen brightness used to dim the screen while dozing in a very low power state.
+ May be less than the minimum allowed brightness setting
+ that can be set by the user. -->
+ <integer name="config_screenBrightnessDoze">5</integer>
+
+ <!-- Screen brightness used to dim the screen when the user activity
+ timeout expires. May be less than the minimum allowed brightness setting
+ that can be set by the user. -->
+ <integer name="config_screenBrightnessDim">20</integer>
+
+ <!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.
+ The N entries of this array define N + 1 control points as follows:
+ (1-based arrays)
+
+ Point 1: (0, value[1]): lux <= 0
+ Point 2: (level[1], value[2]): 0 < lux <= level[1]
+ Point 3: (level[2], value[3]): level[2] < lux <= level[3]
+ ...
+ Point N+1: (level[N], value[N+1]): level[N] < lux
+
+ The control points must be strictly increasing. Each control point
+ corresponds to an entry in the brightness backlight values arrays.
+ For example, if LUX == level[1] (first element of the levels array)
+ then the brightness will be determined by value[2] (second element
+ of the brightness values array).
+
+ Spline interpolation is used to determine the auto-brightness
+ backlight values for LUX levels between these control points.
+
+ Must be overridden in platform specific overlays -->
+ <integer-array name="config_autoBrightnessLevels">
+ <item>2</item>
+ <item>3</item>
+ <item>5</item>
+ <item>10</item>
+ <item>20</item>
+ <item>25</item>
+ <item>40</item>
+ <item>50</item>
+ <item>60</item>
+ <item>85</item>
+ <item>110</item>
+ <item>128</item>
+ <item>256</item>
+ <item>384</item>
+ <item>512</item>
+ <item>640</item>
+ <item>768</item>
+ <item>896</item>
+ <item>1024</item>
+ <item>2048</item>
+ <item>4096</item>
+ <item>6144</item>
+ <item>8192</item>
+ <item>10240</item>
+ <item>12288</item>
+ <item>14336</item>
+ <item>16384</item>
+ <item>18432</item>
+</integer-array>
+
+ <!-- Array of output values for LCD backlight corresponding to the LUX values
+ in the config_autoBrightnessLevels array. This array should have size one greater
+ than the size of the config_autoBrightnessLevels array.
+ The brightness values must be between 0 and 255 and be non-decreasing.
+ This must be overridden in platform specific overlays -->
+ <integer-array name="config_autoBrightnessLcdBacklightValues">
+ <item>67</item>
+ <item>73</item>
+ <item>75</item>
+ <item>75</item>
+ <item>80</item>
+ <item>85</item>
+ <item>90</item>
+ <item>95</item>
+ <item>100</item>
+ <item>100</item>
+ <item>100</item>
+ <item>100</item>
+ <item>100</item>
+ <item>110</item>
+ <item>110</item>
+ <item>115</item>
+ <item>128</item>
+ <item>139</item>
+ <item>150</item>
+ <item>170</item>
+ <item>180</item>
+ <item>200</item>
+ <item>250</item>
+ <item>255</item>
+ <item>255</item>
+ <item>255</item>
+ <item>255</item>
+ <item>255</item>
+ <item>255</item>
+</integer-array>
+
+ <!-- Boolean indicating if restoring network selection should be skipped -->
+ <!-- The restoring is handled by modem if it is true -->
+ <bool translatable="false" name="skip_restoring_network_selection">true</bool>
+
+ <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
+ autodetected from the Configuration. -->
+ <bool name="config_showNavigationBar">false</bool>
+
+ <!-- ComponentName of a dream to show whenever the system would otherwise have
+ gone to sleep. When the PowerManager is asked to go to sleep, it will instead
+ try to start this dream if possible. The dream should typically call startDozing()
+ to put the display into a low power state and allow the application processor
+ to be suspended. When the dream ends, the system will go to sleep as usual.
+ Specify the component name or an empty string if none.
+
+ Note that doze dreams are not subject to the same start conditions as ordinary dreams.
+ Doze dreams will run whenever the power manager is in a dozing state. -->
+ <string name="config_dozeComponent">com.android.systemui/com.android.systemui.doze.DozeService</string>
+
+ <!-- If true, the doze component is not started until after the screen has been
+ turned off and the screen off animation has been performed. -->
+ <bool name="config_dozeAfterScreenOff">true</bool>
+
+ <!-- Set to true to add links to Cell Broadcast app from Settings and MMS app. -->
+ <bool name="config_cellBroadcastAppLinks">true</bool>
+
+ <!-- Shutdown if the battery temperature exceeds (this value * 0.1) Celsius. -->
+ <integer name="config_shutdownBatteryTemperature">680</integer>
+
+ <!-- Enables or disables fading edges when marquee is enabled in TextView. -->
+ <bool name="config_ui_enableFadingMarquee">false</bool>
+
+ <!-- Whether safe headphone volume is enabled or not (country specific). -->
+ <bool name="config_safe_media_volume_enabled">true</bool>
+
+ <!-- If supported, are dreams enabled? (by default) -->
+ <bool name="config_dreamsEnabledByDefault">true</bool>
+
+ <!-- Flag indicating if the speed up audio on mt call code should be executed -->
+ <bool name="config_speed_up_audio_on_mt_calls">false</bool>
+
+ <!-- Indicate whether to allow the device to suspend when the screen is off
+ due to the proximity sensor. This resource should only be set to true
+ if the sensor HAL correctly handles the proximity sensor as a wake-up source.
+ Otherwise, the device may fail to wake out of suspend reliably.
+ The default is false. -->
+ <bool name="config_suspendWhenScreenOffDueToProximity">true</bool>
+
+ <!-- Button illumination -->
+ <bool name="config_deviceHasVariableButtonBrightness">true</bool>
+ <!-- disable button backlight settings -->
+ <integer name="config_buttonBrightnessSettingDefault">0</integer>
+
+ <!-- Flag indicating if the user is notified when the mobile network access is restricted -->
+ <bool name="config_user_notification_of_restrictied_mobile_access">false</bool>
+
+ <!-- The list absolute paths of jar/apk files containing the device specific handlers,
+ delimited by File.pathSeparator, which defaults to ":" on Android -->
+ <string name="config_deviceKeyHandlerLib" translatable="false">/system/framework/com.cyanogenmod.keyhandler.jar</string>
+
+ <!-- Full qualified name of the class that implements
+ com.android.internal.os.DeviceKeyHandler interface. -->
+ <string name="config_deviceKeyHandlerClass" translatable="false">com.cyanogenmod.settings.device.KeyHandler</string>
+
+ <bool name="config_powerDecoupleInteractiveModeFromDisplay">true</bool>
+
+ <!-- Enable device idle mode -->
+ <bool name="config_enableAutoPowerModes">true</bool>
+
+ <!-- Show battery fully charged notification -->
+ <bool name="config_showBatteryFullyChargedNotification">true</bool>
+
+ <!-- Set to true if the wifi display supports compositing content stored
+ in gralloc protected buffers. For this to be true, there must exist
+ a protected hardware path for surface flinger to composite and send
+ protected buffers to the wifi display video encoder.
+
+ If this flag is false, we advise applications not to use protected
+ buffers (if possible) when presenting content to a wifi display because
+ the content may be blanked.
+
+ This flag controls whether the {@link Display#FLAG_SUPPORTS_PROTECTED_BUFFERS}
+ flag is set for wifi displays.
+ -->
+ <bool name="config_wifiDisplaySupportsProtectedBuffers">false</bool>
+
+ <!-- Performance profiles -->
+ <!--
+ <string name="config_perf_profile_prop">sys.perf.profile</string>
+ <string name="config_perf_profile_default_entry">1</string> -->
+
+ <!-- Enable the option to check proximity sensor when deciding whether to
+ turn the screen on
+ NOTE ! - Enable for devices that have a fast response proximity sensor -->
+ <!--
+ <bool name="config_proximityCheckOnWake">true</bool>
+ <integer name="config_proximityCheckTimeout">400</integer> -->
+ <!-- The RadioAccessFamilies supported by the device.
+ Empty is viewed as "all". Only used on devices which
+ don't support RIL_REQUEST_GET_RADIO_CAPABILITY
+ format is UMTS|LTE|... -->
+ <!-- <string translatable="false" name="config_radio_access_family">GSM | WCDMA | LTE</string> -->
+
+ <!-- Older rotation sensors are not setting event.timestamp correctly. Setting to
+ true will use SystemClock.elapsedRealtimeNanos() to set timestamp. -->
+ <bool name="config_useSystemClockforRotationSensor">true</bool>
+
+ <!-- IpReachability monitor enable/Disable -->
+ <bool translatable="false" name="config_wifi_ipreachability_monitor">false</bool>
+
+ <!-- Enables SIP on WIFI only -->
+ <bool name="config_sip_wifi_only">false</bool>
+
+ <!-- Whether WiFi display is supported by this device.
+ There are many prerequisites for this feature to work correctly.
+ Here are a few of them:
+ * The WiFi radio must support WiFi P2P.
+ * The WiFi radio must support concurrent connections to the WiFi display and
+ to an access point.
+ * The Audio Flinger audio_policy.conf file must specify a rule for the "r_submix"
+ remote submix module. This module is used to record and stream system
+ audio output to the WiFi display encoder in the media server.
+ * The remote submix module "audio.r_submix.default" must be installed on the device.
+ * The device must be provisioned with HDCP keys (for protected content).
+ -->
+ <bool name="config_enableWifiDisplay">true</bool>
+
+ <!-- Indicate whether closing the lid causes the device to go to sleep and opening
+ it causes the device to wake up.
+ The default is false. -->
+ <bool name="config_lidControlsSleep">true</bool>
+
+</resources>
diff --git a/overlay/frameworks/base/core/res/res/xml/power_profile.xml b/overlay/frameworks/base/core/res/res/xml/power_profile.xml new file mode 100644 index 0000000..c00000f --- /dev/null +++ b/overlay/frameworks/base/core/res/res/xml/power_profile.xml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 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. +*/ +--> + +<device name="Android"> + <!-- Most values are the incremental current used by a feature, + in mA (measured at nominal voltage). + The default values are deliberately incorrect dummy values. + OEM's must measure and provide actual values before + shipping a device. + Example real-world values are given in comments, but they + are totally dependent on the platform and can vary + significantly, so should be measured on the shipping platform + with a power meter. --> + <item name="none">0</item> + <item name="screen.on">200</item> + <item name="screen.full">300</item> + <item name="bluetooth.active">104</item> + <item name="bluetooth.on">4</item> + <item name="wifi.on">5</item> + <item name="wifi.active">200</item> + <item name="wifi.scan">100</item> + <item name="dsp.audio">100</item> + <item name="dsp.video">100</item> + <item name="radio.active">300</item> + <item name="radio.scanning">10</item> + <item name="gps.on">30</item> + <array name="radio.on"> + <value>4</value> + <value>4</value> + </array> + <!-- Different CPU speeds as reported in + /sys/devices/system/cpu/cpufreq/all_time_in_state --> + <array name="cpu.speeds"> + <value>299000</value> <!-- 299 MHz CPU speed --> + <value>442000</value> <!-- 442 MHz CPU speed --> + <value>598000</value> <!-- 598 MHz CPU speed --> + <value>819000</value> <!-- 819 MHz CPU speed --> + <value>1014000</value> <!-- 1014 MHz CPU speed --> + <value>1040000</value> <!-- 1040 MHz CPU speed --> + <value>1144000</value> <!-- 1144 MHz CPU speed --> + <value>1235000</value> <!-- 1235 MHz CPU speed --> + <value>1300000</value> <!-- 1300 MHz CPU speed --> + </array> + + <!-- Current when CPU is idle --> + <item name="cpu.idle">6</item> + <!-- Current when CPU is awake --> + <item name="cpu.awake">34</item> + <!-- Current at each CPU speed, as per 'cpu.speeds' --> + <array name="cpu.active"> + <value>50.3</value> <!-- ~70mA --> + <value>64.0</value> <!-- ~90mA --> + <value>76.2</value> <!-- ~110mA --> + <value>82.7</value> <!-- ~115mA --> + <value>93.6</value> <!-- ~130mA --> + <value>113.6</value> <!-- ~160mA --> + <value>119.6</value> <!-- ~170mA --> + <value>128.7</value> <!-- ~180mA --> + <value>176.7</value> <!-- ~250mA --> + <value>199.0</value> <!-- ~280mA --> + <value>206.5</value> <!-- ~290mA --> + <value>224.0</value> <!-- ~315mA --> + <value>248.4</value> <!-- ~350mA --> + <value>286.9</value> <!-- ~380mA --> + <value>313.6</value> <!-- ~440mA --> + </array> + <!-- This is the battery capacity in mAh (measured at nominal voltage) --> + <item name="battery.capacity">3100</item> + + <array name="wifi.batchedscan"> <!-- mA --> + <value>.0002</value> <!-- 1-8/hr --> + <value>.002</value> <!-- 9-64/hr --> + <value>.02</value> <!-- 65-512/hr --> + <value>.2</value> <!-- 513-4,096/hr --> + <value>2</value> <!-- 4097-/hr --> + </array> +</device> diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml new file mode 100644 index 0000000..752c636 --- /dev/null +++ b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 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. +*/ +--> + +<!-- These resources are around just to allow their values to be customized + for different hardware and product builds. --> +<resources> + + <!-- Doze: does this device support STATE_DOZE and STATE_DOZE_SUSPEND? --> + <bool name="doze_display_state_supported">true</bool> + <bool name="doze_pulse_on_pick_up">true</bool> + + <!-- Control whether status bar should distinguish HSPA data icon form UMTS + data icon on devices --> + <bool name="config_hspa_data_distinguishable">true</bool> + +</resources> + diff --git a/overlay/frameworks/opt/telephony/resources/res/values/config.xml b/overlay/frameworks/opt/telephony/resources/res/values/config.xml new file mode 100644 index 0000000..5bc7a9d --- /dev/null +++ b/overlay/frameworks/opt/telephony/resources/res/values/config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Configuration for sending and receiving Mms when mobile data is disabled.--> + <bool name="config_enable_mms_with_mobile_data_off">true</bool> +</resources> diff --git a/overlay/packages/apps/Bluetooth/res/values/config.xml b/overlay/packages/apps/Bluetooth/res/values/config.xml new file mode 100644 index 0000000..aaeddd8 --- /dev/null +++ b/overlay/packages/apps/Bluetooth/res/values/config.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted (subject to the limitations in the + disclaimer below) provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the Linux Foundation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE + GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT + HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--> +<resources> + <bool name="profile_supported_hfpclient">true</bool> + <bool name="profile_supported_avrcp_controller">true</bool> + <bool name="profile_supported_a2dp_sink">true</bool> +</resources> diff --git a/overlay/packages/apps/Dialer/res/values/config.xml b/overlay/packages/apps/Dialer/res/values/config.xml new file mode 100644 index 0000000..da46c31 --- /dev/null +++ b/overlay/packages/apps/Dialer/res/values/config.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2016 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. +--> +<resources> + <bool name="call_recording_enabled">true</bool> + <integer name="call_recording_audio_source">4</integer> +</resources> diff --git a/overlay/packages/apps/Snap/res/values/config.xml b/overlay/packages/apps/Snap/res/values/config.xml new file mode 100644 index 0000000..fc65aa4 --- /dev/null +++ b/overlay/packages/apps/Snap/res/values/config.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 The Android Open Source Project + 2015-2016 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. +--> + +<!-- Camera app resources that may need to be customized + for different hardware or product builds. --> +<resources> + <!-- Restart preview for back camera onPictureTaken --> + <bool name="back_camera_restart_preview_onPictureTaken">true</bool> + + <!-- Restart preview for front camera onPictureTaken --> + <bool name="front_camera_restart_preview_onPictureTaken">true</bool> + + <!-- Force use a specific preview-size + Example: 1920x1080 --> + <string name="preview_size_for_photo">1920x1080</string> + +</resources> diff --git a/overlay/packages/services/Telecomm/res/values/config.xml b/overlay/packages/services/Telecomm/res/values/config.xml new file mode 100644 index 0000000..59a1e60 --- /dev/null +++ b/overlay/packages/services/Telecomm/res/values/config.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 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. +--> + +<resources> + + <!-- Flag indicating if the tty is enabled --> + <bool name="tty_enabled">true</bool> + +</resources> diff --git a/overlay/packages/services/Telephony/res/values/config.xml b/overlay/packages/services/Telephony/res/values/config.xml new file mode 100644 index 0000000..6e209bd --- /dev/null +++ b/overlay/packages/services/Telephony/res/values/config.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 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. +--> + +<resources> + <!-- Determine whether calls to mute the microphone in PhoneUtils + are routed through the android.media.AudioManager class (true) or through + the com.android.internal.telephony.Phone interface (false). --> + <bool name="send_mic_mute_to_AudioManager">true</bool> + + <!-- This device implements a noise suppression device for in call audio--> + <bool name="has_in_call_noise_suppression">true</bool> + + <!-- Flag indicating if the phone is a world phone --> + <bool name="world_phone">false</bool> + + <!-- Flag whether to enable Proximity setting--> + <bool name="config_proximity_enable" translatable="false">true</bool> + + <!-- Show enabled lte option for lte device --> + <bool name="config_enabled_lte" translatable="false">true</bool> +</resources> diff --git a/power/Android.mk b/power/Android.mk new file mode 100644 index 0000000..06e4852 --- /dev/null +++ b/power/Android.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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := power.$(TARGET_BOARD_PLATFORM) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := power.c +LOCAL_SHARED_LIBRARIES := liblog +LOCAL_MODULE_TAGS := optional + +ifneq ($(TARGET_TAP_TO_WAKE_NODE),) + LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\" +endif + +include $(BUILD_SHARED_LIBRARY) diff --git a/power/power.c b/power/power.c new file mode 100644 index 0000000..29653ca --- /dev/null +++ b/power/power.c @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2016 CyanogenMod + * + * 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 <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#define LOG_TAG "MTK PowerHAL" +#include <utils/Log.h> + +#include <hardware/hardware.h> +#include <hardware/power.h> + +#define MT_RUSH_BOOST_PATH "/proc/hps/rush_boost_enabled" +#define MT_FPS_UPPER_BOUND_PATH "/d/ged/hal/fps_upper_bound" + + +#define POWER_HINT_POWER_SAVING 0x00000101 +#define POWER_HINT_PERFORMANCE_BOOST 0x00000102 +#define POWER_HINT_BALANCE 0x00000103 + +static void power_init(struct power_module *module) +{ +} + +static void power_set_interactive(struct power_module *module, int on) +{ +} + +static void power_fwrite(const char *path, char *s) +{ + char buf[64]; + int len; + int fd = open(path, O_WRONLY); + + if (fd < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", path, buf); + return; + } + + len = write(fd, s, strlen(s)); + if (len < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error writing to %s: %s\n", path, buf); + } + + close(fd); +} + +static void power_hint(struct power_module *module, power_hint_t hint, + void *data) { + int32_t dataint = -1; + switch (hint) { + case POWER_HINT_LOW_POWER: + dataint = *(int32_t *)data; + if (dataint) { + power_fwrite(MT_FPS_UPPER_BOUND_PATH, "30"); + power_fwrite(MT_RUSH_BOOST_PATH, "0"); + } else { + power_fwrite(MT_FPS_UPPER_BOUND_PATH, "60"); + power_fwrite(MT_RUSH_BOOST_PATH, "1"); + } + ALOGI("POWER_HINT_LOW_POWER"); + break; + case POWER_HINT_VSYNC: + case POWER_HINT_INTERACTION: + case POWER_HINT_CPU_BOOST: + case POWER_HINT_LAUNCH_BOOST: + case POWER_HINT_AUDIO: + case POWER_HINT_SET_PROFILE: + case POWER_HINT_VIDEO_ENCODE: + case POWER_HINT_VIDEO_DECODE: + break; + default: + break; + } +} + +void set_feature(struct power_module *module, feature_t feature, int state) +{ +#ifdef TAP_TO_WAKE_NODE + char tmp_str[64]; + if (feature == POWER_FEATURE_DOUBLE_TAP_TO_WAKE) { + snprintf(tmp_str, 64, "%d", state); + power_fwrite(TAP_TO_WAKE_NODE, tmp_str); + return; + } +#endif +} + +static struct hw_module_methods_t power_module_methods = { + .open = NULL, +}; + +struct power_module HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = POWER_MODULE_API_VERSION_0_2, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = POWER_HARDWARE_MODULE_ID, + .name = "MTK Power HAL", + .author = "Cyanogen", + .methods = &power_module_methods, + }, + + .init = power_init, + .setInteractive = power_set_interactive, + .powerHint = power_hint, + .setFeature = set_feature, +}; diff --git a/product/hardware.mk b/product/hardware.mk new file mode 100644 index 0000000..c78b15e --- /dev/null +++ b/product/hardware.mk @@ -0,0 +1,53 @@ +# Power
+PRODUCT_PACKAGES += \
+ power.default \
+ power.mt6753
+
+# Telecomm
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/telephony/ecc_list.xml:system/etc/ecc_list.xml \
+ $(LOCAL_PATH)/configs/telephony/spn-conf.xml:system/etc/spn-conf.xml
+
+# Media permissions
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/media/media_codecs.xml:system/etc/media_codecs.xml \
+ $(LOCAL_PATH)/configs/media/media_profiles.xml:system/etc/media_profiles.xml
+
+# Audio config
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/audio/audio_policy.conf:system/etc/audio_policy.conf \
+ $(LOCAL_PATH)/configs/audio/audio_device.xml:system/etc/audio_device.xml \
+ $(LOCAL_PATH)/configs/audio/audio_effects.conf:system/etc/audio_effects.conf
+
+# Hostapd
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/hostapd/hostapd_default.conf:system/etc/hostapd/hostapd_default.conf \
+ $(LOCAL_PATH)/configs/hostapd/hostapd.accept:system/etc/hostapd/hostapd.accept \
+ $(LOCAL_PATH)/configs/hostapd/hostapd.deny:system/etc/hostapd/hostapd.deny
+
+# Bluetooth
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/bluetooth/auto_pair_devlist.conf:system/etc/bluetooth/auto_pair_devlist.conf \
+ $(LOCAL_PATH)/configs/bluetooth/bt_stack.conf.debug:system/etc/bluetooth/bt_stack.conf.debug \
+ $(LOCAL_PATH)/configs/bluetooth/bt_did.conf:system/etc/bluetooth/bt_did.conf \
+ $(LOCAL_PATH)/configs/bluetooth/bt_stack.conf:system/etc/bluetooth/bt_stack.conf \
+ $(LOCAL_PATH)/configs/bluetooth/bt_stack.conf.sqc:system/etc/bluetooth/bt_stack.conf.sqc
+
+# GPS
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/gps/slp_conf:system/etc/slp_conf \
+ $(LOCAL_PATH)/configs/gps/agps_profiles_conf2.xml:system/etc/agps_profiles_conf2.xml
+
+#Dhcp
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/wide-dhcpv6/dhcp6c.conf:system/etc/wide-dhcpv6/dhcp6c.conf \
+ $(LOCAL_PATH)/configs/wide-dhcpv6/dhcp6c.script:system/etc/wide-dhcpv6/dhcp6c.script \
+ $(LOCAL_PATH)/configs/wide-dhcpv6/dhcp6cctlkey:system/etc/wide-dhcpv6/dhcp6cctlkey \
+ $(LOCAL_PATH)/configs/wide-dhcpv6/dhcp6cDNS.conf:system/etc/wide-dhcpv6/dhcp6cDNS.conf \
+ $(LOCAL_PATH)/configs/wide-dhcpv6/dhcp6cPD.conf:system/etc/wide-dhcpv6/dhcp6cPD.conf \
+ $(LOCAL_PATH)/configs/wide-dhcpv6/dhcp6cPD.script:system/etc/wide-dhcpv6/dhcp6cPD.script \
+ $(LOCAL_PATH)/configs/wide-dhcpv6/dhcp6s.conf:system/etc/wide-dhcpv6/dhcp6s.conf
+
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/dhcpcd/dhcpcd.conf:system/etc/dhcpcd/dhcpcd.conf
+
diff --git a/product/input.mk b/product/input.mk new file mode 100644 index 0000000..bac3a8b --- /dev/null +++ b/product/input.mk @@ -0,0 +1,8 @@ +# Keyhandler
+PRODUCT_PACKAGES += \
+ com.cyanogenmod.keyhandler
+
+PRODUCT_SYSTEM_SERVER_JARS += com.cyanogenmod.keyhandler
+
+# Never dexopt the keyhandler
+$(call add-product-dex-preopt-module-config,com.cyanogenmod.keyhandler,disable)
diff --git a/product/packages.mk b/product/packages.mk new file mode 100644 index 0000000..3996f99 --- /dev/null +++ b/product/packages.mk @@ -0,0 +1,70 @@ +# CM apps
+PRODUCT_PACKAGES += \
+ Gello \
+ Torch \
+ Stk \
+ CMActions
+
+# Snap
+PRODUCT_PACKAGES += \
+ Snap
+
+PRODUCT_PACKAGES += \
+ libnl_2 \
+ libstlport
+
+# Mediatek
+PRODUCT_PACKAGES += \
+ libgralloc_extra \
+ librrc \
+ libmtk_symbols
+
+# Live Display
+PRODUCT_PACKAGES += libjni_livedisplay
+
+# Charger
+PRODUCT_PACKAGES += charger_res_images
+
+# FS tools
+PRODUCT_PACKAGES += \
+ e2fsck \
+ fibmap.f2fs \
+ fsck.f2fs \
+ mkfs.f2fs \
+ make_ext4fs \
+ resize2fs \
+ setup_fs
+
+# MTK's Engineer Mode
+PRODUCT_PACKAGES += EngineerMode
+
+# WiFi
+PRODUCT_PACKAGES += \
+ dhcpcd.conf \
+ libwpa_client \
+ hostapd \
+ wpa_supplicant
+
+# USB
+PRODUCT_PACKAGES += \
+ librs_jni \
+ com.android.future.usb.accessory
+
+# GPS
+PRODUCT_PACKAGES += \
+ gps.mt6753 \
+ libcurl
+
+# Audio
+PRODUCT_PACKAGES += \
+ audio.a2dp.default \
+ audio.usb.default \
+ audio_policy.stub \
+ audio.r_submix.default \
+ audio_policy.default \
+ libaudio-resampler \
+ libaudiopolicymanagerdefault \
+ libtinyalsa \
+ libtinycompress \
+ libtinyxml
+
diff --git a/product/permissions.mk b/product/permissions.mk new file mode 100644 index 0000000..9a7a0b3 --- /dev/null +++ b/product/permissions.mk @@ -0,0 +1,47 @@ +# Hardware-specific features
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/android.hardware.microphone.xml:system/etc/permissions/android.hardware.microphone.xml \
+ frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.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.touchscreen.multitouch.distinct.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.distinct.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.xml:system/etc/permissions/android.hardware.touchscreen.xml \
+ frameworks/native/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml \
+ frameworks/native/data/etc/android.hardware.faketouch.xml:system/etc/permissions/android.hardware.faketouch.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.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.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml
+
+# GPS
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml
+
+# Sensors
+PRODUCT_COPY_FILES += \
+ 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.sensor.proximity.xml:system/etc/permissions/android.hardware.sensor.proximity.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
+
+# Wifi
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
+ frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml
+
+# Camera
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml \
+ frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:system/etc/permissions/android.hardware.camera.flash-autofocus.xml \
+ frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \
+
+# Media permissions
+PRODUCT_COPY_FILES += \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video_le.xml:system/etc/media_codecs_google_video_le.xml
+
diff --git a/product/prop.mk b/product/prop.mk new file mode 100644 index 0000000..51f21ef --- /dev/null +++ b/product/prop.mk @@ -0,0 +1,23 @@ +# Default.prop +PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \ + ro.zygote=zygote64_32 \ + persist.service.acm.enable=0 \ + ro.mount.fs=EXT4 \ + persist.sys.dun.override=0 \ + camera.disable_zsl_mode=1 + +# RIL +PRODUCT_PROPERTY_OVERRIDES += \ + ro.kernel.android.checkjni=0 \ + ro.telephony.ril_class=MT6753 \ + ro.telephony.ril.config=fakeiccid \ + persist.call_recording.enabled=true \ + persist.call_recording.src=1 + +# MultiWindow +PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \ + persist.sys.debug.multi_window=true + +# Dalvik +PRODUCT_TAGS += dalvik.gc.type-precise + diff --git a/product/ramdisk.mk b/product/ramdisk.mk new file mode 100644 index 0000000..b43214a --- /dev/null +++ b/product/ramdisk.mk @@ -0,0 +1,22 @@ + # Ramdisk
+ PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/rootdir/enableswap.sh:root/enableswap.sh \
+ $(LOCAL_PATH)/rootdir/factory_init.project.rc:root/factory_init.project.rc \
+ $(LOCAL_PATH)/rootdir/factory_init.rc:root/factory_init.rc \
+ $(LOCAL_PATH)/rootdir/fstab.charger:root/fstab.charger \
+ $(LOCAL_PATH)/rootdir/fstab.mt6735:root/fstab.mt6735 \
+ $(LOCAL_PATH)/rootdir/init.modem.rc:root/init.modem.rc \
+ $(LOCAL_PATH)/rootdir/init.mt6735.rc:root/init.mt6735.rc \
+ $(LOCAL_PATH)/rootdir/init.mt6735.usb.rc:root/init.mt6735.usb.rc \
+ $(LOCAL_PATH)/rootdir/init.project.rc:root/init.project.rc \
+ $(LOCAL_PATH)/rootdir/init.rc:root/init.rc \
+ $(LOCAL_PATH)/rootdir/init.ssd.rc:root/init.ssd.rc \
+ $(LOCAL_PATH)/rootdir/meta_init.modem.rc:root/meta_init.modem.rc \
+ $(LOCAL_PATH)/rootdir/meta_init.project.rc:root/meta_init.project.rc \
+ $(LOCAL_PATH)/rootdir/meta_init.rc:root/meta_init.rc \
+ $(LOCAL_PATH)/rootdir/ueventd.mt6735.rc:root/ueventd.mt6735.rc
+
+# # hack for TWRP
+# PRODUCT_COPY_FILES += \
+# $(LOCAL_PATH)/recovery/etc/twrp.fstab:recovery/root/etc/twrp.fstab
+
diff --git a/proprietary-files.txt b/proprietary-files.txt new file mode 100644 index 0000000..32a3443 --- /dev/null +++ b/proprietary-files.txt @@ -0,0 +1,634 @@ +system/bin/6620_launcher +system/bin/6620_wmt_concurrency +system/bin/6620_wmt_lpbk +system/bin/AcdApiDaemon +system/bin/MtkCodecService +system/bin/iperf +system/bin/ntfs-3g +system/bin/akmd8963 +system/bin/akmd8975 +system/bin/akmd09911 +system/bin/ami304d +system/bin/atci_service +system/bin/atcid +system/bin/audiocmdservice_atci +system/bin/autokd +system/bin/badblocks +system/bin/lcdc_screen_cap +system/bin/bmm050d +system/bin/btconfig +system/bin/btlogmask +system/bin/ccci_fsd +system/bin/ccci_mdinit +system/bin/dhcp6c +system/bin/dhcp6ctl +system/bin/dhcp6s +system/bin/em_svr +system/bin/fsck_msdos_mtk +system/bin/fuelgauged +system/bin/geomagneticd +system/bin/gsm0710muxd +system/bin/gsm0710muxdmd2 +system/bin/guiext-server +system/bin/hostapd +system/bin/hostapd_cli +system/bin/kpoc_charger +system/bin/lsm303md +system/bin/magd +system/bin/make_ext4fs +system/bin/matv +system/bin/mc6420d +system/bin/md_ctrl +system/bin/memorydumper +system/bin/memsicd +system/bin/memsicd3416x +system/bin/meta_tst +system/bin/mfv_ut +system/bin/mmp +system/bin/msensord +system/bin/mtk_agpsd +system/bin/mtk_setprop +system/bin/mtkbt +system/bin/mtkrild +system/bin/mtkrildmd2 +system/bin/netcfg +system/bin/netdiag +system/bin/nvram_agent_binder +system/bin/nvram_daemon +system/bin/orientationd +system/bin/perf_native_test +system/bin/permission_check +system/bin/ppl_agent +system/bin/pppd +system/bin/pppd_btdun +system/bin/pppd_dt +system/bin/pq +system/bin/racoon +system/bin/radvd +system/bin/rtt +system/bin/run-as +system/bin/s62xd +system/bin/terservice +system/bin/tertestclient +system/bin/thermal +system/bin/thermal_manager +system/bin/thermald +system/bin/tiny_mkswap +system/bin/tiny_swapoff +system/bin/tiny_swapon +system/bin/wifi2agps +system/bin/wmt_loader +system/bin/xlog +system/etc/bluetooth/auto_pair_blacklist.conf +system/etc/bluetooth/auto_pair_devlist.conf +system/etc/bluetooth/bt_did.conf +system/etc/bluetooth/bt_stack.conf +system/etc/bluetooth/btconfig.xml +system/etc/clatd.conf +system/etc/custom.conf +system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf +system/etc/dhcpcd/dhcpcd-hooks/95-configured +system/etc/dhcpcd/dhcpcd-run-hooks +system/etc/firmware/S_ANDRO_SFL.ini +system/etc/firmware/catcher_filter_1_ltg_n.bin +system/etc/firmware/catcher_filter_1_lwg_n.bin +system/etc/firmware/dsp_1_ltg_n.bin +system/etc/firmware/dsp_1_lwg_n.bin +system/etc/firmware/modem_1_ltg_n.img +system/etc/firmware/modem_1_lwg_n.img +system/etc/firmware/ROMv2_lm_patch_1_0_hdr.bin +system/etc/firmware/ROMv2_lm_patch_1_1_hdr.bin +system/etc/firmware/WIFI_RAM_CODE_6735 +system/etc/firmware/WMT_SOC.cfg +system/etc/mddb/BPLGUInfoCustomAppSrcP_MT6735_S00_MOLY_LR9_W1444_MD_LWTG_CMCC_MP_V9_P42_1_ltg_n +system/etc/mddb/BPLGUInfoCustomAppSrcP_MT6735_S00_MOLY_LR9_W1444_MD_LWTG_CMCC_MP_V9_P42_1_lwg_n +system/etc/mddb/DbgInfo_LR9.W1444.MD.LWTG.CMCC.MP_MEIZU6753_65C_L1_MOLY_LR9_W1444_MD_LWTG_CMCC_MP_V9_P42_2016_06_12_17_29_1_ltg_n +system/etc/mddb/DbgInfo_LR9.W1444.MD.LWTG.CMCC.MP_MEIZU6753_65C_L1_MOLY_LR9_W1444_MD_LWTG_CMCC_MP_V9_P42_2016_06_12_17_41_1_lwg_n +system/etc/mtk_omx_core.cfg +system/etc/mtklog-config.prop +system/etc/radvd/radvd.conf +system/etc/wifi/p2p_supplicant_overlay.conf +system/etc/wifi/wpa_supplicant.conf +system/etc/wifi/wpa_supplicant_overlay.conf +system/lib/drm/libdrmmtkplugin.so +system/lib/egl/egl.cfg +system/lib/hw/audio.primary.mt6753.so +system/lib/libmmsdkservice.feature_platform.so +system/lib64/libmmsdkservice.feature_platform.so +system/lib/hw/camera.mt6753.so +system/lib/hw/gps.default.so +system/lib/hw/lights.default.so +system/lib/hw/hwcomposer.mt6753.so +system/lib/hw/memtrack.mt6753.so +system/lib/hw/mmsdk.default.so +system/lib/lib3a.so +system/lib/lib3a_sample.so +system/lib/libAGifEncoder.so +system/lib/libBnMtkCodec.so +system/lib64/libBnMtkCodec.so +system/lib/libgccdemangle.so +system/lib64/libgccdemangle.so +system/lib/libstlport.so +system/lib64/libstlport.so +system/lib/libGdmaScalerPipe.so +system/lib/libJpgDecPipe.so +system/lib/libJpgEncPipe.so +system/lib/libMtkOmxAdpcmDec.so +system/lib/libMtkOmxAdpcmEnc.so +system/lib/libMtkOmxAlacDec.so +system/lib/libMtkOmxApeDec.so +system/lib/libMtkOmxCore.so +system/lib/libMtkOmxFlacDec.so +system/lib/libMtkOmxG711Dec.so +system/lib/libMtkOmxGsmDec.so +system/lib/libMtkOmxMp3Dec.so +system/lib/libMtkOmxRawDec.so +system/lib/libMtkOmxVdec.so +system/lib/libMtkOmxVenc.so +system/lib/libMtkOmxVorbisEnc.so +system/lib/libHEVCdec_sa.ca7.android.so +system/lib/libh264enc_sa.ca7.so +system/lib/libh264enc_sb.ca7.so +system/lib/libMtkVideoSpeedEffect.so +system/lib/libMtkVideoTranscoder.so +system/lib/libPQDCjni.so +system/lib/libPQjni.so +system/lib/libSwJpgCodec.so +system/lib/liba3m.so +system/lib/libaudioinfo_jni.so +system/lib/libavcodec.so +system/lib/libavformat.so +system/lib/libavutil.so +system/lib/libbt-aptX-ARM-4.2.2.so +system/lib/libcam.common.meizu.so +system/lib/libcfgdevparam.so +system/lib/libDiracAPI_SHARED.so +system/lib/libdlna_jni.so +system/lib/libDominantColors.so +system/lib/libeffects_filters.so +system/lib/libeffects_mosaic.so +system/lib/libexif_gallery.so +system/lib/libFace.so +system/lib/libffmpeg_utils.so +system/lib/libimage_codec.so +system/lib/libimage_dehazing.so +system/lib/libjni_gallery_utils.so +system/lib/libjni_gauss_blur.so +system/lib/libkanbox_meizu_gallery_sdk.so +system/lib/libmcode_image.so +system/lib/libmeizu.camera.algo.so +system/lib/libmeizucamera.so +system/lib/libMtkVideoSpeedEffect.so +system/lib/libmzplayer.so +system/lib/libnative_blur.so +system/lib/libphoto_process.so +system/lib/libRefocusModule.so +system/lib/librender_engine.so +system/lib/libRSSupport.so +system/lib/libsfb.so +system/lib/libskia_hw_interface.so +system/lib/libskia_private.so +system/lib/libstagefright_mzhttplive.so +system/lib/libstagefright_mzmpeg2ts.so +system/lib/libstagefright_soft_ffmpegadec.so +system/lib/libstagefright_soft_ffmpegvdec.so +system/lib/libswresample.so +system/lib/libswscale.so +system/lib/libtaglib.so +system/lib/libtiff.so +system/lib/libaal.so +system/lib/libacdk.so +system/lib/libadpcm.so +system/lib/libaed.so +system/lib/libatciserv_jni.so +system/lib/libatvctrlservice.so +system/lib/libaudiocompensationfilter.so +system/lib/libaudiocomponentengine.so +system/lib/libaudiocustparam.so +system/lib/libaudiodcrflt.so +system/lib/libaudiomtkdcremoval.so +system/lib/libaudiosetting.so +system/lib/libbessound_hd_mtk.so +system/lib/libbessurround_mtk.so +system/lib/libblisrc.so +system/lib/libblisrc32.so +system/lib/libbluetooth_mtk.so +system/lib/libbluetooth_relayer.so +system/lib/libbluetoothdrv.so +system/lib/libbluetoothem_mtk.so +system/lib/libbtcust.so +system/lib/libbtcusttable.so +system/lib/libbtcusttc1.so +system/lib/libbtem.so +system/lib/libbtpcm.so +system/lib/libbtsession.so +system/lib/libbtsniff.so +system/lib/libbtstd.so +system/lib/libbwc.so +system/lib/libcam.camadapter.so +system/lib/libcam.camnode.so +system/lib/libcam.camshot.so +system/lib/libcam.client.so +system/lib/libcam.device1.so +system/lib/libcam.exif.so +system/lib/libcam.halsensor.so +system/lib/libcam.iopipe.so +system/lib/libcam.jni.lomohaljni.so +system/lib/libcam.metadata.so +system/lib/libcam.paramsmgr.so +system/lib/libcam.sdkclient.so +system/lib/libcam.utils.sensorlistener.so +system/lib/libcam.utils.so +system/lib/libcam1_utils.so +system/lib/libcam_hwutils.so +system/lib/libcam_mmp.so +system/lib/libcam_platform.so +system/lib/libcam_utils.so +system/lib/libcamalgo.so +system/lib/libcamdrv.so +system/lib/libcamera_client_mtk.so +system/lib/libcamera_metadata.so +system/lib/libcameracustom.so +system/lib/libccci_util.so +system/lib/libcurl.so +system/lib/libcustom_jni.so +system/lib/libcustom_nvram.so +system/lib/libcustom_prop.so +system/lib/libcvsd_mtk.so +system/lib/libdcfdecoderjni.so +system/lib/libdirect-coredump.so +system/lib/libdpframework.so +system/lib/libdrmmtkutil.so +system/lib/libdrmmtkwhitelist.so +system/lib/libem_bt_jni.so +system/lib/libem_gpio_jni.so +system/lib/libem_lte_jni.so +system/lib/libem_modem_jni.so +system/lib/libem_sensor_jni.so +system/lib/libem_support_jni.so +system/lib/libem_usb_jni.so +system/lib/libem_wifi_jni.so +system/lib/libextsys.so +system/lib/libextsys_jni.so +system/lib/libexttestmode.so +system/lib/libfeatureio.so +system/lib/libfgauge.so +system/lib/libfile_op.so +system/lib/libged.so +system/lib/libgifEncoder_jni.so +system/lib/libgpu_aux.so +system/lib/libgraphite2.so +system/lib/libgui_ext.so +system/lib/libhotknot.so +system/lib/libhotknot_vendor.so +system/lib/libhwm.so +system/lib/libimageio.so +system/lib/libimageio_plat_drv.so +system/lib/libion.so +system/lib/libion_mtk.so +system/lib/libja3m.so +system/lib/libjni_lomoeffect.so +system/lib/libjni_pq.so +system/lib/libjtranscode.so +system/lib/libm.so +system/lib/libm4u.so +system/lib/libmatv_cust.so +system/lib/libmdloggerrecycle.so +system/lib/libmediatek_exceptionlog.so +system/lib/libmemoryDumpEncoder.so +system/lib/libmemorydumper.so +system/lib/libmhalImageCodec.so +system/lib/libmmprofile.so +system/lib/libmmprofile_jni.so +system/lib/libmmsdkservice.so +system/lib/libmnl.so +system/lib/libmp4enc_sa.ca7.so +system/lib/libmp4enc_xa.ca7.so +system/lib/libmpo.so +system/lib/libmpodecoder.so +system/lib/libmpoencoder.so +system/lib/libmpojni.so +system/lib/libmsbc_mtk.so +system/lib/libmtb.so +system/lib/libmtcloader.so +system/lib/libmtk_drvb.so +system/lib/libmtk_mmutils.so +system/lib/libmtkbtextspp.so +system/lib/libmtkjpeg.so +system/lib/libmtklimiter.so +system/lib/libmtkshifter.so +system/lib/libn3d3a.so +system/lib/libnativecheck-jni.so +system/lib/libnetutils.so +system/lib/libnfc_ndef.so +system/lib/libnvram.so +system/lib/libnvram_daemon_callback.so +system/lib/libnvram_platform.so +system/lib/libnvram_sec.so +system/lib/libnvramagentclient.so +system/lib/libpalsecurity.so +system/lib/libpalwlan_mtk.so +system/lib/libperfservice.so +system/lib/libperfservicenative.so +system/lib/libpppbtdun.so +system/lib/libpq_cust.so +system/lib/libpq_prot.so +system/lib/libJniAtvService.so +system/lib/librilmtk.so +system/lib/librilmtkmd2.so +system/lib/libsbccodec.so +system/lib/libsec.so +system/lib/libshowlogo.so +system/lib/libspeech_enh_lib.so +system/lib/libssladp.so +system/lib/libstagefrighthw.so +system/lib/libtimestretch.so +system/lib/libtinyalsa.so +system/lib/libtinyxml.so +system/lib/libtouchfilter.so +system/lib/libudf.so +system/lib/libui.so +system/lib/libui_ext.so +system/lib/libvc1dec_sa.ca7.so +system/lib/libvcodec_oal.so +system/lib/libvcodec_utility.so +system/lib/libvcodecdrv.so +system/lib/libvie.so +system/lib/libtinycompress.so +system/lib64/libtinycompress.so +system/lib/libvie_jni.so +system/lib/libvoicerecognition.so +system/lib/libvoicerecognition_jni.so +system/lib/libvp8dec_sa.ca7.so +system/lib/libvp8enc_sa.ca7.so +system/lib/libvp9dec_sa.ca7.so +system/lib/mtk-ril.so +system/lib/mtk-rilmd2.so +system/lib64/mtk-ril.so +system/lib64/mtk-rilmd2.so +system/lib64/hw/audio.primary.mt6753.so +system/lib64/hw/camera.mt6753.so +system/lib64/hw/gps.default.so +system/lib64/hw/lights.default.so +system/lib64/hw/hwcomposer.mt6753.so +system/lib64/hw/memtrack.mt6753.so +system/lib64/hw/mmsdk.default.so +system/lib64/hw/sensors.mt6753.so +system/lib64/lib3a.so +system/lib64/lib3a_sample.so +system/lib64/libGdmaScalerPipe.so +system/lib64/libJpgDecPipe.so +system/lib64/libJpgEncPipe.so +system/lib64/libMtkOmxCore.so +system/lib64/libMtkVideoTranscoder.so +system/lib/drm/libdrmctaplugin.so +system/lib64/libPQDCjni.so +system/lib64/libPQjni.so +system/lib64/libaudioinfo_jni.so +system/lib64/libavcodec.so +system/lib64/libavformat.so +system/lib64/libavutil.so +system/lib64/libbt-aptX-ARM-4.2.2.so +system/lib64/libcam.common.meizu.so +system/lib64/libcfgdevparam.so +system/lib64/libdlna_jni.so +system/lib64/libDominantColors.so +system/lib64/libeffects_mosaic.so +system/lib64/libexif_gallery.so +system/lib64/libFace.so +system/lib64/libffmpeg_utils.so +system/lib64/libimage_codec.so +system/lib64/libipc_pref.527.1.so +system/lib64/libmcode_image.so +system/lib64/libmeizu.camera.algo.so +system/lib64/libmeizucamera.so +system/lib64/libmzplayer.so +system/lib64/libnative_blur.so +system/lib64/libpatch-1.0.1.so +system/lib64/librender_engine.so +system/lib64/libsfb.so +system/lib64/libskia_hw_interface.so +system/lib64/libstagefright_mzhttplive.so +system/lib64/libstagefright_mzmpeg2ts.so +system/lib64/libstagefright_soft_ffmpegadec.so +system/lib64/libstagefright_soft_ffmpegvdec.so +system/lib64/libswresample.so +system/lib64/libswscale.so +system/lib64/libtaglib.so +system/lib64/libtiff.so +system/lib64/libupdate-jni-1.0.1.2002.so +system/lib64/libSwJpgCodec.so +system/lib64/liba3m.so +system/lib64/libaal.so +system/lib64/libacdk.so +system/lib64/libaed.so +system/lib64/libatciserv_jni.so +system/lib64/libatvctrlservice.so +system/lib64/libaudiocompensationfilter.so +system/lib64/libaudiocomponentengine.so +system/lib64/libaudiocustparam.so +system/lib64/libaudiodcrflt.so +system/lib64/libaudiopolicymanager.so +system/lib64/libaudiopolicymanagerdefault.so +system/lib64/libaudiosetting.so +system/lib64/libbessound_hd_mtk.so +system/lib64/libblisrc.so +system/lib64/libblisrc32.so +system/lib64/libbluetooth_mtk.so +system/lib64/libbluetooth_relayer.so +system/lib64/libbluetoothdrv.so +system/lib64/libbluetoothem_mtk.so +system/lib64/libbtcusttable.so +system/lib64/libbtem.so +system/lib64/libbtstd.so +system/lib64/libbwc.so +system/lib64/libcam.camadapter.so +system/lib64/libcam.camnode.so +system/lib64/libcam.camshot.so +system/lib64/libcam.client.so +system/lib64/libcam.device1.so +system/lib64/libcam.exif.so +system/lib64/libcam.halsensor.so +system/lib64/libcam.iopipe.so +system/lib64/libcam.jni.lomohaljni.so +system/lib64/libcam.metadata.so +system/lib64/libcam.paramsmgr.so +system/lib64/libcam.sdkclient.so +system/lib64/libcam.utils.sensorlistener.so +system/lib64/libcam.utils.so +system/lib64/libcam1_utils.so +system/lib64/libcam_hwutils.so +system/lib64/libcam_mmp.so +system/lib64/libcam_platform.so +system/lib64/libcam_utils.so +system/lib64/libcamalgo.so +system/lib64/libcamdrv.so +system/lib64/libcamera_client_mtk.so +system/lib64/libcamera_metadata.so +system/lib64/libcameracustom.so +system/lib64/libccci_util.so +system/lib64/libcurl.so +system/lib64/libcustom_jni.so +system/lib64/libcustom_nvram.so +system/lib64/libcustom_prop.so +system/lib64/libcvsd_mtk.so +system/lib64/libdcfdecoderjni.so +system/lib64/libdirect-coredump.so +system/lib64/libdpframework.so +system/lib64/libdrmmtkutil.so +system/lib64/libdrmmtkwhitelist.so +system/lib64/libem_bt_jni.so +system/lib64/libem_gpio_jni.so +system/lib64/libem_lte_jni.so +system/lib64/libem_modem_jni.so +system/lib64/libem_sensor_jni.so +system/lib64/libem_support_jni.so +system/lib64/libem_usb_jni.so +system/lib64/libem_wifi_jni.so +system/lib64/libextadvanced_jni.so +system/lib64/libextem.so +system/lib64/libextsys.so +system/lib64/libextsys_jni.so +system/lib64/libfeatureio.so +system/lib64/libfile_op.so +system/lib64/libged.so +system/lib64/libgpu_aux.so +system/lib64/libgraphite2.so +system/lib64/libgui_ext.so +system/lib64/libhotknot.so +system/lib64/libhotknot_vendor.so +system/lib64/libhwm.so +system/lib64/libimageio.so +system/lib64/libimageio_plat_drv.so +system/lib64/libion.so +system/lib64/libion_mtk.so +system/lib64/libja3m.so +system/lib64/libjni_lomoeffect.so +system/lib64/libjni_pq.so +system/lib64/libm4u.so +system/lib64/libmatv_cust.so +system/lib64/libmdloggerrecycle.so +system/lib64/libmediatek_exceptionlog.so +system/lib64/libmemoryDumpEncoder.so +system/lib64/libmemorydumper.so +system/lib64/libmhalImageCodec.so +system/lib64/libmmprofile.so +system/lib64/libmmprofile_jni.so +system/lib64/libmmsdkservice.so +system/lib64/libmpo.so +system/lib64/libmpoencoder.so +system/lib64/libmsbc_mtk.so +system/lib64/libmtk_drvb.so +system/lib64/libmtk_mmutils.so +system/lib64/libmtkjpeg.so +system/lib64/libmtklimiter.so +system/lib64/libmtkshifter.so +system/lib64/liblogwrap.so +system/lib64/libn3d3a.so +system/lib64/libnativecheck-jni.so +system/lib64/libnetutils.so +system/lib64/libnfc_ndef.so +system/lib64/libnvram.so +system/lib64/libnvram_daemon_callback.so +system/lib64/libnvram_platform.so +system/lib64/libnvram_sec.so +system/lib64/libnvramagentclient.so +system/lib64/libperfservice.so +system/lib64/libperfservicenative.so +system/lib64/libpppbtdun.so +system/lib64/libpq_cust.so +system/lib64/libpq_prot.so +system/lib64/librilmtk.so +system/lib64/librilmtkmd2.so +system/lib64/libspeech_enh_lib.so +system/lib64/libstagefrighthw.so +system/lib64/libsysutils.so +system/lib64/libterservice.so +system/lib64/libtinyxml.so +system/lib64/libtouchfilter.so +system/lib64/libudf.so +system/lib64/libui.so +system/lib64/libui_ext.so +system/lib64/libvcodecdrv.so +system/lib64/libwapi.so +system/lib64/libwifitest.so +system/usr/keylayout/ACCDET.kl +system/usr/keylayout/AVRCP.kl +system/usr/keylayout/mtk-kpd.kl +system/usr/keylayout/mtk-tpd.kl +system/vendor/lib/drm/libdrmwvmplugin.so +system/lib/egl/libGLES_mali.so +system/lib64/egl/libGLES_mali.so +system/vendor/lib/hw/audio.a2dp.blueangel.so +system/vendor/lib/hw/bluetooth.blueangel.so +system/lib/hw/gralloc.mt6753.so +system/lib64/hw/gralloc.mt6753.so +system/vendor/lib/libWVStreamControlAPI_L3.so +system/vendor/lib/libwvdrm_L3.so +system/vendor/lib/libwvm.so +system/vendor/lib/mediadrm/libmockdrmcryptoplugin.so +system/vendor/lib/mediadrm/libwvdrmengine.so +system/vendor/lib64/mediadrm/libmockdrmcryptoplugin.so +system/xbin/BGW +system/xbin/mnld +system/lib/libcam.device3.so +system/lib/libcam.hal3a.v3.so +system/lib/libcam.metadataprovider.so +system/lib/libcam3_hwnode.so +system/lib/libcam3_hwpipeline.so +system/lib64/libcam.device3.so +system/lib64/libcam.hal3a.v3.so +system/lib64/libcam.metadataprovider.so +system/lib64/libcam3_hwnode.so +system/lib64/libcam3_hwpipeline.so +system/lib/libcam3_app.so +system/lib64/libcam3_app.so +system/lib/libcam3_pipeline.so +system/lib64/libcam3_pipeline.so +system/lib/libcam3_utils.so +system/lib64/libcam3_utils.so +system/lib/libcam.exif.v3.so +system/lib64/libcam.exif.v3.so +system/lib/libcam.utils.cpuctrl.so +system/lib64/libcam.utils.cpuctrl.so +system/lib/libdngop.so +system/lib64/libdngop.so +system/lib64/libmtksqlite3_custom.so +system/lib64/libmtksqlite3_android.so +system/lib/libcam.hal3a.v3.dng.so +system/lib64/libcam.hal3a.v3.dng.so +system/lib/libmmsdkservice.feature.so +system/lib64/libmmsdkservice.feature.so +system/lib/libfeatureiodrv.so +system/lib64/libfeatureiodrv.so +system/lib64/libMtkOmxAdpcmDec.so +system/lib64/libMtkOmxAdpcmEnc.so +system/lib64/libMtkOmxAlacDec.so +system/lib64/libMtkOmxApeDec.so +system/lib64/libMtkOmxG711Dec.so +system/lib64/libMtkOmxGsmDec.so +system/lib64/libMtkOmxMp3Dec.so +system/lib64/libMtkOmxRawDec.so +system/lib64/libMtkOmxVorbisEnc.so +#system/bin/flymed +#system/bin/batterywarning +#system/bin/boot_logo_updater +#system/bin/factory +#system/bin/dmlog +#system/bin/dualmdlogger +#system/bin/emdlogger1 +#system/bin/mobile_log_d +#system/bin/mdlogger +#system/bin/pppd_via +#system/bin/pppoe +#system/lib/libgralloc_extra.so +#system/lib64/libgralloc_extra.so +#system/bin/program_binary_service +#system/lib/libmtkplayer.so +#system/lib64/libmtkplayer.so +#system/bin/nmbd +#system/bin/smbd +#system/bin/smbpasswd +#system/lib/libkanbox_meizu_gallery_sdk.so +#system/lib64/libmobilesafe360-sdk-jni-524.2.so +#system/bin/muxreport diff --git a/ril/telephony/java/com/android/internal/telephony/MT6753.java b/ril/telephony/java/com/android/internal/telephony/MT6753.java new file mode 100644 index 0000000..6525f1d --- /dev/null +++ b/ril/telephony/java/com/android/internal/telephony/MT6753.java @@ -0,0 +1,516 @@ +/* + * Copyright (C) 2016 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. + */ + +package com.android.internal.telephony; + +import static com.android.internal.telephony.RILConstants.*; + +import com.android.internal.telephony.dataconnection.DataCallResponse; +import com.android.internal.telephony.uicc.IccRefreshResponse; + +import android.content.Context; +import android.os.AsyncResult; +import android.os.Message; +import android.os.Parcel; +import android.os.SystemProperties; + +import android.provider.Settings; +import android.provider.Settings.Global; + +import android.telephony.TelephonyManager; +import android.telephony.Rlog; + +import com.android.internal.telephony.MtkEccList; + + +/** + * Custom wrapper for MTK requests + * + * {@hide} + */ +public class MT6753 extends RIL implements CommandsInterface { + + private static final int RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED = 3015; + private static final int RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED = 3024; + private static final int RIL_UNSOL_INCOMING_CALL_INDICATION = 3042; + private static final int RIL_UNSOL_CALL_INFO_INDICATION = 3049; + private static final int RIL_UNSOL_SET_ATTACH_APN = 3073; + + private static final int RIL_REQUEST_MODEM_POWEROFF = 2010; + private static final int RIL_REQUEST_MODEM_POWERON = 2028; + private static final int RIL_REQUEST_RESUME_REGISTRATION = 2065; + private static final int RIL_REQUEST_SET_CALL_INDICATION = 2086; + private static final int RIL_REQUEST_EMERGENCY_DIAL = 2087; + private static final int RIL_REQUEST_SET_ECC_SERVICE_CATEGORY = 2088; + private static final int RIL_REQUEST_SET_ECC_LIST = 2089; + + private static final int REFRESH_SESSION_RESET = 6; /* Session reset */ + + private int[] dataCallCids = { -1, -1, -1, -1, -1 }; + + private Context mContext; + private TelephonyManager mTelephonyManager; + private MtkEccList mEccList; + + public MT6753(Context context, int preferredNetworkType, int cdmaSubscription) { + super(context, preferredNetworkType, cdmaSubscription, null); + } + + public MT6753(Context context, int preferredNetworkType, + int cdmaSubscription, Integer instanceId) { + super(context, preferredNetworkType, cdmaSubscription, instanceId); + mContext = context; + mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + mEccList = new MtkEccList(); + } + + private static String + localRequestToString(int request) + { + switch(request) { + case RIL_REQUEST_RESUME_REGISTRATION: return "RIL_REQUEST_RESUME_REGISTRATION"; + case RIL_REQUEST_SET_CALL_INDICATION: return "RIL_REQUEST_SET_CALL_INDICATION"; + case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL"; + case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY"; + case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST"; + case RIL_REQUEST_MODEM_POWEROFF: return "RIL_REQUEST_MODEM_POWEROFF"; + case RIL_REQUEST_MODEM_POWERON: return "RIL_REQUEST_MODEM_POWERON"; + default: return "<unknown response>"; + } + } + + + @Override + protected void + processUnsolicited (Parcel p) { + Object ret; + int dataPosition = p.dataPosition(); // save off position within the Parcel + int response = p.readInt(); + + switch(response) { + case RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED: ret = responseRegSuspended(p); break; + case RIL_UNSOL_INCOMING_CALL_INDICATION: ret = responseIncomingCallIndication(p); break; + case RIL_UNSOL_CALL_INFO_INDICATION: ret = responseCallProgress(p); break; + case RIL_UNSOL_SET_ATTACH_APN: ret = responseSetAttachApn(p); break; + case RIL_UNSOL_ON_USSD: ret = responseStrings(p); break; + case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED: ret = responseInts(p); break; + default: + // Rewind the Parcel + p.setDataPosition(dataPosition); + // Forward responses that we are not overriding to the super class + super.processUnsolicited(p); + return; + } + switch(response) { + case RIL_UNSOL_INCOMING_CALL_INDICATION: + mCallStateRegistrants + .notifyRegistrants(new AsyncResult(null, null, null)); + break; + case RIL_UNSOL_CALL_INFO_INDICATION: + if (ret == null) { + mCallStateRegistrants + .notifyRegistrants(new AsyncResult(null, null, null)); + } + break; + case RIL_UNSOL_ON_USSD: + String[] resp = (String[])ret; + + if (resp.length < 2) { + resp = new String[2]; + resp[0] = ((String[])ret)[0]; + resp[1] = null; + } + if (resp[0] != null && + Integer.parseInt(resp[0]) >= 2 && + Integer.parseInt(resp[0]) <=5 ) { + // support USSD_SESSION_END and USSD_HANDLED_BY_STK as normal finishes + resp[0] = "0"; + } + + if (RILJ_LOGD) unsljLogMore(response, resp[0]); + if (mUSSDRegistrant != null) { + mUSSDRegistrant.notifyRegistrant( + new AsyncResult (null, resp, null)); + } + break; + case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED: + if (((int[])ret)[0] != 4) + mVoiceNetworkStateRegistrants + .notifyRegistrants(new AsyncResult(null, null, null)); + break; + + } + + } + + protected Object + responseRegSuspended(Parcel p) { + int numInts; + int response[]; + + numInts = p.readInt(); + + response = new int[numInts]; + + for (int i = 0 ; i < numInts ; i++) { + response[i] = p.readInt(); + } + + RILRequest rr = RILRequest.obtain(RIL_REQUEST_RESUME_REGISTRATION, null); + + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + localRequestToString(rr.mRequest) + + " sessionId " + response[0]); + + rr.mParcel.writeInt(1); + rr.mParcel.writeInt(response[0]); + + send(rr); + + return response; + } + + protected Object + responseIncomingCallIndication(Parcel p) { + String response[]; + + response = p.readStringArray(); + + RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_CALL_INDICATION, null); + + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + localRequestToString(rr.mRequest)); + + rr.mParcel.writeInt(3); + rr.mParcel.writeInt(Integer.parseInt(response[3])); + rr.mParcel.writeInt(Integer.parseInt(response[0])); + rr.mParcel.writeInt(Integer.parseInt(response[4])); + send(rr); + + return response; + } + + protected Object + responseCallProgress(Parcel p) { + String response[]; + + response = p.readStringArray(); + + if (response.length >= 2) { + if (response[1].equals("129")) { // Call termination + return null; + } + } + return response; + } + + @Override + public void setInitialAttachApn(String apn, String protocol, int authType, String username, + String password, Message result) { + RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_INITIAL_ATTACH_APN, null); + + String operatorNumber = mTelephonyManager.getSimOperatorNumericForPhone(mInstanceId); + if (RILJ_LOGD) { riljLog("Set RIL_REQUEST_SET_INITIAL_ATTACH_APN"); } + + rr.mParcel.writeString(apn); + rr.mParcel.writeString(protocol); + rr.mParcel.writeInt(authType); + rr.mParcel.writeString(username); + rr.mParcel.writeString(password); + + rr.mParcel.writeString(operatorNumber); + rr.mParcel.writeInt(1); + rr.mParcel.writeStringArray(null); + + if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + + ", apn:" + apn + ", protocol:" + protocol + ", authType:" + authType + + ", username:" + username + ", password:" + password + ", operator:" + operatorNumber); + } + + send(rr); + } + + protected Object + responseSetAttachApn(Parcel p) { + // The stack refuses to attach to LTE unless an IA APN was set, and + // will loop until it happens. Set an empty one to unblock. + setInitialAttachApn("","",0,"","",null); + return null; + } + + @Override + protected Object + responseSimRefresh(Parcel p) { + IccRefreshResponse response = new IccRefreshResponse(); + + response.refreshResult = p.readInt(); + String rawefId = p.readString(); + response.efId = rawefId == null ? 0 : Integer.parseInt(rawefId); + response.aid = p.readString(); + + if (response.refreshResult > IccRefreshResponse.REFRESH_RESULT_RESET) { + if (response.refreshResult == REFRESH_SESSION_RESET) { + response.refreshResult = IccRefreshResponse.REFRESH_RESULT_RESET; + } else { + response.refreshResult = IccRefreshResponse.REFRESH_RESULT_INIT; + } + } + + return response; + } + + @Override + public void + setupDataCall(String radioTechnology, String profile, String apn, + String user, String password, String authType, String protocol, + Message result) { + int interfaceId=0; + RILRequest rr + = RILRequest.obtain(RIL_REQUEST_SETUP_DATA_CALL, result); + + rr.mParcel.writeInt(8); //bumped by one + + rr.mParcel.writeString(radioTechnology); + rr.mParcel.writeString(profile); + rr.mParcel.writeString(apn); + rr.mParcel.writeString(user); + rr.mParcel.writeString(password); + rr.mParcel.writeString(authType); + rr.mParcel.writeString(protocol); + + /* Find the first available interfaceId */ + for (int i=0; i < 4; i++) { + if (dataCallCids[i] < 0) { + interfaceId = i+1; + break; + } + } + rr.mParcel.writeString(interfaceId+""); + + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + + requestToString(rr.mRequest) + " " + radioTechnology + " " + + profile + " " + apn + " " + user + " " + + password + " " + authType + " " + protocol + " " + interfaceId); + + send(rr); + } + + @Override + public void + deactivateDataCall(int cid, int reason, Message result) { + for (int i=0; i < 4; i++) { + if (dataCallCids[i] == cid) { + dataCallCids[i] = -1; + break; + } + } + super.deactivateDataCall(cid, reason, result); + } + + @Override + public void + dial(String address, int clirMode, UUSInfo uusInfo, Message result) { + if (mEccList.isEmergencyNumberExt(address)) { + int serviceCategory = mEccList.getServiceCategoryFromEcc(address); + + RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_ECC_SERVICE_CATEGORY, null); + + rr.mParcel.writeInt(1); + rr.mParcel.writeInt(serviceCategory); + + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + localRequestToString(rr.mRequest) + + " " + serviceCategory); + + send(rr); + + + rr = RILRequest.obtain(RIL_REQUEST_EMERGENCY_DIAL, result); + rr.mParcel.writeString(address); + rr.mParcel.writeInt(clirMode); + rr.mParcel.writeInt(0); // UUS information is absent + + if (uusInfo == null) { + rr.mParcel.writeInt(0); // UUS information is absent + } else { + rr.mParcel.writeInt(1); // UUS information is present + rr.mParcel.writeInt(uusInfo.getType()); + rr.mParcel.writeInt(uusInfo.getDcs()); + rr.mParcel.writeByteArray(uusInfo.getUserData()); + } + + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + localRequestToString(rr.mRequest)); + + send(rr); + + } else { + super.dial(address, clirMode, uusInfo, result); + } + } + + private void refreshEmergencyList() { + if (mEccList != null) mEccList.updateEmergencyNumbersProperty(); + } + + @Override + public void + setRadioPower(boolean on, Message result) { + boolean isInApm = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.AIRPLANE_MODE_ON, 0) == 1; + boolean wasInApm = SystemProperties.get("persist.radio.airplane.mode.on").equals("true"); + + SystemProperties.set("persist.radio.airplane.mode.on", isInApm ? "true" : "false"); + + if (on && wasInApm && !isInApm) { + SystemProperties.set("gsm.ril.eboot", "0"); + RILRequest rr = RILRequest.obtain(RIL_REQUEST_MODEM_POWERON, result); + if (RILJ_LOGD) { + riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); + } + send(rr); + } else if (!on && isInApm) { + SystemProperties.set("gsm.ril.eboot", "1"); + RILRequest rr = RILRequest.obtain(RIL_REQUEST_MODEM_POWEROFF, result); + if (RILJ_LOGD) { + riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); + } + send(rr); + } else { + super.setRadioPower(on, result); + } + } + + // Solicited request handling + @Override + protected RILRequest + processSolicited (Parcel p) { + int serial, error; + int dataPosition = p.dataPosition(); // save off position within the Parcel + serial = p.readInt(); + error = p.readInt(); + + RILRequest rr = null; + + /* Pre-process the reply before popping it */ + synchronized (mRequestList) { + RILRequest tr = mRequestList.get(serial); + if (tr != null && tr.mSerial == serial) { + if (error == 0 || p.dataAvail() > 0) { + try {switch (tr.mRequest) { + /* Get those we're interested in */ + case RIL_REQUEST_EMERGENCY_DIAL: + case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: + case RIL_REQUEST_DATA_REGISTRATION_STATE: + case RIL_REQUEST_SETUP_DATA_CALL: + case RIL_REQUEST_ALLOW_DATA: + rr = tr; + break; + // vendor ril refreshes the properties while generating this answer. Do our own updates afterwards + case RIL_REQUEST_GET_SIM_STATUS: refreshEmergencyList(); // no break, we want the superclass to process this + }} catch (Throwable thr) { + // Exceptions here usually mean invalid RIL responses + if (tr.mResult != null) { + AsyncResult.forMessage(tr.mResult, null, thr); + tr.mResult.sendToTarget(); + } + return tr; + } + } + } + } + + if (rr == null) { + /* Nothing we care about, go up */ + p.setDataPosition(dataPosition); + + // Forward responses that we are not overriding to the super class + return super.processSolicited(p); + } + + + rr = findAndRemoveRequestFromList(serial); + + if (rr == null) { + return rr; + } + + Object ret = null; + + if (error == 0 || p.dataAvail() > 0) { + switch (rr.mRequest) { + case RIL_REQUEST_EMERGENCY_DIAL: ret = responseVoid(p); break; + case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: ret = responseVoid(p); break; + case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = fixupPSBearerDataRegistration(p); break; + case RIL_REQUEST_SETUP_DATA_CALL: ret = fetchCidFromDataCall(p); break; + case RIL_REQUEST_ALLOW_DATA: ret = responseVoid(p); mVoiceNetworkStateRegistrants.notifyRegistrants(new AsyncResult(null, null, null)); break; + default: + throw new RuntimeException("Shouldn't be here: " + rr.mRequest); + } + //break; + } + + if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest) + + " " + retToString(rr.mRequest, ret)); + + if (rr.mResult != null) { + AsyncResult.forMessage(rr.mResult, ret, null); + rr.mResult.sendToTarget(); + } + + return rr; + } + + private Object + fixupPSBearerDataRegistration(Parcel p) { + int num; + String response[]; + + response = p.readStringArray(); + + if (response.length >= 4 && + response[3] != null && + Integer.parseInt(response[3]) >= 128) { + // extended values >= RIL_RADIO_TECHNOLOGY_MTK (128) == HSPAP (15) + response[3] = "15"; + } + + return response; + } + + private Object + fetchCidFromDataCall(Parcel p) { + DataCallResponse ret = (DataCallResponse)super.responseSetupDataCall(p); + + if (ret.cid >= 0) { + for (int i = 0; i < 4; i++) { + if (dataCallCids[i] < 0) { + dataCallCids[i] = ret.cid; + break; + } + } + } + return ret; + } + + @Override + public void + iccIOForApp (int command, int fileid, String path, int p1, int p2, int p3, + String data, String pin2, String aid, Message result) { + if (command == 0xc0 && p3 == 0) { + Rlog.i("MT6753", "Override the size for the COMMAND_GET_RESPONSE 0 => 15"); + p3 = 15; + } + super.iccIOForApp(command, fileid, path, p1, p2, p3, data, pin2, aid, result); + } + +} diff --git a/ril/telephony/java/com/android/internal/telephony/MtkEccList.java b/ril/telephony/java/com/android/internal/telephony/MtkEccList.java new file mode 100644 index 0000000..fa5d612 --- /dev/null +++ b/ril/telephony/java/com/android/internal/telephony/MtkEccList.java @@ -0,0 +1,384 @@ +/* + * Copyright (C) 2014 MediaTek Inc. + */ + +/* + * Copyright (C) 2016 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. + */ + +package com.android.internal.telephony; + +import android.os.SystemProperties; + +import android.telephony.PhoneNumberUtils; +import android.telephony.Rlog; + +import android.text.TextUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlPullParserFactory; +import java.io.FileReader; +import java.io.IOException; + +public class MtkEccList extends PhoneNumberUtils { + + static final String LOG_TAG = "MtkEccList"; + + private static ArrayList<EccEntry> mCustomizedEccList = null; + private static HashMap<String, Integer> mHashMapForNetworkEccCategory = null; + private static boolean sIsCtaSet = true; + + static { + sIsCtaSet = "1".equals(SystemProperties.get("ro.mtk_cta_set")); + mCustomizedEccList = new ArrayList<EccEntry>(); + parseEccList(); + mHashMapForNetworkEccCategory = new HashMap<String, Integer>(); + } + + /** @hide */ + public static class EccEntry { + public static final String ECC_LIST_PATH = "/system/etc/ecc_list.xml"; + public static final String ECC_ENTRY_TAG = "EccEntry"; + public static final String ECC_ATTR = "Ecc"; + public static final String CATEGORY_ATTR = "Category"; + public static final String CONDITION_ATTR = "Condition"; + + public static final String ECC_NO_SIM = "0"; + public static final String ECC_ALWAYS = "1"; + public static final String ECC_FOR_MMI = "2"; + + private String mEcc; + private String mCategory; + private String mCondition; // ECC_NO_SIM, ECC_ALWAYS, or ECC_FOR_MMI + + public EccEntry() { + mEcc = new String(""); + mCategory = new String(""); + mCondition = new String(""); + } + + public void setEcc(String strEcc) { + mEcc = strEcc; + } + public void setCategory(String strCategory) { + mCategory = strCategory; + } + public void setCondition(String strCondition) { + mCondition = strCondition; + } + + public String getEcc() { + return mEcc; + } + public String getCategory() { + return mCategory; + } + public String getCondition() { + return mCondition; + } + + @Override + public String toString() { + return ("\n" + ECC_ATTR + "=" + getEcc() + ", " + CATEGORY_ATTR + "=" + + getCategory() + ", " + CONDITION_ATTR + "=" + getCondition()); + } + } + + /** + * Parse Ecc List From XML File + * + * @param none. + * @return none. + * @hide + */ + private static void parseEccList() { + mCustomizedEccList.clear(); + + // Parse GSM ECC list + try { + XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); + XmlPullParser parser = factory.newPullParser(); + if (parser == null) { + Rlog.d(LOG_TAG, "XmlPullParserFactory.newPullParser() return null"); + return; + } + FileReader fileReader = new FileReader(EccEntry.ECC_LIST_PATH); + parser.setInput(fileReader); + int eventType = parser.getEventType(); + EccEntry record = null; + + while (eventType != XmlPullParser.END_DOCUMENT) { + switch (eventType) { + case XmlPullParser.START_TAG: + if (parser.getName().equals(EccEntry.ECC_ENTRY_TAG)) { + record = new EccEntry(); + int attrNum = parser.getAttributeCount(); + for (int i = 0; i < attrNum; ++i) { + String name = parser.getAttributeName(i); + String value = parser.getAttributeValue(i); + if (name.equals(EccEntry.ECC_ATTR)) + record.setEcc(value); + else if (name.equals(EccEntry.CATEGORY_ATTR)) + record.setCategory(value); + else if (name.equals(EccEntry.CONDITION_ATTR)) + record.setCondition(value); + } + } + break; + case XmlPullParser.END_TAG: + if (parser.getName().equals(EccEntry.ECC_ENTRY_TAG) && record != null) + mCustomizedEccList.add(record); + break; + } + eventType = parser.next(); + } + fileReader.close(); + + if (sIsCtaSet) { + String [] emergencyCTAList = {"120", "122", "110", "119"}; + for (String emergencyNum : emergencyCTAList) { + record = new EccEntry(); + record.setEcc(emergencyNum); + record.setCategory("0"); + record.setCondition(EccEntry.ECC_FOR_MMI); + + boolean bFound = false; + int nIndex = 0; + for (EccEntry eccEntry : mCustomizedEccList) { + String ecc = eccEntry.getEcc(); + if (ecc.equals(emergencyNum)) { + bFound = true; + Rlog.d(LOG_TAG, "[parseEccList]" + + "CTA ecc match customized ecc list, ecc=" + ecc); + break; + } + nIndex++; + } + + if (bFound) + mCustomizedEccList.set(nIndex, record); + else + mCustomizedEccList.add(record); + } + } + } catch (XmlPullParserException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static boolean isEmergencyNumberExt(String number) { + Rlog.d(LOG_TAG, "[isEmergencyNumberExt], number:" + number ); + if (number == null) { + return false; + } + String numberPlus = null; + boolean bSIMInserted = false; + + // Strip the separators from the number before comparing it + // to the list. + number = extractNetworkPortionAlt(number); + + // 1. Check ECCs updated by network + mHashMapForNetworkEccCategory.clear(); + String strEccCategoryList = SystemProperties.get("ril.ecc.service.category.list"); + if (!TextUtils.isEmpty(strEccCategoryList)) { + for (String strEccCategory : strEccCategoryList.split(";")) { + if (!strEccCategory.isEmpty()) { + String[] strEccCategoryAry = strEccCategory.split(","); + if (2 == strEccCategoryAry.length) { + mHashMapForNetworkEccCategory.put(strEccCategoryAry[0], + Integer.parseInt(strEccCategoryAry[1])); + } + } + } + } + for (String emergencyNum : mHashMapForNetworkEccCategory.keySet()) { + numberPlus = emergencyNum + "+"; + if (emergencyNum.equals(number) + || numberPlus.equals(number)) { + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] match network ecc list"); + return true; + } + } + // 2. Check ECCs stored at SIMs + // Read from SIM1 + String numbers = SystemProperties.get("ril.ecclist"); + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] ril.ecclist: " + numbers); + if (!TextUtils.isEmpty(numbers)) { + // searches through the comma-separated list for a match, + // return true if one is found. + for (String emergencyNum : numbers.split(",")) { + numberPlus = emergencyNum + "+"; + if (emergencyNum.equals(number) + || numberPlus.equals(number)) { + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] match ril.ecclist"); + return true; + } + } + bSIMInserted = true; + } + + // Read from SIM2 + numbers = SystemProperties.get("ril.ecclist1"); + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] ril.ecclist1: " + numbers); + if (!TextUtils.isEmpty(numbers)) { + // searches through the comma-separated list for a match, + // return true if one is found. + for (String emergencyNum : numbers.split(",")) { + numberPlus = emergencyNum + "+"; + if (emergencyNum.equals(number) + || numberPlus.equals(number)) { + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] match ril.ecclist1"); + return true; + } + } + bSIMInserted = true; + } + + // 3. Check ECCs customized by user + if (bSIMInserted) { + if (mCustomizedEccList != null) { + for (EccEntry eccEntry : mCustomizedEccList) { + if (!eccEntry.getCondition().equals(EccEntry.ECC_NO_SIM)) { + String ecc = eccEntry.getEcc(); + numberPlus = ecc + "+"; + if (ecc.equals(number) + || numberPlus.equals(number)) { + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] match" + + " customized ecc list"); + return true; + } + } + } + } + } else { + if (mCustomizedEccList != null) { + for (EccEntry eccEntry : mCustomizedEccList) { + String ecc = eccEntry.getEcc(); + numberPlus = ecc + "+"; + if (ecc.equals(number) + || numberPlus.equals(number)) { + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] match" + + " customized ecc list when no sim"); + return true; + } + } + } + } + Rlog.d(LOG_TAG, "[isEmergencyNumberExt] no match"); + return false; + } + + /** + * Get the service category for the given ECC number. + * @param number The ECC number. + * @return The service category for the given number. + * @hide + */ + public static int getServiceCategoryFromEcc(String number) { + String numberPlus = null; + + // 1. Get category from network + for (String emergencyNum : mHashMapForNetworkEccCategory.keySet()) { + numberPlus = emergencyNum + "+"; + if (emergencyNum.equals(number) + || numberPlus.equals(number)) { + Integer nSC = mHashMapForNetworkEccCategory.get(emergencyNum); + if (nSC != null) { + Rlog.d(LOG_TAG, "[getServiceCategoryFromEcc] match network ecc list, " + + "Ecc= " + number + ", Category= " + nSC); + return nSC; + } + } + } + + // 2. Get category from sim + // ToDo: EF_Ecc will convey service category later + + // 3. Get category from user-customized + if (mCustomizedEccList != null) { + for (EccEntry eccEntry : mCustomizedEccList) { + String ecc = eccEntry.getEcc(); + numberPlus = ecc + "+"; + if (ecc.equals(number) + || numberPlus.equals(number)) { + Rlog.d(LOG_TAG, "[getServiceCategoryFromEcc] match customized ecc list, " + + "Ecc= " + ecc + ", Category= " + eccEntry.getCategory()); + return Integer.parseInt(eccEntry.getCategory()); + } + } + } + + Rlog.d(LOG_TAG, "[getServiceCategoryFromEcc] no matched for Ecc =" + number + ", return 0"); + return 0; + } + + public static void updateEmergencyNumbersProperty() { + ArrayList<String> sim1List = new ArrayList<String>(); + ArrayList<String> sim2List = new ArrayList<String>(); + ArrayList<String> fixedList = new ArrayList<String>(); + ArrayList<String> fixedListNoSim = new ArrayList<String>(); + + if (mCustomizedEccList != null) { + for (EccEntry eccEntry : mCustomizedEccList) { + String ecc = eccEntry.getEcc(); + if (!eccEntry.getCondition().equals(EccEntry.ECC_NO_SIM)) { + fixedList.add(ecc); + } else if (!TextUtils.isEmpty(ecc)) { + fixedListNoSim.add(ecc); + } + } + } + + // Read from SIM1 + String numbers = SystemProperties.get("ril.ecclist"); + for (String emergencyNum : numbers.split(",")) { + if (!TextUtils.isEmpty(emergencyNum)) + sim1List.add(emergencyNum); + } + // dedupe + sim1List.removeAll(fixedList); + sim1List.addAll(fixedList); + if (TextUtils.isEmpty(numbers)) { + sim1List.removeAll(fixedListNoSim); + sim1List.addAll(fixedListNoSim); + } + SystemProperties.set("ril.ecclist",TextUtils.join(",", sim1List)); + + // Read from SIM2 + numbers = SystemProperties.get("ril.ecclist1"); + for (String emergencyNum : numbers.split(",")) { + if (!TextUtils.isEmpty(emergencyNum)) + sim2List.add(emergencyNum); + } + // dedupe + sim2List.removeAll(fixedList); + sim2List.addAll(fixedList); + if (TextUtils.isEmpty(numbers)) { + sim2List.removeAll(fixedListNoSim); + sim2List.addAll(fixedListNoSim); + } + SystemProperties.set("ril.ecclist1",TextUtils.join(",", sim2List)); + + } + +} diff --git a/rootdir/enableswap.sh b/rootdir/enableswap.sh new file mode 100644 index 0000000..186b4b9 --- /dev/null +++ b/rootdir/enableswap.sh @@ -0,0 +1,4 @@ +#!/bin/sh +echo 0 > /sys/block/zram0/disksize +/system/bin/tiny_mkswap /dev/block/zram0 +/system/bin/tiny_swapon /dev/block/zram0 diff --git a/rootdir/factory_init.project.rc b/rootdir/factory_init.project.rc new file mode 100644 index 0000000..c231fcd --- /dev/null +++ b/rootdir/factory_init.project.rc @@ -0,0 +1,80 @@ +mkdir /data/misc/sensors 0664 system system + +service msensord /system/bin/msensord + user system + group system + oneshot + +service akmd8963 /system/bin/akmd8963 + disabled + user system + group system + + +on post-fs +# +# Connectivity related modules and character device nodes (Begin) +# + #for 662x_launcher + chmod 0660 /dev/ttyMT2 + chown system system /dev/ttyMT2 + + # STP, SDIO, WMT, GPS, FM and BT Driver +# insmod /system/lib/modules/mtk_hif_sdio.ko +# insmod /system/lib/modules/mtk_stp_wmt.ko +# insmod /system/lib/modules/mtk_stp_uart.ko +# insmod /system/lib/modules/mtk_stp_gps.ko +# insmod /system/lib/modules/mtk_stp_bt.ko +# insmod /system/lib/modules/mtk_fm_drv.ko +# insmod /system/lib/modules/mtk_fm_priv.ko +# insmod /system/lib/modules/mtk_wmt_wifi.ko + + insmod /system/lib/modules/mtk_wmt_detect.ko + + # Create char device file for WMT, GPS, BT, FM, WIFI + mknod /dev/stpwmt c 190 0; + mknod /dev/stpgps c 191 0; + mknod /dev/stpbt c 192 0; + mknod /dev/fm c 193 0; + chmod 0660 /dev/stpwmt + chown system system /dev/stpwmt + chmod 0660 /dev/wmtdetect + chown system system /dev/wmtdetect + + # FM Radio device, FIXME: this is not a proper way to set permissions + chmod 0666 /dev/fm + + mknod /dev/wmtWifi c 153 0 + chmod 0666 /dev/wmtWifi + chmod 0660 /dev/stpgps + chmod 0660 /dev/stpbt + chown bluetooth radio /dev/stpbt + + # Load WiFi Driver + #insmod /system/lib/modules/wlan.ko + +# +# Connectivity related modules and character device nodes (Ends) +# + +on boot + + +# +# Connectivity related services (Begin) +# + +service wmtLoader /system/bin/wmt_loader + user root + group root + oneshot + +service conn_launcher /system/bin/6620_launcher -p /system/etc/firmware/ + user system + group system + + +# +# Connectivity related services (End) +# + diff --git a/rootdir/factory_init.rc b/rootdir/factory_init.rc new file mode 100644 index 0000000..898f043 --- /dev/null +++ b/rootdir/factory_init.rc @@ -0,0 +1,604 @@ +import /init.environ.rc +import init.ssd.rc +import init.no_ssd.rc +import init.ssd_nomuser.rc +import init.fon.rc +import init.trustonic.rc + +on early-init + # Set init and its forked children's oom_adj. + write /proc/1/oom_score_adj -1000 + + # Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls. + write /sys/fs/selinux/checkreqprot 0 + + # Set the security context for the init process. + # This should occur before anything else (e.g. ueventd) is started. + setcon u:r:init:s0 + + # Set the security context of /adb_keys if present. + restorecon /adb_keys + + start ueventd + + write /proc/bootprof "INIT: usr/eng build setting" +# create mountpoints + mkdir /mnt 0775 root system + +on init + +sysclktz 0 + +loglevel 5 + +# Backward compatibility + symlink /system/etc /etc + symlink /sys/kernel/debug /d + +# Temp Backward compatibility + symlink /dev/block/platform/mtk-msdc.0/by-name/boot /dev/bootimg + symlink /dev/block/platform/mtk-msdc.0/by-name/recovery /dev/recovery + symlink /dev/block/platform/mtk-msdc.0/by-name/secro /dev/sec_ro + symlink /dev/block/platform/mtk-msdc.0/by-name/kb /dev/kb + symlink /dev/block/platform/mtk-msdc.0/by-name/dkb /dev/dkb + symlink /dev/block/platform/mtk-msdc.0/by-name/seccfg /dev/seccfg + symlink /dev/block/platform/mtk-msdc.0/by-name/proinfo /dev/pro_info + symlink /dev/block/platform/mtk-msdc.0/by-name/nvram /dev/nvram + symlink /dev/block/platform/mtk-msdc.0/by-name/para /dev/misc + symlink /dev/block/platform/mtk-msdc.0/by-name/logo /dev/logo + + +# Link /vendor to /system/vendor for devices without a vendor partition. + symlink /system/vendor /vendor + +# Create cgroup mount point for cpu accounting + mkdir /acct + mount cgroup none /acct cpuacct + mkdir /acct/uid + +# Backwards Compat - XXX: Going away in G* + symlink /mnt/sdcard /sdcard + + mkdir /system + mkdir /data 0771 system system + mkdir /cache 0770 system cache + mkdir /config 0500 root root + mkdir /protect_f 0771 system system + mkdir /protect_s 0771 system system + #create mountpoint for persist partition + mkdir /persist 0771 system system +#Create nvdata mount point + mkdir /nvdata 0771 system system + + # See storage config details at http://source.android.com/tech/storage/ + mkdir /mnt/shell 0700 shell shell + mkdir /mnt/media_rw 0700 media_rw media_rw + mkdir /storage 0751 root sdcard_r + + # Filesystem image public mount points. + mkdir /mnt/obb 0700 root system + mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000 + + write /proc/sys/kernel/panic_on_oops 1 + write /proc/sys/kernel/hung_task_timeout_secs 0 + write /proc/cpu/alignment 4 + write /proc/sys/kernel/sched_latency_ns 10000000 + write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 + write /proc/sys/kernel/sched_compat_yield 1 + write /proc/sys/kernel/sched_child_runs_first 0 + + # Healthd can trigger a full boot from charger mode by signaling this + # property when the power button is held. + on property:sys.boot_from_charger_mode=1 + class_stop charger + trigger late-init + + # Load properties from /system/ + /factory after fs mount. + on load_all_props_action + load_system_props + load_persist_props + + # Mount filesystems and start core system services. + on late-init + trigger early-fs + trigger fs + trigger post-fs + trigger post-fs-data + + # Load properties from /system/ + /factory after fs mount. Place + # this in another action so that the load will be scheduled after the prior + # issued fs triggers have completed. + trigger load_all_props_action + + trigger early-boot + trigger boot + +on fs + write /proc/bootprof "INIT:Mount_START" + mount_all /fstab.mt6735 + + #change partition permissions + exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/boot + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/boot + exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/recovery + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/recovery + exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/secro + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/secro + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/seccfg + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/seccfg + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/proinfo + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/proinfo + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/otp + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/otp + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/nvram + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/nvram + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/para + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/para + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/logo + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/logo + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/para + write /proc/bootprof "INIT:Mount_END" + +on post-fs + # once everything is setup, no need to modify / + mount rootfs rootfs / ro remount + chown system system /system/data + mkdir /system/cache 0770 system cache + # We restorecon /cache in case the cache partition has been reset. + restorecon_recursive /cache + + # We chown/chmod /data again so because mount is run as root + defaults + chown system system /system/data + chmod 0777 /system/data + # We chown/chmod /data again so because mount is run as root + defaults + chown system system /data + chmod 0771 /data + # We restorecon /data in case the userdata partition has been reset. + restorecon /data + + # Same reason as /data above + chown system cache /cache + chmod 0770 /cache + + mkdir /cache/recovery 0770 system system + chown system system /protect_f + chmod 0770 /protect_f + + chown system system /protect_s + chmod 0770 /protect_s + + # This may have been created by the recovery system with odd permissions + chown system cache /cache/recovery + chmod 0770 /cache/recovery + + #change permissions on vmallocinfo so we can grab it from bugreports + chown root log /proc/vmallocinfo + chmod 0440 /proc/vmallocinfo + + #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks + chown root system /proc/kmsg + chmod 0440 /proc/kmsg + + # make the selinux kernel policy world-readable + chmod 0444 /sys/fs/selinux/policy + + # create the lost+found directories, so as to enforce our permissions + mkdir /cache/lost+found 0770 root root + +on post-fs-data + +#SeLinux + mkdir /data/ccci_cfg 0770 system radio + restorecon /data/ccci_cfg + restorecon_recursive /protect_f + restorecon_recursive /protect_s + + # We chown/chmod /data again so because mount is run as root + defaults + + chown root system /proc/sysrq-trigger + chmod 0220 /proc/sysrq-trigger + + chown system system /persist + chmod 0771 /persist +# create basic filesystem structure + #mkdir /data/nvram 2770 root system + # We chown/chmod /nvdata again so because mount is run as root + defaults + chown root system /nvdata + chmod 0771 /nvdata + symlink /nvdata /data/nvram + mkdir /nvdata/media 0771 media audio + + # Set SELinux security contexts on upgrade or policy update. + restorecon_recursive /nvdata + + mkdir /data/misc 01771 system misc + mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth + mkdir /data/misc/bluetooth 0770 system system + mkdir /data/misc/keystore 0700 keystore keystore + mkdir /data/misc/keychain 0771 system system + mkdir /data/misc/vpn 0770 system vpn + mkdir /data/misc/systemkeys 0700 system system + # give system access to wpa_supplicant.conf for backup and restore + mkdir /data/misc/wifi 0770 wifi wifi + mkdir /data/misc/wifi/sockets 0770 wifi wifi + mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi + mkdir /data/misc/ethernet 0770 system system + mkdir /data/misc/dhcp 0770 dhcp dhcp + mkdir /data/misc/user 0771 root root + mkdir /data/misc/perfprofd 0775 root root + # give system access to wpa_supplicant.conf for backup and restore + chmod 0660 /data/misc/wifi/wpa_supplicant.conf + mkdir /data/local 0751 root root + mkdir /data/misc/media 0700 media media + mkdir /data/misc/vold 0700 root root + mkdir /data/local/tmp 0771 shell shell + mkdir /data/data 0771 system system + mkdir /data/app-private 0771 system system + mkdir /data/app 0771 system system + mkdir /data/property 0700 root root + mkdir /data/tombstones 0771 system system + + # create the lost+found directories, so as to enforce our permissions + mkdir /data/lost+found 0770 + mkdir /cache/lost+found 0770 + mkdir /data/adb 0700 root root + + # double check the perms, in case lost+found already exists, and set owner + chown root root /data/lost+found + chmod 0770 /data/lost+found + chown root root /cache/lost+found + chmod 0770 /cache/lost+found + + # VIA flashlessd service + mkdir /data/flashless 0770 radio nvram + mkdir /data/nvram/md_via 0770 root nvram + chmod 0660 /dev/ttyMT4 + chown radio radio /dev/ttyMT4 + chmod 0660 /dev/vmodem + chown radio radio /dev/vmodem + + #VIA pppd service + mkdir /data/pppd_via 0770 radio system + + # md32 boot + chown root system /dev/md32 + chmod 0440 /dev/md32 + chown root system /sys/class/misc/md32/md32_mobile_log + chmod 0660 /sys/class/misc/md32/md32_mobile_log + write /sys/class/misc/md32/md32_boot 1 + + # dhcp server + mkdir /data/misc/dhcp 0770 dhcp dhcp + chown dhcp dhcp /data/misc/dhcp + + # device info interface + chmod 0440 /dev/devmap + chown root system /dev/devmap + + + + #change partition permission + exec /system/etc/partition_permission.sh + +## Custom pos-fs area (START) +# Please add custom fs operation below + + # Touch Panel + chown root diag /sys/module/tpd_setting/parameters/tpd_calmat + chown root diag /sys/module/tpd_setting/parameters/tpd_em_debounce_time + chown root diag /sys/module/tpd_debug/parameters/tpd_em_log + chown root diag /sys/module/tpd_debug/parameters/tpd_em_log_to_fs + + chmod 0777 /dev/pmem_multimedia + chmod 0777 /dev/mt6516-isp + chmod 0777 /dev/mt6516-IDP + chmod 0777 /dev/mt9p012 + chmod 0777 /dev/mt6516_jpeg + chmod 0777 /dev/FM50AF + + # RTC + mkdir /data/misc/rtc 0770 system system + + # Modem related device nodes + mkdir /data/nvram/md 0770 root system + mkdir /data/nvram/md2 0770 root system + +# Build-in Modified - S +# insmod /system/lib/modules/ccci_plat.ko +# insmod /system/lib/modules/ccci.ko +# Build-in Modified - E +# chown ccci ccci /sys/class/BOOT/BOOT/boot/md + chown radio radio /sys/kernel/ccci/boot + + # M4U + #insmod /system/lib/modules/m4u.ko + #mknod /dev/M4U_device c 188 0 + chmod 0444 /dev/M4U_device + + #set mlock limit to infinate (for m4u operation) + setrlimit 8 -1 -1 + + # Sensor + chmod 0666 /dev/hwmsensor + chmod 0666 /dev/gyroscope + chmod 0666 /dev/msensor + chmod 0666 /dev/gsensor + chmod 0666 /dev/alsps + + #VideoCodec + chmod 0666 /dev/Vcodec + + + mkdir /data/amit/ + + # GPIO + chmod 0666 /dev/mtgpio + + chmod 0666 /dev/exm0 + + # TTY + # For ATCID + chmod 0660 /dev/ttyGS0 + chown system radio /dev/ttyGS0 + chmod 0660 /dev/ttyGS1 + chown system /dev/ttyGS1 + # For BT relayer + chown bluetooth radio /dev/ttyGS2 + chmod 0660 /dev/ttyGS2 + # For MD Logger + chown system radio /dev/ttyGS3 + chmod 0660 /dev/ttyGS3 + + #NFC + rm /data/mtknfc_server + +## Custom pos_fs area (END) + + # Separate location for storing security policy files on data + mkdir /data/security 0711 system system + + # Reload policy from /data/security if present. + setprop selinux.reload_policy 1 + + # Set SELinux security contexts on upgrade or policy update. + restorecon_recursive /data + + # If there is no fs-post-data action in the init.<device>.rc file, you + # must uncomment this line, otherwise encrypted filesystems + # won't work. + # Set indication (checked by vold) that we have finished this action + setprop vold.post_fs_data_done 1 + +on boot + + #VIA device property + setprop viatel.device.asci uart.4.ttyMT + setprop viatel.device.fls sdio.3.ttySDIO + setprop viatel.device.at sdio.4.ttySDIO + setprop viatel.device.data sdio.1.ttySDIO + +# basic network init + ifup lo + hostname localhost + domainname localdomain + + +# Start default class, this line is very important!! + class_start default + class_start core + +on nonencrypted + class_start main + class_start late_start + +on property:vold.decrypt=trigger_default_encryption + start defaultcrypto + +on property:vold.decrypt=trigger_encryption + start surfaceflinger + start encrypt + +on property:vold.decrypt=trigger_reset_main + class_reset main + +on property:vold.decrypt=trigger_load_persist_props + load_persist_props + +on property:vold.decrypt=trigger_post_fs_data + trigger post-fs-data + +on property:vold.decrypt=trigger_restart_min_framework + class_start main + +on property:vold.decrypt=trigger_restart_framework + start nvram_daemon + class_start main + class_start late_start + start permission_check + +on property:vold.decrypt=trigger_shutdown_framework + class_reset late_start + class_reset main + +## Daemon processes to be run by init. +## + +# Update the second boot logo +# service bootlogoupdater /system/bin/boot_logo_updater +# oneshot + +service ueventd /sbin/ueventd + class core + critical + seclabel u:r:ueventd:s0 + +service logd /system/bin/logd + class core + socket logd stream 0666 logd logd + socket logdr seqpacket 0666 logd logd + socket logdw dgram 0222 logd logd + seclabel u:r:logd:s0 + +service console /system/bin/sh + class core + console + disabled + user shell + group shell log + seclabel u:r:shell:s0 + +on property:sys.powerctl=* + powerctl ${sys.powerctl} + +on property:ro.debuggable=1 + start console + +# adbd is controlled via property triggers in init.<platform>.usb.rc +service adbd /sbin/adbd --root_seclabel=u:r:su:s0 + class core + socket adbd stream 660 system system + disabled + seclabel u:r:adbd:s0 + +service vold /system/bin/vold + class core + socket vold stream 0660 root mount + socket cryptd stream 0660 root mount + ioprio be 2 + +# One shot invocation to deal with encrypted volume. +service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted + disabled + oneshot + # vold will set vold.decrypt to trigger_restart_framework (default + # encryption) or trigger_restart_min_framework (other encryption) + +# One shot invocation to encrypt unencrypted volumes +service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default + disabled + oneshot + # vold will set vold.decrypt to trigger_restart_framework (default + # encryption) + +## Custom service area (START) +# Please add custom service below + +service thermal_manager /system/bin/thermal_manager + user root + oneshot + +service permission_check /system/bin/permission_check + user root + group system radio + oneshot + +service ccci_fsd /system/bin/ccci_fsd 0 + user radio + group radio system + oneshot + +service ccci_mdinit /system/bin/ccci_mdinit 0 + user system + group radio system + oneshot + +service ccci_rpcd /system/bin/ccci_rpcd 0 + user radio + group radio system + oneshot + +service nvram_daemon /system/bin/nvram_daemon + class main + user root + group system + oneshot + +service installd /system/bin/installd + class main + socket installd stream 600 system system + +service factory_no_image /system/bin/factory + disabled + oneshot + +service factory_with_image /sbin/factory + disabled + oneshot + +service mobile_log_d /system/bin/mobile_log_d + class main + +# +# Connectivity related services (End) +# +# +## Custom service area (END) + + +#statusd service +service statusd /system/bin/statusd -f [/system/bin/flashlessd -l -m 0] + socket statusd stream 660 radio radio + user radio + group radio cache inet misc system + +on property:sys.mtk.no.factoryimage=1 + start factory_no_image + +on property:sys.mtk.no.factoryimage=0 + start factory_with_image + +#mass_storage,adb,acm +on property:ro.boot.usbconfig=0 + write /sys/class/android_usb/android0/iSerial $ro.serialno + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor 0e8d + write /sys/class/android_usb/android0/idProduct 2006 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.acm_idx 1 + +#acm +on property:ro.boot.usbconfig=1 + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/iSerial " " + write /sys/class/android_usb/android0/idVendor 0e8d + write /sys/class/android_usb/android0/idProduct 2007 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions acm + write /sys/class/android_usb/android0/bDeviceClass 02 + write /sys/class/android_usb/android0/enable 1 + +#single modem comport for factory mode +on property:sys.usb.config=gs3,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor $sys.usb.vid + write /sys/class/android_usb/android0/idProduct 202E + write /sys/class/android_usb/android0/f_acm/port_index 1,4 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + chown system radio /dev/ttyGS3 + chmod 0660 /dev/ttyGS3 + start adbd + setprop sys.usb.state $sys.usb.config + setprop sys.usb.acm_idx 1,4 + +#dual modem comport for factory mode +on property:sys.usb.config=gs1gs3,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor $sys.usb.vid + write /sys/class/android_usb/android0/idProduct 202F + write /sys/class/android_usb/android0/f_acm/port_index 1,2,4 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions adb,acm + write /sys/class/android_usb/android0/enable 1 + chown system radio /dev/ttyGS3 + chmod 0660 /dev/ttyGS3 + chown system radio /dev/ttyGS1 + chmod 0660 /dev/ttyGS1 + start adbd + setprop sys.usb.state $sys.usb.config + setprop sys.usb.acm_idx 1,2,4 + diff --git a/rootdir/fstab.charger b/rootdir/fstab.charger new file mode 100644 index 0000000..c73e389 --- /dev/null +++ b/rootdir/fstab.charger @@ -0,0 +1,10 @@ +# Android fstab file. +#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags> +# The filesystem that contains the filesystem checker binary (typically /system) cannot +# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK + +/dev/block/platform/mtk-msdc.0/by-name/userdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,discard wait,check,resize,encryptable=footer + +#please add cip or persist on project fstab +#/dev/block/platform/mtk-msdc.0/by-name/persist /persist ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,autoformat +#/dev/block/platform/mtk-msdc.0/by-name/custom /custom ext4 ro wait diff --git a/rootdir/fstab.mt6735 b/rootdir/fstab.mt6735 new file mode 100644 index 0000000..0ac1712 --- /dev/null +++ b/rootdir/fstab.mt6735 @@ -0,0 +1,30 @@ +# Android fstab file. +#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags> +# The filesystem that contains the filesystem checker binary (typically /system) cannot +# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK + +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/recovery /recovery emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/boot /boot emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/system /system ext4 ro,barrier=1 wait +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/userdata /data ext4 rw,nosuid,nodev,noatime,noauto_da_alloc,discard,barrier=1 wait,check,formattable,encryptable=/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/metadata +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/cache /cache ext4 rw,nosuid,nodev,noatime,noauto_da_alloc,discard,barrier=1 wait,check,formattable +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/protect1 /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/protect2 /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/nvdata /nvdata ext4 noatime,nosuid,nodev,noauto_da_alloc,discard wait,check,formattable +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/frp /persistent emmc defaults defaults + +#/devices/mtk-msdc.0/11230000.MSDC0* auto vfat defaults voldmanaged=sdcard0:auto +/devices/mtk-msdc.0/11240000.MSDC1* auto vfat defaults voldmanaged=sdcard1:auto,encryptable=userdata +/devices/platform/mt_usb* auto vfat defaults voldmanaged=usbotg:auto +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/nvram /nvram emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/proinfo /proinfo emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/lk /bootloader emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/lk2 /bootloader2 emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/para /misc emmc defaults defaults + +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/logo /logo emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/expdb /expdb emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/secro /secro emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/seccfg /seccfg emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/tee1 /tee1 emmc defaults defaults +/dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/tee2 /tee2 emmc defaults defaults diff --git a/rootdir/init.modem.rc b/rootdir/init.modem.rc new file mode 100755 index 0000000..1ccbabe --- /dev/null +++ b/rootdir/init.modem.rc @@ -0,0 +1,170 @@ +# Copyright (C) 2012 The Android Open Source Project +# +# IMPORTANT: Do not create world writable files or directories. +# This is a common source of Android security bugs. +# + +on early-init + write /sys/class/net/ccmni0/queues/rx-0/rps_cpus "ff" + write /sys/class/net/ccmni1/queues/rx-0/rps_cpus "ff" + write /sys/class/net/ccmni2/queues/rx-0/rps_cpus "ff" + write /sys/class/net/ccmni0/queues/rx-0/rps_flow_cnt "1000" + write /sys/class/net/ccmni1/queues/rx-0/rps_flow_cnt "1000" + write /sys/class/net/ccmni2/queues/rx-0/rps_flow_cnt "1000" + setprop net.perf.rps ff + setprop net.perf.cpu.core 4,4,0,0 + setprop net.perf.cpu.freq 1144000,1144000,0,0 + +on post-fs-data + + write /proc/bootprof "post-fs-data: on modem start" + + # Modem related device nodes + mkdir /data/nvram/md 0770 root system + mkdir /data/nvram/md3 0770 root system + mkdir /data/md3 0770 root system + chown radio radio /sys/kernel/ccci/boot + chown radio radio /dev/ccci_fs + chown radio radio /dev/ccci_ioctl0 + chown radio radio /dev/ccci_ioctl1 + chown radio radio /dev/ccci_ipc_1220_0 + chown radio radio /dev/ccci_md_log_rx + chown radio radio /dev/ccci_md_log_tx + chown radio radio /dev/ccci_monitor + chown radio radio /dev/ccci_aud + chown radio radio /dev/ccci_pcm_rx + chown radio radio /dev/ccci_pcm_tx + chown radio radio /dev/ccci_uem_rx + chown radio radio /dev/ccci_uem_tx + + # Selinux + mkdir /data/ccci_cfg 0770 system radio + restorecon /data/ccci_cfg + restorecon_recursive /protect_f + restorecon_recursive /protect_s + + # clear the sim switch flag + setprop persist.radio.simswitch "" + +service gsm0710muxd /system/bin/gsm0710muxd -s /dev/ttyC0 -f 512 -n 8 -m basic + class core + user root + group radio cache inet misc + disabled + oneshot + +service gsm0710muxdmd2 /system/bin/gsm0710muxdmd2 -s /dev/ccci2_tty0 -f 512 -n 8 -m basic + class core + user root + group radio cache inet misc + disabled + oneshot + +service muxreport-daemon /system/bin/muxreport + class core + user radio + group radio cache inet misc + disabled + oneshot + +service ril-daemon-mtk /system/bin/mtkrild + class core + socket rild stream 660 root radio + socket rild2 stream 660 root radio + socket rild3 stream 660 root radio + socket rild4 stream 660 root radio + socket rild-ims stream 660 root radio + socket rild-debug stream 660 radio system + socket rild-oem stream 660 radio system + socket rild-mtk-ut stream 660 radio net_bt + socket rild-mtk-ut-2 stream 660 radio net_bt + socket rild-mtk-modem stream 660 radio system + socket rild-atci stream 660 root radio + socket rild-mal stream 660 radio system + socket rild-mal-at stream 660 radio system + socket rild-vsim stream 660 root radio + socket rild-mbim stream 660 root radio + socket sap_uim_socket1 stream 660 bluetooth bluetooth + socket sap_uim_socket2 stream 660 bluetooth bluetooth + user root + group radio cache inet misc audio sdcard_r sdcard_rw log system + disabled + oneshot + +service ril-daemon-mtkmd2 /system/bin/mtkrildmd2 + class core + socket rild-md2 stream 660 root radio + socket rild2-md2 stream 660 root radio + socket rild-debug-md2 stream 660 radio system + socket rild-oem-md2 stream 660 radio system + socket rild-mtk-ut-md2 stream 660 radio net_bt + socket rild-mtk-ut-2-md2 stream 660 radio net_bt + socket rild-mtk-modem-md2 stream 660 radio system + socket rild-atci-md2 stream 660 root radio + socket rild-mal-md2 stream 660 radio system + socket rild-mal-at-md2 stream 660 radio system + socket rild-vsim-md2 stream 660 root radio + socket rild-mbim-md2 stream 660 root radio + user root + group radio cache inet misc audio sdcard_r sdcard_rw log system + disabled + oneshot + +# +# Modem related services (Begin) +# + +service permission_check /system/bin/permission_check + class main + user root + group system radio + oneshot + +service ccci_fsd /system/bin/ccci_fsd 0 + user radio + group radio system + class core + oneshot + +service ccci_mdinit /system/bin/ccci_mdinit 0 + user system + group radio system + class core + oneshot + +service ccci_rpcd /system/bin/ccci_rpcd 0 + user radio + group radio system + class core + oneshot + +service pppd_gprs /system/bin/pppd_dt /dev/ttyACM0 debug noauth refuse-eap usepeerdns nodetach + user root + group radio cache inet misc + disabled + oneshot + +#Add by T.Zh for ppp daemon +service pppd /system/bin/pppd file /data/misc/ppp/ppp_options + user root + disabled + oneshot + +# +# +# Modem related services (End) +# + +#Add by hp.chen for +# +# Telephony Early Read service +# +service terservice /system/bin/terservice + class core + user radio + group radio cache inet misc + oneshot + +on property:ril.muxreport=1 + start muxreport-daemon + diff --git a/rootdir/init.mt6735.rc b/rootdir/init.mt6735.rc new file mode 100755 index 0000000..bcfbb81 --- /dev/null +++ b/rootdir/init.mt6735.rc @@ -0,0 +1,1215 @@ +import init.project.rc +import init.ssd.rc +import init.modem.rc + +on early-boot + # NOTE: early-boot is AFTER even post-fs-data! + # damn this is so easily overlooked + mount debugfs debugfs /sys/kernel/debug + chmod 0755 /sys/kernel/debug + +on early-init + restorecon /sys/class/meizu/ps/ps_calibration + +on init +# Setup zram options + write /sys/block/zram0/comp_algorithm lz4 + + # Platform-specific mount points + mkdir /protect_f 0771 system system + mkdir /protect_s 0771 system system + mkdir /persist 0771 system system + mkdir /nvdata 0771 system system +# Create CIP mount point + mkdir /custom + + #mkdir /nvram 0771 system system + #mkdir /proinfo 0771 system system + #mkdir /misc 0771 system system + + mkdir /mnt/cd-rom 0000 system system + +# Change ION driver permission + chmod 0644 /dev/ion + +# change lk_env permission + chown root system /proc/lk_env + chmod 0660 /proc/lk_env + chmod 0666 /dev/kmsg + +on charger + mkdir /dev/block/platform/mtk-msdc.0/by-name 0777 system system + symlink /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/logo /dev/block/platform/mtk-msdc.0/by-name/logo + exec /system/bin/chown -R system:system /dev/block/platform/mtk-msdc.0/by-name/logo + exec /system/bin/chmod 0777 /dev/block/platform/mtk-msdc.0/by-name/logo + + mount ext4 /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/system /system ro wait + start fuelgauged + start kpoc_charger + start servicemanager + +on fs + write /proc/bootprof "INIT:Mount_START" + mount_all /fstab.mt6735 + + # Workaround for old nvram blobs + mkdir /dev/block/platform/mtk-msdc.0/by-name 0777 system system + symlink /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/nvram /dev/block/platform/mtk-msdc.0/by-name/nvram + symlink /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/proinfo /dev/block/platform/mtk-msdc.0/by-name/proinfo + exec /system/bin/chown -R system:system /dev/block/platform/mtk-msdc.0/by-name/nvram + exec /system/bin/chmod 0777 /dev/block/platform/mtk-msdc.0/by-name/nvram + exec /system/bin/chown -R system:system /dev/block/platform/mtk-msdc.0/by-name/proinfo + exec /system/bin/chmod 0777 /dev/block/platform/mtk-msdc.0/by-name/proinfo + + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/secro + exec /system/bin/chmod 0770 /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/secro + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/seccfg + exec /system/bin/chmod 0770 /dev/block/platform/mtk-msdc.0/11230000.MSDC0/by-name/seccfg + write /proc/bootprof "INIT:Mount_END" + +on post-fs + # Support legacy paths + symlink /sdcard /storage/sdcard0 + + #change permissions for mediaserver + chown root media /proc/clkmgr/mipi_test + + #change permission for engineer mode + chown radio system /proc/clkmgr/pll_test + chown radio system /proc/clkmgr/pll_fsel + chmod 0664 /proc/clkmgr/pll_test + chmod 0664 /proc/clkmgr/pll_fsel + #change permission for engineer mode + chown radio system /proc/freqhopping/dramc + chown radio system /proc/freqhopping/dumpregs + chown radio system /proc/freqhopping/freqhopping_debug + chown radio system /proc/freqhopping/status + chown radio system /proc/freqhopping/userdef + +# change owner + chown system system /proc/bootprof + chown root system /proc/mtprof/cputime + chown root system /proc/mtprof/reboot_pid + + chown system system /protect_f + chmod 0770 /protect_f + + chown system system /protect_s + chmod 0770 /protect_s + + chown system system /system/bin/sbchk + chmod 0771 /system/bin/sbchk + + # Wifi + exec /system/xbin/mknod /dev/wmtWifi c 153 0 + chmod 0660 /dev/wmtWifi + chown system system /dev/wmtWifi + + exec /system/xbin/mknod /dev/stpwmt c 190 0 + exec /system/xbin/mknod /dev/stpgps c 191 0 + exec /system/xbin/mknod /dev/stpbt c 192 0 + + # BT + chmod 0660 /dev/stpbt + chown radio bluetooth /dev/stpbt + + chmod 0660 /dev/stpwmt + chown system system /dev/stpwmt + + chmod 0660 /dev/wmtdetect + chown system system /dev/wmtdetect + + # GPS + chmod 0660 /dev/gps + chown system gps /dev/gps + chmod 0660 /dev/stpgps + chown gps gps /dev/stpgps + + chmod 0660 /dev/ttyC2 + chown system gps /dev/ttyC2 + + chown system system /sys/block/mmcblk0/queue/scheduler + +on post-fs-data + chown system system /persist + chmod 0771 /persist + + # create basic filesystem structure + # mkdir /data/nvram 2770 root system + mkdir /data/nvram/APCFG 2770 media system + mkdir /data/nvram/APCFG/APRDCL 2770 media system + mkdir /data/nvram/APCFG/APRDEB 2770 media system + + # We chown/chmod /nvdata again so because mount is run as root + defaults + chown media system /nvdata + chmod 0771 /nvdata + symlink /nvdata /data/nvram + mkdir /nvdata/media 0771 media audio + + # Set SELinux security contexts on upgrade or policy update. + restorecon_recursive /nvdata + + chmod 0660 /data/misc/wifi/p2p_supplicant.conf + + #give system access to rfkill device node + chmod 0660 /dev/rfkill + + # Radio + mkdir /dev/radio 0770 radio radio + mkdir /data/drm/wv 0770 drm system + + # GPS + mkdir /data/gps_mnl 0771 gps system + mkdir /data/misc/gps 0770 gps system + mkdir /data/mpe_mnl 0771 gps system + chown gps system /data/mpe_mnl + mkdir /data/agps_supl 0771 gps system + restorecon_recursive /data/misc/gps + + + # Hostapd + mkdir /data/misc/wifi/hostapd 0771 system wifi + restorecon /data/misc/wifi/hostapd + + # Add by MTK + # md32 boot + chown root system /dev/md32 + chmod 0440 /dev/md32 + chown root system /sys/class/misc/md32/md32_mobile_log + chmod 0660 /sys/class/misc/md32/md32_mobile_log + write /sys/class/misc/md32/md32_boot 1 + + # dhcp server + mkdir /data/misc/dhcp 0770 dhcp wifi + chown dhcp wifi /data/misc/dhcp + + # dhcpv6 server + mkdir /data/misc/wide-dhcpv6 0770 dhcp wifi + chown dhcp wifi /data/misc/wide-dhcpv6 + + # radvd + mkdir /data/misc/radvd 0770 system system + chmod 444 /etc/radvd/radvd.conf + + # Mali Graphics + chmod 666 /dev/mali0 + + # Touch Panel + chown root diag /sys/module/tpd_setting/parameters/tpd_calmat + chown root diag /sys/module/tpd_setting/parameters/tpd_em_debounce_time + chown root diag /sys/module/tpd_setting/parameters/tpd_mode + chown root diag /sys/module/tpd_setting/parameters/tpd_em_debounce_time0 + chown root diag /sys/module/tpd_setting/parameters/tpd_em_debounce_time1 + chown root diag /sys/module/tpd_setting/parameters/tpd_em_spl_num + chown root diag /sys/module/tpd_setting/parameters/tpd_em_pressure_threshold + chown root diag /sys/module/tpd_setting/parameters/tpd_em_auto_time_interval + chown root diag /sys/module/tpd_setting/parameters/tpd_em_sample_cnt + chown root diag /sys/module/tpd_setting/parameters/tpd_em_asamp + chown root diag /sys/module/tpd_debug/parameters/tpd_em_log + chown root diag /sys/module/tpd_debug/parameters/tpd_em_log_to_fs + + chmod 0666 /dev/pmem_multimedia + + # watch dog kicker + write /proc/wdk "0 20 30" + + # set ptmx group to non-root + chown root radio /dev/ptmx + + # RTC + mkdir /data/misc/rtc 0770 system system + + # M4U + chmod 0444 /dev/m4u + #set mlock limit to infinate (for m4u operation) + setrlimit 8 -1 -1 + + # CMDQ + chmod 0640 /dev/mtk_cmdq + chown system system /dev/mtk_cmdq + + #OFFLOAD SERVICE + chmod 0640 /dev/offloadservice + chown media media /dev/offloadservice + + # media - memory bandwidth + chmod 0664 /sys/bus/platform/drivers/mem_bw_ctrl/concurrency_scenario + chown system media /sys/bus/platform/drivers/mem_bw_ctrl/concurrency_scenario + + # Sensor + chmod 0660 /dev/hwmsensor + chmod 0660 /dev/msensor + chmod 0660 /dev/gsensor + chmod 0660 /dev/als_ps + chmod 0660 /dev/gyroscope + chmod 0660 /dev/aal_als + + chmod 0660 /sys/devices/platform/msensor/driver/cpsopmode + chmod 0660 /sys/devices/platform/msensor/driver/cpsreptxy + chmod 0660 /sys/devices/platform/msensor/driver/cpsreptz + chmod 0660 /sys/devices/platform/gsensor/driver/cpsopmode + chmod 0660 /sys/devices/platform/gsensor/driver/cpsrange + chmod 0660 /sys/devices/platform/gsensor/driver/cpsbandwidth + + chown system system /dev/hwmsensor + chown system system /dev/msensor + chown system system /dev/gsensor + chown radio system /dev/als_ps + chown system system /dev/gyroscope + chown system system /dev/aal_als + + chmod 0660 /sys/class/misc/m_acc_misc/accenablenodata + chmod 0660 /sys/class/misc/m_acc_misc/accactive + chmod 0660 /sys/class/misc/m_acc_misc/accdelay + chmod 0660 /sys/class/misc/m_acc_misc/accbatch + chmod 0660 /sys/class/misc/m_acc_misc/accflush + chown system system /sys/class/misc/m_acc_misc/accenablenodata + chown system system /sys/class/misc/m_acc_misc/accactive + chown system system /sys/class/misc/m_acc_misc/accdelay + chown system system /sys/class/misc/m_acc_misc/accbatch + chown system system /sys/class/misc/m_acc_misc/accflush + + #camera flashlight sysfs + chmod 0644 /sys/class/flashlightdrv/kd_camera_flashlight/flash1 + chmod 0644 /sys/class/flashlightdrv/kd_camera_flashlight/flash2 + chown media system /sys/class/flashlightdrv/kd_camera_flashlight/flash1 + chown media system /sys/class/flashlightdrv/kd_camera_flashlight/flash2 + + chmod 0660 /sys/class/misc/m_mag_misc/magactive + chmod 0660 /sys/class/misc/m_mag_misc/magdelay + chmod 0660 /sys/class/misc/m_mag_misc/magbatch + chmod 0660 /sys/class/misc/m_mag_misc/magflush + chmod 0660 /sys/class/misc/m_mag_misc/magoactive + chmod 0660 /sys/class/misc/m_mag_misc/magodelay + chmod 0660 /sys/class/misc/m_mag_misc/magobatch + chmod 0660 /sys/class/misc/m_mag_misc/magoflush + chown system system /sys/class/misc/m_mag_misc/magactive + chown system system /sys/class/misc/m_mag_misc/magdelay + chown system system /sys/class/misc/m_mag_misc/magbatch + chown system system /sys/class/misc/m_mag_misc/magflush + chown system system /sys/class/misc/m_mag_misc/magoactive + chown system system /sys/class/misc/m_mag_misc/magodelay + chown system system /sys/class/misc/m_mag_misc/magobatch + chown system system /sys/class/misc/m_mag_misc/magoflush + chmod 0660 /sys/class/misc/m_batch_misc/batchactive + chmod 0660 /sys/class/misc/m_batch_misc/batchdelay + chmod 0660 /sys/class/misc/m_batch_misc/batchbatch + chmod 0660 /sys/class/misc/m_batch_misc/batchflush + chown system system /sys/class/misc/m_batch_misc/batchactive + chown system system /sys/class/misc/m_batch_misc/batchdelay + chown system system /sys/class/misc/m_batch_misc/batchbatch + chown system system /sys/class/misc/m_batch_misc/batchflush + + chmod 0660 /sys/class/misc/m_gyro_misc/gyroenablenodata + chmod 0660 /sys/class/misc/m_gyro_misc/gyroactive + chmod 0660 /sys/class/misc/m_gyro_misc/gyrodelay + chmod 0660 /sys/class/misc/m_gyro_misc/gyrobatch + chmod 0660 /sys/class/misc/m_gyro_misc/gyroflush + chown system system /sys/class/misc/m_gyro_misc/gyroenablenodata + chown system system /sys/class/misc/m_gyro_misc/gyroactive + chown system system /sys/class/misc/m_gyro_misc/gyrodelay + chown system system /sys/class/misc/m_gyro_misc/gyrobatch + chown system system /sys/class/misc/m_gyro_misc/gyroflush + + chmod 0660 /sys/class/misc/m_alsps_misc/alsactive + chmod 0660 /sys/class/misc/m_alsps_misc/alsdelay + chmod 0660 /sys/class/misc/m_alsps_misc/alsbatch + chmod 0660 /sys/class/misc/m_alsps_misc/alsflush + chmod 0660 /sys/class/misc/m_alsps_misc/psactive + chmod 0660 /sys/class/misc/m_alsps_misc/psdelay + chmod 0660 /sys/class/misc/m_alsps_misc/psbatch + chmod 0660 /sys/class/misc/m_alsps_misc/psflush + chown system system /sys/class/misc/m_alsps_misc/alsactive + chown system system /sys/class/misc/m_alsps_misc/alsdelay + chown system system /sys/class/misc/m_alsps_misc/alsbatch + chown system system /sys/class/misc/m_alsps_misc/alsflush + chown system system /sys/class/misc/m_alsps_misc/psactive + chown system system /sys/class/misc/m_alsps_misc/psdelay + chown system system /sys/class/misc/m_alsps_misc/psbatch + chown system system /sys/class/misc/m_alsps_misc/psflush + + chmod 0660 /sys/class/misc/m_baro_misc/baroenablenodata + chmod 0660 /sys/class/misc/m_baro_misc/baroactive + chmod 0660 /sys/class/misc/m_baro_misc/barodelay + chmod 0660 /sys/class/misc/m_baro_misc/barobatch + chmod 0660 /sys/class/misc/m_baro_misc/baroflush + chown system system /sys/class/misc/m_baro_misc/baroenablenodata + chown system system /sys/class/misc/m_baro_misc/baroactive + chown system system /sys/class/misc/m_baro_misc/barodelay + chown system system /sys/class/misc/m_baro_misc/barobatch + chown system system /sys/class/misc/m_baro_misc/baroflush + + #dixiaobing@wind-mobi.com 20150525 + # ps cali + chown system system /sys/class/meizu/ps/ps_calibration + chown system system /sys/class/meizu/ps/ps_offset + + # acc cali + chown system system /sys/class/meizu/acc/acc_calibration + chown system system /sys/class/meizu/acc/acc_x_offset + chown system system /sys/class/meizu/acc/acc_y_offset + chown system system /sys/class/meizu/acc/acc_z_offset + + #duanzhanyang@wind-mobi.com 20150620 + chown system system /sys/devices/mx_leds/leds_mode + + #Accdet + chown root radio /sys/devices/platform/Accdet_Driver/driver/accdet_call_state + + #VideoCodec + mknod /dev/Vcodec c 160 0 + chmod 0660 /dev/Vcodec + chown system media /dev/Vcodec + + #MJC + chmod 0660 /dev/MJC + chown system media /dev/MJC + + #kpd + chown radio radio /sys/devices/platform/mtk-kpd/driver/kpd_call_state + + #Charging Battery + chown radio radio /sys/devices/platform/battery/Charging_CallState + + # PMIC property + chown radio system /sys/devices/platform/mt-pmic/low_battery_protect_stop + chown radio system /sys/devices/platform/mt-pmic/low_battery_protect_ut + + mkdir /data/amit/ 0770 system system + mkdir /data/misc/sensor 0774 system system + mkdir /data/misc/akmd 0770 system system + mkdir /data/misc/s62x 0771 compass compass + mkdir /data/acdapi/ 0770 system system + chmod 0666 /data/misc/acdapi/calib.dat + chmod 0666 /data/misc/acdapi/param.dat + chmod 0666 /data/misc/acdapi/sensors.dat + chown system /sys/devices/platform/msensor/driver/cpsopmode + chown system /sys/devices/platform/msensor/driver/cpsreptxy + chown system /sys/devices/platform/msensor/driver/cpsreptz + chown system /sys/devices/platform/gsensor/driver/cpsopmode + chown system /sys/devices/platform/gsensor/driver/cpsrange + mkdir /data/data/mcube 0664 system system + + chown system /sys/class/input/input1/enable + chown system /sys/class/input/input1/delay + chown system /sys/class/input/input1/wake + chown system /sys/class/input/input1/offsets + chown system /sys/class/input/input2/enable + chown system /sys/class/input/input2/delay + chown system /sys/class/input/input2/wake + chown system /sys/class/input/input2/offsets + chown system /sys/class/input/input3/enable + chown system /sys/class/input/input3/delay + chown system /sys/class/input/input3/wake + chown system /sys/class/input/input3/offsets + chown system /sys/class/input/input4/enable + chown system /sys/class/input/input4/delay + chown system /sys/class/input/input4/wake + chown system /sys/class/input/input4/offsets + chown system /sys/class/input/input5/enable + chown system /sys/class/input/input5/delay + chown system /sys/class/input/input5/wake + chown system /sys/class/input/input5/offsets + chown system /sys/class/input/input6/enable + chown system /sys/class/input/input6/delay + chown system /sys/class/input/input6/wake + chown system /sys/class/input/input6/offsets + chown system /sys/class/input/input7/enable + chown system /sys/class/input/input7/delay + chown system /sys/class/input/input7/wake + chown system /sys/class/input/input7/offsets + chown system /sys/class/input/input8/enable + chown system /sys/class/input/input8/delay + chown system /sys/class/input/input8/wake + chown system /sys/class/input/input8/offsets + chown system /sys/class/input/input9/enable + chown system /sys/class/input/input9/delay + chown system /sys/class/input/input9/wake + chown system /sys/class/input/input9/offsets + chown system /sys/class/input/input10/enable + chown system /sys/class/input/input10/delay + chown system /sys/class/input/input10/wake + chown system /sys/class/input/input10/offsets + + #EM eint + chown root diag /sys/bus/platform/drivers/eint/current_eint + + # Display + chmod 0660 /dev/graphics/fb0 + chown system graphics /dev/graphics/fb0 + + chmod 0660 /dev/mtk_disp_mgr + chown system graphics /dev/mtk_disp_mgr + + chmod 0660 /sys/devices/platform/mtk_disp_mgr.0/rgb + chown system system /sys/devices/platform/mtk_disp_mgr.0/rgb + + chmod 0660 /dev/mtkfb_vsync + chown system graphics /dev/mtkfb_vsync + + chmod 0660 /dev/sw_sync + chown system graphics /dev/sw_sync + + # EM baseband file + chown root diag /system/bin/baseband_regdump + chmod 4750 /system/bin/baseband_regdump + + #pmu + chown root radio /sys/devices/platform/mt-pmic/pmic_access_bank0 + chown root radio /sys/devices/platform/mt-pmic/pmic_access_bank1 + chown root radio /sys/devices/platform/mt6311-user/mt6311_access + chown root radio /sys/devices/platform/mt-pmic/pmic_access + chmod 0664 /sys/devices/platform/mt-pmic/pmic_access_bank0 + chmod 0664 /sys/devices/platform/mt-pmic/pmic_access_bank1 + chmod 0664 /sys/devices/platform/mt6311-user/mt6311_access + chmod 0664 /sys/devices/platform/mt-pmic/pmic_access + + # EM CPU Speed Stress + chown root radio /proc/cpu_ss/cpu_ss_debug_mode + chown root radio /proc/cpu_ss/cpu_ss_mode + chown root radio /proc/cpu_ss/cpu_ss_period + chown root radio /proc/cpu_ss/cpu_ss_period_mode + chmod 0664 /proc/cpu_ss/cpu_ss_debug_mode + chmod 0664 /proc/cpu_ss/cpu_ss_mode + chmod 0664 /proc/cpu_ss/cpu_ss_period + chmod 0664 /proc/cpu_ss/cpu_ss_period_mode + + #EM eint + chown root diag /sys/bus/platform/drivers/eint/current_eint + + # for ppp options file + mkdir /data/misc/ppp 0770 bluetooth net_bt + + # Android SEC related device nodes + chmod 0660 /dev/sec + chown root system /dev/sec + + # device apc settings + + # device info /proc interface + mknod /dev/devmap c 196 0; + chmod 0440 /dev/devmap + chown root system /dev/devmap + + # BT relayer mode used VCOM + chown bluetooth radio /dev/ttyGS2 + chmod 0660 /dev/ttyGS2 + + # bluetooth + mkdir /data/@btmtk 0770 bluetooth net_bt + chown bluetooth bluetooth /data/@btmtk/host_cache + chown bluetooth bluetooth /data/@btmtk/dev_cache + chown bluetooth bluetooth /dev/hid-keyboard + chmod 0660 /dev/hid-keyboard + #Use uinput's default permission + chown system net_bt_admin /dev/uinput + + # UIBC + chown system media /dev/uibc + chmod 0660 /dev/uibc + + #TV-out + chmod 0664 /dev/TV-out + + #HDMI + chown media system /dev/hdmitx + chmod 0664 /dev/hdmitx + + # JPEG + #chmod 0444 /dev/mtk_jpeg + + # almk + chmod 0440 /dev/mtk_almk + + # DISP + chmod 0444 /dev/mtk_disp + + #Camera + chmod 0660 /dev/camera-sysram + chmod 0660 /dev/camera-isp + chmod 0660 /dev/camera-fdvt + chmod 0660 /dev/camera-pipemgr + chmod 0660 /dev/kd_camera_hw + chmod 0660 /dev/kd_camera_flashlight + chmod 0660 /dev/kd_camera_hw_bus2 + chmod 0660 /dev/BU64245 + chmod 0660 /dev/CAM_CAL_DRV + chmod 0660 /dev/CAM_CAL_DRV_SUB + + chown system camera /dev/camera-sysram + chown system camera /dev/camera-isp + chown system camera /dev/camera-fdvt + chown system camera /dev/camera-pipemgr + chown system camera /dev/kd_camera_hw + chown system camera /dev/kd_camera_flashlight + chown system camera /dev/kd_camera_hw_bus2 + chown system camera /dev/BU64245 + chown system camera /dev/CAM_CAL_DRV + chown system camera /dev/CAM_CAL_DRV_SUB + + #MATV + chmod 0660 /dev/MATV + chown system media /dev/MATV + + # otg_test + chown root radio /dev/mt_otg_test + chmod 0660 /dev/mt_otg_test + + # MDP + chmod 0660 /dev/mt-mdp + chown system media /dev/mt-mdp + + # SMI + chmod 0660 /dev/MTK_SMI + chown system media /dev/MTK_SMI + + + #change partition permission + + chmod 0640 /mtd@sec_ro + chown root system /mtd@sec_ro + + chmod 0640 /mtd@preloader + chown root system /mtd@preloader + + chmod 0660 /mtd@pro_info + chown root system /mtd@pro_info + + chmod 0640 /mtd@bootimg + chown root system /mtd@bootimg + + chmod 0640 /mtd@recovery + chown root system /mtd@recovery + + chmod 0660 /mtd@nvram + chown root system /mtd@nvram + + chmod 0660 /mtd@seccfg + chown root system /mtd@seccfg + + chmod 0660 /mtd@misc + chown root system /mtd@misc + + #mtk_sched + chmod 0660 /dev/mtk_sched + chown system media /dev/mtk_sched + + #BT SCO CVSD, for MT6572 and MT6582 CVSD codec on AP + chmod 0660 /dev/ebc + chown media media /dev/ebc + + chmod 0666 /dev/uio0 + + #otp + chmod 0660 /proc/driver/otp + chown root system /proc/driver/otp + + #autok + chown root system /sys/autok/debug + chown root system /sys/autok/param_count + chown root system /sys/autok/ready + chown root system /sys/autok/ss_corner + chown root system /sys/autok/suggest_vol + chown root system /sys/autok/stage1/2/DONE + chown root system /sys/autok/stage1/2/PARAMS + chown root system /sys/autok/stage1/2/VOLTAGE + chown root system /sys/autok/stage1/2/LOG + chown root system /sys/autok/stage2/2 + + #sn + chmod 0664 /sys/class/android_usb/android0/iSerial + chown root system /sys/class/android_usb/android0/iSerial + chmod 0664 /sys/devices/platform/mt_usb/cmode + chown root system /sys/devices/platform/mt_usb/cmode + + # secure memory + chown system system /proc/secmem0 + + # mcDriverDaemon + mkdir /data/app/mcRegistry 0770 system system + mkdir /data/app/mcRegistry/TbStorage 0770 system system + + # Recycle stuffs + exec /system/bin/rm -f /cache/.ipoh.img + + chmod 0666 /dev/exm0 + + # Thermal + mkdir /data/.tp/ 0775 system system + + +# Add by MEIZU BSP + setprop ro.product.mobile.name m81 + +on boot + write /proc/sys/vm/dirty_writeback_centisecs 300 + chmod 0660 /sys/power/autosleep + + chmod 0664 /sys/class/leds/lcd-backlight/brightness + + chown system system /sys/bus/platform/drivers/gyroscope/gyro_orientation + chown system system /sys/devices/system/cpu/cpufreq/hotplug/cpu_num_base + chmod 0660 /sys/devices/system/cpu/cpufreq/hotplug/cpu_num_base + chown root system /sys/kernel/debug/binder/transaction_log_enable + chown root system /sys/kernel/debug/binder/perf_evalue + + chown system /sys/module/mlog/parameters/do_mlog + chown system /sys/module/mlog/parameters/timer_intval + + chown root radio /sys/class/leds/lcd-backlight/duty + chown root radio /sys/class/leds/lcd-backlight/div + chown system system /sys/class/leds/lcd-backlight/trigger + chown system system /sys/class/leds/button-backlight/trigger + chown system system /sys/class/leds/keyboard-backlight/trigger + chown system system /sys/class/leds/jogball-backlight/trigger + chown system system /sys/class/leds/red/trigger + chown system system /sys/class/leds/green/trigger + chown system system /sys/class/leds/blue/trigger + # Add by Meizu BSP@YinShunQing + chown system system /sys/class/leds/button-backlight/oneshot_blink + + # Permission for hibernation + chown radio system /sys/power/tuxonice + chown radio system /sys/power/tuxonice/do_hibernate + chmod 0770 /sys/power/tuxonice + chmod 0220 /sys/power/tuxonice/do_hibernate + +# Smartbook Handler Framework + chown system system /sys/power/sb_state + chmod 0660 /sys/power/sb_state + + # HMP CPU hotplug strategy + chown system system /proc/hps/num_base_perf_serv + chmod 0660 /proc/hps/num_base_perf_serv + chown system system /proc/hps/num_limit_power_serv + chmod 0660 /proc/hps/num_limit_power_serv + chown system system /proc/hps/num_limit_ultra_power_saving + chmod 0660 /proc/hps/num_limit_ultra_power_saving + chown system system /proc/hps/down_threshold + chmod 0660 /proc/hps/down_threshold + chown system system /proc/hps/up_threshold + chmod 0660 /proc/hps/up_threshold + + # CPU freq + chown system system /proc/cpufreq/cpufreq_limited_by_hevc + chmod 0660 /proc/cpufreq/cpufreq_limited_by_hevc + chown system system /proc/cpufreq/cpufreq_limited_max_freq_by_user + chmod 0660 /proc/cpufreq/cpufreq_limited_max_freq_by_user + + # BW monitor + chown system system /proc/fliper + chmod 0664 /proc/fliper + + #change permissions about terminal + chown root radio /proc/net/vlan/config + chmod 0640 /proc/net/vlan/config + chown root radio /proc/net/ip6_tables_matches + chown root radio /proc/net/ip6_tables_names + chown root radio /proc/net/ip6_tables_targets + chown root radio /proc/net/arp_tables_targets + chown root radio /proc/net/arp_tables_matches + chown root radio /proc/net/arp_tables_names + chown root radio /proc/net/ip_tables_targets + chown root radio /proc/net/ip_tables_matches + chown root radio /proc/net/ip_tables_names + chown root radio /proc/net/ip_conntrack_expect + chown root radio /proc/net/ip_conntrack + chown root radio /proc/net/nf_conntrack + chown root radio /proc/net/nf_conntrack_expect + chown root radio /proc/net/netfilter/nfnetlink_log + chown root radio /proc/net/netfilter/nfnetlink_queue + + # WMT proc + chown shell system /proc/driver/wmt_dbg + chown shell system /proc/driver/wmt_aee + + # define device for EMCSMDLOGGER + chown system radio /dev/ttyGS3 + chmod 0660 /dev/ttyGS3 + + #Define device for ATCID + chmod 660 /dev/ttyGS0 + chown system /dev/ttyGS0 + chmod 660 /dev/ttyGS1 + chown system /dev/ttyGS1 + +on property:ro.board.platform=mt6753 + chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + write /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq 1300000 + +on property:vold.decrypt=trigger_reset_main + start stop_modem + write /proc/bootprof "trigger_reset_main" + +on property:vold.decrypt=trigger_restart_min_framework + start start_modem + start msensord + start permission_check + write /proc/bootprof "trigger_restart_min_framework" + +on property:vold.decrypt=trigger_restart_framework + start nvram_daemon + start start_modem + start msensord + start permission_check + write /proc/bootprof "trigger_restart_framework" + +on property:vold.decrypt=trigger_shutdown_framework + start stop_modem + write /proc/bootprof "trigger_shutdown_framework" + +service stop_modem /system/bin/md_ctrl 0 + class main + disabled + oneshot + +service start_modem /system/bin/md_ctrl 1 + class main + disabled + oneshot +# Define TCP buffer sizes for various networks +# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, + setprop net.tcp.buffersize.default 4096,87380,524288,4096,16384,524288 + setprop net.tcp.buffersize.wifi 524288,1048576,2097152,262144,524288,1048576 + setprop net.tcp.buffersize.lte 524288,1048576,2097152,262144,524288,1048576 + setprop net.tcp.buffersize.umts 4094,87380,524288,4096,16384,524288 + setprop net.tcp.buffersize.hspa 4094,87380,524288,4096,16384,524288 + setprop net.tcp.buffersize.hsupa 4094,87380,524288,4096,16384,524288 + setprop net.tcp.buffersize.hsdpa 4094,87380,524288,4096,16384,524288 + setprop net.tcp.buffersize.hspap 4094,87380,1220608,4096,16384,1220608 + setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040 + setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680 + + setprop persist.sys.strictmode.disable 1 + +## mtk printk uart controller +on property:persist.uartconsole.enable=1 + write /proc/mtprintk 1 + +# Update the second boot logo +service bootlogoupdater /system/bin/boot_logo_updater + class core + oneshot + +# bugreport is triggered by holding down volume down, volume up and power +service bugreport /system/bin/dumpstate -d -p -B \ + -o /data/data/com.android.shell/files/bugreports/bugreport + class main + disabled + oneshot + keycodes 114 115 116 + +service netdiag /system/bin/netdiag + class main + socket netdiag stream 0664 root inet + +service nvram_daemon /system/bin/nvram_daemon + class main + user root + group system + oneshot + +service atci_service /system/bin/atci_service + class core + socket atci-service stream 660 radio system + socket atci-serv-fw stream 660 radio system + user root + disabled + group radio system + +service atcid-daemon-u /system/bin/atcid + class main + socket adb_atci_socket stream 660 radio system + user system + group radio system media + disabled + oneshot + +service atcid-daemon-e /system/bin/atcid + class core + socket adb_atci_socket stream 660 radio system + user root + group radio system + disabled + oneshot + +on property:persist.service.atci.usermode=1 + setprop persist.sys.usb.config mass_storage,adb,acm + +#on property:ro.build.type=eng +#start atci_service +#start atcid-daemon-e + +service audio-daemon /system/bin/audiocmdservice_atci + class main + socket atci-audio stream 660 root system + user root + disabled + oneshot + +service pq /system/bin/pq + class main + user system + group system graphics + oneshot + +# +# MTK Wi-Fi related services (Begin) +# + +# monitor property and power on/off wlan +on property:wlan.driver.status=ok + write /dev/wmtWifi "1" + +on property:wlan.driver.status=unloaded + write /dev/wmtWifi "0" + +service p2p_supplicant /system/bin/wpa_supplicant \ + -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ + -I/system/etc/wifi/wpa_supplicant_overlay.conf -N \ + -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin \ + -I/system/etc/wifi/p2p_supplicant_overlay.conf \ + -O/data/misc/wifi/sockets -g@android:wpa_wlan0 + # we will start as root and wpa_supplicant will switch to user wifi + # after setting up the capabilities required for WEXT + # user wifi + # group wifi inet keystore + class main + socket wpa_wlan0 dgram 660 wifi wifi + disabled + oneshot + +service wpa_supplicant /system/bin/wpa_supplicant \ + -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -e/data/misc/wifi/entropy.bin \ + -I/system/etc/wifi/wpa_supplicant_overlay.conf \ + -O/data/misc/wifi/sockets -g@android:wpa_wlan0 + # we will start as root and wpa_supplicant will switch to user wifi + # after setting up the capabilities required for WEXT + # user wifi + # group wifi inet keystore + class main + socket wpa_wlan0 dgram 660 wifi wifi + disabled + oneshot + +# For WiFi High Speed calibration +service autokd /system/bin/autokd + class core + user system + group system + +# +# MTK Wi-Fi related services (End) +# + + +service dhcpcd_bt-pan /system/bin/dhcpcd -ABKL + class main + user root + group net_admin net_raw + disabled + oneshot + +service dhcpcd_wlan0 /system/bin/dhcpcd -aABDKL + class main + user root + group net_admin net_raw + disabled + oneshot + +service dhcpcd_p2p /system/bin/dhcpcd -aABKL + class main + user root + group net_admin net_raw + disabled + oneshot + +service iprenew_wlan0 /system/bin/dhcpcd -n + class main + user dhcp + group net_admin net_raw + disabled + oneshot + +service iprenew_p2p /system/bin/dhcpcd -n + class main + user dhcp + group net_admin net_raw + disabled + oneshot + +service dhcp_inform /system/bin/dhcpcd -s -BK -A + class main + user root + group system radio dhcp net_admin net_raw + disabled + oneshot + +service dhcpv6_inform /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6cSIP.conf" -fi + class main + user root + group system radio dhcp net_admin net_raw + disabled + oneshot + +service dhcp6cDNS_wlan0 /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6cDNS.conf" -f wlan0 + disabled + oneshot + +service dhcp6c_wlan0 /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6c.conf" -f wlan0 + disabled + oneshot + +on property:service.dhcp6c_wlan0.enable=0 + stop dhcp6c_wlan0 + +on property:service.dhcp6c_wlan0.enable=1 + start dhcp6c_wlan0 + +service dhcp6c_PD /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6cPD.conf" -f + disabled + oneshot + +on property:service.pppoe_wlan0.enable=0 + stop pppoe_wlan0 + +on property:service.pppoe_wlan0.enable=1 + start pppoe_wlan0 + +# write proc for test sim + on property:gsm.sim.ril.testsim=0 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0 + write /proc/sys/net/ipv4/tcp_rto_min 200 + on property:gsm.sim.ril.testsim=1 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1 + write /proc/sys/net/ipv4/tcp_rto_min 400 + on property:gsm.sim.ril.testsim.2=0 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0 + write /proc/sys/net/ipv4/tcp_rto_min 200 + on property:gsm.sim.ril.testsim.2=1 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1 + write /proc/sys/net/ipv4/tcp_rto_min 400 + on property:gsm.sim.ril.testsim.3=0 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0 + write /proc/sys/net/ipv4/tcp_rto_min 200 + on property:gsm.sim.ril.testsim.3=1 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1 + write /proc/sys/net/ipv4/tcp_rto_min 400 + on property:gsm.sim.ril.testsim.4=0 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0 + write /proc/sys/net/ipv4/tcp_rto_min 200 + on property:gsm.sim.ril.testsim.4=1 + write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1 + write /proc/sys/net/ipv4/tcp_rto_min 400 + +service PPLAgent /system/bin/ppl_agent + class main + user system + group system cache + +service enableswap /system/bin/sh /enableswap.sh + class late_start + oneshot + seclabel u:r:enableswap:s0 + +# +# Modem related services (Begin) +# +service pppd_gprs /system/bin/pppd_dt /dev/ttyACM0 debug noauth refuse-eap usepeerdns nodetach + user root + group radio cache inet misc + disabled + oneshot + +# +# Modem related services (End) +# + +service agpsd /system/bin/mtk_agpsd + class main + socket agpsd stream 660 gps system + socket agpsd2 stream 660 gps inet + socket agpsd3 stream 660 gps inet + user gps + group gps radio inet sdcard_r sdcard_rw misc + +service wifi2agps /system/bin/wifi2agps + class main + user wifi + group gps inet + +service mnld /system/xbin/mnld + class main + user gps + group gps inet misc sdcard_rw sdcard_r media_rw system radio + socket mnld stream 660 gps system + +# Sensors +service msensord /system/bin/msensord + class main + oneshot + +service s62xd /system/bin/s62xd + disabled + user compass + group system + class main + +service ami304d /system/bin/ami304d + user system + group system + disabled + class main + +service memsicd /system/bin/memsicd + disabled + user system + group system + class main + +service memsicd3416x /system/bin/memsicd3416x + disabled + user system + group system + class main + +service akmd8975 /system/bin/akmd8975 + disabled + user system + group system + class main + +service akmd8963 /system/bin/akmd8963 + disabled + user system + group system + class main + +service akmd09911 /system/bin/akmd09911 + disabled + user system + group system + class main + +service bmm050d /system/bin/bmm050d + disabled + user system + group system + class main + +service bmm056d /system/bin/bmm056d + disabled + user system + group system + class main + +service mc6420d /system/bin/mc6420d + disabled + user system + group system + class main + +service orientationd /system/bin/orientationd + disabled + user system + group system input + class main + +service AcdApiDaemon /system/bin/AcdApiDaemon + disabled + user system + group system + class main + +service geomagneticd /system/bin/geomagneticd + disabled + user system + group system input + class main + +# +#emsvr service (start) +# +on property:ro.build.type=eng + start emsvr + +on property:ro.build.type=user + start emsvr_user + +on property:ro.build.type=userdebug + start emsvr_user + +service emsvr_user /system/bin/em_svr + disabled + user system + group system radio diag net_bt_stack + +service emsvr /system/bin/em_svr + disabled + user root + group net_bt_stack + +# +#emsvr service (end) +# + +service NvRAMAgent /system/bin/nvram_agent_binder + class main + user system + group system + +# Thermal +service thermal_manager /system/bin/thermal_manager + class main + user root + oneshot + +service thermal /system/bin/thermal + class main + user system + group system + +service thermald /system/bin/thermald + class main + user system + group system + +service fuelgauged /system/bin/fuelgauged + class main + user system + group system + + +#monitor battery status +service batterywarning /system/bin/batterywarning + class main + user shell + group shell + +service MtkCodecService /system/bin/MtkCodecService + class main + user system + group audio media sdcard_r + +# GuiExt Server init +service guiext-server /system/bin/guiext-server + class main + user system + group system graphics + +service kpoc_charger /system/bin/kpoc_charger + class charger + +###########add for 3Gdongle + +on boot + +#set the property of persiste.radio.reset_on_switch +setprop persist.radio.reset_on_switch true +#end + +#set the property of rild.mark_switchuser +setprop rild.mark_switchuser 0 +#end + diff --git a/rootdir/init.mt6735.usb.rc b/rootdir/init.mt6735.usb.rc new file mode 100755 index 0000000..0bde1bb --- /dev/null +++ b/rootdir/init.mt6735.usb.rc @@ -0,0 +1,727 @@ +on boot + setprop sys.usb.vid 2A45 + write /sys/class/android_usb/android0/iManufacturer Meizu + write /sys/class/android_usb/android0/iProduct M81 + write /sys/class/android_usb/android0/iSerial ${ro.serialno} + write /sys/class/android_usb/android0/f_rndis/wceis 1 + write /sys/class/android_usb/android0/f_rndis/manufacturer Meizu + write /sys/class/android_usb/android0/f_rndis/vendorID ${sys.usb.vid} + +on charger + write /sys/class/android_usb/android0/enable 1 + +on fs + mkdir /dev/usb-ffs 0770 shell shell + mkdir /dev/usb-ffs/adb 0770 shell shell + mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 + write /sys/class/android_usb/android0/f_ffs/aliases adb + chown system system /sys/class/android_usb/android0/f_acm/port_index + chmod 0660 /sys/class/android_usb/android0/f_acm/port_index + + +on post-fs-data + chown radio system /sys/class/usb_rawbulk/data/enable + chmod 0660 /sys/class/usb_rawbulk/data/enable + chown radio system /sys/class/usb_rawbulk/ets/enable + chmod 0660 /sys/class/usb_rawbulk/ets/enable + chown radio system /sys/class/usb_rawbulk/atc/enable + chmod 0660 /sys/class/usb_rawbulk/atc/enable + chown radio system /sys/class/usb_rawbulk/pcv/enable + chmod 0660 /sys/class/usb_rawbulk/pcv/enable + chown radio system /sys/class/usb_rawbulk/gps/enable + chmod 0660 /sys/class/usb_rawbulk/gps/enable + +# Used to disable USB when switching states +on property:sys.usb.config=none + stop adbd + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/bDeviceClass 0 + write /sys/devices/platform/mt_usb/saving 0 + setprop sys.usb.state ${sys.usb.config} + +#1.acm +on property:sys.usb.config=acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0006 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/bDeviceClass 02 + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#2.adb +on property:sys.usb.config=adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0C01 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#3.adb,acm +on property:sys.usb.config=adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 200E + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#4.mass_storage +on property:sys.usb.config=mass_storage + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0001 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#5.mass_storage,adb +on property:sys.usb.config=mass_storage,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0C03 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#6.mtp +on property:sys.usb.config=mtp + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2008 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#7.mtp,acm +on property:sys.usb.config=mtp,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2012 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#8.mtp,adb +on property:sys.usb.config=mtp,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0C02 + write /sys/class/android_usb/android0/functions mtp,adb + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#9.mtp,adb,acm +on property:sys.usb.config=mtp,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 200A + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#10.mtp,mass_storage +on property:sys.usb.config=mtp,mass_storage + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2016 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#11.mtp,mass_storage,adb +on property:sys.usb.config=mtp,mass_storage,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2017 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#12.ptp +on property:sys.usb.config=ptp + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 200B + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#13.ptp,acm +on property:sys.usb.config=ptp,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2013 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#14.ptp,adb +on property:sys.usb.config=ptp,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 200C + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#15.ptp,adb,acm +on property:sys.usb.config=ptp,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 200D + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#16.ptp,mass_storage +on property:sys.usb.config=ptp,mass_storage + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2015 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#17.ptp,mass_storage,adb +on property:sys.usb.config=ptp,mass_storage,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2014 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#18.rndis +on property:sys.usb.config=rndis + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0003 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/bDeviceClass 224 + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#19.rndis,acm +on property:sys.usb.config=rndis,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2011 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#20.rndis,adb +on property:sys.usb.config=rndis,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0004 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#21.rndis,adb,acm +on property:sys.usb.config=rndis,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2010 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#22.mass_storage,acm +on property:sys.usb.config=mass_storage,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 200F + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#23.mass_storage,adb,acm +on property:sys.usb.config=mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0005 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#24.mtp,mass_storage,acm +on property:sys.usb.config=mtp,mass_storage,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2018 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#25.mtp,mass_storage,adb,acm +on property:sys.usb.config=mtp,mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2019 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#26.ptp,mass_storage,acm +on property:sys.usb.config=ptp,mass_storage,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 201A + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#27.ptp,mass_storage,adb,acm +on property:sys.usb.config=ptp,mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 201B + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +# duplicate of init.usb.rc + +#28. USB accessory configuration +#on property:sys.usb.config=accessory +# write /sys/class/android_usb/android0/enable 0 +# write /sys/class/android_usb/android0/idVendor 18d1 +# write /sys/class/android_usb/android0/idProduct 2d00 +# write /sys/class/android_usb/android0/functions ${sys.usb.config} +# write /sys/class/android_usb/android0/enable 1 +# setprop sys.usb.state ${sys.usb.config} + +#39. USB accessory configuration, with adb +#on property:sys.usb.config=accessory,adb +# write /sys/class/android_usb/android0/enable 0 +# write /sys/class/android_usb/android0/idVendor 18d1 +# write /sys/class/android_usb/android0/idProduct 2d01 +# write /sys/class/android_usb/android0/functions ${sys.usb.config} +# write /sys/class/android_usb/android0/enable 1 +# start adbd +# setprop sys.usb.state ${sys.usb.config} + +#30. audio accessory configuration +#on property:sys.usb.config=audio_source +# write /sys/class/android_usb/android0/enable 0 +# write /sys/class/android_usb/android0/idVendor 18d1 +# write /sys/class/android_usb/android0/idProduct 2d02 +# write /sys/class/android_usb/android0/functions ${sys.usb.config} +# write /sys/class/android_usb/android0/enable 1 +# setprop sys.usb.state ${sys.usb.config} + +#31. audio accessory configuration, with adb +#on property:sys.usb.config=audio_source,adb +# write /sys/class/android_usb/android0/enable 0 +# write /sys/class/android_usb/android0/idVendor 18d1 +# write /sys/class/android_usb/android0/idProduct 2d03 +# write /sys/class/android_usb/android0/functions ${sys.usb.config} +# write /sys/class/android_usb/android0/enable 1 +# start adbd +# setprop sys.usb.state ${sys.usb.config} + +#32. USB and audio accessory configuration +#on property:sys.usb.config=accessory,audio_source +# write /sys/class/android_usb/android0/enable 0 +# write /sys/class/android_usb/android0/idVendor 18d1 +# write /sys/class/android_usb/android0/idProduct 2d04 +# write /sys/class/android_usb/android0/functions ${sys.usb.config} +# write /sys/class/android_usb/android0/enable 1 +# setprop sys.usb.state ${sys.usb.config} + +#33. USB and audio accessory configuration, with adb +#on property:sys.usb.config=accessory,audio_source,adb +# write /sys/class/android_usb/android0/enable 0 +# write /sys/class/android_usb/android0/idVendor 18d1 +# write /sys/class/android_usb/android0/idProduct 2d05 +# write /sys/class/android_usb/android0/functions ${sys.usb.config} +# write /sys/class/android_usb/android0/enable 1 +# start adbd +# setprop sys.usb.state ${sys.usb.config} + +#34.USB Charging Only configuration +on property:sys.usb.config=charging + setprop sys.usb.state ${sys.usb.config} + setprop sys.usb.charging yes + +on property:sys.usb.charging=yes + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2008 + write /sys/class/android_usb/android0/functions mtp + write /sys/class/android_usb/android0/enable 1 + write /sys/devices/platform/mt_usb/cmode 2 + +on property:sys.usb.charging=no + write /sys/devices/platform/mt_usb/cmode 1 + +#35.USB BICR configuration(mass_storage) +on property:sys.usb.config=bicr + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0001 + write /sys/class/android_usb/android0/functions mass_storage + write /sys/class/android_usb/android0/f_mass_storage/bicr 1 + write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0" + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#36.USB BICR configuration(mass_storage+adb) +on property:sys.usb.config=bicr,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0C03 + write /sys/class/android_usb/android0/functions mass_storage,adb + write /sys/class/android_usb/android0/f_mass_storage/bicr 1 + write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0" + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#37.USB BICR configuration(mass_storage+adb+acm) +on property:sys.usb.config=bicr,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0005 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/f_mass_storage/bicr 1 + write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0" + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#38.USB BICR configuration(mass_storage+acm) +on property:sys.usb.config=bicr,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 200F + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions mass_storage,acm + write /sys/class/android_usb/android0/f_mass_storage/bicr 1 + write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0" + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#39.eem +on property:sys.usb.config=eem + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2026 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/bDeviceClass 224 + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#40.eem,acm +on property:sys.usb.config=eem,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2027 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#41.eem,adb +on property:sys.usb.config=eem,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2028 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#42.eem,adb,acm +on property:sys.usb.config=eem,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2029 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions ${sys.usb.config} + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#C2K bypass +on property:sys.usb.config=via_bypass + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2031 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions via_modem,via_ets,via_atc + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#C2K bypass,adb +on property:sys.usb.config=via_bypass,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2032 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions via_modem,via_ets,via_atc,adb + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#C2K bypass,acm +on property:sys.usb.config=via_bypass,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2033 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions via_modem,via_ets,via_atc,acm + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#C2K bypass,adb,acm +on property:sys.usb.config=via_bypass,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2034 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions via_modem,via_ets,via_atc,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#C2K rndis,bypass +on property:sys.usb.config=rndis,via_bypass + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2036 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions rndis,via_ets + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#C2K rndis,bypass,adb +on property:sys.usb.config=rndis,via_bypass,adb + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2037 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions rndis,via_ets,adb + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#C2K rndis,bypass,acm + on property:sys.usb.config=rndis,via_bypass,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2038 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions rndis,via_ets,acm + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +#C2K rndis,bypass,adb,acm + on property:sys.usb.config=rndis,via_bypass,adb,acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.config} + write /sys/class/android_usb/android0/idProduct 2039 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions rndis,via_ets,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#43.acm third port for bt +on property:sys.usb.config=acm_third + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0005 + write /sys/class/android_usb/android0/f_acm/port_index 3 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +#44.comport --> /dev/ttyGS3 +on property:sys.usb.config=gs3 + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 0005 + write /sys/class/android_usb/android0/f_acm/port_index 4 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + setprop sys.usb.acm_idx 4 + +on property:sys.usb.config=gs3,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 202E + write /sys/class/android_usb/android0/f_acm/port_index 1,4 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + setprop sys.usb.acm_idx 1,4 + +on property:sys.usb.config=gs1gs3 + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2029 + write /sys/class/android_usb/android0/f_acm/port_index 2,4 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + setprop sys.usb.acm_idx 2,4 + +on property:sys.usb.config=gs1gs3,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 202F + write /sys/class/android_usb/android0/f_acm/port_index 1,2,4 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + setprop sys.usb.acm_idx 1,2,4 + +############################################### + +on property:sys.usb.config=mass_storage,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 202D + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions mass_storage,acm + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=mtp,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 202A + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions mtp,acm + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=ptp,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 202B + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions ptp,acm + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=rndis,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 202C + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions rndis,acm + write /sys/class/android_usb/android0/enable 1 + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=mass_storage,adb,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2029 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=mtp,adb,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2026 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions mtp,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=ptp,adb,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2027 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions ptp,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=rndis,adb,dual_acm + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor ${sys.usb.vid} + write /sys/class/android_usb/android0/idProduct 2028 + write /sys/devices/platform/mt_usb/saving 1 + write /sys/class/android_usb/android0/functions rndis,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.bicr=yes + write /sys/class/android_usb/android0/f_mass_storage/bicr 1 + write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0" + +on property:sys.usb.bicr=no + write /sys/class/android_usb/android0/f_mass_storage/bicr 0 + write /sys/class/android_usb/android0/f_mass_storage/lun/file "0" + +on property:mediatek.usb.port.mode=usb + write /sys/devices/platform/mt_usb/portmode 0 + +on property:mediatek.usb.port.mode=uart + write /sys/devices/platform/mt_usb/portmode 1 + +on property:mediatek.em.usb.set=USB_DRIVING_CAPABILITY + write /sys/kernel/debug/usb20_phy/USB_DRIVING_CAPABILITY ${mediatek.em.usb.value} + +on property:mediatek.em.usb.set=RG_USB20_TERM_VREF_SEL + write /sys/kernel/debug/usb20_phy/RG_USB20_TERM_VREF_SEL ${mediatek.em.usb.value} + +on property:mediatek.em.usb.set=RG_USB20_HSTX_SRCTRL + write /sys/kernel/debug/usb20_phy/RG_USB20_HSTX_SRCTRL ${mediatek.em.usb.value} + +on property:mediatek.em.usb.set=RG_USB20_VRT_VREF_SEL + write /sys/kernel/debug/usb20_phy/RG_USB20_VRT_VREF_SEL ${mediatek.em.usb.value} + +on property:mediatek.em.usb.set=RG_USB20_INTR_EN + write /sys/kernel/debug/usb20_phy/RG_USB20_INTR_EN ${mediatek.em.usb.value} diff --git a/rootdir/init.project.rc b/rootdir/init.project.rc new file mode 100755 index 0000000..94d2bbf --- /dev/null +++ b/rootdir/init.project.rc @@ -0,0 +1,239 @@ +# MTK project .rc configure + +import init.mt6735.usb.rc + +on init + mkdir /mnt/media_rw/usbotg 0700 media_rw media_rw + mkdir /storage/usbotg 0700 root root + +on post-fs-data + +# +# Connectivity related device nodes & configuration (begin) +# + +#/dev/ttyMT2 for Connectivity BT/FM/GPS usage + chmod 0660 /dev/ttyMT2 + chown system system /dev/ttyMT2 + + exec /system/xbin/mknod /dev/wmtWifi c 153 0 + chmod 0660 /dev/wmtWifi + chown system system /dev/wmtWifi + +#Camera + chmod 0660 /dev/GAF001AF + chown system camera /dev/GAF001AF + + chmod 0660 /dev/DW9714AF + chown system camera /dev/DW9714AF + + chmod 0660 /dev/AD5820AF + chown system camera /dev/AD5820AF + + chmod 0660 /dev/BU64745GWZAF + chown system camera /dev/BU64745GWZAF + + chmod 0660 /dev/BU64245 + chown system camera /dev/BU64245 + + chmod 0660 /dev/LC898122AF + chown system camera /dev/LC898122AF + + chmod 0660 /dev/AK7345AF + chown system camera /dev/AK7345AF + +#SMB + chown system system /proc/smb/ScreenComm + chmod 0660 /proc/smb/ScreenComm + +# GPS + chown gps gps /sys/class/gpsdrv/gps/pwrctl + chown gps gps /sys/class/gpsdrv/gps/suspend + chown gps gps /sys/class/gpsdrv/gps/state + chown gps gps /sys/class/gpsdrv/gps/pwrsave + chown gps gps /sys/class/gpsdrv/gps/status + +# WiFi + mkdir /data/misc/wifi 0770 wifi wifi + mkdir /data/misc/wifi/sockets 0770 wifi wifi + mkdir /data/misc/wpa_supplicant 0770 wifi wifi + chown wifi wifi /data/misc/wifi + +#Define device for ATCID + chmod 660 /dev/ttyGS0 + chown system /dev/ttyGS0 + chmod 660 /dev/ttyGS1 + chown system /dev/ttyGS1 + +## Sensors +# ltr559 + chmod 0660 /sys/bus/i2c/devices/2-0023/als_data + chown system system /sys/bus/i2c/devices/2-0023/als_data + + chmod 0660 /sys/bus/i2c/devices/2-0023/als_enable + chown system system /sys/bus/i2c/devices/2-0023/als_enable + + chmod 0660 /sys/bus/i2c/devices/2-0023/ps_data + chown system system /sys/bus/i2c/devices/2-0023/ps_data + + chmod 0660 /sys/bus/i2c/devices/2-0023/ps_enable + chown system system /sys/bus/i2c/devices/2-0023/ps_enable + + chmod 0660 /sys/bus/i2c/devices/2-0023/ps_interrupt + chown system system /sys/bus/i2c/devices/2-0023/ps_interrupt + + chmod 0660 /sys/bus/i2c/devices/2-0023/ps_offset + chown system system /sys/bus/i2c/devices/2-0023/ps_offset + + chmod 0660 /sys/bus/i2c/devices/2-0023/reg + chown system system /sys/bus/i2c/devices/2-0023/reg + + chmod 660 /sys/bus/i2c/devices/2-0023/self_test + chown system system /sys/bus/i2c/devices/2-0023/self_test + +# sensor st480 and ak09911 + chmod 660 /sys/bus/i2c/devices/2-000c/self_test + chown system system /sys/bus/i2c/devices/2-000c/self_test + +# lsm6ds3 + chown system system /dev/iio\:device0 + chmod 0666 /dev/iio\:device0 + chown system system /dev/iio\:device1 + chmod 0666 /dev/iio\:device1 + chown system system /dev/iio\:device2 + chmod 0666 /dev/iio\:device2 + chown system system /dev/iio\:device3 + chmod 0666 /dev/iio\:device3 + chown system system /dev/iio\:device4 + chmod 0666 /dev/iio\:device4 + chown system system /dev/iio\:device5 + chmod 0666 /dev/iio\:device5 + chown system system /dev/iio\:device6 + chmod 0666 /dev/iio\:device6 + chown system system /dev/iio\:device7 + chmod 0666 /dev/iio\:device7 + chown system system /dev/iio\:device8 + chmod 0666 /dev/iio\:device8 + chown system system /dev/iio\:device9 + chmod 0666 /dev/iio\:device9 + + +# meizu sensor interfaces + chown system system /sys/class/meizu/acc/acc_calibration + chown system system /sys/class/meizu/acc/acc_enable + chown system system /sys/class/meizu/acc/acc_self_test + chown system system /sys/class/meizu/acc/acc_x_calibbias + chown system system /sys/class/meizu/acc/acc_y_calibbias + chown system system /sys/class/meizu/acc/acc_z_calibbias + chown system system /sys/class/meizu/acc/acc_x_offset + chown system system /sys/class/meizu/acc/acc_y_offset + chown system system /sys/class/meizu/acc/acc_z_offset + chown system system /sys/class/meizu/acc/acc_id + chown system system /sys/class/meizu/acc/acc_name + + chown system system /sys/class/meizu/gyr/gyr_enable + chown system system /sys/class/meizu/gyr/gyr_self_test + chown system system /sys/class/meizu/gyr/gyr_id + chown system system /sys/class/meizu/gyr/gyr_name + + chown system system /sys/class/meizu/ps/ps_enable + chown system system /sys/class/meizu/ps/ps_data + chown system system /sys/class/meizu/ps/ps_calibration + chown system system /sys/class/meizu/ps/ps_calibbias + chown system system /sys/class/meizu/ps/ps_offset + chown system system /sys/class/meizu/ps/ps_id + chown system system /sys/class/meizu/ps/ps_name + chown system system /sys/class/meizu/ps/ps_irq_gpio + + chown system system /sys/class/meizu/als/als_enable + chown system system /sys/class/meizu/als/als_data + chown system system /sys/class/meizu/als/als_id + chown system system /sys/class/meizu/als/als_name + + chown system system /sys/class/meizu/compass/compass_enable + chown system system /sys/class/meizu/compass/compass_self_test + chown system system /sys/class/meizu/compass/compass_id + chown system system /sys/class/meizu/compass/compass_name + +# Char device for BT 3.0 HS + mknod /dev/ampc0 c 151 0 + chown bluetooth bluetooth /dev/ampc0 + chmod 0660 /dev/ampc0 + +# Add by Meizu BSP@YinShunQing for HALL + chown system system /sys/devices/platform/gpio-keys.0/key_hall_state + chmod 0440 /sys/devices/platform/gpio-keys.0/key_hall_state + +# Add by WuWeilin@BSP for power mode permission + chown system system /sys/power/power_mode +# for Holster + chown system system /sys/devices/mx_tsp/hall_mode + chmod 0660 /sys/devices/mx_tsp/hall_mode + +# for Gesture + chown system system /sys/devices/platform/mx-gs/gesture_control + chmod 0660 /sys/devices/platform/mx-gs/gesture_control + chown system system /sys/devices/platform/mx-gs/gesture_data + chmod 0660 /sys/devices/platform/mx-gs/gesture_data + +# for notification leds + chmod 0660 /sys/class/leds/button-backlight/trigger + chmod 0660 /sys/class/leds/button-backlight/oneshot_blink + chmod 0660 /sys/class/leds/button-backlight/brightness + +# +# Connectivity related device nodes & configuration (end) +# + +# Encrypt phone function + setprop vold.post_fs_data_done 1 + +# +# Connectivity related services (Begin) +# + +service atci_service /system/bin/atci_service + socket atci-service stream 660 radio system + socket atci-serv-fw stream 660 radio system + user root + disabled + group radio system +service atcid-daemon-u /system/bin/atcid + user system + group radio system media + disabled + oneshot + +service atcid-daemon-e /system/bin/atcid + user root + group radio system + disabled + oneshot + +on early_property:ro.build.type=eng +start atci_service +start atcid-daemon-e +service audio-daemon /system/bin/audiocmdservice_atci + class main + socket atci-audio stream 660 media system + user media + group nvram media system sdcard_rw + disabled + oneshot + +service wmtLoader /system/bin/wmt_loader + user root + group root + class core + oneshot + + +service conn_launcher /system/bin/6620_launcher -p /system/etc/firmware/ + user system + group system + class core + +# +# Connectivity related services (End) +# + diff --git a/rootdir/init.rc b/rootdir/init.rc new file mode 100644 index 0000000..75d8304 --- /dev/null +++ b/rootdir/init.rc @@ -0,0 +1,794 @@ +# Copyright (C) 2012 The Android Open Source Project +# +# IMPORTANT: Do not create world writable files or directories. +# This is a common source of Android security bugs. +# + +import /init.environ.rc +import /init.usb.rc +import /init.${ro.hardware}.rc +import /init.usb.configfs.rc +import /init.${ro.zygote}.rc +import /init.trace.rc +# Include CM's extra init file +import /init.cm.rc +import /init.modem.rc + +on early-init + # Set init and its forked children's oom_adj. + write /proc/1/oom_score_adj -1000 + + # Set the security context of /adb_keys if present. + restorecon /adb_keys + + start ueventd + +on init + sysclktz 0 + + write /proc/bootprof "INIT: on init start" + + # Backward compatibility. + symlink /system/etc /etc + symlink /sys/kernel/debug /d + + # Link /vendor to /system/vendor for devices without a vendor partition. + symlink /system/vendor /vendor + + # Create cgroup mount point for cpu accounting + mkdir /acct + mount cgroup none /acct cpuacct + mkdir /acct/uid + + # Create cgroup mount point for memory + mount tmpfs none /sys/fs/cgroup mode=0750,uid=0,gid=1000 + mkdir /sys/fs/cgroup/memory 0750 root system + mount cgroup none /sys/fs/cgroup/memory memory + write /sys/fs/cgroup/memory/memory.move_charge_at_immigrate 1 + chown root system /sys/fs/cgroup/memory/tasks + chmod 0660 /sys/fs/cgroup/memory/tasks + mkdir /sys/fs/cgroup/memory/sw 0750 root system + write /sys/fs/cgroup/memory/sw/memory.swappiness 100 + write /sys/fs/cgroup/memory/sw/memory.move_charge_at_immigrate 1 + chown root system /sys/fs/cgroup/memory/sw/tasks + chmod 0660 /sys/fs/cgroup/memory/sw/tasks + chmod 0220 /sys/fs/cgroup/memory/cgroup.event_control + + mkdir /system + mkdir /data 0771 system system + mkdir /cache 0770 system cache + mkdir /config 0500 root root + + # Mount staging areas for devices managed by vold + # See storage config details at http://source.android.com/tech/storage/ + mkdir /mnt 0755 root system + mount tmpfs tmpfs /mnt mode=0755,uid=0,gid=1000 + restorecon_recursive /mnt + + # Directory for putting things only root should see. + mkdir /mnt/secure 0700 root root + + # Directory for staging bindmounts + mkdir /mnt/secure/staging 0700 root root + mkdir /mnt/secure/asec 0700 root root + mkdir /mnt/asec 0755 root system + mkdir /mnt/obb 0755 root system + mkdir /mnt/media_rw 0750 root media_rw + mkdir /mnt/user 0755 root root + mkdir /mnt/user/0 0755 root root + mkdir /mnt/expand 0771 system system + + # Storage views to support runtime permissions + mkdir /storage 0755 root root + mkdir /mnt/runtime 0700 root root + mkdir /mnt/runtime/default 0755 root root + mkdir /mnt/runtime/default/self 0755 root root + mkdir /mnt/runtime/read 0755 root root + mkdir /mnt/runtime/read/self 0755 root root + mkdir /mnt/runtime/write 0755 root root + mkdir /mnt/runtime/write/self 0755 root root + + # Symlink to keep legacy apps working in multi-user world + symlink /storage/self/primary /sdcard + symlink /mnt/user/0/primary /mnt/runtime/default/self/primary + + # memory control cgroup + mkdir /dev/memcg 0700 root system + mount cgroup none /dev/memcg memory + + write /proc/sys/kernel/panic_on_oops 1 + write /proc/sys/kernel/hung_task_timeout_secs 0 + write /proc/cpu/alignment 4 + + # scheduler tunables + # Disable auto-scaling of scheduler tunables with hotplug. The tunables + # will vary across devices in unpredictable ways if allowed to scale with + # cpu cores. + write /proc/sys/kernel/sched_tunable_scaling 0 + write /proc/sys/kernel/sched_latency_ns 10000000 + write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 + write /proc/sys/kernel/sched_compat_yield 1 + write /proc/sys/kernel/sched_child_runs_first 0 + + write /proc/sys/kernel/randomize_va_space 2 + write /proc/sys/kernel/kptr_restrict 2 + write /proc/sys/vm/mmap_min_addr 32768 + write /proc/sys/net/ipv4/ping_group_range "0 2147483647" + write /proc/sys/net/unix/max_dgram_qlen 300 + write /proc/sys/kernel/sched_rt_runtime_us 950000 + write /proc/sys/kernel/sched_rt_period_us 1000000 + + # reflect fwmark from incoming packets onto generated replies + write /proc/sys/net/ipv4/fwmark_reflect 1 + write /proc/sys/net/ipv6/fwmark_reflect 1 + + # set fwmark on accepted sockets + write /proc/sys/net/ipv4/tcp_fwmark_accept 1 + + # disable icmp redirects + write /proc/sys/net/ipv4/conf/all/accept_redirects 0 + write /proc/sys/net/ipv6/conf/all/accept_redirects 0 + + # Create cgroup mount points for process groups + mkdir /dev/cpuctl + mount cgroup none /dev/cpuctl cpu + chown system system /dev/cpuctl + chown system system /dev/cpuctl/tasks + chmod 0666 /dev/cpuctl/tasks + write /dev/cpuctl/cpu.shares 1024 + write /dev/cpuctl/cpu.rt_runtime_us 950000 + write /dev/cpuctl/cpu.rt_period_us 1000000 + + mkdir /dev/cpuctl/bg_non_interactive + chown system system /dev/cpuctl/bg_non_interactive/tasks + chmod 0666 /dev/cpuctl/bg_non_interactive/tasks + # 5.0 % + write /dev/cpuctl/bg_non_interactive/cpu.shares 52 + write /dev/cpuctl/bg_non_interactive/cpu.rt_runtime_us 700000 + write /dev/cpuctl/bg_non_interactive/cpu.rt_period_us 1000000 + + # sets up initial cpusets for ActivityManager + mkdir /dev/cpuset + mount cpuset none /dev/cpuset + + # this ensures that the cpusets are present and usable, but the device's + # init.rc must actually set the correct cpus + mkdir /dev/cpuset/foreground + write /dev/cpuset/foreground/cpus 0 + write /dev/cpuset/foreground/mems 0 + mkdir /dev/cpuset/foreground/boost + write /dev/cpuset/foreground/boost/cpus 0 + write /dev/cpuset/foreground/boost/mems 0 + mkdir /dev/cpuset/background + write /dev/cpuset/background/cpus 0 + write /dev/cpuset/background/mems 0 + + # system-background is for system tasks that should only run on + # little cores, not on bigs + # to be used only by init, so don't change system-bg permissions + mkdir /dev/cpuset/system-background + write /dev/cpuset/system-background/cpus 0 + write /dev/cpuset/system-background/mems 0 + + # change permissions for all cpusets we'll touch at runtime + chown system system /dev/cpuset + chown system system /dev/cpuset/foreground + chown system system /dev/cpuset/foreground/boost + chown system system /dev/cpuset/background + chown system system /dev/cpuset/system-background + chown system system /dev/cpuset/tasks + chown system system /dev/cpuset/foreground/tasks + chown system system /dev/cpuset/foreground/boost/tasks + chown system system /dev/cpuset/background/tasks + chown system system /dev/cpuset/system-background/tasks + + # set system-background to 0775 so SurfaceFlinger can touch it + chmod 0775 /dev/cpuset/system-background + chmod 0664 /dev/cpuset/foreground/tasks + chmod 0664 /dev/cpuset/foreground/boost/tasks + chmod 0664 /dev/cpuset/background/tasks + chmod 0664 /dev/cpuset/system-background/tasks + chmod 0664 /dev/cpuset/tasks + + + # qtaguid will limit access to specific data based on group memberships. + # net_bw_acct grants impersonation of socket owners. + # net_bw_stats grants access to other apps' detailed tagged-socket stats. + chown root net_bw_acct /proc/net/xt_qtaguid/ctrl + chown root net_bw_stats /proc/net/xt_qtaguid/stats + + # Allow everybody to read the xt_qtaguid resource tracking misc dev. + # This is needed by any process that uses socket tagging. + chmod 0644 /dev/xt_qtaguid + + # Create location for fs_mgr to store abbreviated output from filesystem + # checker programs. + mkdir /dev/fscklogs 0770 root system + + # pstore/ramoops previous console log + mount pstore pstore /sys/fs/pstore + chown system log /sys/fs/pstore/console-ramoops + chmod 0440 /sys/fs/pstore/console-ramoops + chown system log /sys/fs/pstore/pmsg-ramoops-0 + chmod 0440 /sys/fs/pstore/pmsg-ramoops-0 + + # enable armv8_deprecated instruction hooks + write /proc/sys/abi/swp 1 + + # ion device + chmod 0666 /dev/ion + chmod 0660 /sys/bus/platform/drivers/gsensor/cpsdata + chmod 0660 /sys/bus/platform/drivers/gsensor/cpsrange + chmod 0660 /sys/bus/platform/drivers/gsensor/cpsbandwidth + chmod 0660 /sys/bus/platform/drivers/gsensor/cpsopmode + chmod 0660 /sys/bus/platform/drivers/gsensor/fifo_mode + chmod 0660 /sys/bus/platform/drivers/gsensor/fifo_data_frame + chmod 0660 /sys/bus/platform/drivers/gsensor/fifo_framecount + chown system system /sys/bus/platform/drivers/gsensor/cpsdata + chown system system /sys/bus/platform/drivers/gsensor/cpsrange + chown system system /sys/bus/platform/drivers/gsensor/cpsbandwidth + chown system system /sys/bus/platform/drivers/gsensor/cpsopmode + chown system system /sys/bus/platform/drivers/gsensor/fifo_mode + chown system system /sys/bus/platform/drivers/gsensor/fifo_data_frame + chown system system /sys/bus/platform/drivers/gsensor/fifo_framecount + + # add for mag + chmod 0660 /sys/bus/platform/drivers/msensor/rawdata + chown system system /sys/bus/platform/drivers/msensor/rawdata + chmod 0660 /sys/bus/platform/drivers/msensor/daemon + chown system system /sys/bus/platform/drivers/msensor/daemon + + # add for gyro + chmod 0660 /sys/bus/platform/drivers/gyroscope/rawdata + chmod 0660 /sys/bus/platform/drivers/gyroscope/datarate + chmod 0660 /sys/bus/platform/drivers/gyroscope/range + chmod 0660 /sys/bus/platform/drivers/gyroscope/powermode + chmod 0660 /sys/bus/platform/drivers/gyroscope/fifo_mode + chmod 0660 /sys/bus/platform/drivers/gyroscope/fifo_data_frame + chmod 0660 /sys/bus/platform/drivers/gyroscope/fifo_framecount + chown system system /sys/bus/platform/drivers/gyroscope/rawdata + chown system system /sys/bus/platform/drivers/gyroscope/datarate + chown system system /sys/bus/platform/drivers/gyroscope/range + chown system system /sys/bus/platform/drivers/gyroscope/powermode + chown system system /sys/bus/platform/drivers/gyroscope/fifo_mode + chown system system /sys/bus/platform/drivers/gyroscope/fifo_data_frame + chown system system /sys/bus/platform/drivers/gyroscope/fifo_framecount + +# Healthd can trigger a full boot from charger mode by signaling this +# property when the power button is held. +on property:sys.boot_from_charger_mode=1 + class_stop charger + trigger late-init + +# Load properties from /system/ + /factory after fs mount. +on load_system_props_action + load_system_props + +on load_persist_props_action + load_persist_props + start logd + start logd-reinit + +# Indicate to fw loaders that the relevant mounts are up. +on firmware_mounts_complete + rm /dev/.booting + +# Mount filesystems and start core system services. +on late-init + trigger early-fs + trigger fs + trigger post-fs + + # Load properties from /system/ + /factory after fs mount. Place + # this in another action so that the load will be scheduled after the prior + # issued fs triggers have completed. + trigger load_system_props_action + + # Now we can mount /data. File encryption requires keymaster to decrypt + # /data, which in turn can only be loaded when system properties are present + trigger post-fs-data + trigger load_persist_props_action + + # Remove a file to wake up anything waiting for firmware. + trigger firmware_mounts_complete + + trigger early-boot + trigger boot + + +on post-fs + # once everything is setup, no need to modify / + mount rootfs rootfs / ro remount + # Mount shared so changes propagate into child namespaces + mount rootfs rootfs / shared rec + # Mount default storage into root namespace + mount none /mnt/runtime/default /storage slave bind rec + + # We chown/chmod /cache again so because mount is run as root + defaults + chown system cache /cache + chmod 0770 /cache + # We restorecon /cache in case the cache partition has been reset. + restorecon_recursive /cache + + # Create /cache/recovery in case it's not there. It'll also fix the odd + # permissions if created by the recovery system. + mkdir /cache/recovery 0770 system cache + + #change permissions on vmallocinfo so we can grab it from bugreports + chown root log /proc/vmallocinfo + chmod 0440 /proc/vmallocinfo + + chown root log /proc/slabinfo + chmod 0440 /proc/slabinfo + + #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks + chown root system /proc/kmsg + chmod 0440 /proc/kmsg + chown root system /proc/sysrq-trigger + chmod 0220 /proc/sysrq-trigger + chown system log /proc/last_kmsg + chmod 0440 /proc/last_kmsg + + # make the selinux kernel policy world-readable + chmod 0444 /sys/fs/selinux/policy + + # create the lost+found directories, so as to enforce our permissions + mkdir /cache/lost+found 0770 root root + +on post-fs-data + # We chown/chmod /data again so because mount is run as root + defaults + chown system system /data + chmod 0771 /data + # We restorecon /data in case the userdata partition has been reset. + restorecon /data + + # Emulated internal storage area + mkdir /data/media 0770 media_rw media_rw + + # Make sure we have the device encryption key + start vold + installkey /data + + # Start bootcharting as soon as possible after the data partition is + # mounted to collect more data. + mkdir /data/bootchart 0755 shell shell + bootchart_init + + # Avoid predictable entropy pool. Carry over entropy from previous boot. + copy /data/system/entropy.dat /dev/urandom + + # create basic filesystem structure + mkdir /data/misc 01771 system misc + mkdir /data/misc/adb 02750 system shell + mkdir /data/misc/bluedroid 02770 bluetooth net_bt_stack + # Fix the access permissions and group ownership for 'bt_config.conf' + chmod 0660 /data/misc/bluedroid/bt_config.conf + chown bluetooth net_bt_stack /data/misc/bluedroid/bt_config.conf + mkdir /data/misc/bluetooth 0770 system system + mkdir /data/misc/keystore 0700 keystore keystore + mkdir /data/misc/gatekeeper 0700 system system + mkdir /data/misc/keychain 0771 system system + mkdir /data/misc/net 0750 root shell + mkdir /data/misc/radio 0770 system radio + mkdir /data/misc/sms 0770 system radio + mkdir /data/misc/zoneinfo 0775 system system + mkdir /data/misc/vpn 0770 system vpn + mkdir /data/misc/shared_relro 0771 shared_relro shared_relro + mkdir /data/misc/systemkeys 0700 system system + mkdir /data/misc/wifi 0770 wifi wifi + mkdir /data/misc/wifi/sockets 0770 wifi wifi + mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi + mkdir /data/misc/ethernet 0770 system system + mkdir /data/misc/dhcp 0770 dhcp dhcp + mkdir /data/misc/user 0771 root root + mkdir /data/misc/perfprofd 0775 root root + # give system access to wpa_supplicant.conf for backup and restore + chmod 0660 /data/misc/wifi/wpa_supplicant.conf + mkdir /data/local 0751 root root + mkdir /data/misc/media 0700 media media + mkdir /data/misc/vold 0700 root root + + # For security reasons, /data/local/tmp should always be empty. + # Do not place files or directories in /data/local/tmp + mkdir /data/local/tmp 0771 shell shell + mkdir /data/data 0771 system system + mkdir /data/app-private 0771 system system + mkdir /data/app-asec 0700 root root + mkdir /data/app-lib 0771 system system + mkdir /data/app 0771 system system + mkdir /data/property 0700 root root + mkdir /data/tombstones 0771 system system + + # create dalvik-cache, so as to enforce our permissions + mkdir /data/dalvik-cache 0771 root root + mkdir /data/dalvik-cache/profiles 0711 system system + + # create resource-cache and double-check the perms + mkdir /data/resource-cache 0771 system system + chown system system /data/resource-cache + chmod 0771 /data/resource-cache + + # create the lost+found directories, so as to enforce our permissions + mkdir /data/lost+found 0770 root root + + # create directory for DRM plug-ins - give drm the read/write access to + # the following directory. + mkdir /data/drm 0770 drm drm + + # create directory for MediaDrm plug-ins - give drm the read/write access to + # the following directory. + mkdir /data/mediadrm 0770 mediadrm mediadrm + + mkdir /data/adb 0700 root root + + # symlink to bugreport storage location + symlink /data/data/com.android.shell/files/bugreports /data/bugreports + + # Separate location for storing security policy files on data + mkdir /data/security 0711 system system + + # Create all remaining /data root dirs so that they are made through init + # and get proper encryption policy installed + mkdir /data/backup 0700 system system + mkdir /data/media 0770 media_rw media_rw + mkdir /data/ss 0700 system system + mkdir /data/system 0775 system system + mkdir /data/system/heapdump 0700 system system + mkdir /data/user 0711 system system + + # add for mediaserver data + mkdir /data/mediaserver 0775 media media + restorecon /data/mediaserver + + setusercryptopolicies /data/user + + # Reload policy from /data/security if present. + setprop selinux.reload_policy 1 + + # Set SELinux security contexts on upgrade or policy update. + restorecon_recursive /data + restorecon /data/data + restorecon /data/user + restorecon /data/user/0 + + # Check any timezone data in /data is newer than the copy in /system, delete if not. + exec - system system -- /system/bin/tzdatacheck /system/usr/share/zoneinfo /data/misc/zoneinfo + + # If there is no fs-post-data action in the init.<device>.rc file, you + # must uncomment this line, otherwise encrypted filesystems + # won't work. + # Set indication (checked by vold) that we have finished this action + #setprop vold.post_fs_data_done 1 + +on boot + # basic network init + ifup lo + hostname localhost + domainname localdomain + + # set RLIMIT_NICE to allow priorities from 19 to -20 + setrlimit 13 40 40 + + # Memory management. Basic kernel parameters, and allow the high + # level system server to be able to adjust the kernel OOM driver + # parameters to match how it is managing things. + write /proc/sys/vm/overcommit_memory 1 + write /proc/sys/vm/min_free_order_shift 4 + chown root system /sys/module/lowmemorykiller/parameters/adj + chmod 0664 /sys/module/lowmemorykiller/parameters/adj + chown root system /sys/module/lowmemorykiller/parameters/minfree + chmod 0664 /sys/module/lowmemorykiller/parameters/minfree + + # Tweak background writeout + write /proc/sys/vm/dirty_expire_centisecs 200 + write /proc/sys/vm/dirty_background_ratio 5 + + # Permissions for System Server and daemons. + chown radio system /sys/android_power/state + chown radio system /sys/android_power/request_state + chown radio system /sys/android_power/acquire_full_wake_lock + chown radio system /sys/android_power/acquire_partial_wake_lock + chown radio system /sys/android_power/release_wake_lock + chown system system /sys/power/autosleep + chown system system /sys/power/state + chown system system /sys/power/wakeup_count + chown radio system /sys/power/wake_lock + chown radio system /sys/power/wake_unlock + chmod 0660 /sys/power/state + chmod 0660 /sys/power/wake_lock + chmod 0660 /sys/power/wake_unlock + + chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate + chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_slack + chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + chown system system /sys/devices/system/cpu/cpufreq/interactive/target_loads + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target_loads + chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + chown system system /sys/devices/system/cpu/cpufreq/interactive/boost + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost + chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse + chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost + chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration + chown system system /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + + # Assume SMP uses shared cpufreq policy for all CPUs + chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + + chown system system /sys/class/timed_output/vibrator/enable + chown system system /sys/class/leds/keyboard-backlight/brightness + chown system system /sys/class/leds/lcd-backlight/brightness + chown system system /sys/class/leds/torch-light/brightness + chown system system /sys/class/leds/button-backlight/brightness + chown system system /sys/class/leds/jogball-backlight/brightness + chown system system /sys/class/leds/red/brightness + chown system system /sys/class/leds/green/brightness + chown system system /sys/class/leds/blue/brightness + chown system system /sys/class/leds/red/device/grpfreq + chown system system /sys/class/leds/red/device/grppwm + chown system system /sys/class/leds/red/device/blink + chown system system /sys/class/timed_output/vibrator/enable + chown system system /sys/module/sco/parameters/disable_esco + chown system system /sys/kernel/ipv4/tcp_wmem_min + chown system system /sys/kernel/ipv4/tcp_wmem_def + chown system system /sys/kernel/ipv4/tcp_wmem_max + chown system system /sys/kernel/ipv4/tcp_rmem_min + chown system system /sys/kernel/ipv4/tcp_rmem_def + chown system system /sys/kernel/ipv4/tcp_rmem_max + chown root radio /proc/cmdline + + # Define default initial receive window size in segments. + setprop net.tcp.default_init_rwnd 60 + + class_start core + +on nonencrypted + class_start main + class_start late_start + +on property:vold.decrypt=trigger_default_encryption + start defaultcrypto + +on property:vold.decrypt=trigger_encryption + start surfaceflinger + start encrypt + +on property:sys.init_log_level=* + loglevel ${sys.init_log_level} + +on charger + class_start charger + +on property:vold.decrypt=trigger_reset_main + class_reset main + +on property:vold.decrypt=trigger_load_persist_props + load_persist_props + +on property:vold.decrypt=trigger_post_fs_data + trigger post-fs-data + +on property:vold.decrypt=trigger_restart_min_framework + class_start main + +on property:vold.decrypt=trigger_restart_framework + class_start main + class_start late_start + +on property:vold.decrypt=trigger_shutdown_framework + class_reset late_start + class_reset main + +on property:sys.powerctl=* + powerctl ${sys.powerctl} + +# system server cannot write to /proc/sys files, +# and chown/chmod does not work for /proc/sys/ entries. +# So proxy writes through init. +on property:sys.sysctl.extra_free_kbytes=* + write /proc/sys/vm/extra_free_kbytes ${sys.sysctl.extra_free_kbytes} + +# "tcp_default_init_rwnd" Is too long! +on property:sys.sysctl.tcp_def_init_rwnd=* + write /proc/sys/net/ipv4/tcp_default_init_rwnd ${sys.sysctl.tcp_def_init_rwnd} + + +## Daemon processes to be run by init. +## +service ueventd /sbin/ueventd + class core + critical + seclabel u:r:ueventd:s0 + +service logd /system/bin/logd + class core + socket logd stream 0666 logd logd + socket logdr seqpacket 0666 logd logd + socket logdw dgram 0222 logd logd + group root system + + +service healthd /sbin/healthd + class core + critical + seclabel u:r:healthd:s0 + group root system + +service console /system/bin/sh + class core + console + disabled + user shell + group shell log + seclabel u:r:shell:s0 + +on property:ro.debuggable=1 + start console + +# adbd is controlled via property triggers in init.<platform>.usb.rc +service adbd /sbin/adbd --root_seclabel=u:r:su:s0 + class core + socket adbd stream 660 system system + disabled + seclabel u:r:adbd:s0 + +# adbd on at boot in emulator +on property:ro.kernel.qemu=1 + start adbd + +service lmkd /system/bin/lmkd + class core + critical + socket lmkd seqpacket 0660 system system + +service servicemanager /system/bin/servicemanager + class core + user system + group system + critical + onrestart restart healthd + onrestart restart zygote + onrestart restart media + onrestart restart surfaceflinger + onrestart restart drm + +service vold /system/bin/vold \ + --blkid_context=u:r:blkid:s0 --blkid_untrusted_context=u:r:blkid_untrusted:s0 \ + --fsck_context=u:r:fsck:s0 --fsck_untrusted_context=u:r:fsck_untrusted:s0 + class core + socket vold stream 0660 root mount + socket cryptd stream 0660 root mount + ioprio be 2 + +service netd /system/bin/netd + class main + socket netd stream 0660 root system + socket dnsproxyd stream 0660 root inet + socket mdns stream 0660 root system + socket fwmarkd stream 0660 root inet + +service debuggerd /system/bin/debuggerd + class main + +service debuggerd64 /system/bin/debuggerd64 + class main + +#service ril-daemon /system/bin/rild +# class main +# socket rild stream 660 root radio +# socket sap_uim_socket1 stream 660 bluetooth bluetooth +# socket rild-debug stream 660 radio system +# user root +# group radio cache inet misc audio log qcom_diag + +service surfaceflinger /system/bin/surfaceflinger + class core + user system + group graphics drmrpc + onrestart restart zygote + +service drm /system/bin/drmserver + class main + user drm + group drm system inet drmrpc sdcard_rw media_rw + +service media /system/bin/mediaserver + class main + user root + group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm media sdcard_r system net_bt_stack + ioprio rt 4 + +# One shot invocation to deal with encrypted volume. +service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted + disabled + oneshot + # vold will set vold.decrypt to trigger_restart_framework (default + # encryption) or trigger_restart_min_framework (other encryption) + +# One shot invocation to encrypt unencrypted volumes +service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default noui + disabled + oneshot + # vold will set vold.decrypt to trigger_restart_framework (default + # encryption) + +service bootanim /system/bin/bootanimation + class core + user graphics + group graphics media audio + disabled + oneshot + +service gatekeeperd /system/bin/gatekeeperd /data/misc/gatekeeper + class late_start + user system + +service installd /system/bin/installd + class main + socket installd stream 600 system system + +service flash_recovery /system/bin/install-recovery.sh + class main + oneshot + disabled + +# update recovery if enabled +on property:persist.sys.recovery_update=true + start flash_recovery + +service racoon /system/bin/racoon + class main + socket racoon stream 600 system system + # IKE uses UDP port 500. Racoon will setuid to vpn after binding the port. + group vpn net_admin inet + disabled + oneshot + +service mtpd /system/bin/mtpd + class main + socket mtpd stream 600 system system + user vpn + group vpn net_admin inet net_raw + disabled + oneshot + +service keystore /system/bin/keystore /data/misc/keystore + class main + user keystore + group keystore drmrpc + +service dumpstate /system/bin/dumpstate -s + class main + socket dumpstate stream 0660 shell log + disabled + oneshot + +service mdnsd /system/bin/mdnsd + class main + user mdnsr + group inet net_raw + socket mdnsd stream 0660 mdnsr inet + disabled + oneshot + +service uncrypt /system/bin/uncrypt + class main + disabled + oneshot + +service pre-recovery /system/bin/uncrypt --reboot + class main + disabled + oneshot + diff --git a/rootdir/init.ssd.rc b/rootdir/init.ssd.rc new file mode 100644 index 0000000..ae081e1 --- /dev/null +++ b/rootdir/init.ssd.rc @@ -0,0 +1,27 @@ +# MTK project .rc configure + +on post-fs-data +# +# SHARED_SDCARD related directory & configuration (begin) +# + +# we will remap this as /mnt/sdcard with the sdcard fuse tool + mkdir /data/media 0770 media_rw media_rw + chown media_rw media_rw /data/media + +# +# SHARED_SDCARD related directory & configuration (end) +# + +on init + mount tmpfs tmpfs /storage/emulated mode=0755,uid=1023,gid=1023 + + # Support legacy paths + symlink /sdcard /mnt/sdcard + symlink /sdcard /storage/sdcard0 + +on post-fs + # mount shared so changes propagate into child namespaces + mount rootfs rootfs / shared rec + mount tmpfs tmpfs /mnt/secure private rec + diff --git a/rootdir/init.trace.rc b/rootdir/init.trace.rc new file mode 100755 index 0000000..9085e3d --- /dev/null +++ b/rootdir/init.trace.rc @@ -0,0 +1,42 @@ +## Permissions to allow system-wide tracing to the kernel trace buffer. +## +on boot + +# Allow writing to the kernel trace log. + mount debugfs debugfs /sys/kernel/debug + chmod 0755 /sys/kernel/debug + chmod 0222 /sys/kernel/debug/tracing/trace_marker + +# Allow the shell group to enable (some) kernel tracing. + chown root shell /sys/kernel/debug/tracing/trace_clock + chown system shell /sys/kernel/debug/tracing/buffer_size_kb + chown root shell /sys/kernel/debug/tracing/options/overwrite + chown root shell /sys/kernel/debug/tracing/options/record-cmd + chown root shell /sys/kernel/debug/tracing/events/sched/sched_switch/enable + chown root shell /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable + chown root shell /sys/kernel/debug/tracing/events/power/cpu_frequency/enable + chown root shell /sys/kernel/debug/tracing/events/power/cpu_idle/enable + chown root shell /sys/kernel/debug/tracing/events/power/clock_set_rate/enable + chown root shell /sys/kernel/debug/tracing/events/cpufreq_interactive/enable + # change to system owner for AMS to control + chown system shell /sys/kernel/debug/tracing/tracing_on + chown system shell /sys/kernel/debug/tracing/tracing_enabled + chown root shell /sys/kernel/debug/tracing/set_event + + chmod 0664 /sys/kernel/debug/tracing/trace_clock + chmod 0664 /sys/kernel/debug/tracing/buffer_size_kb + chmod 0664 /sys/kernel/debug/tracing/options/overwrite + chmod 0664 /sys/kernel/debug/tracing/options/record-cmd + chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_switch/enable + chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable + chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_frequency/enable + chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_idle/enable + chmod 0664 /sys/kernel/debug/tracing/events/power/clock_set_rate/enable + chmod 0664 /sys/kernel/debug/tracing/events/cpufreq_interactive/enable + chmod 0664 /sys/kernel/debug/tracing/tracing_on + chmod 0664 /sys/kernel/debug/tracing/tracing_enabled + chmod 0664 /sys/kernel/debug/tracing/set_event + +# Allow only the shell group to read and truncate the kernel trace. + chown system shell /sys/kernel/debug/tracing/trace + chmod 0664 /sys/kernel/debug/tracing/trace diff --git a/rootdir/meta_init.modem.rc b/rootdir/meta_init.modem.rc new file mode 100644 index 0000000..9b9cadb --- /dev/null +++ b/rootdir/meta_init.modem.rc @@ -0,0 +1,46 @@ +# Copyright (C) 2012 The Android Open Source Project +# +# IMPORTANT: Do not create world writable files or directories. +# This is a common source of Android security bugs. +# + +on post-fs-data + +#INTERNAL_START + write /proc/bootprof "post-fs-data: on meta modem start" + + # Modem related device nodes + mkdir /data/nvram/md 0770 root system + + chown radio radio /sys/kernel/ccci/boot + + #SeLinux + mkdir /data/ccci_cfg 0770 system radio + restorecon /data/ccci_cfg + restorecon_recursive /protect_f + restorecon_recursive /protect_s + + # Encrypt phone function + setprop vold.post_fs_data_done 1 + +service permission_check /system/bin/permission_check + user root + group system radio + oneshot + +service ccci_fsd /system/bin/ccci_fsd 0 + user radio + group radio system + oneshot + +service ccci_mdinit /system/bin/ccci_mdinit 0 + user system + group radio system + oneshot + +service ccci_rpcd /system/bin/ccci_rpcd 0 + user radio + group radio system + oneshot + +#INTERNAL_END
\ No newline at end of file diff --git a/rootdir/meta_init.project.rc b/rootdir/meta_init.project.rc new file mode 100644 index 0000000..55f4ae9 --- /dev/null +++ b/rootdir/meta_init.project.rc @@ -0,0 +1,65 @@ +on post-fs +# +# Connectivity related modules and character device nodes (Begin) +# + #for 662x_launcher + chmod 0660 /dev/ttyMT2 + chown system system /dev/ttyMT2 + + # STP, SDIO, WMT, GPS, FM and BT Driver +# insmod /system/lib/modules/mtk_hif_sdio.ko +# insmod /system/lib/modules/mtk_stp_wmt.ko +# insmod /system/lib/modules/mtk_stp_uart.ko +# insmod /system/lib/modules/mtk_stp_gps.ko +# insmod /system/lib/modules/mtk_stp_bt.ko +# insmod /system/lib/modules/mtk_fm_drv.ko +# insmod /system/lib/modules/mtk_fm_priv.ko +# insmod /system/lib/modules/mtk_wmt_wifi.ko + + insmod /system/lib/modules/mtk_wmt_detect.ko + + # Create char device file for WMT, GPS, BT, FM, WIFI + mknod /dev/stpwmt c 190 0; + mknod /dev/stpgps c 191 0; + mknod /dev/stpbt c 192 0; + mknod /dev/fm c 193 0; + chmod 0660 /dev/stpwmt + chown system system /dev/stpwmt + chmod 0660 /dev/wmtdetect + chown system system /dev/wmtdetect + + # FM Radio device, FIXME: this is not a proper way to set permissions + chmod 0666 /dev/fm + + mknod /dev/wmtWifi c 153 0 + chmod 0666 /dev/wmtWifi + chmod 0660 /dev/stpgps + chmod 0660 /dev/stpbt + chown bluetooth radio /dev/stpbt + + # Load WiFi Driver + #insmod /system/lib/modules/wlan.ko + +# +# Connectivity related modules and character device nodes (Ends) +# + +on boot + + +# +# Connectivity related services (Begin) +# + +service wmtLoader /system/bin/wmt_loader + user root + group root + oneshot + +service conn_launcher /system/bin/6620_launcher -p /system/etc/firmware/ + user system + group system + +# +# Connectivity related services (End) +# diff --git a/rootdir/meta_init.rc b/rootdir/meta_init.rc new file mode 100644 index 0000000..bdadd70 --- /dev/null +++ b/rootdir/meta_init.rc @@ -0,0 +1,497 @@ +# Copyright (C) 2012 The Android Open Source Project +# +# IMPORTANT: Do not create world writable files or directories. +# This is a common source of Android security bugs. +# +import /init.environ.rc +import init.ssd.rc +import init.no_ssd.rc +import init.ssd_nomuser.rc +import init.fon.rc +import init.trustonic.rc + +on early-init + # Set init and its forked children's oom_adj. + write /proc/1/oom_score_adj -1000 + + # Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls. + write /sys/fs/selinux/checkreqprot 0 + + # Set the security context for the init process. + # This should occur before anything else (e.g. ueventd) is started. + setcon u:r:init:s0 + + # Set the security context of /adb_keys if present. + restorecon /adb_keys + + start ueventd + +# create mountpoints + mkdir /mnt 0775 root system + +on init + sysclktz 0 + +loglevel 5 + write /proc/bootprof "INIT: on init start" + + # Backward compatibility. + symlink /system/etc /etc + symlink /sys/kernel/debug /d + + # Link /vendor to /system/vendor for devices without a vendor partition. + symlink /system/vendor /vendor + +# Temp Backward compatibility + symlink /dev/block/platform/mtk-msdc.0/by-name/boot /dev/bootimg + symlink /dev/block/platform/mtk-msdc.0/by-name/recovery /dev/recovery + symlink /dev/block/platform/mtk-msdc.0/by-name/secro /dev/sec_ro + symlink /dev/block/platform/mtk-msdc.0/by-name/kb /dev/kb + symlink /dev/block/platform/mtk-msdc.0/by-name/dkb /dev/dkb + symlink /dev/block/platform/mtk-msdc.0/by-name/seccfg /dev/seccfg + symlink /dev/block/platform/mtk-msdc.0/by-name/proinfo /dev/pro_info + symlink /dev/block/platform/mtk-msdc.0/by-name/nvram /dev/nvram + symlink /dev/block/platform/mtk-msdc.0/by-name/para /dev/misc + symlink /dev/block/platform/mtk-msdc.0/by-name/logo /dev/logo +# Create cgroup mount point for cpu accounting + mkdir /acct + mount cgroup none /acct cpuacct + mkdir /acct/uid + + mkdir /system + mkdir /data 0771 system system + mkdir /cache 0770 system cache + mkdir /config 0500 root root + + # Mount staging areas for devices managed by vold + # See storage config details at http://source.android.com/tech/storage/ + mkdir /mnt 0755 root system + mount tmpfs tmpfs /mnt mode=0755,uid=0,gid=1000 + restorecon_recursive /mnt + # Support legacy paths + symlink /sdcard /mnt/sdcard + + + mkdir /mnt/secure 0700 root root + mkdir /mnt/secure/asec 0700 root root + mkdir /mnt/asec 0755 root system + mkdir /mnt/obb 0755 root system + mkdir /mnt/media_rw 0750 root media_rw + mkdir /mnt/user 0755 root root + mkdir /mnt/user/0 0755 root root + mkdir /mnt/expand 0771 system system + + # Storage views to support runtime permissions + mkdir /storage 0755 root root + mkdir /mnt/runtime 0700 root root + mkdir /mnt/runtime/default 0755 root root + mkdir /mnt/runtime/default/self 0755 root root + mkdir /mnt/runtime/read 0755 root root + mkdir /mnt/runtime/read/self 0755 root root + mkdir /mnt/runtime/write 0755 root root + mkdir /mnt/runtime/write/self 0755 root root + + # Symlink to keep legacy apps working in multi-user world + symlink /storage/self/primary /sdcard + symlink /mnt/user/0/primary /mnt/runtime/default/self/primary + + write /proc/sys/kernel/panic_on_oops 1 + write /proc/sys/kernel/hung_task_timeout_secs 0 + write /proc/cpu/alignment 4 + write /proc/sys/kernel/sched_latency_ns 10000000 + write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 + write /proc/sys/kernel/sched_compat_yield 1 + +#INTERNAL_START + mkdir /protect_f 0771 system system + mkdir /protect_s 0771 system system + #create mountpoint for persist partition + mkdir /persist 0771 system system + #Create nvdata mount point + mkdir /nvdata 0771 system system + + #Create CIP mount point + mkdir /custom + + # See storage config details at http://source.android.com/tech/storage/ + mkdir /mnt/shell 0700 shell shell + mkdir /mnt/media_rw 0700 media_rw media_rw + mkdir /storage 0751 root sdcard_r + + mkdir /mnt/cd-rom 0000 system system + + +# Healthd can trigger a full boot from charger mode by signaling this +# property when the power button is held. +on property:sys.boot_from_charger_mode=1 + class_stop charger + trigger late-init + +# Load properties from /system/ + /factory after fs mount. +on load_all_props_action + load_system_props + load_persist_props + +# Mount filesystems and start core system services. +on late-init + trigger early-fs + trigger fs + trigger post-fs + trigger post-fs-data + + # Load properties from /system/ + /factory after fs mount. Place + # this in another action so that the load will be scheduled after the prior + # issued fs triggers have completed. + trigger load_all_props_action + + trigger early-boot + trigger boot + +on fs + write /proc/bootprof "INIT:Mount_START" + mount_all /fstab.mt6735 + + #change partition permissions + exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/boot + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/boot + exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/recovery + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/recovery + exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/secro + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/secro + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/seccfg + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/seccfg + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/proinfo + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/proinfo + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/otp + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/otp + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/nvram + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/nvram + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/para + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/para + exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/logo + exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/logo + write /proc/bootprof "INIT:Mount_END" + +on post-fs + # once everything is setup, no need to modify / + mount rootfs rootfs / ro remount + + # We chown/chmod /cache again so because mount is run as root + defaults + chown system cache /cache + chmod 0770 /cache + # We restorecon /cache in case the cache partition has been reset. + restorecon_recursive /cache + + #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks + chown root system /proc/kmsg + chmod 0440 /proc/kmsg + + # make the selinux kernel policy world-readable + chmod 0444 /sys/fs/selinux/policy + + # create the lost+found directories, so as to enforce our permissions + mkdir /cache/lost+found 0770 root root + +#INTERNAL_START + chown system system /protect_f + chmod 0770 /protect_f + + chown system system /protect_s + chmod 0770 /protect_s + + chown system system /persist + chmod 0770 /persist + + chown system system /custom + chmod 0770 /custom +#INTERNAL_END + +on post-fs-data + # We chown/chmod /data again so because mount is run as root + defaults + chown system system /data + chmod 0771 /data + # We restorecon /data in case the userdata partition has been reset. + restorecon /data + + # create basic filesystem structure + chown root system /nvdata + chmod 2770 /nvdata + symlink /nvdata /data/nvram + + # Set SELinux security contexts on upgrade or policy update. + restorecon_recursive /nvdata + + mkdir /data/misc 01771 system misc + mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth + mkdir /data/misc/bluedroid 02770 bluetooth net_bt_stack + # Fix the access permissions and group ownership for 'bt_config.conf' + chmod 0660 /data/misc/bluedroid/bt_config.conf + chown bluetooth net_bt_stack /data/misc/bluedroid/bt_config.conf + mkdir /data/misc/bluetooth 0770 system system + mkdir /data/misc/keystore 0700 keystore keystore + mkdir /data/misc/keychain 0771 system system + mkdir /data/misc/vpn 0770 system vpn + mkdir /data/misc/systemkeys 0700 system system + mkdir /data/misc/wifi 0770 wifi wifi + mkdir /data/misc/wifi/sockets 0770 wifi wifi + mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi + mkdir /data/misc/ethernet 0770 system system + mkdir /data/misc/dhcp 0770 dhcp dhcp + mkdir /data/misc/user 0771 root root + mkdir /data/misc/perfprofd 0775 root root + # give system access to wpa_supplicant.conf for backup and restore + mkdir /data/misc/wifi 0770 wifi wifi + chmod 0660 /data/misc/wifi/wpa_supplicant.conf + chmod 0660 /data/misc/wifi/p2p_supplicant.conf + mkdir /data/local 0751 root root + mkdir /data/misc/media 0700 media media + mkdir /data/misc/vold 0700 root root + + # For security reasons, /data/local/tmp should always be empty. + # Do not place files or directories in /data/local/tmp + mkdir /data/local/tmp 0771 shell shell + mkdir /data/data 0771 system system + mkdir /data/app-private 0771 system system + mkdir /data/app-asec 0700 root root + mkdir /data/app 0771 system system + mkdir /data/property 0700 root root + mkdir /data/tombstones 0771 system system + mkdir /data/ssh 0750 root shell + mkdir /data/ssh/empty 0700 root root + + # create the lost+found directories, so as to enforce our permissions + mkdir /data/lost+found 0770 + + # double check the perms, in case lost+found already exists, and set owner + chown root root /data/lost+found + chmod 0770 /data/lost+found + + # H264 Decoder + chmod 777 /dev/MT6516_H264_DEC + + # Internal SRAM Driver + chmod 777 /dev/MT6516_Int_SRAM + + # MM QUEUE Driver + chmod 777 /dev/MT6516_MM_QUEUE + + # MPEG4 Decoder + chmod 777 /dev/MT6516_MP4_DEC + + # MPEG4 Encoder + chmod 777 /dev/MT6516_MP4_ENC + + # OpenCORE proxy config + chmod 0666 /data/http-proxy-cfg + + # OpenCORE player config + chmod 0666 /etc/player.cfg + + # WiFi + mkdir /data/misc/wifi 0770 system wifi + mkdir /data/misc/wifi/sockets 0770 system wifi + mkdir /data/misc/dhcp 0770 dhcp dhcp + chown dhcp dhcp /data/misc/dhcp + #give system access to rfkill device node + chmod 0660 /sys/class/rfkill/rfkill1/state + chown system system /sys/class/rfkill/rfkill1/state + # Turn off wifi by default + write /sys/class/rfkill/rfkill1/state 0 + + #otp + chmod 0660 /dev/otp + chown root system /dev/otp + + # Touch Panel + chown system system /sys/touchpanel/calibration + chmod 0660 /sys/touchpanel/calibration + + chmod 0777 /dev/pmem_multimedia + chmod 0777 /dev/mt6516-isp + chmod 0777 /dev/mt6516-IDP + chmod 0777 /dev/mt9p012 + chmod 0777 /dev/mt6516_jpeg + # RTC + mkdir /data/misc/rtc 0770 system system + + + # M4U + #insmod /system/lib/modules/m4u.ko + #mknod /dev/M4U_device c 188 0 + chmod 0444 /dev/M4U_device + + # Sensor + chmod 0666 /dev/sensor + + # GPIO + chmod 0666 /dev/mtgpio + + # Android SEC related device nodes + chmod 0660 /dev/sec + chown root system /dev/sec + + # device info interface + chmod 0440 /dev/devmap + chown root system /dev/devmap + + + #change partition permission + exec /system/etc/partition_permission.sh + + chmod 0666 /dev/exm0 + + # Separate location for storing security policy files on data + mkdir /data/security 0711 system system + + # Reload policy from /data/security if present. + setprop selinux.reload_policy 1 + + # Set SELinux security contexts on upgrade or policy update. + restorecon_recursive /data + + # If there is no fs-post-data action in the init.<device>.rc file, you + # must uncomment this line, otherwise encrypted filesystems + # won't work. + # Set indication (checked by vold) that we have finished this action + setprop vold.post_fs_data_done 1 + +on boot + + +# basic network init + ifup lo + hostname localhost + domainname localdomain + + class_start default + class_start core + +on nonencrypted + class_start main + class_start late_start + +on property:vold.decrypt=trigger_default_encryption + start defaultcrypto + +on property:vold.decrypt=trigger_encryption + start surfaceflinger + start encrypt + +on property:vold.decrypt=trigger_reset_main + class_reset main + +on property:vold.decrypt=trigger_load_persist_props + load_persist_props + +on property:vold.decrypt=trigger_post_fs_data + trigger post-fs-data + +on property:vold.decrypt=trigger_restart_min_framework + class_start main + +on property:vold.decrypt=trigger_restart_framework + start nvram_daemon + class_start main + class_start late_start + start permission_check + +on property:vold.decrypt=trigger_shutdown_framework + class_reset late_start + class_reset main + +service ueventd /sbin/ueventd + class core + critical + seclabel u:r:ueventd:s0 + +service logd /system/bin/logd + class core + socket logd stream 0666 logd logd + socket logdr seqpacket 0666 logd logd + socket logdw dgram 0222 logd logd + seclabel u:r:logd:s0 + +service console /system/bin/sh + class core + console + disabled + user shell + group shell log + seclabel u:r:shell:s0 + +on property:sys.powerctl=* + powerctl ${sys.powerctl} + +on property:ro.debuggable=1 + start console + +# adbd is controlled via property triggers in init.<platform>.usb.rc +service adbd /sbin/adbd --root_seclabel=u:r:su:s0 + class core + socket adbd stream 660 system system + disabled + seclabel u:r:adbd:s0 + +service vold /system/bin/vold + class core + socket vold stream 0660 root mount + ioprio be 2 + +service debuggerd /system/bin/debuggerd + class main + +service debuggerd64 /system/bin/debuggerd64 + class main + +# One shot invocation to deal with encrypted volume. +service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted + disabled + oneshot + # vold will set vold.decrypt to trigger_restart_framework (default + # encryption) or trigger_restart_min_framework (other encryption) + +# One shot invocation to encrypt unencrypted volumes +service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default + disabled + oneshot + # vold will set vold.decrypt to trigger_restart_framework (default + # encryption) + +service meta_tst /system/bin/meta_tst + +service nvram_daemon /system/bin/nvram_daemon + class main + user root + group system + oneshot + +service mobile_log_d /system/bin/mobile_log_d + class main + +on property:ro.boot.mblogenable=0 + stop mobile_log_d + +on property:ro.boot.mblogenable=1 + start mobile_log_d + +#mass_storage,adb,acm +on property:ro.boot.usbconfig=0 + write /sys/class/android_usb/android0/iSerial $ro.serialno + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/idVendor 0e8d + write /sys/class/android_usb/android0/idProduct 2006 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions mass_storage,adb,acm + write /sys/class/android_usb/android0/enable 1 + start adbd + +#acm +on property:ro.boot.usbconfig=1 + write /sys/class/android_usb/android0/enable 0 + write /sys/class/android_usb/android0/iSerial " " + write /sys/class/android_usb/android0/idVendor 0e8d + write /sys/class/android_usb/android0/idProduct 2007 + write /sys/class/android_usb/android0/f_acm/instances 1 + write /sys/class/android_usb/android0/functions acm + write /sys/class/android_usb/android0/bDeviceClass 02 + write /sys/class/android_usb/android0/enable 1 diff --git a/rootdir/recovery.fstab b/rootdir/recovery.fstab new file mode 100644 index 0000000..613895c --- /dev/null +++ b/rootdir/recovery.fstab @@ -0,0 +1,19 @@ +# Android fstab file. +# 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 + +#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags> + +/dev/block/platform/mtk-msdc.0/by-name/boot /boot emmc defaults defaults +/dev/block/platform/mtk-msdc.0/by-name/nvram /nvram emmc defaults defaults +/dev/block/platform/mtk-msdc.0/by-name/recovery /recovery emmc defaults defaults + +/dev/block/platform/mtk-msdc.0/by-name/system /system ext4 ro,noatime wait +/dev/block/platform/mtk-msdc.0/by-name/cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait +/dev/block/platform/mtk-msdc.0/by-name/userdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check,encryptable=footer +/dev/block/platform/mtk-msdc.0/by-name/protect1 /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check +/dev/block/platform/mtk-msdc.0/by-name/protect2 /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check + +# vold-managed volumes +/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:16 +/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto diff --git a/rootdir/ueventd.mt6735.rc b/rootdir/ueventd.mt6735.rc new file mode 100644 index 0000000..fe0d94d --- /dev/null +++ b/rootdir/ueventd.mt6735.rc @@ -0,0 +1,305 @@ +subsystem adf + devname uevent_devname + +/dev/null 0666 root root +/dev/zero 0666 root root +/dev/full 0666 root root +/dev/ptmx 0666 root root +/dev/tty 0666 root root +/dev/random 0666 root root +/dev/urandom 0666 root root +# Make HW RNG readable by group system to let EntropyMixer read it. +/dev/hw_random 0440 root system +/dev/ashmem 0666 root root +/dev/binder 0666 root root + + #change partition permission +/dev/preloader 0640 root system +/dev/bootimg 0640 root system +/dev/recovery 0660 root system +/dev/sec_ro 0640 root system +/dev/kb 0660 root system +/dev/dkb 0660 root system +/dev/seccfg 0660 root system +/dev/pro_info 0660 root system +/dev/otp 0660 root system +/dev/nvram 0660 root system +/dev/misc 0660 root system +/dev/misc2 0660 root system +/dev/block/platform/mtk-msdc.0/by-name/misc2 0660 root system +/dev/block/mmcblk0 0660 root system +/dev/block/mmcblk0boot0 0660 root system +/dev/block/mmcblk0boot1 0660 root system +/dev/misc-sd 0660 root system + + +# Connectivity +/dev/stpwmt 0660 system system +/dev/wmtdetect 0660 system system + +# BT +/dev/stpbt 0660 bluetooth net_bt_stack + +# GPS +/dev/stpgps 0660 gps gps +/dev/gps 0660 gps system + +# ANT +/dev/stpant 0660 system system + +# WIFI +/dev/wmtWifi 0660 system system + +# MTK BTIF driver +/dev/btif 0600 system system + +# Trusty driver +/dev/trusty-ipc-dev0 0660 system keystore + +# add the read write right of ttyUSB* +/dev/bus/usb/* 0660 root usb +/dev/ttyUSB0 0660 radio radio +/dev/ttyUSB1 0660 radio radio +/dev/ttyUSB2 0660 radio radio +/dev/ttyUSB3 0660 radio radio +/dev/ttyUSB4 0660 radio radio + +# Anyone can read the logs, but if they're not in the "logs" +# group, then they'll only see log entries for their UID. +/dev/xLog 0600 root root +/dev/log/* 0666 root log +/dev/log/ksystem 0600 root log + +# the msm hw3d client device node is world writable/readable +/dev/msm_hw3dc 0666 root root + +# the DIAG device node is not world writable/readable. +/dev/diag 0660 system qcom_diag + +# gpu driver for adreno200 is globally accessible +/dev/kgsl 0666 root root + +# kms driver for drm based gpu +/dev/dri/* 0666 root graphics + +# these should not be world writable +/dev/diag 0660 radio radio +/dev/diag_arm9 0660 radio radio +/dev/android_adb 0660 adb adb +/dev/android_adb_enable 0660 adb adb +/dev/ttyMSM0 0600 bluetooth bluetooth +/dev/uhid 0660 system net_bt_stack +/dev/uinput 0660 system net_bt_stack +/dev/alarm 0664 system radio +/dev/rtc0 0640 system system +/dev/tty0 0660 root system +/dev/graphics/* 0660 system graphics +/dev/msm_hw3dm 0660 system graphics +/dev/input/* 0660 root input +/dev/eac 0660 root audio +/dev/cam 0660 root camera +/dev/pmem 0660 system graphics +/dev/pmem_adsp* 0660 system audio +/dev/pmem_camera* 0660 system camera +/dev/oncrpc/* 0660 root system +/dev/adsp/* 0660 system audio +/dev/snd/* 0660 system audio +/dev/mt9t013 0660 system system +/dev/msm_camera/* 0660 system system +/dev/akm8976_daemon 0640 compass system +/dev/akm8976_aot 0640 compass system +/dev/akm8973_daemon 0640 compass system +/dev/akm8973_aot 0640 compass system +/dev/bma150 0640 compass system +/dev/cm3602 0640 compass system +/dev/akm8976_pffd 0640 compass system +/dev/lightsensor 0640 system system +/dev/msm_pcm_out* 0660 system audio +/dev/msm_pcm_in* 0660 system audio +/dev/msm_pcm_ctl* 0660 system audio +/dev/msm_snd* 0660 system audio +/dev/msm_mp3* 0660 system audio +/dev/audience_a1026* 0660 system audio +/dev/tpa2018d1* 0660 system audio +/dev/msm_audpre 0660 system audio +/dev/msm_audio_ctl 0660 system audio +/dev/htc-acoustic 0660 system audio +/dev/vdec 0660 system audio +/dev/q6venc 0660 system audio +/dev/snd/dsp 0660 system audio +/dev/snd/dsp1 0660 system audio +/dev/snd/mixer 0660 system audio +/dev/smd0 0640 radio radio +/dev/qmi 0640 radio radio +/dev/qmi0 0640 radio radio +/dev/qmi1 0640 radio radio +/dev/qmi2 0640 radio radio +/dev/bus/usb/* 0660 root usb +/dev/mtp_usb 0660 root mtp +/dev/usb_accessory 0660 root usb +/dev/tun 0660 system vpn + +/dev/ccci* 0660 radio radio +/dev/ttyC* 0660 radio radio +/sys/kernel/ccci modem_info 0644 radio radio +/sys/kernel/ccci md1_postfix 0644 radio radio +/sys/kernel/ccci md2_postfix 0644 radio radio +/dev/eemcs* 0660 radio radio +/dev/emd* 0660 radio radio +/dev/ccci_pcm_rx 0660 media media +/dev/ccci_pcm_tx 0660 media media +/dev/ccci_aud 0660 media media +/dev/ccci2_aud 0660 media media +/dev/eemcs_aud 0660 media media + +# SGX device node +/dev/pvrsrvkm 0666 root root +/dev/pvr_sync 0666 root root + +# CDMA radio interface MUX +/dev/ts0710mux* 0640 radio radio +/dev/ppp 0660 radio vpn + +# sysfs properties +/sys/devices/platform/trusty.* trusty_version 0440 root log +/sys/devices/virtual/input/input* enable 0660 root input +/sys/devices/virtual/input/input* poll_delay 0660 root input +/sys/devices/virtual/usb_composite/* enable 0664 root system +/sys/devices/system/cpu/cpu* cpufreq/scaling_max_freq 0664 system system +/sys/devices/system/cpu/cpu* cpufreq/scaling_min_freq 0664 system system +/sys/devices/system/cpu/cpu* cpufreq/scaling_governor 0664 system system + +/sys/devices/system/cpu/cpufreq ondemand/boostfreq 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/boostpulse 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/boosttime 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/down_differential 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/down_differential_multi_core 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/ignore_nice_load 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/input_boost 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/io_is_busy 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/optimal_freq 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/powersave_bias 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/sampling_down_factor 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/sampling_rate 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/sampling_rate_min 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/sync_freq 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/up_threshold 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/up_threshold_any_cpu_load 0664 system system +/sys/devices/system/cpu/cpufreq ondemand/up_threshold_multi_core 0664 system system + +/sys/devices/system/cpu/cpufreq interactive/above_hispeed_delay 0664 system system +/sys/devices/system/cpu/cpufreq interactive/align_windows 0664 system system +/sys/devices/system/cpu/cpufreq interactive/boost 0664 system system +/sys/devices/system/cpu/cpufreq interactive/boostpulse 0664 system system +/sys/devices/system/cpu/cpufreq interactive/boostpulse_duration 0664 system system +/sys/devices/system/cpu/cpufreq interactive/go_hispeed_load 0664 system system +/sys/devices/system/cpu/cpufreq interactive/hispeed_freq 0664 system system +/sys/devices/system/cpu/cpufreq interactive/io_is_busy 0664 system system +/sys/devices/system/cpu/cpufreq interactive/max_freq_hysteresis 0664 system system +/sys/devices/system/cpu/cpufreq interactive/min_sample_rate 0664 system system +/sys/devices/system/cpu/cpufreq interactive/min_sample_time 0664 system system +/sys/devices/system/cpu/cpufreq interactive/sampling_down_factor 0664 system system +/sys/devices/system/cpu/cpufreq interactive/sync_freq 0664 system system +/sys/devices/system/cpu/cpufreq interactive/target_loads 0664 system system +/sys/devices/system/cpu/cpufreq interactive/timer_rate 0664 system system +/sys/devices/system/cpu/cpufreq interactive/timer_slack 0664 system system +/sys/devices/system/cpu/cpufreq interactive/up_threshold_any_cpu_freq 0664 system system +/sys/devices/system/cpu/cpufreq interactive/up_threshold_any_cpu_load 0664 system system +/sys/devices/platform/leds-mt65xx/leds/green delay_on 0664 system system +/sys/devices/platform/leds-mt65xx/leds/green delay_off 0664 system system +/sys/devices/platform/leds-mt65xx/leds/red delay_on 0664 system system +/sys/devices/platform/leds-mt65xx/leds/red delay_off 0664 system system +/sys/devices/platform/leds-mt65xx/leds/blue delay_on 0664 system system +/sys/devices/platform/leds-mt65xx/leds/blue delay_off 0664 system system +/sys/devices/platform/leds-mt65xx/leds/yellow delay_on 0664 system system +/sys/devices/platform/leds-mt65xx/leds/yellow delay_off 0664 system system +/sys/devices/platform/leds-mt65xx/leds/white delay_on 0664 system system +/sys/devices/platform/leds-mt65xx/leds/white delay_off 0664 system system +/sys/devices/platform/leds-mt65xx/leds/cyan delay_on 0664 system system +/sys/devices/platform/leds-mt65xx/leds/cyan delay_off 0664 system system +/sys/devices/platform/leds-mt65xx/leds/violet delay_on 0664 system system +/sys/devices/platform/leds-mt65xx/leds/violet delay_off 0664 system system + +#GPS +/dev/gps 0660 gps system + +#GPIO +/dev/mtgpio 0600 radio root + +#MTK BTIF driver +/dev/btif 0600 system system + +#FOR VIA MODEM +/dev/ttySDIO* 0660 radio sdcard_rw +/dev/ttyRB* 0660 radio radio + +# Mali node +/dev/mali 0666 system graphics + +#touch +/dev/touch 0660 root system +/dev/hotknot 0660 root system + +#hang_detect +/dev/RT_Monitor 0600 system system +/dev/kick_powerkey 0600 system system + +#MTK In-House TEE +/dev/ttyACM0 0660 radio radio + +# for lsm6ds3 + +#common sensors files +/sys/devices/iio:device* buffer/enable 0666 system system +/sys/devices/iio:device* buffer/length 0666 system system +/sys/devices/iio:device* flush 0666 system system +/sys/devices/iio:device* self_test 0666 system system +/sys/devices/iio:device* sampling_frequency 0666 system system +/sys/devices/iio:device* scan_elements/in_timestamp_en 0666 system system + +#accelerometer sensor +/sys/devices/iio:device* scan_elements/in_accel_x_en 0666 system system +/sys/devices/iio:device* scan_elements/in_accel_y_en 0666 system system +/sys/devices/iio:device* scan_elements/in_accel_z_en 0666 system system +/sys/devices/iio:device* in_accel_x_scale 0666 system system +/sys/devices/iio:device* in_accel_y_scale 0666 system system +/sys/devices/iio:device* in_accel_z_scale 0666 system system +/sys/devices/iio:device* sensor_phone_calling 0666 system system + +#magnetometer sensor +/sys/devices/iio:device* scan_elements/in_magn_x_en 0666 system system +/sys/devices/iio:device* scan_elements/in_magn_y_en 0666 system system +/sys/devices/iio:device* scan_elements/in_magn_z_en 0666 system system +/sys/devices/iio:device* in_magn_x_scale 0666 system system +/sys/devices/iio:device* in_magn_y_scale 0666 system system +/sys/devices/iio:device* in_magn_z_scale 0666 system system + +#light sensor +/sys/devices/iio:device* scan_elements/in_illuminance_x_en 0666 system system +/sys/devices/iio:device* in_illuminance_x_scale 0666 system system + +#proximity sensor +/sys/devices/iio:device* scan_elements/in_proximity_x_en 0666 system system +/sys/devices/iio:device* in_proximity_x_scale 0666 system system + +#gyroscope sensor +/sys/devices/iio:device* scan_elements/in_anglvel_x_en 0666 system system +/sys/devices/iio:device* scan_elements/in_anglvel_y_en 0666 system system +/sys/devices/iio:device* scan_elements/in_anglvel_z_en 0666 system system +/sys/devices/iio:device* in_anglvel_x_scale 0666 system system +/sys/devices/iio:device* in_anglvel_y_scale 0666 system system +/sys/devices/iio:device* in_anglvel_z_scale 0666 system system + +#step counter sensor +/sys/devices/iio:device* max_delivery_rate 0666 system system +/sys/devices/iio:device* reset_counter 0666 system system +/sys/devices/iio:device* scan_elements/in_step_counter_en 0666 system system + +#significant motion sensor +/sys/devices/iio:device* scan_elements/in_sign_motion_en 0666 system system + +#step detector sensor +/sys/devices/iio:device* scan_elements/in_step_detector_en 0666 system system + +#tilt sensor +/sys/devices/iio:device* scan_elements/in_tilt_en 0666 system system diff --git a/sepolicy/BGW.te b/sepolicy/BGW.te new file mode 100644 index 0000000..d9ecfcd --- /dev/null +++ b/sepolicy/BGW.te @@ -0,0 +1,23 @@ +# ============================================== +# Policy File of /system/xbin/BGW Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type BGW_exec , exec_type, file_type; +type BGW ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive BGW; +init_daemon_domain(BGW) + +#============= BGW ============== +allow BGW ccci_device:chr_file { read write open }; +allow BGW self:netlink_socket { read bind create write }; +allow BGW stpwmt_device:chr_file { read write open }; diff --git a/sepolicy/GoogleOtaBinder.te b/sepolicy/GoogleOtaBinder.te new file mode 100644 index 0000000..8112e7f --- /dev/null +++ b/sepolicy/GoogleOtaBinder.te @@ -0,0 +1,41 @@ +# ============================================== +# Policy File of /system/binGoogleOtaBinder Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type GoogleOtaBinder_exec , exec_type, file_type; +type GoogleOtaBinder ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive GoogleOtaBinder; +init_daemon_domain(GoogleOtaBinder) +#unconfined_domain(GoogleOtaBinder) + +# Date : 2014/09/10 +# Operation : Migration +# Purpose : allow Binder IPC +binder_use(GoogleOtaBinder) +binder_service(GoogleOtaBinder) + +allow GoogleOtaBinder ota_agent_service:service_manager add; +# /dev/block/mmcblko +allow GoogleOtaBinder platformblk_device:blk_file { write read open }; + +allow GoogleOtaBinder block_device:dir search; +allow GoogleOtaBinder platformblk_device:dir search; +#/dev/misc +allow GoogleOtaBinder misc_device:chr_file { write read open }; diff --git a/sepolicy/MtkCodecService.te b/sepolicy/MtkCodecService.te new file mode 100644 index 0000000..f373487 --- /dev/null +++ b/sepolicy/MtkCodecService.te @@ -0,0 +1,36 @@ +# ============================================== +# Policy File of /system/bin/MtkCodecService Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type MtkCodecService_exec , exec_type, file_type; +type MtkCodecService ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + + +# Date : 2014/09/10 +# Operation : Migration +# Purpose : allow Binder IPC +binder_use(MtkCodecService) + +# Date : +# Operation : Migration +# Purpose : allow Binder IPC + +# Date : W14.43 +# Operation : selinux inforce +# Purpose : for L : add for ape playback + +init_daemon_domain(MtkCodecService) +allow MtkCodecService mediaserver:binder call; +allow MtkCodecService mediaserver:fd use; +allow MtkCodecService mtk_codec_service_service:service_manager add; +allow MtkCodecService self:capability{setuid sys_nice}; +allow MtkCodecService dumpstate:fd use;
\ No newline at end of file diff --git a/sepolicy/aal.te b/sepolicy/aal.te new file mode 100644 index 0000000..bbaa1bb --- /dev/null +++ b/sepolicy/aal.te @@ -0,0 +1,40 @@ +# ============================================== +# Policy File of /system/binaal Executable File + +# ============================================== +# Type Declaration +# ============================================== + +type aal_exec , exec_type, file_type; +type aal ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive aal; +init_daemon_domain(aal) +# unconfined_domain(aal) + +# Date : 2014/09/09 (or WK14.37) +# Operation : Migration +# Purpose : allow Binder IPC +binder_use(aal) +binder_call(aal, binderservicedomain) +binder_service(aal) + +# Date : WK14.41 +# Operation : Migration +# Purpose : All enforing mode +allow aal aal_als_device:chr_file { read open ioctl }; +allow aal graphics_device:chr_file { read open ioctl }; +allow aal graphics_device:dir search; +allow aal aal_service:service_manager add; diff --git a/sepolicy/adbd.te b/sepolicy/adbd.te new file mode 100644 index 0000000..e11c9ed --- /dev/null +++ b/sepolicy/adbd.te @@ -0,0 +1,51 @@ +# ============================================== +# MTK Policy Rule +# ============ + + +#violate neverallow rule +#allow adbd block_device:blk_file { read ioctl open }; + +#violate neverallow rule +#allow adbd labeledfs:filesystem remount; + +# Date : WK14.27 +# Operation : KK.AOSP SQC +# Purpose : MTK snapshot-related mechanism +allow adbd graphics_device:chr_file { read ioctl open }; + +# Date : WK14.27 +# Operation : KK.AOSP SQC +# Purpose : A process wants to access a specific path. For example : shell:ls -l /data/data/ +allow adbd platform_app_data_file:dir { write getattr add_name }; +allow adbd platform_app_data_file:file { read create open }; +allow adbd radio_data_file:file { read open }; + +# Date : WK14.27 +# Operation : KK.AOSP SQC +# Purpose : shell:logcat -v threadtime +allow adbd self:capability2 syslog; + +allow adbd block_device:dir search; +allow adbd kernel:process setsched; +allow adbd self:capability { net_raw ipc_lock dac_override }; +allow adbd system_data_file:dir { write remove_name add_name }; +allow adbd tmpfs:lnk_file read; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow adbd qemu_pipe_device:chr_file rw_file_perms; + +# user load adb pull /data/aee_exp db +allow adbd aee_exp_data_file:dir r_dir_perms; +allow adbd aee_exp_data_file:file r_file_perms; + +# call screencap by DDMS +allow adbd surfaceflinger:dir search; +allow adbd surfaceflinger:file r_file_perms; + +# Date : WK14.48 +# Operation : L0 SQC +# Purpose : push/pull files to specific folders +allow adbd sf_rtt_file:dir getattr;
\ No newline at end of file diff --git a/sepolicy/aee_core_forwarder.te b/sepolicy/aee_core_forwarder.te new file mode 100644 index 0000000..b7f0b5c --- /dev/null +++ b/sepolicy/aee_core_forwarder.te @@ -0,0 +1,52 @@ +# ============================================== +# Policy File of /system/binaee_core_forwarder Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type aee_core_forwarder_exec , exec_type, file_type; +type aee_core_forwarder ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(aee_core_forwarder) + +#/data/core/zcorexxx.zip +allow aee_core_forwarder aee_core_data_file:dir relabelto; +allow aee_core_forwarder aee_core_data_file:dir create_dir_perms; +allow aee_core_forwarder aee_core_data_file:file create_file_perms; +allow aee_core_forwarder system_data_file:dir { write relabelfrom create add_name }; + +#mkdir /sdcard/mtklog/aee_exp£¬and write /sdcard/mtklog/aee_exp/zcorexxx.zip +allow aee_core_forwarder fuse:dir create_dir_perms; +allow aee_core_forwarder fuse:file create_file_perms; +allow aee_core_forwarder tmpfs:lnk_file read; +allow aee_core_forwarder self:capability fsetid; +allow aee_core_forwarder aee_exp_data_file:dir create_dir_perms; +allow aee_core_forwarder aee_exp_data_file:file create_file_perms; + +#mkdir(path, mode) +allow aee_core_forwarder self:capability dac_override; + +#read STDIN_FILENO +allow aee_core_forwarder kernel:fifo_file read; + +#read /proc/<pid>/cmdline +allow aee_core_forwarder domain:dir r_dir_perms; +allow aee_core_forwarder domain:file r_file_perms; + +#read +allow aee_core_forwarder sysfs_wake_lock:file { read write open }; + diff --git a/sepolicy/akmd8963.te b/sepolicy/akmd8963.te new file mode 100644 index 0000000..699d0bd --- /dev/null +++ b/sepolicy/akmd8963.te @@ -0,0 +1,37 @@ +# ============================================== +# Policy File of /system/binakmd8963 Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type akmd8963_exec , exec_type, file_type; +type akmd8963 ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive akmd8963; +init_daemon_domain(akmd8963) +#unconfined_domain(akmd8963) +# Data : WK14.43 +# Operation : Migration +# Purpose : M-sensor daemon for access driver node +allow akmd8963 msensor_device:chr_file { open ioctl read write }; +allow akmd8963 gsensor_device:chr_file { open ioctl read write }; +allow akmd8963 input_device:dir { search open read write }; +allow akmd8963 input_device:file { open read }; +allow akmd8963 akmd8963_access_file1:file { open read write }; +allow akmd8963 akmd8963_access_file2:file { open read write}; +# Operate data partation directly, need modify later,e.g. use "data/misc/sensor". +allow akmd8963 system_data_file:dir { write add_name create setattr }; diff --git a/sepolicy/akmd8975.te b/sepolicy/akmd8975.te new file mode 100644 index 0000000..539a030 --- /dev/null +++ b/sepolicy/akmd8975.te @@ -0,0 +1,17 @@ +# ============================================== +# Policy File of /system/binakmd8975 Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type akmd8975_exec , exec_type, file_type; +type akmd8975 ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(akmd8975) diff --git a/sepolicy/ami304d.te b/sepolicy/ami304d.te new file mode 100644 index 0000000..cd45837 --- /dev/null +++ b/sepolicy/ami304d.te @@ -0,0 +1,16 @@ +# ============================================== +# Policy File of /system/binami304d Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type ami304d_exec , exec_type, file_type; +type ami304d ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(ami304d) diff --git a/sepolicy/app.te b/sepolicy/app.te new file mode 100644 index 0000000..eb509b2 --- /dev/null +++ b/sepolicy/app.te @@ -0,0 +1,13 @@ + + +# ============================================== +# MTK Policy Rule +# ============================================== + + +# Date: wk14.40 +# Operation : SQC +# Purpose : [ALPS01756200] wwop boot up fail +allow appdomain custom_file:dir { search getattr open read }; +allow appdomain custom_file:file { read open getattr}; + diff --git a/sepolicy/atci_service.te b/sepolicy/atci_service.te new file mode 100644 index 0000000..b98a146 --- /dev/null +++ b/sepolicy/atci_service.te @@ -0,0 +1,72 @@ +# ============================================== +# Policy File of /system/binatci_service Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type atci_service_exec , exec_type, file_type; +type atci_service ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== +init_daemon_domain(atci_service) + +# Date : 2014/09/09 (or WK14.37) +# Operation : Migration +# Purpose : allow Binder IPC +# atci_pq_cmd.cpp will call aal for runtime tuning +binder_use(atci_service) +binder_call(atci_service, aal) +binder_service(atci_service) +allow atci_service block_device:dir search; +allow atci_service platformblk_device:dir search; +allow atci_service platformblk_device:blk_file { open read write }; +allow atci_service system_data_file:dir write; +allow atci_service system_data_file:dir add_name; +allow atci_service system_data_file:sock_file create; +allow atci_service system_data_file:sock_file setattr; +allow atci_service self:capability chown; +allow atci_service system_data_file:dir remove_name; +allow atci_service system_data_file:sock_file unlink; +allow atci_service system_server:unix_dgram_socket sendto; +allow atci_service system_data_file:sock_file write; +allow atci_service misc2_device:chr_file { open read write }; +allow atci_service mt6605_device:chr_file { read write ioctl open getattr }; +allow atci_service nfc_socket:dir { write add_name remove_name search }; +allow atci_service nfc_socket:sock_file { create write unlink setattr }; +allow atci_service system_file:file execute_no_trans; + +allow atci_service self:capability { dac_read_search dac_override net_raw chown fsetid sys_nice net_admin fowner sys_admin }; +allow atci_service camera_isp_device:chr_file { read write ioctl open }; +allow atci_service graphics_device:chr_file { read write ioctl open }; +allow atci_service graphics_device:dir search; +allow atci_service kd_camera_hw_device:chr_file { read write ioctl open }; +allow atci_service self:capability { sys_nice ipc_lock }; +allow atci_service nvram_data_file:dir { write read open add_name remove_name search create getattr setattr }; +allow atci_service nvram_data_file:file { setattr read create write getattr unlink open append }; +allow atci_service nvram_device:chr_file { read write open ioctl }; +allow atci_service camera_isp_device:chr_file { read write ioctl open }; +allow atci_service camera_sysram_device:chr_file { read ioctl open }; +allow atci_service kd_camera_flashlight_device:chr_file { read write ioctl open }; +allow atci_service MTK_SMI_device:chr_file { open read write ioctl }; +allow atci_service system_server:binder call; +allow atci_service system_data_file:dir { write remove_name add_name }; +allow atci_service DW9714AF_device:chr_file { read write ioctl open }; +allow atci_service devmap_device:chr_file { open read write ioctl }; +allow atci_service fuse:dir { search write read open add_name remove_name create getattr setattr }; +allow atci_service fuse:file { setattr read create write getattr unlink open append }; +allow atci_service mediaserver:binder call; +allow atci_service sysfs:file write; +allow atci_service system_server:unix_stream_socket { read write }; +allow atci_service self:capability sys_boot;
\ No newline at end of file diff --git a/sepolicy/atcid.te b/sepolicy/atcid.te new file mode 100644 index 0000000..864d1d7 --- /dev/null +++ b/sepolicy/atcid.te @@ -0,0 +1,50 @@ +# ============================================== +# Policy File of /system/binatcid Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type atcid_exec , exec_type, file_type; +type atcid ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== +init_daemon_domain(atcid) +allow atcid self:capability dac_override; +allow atcid init:unix_stream_socket connectto; +allow atcid property_socket:sock_file write; +allow atcid ttyGS_device:chr_file { read write ioctl open }; +allow atcid atci_service:unix_stream_socket connectto; +allow atcid atci_service_socket:sock_file write; +allow atcid mtkrild:unix_stream_socket connectto; +allow atcid rild_atci_socket:sock_file write; +allow atcid atci_audio_socket:sock_file write; +allow atcid audiocmdservice_atci:unix_stream_socket connectto; +allow atcid system_prop:property_service set; +allow atcid persist_service_atci_prop:property_service set; +allow atcid misc2_device:chr_file { read write open }; +allow atcid wmtWifi_device:chr_file { write open }; +allow atcid block_device:dir search; +allow atcid platformblk_device:blk_file { read write open }; +allow atcid self:capability { net_admin net_raw }; +allow atcid self:udp_socket { create ioctl }; +allow atcid shell_exec:file execute; +allow atcid socket_device:sock_file write; +allow atcid shell_exec:file { read open }; +allow atcid statusd:unix_stream_socket connectto; +allow atcid shell_exec:file execute_no_trans; +allow atcid system_file:file execute_no_trans; +allow atcid self:rawip_socket create; +allow atcid self:rawip_socket getopt; +allow atcid self:rawip_socket setopt; diff --git a/sepolicy/audiocmdservice_atci.te b/sepolicy/audiocmdservice_atci.te new file mode 100644 index 0000000..498267e --- /dev/null +++ b/sepolicy/audiocmdservice_atci.te @@ -0,0 +1,49 @@ +# ============================================== +# Policy File of /system/binaudiocmdservice_atci Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type audiocmdservice_atci_exec , exec_type, file_type; +type audiocmdservice_atci ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== +allow audiocmdservice_atci mediaserver:binder call; +allow audiocmdservice_atci mediaserver:chr_file { read write ioctl open create setattr append }; +allow audiocmdservice_atci mediaserver:dir { write add_name search }; +allow audiocmdservice_atci platformblk_device:blk_file { read write open }; + +allow audiocmdservice_atci fuse:file { create read write open }; +allow audiocmdservice_atci fuse:dir { search write add_name }; + +allow audiocmdservice_atci tmpfs:lnk_file read; +allow audiocmdservice_atci block_device:dir { write search }; +allow audiocmdservice_atci nvram_data_file:dir { add_name write search }; +allow audiocmdservice_atci nvdata_file:dir { add_name write search }; +allow audiocmdservice_atci nvram_device:chr_file { open read write }; +allow audiocmdservice_atci nvram_data_file:file { write getattr setattr read create open }; +allow audiocmdservice_atci nvram_data_file:lnk_file read; +allow audiocmdservice_atci nvdata_file:file { write getattr setattr read create open }; +allow audiocmdservice_atci self:capability { dac_override }; + +# ============================================== +# Data: 2014/09/24 +# Operation: Migration +# Purpose: allow Binder IPC for audio tuning tool +# ============================================== +binder_use(audiocmdservice_atci) +binder_call(audiocmdservice_atci, mediaserver) + +init_daemon_domain(audiocmdservice_atci)
\ No newline at end of file diff --git a/sepolicy/autokd.te b/sepolicy/autokd.te new file mode 100644 index 0000000..2711dbd --- /dev/null +++ b/sepolicy/autokd.te @@ -0,0 +1,42 @@ +# ============================================== +# Policy File of /system/bin/autokd Executable File + +# ============================================== +# Type Declaration +# ============================================== +type autokd, domain; +type autokd_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +# Date : WK14.43 +# Operation : Migration +# Purpose : Start autokd +init_daemon_domain(autokd) +allow init self:tcp_socket create; + +# Date : WK14.43 +# Operation : Migration +# Purpose : Interact with kernel to perform autok +allow autokd debugfs:file read; +allow autokd init:unix_stream_socket connectto; +allow autokd property_socket:sock_file write; +allow autokd self:netlink_kobject_uevent_socket { read bind create setopt }; +allow autokd self:tcp_socket create; +allow autokd shell_exec:file { read execute open execute_no_trans }; + +# Date : WK14.43 +# Operation : Migration +# Purpose : Read/Write autok result in data paritition +# To do: Consider to move files into a sub-directory in /data, said, /data/autokd +allow autokd sysfs:file write; +allow autokd system_data_file:dir { read write open add_name remove_name }; +allow autokd system_data_file:file { open }; +allow autokd system_file:file execute_no_trans; +allow autokd block_device:dir search; +allow autokd nvram_data_file:dir {search read write getattr add_name remove_name }; +allow autokd nvram_data_file:file { read write getattr create open }; +allow autokd platformblk_device:dir search; +allow autokd platformblk_device:blk_file { open read write }; + diff --git a/sepolicy/batterywarning.te b/sepolicy/batterywarning.te new file mode 100644 index 0000000..d1f1062 --- /dev/null +++ b/sepolicy/batterywarning.te @@ -0,0 +1,34 @@ +# ============================================== +# Policy File of /system/binbatterywarning Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type batterywarning_exec , exec_type, file_type; +type batterywarning ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(batterywarning) + +# Date : 2014/10/15 +# Operation : Migration +# Purpose : all Binder IPC for battery warning to call IActivityManager to send broadcast +binder_use(batterywarning) + +# Date : 2014/10/16 +# Operation : Migration +# Purpose : allow battery warning use AMS to send broadcast through binder call +allow batterywarning system_server:binder call; diff --git a/sepolicy/bluetooth.te b/sepolicy/bluetooth.te new file mode 100644 index 0000000..2ed77ad --- /dev/null +++ b/sepolicy/bluetooth.te @@ -0,0 +1,32 @@ + +# ============================================== +# MTK Policy Rule +# ============ + + +# Data : WK14.36 +# Operation : Migration +# Purpose : IPC communication between bluetooth and mtkbt (BT host), and bluetooth and mediaserver +allow bluetooth bt_int_adp_socket:sock_file write; +allow bluetooth mediaserver:unix_dgram_socket sendto; +allow bluetooth mtkbt:unix_dgram_socket sendto; +allow bluetooth mtkbt:unix_stream_socket connectto; +allow bluetooth mtkbt:fd use; +allow bluetooth init:unix_dgram_socket sendto; + +# Data : WK14.36 +# Operation : Migration +# Purpose : BT host stack cached data access +allow bluetooth bt_data_file:dir { write add_name remove_name search}; +allow bluetooth bt_data_file:file { open read write create setattr getattr append unlink rename}; + +# Data : WK14.44 +# Operation : Migration +# IPC communication between bluetooth and mtkbt +binder_call(bluetooth, mtkbt) +#============= mediaserver ============== +allow mediaserver bt_data_file:file read; + +#============= bluetooth ============== +allow bluetooth platform_app_tmpfs:file write; + diff --git a/sepolicy/bmm050d.te b/sepolicy/bmm050d.te new file mode 100644 index 0000000..574d1c5 --- /dev/null +++ b/sepolicy/bmm050d.te @@ -0,0 +1,50 @@ +# ============================================== +# Policy File of /system/binbmm050d Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type bmm050d_exec , exec_type, file_type; +type bmm050d ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive bmm050d; +init_daemon_domain(bmm050d) +#unconfined_domain(bmm050d) + +# Data : WK14.43 +# Operation : Migration +# Purpose : M-sensor daemon for access driver node + +allow bmm050d msensor_device:chr_file { open read write ioctl }; +allow bmm050d msensor_device:chr_file { open read write ioctl }; +allow bmm050d input_device:dir { search open read write }; +allow bmm050d input_device:file { open read write ioctl }; +allow bmm050d mtk_agpsd:dir search; +allow bmm050d sensor_data_file:dir {search open read write create getattr setattr }; +allow bmm050d sensor_data_file:file { open read write create append unlink ioctl getattr setattr }; +allow bmm050d system_sensor_data_file:dir { search open read create }; +allow bmm050d system_sensor_data_file:file { open read create write }; +allow bmm050d bmm050_sensor_log_file:file { open create read write }; +allow bmm050d sysfs:file write; +allow bmm050d sysfs_gsensor_file:dir { search open read create }; +allow bmm050d sysfs_gsensor_file:file { open read create write }; +allow bmm050d sysfs_gsensor_file:lnk_file read; +allow bmm050d sysfs_msensor_file:dir { search open read create }; +allow bmm050d sysfs_msensor_file:file { open read create write }; +allow bmm050d sysfs_msensor_file:lnk_file read; +# Operate data partation directly, need modify later,e.g. use "data/misc/sensor". +allow bmm050d system_data_file:dir { write add_name create setattr};
\ No newline at end of file diff --git a/sepolicy/boot_logo_updater.te b/sepolicy/boot_logo_updater.te new file mode 100644 index 0000000..2cf0064 --- /dev/null +++ b/sepolicy/boot_logo_updater.te @@ -0,0 +1,49 @@ +# ============================================== +# Policy File of /system/binboot_logo_updater Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type boot_logo_updater_exec , exec_type, file_type; +type boot_logo_updater ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(boot_logo_updater) + + +# Date : WK14.31 +# Operation : Migration +# Purpose : for L early bring up. +allow boot_logo_updater mmcblk_device:blk_file { read open }; +allow boot_logo_updater platformblk_device:blk_file { read open }; + +# Date : WK14.32 +# Operation : Migration +# Puration : set boot reason +allow boot_logo_updater system_prop:property_service set; + +# Date : WK14.43 +# Operation : Migration +# Puration : for policy migration +allow boot_logo_updater graphics_device:chr_file { read write ioctl open }; +allow boot_logo_updater init:unix_stream_socket connectto; +allow boot_logo_updater logo_device:chr_file { read open }; +allow boot_logo_updater platformblk_device:dir search; +allow boot_logo_updater property_socket:sock_file write; +allow boot_logo_updater self:capability dac_override; +allow boot_logo_updater sysfs:file write; +allow boot_logo_updater block_device:dir search; +allow boot_logo_updater graphics_device:dir search; diff --git a/sepolicy/bootanim.te b/sepolicy/bootanim.te new file mode 100644 index 0000000..4dfc6ba --- /dev/null +++ b/sepolicy/bootanim.te @@ -0,0 +1,43 @@ +# ============================================== +# MTK Policy Rule +# ============ + + +# Date : WK14.31 +# Operation : Migration +# Purpose : for L early bring up +allow bootanim self:netlink_socket { read bind create write}; +allow bootanim proc_secmem:file { read open}; + +# Date : WK14.32 +# Operation : Migration +# Purpose : for playing boot tone +allow bootanim mediaserver:binder call; +allow bootanim mediaserver:binder transfer; + +# Date : WK14.36 +# Operation : Migration +# Purpose : for ui +allow bootanim guiext-server:binder call; +allow bootanim guiext-server:binder transfer; + +# Date : WK14.37 +# Operation : Migration +# Purpose : for op +allow bootanim terservice:binder call; +allow bootanim property_socket:sock_file write; +allow bootanim init:unix_stream_socket connectto; +allow bootanim custom_file:dir search; +allow bootanim custom_file:file open; +allow bootanim custom_file:file read; +allow bootanim bootani_prop:property_service set; + +# Date : WK14.43 +# Operation : Migration +# Purpose : for policy migration +allow bootanim debug_prop:property_service set; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow bootanim qemu_pipe_device:chr_file rw_file_perms;
\ No newline at end of file diff --git a/sepolicy/br_app_data_service.te b/sepolicy/br_app_data_service.te new file mode 100644 index 0000000..44f621f --- /dev/null +++ b/sepolicy/br_app_data_service.te @@ -0,0 +1,19 @@ +# ============================================== +# Policy File of /system/br_app_data_service Executable File + +# ============================================== +# Type Declaration +# ============================================== +type br_app_data_service_exec , exec_type, file_type; +type br_app_data_service ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== +#permissive br_app_data_service; +init_daemon_domain(br_app_data_service) + +#============= br_app_data_service ============== +allow br_app_data_service app_data_file:dir create_dir_perms; +allow br_app_data_service self:capability { chown dac_override }; +allow br_app_data_service app_data_file:file create_file_perms; diff --git a/sepolicy/ccci_fsd.te b/sepolicy/ccci_fsd.te new file mode 100644 index 0000000..2703f56 --- /dev/null +++ b/sepolicy/ccci_fsd.te @@ -0,0 +1,48 @@ +# ============================================== +# Policy File of /system/binccci_fsd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type ccci_fsd_exec, exec_type, file_type; +type ccci_fsd, domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive ccci_fsd; +init_daemon_domain(ccci_fsd) +#unconfined_domain(ccci_fsd) + +wakelock_use(ccci_fsd) + +allow ccci_fsd nvram_data_file:dir create_dir_perms; +allow ccci_fsd nvram_data_file:file create_file_perms; +allow ccci_fsd nvram_data_file:lnk_file read; +allow ccci_fsd nvdata_file:dir create_dir_perms; +allow ccci_fsd nvdata_file:file create_file_perms; +allow ccci_fsd ccci_device:chr_file rw_file_perms; +allow ccci_fsd ccci_cfg_file:dir create_dir_perms; +allow ccci_fsd ccci_cfg_file:file create_file_perms; +#============= ccci_fsd ============== +allow ccci_fsd protect_f_data_file:dir create_dir_perms; +allow ccci_fsd protect_f_data_file:file create_file_perms; + +allow ccci_fsd protect_s_data_file:dir create_dir_perms; +allow ccci_fsd protect_s_data_file:file create_file_perms; + +allow ccci_fsd otp_device:chr_file rw_file_perms; +allow ccci_fsd block_device:dir search; +allow ccci_fsd platformblk_device:blk_file { read write open ioctl }; +allow ccci_fsd platformblk_device:dir { search };
\ No newline at end of file diff --git a/sepolicy/ccci_mdinit.te b/sepolicy/ccci_mdinit.te new file mode 100644 index 0000000..af256e7 --- /dev/null +++ b/sepolicy/ccci_mdinit.te @@ -0,0 +1,86 @@ +# ============================================== +# Policy File of /system/binccci_mdinit Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type ccci_mdinit_exec , exec_type, file_type; +type ccci_mdinit ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive ccci_mdinit; +init_daemon_domain(ccci_mdinit) +#unconfined_domain(ccci_mdinit) +wakelock_use(ccci_mdinit) +#=============allow ccci_mdinit to start gsm0710muxd============== +allow ccci_mdinit ctl_gsm0710muxd_prop:property_service set; +#=============allow ccci_mdinit to start emcsmdlogger============== +allow ccci_mdinit ctl_mdlogger_prop:property_service set; + +unix_socket_connect(ccci_mdinit, property, init) +#allow ccci_mdinit ctl_mdlogger_prop:property_service set; +allow ccci_mdinit { ctl_mdlogger_prop ctl_emdlogger1_prop ctl_emdlogger2_prop ctl_dualmdlogger_prop }:property_service set; + +#allow ccci_mdinit ctl_gsm0710muxd_prop:property_service set; +allow ccci_mdinit { ctl_gsm0710muxd_prop ctl_gsm0710muxd-s_prop ctl_gsm0710muxd-d_prop ctl_gsm0710muxdmd2_prop}:property_service set; + +#allow ccci_mdinit ctl_ril-daemon-mtk_prop:property_service set; +allow ccci_mdinit { ctl_rildaemon_prop ctl_ril-daemon-mtk_prop ctl_ril-daemon-s_prop ctl_ril-daemon-d_prop ctl_ril-daemon-md2_prop }:property_service set; + +allow ccci_mdinit ril_active_md_prop:property_service set; +allow ccci_mdinit mtk_md_prop:property_service set; +allow ccci_mdinit radio_prop:property_service set; + +allow ccci_mdinit { ctl_ccci_fsd_prop ctl_ccci2_fsd_prop }:property_service set; +allow ccci_mdinit { ctl_ccci_rpcd_prop ctl_ccci2_rpcd_prop }:property_service set; + +allow ccci_mdinit ccci_device:chr_file rw_file_perms; +allow ccci_mdinit ccci_monitor_device:chr_file rw_file_perms; + +# TODO: Do not allow write access to all of /sys +allow ccci_mdinit sysfs:file write; + +allow ccci_mdinit nvram_data_file:dir rw_dir_perms; +allow ccci_mdinit nvram_data_file:file create_file_perms; +allow ccci_mdinit nvram_data_file:lnk_file read; +allow ccci_mdinit nvdata_file:dir rw_dir_perms; +allow ccci_mdinit nvdata_file:file create_file_perms; +allow ccci_mdinit nvram_device:chr_file rw_file_perms; + +allow ccci_mdinit protect_f_data_file:dir rw_dir_perms; +allow ccci_mdinit protect_f_data_file:file create_file_perms; + +allow ccci_mdinit protect_s_data_file:dir rw_dir_perms; +allow ccci_mdinit protect_s_data_file:file create_file_perms; +allow ccci_mdinit platformblk_device:blk_file { read write open }; + +allow ccci_mdinit ril_mux_report_case_prop:property_service set; + +allow ccci_mdinit mdlog_data_file:dir search; +allow ccci_mdinit mdlog_data_file:file { read open }; +allow ccci_mdinit platformblk_device:dir search; + +allow ccci_mdinit ccci_cfg_file:dir create_dir_perms; +allow ccci_mdinit ccci_cfg_file:file create_file_perms; +allow ccci_mdinit block_device:dir search; + +allow ccci_mdinit preloader_device:chr_file rw_file_perms; +allow ccci_mdinit misc_sd_device:chr_file { read open }; +allow ccci_mdinit sec_ro_device:chr_file { read open }; + +allow ccci_mdinit custom_file:dir { search }; +allow ccci_mdinit custom_file:file { open read getattr }; +allow ccci_mdinit mtk_tele_prop:property_service set; diff --git a/sepolicy/ccci_rpcd.te b/sepolicy/ccci_rpcd.te new file mode 100644 index 0000000..accd85f --- /dev/null +++ b/sepolicy/ccci_rpcd.te @@ -0,0 +1,34 @@ +# ============================================== +# Policy File of /system/binccci_fsd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type ccci_rpcd_exec, exec_type, file_type; +type ccci_rpcd, domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive ccci_rpcd; +init_daemon_domain(ccci_rpcd) +#unconfined_domain(ccci_rpcd) + +wakelock_use(ccci_rpcd) +#============= ccci_rpcd ============== +allow ccci_rpcd ccci_device:chr_file rw_file_perms; +allow ccci_rpcd block_device:dir search; +allow ccci_rpcd platformblk_device:dir search; +allow ccci_rpcd platformblk_device:blk_file { open read write }; +allow ccci_rpcd misc2_device:chr_file { open read write }; diff --git a/sepolicy/clatd.te b/sepolicy/clatd.te new file mode 100644 index 0000000..7b20973 --- /dev/null +++ b/sepolicy/clatd.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + diff --git a/sepolicy/cmddumper.te b/sepolicy/cmddumper.te new file mode 100644 index 0000000..f605d3c --- /dev/null +++ b/sepolicy/cmddumper.te @@ -0,0 +1,35 @@ +# ============================================== +# Policy File of /system/bin/cmddumper Executable File + +# ============================================== +# Type Declaration +# ============================================== +type cmddumper, domain; +type cmddumper_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +init_daemon_domain(cmddumper) + +#============= cmddumper ============== +allow cmddumper mdlog_data_file:fifo_file create_file_perms; +allow cmddumper mdlog_data_file:file create_file_perms; +allow cmddumper mdlog_data_file:dir { create_dir_perms relabelto }; +allow cmddumper ttySDIO_device:chr_file { read write ioctl open }; +allow cmddumper fuse:dir create_dir_perms; +allow cmddumper fuse:file create_file_perms; + +allow cmddumper init:unix_stream_socket connectto; +allow cmddumper property_socket:sock_file { write read }; +allow cmddumper platform_app:unix_stream_socket connectto; + +allow cmddumper shell_exec:file { read execute open execute_no_trans }; +allow cmddumper system_file:file execute_no_trans; + +allow cmddumper debug_mdlogger_prop:property_service set; +allow cmddumper debug_prop:property_service set; + +allow cmddumper tmpfs:lnk_file read; +allow cmddumper system_data_file:dir { write create open add_name relabelfrom relabelto}; + diff --git a/sepolicy/debuggerd.te b/sepolicy/debuggerd.te new file mode 100644 index 0000000..eba01d1 --- /dev/null +++ b/sepolicy/debuggerd.te @@ -0,0 +1,151 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK14.32 +# Operation : AEE UT +# Purpose : for AEE module +domain_auto_trans(debuggerd, dmlog_exec, dmlog) + +allow debuggerd aed_device:chr_file { read write ioctl open }; +allow debuggerd expdb_device:chr_file { read write ioctl open }; +allow debuggerd platformblk_device:blk_file { read write ioctl open }; +allow debuggerd ccci_device:chr_file { read ioctl open }; +allow debuggerd etb_device:chr_file { read write ioctl open }; +allow debuggerd graphics_device:dir search; +allow debuggerd graphics_device:chr_file r_file_perms; +allow debuggerd Vcodec_device:chr_file r_file_perms; +allow debuggerd camera_isp_device:chr_file r_file_perms; + +# AED start: /dev/block/expdb +allow debuggerd block_device:dir search; +allow debuggerd platformblk_device:dir search; + +# NE flow: /dev/RT_Monitor +allow debuggerd RT_Monitor_device:chr_file { read ioctl open }; + +# /dev/_GPU_ dev/pvrsrvkm +allow debuggerd gpu_device:chr_file rw_file_perms; + +# /dev/exm0 +allow debuggerd exm0_device:chr_file r_file_perms; + +allow debuggerd shell_exec:file { execute execute_no_trans }; +allow debuggerd dex2oat_exec:file { execute execute_no_trans }; + +# aee db dir and db files +allow debuggerd sdcard_internal:dir create_dir_perms; +allow debuggerd sdcard_internal:file create_file_perms; + +#data/anr +allow debuggerd anr_data_file:dir create_dir_perms; +allow debuggerd anr_data_file:file create_file_perms; + +#data/aee_exp +allow debuggerd aee_exp_data_file:dir { relabelto create_dir_perms }; +allow debuggerd aee_exp_data_file:file create_file_perms; + +#data/dumpsys +allow debuggerd aee_dumpsys_data_file:dir { relabelto create_dir_perms }; +allow debuggerd aee_dumpsys_data_file:file create_file_perms; + +#/data/core +allow debuggerd aee_core_data_file:dir create_dir_perms; +allow debuggerd aee_core_data_file:file create_file_perms; + +# /data/data_tmpfs_log +allow debuggerd data_tmpfs_log_file:dir create_dir_perms; +allow debuggerd data_tmpfs_log_file:file create_file_perms; + +allow debuggerd shell_data_file:dir search; +allow debuggerd shell_data_file:file r_file_perms; + +#/data/anr/SF_RTT +allow debuggerd sf_rtt_file:dir search; +allow debuggerd sf_rtt_file:file r_file_perms; + +allow debuggerd sysfs:file write; +allow debuggerd proc:file write; +allow debuggerd sysfs_lowmemorykiller:file { read open }; +allow debuggerd debugfs:file read; +#allow debuggerd proc_security:file { write open }; + +allow debuggerd self:capability { fsetid sys_nice sys_resource net_admin sys_module }; + +allow debuggerd domain:process { sigkill getattr getsched}; +allow debuggerd domain:lnk_file getattr; + +#core-pattern +allow debuggerd usermodehelper:file { read open }; + +#suid_dumpable +allow debuggerd proc_security:file { read open }; + +#kptr_restrict +#allow debuggerd proc_security:file { write open }; + +#dmesg +allow debuggerd kernel:system syslog_read; + +#property +allow debuggerd init:unix_stream_socket connectto; +allow debuggerd property_socket:sock_file write; + +# dumpstate ION_MM_HEAP +allow debuggerd debugfs:lnk_file read; + +allow debuggerd tmpfs:lnk_file read; + + +# aed set property +allow debuggerd persist_mtk_aee_prop:property_service set; +allow debuggerd persist_aee_prop:property_service set; +allow debuggerd debug_mtk_aee_prop:property_service set; + +# aee_dumpstate set property +allow debuggerd debug_bq_dump_prop:property_service set; + +#com.android.settings NE +allow debuggerd system_app_data_file:dir search; + +# sogou NE +allow debuggerd app_data_file:dir search; + +# open and read /data/data/com.android.settings/databases/search_index.db-journal +allow debuggerd system_app_data_file:file r_file_perms; +allow debuggerd app_data_file:file r_file_perms; + +# /system/bin/am +allow debuggerd system_file:file execute_no_trans; +allow debuggerd zygote_exec:file { execute execute_no_trans }; + +#/proc/driver/storage_logger +allow debuggerd proc_slogger:file { write read open }; + +# MOTA upgrade from JB->L: aee_dumpstate(ps top df dmesg) +# allow debuggerd unlabeled:lnk_file read; + +binder_use(debuggerd) +allow debuggerd system_server:binder call; +allow debuggerd surfaceflinger:binder call; +allow debuggerd surfaceflinger:fd use; +allow debuggerd platform_app:fd use; +allow debuggerd platform_app_tmpfs:file write; + +# aed and MTKLogger.apk socket connect +allow debuggerd platform_app:unix_stream_socket connectto; + +allow debuggerd self:udp_socket { create ioctl }; + +allow debuggerd init:process getsched; +allow debuggerd kernel:process getsched; + +# for SF_dump +allow debuggerd sf_bqdump_data_file:dir { read write open remove_name search}; +allow debuggerd sf_bqdump_data_file:file { read getattr unlink open }; + + +allow debuggerd custom_file:dir search; + +# avc: denied { read } for pid=4503 comm="screencap" name="secmem0" dev="proc" +allow debuggerd proc_secmem:file r_file_perms; diff --git a/sepolicy/device.te b/sepolicy/device.te new file mode 100644 index 0000000..7901b2c --- /dev/null +++ b/sepolicy/device.te @@ -0,0 +1,161 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +type devmap_device, dev_type; +type ttyMT_device, dev_type; +type ttySDIO_device, dev_type; +type vmodem_device, dev_type; +type stpwmt_device, dev_type; +type wmtdetect_device, dev_type; +type wmtWifi_device, dev_type; +type stpbt_device, dev_type; +type stpant_device, dev_type; +type fm_device, dev_type; +type stpgps_device, dev_type; +type pmem_multimedia_device, dev_type; +type mt6516_isp_device, dev_type; +type mt6516_IDP_device, dev_type; +type mt9p012_device, dev_type; +type mt6516_jpeg_device, dev_type; +type FM50AF_device, dev_type; +type DW9714AF_device, dev_type; +type AK7345AF_device, dev_type; +type DW9714A_device, dev_type; +type LC898122AF_device, dev_type; +type LC898212AF_device, dev_type; +type BU6429AF_device, dev_type; +type AD5820AF_device, dev_type; +type DW9718AF_device, dev_type; +type BU64745GWZAF_device, dev_type; +# M2N camera +type BU64245_device, dev_type; +type M4U_device_device, dev_type; +type hwmsensor_device, dev_type; +type msensor_device, dev_type; +type gsensor_device, dev_type; +type als_ps_device, dev_type; +type gyroscope_device, dev_type; +type Vcodec_device, dev_type; +type MJC_device, dev_type; +type smartpa_device, dev_type; +type smartpa1_device, dev_type; +type uio0_device, dev_type; +type xt_qtaguid_device, dev_type; +type rfkill_device, dev_type; +type sw_sync_device, dev_type; +type sec_device, dev_type; +type hid_keyboard_device, dev_type; +type btn_device, dev_type; +type uinput_device, dev_type; +type TV_out_device, dev_type; +type camera_sysram_device, dev_type; +type camera_isp_device, dev_type; +type camera_fdvt_device, dev_type; +type camera_pipemgr_device, dev_type; +type mtk_jpeg_device, dev_type; +type kd_camera_hw_device, dev_type; +type kd_camera_flashlight_device, dev_type; +type kd_camera_hw_bus2_device, dev_type; +type MATV_device, dev_type; +type mt_otg_test_device, dev_type; +type mt_mdp_device, dev_type; +type mtkg2d_device, dev_type; +type misc_sd_device, dev_type; +type mtk_sched_device, dev_type; +type ampc0_device, dev_type; +type mmp_device, dev_type; +type ttyGS_device, dev_type; +type CAM_CAL_DRV_device, dev_type; +type MTK_SMI_device, dev_type; +type mtk_rrc_device, dev_type; +type ebc_device, dev_type; +type vow_device, dev_type; +type MT6516_H264_DEC_device, dev_type; +type MT6516_Int_SRAM_device, dev_type; +type MT6516_MM_QUEUE_device, dev_type; +type MT6516_MP4_DEC_device, dev_type; +type MT6516_MP4_ENC_device, dev_type; +type sensor_device, dev_type; +type xlog_device, dev_type; +type aed_device, dev_type; +type ccci_device, dev_type; +type ccci_monitor_device, dev_type; +type gsm0710muxd_device, dev_type; +type eemcs_device, dev_type; +type emd_device, dev_type; +type mt6605_device, dev_type; +type exm0_device, dev_type; +type mmcblk_device, dev_type; +type BOOT_device, dev_type; +type MT_pmic_device, dev_type; +type aal_als_device, dev_type; +type accdet_device, dev_type; +type android_device, dev_type; +type bmtpool_device, dev_type; +type bootimg_device, dev_type; +type btif_device, dev_type; +type cache_device, dev_type; +type cpu_dma_latency_device, dev_type; +type dummy_cam_cal_device, dev_type; +type ebr_device, dev_type; +type expdb_device, dev_type; +type fat_device, dev_type; +type logo_device, dev_type; +type loop-control_device, dev_type; +type m_acc_misc_device, dev_type; +type m_batch_misc_device, dev_type; +type m_mag_misc_device, dev_type; +type mbr_device, dev_type; +type met_device, dev_type; +type misc_device, dev_type; +type misc2_device, dev_type; +type mtfreqhopping_device, dev_type; +type mtgpio_device, dev_type; +type mtk_kpd_device, dev_type; +type network_device, dev_type; +type nvram_device, dev_type; +type pmt_device, dev_type; +type preloader_device, dev_type; +type pro_info_device, dev_type; +type protect_f_device, dev_type; +type protect_s_device, dev_type; +type psaux_device, dev_type; +type ptyp_device, dev_type; +type recovery_device, dev_type; +type sec_ro_device, dev_type; +type seccfg_device, dev_type; +type tee_part_device, dev_type; +type snapshot_device, dev_type; +type tgt_device, dev_type; +type touch_device, dev_type; +type tpd_em_log_device, dev_type; +type ttyp_device, dev_type; +type uboot_device, dev_type; +type uibc_device, dev_type; +type usrdata_device, dev_type; +type voldblk_device, dev_type; +type zram0_device, dev_type; +type platformblk_device, dev_type; +type RT_Monitor_device, dev_type; +type kick_powerkey_device, dev_type; +type agps_device, dev_type; +type mnld_device, dev_type; +type hotknot_device, dev_type; +type mdlog_device, dev_type; +type md32_device, dev_type; +type etb_device, dev_type; +type MT_pmic_adc_cali_device, dev_type; +type mtk-adc-cali_device, dev_type; +type MT_pmic_cali_device,dev_type; +type barometer_device,dev_type; +type otp_device, dev_type; +type qemu_pipe_device, dev_type; +type icusb_device, dev_type; +type irtx_device, dev_type; +type pmic_ftm_device, dev_type; +type shf_device, dev_type; +type keyblock_device, dev_type; +type offloadservice_device, dev_type; +type ttyACM_device, dev_type; +type hrm_device, dev_type; diff --git a/sepolicy/dex2oat.te b/sepolicy/dex2oat.te new file mode 100644 index 0000000..92fbdb1 --- /dev/null +++ b/sepolicy/dex2oat.te @@ -0,0 +1,29 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date : WK14.34 +# Operation : Migration +# Purpose : 6571/6572 LCA external memory access(/dev/exm0) +allow dex2oat exm0_device:chr_file { read write ioctl open }; + +# Date : WK14.36 +# Operation : Migration +# Purpose : for CIP project (access /custom partition) +allow dex2oat custom_file:dir { search getattr }; +allow dex2oat custom_file:file { getattr read open }; + +# Date : WK14.38 +# Operation : Sanity Test +# Purpose : avoid SELinux warning after dex2oat execv failed +allow dex2oat dex2oat_exec:file x_file_perms; + +# Date : WK15.03 +# Operation : MTBF Test +# Purpose : for K35V1_64_OP02 project MTBF test (ALPS01905764) +allow dex2oat platform_app:fd use; + +# Date : WK15.04 +# Operation : MTBF Test +# Purpose : for K35V1_64_OP02 project MTBF test (ALPS01920449) +allow dex2oat platform_app_tmpfs:file write; diff --git a/sepolicy/dhcp.te b/sepolicy/dhcp.te new file mode 100644 index 0000000..758715c --- /dev/null +++ b/sepolicy/dhcp.te @@ -0,0 +1,28 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date :WK14.34 +# Operation : Migration +# Purpose: for connecting Wifi +allow dhcp devpts:chr_file { read write ioctl }; + + + +# Date :WK14.41 +# Operation : [Auto Sanity][L.AOSP.EARLY.DEV.BSP][k2v1] +# Purpose: ALPS01757300 +#============= dhcp ============== +allow dhcp kernel:system module_request; + + +# Date :WK14.44 +# Operation : [Rose][82L TK][FTester] +# Purpose: ALPS01798575 +#============= netd ============== +allow dhcp platform_app:fd use; +allow dhcp platform_app_tmpfs:file write; + +#============= dhcp ============== +allow dhcp init:fifo_file { read write }; +allow dhcp init:unix_stream_socket { read write };
\ No newline at end of file diff --git a/sepolicy/dhcp6c.te b/sepolicy/dhcp6c.te new file mode 100644 index 0000000..4dc27ae --- /dev/null +++ b/sepolicy/dhcp6c.te @@ -0,0 +1,77 @@ +# ============================================== +# Policy File of /system/bindhcp6c Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type dhcp6c_exec , exec_type, file_type; +type dhcp6c ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + + +init_daemon_domain(dhcp6c) + + + +# Date : WK14.34 +# Operation : Migration +# Purpose : wifi +allow dhcp6c self:udp_socket { create setopt write bind ioctl read }; + + +# Date : WK14.41 +# Operation : SQC +# Purpose : ALPS01763317 +# After connected to DHCPv6 enabled 6to4 IPv6 AP, +#the ipv6 related values of getprop command are wrong +#============= dhcp6c ============== +allow dhcp6c node:udp_socket node_bind; +allow dhcp6c port:udp_socket name_bind; +allow dhcp6c system_file:file execute_no_trans; +allow dhcp6c dhcp_prop:property_service set; + + +# Date : WK14.42 +# Operation : SQC +# Purpose : L 2nd Migration + +#============= dhcp6c ============== + +allow dhcp6c system_file:file execute_no_trans; + +# Date : WK14.43 +# Operation : SQC +# Purpose : dhcp6c get ip address and ps + +#============= dhcp6c ============== +allow dhcp6c dhcp_data_file:dir { write add_name search}; +allow dhcp6c dhcp_data_file:file { read write create open getattr }; +allow dhcp6c init:unix_stream_socket connectto; +allow dhcp6c property_socket:sock_file write; +allow dhcp6c self:capability { setuid net_admin net_bind_service setgid }; +allow dhcp6c self:netlink_route_socket { write getattr read bind create nlmsg_read }; +allow dhcp6c shell_exec:file { read execute open }; +allow dhcp6c wide_dhcpv6_data_file:dir { write search add_name }; +allow dhcp6c wide_dhcpv6_data_file:file { read write create open getattr }; + + + + + + + + + diff --git a/sepolicy/dm_agent_binder.te b/sepolicy/dm_agent_binder.te new file mode 100644 index 0000000..1218e1f --- /dev/null +++ b/sepolicy/dm_agent_binder.te @@ -0,0 +1,99 @@ +# ============================================== +# Policy File of /system/bin/dm_agent_binder Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type dm_agent_binder_exec , exec_type, file_type; +type dm_agent_binder ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(dm_agent_binder) + +# Date : WK14.37 +# Operation : access DmAgent by binder +# Purpose : ensure can access DmAgent api normally. +allow dm_agent_binder dm_agent_binder_service:service_manager add; + +# Date : WK14.37 +# Operation : access DmAgent by binder +# Purpose : ensure can access DmAgent api normally. +binder_use(dm_agent_binder) +binder_service(dm_agent_binder) + +# Date : WK14.42 +# Operation : Migration +# Purpose : Allow DmAgent access nvram_data_file. +allow dm_agent_binder nvram_data_file:dir { rw_dir_perms }; +allow dm_agent_binder nvdata_file:dir { rw_dir_perms }; + +# Date : WK14.42 +# Operation : Basic UT +# Purpose : Allow DmAgent access nvram_data_file. +allow dm_agent_binder nvram_data_file:file { create_file_perms }; +allow dm_agent_binder nvram_data_file:lnk_file read; +allow dm_agent_binder nvdata_file:file { create_file_perms }; + +# Date : WK14.42 +# Operation : Basic UT +# Purpose : Allow DmAgent access block_device. +allow dm_agent_binder block_device:dir search; + +# Date : WK14.42 +# Operation : Basic UT +# Purpose : Allow DmAgent access platformblk_device. +allow dm_agent_binder platformblk_device:dir search; + +# Date : WK14.42 +# Operation : Basic UT +# Purpose : Allow DmAgent access misc_device. +allow dm_agent_binder misc_device:chr_file { rw_file_perms }; + +# Date : WK14.42 +# Operation : Basic UT +# Purpose : Allow DmAgent write sock_file. +allow dm_agent_binder property_socket:sock_file write; + +# Date : WK14.42 +# Operation : Basic UT +# Purpose : Allow DmAgent connectto unix_stream_socket. +allow dm_agent_binder init:unix_stream_socket connectto; + +# Date : 2014/10/17 +# Operation : QC +# Purpose : [Privacy protection lock][dm_agent_binder call FileOp_BackupToBinRegionForDM to do nvram backup] +allow dm_agent_binder mmcblk_device:blk_file rw_file_perms; +allow dm_agent_binder platformblk_device:blk_file rw_file_perms; + +# Date : WK14.42 +# Operation : Basic UT +# Purpose : Allow DmAgent to set properties. +allow dm_agent_binder persist_dm_prop:property_service set; + +# Date : WK14.43 +# Operation : Basic UT +# Purpose : Allow DmAgent to access cache_file. +allow dm_agent_binder cache_file:dir { w_dir_perms create }; + +# Date : WK14.43 +# Operation : Basic UT +# Purpose : Allow DmAgent to access cache_file. +allow dm_agent_binder cache_file:file { create_file_perms }; + +# Date : WK14.44 +# Operation : Basic UT +# Purpose : Allow DmAgent to access nvram_device. +allow dm_agent_binder nvram_device:chr_file { rw_file_perms }; diff --git a/sepolicy/dmlog.te b/sepolicy/dmlog.te new file mode 100644 index 0000000..ea8f25a --- /dev/null +++ b/sepolicy/dmlog.te @@ -0,0 +1,29 @@ +# ============================================== +# Policy File of /system/bin/dmlog Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type dmlog_exec , exec_type, file_type; +type dmlog ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive dmlog; +init_daemon_domain(dmlog) + +# Date : 2014/09/23 +# Operation : Migration +# Purpose : for mtk debug mechanism +allow dmlog aed_device:chr_file read; +allow dmlog debuggerd:fd use; +allow dmlog debuggerd:unix_stream_socket { read write }; +allow dmlog expdb_device:chr_file { read write }; +allow dmlog fuse:file { write getattr }; +allow dmlog sysfs:file write; +allow dmlog aee_exp_data_file:file write; +allow dmlog platformblk_device:blk_file { read write }; diff --git a/sepolicy/dnsmasq.te b/sepolicy/dnsmasq.te new file mode 100644 index 0000000..5fd790a --- /dev/null +++ b/sepolicy/dnsmasq.te @@ -0,0 +1,6 @@ +# ============================================== +# MTK Policy Rule +# ============ + + +allow dnsmasq netd:file read; diff --git a/sepolicy/domain.te b/sepolicy/domain.te new file mode 100644 index 0000000..a905bb3 --- /dev/null +++ b/sepolicy/domain.te @@ -0,0 +1,8 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# allow domain anr_data_file:file append; + +# extmem policy for lca debug15 over external memory +allow domain exm0_device:chr_file { read write ioctl open }; diff --git a/sepolicy/drmserver.te b/sepolicy/drmserver.te new file mode 100644 index 0000000..2403ad3 --- /dev/null +++ b/sepolicy/drmserver.te @@ -0,0 +1,76 @@ +# ============================================== +# MTK Policy Rule +# ============ + +#Add by rui.hu + +# Date : WK14.30 +# Operation : DRM UT +# Purpose : To pass DRM UT + +allow drmserver nvram_agent_binder:binder call; +allow drmserver platform_app:dir search; +allow drmserver platform_app:file { read getattr open }; +allow drmserver property_socket:sock_file write; +allow drmserver radio_data_file:file { read getattr open }; +allow drmserver sdcard_internal:file open; +allow drmserver tmpfs:lnk_file read; + +#Add by rui.hu +# Date : WK14.36 +# Operation : DRM UT +# Purpose : Make drmserver and binder read /proc/pid/cmdline to get process name +#system app to drmserver +allow drmserver system_app:dir search; +allow drmserver system_app:file { read open getattr }; +#Mediaserver to drmserver +allow drmserver mediaserver:dir search; +allow drmserver mediaserver:file { read open getattr }; + +#Add by rui.hu +# Date : WK14.36.5 +# Operation : DRM UT +# Purpose : Make widevine mediacodec mode work +allow drmserver untrusted_app:dir search; +allow drmserver untrusted_app:file { read open getattr }; + +#Add by rui.hu +# Date : WK14.40.1 +# Operation : DRM SQC - play OMA DRM audio file failed +# Purpose : Make OMA DRM audio file can be played +allow drmserver radio_data_file:dir search; + +#Add by rui.hu +# Date : WK14.44.2 +# Operation : DRM SQC - view image failed +# Purpose : To fix ALPS01790300 +allow drmserver surfaceflinger:fd use; + +#Add by rui.hu +# Date : WK14.44.3 +# Operation : MTBF test fail +# Purpose : To fix ALPS01793801 +allow drmserver mediaserver:fifo_file read; + +#Add by rui.hu +# Date : WK14.46.4 +# Operation : DRM SQC - view image failed +# Purpose : To fix ALPS01822176 +allow drmserver mediaserver:fifo_file write; + +# Date : WK14.52 +# Operation : WVL1 IT +# Purpose : SVP module operates secmem driver and SVP module operate tee +allow drmserver mobicore:unix_stream_socket connectto; +allow drmserver mobicore_data_file:file { read getattr open lock}; +allow drmserver mobicore_data_file:dir search; +allow drmserver mobicore_user_device:chr_file { read write ioctl open }; +allow drmserver persist_data_file:file { read getattr open }; +allow drmserver persist_data_file:dir search; +allow drmserver proc_secmem:file { read write ioctl open }; + +# Date : WK15.07 +# Operation : DRM SQC +# Purpose : For gmo project, low memory kill +allow drmserver platform_app_tmpfs:file write; + diff --git a/sepolicy/dualmdlogger.te b/sepolicy/dualmdlogger.te new file mode 100644 index 0000000..01a8cfe --- /dev/null +++ b/sepolicy/dualmdlogger.te @@ -0,0 +1,63 @@ +# ============================================== +# Policy File of /system/bindualmdlogger Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type dualmdlogger_exec , exec_type, file_type; +type dualmdlogger ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive dualmdlogger; +init_daemon_domain(dualmdlogger) + + +#=============allow mdlogger to set ============== +allow dualmdlogger debug_mdlogger_prop:property_service set; +allow dualmdlogger debug_prop:property_service set; +allow dualmdlogger ccci_device:chr_file { read write ioctl open }; +allow dualmdlogger ttyGS_device:chr_file { read write open ioctl}; +allow dualmdlogger fuse:dir { write search create rmdir add_name remove_name read open rename}; +allow dualmdlogger fuse:file { write read create open rename unlink getattr setattr append}; +allow dualmdlogger mdlog_data_file:dir { write search read create open rmdir remove_name add_name relabelto getattr}; +allow dualmdlogger mdlog_data_file:fifo_file { read open create setattr}; +allow dualmdlogger mdlog_data_file:file { write read create open rename unlink getattr setattr}; +allow dualmdlogger mdlog_device:chr_file { read write open ioctl}; +allow dualmdlogger system_data_file:dir { write create open add_name relabelfrom}; + +allow dualmdlogger init:unix_stream_socket connectto; +allow dualmdlogger property_socket:sock_file write; +allow dualmdlogger platform_app:unix_stream_socket connectto; + +allow dualmdlogger shell_exec:file { read execute open execute_no_trans }; +allow dualmdlogger system_file:file execute_no_trans; +allow dualmdlogger zygote_exec:file { read getattr open execute execute_no_trans }; +allow dualmdlogger tmpfs:lnk_file read; + +#============= dualmdlogger usb logging ============== +# Date : 2014/09/26 +# Operation : Migration +# Purpose : [DUALMDLOGGER] [dualmdlogger usb logging tcp_socket] +# Package: system/bin/dualmdlogger + +allow dualmdlogger fuse:dir search; +allow dualmdlogger node:tcp_socket node_bind; +allow dualmdlogger port:tcp_socket name_bind; +allow dualmdlogger self:tcp_socket { write read bind create setopt accept listen }; + + +binder_use(dualmdlogger) +binder_service(dualmdlogger) diff --git a/sepolicy/dumpstate.te b/sepolicy/dumpstate.te new file mode 100644 index 0000000..be4bbfc --- /dev/null +++ b/sepolicy/dumpstate.te @@ -0,0 +1,18 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date : WK14.33 +# Operation : Bugreport UT +# Purpose : add dumpstate policy rule + +#allow dumpstate init:binder call; +allow dumpstate mtkbt:binder call; +allow dumpstate MtkCodecService:binder call; +allow dumpstate nvram_agent_binder:binder call; +allow dumpstate ppl_agent:binder call; +allow dumpstate GoogleOtaBinder:binder call; + +allow dumpstate dontpanic_data_file:dir search; +allow dumpstate guiext-server:binder call; + diff --git a/sepolicy/em_svr.te b/sepolicy/em_svr.te new file mode 100644 index 0000000..36df432 --- /dev/null +++ b/sepolicy/em_svr.te @@ -0,0 +1,69 @@ +# ============================================== +# Policy File of /system/binem_svr Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type em_svr_exec , exec_type, file_type; +type em_svr ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(em_svr) + +# Date: W14.38 2014/09/17 +# Operation : Migration +# Purpose : for em_svr +allow em_svr proc:file write; +allow em_svr sysfs:file write; +allow em_svr platformblk_device:blk_file { read write open }; +allow em_svr platformblk_device:dir search; +allow em_svr shell_exec:file { read execute open execute_no_trans }; +allow em_svr system_file:file execute_no_trans; +allow em_svr block_device:dir search; +allow em_svr graphics_device:chr_file { read write open ioctl}; +allow em_svr graphics_device:dir search; +allow em_svr radio_data_file:dir { search write add_name create }; +allow em_svr radio_data_file:file { create write open read }; +allow em_svr sysfs_devices_system_cpu:file write; +allow em_svr misc_sd_device:chr_file { read open ioctl }; +allow em_svr als_ps_device:chr_file { read ioctl open }; +allow em_svr gsensor_device:chr_file { read ioctl open }; +allow em_svr gyroscope_device:chr_file { read ioctl open }; +allow em_svr nvram_data_file:dir { write read open add_name search }; +allow em_svr nvram_data_file:file { write getattr setattr read create open }; +allow em_svr nvram_data_file:lnk_file read; +allow em_svr nvdata_file:dir { write read open add_name search }; +allow em_svr nvdata_file:file { write getattr setattr read create open }; +allow em_svr nvram_device:chr_file { open read write ioctl }; +allow em_svr thermal_manager_exec:file { getattr execute read open execute_no_trans }; +allow em_svr self:capability { dac_override sys_nice fowner chown fsetid }; +allow em_svr self:process execmem; +allow em_svr proc_mtkcooler:dir search; +allow em_svr proc_mtkcooler:file { read getattr open write }; +allow em_svr proc_thermal:dir search; +allow em_svr proc_thermal:file { read getattr open write }; +allow em_svr proc_mtktz:dir search; +allow em_svr proc_mtktz:file { read getattr open write }; +allow em_svr proc_slogger:file { read getattr open write }; +allow em_svr system_data_file:dir { write remove_name add_name relabelfrom create open }; +allow em_svr kernel:system module_request; +allow em_svr fuse:dir create_dir_perms; +allow em_svr fuse:file create_file_perms; +allow em_svr tmpfs:lnk_file read; + +# for use binder +binder_use(em_svr) +binder_call(em_svr, surfaceflinger) diff --git a/sepolicy/emdlogger.te b/sepolicy/emdlogger.te new file mode 100644 index 0000000..f4acc65 --- /dev/null +++ b/sepolicy/emdlogger.te @@ -0,0 +1,72 @@ +# ============================================== +# Policy File of /system/bin/emdlogger[x] Executable File + + +# ============================================== +# Type Declaration +# ============================================== +type emdlogger_exec , exec_type, file_type; +type emdlogger, domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive emdlogger; +init_daemon_domain(emdlogger) + +binder_use(emdlogger) +binder_service(emdlogger) +#=============allow emdlogger to set ============== +allow emdlogger debug_mdlogger_prop:property_service set; +allow emdlogger debug_prop:property_service set; +allow emdlogger persist_mtklog_prop:property_service set; +allow emdlogger system_radio_prop:property_service set; + +#========================================================= +# ccci device for internal modem +#========================================================= +allow emdlogger ccci_device:chr_file { read write ioctl open }; + +#========================================================= +# eemcs device for external modem +#========================================================= +allow emdlogger eemcs_device:chr_file { read write ioctl open }; + +#========================================================= +# usb device ttyGSx for modem logger usb logging +#========================================================= +allow emdlogger ttyGS_device:chr_file { read write open ioctl}; + +#========================================================= +# for modem logging sdcard access +#========================================================= +allow emdlogger fuse:dir { write search create rmdir add_name remove_name read open rename}; +allow emdlogger fuse:file { write read create open rename unlink getattr setattr append}; + +#========================================================= +# modem logger access on /data/mdlog +#========================================================= +allow emdlogger mdlog_data_file:dir { write search read create open rmdir remove_name add_name relabelto getattr}; +allow emdlogger mdlog_data_file:fifo_file { read write open create setattr}; +allow emdlogger mdlog_data_file:file { write read create open rename unlink getattr setattr}; +allow emdlogger system_data_file:dir { write create open add_name relabelfrom}; + +#========================================================= +# modem logger control port access /dev/ttyC1 +#========================================================= +allow emdlogger mdlog_device:chr_file { read write open ioctl}; + +#========================================================= +# modem logger socket access +#========================================================= +allow emdlogger property_socket:sock_file write; +allow emdlogger init:unix_stream_socket connectto; +allow emdlogger platform_app:unix_stream_socket connectto; + +allow emdlogger shell_exec:file { read execute open execute_no_trans }; +allow emdlogger system_file:file execute_no_trans; +allow emdlogger zygote_exec:file { read getattr open execute execute_no_trans }; +allow emdlogger tmpfs:lnk_file read; + diff --git a/sepolicy/enableswap.te b/sepolicy/enableswap.te new file mode 100644 index 0000000..8153fff --- /dev/null +++ b/sepolicy/enableswap.te @@ -0,0 +1,48 @@ +# ============================================== +# Policy File of enableswap.sh + + +# ============================================== +# Type Declaration +# ============================================== + +type enableswap_exec , exec_type, file_type; +type enableswap ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date : WK14.34 +# Operation : Migration +# Purpose : Add new swap areas +init_daemon_domain(enableswap) +allow enableswap block_device:dir search; +allow enableswap self:capability sys_admin; +allow enableswap shell_exec:file { entrypoint read }; +allow enableswap sysfs:file write; +allow enableswap tiny_mkswap_exec:file { read getattr open execute execute_no_trans }; +allow enableswap tiny_swapon_exec:file { read getattr open execute execute_no_trans }; +allow enableswap zram0_device:blk_file { read write getattr open ioctl }; + +# Date : WK14.46 +# Operation : Migration +# Purpose : Allow more operations on swap areas +allow enableswap proc:file write; +allow enableswap system_file:file execute_no_trans; +allow enableswap system_data_file:file { open }; +allow enableswap system_data_file:dir { write add_name }; +allow enableswap self:capability dac_override; + +# Date : WK15.05 +# Operation : Migration +# Purpose : Allow more operations on init_tmpfs +allow enableswap init_tmpfs:file write; diff --git a/sepolicy/epdg_wod.te b/sepolicy/epdg_wod.te new file mode 100644 index 0000000..5accab6 --- /dev/null +++ b/sepolicy/epdg_wod.te @@ -0,0 +1,59 @@ +# ============================================== +# Policy File of /system/bin/epdg_wod Executable File + +# ============================================== +# Type Declaration +# ============================================== +type epdg_wod_exec , exec_type, file_type; +type epdg_wod ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== +init_daemon_domain(epdg_wod) + +domain_auto_trans(epdg_wod, starter_exec, ipsec) +domain_auto_trans(epdg_wod, charon_exec, ipsec) +domain_auto_trans(epdg_wod, starter_exec, ipsec) +domain_auto_trans(epdg_wod, stroke_exec, ipsec) + +# Date: WK14.52 +# Operation : Feature for ePDG +# Purpose : handle tunnel interface +allow epdg_wod system_file:file { read getattr open execute execute_no_trans }; +allow epdg_wod self:tun_socket { relabelfrom relabelto create }; +allow epdg_wod tun_device:chr_file { read write ioctl open }; +allow epdg_wod self:netlink_route_socket { setopt nlmsg_write read bind create nlmsg_read write getattr }; +allow epdg_wod self:capability { net_admin dac_override kill }; + +# Purpose : update ipsec deamon +allow epdg_wod ipsec_exec:file { read getattr open execute execute_no_trans }; + +# Purpose : send signal to process (ipsec/charon) +allow epdg_wod ipsec:process signal; + +# Purpose : set property for debug messages +allow epdg_wod init:unix_stream_socket connectto; +allow epdg_wod mtk_wod_prop:property_service set; +allow epdg_wod property_socket:sock_file write; + +# Purpose : Query ePDG IP address +allow epdg_wod dnsproxyd_socket:sock_file write; +allow epdg_wod netd:unix_stream_socket connectto; + +# Purpose : removal old charon/starter PID file +allow epdg_wod vpn_data_file:dir { search write remove_name }; +allow epdg_wod vpn_data_file:file { read getattr open unlink }; + +# Purpose : create strongswan config file for IKEv2 Tunnel +allow epdg_wod wod_apn_conf_file:dir { write read open add_name remove_name search }; +allow epdg_wod wod_apn_conf_file:file { write create unlink open getattr }; +allow epdg_wod wod_ipsec_conf_file:file { write create unlink open getattr }; +allow epdg_wod wod_ipsec_conf_file:dir { write read open add_name remove_name search }; + +# +# TODO: NEED PATCH before 20150331, need to remove shell command +# +#allow epdg_wod shell_exec:file { read execute open execute_no_trans }; + diff --git a/sepolicy/factory.te b/sepolicy/factory.te new file mode 100644 index 0000000..c3a105a --- /dev/null +++ b/sepolicy/factory.te @@ -0,0 +1,139 @@ +# ============================================== +# Policy File of /system/binfactory Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type factory_exec , exec_type, file_type; +type factory ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive factory; +init_daemon_domain(factory) +#unconfined_domain(factory) + +#============= factory ============== +allow factory FM50AF_device:chr_file { read write ioctl open }; +allow factory AD5820AF_device:chr_file { read write ioctl open }; +allow factory DW9714AF_device:chr_file { read write ioctl open }; +allow factory DW9714A_device:chr_file { read write ioctl open }; +allow factory LC898122AF_device:chr_file { read write ioctl open }; +allow factory LC898212AF_device:chr_file { read write ioctl open }; +allow factory BU6429AF_device:chr_file { read write ioctl open }; +allow factory DW9718AF_device:chr_file { read write ioctl open }; +allow factory BU64745GWZAF_device:chr_file { read write ioctl open }; +# Camera bu64245 +allow factory BU64245_device:chr_file { read write ioctl open }; +allow factory MTK_SMI_device:chr_file { read ioctl open }; +allow factory accdet_device:chr_file { read ioctl open }; +allow factory als_ps_device:chr_file { read ioctl open }; +allow factory ashmem_device:chr_file execute; +allow factory audio_device:chr_file { read write ioctl open }; +allow factory camera_isp_device:chr_file { read write ioctl open }; +allow factory camera_pipemgr_device:chr_file { read ioctl open }; +allow factory camera_sysram_device:chr_file { read ioctl open }; +allow factory ccci_device:chr_file { read write ioctl open }; +allow factory MT_pmic_cali_device:chr_file { read ioctl open }; +allow factory barometer_device:chr_file { read ioctl open }; +allow factory mtk_kpd_device:chr_file { read ioctl open }; +allow factory ebc_device:chr_file { read write open }; +allow factory fm_device:chr_file { read write ioctl open }; +allow factory fuse:dir { read search open }; +allow factory gps_device:chr_file { read write open }; +allow factory graphics_device:chr_file { read write ioctl open }; +allow factory gsensor_device:chr_file { read ioctl open }; +allow factory gsm0710muxd_device:chr_file { read write ioctl open }; +allow factory gyroscope_device:chr_file { read ioctl open }; +allow factory init:unix_stream_socket connectto; +allow factory input_device:chr_file { read ioctl open }; +allow factory input_device:dir { read open }; +allow factory kd_camera_flashlight_device:chr_file { read write ioctl open }; +allow factory kd_camera_hw_device:chr_file { read write ioctl open }; +allow factory kernel:system module_request; +allow factory misc_sd_device:chr_file { read ioctl open }; +allow factory mnld_device:chr_file { read write ioctl open }; +allow factory mnld_exec:file { read execute open execute_no_trans }; +allow factory msensor_device:chr_file { read ioctl open }; +allow factory mt6605_device:chr_file { read write ioctl open getattr }; +allow factory node:tcp_socket node_bind; +allow factory nvram_data_file:dir { write read open add_name getattr setattr}; +allow factory nvram_data_file:file { write getattr setattr read create open }; +allow factory nvram_device:chr_file { read write ioctl open }; +allow factory platformblk_device:blk_file { read write open ioctl}; +allow factory self:capability sys_boot; +allow factory platformblk_device:dir search; +allow factory port:tcp_socket { name_bind name_connect }; +allow factory property_socket:sock_file write; +allow factory rtc_device:chr_file { read write ioctl open }; +allow factory self:capability { sys_module ipc_lock sys_nice dac_override net_raw fsetid net_admin sys_time }; +allow factory self:netlink_route_socket { bind create }; +allow factory self:process execmem; +allow factory self:tcp_socket { setopt read bind create accept write connect listen }; +allow factory self:udp_socket { create ioctl }; +allow factory stpbt_device:chr_file { read write open }; +allow factory sysfs:file write; +allow factory sysfs_wake_lock:file { read write open }; +allow factory system_data_file:dir { write remove_name add_name }; +allow factory system_data_file:sock_file { write create setattr }; +allow factory system_file:file execute_no_trans; +allow factory tmpfs:lnk_file read; +allow factory ttyGS_device:chr_file { read write open }; +allow factory wmtWifi_device:chr_file { write open }; +allow factory nvram_data_file:dir { create_dir_perms }; +allow factory nvram_data_file:file { create_file_perms }; +allow factory nvram_data_file:lnk_file read; +allow factory nvdata_file:dir { create_dir_perms }; +allow factory nvdata_file:file { create_file_perms }; +allow factory self:capability { sys_nice sys_time }; +allow factory system_data_file:dir { write add_name }; +allow factory rootfs:dir mounton; +allow factory vfat:dir { read open search mounton }; +allow factory vfat:filesystem { mount unmount }; +allow factory block_device:dir search; +allow factory graphics_device:dir search; +allow factory input_device:dir search; +allow factory self:capability sys_admin; +allow factory self:capability sys_boot; +allow factory labeledfs:filesystem unmount; +allow factory platformblk_device:blk_file { getattr ioctl }; +allow factory shell_exec:file execute; +allow factory MT_pmic_adc_cali_device:chr_file { read write ioctl open}; +allow factory audio_device:dir search; +allow factory nvram_data_file:dir search; +allow factory audiohal_prop:property_service set; +allow factory pmic_ftm_device:chr_file { read write ioctl open}; +allow factory powerctl_prop:property_service set; +allow factory ttyGS_device:chr_file { read write open ioctl}; +allow factory ttyMT_device:chr_file { read write open ioctl}; +allow factory irtx_device:chr_file { read write ioctl open }; +allow factory devpts:chr_file { read write getattr ioctl }; +allow factory vfat:dir search; +allow factory hrm_device:chr_file { read ioctl open }; + +# Date: WK14.47 +# Operation : Migration +# Purpose : CCCI +allow factory eemcs_device:chr_file { read write ioctl open }; + +# Purpose : SDIO +allow factory ttySDIO_device:chr_file { read write ioctl open }; + +# Date: WK15.01 +# Purpose : OTG Mount +allow factory fuse:dir mounton; +# Date: WK15.07 +# Purpose : use c2k flight mode; +allow factory vmodem_device:chr_file { read write ioctl open }; diff --git a/sepolicy/file.te b/sepolicy/file.te new file mode 100644 index 0000000..264f973 --- /dev/null +++ b/sepolicy/file.te @@ -0,0 +1,146 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +type custom_file, file_type, data_file_type; +type lost_found_data_file, file_type, data_file_type; +type dontpanic_data_file, file_type, data_file_type; +type resource_cache_data_file, file_type, data_file_type; +type http_proxy_cfg_data_file, file_type, data_file_type; +type acdapi_data_file, file_type, data_file_type; +type ppp_data_file, file_type, data_file_type; +type wide_dhcpv6_data_file, file_type, data_file_type; +type wpa_supplicant_data_file, file_type, data_file_type; +type radvd_data_file, file_type, data_file_type; +# Date : WK14.37 +# Operation : Migration +# Purpose : SF rtt dump +type sf_rtt_file, file_type, data_file_type; + +type dfo_socket, file_type; +type rild2_socket, file_type; +type rild3_socket, file_type; +type rild4_socket, file_type; +type rild_ims_socket, file_type; +type rild_oem_socket, file_type; +type rild_mtk_ut_socket, file_type; +type rild_mtk_ut_2_socket, file_type; +type rild_mtk_modem_socket, file_type; +type rild_atci_socket, file_type; +type rild_md2_socket, file_type; +type rild2_md2_socket, file_type; +type rild_debug_md2_socket, file_type; +type rild_oem_md2_socket, file_type; +type rild_mtk_ut_md2_socket, file_type; +type rild_mtk_ut_2_md2_socket, file_type; +type rild_mtk_modem_md2_socket, file_type; +type rild_atci_md2_socket, file_type; +type netdiag_socket, file_type; +type atci_service_socket, file_type; +type atci_serv_fw_socket, file_type; +type atci_audio_socket, file_type; +type wpa_wlan0_socket, file_type; +type soc_vt_tcv_socket, file_type; +type soc_vt_stk_socket, file_type; +type soc_vt_svc_socket, file_type; +type dbus_bluetooth_socket, file_type; +type bt_int_adp_socket, file_type; +type bt_a2dp_stream_socket, file_type; +type bt_data_file, file_type, data_file_type; +type proc_thermal, fs_type; +type proc_mtkcooler, fs_type; +type proc_mtktz, fs_type; +type proc_slogger, fs_type; +type proc_lk_env, fs_type; +type sysfs_vcorefs_pwrctrl, fs_type, sysfs_type; + +type agpsd_socket, file_type; +type agpsd_data_file, file_type, data_file_type; +type mnld_socket, file_type; +type mnld_data_file, file_type, data_file_type; +type sysctl_socket, file_type; + +type backuprestore_socket, file_type; +type nfc_socket, file_type; + +type protect_f_data_file, file_type, data_file_type; +type protect_s_data_file, file_type, data_file_type; +type persist_data_file, file_type, data_file_type; +type nvram_data_file, file_type, data_file_type; +type nvdata_file, file_type, data_file_type; +type mediaserver_data_file, file_type, data_file_type; + +# 20131213 KKMR1_CQ_CTS_02 +allow asec_apk_file rootfs:filesystem associate; + + +# 20131213 KKMR1_CQ_CTS_02 +allow cache_file rootfs:filesystem associate; + + +allow custom_file rootfs:filesystem associate; + +# Modem Log folder +type mdlog_data_file, file_type, data_file_type; + +#mobilelog data/misc/mblog +type logmisc_data_file, file_type, data_file_type; + +#mobilelog data/log_temp +type logtemp_data_file, file_type, data_file_type; + +# NE core_forwarder +type aee_core_data_file, file_type, data_file_type; + +# AEE exp +type aee_exp_data_file, file_type, data_file_type; +type aee_dumpsys_data_file, file_type, data_file_type; + +# SF bqdump +type sf_bqdump_data_file, file_type, data_file_type; + +#for 3Gdongle +type rild-dongle_socket, file_type; + +type ccci_cfg_file, file_type, data_file_type; +#For sensor +type msensord_daemon, fs_type,sysfs_type; +type msensord_daemon2, fs_type,sysfs_type; +type akmd8963_access_file1, file_type,data_file_type; +type akmd8963_access_file2, file_type,data_file_type; +type gyroscope_mpud6050_chipinfo, fs_type,sysfs_type; +type gyroscope_mpud6050_status, fs_type,sysfs_type; +type gyroscope_mpud6050_use, fs_type,sysfs_type; +type gyroscope_mpud6050_file, fs_type,sysfs_type; +type sensor_data_file, file_type,data_file_type; +type system_sensor_data_file, file_type; +type bmm050_sensor_log_file, file_type,data_file_type; +type sysfs_gsensor_file, file_type,sysfs_type; +type sysfs_msensor_file, file_type,sysfs_type; +type sysfs_keypad_file, file_type,sysfs_type; +type istd8303_access_file1, file_type,data_file_type; +type istd8303_access_file2, file_type,data_file_type; + + +type rild_via_socket, file_type; +type rpc_socket, file_type; +type rild_ctclient_socket, file_type; +type rild_atci_c2k_socket, file_type; +type statusd_socket, file_type; +#For icusb +type proc_icusb, fs_type; + +#for drm key install +type provision_file, file_type, data_file_type; +#20141222 Add EPDG socket usage +type wod_ipsec_conf_file, file_type, data_file_type; +type wod_apn_conf_file, file_type, data_file_type; +type wod_action_socket, file_type; +type wod_sim_socket, file_type; +type wod_ipsec_socket, file_type; + +# for labeling /mnt/cd-rom as iso9660 +type iso9660, fs_type; + +# data_tmpfs_log +type data_tmpfs_log_file, file_type, data_file_type; diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts new file mode 100644 index 0000000..37ee87b --- /dev/null +++ b/sepolicy/file_contexts @@ -0,0 +1,411 @@ +# +############################# +# Custom files +/custom(/.*)? u:object_r:custom_file:s0 + + +############################# +# Data files +# +/data/aee_exp(/.*)? u:object_r:aee_exp_data_file:s0 +/data/agps_supl(/.*)? u:object_r:agpsd_data_file:s0 +/data/anr/SF_RTT(/.*)? u:object_r:sf_rtt_file:s0 +/data/app/mcRegistry(/.*)? u:object_r:mobicore_data_file:s0 +/data/@btmtk(/.*)? u:object_r:bt_data_file:s0 +/data/ccci_cfg(/.*)? u:object_r:ccci_cfg_file:s0 +/data/core(/.*)? u:object_r:aee_core_data_file:s0 +/data/dontpanic(/.*)? u:object_r:dontpanic_data_file:s0 +/data/dumpsys(/.*)? u:object_r:aee_dumpsys_data_file:s0 +/data/extmdl(/.*)? u:object_r:mdlog_data_file:s0 +/data/http-proxy-cfg(/.*)? u:object_r:http_proxy_cfg_data_file:s0 +/data/log_temp(/.*)? u:object_r:logtemp_data_file:s0 +/data/lost\+found(/.*)? u:object_r:lost_found_data_file:s0 +/data/mdlog(/.*)? u:object_r:mdlog_data_file:s0 +/data/mdl(/.*)? u:object_r:mdlog_data_file:s0 +/data/mdl3(/.*)? u:object_r:mdlog_data_file:s0 +/data/mediaserver(/.*)? u:object_r:mediaserver_data_file:s0 +/data/misc/acdapi(/.*)? u:object_r:acdapi_data_file:s0 +/data/misc/akmd_set.txt u:object_r:akmd8963_access_file1:s0 +/data/misc/mblog(/.*)? u:object_r:logmisc_data_file:s0 +/data/misc/PDC.ini u:object_r:akmd8963_access_file2:s0 +/data/misc/ppp(/.*)? u:object_r:ppp_data_file:s0 +/data/misc/radvd(/.*)? u:object_r:radvd_data_file:s0 +/data/misc/sensor.log u:object_r:bmm050_sensor_log_file:s0 +/data/misc/sensor(/.*)? u:object_r:sensor_data_file:s0 +/data/misc/wide-dhcpv6(/.*)? u:object_r:wide_dhcpv6_data_file:s0 +/data/misc/wpa_supplicant(/.*)? u:object_r:wpa_supplicant_data_file:s0 +/data/nfc_socket(/.*)? u:object_r:nfc_socket:s0 +/data/nvram(/.*)? u:object_r:nvram_data_file:s0 +/nvdata(/.*)? u:object_r:nvdata_file:s0 +/data/SF_dump(./*)? u:object_r:sf_bqdump_data_file:s0 +/data/ipsec(./*)? u:object_r:wod_ipsec_conf_file:s0 +/data/ipsec/wo(./*)? u:object_r:wod_apn_conf_file:s0 +/data/data_tmpfs_log(/.*)? u:object_r:data_tmpfs_log_file:s0 +/data/tmp_mnt/data_tmpfs_log(/.*)? u:object_r:data_tmpfs_log_file:s0 + +########################## +# Devices +# +/dev/aal_als(/.*)? u:object_r:aal_als_device:s0 +/dev/accdet(/.*)? u:object_r:accdet_device:s0 +/dev/AD5820AF(/.*)? u:object_r:AD5820AF_device:s0 +/dev/aed[0-9]+ u:object_r:aed_device:s0 +/dev/als_ps(/.*)? u:object_r:als_ps_device:s0 +/dev/ampc0(/.*)? u:object_r:ampc0_device:s0 +/dev/android(/.*)? u:object_r:android_device:s0 +/dev/barometer(/.*)? u:object_r:barometer_device:s0 +/dev/block/mmcblk[0-9a-z]* u:object_r:mmcblk_device:s0 +/dev/block/platform(/.*)? u:object_r:platformblk_device:s0 +/dev/block/vold(/.*)? u:object_r:voldblk_device:s0 +/dev/block/zram0(/.*)? u:object_r:zram0_device:s0 +/dev/bmtpool(/.*)? u:object_r:bmtpool_device:s0 +/dev/bootimg(/.*)? u:object_r:bootimg_device:s0 +/dev/BOOT(/.*)? u:object_r:BOOT_device:s0 +/dev/btif(/.*)? u:object_r:btif_device:s0 +/dev/btn(/.*)? u:object_r:btn_device:s0 +/dev/BU6429AF(/.*)? u:object_r:BU6429AF_device:s0 +/dev/BU64745GWZAF(/.*)? u:object_r:BU64745GWZAF_device:s0 +/dev/cache(/.*)? u:object_r:cache_device:s0 +/dev/CAM_CAL_DRV(/.*)? u:object_r:CAM_CAL_DRV_device:s0 +/dev/camera-fdvt(/.*)? u:object_r:camera_fdvt_device:s0 +/dev/camera-isp(/.*)? u:object_r:camera_isp_device:s0 +/dev/camera-pipemgr(/.*)? u:object_r:camera_pipemgr_device:s0 +/dev/camera-sysram(/.*)? u:object_r:camera_sysram_device:s0 +/dev/ccci_monitor u:object_r:ccci_monitor_device:s0 +/dev/ccci.* u:object_r:ccci_device:s0 +/dev/cpu_dma_latency(/.*)? u:object_r:cpu_dma_latency_device:s0 +/dev/devmap(/.*)? u:object_r:devmap_device:s0 +/dev/dummy_cam_cal(/.*)? u:object_r:dummy_cam_cal_device:s0 +/dev/DW9714AF(/.*)? u:object_r:DW9714AF_device:s0 +/dev/AK7345AF(/.*)? u:object_r:AK7345AF_device:s0 +/dev/DW9714A(/.*)? u:object_r:DW9714A_device:s0 +/dev/DW9718AF(/.*)? u:object_r:DW9718AF_device:s0 +/dev/ebc(/.*)? u:object_r:ebc_device:s0 +/dev/ebr[0-9]+ u:object_r:ebr_device:s0 +/dev/eemcs.* u:object_r:eemcs_device:s0 +/dev/emd.* u:object_r:emd_device:s0 +/dev/etb u:object_r:etb_device:s0 +/dev/exm0(/.*)? u:object_r:exm0_device:s0 +/dev/expdb(/.*)? u:object_r:expdb_device:s0 +/dev/fat(/.*)? u:object_r:fat_device:s0 +/dev/FM50AF(/.*)? u:object_r:FM50AF_device:s0 +/dev/fm(/.*)? u:object_r:fm_device:s0 +/dev/gps(/.*)? u:object_r:gps_device:s0 +/dev/gsensor(/.*)? u:object_r:gsensor_device:s0 +/dev/gyroscope(/.*)? u:object_r:gyroscope_device:s0 +/dev/hdmitx(/.*)? u:object_r:graphics_device:s0 +/dev/hid-keyboard(/.*)? u:object_r:hid_keyboard_device:s0 +/dev/hotknot(/.*)? u:object_r:hotknot_device:s0 +/dev/hwmsensor(/.*)? u:object_r:hwmsensor_device:s0 +/dev/ion(/.*)? u:object_r:ion_device:s0 +/dev/kd_camera_flashlight(/.*)? u:object_r:kd_camera_flashlight_device:s0 +/dev/kd_camera_hw_bus2(/.*)? u:object_r:kd_camera_hw_bus2_device:s0 +/dev/kd_camera_hw(/.*)? u:object_r:kd_camera_hw_device:s0 +/dev/LC898122AF(/.*)? u:object_r:LC898122AF_device:s0 +/dev/LC898212AF(/.*)? u:object_r:LC898212AF_device:s0 +/dev/logo(/.*)? u:object_r:logo_device:s0 +/dev/loop-control(/.*)? u:object_r:loop-control_device:s0 +/dev/M4U_device(/.*)? u:object_r:M4U_device_device:s0 +/dev/m_acc_misc(/.*)? u:object_r:m_acc_misc_device:s0 +/dev/mali.* u:object_r:gpu_device:s0 +/dev/MATV(/.*)? u:object_r:MATV_device:s0 +/dev/m_batch_misc(/.*)? u:object_r:m_batch_misc_device:s0 +/dev/mbr(/.*)? u:object_r:mbr_device:s0 +/dev/md32(/.*)? u:object_r:md32_device:s0 +/dev/met(/.*)? u:object_r:met_device:s0 +/dev/misc-sd(/.*)? u:object_r:misc_sd_device:s0 +/dev/misc(/.*)? u:object_r:misc_device:s0 +/dev/misc2(/.*)? u:object_r:misc2_device:s0 +/dev/MJC(/.*)? u:object_r:MJC_device:s0 +/dev/m_mag_misc(/.*)? u:object_r:m_mag_misc_device:s0 +/dev/mmp(/.*)? u:object_r:mmp_device:s0 +/dev/mobicore u:object_r:mobicore_admin_device:s0 +/dev/mobicore-user u:object_r:mobicore_user_device:s0 +/dev/t-base-tui u:object_r:mobicore_tui_device:s0 +/dev/msensor(/.*)? u:object_r:msensor_device:s0 +/dev/MT6516_H264_DEC(/.*)? u:object_r:MT6516_H264_DEC_device:s0 +/dev/mt6516-IDP(/.*)? u:object_r:mt6516_IDP_device:s0 +/dev/MT6516_Int_SRAM(/.*)? u:object_r:MT6516_Int_SRAM_device:s0 +/dev/mt6516-isp(/.*)? u:object_r:mt6516_isp_device:s0 +/dev/mt6516_jpeg(/.*)? u:object_r:mt6516_jpeg_device:s0 +/dev/MT6516_MM_QUEUE(/.*)? u:object_r:MT6516_MM_QUEUE_device:s0 +/dev/MT6516_MP4_DEC(/.*)? u:object_r:MT6516_MP4_DEC_device:s0 +/dev/MT6516_MP4_ENC(/.*)? u:object_r:MT6516_MP4_ENC_device:s0 +/dev/mt6605 u:object_r:mt6605_device:s0 +/dev/mt9p012(/.*)? u:object_r:mt9p012_device:s0 +/dev/mtfreqhopping(/.*)? u:object_r:mtfreqhopping_device:s0 +/dev/mtgpio(/.*)? u:object_r:mtgpio_device:s0 +/dev/mtk-adc-cali(/.*)? u:object_r:mtk-adc-cali_device:s0 +/dev/mtk_disp.* u:object_r:graphics_device:s0 +/dev/mtkfb_vsync(/.*)? u:object_r:graphics_device:s0 +/dev/mtkg2d(/.*)? u:object_r:mtkg2d_device:s0 +/dev/mtk_jpeg(/.*)? u:object_r:mtk_jpeg_device:s0 +/dev/mtk-kpd(/.*)? u:object_r:mtk_kpd_device:s0 +/dev/mtk_sched(/.*)? u:object_r:mtk_sched_device:s0 +/dev/MTK_SMI(/.*)? u:object_r:MTK_SMI_device:s0 +/dev/mtk_rrc(/.*)? u:object_r:mtk_rrc_device:s0 +/dev/mt-mdp(/.*)? u:object_r:mt_mdp_device:s0 +/dev/mt_otg_test(/.*)? u:object_r:mt_otg_test_device:s0 +/dev/MT_pmic_adc_cali u:object_r:MT_pmic_adc_cali_device:s0 +/dev/MT_pmic_adc_cali(/.*)? u:object_r:MT_pmic_cali_device:s0 +/dev/MT_pmic(/.*)? u:object_r:MT_pmic_device:s0 +/dev/network.* u:object_r:network_device:s0 +/dev/nvram(/.*)? u:object_r:nvram_device:s0 +/dev/nxpspk(/.*)? u:object_r:smartpa_device:s0 +/dev/otp u:object_r:otp_device:s0 +/dev/pmem_multimedia(/.*)? u:object_r:pmem_multimedia_device:s0 +/dev/pmt(/.*)? u:object_r:pmt_device:s0 +/dev/preloader(/.*)? u:object_r:preloader_device:s0 +/dev/pro_info(/.*)? u:object_r:pro_info_device:s0 +/dev/protect_f(/.*)? u:object_r:protect_f_device:s0 +/dev/protect_s(/.*)? u:object_r:protect_s_device:s0 +/dev/psaux(/.*)? u:object_r:psaux_device:s0 +/dev/ptmx(/.*)? u:object_r:ptmx_device:s0 +/dev/ptyp.* u:object_r:ptyp_device:s0 +/dev/pvr_sync(/.*)? u:object_r:gpu_device:s0 +/dev/qemu_pipe(/.*)? u:object_r:qemu_pipe_device:s0 +/dev/recovery(/.*)? u:object_r:recovery_device:s0 +/dev/rfkill(/.*)? u:object_r:rfkill_device:s0 +/dev/rtc[0-9]+ u:object_r:rtc_device:s0 +/dev/RT_Monitor(/.*)? u:object_r:RT_Monitor_device:s0 +/dev/kick_powerkey(/.*)? u:object_r:kick_powerkey_device:s0 +/dev/seccfg(/.*)? u:object_r:seccfg_device:s0 +/dev/sec_ro(/.*)? u:object_r:sec_ro_device:s0 +/dev/sec(/.*)? u:object_r:sec_device:s0 +/dev/tee1 u:object_r:tee_part_device:s0 +/dev/tee2 u:object_r:tee_part_device:s0 +/dev/sensor(/.*)? u:object_r:sensor_device:s0 +/dev/smartpa_i2c(/.*)? u:object_r:smartpa1_device:s0 +/dev/snapshot(/.*)? u:object_r:snapshot_device:s0 +/dev/socket/adbd(/.*)? u:object_r:adbd_socket:s0 +/dev/socket/agpsd2(/.*)? u:object_r:agpsd_socket:s0 +/dev/socket/agpsd3(/.*)? u:object_r:agpsd_socket:s0 +/dev/socket/agpsd(/.*)? u:object_r:agpsd_socket:s0 +/dev/socket/atci-audio(/.*)? u:object_r:atci_audio_socket:s0 +/dev/socket/atci-serv-fw(/.*)? u:object_r:atci_serv_fw_socket:s0 +/dev/socket/atci-service(/.*)? u:object_r:atci_service_socket:s0 +/dev/socket/backuprestore(/.*)? u:object_r:backuprestore_socket:s0 +/dev/socket/bluetooth(/.*)? u:object_r:bluetooth_socket:s0 +/dev/socket/bt.a2dp.stream(/.*)? u:object_r:bt_a2dp_stream_socket:s0 +/dev/socket/bt.int.adp(/.*)? u:object_r:bt_int_adp_socket:s0 +/dev/socket/dbus_bluetooth(/.*)? u:object_r:dbus_bluetooth_socket:s0 +/dev/socket/dfo(/.*)? u:object_r:dfo_socket:s0 +/dev/socket/dnsproxyd(/.*)? u:object_r:dnsproxyd_socket:s0 +/dev/socket/dumpstate(/.*)? u:object_r:dumpstate_socket:s0 +/dev/socket/installd(/.*)? u:object_r:installd_socket:s0 +/dev/socket/mdnsd(/.*)? u:object_r:mdnsd_socket:s0 +/dev/socket/mdns(/.*)? u:object_r:mdns_socket:s0 +/dev/socket/mnld(/.*)? u:object_r:mnld_socket:s0 +/dev/socket/mtpd(/.*)? u:object_r:mtpd_socket:s0 +/dev/socket/netdiag(/.*)? u:object_r:netdiag_socket:s0 +/dev/socket/netd(/.*)? u:object_r:netd_socket:s0 +/dev/socket/racoon(/.*)? u:object_r:racoon_socket:s0 +/dev/socket/rild2-md2(/.*)? u:object_r:rild2_md2_socket:s0 +/dev/socket/rild2(/.*)? u:object_r:rild2_socket:s0 +/dev/socket/rild3(/.*)? u:object_r:rild3_socket:s0 +/dev/socket/rild4(/.*)? u:object_r:rild4_socket:s0 +/dev/socket/rild-ims(/.*)? u:object_r:rild_ims_socket:s0 +/dev/socket/rild-atci-md2(/.*)? u:object_r:rild_atci_md2_socket:s0 +/dev/socket/rild-atci(/.*)? u:object_r:rild_atci_socket:s0 +/dev/socket/rild-ctclient u:object_r:rild_ctclient_socket:s0 +/dev/socket/rild-debug-md2(/.*)? u:object_r:rild_debug_md2_socket:s0 +/dev/socket/rild-debug(/.*)? u:object_r:rild_debug_socket:s0 +/dev/socket/rild-dongle(/.*)? u:object_r:rild-dongle_socket:s0 +/dev/socket/rild-md2(/.*)? u:object_r:rild_md2_socket:s0 +/dev/socket/rild-mtk-modem-md2(/.*)? u:object_r:rild_mtk_modem_md2_socket:s0 +/dev/socket/rild-mtk-modem(/.*)? u:object_r:rild_mtk_modem_socket:s0 +/dev/socket/rild-mtk-ut-2-md2(/.*)? u:object_r:rild_mtk_ut_2_md2_socket:s0 +/dev/socket/rild-mtk-ut-2(/.*)? u:object_r:rild_mtk_ut_2_socket:s0 +/dev/socket/rild-mtk-ut-md2(/.*)? u:object_r:rild_mtk_ut_md2_socket:s0 +/dev/socket/rild-mtk-ut(/.*)? u:object_r:rild_mtk_ut_socket:s0 +/dev/socket/rild-oem-md2(/.*)? u:object_r:rild_oem_md2_socket:s0 +/dev/socket/rild-oem(/.*)? u:object_r:rild_oem_socket:s0 +/dev/socket/rild(/.*)? u:object_r:rild_socket:s0 +/dev/socket/rild-via u:object_r:rild_via_socket:s0 +/dev/socket/rild-atci-c2k(/.*)? u:object_r:rild_atci_c2k_socket:s0 +/dev/socket/rpc u:object_r:rpc_socket:s0 +/dev/socket/soc_vt_stk(/.*)? u:object_r:soc_vt_stk_socket:s0 +/dev/socket/soc_vt_svc(/.*)? u:object_r:soc_vt_svc_socket:s0 +/dev/socket/soc_vt_tcv(/.*)? u:object_r:soc_vt_tcv_socket:s0 +/dev/socket/statusd u:object_r:statusd_socket:s0 +/dev/socket/sysctl(/.*)? u:object_r:sysctl_socket:s0 +/dev/socket/vold(/.*)? u:object_r:vold_socket:s0 +/dev/socket/volte_imsa1(/.*)? u:object_r:volte_imsa1_socket:s0 +/dev/socket/wpa_wlan0(/.*)? u:object_r:wpa_wlan0_socket:s0 +/dev/socket/zygote(/.*)? u:object_r:zygote_socket:s0 +/dev/socket/wod_action(/.*)? u:object_r:wod_action_socket:s0 +/dev/socket/wod_sim(/.*)? u:object_r:wod_sim_socket:s0 +/dev/socket/wod_ipsec(/.*)? u:object_r:wod_ipsec_socket:s0 +/dev/socket/tunman(/.*)? u:object_r:tunman_socket:s0 +/dev/stpant(/.*)? u:object_r:stpant_device:s0 +/dev/stpbt(/.*)? u:object_r:stpbt_device:s0 +/dev/stpgps u:object_r:mnld_device:s0 +/dev/stpgps(/.*)? u:object_r:stpgps_device:s0 +/dev/stpwmt(/.*)? u:object_r:stpwmt_device:s0 +/dev/sw_sync(/.*)? u:object_r:sw_sync_device:s0 +/dev/tgt(/.*)? u:object_r:tgt_device:s0 +/dev/touch(/.*)? u:object_r:touch_device:s0 +/dev/tpd_em_log(/.*)? u:object_r:tpd_em_log_device:s0 +/dev/ttyC0 u:object_r:gsm0710muxd_device:s0 +/dev/ttyC1 u:object_r:mdlog_device:s0 +/dev/ttyC2 u:object_r:agps_device:s0 +/dev/ttyC3 u:object_r:icusb_device:s0 +/dev/ttyGS.* u:object_r:ttyGS_device:s0 +/dev/ttyMT.* u:object_r:ttyMT_device:s0 +/dev/ttyp.* u:object_r:ttyp_device:s0 +/dev/ttySDIO.* u:object_r:ttySDIO_device:s0 +/dev/ttyUSB0 u:object_r:tty_device:s0 +/dev/ttyUSB1 u:object_r:tty_device:s0 +/dev/ttyUSB2 u:object_r:tty_device:s0 +/dev/ttyUSB3 u:object_r:tty_device:s0 +/dev/ttyUSB4 u:object_r:tty_device:s0 +/dev/TV-out(/.*)? u:object_r:TV_out_device:s0 +/dev/uboot(/.*)? u:object_r:uboot_device:s0 +/dev/uibc(/.*)? u:object_r:uibc_device:s0 +/dev/uinput(/.*)? u:object_r:uinput_device:s0 +/dev/uio0(/.*)? u:object_r:uio0_device:s0 +/dev/usrdata(/.*)? u:object_r:usrdata_device:s0 +/dev/Vcodec(/.*)? u:object_r:Vcodec_device:s0 +/dev/vmodem u:object_r:vmodem_device:s0 +/dev/vow(/.*)? u:object_r:vow_device:s0 +/dev/wmtdetect(/.*)? u:object_r:wmtdetect_device:s0 +/dev/wmtWifi(/.*)? u:object_r:wmtWifi_device:s0 +/dev/xlog u:object_r:xlog_device:s0 +/dev/offloadservice(/.*)? u:object_r:offloadservice_device:s0 +/dev/irtx u:object_r:irtx_device:s0 + +/dev/xt_qtaguid(/.*)? u:object_r:xt_qtaguid_device:s0 +/dev/pmic_ftm(/.*)? u:object_r:pmic_ftm_device:s0 +/dev/shf u:object_r:shf_device:s0 +/protect_f(/.*)? u:object_r:protect_f_data_file:s0 +/protect_s(/.*)? u:object_r:protect_s_data_file:s0 +/persist(/.*)? u:object_r:persist_data_file:s0 +/dev/ttyACM0 u:object_r:ttyACM_device:s0 +/dev/hrm u:object_r:hrm_device:s0 + +############################# +# sysfs files +# +/sys/bus/platform/drivers/gyrocope/chipinfo u:object_r:gyroscope_mpud6050_chipinfo:s0 +/sys/bus/platform/drivers/gyrocope/status u:object_r:gyroscope_mpud6050_status:s0 +/sys/bus/platform/drivers/msensor/daemon2 u:object_r:msensord_daemon2:s0 +/sys/bus/platform/drivers/msensor/daemon u:object_r:msensord_daemon:s0 +/sys/class/i2c-adapter/(/.*)? u:object_r:gyroscope_mpud6050_use:s0 +/sys/class/invensense_daemon_class/invensense_daemon_device(/.*)? u:object_r:gyroscope_mpud6050_file:s0 +/sys/devices/platform/gsensor/driver(/.*)? u:object_r:sysfs_gsensor_file:s0 +/sys/devices/platform/msensor/driver(/.*)? u:object_r:sysfs_msensor_file:s0 +/sys/bus/platform/drivers/mtk-kpd(/.*)? u:object_r:sysfs_keypad_file:s0 +/sys/power/vcorefs/pwr_ctrl -- u:object_r:sysfs_vcorefs_pwrctrl:s0 + + +############################# +# System files +# +/system/app/mcRegistry(/.*)? u:object_r:mobicore_data_file:s0 +/system/bin/6620_launcher u:object_r:mtk_6620_launcher_exec:s0 +/system/bin/aal u:object_r:aal_exec:s0 +/system/bin/aee_core_forwarder u:object_r:aee_core_forwarder_exec:s0 +/system/bin/akmd8963 u:object_r:akmd8963_exec:s0 +/system/bin/akmd8975 u:object_r:akmd8975_exec:s0 +/system/bin/ami304d u:object_r:ami304d_exec:s0 +/system/bin/atcid u:object_r:atcid_exec:s0 +/system/bin/atci_service u:object_r:atci_service_exec:s0 +/system/bin/audiocmdservice_atci u:object_r:audiocmdservice_atci_exec:s0 +/system/bin/autokd u:object_r:autokd_exec:s0 +/system/bin/batterywarning u:object_r:batterywarning_exec:s0 +/system/bin/bmm050d u:object_r:bmm050d_exec:s0 +/system/bin/boot_logo_updater u:object_r:boot_logo_updater_exec:s0 +/system/bin/br_app_data_service u:object_r:br_app_data_service_exec:s0 +/system/bin/ccci_fsd u:object_r:ccci_fsd_exec:s0 +/system/bin/ccci_mdinit u:object_r:ccci_mdinit_exec:s0 +/system/bin/ccci_rpcd u:object_r:ccci_rpcd_exec:s0 +/system/bin/dhcp6c u:object_r:dhcp6c_exec:s0 +/system/bin/dm_agent_binder u:object_r:dm_agent_binder_exec:s0 +/system/bin/dmlog u:object_r:dmlog_exec:s0 +/system/bin/dongled u:object_r:usbdongled_exec:s0 +/system/bin/dualmdlogger u:object_r:dualmdlogger_exec:s0 +/system/bin/emdlogger[0-9]+ u:object_r:emdlogger_exec:s0 +/system/bin/em_svr u:object_r:em_svr_exec:s0 +/system/bin/factory u:object_r:factory_exec:s0 +/system/bin/flashlessd u:object_r:flashlessd_exec:s0 +/system/bin/fuelgauged u:object_r:fuelgauged_exec:s0 +/system/bin/geomagneticd u:object_r:geomagneticd_exec:s0 +/system/bin/GoogleOtaBinder u:object_r:GoogleOtaBinder_exec:s0 +/system/bin/gsm0710muxdmd2 u:object_r:gsm0710muxdmd2_exec:s0 +/system/bin/gsm0710muxd u:object_r:gsm0710muxd_exec:s0 +/system/bin/guiext-server u:object_r:guiext-server_exec:s0 +/system/bin/icusbd u:object_r:icusbd_exec:s0 +/system/bin/init.gprs-pppd u:object_r:zpppd_gprs_exec:s0 +/system/bin/ipod u:object_r:ipod_exec:s0 +/system/bin/launchpppoe u:object_r:launchpppoe_exec:s0 +/system/bin/matv u:object_r:matv_exec:s0 +/system/bin/mc6420d u:object_r:mc6420d_exec:s0 +/system/bin/mcDriverDaemon u:object_r:mobicore_exec:s0 +/system/bin/mdlogger u:object_r:mdlogger_exec:s0 +/system/bin/memsicd3416x u:object_r:memsicd3416x_exec:s0 +/system/bin/memsicd u:object_r:memsicd_exec:s0 +/system/bin/meta_tst u:object_r:meta_tst_exec:s0 + +/system/bin/mmp u:object_r:mmp_exec:s0 +/system/bin/mobile_log_d u:object_r:mobile_log_d_exec:s0 +/system/bin/mpud6050 u:object_r:mpud6050_exec:s0 +/system/bin/msensord u:object_r:msensord_exec:s0 +/system/bin/mtk_agpsd u:object_r:mtk_agpsd_exec:s0 +/system/bin/mtkbt u:object_r:mtkbt_exec:s0 +/system/bin/MtkCodecService u:object_r:MtkCodecService_exec:s0 +/system/bin/mtkrildmd2 u:object_r:mtkrildmd2_exec:s0 +/system/bin/mtkrild u:object_r:mtkrild_exec:s0 +/system/bin/muxreport u:object_r:muxreport_exec:s0 +/system/bin/netdiag u:object_r:netdiag_exec:s0 +/system/bin/nvram_agent_binder u:object_r:nvram_agent_binder_exec:s0 +/system/bin/nvram_daemon u:object_r:nvram_daemon_exec:s0 +/system/bin/orientationd u:object_r:orientationd_exec:s0 +/system/bin/permission_check u:object_r:permission_check_exec:s0 +/system/bin/poad u:object_r:poad_exec:s0 +/system/bin/ppl_agent u:object_r:ppl_agent_exec:s0 +/system/bin/pppd_dt u:object_r:pppd_dt_exec:s0 +/system/bin/pppd_via u:object_r:pppd_via_exec:s0 +/system/bin/pq u:object_r:pq_exec:s0 +/system/bin/resmon u:object_r:resmon_exec:s0 +/system/bin/rild_dongle u:object_r:ril-3gddaemon_exec:s0 +/system/bin/s62xd u:object_r:s62xd_exec:s0 +/system/bin/sn u:object_r:sn_exec:s0 +/system/bin/statusd u:object_r:statusd_exec:s0 +/system/bin/terservice u:object_r:terservice_exec:s0 +/system/bin/thermald u:object_r:thermald_exec:s0 +/system/bin/thermal_manager u:object_r:thermal_manager_exec:s0 +/system/bin/thermal u:object_r:thermal_exec:s0 +/system/bin/tiny_mkswap u:object_r:tiny_mkswap_exec:s0 +/system/bin/tiny_swapon u:object_r:tiny_swapon_exec:s0 +/system/bin/viarild u:object_r:viarild_exec:s0 +/system/bin/volte_imcb u:object_r:volte_imcb_exec:s0 +/system/bin/volte_stack u:object_r:volte_stack_exec:s0 +/system/bin/volte_ua u:object_r:volte_ua_exec:s0 +/system/bin/wifi2agps u:object_r:wifi2agps_exec:s0 +/system/bin/wmt_loader u:object_r:wmt_loader_exec:s0 +/system/bin/xlog u:object_r:xlog_exec:s0 +/system/bin/sbchk u:object_r:sbchk_exec:s0 +/system/bin/OperaMaxSystem u:object_r:tunman_exec:s0 +/system/etc/sensor(/.*)? u:object_r:system_sensor_data_file:s0 +/system/vendor/bin/pvrsrvctl u:object_r:pvrsrvctl_exec:s0 +/system/xbin/BGW u:object_r:BGW_exec:s0 +/system/xbin/mnld u:object_r:mnld_exec:s0 +/system/bin/md_ctrl u:object_r:md_ctrl_exec:s0 +/system/bin/cmddumper u:object_r:cmddumper_exec:s0 +/system/bin/epdg_wod u:object_r:epdg_wod_exec:s0 +/system/bin/ipsec u:object_r:ipsec_exec:s0 +/system/bin/charon u:object_r:charon_exec:s0 +/system/bin/starter u:object_r:starter_exec:s0 +/system/bin/stroke u:object_r:stroke_exec:s0 +/system/bin/mmc3524xd u:object_r:mmc3524xd_exec:s0 +/system/bin/vtservice u:object_r:vtservice_exec:s0 + +# Wallpaper file for smartbook +/data/system/users/[0-9]+/smartbook_wallpaper u:object_r:wallpaper_file:s0 + +# Camera stuff +/dev/BU64245(/.*)? u:object_r:BU64245_device:s0 + +# Live Display +/sys/devices/platform/mtk_disp_mgr.0/rgb u:object_r:livedisplay_sysfs:s0 + diff --git a/sepolicy/flashlessd.te b/sepolicy/flashlessd.te new file mode 100644 index 0000000..f9e8a58 --- /dev/null +++ b/sepolicy/flashlessd.te @@ -0,0 +1,10 @@ +# ============================================== +# Policy File of /system/bin/flashlessd Executable File + +type flashlessd_exec, exec_type, file_type; +type flashlessd, domain; + + +# permissive flashlessd; + +init_daemon_domain(flashlessd) diff --git a/sepolicy/fota1.te b/sepolicy/fota1.te new file mode 100644 index 0000000..3d0e06d --- /dev/null +++ b/sepolicy/fota1.te @@ -0,0 +1,23 @@ +# ============================================== +# Policy File of /system/bin/fota1 Executable File + +# ============================================== +# Type Declaration +# ============================================== +type fota1, domain; +type fota1_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(fota1) + +# Date : WK14.46 +# Operation : Migration +# Purpose : For recovery and tee1 upgrade +allow fota1 cache_file:file append; +allow fota1 misc_device:chr_file { write open }; +allow fota1 platformblk_device:blk_file { read write open }; +allow fota1 platformblk_device:dir search; +allow fota1 recovery_device:chr_file { read write open }; diff --git a/sepolicy/fs_use b/sepolicy/fs_use new file mode 100644 index 0000000..e04b587 --- /dev/null +++ b/sepolicy/fs_use @@ -0,0 +1,2 @@ +#Add support for ubifs +fs_use_xattr ubifs u:object_r:labeledfs:s0; diff --git a/sepolicy/fuelgauged.te b/sepolicy/fuelgauged.te new file mode 100644 index 0000000..4cb2827 --- /dev/null +++ b/sepolicy/fuelgauged.te @@ -0,0 +1,47 @@ +# ============================================== +# Policy File of /system/bin/fuelgauged Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type fuelgauged_exec , exec_type, file_type; +type fuelgauged ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive fuelgauged; +init_daemon_domain(fuelgauged) +#unconfined_domain(fuelgauged) +#write_klog(fuelgauged) + +# Data : WK14.43 +# Operation : Migration +# Purpose : Fuel Gauge daemon for access driver node +allow fuelgauged input_device:dir { search open read write }; +allow fuelgauged input_device:file { open read }; +allow fuelgauged mtk-adc-cali_device:chr_file { open ioctl read write }; + +#add by xiaoqin +allow fuelgauged kmsg_device:chr_file { open write }; +allow fuelgauged fuelgauged:netlink_kobject_uevent_socket { write create bind read}; +allow fuelgauged fuelgauged:netlink_socket { create bind write read}; +#add by xiaoqin + +allow fuelgauged input_device:dir { search open read write }; +allow fuelgauged input_device:file { open read }; +#allow fuelgauged fuelgauged_access_file1:file { open read write }; +#allow fuelgauged fuelgauged_access_file2:file { open read write}; +# Operate data partation directly, need modify later,e.g. use "data/misc/sensor". +allow fuelgauged system_data_file:dir { write add_name create setattr }; diff --git a/sepolicy/genfs_contexts b/sepolicy/genfs_contexts new file mode 100644 index 0000000..977c6d5 --- /dev/null +++ b/sepolicy/genfs_contexts @@ -0,0 +1,11 @@ + +genfscon proc /secmem0 u:object_r:proc_secmem:s0 + +genfscon proc /driver/thermal u:object_r:proc_thermal:s0 +genfscon proc /mtkcooler u:object_r:proc_mtkcooler:s0 +genfscon proc /mtktz u:object_r:proc_mtktz:s0 +genfscon proc /lk_env u:object_r:proc_lk_env:s0 +genfscon proc /driver/storage_logger u:object_r:proc_slogger:s0 +genfscon proc /driver/icusb u:object_r:proc_icusb:s0 + +genfscon iso9660 / u:object_r:iso9660:s0 diff --git a/sepolicy/geomagneticd.te b/sepolicy/geomagneticd.te new file mode 100644 index 0000000..07b86aa --- /dev/null +++ b/sepolicy/geomagneticd.te @@ -0,0 +1,26 @@ +# ============================================== +# Policy File of /system/bingeomagneticd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type geomagneticd_exec , exec_type, file_type; +type geomagneticd ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive geomagneticd; +init_daemon_domain(geomagneticd) +#unconfined_domain(geomagneticd) + +# Date : WK14.43 +# Operation : Migration +# Purpose : access sensor data and do calibration +allow geomagneticd input_device:chr_file { read ioctl open }; +allow geomagneticd input_device:dir { read search open }; +allow geomagneticd sysfs:file write; +allow geomagneticd system_data_file:dir { write remove_name add_name }; diff --git a/sepolicy/gpsd.te b/sepolicy/gpsd.te new file mode 100644 index 0000000..0ab2fdc --- /dev/null +++ b/sepolicy/gpsd.te @@ -0,0 +1,5 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + + diff --git a/sepolicy/gsm0710muxd.te b/sepolicy/gsm0710muxd.te new file mode 100644 index 0000000..d9d9b54 --- /dev/null +++ b/sepolicy/gsm0710muxd.te @@ -0,0 +1,42 @@ +# ============================================== +# Policy File of /system/bingsm0710muxd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type gsm0710muxd_exec , exec_type, file_type; +type gsm0710muxd ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(gsm0710muxd) +allow gsm0710muxd gsm0710muxd_device:chr_file open; +allow gsm0710muxd gsm0710muxd_device:chr_file { read write }; +allow gsm0710muxd ctl_rildaemon_prop:property_service set; +allow gsm0710muxd ctl_ril-daemon-mtk_prop:property_service set; +allow gsm0710muxd gsm0710muxd_prop:property_service set; +allow gsm0710muxd devpts:chr_file setattr; +allow gsm0710muxd device:dir write; +allow gsm0710muxd self:capability chown; +allow gsm0710muxd self:capability fowner; +allow gsm0710muxd device:dir add_name; +allow gsm0710muxd device:lnk_file create; +allow gsm0710muxd init:unix_stream_socket connectto; +allow gsm0710muxd property_socket:sock_file write; +allow gsm0710muxd self:capability setuid; +allow gsm0710muxd device:dir remove_name; +allow gsm0710muxd device:lnk_file unlink; +allow gsm0710muxd eemcs_device:chr_file open; +allow gsm0710muxd eemcs_device:chr_file { read write }; diff --git a/sepolicy/gsm0710muxdmd2.te b/sepolicy/gsm0710muxdmd2.te new file mode 100644 index 0000000..7ce2937 --- /dev/null +++ b/sepolicy/gsm0710muxdmd2.te @@ -0,0 +1,45 @@ +# ============================================== +# Policy File of /system/bingsm0710muxdmd2 Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type gsm0710muxdmd2_exec , exec_type, file_type; +type gsm0710muxdmd2 ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(gsm0710muxdmd2) +allow gsm0710muxdmd2 gsm0710muxd_device:chr_file open; +allow gsm0710muxdmd2 gsm0710muxd_device:chr_file { read write }; +allow gsm0710muxdmd2 ctl_ril-daemon-md2_prop:property_service set; +allow gsm0710muxdmd2 ril_mux_report_case_prop:property_service set; +allow gsm0710muxdmd2 ctl_muxreport-daemon_prop:property_service set; +allow gsm0710muxdmd2 gsm0710muxd_prop:property_service set; +allow gsm0710muxdmd2 devpts:chr_file setattr; +allow gsm0710muxdmd2 device:dir write; +allow gsm0710muxdmd2 self:capability chown; +allow gsm0710muxdmd2 self:capability fowner; +allow gsm0710muxdmd2 device:dir add_name; +allow gsm0710muxdmd2 device:lnk_file create; +allow gsm0710muxdmd2 init:unix_stream_socket connectto; +allow gsm0710muxdmd2 property_socket:sock_file write; +allow gsm0710muxdmd2 self:capability setuid; +allow gsm0710muxdmd2 device:dir remove_name; +allow gsm0710muxdmd2 device:lnk_file unlink; +allow gsm0710muxdmd2 eemcs_device:chr_file open; +allow gsm0710muxdmd2 eemcs_device:chr_file { read write }; +allow gsm0710muxdmd2 ctl_ril-daemon-md2_prop:property_service set; +allow gsm0710muxdmd2 emd_device:chr_file { read write open }; diff --git a/sepolicy/guiext-server.te b/sepolicy/guiext-server.te new file mode 100644 index 0000000..c961d31 --- /dev/null +++ b/sepolicy/guiext-server.te @@ -0,0 +1,31 @@ +# ============================================== +# Policy File of /system/bin/guiext-server Executable File + +# ============================================== +# Type Declaration +# ============================================== +type guiext-server, domain; +type guiext-server_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +init_daemon_domain(guiext-server) + +# to allocate GraphicBuffer +allow guiext-server surfaceflinger:binder call; +allow guiext-server surfaceflinger:fd use; +allow guiext-server gpu_device:chr_file { open read write ioctl }; + +# to be a service +allow guiext-server guiext-server_service:service_manager add; + +# for dump +allow guiext-server system_server:binder call; + +# for MiraVision +allow guiext-server graphics_device:chr_file { open read write ioctl }; + +# for CTS +allow guiext-server platform_app:binder call; +allow guiext-server app_data_file:file write; diff --git a/sepolicy/hci_attach.te b/sepolicy/hci_attach.te new file mode 100644 index 0000000..79b118a --- /dev/null +++ b/sepolicy/hci_attach.te @@ -0,0 +1,3 @@ +# ============================================== +# MTK Policy Rule +# ============ diff --git a/sepolicy/healthd.te b/sepolicy/healthd.te new file mode 100644 index 0000000..69904f5 --- /dev/null +++ b/sepolicy/healthd.te @@ -0,0 +1,11 @@ +# ============================================== +# MTK Policy Rule +# ============ + +#============= healthd ============== +allow healthd self:capability dac_override; +allow healthd mtkrild:unix_stream_socket connectto; +allow healthd rild_oem_socket:sock_file write; +allow healthd sysfs_vcorefs_pwrctrl:file write; +allow healthd app_data_file:file write; + diff --git a/sepolicy/hostapd.te b/sepolicy/hostapd.te new file mode 100644 index 0000000..bca40bb --- /dev/null +++ b/sepolicy/hostapd.te @@ -0,0 +1,15 @@ +# ==================================== +# MTK Policy Rule +# ==================================== + +# Date: 2014/09/15 +# Operation: [Pre-SQC] Hotspot Manager cannot communicate with framework +# Purpose: Add socket write permission for hostapd +allow hostapd system_wpa_socket:sock_file write; + + +# Date: 2014/10/13 +# Operation: [L-SQC] SELinux warning during whole chip reset +# Purpose: kernel module netdev-ap0 gets invalid during whole chip reset, no impact to normal flow, dontaudit +dontaudit hostapd kernel:system module_request; + diff --git a/sepolicy/icusbd.te b/sepolicy/icusbd.te new file mode 100644 index 0000000..4a8773b --- /dev/null +++ b/sepolicy/icusbd.te @@ -0,0 +1,35 @@ +# ============================================== +# Policy File of /system/binicusbd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type icusbd_exec , exec_type, file_type; +type icusbd ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + + +init_daemon_domain(icusbd) + +allow icusbd vdc_exec:file execute_no_trans; +allow icusbd icusb_device:chr_file rw_file_perms; +allow icusbd ccci_device:chr_file { read write ioctl open }; +allow icusbd proc_icusb:file { read write open }; +allow icusbd proc_icusb:dir search; +allow icusbd self:capability dac_override; +allow icusbd self:netlink_socket create_socket_perms; +allow icusbd usb_device:chr_file { read write ioctl open }; +allow icusbd usb_device:dir { read open search}; diff --git a/sepolicy/init.te b/sepolicy/init.te new file mode 100644 index 0000000..e6374dc --- /dev/null +++ b/sepolicy/init.te @@ -0,0 +1,15 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK14.34 +# Operation : Migration +# Purpose : for L early bring up: add for nvram command in init rc files +allow init nvram_data_file:dir { write search setattr read create open add_name }; +allow init nvdata_file:dir { write search setattr read create open add_name }; + +#============= init ============== +# Date : W14.42 +# Operation : Migration +# Purpose : for L : add for partition +allow init platformblk_device:blk_file setattr; diff --git a/sepolicy/init_shell.te b/sepolicy/init_shell.te new file mode 100644 index 0000000..4b5a0be --- /dev/null +++ b/sepolicy/init_shell.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============ + diff --git a/sepolicy/inputflinger.te b/sepolicy/inputflinger.te new file mode 100644 index 0000000..4b5a0be --- /dev/null +++ b/sepolicy/inputflinger.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============ + diff --git a/sepolicy/install_recovery.te b/sepolicy/install_recovery.te new file mode 100644 index 0000000..73e64c7 --- /dev/null +++ b/sepolicy/install_recovery.te @@ -0,0 +1,10 @@ +# Date : WK14.41 +# Operation : Migration +# Purpose : update recovery image +allow install_recovery bootimg_device:chr_file { open read write }; +allow install_recovery recovery_device:chr_file { open read write }; +allow install_recovery platformblk_device:dir search; +allow install_recovery platformblk_device:blk_file { open read write }; +allow install_recovery sysfs:file { open read write }; +allow install_recovery tee_part_device:chr_file *; +dontaudit install_recovery system_file:file entrypoint; diff --git a/sepolicy/installd.te b/sepolicy/installd.te new file mode 100644 index 0000000..79796be --- /dev/null +++ b/sepolicy/installd.te @@ -0,0 +1,57 @@ +# ============================================== +# MTK Policy Rule + +# Date : WK14.34 +# Operation : Migration +# Purpose : 6571/6572 GMO external memory access(/dev/exm0) +allow installd exm0_device:chr_file { read write ioctl open }; + +# Date : WK14.34 +# Operation : Migration +# Purpose : Move app to phone storage +# 1. Enter Settings->Apps +# 2. Select Downloaded tab +# 3. Choose the application and move to phone storage +# 4. Check the application in Phone storage tab +allow installd apk_tmp_file:dir getattr; +allow installd vfat:file getattr; + +# Date : WK14.34 +# Operation : Migration +# Purpose : for CIP project (access /custom partition) +allow installd custom_file:file { getattr read open }; +allow installd custom_file:dir search; + +# Date : WK14.34 +# Operation : Development GMO Feature "Move OAT to SD Card" +# Purpose : for GMO ROM Size Slim +allow installd dalvikcache_data_file:lnk_file { read getattr setattr unlink create }; +allow installd fuse:dir { write read remove_name search create add_name getattr setattr }; +allow installd fuse:file { write getattr setattr read create unlink open }; + +# Date : WK14.40 +# Operation : SQC1 +# Purpose : for access .android_secure +allow installd vfat:dir search; + +# Date : WK14.44 +# Operation : SQC1 +# Purpose : for phone encrypted +# Disabled 20150109 for bad policy review (ALPS01902735) +#allow installd unlabeled:fifo_file write; +#allow installd unlabeled:sock_file write; + +# Date : WK14.46 +# Operation : SQC1 +# Purpose : MOTA update KK to L, workaround for access /data/.layout_version +allow installd system_data_file:file open; + +# Date : WK15.02 +# Operation : SQC0 +# Purpose : ALPS01889518 (MTK MTBF) +allow installd platform_app:fd use; + +# Date : WK15.03 +# Operation : SQC1 +# Purpose : ALPS01911340 (MTK MTBF for GMO project) +allow installd platform_app_tmpfs:file { open read write getattr };
\ No newline at end of file diff --git a/sepolicy/ipod.te b/sepolicy/ipod.te new file mode 100644 index 0000000..ca37c28 --- /dev/null +++ b/sepolicy/ipod.te @@ -0,0 +1,88 @@ +# ============================================== +# Policy File of /system/binipod Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type ipod_exec , exec_type, file_type; +type ipod ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive ipod; +init_daemon_domain(ipod) +# unconfined_domain(ipod) + +# date: 2014/09/19 +# operation : migration +# purpose : allow ipod to perform binder IPC to control screen on/off via PowerManager +binder_use(ipod) +binder_service(ipod) +binder_call(ipod, system_server) +binder_call(ipod, surfaceflinger) + +allow ipod ctl_bootanim_prop:property_service set; +allow ipod ctl_ipod_prop:property_service set; +allow ipod ipod_prop:property_service set; +allow ipod powerctl_prop:property_service set; +allow ipod audiohal_prop:property_service set; +allow ipod system_prop:property_service set; +allow ipod shell_exec:file { read open execute_no_trans execute }; +allow ipod system_file:file execute_no_trans; + +# permissions for IPO with phone encrypted +# removed due to IPO will be disabled when phone is encrypted +# allow ipod vdc_exec:file { getattr execute read open execute_no_trans }; +# allow ipod vold_socket:sock_file write; +# allow ipod vold:unix_stream_socket connectto; + +allow ipod platformblk_device:blk_file { read open write }; +allow ipod platformblk_device:dir search; + +allow ipod self:capability dac_override; +allow ipod self:capability net_admin; +allow ipod kmsg_device:chr_file { open write }; +allow ipod property_socket:sock_file write; + +allow ipod init:dir getattr; +allow ipod init:unix_stream_socket connectto; +allow ipod sysfs_wake_lock:file { read write open getattr }; +allow ipod block_device:dir search; +allow ipod gpu_device:chr_file { read write open ioctl }; +allow ipod ipod:netlink_kobject_uevent_socket { create bind read setopt }; +allow ipod input_device:dir { open read search }; +allow ipod input_device:file { open read write ioctl }; +allow ipod input_device:chr_file { open read write ioctl }; +allow ipod rtc_device:chr_file { open read write ioctl }; +allow ipod sysfs:file { open read write getattr }; +allow ipod alarm_device:chr_file write; +allow ipod system_server:unix_stream_socket connectto; +allow ipod proc:file { open read write }; +allow ipod proc:dir { search getattr }; +allow ipod logo_device:chr_file { open read }; + +# reboot syscall to switch to recovery/factory mode instantly +allow ipod self:capability sys_boot; +allow ipod proc_sysrq:file { open write }; + +allow ipod debugfs:file { open read getattr }; + +# IPOH +allow ipod system_data_file:dir { open read write add_name create remove_name }; +allow ipod cache_file:dir { open read write add_name create remove_name }; +allow ipod cache_file:file { create open write ioctl setattr }; +allow ipod proc_lk_env:file { open read write }; +allow ipod misc_device:chr_file { open read write }; +allow ipod self:capability { chown sys_admin }; diff --git a/sepolicy/ipsec.te b/sepolicy/ipsec.te new file mode 100644 index 0000000..c4b2163 --- /dev/null +++ b/sepolicy/ipsec.te @@ -0,0 +1,75 @@ +# ============================================== +# Policy File of /system/bin/ipsec Executable File + +# ============================================== +# Type Declaration +# ============================================== +type starter_exec , exec_type, file_type; +type charon_exec , exec_type, file_type; +type ipsec_exec , exec_type, file_type; +type stroke_exec , exec_type, file_type; +type ipsec ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date: WK14.52 +# Operation : Feature developing for ePDG + +# Purpose : access xfrm +allow ipsec proc_net:file write; + +# Purpose : set property for ip address with epdg_wod +allow ipsec mtk_wod_prop:property_service set; +allow ipsec property_socket:sock_file write; + +# Purpose : send command to epdg_wod +allow ipsec wod_ipsec_socket:sock_file write; + +# Purpose : create socket for IKEv2 protocol +allow ipsec node:udp_socket node_bind; +allow ipsec port:tcp_socket name_connect; +allow ipsec port:udp_socket name_bind; + +# Purpose : Query DNS address +allow ipsec netd:unix_stream_socket connectto; +allow ipsec dnsproxyd_socket:sock_file write; + +# Purpose : access property socket +allow ipsec init:unix_stream_socket connectto; + +# Purpose : access socket of wod and property +allow ipsec epdg_wod:unix_stream_socket { read write connectto }; + +# Purpose : output to /dev/null +allow ipsec epdg_wod:fd use; + +# Purpose : starter invoke charon +allow ipsec charon_exec:file execute_no_trans; + +# Purpose : charon set fwmark +allow ipsec fwmarkd_socket:sock_file write; + +# Purpose : kernel ip/route operations +allow ipsec self:capability { net_admin net_bind_service dac_override kill }; + +# Purpose : send/receive packet to/from peer +allow ipsec self:tcp_socket { write getattr connect read getopt create }; +allow ipsec self:udp_socket { write bind create read setopt }; + +# Purpose : kernel ip/route operations +allow ipsec self:netlink_route_socket { write nlmsg_write read bind create nlmsg_read }; +allow ipsec self:netlink_xfrm_socket { write bind create read nlmsg_write nlmsg_read }; + +# Purpose : charon/starter PID file +allow ipsec vpn_data_file:dir { write remove_name add_name search }; +allow ipsec vpn_data_file:file { write create open getattr setattr read unlink }; +allow ipsec vpn_data_file:sock_file { write create unlink setattr }; + +# Purpose : read strongswan config file for IKEv2 Tunnel +allow ipsec wod_apn_conf_file:dir search; +allow ipsec wod_apn_conf_file:file { read ioctl open getattr }; +allow ipsec wod_ipsec_conf_file:file { read ioctl open getattr }; +allow ipsec wod_ipsec_conf_file:dir search; + diff --git a/sepolicy/isolated_app.te b/sepolicy/isolated_app.te new file mode 100644 index 0000000..86cbf61 --- /dev/null +++ b/sepolicy/isolated_app.te @@ -0,0 +1,5 @@ +# ============================================== +# MTK Policy Rule +# ============ + + diff --git a/sepolicy/kernel.te b/sepolicy/kernel.te new file mode 100644 index 0000000..6112da4 --- /dev/null +++ b/sepolicy/kernel.te @@ -0,0 +1,24 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK14.31 +# Operation : Migration +# Purpose : transit from kernel to aee_core_forwarder domain when executing aee_core_forwarder +domain_auto_trans(kernel, aee_core_forwarder_exec, aee_core_forwarder) + +# Date : WK14.38 +# Operation : Migration +# Purpose : run guitar_update for touch F/W upgrade. +allow kernel fuse:dir search; + +# Date : WK14.39 +# Operation : Migration +# Purpose : ums driver can access blk_file +allow kernel block_device:blk_file { read write }; +allow kernel loop_device:blk_file { read }; + +# Date : WK14.43 +# Operation : Migration +# Purpose : Access to TC1 partition for reading MAC +allow kernel platformblk_device:blk_file { open read write }; diff --git a/sepolicy/keystore.te b/sepolicy/keystore.te new file mode 100644 index 0000000..1c6acb8 --- /dev/null +++ b/sepolicy/keystore.te @@ -0,0 +1,14 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK14.40 2014/10/3 +# Operation : keystore CTS +# Purpose : Open MobiCore access permission for keystore CTS hardware-backed solution +allow keystore mobicore:unix_stream_socket { connectto read write }; +allow keystore mobicore_user_device:chr_file { read write open ioctl}; + +# Date : WK14.40 2014/12/26 +# Operation : CTS 5.0_r1 +# Purpose : allow access to /data/data/com.android.cts.security/cache/CTS_DUMP for full CTS +allow keystore app_data_file:file write;
\ No newline at end of file diff --git a/sepolicy/launchpppoe.te b/sepolicy/launchpppoe.te new file mode 100644 index 0000000..fc877a4 --- /dev/null +++ b/sepolicy/launchpppoe.te @@ -0,0 +1,19 @@ +# ============================================== +# Policy File of /system/bin/launchpppoe Executable File + +# ============================================== +# Type Declaration +# ============================================== +type launchpppoe, domain; +type launchpppoe_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== + + +# Date : WK14.38 +# Operation : Migration +# Purpose : transit to ppp directly since the resource are shared and serve the same purpose +domain_auto_trans(init, launchpppoe_exec, ppp) + diff --git a/sepolicy/lmkd.te b/sepolicy/lmkd.te new file mode 100644 index 0000000..2eab8cc --- /dev/null +++ b/sepolicy/lmkd.te @@ -0,0 +1,11 @@ +# ============================================== +# MTK Policy Rule +# ============ + + +# Data : 2015/01/14 +# Operation : MT6735 SQC bug fix +# Purpose : ALPS01905960 - selinux_warning: audit(1420845354.752:91): avc: denied { search } +# for pid=194 comm="lmkd" name="23573" dev="proc" +# ino=915740 scontext=u:r:lmkd:s0 tcontext=u:r:zygote:s0 tclass=dir permissive=0 +dontaudit lmkd zygote:dir *; diff --git a/sepolicy/logd.te b/sepolicy/logd.te new file mode 100644 index 0000000..379cdbc --- /dev/null +++ b/sepolicy/logd.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============ +dontaudit logd unlabeled:dir search; diff --git a/sepolicy/matv.te b/sepolicy/matv.te new file mode 100644 index 0000000..3f83ad9 --- /dev/null +++ b/sepolicy/matv.te @@ -0,0 +1,27 @@ +# ============================================== +# Policy File of /system/binmatv Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type matv_exec , exec_type, file_type; +type matv ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== +binder_use(matv) + +#permissive matv; +init_daemon_domain(matv) +#unconfined_domain(matv) diff --git a/sepolicy/mc6420d.te b/sepolicy/mc6420d.te new file mode 100644 index 0000000..427536c --- /dev/null +++ b/sepolicy/mc6420d.te @@ -0,0 +1,26 @@ +# ============================================== +# Policy File of /system/binmc6420d Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mc6420d_exec , exec_type, file_type; +type mc6420d ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive mc6420d; +init_daemon_domain(mc6420d) +#unconfined_domain(mc6420d) diff --git a/sepolicy/md_ctrl.te b/sepolicy/md_ctrl.te new file mode 100644 index 0000000..b286493 --- /dev/null +++ b/sepolicy/md_ctrl.te @@ -0,0 +1,23 @@ +# ============================================== +# Policy File of /system/bin/md_ctrl Executable File + +# ============================================== +# Type Declaration +# ============================================== +type md_ctrl, domain; +type md_ctrl_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +# Date : WK14.46 +# Operation : Migration +# Purpose : Start md_ctrl + +init_daemon_domain(md_ctrl) +allow md_ctrl ccci_device:chr_file { read write ioctl open }; +allow md_ctrl devpts:chr_file { read write getattr open ioctl }; +allow md_ctrl muxreport_exec:file { read execute open execute_no_trans }; +allow md_ctrl self:capability dac_override; +allow md_ctrl emd_device:chr_file { read write open }; + diff --git a/sepolicy/mdlogger.te b/sepolicy/mdlogger.te new file mode 100644 index 0000000..67bd14e --- /dev/null +++ b/sepolicy/mdlogger.te @@ -0,0 +1,62 @@ +# ============================================== +# Policy File of /system/binmdlogger Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mdlogger_exec , exec_type, file_type; +type mdlogger ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive mdlogger; +init_daemon_domain(mdlogger) + +binder_use(mdlogger) +binder_service(mdlogger) + +#=============allow mdlogger to set ============== +allow mdlogger debug_mdlogger_prop:property_service set; +allow mdlogger debug_prop:property_service set; +allow mdlogger ccci_device:chr_file { read write ioctl open }; +allow mdlogger ttyGS_device:chr_file { read write open ioctl}; +allow mdlogger fuse:dir { write search create rmdir add_name remove_name read open rename}; +allow mdlogger fuse:file { write read create open rename unlink getattr setattr append}; +allow mdlogger mdlog_data_file:dir { write search read create open rmdir remove_name add_name relabelto getattr}; +allow mdlogger mdlog_data_file:fifo_file { read open create setattr}; +allow mdlogger mdlog_data_file:file { write read create open rename unlink getattr setattr}; +allow mdlogger mdlog_device:chr_file { read write open ioctl}; +allow mdlogger system_data_file:dir { write create open add_name relabelfrom}; + +allow mdlogger init:unix_stream_socket connectto; +allow mdlogger property_socket:sock_file write; +allow mdlogger platform_app:unix_stream_socket connectto; + +allow mdlogger shell_exec:file { read execute open execute_no_trans }; +allow mdlogger system_file:file execute_no_trans; +allow mdlogger zygote_exec:file { read getattr open }; +allow mdlogger tmpfs:lnk_file read; + +#============= mdlogger usb logging ============== +# Date : 2014/09/26 +# Operation : Migration +# Purpose : [MDLOGGER] [mdlogger usb logging tcp_socket] +# Package: system/bin/mdlogger + +allow mdlogger fuse:dir search; +allow mdlogger node:tcp_socket node_bind; +allow mdlogger port:tcp_socket name_bind; +allow mdlogger self:tcp_socket { write read bind create setopt accept listen }; + diff --git a/sepolicy/mdnsd.te b/sepolicy/mdnsd.te new file mode 100644 index 0000000..7b20973 --- /dev/null +++ b/sepolicy/mdnsd.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + diff --git a/sepolicy/mediaserver.te b/sepolicy/mediaserver.te new file mode 100644 index 0000000..b1b4508 --- /dev/null +++ b/sepolicy/mediaserver.te @@ -0,0 +1,361 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date : WK15.02 +# Operation : 120Hz Feature SQC +# Purpose : for 120Hz Smart Switch +allow mediaserver mtk_rrc_device:chr_file { read write ioctl open }; + +# Date : WK14.31 +# Operation : Migration +# Purpose : for L early bring up. +allow mediaserver camera_isp_device:chr_file { read write ioctl open }; +allow mediaserver kd_camera_hw_device:chr_file { read write ioctl open }; +allow mediaserver self:capability { setuid ipc_lock }; +allow mediaserver sysfs_wake_lock:file { read write open }; +allow mediaserver MTK_SMI_device:chr_file { read ioctl open }; +allow mediaserver camera_pipemgr_device:chr_file { read ioctl open }; +allow mediaserver kd_camera_flashlight_device:chr_file { read write ioctl open }; +allow mediaserver self:capability sys_nice; + + +# Date : WK14.32 +# Operation : Migration +# Purpose : Set audio driver permission to access SD card for debug purpose and accss NVRam. +allow mediaserver sdcard_internal:dir { write create add_name }; +allow mediaserver sdcard_internal:file create; +allow mediaserver nvram_data_file:dir { add_name write search }; +allow mediaserver nvram_data_file:file { write getattr setattr read create open }; +allow mediaserver nvram_data_file:lnk_file read; +allow mediaserver nvdata_file:dir { add_name write search }; +allow mediaserver nvdata_file:file { write getattr setattr read create open }; +allow mediaserver fuse:dir remove_name; +allow mediaserver fuse:file unlink; + +# Date : WK14.34 +# Operation : Migration +# Purpose : for bring up +allow mediaserver platformblk_device:dir { search }; +allow mediaserver nvram_device:chr_file { open read write }; +allow mediaserver self:netlink_kobject_uevent_socket { create setopt bind }; +allow mediaserver self:capability { net_admin dac_override }; + +# Date : WK14.34 +# Operation : Migration +# Purpose : VP/VR +allow mediaserver devmap_device:chr_file { ioctl }; + +# Date : WK14.34 +# Operation : Migration +# Purpose : Smartcard Service +allow mediaserver self:netlink_kobject_uevent_socket read; +allow mediaserver system_data_file:file open; + +# Date : WK14.36 +# Operation : Migration +# Purpose : guiext service for VP +allow mediaserver guiext-server:binder { transfer call }; + +# Date : WK14.36 +# Operation : Migration +# Purpose : media server and bt process communication for A2DP data.and other control flow +allow mediaserver bluetooth:unix_dgram_socket sendto; +allow mediaserver bt_a2dp_stream_socket:sock_file write; +allow mediaserver bt_int_adp_socket:sock_file write; +allow mediaserver mtkbt:unix_dgram_socket sendto; + +# Date : WK14.37 +# Operation : Migration +# Purpose : WFD and MET Latency measurement +allow mediaserver media_wfd_prop:property_service set; + +# Date : WK14.37 +# Operation : Migration +# Purpose : camera ioctl +allow mediaserver camera_sysram_device:chr_file { read ioctl open }; + +# Date : WK14.36 +# Operation : Migration +# Purpose : VDEC/VENC device node +allow mediaserver Vcodec_device:chr_file { read write ioctl open }; + +# Date : WK14.36 +# Operation : Migration +# Purpose : MMProfile debug +# userdebug_or_eng(` +allow mediaserver debugfs:file {read ioctl}; +# ') + +# Date : WK14.36 +# Operation : Migration +# Purpose : bring up +allow mediaserver MtkCodecService:binder call; +allow mediaserver ccci_device:chr_file { read write ioctl open }; +allow mediaserver eemcs_device:chr_file { read write ioctl open }; +allow mediaserver devmap_device:chr_file { read open }; +allow mediaserver ebc_device:chr_file { read write ioctl open }; +allow mediaserver platformblk_device:blk_file { read write open }; +#allow mediaserver nvram_data_file:dir { write search }; +#allow mediaserver system_data_file:dir { write add_name }; +#allow mediaserver system_data_file:file { write create setattr }; + +# Date : WK14.36 +# Operation : Migration +# Purpose : for SW codec VP/VR +#allow mediaserver mtk_device:chr_file { read write ioctl open }; +allow mediaserver mtk_sched_device:chr_file { read write ioctl open }; + +# Date : WK14.36 +# Operation : Migration +# Purpose : for DRM VP +allow mediaserver platform_app:dir search; +allow mediaserver platform_app:file { read getattr open }; + + +# Date : WK14.38 +# Operation : Migration +# Purpose : NVRam access +allow mediaserver block_device:dir { write search }; + +# Date : WK14.38 +# Operation : Migration +# Purpose : FM driver access +allow mediaserver fm_device:chr_file { read write ioctl open }; + +# Data : WK14.38 +# Operation : Migration +# Purpose : for VP/VR +allow mediaserver block_device:dir search; +allow mediaserver FM50AF_device:chr_file { read write ioctl open }; +allow mediaserver AD5820AF_device:chr_file { read write ioctl open }; +allow mediaserver DW9714AF_device:chr_file { read write ioctl open }; +allow mediaserver AK7345AF_device:chr_file { read write ioctl open }; +allow mediaserver DW9714A_device:chr_file { read write ioctl open }; +allow mediaserver LC898122AF_device:chr_file { read write ioctl open }; +allow mediaserver LC898212AF_device:chr_file { read write ioctl open }; +allow mediaserver BU6429AF_device:chr_file { read write ioctl open }; +allow mediaserver DW9718AF_device:chr_file { read write ioctl open }; +allow mediaserver BU64745GWZAF_device:chr_file { read write ioctl open }; +allow mediaserver BU64245_device:chr_file { read write ioctl open }; + +# Data : WK14.38 +# Operation : Migration +# Purpose : WFD +allow mediaserver surfaceflinger:dir search; +allow mediaserver surfaceflinger:file { read open }; + +# Data : WK14.38 +# Operation : Migration +# Purpose : bring up +allow mediaserver bootanim:binder { transfer call }; +allow mediaserver tmpfs:lnk_file read; +#allow mediaserver default_android_service:service_manager { add }; + +# Data : WK14.38 +# Operation : Migration +# Purpose : bring up +allow mediaserver bt_data_file:dir { write add_name search}; +allow mediaserver bt_data_file:file { open write create setattr append }; + +# Data : WK14.38 +# Operation : Migration +# Purpose : dump for debug +allow mediaserver fuse:file append; + +# Date : WK14.39 +# Operation : Migration +# Purpose : FDVT Driver +allow mediaserver camera_fdvt_device:chr_file { read write ioctl open }; + +# Date : WK14.39 +# Operation : Migration +# Purpose : MJC Driver +allow mediaserver MJC_device:chr_file { read write ioctl open }; + +# Date : WK14.39 +# Operation : Migration +# Purpose : APE PLAYBACK +binder_call(mediaserver,MtkCodecService) + +# Data : WK14.39 +# Operation : Migration +# Purpose : dump for debug +allow mediaserver audiohal_prop:property_service set; + +# Data : WK14.39 +# Operation : Migration +# Purpose : HW encrypt SW codec +allow mediaserver mediaserver_data_file:file { create open read write setattr }; +allow mediaserver mediaserver_data_file:dir { search getattr open read write setattr add_name }; +allow mediaserver sec_device:chr_file { read open ioctl }; + +# Date : WK14.39 +# Operation : Migration +# Purpose : WFD UIBC Driver +allow mediaserver uibc_device:chr_file { read write getattr ioctl open }; + +# Date : WK14.40 +# Operation : Migration +# Purpose : HDMI driver access +allow mediaserver graphics_device:chr_file { read write ioctl open }; + +# Date : WK14.40 +# Operation : Migration +# Purpose : Smartpa +allow mediaserver smartpa_device:chr_file { read write ioctl open }; + +# Date : WK14.40 +# Operation : Migration +# Purpose : Smartpa +allow mediaserver smartpa1_device:chr_file { read write ioctl open }; + +# Data : WK14.40 +# Operation : Migration +# Purpose : permit 'call' by audio tunning tool audiocmdservice_atci +allow mediaserver audiocmdservice_atci:binder call; +binder_call(mediaserver,audiocmdservice_atci) + +# Date : WK14.40 +# Operation : Migration +# Purpose : mtk_jpeg +allow mediaserver mtk_jpeg_device:chr_file { read ioctl open }; + +# Date : WK14.41 +# Operation : Migration +# Purpose : Lossless BT audio +allow mediaserver shell_exec:file { read open execute execute_no_trans }; +allow mediaserver system_file:file execute_no_trans; +allow mediaserver zygote_exec:file execute_no_trans; + +# Date : WK14.41 +# Operation : Migration +# Purpose : WFD HID Driver +allow mediaserver uhid_device:chr_file { read write ioctl open }; + +# Date : WK14.41 +# Operation : Migration +# Purpose : Camera EEPROM Calibration +allow mediaserver CAM_CAL_DRV_device:chr_file { read write ioctl open }; + +# Date : WK14.43 +# Operation : Migration +# Purpose : VOW +allow mediaserver vow_device:chr_file { read write ioctl open }; + +# Date: WK14.44 +# Operation : Migration +# Purpose : EVDO +allow mediaserver rpc_socket:sock_file write; +allow mediaserver statusd:unix_stream_socket connectto; +allow mediaserver ttySDIO_device:chr_file { read write }; +allow mediaserver ttySDIO_device:chr_file open; + +# Data: WK14.44 +# Operation : Migration +# Purpose : VP +allow mediaserver surfaceflinger:file getattr; + +# Data: WK14.44 +# Operation : Migration +# Purpose : for low SD card latency issue +allow mediaserver sysfs_lowmemorykiller:file { read open }; + +# Date: WK14.45 +# Operation : Migration +# Purpose : HDCP +allow mediaserver mobicore:unix_stream_socket connectto; +allow mediaserver mobicore_data_file:dir search; +allow mediaserver mobicore_data_file:file { getattr read open lock}; +allow mediaserver mobicore_user_device:chr_file { read write open ioctl}; +allow mediaserver persist_data_file:dir { create write add_name search}; +allow mediaserver persist_data_file:file { read write create open getattr }; + +# Data: WK14.45 +# Operation : Migration +# Purpose : for change thermal policy when needed +allow mediaserver proc_mtkcooler:dir search; +allow mediaserver proc_mtktz:dir search; +allow mediaserver proc_thermal:dir search; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow mediaserver qemu_pipe_device:chr_file rw_file_perms; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for camera init +allow mediaserver system_server:unix_stream_socket { read write }; + +# Data : WK14.46 +# Operation : Migration +# Purpose : for SMS app +allow mediaserver radio_data_file:dir search; +allow mediaserver radio_data_file:file open; + +# Data : WK14.47 +# Operation : Migration +# Purpose : for WFD looper +allow mediaserver custom_file:dir search; + +# Data : WK14.47 +# Operation : OMA DRM SQC +# Purpose : for OMA DRM - set OMA DRM file to ringtone +allow mediaserver system_app:dir search; + +# Data : WK14.47 +# Operation : Audio playback +# Purpose : Music as ringtone +allow mediaserver radio:dir { search read }; +allow mediaserver radio:file { read getattr open }; + +# Data : WK14.47 +# Operation : Launch camcorder from MMS +# Purpose : Camcorder +allow mediaserver radio_data_file:file open; + +# Data : WK14.47 +# Operation : CTS +# Purpose : cts search strange app +allow mediaserver untrusted_app:dir search; + +# Data : 2014/11/25 +# Operation : OMA DRM SQC +# Purpose : for OMA DRM - set OMA DRM file to ringtone and play OMA DRM file +allow mediaserver system_app:file { read open getattr }; + +# Data : 2014/11/25 +# Operation : OMA DRM SQC +# Purpose : for OMA DRM - set OMA DRM file to ringtone and play DRM ringtone +allow mediaserver untrusted_app:file { read open getattr }; + +# Data : 2014/11/26 +# Operation : Camera display client +# Purpose : for access proc_secmem +allow mediaserver proc_secmem:file { read write open}; + +# Data : WK14.48 +# Operation : WFD +# Purpose : For WFD scenario +allow mediaserver untrusted_app_tmpfs:file write; + +# Date : WK14.49 +# Operation : WFD +# Purpose : WFD notifies its status to thermal module +allow mediaserver proc_thermal:file { write getattr open }; +allow mediaserver thermal_manager_exec:file { getattr execute read open execute_no_trans }; +allow mediaserver proc_mtkcooler:file { read write open }; +allow mediaserver proc_mtktz:file { read write open }; +allow mediaserver proc_thermal:file { read write open }; + +# Date : WK14.52 +# Operation : WVL1 IT +# Purpose : SVP module operates secmem driver +allow mediaserver mobicore_data_file:file getattr; +allow mediaserver proc_secmem:file ioctl; + +# Date : WK15.03 +# Operation : Migration +# Purpose : offloadservice +allow mediaserver offloadservice_device:chr_file { read write ioctl open }; diff --git a/sepolicy/memsicd.te b/sepolicy/memsicd.te new file mode 100644 index 0000000..39466b8 --- /dev/null +++ b/sepolicy/memsicd.te @@ -0,0 +1,16 @@ +# ============================================== +# Policy File of /system/binmemsicd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type memsicd_exec , exec_type, file_type; +type memsicd ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(memsicd) diff --git a/sepolicy/memsicd3416x.te b/sepolicy/memsicd3416x.te new file mode 100644 index 0000000..dc33eed --- /dev/null +++ b/sepolicy/memsicd3416x.te @@ -0,0 +1,16 @@ +# ============================================== +# Policy File of /system/binmemsicd3416x Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type memsicd3416x_exec , exec_type, file_type; +type memsicd3416x ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(memsicd3416x) diff --git a/sepolicy/meta_tst.te b/sepolicy/meta_tst.te new file mode 100644 index 0000000..4a4c215 --- /dev/null +++ b/sepolicy/meta_tst.te @@ -0,0 +1,149 @@ +# ============================================== +# Policy File of /system/bin/meta_tst Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type meta_tst_exec , exec_type, file_type; +type meta_tst ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(meta_tst) + +# Date : WK14.42 +# Operation : L Migration +# Purpose : for meta mode driver module operation +#============= meta_tst ============== +allow meta_tst audio_device:chr_file { read write ioctl open }; +allow meta_tst audio_device:dir search; +allow meta_tst nvram_data_file:dir search; +allow meta_tst audiohal_prop:property_service set; +allow meta_tst ccci_device:chr_file { read write ioctl open }; +allow meta_tst fm_device:chr_file { read write ioctl open }; +allow meta_tst graphics_device:chr_file { read write ioctl open }; +allow meta_tst graphics_device:dir search; +allow meta_tst mdlog_device:chr_file { read write open }; +allow meta_tst nvram_data_file:dir { write read open add_name remove_name search create getattr setattr }; +allow meta_tst nvram_data_file:file { setattr read create write getattr unlink open append }; +allow meta_tst nvram_data_file:lnk_file read; +allow meta_tst nvdata_file:dir { write read open add_name remove_name search create getattr setattr }; +allow meta_tst nvdata_file:file { setattr read create write getattr unlink open append }; +allow meta_tst nvram_device:chr_file { read write open ioctl }; +allow meta_tst platformblk_device:blk_file { read write open }; +allow meta_tst platformblk_device:dir search; +allow meta_tst port:tcp_socket { name_connect name_bind }; +allow meta_tst rootfs:file entrypoint; +allow meta_tst rtc_device:chr_file { read ioctl open }; +allow meta_tst self:capability { net_raw chown fsetid sys_nice net_admin fowner dac_override sys_admin }; +allow meta_tst self:tcp_socket { create connect setopt bind }; +allow meta_tst self:udp_socket { create ioctl }; +allow meta_tst stpbt_device:chr_file { read write open }; +allow meta_tst sysfs:file write; +allow meta_tst system_data_file:dir { write remove_name add_name }; +allow meta_tst system_data_file:sock_file unlink; +allow meta_tst ttyGS_device:chr_file { read write ioctl open }; +allow meta_tst wmtWifi_device:chr_file { write open }; +allow meta_tst FM50AF_device:chr_file { read write ioctl open }; +allow meta_tst AD5820AF_device:chr_file { read write ioctl open }; +allow meta_tst DW9714AF_device:chr_file { read write ioctl open }; +allow meta_tst DW9714A_device:chr_file { read write ioctl open }; +allow meta_tst LC898122AF_device:chr_file { read write ioctl open }; +allow meta_tst LC898212AF_device:chr_file { read write ioctl open }; +allow meta_tst BU6429AF_device:chr_file { read write ioctl open }; +allow meta_tst DW9718AF_device:chr_file { read write ioctl open }; +allow meta_tst BU64745GWZAF_device:chr_file { read write ioctl open }; +allow meta_tst als_ps_device:chr_file { read ioctl open }; +allow meta_tst camera_isp_device:chr_file { read write ioctl open }; +allow meta_tst camera_sysram_device:chr_file { read ioctl open }; +allow meta_tst gsensor_device:chr_file { read ioctl open }; +allow meta_tst kd_camera_flashlight_device:chr_file { read write ioctl open }; +allow meta_tst kd_camera_hw_device:chr_file { read write ioctl open }; +allow meta_tst msensor_device:chr_file { read ioctl open }; +allow meta_tst mt6605_device:chr_file { read write open ioctl getattr }; +allow meta_tst self:capability { sys_boot ipc_lock }; +allow meta_tst sysfs_wake_lock:file { read write open }; +allow meta_tst system_data_file:sock_file { write create setattr }; +allow meta_tst system_file:file execute_no_trans; +allow meta_tst MT_pmic_adc_cali_device:chr_file { read write ioctl open }; +allow meta_tst block_device:dir search; +allow meta_tst gyroscope_device:chr_file { read ioctl open }; +allow meta_tst mnld_exec:file { execute read open }; +allow meta_tst ttyMT_device:chr_file { read write ioctl open }; +allow meta_tst mnld_exec:file execute_no_trans; +allow meta_tst mnld_device:chr_file { open read write ioctl }; +allow meta_tst property_socket:sock_file write; +allow meta_tst vold_socket:sock_file write; +allow meta_tst init:unix_stream_socket connectto; +allow meta_tst vold:unix_stream_socket connectto; +allow meta_tst gps_device:chr_file { read write open }; +allow meta_tst mnld_prop:property_service set; +allow meta_tst agpsd_data_file:dir search; +allow meta_tst self:tcp_socket { bind setopt listen accept read write }; +allow meta_tst agpsd_data_file:sock_file write; +allow meta_tst node:tcp_socket node_bind; +allow meta_tst powerctl_prop:property_service set; +allow meta_tst labeledfs:filesystem unmount; +allow meta_tst platformblk_device:blk_file { getattr ioctl }; +allow meta_tst shell_exec:file execute; + +# Date: WK14.45 +# Operation : Migration +# Purpose : HDCP +allow meta_tst mobicore:unix_stream_socket connectto; +allow meta_tst mobicore_data_file:dir search; +allow meta_tst mobicore_data_file:file { getattr read open lock}; +allow meta_tst mobicore_user_device:chr_file { read write open ioctl}; +allow meta_tst persist_data_file:dir { create setattr write add_name search}; +allow meta_tst persist_data_file:file { read write create open getattr setattr}; + +# Date: WK14.46 +# Operation : Migration +# Purpose : Camera +allow meta_tst devmap_device:chr_file { open read write ioctl }; +allow meta_tst camera_pipemgr_device:chr_file { open read write ioctl }; +allow meta_tst MTK_SMI_device:chr_file { open read write ioctl }; +allow meta_tst tmpfs:lnk_file read; + +# Date: WK14.47 +# Operation : Migration +# Purpose : CCCI +allow meta_tst eemcs_device:chr_file { read write ioctl open }; + +#Date WK14.49 +#Operation : Migration +#Purpose : DRM key installation +allow meta_tst mobicore_data_file:file getattr; +allow meta_tst shell_exec:file { read open execute_no_trans }; +allow meta_tst system_data_file:dir create; + +# Date: WK14.51 +# Purpose : set/get cryptfs cfg in sys env +allow meta_tst misc_device:chr_file { read write open }; +allow meta_tst proc_lk_env:file { read write ioctl open }; + +# Date: WK14.51 +# Purpose : CCCI +allow meta_tst emd_device:chr_file { read write ioctl open }; +allow meta_tst ttyACM_device:chr_file { read write ioctl open }; + +# Purpose : FT_EMMC_OP_FORMAT_TCARD +allow meta_tst block_device:blk_file getattr; +allow meta_tst fuse_device:chr_file getattr; +allow meta_tst shell_exec:file { read open }; + +# Date: WK15.52 +# Purpose : NVRAM related LID +allow meta_tst pro_info_device:chr_file { open read write ioctl }; +# Data: WK15.07 +# Purpose : SDIO +allow meta_tst ttySDIO_device:chr_file { read write ioctl open }; + +# Camera M2 Note +allow meta_tst BU64245_device:chr_file { read write ioctl open }; + diff --git a/sepolicy/mmc3524xd.te b/sepolicy/mmc3524xd.te new file mode 100644 index 0000000..54e8f1a --- /dev/null +++ b/sepolicy/mmc3524xd.te @@ -0,0 +1,17 @@ +# ============================================== +# Policy File of /system/bin/mmc3524xd Executable File + + +# ============================================== +# Type Declaration +# ============================================== +type mmc3524xd_exec , exec_type, file_type; +type mmc3524xd ,domain; + +#permissive mmc3524xd; +init_daemon_domain(mmc3524xd) + +#add permission +allow mmc3524xd gsensor_device:chr_file {open ioctl read write}; +allow mmc3524xd msensor_device:chr_file {open ioctl read write}; + diff --git a/sepolicy/mmp.te b/sepolicy/mmp.te new file mode 100644 index 0000000..d956366 --- /dev/null +++ b/sepolicy/mmp.te @@ -0,0 +1,25 @@ +# ============================================== +# Policy File of /system/binmmp Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mmp_exec , exec_type, file_type; +type mmp ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(mmp) + diff --git a/sepolicy/mnld.te b/sepolicy/mnld.te new file mode 100644 index 0000000..993cfb9 --- /dev/null +++ b/sepolicy/mnld.te @@ -0,0 +1,49 @@ +type mnld, domain; +type mnld_exec, exec_type, file_type; + +# STOPSHIP: Permissive is not allowed. CTS violation! + +init_daemon_domain(mnld) + +net_domain(mnld) +allow mnld agpsd_data_file:dir create_dir_perms; +allow mnld agpsd_data_file:sock_file create_file_perms; +allow mnld mtk_agpsd:unix_dgram_socket sendto; +allow mnld sysfs:file rw_file_perms; +allow mnld sysfs_wake_lock:file rw_file_perms; +allow mnld nvram_data_file:dir create_dir_perms; +allow mnld nvram_data_file:file create_file_perms; +allow mnld nvram_data_file:lnk_file read; +allow mnld nvdata_file:dir create_dir_perms; +allow mnld nvdata_file:file create_file_perms; +allow mnld mnld_data_file:dir rw_dir_perms; +allow mnld mnld_data_file:sock_file create_file_perms; +allow mnld mnld_device:chr_file rw_file_perms; +allow mnld gps_device:chr_file rw_file_perms; +allow mnld init:unix_stream_socket connectto; +allow mnld property_socket:sock_file rw_file_perms; +allow mnld system_data_file:dir rw_dir_perms; +allow mnld system_data_file:dir create_dir_perms; +allow mnld system_server:unix_dgram_socket sendto; +allow mnld system_data_file:sock_file create_file_perms; +allow mnld platformblk_device:blk_file rw_file_perms; +allow mnld block_device:dir search; +allow mnld platformblk_device:dir search; +allow mnld nvram_device:chr_file{read write}; +allow mnld mnld_prop:property_service set; +allow mnld nvram_device:chr_file open; +allow mnld init:udp_socket { read write }; +allow mnld mdlog_device:chr_file { read write }; +allow mnld self:capability { fsetid dac_override }; +allow mnld stpbt_device:chr_file { read write }; +allow mnld ttyGS_device:chr_file { read write }; +allow mnld fuse:dir search; +allow mnld fuse:dir write; +allow mnld fuse:dir add_name; +allow mnld fuse:file create; +allow mnld fuse:file rw_file_perms; +allow mnld fuse:file create_file_perms; +allow mnld nvram_device:chr_file ioctl; +allow mnld fuse:dir { read remove_name create open }; +allow mnld tmpfs:lnk_file { read create open }; +allow mnld platform_app:unix_stream_socket connectto; diff --git a/sepolicy/mobicore.te b/sepolicy/mobicore.te new file mode 100644 index 0000000..dc602f8 --- /dev/null +++ b/sepolicy/mobicore.te @@ -0,0 +1,34 @@ +## +# Trustonic TEE (mobicore) daemon +# + +# ============================================== +# Type Declaration +# ============================================== +type mobicore, domain; +type mobicore_exec, exec_type, file_type; +type mobicore_admin_device, dev_type; +type mobicore_user_device, dev_type; +type mobicore_tui_device, dev_type; +type mobicore_data_file, file_type, data_file_type; + +# ============================================== +# Type Declaration for secmem +# ============================================== +type proc_secmem, fs_type; +# genfscon proc /secmem0 u:object_r:proc_secmem:s0; + +# ============================================== +# MTK Policy Rule +# ============================================== +# permissive mobicore; +init_daemon_domain(mobicore) +allow mobicore self:capability { dac_override }; +allow mobicore mobicore_admin_device:chr_file rw_file_perms; +allow mobicore mobicore_user_device:chr_file rw_file_perms; +allow mobicore mobicore_data_file:dir rw_dir_perms; +allow mobicore mobicore_data_file:file create_file_perms; +allow mobicore self:netlink_socket create_socket_perms; +allow mobicore apk_data_file:dir write; +allow mobicore mobicore_data_file:dir create; +allow mobicore mobicore_data_file:file rw_file_perms; diff --git a/sepolicy/mobile_log_d.te b/sepolicy/mobile_log_d.te new file mode 100644 index 0000000..3849a79 --- /dev/null +++ b/sepolicy/mobile_log_d.te @@ -0,0 +1,75 @@ +# ============================================== +# Policy File of /system/binmobile_log_d Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mobile_log_d_exec , exec_type, file_type; +type mobile_log_d ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(mobile_log_d) + +# Date : WK14.31 +# Operation : Migration +# Purpose : for L early bring-up +allow mobile_log_d kernel:system syslog_mod; +allow mobile_log_d sdcard_internal:dir create_dir_perms; +allow mobile_log_d sdcard_internal:file create_file_perms; +allow mobile_log_d platform_app:fd use; +allow mobile_log_d platform_app_tmpfs:file write; +#allow mobile_log_d unlabeled:lnk_file read; + +#GMO project +dontaudit mobile_log_d untrusted_app:fd use; +dontaudit mobile_log_d isolated_app:fd use; + +#md32 +#sysfs label need to be changed later +allow mobile_log_d sysfs:file write; +allow mobile_log_d md32_device:chr_file { read open }; + +#debug.MB.running +allow mobile_log_d debug_prop:property_service set; + +allow mobile_log_d fuse:dir create_dir_perms; +allow mobile_log_d fuse:file create_file_perms; +allow mobile_log_d init:unix_stream_socket connectto; +allow mobile_log_d property_socket:sock_file write; +allow mobile_log_d system_file:file x_file_perms; +allow mobile_log_d tmpfs:lnk_file read; + +allow mobile_log_d logd:unix_stream_socket connectto; +allow mobile_log_d logdr_socket:sock_file write; +allow mobile_log_d mtkbt:unix_stream_socket connectto; +allow mobile_log_d self:capability { setuid setgid }; +allow mobile_log_d self:capability2 syslog; +allow mobile_log_d shell_exec:file rx_file_perms; + +#factory mode +allow mobile_log_d vfat:dir create_dir_perms; +allow mobile_log_d vfat:file create_file_perms; + +#data/misc/mblog +allow mobile_log_d system_data_file:dir { relabelfrom create_dir_perms }; +allow mobile_log_d logmisc_data_file:dir { relabelto create_dir_perms }; +allow mobile_log_d logmisc_data_file:file create_file_perms; +#data/log_temp +allow mobile_log_d logtemp_data_file:dir { relabelto create_dir_perms }; +allow mobile_log_d logtemp_data_file:file create_file_perms; +#data/data_tmpfs_log +allow mobile_log_d data_tmpfs_log_file:dir create_dir_perms; +allow mobile_log_d data_tmpfs_log_file:file create_file_perms; diff --git a/sepolicy/mpud6050.te b/sepolicy/mpud6050.te new file mode 100644 index 0000000..f786b6b --- /dev/null +++ b/sepolicy/mpud6050.te @@ -0,0 +1,39 @@ +# ============================================== +# Policy File of /system/bin/mpud6050 Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mpud6050_exec , exec_type, file_type; +type mpud6050 ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive mpud6050; +init_daemon_domain(mpud6050) +#unconfined_domain(mpud6050) + + +# Data : WK14.43 +# Operation : Migration +# Purpose : Gyroscope daemon for access driver node +allow mpud6050 gyroscope_device:chr_file { open ioctl read write}; + +allow mpud6050 gyroscope_mpud6050_chipinfo:file { open read }; +allow mpud6050 gyroscope_mpud6050_status:file { open read }; +allow mpud6050 gyroscope_mpud6050_use:dir { open read search}; +allow mpud6050 gyroscope_mpud6050_use:file { open read }; +allow mpud6050 gyroscope_mpud6050_file:dir { open read search}; +allow mpud6050 gyroscope_mpud6050_file:file { open read write};
\ No newline at end of file diff --git a/sepolicy/msensord.te b/sepolicy/msensord.te new file mode 100644 index 0000000..58f1f73 --- /dev/null +++ b/sepolicy/msensord.te @@ -0,0 +1,52 @@ +# ============================================== +# Policy File of /system/bin/msensord Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type msensord_exec , exec_type, file_type; +type msensord ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive msensord; +init_daemon_domain(msensord) +#unconfined_domain(msensord) + +# Data : WK14.43 +# Operation : Migration +# Purpose : M-sensor daemon for access driver node +allow msensord msensord_daemon:file { read open }; +allow msensord msensord_daemon2:file { read open }; + + +# Data : WK14.43 +# Operation : Migration +# Purpose : M-sensor daemon for property operation +allow msensord ctl_msensord_prop:property_service set; +unix_socket_connect(msensord,property,init) + +allow msensord ctl_akmd8963_prop:property_service set; +allow msensord ctl_akmd09911_prop:property_service set; +allow msensord ctl_bmm050d_prop:property_service set; +allow msensord ctl_bmm056d_prop:property_service set; +allow msensord ctl_geomagneticd_prop:property_service set; +allow msensord ctl_orientationd_prop:property_service set; +allow msensord ctl_istd8303_prop:property_service set; +allow msensord ctl_st480_prop:property_service set; +allow msensord ctl_mmc3524xd_prop:property_service set; +allow msensord ctl_mc6470d_prop:property_service set; +allow msensord ctl_qmcX983d_prop:property_service set; +allow msensord ctl_af7133e_prop:property_service set;
\ No newline at end of file diff --git a/sepolicy/mtk_6620_launcher.te b/sepolicy/mtk_6620_launcher.te new file mode 100644 index 0000000..064e4f5 --- /dev/null +++ b/sepolicy/mtk_6620_launcher.te @@ -0,0 +1,29 @@ +# ============================================== +# Policy File of /system/binmtk_6620_launcher Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mtk_6620_launcher_exec , exec_type, file_type; +type mtk_6620_launcher ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +allow mtk_6620_launcher wmt_prop:property_service set; +allow mtk_6620_launcher init:unix_stream_socket connectto; +allow mtk_6620_launcher property_socket:sock_file write; +allow mtk_6620_launcher stpwmt_device:chr_file { read write ioctl open }; +allow mtk_6620_launcher devpts:chr_file { read write }; +init_daemon_domain(mtk_6620_launcher) diff --git a/sepolicy/mtk_agpsd.te b/sepolicy/mtk_agpsd.te new file mode 100644 index 0000000..be84baf --- /dev/null +++ b/sepolicy/mtk_agpsd.te @@ -0,0 +1,39 @@ +# ============================================== +# Policy File of /system/binmtk_agpsd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mtk_agpsd_exec , exec_type, file_type; +type mtk_agpsd ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(mtk_agpsd) + +# Date : WK14.31 +# Operation : Migration +# Purpose : for L bring-up +net_domain(mtk_agpsd) +allow mtk_agpsd mnld:unix_dgram_socket sendto; +allow mtk_agpsd agps_device:chr_file rw_file_perms; +allow mtk_agpsd agpsd_data_file:dir create_dir_perms; +allow mtk_agpsd agpsd_data_file:file create_file_perms; +allow mtk_agpsd agpsd_data_file:sock_file create_file_perms; +allow mtk_agpsd fuse:dir create_dir_perms; +allow mtk_agpsd fuse:file create_file_perms; +allow mtk_agpsd ttySDIO_device:chr_file create_file_perms; +allow mtk_agpsd eemcs_device:chr_file rw_file_perms; +allow mtk_agpsd tmpfs:lnk_file create_file_perms;
\ No newline at end of file diff --git a/sepolicy/mtkbt.te b/sepolicy/mtkbt.te new file mode 100644 index 0000000..1de109d --- /dev/null +++ b/sepolicy/mtkbt.te @@ -0,0 +1,174 @@ +# ============================================== +# Policy File of /system/binmtkbt Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mtkbt_exec , exec_type, file_type; +type mtkbt ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive mtkbt; +init_daemon_domain(mtkbt) +# unconfined_domain(mtkbt) + +# Data : WK14.36 +# Operation : Migration +# Purpose : Bt host stack files access & IPC mechanism +allow mtkbt platformblk_device:blk_file { read write open }; +allow mtkbt self:udp_socket { create ioctl }; +# Date : WK14.37 +# Operation : Migration +# Purpose : Bt host stack binder access & IPC mechanism +binder_use(mtkbt) +# Date : WK14.43 +# Operation : Migration +# Purpose : Bt host stack binder access & IPC mechanism +allow mtkbt bluetooth_service:service_manager add; + +# result of audit2allow +allow mtkbt nvram_data_file:file { create setattr read write getattr open }; +allow mtkbt nvram_data_file:lnk_file read; +allow mtkbt nvram_data_file:dir { write add_name search}; +allow mtkbt nvdata_file:file { create setattr read write getattr open }; +allow mtkbt nvdata_file:dir { write add_name search }; + +allow mtkbt block_device:dir search; +allow mtkbt bt_data_file:dir search; +allow mtkbt bt_int_adp_socket:sock_file write; +allow mtkbt platformblk_device:dir search; +allow mtkbt self:netlink_socket { write bind create setopt }; +allow mtkbt sn:dir search; +allow mtkbt sn:file { read getattr open }; +allow mtkbt sysfs_wake_lock:file { read write open }; +allow mtkbt MtkCodecService:dir search; +allow mtkbt MtkCodecService:file { read getattr open }; +allow mtkbt aal:dir search; +allow mtkbt aal:file { read getattr open }; +allow mtkbt atci_service:dir search; +allow mtkbt atci_service:file { read getattr open }; +allow mtkbt atcid:dir search; +allow mtkbt atcid:file { read getattr open }; +allow mtkbt autokd:dir search; +allow mtkbt autokd:file { read getattr open }; +allow mtkbt batterywarning:dir search; +allow mtkbt batterywarning:file { read getattr open }; +allow mtkbt bluetooth:unix_dgram_socket sendto; +allow mtkbt bt_data_file:dir { write getattr read remove_name open add_name }; +allow mtkbt bt_data_file:file { write getattr read create unlink open append}; +allow mtkbt bluetooth:binder transfer; +allow mtkbt bt_data_file:dir create; +allow mtkbt bluetooth_data_file:dir search; +allow mtkbt system_data_file:dir write; +allow mtkbt system_data_file:dir add_name; +allow mtkbt ccci_fsd:dir search; +allow mtkbt ccci_fsd:file { read getattr open }; +allow mtkbt ccci_mdinit:dir search; +allow mtkbt ccci_mdinit:file { read getattr open }; +allow mtkbt debuggerd:dir search; +allow mtkbt debuggerd:file { read getattr open }; +allow mtkbt drmserver:dir search; +allow mtkbt drmserver:file { read getattr open }; +allow mtkbt em_svr:dir search; +allow mtkbt em_svr:file { read getattr open }; +allow mtkbt geomagneticd:dir search; +allow mtkbt geomagneticd:file { read getattr open }; +allow mtkbt guiext-server:dir search; +allow mtkbt guiext-server:file { read getattr open }; +allow mtkbt healthd:dir search; +allow mtkbt healthd:file { read getattr open }; +allow mtkbt init:dir search; +allow mtkbt init:file { read getattr open }; +allow mtkbt init:unix_stream_socket connectto; +allow mtkbt installd:dir search; +allow mtkbt installd:file { read getattr open }; +allow mtkbt kernel:dir search; +allow mtkbt kernel:file { read getattr open }; +allow mtkbt keystore:dir search; +allow mtkbt keystore:file { read getattr open }; +allow mtkbt lmkd:dir search; +allow mtkbt lmkd:file { read getattr open }; +allow mtkbt logd:dir search; +allow mtkbt logd:file { read getattr open }; +allow mtkbt mediaserver:dir search; +allow mtkbt mediaserver:file { read getattr open }; +allow mtkbt mnld:dir search; +allow mtkbt mnld:file { read getattr open }; +allow mtkbt mobile_log_d:dir search; +allow mtkbt mobile_log_d:file { read getattr open }; +allow mtkbt mtk_6620_launcher:dir search; +allow mtkbt mtk_6620_launcher:file { read getattr open }; +allow mtkbt mtk_agpsd:dir search; +allow mtkbt mtk_agpsd:file { read getattr open }; +allow mtkbt netd:dir search; +allow mtkbt netd:file { read getattr open }; +allow mtkbt netdiag:dir search; +allow mtkbt netdiag:file { read getattr open }; +allow mtkbt nvram_agent_binder:dir search; +allow mtkbt nvram_agent_binder:file { read getattr open }; +allow mtkbt orientationd:dir search; +allow mtkbt orientationd:file { read getattr open }; +allow mtkbt ppl_agent:dir search; +allow mtkbt ppl_agent:file { read getattr open }; +allow mtkbt proc_mtkcooler:dir search; +allow mtkbt proc_mtktz:dir search; +allow mtkbt property_socket:sock_file write; +allow mtkbt resmon:dir search; +allow mtkbt resmon:file { read getattr open }; +allow mtkbt self:capability net_admin; +allow mtkbt self:netlink_socket read; +allow mtkbt self:tun_socket create; +allow mtkbt servicemanager:dir search; +allow mtkbt servicemanager:file { read getattr open }; +allow mtkbt shell:dir search; +allow mtkbt shell:file { read getattr open }; +allow mtkbt stpbt_device:chr_file { read write ioctl getattr open }; +allow mtkbt surfaceflinger:dir search; +allow mtkbt surfaceflinger:file { read getattr open }; +allow mtkbt thermal:dir search; +allow mtkbt thermal:file { read getattr open }; +allow mtkbt thermald:dir search; +allow mtkbt thermald:file { read getattr open }; +allow mtkbt tun_device:chr_file { read write ioctl open }; +allow mtkbt ueventd:dir search; +allow mtkbt ueventd:file { read getattr open }; +allow mtkbt uhid_device:chr_file { read write open }; +allow mtkbt vold:dir search; +allow mtkbt vold:file { read getattr open }; +allow mtkbt wifi2agps:dir search; +allow mtkbt wifi2agps:file { read getattr open }; +allow mtkbt zygote:dir search; +allow mtkbt zygote:file { read getattr open }; +userdebug_or_eng(` +allow mtkbt su:dir search; +allow mtkbt su:file { read getattr open }; +') + +# prop +allow mtkbt bt_prop:property_service set; +allow mtkbt persist_bt_prop:property_service set; + +# add for ftp to create file on sdcard +allow mtkbt tmpfs:lnk_file read; + +# add for BPP +allow mtkbt bluetooth_data_file:file { read open getattr}; +allow mtkbt system_data_file:dir create; +allow mtkbt fuse:dir { search write add_name write getattr read remove_name open }; +allow mtkbt fuse:file { read open getattr write create unlink }; + +allow mtkbt system_data_file:dir { read remove_name }; +allow mtkbt nvram_device:chr_file open;
\ No newline at end of file diff --git a/sepolicy/mtkrild.te b/sepolicy/mtkrild.te new file mode 100644 index 0000000..65c6e73 --- /dev/null +++ b/sepolicy/mtkrild.te @@ -0,0 +1,88 @@ +# ============================================== +# Policy File of /system/bin/mtkrild Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mtkrild_exec , exec_type, file_type; +type mtkrild ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(mtkrild) +net_domain(mtkrild) +allow mtkrild self:netlink_route_socket nlmsg_write; +allow mtkrild kernel:system module_request; +unix_socket_connect(mtkrild, property, init) +allow mtkrild self:capability { setuid net_admin net_raw }; +allow mtkrild alarm_device:chr_file rw_file_perms; +allow mtkrild cgroup:dir create_dir_perms; +allow mtkrild radio_device:chr_file rw_file_perms; +allow mtkrild radio_device:blk_file r_file_perms; +allow mtkrild mtd_device:dir search; +allow mtkrild efs_file:dir create_dir_perms; +allow mtkrild efs_file:file create_file_perms; +allow mtkrild shell_exec:file rx_file_perms; +allow mtkrild bluetooth_efs_file:file r_file_perms; +allow mtkrild bluetooth_efs_file:dir r_dir_perms; +allow mtkrild radio_data_file:dir rw_dir_perms; +allow mtkrild radio_data_file:file create_file_perms; +allow mtkrild sdcard_type:dir r_dir_perms; +allow mtkrild system_data_file:dir r_dir_perms; +allow mtkrild system_data_file:file r_file_perms; +allow mtkrild system_file:file x_file_perms; +allow mtkrild proc:file write; +allow mtkrild proc_net:file write; +allow mtkrild eemcs_device:chr_file { read write }; +allow mtkrild eemcs_device:chr_file open; +allow mtkrild eemcs_device:chr_file ioctl; + +# property service +allow mtkrild radio_prop:property_service set; +allow mtkrild net_radio_prop:property_service set; +allow mtkrild system_radio_prop:property_service set; +allow mtkrild persist_ril_prop:property_service set; +auditallow mtkrild net_radio_prop:property_service set; +auditallow mtkrild system_radio_prop:property_service set; + +# Read/Write to uart driver (for GPS) +allow mtkrild gps_device:chr_file rw_file_perms; + +allow mtkrild tty_device:chr_file rw_file_perms; + +# Allow mtkrild to create and use netlink sockets. +allow mtkrild self:netlink_socket create_socket_perms; +allow mtkrild self:netlink_kobject_uevent_socket create_socket_perms; + +# Access to wake locks +wakelock_use(mtkrild) + +allow mtkrild self:socket create_socket_perms; +allow mtkrild Vcodec_device:chr_file { read write open }; +allow mtkrild devmap_device:chr_file { read ioctl open }; +allow mtkrild devpts:chr_file { read write open }; +allow mtkrild self:capability dac_override; + +allow mtkrild ccci_device:chr_file { read write ioctl open }; +allow mtkrild devpts:chr_file ioctl; +allow mtkrild misc_device:chr_file { read write open }; +allow mtkrild platformblk_device:blk_file { read write open }; +allow mtkrild proc_lk_env:file rw_file_perms; +allow mtkrild sysfs_vcorefs_pwrctrl:file { open write }; +allow mtkrild ril_active_md_prop:property_service set; +allow mtkrild ril_mux_report_case_prop:property_service set; +allow mtkrild ctl_muxreport-daemon_prop:property_service set; +allow mtkrild persist_service_atci_prop:property_service set; +allow mtkrild block_device:dir search; +allow mtkrild platformblk_device:dir search; +allow mtkrild platform_app:fd use; +allow mtkrild radio:fd use; + +# For emulator +allow mtkrild qemu_pipe_device:chr_file rw_file_perms; +allow mtkrild socket_device:sock_file write; diff --git a/sepolicy/mtkrildmd2.te b/sepolicy/mtkrildmd2.te new file mode 100644 index 0000000..030e329 --- /dev/null +++ b/sepolicy/mtkrildmd2.te @@ -0,0 +1,94 @@ +# ============================================== +# Policy File of /system/bin/mtkrildmd2 Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type mtkrildmd2_exec , exec_type, file_type; +type mtkrildmd2 ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(mtkrildmd2) +net_domain(mtkrildmd2) +allow mtkrildmd2 self:netlink_route_socket nlmsg_write; +allow mtkrildmd2 kernel:system module_request; +unix_socket_connect(mtkrildmd2, property, init) +allow mtkrildmd2 self:capability { setuid net_admin net_raw }; +allow mtkrildmd2 alarm_device:chr_file rw_file_perms; +allow mtkrildmd2 cgroup:dir create_dir_perms; +allow mtkrildmd2 radio_device:chr_file rw_file_perms; +allow mtkrildmd2 radio_device:blk_file r_file_perms; +allow mtkrildmd2 mtd_device:dir search; +allow mtkrildmd2 efs_file:dir create_dir_perms; +allow mtkrildmd2 efs_file:file create_file_perms; +allow mtkrildmd2 shell_exec:file rx_file_perms; +allow mtkrildmd2 bluetooth_efs_file:file r_file_perms; +allow mtkrildmd2 bluetooth_efs_file:dir r_dir_perms; +allow mtkrildmd2 radio_data_file:dir rw_dir_perms; +allow mtkrildmd2 radio_data_file:file create_file_perms; +allow mtkrildmd2 sdcard_type:dir r_dir_perms; +allow mtkrildmd2 system_data_file:dir r_dir_perms; +allow mtkrildmd2 system_data_file:file r_file_perms; +allow mtkrildmd2 system_file:file x_file_perms; +allow mtkrildmd2 proc:file write; +allow mtkrildmd2 proc_net:file write; +allow mtkrildmd2 eemcs_device:chr_file { read write }; +allow mtkrildmd2 eemcs_device:chr_file open; +allow mtkrildmd2 eemcs_device:chr_file ioctl; + +# property service +allow mtkrildmd2 radio_prop:property_service set; +allow mtkrildmd2 net_radio_prop:property_service set; +allow mtkrildmd2 system_radio_prop:property_service set; +allow mtkrildmd2 persist_ril_prop:property_service set; +auditallow mtkrildmd2 net_radio_prop:property_service set; +auditallow mtkrildmd2 system_radio_prop:property_service set; + +# Read/Write to uart driver (for GPS) +allow mtkrildmd2 gps_device:chr_file rw_file_perms; + +allow mtkrildmd2 tty_device:chr_file rw_file_perms; + +# Allow mtkrildmd2 to create and use netlink sockets. +allow mtkrildmd2 self:netlink_socket create_socket_perms; +allow mtkrildmd2 self:netlink_kobject_uevent_socket create_socket_perms; + +# Access to wake locks +wakelock_use(mtkrildmd2) + +allow mtkrildmd2 self:socket create_socket_perms; + +allow mtkrildmd2 Vcodec_device:chr_file { read write open }; +allow mtkrildmd2 devmap_device:chr_file { read ioctl open }; +allow mtkrildmd2 devpts:chr_file { read write open }; +allow mtkrildmd2 self:capability dac_override; + +allow mtkrildmd2 ccci_device:chr_file { read write ioctl open }; +allow mtkrildmd2 devpts:chr_file ioctl; +allow mtkrildmd2 misc_device:chr_file { read write open }; +allow mtkrildmd2 platformblk_device:blk_file { read write open }; +allow mtkrildmd2 proc_lk_env:file rw_file_perms; +allow mtkrildmd2 sysfs_vcorefs_pwrctrl:file { open write }; +allow mtkrildmd2 ril_active_md_prop:property_service set; +allow mtkrildmd2 ril_mux_report_case_prop:property_service set; +allow mtkrildmd2 ctl_muxreport-daemon_prop:property_service set; +allow mtkrildmd2 persist_service_atci_prop:property_service set; +allow mtkrildmd2 block_device:dir search; +allow mtkrildmd2 platformblk_device:dir search; +allow mtkrildmd2 emd_device:chr_file { read write open }; +allow mtkrildmd2 emd_device:chr_file ioctl; +allow mtkrildmd2 platform_app:fd use; +allow mtkrildmd2 radio:fd use; + +# For emulator +allow mtkrildmd2 qemu_pipe_device:chr_file { read write }; +allow mtkrildmd2 socket_device:sock_file write; + +allow mtkrildmd2 ttyACM_device:chr_file { read write ioctl open }; +allow mtkrildmd2 pppd_gprs_prop:property_service set; diff --git a/sepolicy/mtp.te b/sepolicy/mtp.te new file mode 100644 index 0000000..7b20973 --- /dev/null +++ b/sepolicy/mtp.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + diff --git a/sepolicy/muxreport.te b/sepolicy/muxreport.te new file mode 100644 index 0000000..159ff71 --- /dev/null +++ b/sepolicy/muxreport.te @@ -0,0 +1,25 @@ +# ============================================== +# Policy File of /system/binmuxreport Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type muxreport_exec , exec_type, file_type; +type muxreport ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive muxreport; +init_daemon_domain(muxreport) +allow muxreport ccci_device:chr_file { read write ioctl open }; +allow muxreport ril_mux_report_case_prop:property_service set; +allow muxreport init:unix_stream_socket connectto; +allow muxreport property_socket:sock_file write; +allow muxreport devpts:chr_file { read write getattr ioctl }; +allow muxreport self:capability dac_override; +allow muxreport eemcs_device:chr_file { read write ioctl open }; +allow muxreport emd_device:chr_file { read write open }; diff --git a/sepolicy/net.te b/sepolicy/net.te new file mode 100644 index 0000000..9432fd2 --- /dev/null +++ b/sepolicy/net.te @@ -0,0 +1,25 @@ +# ============================================== +# NSA Policy Rule +# ============================================== + +# Network types + +# Use network sockets. +allow netdomain self:{ tcp_socket udp_socket } *; +# Connect to ports. +allow netdomain port_type:tcp_socket name_connect; +# Bind to ports. +allow netdomain node_type:{ tcp_socket udp_socket } node_bind; +allow netdomain port_type:udp_socket name_bind; +allow netdomain port_type:tcp_socket name_bind; +# Get route information. +allow netdomain self:netlink_route_socket { create bind read nlmsg_read }; + +# Talks to netd via dnsproxyd socket. +unix_socket_connect(netdomain, dnsproxyd, netd) + + +# ============================================== +# MTK Policy Rule +# ============================================== + diff --git a/sepolicy/netd.te b/sepolicy/netd.te new file mode 100644 index 0000000..a94eaee --- /dev/null +++ b/sepolicy/netd.te @@ -0,0 +1,120 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +type dhcp6s_exec,exec_type,file_type; + + +# Date : WK14.34 +# Operation : Migration +# Purpose : wifi +allow netd wmtWifi_device:chr_file { write open }; + +allow netd kernel:system module_request; +allow netd self:capability sys_module; +allow netd self:capability fsetid; + + +# Date : WK14.34 +# Operation : Migration +# Purpose : property_service for wifi +allow netd mtk_wifi_prop:property_service set; + + +# Date : WK14.34 +# Operation : Migration +# Purpose : APP +allow netd platform_app:fd use; +allow netd platform_app_tmpfs:file write; + + +# Date : WK14.37 +# Operation : Migration +# Purpose : PPPOE Test +allow netd ppp:process sigkill; + +# Date : WK14.39 +# Operation : Migration +# Purpose : MDLogger USB logging +allow netd mdlogger:fd use; +allow netd mdlogger:tcp_socket { read write }; +allow netd mdlogger:tcp_socket { getopt setopt }; + +# Date : WK14.41 +# Operation : Migration +# Purpose : network logging +allow netd netdiag:fd use; +allow netd netdiag:udp_socket { read write getopt setopt}; + + +# Date : WK14.41 +# Operation : Migration +# Purpose : ipv6 Tethering Test +#============= netd ============== +allow netd dhcp6s_exec:file execute; +allow netd dhcp_data_file:dir { read search write add_name remove_name }; +allow netd dhcp_data_file:file { read write create open getattr unlink}; + +allow netd radvd_data_file:dir { read write search add_name remove_name}; +allow netd radvd_data_file:file { read write create open unlink}; + +allow netd self:capability { setuid net_bind_service setgid }; +allow netd wide_dhcpv6_data_file:dir { read search write add_name remove_name}; +allow netd wide_dhcpv6_data_file:file { read write create open getattr unlink}; + +# Date : WK14.42 +# Operation : Migration +# Purpose : for VoLTE L early bring up and first call +allow netd volte_stack:fd use; +allow netd volte_stack:tcp_socket { read write setopt getopt }; +allow netd volte_stack:udp_socket { read write setopt getopt }; + +# Date : WK14.42 +# Operation : Migration +# Purpose : ALPS01774455[Need Patch] [Sanity Fail][95E2 L][WFD][EE]EE occur when connect dongle1 +allow netd device:file { open write }; + + +# Date : WK14.44 +# Operation : Migration +# Purpose : ALPS01789552 +#============= netd ============== +allow netd self:capability { setuid setgid }; + + +#============= netd ============== +allow netd isolated_app_tmpfs:file write; + +# Date : W14.52 +# Operation : Migration +# Purpose : add ePDG support +allow netd ipsec:fd use; +allow netd ipsec:tcp_socket { read write setopt getopt }; + +#============= netd ============== +allow netd untrusted_app:fd use; +allow netd untrusted_app_tmpfs:file write; + +#============= netd ============== +# Date : W14.53 +# Operation : Migration +# Purpose : For volte_imcb ut +allow netd volte_imcb:fd use; +allow netd volte_imcb:tcp_socket { read write }; +allow netd volte_imcb:tcp_socket getopt; +allow netd volte_imcb:tcp_socket setopt; + + +# Date : W15.02 +# Operation : SQC +# Purpose : CTS for wifi +allow netd untrusted_app:unix_stream_socket { read write getopt setopt}; + +allow netd isolated_app:fd use; + + +#============= netd ============== +allow netd radio_tmpfs:file write; + + + diff --git a/sepolicy/netdiag.te b/sepolicy/netdiag.te new file mode 100644 index 0000000..71da394 --- /dev/null +++ b/sepolicy/netdiag.te @@ -0,0 +1,72 @@ +# ============================================== +# Policy File of /system/binnetdiag Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type netdiag_exec , exec_type, file_type; +type netdiag ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive netdiag; +init_daemon_domain(netdiag) +#unconfined_domain(netdiag) + + +# Date : WK14.31 +# Operation : Migration +# Purpose : for L early bring-up +allow netdiag shell_exec:file execute_no_trans; +allow netdiag sdcard_internal:dir { write search read create open add_name }; +allow netdiag sdcard_internal:file { write create open getattr }; +allow netdiag self:packet_socket { write ioctl setopt read getopt create }; +allow netdiag fuse:dir { remove_name write search read remove_name open add_name create}; +allow netdiag fuse:file { rename write getattr read create open unlink}; + +allow netdiag init:unix_stream_socket connectto; +allow netdiag property_socket:sock_file write; +allow netdiag self:capability { setuid net_raw setgid }; +allow netdiag shell_exec:file { read execute open }; +allow netdiag tmpfs:lnk_file read; +allow netdiag domain:dir search; +allow netdiag domain:file { read open }; +#/proc/3523/net/xt_qtaguid/ctrl & /proc +allow netdiag qtaguid_proc:file { read getattr open }; + +allow netdiag self:capability net_admin; +allow netdiag self:udp_socket create; +allow netdiag system_file:file execute_no_trans; +#/system/bin/aee +#allow netdiag aee_exec:file { read getattr open execute execute_no_trans }; + +#ping +allow netdiag dnsproxyd_socket:sock_file write; +allow netdiag fwmarkd_socket:sock_file write; +allow netdiag netd:unix_stream_socket connectto; + +#ip +allow netdiag self:netlink_route_socket { write getattr setopt read bind create nlmsg_read }; + +allow netdiag net_data_file:file { read getattr open }; +allow netdiag net_data_file:dir search; +allow netdiag self:rawip_socket { getopt create }; +allow netdiag self:udp_socket ioctl; + +#for network log property +allow netdiag debug_netlog_prop:property_service set; +allow netdiag persist_mtklog_prop:property_service set; +allow netdiag debug_mtklog_prop:property_service set; + diff --git a/sepolicy/nfc.te b/sepolicy/nfc.te new file mode 100644 index 0000000..00b09d3 --- /dev/null +++ b/sepolicy/nfc.te @@ -0,0 +1,104 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : Set NFC permission to access nfc_socket. + +allow nfc nfc_socket:dir { write remove_name add_name search }; +allow nfc nfc_socket:sock_file { write create setattr unlink }; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : Set NFC permission to access custom file. + +allow nfc custom_file:dir getattr; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : Set NFC permission to access mt6605_device ( nfc device node ) . + +allow nfc mt6605_device:chr_file { read write getattr open ioctl }; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : Set NFC permission to access nfc data file. + +allow nfc nfc_data_file:dir { write remove_name add_name search create setattr }; +allow nfc nfc_data_file:file { read getattr open rename write ioctl setattr create unlink }; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : Set NFC permission to access SD card for debug purpose. + +allow nfc sdcard_internal:dir { write remove_name search create add_name }; +allow nfc sdcard_internal:file { read write getattr open rename create }; +allow nfc sdcard_external:dir { write add_name search }; +allow nfc sdcard_external:file { read write getattr open create }; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : Set NFC permission for update screen (activity,dialog,animation, ex: Nfc Beam) + +allow nfc guiext-server:binder call; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : Set NFC permission for WFD + +allow nfc surfaceflinger:dir search; +allow nfc surfaceflinger:file { read getattr open }; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : For Mdlogger + +allow nfc node:tcp_socket node_bind; +allow nfc port:tcp_socket name_bind; +allow nfc self:tcp_socket { setopt read bind create accept write getattr connect getopt listen }; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : For NFC-JNI + +allow nfc zygote:unix_stream_socket { getopt getattr }; + + +# ============================================== +# Date : 2014/10/15 +# Operation : Refine +# Purpose : For VPN + +allow nfc init:unix_stream_socket { write read setopt }; + + +# ============================================== +# Date : 2015/03/11 +# Operation : SQC +# Purpose : For platform_app_tmpfs +allow nfc platform_app_tmpfs:file write; + + +# allow nfc init_tmpfs:file read; +# allow nfc adbd:unix_stream_socket setopt; +# allow nfc dumpstate:fd use; +# allow nfc dumpstate:unix_stream_socket { read write getopt getattr }; diff --git a/sepolicy/nvram_agent_binder.te b/sepolicy/nvram_agent_binder.te new file mode 100644 index 0000000..27d5ee2 --- /dev/null +++ b/sepolicy/nvram_agent_binder.te @@ -0,0 +1,70 @@ +# ============================================== +# Policy File of /system/binnvram_agent_binder Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type nvram_agent_binder_exec , exec_type, file_type; +type nvram_agent_binder ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive nvram_agent_binder; +init_daemon_domain(nvram_agent_binder) + + +# Date : WK14.35 +# Operation : access nvram by binder +# Purpose : ensure nvram user can access nvram file normally. +binder_use(nvram_agent_binder) +binder_service(nvram_agent_binder) + +# Date : WK14.35 +# Operation : access nvram by binder +# Purpose : ensure nvram user can access nvram file normally. +allow nvram_agent_binder nvram_agent_service:service_manager add; + + +# Date : WK14.43 +# Operation : 2rd Selinux Migration +# Purpose : the role of nvram_agent_binder is same with nvram_daemon except property_set & exect permission +allow nvram_agent_binder mmcblk_device:blk_file rw_file_perms; +allow nvram_agent_binder platformblk_device:blk_file rw_file_perms; +allow nvram_agent_binder nvram_data_file:dir create_dir_perms; +allow nvram_agent_binder nvram_data_file:file create_file_perms; +allow nvram_agent_binder nvram_data_file:lnk_file read; +allow nvram_agent_binder nvdata_file:dir create_dir_perms; +allow nvram_agent_binder nvdata_file:file create_file_perms; + +allow nvram_agent_binder system_file:file execute_no_trans; + +allow nvram_agent_binder als_ps_device:chr_file { read ioctl open }; +allow nvram_agent_binder mtk-adc-cali_device:chr_file { read write ioctl open }; +allow nvram_agent_binder gsensor_device:chr_file { read ioctl open }; +allow nvram_agent_binder gyroscope_device:chr_file { read ioctl open }; +allow nvram_agent_binder init:unix_stream_socket connectto; +allow nvram_agent_binder platformblk_device:dir search; +allow nvram_agent_binder property_socket:sock_file write; +allow nvram_agent_binder sysfs:file write; +allow nvram_agent_binder system_data_file:file { open }; +allow nvram_agent_binder self:capability { fowner chown dac_override fsetid }; +allow nvram_agent_binder system_data_file:dir {create write add_name}; + +# Purpose: for backup +allow nvram_agent_binder nvram_device:chr_file {read write open ioctl}; +allow nvram_agent_binder pro_info_device:chr_file {read write open ioctl}; +allow nvram_agent_binder block_device:dir search; + +allow nvram_agent_binder app_data_file:file write; diff --git a/sepolicy/nvram_daemon.te b/sepolicy/nvram_daemon.te new file mode 100644 index 0000000..9e98646 --- /dev/null +++ b/sepolicy/nvram_daemon.te @@ -0,0 +1,73 @@ +# ============================================== +# Policy File of /system/binnvram_daemon Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type nvram_daemon_exec , exec_type, file_type; +type nvram_daemon ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive nvram_daemon; +init_daemon_domain(nvram_daemon) + + + +# Date : WK14.31 +# Operation : Migration +# Purpose : the device is used to store Nvram backup data that can not be lost. +allow nvram_daemon mmcblk_device:blk_file rw_file_perms; +allow nvram_daemon platformblk_device:blk_file rw_file_perms; + + +# Date : WK14.34 +# Operation : Migration +# Purpose : the option is used to tell that if other processes can access nvram. +allow nvram_daemon system_prop:property_service set; + + +# Date : WK14.35 +# Operation : chown folder and file permission +# Purpose : ensure nvram user can access nvram file normally when upgrade from KK/KK.AOSP to L. +allow nvram_daemon shell_exec:file { x_file_perms read open }; +allow nvram_daemon nvram_data_file:dir create_dir_perms; +allow nvram_daemon nvram_data_file:file create_file_perms; +allow nvram_daemon nvram_data_file:lnk_file read; +allow nvram_daemon nvdata_file:dir create_dir_perms; +allow nvram_daemon nvdata_file:file create_file_perms; + +allow nvram_daemon system_file:file execute_no_trans; + +# Date : WK14.43 +allow nvram_daemon als_ps_device:chr_file { read ioctl open }; +allow nvram_daemon mtk-adc-cali_device:chr_file { read write ioctl open }; +allow nvram_daemon gsensor_device:chr_file { read ioctl open }; +allow nvram_daemon gyroscope_device:chr_file { read ioctl open }; +allow nvram_daemon init:unix_stream_socket connectto; +allow nvram_daemon platformblk_device:dir search; + +# Purpose: for property set +allow nvram_daemon property_socket:sock_file write; +allow nvram_daemon sysfs:file write; +allow nvram_daemon self:capability { fowner chown dac_override fsetid }; + +allow nvram_daemon system_data_file:dir {create write add_name}; + +# Purpose: for backup +allow nvram_daemon nvram_device:chr_file {read write open ioctl}; +allow nvram_daemon pro_info_device:chr_file {read write open ioctl}; + +allow nvram_daemon block_device:dir search; diff --git a/sepolicy/orientationd.te b/sepolicy/orientationd.te new file mode 100644 index 0000000..f4ade22 --- /dev/null +++ b/sepolicy/orientationd.te @@ -0,0 +1,25 @@ +# ============================================== +# Policy File of /system/binorientationd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type orientationd_exec , exec_type, file_type; +type orientationd ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive orientationd; +init_daemon_domain(orientationd) +#unconfined_domain(orientationd) + +# Date : WK14.43 +# Operation : Migration +# Purpose : access sensor data and do calibration +allow orientationd gsensor_device:chr_file { read ioctl open }; +allow orientationd input_device:chr_file { read write ioctl open }; +allow orientationd input_device:dir { read search open };
\ No newline at end of file diff --git a/sepolicy/permission_check.te b/sepolicy/permission_check.te new file mode 100644 index 0000000..05634c6 --- /dev/null +++ b/sepolicy/permission_check.te @@ -0,0 +1,53 @@ +# ============================================== +# Policy File of /system/binpermission_check Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type permission_check_exec , exec_type, file_type; +type permission_check ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive permission_check; +init_daemon_domain(permission_check) +#unconfined_domain(permission_check) + +allow permission_check persist_md_prop: property_service set; + +allow permission_check init:unix_stream_socket connectto; +allow permission_check nvram_data_file:dir { rw_dir_perms setattr }; +allow permission_check nvram_data_file:file { write create open setattr getattr }; +allow permission_check nvram_data_file:lnk_file read; +allow permission_check nvdata_file:dir { rw_dir_perms setattr }; +allow permission_check nvdata_file:file { write create open setattr getattr }; + +allow permission_check property_socket:sock_file write; + +allow permission_check protect_f_data_file:dir { read getattr open setattr search }; +allow permission_check protect_s_data_file:dir { read getattr open setattr search }; +allow permission_check protect_f_data_file:file { getattr setattr }; +allow permission_check protect_s_data_file:file { getattr setattr }; + +allow permission_check self:capability { fowner chown dac_override fsetid }; +allow permission_check shell_exec:file { read execute open execute_no_trans }; +allow permission_check system_file:file { read getattr open execute execute_no_trans }; + +allow permission_check ccci_cfg_file:dir create_dir_perms; +allow permission_check ccci_cfg_file:file create_file_perms; + +allow permission_check mdlog_data_file:dir { read search setattr open }; +allow permission_check mdlog_data_file:fifo_file setattr; +allow permission_check mdlog_data_file:file setattr;
\ No newline at end of file diff --git a/sepolicy/platform_app.te b/sepolicy/platform_app.te new file mode 100644 index 0000000..00a3db1 --- /dev/null +++ b/sepolicy/platform_app.te @@ -0,0 +1,177 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive platform_app; + +# Date : 2014/07/22 +# Operation : Migration +# Purpose : mtk_agpsd establishes the local socket as agpsd for all A-GPS +# application to do something with mtk_agpsd +unix_socket_connect(platform_app, agpsd, mtk_agpsd); + +# Date : 2014/08/21 +# Operation : Migration +# Purpose : FMRadio enable driver access permission for fmradio hardware device +# Package: com.mediatek.fmradio +allow platform_app fm_device:chr_file rw_file_perms; + +# Date: 2014/08/22 +# Operation: Migration +# Purpose: enable drawing picture/texture in OpenGl environment for gallery3d +# Package: com.android.gallery3d +# add debugfs policy for MMProfile +allow platform_app debugfs:file { read ioctl }; + +# Date: 2014/09/05 +# Operation: FullUT +# Purpose: [SystemUI] [Bind to guiext-server for updating view][path:hardware/gui_ext/] +# Package: com.android.systemui +allow platform_app guiext-server:binder { transfer call }; + +# Date : 2014/09/11 +# Operation : Migration +# Purpose : MTKLogger need setup local socket with netdiag +# Package: com.mediatek.mtklogger +allow platform_app netdiag_socket:sock_file write; + +# Date : 2014/09/11 +# Operation : Migration +# Purpose : MTKLogger need setup local socket with netdiag +# Package: com.mediatek.mtklogger +allow platform_app netdiag:unix_stream_socket connectto; + +# Date : 2014/09/11 +# Operation : Migration +# Purpose : MTKLogger need setup local socket with mobile_log_d +# Package: com.mediatek.mtklogger +allow platform_app mobile_log_d:unix_stream_socket connectto; + +# Date : 2014/09/11 +# Operation : Migration +# Purpose : MTKLogger need setup local socket with mdlogger +# Package: com.mediatek.mtklogger +allow platform_app mdlogger:unix_stream_socket connectto; + +# Date : 2014/09/18 +# Operation : Migration +# Purpose : MTKLogger need setup local socket with emdlogger +# Package: com.mediatek.mtklogger +allow platform_app emdlogger:unix_stream_socket connectto; + + +# Date : 2014/09/23 +# Operation : Migration +# Purpose : camera process need to read cpu temperature from /proc/mtktz/mtktscpu path +# Package: com.android.gallery3d +allow platform_app proc_mtktz:dir search; +allow platform_app proc_mtktz:file read; + +# Date : 2014/09/26 +# Operation : Migration +# Purpose : camera app need to r/w camera_isp_device file for lomo effect +# Package: com.android.gallery3d +allow platform_app camera_isp_device:chr_file rw_file_perms; + +# Date : 2014/10/17 +# Operation : Migration +# Purpose :Make MTKLogger or VIASaber apk can Access TTYSDIO_device +# Package: com.mediatek.mtklogger +allow platform_app ttySDIO_device:chr_file rw_file_perms; + +# Date : 2014/10/21 +# Operation : SQC +# Purpose : [ALPS01772746] Permission denied for backup App data +# Package: com.mediatek.backuprestore +unix_socket_connect(platform_app, backuprestore, br_app_data_service); +# Date : 2014/10/23 +# Operation : Migration +# Purpose : stress suspend resume test +# Package: Suspend Resume +allow platform_app mtk_kpd_device:chr_file rw_file_perms; + +# Date : 2014/10/27 +# Operation : SQC +# Purpose : [ALPS01785313] Permission denied for dump hprof +# Package: com.android.gallery3d +allow platform_app anr_data_file:file rw_file_perms; + +# Date : 2014/10/28 +# Operation : hs_xiangxu +# Purpose : [ALPS01782971]Settings need read&write to system_app_data_file +# Package: com.android.settings +allow platform_app system_app_data_file:file {read write}; + +# Date : 2014/10/28 +# Operation : Migration +# Purpose : [VoiceWakeup][allow VoiceCommand to do something with vow device] +# Package: com.mediatek.voicecommand +allow platform_app vow_device:chr_file rw_file_perms; + +# Date : 2014/11/12 +# Operation : Migration +# Purpose : MTKLogger need copy db from data folder +# Package: com.mediatek.mtklogger +allow platform_app aee_exp_data_file:file r_file_perms; +allow platform_app aee_exp_data_file:dir r_dir_perms; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow platform_app qemu_pipe_device:chr_file rw_file_perms; + +# Date : 2014/11/14 +# Operation: SQC +# Purpose: [ALPS01824827][SystemUI] [RenderThread][open device file failed] +# Package: com.android.systemui +allow platform_app proc_secmem:file r_file_perms; + +# Date : 2014/11/14 +# Operation : Migration +# Purpose : MTKLogger need update md config file in data for mode changed +# Package: com.mediatek.mtklogger +allow platform_app mdlog_data_file:file rw_file_perms; +allow platform_app mdlog_data_file:dir rw_dir_perms; + +# Date : 2014/11/17 +# Operation : Migration +# Purpose : Gallery needs to access video codec to encode motion track video +# Package: com.android.gallery3d +allow platform_app Vcodec_device:chr_file { read write ioctl open }; + +# Date : 2014/11/17 +# Operation : Migration +# Purpose : AALTool to access /dev/als_ps for light sensor calibration +# Package: com.mediatek.aaltool +allow platform_app als_ps_device:chr_file { read open ioctl }; + +# Date : 2014/11/19 +# Operation : Migration +# Purpose : FileManager can access attribute of file execute +# Package: com.mediatek.filemanager +allow platform_app fuse:file execute; + +# Date : 2014/11/21 +# Operation : Migration +# Purpose : Gallery needs to search radio data when send mms +# Package: com.android.gallery3d +allow platform_app radio_data_file:dir search; + +# Date : 2014/12/07 +# Operation : Migration +# Purpose : MTKLogger need setup local socket with cmddumper +# Package: com.mediatek.mtklogger +allow platform_app init:unix_stream_socket connectto; +allow platform_app cmddumper:unix_stream_socket connectto; + +# Date : 2014/12/30 +# Operation : TUI Migration +# Purpose : TUI service need to access tui device driver +# Package: com.trustonic.tuiservice.TuiService +allow platform_app mobicore_tui_device:chr_file { read open ioctl }; + +# Date : 2015/01/13 +# Operation : New feature for GPS Log +# Purpose : MTKLogger need setup local socket with mnld +# Package: com.mediatek.mtklogger +allow platform_app mnld:unix_stream_socket connectto; diff --git a/sepolicy/poad.te b/sepolicy/poad.te new file mode 100644 index 0000000..baf899a --- /dev/null +++ b/sepolicy/poad.te @@ -0,0 +1,26 @@ +# ============================================== +# Policy File of /system/binpoad Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type poad_exec , exec_type, file_type; +type poad ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + + +init_daemon_domain(poad) + diff --git a/sepolicy/ppl_agent.te b/sepolicy/ppl_agent.te new file mode 100644 index 0000000..0bf67df --- /dev/null +++ b/sepolicy/ppl_agent.te @@ -0,0 +1,58 @@ +# ============================================== +# Policy File of /system/bin/ppl_agent Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type ppl_agent_exec , exec_type, file_type; +type ppl_agent ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(ppl_agent) + +# Date : 2014/09/11 +# Operation : Migration +# Purpose : [Privacy protection lock][allow com.mediatek.ppl binder IPC to ppl_agent service] +# Package name : com.mediatek.ppl +binder_use(ppl_agent) +binder_service(ppl_agent) + +# Date : 2014/10/16 +# Operation : QC +# Purpose : [Privacy protection lock][ppl_agent call FileOp_BackupToBinRegionForDM to do nvram backup] +# Package name : com.mediatek.ppl +allow ppl_agent mmcblk_device:blk_file rw_file_perms; +allow ppl_agent platformblk_device:blk_file rw_file_perms; + +# Date : 2014/10/24 +# Operation : Migration +# Purpose : [Privacy protection lock][ppl_agent call FileOp_BackupToBinRegionForDM to do nvram backup] +# Package name : com.mediatek.ppl +allow ppl_agent platformblk_device:dir search; +allow ppl_agent block_device:dir search; + +# Data : 2014/10/24 +# Operation : Migration +# Purpose : [Privacy protection lock][ppl_agent need access nvram data file for backup restore function] +# Package name : com.mediatek.ppl +allow ppl_agent nvram_data_file:dir create_dir_perms; +allow ppl_agent nvram_data_file:file create_file_perms; +allow ppl_agent nvram_data_file:lnk_file read; +allow ppl_agent nvdata_file:dir create_dir_perms; +allow ppl_agent nvdata_file:file create_file_perms; + +# Data : 2014/10/24 +# Operation : Migration +# Purpose : [Privacy protection lock][Allow ServiceManager add this service] +# Package name : ServiceManager +allow ppl_agent ppl_agent_service:service_manager add; +# Data : 2014/10/31 +# Operation : QC +# Purpose : [Privacy protection lock][ppl_agent need access nvram data file for backup restore function on MT6582] +# Package name : ServiceManager +allow ppl_agent nvram_device:chr_file { read write ioctl open };
\ No newline at end of file diff --git a/sepolicy/ppp.te b/sepolicy/ppp.te new file mode 100644 index 0000000..c2c5333 --- /dev/null +++ b/sepolicy/ppp.te @@ -0,0 +1,42 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + + + +# Date : WK14.34 +# Operation : Migration +# Purpose: for VPN + +allow ppp init:unix_stream_socket connectto; +allow ppp property_socket:sock_file write; + +# Date : WK14.37 +# Operation : Migration +# Purpose: for PPPOE Test + +allow ppp devpts:chr_file { read write ioctl open setattr }; +allow ppp self:capability { setuid net_raw setgid dac_override }; +allow ppp self:packet_socket { write ioctl setopt read bind create }; +allow ppp shell_exec:file { read execute open execute_no_trans }; + + +# Date : WK14.37 +# Operation : Migration +# Purpose: for PPPOE Test: Property permission + +allow ppp pppoe_ppp0_prop:property_service set; +allow ppp net_radio_prop:property_service set; +allow ppp system_prop:property_service set; + + +# Date : WK14.38 +# Operation : Migration +# Purpose: for PPPOE Test + +allow ppp ppp_exec:file execute_no_trans; + +# Date : WK14.53 +# Operation : check in +# Purpose: for warning kernel API +allow ppp mtp:file read;
\ No newline at end of file diff --git a/sepolicy/pppd_dt.te b/sepolicy/pppd_dt.te new file mode 100644 index 0000000..9351ec2 --- /dev/null +++ b/sepolicy/pppd_dt.te @@ -0,0 +1,38 @@ +# ============================================== +# Policy File of /system/binpppd_dt Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type pppd_dt_exec , exec_type, file_type; +type pppd_dt ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + + +init_daemon_domain(pppd_dt) +allow pppd_dt self:capability { setgid setuid net_admin }; +allow pppd_dt property_socket:sock_file write; +allow pppd_dt dnsproxyd_socket:sock_file write; +allow pppd_dt init:unix_stream_socket connectto; +allow pppd_dt self:udp_socket { ioctl create }; +allow pppd_dt netd:unix_stream_socket connectto; +allow pppd_dt ttyACM_device:chr_file { read write ioctl open getattr }; +allow pppd_dt ppp_device:chr_file { read write ioctl open }; +allow pppd_dt system_file:file execute_no_trans; +allow pppd_dt shell_exec:file { read open execute }; +allow pppd_dt net_radio_prop:property_service set; +allow pppd_dt pppoe_ppp0_prop:property_service set; +allow pppd_dt system_prop:property_service set; diff --git a/sepolicy/pppd_via.te b/sepolicy/pppd_via.te new file mode 100644 index 0000000..fee7b10 --- /dev/null +++ b/sepolicy/pppd_via.te @@ -0,0 +1,55 @@ +# ============================================== +# Policy File of /system/bin/pppd_via Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type pppd_via_exec , exec_type, file_type; +type pppd_via ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + + +#permissive pppd_via; +init_daemon_domain(pppd_via) +#unconfined_domain(pppd_via) + + +allow pppd_via self:udp_socket create; +allow pppd_via system_file:file execute_no_trans; +allow pppd_via ttySDIO_device:chr_file { read write open setattr getattr ioctl }; +allow pppd_via dnsproxyd_socket:sock_file write; +allow pppd_via init:unix_stream_socket connectto; +allow pppd_via netd:unix_stream_socket connectto; +allow pppd_via ppp_device:chr_file { read write ioctl open }; +allow pppd_via property_socket:sock_file write; +allow pppd_via self:capability { setuid net_admin dac_override }; +allow pppd_via self:udp_socket ioctl; +allow pppd_via system_data_file:file open; +allow pppd_via net_radio_prop:property_service set; + + + + + + + + + + + + + + diff --git a/sepolicy/pq.te b/sepolicy/pq.te new file mode 100644 index 0000000..bc8ae7f --- /dev/null +++ b/sepolicy/pq.te @@ -0,0 +1,40 @@ +# ============================================== +# Policy File of /system/binpq Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type pq_exec , exec_type, file_type; +type pq ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive pq; +init_daemon_domain(pq) +# unconfined_domain(pq) + +# Date : 2014/10/16 +# Operation : Migration +# Purpose : for enforcing +allow pq system_prop:property_service set; +allow pq graphics_device:chr_file { read write open ioctl }; + + +# Date : 2014/10/29 +# Operation : Migration +# Purpose : for enforcing +allow pq init:unix_stream_socket connectto; +allow pq property_socket:sock_file write; +allow pq tmpfs:lnk_file read;
\ No newline at end of file diff --git a/sepolicy/property.te b/sepolicy/property.te new file mode 100644 index 0000000..4345d1b --- /dev/null +++ b/sepolicy/property.te @@ -0,0 +1,157 @@ +# ============================================== +# MTK Policy Rule +# ============================================== +type mtk_default_prop, property_type; + +# Date: W14.32 +# Operation: Migration +# Purpose: don't allow to use default_prop +neverallow { domain -init } default_prop:property_service set; +neverallow { domain -init -system_server -recovery } ctl_default_prop:property_service set; + +#=============allow ccci_mdinit to start gsm0710muxd============== +type ctl_gsm0710muxd_prop, property_type; +type ctl_gsm0710muxd-s_prop, property_type; +type ctl_gsm0710muxd-d_prop, property_type; +type ctl_gsm0710muxdmd2_prop, property_type; +#=============allow ccci_mdinit to ctl. mdlogger============== +type ctl_mdlogger_prop, property_type; +type ctl_emdlogger1_prop, property_type; +type ctl_emdlogger2_prop, property_type; +type ctl_dualmdlogger_prop, property_type; +#=============allow eemcs_mdinit to start mdlogger========== +type ctl_eemcs_fmdl_prop, property_type; +#type ctl_emdlogger5_prop, property_type; + +#=============allow mtkrild to set persist.ril property============== +type persist_ril_prop, property_type; +#=============allow terserver to set terservice property============== +type terservice_prop, property_type; +#=============allow gsm0710muxd to set mux property============== +type gsm0710muxd_prop, property_type; + +#=============allow netlog running============== +type debug_mtklog_prop, property_type; +type persist_mtklog_prop, property_type; +type debug_netlog_prop, property_type; +#=============allow system_server to set media.wfd.*============== +type media_wfd_prop, property_type; + +#=============allow netd to set mtk_wifi.*========================= +type mtk_wifi_prop, property_type; + +#=============allow mdlogger============== +type debug_mdlogger_prop, property_type; + +#=============allow AEE============== +type persist_mtk_aee_prop, property_type; +type persist_aee_prop, property_type; +type debug_mtk_aee_prop, property_type; + +#=============allow aee_dumpstate============== +type debug_bq_dump_prop, property_type; + +#=============allow ccci_mdinit to stop rild============== +type ctl_ril-daemon-mtk_prop, property_type; +type ctl_ril-daemon-s_prop, property_type; +type ctl_ril-daemon-d_prop, property_type; +type ctl_ril-daemon-md2_prop, property_type; + +#=============allow ccci_mdinit to start ccci_fsd============== +type ctl_ccci_fsd_prop, property_type; +type ctl_ccci2_fsd_prop, property_type; + +#=============allow ccci_mdinit to start ccci_rpcd============== +type ctl_ccci_rpcd_prop, property_type; +type ctl_ccci2_rpcd_prop, property_type; + +#=============allow ccci_mdinit to set ril_active_md_prop============== +type ril_active_md_prop, property_type; + +#=============allow ccci_mdinit to stop rild============== +type ril_mux_report_case_prop, property_type; +type ril_cdma_report_prop, property_type; + +#=============allow ccci_mdinit to mtk_md_prop============== +type mtk_md_prop, property_type; + +#=============allow mtkrild to start muxreport============== +type ctl_muxreport-daemon_prop, property_type; + +#=============allow ppp to set pppoe.ppp0============== +type pppoe_ppp0_prop, property_type; + +#=============allow rild to start pppd_via============== +type ctl_pppd_via_prop, property_type; + +#=============allow mediatek_prop ============== +type mediatek_prop, property_type; + +#=============allow bootanim============== +type bootani_prop, property_type; + +#=============allow mnld_prop============== +type mnld_prop, property_type; + +#=============allow audiohal============== +type audiohal_prop, property_type; + +#=============allow contrl ril3gd=========== +type ctl_ril3gd_prop, property_type; + +#=============allow contrl zpppd_gprs=========== +type ctl_zpppdgprs_prop, property_type; + +#=============allow DM============== +type persist_dm_prop, property_type; +type ctl_rbfota_prop, property_type; + +#=============allow ipod============== +type ipod_prop, property_type; +type ctl_ipod_prop, property_type; + +#=============allow wmt============== +type wmt_prop, property_type; + +#=============allow atcid============== +type ctl_atcid-daemon-u_prop, property_type; +type ctl_atci_service_prop, property_type; +type persist_service_atci_prop, property_type; +#============= permission_check ============== +type persist_md_prop, property_type; + +#=============allow sensor============== +type ctl_msensord_prop, property_type; +type ctl_akmd8963_prop, property_type; +type ctl_akmd09911_prop, property_type; +type ctl_bmm050d_prop, property_type; +type ctl_bmm056d_prop, property_type; +type ctl_geomagneticd_prop, property_type; +type ctl_orientationd_prop, property_type; +type ctl_emcsmdlogger_prop, property_type; +type ctl_eemcs_fsd_prop, property_type; +type ctl_istd8303_prop, property_type; +type ctl_st480_prop, property_type; +type ctl_mmc3524xd_prop, property_type; +type ctl_mc6470d_prop, property_type; +type ctl_qmcX983d_prop, property_type; +type ctl_af7133e_prop, property_type; +#=============allow statusd============== +type net_cdma_mdmstat, property_type; +type cdma_prop, property_type; + +#=============allow saveLocale============== +type save_locale_prop, property_type; + +#=============allow bt============== +type bt_prop, property_type; +type persist_bt_prop, property_type; + +#=============allow ccci_mdinit EVDO ============== +type mtk_tele_prop, property_type; + +#=============allow pppd ============== +type pppd_gprs_prop, property_type; + +#=============allow wifi offload deamon ============== +type mtk_wod_prop, property_type; diff --git a/sepolicy/property_contexts b/sepolicy/property_contexts new file mode 100644 index 0000000..0e733e7 --- /dev/null +++ b/sepolicy/property_contexts @@ -0,0 +1,166 @@ +# ============================================== +# MTK Policy Rule +# ============================================== +#=============allow ccci_mdinit to start gsm0710muxd============== +ctl.gsm0710muxd u:object_r:ctl_gsm0710muxd_prop:s0 +ctl.gsm0710muxd-s u:object_r:ctl_gsm0710muxd-s_prop:s0 +ctl.gsm0710muxd-d u:object_r:ctl_gsm0710muxd-d_prop:s0 +ctl.gsm0710muxdmd2 u:object_r:ctl_gsm0710muxdmd2_prop:s0 + +#=============allow ccci_mdinit to ctl. mdlogger============== +ctl.mdlogger u:object_r:ctl_mdlogger_prop:s0 +ctl.emdlogger1 u:object_r:ctl_emdlogger1_prop:s0 +ctl.emdlogger2 u:object_r:ctl_emdlogger2_prop:s0 +ctl.dualmdlogger u:object_r:ctl_dualmdlogger_prop:s0 +#=============allow eemcs_mdinit to start mdlogger========== +ctl.eemcs_fmdl u:object_r:ctl_eemcs_fmdl_prop:s0 +#ctl.emdlogger5 u:object_r:ctl_emdlogger5_prop:s0 + +#=============allow mtkrild to set persist.ril property============== +persist.ril u:object_r:persist_ril_prop:s0 +#=============allow terservice to set terservice property============== +persist.ter u:object_r:terservice_prop:s0 + +#=============allow netlog============== +#debug.mtklog.init.flag +debug.mtklog u:object_r:debug_mtklog_prop:s0 +#persist.mtklog.log2sd.path +persist.mtklog u:object_r:persist_mtklog_prop:s0 +#debug.netlog.stopreason +debug.netlog u:object_r:debug_netlog_prop:s0 + +#=============allow system_server to set media.wfd.*============== +media.wfd. u:object_r:media_wfd_prop:s0 + +#=============allow netd to set mtk_wifi.*======================== +mtk_wifi. u:object_r:mtk_wifi_prop:s0 + +#=============allow mdlogger============== +debug.mdlogger u:object_r:debug_mdlogger_prop:s0 + +#=============allow AEE============== +# persist.mtk.aee.mode && persist.mtk.aee.dal +persist.mtk.aee u:object_r:persist_mtk_aee_prop:s0 + +# persist.aee.core.dump && persist.aee.core.direct +persist.aee u:object_r:persist_aee_prop:s0 + +# debug.mtk.aee.db +debug.mtk.aee u:object_r:debug_mtk_aee_prop:s0 + +#=============allow AEE_Dumpstate============== +debug.bq.dump u:object_r:debug_bq_dump_prop:s0 + +#=============allow mux============== +ril.mux. u:object_r:gsm0710muxd_prop:s0 + +#=============allow vold============== +persist.vold. u:object_r:vold_prop:s0 +ctl.sdcard u:object_r:ctl_fuse_prop:s0 + +#=============allow mdinit============== +ctl.ril-daemon-mtk u:object_r:ctl_ril-daemon-mtk_prop:s0 +ctl.ril-daemon-s u:object_r:ctl_ril-daemon-s_prop:s0 +ctl.ril-daemon-d u:object_r:ctl_ril-daemon-d_prop:s0 +ctl.ril-daemon-md2 u:object_r:ctl_ril-daemon-md2_prop:s0 + +ctl.ccci_fsd u:object_r:ctl_ccci_fsd_prop:s0 +ctl.ccci2_fsd u:object_r:ctl_ccci2_fsd_prop:s0 +ctl.ccci_rpcd u:object_r:ctl_ccci_rpcd_prop:s0 +ctl.ccci2_rpcd u:object_r:ctl_ccci2_rpcd_prop:s0 +ctl.muxreport-daemon u:object_r:ctl_muxreport-daemon_prop:s0 + +ril.active.md u:object_r:ril_active_md_prop:s0 +ril.mux.report.case u:object_r:ril_mux_report_case_prop:s0 +ril.cdma.report u:object_r:ril_cdma_report_prop:s0 + +#=============allow pppd_via============== +ctl.pppd_via u:object_r:ctl_pppd_via_prop:s0 + +#=============allow ppp to set pppoe.ppp0.*======================== +pppoe.ppp0. u:object_r:pppoe_ppp0_prop:s0 + +#=============allow mediatek_prop ============== +mediatek. u:object_r:mediatek_prop:s0 + +#=============allow bootanim============== +persist.bootanim. u:object_r:bootani_prop:s0 + +#=============allow mnld_prop ============== +gps.clock.type u:object_r:mnld_prop:s0 +gps.gps.version u:object_r:mnld_prop:s0 + +#=============allow audiohal============== +streamout. u:object_r:audiohal_prop:s0 +af. u:object_r:audiohal_prop:s0 +streamin. u:object_r:audiohal_prop:s0 +a2dp. u:object_r:audiohal_prop:s0 +persist.af. u:object_r:audiohal_prop:s0 + +#=============allow tedongle to set tedongle.*============= +tedongle. u:object_r:radio_prop:s0 +ctl.ril-3gddaemon u:object_r:ctl_ril3gd_prop:s0 +ctl.zpppd_gprs u:object_r:ctl_zpppdgprs_prop:s0 + +#=============allow DM============== +# persist.dm.lock +persist.dm. u:object_r:persist_dm_prop:s0 +# dm fota +ctl.rbfota u:object_r:ctl_rbfota_prop:s0 + +#=============allow atcid============== +ctl.atcid-daemon-u u:object_r:ctl_atcid-daemon-u_prop:s0 +ctl.atci_service u:object_r:ctl_atci_service_prop:s0 +persist.service.atci. u:object_r:persist_service_atci_prop:s0 + +#=============allow ipod============== +ctl.ipod u:object_r:ctl_ipod_prop:s0 +ipo.ipoh. u:object_r:ipod_prop:s0 +persist.ipoh. u:object_r:ipod_prop:s0 + +#=============allow wmt ============== +persist.mtk.wcn u:object_r:wmt_prop:s0 +service.wcn u:object_r:wmt_prop:s0 + +#============= permission_check ============== +#persist.md.perm.checked +persist.md u:object_r:persist_md_prop:s0 + +#=============allow sensor daemon============== +ctl.msensord u:object_r:ctl_msensord_prop:s0 +ctl.bmm050d u:object_r:ctl_bmm050d_prop:s0 +ctl.bmm056d u:object_r:ctl_bmm056d_prop:s0 +ctl.akmd8963 u:object_r:ctl_akmd8963_prop:s0 +ctl.akmd09911 u:object_r:ctl_akmd09911_prop:s0 +ctl.geomagneticd u:object_r:ctl_geomagneticd_prop:s0 +ctl.orientationd u:object_r:ctl_orientationd_prop:s0 +ctl.emdlogger5 u:object_r:ctl_emcsmdlogger_prop:s0 +ctl.eemcs_fsd u:object_r:ctl_eemcs_fsd_prop:s0 +ctl.istd8303 u:object_r:ctl_istd8303_prop:s0 +ctl.st480 u:object_r:ctl_st480_prop:s0 +ctl.mmc3524xd u:object_r:ctl_mmc3524xd_prop:s0 +ctl.mc6470d u:object_r:ctl_mc6470d_prop:s0 +ctl.qmcX983d u:object_r:ctl_qmcX983d_prop:s0 +ctl.af7133e u:object_r:ctl_af7133e_prop:s0 +#=============allow statusd============== +net.cdma.mdmstat u:object_r:net_cdma_mdmstat:s0 + +#=============allow c2k_prop ============== +cdma. u:object_r:cdma_prop:s0 + +#=============allow saveLocale============== +user.language u:object_r:save_locale_prop:s0 +user.region u:object_r:save_locale_prop:s0 + +#=============allow bt prop============== +bt. u:object_r:bt_prop:s0 +persist.bt. u:object_r:persist_bt_prop:s0 +#=============allow ccci_mdinit EVDO ============== +mtk_telephony u:object_r:mtk_tele_prop:s0 +#=============allow ccci_mdinit md status ============== +mtk.md u:object_r:mtk_md_prop:s0 +#=============allow pppd ============== +ctl.pppd_gprs u:object_r:pppd_gprs_prop:s0 + +#=============allow wifi offload deamon ============== +net.wo. u:object_r:mtk_wod_prop:s0 diff --git a/sepolicy/pvrsrvctl.te b/sepolicy/pvrsrvctl.te new file mode 100644 index 0000000..84a8ccc --- /dev/null +++ b/sepolicy/pvrsrvctl.te @@ -0,0 +1,18 @@ +# ============================================== +# Policy File of /system/bin/pvrsrvctl Executable File + +# ============================================== +# Type Declaration +# ============================================== +type pvrsrvctl, domain; +type pvrsrvctl_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +init_daemon_domain(pvrsrvctl) + +allow pvrsrvctl self:capability sys_admin; +allow pvrsrvctl gpu_device:chr_file rw_file_perms; +allow pvrsrvctl self:capability sys_module; + diff --git a/sepolicy/racoon.te b/sepolicy/racoon.te new file mode 100644 index 0000000..7b20973 --- /dev/null +++ b/sepolicy/racoon.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + diff --git a/sepolicy/radio.te b/sepolicy/radio.te new file mode 100644 index 0000000..7af090c --- /dev/null +++ b/sepolicy/radio.te @@ -0,0 +1,133 @@ +# ============================================== +# MTK Policy Rule +# ============ + +allow radio custom_file:dir getattr; +#violate never allow rule +#allow radio device:chr_file { read write ioctl open getattr }; +allow radio dm_agent_binder:binder call; +allow radio rild2_socket:sock_file write; +allow radio rild3_socket:sock_file write; +allow radio rild4_socket:sock_file write; +allow radio rild_via_socket:sock_file write; +allow radio rild_md2_socket:sock_file write; +allow radio sdcard_internal:dir { write create add_name }; +allow radio sdcard_internal:file { read write getattr open create }; +##violate never allow rule +#allow radio sysfs:file write; +##violate never allow rule +#allow radio system_data_file:file append; +allow radio zygote:unix_stream_socket { getopt getattr }; + +# Date : WK14.36 +# Operation : Migration +# Purpose : for mtkrild and viarild +allow radio mtkrild:unix_stream_socket connectto; +allow radio mtkrildmd2:unix_stream_socket connectto; +allow radio statusd:unix_stream_socket connectto; + +# Date : WK14.38 2014/09/16 +# Operation : Migration +# Purpose : for engineermode +allow radio mediatek_prop:property_service set; +allow radio em_svr:unix_stream_socket connectto; +allow radio mt_otg_test_device:chr_file { read write ioctl open }; +allow radio mtgpio_device:chr_file { read ioctl open }; +allow radio platformblk_device:dir search; +allow radio stpbt_device:chr_file { read write open }; +allow radio stpant_device:chr_file { read write open }; +allow radio bt_int_adp_socket:sock_file write; +allow radio mtkbt:unix_dgram_socket sendto; +allow radio guiext-server:binder { transfer call }; +allow radio persist_ril_prop:property_service set; +allow radio mt6605_device:chr_file { read write ioctl open getattr }; +allow radio nfc_socket:dir { write add_name remove_name search }; +allow radio nfc_socket:sock_file { create write unlink setattr }; +allow radio system_prop:property_service set; + +# Date: wk14.40 +# Operation : SQC +# Purpose : [ALPS01756200] wwop boot up fail +allow radio custom_file:dir { search getattr open read }; +allow radio custom_file:file { read open getattr}; + +# C2K System Property +allow radio cdma_prop:property_service set; + +# Date : 2014/10/13 +# Operation : IT +# Purpose : mtk_agpsd establishes the local socket as agpsd for all A-GPS +# application to do something with mtk_agpsd +unix_socket_connect(radio, agpsd, mtk_agpsd) + +# Date : 2014/10/14 +# Operation : IT +# Purpose : for IMSA connect to volte_imsa1 provided by imcb process +unix_socket_connect(radio, volte_imsa1, volte_imcb) + +# Date : 2014/10/16 +# Operation : IT +# Purpose : for TTLIA apk connect to rild_atci by mtkrild process +allow radio rild_atci_socket:sock_file write; + +# Date : 2014/10/17 +# Operation : IT +# Purpose : Talks to ril-3gddaemon via the rild-dongle socket. +unix_socket_connect(radio, rild-dongle, ril-3gddaemon) + +# Date : 2014/10/20 +# Operation : IT +# Purpose : enable ATCId in engineer mode. +allow radio ctl_atcid-daemon-u_prop:property_service set; +allow radio ctl_atci_service_prop:property_service set; +allow radio persist_service_atci_prop:property_service set; + +# Date : 2014/11/05 +# Operation : IT +# Purpose : for IMS_RILA connect to rild_ims provided by mtkrild process +unix_socket_connect(radio, rild_ims, mtkrild) + +# Purpose : allow to access kpd driver file +allow radio sysfs_keypad_file:dir { open write }; +allow radio sysfs_keypad_file:file { open write }; + +# Date : 2014/12/13 +# Operation : IT +# Purpose : for bluetooth relayer mode +allow radio block_device:dir search; +allow radio ttyGS_device:chr_file { open read write ioctl }; + +# Date : 2014/12/26 +# Operation : IT +# Purpose : for engineermode sensor can work normal +allow radio als_ps_device:chr_file { read open ioctl }; + +# Date : 2015/01/20 +# Operation : IT +# Purpose : for engineermode Usb PHY Tuning +allow radio debugfs:file { read getattr }; + +# Date : 2015/01/21 +# Operation : IT +# Purpose : C2K rild +allow radio rild_atci_md2_socket:sock_file write; +allow radio rild_atci_c2k_socket:sock_file write; + +# Date : WK15.05 2015/01/26 +# Operation : IT +# Purpose : for engineermode camera +allow radio debug_prop:property_service set; + +# Date : 2015/04/11 +# Operation : VT development +# Purpose : for VT usage +allow radio vtservice:binder call; +allow radio vtservice:binder transfer; +allow vtservice self:capability dac_override; +allow vtservice soc_vt_svc_socket:sock_file write; +allow vtservice soc_vt_tcv_socket:sock_file write; +allow vtservice platform_app:binder call; +allow vtservice system_server:binder call; +allow vtservice fuse:dir write; +allow vtservice surfaceflinger:fd use; +allow vtservice tmpfs:lnk_file read; diff --git a/sepolicy/recovery.te b/sepolicy/recovery.te new file mode 100644 index 0000000..a4a253f --- /dev/null +++ b/sepolicy/recovery.te @@ -0,0 +1,97 @@ +# ============================================== +# MTK Policy Rule +# ============================================== +# recovery console (used in recovery init.rc for /sbin/recovery) + +# special factory reset & backup/restore needs permissive mode +# permissive recovery; + +# Date : WK14.38 +# Operation : Migration +# Purpose : for recovery operation +allow recovery misc_device:chr_file *; +allow recovery platformblk_device:dir *; +allow recovery platformblk_device:blk_file *; +allow recovery vfat:dir *; +allow recovery misc_sd_device:chr_file *; + +# Date : WK14.39 +# Operation : Migration +# Purpose : for CIP project access /custom partition +allow recovery custom_file:dir *; +allow recovery rootfs:dir *; + +# Date : WK14.41 +# Operation : Migration +# Purpose : Differential update +allow recovery bootimg_device:chr_file *; +allow recovery recovery_device:chr_file *; +allow recovery logo_device:chr_file *; +allow recovery preloader_device:chr_file *; +allow recovery uboot_device:chr_file *; +allow recovery init:dir *; +allow recovery init:file ~{ execute entrypoint }; +allow recovery init:lnk_file *; +allow recovery kernel:dir *; +allow recovery kernel:file ~{ execute entrypoint }; +allow recovery kernel:lnk_file *; + + +# Date : WK14.41 +# Operation : Migration +# Purpose : Block full update +allow recovery healthd:dir *; +allow recovery healthd:file ~{ execute entrypoint }; +allow recovery healthd:lnk_file *; +dontaudit recovery self:capability sys_ptrace; +allow recovery ueventd:dir *; +allow recovery ueventd:file ~{ execute entrypoint }; +allow recovery ueventd:lnk_file *; + +# Date : WK14.42 +# Operation : Migration +# Purpose : for sepcial factory reset +allow recovery system_data_file:dir *; +allow recovery apk_data_file:dir *; + +userdebug_or_eng(` + allow recovery su:dir *; + allow recovery su:file *; + allow recovery su:lnk_file *; +') + +# Date : WK14.43 +# Operation : Migration +# Purpose : JB to L differential OTA +#allow recovery unlabeled:lnk_file *; + +# Date : WK14.45 +# Operation : SQC +# Purpose : partition size changed +allow recovery pmt_device:chr_file *; +allow recovery tee_part_device:chr_file *; + +# Date : WK14.45 +# Operation : Migration +# Purpose : KK->L->L legacy secure OTA +allow recovery proc_sysrq:file { write open }; +allow recovery sec_device:chr_file { read ioctl open }; +allow recovery sec_ro_device:chr_file { read open }; +allow recovery seccfg_device:chr_file { read open }; +allow recovery self:capability sys_boot; + +# Date : WK14.46 +# Operation : Migration +# Purpose : FOTA upgrade +allow recovery app_data_file:dir { write create add_name }; +allow recovery app_data_file:dir { read open }; +allow recovery app_data_file:file { read write create open }; +allow recovery mobicore_data_file:dir { write remove_name search add_name }; +allow recovery mobicore_data_file:file { rename setattr read create write getattr unlink open }; +allow recovery mobicore_data_file:file { relabelfrom relabelto }; + +# Date : WK14.47 +# Operation : Migration +# Purpose : Root Integrity Check +allow recovery md_ctrl:file { read getattr open }; +allow recovery mobicore_data_file:dir { read open }; diff --git a/sepolicy/resmon.te b/sepolicy/resmon.te new file mode 100644 index 0000000..ad7f099 --- /dev/null +++ b/sepolicy/resmon.te @@ -0,0 +1,43 @@ +# ============================================== +# Policy File of /system/binresmon Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type resmon_exec , exec_type, file_type; +type resmon ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== +userdebug_or_eng(` + permissive resmon; + init_daemon_domain(resmon) + + # Date : 2014/09/10 + # Operation : Migration + # Purpose : allow Binder IPC for dumpsys windows display + binder_use(resmon) + + # Date : 2014/10/20 + # Operation : Migration + # Purpose : allow resmon to execute shell commands + allow resmon fuse:dir { write search add_name }; + allow resmon fuse:file { read write create open }; + allow resmon shell_exec:file execute_no_trans; + allow resmon system_file:file execute_no_trans; + allow resmon zygote_exec:file execute_no_trans; + + allow untrusted_app resmon:fd use; + +') diff --git a/sepolicy/ril-3gddaemon.te b/sepolicy/ril-3gddaemon.te new file mode 100644 index 0000000..76b302a --- /dev/null +++ b/sepolicy/ril-3gddaemon.te @@ -0,0 +1,52 @@ +# ril-3gddaemon - radio interface layer daemon +type ril-3gddaemon, domain; +type ril-3gddaemon_exec, exec_type, file_type; +init_daemon_domain(ril-3gddaemon) +net_domain(ril-3gddaemon) + +allow ril-3gddaemon self:netlink_route_socket nlmsg_write; +allow ril-3gddaemon kernel:system module_request; +unix_socket_connect(ril-3gddaemon, property, init) +allow ril-3gddaemon self:capability { setuid setgid net_admin net_raw dac_override sys_module }; +allow ril-3gddaemon alarm_device:chr_file rw_file_perms; +allow ril-3gddaemon cgroup:dir create_dir_perms; +allow ril-3gddaemon radio_device:chr_file rw_file_perms; +allow ril-3gddaemon radio_device:blk_file r_file_perms; +allow ril-3gddaemon mtd_device:dir search; +allow ril-3gddaemon efs_file:dir create_dir_perms; +allow ril-3gddaemon efs_file:file create_file_perms; +allow ril-3gddaemon shell_exec:file rx_file_perms; +allow ril-3gddaemon radio_data_file:dir rw_dir_perms; +allow ril-3gddaemon radio_data_file:file create_file_perms; +allow ril-3gddaemon sdcard_type:dir r_dir_perms; +allow ril-3gddaemon system_data_file:dir r_dir_perms; +allow ril-3gddaemon system_data_file:file r_file_perms; +allow ril-3gddaemon system_file:file x_file_perms; + +# property service +allow ril-3gddaemon radio_prop:property_service set; +allow ril-3gddaemon net_radio_prop:property_service set; +allow ril-3gddaemon system_radio_prop:property_service set; +allow ril-3gddaemon system_prop:property_service set; +auditallow ril-3gddaemon net_radio_prop:property_service set; +auditallow ril-3gddaemon system_radio_prop:property_service set; +allow ril-3gddaemon pppoe_ppp0_prop:property_service set; +allow ril-3gddaemon ctl_zpppdgprs_prop:property_service set; + + +# Read/Write to uart driver (for 3gdongle) +allow ril-3gddaemon tty_device:chr_file rw_file_perms; + +# Allow ril-3gddaemon to create and use netlink sockets. +allow ril-3gddaemon self:netlink_socket create_socket_perms; +allow ril-3gddaemon self:netlink_kobject_uevent_socket create_socket_perms; + +allow ril-3gddaemon init:dir { getattr open read search }; +allow ril-3gddaemon ppp_exec:file { read open getattr execute execute_no_trans }; +allow ril-3gddaemon ppp_device:chr_file { read write open ioctl }; +allow ril-3gddaemon device:dir { read open write}; + +# Access to wake locks +wakelock_use(ril-3gddaemon) + +allow ril-3gddaemon self:socket create_socket_perms; diff --git a/sepolicy/rild.te b/sepolicy/rild.te new file mode 100644 index 0000000..86cbf61 --- /dev/null +++ b/sepolicy/rild.te @@ -0,0 +1,5 @@ +# ============================================== +# MTK Policy Rule +# ============ + + diff --git a/sepolicy/runas.te b/sepolicy/runas.te new file mode 100644 index 0000000..4b5a0be --- /dev/null +++ b/sepolicy/runas.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============ + diff --git a/sepolicy/s62xd.te b/sepolicy/s62xd.te new file mode 100644 index 0000000..e053546 --- /dev/null +++ b/sepolicy/s62xd.te @@ -0,0 +1,16 @@ +# ============================================== +# Policy File of /system/bins62xd Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type s62xd_exec , exec_type, file_type; +type s62xd ,domain; + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(s62xd) diff --git a/sepolicy/sbchk.te b/sepolicy/sbchk.te new file mode 100644 index 0000000..6824e92 --- /dev/null +++ b/sepolicy/sbchk.te @@ -0,0 +1,25 @@ +# ============================================== +# Policy File of /system/bin/sbchk Executable File + +# ============================================== +# Type Declaration +# ============================================== +type sbchk, domain; +type sbchk_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +init_daemon_domain(sbchk) + +# Date WK14.46 +# Operation : Migration +# Purpose : for security driver access +allow sbchk misc_sd_device:chr_file { read open }; +allow sbchk platformblk_device:blk_file { read write open }; +allow sbchk platformblk_device:dir search; +allow sbchk preloader_device:chr_file { read open }; +allow sbchk sec_device:chr_file { read ioctl open }; +allow sbchk seccfg_device:chr_file { read write open }; +allow sbchk sec_ro_device:chr_file { open read }; +allow sbchk block_device:dir search; diff --git a/sepolicy/sdcardd.te b/sepolicy/sdcardd.te new file mode 100644 index 0000000..24486a0 --- /dev/null +++ b/sepolicy/sdcardd.te @@ -0,0 +1,36 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK14.37 +# Operation : Migration +# Purpose : for sdcard daemon to access lk_env +allow sdcardd proc_lk_env:file { read write ioctl open }; +allow sdcardd misc_device:chr_file { read write open }; +allow sdcardd mmcblk_device:blk_file rw_file_perms; +allow sdcardd platformblk_device:blk_file rw_file_perms; +allow sdcardd block_device:dir search; +allow sdcardd platformblk_device:dir search; + +# Date : WK14.47 +# Purpose : create symbolic link from /mnt/shell/emulated to /storage/emulated +allow sdcardd tmpfs:dir {write add_name mounton}; +allow sdcardd tmpfs:lnk_file create; +allow sdcardd tmpfs:filesystem unmount; + +# Date : WK14.48 +# Purpose : invoke vdc for handle_users +allow sdcardd devpts:chr_file { read write getattr open ioctl }; +allow sdcardd vdc_exec:file { read execute open execute_no_trans }; +allow sdcardd vold:unix_stream_socket connectto; +allow sdcardd vold_socket:sock_file write; + + +# Date : WK14.48 +# Purpose : unknown +allow sdcardd platform_app:fd use; +allow sdcardd untrusted_app:fd use; + +# Date : WK15.02 +# Purpose : ashared memory +allow sdcardd platform_app_tmpfs:file write; diff --git a/sepolicy/service.te b/sepolicy/service.te new file mode 100644 index 0000000..e4a31ce --- /dev/null +++ b/sepolicy/service.te @@ -0,0 +1,12 @@ +# ============================================== +# MTK Policy Rule +# ============================================== +type nvram_agent_service, service_manager_type; +type dm_agent_binder_service, service_manager_type; +type terservice_service, service_manager_type; +type ota_agent_service, service_manager_type; +type aal_service, service_manager_type; +type guiext-server_service, service_manager_type; +type mtk_codec_service_service, service_manager_type; +type ppl_agent_service, service_manager_type; +type vtservice_service, service_manager_type; diff --git a/sepolicy/service_contexts b/sepolicy/service_contexts new file mode 100644 index 0000000..c18939b --- /dev/null +++ b/sepolicy/service_contexts @@ -0,0 +1,24 @@ +# ============================================== +# MTK Policy Rule +# ============================================== +NvRAMAgent u:object_r:nvram_agent_service:s0 +phoneEx u:object_r:radio_service:s0 +DmAgent u:object_r:dm_agent_binder_service:s0 +hotknot_service u:object_r:system_app_service:s0 +vie_command u:object_r:system_app_service:s0 +terservice u:object_r:terservice_service:s0 +GoogleOtaBinder u:object_r:ota_agent_service:s0 +memory_dumper u:object_r:mediaserver_service:s0 +AAL u:object_r:aal_service:s0 +iphonesubinfotedongle u:object_r:radio_service:s0 +isubtedongle u:object_r:radio_service:s0 +simphonebooktedongle u:object_r:radio_service:s0 +ismstedongle u:object_r:radio_service:s0 +tedongleservice u:object_r:radio_service:s0 +GbaService u:object_r:radio_service:s0 +GuiExtService u:object_r:guiext-server_service:s0 +mtk.codecservice u:object_r:mtk_codec_service_service:s0 +PPLAgent u:object_r:ppl_agent_service:s0 +media.mmsdk u:object_r:mediaserver_service:s0 +multiwindow_service_v1 u:object_r:system_app_service:s0 +media.VTS u:object_r:vtservice_service:s0 diff --git a/sepolicy/servicemanager.te b/sepolicy/servicemanager.te new file mode 100644 index 0000000..4b5a0be --- /dev/null +++ b/sepolicy/servicemanager.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============ + diff --git a/sepolicy/shared_relro.te b/sepolicy/shared_relro.te new file mode 100644 index 0000000..79b118a --- /dev/null +++ b/sepolicy/shared_relro.te @@ -0,0 +1,3 @@ +# ============================================== +# MTK Policy Rule +# ============ diff --git a/sepolicy/shell.te b/sepolicy/shell.te new file mode 100644 index 0000000..1aa1ed9 --- /dev/null +++ b/sepolicy/shell.te @@ -0,0 +1,110 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK14.XX +# Operation : Migration +# Purpose : for exec labels defined by mtk +allow shell mtk_6620_launcher_exec:file rx_file_perms; +allow shell GoogleOtaBinder_exec:file rx_file_perms; +allow shell MtkCodecService_exec:file rx_file_perms; +allow shell aee_core_forwarder_exec:file rx_file_perms; +allow shell akmd8963_exec:file rx_file_perms; +allow shell akmd8975_exec:file rx_file_perms; +allow shell ami304d_exec:file rx_file_perms; +allow shell zygote_exec:file rx_file_perms; +allow shell atci_service_exec:file rx_file_perms; +allow shell atcid_exec:file rx_file_perms; +allow shell audiocmdservice_atci_exec:file rx_file_perms; +allow shell autokd_exec:file rx_file_perms; +allow shell batterywarning_exec:file rx_file_perms; +allow shell bmm050d_exec:file rx_file_perms; +allow shell boot_logo_updater_exec:file rx_file_perms; +allow shell bootanim_exec:file rx_file_perms; +allow shell ccci_fsd_exec:file rx_file_perms; +allow shell ccci_mdinit_exec:file rx_file_perms; +allow shell clatd_exec:file rx_file_perms; +allow shell debuggerd_exec:file rx_file_perms; +allow shell dex2oat_exec:file rx_file_perms; +allow shell dhcp6c_exec:file rx_file_perms; +allow shell dhcp_exec:file rx_file_perms; +allow shell dmlog_exec:file rx_file_perms; +allow shell dnsmasq_exec:file rx_file_perms; +allow shell drmserver_exec:file rx_file_perms; +allow shell dualmdlogger_exec:file rx_file_perms; +allow shell dumpstate_exec:file rx_file_perms; +allow shell em_svr_exec:file rx_file_perms; +allow shell emdlogger_exec:file rx_file_perms; +allow shell factory_exec:file rx_file_perms; +allow shell geomagneticd_exec:file rx_file_perms; +allow shell gsm0710muxd_exec:file rx_file_perms; +allow shell gsm0710muxdmd2_exec:file rx_file_perms; +allow shell hostapd_exec:file rx_file_perms; +allow shell installd_exec:file rx_file_perms; +allow shell keystore_exec:file rx_file_perms; +allow shell lmkd_exec:file rx_file_perms; +allow shell logd_exec:file rx_file_perms; +allow shell matv_exec:file rx_file_perms; +allow shell mc6420d_exec:file rx_file_perms; +allow shell mdlogger_exec:file rx_file_perms; +allow shell mdnsd_exec:file rx_file_perms; +allow shell mediaserver_exec:file rx_file_perms; +allow shell memsicd_exec:file rx_file_perms; +allow shell memsicd3416x_exec:file rx_file_perms; +allow shell mobile_log_d_exec:file rx_file_perms; +allow shell msensord_exec:file rx_file_perms; +allow shell mtk_agpsd_exec:file rx_file_perms; +allow shell mtkbt_exec:file rx_file_perms; +allow shell mtkrild_exec:file rx_file_perms; +allow shell mtkrildmd2_exec:file rx_file_perms; +allow shell mtp_exec:file rx_file_perms; +allow shell muxreport_exec:file rx_file_perms; +allow shell netdiag_exec:file rx_file_perms; +allow shell nvram_agent_binder_exec:file rx_file_perms; +allow shell nvram_daemon_exec:file rx_file_perms; +allow shell orientationd_exec:file rx_file_perms; +allow shell dex2oat_exec:file rx_file_perms; +allow shell ppl_agent_exec:file rx_file_perms; +allow shell ppp_exec:file rx_file_perms; +allow shell pq_exec:file rx_file_perms; +allow shell racoon_exec:file rx_file_perms; +allow shell runas_exec:file rx_file_perms; +allow shell s62xd_exec:file rx_file_perms; +allow shell sdcardd_exec:file rx_file_perms; +allow shell shell_exec:file rx_file_perms; +allow shell sn_exec:file rx_file_perms; +allow shell thermal_exec:file rx_file_perms; +allow shell thermal_manager_exec:file rx_file_perms; +allow shell thermald_exec:file rx_file_perms; +allow shell tiny_mkswap_exec:file rx_file_perms; +allow shell tiny_swapon_exec:file rx_file_perms; +allow shell wifi2agps_exec:file rx_file_perms; +allow shell wmt_loader_exec:file rx_file_perms; +allow shell wpa_exec:file rx_file_perms; +allow shell xlog_exec:file rx_file_perms; + +# Date : WK14.47 +# Operation : Migration +# Purpose : for accessing /storage/emulated/legacy +# It's mounted as tmpfs file. +# CTS: testSyncFiles_extStorageVariable & testSyncFiles_normal +allow shell tmpfs:lnk_file read; +allow shell tmpfs:lnk_file getattr; +allow shell block_device:dir search; + +# Date : WK14.47 +# Operation : Migration +# Purpose : for debugging in user debug load. +# su does't exist on user load. +userdebug_or_eng(` +allow shell su_exec:file rx_file_perms; +') + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow shell qemu_pipe_device:chr_file rw_file_perms; + +# GAT ls /data/aee_exp/db.xxxx +allow shell aee_exp_data_file:dir r_dir_perms; +allow shell aee_exp_data_file:file r_file_perms; diff --git a/sepolicy/sn.te b/sepolicy/sn.te new file mode 100644 index 0000000..474ba72 --- /dev/null +++ b/sepolicy/sn.te @@ -0,0 +1,33 @@ +# ============================================== +# Policy File of /system/binsn Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type sn_exec , exec_type, file_type; +type sn ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(sn) + +# Date : WK14.31 +# Operation : Migration +# Purpose : for L early bring up +allow sn sdcard_internal:dir search; +allow sn fuse:file { read getattr open }; +allow sn sysfs:file write; +allow sn tmpfs:lnk_file read; +allow sn self:capability { dac_read_search dac_override }; diff --git a/sepolicy/statusd.te b/sepolicy/statusd.te new file mode 100644 index 0000000..647512e --- /dev/null +++ b/sepolicy/statusd.te @@ -0,0 +1,49 @@ +# ============================================== +# Policy File of /system/bin/statusd Executable File + +type statusd_exec, exec_type, file_type; +type statusd, domain; + +#permissive statusd; + +init_daemon_domain(statusd) + +allow statusd block_device:dir search; +allow statusd ctl_pppd_via_prop:property_service set; +allow statusd flashlessd_exec:file { read execute open execute_no_trans }; +allow statusd init:unix_stream_socket connectto; +allow statusd mtk_md_prop:property_service set; +allow statusd net_cdma_mdmstat:property_service set; +allow statusd net_radio_prop:property_service set; +allow statusd nvram_data_file:dir { search add_name write remove_name read open}; +allow statusd nvram_data_file:file { create write open read getattr setattr}; +allow statusd nvram_data_file:lnk_file { read}; +allow statusd nvdata_file:dir { search add_name write remove_name read open}; +allow statusd nvdata_file:file { create write open read getattr setattr}; +allow statusd platformblk_device:blk_file { read write open }; +allow statusd platformblk_device:dir search; +allow statusd property_socket:sock_file write; +allow statusd radio_prop:property_service set; +allow statusd ril_cdma_report_prop:property_service set; +allow statusd self:capability net_admin; +allow statusd self:udp_socket { create ioctl }; +allow statusd statusd_socket:sock_file { write setattr }; +allow statusd sysfs_wake_lock:file { read write open }; +allow statusd system_data_file:dir { write add_name }; +allow statusd system_data_file:sock_file { write create setattr }; +allow statusd system_file:file execute_no_trans; +allow statusd ttyMT_device:chr_file { read write ioctl open }; +allow statusd ttySDIO_device:chr_file { read write open setattr ioctl}; +allow statusd viarild_exec:file { read execute open execute_no_trans }; +allow statusd vmodem_device:chr_file { read write open setattr ioctl}; + +# property service +allow statusd system_prop:property_service set; +allow statusd system_radio_prop:property_service set; +allow statusd persist_ril_prop:property_service set; +allow statusd ril_mux_report_case_prop:property_service set; +auditallow statusd net_radio_prop:property_service set; +auditallow statusd system_radio_prop:property_service set; + +#Search permission for findPidByName +allow statusd domain:dir search; diff --git a/sepolicy/surfaceflinger.te b/sepolicy/surfaceflinger.te new file mode 100644 index 0000000..1aa9170 --- /dev/null +++ b/sepolicy/surfaceflinger.te @@ -0,0 +1,71 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# for debug purpose +allow surfaceflinger self:capability { net_admin sys_nice }; +allow surfaceflinger self:netlink_socket { read bind create }; +allow surfaceflinger debug_prop:property_service set; +allow surfaceflinger guiext-server:binder { transfer call }; +allow surfaceflinger system_data_file:dir { write add_name create}; +allow surfaceflinger system_data_file:file { open }; +allow surfaceflinger proc:file write; +allow surfaceflinger shell_exec:file { read execute open execute_no_trans }; +allow surfaceflinger anr_data_file:dir { write search create add_name }; +allow surfaceflinger anr_data_file:file { create write}; +allow surfaceflinger aee_exp_data_file:file write; +allow surfaceflinger custom_file:dir search; +binder_call(surfaceflinger, debuggerd) +allow surfaceflinger aee_dumpsys_data_file:file write; +allow surfaceflinger RT_Monitor_device:chr_file { read ioctl open }; + +# for using toolbox +allow surfaceflinger system_file:file x_file_perms; + +# for sf_dump +userdebug_or_eng(` +allow surfaceflinger system_data_file:dir {relabelfrom read}; +allow surfaceflinger sf_bqdump_data_file:{dir file} {relabelto open create read write getattr }; +allow surfaceflinger sf_bqdump_data_file:dir {search add_name}; +') + +# for driver access +allow surfaceflinger sw_sync_device:chr_file { read write open ioctl }; +allow surfaceflinger MTK_SMI_device:chr_file { read write open ioctl }; + +# for bootanimation +allow surfaceflinger bootanim:dir search; +allow surfaceflinger bootanim:file { read getattr open }; +allow surfaceflinger self:capability dac_override; + +# for ipo +allow surfaceflinger ipod:dir search; +binder_call(surfaceflinger, ipod) + +# for MTK Emulator HW GPU +allow surfaceflinger qemu_pipe_device:chr_file rw_file_perms; + +# for SVP secure memory allocation +allow surfaceflinger proc_secmem:file { read write open ioctl }; + +# for watchdog +allow surfaceflinger anr_data_file:dir { relabelfrom read remove_name getattr }; +allow surfaceflinger anr_data_file:file { rename getattr unlink open }; +allow surfaceflinger sf_rtt_file:dir { create search write add_name remove_name}; +allow surfaceflinger sf_rtt_file:file { open read write create rename append getattr unlink}; +allow surfaceflinger sf_rtt_file:dir {relabelto getattr}; + +# for system shrinks memory pages when low memory +allow surfaceflinger platform_app_tmpfs:file write; +allow surfaceflinger isolated_app_tmpfs:file write; +allow surfaceflinger untrusted_app_tmpfs:file write; + +#for BufferQueue check process name of em_svr +allow surfaceflinger em_svr:dir search; +allow surfaceflinger em_svr:file { read getattr open }; + +# need to check what is this allowance for +allow surfaceflinger mobicore:unix_stream_socket connectto; +allow surfaceflinger mobicore_data_file:file { read getattr open }; +allow surfaceflinger mobicore_user_device:chr_file { read write ioctl open }; +allow surfaceflinger mobicore_data_file:dir search; diff --git a/sepolicy/system_app.te b/sepolicy/system_app.te new file mode 100644 index 0000000..abdf5ca --- /dev/null +++ b/sepolicy/system_app.te @@ -0,0 +1,159 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive system_app; + + +# Date : 2014/07/31 +# Stage: BaseUT +# Purpose :[CdsInfo][CdsInfo uses net shell commands to get network information and write WI-FI MAC address by NVRAM] +# Package Name: com.mediatek.connectivity +allow system_app nvram_agent_binder:binder call; + +# Date: 2014/08/01 +# Operation: BaseUT +# Purpose: [Settings][Settings used list views need velocity tracker access touch dev] +# Package: com.android.settings +allow system_app touch_device:chr_file { read ioctl open }; + +# Date: 2014/08/04 +# Stage: BaseUT +# Purpose: [MTKThermalManager][View thermal zones and coolers, and change thermal policies] +# Package Name: com.mediatek.mtkthermalmanager +allow system_app apk_private_data_file:dir getattr; +allow system_app asec_image_file:dir getattr; +allow system_app dontpanic_data_file:dir getattr; +allow system_app drm_data_file:dir getattr; +allow system_app install_data_file:file getattr; +allow system_app lost_found_data_file:dir getattr; +allow system_app media_data_file:dir getattr; +allow system_app property_data_file:dir getattr; +allow system_app shell_data_file:dir search; +allow system_app thermal_manager_exec:file { read execute open execute_no_trans }; +allow system_app proc_thermal:dir search; +allow system_app proc_thermal:file { read getattr open write }; +allow system_app proc_mtkcooler:dir search; +allow system_app proc_mtkcooler:file { read getattr open write }; +allow system_app proc_mtktz:dir search; +allow system_app proc_mtktz:file { read getattr open write }; +allow system_app proc_slogger:file { read getattr open write }; + +# Date: 2014/08/21 +# Stage: BaseUT +# Purpose: [AtciService][Atci Service will use atci_serv_fw_socket to connect to atci_service which in native layer] +# Package Name: com.mediatek.atci.service +allow system_app atci_serv_fw_socket:sock_file write; +allow system_app atci_service:unix_stream_socket connectto; + +# Date: 2014/08/29 +# Stage: BaseUT +# Purpose: [BatteryWarning][View update graphics] +# Package Name: com.mediatek.batterywarning +allow system_app guiext-server:binder { transfer call }; + +# Date: 2014/09/02 +# Operation: BaseUT +# Purpose: [HotKnot][HotKnot service will use hoknot device node] +# Package: com.mediatek.hotknot.service +allow system_app hotknot_device:chr_file { read write ioctl open }; + +# Date: 2014/09/02 +# Operation: BaseUT +# Purpose: [HotKnot][HotKnot service will use devmap_device device node] +# Package: com.mediatek.hotknot.service +allow system_app devmap_device:chr_file { read ioctl open }; + +# Date: 2014/09/02 +# Operation: BaseUT +# Purpose: [HotKnot][HotKnot service will use mtkfb device node] +# Package: com.mediatek.hotknot.service +allow system_app graphics_device:chr_file { read write ioctl open }; +allow system_app graphics_device:dir search; + +# Data : 2014/09/09 +# Operation : Migration +# Purpose : [Privacy protection lock][com.mediatek.ppl need to bind ppl_agent service to read/write nvram file] +# Package name : com.mediatek.ppl + +allow system_app ppl_agent:binder call; + +# Date: 2014/10/7 +# Operation: SQC +# Purpose: [sysoper][sysoper will create folder /cache/recovery] +# Package: com.mediatek.systemupdate.sysoper +allow system_app cache_file:dir { write create add_name }; +allow system_app cache_file:file { write create open }; + +# Date : 2014/10/08 +# Operation : BaseUT +# Purpose : [op01 agps setting][mtk_agpsd establishes the local socket as agpsd for all A-GPS +# application to do something with mtk_agpsd in system app] +# Package: com.mediatek.op01.plugin +unix_socket_connect(system_app, agpsd, mtk_agpsd); + +# Date : 2014/10/28 +# Operation: SQC +# Purpose : ALPS01761930 +# Package: com.android.settings +allow system_app asec_apk_file:file r_file_perms; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow system_app qemu_pipe_device:chr_file rw_file_perms; + +# Date : WK14.46 +# Operation : Migration +# Package: org.simalliance.openmobileapi.service +# Purpose : ALPS01820916, for SmartcardService +allow system_app system_app_data_file:file execute; + +# Date : 2014/11/17 +# Operation: SQC +# Purpose : [Settings][Battery module will call batterystats API, and it will read /sys/kernel/debug/wakeup_sources] +# Package: com.android.settings +allow system_app debugfs:file r_file_perms; + +# Date : 2014/11/18 +# Operation : SQC +# Purpose : for oma dm fota recovery update +allow system_app ctl_rbfota_prop:property_service set; + +# Date : 2014/11/19 +# Operation: SQC +# Purpose: [Settings][RenderThread][operate device file failed] +# Package: com.android.settings +allow system_app proc_secmem:file rw_file_perms; + +# Date : 2014/11/20 +# Operation: SQC +# Purpose: [Settings][Developer options module will communicate with all Services through binder call] +# Package: com.android.settings +binder_call(system_app, mtkbt) +binder_call(system_app, MtkCodecService) + +# Date : 2014/11/26 +# Operation: SQC +# Purpose: [Settings][Browser][warning kernel API'selinux enforce violation:sdcardd' when do stress test with ' AT_ST_Browser_Test.rar'] +# Package: com.android.settings +allow system_app platform_app_tmpfs:file write; + +# Date : 2015/01/13 +# Operation: SQC +# Purpose: access ashmem of isolated_app +# Package: com.fw.upgrade.sysoper +dontaudit system_app isolated_app_tmpfs:file write; + +# Date : 2015/01/14 +# Operation: SQC +# Purpose: access ashmem of untrusted_app +# Package: android.ui +dontaudit system_app untrusted_app_tmpfs:file write; + +# Date : 2015/01/27 +# Operation: SQC +# Purpose: It's not normal behavior, that system_app want to access radio_file_data +# Package: android.ui +dontaudit system_app radio_data_file:dir search; + diff --git a/sepolicy/system_server.te b/sepolicy/system_server.te new file mode 100644 index 0000000..3189f19 --- /dev/null +++ b/sepolicy/system_server.te @@ -0,0 +1,225 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK15.02 +# Operation : 120Hz Feature SQC +# Purpose : for 120Hz Smart Switch +allow system_server mtk_rrc_device:chr_file { read write ioctl open }; +# Date : WK14.31 +# Operation : Migration +# Purpose : for bring up +allow system_server hwmsensor_device:chr_file { read ioctl open }; +allow system_server m_batch_misc_device:chr_file { read ioctl open }; +allow system_server proc:file write; +allow system_server touch_device:chr_file { read ioctl open }; + +# Date : WK14.32 +# Operation : Migration +# Purpose : for wifi p2p functionality +allow system_server dhcp_data_file:dir { read write remove_name search getattr }; +allow system_server dhcp_data_file:file { read open unlink getattr }; + +# Date : WK14.33 +# Operation : Migration +# Purpose : for wifi functionality +allow system_server wpa_wlan0_socket:sock_file write; +allow system_server hostapd:unix_dgram_socket sendto; +allow hostapd system_server:unix_dgram_socket sendto; + +# Date : WK14.34 +# Operation : Migration +# Purpose : for WFD functionality +allow system_server media_wfd_prop:property_service set; + +# Date : WK14.34 +# Operation : Migration +# Purpose : for idling on homescreen +allow system_server dontpanic_data_file:dir search; +allow system_server mnld:unix_dgram_socket sendto; + +# Date : WK14.34 +# Operation : Migration +# Purpose : for debug +allow system_server debuggerd:fd use; +allow system_server mnld_data_file:sock_file create_file_perms; +allow system_server mnld_data_file:sock_file rw_file_perms; +allow system_server mnld_data_file:dir create_file_perms; +allow system_server mnld_data_file:dir rw_dir_perms; + +# Date : WK14.37 +# Operation : Migration +# Purpose : for idling on homescreen +allow system_server guiext-server:binder { transfer call }; +allow system_server touch_device:chr_file write; + +# Date : WK14.37 +# Operation : Migration +# Purpose : for relabeling files in /data/anr/ created at bootup +allow system_server anr_data_file:file relabelto; + +# Date : WK14.38 +# Operation : Migration +# Purpose : for debug +allow system_server debuggerd:binder call; +allow system_server resmon:fd use; +allow system_server resmon:fifo_file write; + +# Date : WK14.39 +# Operation : Migration +# Purpose : for operate HDMI device +allow system_server graphics_device:chr_file { read ioctl open }; + +# Date : WK14.40 +# Operation : Migration +# Purpose : for operate ANT device driver +allow system_server stpant_device:chr_file { read open write ioctl}; + +# Date: WK14.40 +# Operation : Migration +# Purpose : for ACTION_PREBOOT_IPO intent in ipo boot +binder_call(system_server, ipod) + +# Date: wk14.40 +# Operation : SQC +# Purpose : [ALPS01756200] wwop boot up fail +allow system_server custom_file:dir { read search open getattr}; +allow system_server custom_file:file { read open getattr}; + +# Date: WK14.41 +# Operation : Migration +# Purpose : boost surfaceflinger to RT +allow system_server surfaceflinger:process setsched; + +# Date: WK14.41 +# Operation : Migration +# Purpose : [ALPS01760531] for bring up after auto-merge +allow system_server zygote:binder impersonate; + +# Date: WK14.41 +# Operation : Migration +# Purpose : for system_server operate /dev/RT_Monitor when enable hang detect +allow system_server RT_Monitor_device:chr_file { read ioctl open }; + +# Date: WK14.42 +# Operation : Migration +# Purpose : for system_server to start bootanim +allow system_server ctl_bootanim_prop:property_service set; + + +# Date : WK14.42 +# Operation : SQC +# Purpose : ALPS01763317 +# After connected to DHCPv6 enabled 6to4 IPv6 AP, +#the ipv6 related values of getprop command are wrong +#============= system_server ============== +allow system_server proc_net:file write; +allow system_server wide_dhcpv6_data_file:dir search; +allow system_server wide_dhcpv6_data_file:file { read getattr open }; + +# Date: WK14.41 +# Operation : Migration +# Purpose : allow system_server to start ipod +allow system_server ctl_ipod_prop:property_service set; + +# Date: WK14.43 +# Operation : Migration +# Purpose : access to atcid from system server for GPS AT Command. +allow system_server atci_service:unix_dgram_socket sendto; +allow system_server atci_service:dir write; +allow system_server atci_service:dir add_name; + +# Date: WK14.43 +# Operation : Migration +# Purpose : for bring up +allow system_server anr_data_file:dir relabelfrom; +allow system_server sf_rtt_file:dir relabelto; + +# Date: WK14.43 +# Operation : Migration +# Purpose : for dumpsys +allow system_server aee_dumpsys_data_file:file write; +allow system_server aee_exp_data_file:file write; + +# Date: WK14.44 +# Operation : Migration +# Purpose : for debug +allow system_server sf_rtt_file:dir r_dir_perms; + +# Date: WK14.44 +# Operation : Migration +# Purpose : for mtk gps epos library useage +allow system_server devmap_device:chr_file r_file_perms; + +allow system_server irtx_device:chr_file { read write ioctl open }; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow system_server qemu_pipe_device:chr_file rw_file_perms; + +# Date: WK14.46 +# Operation : Migration +# Purpose : for sensorhubservice +allow system_server shf_device:chr_file rw_file_perms; + +# Date: W14.46 +# Operation : Migration +# Purpose : for GpsLocationProvider.java to check ESUPL status +allow system_server agpsd_data_file:dir search; + +# Date: WK14.46 +# Operation : Migration +# Purpose : for saveLocale to set SystemProperties +allow system_server save_locale_prop:property_service set; + +# Date: WK14.47 +# Operation : Sanity +# Purpose : for /system/app/mcRegistry and /proc/secmem (TEE enable) +allow system_server mobicore_data_file:dir r_dir_perms; +allow system_server proc_secmem:file { rw_file_perms }; + +# Date: WK14.47 +# Operation : Sanity +# Purpose : for avoid SELinux warning after dex2oat execv failed +allow system_server dex2oat_exec:file rx_file_perms; + +# Date: WK14.47 +# Operation : CTS +# Purpose : for executing recovery.dex +allow system_server system_data_file:file execute; + +# Date: WK14.47 +# Operation : MTBF +# Purpose : for debug +allow system_server sf_rtt_file:file r_file_perms; + +# Date: WK14.47 +# Operation : MTBF +# Purpose : for native process backtrace dump +allow system_server exec_type:file r_file_perms; + +# Date: WK14.47 +# Operation : SQC +# Purpose : for debug +allow system_server aee_core_data_file:dir r_dir_perms; + +# Date: WK14.48 +# Operation : SQC +# Purpose : for accessing exm0 tmpfs device +allow system_server exm0_device:chr_file { read write open }; + +# Date: WK14.48 +# Operation : SQC +# Purpose : for querying zygote socket +allow system_server zygote:unix_stream_socket { getopt getattr }; + +# Date: WK14.52 +# Operation : Feature developing +# Purpose : Communicate with native daemon (epdg_wod) +unix_socket_connect(system_server, wod_action, epdg_wod) +unix_socket_connect(system_server, wod_sim, epdg_wod) + +# Date: WK15.05 +# Purpose : for kill-switch should only grant to access frp partition, to be fix +allow system_server platformblk_device:dir search;
\ No newline at end of file diff --git a/sepolicy/te_macros b/sepolicy/te_macros new file mode 100644 index 0000000..e815c29 --- /dev/null +++ b/sepolicy/te_macros @@ -0,0 +1,13 @@ +##################################### +# create_pty(domain) +# Allow domain to create and use a pty, isolated from any other domain ptys. +define(`create_pty', ` +# Each domain gets a unique devpts type. +type $1_devpts, fs_type; +# Label the pty with the unique type when created. +type_transition $1 devpts:chr_file $1_devpts; +# Allow use of the pty after creation. +allow $1 $1_devpts:chr_file { open getattr read write ioctl }; +# Note: devpts:dir search and ptmx_device:chr_file rw_file_perms +# allowed to everyone via domain.te. +') diff --git a/sepolicy/tee.te b/sepolicy/tee.te new file mode 100644 index 0000000..4b5a0be --- /dev/null +++ b/sepolicy/tee.te @@ -0,0 +1,4 @@ +# ============================================== +# MTK Policy Rule +# ============ + diff --git a/sepolicy/terservice.te b/sepolicy/terservice.te new file mode 100644 index 0000000..4c93863 --- /dev/null +++ b/sepolicy/terservice.te @@ -0,0 +1,42 @@ +# ============================================== +# Policy File of /system/binterservice Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type terservice_exec , exec_type, file_type; +type terservice ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(terservice) + +# Date : 2014/09/18 (WK14.38) +# Operation : Migration +# Purpose : allow register terservice service in servicemanager. +allow terservice terservice_service:service_manager add; + +# property service +unix_socket_connect(terservice, property, init) +allow terservice terservice_prop:property_service set; + +# ccci ioctl +allow terservice ccci_device:chr_file { read write ioctl open }; + +# ipc call +binder_use(terservice) +binder_service(terservice) + + diff --git a/sepolicy/thermal.te b/sepolicy/thermal.te new file mode 100644 index 0000000..f35bfcc --- /dev/null +++ b/sepolicy/thermal.te @@ -0,0 +1,33 @@ +# ============================================== +# Policy File of /system/binthermal Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type thermal_exec , exec_type, file_type; +type thermal ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(thermal) + +allow thermal mtkrild:unix_stream_socket connectto; +allow thermal proc_thermal:dir search; +allow thermal proc_thermal:file { read write open }; +allow thermal rild_oem_socket:sock_file write; +allow thermal netd_socket:sock_file write; +allow thermal netd:unix_stream_socket connectto; + + diff --git a/sepolicy/thermal_manager.te b/sepolicy/thermal_manager.te new file mode 100644 index 0000000..08b2468 --- /dev/null +++ b/sepolicy/thermal_manager.te @@ -0,0 +1,38 @@ +# ============================================== +# Policy File of /system/binthermal_manager Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type thermal_manager_exec , exec_type, file_type; +type thermal_manager ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(thermal_manager) + +allow thermal_manager proc_mtkcooler:dir search; +allow thermal_manager proc_mtktz:dir search; +allow thermal_manager proc_thermal:dir search; +allow thermal_manager proc_mtkcooler:file { read getattr open write }; +allow thermal_manager proc_mtktz:file { read getattr open write }; +allow thermal_manager proc_thermal:file { read getattr open write }; +allow thermal_manager system_data_file:dir write; +allow thermal_manager system_data_file:dir add_name; +allow thermal_manager self:capability dac_override; +allow thermal_manager self:capability chown; +allow thermal_manager self:capability fowner; +allow thermal_manager self:capability fsetid; + diff --git a/sepolicy/thermald.te b/sepolicy/thermald.te new file mode 100644 index 0000000..6d7ec00 --- /dev/null +++ b/sepolicy/thermald.te @@ -0,0 +1,35 @@ +# ============================================== +# Policy File of /system/binthermald Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type thermald_exec , exec_type, file_type; +type thermald ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(thermald) + +# Date : WK14.39 +# Operation : SQC +# Purpose : for thermal management to shutdown the phone +binder_use(thermald) +allow thermald proc_thermal:dir search; +allow thermald proc_thermal:file { read getattr open write }; +allow thermald system_server:binder call; + + + diff --git a/sepolicy/tiny_mkswap.te b/sepolicy/tiny_mkswap.te new file mode 100644 index 0000000..103fa6d --- /dev/null +++ b/sepolicy/tiny_mkswap.te @@ -0,0 +1,29 @@ +# ============================================== +# Policy File of /system/bin/tiny_mkswap Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type tiny_mkswap_exec , exec_type, file_type; +type tiny_mkswap ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date : WK14.34 +# Operation : Migration +# Purpose : Add new swap areas +init_daemon_domain(tiny_mkswap) +allow tiny_mkswap zram0_device:blk_file { getattr read write open ioctl }; +allow tiny_mkswap enableswap:fd use; diff --git a/sepolicy/tiny_swapon.te b/sepolicy/tiny_swapon.te new file mode 100644 index 0000000..61d8901 --- /dev/null +++ b/sepolicy/tiny_swapon.te @@ -0,0 +1,29 @@ +# ============================================== +# Policy File of /system/bin/tiny_swapon Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type tiny_swapon_exec , exec_type, file_type; +type tiny_swapon ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date : WK14.34 +# Operation : Migration +# Purpose : Add new swap areas +init_daemon_domain(tiny_swapon) +allow tiny_swapon zram0_device:blk_file { getattr read write open ioctl }; +allow tiny_swapon enableswap:fd use; diff --git a/sepolicy/tunman.te b/sepolicy/tunman.te new file mode 100644 index 0000000..6e86413 --- /dev/null +++ b/sepolicy/tunman.te @@ -0,0 +1,59 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# Date : WK14.48 +# Operation : OperaMaxSystem +# Purpose : for MTK_OPERAMAX_SUPPORT + +type tunman, domain; +type tunman_exec, exec_type, file_type; + +type tunman_socket, file_type, mlstrustedobject; + +type tunman_prop, property_type; + +init_daemon_domain(tunman) +net_domain(tunman) + +# Allows connections to /dev/socket/tunman +unix_socket_connect(netdomain, tunman, tunman) + +# Allows us to set 'tunman.protocol' property +unix_socket_connect(tunman, property, init) +allow tunman tunman_prop:property_service set; + +# Allows us to talk to netd +unix_socket_connect(tunman, netd, netd) + +# Multiple instance detection (fs lock) +allow tunman shell_data_file:dir { search write add_name}; +allow tunman shell_data_file:file { create open read write lock }; + +#allow tunman system_data_file:dir { search write add_name}; +#allow tunman system_data_file:file { create open read write lock}; +allow tunman system_data_file:file { open read }; + +# TUN management +allow tunman self:capability { net_admin net_raw dac_override }; +allow tunman tun_device:chr_file rw_file_perms; +allow tunman self:tun_socket create_socket_perms; + +# Allows Max to use the fd received from Tunman +allow appdomain tunman:fd use; + +# Needed for protect() implementation +allow tunman appdomain:fd use; +allow tunman appdomain:{ tcp_socket udp_socket } { read write }; + +# Needed for socket re-tagging +allow tunman qtaguid_proc:file { open write }; + +# +#allow tunman socket_device:dir { search write add_name remove_name}; +#allow tunman socket_device:sock_file { create open read write lock unlink}; +#allow untrusted_app socket_device:sock_file { read write }; + +allow tunman tunman_socket:dir { search write add_name remove_name}; +allow tunman tunman_socket:sock_file { create open read write lock unlink}; +allow untrusted_app tunman_socket:sock_file { read write }; diff --git a/sepolicy/ueventd.te b/sepolicy/ueventd.te new file mode 100644 index 0000000..2a54b7b --- /dev/null +++ b/sepolicy/ueventd.te @@ -0,0 +1,9 @@ +# ============================================== +# MTK Policy Rule +# ============ + +# for early-migration, set as permissive +# permissive ueventd; + +# add for sysfs:leds; pls check it on L official policy +allow ueventd sysfs:file setattr; diff --git a/sepolicy/uncrypt.te b/sepolicy/uncrypt.te new file mode 100644 index 0000000..fcefb9d --- /dev/null +++ b/sepolicy/uncrypt.te @@ -0,0 +1,8 @@ +# ============================================== +# MTK Policy Rule +# ============ +allow uncrypt misc_device:chr_file *; +allow uncrypt platformblk_device:dir *; +allow uncrypt platformblk_device:blk_file *; +allow uncrypt system_data_file:file { open read }; + diff --git a/sepolicy/untrusted_app.te b/sepolicy/untrusted_app.te new file mode 100644 index 0000000..e6fcdba --- /dev/null +++ b/sepolicy/untrusted_app.te @@ -0,0 +1,46 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# permissive untrusted_app; + +# Date : 2014/09/04 +# Stage: BaseUT +# Purpose :[Launcher2][View update graphics] +# Package Name: com.android.launcher2 +allow untrusted_app guiext-server:binder { transfer call }; + +# Date : 2014/10/27 +# Operation : SQC +# Purpose : [ALPS01785313] Permission denied for dump hprof +# Package: com.android.gallery3d +allow untrusted_app anr_data_file:file rw_file_perms; + +# Date : 2014/09/09 +# Operation : Development LCA Feature "Move OAT to SD Card" +# Purpose : for LCA ROM Size Slim +allow untrusted_app dalvikcache_data_file:lnk_file read; + +# Date : WK14.46 +# Operation : Migration +# Purpose : for MTK Emulator HW GPU +allow untrusted_app qemu_pipe_device:chr_file rw_file_perms; + +# CTS issue +allow untrusted_app proc_lk_env:file getattr; +allow untrusted_app proc_sysrq:file getattr; +allow untrusted_app fuse:file execute; +allow untrusted_app protect_f_data_file:dir getattr; +allow untrusted_app protect_s_data_file:dir getattr; + +# Date : W1452 +# Operation : WVL1 Modular DRM IT +# Purpose : Allow svp client alloc sec mem +allow untrusted_app proc_secmem:file { read ioctl open }; + + +#elephantstress tools for thermal +allow untrusted_app proc_mtktz:dir search; +allow untrusted_app proc_mtktz:file read; +allow untrusted_app proc_mtktz:file open; +allow untrusted_app proc_mtktz:file getattr; diff --git a/sepolicy/usbdongled.te b/sepolicy/usbdongled.te new file mode 100644 index 0000000..33f7a3e --- /dev/null +++ b/sepolicy/usbdongled.te @@ -0,0 +1,24 @@ +# usbdongled - usb auto select daemon +type usbdongled, domain; +type usbdongled_exec, exec_type, file_type; +init_daemon_domain(usbdongled) +net_domain(usbdongled) + +allow usbdongled self:capability { net_admin net_raw dac_override kill }; + +# Allow ril-3gddaemon to create and use netlink sockets. +allow usbdongled self:netlink_socket create_socket_perms; +allow usbdongled self:netlink_kobject_uevent_socket create_socket_perms; +allow usbdongled self:netlink_nflog_socket create_socket_perms; +allow usbdongled netdomain:{tcp_socket udp_socket rawip_socket dccp_socket tun_socket} {read write getattr setattr getopt setopt}; +allow usbdongled netdomain:fd use; + +# property service +allow usbdongled radio_prop:property_service set; +allow usbdongled ctl_ril3gd_prop:property_service set; + + +allow usbdongled system_file:file x_file_perms; +allow usbdongled shell_exec:file rx_file_perms; + +unix_socket_connect(usbdongled, property, init)
\ No newline at end of file diff --git a/sepolicy/vdc.te b/sepolicy/vdc.te new file mode 100644 index 0000000..fe976d1 --- /dev/null +++ b/sepolicy/vdc.te @@ -0,0 +1,14 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + + +# Date : WK14.37 +# Operation : Migration +# Purpose : property +allow vdc vold_prop:property_service set; + +# Date : WK14.53 +# Purpose : dumpstate +allow vdc dumpstate:file read; + diff --git a/sepolicy/viarild.te b/sepolicy/viarild.te new file mode 100644 index 0000000..4c5bc3e --- /dev/null +++ b/sepolicy/viarild.te @@ -0,0 +1,78 @@ +# ============================================== +# Policy File of /system/bin/viarild Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type viarild_exec , exec_type, file_type; +type viarild ,domain; + + +# ============================================== +# MTK C2K Policy Rule +# ============================================== + +init_daemon_domain(viarild) +net_domain(viarild) +allow viarild self:netlink_route_socket nlmsg_write; +allow viarild kernel:system module_request; +unix_socket_connect(viarild, property, init) +allow viarild self:capability { setuid net_admin net_raw }; +allow viarild alarm_device:chr_file rw_file_perms; +allow viarild cgroup:dir create_dir_perms; +allow viarild radio_device:chr_file rw_file_perms; +allow viarild radio_device:blk_file r_file_perms; +allow viarild mtd_device:dir search; +allow viarild efs_file:dir create_dir_perms; +allow viarild efs_file:file create_file_perms; +allow viarild shell_exec:file rx_file_perms; +allow viarild bluetooth_efs_file:file r_file_perms; +allow viarild bluetooth_efs_file:dir r_dir_perms; +allow viarild radio_data_file:dir rw_dir_perms; +allow viarild radio_data_file:file create_file_perms; +allow viarild sdcard_type:dir r_dir_perms; +allow viarild system_data_file:dir r_dir_perms; +allow viarild system_data_file:file r_file_perms; +allow viarild system_file:file x_file_perms; +allow viarild proc:file write; + +# property service +allow statusd system_prop:property_service set; +allow viarild radio_prop:property_service set; +allow viarild net_radio_prop:property_service set; +allow viarild system_radio_prop:property_service set; +allow viarild persist_ril_prop:property_service set; +auditallow viarild net_radio_prop:property_service set; +auditallow viarild system_radio_prop:property_service set; + +# Read/Write to uart driver (for GPS) +allow viarild gps_device:chr_file rw_file_perms; + +allow viarild tty_device:chr_file rw_file_perms; + +# Allow viarild to create and use netlink sockets. +allow viarild self:netlink_socket create_socket_perms; +allow viarild self:netlink_kobject_uevent_socket create_socket_perms; + +# Access to wake locks +wakelock_use(viarild) + +allow viarild self:socket create_socket_perms; + +allow viarild Vcodec_device:chr_file { read write open }; +allow viarild devmap_device:chr_file { read ioctl open }; +allow viarild devpts:chr_file { read write open }; +allow viarild self:capability dac_override; + +allow viarild ccci_device:chr_file { read write ioctl open }; +allow viarild devpts:chr_file ioctl; +allow viarild misc_device:chr_file { read write open }; +allow viarild platformblk_device:blk_file { read write open }; +allow viarild proc_lk_env:file { read ioctl open }; +allow viarild sysfs_vcorefs_pwrctrl:file { open write }; +allow viarild ril_active_md_prop:property_service set; + +#Search permission for findPidByName +allow statusd domain:dir search; diff --git a/sepolicy/vold.te b/sepolicy/vold.te new file mode 100644 index 0000000..5a94970 --- /dev/null +++ b/sepolicy/vold.te @@ -0,0 +1,96 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + +# Date : WK14.37 +# Operation : Migration +# Purpose : Access 'OMADM_USB' nvram +allow vold nvram_data_file:file { read getattr open write create setattr}; +allow vold nvram_data_file:lnk_file read; +allow vold nvram_data_file:dir { read open write add_name create getattr setattr search}; +allow vold nvdata_file:file { read getattr open write create setattr}; +allow vold nvdata_file:dir { read ioctl open write add_name create getattr setattr search}; +allow vold nvram_device:chr_file { read write open }; +allow vold platformblk_device:blk_file { read write open }; +allow vold platformblk_device:dir search; +allow vold proc:file write; + +# Date : WK14.37 +# Operation : Migration +# Purpose : re-init ExternalSD +allow vold misc_sd_device:chr_file { read ioctl open }; + + +# Date : WK14.38 +# Operation : Migration +# Purpose : encrypt phone +allow vold kernel:system module_request; +allow vold misc_device:chr_file { write open }; +allow vold platformblk_device:blk_file { ioctl getattr }; +allow vold zram0_device:blk_file getattr; + +# Date : WK14.38 +# Operation : Migration +# Purpose : symbolic link for /data/ext_sdcard_tool +allow vold system_data_file:lnk_file { create unlink }; + +# Date : WK14.40 +# Operation : Migration +# Purpose : multi partition +allow vold sdcardd_exec:file { read open execute execute_no_trans }; +allow vold self:capability { sys_resource setgid setuid }; +allow vold install_data_file:file { read open }; +allow vold fuse_device:chr_file { read write open }; +allow vold system_data_file:file open; + +# Date : WK14.40 +# Operation : Migration +# Purpose : ptrace process +allow vold mediaserver:process ptrace; + +# Date : WK14.43 +# Purpose : grant permission to /protect_f and /protect_s for the command, fstrim dotrim +allow vold protect_f_data_file:dir { read getattr open ioctl }; +allow vold protect_s_data_file:dir { read getattr open ioctl }; +allow vold persist_data_file:dir { read getattr open ioctl }; + +# Date : WK14.44 +# Operation : Migration +allow vold proc_lk_env:file { read write open ioctl}; +allow vold media_rw_data_file:dir { read open }; + +# Date : WK14.46 +# Operation : allow sdcard create tmpfs link file +allow vold tmpfs:lnk_file create; + +# Date : WK14.46 +# Operation : copy the logs in /data(tmpfs) to real userdata partition +allow vold logtemp_data_file:dir { read open getattr search}; +allow vold logtemp_data_file:file { read getattr open }; +allow vold logmisc_data_file:dir { read open getattr search}; +allow vold logmisc_data_file:file { read getattr open }; +allow vold mdlog_data_file:dir { read open getattr search}; +allow vold mdlog_data_file:file { read getattr open }; +allow vold aee_exp_data_file:dir { read open getattr search}; +allow vold aee_exp_data_file:file { read getattr open }; +allow vold data_tmpfs_log_file:dir { setattr getattr read create write rmdir relabelto remove_name open add_name search}; +allow vold data_tmpfs_log_file:file { write setattr getattr relabelto create unlink open }; +# mount crypto block device to /data/tmp_mnt/data_tmpfs_log and restorecon +allow vold system_data_file:dir { relabelfrom relabelto setattr }; +allow vold system_data_file:file { relabelto }; + +# Date : WK14.49 +# Purpose : ptrace process +allow vold platform_app:process ptrace; +allow vold mobile_log_d:process ptrace; + +# Date : WK14.50 +# Purpose : read/write sys env +allow vold misc_device:chr_file read; + +# Date : WK15.02 +# Purpose : fsck_msdos +allow vold platform_app:fd use; + +#install APK move to SD +allow vold block_device:file create; diff --git a/sepolicy/volte_imcb.te b/sepolicy/volte_imcb.te new file mode 100644 index 0000000..07169ad --- /dev/null +++ b/sepolicy/volte_imcb.te @@ -0,0 +1,29 @@ +# ============================================== +# Policy File of /system/bin/volte_imcb Executable File + +# ============================================== +# Type Declaration +# ============================================== +type volte_imcb, domain; +type volte_imcb_exec, exec_type, file_type; +type volte_imsa1_socket, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +#permissive volte_imcb; +init_daemon_domain(volte_imcb) + +# Date : WK14.42 +# Operation : Migration +# Purpose : for VoLTE L early bring up and first call +allow volte_imcb ccci_device:chr_file { read write open }; +allow volte_imcb node:tcp_socket node_bind; +allow volte_imcb port:tcp_socket name_bind; +allow volte_imcb self:tcp_socket { bind create setopt accept listen }; +allow volte_imcb socket_device:sock_file write; +allow volte_imcb volte_ua:unix_stream_socket connectto; +allow volte_imcb fwmarkd_socket:sock_file write; +allow volte_imcb self:tcp_socket { read getattr }; +allow volte_imcb netd:unix_stream_socket connectto; +allow volte_imcb self:tcp_socket write;
\ No newline at end of file diff --git a/sepolicy/volte_stack.te b/sepolicy/volte_stack.te new file mode 100644 index 0000000..e98fa24 --- /dev/null +++ b/sepolicy/volte_stack.te @@ -0,0 +1,47 @@ +# ============================================== +# Policy File of /system/bin/volte_stack Executable File + +# ============================================== +# Type Declaration +# ============================================== +type volte_stack, domain; +type volte_stack_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +#permissive volte_stack; +init_daemon_domain(volte_stack) + +# Date : WK14.42 +# Operation : Migration +# Purpose : for VoLTE L early bring up and first call +allow volte_stack netd:unix_stream_socket connectto; +allow volte_stack shell_exec:file { read execute open execute_no_trans }; +allow volte_stack socket_device:sock_file write; +allow volte_stack self:key_socket { write read create setopt }; +allow volte_stack self:capability net_admin; +allow volte_stack self:capability { setuid setgid }; +allow volte_stack self:tcp_socket { bind create setopt listen }; +allow volte_stack self:udp_socket { write bind read setopt }; +allow volte_stack self:udp_socket create; +allow volte_stack self:tcp_socket shutdown; +allow volte_stack self:udp_socket shutdown; +allow volte_stack node:tcp_socket node_bind; +allow volte_stack node:udp_socket node_bind; +allow volte_stack port:tcp_socket name_bind; +allow volte_stack port:udp_socket name_bind; +allow volte_stack fwmarkd_socket:sock_file write; +allow volte_stack system_data_file:dir { write remove_name add_name }; +allow volte_stack system_data_file:file { ioctl open }; +allow volte_stack system_file:file execute_no_trans; + +# Date : 2015/01/07 +# Operation : Migration +# Purpose : for VoLTE L Pre-FT test, Pre-FT error show we need add tcp rule +allow volte_stack self:tcp_socket accept; +allow volte_stack self:tcp_socket read; +allow volte_stack self:tcp_socket write; +allow volte_stack self:tcp_socket getattr; +allow volte_stack self:tcp_socket connect; +allow volte_stack port:tcp_socket name_connect; diff --git a/sepolicy/volte_ua.te b/sepolicy/volte_ua.te new file mode 100644 index 0000000..dba7458 --- /dev/null +++ b/sepolicy/volte_ua.te @@ -0,0 +1,23 @@ +# ============================================== +# Policy File of /system/bin/volte_ua Executable File + +# ============================================== +# Type Declaration +# ============================================== +type volte_ua, domain; +type volte_ua_exec, exec_type, file_type; + +# ============================================== +# MTK Policy Rule +# ============================================== +#permissive volte_ua; +init_daemon_domain(volte_ua) + +# Date : WK14.42 +# Operation : Migration +# Purpose : for VoLTE L early bring up and first call +allow volte_ua socket_device:sock_file write; +allow volte_ua volte_stack:unix_stream_socket connectto; +allow volte_ua node:udp_socket node_bind; +allow volte_ua self:udp_socket { bind create }; +allow volte_ua self:udp_socket read; diff --git a/sepolicy/vtservice.te b/sepolicy/vtservice.te new file mode 100644 index 0000000..8cd2600 --- /dev/null +++ b/sepolicy/vtservice.te @@ -0,0 +1,32 @@ +# ============================================== +# Policy File of /system/binvtservice Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type vtservice_exec , exec_type, file_type; +type vtservice ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +init_daemon_domain(vtservice) +binder_use(vtservice) +binder_call(vtservice, mediaserver) +binder_service(vtservice) + +allow vtservice vtservice_service:service_manager add; +#unix_socket_connect(vtservice, volte_imsvt1, volte_imcb) +allow vtservice fuse:dir search; +allow vtservice fuse:file { read write open }; diff --git a/sepolicy/watchdogd.te b/sepolicy/watchdogd.te new file mode 100644 index 0000000..79b118a --- /dev/null +++ b/sepolicy/watchdogd.te @@ -0,0 +1,3 @@ +# ============================================== +# MTK Policy Rule +# ============ diff --git a/sepolicy/wifi2agps.te b/sepolicy/wifi2agps.te new file mode 100644 index 0000000..8a90cec --- /dev/null +++ b/sepolicy/wifi2agps.te @@ -0,0 +1,26 @@ +# ============================================== +# Policy File of /system/bin/wifi2agps Executable File + + +# ============================================== +# Type Declaration +# ============================================== +type wifi2agps_exec , exec_type, file_type; +type wifi2agps ,domain; + + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive wifi2agps; +init_daemon_domain(wifi2agps) + +# Date : WK14.34 +# Operation : Migration +# Purpose : for mtk debug mechanism +allow wifi2agps agpsd_data_file:sock_file write; +allow wifi2agps mtk_agpsd:unix_dgram_socket sendto; +allow wifi2agps self:netlink_socket {write getattr setopt read bind create}; +allow wifi2agps self:udp_socket { create ioctl }; +allow wifi2agps agpsd_data_file:dir search; diff --git a/sepolicy/wmt_loader.te b/sepolicy/wmt_loader.te new file mode 100644 index 0000000..6a2fede --- /dev/null +++ b/sepolicy/wmt_loader.te @@ -0,0 +1,32 @@ +# ============================================== +# Policy File of /system/binwmt_loader Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type wmt_loader_exec , exec_type, file_type; +type wmt_loader ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +allow wmt_loader wmt_prop:property_service set; +allow wmt_loader init:unix_stream_socket connectto; +allow wmt_loader proc:file setattr; +allow wmt_loader property_socket:sock_file write; +allow wmt_loader self:capability { chown dac_override }; +allow wmt_loader wmtdetect_device:chr_file { read write ioctl open }; +allow wmt_loader stpwmt_device:chr_file { read write ioctl open }; +allow wmt_loader devpts:chr_file { read write getattr ioctl }; +init_daemon_domain(wmt_loader) diff --git a/sepolicy/wpa.te b/sepolicy/wpa.te new file mode 100644 index 0000000..0f1d1b8 --- /dev/null +++ b/sepolicy/wpa.te @@ -0,0 +1,14 @@ +# ============================================== +# MTK Policy Rule +# ============ + +allow wpa rild_oem_socket:sock_file write; +allow wpa rild_oem_md2_socket:sock_file write; +allow wpa mtkrild:unix_stream_socket connectto; +# if low memory occured, and system try to free more memory, wpa_suppliant may meet a violation like: +# avc: denied { use } for pid=4063 comm="wpa_supplicant" +# path=2F6465762F6173686D656D2F4469736361726461626C654D656D6F72794173686D656D416C6C6F6361746F72202864656C6574656429 +# dev="tmpfs" ino=46425 scontext=u:r:wpa:s0 tcontext=u:r:platform_app:s0 tclass=fd permissive=0 +# this is a issue caused by low memory, so we should add this rule below +allow wpa platform_app:fd use; +allow wpa platform_app_tmpfs:file write;
\ No newline at end of file diff --git a/sepolicy/wpa_supplicant.te b/sepolicy/wpa_supplicant.te new file mode 100644 index 0000000..79b118a --- /dev/null +++ b/sepolicy/wpa_supplicant.te @@ -0,0 +1,3 @@ +# ============================================== +# MTK Policy Rule +# ============ diff --git a/sepolicy/xlog.te b/sepolicy/xlog.te new file mode 100644 index 0000000..fd90144 --- /dev/null +++ b/sepolicy/xlog.te @@ -0,0 +1,28 @@ +# ============================================== +# Policy File of /system/binxlog Executable File + + +# ============================================== +# Type Declaration +# ============================================== + +type xlog_exec , exec_type, file_type; +type xlog ,domain; + +# ============================================== +# Android Policy Rule +# ============================================== + +# ============================================== +# NSA Policy Rule +# ============================================== + +# ============================================== +# MTK Policy Rule +# ============================================== + +#permissive xlog; +init_daemon_domain(xlog) +#unconfined_domain(xlog) +allow xlog self:capability { fowner chown fsetid dac_override }; +allow xlog system_data_file:dir { write add_name }; diff --git a/sepolicy/zpppd_gprs.te b/sepolicy/zpppd_gprs.te new file mode 100644 index 0000000..1ca2b57 --- /dev/null +++ b/sepolicy/zpppd_gprs.te @@ -0,0 +1,24 @@ +# zpppd_gprs - pppd process for ZTE 3gdongle ppp dail +type zpppd_gprs, domain; +type zpppd_gprs_exec, exec_type, file_type; +init_daemon_domain(zpppd_gprs) +net_domain(zpppd_gprs) + +allow zpppd_gprs self:capability { setuid setgid net_admin net_raw dac_override sys_module }; + +# property service +allow zpppd_gprs radio_prop:property_service set; +allow zpppd_gprs net_radio_prop:property_service set; +allow zpppd_gprs system_radio_prop:property_service set; +allow zpppd_gprs system_prop:property_service set; +allow zpppd_gprs pppoe_ppp0_prop:property_service set; +allow zpppd_gprs ctl_zpppdgprs_prop:property_service set; + +# device and file allow +allow zpppd_gprs tty_device:chr_file rw_file_perms; +allow zpppd_gprs ppp_exec:file { read open getattr execute execute_no_trans }; +allow zpppd_gprs ppp_device:chr_file { read write open ioctl }; +allow zpppd_gprs system_file:file x_file_perms; +allow zpppd_gprs shell_exec:file rx_file_perms; + +unix_socket_connect(zpppd_gprs, property, init) diff --git a/sepolicy/zygote.te b/sepolicy/zygote.te new file mode 100644 index 0000000..2d4a7ae --- /dev/null +++ b/sepolicy/zygote.te @@ -0,0 +1,72 @@ +# ============================================== +# MTK Policy Rule +# ============================================== + + +# Date : WK14.31 +# Operation : Migration +# Purpose : for MTK boot performance profiling, for access /proc/bootprof +allow zygote devmap_device:chr_file { read ioctl open }; +allow zygote proc:file write; + +# Date : WK14.34 +# Operation : Migration +# Purpose : 6571/6572 LCA external memory access(/dev/exm0) +allow zygote exm0_device:chr_file { read write ioctl open }; + +# Date : WK14.34 +# Operation : Migration +# Purpose : for CIP project (access /custom partition) +allow zygote custom_file:dir rw_dir_perms; +allow zygote custom_file:file create_file_perms; + +# Date : WK14.34 +# Operation : Migration +# Purpose : for untrusted app to use ptrace (e.g. 360Mobile, taobao) +dontaudit zygote untrusted_app:process ptrace; + +# Date : WK14.43 +# Operation : Migration +# Purpose : for dump hprof when OOME +allow zygote anr_data_file:dir *; + +# Date : WK14.43 +# Operation : SQC2 +# Purpose : found in FST Auto Test (ALPS01774709) +allow zygote platform_app:fd use; + +# Date : WK14.44 +# Operation : SQC +# Purpose : found in WLAN test (ALPS01784932) +allow zygote platform_app_tmpfs:file write; + +# Date : WK14.46 +# Operation : SQC +# Purpose : found in sanity test (ALPS01825280) +allow zygote servicemanager:binder call; + +# Date : WK14.49 +# Operation : SQC +# Purpose : for isolated_app to use fd (ex: share image by gmail) +allow zygote isolated_app:fd use; + +# Date : WK15.02 +# Operation : SQC +# Purpose : for Chrome search (ALPS01897864) +allow zygote isolated_app_tmpfs:file write; + +# Date : WK15.02 +# Operation : SQC +# Purpose : for "theScore Sports & Scores" app to play video(ALPS01897019) +allow zygote untrusted_app:fd use; + +# Date : WK15.03 +# Operation : SQC +# Purpose : for FB webpage loading +allow zygote untrusted_app_tmpfs:file write; + +# Date : WK15.08 +# Operation : SQC +# Purpose : for TTLIA +allow zygote radio:fd use; +allow zygote radio_tmpfs:file create_file_perms;
\ No newline at end of file diff --git a/setup-makefiles.sh b/setup-makefiles.sh new file mode 100755 index 0000000..8f82413 --- /dev/null +++ b/setup-makefiles.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +VENDOR=ulefone +DEVICE=metal +OUTDIR=vendor/$VENDOR/$DEVICE +MAKEFILE=../../../$OUTDIR/$DEVICE-vendor-blobs.mk + +(cat << EOF) > $MAKEFILE +# 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. + +# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh + +PRODUCT_COPY_FILES += \\ +EOF + +LINEEND=" \\" +COUNT=`cat proprietary-files.txt | grep -v ^# | grep -v ^$ | wc -l | awk {'print $1'}` +for FILE in `cat proprietary-files.txt | grep -v ^# | grep -v ^$`; do +COUNT=`expr $COUNT - 1` + if [ $COUNT = "0" ]; then +LINEEND="" + fi +echo " $OUTDIR/proprietary/$FILE:system/$FILE$LINEEND" >> $MAKEFILE +done + +(cat << EOF) > ../../../$OUTDIR/$DEVICE-vendor.mk +# 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. + +# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh + +\$(call inherit-product, vendor/$VENDOR/$DEVICE/$DEVICE-vendor-blobs.mk) +EOF + +(cat << EOF) > ../../../$OUTDIR/BoardConfigVendor.mk +# 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. + +# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh +EOF diff --git a/system.prop b/system.prop new file mode 100644 index 0000000..1a14e0e --- /dev/null +++ b/system.prop @@ -0,0 +1,185 @@ +# +# +# system.prop for M2 Note +# + +rild.libpath=/system/lib64/mtk-ril.so +rild.libargs=-d /dev/ttyC0 + + +wifi.interface=wlan0 +ro.mediatek.wlan.wsc=1 +ro.mediatek.wlan.p2p=1 +mediatek.wlan.ctia=0 + +# +wifi.tethering.interface=ap0 +# + +ro.opengles.version=196609 + +wifi.direct.interface=p2p0 + +# USB MTP WHQL +ro.sys.usb.mtp.whql.enable=0 + +# Power off opt in IPO +sys.ipo.pwrdncap=2 + +ro.sys.usb.storage.type=mtp,mass_storage + +# USB BICR function +ro.sys.usb.bicr=yes + +# USB Charge only function +ro.sys.usb.charging.only=yes + +# audio +ro.camera.sound.forced=0 +ro.audio.silent=0 +persist.audio.dirac.speaker=true + +ro.zygote.preload.enable=0 +ro.kernel.zio=38,108,105,16 +ro.kernel.android.checkjni=0 +dalvik.vm.checkjni=false +dalvik.vm.stack-trace-file=/data/anr/traces.txt + +#ro.kernel.qemu=1 +#ro.kernel.qemu.gles=0 +#ro.boot.selinux=disable + +# Disable dirty region for Mali +debug.hwui.render_dirty_regions=true + +# temp nav bar +ro.sf.lcd_density=480 +ro.sf.hwrotation=180 + +# performance +ro.mtk_perf_simple_start_win=1 +ro.mtk_perf_response_time=1 +ro.mtk_benchmark_boost_tp=1 + +# RIL +ro.telephony.sim.count=2 +persist.radio.default.sim=0 +persist.radio.mobile.data=0,0 +persist.radio.multisim.config=dsds +ro.mtk_gemini_support=1 +persist.gemini.sim_num=2 +ro.gemini.smart_sim_switch=false +ril.specific.sm_cause=0 +bgw.current3gband=0 +ril.current.share_modem=2 +ro.mediatek.gemini_support=true +ril.external.md=0 + +persist.call_recording.enabled=true +persist.call_recording.src=1 +persist.sys.log-main.enable=0 +persist.sys.log-system.enable=0 +persist.sys.log-events.enable=0 +persist.sys.log-radio.enable=0 +keyguard.no_require_sim=true +persist.sys.keyguard_intercept=true +persist.sys.disable_blur_view=true +persist.sys.static_blur_mode=false + +ro.meizu.published.type=prd +ro.mediatek.cmcc.oompolicy=1 +ro.mediatek.chip_ver=S01 +ro.mediatek.platform=MT6735 +ro.mediatek.version.release=ALPS.L1.MP3.V2.95_MEIZU6753.65CN.L1 +mediatek.wlan.chip=CONSYS_MT6735 +mediatek.wlan.module.postfix=_consys_mt6735 +ro.mediatek.version.branch=L1.MP3.EE.WFC.DEV +ro.mediatek.project.path=device/meizu/meizu6753_65cn_l1 +ro.product.perf.config=M81-l1_base + +persist.md.perm.checked=to_upgrade +ro.mtk_cam_lomo_support=1 +ro.btstack=blueangel + +curlockscreen=1 +persist.radio.fd.counter=15 +persist.radio.fd.off.counter=5 +persist.radio.fd.r8.counter=15 +persist.radio.fd.off.r8.counter=5 +drm.service.enabled=true +fmradio.driver.enable=0 +ril.first.md=1 +ril.flightmode.poweroffMD=0 +ril.telephony.mode=0 +ril.radiooff.poweroffMD=0 +ro.mediatek.version.sdk=4 +ro.mtk_audenh_support=1 +ro.mtk_lossless_bt_audio=1 +ro.mtk_besloudness_support=1 +ro.mtk_bessurround_support=1 +ro.mtk_gemini_enhancement=1 +ro.mtk_wapi_support=1 +ro.mtk_bt_support=1 +ro.mtk_wappush_support=1 +ro.mtk_agps_app=1 +ro.mtk_wlan_support=1 +ro.mtk_gps_support=1 +ro.mtk_omacp_support=1 +ro.mtk_search_db_support=1 +ro.mtk_dialer_search_support=1 +ro.mtk_dhcpv6c_wifi=1 +ro.have_aacencode_feature=1 +ro.mtk_fd_support=1 +ro.mtk_oma_drm_support=1 +ro.mtk_cta_drm_support=1 +ro.mtk_widevine_drm_l3_support=1 +ro.mtk_eap_sim_aka=1 +ro.mtk_audio_ape_support=1 +ro.mtk_flv_playback_support=1 +ro.mtk_wmv_playback_support=1 +ro.mtk_send_rr_support=1 +ro.mtk_emmc_support=1 +ro.mtk_tetheringipv6_support=1 +ro.mtk_phone_number_geo=1 +ro.mtk_shared_sdcard=1 +ro.mtk_enable_md1=1 +ro.mtk_pq_support=2 +ro.mtk_miravision_support=1 +ro.mtk_miravision_image_dc=1 +ro.mtk_wfd_support=1 +ro.mtk_system_update_support=1 +ro.mtk_sim_hot_swap=1 +ro.mtk_thumbnail_play_support=1 +ro.mtk_bip_scws=1 +ro.mtk_cmcc_ft_precheck_support=1 +ro.mtk_world_phone=1 +ro.mtk_world_phone_policy=0 +ro.mtk_perfservice_support=1 +ro.mtk_sim_hot_swap_common_slot=1 +ro.mtk_cta_set=1 +ro.mtk_mobile_management=1 +ro.mtk_antibricking_level=2 +ro.mtk_cam_mfb_support=3 +ro.mtk_slow_motion_support=1 +ro.mtk_lte_support=1 +ro.mtk_cam_mav_support=1 +ro.sim_refresh_reset_by_modem=1 +ro.mtk_external_sim_support=1 +ro.mtk_live_photo_support=1 +ro.mtk_motion_track_support=1 +ro.mtk_bg_power_saving_support=1 +ro.mtk_bg_power_saving_ui=1 +ro.sim_me_lock_mode=0 +wfd.dummy.enable=1 + +persist.mtk.wcn.combo.chipid=-1 +service.wcn.driver.ready=no + +ro.mtk_hetcomm_support=1 + +persist.dtmf.volume=90 +persist.call.waiting.volume=70 +net.bt.name=Android + +# OTA +# cm.updater.uri= diff --git a/vendorsetup.sh b/vendorsetup.sh new file mode 100755 index 0000000..17a7286 --- /dev/null +++ b/vendorsetup.sh @@ -0,0 +1,25 @@ +# +# Copyright 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. +# + +# This file is executed by build/envsetup.sh, and can use anything +# defined in envsetup.sh. +# +# In particular, you can add lunch options with the add_lunch_combo +# function: add_lunch_combo generic-eng + +for var in eng user userdebug; do + add_lunch_combo cm_m2note-$var +done |
