├── dspcrashd ├── MODULE_LICENSE_BSD ├── Android.mk ├── NOTICE └── dspcrashd.c ├── libaudio ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── AudioPolicyManager.cpp ├── AudioPolicyManager.h └── AudioHardware.h ├── libcamera ├── MODULE_LICENSE_APACHE2 ├── Android.mk └── QualcommCameraHardware.h ├── libcopybit ├── MODULE_LICENSE_APACHE2 └── Android.mk ├── libgralloc ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── gr.h ├── gralloc_priv.h ├── allocator.h ├── allocator.cpp └── mapper.cpp ├── liblights ├── MODULE_LICENSE_APACHE2 └── Android.mk ├── librpc ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── rpc │ ├── rpc_router_ioctl.h │ ├── pmap_clnt.h │ ├── rpc.h │ ├── xdr.h │ ├── clnt.h │ └── svc.h ├── ops.c ├── debug.h ├── rpc.c └── svc_clnt_common.c ├── libaudio-qsd8k ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── AudioPolicyManager.h └── msm_audio.h ├── libopencorehw ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── android_surface_output_msm72xx.h └── android_surface_output_msm72xx.cpp ├── libaudio-qdsp5v2 ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── AudioPolicyManager.h ├── msm_audio.h ├── AudioHardware.h └── AudioHardware.cpp ├── libgralloc-qsd8k ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── tests │ └── Android.mk ├── gr.h ├── gpu.h ├── allocator.h ├── pmemalloc.h ├── allocator.cpp ├── gralloc_priv.h ├── gralloc.cpp └── pmemalloc.cpp ├── libstagefrighthw ├── MODULE_LICENSE_APACHE2 ├── Android.mk ├── stagefright_surface_output_msm72xx.cpp ├── QComHardwareRenderer.h ├── QComOMXPlugin.h ├── QComOMXPlugin.cpp └── QComHardwareRenderer.cpp ├── boot └── boot.ld ├── liboverlay └── Android.mk ├── Android.mk └── CleanSpec.mk /dspcrashd/MODULE_LICENSE_BSD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libaudio/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libcamera/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libcopybit/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libgralloc/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /liblights/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /librpc/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libaudio-qsd8k/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libopencorehw/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libaudio-qdsp5v2/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libstagefrighthw/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dspcrashd/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(BUILD_TINY_ANDROID),true) 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | LOCAL_SRC_FILES:= dspcrashd.c 6 | LOCAL_MODULE:= dspcrashd 7 | 8 | LOCAL_SHARED_LIBRARIES := libc libcutils 9 | 10 | LOCAL_MODULE_TAGS := debug 11 | 12 | include $(BUILD_EXECUTABLE) 13 | endif 14 | -------------------------------------------------------------------------------- /boot/boot.ld: -------------------------------------------------------------------------------- 1 | SECTIONS { 2 | BOOTLOADER_START = 0x00000000 ; 3 | .text BOOTLOADER_START : 4 | { 5 | *(.text) 6 | . = ALIGN(8); 7 | } 8 | .init : { 9 | . = ALIGN(8); 10 | BOOTLOADER_INIT_FIRST = . ; 11 | *(.init.func.0) 12 | BOOTLOADER_INIT_LAST = . ; 13 | } 14 | .data : { 15 | . = ALIGN(8); 16 | *(.data) 17 | . = ALIGN(8); 18 | } 19 | .bss : { 20 | BOOTLOADER_BSS = . ; 21 | . = ALIGN(8); 22 | *(.bss) *(COMMON) 23 | . = ALIGN(8); 24 | BOOTLOADER_END = . ; 25 | } 26 | BOOTLOADER_STACK = 0x000FF000 ; 27 | BOOTLOADER_HEAP = 0x00100000 ; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /libcamera/Android.mk: -------------------------------------------------------------------------------- 1 | BUILD_OLD_LIBCAMERA:= 2 | ifeq ($(BUILD_OLD_LIBCAMERA),true) 3 | 4 | # When zero we link against libqcamera; when 1, we dlopen libqcamera. 5 | DLOPEN_LIBQCAMERA:=1 6 | 7 | ifneq ($(BUILD_TINY_ANDROID),true) 8 | 9 | LOCAL_PATH:= $(call my-dir) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | LOCAL_CFLAGS:=-fno-short-enums 14 | LOCAL_CFLAGS+=-DDLOPEN_LIBQCAMERA=$(DLOPEN_LIBQCAMERA) 15 | 16 | LOCAL_SRC_FILES:= QualcommCameraHardware.cpp 17 | 18 | LOCAL_SHARED_LIBRARIES:= libutils libbinder libui liblog libcamera_client 19 | ifneq ($(DLOPEN_LIBQCAMERA),1) 20 | LOCAL_SHARED_LIBRARIES+= liboemcamera 21 | else 22 | LOCAL_SHARED_LIBRARIES+= libdl 23 | endif 24 | 25 | LOCAL_MODULE:= libcamera 26 | 27 | include $(BUILD_SHARED_LIBRARY) 28 | 29 | endif # not BUILD_TINY_ANDROID 30 | endif # not BUILD_OLD_LIBCAMERA 31 | -------------------------------------------------------------------------------- /librpc/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES:= xdr.c rpc.c svc.c clnt.c ops.c svc_clnt_common.c 6 | 7 | LOCAL_C_INCLUDES:=$(LOCAL_PATH) 8 | 9 | LOCAL_CFLAGS:= -fno-short-enums 10 | 11 | LOCAL_CFLAGS+=-DRPC_OFFSET=0 12 | #LOCAL_CFLAGS+=-DDEBUG -DVERBOSE 13 | 14 | LOCAL_COPY_HEADERS_TO:= librpc/rpc 15 | LOCAL_COPY_HEADERS:= \ 16 | rpc/clnt.h \ 17 | rpc/pmap_clnt.h \ 18 | rpc/rpc.h \ 19 | rpc/rpc_router_ioctl.h \ 20 | rpc/svc.h \ 21 | rpc/types.h \ 22 | rpc/xdr.h 23 | 24 | LOCAL_MODULE:= librpc 25 | 26 | include $(BUILD_STATIC_LIBRARY) 27 | 28 | include $(CLEAR_VARS) 29 | LOCAL_MODULE := librpc 30 | LOCAL_SHARED_LIBRARIES := liblog 31 | LOCAL_STATIC_LIBRARIES := libpower 32 | LOCAL_WHOLE_STATIC_LIBRARIES := librpc 33 | # LOCAL_PRELINK_MODULE := false 34 | include $(BUILD_SHARED_LIBRARY) 35 | -------------------------------------------------------------------------------- /liblights/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH:= $(call my-dir) 17 | # HAL module implemenation, not prelinked and stored in 18 | # hw/..so 19 | include $(CLEAR_VARS) 20 | 21 | LOCAL_SRC_FILES := lights.c 22 | 23 | LOCAL_PRELINK_MODULE := false 24 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 25 | 26 | LOCAL_SHARED_LIBRARIES := liblog 27 | 28 | LOCAL_MODULE := lights.$(TARGET_BOARD_PLATFORM) 29 | 30 | include $(BUILD_SHARED_LIBRARY) 31 | -------------------------------------------------------------------------------- /libaudio-qdsp5v2/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | ifneq ($(BUILD_TINY_ANDROID),true) 3 | 4 | LOCAL_PATH := $(call my-dir) 5 | 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES:= \ 9 | AudioPolicyManager.cpp 10 | 11 | LOCAL_SHARED_LIBRARIES := \ 12 | libcutils \ 13 | libutils \ 14 | libmedia 15 | 16 | LOCAL_STATIC_LIBRARIES := libaudiopolicybase 17 | 18 | LOCAL_MODULE:= libaudiopolicy 19 | 20 | ifeq ($(BOARD_HAVE_BLUETOOTH),true) 21 | LOCAL_CFLAGS += -DWITH_A2DP 22 | endif 23 | 24 | include $(BUILD_SHARED_LIBRARY) 25 | 26 | include $(CLEAR_VARS) 27 | 28 | LOCAL_MODULE := libaudio 29 | 30 | LOCAL_SHARED_LIBRARIES := \ 31 | libcutils \ 32 | libutils \ 33 | libmedia \ 34 | libhardware_legacy 35 | 36 | ifeq ($TARGET_OS)-$(TARGET_SIMULATOR),linux-true) 37 | LOCAL_LDLIBS += -ldl 38 | endif 39 | 40 | ifneq ($(TARGET_SIMULATOR),true) 41 | LOCAL_SHARED_LIBRARIES += libdl 42 | endif 43 | 44 | LOCAL_SRC_FILES += AudioHardware.cpp 45 | 46 | LOCAL_CFLAGS += -fno-short-enums 47 | 48 | LOCAL_STATIC_LIBRARIES += libaudiointerface 49 | ifeq ($(BOARD_HAVE_BLUETOOTH),true) 50 | LOCAL_SHARED_LIBRARIES += liba2dp 51 | endif 52 | 53 | include $(BUILD_SHARED_LIBRARY) 54 | 55 | endif # not BUILD_TINY_ANDROID 56 | 57 | -------------------------------------------------------------------------------- /libaudio/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | ifneq ($(BUILD_TINY_ANDROID),true) 3 | 4 | LOCAL_PATH := $(call my-dir) 5 | 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES:= \ 9 | AudioPolicyManager.cpp 10 | 11 | LOCAL_SHARED_LIBRARIES := \ 12 | libcutils \ 13 | libutils \ 14 | libmedia 15 | 16 | LOCAL_STATIC_LIBRARIES := libaudiopolicybase 17 | 18 | LOCAL_MODULE:= libaudiopolicy 19 | 20 | ifeq ($(BOARD_HAVE_BLUETOOTH),true) 21 | LOCAL_CFLAGS += -DWITH_A2DP 22 | endif 23 | 24 | include $(BUILD_SHARED_LIBRARY) 25 | 26 | 27 | include $(CLEAR_VARS) 28 | 29 | LOCAL_MODULE := libaudio 30 | 31 | LOCAL_SHARED_LIBRARIES := \ 32 | libcutils \ 33 | libutils \ 34 | libmedia \ 35 | libhardware_legacy 36 | 37 | ifeq ($TARGET_OS)-$(TARGET_SIMULATOR),linux-true) 38 | LOCAL_LDLIBS += -ldl 39 | endif 40 | 41 | ifneq ($(TARGET_SIMULATOR),true) 42 | LOCAL_SHARED_LIBRARIES += libdl 43 | endif 44 | 45 | LOCAL_SRC_FILES += AudioHardware.cpp 46 | 47 | LOCAL_CFLAGS += -fno-short-enums 48 | 49 | LOCAL_STATIC_LIBRARIES += libaudiointerface 50 | ifeq ($(BOARD_HAVE_BLUETOOTH),true) 51 | LOCAL_SHARED_LIBRARIES += liba2dp 52 | endif 53 | 54 | include $(BUILD_SHARED_LIBRARY) 55 | 56 | endif # not BUILD_TINY_ANDROID 57 | 58 | -------------------------------------------------------------------------------- /libgralloc/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH := $(call my-dir) 17 | 18 | # HAL module implemenation, not prelinked and stored in 19 | # hw/..so 20 | include $(CLEAR_VARS) 21 | LOCAL_PRELINK_MODULE := false 22 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 23 | LOCAL_SHARED_LIBRARIES := liblog libcutils 24 | 25 | LOCAL_SRC_FILES := \ 26 | allocator.cpp \ 27 | gralloc.cpp \ 28 | framebuffer.cpp \ 29 | mapper.cpp 30 | 31 | LOCAL_MODULE := gralloc.msm7k 32 | LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc\" 33 | include $(BUILD_SHARED_LIBRARY) 34 | -------------------------------------------------------------------------------- /libaudio-qsd8k/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | ifneq ($(BUILD_TINY_ANDROID),true) 3 | 4 | LOCAL_PATH := $(call my-dir) 5 | 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES:= \ 9 | AudioPolicyManager.cpp 10 | 11 | LOCAL_SHARED_LIBRARIES := \ 12 | libcutils \ 13 | libutils \ 14 | libmedia 15 | 16 | LOCAL_STATIC_LIBRARIES := libaudiopolicybase 17 | 18 | LOCAL_MODULE:= libaudiopolicy 19 | 20 | ifeq ($(BOARD_HAVE_BLUETOOTH),true) 21 | LOCAL_CFLAGS += -DWITH_A2DP 22 | endif 23 | 24 | include $(BUILD_SHARED_LIBRARY) 25 | 26 | 27 | include $(CLEAR_VARS) 28 | 29 | LOCAL_MODULE := libaudio 30 | 31 | LOCAL_SHARED_LIBRARIES := \ 32 | libcutils \ 33 | libutils \ 34 | libmedia \ 35 | libhardware_legacy 36 | 37 | ifeq ($TARGET_OS)-$(TARGET_SIMULATOR),linux-true) 38 | LOCAL_LDLIBS += -ldl 39 | endif 40 | 41 | ifneq ($(TARGET_SIMULATOR),true) 42 | LOCAL_SHARED_LIBRARIES += libdl 43 | endif 44 | 45 | LOCAL_SRC_FILES += AudioHardware.cpp 46 | 47 | LOCAL_CFLAGS += -fno-short-enums 48 | 49 | LOCAL_STATIC_LIBRARIES += libaudiointerface 50 | ifeq ($(BOARD_HAVE_BLUETOOTH),true) 51 | LOCAL_SHARED_LIBRARIES += liba2dp 52 | endif 53 | 54 | include $(BUILD_SHARED_LIBRARY) 55 | 56 | endif # not BUILD_TINY_ANDROID 57 | 58 | -------------------------------------------------------------------------------- /liboverlay/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # Copyright (c) 2009, Code Aurora Forum. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | # HAL module implemenation, not prelinked and stored in 20 | # hw/..so 21 | include $(CLEAR_VARS) 22 | LOCAL_PRELINK_MODULE := false 23 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 24 | LOCAL_SHARED_LIBRARIES := liblog 25 | LOCAL_SRC_FILES := overlay.cpp 26 | LOCAL_MODULE := overlay.default 27 | LOCAL_C_INCLUDES += hardware/msm7k/libgralloc-qsd8k 28 | LOCAL_CFLAGS := -DCONFIG_MSM_MDP40 29 | LOCAL_MODULE_TAGS := optional 30 | include $(BUILD_SHARED_LIBRARY) 31 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | common_msm_dirs := libcopybit liblights libopencorehw librpc libstagefrighthw 18 | msm7k_dirs := $(common_msm_dirs) boot libgralloc libaudio 19 | qsd8k_dirs := $(common_msm_dirs) libgralloc-qsd8k libaudio-qsd8k dspcrashd 20 | msm7x30_dirs := liblights libgralloc-qsd8k librpc libaudio-qdsp5v2 21 | 22 | ifeq ($(TARGET_BOARD_PLATFORM),msm7k) 23 | include $(call all-named-subdir-makefiles,$(msm7k_dirs)) 24 | else 25 | ifeq ($(TARGET_BOARD_PLATFORM),qsd8k) 26 | include $(call all-named-subdir-makefiles,$(qsd8k_dirs)) 27 | else 28 | ifeq ($(TARGET_BOARD_PLATFORM),msm7x30) 29 | include $(call all-named-subdir-makefiles,$(msm7x30_dirs)) 30 | endif 31 | endif 32 | endif 33 | -------------------------------------------------------------------------------- /librpc/rpc/rpc_router_ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008, Google Inc. 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | #ifndef RPC_IOCTL_H 18 | #define RPC_IOCTL_H 19 | 20 | #include 21 | 22 | struct rpcrouter_ioctl_server_args { 23 | uint32_t prog; 24 | uint32_t vers; 25 | }; 26 | 27 | #define RPC_ROUTER_IOCTL_MAGIC (0xC1) 28 | 29 | #define RPC_ROUTER_IOCTL_GET_VERSION \ 30 | _IOR(RPC_ROUTER_IOCTL_MAGIC, 0, unsigned int) 31 | 32 | #define RPC_ROUTER_IOCTL_GET_MTU \ 33 | _IOR(RPC_ROUTER_IOCTL_MAGIC, 1, unsigned int) 34 | 35 | #define RPC_ROUTER_IOCTL_REGISTER_SERVER \ 36 | _IOWR(RPC_ROUTER_IOCTL_MAGIC, 2, unsigned int) 37 | 38 | #define RPC_ROUTER_IOCTL_UNREGISTER_SERVER \ 39 | _IOWR(RPC_ROUTER_IOCTL_MAGIC, 3, unsigned int) 40 | 41 | #endif /* RPC_IOCTL_H */ 42 | -------------------------------------------------------------------------------- /libstagefrighthw/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | include $(CLEAR_VARS) 19 | 20 | LOCAL_SRC_FILES := \ 21 | stagefright_surface_output_msm72xx.cpp \ 22 | QComOMXPlugin.cpp \ 23 | QComHardwareRenderer.cpp 24 | 25 | LOCAL_CFLAGS := $(PV_CFLAGS_MINUS_VISIBILITY) 26 | 27 | LOCAL_C_INCLUDES:= \ 28 | $(TOP)/frameworks/base/include/media/stagefright/openmax 29 | 30 | LOCAL_SHARED_LIBRARIES := \ 31 | libbinder \ 32 | libutils \ 33 | libcutils \ 34 | libdl \ 35 | libui \ 36 | libsurfaceflinger_client\ 37 | 38 | LOCAL_MODULE := libstagefrighthw 39 | 40 | include $(BUILD_SHARED_LIBRARY) 41 | 42 | -------------------------------------------------------------------------------- /libopencorehw/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | ifneq ($(BUILD_WITHOUT_PV),true) 18 | 19 | LOCAL_PATH := $(call my-dir) 20 | include $(CLEAR_VARS) 21 | 22 | # Set up the OpenCore variables. 23 | include external/opencore/Config.mk 24 | LOCAL_C_INCLUDES := $(PV_INCLUDES) 25 | 26 | LOCAL_SRC_FILES := \ 27 | android_surface_output_msm72xx.cpp 28 | 29 | LOCAL_CFLAGS := $(PV_CFLAGS_MINUS_VISIBILITY) 30 | 31 | LOCAL_SHARED_LIBRARIES := \ 32 | libutils \ 33 | libbinder \ 34 | libcutils \ 35 | libui \ 36 | libhardware\ 37 | libandroid_runtime \ 38 | libmedia \ 39 | libskia \ 40 | libopencore_common \ 41 | libicuuc \ 42 | libopencore_player \ 43 | libsurfaceflinger_client 44 | 45 | LOCAL_MODULE := libopencorehw 46 | 47 | LOCAL_LDLIBS += 48 | 49 | include $(BUILD_SHARED_LIBRARY) 50 | 51 | endif 52 | -------------------------------------------------------------------------------- /libaudio/AudioPolicyManager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "AudioPolicyManager" 18 | //#define LOG_NDEBUG 0 19 | #include 20 | #include "AudioPolicyManager.h" 21 | #include 22 | 23 | namespace android { 24 | 25 | 26 | 27 | // ---------------------------------------------------------------------------- 28 | // AudioPolicyManager for msm7k platform 29 | // Common audio policy manager code is implemented in AudioPolicyManagerBase class 30 | // ---------------------------------------------------------------------------- 31 | 32 | // --- class factory 33 | 34 | 35 | extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface) 36 | { 37 | return new AudioPolicyManager(clientInterface); 38 | } 39 | 40 | extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface) 41 | { 42 | delete interface; 43 | } 44 | 45 | }; // namespace android 46 | -------------------------------------------------------------------------------- /libaudio/AudioPolicyManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | namespace android { 27 | 28 | class AudioPolicyManager: public AudioPolicyManagerBase 29 | { 30 | 31 | public: 32 | AudioPolicyManager(AudioPolicyClientInterface *clientInterface) 33 | : AudioPolicyManagerBase(clientInterface) {} 34 | 35 | virtual ~AudioPolicyManager() {} 36 | 37 | protected: 38 | // true is current platform implements a back microphone 39 | virtual bool hasBackMicrophone() const { return false; } 40 | #ifdef WITH_A2DP 41 | // true is current platform supports suplication of notifications and ringtones over A2DP output 42 | virtual bool a2dpUsedForSonification() const { return true; } 43 | #endif 44 | 45 | }; 46 | }; 47 | -------------------------------------------------------------------------------- /dspcrashd/NOTICE: -------------------------------------------------------------------------------- 1 | /* dspcrashd.c 2 | ** 3 | ** Copyright 2010, The Android Open Source Project 4 | ** 5 | ** Redistribution and use in source and binary forms, with or without 6 | ** modification, are permitted provided that the following conditions are met: 7 | ** * Redistributions of source code must retain the above copyright 8 | ** notice, this list of conditions and the following disclaimer. 9 | ** * Redistributions in binary form must reproduce the above copyright 10 | ** notice, this list of conditions and the following disclaimer in the 11 | ** documentation and/or other materials provided with the distribution. 12 | ** * Neither the name of Google Inc. nor the names of its contributors may 13 | ** be used to endorse or promote products derived from this software 14 | ** without specific prior written permission. 15 | ** 16 | ** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 17 | ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | ** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | ** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | ** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | -------------------------------------------------------------------------------- /libcopybit/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH:= $(call my-dir) 17 | # HAL module implemenation, not prelinked and stored in 18 | # hw/..so 19 | 20 | ifeq ($(TARGET_BOARD_PLATFORM),msm7k) 21 | include $(CLEAR_VARS) 22 | LOCAL_PRELINK_MODULE := false 23 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 24 | LOCAL_SHARED_LIBRARIES := liblog 25 | LOCAL_SRC_FILES := copybit.cpp 26 | LOCAL_MODULE := copybit.msm7k 27 | LOCAL_C_INCLUDES += hardware/msm7k/libgralloc 28 | LOCAL_CFLAGS += -DCOPYBIT_MSM7K=1 29 | include $(BUILD_SHARED_LIBRARY) 30 | endif 31 | 32 | ifeq ($(TARGET_BOARD_PLATFORM),qsd8k) 33 | include $(CLEAR_VARS) 34 | LOCAL_PRELINK_MODULE := false 35 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 36 | LOCAL_SHARED_LIBRARIES := liblog 37 | LOCAL_SRC_FILES := copybit.cpp 38 | LOCAL_MODULE := copybit.qsd8k 39 | LOCAL_C_INCLUDES += hardware/libhardware/modules/gralloc 40 | LOCAL_CFLAGS += -DCOPYBIT_QSD8K=1 41 | include $(BUILD_SHARED_LIBRARY) 42 | endif 43 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | # HAL module implemenation, not prelinked and stored in 18 | # hw/..so 19 | include $(CLEAR_VARS) 20 | LOCAL_PRELINK_MODULE := false 21 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 22 | LOCAL_SHARED_LIBRARIES := liblog libcutils libGLESv1_CM 23 | 24 | LOCAL_SRC_FILES := \ 25 | allocator.cpp \ 26 | framebuffer.cpp \ 27 | gpu.cpp \ 28 | gralloc.cpp \ 29 | mapper.cpp \ 30 | pmemalloc.cpp 31 | 32 | LOCAL_MODULE := gralloc.$(TARGET_BOARD_PLATFORM) 33 | LOCAL_CFLAGS:= -DLOG_TAG=\"$(TARGET_BOARD_PLATFORM).gralloc\" 34 | include $(BUILD_SHARED_LIBRARY) 35 | 36 | # Build a host library for testing 37 | ifeq ($(HOST_OS),linux) 38 | include $(CLEAR_VARS) 39 | LOCAL_SRC_FILES := \ 40 | gpu.cpp \ 41 | pmemalloc.cpp 42 | 43 | LOCAL_MODULE_TAGS := tests 44 | LOCAL_MODULE := libgralloc_qsd8k_host 45 | LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc-qsd8k\" 46 | include $(BUILD_HOST_STATIC_LIBRARY) 47 | endif 48 | -------------------------------------------------------------------------------- /librpc/ops.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define DUMP_DATA 0 13 | 14 | int r_open(const char *router) 15 | { 16 | int handle = open(router, O_RDWR, 0); 17 | 18 | if(handle < 0) 19 | E("error opening %s: %s\n", router, strerror(errno)); 20 | return handle; 21 | } 22 | 23 | void r_close(int handle) 24 | { 25 | if(close(handle) < 0) E("error: %s\n", strerror(errno)); 26 | } 27 | 28 | int r_read(int handle, char *buf, uint32 size) 29 | { 30 | int rc = read((int) handle, (void *)buf, size); 31 | if (rc < 0) 32 | E("error reading RPC packet: %d (%s)\n", errno, strerror(errno)); 33 | #if DUMP_DATA 34 | else { 35 | int len = rc / 4; 36 | uint32_t *data = (uint32_t *)buf; 37 | fprintf(stdout, "RPC in %02d:", rc); 38 | while (len--) 39 | fprintf(stdout, " %08x", *data++); 40 | fprintf(stdout, "\n"); 41 | } 42 | #endif 43 | return rc; 44 | } 45 | 46 | int r_write (int handle, const char *buf, uint32 size) 47 | { 48 | int rc = write(handle, (void *)buf, size); 49 | if (rc < 0) 50 | E("error writing RPC packet: %d (%s)\n", errno, strerror(errno)); 51 | #if DUMP_DATA 52 | else { 53 | int len = rc / 4; 54 | uint32_t *data = (uint32_t *)buf; 55 | fprintf(stdout, "RPC out %02d:", rc); 56 | while (len--) 57 | fprintf(stdout, " %08x", *data++); 58 | fprintf(stdout, "\n"); 59 | } 60 | #endif 61 | return rc; 62 | } 63 | 64 | int r_control(int handle, const uint32 cmd, void *arg) 65 | { 66 | return ioctl(handle, cmd, arg); 67 | } 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /libstagefrighthw/stagefright_surface_output_msm72xx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "QComHardwareRenderer.h" 20 | 21 | using android::sp; 22 | using android::ISurface; 23 | using android::VideoRenderer; 24 | 25 | VideoRenderer *createRendererWithRotation( 26 | const sp &surface, 27 | const char *componentName, 28 | OMX_COLOR_FORMATTYPE colorFormat, 29 | size_t displayWidth, size_t displayHeight, 30 | size_t decodedWidth, size_t decodedHeight, 31 | int32_t rotationDegrees) { 32 | using android::QComHardwareRenderer; 33 | 34 | static const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00; 35 | 36 | if (colorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar 37 | && !strncmp(componentName, "OMX.qcom.video.decoder.", 23)) { 38 | return new QComHardwareRenderer( 39 | surface, displayWidth, displayHeight, 40 | decodedWidth, decodedHeight, 41 | rotationDegrees); 42 | } 43 | 44 | return NULL; 45 | } 46 | -------------------------------------------------------------------------------- /librpc/rpc/pmap_clnt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 | * unrestricted use provided that this legend is included on all tape 4 | * media and as a part of the software program in whole or part. Users 5 | * may copy or modify Sun RPC without charge, but are not authorized 6 | * to license or distribute it to anyone else except as part of a product or 7 | * program developed by the user. 8 | * 9 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 | * 13 | * Sun RPC is provided with no support and without any obligation on the 14 | * part of Sun Microsystems, Inc. to assist in its use, correction, 15 | * modification or enhancement. 16 | * 17 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 | * OR ANY PART THEREOF. 20 | * 21 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 | * or profits or other special, indirect and consequential damages, even if 23 | * Sun has been advised of the possibility of such damages. 24 | * 25 | * Sun Microsystems, Inc. 26 | * 2550 Garcia Avenue 27 | * Mountain View, California 94043 28 | */ 29 | 30 | /* 31 | * pmap_clnt.h 32 | * Supplies C routines to get to portmap services. 33 | * 34 | * Copyright (C) 1984, Sun Microsystems, Inc. 35 | */ 36 | 37 | #ifndef PMAP_CLIENT_H 38 | #define PMAP_CLIENT_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /*PMAP_CLIENT_H*/ 54 | -------------------------------------------------------------------------------- /librpc/rpc/rpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 | * unrestricted use provided that this legend is included on all tape 4 | * media and as a part of the software program in whole or part. Users 5 | * may copy or modify Sun RPC without charge, but are not authorized 6 | * to license or distribute it to anyone else except as part of a product or 7 | * program developed by the user. 8 | * 9 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 | * 13 | * Sun RPC is provided with no support and without any obligation on the 14 | * part of Sun Microsystems, Inc. to assist in its use, correction, 15 | * modification or enhancement. 16 | * 17 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 | * OR ANY PART THEREOF. 20 | * 21 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 | * or profits or other special, indirect and consequential damages, even if 23 | * Sun has been advised of the possibility of such damages. 24 | * 25 | * Sun Microsystems, Inc. 26 | * 2550 Garcia Avenue 27 | * Mountain View, California 94043 28 | */ 29 | 30 | /* 31 | * rpc.h, Just includes the billions of rpc header files necessary to 32 | * do remote procedure calling. 33 | * 34 | * Copyright (C) 1984, Sun Microsystems, Inc. 35 | */ 36 | 37 | #ifndef RPC_H 38 | #define RPC_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* RPC_H */ 54 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/tests/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | # you can use EXTRA_CFLAGS to indicate additional CFLAGS to use 18 | # in the build. The variables will be cleaned on exit 19 | # 20 | # 21 | 22 | libgralloc_test_includes:= \ 23 | bionic/libstdc++/include \ 24 | external/astl/include \ 25 | external/gtest/include \ 26 | $(LOCAL_PATH)/.. 27 | 28 | libgralloc_test_static_libs := \ 29 | libgralloc_qsd8k_host \ 30 | libgtest_main_host \ 31 | libgtest_host \ 32 | libastl_host \ 33 | liblog 34 | 35 | define host-test 36 | $(foreach file,$(1), \ 37 | $(eval include $(CLEAR_VARS)) \ 38 | $(eval LOCAL_CPP_EXTENSION := .cpp) \ 39 | $(eval LOCAL_SRC_FILES := $(file)) \ 40 | $(eval LOCAL_C_INCLUDES := $(libgralloc_test_includes)) \ 41 | $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ 42 | $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \ 43 | $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \ 44 | $(eval LOCAL_STATIC_LIBRARIES := $(libgralloc_test_static_libs)) \ 45 | $(eval LOCAL_MODULE_TAGS := eng tests) \ 46 | $(eval include $(BUILD_HOST_EXECUTABLE)) \ 47 | ) \ 48 | $(eval EXTRA_CFLAGS :=) \ 49 | $(eval EXTRA_LDLIBS :=) 50 | endef 51 | 52 | TEST_SRC_FILES := \ 53 | pmemalloc_test.cpp 54 | 55 | $(call host-test, $(TEST_SRC_FILES)) 56 | -------------------------------------------------------------------------------- /libstagefrighthw/QComHardwareRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef QCOM_HARDWARE_RENDERER_H_ 18 | 19 | #define QCOM_HARDWARE_RENDERER_H_ 20 | 21 | #include 22 | #include 23 | 24 | namespace android { 25 | 26 | class ISurface; 27 | class MemoryHeapPmem; 28 | 29 | class QComHardwareRenderer : public VideoRenderer { 30 | public: 31 | QComHardwareRenderer( 32 | const sp &surface, 33 | size_t displayWidth, size_t displayHeight, 34 | size_t decodedWidth, size_t decodedHeight, 35 | int32_t rotationDegrees); 36 | 37 | virtual ~QComHardwareRenderer(); 38 | 39 | virtual void render( 40 | const void *data, size_t size, void *platformPrivate); 41 | 42 | private: 43 | sp mISurface; 44 | size_t mDisplayWidth, mDisplayHeight; 45 | size_t mDecodedWidth, mDecodedHeight; 46 | size_t mFrameSize; 47 | int32_t mRotationDegrees; 48 | sp mMemoryHeap; 49 | 50 | bool getOffset(void *platformPrivate, size_t *offset); 51 | void publishBuffers(uint32_t pmem_fd); 52 | 53 | QComHardwareRenderer(const QComHardwareRenderer &); 54 | QComHardwareRenderer &operator=(const QComHardwareRenderer &); 55 | }; 56 | 57 | } // namespace android 58 | 59 | #endif // QCOM_HARDWARE_RENDERER_H_ 60 | -------------------------------------------------------------------------------- /libaudio-qsd8k/AudioPolicyManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | namespace android { 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | class AudioPolicyManager: public AudioPolicyManagerBase 31 | { 32 | 33 | public: 34 | AudioPolicyManager(AudioPolicyClientInterface *clientInterface) 35 | : AudioPolicyManagerBase(clientInterface) {} 36 | 37 | virtual ~AudioPolicyManager() {} 38 | 39 | protected: 40 | 41 | // true is current platform implements a back microphone 42 | virtual bool hasBackMicrophone() const { return true; } 43 | 44 | #ifdef WITH_A2DP 45 | // true is current platform supports suplication of notifications and ringtones over A2DP output 46 | virtual bool a2dpUsedForSonification() const { return true; } 47 | #endif 48 | 49 | // return appropriate device for streams handled by the specified strategy according to current 50 | // phone state, connected devices... 51 | virtual uint32_t getDeviceForStrategy(routing_strategy strategy, bool fromCache = true); 52 | virtual float computeVolume(int stream, int index, audio_io_handle_t output, uint32_t device); 53 | }; 54 | 55 | }; 56 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/gr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GR_H_ 18 | #define GR_H_ 19 | 20 | #include 21 | #ifdef HAVE_ANDROID_OS // just want PAGE_SIZE define 22 | # include 23 | #else 24 | # include 25 | #endif 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | /*****************************************************************************/ 35 | 36 | struct private_module_t; 37 | struct private_handle_t; 38 | 39 | inline size_t roundUpToPageSize(size_t x) { 40 | return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); 41 | } 42 | 43 | int mapFrameBufferLocked(struct private_module_t* module); 44 | int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd); 45 | 46 | /*****************************************************************************/ 47 | 48 | class Locker { 49 | pthread_mutex_t mutex; 50 | public: 51 | class Autolock { 52 | Locker& locker; 53 | public: 54 | inline Autolock(Locker& locker) : locker(locker) { locker.lock(); } 55 | inline ~Autolock() { locker.unlock(); } 56 | }; 57 | inline Locker() { pthread_mutex_init(&mutex, 0); } 58 | inline ~Locker() { pthread_mutex_destroy(&mutex); } 59 | inline void lock() { pthread_mutex_lock(&mutex); } 60 | inline void unlock() { pthread_mutex_unlock(&mutex); } 61 | }; 62 | 63 | #endif /* GR_H_ */ 64 | -------------------------------------------------------------------------------- /libgralloc/gr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GR_H_ 18 | #define GR_H_ 19 | 20 | #include 21 | #ifdef HAVE_ANDROID_OS // just want PAGE_SIZE define 22 | # include 23 | #else 24 | # include 25 | #endif 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | /*****************************************************************************/ 35 | 36 | struct private_module_t; 37 | struct private_handle_t; 38 | 39 | inline size_t roundUpToPageSize(size_t x) { 40 | return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); 41 | } 42 | 43 | int mapFrameBufferLocked(struct private_module_t* module); 44 | int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd); 45 | int mapBuffer(gralloc_module_t const* module, private_handle_t* hnd); 46 | 47 | /*****************************************************************************/ 48 | 49 | class Locker { 50 | pthread_mutex_t mutex; 51 | public: 52 | class Autolock { 53 | Locker& locker; 54 | public: 55 | inline Autolock(Locker& locker) : locker(locker) { locker.lock(); } 56 | inline ~Autolock() { locker.unlock(); } 57 | }; 58 | inline Locker() { pthread_mutex_init(&mutex, 0); } 59 | inline ~Locker() { pthread_mutex_destroy(&mutex); } 60 | inline void lock() { pthread_mutex_lock(&mutex); } 61 | inline void unlock() { pthread_mutex_unlock(&mutex); } 62 | }; 63 | 64 | #endif /* GR_H_ */ 65 | -------------------------------------------------------------------------------- /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # ************************************************ 48 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 49 | # ************************************************ 50 | -------------------------------------------------------------------------------- /librpc/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008, The Android Open-Source Project 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | #ifndef DEBUG_H 18 | #define DEBUG_H 19 | 20 | #include 21 | 22 | #define LOG_TAG "RPC" 23 | #include 24 | 25 | #ifdef RPC_LOG_TO_STDOUT_ONLY 26 | #define PRINT(x...) do { \ 27 | fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \ 28 | fprintf(stdout, ##x); \ 29 | } while(0) 30 | #elif defined(RPC_LOG_TO_STDOUT_AND_LOG) 31 | #define PRINT(x...) do { \ 32 | fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \ 33 | fprintf(stdout, ##x); \ 34 | LOGI(x); \ 35 | } while(0) 36 | #else 37 | #define PRINT(x...) LOGI(x) 38 | #endif 39 | 40 | #ifdef DEBUG 41 | #define D PRINT 42 | #else 43 | #define D(x...) do { } while(0) 44 | #endif 45 | 46 | #ifdef VERBOSE 47 | #define V PRINT 48 | #else 49 | #define V(x...) do { } while(0) 50 | #endif 51 | 52 | #define E(x...) do { \ 53 | fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \ 54 | fprintf(stderr, ##x); \ 55 | LOGE(x); \ 56 | } while(0) 57 | 58 | #define FAILIF(cond, msg...) do { \ 59 | if (__builtin_expect (cond, 0)) { \ 60 | fprintf(stderr, "%s:%s:(%d): ", __FILE__, __FUNCTION__, __LINE__); \ 61 | fprintf(stderr, ##msg); \ 62 | LOGE(msg); \ 63 | } \ 64 | } while(0) 65 | 66 | #endif/*DEBUG_H*/ 67 | -------------------------------------------------------------------------------- /libstagefrighthw/QComOMXPlugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef QCOM_OMX_PLUGIN_H_ 18 | 19 | #define QCOM_OMX_PLUGIN_H_ 20 | 21 | #include 22 | 23 | namespace android { 24 | 25 | struct QComOMXPlugin : public OMXPluginBase { 26 | QComOMXPlugin(); 27 | virtual ~QComOMXPlugin(); 28 | 29 | virtual OMX_ERRORTYPE makeComponentInstance( 30 | const char *name, 31 | const OMX_CALLBACKTYPE *callbacks, 32 | OMX_PTR appData, 33 | OMX_COMPONENTTYPE **component); 34 | 35 | virtual OMX_ERRORTYPE destroyComponentInstance( 36 | OMX_COMPONENTTYPE *component); 37 | 38 | virtual OMX_ERRORTYPE enumerateComponents( 39 | OMX_STRING name, 40 | size_t size, 41 | OMX_U32 index); 42 | 43 | virtual OMX_ERRORTYPE getRolesOfComponent( 44 | const char *name, 45 | Vector *roles); 46 | 47 | private: 48 | void *mLibHandle; 49 | 50 | typedef OMX_ERRORTYPE (*InitFunc)(); 51 | typedef OMX_ERRORTYPE (*DeinitFunc)(); 52 | typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)( 53 | OMX_STRING, OMX_U32, OMX_U32); 54 | 55 | typedef OMX_ERRORTYPE (*GetHandleFunc)( 56 | OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *); 57 | 58 | typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE *); 59 | 60 | typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)( 61 | OMX_STRING, OMX_U32 *, OMX_U8 **); 62 | 63 | InitFunc mInit; 64 | DeinitFunc mDeinit; 65 | ComponentNameEnumFunc mComponentNameEnum; 66 | GetHandleFunc mGetHandle; 67 | FreeHandleFunc mFreeHandle; 68 | GetRolesOfComponentFunc mGetRolesOfComponentHandle; 69 | 70 | QComOMXPlugin(const QComOMXPlugin &); 71 | QComOMXPlugin &operator=(const QComOMXPlugin &); 72 | }; 73 | 74 | } // namespace android 75 | 76 | #endif // QCOM_OMX_PLUGIN_H_ 77 | -------------------------------------------------------------------------------- /libaudio-qdsp5v2/AudioPolicyManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | namespace android { 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | class AudioPolicyManager: public AudioPolicyManagerBase 31 | { 32 | 33 | public: 34 | AudioPolicyManager(AudioPolicyClientInterface *clientInterface) 35 | : AudioPolicyManagerBase(clientInterface) {} 36 | 37 | virtual ~AudioPolicyManager() {} 38 | 39 | #ifdef HAVE_FM_RADIO 40 | // AudioPolicyInterface 41 | virtual status_t setDeviceConnectionState(AudioSystem::audio_devices device, 42 | AudioSystem::device_connection_state state, 43 | const char *device_address); 44 | #endif 45 | protected: 46 | // return appropriate device for streams handled by the specified strategy according to current 47 | // phone state, connected devices... 48 | virtual uint32_t getDeviceForStrategy(routing_strategy strategy, bool fromCache = true); 49 | 50 | #ifdef HAVE_FM_RADIO 51 | void setOutputDevice(audio_io_handle_t output, uint32_t device, bool force = false, int delayMs = 0); 52 | #endif 53 | 54 | virtual float computeVolume(int stream, int index, audio_io_handle_t output, uint32_t device); 55 | 56 | // true is current platform implements a back microphone 57 | virtual bool hasBackMicrophone() const { return true; } 58 | 59 | #ifdef WITH_A2DP 60 | // true is current platform supports suplication of notifications and ringtones over A2DP output 61 | virtual bool a2dpUsedForSonification() const { return true; } 62 | #endif 63 | 64 | }; 65 | 66 | }; 67 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/gpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GRALLOC_QSD8K_GPU_H_ 18 | #define GRALLOC_QSD8K_GPU_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include "gralloc_priv.h" 29 | #include "pmemalloc.h" 30 | 31 | 32 | class gpu_context_t : public alloc_device_t { 33 | public: 34 | 35 | class Deps { 36 | public: 37 | 38 | virtual ~Deps(); 39 | 40 | // ashmem 41 | virtual int ashmem_create_region(const char *name, size_t size) = 0; 42 | 43 | // POSIX 44 | virtual int close(int fd) = 0; 45 | 46 | // Framebuffer (locally defined) 47 | virtual int mapFrameBufferLocked(struct private_module_t* module) = 0; 48 | virtual int terminateBuffer(gralloc_module_t const* module, 49 | private_handle_t* hnd) = 0; 50 | }; 51 | 52 | gpu_context_t(Deps& deps, PmemAllocator& pmemAllocator, 53 | PmemAllocator& pmemAdspAllocator, const private_module_t* module); 54 | 55 | int gralloc_alloc_framebuffer_locked(size_t size, int usage, 56 | buffer_handle_t* pHandle); 57 | int gralloc_alloc_framebuffer(size_t size, int usage, 58 | buffer_handle_t* pHandle); 59 | int gralloc_alloc_buffer(size_t size, int usage, buffer_handle_t* pHandle); 60 | int free_impl(private_handle_t const* hnd); 61 | int alloc_impl(int w, int h, int format, int usage, 62 | buffer_handle_t* pHandle, int* pStride); 63 | 64 | static int gralloc_alloc(alloc_device_t* dev, int w, int h, int format, 65 | int usage, buffer_handle_t* pHandle, int* pStride); 66 | static int gralloc_free(alloc_device_t* dev, buffer_handle_t handle); 67 | static int gralloc_close(struct hw_device_t *dev); 68 | 69 | private: 70 | 71 | Deps& deps; 72 | PmemAllocator& pmemAllocator; 73 | PmemAllocator& pmemAdspAllocator; 74 | }; 75 | 76 | #endif // GRALLOC_QSD8K_GPU_H 77 | -------------------------------------------------------------------------------- /libopencorehw/android_surface_output_msm72xx.h: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------ 2 | * Copyright (C) 2009 Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 | * express or implied. 14 | * See the License for the specific language governing permissions 15 | * and limitations under the License. 16 | * ------------------------------------------------------------------- 17 | */ 18 | 19 | #ifndef ANDROID_SURFACE_OUTPUT_MSM72XXH_INCLUDED 20 | #define ANDROID_SURFACE_OUTPUT_MSM72XXH_INCLUDED 21 | 22 | #include "android_surface_output.h" 23 | 24 | // support for shared contiguous physical memory 25 | #include 26 | 27 | // data structures for tunneling buffers 28 | typedef struct PLATFORM_PRIVATE_PMEM_INFO 29 | { 30 | /* pmem file descriptor */ 31 | uint32 pmem_fd; 32 | uint32 offset; 33 | } PLATFORM_PRIVATE_PMEM_INFO; 34 | 35 | typedef struct PLATFORM_PRIVATE_ENTRY 36 | { 37 | /* Entry type */ 38 | uint32 type; 39 | 40 | /* Pointer to platform specific entry */ 41 | OsclAny* entry; 42 | } PLATFORM_PRIVATE_ENTRY; 43 | 44 | typedef struct PLATFORM_PRIVATE_LIST 45 | { 46 | /* Number of entries */ 47 | uint32 nEntries; 48 | 49 | /* Pointer to array of platform specific entries * 50 | * Contiguous block of PLATFORM_PRIVATE_ENTRY elements */ 51 | PLATFORM_PRIVATE_ENTRY* entryList; 52 | } PLATFORM_PRIVATE_LIST; 53 | 54 | 55 | class AndroidSurfaceOutputMsm72xx : public AndroidSurfaceOutput 56 | { 57 | public: 58 | AndroidSurfaceOutputMsm72xx(); 59 | 60 | // frame buffer interface 61 | virtual bool initCheck(); 62 | virtual PVMFStatus writeFrameBuf(uint8* aData, uint32 aDataLen, const PvmiMediaXferHeader& data_header_info); 63 | virtual void postLastFrame(); 64 | 65 | OSCL_IMPORT_REF ~AndroidSurfaceOutputMsm72xx(); 66 | 67 | private: 68 | bool getPmemFd(OsclAny *private_data_ptr, uint32 *pmemFD); 69 | bool getOffset(OsclAny *private_data_ptr, uint32 *offset); 70 | void convertFrame(void* src, void* dst, size_t len); 71 | 72 | // hardware frame buffer support 73 | bool mHardwareCodec; 74 | uint32 mOffset; 75 | }; 76 | 77 | #endif // ANDROID_SURFACE_OUTPUT_MSM72XX_H_INCLUDED 78 | -------------------------------------------------------------------------------- /libgralloc/gralloc_priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GRALLOC_PRIV_H_ 18 | #define GRALLOC_PRIV_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | /*****************************************************************************/ 33 | 34 | struct private_module_t; 35 | struct private_handle_t; 36 | 37 | struct private_module_t { 38 | gralloc_module_t base; 39 | 40 | struct private_handle_t* framebuffer; 41 | uint32_t flags; 42 | uint32_t numBuffers; 43 | uint32_t bufferMask; 44 | pthread_mutex_t lock; 45 | buffer_handle_t currentBuffer; 46 | int pmem_master; 47 | void* pmem_master_base; 48 | unsigned long master_phys; 49 | int gpu; 50 | void* gpu_base; 51 | int fb_map_offset; 52 | 53 | struct fb_var_screeninfo info; 54 | struct fb_fix_screeninfo finfo; 55 | float xdpi; 56 | float ydpi; 57 | float fps; 58 | }; 59 | 60 | /*****************************************************************************/ 61 | 62 | #ifdef __cplusplus 63 | struct private_handle_t : public native_handle { 64 | #else 65 | struct private_handle_t { 66 | native_handle_t nativeHandle; 67 | #endif 68 | 69 | enum { 70 | PRIV_FLAGS_FRAMEBUFFER = 0x00000001, 71 | PRIV_FLAGS_USES_PMEM = 0x00000002, 72 | PRIV_FLAGS_USES_GPU = 0x00000004, 73 | }; 74 | 75 | // file-descriptors 76 | int fd; 77 | // ints 78 | int magic; 79 | int flags; 80 | int size; 81 | int offset; 82 | int gpu_fd; // stored as an int, b/c we don't want it marshalled 83 | 84 | // FIXME: the attributes below should be out-of-line 85 | int base; 86 | int map_offset; 87 | int pid; 88 | 89 | #ifdef __cplusplus 90 | static const int sNumInts = 8; 91 | static const int sNumFds = 1; 92 | static const int sMagic = 'gmsm'; 93 | 94 | private_handle_t(int fd, int size, int flags) : 95 | fd(fd), magic(sMagic), flags(flags), size(size), offset(0), 96 | base(0), pid(getpid()) 97 | { 98 | version = sizeof(native_handle); 99 | numInts = sNumInts; 100 | numFds = sNumFds; 101 | } 102 | ~private_handle_t() { 103 | magic = 0; 104 | } 105 | 106 | static int validate(const native_handle* h) { 107 | const private_handle_t* hnd = (const private_handle_t*)h; 108 | if (!h || h->version != sizeof(native_handle) || 109 | h->numInts != sNumInts || h->numFds != sNumFds || 110 | hnd->magic != sMagic) 111 | { 112 | LOGE("invalid gralloc handle (at %p)", h); 113 | return -EINVAL; 114 | } 115 | return 0; 116 | } 117 | #endif 118 | }; 119 | 120 | #endif /* GRALLOC_PRIV_H_ */ 121 | -------------------------------------------------------------------------------- /libgralloc/allocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef GRALLOC_ALLOCATOR_H_ 19 | #define GRALLOC_ALLOCATOR_H_ 20 | 21 | #include 22 | #include 23 | 24 | #include "gr.h" 25 | 26 | // ---------------------------------------------------------------------------- 27 | 28 | /* 29 | * A simple templatized doubly linked-list implementation 30 | */ 31 | 32 | template 33 | class LinkedList 34 | { 35 | NODE* mFirst; 36 | NODE* mLast; 37 | 38 | public: 39 | LinkedList() : mFirst(0), mLast(0) { } 40 | bool isEmpty() const { return mFirst == 0; } 41 | NODE const* head() const { return mFirst; } 42 | NODE* head() { return mFirst; } 43 | NODE const* tail() const { return mLast; } 44 | NODE* tail() { return mLast; } 45 | 46 | void insertAfter(NODE* node, NODE* newNode) { 47 | newNode->prev = node; 48 | newNode->next = node->next; 49 | if (node->next == 0) mLast = newNode; 50 | else node->next->prev = newNode; 51 | node->next = newNode; 52 | } 53 | 54 | void insertBefore(NODE* node, NODE* newNode) { 55 | newNode->prev = node->prev; 56 | newNode->next = node; 57 | if (node->prev == 0) mFirst = newNode; 58 | else node->prev->next = newNode; 59 | node->prev = newNode; 60 | } 61 | 62 | void insertHead(NODE* newNode) { 63 | if (mFirst == 0) { 64 | mFirst = mLast = newNode; 65 | newNode->prev = newNode->next = 0; 66 | } else { 67 | newNode->prev = 0; 68 | newNode->next = mFirst; 69 | mFirst->prev = newNode; 70 | mFirst = newNode; 71 | } 72 | } 73 | 74 | void insertTail(NODE* newNode) { 75 | if (mLast == 0) { 76 | insertHead(newNode); 77 | } else { 78 | newNode->prev = mLast; 79 | newNode->next = 0; 80 | mLast->next = newNode; 81 | mLast = newNode; 82 | } 83 | } 84 | 85 | NODE* remove(NODE* node) { 86 | if (node->prev == 0) mFirst = node->next; 87 | else node->prev->next = node->next; 88 | if (node->next == 0) mLast = node->prev; 89 | else node->next->prev = node->prev; 90 | return node; 91 | } 92 | }; 93 | 94 | class SimpleBestFitAllocator 95 | { 96 | public: 97 | 98 | SimpleBestFitAllocator(); 99 | SimpleBestFitAllocator(size_t size); 100 | ~SimpleBestFitAllocator(); 101 | 102 | ssize_t setSize(size_t size); 103 | 104 | ssize_t allocate(size_t size, uint32_t flags = 0); 105 | ssize_t deallocate(size_t offset); 106 | size_t size() const; 107 | 108 | private: 109 | struct chunk_t { 110 | chunk_t(size_t start, size_t size) 111 | : start(start), size(size), free(1), prev(0), next(0) { 112 | } 113 | size_t start; 114 | size_t size : 28; 115 | int free : 4; 116 | mutable chunk_t* prev; 117 | mutable chunk_t* next; 118 | }; 119 | 120 | ssize_t alloc(size_t size, uint32_t flags); 121 | chunk_t* dealloc(size_t start); 122 | 123 | static const int kMemoryAlign; 124 | mutable Locker mLock; 125 | LinkedList mList; 126 | size_t mHeapSize; 127 | }; 128 | 129 | #endif /* GRALLOC_ALLOCATOR_H_ */ 130 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/allocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef GRALLOC_ALLOCATOR_H_ 19 | #define GRALLOC_ALLOCATOR_H_ 20 | 21 | #include 22 | #include 23 | 24 | #include "gr.h" 25 | #include "pmemalloc.h" 26 | 27 | // ---------------------------------------------------------------------------- 28 | 29 | /* 30 | * A simple templatized doubly linked-list implementation 31 | */ 32 | 33 | template 34 | class LinkedList 35 | { 36 | NODE* mFirst; 37 | NODE* mLast; 38 | 39 | public: 40 | LinkedList() : mFirst(0), mLast(0) { } 41 | bool isEmpty() const { return mFirst == 0; } 42 | NODE const* head() const { return mFirst; } 43 | NODE* head() { return mFirst; } 44 | NODE const* tail() const { return mLast; } 45 | NODE* tail() { return mLast; } 46 | 47 | void insertAfter(NODE* node, NODE* newNode) { 48 | newNode->prev = node; 49 | newNode->next = node->next; 50 | if (node->next == 0) mLast = newNode; 51 | else node->next->prev = newNode; 52 | node->next = newNode; 53 | } 54 | 55 | void insertBefore(NODE* node, NODE* newNode) { 56 | newNode->prev = node->prev; 57 | newNode->next = node; 58 | if (node->prev == 0) mFirst = newNode; 59 | else node->prev->next = newNode; 60 | node->prev = newNode; 61 | } 62 | 63 | void insertHead(NODE* newNode) { 64 | if (mFirst == 0) { 65 | mFirst = mLast = newNode; 66 | newNode->prev = newNode->next = 0; 67 | } else { 68 | newNode->prev = 0; 69 | newNode->next = mFirst; 70 | mFirst->prev = newNode; 71 | mFirst = newNode; 72 | } 73 | } 74 | 75 | void insertTail(NODE* newNode) { 76 | if (mLast == 0) { 77 | insertHead(newNode); 78 | } else { 79 | newNode->prev = mLast; 80 | newNode->next = 0; 81 | mLast->next = newNode; 82 | mLast = newNode; 83 | } 84 | } 85 | 86 | NODE* remove(NODE* node) { 87 | if (node->prev == 0) mFirst = node->next; 88 | else node->prev->next = node->next; 89 | if (node->next == 0) mLast = node->prev; 90 | else node->next->prev = node->prev; 91 | return node; 92 | } 93 | }; 94 | 95 | class SimpleBestFitAllocator : public PmemUserspaceAllocator::Deps::Allocator 96 | { 97 | public: 98 | 99 | SimpleBestFitAllocator(); 100 | SimpleBestFitAllocator(size_t size); 101 | virtual ~SimpleBestFitAllocator(); 102 | 103 | virtual ssize_t setSize(size_t size); 104 | 105 | virtual ssize_t allocate(size_t size, uint32_t flags = 0); 106 | virtual ssize_t deallocate(size_t offset); 107 | virtual size_t size() const; 108 | 109 | private: 110 | struct chunk_t { 111 | chunk_t(size_t start, size_t size) 112 | : start(start), size(size), free(1), prev(0), next(0) { 113 | } 114 | size_t start; 115 | size_t size : 28; 116 | int free : 4; 117 | mutable chunk_t* prev; 118 | mutable chunk_t* next; 119 | }; 120 | 121 | ssize_t alloc(size_t size, uint32_t flags); 122 | chunk_t* dealloc(size_t start); 123 | 124 | static const int kMemoryAlign; 125 | mutable Locker mLock; 126 | LinkedList mList; 127 | size_t mHeapSize; 128 | }; 129 | 130 | #endif /* GRALLOC_ALLOCATOR_H_ */ 131 | -------------------------------------------------------------------------------- /libaudio-qdsp5v2/msm_audio.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | **************************************************************************** 11 | ****************************************************************************/ 12 | #ifndef __LINUX_MSM_AUDIO_H 13 | #define __LINUX_MSM_AUDIO_H 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #define AUDIO_IOCTL_MAGIC 'a' 20 | 21 | #define AUDIO_START _IOW(AUDIO_IOCTL_MAGIC, 0, unsigned) 22 | #define AUDIO_STOP _IOW(AUDIO_IOCTL_MAGIC, 1, unsigned) 23 | #define AUDIO_FLUSH _IOW(AUDIO_IOCTL_MAGIC, 2, unsigned) 24 | #define AUDIO_GET_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 3, unsigned) 25 | #define AUDIO_SET_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 4, unsigned) 26 | #define AUDIO_GET_STATS _IOR(AUDIO_IOCTL_MAGIC, 5, unsigned) 27 | #define AUDIO_ENABLE_AUDPP _IOW(AUDIO_IOCTL_MAGIC, 6, unsigned) 28 | #define AUDIO_SET_ADRC _IOW(AUDIO_IOCTL_MAGIC, 7, unsigned) 29 | #define AUDIO_SET_EQ _IOW(AUDIO_IOCTL_MAGIC, 8, unsigned) 30 | #define AUDIO_SET_RX_IIR _IOW(AUDIO_IOCTL_MAGIC, 9, unsigned) 31 | #define AUDIO_SET_VOLUME _IOW(AUDIO_IOCTL_MAGIC, 10, unsigned) 32 | #define AUDIO_ENABLE_AUDPRE _IOW(AUDIO_IOCTL_MAGIC, 11, unsigned) 33 | #define AUDIO_SET_AGC _IOW(AUDIO_IOCTL_MAGIC, 12, unsigned) 34 | #define AUDIO_SET_NS _IOW(AUDIO_IOCTL_MAGIC, 13, unsigned) 35 | #define AUDIO_SET_TX_IIR _IOW(AUDIO_IOCTL_MAGIC, 14, unsigned) 36 | #define AUDIO_SET_AAC_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 15, unsigned) 37 | #define AUDIO_WAIT_ADSP_DONE _IOR(AUDIO_IOCTL_MAGIC, 16, unsigned) 38 | #define AUDIO_ADSP_PAUSE _IOR(AUDIO_IOCTL_MAGIC, 17, unsigned) 39 | #define AUDIO_ADSP_RESUME _IOR(AUDIO_IOCTL_MAGIC, 18, unsigned) 40 | #define AUDIO_PLAY_DTMF _IOW(AUDIO_IOCTL_MAGIC, 19, unsigned) 41 | #define AUDIO_GET_AAC_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 20, unsigned) 42 | #define AUDIO_GET_AMRNB_ENC_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 21, unsigned) 43 | #define AUDIO_SET_AMRNB_ENC_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 22, unsigned) 44 | #define AUDIO_GET_PCM_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 30, unsigned) 45 | #define AUDIO_SET_PCM_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 31, unsigned) 46 | #define AUDIO_SWITCH_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 32, unsigned) 47 | #define AUDIO_SET_MUTE _IOW(AUDIO_IOCTL_MAGIC, 33, unsigned) 48 | #define AUDIO_UPDATE_ACDB _IOW(AUDIO_IOCTL_MAGIC, 34, unsigned) 49 | #define AUDIO_START_VOICE _IOW(AUDIO_IOCTL_MAGIC, 35, unsigned) 50 | #define AUDIO_STOP_VOICE _IOW(AUDIO_IOCTL_MAGIC, 36, unsigned) 51 | 52 | struct msm_audio_config { 53 | uint32_t buffer_size; 54 | uint32_t buffer_count; 55 | uint32_t channel_count; 56 | uint32_t sample_rate; 57 | uint32_t type; 58 | uint32_t unused[3]; 59 | }; 60 | 61 | struct msm_audio_stats { 62 | uint32_t byte_count; 63 | uint32_t sample_count; 64 | uint32_t unused[2]; 65 | }; 66 | 67 | #define SND_IOCTL_MAGIC 's' 68 | 69 | #define SND_MUTE_UNMUTED 0 70 | #define SND_MUTE_MUTED 1 71 | 72 | struct msm_snd_device_config { 73 | uint32_t device; 74 | uint32_t ear_mute; 75 | uint32_t mic_mute; 76 | }; 77 | 78 | #define SND_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_device_config *) 79 | 80 | #define SND_METHOD_VOICE 0 81 | 82 | struct msm_snd_volume_config { 83 | uint32_t device; 84 | uint32_t method; 85 | uint32_t volume; 86 | }; 87 | 88 | #define SND_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_snd_volume_config *) 89 | 90 | #define SND_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned *) 91 | 92 | struct msm_snd_endpoint { 93 | int id; 94 | char name[64]; 95 | }; 96 | 97 | #define SND_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_snd_endpoint *) 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /libaudio-qsd8k/msm_audio.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | **************************************************************************** 11 | ****************************************************************************/ 12 | #ifndef __LINUX_MSM_AUDIO_H 13 | #define __LINUX_MSM_AUDIO_H 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #define AUDIO_IOCTL_MAGIC 'a' 20 | 21 | #define AUDIO_START _IOW(AUDIO_IOCTL_MAGIC, 0, unsigned) 22 | #define AUDIO_STOP _IOW(AUDIO_IOCTL_MAGIC, 1, unsigned) 23 | #define AUDIO_FLUSH _IOW(AUDIO_IOCTL_MAGIC, 2, unsigned) 24 | #define AUDIO_GET_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 3, unsigned) 25 | #define AUDIO_SET_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 4, unsigned) 26 | #define AUDIO_GET_STATS _IOR(AUDIO_IOCTL_MAGIC, 5, unsigned) 27 | #define AUDIO_ENABLE_AUDPP _IOW(AUDIO_IOCTL_MAGIC, 6, unsigned) 28 | #define AUDIO_SET_ADRC _IOW(AUDIO_IOCTL_MAGIC, 7, unsigned) 29 | #define AUDIO_SET_EQ _IOW(AUDIO_IOCTL_MAGIC, 8, unsigned) 30 | #define AUDIO_SET_RX_IIR _IOW(AUDIO_IOCTL_MAGIC, 9, unsigned) 31 | #define AUDIO_SET_VOLUME _IOW(AUDIO_IOCTL_MAGIC, 10, unsigned) 32 | #define AUDIO_ENABLE_AUDPRE _IOW(AUDIO_IOCTL_MAGIC, 11, unsigned) 33 | #define AUDIO_SET_AGC _IOW(AUDIO_IOCTL_MAGIC, 12, unsigned) 34 | #define AUDIO_SET_NS _IOW(AUDIO_IOCTL_MAGIC, 13, unsigned) 35 | #define AUDIO_SET_TX_IIR _IOW(AUDIO_IOCTL_MAGIC, 14, unsigned) 36 | #define AUDIO_SET_AAC_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 15, unsigned) 37 | #define AUDIO_WAIT_ADSP_DONE _IOR(AUDIO_IOCTL_MAGIC, 16, unsigned) 38 | #define AUDIO_ADSP_PAUSE _IOR(AUDIO_IOCTL_MAGIC, 17, unsigned) 39 | #define AUDIO_ADSP_RESUME _IOR(AUDIO_IOCTL_MAGIC, 18, unsigned) 40 | #define AUDIO_PLAY_DTMF _IOW(AUDIO_IOCTL_MAGIC, 19, unsigned) 41 | #define AUDIO_GET_AAC_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 20, unsigned) 42 | #define AUDIO_GET_AMRNB_ENC_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 21, unsigned) 43 | #define AUDIO_SET_AMRNB_ENC_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 22, unsigned) 44 | #define AUDIO_GET_PCM_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 30, unsigned) 45 | #define AUDIO_SET_PCM_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 31, unsigned) 46 | #define AUDIO_SWITCH_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 32, unsigned) 47 | #define AUDIO_SET_MUTE _IOW(AUDIO_IOCTL_MAGIC, 33, unsigned) 48 | #define AUDIO_UPDATE_ACDB _IOW(AUDIO_IOCTL_MAGIC, 34, unsigned) 49 | #define AUDIO_START_VOICE _IOW(AUDIO_IOCTL_MAGIC, 35, unsigned) 50 | #define AUDIO_STOP_VOICE _IOW(AUDIO_IOCTL_MAGIC, 36, unsigned) 51 | 52 | struct msm_audio_config { 53 | uint32_t buffer_size; 54 | uint32_t buffer_count; 55 | uint32_t channel_count; 56 | uint32_t sample_rate; 57 | uint32_t type; 58 | uint32_t unused[3]; 59 | }; 60 | 61 | struct msm_audio_stats { 62 | uint32_t byte_count; 63 | uint32_t sample_count; 64 | uint32_t unused[2]; 65 | }; 66 | 67 | #define SND_IOCTL_MAGIC 's' 68 | 69 | #define SND_MUTE_UNMUTED 0 70 | #define SND_MUTE_MUTED 1 71 | 72 | struct msm_snd_device_config { 73 | uint32_t device; 74 | uint32_t ear_mute; 75 | uint32_t mic_mute; 76 | }; 77 | 78 | #define SND_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_device_config *) 79 | 80 | #define SND_METHOD_VOICE 0 81 | 82 | struct msm_snd_volume_config { 83 | uint32_t device; 84 | uint32_t method; 85 | uint32_t volume; 86 | }; 87 | 88 | #define SND_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_snd_volume_config *) 89 | 90 | #define SND_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned *) 91 | 92 | struct msm_snd_endpoint { 93 | int id; 94 | char name[64]; 95 | }; 96 | 97 | #define SND_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_snd_endpoint *) 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /librpc/rpc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * Functions to compose RPC messages from XDR primitives 5 | */ 6 | 7 | bool_t xdr_call_msg_start( 8 | xdr_s_type *xdr, 9 | uint32 prog, 10 | uint32 ver, 11 | uint32 proc, 12 | opaque_auth *cred, 13 | opaque_auth *verf) 14 | { 15 | uint32 vers = RPC_MSG_VERSION; 16 | 17 | xdr->x_prog = prog; 18 | xdr->x_proc = proc; 19 | 20 | return (XDR_MSG_START(xdr, RPC_MSG_CALL) && 21 | XDR_SEND_UINT32(xdr, &vers) && 22 | XDR_SEND_UINT32(xdr, &prog) && 23 | XDR_SEND_UINT32(xdr, &ver) && 24 | XDR_SEND_UINT32(xdr, &proc) && 25 | xdr_send_auth(xdr, cred) && 26 | xdr_send_auth(xdr, verf)); 27 | } // xdr_call_msg_start 28 | 29 | bool_t xdr_reply_msg_start( 30 | xdr_s_type *xdr, 31 | opaque_auth *verf) 32 | { 33 | int32 stat = (int32) RPC_MSG_ACCEPTED; 34 | int32 accept = (int32) RPC_ACCEPT_SUCCESS; 35 | 36 | return(XDR_MSG_START(xdr, RPC_MSG_REPLY) && 37 | XDR_SEND_INT32(xdr, &stat) && 38 | xdr_send_auth(xdr, verf) && 39 | XDR_SEND_INT32(xdr, &accept)); 40 | } // xdr_reply_msg_start 41 | 42 | static bool_t xdr_send_accepted_reply_header( 43 | xdr_s_type *xdr, 44 | struct rpc_accepted_reply_header const *accreply) 45 | { 46 | if (!xdr_send_auth(xdr, &accreply->verf)) 47 | return FALSE; 48 | 49 | if (!XDR_SEND_ENUM(xdr, &accreply->stat)) 50 | return FALSE; 51 | 52 | switch ((*accreply).stat){ 53 | case RPC_PROG_MISMATCH: 54 | if (!XDR_SEND_UINT32(xdr, &accreply->u.versions.low)) 55 | return FALSE; 56 | 57 | if (!XDR_SEND_UINT32(xdr, &accreply->u.versions.high)) 58 | return FALSE; 59 | break; 60 | 61 | case RPC_ACCEPT_SUCCESS: 62 | case RPC_PROG_UNAVAIL: 63 | case RPC_PROC_UNAVAIL: 64 | case RPC_GARBAGE_ARGS: 65 | case RPC_SYSTEM_ERR: 66 | case RPC_PROG_LOCKED: 67 | // case ignored 68 | break; 69 | 70 | default: 71 | return FALSE; 72 | } 73 | 74 | return TRUE; 75 | } /* xdr_send_accepted_reply_header */ 76 | 77 | static bool_t xdr_send_denied_reply( 78 | xdr_s_type *xdr, 79 | struct rpc_denied_reply const *rejreply) 80 | { 81 | if (!XDR_SEND_ENUM(xdr, &rejreply->stat)) 82 | return FALSE; 83 | 84 | switch ((*rejreply).stat){ 85 | case RPC_MISMATCH: 86 | if (!XDR_SEND_UINT32(xdr, &rejreply->u.versions.low)) 87 | return FALSE; 88 | if (!XDR_SEND_UINT32(xdr, &rejreply->u.versions.high)) 89 | return FALSE; 90 | break; 91 | case RPC_AUTH_ERROR: 92 | if (!XDR_SEND_ENUM(xdr, &rejreply->u.why)) 93 | return FALSE; 94 | break; 95 | default: 96 | return FALSE; 97 | } 98 | 99 | return TRUE; 100 | } /* xdr_send_denied_reply */ 101 | 102 | bool_t xdr_send_reply_header( 103 | xdr_s_type *xdr, 104 | rpc_reply_header const *reply) 105 | { 106 | if (!XDR_SEND_ENUM(xdr, &reply->stat)) 107 | return FALSE; 108 | 109 | switch ((*reply).stat) { 110 | case RPC_MSG_ACCEPTED: 111 | if (!xdr_send_accepted_reply_header(xdr, &reply->u.ar)) 112 | return FALSE; 113 | break; 114 | case RPC_MSG_DENIED: 115 | if (!xdr_send_denied_reply(xdr, &reply->u.dr)) 116 | return FALSE; 117 | break; 118 | default: 119 | return FALSE; 120 | } 121 | 122 | return TRUE; 123 | } /* xdr_send_reply_header */ 124 | 125 | #include 126 | 127 | bool_t 128 | xdr_send_auth(xdr_s_type *xdr, const opaque_auth *auth) 129 | { 130 | #define FAILIF(x) do { if (x) return FALSE; } while(0) 131 | 132 | switch (sizeof(auth->oa_flavor)) { 133 | case 1: 134 | FAILIF(!XDR_SEND_INT8(xdr, (int8_t *)&auth->oa_flavor)); 135 | break; 136 | case 2: 137 | FAILIF(!XDR_SEND_INT16(xdr, (int16_t *)&auth->oa_flavor)); 138 | break; 139 | case 4: 140 | FAILIF(!XDR_SEND_INT32(xdr, (int32_t *)&auth->oa_flavor)); 141 | break; 142 | default: 143 | return FALSE; 144 | } 145 | 146 | return (XDR_SEND_UINT(xdr, (uint32_t *)&auth->oa_length) && 147 | (auth->oa_length == 0 || 148 | XDR_SEND_BYTES(xdr, (uint8_t *)auth->oa_base, auth->oa_length))); 149 | } 150 | 151 | void xdr_free(xdrproc_t proc, char *objp) 152 | { 153 | XDR x; 154 | x.x_op = XDR_FREE; 155 | (*proc)(&x, objp); 156 | } 157 | -------------------------------------------------------------------------------- /libstagefrighthw/QComOMXPlugin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "QComOMXPlugin.h" 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace android { 25 | 26 | OMXPluginBase *createOMXPlugin() { 27 | return new QComOMXPlugin; 28 | } 29 | 30 | QComOMXPlugin::QComOMXPlugin() 31 | : mLibHandle(dlopen("libOmxCore.so", RTLD_NOW)), 32 | mInit(NULL), 33 | mDeinit(NULL), 34 | mComponentNameEnum(NULL), 35 | mGetHandle(NULL), 36 | mFreeHandle(NULL), 37 | mGetRolesOfComponentHandle(NULL) { 38 | if (mLibHandle != NULL) { 39 | mInit = (InitFunc)dlsym(mLibHandle, "OMX_Init"); 40 | mDeinit = (DeinitFunc)dlsym(mLibHandle, "OMX_DeInit"); 41 | 42 | mComponentNameEnum = 43 | (ComponentNameEnumFunc)dlsym(mLibHandle, "OMX_ComponentNameEnum"); 44 | 45 | mGetHandle = (GetHandleFunc)dlsym(mLibHandle, "OMX_GetHandle"); 46 | mFreeHandle = (FreeHandleFunc)dlsym(mLibHandle, "OMX_FreeHandle"); 47 | 48 | mGetRolesOfComponentHandle = 49 | (GetRolesOfComponentFunc)dlsym( 50 | mLibHandle, "OMX_GetRolesOfComponent"); 51 | 52 | (*mInit)(); 53 | } 54 | } 55 | 56 | QComOMXPlugin::~QComOMXPlugin() { 57 | if (mLibHandle != NULL) { 58 | (*mDeinit)(); 59 | 60 | dlclose(mLibHandle); 61 | mLibHandle = NULL; 62 | } 63 | } 64 | 65 | OMX_ERRORTYPE QComOMXPlugin::makeComponentInstance( 66 | const char *name, 67 | const OMX_CALLBACKTYPE *callbacks, 68 | OMX_PTR appData, 69 | OMX_COMPONENTTYPE **component) { 70 | if (mLibHandle == NULL) { 71 | return OMX_ErrorUndefined; 72 | } 73 | 74 | return (*mGetHandle)( 75 | reinterpret_cast(component), 76 | const_cast(name), 77 | appData, const_cast(callbacks)); 78 | } 79 | 80 | OMX_ERRORTYPE QComOMXPlugin::destroyComponentInstance( 81 | OMX_COMPONENTTYPE *component) { 82 | if (mLibHandle == NULL) { 83 | return OMX_ErrorUndefined; 84 | } 85 | 86 | return (*mFreeHandle)(reinterpret_cast(component)); 87 | } 88 | 89 | OMX_ERRORTYPE QComOMXPlugin::enumerateComponents( 90 | OMX_STRING name, 91 | size_t size, 92 | OMX_U32 index) { 93 | if (mLibHandle == NULL) { 94 | return OMX_ErrorUndefined; 95 | } 96 | 97 | return (*mComponentNameEnum)(name, size, index); 98 | } 99 | 100 | OMX_ERRORTYPE QComOMXPlugin::getRolesOfComponent( 101 | const char *name, 102 | Vector *roles) { 103 | roles->clear(); 104 | 105 | if (mLibHandle == NULL) { 106 | return OMX_ErrorUndefined; 107 | } 108 | 109 | OMX_U32 numRoles; 110 | OMX_ERRORTYPE err = (*mGetRolesOfComponentHandle)( 111 | const_cast(name), &numRoles, NULL); 112 | 113 | if (err != OMX_ErrorNone) { 114 | return err; 115 | } 116 | 117 | if (numRoles > 0) { 118 | OMX_U8 **array = new OMX_U8 *[numRoles]; 119 | for (OMX_U32 i = 0; i < numRoles; ++i) { 120 | array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; 121 | } 122 | 123 | OMX_U32 numRoles2; 124 | err = (*mGetRolesOfComponentHandle)( 125 | const_cast(name), &numRoles2, array); 126 | 127 | CHECK_EQ(err, OMX_ErrorNone); 128 | CHECK_EQ(numRoles, numRoles2); 129 | 130 | for (OMX_U32 i = 0; i < numRoles; ++i) { 131 | String8 s((const char *)array[i]); 132 | roles->push(s); 133 | 134 | delete[] array[i]; 135 | array[i] = NULL; 136 | } 137 | 138 | delete[] array; 139 | array = NULL; 140 | } 141 | 142 | return OMX_ErrorNone; 143 | } 144 | 145 | } // namespace android 146 | -------------------------------------------------------------------------------- /dspcrashd/dspcrashd.c: -------------------------------------------------------------------------------- 1 | /* dspcrashd.c 2 | ** 3 | ** Copyright 2010, The Android Open Source Project 4 | ** 5 | ** Redistribution and use in source and binary forms, with or without 6 | ** modification, are permitted provided that the following conditions are met: 7 | ** * Redistributions of source code must retain the above copyright 8 | ** notice, this list of conditions and the following disclaimer. 9 | ** * Redistributions in binary form must reproduce the above copyright 10 | ** notice, this list of conditions and the following disclaimer in the 11 | ** documentation and/or other materials provided with the distribution. 12 | ** * Neither the name of Google Inc. nor the names of its contributors may 13 | ** be used to endorse or promote products derived from this software 14 | ** without specific prior written permission. 15 | ** 16 | ** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 17 | ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | ** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | ** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | ** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | #define KLOG_BUF_SHIFT 17 /* CONFIG_LOG_BUF_SHIFT from our kernel */ 39 | #define KLOG_BUF_LEN (1 << KLOG_BUF_SHIFT) 40 | 41 | char *props[] = { 42 | "ro.product.name", 43 | "ro.build.id", 44 | "ro.build.date", 45 | "ro.serialno", 46 | "ro.baseband", 47 | 0, 48 | }; 49 | 50 | char *dashes = "---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n"; 51 | 52 | void dump_dmesg(int fd) 53 | { 54 | char buffer[KLOG_BUF_LEN + 1]; 55 | char *p = buffer; 56 | ssize_t ret; 57 | int n, op; 58 | 59 | n = klogctl(KLOG_READ_ALL, buffer, KLOG_BUF_LEN); 60 | if (n < 0) 61 | return; 62 | buffer[n] = '\0'; 63 | 64 | while((ret = write(fd, p, n))) { 65 | if (ret < 0) { 66 | if (errno == EINTR) 67 | continue; 68 | return; 69 | } 70 | p += ret; 71 | n -= ret; 72 | } 73 | 74 | return 0; 75 | } 76 | 77 | void dump_info(int fd) 78 | { 79 | char buf[4096]; 80 | char val[PROPERTY_VALUE_MAX]; 81 | char **p = props; 82 | 83 | write(fd, dashes, strlen(dashes)); 84 | while (*p) { 85 | property_get(*p,val,""); 86 | sprintf(buf,"%s: %s\n", *p, val); 87 | write(fd, buf, strlen(buf)); 88 | p++; 89 | } 90 | write(fd, dashes, strlen(dashes)); 91 | dump_dmesg(fd); 92 | write(fd, dashes, strlen(dashes)); 93 | } 94 | 95 | void dump_dsp_state(int dsp) 96 | { 97 | int fd, r; 98 | char name[128]; 99 | char buf[128*1024]; 100 | 101 | sprintf(name,"/sdcard/dsp.crash.%d.img", (int) time(0)); 102 | 103 | fd = open(name, O_CREAT | O_TRUNC | O_WRONLY, 0644); 104 | if (fd < 0) 105 | return; 106 | 107 | for (;;) { 108 | r = read(dsp, buf, sizeof(buf)); 109 | if (r == 0) break; 110 | if (r < 0) { 111 | if (errno == EINTR) 112 | continue; 113 | break; 114 | } 115 | write(fd, buf, r); 116 | } 117 | 118 | dump_info(fd); 119 | close(fd); 120 | 121 | fd = open("/dev/kmsg", O_WRONLY); 122 | if (fd >= 0) { 123 | sprintf(buf,"*** WROTE DSP RAMDUMP TO %s ***\n",name); 124 | write(fd, buf, strlen(buf)); 125 | close(fd); 126 | } 127 | } 128 | 129 | int main(int argc, char **argv) 130 | { 131 | int fd; 132 | fd = open("/dev/dsp_debug", O_RDWR); 133 | if (fd < 0) 134 | return -1; 135 | 136 | write(fd, "wait-for-crash", 14); 137 | 138 | dump_dsp_state(fd); 139 | 140 | sync(); 141 | sync(); 142 | sync(); 143 | 144 | write(fd, "continue-crash", 14); 145 | 146 | close(fd); 147 | 148 | for (;;) 149 | sleep(100); 150 | 151 | return 0; 152 | } 153 | 154 | -------------------------------------------------------------------------------- /libstagefrighthw/QComHardwareRenderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "QComHardwareRenderer.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace android { 25 | 26 | //////////////////////////////////////////////////////////////////////////////// 27 | 28 | typedef struct PLATFORM_PRIVATE_ENTRY 29 | { 30 | /* Entry type */ 31 | uint32_t type; 32 | 33 | /* Pointer to platform specific entry */ 34 | void *entry; 35 | 36 | } PLATFORM_PRIVATE_ENTRY; 37 | 38 | typedef struct PLATFORM_PRIVATE_LIST 39 | { 40 | /* Number of entries */ 41 | uint32_t nEntries; 42 | 43 | /* Pointer to array of platform specific entries * 44 | * Contiguous block of PLATFORM_PRIVATE_ENTRY elements */ 45 | PLATFORM_PRIVATE_ENTRY *entryList; 46 | 47 | } PLATFORM_PRIVATE_LIST; 48 | 49 | // data structures for tunneling buffers 50 | typedef struct PLATFORM_PRIVATE_PMEM_INFO 51 | { 52 | /* pmem file descriptor */ 53 | uint32_t pmem_fd; 54 | uint32_t offset; 55 | 56 | } PLATFORM_PRIVATE_PMEM_INFO; 57 | 58 | #define PLATFORM_PRIVATE_PMEM 1 59 | 60 | QComHardwareRenderer::QComHardwareRenderer( 61 | const sp &surface, 62 | size_t displayWidth, size_t displayHeight, 63 | size_t decodedWidth, size_t decodedHeight, 64 | int32_t rotationDegrees) 65 | : mISurface(surface), 66 | mDisplayWidth(displayWidth), 67 | mDisplayHeight(displayHeight), 68 | mDecodedWidth(decodedWidth), 69 | mDecodedHeight(decodedHeight), 70 | mFrameSize((mDecodedWidth * mDecodedHeight * 3) / 2), 71 | mRotationDegrees(rotationDegrees) { 72 | CHECK(mISurface.get() != NULL); 73 | CHECK(mDecodedWidth > 0); 74 | CHECK(mDecodedHeight > 0); 75 | } 76 | 77 | QComHardwareRenderer::~QComHardwareRenderer() { 78 | mISurface->unregisterBuffers(); 79 | } 80 | 81 | void QComHardwareRenderer::render( 82 | const void *data, size_t size, void *platformPrivate) { 83 | size_t offset; 84 | if (!getOffset(platformPrivate, &offset)) { 85 | return; 86 | } 87 | 88 | mISurface->postBuffer(offset); 89 | } 90 | 91 | bool QComHardwareRenderer::getOffset(void *platformPrivate, size_t *offset) { 92 | *offset = 0; 93 | 94 | PLATFORM_PRIVATE_LIST *list = (PLATFORM_PRIVATE_LIST *)platformPrivate; 95 | for (uint32_t i = 0; i < list->nEntries; ++i) { 96 | if (list->entryList[i].type != PLATFORM_PRIVATE_PMEM) { 97 | continue; 98 | } 99 | 100 | PLATFORM_PRIVATE_PMEM_INFO *info = 101 | (PLATFORM_PRIVATE_PMEM_INFO *)list->entryList[i].entry; 102 | 103 | if (info != NULL) { 104 | if (mMemoryHeap.get() == NULL) { 105 | publishBuffers(info->pmem_fd); 106 | } 107 | 108 | if (mMemoryHeap.get() == NULL) { 109 | return false; 110 | } 111 | 112 | *offset = info->offset; 113 | 114 | return true; 115 | } 116 | } 117 | 118 | return false; 119 | } 120 | 121 | void QComHardwareRenderer::publishBuffers(uint32_t pmem_fd) { 122 | sp master = 123 | reinterpret_cast(pmem_fd); 124 | 125 | master->setDevice("/dev/pmem"); 126 | 127 | uint32_t heap_flags = master->getFlags() & MemoryHeapBase::NO_CACHING; 128 | mMemoryHeap = new MemoryHeapPmem(master, heap_flags); 129 | mMemoryHeap->slap(); 130 | 131 | uint32_t orientation; 132 | switch (mRotationDegrees) { 133 | case 0: orientation = ISurface::BufferHeap::ROT_0; break; 134 | case 90: orientation = ISurface::BufferHeap::ROT_90; break; 135 | case 180: orientation = ISurface::BufferHeap::ROT_180; break; 136 | case 270: orientation = ISurface::BufferHeap::ROT_270; break; 137 | default: orientation = ISurface::BufferHeap::ROT_0; break; 138 | } 139 | 140 | ISurface::BufferHeap bufferHeap( 141 | mDisplayWidth, mDisplayHeight, 142 | mDecodedWidth, mDecodedHeight, 143 | HAL_PIXEL_FORMAT_YCrCb_420_SP, 144 | orientation, 0, 145 | mMemoryHeap); 146 | 147 | status_t err = mISurface->registerBuffers(bufferHeap); 148 | CHECK_EQ(err, OK); 149 | } 150 | 151 | } // namespace android 152 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/pmemalloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GRALLOC_QSD8K_PMEMALLOC_H 18 | #define GRALLOC_QSD8K_PMEMALLOC_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | /** 27 | * An interface to the PMEM allocators. 28 | */ 29 | class PmemAllocator { 30 | 31 | public: 32 | 33 | virtual ~PmemAllocator(); 34 | 35 | // Only valid after init_pmem_area() has completed successfully. 36 | virtual void* get_base_address() = 0; 37 | 38 | virtual int alloc_pmem_buffer(size_t size, int usage, void** pBase, 39 | int* pOffset, int* pFd) = 0; 40 | virtual int free_pmem_buffer(size_t size, void* base, int offset, int fd) = 0; 41 | }; 42 | 43 | 44 | /** 45 | * A PMEM allocator that allocates the entire pmem memory from the kernel and 46 | * then uses a user-space allocator to suballocate from that. This requires 47 | * that the PMEM device driver have kernel allocation disabled. 48 | */ 49 | class PmemUserspaceAllocator: public PmemAllocator { 50 | 51 | public: 52 | 53 | class Deps { 54 | public: 55 | 56 | class Allocator { 57 | public: 58 | virtual ~Allocator(); 59 | virtual ssize_t setSize(size_t size) = 0; 60 | virtual size_t size() const = 0; 61 | virtual ssize_t allocate(size_t size, uint32_t flags = 0) = 0; 62 | virtual ssize_t deallocate(size_t offset) = 0; 63 | }; 64 | 65 | virtual ~Deps(); 66 | 67 | // pmem 68 | virtual size_t getPmemTotalSize(int fd, size_t* size) = 0; 69 | virtual int connectPmem(int fd, int master_fd) = 0; 70 | virtual int mapPmem(int fd, int offset, size_t size) = 0; 71 | virtual int unmapPmem(int fd, int offset, size_t size) = 0; 72 | 73 | // C99 74 | virtual int getErrno() = 0; 75 | 76 | // POSIX 77 | virtual void* mmap(void* start, size_t length, int prot, int flags, int fd, 78 | off_t offset) = 0; 79 | virtual int open(const char* pathname, int flags, int mode) = 0; 80 | virtual int close(int fd) = 0; 81 | }; 82 | 83 | PmemUserspaceAllocator(Deps& deps, Deps::Allocator& allocator, const char* pmemdev); 84 | virtual ~PmemUserspaceAllocator(); 85 | 86 | // Only valid after init_pmem_area() has completed successfully. 87 | virtual void* get_base_address(); 88 | 89 | virtual int init_pmem_area_locked(); 90 | virtual int init_pmem_area(); 91 | virtual int alloc_pmem_buffer(size_t size, int usage, void** pBase, 92 | int* pOffset, int* pFd); 93 | virtual int free_pmem_buffer(size_t size, void* base, int offset, int fd); 94 | 95 | #ifndef ANDROID_OS 96 | // DO NOT USE: For testing purposes only. 97 | void set_master_values(int fd, void* base) { 98 | master_fd = fd; 99 | master_base = base; 100 | } 101 | #endif // ANDROID_OS 102 | 103 | private: 104 | 105 | enum { 106 | MASTER_FD_INIT = -1, 107 | }; 108 | 109 | Deps& deps; 110 | Deps::Allocator& allocator; 111 | 112 | pthread_mutex_t lock; 113 | const char* pmemdev; 114 | int master_fd; 115 | void* master_base; 116 | }; 117 | 118 | 119 | /** 120 | * A PMEM allocator that allocates each individual allocation from the kernel 121 | * (using the kernel's allocator). This requires the kernel driver for the 122 | * particular PMEM device being allocated from to support kernel allocation. 123 | */ 124 | class PmemKernelAllocator: public PmemAllocator { 125 | 126 | public: 127 | 128 | class Deps { 129 | public: 130 | 131 | virtual ~Deps(); 132 | 133 | // C99 134 | virtual int getErrno() = 0; 135 | 136 | // POSIX 137 | virtual void* mmap(void* start, size_t length, int prot, int flags, int fd, 138 | off_t offset) = 0; 139 | virtual int munmap(void* start, size_t length) = 0; 140 | virtual int open(const char* pathname, int flags, int mode) = 0; 141 | virtual int close(int fd) = 0; 142 | }; 143 | 144 | PmemKernelAllocator(Deps& deps, const char* pmemdev); 145 | virtual ~PmemKernelAllocator(); 146 | 147 | // Only valid after init_pmem_area() has completed successfully. 148 | virtual void* get_base_address(); 149 | 150 | virtual int alloc_pmem_buffer(size_t size, int usage, void** pBase, 151 | int* pOffset, int* pFd); 152 | virtual int free_pmem_buffer(size_t size, void* base, int offset, int fd); 153 | 154 | private: 155 | 156 | Deps& deps; 157 | 158 | const char* pmemdev; 159 | }; 160 | 161 | #endif // GRALLOC_QSD8K_PMEMALLOC_H 162 | -------------------------------------------------------------------------------- /libgralloc/allocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "allocator.h" 20 | 21 | 22 | // align all the memory blocks on a cache-line boundary 23 | const int SimpleBestFitAllocator::kMemoryAlign = 32; 24 | 25 | SimpleBestFitAllocator::SimpleBestFitAllocator() 26 | : mHeapSize(0) 27 | { 28 | } 29 | 30 | SimpleBestFitAllocator::SimpleBestFitAllocator(size_t size) 31 | : mHeapSize(0) 32 | { 33 | setSize(size); 34 | } 35 | 36 | SimpleBestFitAllocator::~SimpleBestFitAllocator() 37 | { 38 | while(!mList.isEmpty()) { 39 | delete mList.remove(mList.head()); 40 | } 41 | } 42 | 43 | ssize_t SimpleBestFitAllocator::setSize(size_t size) 44 | { 45 | Locker::Autolock _l(mLock); 46 | if (mHeapSize != 0) return -EINVAL; 47 | size_t pagesize = getpagesize(); 48 | mHeapSize = ((size + pagesize-1) & ~(pagesize-1)); 49 | chunk_t* node = new chunk_t(0, mHeapSize / kMemoryAlign); 50 | mList.insertHead(node); 51 | return size; 52 | } 53 | 54 | 55 | size_t SimpleBestFitAllocator::size() const 56 | { 57 | return mHeapSize; 58 | } 59 | 60 | ssize_t SimpleBestFitAllocator::allocate(size_t size, uint32_t flags) 61 | { 62 | Locker::Autolock _l(mLock); 63 | if (mHeapSize == 0) return -EINVAL; 64 | ssize_t offset = alloc(size, flags); 65 | return offset; 66 | } 67 | 68 | ssize_t SimpleBestFitAllocator::deallocate(size_t offset) 69 | { 70 | Locker::Autolock _l(mLock); 71 | if (mHeapSize == 0) return -EINVAL; 72 | chunk_t const * const freed = dealloc(offset); 73 | if (freed) { 74 | return 0; 75 | } 76 | return -ENOENT; 77 | } 78 | 79 | ssize_t SimpleBestFitAllocator::alloc(size_t size, uint32_t flags) 80 | { 81 | if (size == 0) { 82 | return 0; 83 | } 84 | size = (size + kMemoryAlign-1) / kMemoryAlign; 85 | chunk_t* free_chunk = 0; 86 | chunk_t* cur = mList.head(); 87 | 88 | size_t pagesize = getpagesize(); 89 | while (cur) { 90 | int extra = ( -cur->start & ((pagesize/kMemoryAlign)-1) ) ; 91 | 92 | // best fit 93 | if (cur->free && (cur->size >= (size+extra))) { 94 | if ((!free_chunk) || (cur->size < free_chunk->size)) { 95 | free_chunk = cur; 96 | } 97 | if (cur->size == size) { 98 | break; 99 | } 100 | } 101 | cur = cur->next; 102 | } 103 | 104 | if (free_chunk) { 105 | const size_t free_size = free_chunk->size; 106 | free_chunk->free = 0; 107 | free_chunk->size = size; 108 | if (free_size > size) { 109 | int extra = ( -free_chunk->start & ((pagesize/kMemoryAlign)-1) ) ; 110 | if (extra) { 111 | chunk_t* split = new chunk_t(free_chunk->start, extra); 112 | free_chunk->start += extra; 113 | mList.insertBefore(free_chunk, split); 114 | } 115 | 116 | LOGE_IF(((free_chunk->start*kMemoryAlign)&(pagesize-1)), 117 | "page is not aligned!!!"); 118 | 119 | const ssize_t tail_free = free_size - (size+extra); 120 | if (tail_free > 0) { 121 | chunk_t* split = new chunk_t( 122 | free_chunk->start + free_chunk->size, tail_free); 123 | mList.insertAfter(free_chunk, split); 124 | } 125 | } 126 | return (free_chunk->start)*kMemoryAlign; 127 | } 128 | return -ENOMEM; 129 | } 130 | 131 | SimpleBestFitAllocator::chunk_t* SimpleBestFitAllocator::dealloc(size_t start) 132 | { 133 | start = start / kMemoryAlign; 134 | chunk_t* cur = mList.head(); 135 | while (cur) { 136 | if (cur->start == start) { 137 | LOG_FATAL_IF(cur->free, 138 | "block at offset 0x%08lX of size 0x%08lX already freed", 139 | cur->start*kMemoryAlign, cur->size*kMemoryAlign); 140 | 141 | // merge freed blocks together 142 | chunk_t* freed = cur; 143 | cur->free = 1; 144 | do { 145 | chunk_t* const p = cur->prev; 146 | chunk_t* const n = cur->next; 147 | if (p && (p->free || !cur->size)) { 148 | freed = p; 149 | p->size += cur->size; 150 | mList.remove(cur); 151 | delete cur; 152 | } 153 | cur = n; 154 | } while (cur && cur->free); 155 | 156 | LOG_FATAL_IF(!freed->free, 157 | "freed block at offset 0x%08lX of size 0x%08lX is not free!", 158 | freed->start * kMemoryAlign, freed->size * kMemoryAlign); 159 | 160 | return freed; 161 | } 162 | cur = cur->next; 163 | } 164 | return 0; 165 | } 166 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/allocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "allocator.h" 20 | 21 | 22 | // align all the memory blocks on a cache-line boundary 23 | const int SimpleBestFitAllocator::kMemoryAlign = 32; 24 | 25 | SimpleBestFitAllocator::SimpleBestFitAllocator() 26 | : mHeapSize(0) 27 | { 28 | } 29 | 30 | SimpleBestFitAllocator::SimpleBestFitAllocator(size_t size) 31 | : mHeapSize(0) 32 | { 33 | setSize(size); 34 | } 35 | 36 | SimpleBestFitAllocator::~SimpleBestFitAllocator() 37 | { 38 | while(!mList.isEmpty()) { 39 | delete mList.remove(mList.head()); 40 | } 41 | } 42 | 43 | ssize_t SimpleBestFitAllocator::setSize(size_t size) 44 | { 45 | Locker::Autolock _l(mLock); 46 | if (mHeapSize != 0) return -EINVAL; 47 | size_t pagesize = getpagesize(); 48 | mHeapSize = ((size + pagesize-1) & ~(pagesize-1)); 49 | chunk_t* node = new chunk_t(0, mHeapSize / kMemoryAlign); 50 | mList.insertHead(node); 51 | return size; 52 | } 53 | 54 | 55 | size_t SimpleBestFitAllocator::size() const 56 | { 57 | return mHeapSize; 58 | } 59 | 60 | ssize_t SimpleBestFitAllocator::allocate(size_t size, uint32_t flags) 61 | { 62 | Locker::Autolock _l(mLock); 63 | if (mHeapSize == 0) return -EINVAL; 64 | ssize_t offset = alloc(size, flags); 65 | return offset; 66 | } 67 | 68 | ssize_t SimpleBestFitAllocator::deallocate(size_t offset) 69 | { 70 | Locker::Autolock _l(mLock); 71 | if (mHeapSize == 0) return -EINVAL; 72 | chunk_t const * const freed = dealloc(offset); 73 | if (freed) { 74 | return 0; 75 | } 76 | return -ENOENT; 77 | } 78 | 79 | ssize_t SimpleBestFitAllocator::alloc(size_t size, uint32_t flags) 80 | { 81 | if (size == 0) { 82 | return 0; 83 | } 84 | size = (size + kMemoryAlign-1) / kMemoryAlign; 85 | chunk_t* free_chunk = 0; 86 | chunk_t* cur = mList.head(); 87 | 88 | size_t pagesize = getpagesize(); 89 | while (cur) { 90 | int extra = ( -cur->start & ((pagesize/kMemoryAlign)-1) ) ; 91 | 92 | // best fit 93 | if (cur->free && (cur->size >= (size+extra))) { 94 | if ((!free_chunk) || (cur->size < free_chunk->size)) { 95 | free_chunk = cur; 96 | } 97 | if (cur->size == size) { 98 | break; 99 | } 100 | } 101 | cur = cur->next; 102 | } 103 | 104 | if (free_chunk) { 105 | const size_t free_size = free_chunk->size; 106 | free_chunk->free = 0; 107 | free_chunk->size = size; 108 | if (free_size > size) { 109 | int extra = ( -free_chunk->start & ((pagesize/kMemoryAlign)-1) ) ; 110 | if (extra) { 111 | chunk_t* split = new chunk_t(free_chunk->start, extra); 112 | free_chunk->start += extra; 113 | mList.insertBefore(free_chunk, split); 114 | } 115 | 116 | LOGE_IF(((free_chunk->start*kMemoryAlign)&(pagesize-1)), 117 | "page is not aligned!!!"); 118 | 119 | const ssize_t tail_free = free_size - (size+extra); 120 | if (tail_free > 0) { 121 | chunk_t* split = new chunk_t( 122 | free_chunk->start + free_chunk->size, tail_free); 123 | mList.insertAfter(free_chunk, split); 124 | } 125 | } 126 | return (free_chunk->start)*kMemoryAlign; 127 | } 128 | return -ENOMEM; 129 | } 130 | 131 | SimpleBestFitAllocator::chunk_t* SimpleBestFitAllocator::dealloc(size_t start) 132 | { 133 | start = start / kMemoryAlign; 134 | chunk_t* cur = mList.head(); 135 | while (cur) { 136 | if (cur->start == start) { 137 | LOG_FATAL_IF(cur->free, 138 | "block at offset 0x%08lX of size 0x%08lX already freed", 139 | cur->start*kMemoryAlign, cur->size*kMemoryAlign); 140 | 141 | // merge freed blocks together 142 | chunk_t* freed = cur; 143 | cur->free = 1; 144 | do { 145 | chunk_t* const p = cur->prev; 146 | chunk_t* const n = cur->next; 147 | if (p && (p->free || !cur->size)) { 148 | freed = p; 149 | p->size += cur->size; 150 | mList.remove(cur); 151 | delete cur; 152 | } 153 | cur = n; 154 | } while (cur && cur->free); 155 | 156 | LOG_FATAL_IF(!freed->free, 157 | "freed block at offset 0x%08lX of size 0x%08lX is not free!", 158 | freed->start * kMemoryAlign, freed->size * kMemoryAlign); 159 | 160 | return freed; 161 | } 162 | cur = cur->next; 163 | } 164 | return 0; 165 | } 166 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/gralloc_priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GRALLOC_PRIV_H_ 18 | #define GRALLOC_PRIV_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | enum { 33 | /* gralloc usage bit indicating a pmem_adsp allocation should be used */ 34 | GRALLOC_USAGE_PRIVATE_PMEM_ADSP = GRALLOC_USAGE_PRIVATE_0, 35 | }; 36 | 37 | /*****************************************************************************/ 38 | 39 | enum { 40 | /* OEM specific HAL formats */ 41 | //HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x100, // defined in hardware.h 42 | //HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x101, // defined in hardware.h 43 | HAL_PIXEL_FORMAT_YCbCr_422_P = 0x102, 44 | HAL_PIXEL_FORMAT_YCbCr_420_P = 0x103, 45 | //HAL_PIXEL_FORMAT_YCbCr_422_I = 0x104, // defined in hardware.h 46 | HAL_PIXEL_FORMAT_YCbCr_420_I = 0x105, 47 | HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x106, 48 | HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x107, 49 | HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED = 0x108, 50 | HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x109, 51 | HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO = 0x10A, 52 | HAL_PIXEL_FORMAT_YCrCb_422_SP = 0x10B, 53 | HAL_PIXEL_FORMAT_YCrCb_420_SP_INTERLACE = 0x10C, 54 | }; 55 | 56 | /*****************************************************************************/ 57 | 58 | struct private_module_t; 59 | struct private_handle_t; 60 | struct PmemAllocator; 61 | 62 | struct private_module_t { 63 | gralloc_module_t base; 64 | 65 | struct private_handle_t* framebuffer; 66 | uint32_t fbFormat; 67 | uint32_t flags; 68 | uint32_t numBuffers; 69 | uint32_t bufferMask; 70 | pthread_mutex_t lock; 71 | buffer_handle_t currentBuffer; 72 | 73 | struct fb_var_screeninfo info; 74 | struct fb_fix_screeninfo finfo; 75 | float xdpi; 76 | float ydpi; 77 | float fps; 78 | 79 | enum { 80 | // flag to indicate we'll post this buffer 81 | PRIV_USAGE_LOCKED_FOR_POST = 0x80000000 82 | }; 83 | }; 84 | 85 | /*****************************************************************************/ 86 | 87 | #ifdef __cplusplus 88 | struct private_handle_t : public native_handle { 89 | #else 90 | struct private_handle_t { 91 | native_handle_t nativeHandle; 92 | #endif 93 | 94 | enum { 95 | PRIV_FLAGS_FRAMEBUFFER = 0x00000001, 96 | PRIV_FLAGS_USES_PMEM = 0x00000002, 97 | PRIV_FLAGS_USES_PMEM_ADSP = 0x00000004, 98 | PRIV_FLAGS_NEEDS_FLUSH = 0x00000008, 99 | }; 100 | 101 | enum { 102 | LOCK_STATE_WRITE = 1<<31, 103 | LOCK_STATE_MAPPED = 1<<30, 104 | LOCK_STATE_READ_MASK = 0x3FFFFFFF 105 | }; 106 | 107 | // file-descriptors 108 | int fd; 109 | // ints 110 | int magic; 111 | int flags; 112 | int size; 113 | int offset; 114 | int gpu_fd; // stored as an int, b/c we don't want it marshalled 115 | 116 | // FIXME: the attributes below should be out-of-line 117 | int base; 118 | int lockState; 119 | int writeOwner; 120 | int gpuaddr; // The gpu address mapped into the mmu. If using ashmem, set to 0 They don't care 121 | int pid; 122 | 123 | #ifdef __cplusplus 124 | static const int sNumInts = 10; 125 | static const int sNumFds = 1; 126 | static const int sMagic = 'gmsm'; 127 | 128 | private_handle_t(int fd, int size, int flags) : 129 | fd(fd), magic(sMagic), flags(flags), size(size), offset(0), gpu_fd(-1), 130 | base(0), lockState(0), writeOwner(0), gpuaddr(0), pid(getpid()) 131 | { 132 | version = sizeof(native_handle); 133 | numInts = sNumInts; 134 | numFds = sNumFds; 135 | } 136 | ~private_handle_t() { 137 | magic = 0; 138 | } 139 | 140 | bool usesPhysicallyContiguousMemory() { 141 | return (flags & PRIV_FLAGS_USES_PMEM) != 0; 142 | } 143 | 144 | static int validate(const native_handle* h) { 145 | const private_handle_t* hnd = (const private_handle_t*)h; 146 | if (!h || h->version != sizeof(native_handle) || 147 | h->numInts != sNumInts || h->numFds != sNumFds || 148 | hnd->magic != sMagic) 149 | { 150 | LOGE("invalid gralloc handle (at %p)", h); 151 | return -EINVAL; 152 | } 153 | return 0; 154 | } 155 | 156 | static private_handle_t* dynamicCast(const native_handle* in) { 157 | if (validate(in) == 0) { 158 | return (private_handle_t*) in; 159 | } 160 | return NULL; 161 | } 162 | #endif 163 | }; 164 | 165 | #endif /* GRALLOC_PRIV_H_ */ 166 | -------------------------------------------------------------------------------- /librpc/rpc/xdr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 | * unrestricted use provided that this legend is included on all tape 4 | * media and as a part of the software program in whole or part. Users 5 | * may copy or modify Sun RPC without charge, but are not authorized 6 | * to license or distribute it to anyone else except as part of a product or 7 | * program developed by the user. 8 | * 9 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 | * 13 | * Sun RPC is provided with no support and without any obligation on the 14 | * part of Sun Microsystems, Inc. to assist in its use, correction, 15 | * modification or enhancement. 16 | * 17 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 | * OR ANY PART THEREOF. 20 | * 21 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 | * or profits or other special, indirect and consequential damages, even if 23 | * Sun has been advised of the possibility of such damages. 24 | * 25 | * Sun Microsystems, Inc. 26 | * 2550 Garcia Avenue 27 | * Mountain View, California 94043 28 | */ 29 | 30 | /* 31 | * xdr.h, External Data Representation Serialization Routines. 32 | * 33 | * Copyright (C) 1984, Sun Microsystems, Inc. 34 | */ 35 | 36 | #ifndef XDR_H 37 | #define XDR_H 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /*=========================================================================== 44 | Macros for calling primitive XDR routines (this is independent of RPC) 45 | ===========================================================================*/ 46 | 47 | #define XDR_RECV_BYTES(XDR, BUF, LEN) (XDR)->xops->recv_bytes(XDR, BUF, LEN) 48 | #define XDR_RECV_INT16(XDR, VALUE) (XDR)->xops->recv_int16(XDR, VALUE) 49 | #define XDR_RECV_INT32(XDR, VALUE) (XDR)->xops->recv_int32(XDR, VALUE) 50 | #define XDR_RECV_INT8(XDR, VALUE) (XDR)->xops->recv_int8(XDR, VALUE) 51 | #define XDR_RECV_UINT(XDR, VALUE) (XDR)->xops->recv_uint32(XDR, (uint32 *)(VALUE)) 52 | #define XDR_RECV_UINT32(XDR, VALUE) (XDR)->xops->recv_uint32(XDR, VALUE) 53 | #define XDR_SEND_BYTES(XDR, BUF, LEN) (XDR)->xops->send_bytes(XDR, BUF, LEN) 54 | #define XDR_SEND_INT16(XDR, VALUE) (XDR)->xops->send_int16(XDR, VALUE) 55 | #define XDR_SEND_INT32(XDR, VALUE) (XDR)->xops->send_int32(XDR, VALUE) 56 | #define XDR_SEND_INT8(XDR, VALUE) (XDR)->xops->send_int8(XDR, VALUE) 57 | #define XDR_SEND_UINT(XDR, VALUE) (XDR)->xops->send_uint32(XDR, (uint32 *)(VALUE)) 58 | #define XDR_SEND_UINT32(XDR, VALUE) (XDR)->xops->send_uint32(XDR, VALUE) 59 | 60 | /*=========================================================================== 61 | Macros for sending and receiving an RPC message through the transport 62 | ===========================================================================*/ 63 | 64 | #define XDR_MSG_START(XDR, TYPE) (XDR)->xops->msg_start(XDR, TYPE) 65 | #define XDR_MSG_SEND(XDR) (XDR)->xops->msg_send(XDR) 66 | #define XDR_MSG_DONE(XDR) (XDR)->xops->msg_done(XDR) 67 | #define XDR_MSG_ABORT(XDR) (XDR)->xops->msg_abort(XDR) 68 | 69 | extern bool_t xdr_call_msg_start (XDR *xdr, uint32 prog, uint32 ver, uint32 proc, opaque_auth *cred, opaque_auth *verf); 70 | extern bool_t xdr_reply_msg_start (XDR *xdr, opaque_auth *verf); 71 | extern bool_t xdr_send_auth (XDR *xdr, const opaque_auth *auth); 72 | extern bool_t xdr_send_reply_header (XDR *xdr, rpc_reply_header const *reply); 73 | extern void xdr_free (xdrproc_t proc, char *objp); 74 | 75 | /*********************************************************************** 76 | Support for rpcgen 77 | ***********************************************************************/ 78 | 79 | #define XDR_SEND_ENUM(XDR, VALUE) xdr_send_enum(XDR, (void *) (VALUE), sizeof(*(VALUE))) 80 | #define XDR_RECV_ENUM(XDR, VALUE) xdr_recv_enum(XDR, (void *) (VALUE), sizeof(*(VALUE))) 81 | extern bool_t xdr_send_enum (XDR *xdr, const void *value, uint32 size); 82 | extern bool_t xdr_recv_enum (XDR *xdr, void *value, uint32 size); 83 | 84 | extern bool_t xdr_bytes (XDR *xdr, char **cpp, u_int *sizep, u_int maxsize); 85 | extern bool_t xdr_enum (XDR *xdr, enum_t *ep); 86 | extern bool_t xdr_pointer (XDR *xdrs, char **_objpp, u_int obj_size, xdrproc_t xdr_obj); 87 | extern bool_t xdr_int (XDR *xdr, int *ip); 88 | extern bool_t xdr_u_int (XDR *xdr, u_int *ip); 89 | extern bool_t xdr_char (XDR *xdr, char *cp); 90 | extern bool_t xdr_u_char (XDR *xdr, u_char *cp); 91 | extern bool_t xdr_long (XDR *xdr, long *ulp); 92 | extern bool_t xdr_u_long (XDR *xdr, u_long *ulp); 93 | #define xdr_uint32 xdr_u_long 94 | extern bool_t xdr_quad_t (XDR *xdrs, quad_t *llp); 95 | extern bool_t xdr_u_quad_t (XDR *__xdrs, u_quad_t *__ullp); 96 | extern bool_t xdr_short (XDR *xdr, short *sp); 97 | extern bool_t xdr_u_short (XDR *xdr, u_short *usp); 98 | extern bool_t xdr_vector (XDR *xdrs, char *basep, u_int nelem, u_int elemsize, xdrproc_t xdr_elem); 99 | extern bool_t xdr_void (void); 100 | extern bool_t xdr_opaque (XDR *xdr, caddr_t cp, u_int cnt); 101 | extern bool_t xdr_string (XDR *xdr, char **cpp, u_int maxsize); 102 | 103 | extern bool_t xdr_array ( 104 | XDR *xdrs, 105 | caddr_t *addrp,/* array pointer */ 106 | u_int *sizep, /* number of elements */ 107 | u_int maxsize, /* max numberof elements */ 108 | u_int elsize, /* size in bytes of each element */ 109 | xdrproc_t elproc); /* xdr routine to handle each element */ 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* rpc/xdr.h */ 116 | -------------------------------------------------------------------------------- /libaudio-qdsp5v2/AudioHardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008, The Android Open-Source Project 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_AUDIO_HARDWARE_H 18 | #define ANDROID_AUDIO_HARDWARE_H 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | namespace android { 29 | 30 | #define CODEC_TYPE_PCM 0 31 | #define PCM_FILL_BUFFER_COUNT 1 32 | #define AUDIO_HW_NUM_OUT_BUF 2 // Number of buffers in audio driver for output 33 | 34 | // TODO: determine actual audio DSP and hardware latency 35 | #define AUDIO_HW_OUT_LATENCY_MS 0 // Additionnal latency introduced by audio DSP and hardware in ms 36 | #define AUDIO_HW_OUT_SAMPLERATE 44100 // Default audio output sample rate 37 | #define AUDIO_HW_OUT_CHANNELS (AudioSystem::CHANNEL_OUT_STEREO) // Default audio output channel mask 38 | #define AUDIO_HW_OUT_FORMAT (AudioSystem::PCM_16_BIT) // Default audio output sample format 39 | #define AUDIO_HW_OUT_BUFSZ 4096 // Default audio output buffer size 40 | 41 | #if 0 42 | #define AUDIO_HW_IN_SAMPLERATE 8000 // Default audio input sample rate 43 | #define AUDIO_HW_IN_CHANNELS (AudioSystem::CHANNEL_IN_MONO) // Default audio input channel mask 44 | #define AUDIO_HW_IN_FORMAT (AudioSystem::PCM_16_BIT) // Default audio input sample format 45 | #define AUDIO_HW_IN_BUFSZ 256 // Default audio input buffer size 46 | 47 | #define VOICE_VOLUME_MAX 5 // Maximum voice volume 48 | #endif 49 | 50 | class AudioHardware : public AudioHardwareBase 51 | { 52 | class AudioStreamOutQ5V2; 53 | 54 | public: 55 | AudioHardware(); 56 | virtual ~AudioHardware(); 57 | virtual status_t initCheck(); 58 | 59 | virtual status_t setVoiceVolume(float volume); 60 | virtual status_t setMasterVolume(float volume); 61 | 62 | virtual status_t setMode(int mode); 63 | 64 | virtual status_t setMicMute(bool state); 65 | virtual status_t getMicMute(bool* state); 66 | 67 | virtual status_t setParameters(const String8& keyValuePairs); 68 | virtual String8 getParameters(const String8& keys); 69 | 70 | virtual AudioStreamOut* openOutputStream( 71 | uint32_t devices, 72 | int *format=0, 73 | uint32_t *channels=0, 74 | uint32_t *sampleRate=0, 75 | status_t *status=0); 76 | 77 | virtual AudioStreamIn* openInputStream( 78 | uint32_t devices, 79 | int *format, 80 | uint32_t *channels, 81 | uint32_t *sampleRate, 82 | status_t *status, 83 | AudioSystem::audio_in_acoustics acoustics); 84 | 85 | virtual void closeOutputStream(AudioStreamOut* out); 86 | virtual void closeInputStream(AudioStreamIn* in); 87 | 88 | virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount); 89 | 90 | void clearCurDevice() { } 91 | 92 | protected: 93 | virtual status_t dump(int fd, const Vector& args); 94 | 95 | private: 96 | 97 | class AudioStreamOutQ5V2 : public AudioStreamOut { 98 | public: 99 | AudioStreamOutQ5V2(); 100 | virtual ~AudioStreamOutQ5V2(); 101 | status_t set(AudioHardware* mHardware, 102 | uint32_t devices, 103 | int *pFormat, 104 | uint32_t *pChannels, 105 | uint32_t *pRate); 106 | virtual uint32_t sampleRate() const { return mSampleRate; } 107 | // must be 32-bit aligned 108 | virtual size_t bufferSize() const { return mBufferSize; } 109 | virtual uint32_t channels() const { return mChannels; } 110 | virtual int format() const { return AUDIO_HW_OUT_FORMAT; } 111 | virtual uint32_t latency() const { return (1000*AUDIO_HW_NUM_OUT_BUF*(bufferSize()/frameSize()))/sampleRate()+AUDIO_HW_OUT_LATENCY_MS; } 112 | virtual status_t setVolume(float left, float right) { return INVALID_OPERATION; } 113 | virtual ssize_t write(const void* buffer, size_t bytes); 114 | virtual status_t standby(); 115 | virtual status_t dump(int fd, const Vector& args); 116 | bool checkStandby(); 117 | virtual status_t setParameters(const String8& keyValuePairs); 118 | virtual String8 getParameters(const String8& keys); 119 | uint32_t devices() { return mDevices; } 120 | virtual status_t getRenderPosition(uint32_t *dspFrames); 121 | 122 | private: 123 | AudioHardware* mHardware; 124 | int mFd; 125 | int mStartCount; 126 | int mRetryCount; 127 | bool mStandby; 128 | uint32_t mDevices; 129 | uint32_t mChannels; 130 | uint32_t mSampleRate; 131 | size_t mBufferSize; 132 | }; 133 | 134 | bool mInit; 135 | bool mMicMute; 136 | 137 | AudioStreamOutQ5V2* mOutput; 138 | Mutex mLock; 139 | }; 140 | 141 | 142 | }; // namespace android 143 | 144 | #endif // ANDROID_AUDIO_HARDWARE_MSM72XX_H 145 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/gralloc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include "allocator.h" 28 | #include "gr.h" 29 | #include "gpu.h" 30 | 31 | /*****************************************************************************/ 32 | 33 | static int gralloc_alloc_buffer(alloc_device_t* dev, 34 | size_t size, int usage, buffer_handle_t* pHandle); 35 | 36 | /*****************************************************************************/ 37 | 38 | int fb_device_open(const hw_module_t* module, const char* name, 39 | hw_device_t** device); 40 | 41 | static int gralloc_device_open(const hw_module_t* module, const char* name, 42 | hw_device_t** device); 43 | 44 | extern int gralloc_lock(gralloc_module_t const* module, 45 | buffer_handle_t handle, int usage, 46 | int l, int t, int w, int h, 47 | void** vaddr); 48 | 49 | extern int gralloc_unlock(gralloc_module_t const* module, 50 | buffer_handle_t handle); 51 | 52 | extern int gralloc_register_buffer(gralloc_module_t const* module, 53 | buffer_handle_t handle); 54 | 55 | extern int gralloc_unregister_buffer(gralloc_module_t const* module, 56 | buffer_handle_t handle); 57 | 58 | extern int gralloc_perform(struct gralloc_module_t const* module, 59 | int operation, ... ); 60 | 61 | /*****************************************************************************/ 62 | 63 | /* On-device dependency implementation */ 64 | class PmemAllocatorDepsDeviceImpl : public PmemUserspaceAllocator::Deps, 65 | public PmemKernelAllocator::Deps { 66 | 67 | virtual size_t getPmemTotalSize(int fd, size_t* size) { 68 | pmem_region region; 69 | int err = ioctl(fd, PMEM_GET_TOTAL_SIZE, ®ion); 70 | if (err == 0) { 71 | *size = region.len; 72 | } 73 | return err; 74 | } 75 | 76 | virtual int connectPmem(int fd, int master_fd) { 77 | return ioctl(fd, PMEM_CONNECT, master_fd); 78 | } 79 | 80 | virtual int mapPmem(int fd, int offset, size_t size) { 81 | struct pmem_region sub = { offset, size }; 82 | return ioctl(fd, PMEM_MAP, &sub); 83 | } 84 | 85 | virtual int unmapPmem(int fd, int offset, size_t size) { 86 | struct pmem_region sub = { offset, size }; 87 | return ioctl(fd, PMEM_UNMAP, &sub); 88 | } 89 | 90 | virtual int getErrno() { 91 | return errno; 92 | } 93 | 94 | virtual void* mmap(void* start, size_t length, int prot, int flags, int fd, 95 | off_t offset) { 96 | return ::mmap(start, length, prot, flags, fd, offset); 97 | } 98 | 99 | virtual int munmap(void* start, size_t length) { 100 | return ::munmap(start, length); 101 | } 102 | 103 | virtual int open(const char* pathname, int flags, int mode) { 104 | return ::open(pathname, flags, mode); 105 | } 106 | 107 | virtual int close(int fd) { 108 | return ::close(fd); 109 | } 110 | }; 111 | 112 | class GpuContextDepsDeviceImpl : public gpu_context_t::Deps { 113 | 114 | public: 115 | 116 | virtual int ashmem_create_region(const char *name, size_t size) { 117 | return ::ashmem_create_region(name, size); 118 | } 119 | 120 | virtual int mapFrameBufferLocked(struct private_module_t* module) { 121 | return ::mapFrameBufferLocked(module); 122 | } 123 | 124 | virtual int terminateBuffer(gralloc_module_t const* module, 125 | private_handle_t* hnd) { 126 | return ::terminateBuffer(module, hnd); 127 | } 128 | 129 | virtual int close(int fd) { 130 | return ::close(fd); 131 | } 132 | }; 133 | 134 | static PmemAllocatorDepsDeviceImpl pmemAllocatorDeviceDepsImpl; 135 | static GpuContextDepsDeviceImpl gpuContextDeviceDepsImpl; 136 | 137 | /*****************************************************************************/ 138 | 139 | static SimpleBestFitAllocator pmemAllocMgr; 140 | static PmemUserspaceAllocator pmemAllocator(pmemAllocatorDeviceDepsImpl, pmemAllocMgr, 141 | "/dev/pmem"); 142 | 143 | static PmemKernelAllocator pmemAdspAllocator(pmemAllocatorDeviceDepsImpl, 144 | "/dev/pmem_adsp"); 145 | 146 | /*****************************************************************************/ 147 | 148 | static struct hw_module_methods_t gralloc_module_methods = { 149 | open: gralloc_device_open 150 | }; 151 | 152 | struct private_module_t HAL_MODULE_INFO_SYM = { 153 | base: { 154 | common: { 155 | tag: HARDWARE_MODULE_TAG, 156 | version_major: 1, 157 | version_minor: 0, 158 | id: GRALLOC_HARDWARE_MODULE_ID, 159 | name: "Graphics Memory Allocator Module", 160 | author: "The Android Open Source Project", 161 | methods: &gralloc_module_methods 162 | }, 163 | registerBuffer: gralloc_register_buffer, 164 | unregisterBuffer: gralloc_unregister_buffer, 165 | lock: gralloc_lock, 166 | unlock: gralloc_unlock, 167 | perform: gralloc_perform, 168 | }, 169 | framebuffer: 0, 170 | fbFormat: 0, 171 | flags: 0, 172 | numBuffers: 0, 173 | bufferMask: 0, 174 | lock: PTHREAD_MUTEX_INITIALIZER, 175 | currentBuffer: 0, 176 | }; 177 | 178 | /*****************************************************************************/ 179 | 180 | int gralloc_device_open(const hw_module_t* module, const char* name, 181 | hw_device_t** device) 182 | { 183 | int status = -EINVAL; 184 | if (!strcmp(name, GRALLOC_HARDWARE_GPU0)) { 185 | const private_module_t* m = reinterpret_cast( 186 | module); 187 | gpu_context_t *dev; 188 | dev = new gpu_context_t(gpuContextDeviceDepsImpl, pmemAllocator, 189 | pmemAdspAllocator, m); 190 | *device = &dev->common; 191 | status = 0; 192 | } else { 193 | status = fb_device_open(module, name, device); 194 | } 195 | return status; 196 | } 197 | -------------------------------------------------------------------------------- /librpc/rpc/clnt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 | * unrestricted use provided that this legend is included on all tape 4 | * media and as a part of the software program in whole or part. Users 5 | * may copy or modify Sun RPC without charge, but are not authorized 6 | * to license or distribute it to anyone else except as part of a product or 7 | * program developed by the user. 8 | * 9 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 | * 13 | * Sun RPC is provided with no support and without any obligation on the 14 | * part of Sun Microsystems, Inc. to assist in its use, correction, 15 | * modification or enhancement. 16 | * 17 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 | * OR ANY PART THEREOF. 20 | * 21 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 | * or profits or other special, indirect and consequential damages, even if 23 | * Sun has been advised of the possibility of such damages. 24 | * 25 | * Sun Microsystems, Inc. 26 | * 2550 Garcia Avenue 27 | * Mountain View, California 94043 28 | */ 29 | 30 | /* 31 | * clnt.h - Client side remote procedure call interface. 32 | * 33 | * Copyright (C) 1984, Sun Microsystems, Inc. 34 | */ 35 | 36 | #ifndef _RPC_CLNT_H 37 | #define _RPC_CLNT_H 1 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include 44 | 45 | /* 46 | * Rpc calls return an enum clnt_stat. This should be looked at more, 47 | * since each implementation is required to live with this (implementation 48 | * independent) list of errors. 49 | */ 50 | enum clnt_stat { 51 | RPC_SUCCESS=0, /* call succeeded */ 52 | /* 53 | * local errors 54 | */ 55 | RPC_CANTENCODEARGS=1, /* can't encode arguments */ 56 | RPC_CANTDECODERES=2, /* can't decode results */ 57 | RPC_CANTSEND=3, /* failure in sending call */ 58 | RPC_CANTRECV=4, /* failure in receiving result */ 59 | RPC_TIMEDOUT=5, /* call timed out */ 60 | /* 61 | * remote errors 62 | */ 63 | RPC_VERSMISMATCH=6, /* rpc versions not compatible */ 64 | RPC_AUTHERROR=7, /* authentication error */ 65 | RPC_PROGUNAVAIL=8, /* program not available */ 66 | RPC_PROGVERSMISMATCH=9, /* program version mismatched */ 67 | RPC_PROCUNAVAIL=10, /* procedure unavailable */ 68 | RPC_CANTDECODEARGS=11, /* decode arguments error */ 69 | RPC_SYSTEMERROR=12, /* generic "other problem" */ 70 | RPC_NOBROADCAST = 21, /* Broadcasting not supported */ 71 | /* 72 | * callrpc & clnt_create errors 73 | */ 74 | RPC_UNKNOWNHOST=13, /* unknown host name */ 75 | RPC_UNKNOWNPROTO=17, /* unknown protocol */ 76 | RPC_UNKNOWNADDR = 19, /* Remote address unknown */ 77 | 78 | /* 79 | * rpcbind errors 80 | */ 81 | RPC_RPCBFAILURE=14, /* portmapper failed in its call */ 82 | #define RPC_PMAPFAILURE RPC_RPCBFAILURE 83 | RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ 84 | RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */ 85 | /* 86 | * unspecified error 87 | */ 88 | RPC_FAILED=16, 89 | RPC_INTR=18, 90 | RPC_TLIERROR=20, 91 | RPC_UDERROR=23, 92 | /* 93 | * asynchronous errors 94 | */ 95 | RPC_INPROGRESS = 24, 96 | RPC_STALERACHANDLE = 25 97 | }; 98 | 99 | struct CLIENT; 100 | typedef struct CLIENT CLIENT; 101 | /* client call callback. 102 | * Callback called when the reply is recieved or there is an error in 103 | * getting reply. 104 | */ 105 | typedef void (*clnt_call_cb) 106 | ( 107 | CLIENT * clnt, 108 | void * cookie, 109 | caddr_t results, 110 | rpc_reply_header error 111 | ); 112 | 113 | typedef void (*clnt_call_non_blocking_cb) 114 | ( 115 | CLIENT * clnt, 116 | void * cookie, 117 | caddr_t results, 118 | rpc_reply_header error 119 | ); 120 | 121 | /* 122 | * By convention, procedure 0 takes null arguments and returns them 123 | */ 124 | #define NULLPROC ((rpcproc_t)0) 125 | 126 | /*=========================================================================== 127 | FUNCTION CLNT_CALL 128 | 129 | DESCRIPTION 130 | RPCGEN support routine. This routine is called by client routines generated 131 | by RPCGEN. It generates and sends an RPC message to a server. 132 | 133 | This is a blocking call. 134 | 135 | DEPENDENCIES 136 | None. 137 | 138 | ARGUMENTS 139 | xdr - the XDR to use to send the RPC message 140 | proc - the server procedure to call 141 | xdr_args - function pointer for encoding the RPC message args 142 | args_ptr - pointer to args data structure 143 | xdr_results - function pointer for decoding the RPC response 144 | rets_ptr - pointer to results data structure 145 | timeout - return after timeout (ignored) 146 | 147 | RETURN VALUE 148 | RPC_SUCCESS - if successful 149 | error code otherwise 150 | 151 | SIDE EFFECTS 152 | None. 153 | ===========================================================================*/ 154 | extern enum clnt_stat 155 | clnt_call 156 | ( 157 | CLIENT *h, 158 | u_long proc, 159 | xdrproc_t xdr_args, 160 | caddr_t args_ptr, 161 | xdrproc_t xdr_results, 162 | caddr_t rets_ptr, 163 | struct timeval timeout 164 | ); 165 | 166 | /*=========================================================================== 167 | FUNCTION CLNT_CALL_NON_BLOCKING 168 | 169 | DESCRIPTION 170 | RPCGEN support routine. This routine is called by client routines generated 171 | by RPCGEN. It generates and sends an RPC message to a server. 172 | 173 | This is a non-blocking call. It registers clnt_call_callback to be called 174 | when the RPC response is received. 175 | 176 | DEPENDENCIES 177 | None. 178 | 179 | ARGUMENTS 180 | xdr - the XDR to use to send the RPC message 181 | proc - the server procedure to call 182 | xdr_args - function pointer for encoding the RPC message args 183 | args_ptr - pointer to args data structure 184 | xdr_results - function pointer for decoding the RPC response 185 | results_size - size of the results data structure 186 | result_cb - function pointer to be called with the results 187 | cb_data - cookie for results call back function 188 | 189 | RETURN VALUE 190 | RPC_SUCCESS - if successful 191 | error code otherwise 192 | 193 | SIDE EFFECTS 194 | None. 195 | ===========================================================================*/ 196 | extern enum clnt_stat 197 | clnt_call_non_blocking 198 | ( 199 | CLIENT *h, 200 | u_long proc, 201 | xdrproc_t xdr_args, 202 | caddr_t args_ptr, 203 | xdrproc_t xdr_results, 204 | int results_size, 205 | clnt_call_cb result_cb, 206 | void * cb_data 207 | ); 208 | 209 | extern bool_t clnt_freeres( CLIENT *xdr, xdrproc_t xdr_res, caddr_t res_ptr ); 210 | extern void clnt_destroy( CLIENT *xdr ); 211 | extern CLIENT * clnt_create ( char * host, uint32 prog, uint32 vers, 212 | char * proto); 213 | 214 | #ifdef __cplusplus 215 | } 216 | #endif 217 | 218 | #endif /* rpc/clnt.h */ 219 | -------------------------------------------------------------------------------- /librpc/rpc/svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 | * unrestricted use provided that this legend is included on all tape 4 | * media and as a part of the software program in whole or part. Users 5 | * may copy or modify Sun RPC without charge, but are not authorized 6 | * to license or distribute it to anyone else except as part of a product or 7 | * program developed by the user. 8 | * 9 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12 | * 13 | * Sun RPC is provided with no support and without any obligation on the 14 | * part of Sun Microsystems, Inc. to assist in its use, correction, 15 | * modification or enhancement. 16 | * 17 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 | * OR ANY PART THEREOF. 20 | * 21 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 | * or profits or other special, indirect and consequential damages, even if 23 | * Sun has been advised of the possibility of such damages. 24 | * 25 | * Sun Microsystems, Inc. 26 | * 2550 Garcia Avenue 27 | * Mountain View, California 94043 28 | */ 29 | 30 | /* 31 | * svc.h, Server-side remote procedure call interface. 32 | * 33 | * Copyright (C) 1984, Sun Microsystems, Inc. 34 | */ 35 | 36 | #ifndef _RPC_SVC_H 37 | #define _RPC_SVC_H 1 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include 44 | 45 | /* 46 | * This interface must manage two items concerning remote procedure calling: 47 | * 48 | * 1) An arbitrary number of transport connections upon which rpc requests 49 | * are received. The two most notable transports are TCP and UDP; they are 50 | * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; 51 | * they in turn call xprt_register and xprt_unregister. 52 | * 53 | * 2) An arbitrary number of locally registered services. Services are 54 | * described by the following four data: program number, version number, 55 | * "service dispatch" function, a transport handle, and a bool_t that 56 | * indicates whether or not the exported program should be registered with a 57 | * local binder service; if true the program's number and version and the 58 | * port number from the transport handle are registered with the binder. 59 | * These data are registered with the rpc svc system via svc_register. 60 | * 61 | * A service's dispatch function is called whenever an rpc request comes in 62 | * on a transport. The request's program and version numbers must match 63 | * those of the registered service. The dispatch function is passed two 64 | * parameters, struct svc_req * and SVCXPRT *, defined below. 65 | */ 66 | 67 | /* 68 | * Server side transport handle 69 | */ 70 | struct SVCXPRT; 71 | typedef struct SVCXPRT SVCXPRT; 72 | 73 | /* 74 | * Service request 75 | */ 76 | struct svc_req { 77 | rpcprog_t rq_prog; /* service program number */ 78 | rpcvers_t rq_vers; /* service protocol version */ 79 | rpcproc_t rq_proc; /* the desired procedure */ 80 | SVCXPRT *rq_xprt; /* associated transport */ 81 | }; 82 | 83 | #ifndef __DISPATCH_FN_T 84 | #define __DISPATCH_FN_T 85 | typedef void (*__dispatch_fn_t) (struct svc_req*, SVCXPRT*); 86 | #endif 87 | 88 | /* 89 | * Transport registration. 90 | * 91 | * xprt_register(xprt) 92 | * SVCXPRT *xprt; 93 | */ 94 | extern void xprt_register (SVCXPRT *__xprt); 95 | 96 | /* 97 | * Transport un-register 98 | * 99 | * xprt_unregister(xprt) 100 | * SVCXPRT *xprt; 101 | */ 102 | extern void xprt_unregister (SVCXPRT *__xprt); 103 | 104 | /* 105 | * Service registration (registers only with plugger module) 106 | * 107 | * svc_register_with_plugger(xprt, prog, vers, dispatch, protocol) 108 | * SVCXPRT *xprt; 109 | * rpcprog_t prog; 110 | * rpcvers_t vers; 111 | * void (*dispatch)(struct svc_req*, SVCXPRT*); 112 | * rpcprot_t protocol; like TCP or UDP, zero means do not register 113 | */ 114 | extern bool_t svc_register_with_plugger (SVCXPRT *__xprt, rpcprog_t __prog, 115 | rpcvers_t __vers, 116 | __dispatch_fn_t __dispatch, 117 | rpcprot_t __protocol); 118 | 119 | /* 120 | * Service registration (registers with plugger module and lower layers) 121 | * 122 | * svc_register(xprt, prog, vers, dispatch, protocol) 123 | * SVCXPRT *xprt; 124 | * rpcprog_t prog; 125 | * rpcvers_t vers; 126 | * void (*dispatch)(struct svc_req*, SVCXPRT*); 127 | * rpcprot_t protocol; like TCP or UDP, zero means do not register 128 | */ 129 | extern bool_t svc_register (SVCXPRT *__xprt, rpcprog_t __prog, 130 | rpcvers_t __vers, __dispatch_fn_t __dispatch, 131 | rpcprot_t __protocol); 132 | 133 | extern void svc_destroy(SVCXPRT *xprt); 134 | 135 | /* 136 | * Service un-registration 137 | * 138 | * svc_unregister(xprt, prog, vers) 139 | * SVCXPRT *xprt 140 | * rpcprog_t prog; 141 | * rpcvers_t vers; 142 | */ 143 | void 144 | svc_unregister (SVCXPRT *__xprt, rpcprog_t prog, rpcvers_t vers); 145 | 146 | /* 147 | * Service Enable 148 | * 149 | * svc_enable( prog, vers ) 150 | * rpcprog_t prog; 151 | * rpcvers_t vers; 152 | */ 153 | #define svc_enable(prog, vers) svc_lock(prog, vers, FALSE) 154 | 155 | /* 156 | * Service Disable 157 | * 158 | * svc_disable( prog, vers ) 159 | * rpcprog_t prog; 160 | * rpcvers_t vers; 161 | */ 162 | #define svc_disable(prog, vers) svc_lock(prog, vers, TRUE) 163 | 164 | extern void svc_lock(rpcprog_t __prog, rpcvers_t __vers, bool_t __lock); 165 | 166 | /* 167 | * When the service routine is called, it must first check to see if it 168 | * knows about the procedure; if not, it should call svcerr_noproc 169 | * and return. If so, it should deserialize its arguments via 170 | * SVC_GETARGS (defined above). If the deserialization does not work, 171 | * svcerr_decode should be called followed by a return. Successful 172 | * decoding of the arguments should be followed the execution of the 173 | * procedure's code and a call to svc_sendreply. 174 | * 175 | * Also, if the service refuses to execute the procedure due to too- 176 | * weak authentication parameters, svcerr_weakauth should be called. 177 | * Note: do not confuse access-control failure with weak authentication! 178 | * 179 | * NB: In pure implementations of rpc, the caller always waits for a reply 180 | * msg. This message is sent when svc_sendreply is called. 181 | * Therefore pure service implementations should always call 182 | * svc_sendreply even if the function logically returns void; use 183 | * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows 184 | * for the abuse of pure rpc via batched calling or pipelining. In the 185 | * case of a batched call, svc_sendreply should NOT be called since 186 | * this would send a return message, which is what batching tries to avoid. 187 | * It is the service/protocol writer's responsibility to know which calls are 188 | * batched and which are not. Warning: responding to batch calls may 189 | * deadlock the caller and server processes! 190 | */ 191 | 192 | extern bool_t svc_getargs(SVCXPRT *xdr, xdrproc_t xdr_args, caddr_t args_ptr); 193 | extern bool_t svc_freeargs(SVCXPRT *xdr, xdrproc_t xdr_args, caddr_t args_ptr); 194 | 195 | extern bool_t svc_sendreply (SVCXPRT *xprt, xdrproc_t __xdr_results, 196 | caddr_t __xdr_location); 197 | 198 | /* 199 | * Socket to use on svcxxx_create call to get default socket 200 | */ 201 | #define RPC_ANYSOCK -1 202 | 203 | /* 204 | * Router based rpc. 205 | */ 206 | extern SVCXPRT *svcrtr_create (void); 207 | 208 | extern void svcerr_decode (SVCXPRT *); 209 | extern void svcerr_weakauth (SVCXPRT *); 210 | extern void svcerr_noproc (SVCXPRT *); 211 | extern void svcerr_noprog (SVCXPRT *); 212 | extern void svcerr_systemerr (SVCXPRT *); 213 | extern void svcerr_progvers (SVCXPRT *, rpcvers_t __low_vers, rpcvers_t __high_vers); 214 | extern void svcerr_auth (SVCXPRT *, auth_stat __why); 215 | 216 | #ifdef __cplusplus 217 | } 218 | #endif 219 | 220 | #endif /* rpc/svc.h */ 221 | -------------------------------------------------------------------------------- /libgralloc/mapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #include "gralloc_priv.h" 38 | 39 | 40 | // we need this for now because pmem cannot mmap at an offset 41 | #define PMEM_HACK 1 42 | 43 | /* desktop Linux needs a little help with gettid() */ 44 | #if defined(ARCH_X86) && !defined(HAVE_ANDROID_OS) 45 | #define __KERNEL__ 46 | # include 47 | pid_t gettid() { return syscall(__NR_gettid);} 48 | #undef __KERNEL__ 49 | #endif 50 | 51 | /*****************************************************************************/ 52 | 53 | static int gralloc_map(gralloc_module_t const* module, 54 | buffer_handle_t handle, 55 | void** vaddr) 56 | { 57 | private_handle_t* hnd = (private_handle_t*)handle; 58 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { 59 | size_t size = hnd->size; 60 | #if PMEM_HACK 61 | size += hnd->offset; 62 | #endif 63 | void* mappedAddress = mmap(0, size, 64 | PROT_READ|PROT_WRITE, MAP_SHARED, hnd->fd, 0); 65 | if (mappedAddress == MAP_FAILED) { 66 | LOGE("Could not mmap handle %p, fd=%d (%s)", 67 | handle, hnd->fd, strerror(errno)); 68 | hnd->base = 0; 69 | return -errno; 70 | } 71 | hnd->base = intptr_t(mappedAddress) + hnd->offset; 72 | //LOGD("gralloc_map() succeeded fd=%d, off=%d, size=%d, vaddr=%p", 73 | // hnd->fd, hnd->offset, hnd->size, mappedAddress); 74 | } 75 | *vaddr = (void*)hnd->base; 76 | return 0; 77 | } 78 | 79 | static int gralloc_unmap(gralloc_module_t const* module, 80 | buffer_handle_t handle) 81 | { 82 | private_handle_t* hnd = (private_handle_t*)handle; 83 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { 84 | void* base = (void*)hnd->base; 85 | size_t size = hnd->size; 86 | #if PMEM_HACK 87 | base = (void*)(intptr_t(base) - hnd->offset); 88 | size += hnd->offset; 89 | #endif 90 | //LOGD("unmapping from %p, size=%d, flags=%08x", base, size, hnd->flags); 91 | if (munmap(base, size) < 0) { 92 | LOGE("Could not unmap %s", strerror(errno)); 93 | } 94 | } 95 | hnd->base = 0; 96 | return 0; 97 | } 98 | 99 | /*****************************************************************************/ 100 | 101 | static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER; 102 | 103 | /*****************************************************************************/ 104 | 105 | int gralloc_register_buffer(gralloc_module_t const* module, 106 | buffer_handle_t handle) 107 | { 108 | if (private_handle_t::validate(handle) < 0) 109 | return -EINVAL; 110 | 111 | // if this handle was created in this process, then we keep it as is. 112 | int err = 0; 113 | private_handle_t* hnd = (private_handle_t*)handle; 114 | if (hnd->pid != getpid()) { 115 | hnd->base = NULL; 116 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_USES_GPU)) { 117 | void *vaddr; 118 | err = gralloc_map(module, handle, &vaddr); 119 | } 120 | } 121 | return err; 122 | } 123 | 124 | int gralloc_unregister_buffer(gralloc_module_t const* module, 125 | buffer_handle_t handle) 126 | { 127 | if (private_handle_t::validate(handle) < 0) 128 | return -EINVAL; 129 | 130 | // never unmap buffers that were created in this process 131 | private_handle_t* hnd = (private_handle_t*)handle; 132 | if (hnd->pid != getpid()) { 133 | if (hnd->base) { 134 | gralloc_unmap(module, handle); 135 | } 136 | } 137 | return 0; 138 | } 139 | 140 | int mapBuffer(gralloc_module_t const* module, 141 | private_handle_t* hnd) 142 | { 143 | void* vaddr; 144 | return gralloc_map(module, hnd, &vaddr); 145 | } 146 | 147 | int terminateBuffer(gralloc_module_t const* module, 148 | private_handle_t* hnd) 149 | { 150 | if (hnd->base) { 151 | // this buffer was mapped, unmap it now 152 | if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_PMEM) { 153 | if (hnd->pid != getpid()) { 154 | // ... unless it's a "master" pmem buffer, that is a buffer 155 | // mapped in the process it's been allocated. 156 | // (see gralloc_alloc_buffer()) 157 | gralloc_unmap(module, hnd); 158 | } 159 | } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_GPU) { 160 | // XXX: for now do nothing here 161 | } else { 162 | gralloc_unmap(module, hnd); 163 | } 164 | } 165 | 166 | return 0; 167 | } 168 | 169 | int gralloc_lock(gralloc_module_t const* module, 170 | buffer_handle_t handle, int usage, 171 | int l, int t, int w, int h, 172 | void** vaddr) 173 | { 174 | // this is called when a buffer is being locked for software 175 | // access. in thin implementation we have nothing to do since 176 | // not synchronization with the h/w is needed. 177 | // typically this is used to wait for the h/w to finish with 178 | // this buffer if relevant. the data cache may need to be 179 | // flushed or invalidated depending on the usage bits and the 180 | // hardware. 181 | 182 | if (private_handle_t::validate(handle) < 0) 183 | return -EINVAL; 184 | 185 | private_handle_t* hnd = (private_handle_t*)handle; 186 | *vaddr = (void*)hnd->base; 187 | return 0; 188 | } 189 | 190 | int gralloc_unlock(gralloc_module_t const* module, 191 | buffer_handle_t handle) 192 | { 193 | // we're done with a software buffer. nothing to do in this 194 | // implementation. typically this is used to flush the data cache. 195 | 196 | if (private_handle_t::validate(handle) < 0) 197 | return -EINVAL; 198 | return 0; 199 | } 200 | 201 | 202 | /*****************************************************************************/ 203 | 204 | int gralloc_perform(struct gralloc_module_t const* module, 205 | int operation, ... ) 206 | { 207 | int res = -EINVAL; 208 | va_list args; 209 | va_start(args, operation); 210 | 211 | switch (operation) { 212 | case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: { 213 | int fd = va_arg(args, int); 214 | size_t size = va_arg(args, size_t); 215 | size_t offset = va_arg(args, size_t); 216 | void* base = va_arg(args, void*); 217 | 218 | // validate that it's indeed a pmem buffer 219 | pmem_region region; 220 | if (ioctl(fd, PMEM_GET_SIZE, ®ion) < 0) { 221 | break; 222 | } 223 | 224 | native_handle_t** handle = va_arg(args, native_handle_t**); 225 | private_handle_t* hnd = (private_handle_t*)native_handle_create( 226 | private_handle_t::sNumFds, private_handle_t::sNumInts); 227 | hnd->magic = private_handle_t::sMagic; 228 | hnd->fd = fd; 229 | hnd->flags = private_handle_t::PRIV_FLAGS_USES_PMEM; 230 | hnd->size = size; 231 | hnd->offset = offset; 232 | hnd->base = intptr_t(base) + offset; 233 | *handle = (native_handle_t *)hnd; 234 | res = 0; 235 | break; 236 | } 237 | } 238 | 239 | va_end(args); 240 | return res; 241 | } 242 | -------------------------------------------------------------------------------- /libgralloc-qsd8k/pmemalloc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //#define LOG_NDEBUG 0 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "gralloc_priv.h" 32 | #include "pmemalloc.h" 33 | 34 | 35 | #define BEGIN_FUNC LOGV("%s begin", __PRETTY_FUNCTION__) 36 | #define END_FUNC LOGV("%s end", __PRETTY_FUNCTION__) 37 | 38 | 39 | static int get_open_flags(int usage) { 40 | int openFlags = O_RDWR | O_SYNC; 41 | uint32_t uread = usage & GRALLOC_USAGE_SW_READ_MASK; 42 | uint32_t uwrite = usage & GRALLOC_USAGE_SW_WRITE_MASK; 43 | if (uread == GRALLOC_USAGE_SW_READ_OFTEN || 44 | uwrite == GRALLOC_USAGE_SW_WRITE_OFTEN) { 45 | openFlags &= ~O_SYNC; 46 | } 47 | return openFlags; 48 | } 49 | 50 | PmemAllocator::~PmemAllocator() 51 | { 52 | BEGIN_FUNC; 53 | END_FUNC; 54 | } 55 | 56 | 57 | PmemUserspaceAllocator::PmemUserspaceAllocator(Deps& deps, Deps::Allocator& allocator, const char* pmemdev): 58 | deps(deps), 59 | allocator(allocator), 60 | pmemdev(pmemdev), 61 | master_fd(MASTER_FD_INIT) 62 | { 63 | BEGIN_FUNC; 64 | pthread_mutex_init(&lock, NULL); 65 | END_FUNC; 66 | } 67 | 68 | 69 | PmemUserspaceAllocator::~PmemUserspaceAllocator() 70 | { 71 | BEGIN_FUNC; 72 | END_FUNC; 73 | } 74 | 75 | 76 | void* PmemUserspaceAllocator::get_base_address() { 77 | BEGIN_FUNC; 78 | END_FUNC; 79 | return master_base; 80 | } 81 | 82 | 83 | int PmemUserspaceAllocator::init_pmem_area_locked() 84 | { 85 | BEGIN_FUNC; 86 | int err = 0; 87 | int fd = deps.open(pmemdev, O_RDWR, 0); 88 | if (fd >= 0) { 89 | size_t size = 0; 90 | err = deps.getPmemTotalSize(fd, &size); 91 | if (err < 0) { 92 | LOGE("%s: PMEM_GET_TOTAL_SIZE failed (%d), limp mode", pmemdev, 93 | err); 94 | size = 8<<20; // 8 MiB 95 | } 96 | allocator.setSize(size); 97 | 98 | void* base = deps.mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 99 | 0); 100 | if (base == MAP_FAILED) { 101 | LOGE("%s: failed to map pmem master fd: %s", pmemdev, 102 | strerror(deps.getErrno())); 103 | err = -deps.getErrno(); 104 | base = 0; 105 | deps.close(fd); 106 | fd = -1; 107 | } else { 108 | master_fd = fd; 109 | master_base = base; 110 | } 111 | } else { 112 | LOGE("%s: failed to open pmem device: %s", pmemdev, 113 | strerror(deps.getErrno())); 114 | err = -deps.getErrno(); 115 | } 116 | END_FUNC; 117 | return err; 118 | } 119 | 120 | 121 | int PmemUserspaceAllocator::init_pmem_area() 122 | { 123 | BEGIN_FUNC; 124 | pthread_mutex_lock(&lock); 125 | int err = master_fd; 126 | if (err == MASTER_FD_INIT) { 127 | // first time, try to initialize pmem 128 | err = init_pmem_area_locked(); 129 | if (err) { 130 | LOGE("%s: failed to initialize pmem area", pmemdev); 131 | master_fd = err; 132 | } 133 | } else if (err < 0) { 134 | // pmem couldn't be initialized, never use it 135 | } else { 136 | // pmem OK 137 | err = 0; 138 | } 139 | pthread_mutex_unlock(&lock); 140 | END_FUNC; 141 | return err; 142 | } 143 | 144 | 145 | int PmemUserspaceAllocator::alloc_pmem_buffer(size_t size, int usage, 146 | void** pBase, int* pOffset, int* pFd) 147 | { 148 | BEGIN_FUNC; 149 | int err = init_pmem_area(); 150 | if (err == 0) { 151 | void* base = master_base; 152 | int offset = allocator.allocate(size); 153 | if (offset < 0) { 154 | // no more pmem memory 155 | LOGE("%s: no more pmem available", pmemdev); 156 | err = -ENOMEM; 157 | } else { 158 | int openFlags = get_open_flags(usage); 159 | 160 | //LOGD("%s: allocating pmem at offset 0x%p", pmemdev, offset); 161 | 162 | // now create the "sub-heap" 163 | int fd = deps.open(pmemdev, openFlags, 0); 164 | err = fd < 0 ? fd : 0; 165 | 166 | // and connect to it 167 | if (err == 0) 168 | err = deps.connectPmem(fd, master_fd); 169 | 170 | // and make it available to the client process 171 | if (err == 0) 172 | err = deps.mapPmem(fd, offset, size); 173 | 174 | if (err < 0) { 175 | LOGE("%s: failed to initialize pmem sub-heap: %d", pmemdev, 176 | err); 177 | err = -deps.getErrno(); 178 | deps.close(fd); 179 | allocator.deallocate(offset); 180 | fd = -1; 181 | } else { 182 | LOGV("%s: mapped fd %d at offset %d, size %d", pmemdev, fd, offset, size); 183 | memset((char*)base + offset, 0, size); 184 | *pBase = base; 185 | *pOffset = offset; 186 | *pFd = fd; 187 | } 188 | //LOGD_IF(!err, "%s: allocating pmem size=%d, offset=%d", pmemdev, size, offset); 189 | } 190 | } 191 | END_FUNC; 192 | return err; 193 | } 194 | 195 | 196 | int PmemUserspaceAllocator::free_pmem_buffer(size_t size, void* base, int offset, int fd) 197 | { 198 | BEGIN_FUNC; 199 | int err = 0; 200 | if (fd >= 0) { 201 | int err = deps.unmapPmem(fd, offset, size); 202 | LOGE_IF(err<0, "PMEM_UNMAP failed (%s), fd=%d, sub.offset=%u, " 203 | "sub.size=%u", strerror(deps.getErrno()), fd, offset, size); 204 | if (err == 0) { 205 | // we can't deallocate the memory in case of UNMAP failure 206 | // because it would give that process access to someone else's 207 | // surfaces, which would be a security breach. 208 | allocator.deallocate(offset); 209 | } 210 | } 211 | END_FUNC; 212 | return err; 213 | } 214 | 215 | PmemUserspaceAllocator::Deps::Allocator::~Allocator() 216 | { 217 | BEGIN_FUNC; 218 | END_FUNC; 219 | } 220 | 221 | PmemUserspaceAllocator::Deps::~Deps() 222 | { 223 | BEGIN_FUNC; 224 | END_FUNC; 225 | } 226 | 227 | PmemKernelAllocator::PmemKernelAllocator(Deps& deps, const char* pmemdev): 228 | deps(deps), 229 | pmemdev(pmemdev) 230 | { 231 | BEGIN_FUNC; 232 | END_FUNC; 233 | } 234 | 235 | 236 | PmemKernelAllocator::~PmemKernelAllocator() 237 | { 238 | BEGIN_FUNC; 239 | END_FUNC; 240 | } 241 | 242 | 243 | void* PmemKernelAllocator::get_base_address() { 244 | BEGIN_FUNC; 245 | END_FUNC; 246 | return 0; 247 | } 248 | 249 | 250 | static unsigned clp2(unsigned x) { 251 | x = x - 1; 252 | x = x | (x >> 1); 253 | x = x | (x >> 2); 254 | x = x | (x >> 4); 255 | x = x | (x >> 8); 256 | x = x | (x >>16); 257 | return x + 1; 258 | } 259 | 260 | 261 | int PmemKernelAllocator::alloc_pmem_buffer(size_t size, int usage, 262 | void** pBase,int* pOffset, int* pFd) 263 | { 264 | BEGIN_FUNC; 265 | 266 | *pBase = 0; 267 | *pOffset = 0; 268 | *pFd = -1; 269 | 270 | int err; 271 | int openFlags = get_open_flags(usage); 272 | int fd = deps.open(pmemdev, openFlags, 0); 273 | if (fd < 0) { 274 | err = -deps.getErrno(); 275 | END_FUNC; 276 | return err; 277 | } 278 | 279 | // The size should already be page aligned, now round it up to a power of 2. 280 | size = clp2(size); 281 | 282 | void* base = deps.mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 283 | if (base == MAP_FAILED) { 284 | LOGE("%s: failed to map pmem fd: %s", pmemdev, 285 | strerror(deps.getErrno())); 286 | err = -deps.getErrno(); 287 | deps.close(fd); 288 | END_FUNC; 289 | return err; 290 | } 291 | 292 | memset(base, 0, size); 293 | 294 | *pBase = base; 295 | *pOffset = 0; 296 | *pFd = fd; 297 | 298 | END_FUNC; 299 | return 0; 300 | } 301 | 302 | 303 | int PmemKernelAllocator::free_pmem_buffer(size_t size, void* base, int offset, int fd) 304 | { 305 | BEGIN_FUNC; 306 | // The size should already be page aligned, now round it up to a power of 2 307 | // like we did when allocating. 308 | size = clp2(size); 309 | 310 | int err = deps.munmap(base, size); 311 | if (err < 0) { 312 | err = deps.getErrno(); 313 | LOGW("%s: error unmapping pmem fd: %s", pmemdev, strerror(err)); 314 | return -err; 315 | } 316 | END_FUNC; 317 | return 0; 318 | } 319 | 320 | PmemKernelAllocator::Deps::~Deps() 321 | { 322 | BEGIN_FUNC; 323 | END_FUNC; 324 | } 325 | -------------------------------------------------------------------------------- /libaudio-qdsp5v2/AudioHardware.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008, The Android Open-Source Project 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | //#define LOG_NDEBUG 0 20 | #define LOG_TAG "AudioHardware" 21 | 22 | #include 23 | #include 24 | //#include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "AudioHardware.h" 35 | #include 36 | 37 | extern "C" { 38 | #include "msm_audio.h" 39 | } 40 | 41 | 42 | namespace android { 43 | // ---------------------------------------------------------------------------- 44 | 45 | AudioHardware::AudioHardware() : 46 | mInit(false), mMicMute(true), mOutput(0) 47 | { 48 | mInit = true; 49 | } 50 | 51 | AudioHardware::~AudioHardware() 52 | { 53 | closeOutputStream((AudioStreamOut*)mOutput); 54 | mInit = false; 55 | } 56 | 57 | status_t AudioHardware::initCheck() 58 | { 59 | return mInit ? NO_ERROR : NO_INIT; 60 | } 61 | 62 | AudioStreamOut* AudioHardware::openOutputStream( 63 | uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status) 64 | { 65 | { // scope for the lock 66 | Mutex::Autolock lock(mLock); 67 | 68 | // only one output stream allowed 69 | if (mOutput) { 70 | if (status) { 71 | *status = INVALID_OPERATION; 72 | } 73 | return 0; 74 | } 75 | 76 | AudioStreamOutQ5V2* out = new AudioStreamOutQ5V2(); 77 | 78 | status_t rc = out->set(this, devices, format, channels, sampleRate); 79 | if (rc) { 80 | *status = rc; 81 | } 82 | if (rc == NO_ERROR) { 83 | mOutput = out; 84 | } else { 85 | delete out; 86 | } 87 | } 88 | return mOutput; 89 | } 90 | 91 | void AudioHardware::closeOutputStream(AudioStreamOut* out) { 92 | Mutex::Autolock lock(mLock); 93 | if (mOutput == 0 || mOutput != out) { 94 | LOGW("Attempt to close invalid output stream"); 95 | } 96 | else { 97 | delete mOutput; 98 | mOutput = 0; 99 | } 100 | } 101 | 102 | AudioStreamIn* AudioHardware::openInputStream( 103 | uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status, 104 | AudioSystem::audio_in_acoustics acoustic_flags) 105 | { 106 | return 0; 107 | } 108 | 109 | void AudioHardware::closeInputStream(AudioStreamIn* in) { 110 | } 111 | 112 | status_t AudioHardware::setMode(int mode) 113 | { 114 | return NO_ERROR; 115 | } 116 | 117 | status_t AudioHardware::setMicMute(bool state) 118 | { 119 | return NO_ERROR; 120 | } 121 | 122 | status_t AudioHardware::getMicMute(bool* state) 123 | { 124 | *state = mMicMute; 125 | return NO_ERROR; 126 | } 127 | 128 | status_t AudioHardware::setParameters(const String8& keyValuePairs) 129 | { 130 | return NO_ERROR; 131 | } 132 | 133 | String8 AudioHardware::getParameters(const String8& keys) 134 | { 135 | AudioParameter request = AudioParameter(keys); 136 | AudioParameter reply = AudioParameter(); 137 | 138 | LOGV("getParameters() %s", keys.string()); 139 | 140 | return reply.toString(); 141 | } 142 | 143 | size_t AudioHardware::getInputBufferSize(uint32_t sampleRate, int format, int channelCount) 144 | { 145 | return 4096; 146 | } 147 | 148 | status_t AudioHardware::setVoiceVolume(float v) 149 | { 150 | return NO_ERROR; 151 | } 152 | 153 | status_t AudioHardware::setMasterVolume(float v) 154 | { 155 | LOGI("Set master volume to %f.\n", v); 156 | // We return an error code here to let the audioflinger do in-software 157 | // volume on top of the maximum volume that we set through the SND API. 158 | // return error - software mixer will handle it 159 | return -1; 160 | } 161 | 162 | status_t AudioHardware::dump(int fd, const Vector& args) 163 | { 164 | return NO_ERROR; 165 | } 166 | 167 | AudioHardware::AudioStreamOutQ5V2::AudioStreamOutQ5V2() : 168 | mHardware(0), mFd(-1), mStartCount(0), mRetryCount(0), mStandby(true), 169 | mDevices(0), mChannels(AUDIO_HW_OUT_CHANNELS), mSampleRate(AUDIO_HW_OUT_SAMPLERATE), 170 | mBufferSize(AUDIO_HW_OUT_BUFSZ) 171 | { 172 | } 173 | 174 | status_t AudioHardware::AudioStreamOutQ5V2::set( 175 | AudioHardware* hw, uint32_t devices, int *pFormat, uint32_t *pChannels, uint32_t *pRate) 176 | { 177 | int lFormat = pFormat ? *pFormat : 0; 178 | uint32_t lChannels = pChannels ? *pChannels : 0; 179 | uint32_t lRate = pRate ? *pRate : 0; 180 | 181 | mHardware = hw; 182 | mDevices = devices; 183 | 184 | // fix up defaults 185 | if (lFormat == 0) lFormat = format(); 186 | if (lChannels == 0) lChannels = channels(); 187 | if (lRate == 0) lRate = sampleRate(); 188 | 189 | // check values 190 | if ((lFormat != format()) || 191 | (lChannels != channels()) || 192 | (lRate != sampleRate())) { 193 | if (pFormat) *pFormat = format(); 194 | if (pChannels) *pChannels = channels(); 195 | if (pRate) *pRate = sampleRate(); 196 | return BAD_VALUE; 197 | } 198 | 199 | if (pFormat) *pFormat = lFormat; 200 | if (pChannels) *pChannels = lChannels; 201 | if (pRate) *pRate = lRate; 202 | 203 | mChannels = lChannels; 204 | mSampleRate = lRate; 205 | mBufferSize = 4096; 206 | 207 | return NO_ERROR; 208 | } 209 | 210 | AudioHardware::AudioStreamOutQ5V2::~AudioStreamOutQ5V2() 211 | { 212 | standby(); 213 | } 214 | 215 | ssize_t AudioHardware::AudioStreamOutQ5V2::write(const void* buffer, size_t bytes) 216 | { 217 | // LOGD("AudioStreamOutQ5V2::write(%p, %u)", buffer, bytes); 218 | status_t status = NO_INIT; 219 | size_t count = bytes; 220 | const uint8_t* p = static_cast(buffer); 221 | 222 | if (mStandby) { 223 | LOGV("open pcm_out driver"); 224 | status = ::open("/dev/msm_pcm_out", O_RDWR); 225 | if (status < 0) { 226 | LOGE("Cannot open /dev/msm_pcm_out errno: %d", errno); 227 | goto Error; 228 | } 229 | mFd = status; 230 | 231 | // configuration 232 | LOGV("get config"); 233 | struct msm_audio_config config; 234 | status = ioctl(mFd, AUDIO_GET_CONFIG, &config); 235 | if (status < 0) { 236 | LOGE("Cannot read pcm_out config"); 237 | goto Error; 238 | } 239 | 240 | LOGV("set pcm_out config"); 241 | config.channel_count = AudioSystem::popCount(channels()); 242 | config.sample_rate = mSampleRate; 243 | config.buffer_size = mBufferSize; 244 | config.buffer_count = AUDIO_HW_NUM_OUT_BUF; 245 | // config.codec_type = CODEC_TYPE_PCM; 246 | status = ioctl(mFd, AUDIO_SET_CONFIG, &config); 247 | if (status < 0) { 248 | LOGE("Cannot set config"); 249 | goto Error; 250 | } 251 | 252 | LOGV("buffer_size: %u", config.buffer_size); 253 | LOGV("buffer_count: %u", config.buffer_count); 254 | LOGV("channel_count: %u", config.channel_count); 255 | LOGV("sample_rate: %u", config.sample_rate); 256 | 257 | #if 0 258 | status = ioctl(mFd, AUDIO_START, &acdb_id); 259 | if (status < 0) { 260 | LOGE("Cannot start pcm playback"); 261 | goto Error; 262 | } 263 | 264 | status = ioctl(mFd, AUDIO_SET_VOLUME, &stream_volume); 265 | if (status < 0) { 266 | LOGE("Cannot start pcm playback"); 267 | goto Error; 268 | } 269 | #endif 270 | mStandby = false; 271 | } 272 | 273 | while (count) { 274 | ssize_t written = ::write(mFd, p, count); 275 | if (written >= 0) { 276 | count -= written; 277 | p += written; 278 | } else { 279 | if (errno != EAGAIN) return written; 280 | mRetryCount++; 281 | LOGW("EAGAIN - retry"); 282 | } 283 | } 284 | 285 | return bytes; 286 | 287 | Error: 288 | if (mFd >= 0) { 289 | ::close(mFd); 290 | mFd = -1; 291 | } 292 | // Simulate audio output timing in case of error 293 | usleep(bytes * 1000000 / frameSize() / sampleRate()); 294 | 295 | return status; 296 | } 297 | 298 | status_t AudioHardware::AudioStreamOutQ5V2::standby() 299 | { 300 | status_t status = NO_ERROR; 301 | if (!mStandby && mFd >= 0) { 302 | ::close(mFd); 303 | mFd = -1; 304 | } 305 | mStandby = true; 306 | LOGI("AudioHardware pcm playback is going to standby."); 307 | return status; 308 | } 309 | 310 | status_t AudioHardware::AudioStreamOutQ5V2::dump(int fd, const Vector& args) 311 | { 312 | return NO_ERROR; 313 | } 314 | 315 | bool AudioHardware::AudioStreamOutQ5V2::checkStandby() 316 | { 317 | return mStandby; 318 | } 319 | 320 | status_t AudioHardware::AudioStreamOutQ5V2::setParameters(const String8& keyValuePairs) 321 | { 322 | return NO_ERROR; 323 | } 324 | 325 | String8 AudioHardware::AudioStreamOutQ5V2::getParameters(const String8& keys) 326 | { 327 | AudioParameter param = AudioParameter(keys); 328 | LOGV("AudioStreamOutQ5V2::getParameters() %s", param.toString().string()); 329 | return param.toString(); 330 | } 331 | 332 | status_t AudioHardware::AudioStreamOutQ5V2::getRenderPosition(uint32_t *dspFrames) 333 | { 334 | return INVALID_OPERATION; 335 | } 336 | 337 | extern "C" AudioHardwareInterface* createAudioHardware(void) { 338 | return new AudioHardware(); 339 | } 340 | 341 | }; // namespace android 342 | -------------------------------------------------------------------------------- /libcamera/QualcommCameraHardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008, The Android Open-Source Project 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_HARDWARE_QUALCOMM_CAMERA_HARDWARE_H 18 | #define ANDROID_HARDWARE_QUALCOMM_CAMERA_HARDWARE_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | extern "C" { 25 | #include 26 | } 27 | 28 | namespace android { 29 | 30 | class QualcommCameraHardware : public CameraHardwareInterface { 31 | public: 32 | 33 | virtual sp getPreviewHeap() const; 34 | virtual sp getRawHeap() const; 35 | 36 | virtual status_t dump(int fd, const Vector& args) const; 37 | virtual status_t startPreview(preview_callback cb, void* user); 38 | virtual void stopPreview(); 39 | virtual bool previewEnabled(); 40 | virtual status_t startRecording(recording_callback cb, void* user); 41 | virtual void stopRecording(); 42 | virtual bool recordingEnabled(); 43 | virtual void releaseRecordingFrame(const sp& mem); 44 | virtual status_t autoFocus(autofocus_callback, void *user); 45 | virtual status_t takePicture(shutter_callback, 46 | raw_callback, 47 | jpeg_callback, 48 | void* user); 49 | virtual status_t cancelPicture(bool cancel_shutter, 50 | bool cancel_raw, bool cancel_jpeg); 51 | virtual status_t setParameters(const CameraParameters& params); 52 | virtual CameraParameters getParameters() const; 53 | 54 | virtual void release(); 55 | 56 | static sp createInstance(); 57 | static sp getInstance(); 58 | 59 | void* get_preview_mem(uint32_t size, uint32_t *phy_addr, uint32_t index); 60 | void* get_raw_mem(uint32_t size, uint32_t *phy_addr, uint32_t index); 61 | void free_preview_mem(uint32_t *phy_addr, uint32_t size, uint32_t index); 62 | void free_raw_mem(uint32_t *phy_addr, uint32_t size, uint32_t index); 63 | 64 | private: 65 | 66 | QualcommCameraHardware(); 67 | virtual ~QualcommCameraHardware(); 68 | status_t startPreviewInternal(preview_callback pcb, void *puser, 69 | recording_callback rcb, void *ruser); 70 | void stopPreviewInternal(); 71 | 72 | static wp singleton; 73 | 74 | /* These constants reflect the number of buffers that libqcamera requires 75 | for preview and raw, and need to be updated when libqcamera 76 | changes. 77 | */ 78 | static const int kPreviewBufferCount = 4; 79 | static const int kRawBufferCount = 1; 80 | static const int kJpegBufferCount = 1; 81 | static const int kRawFrameHeaderSize = 0x48; 82 | 83 | //TODO: put the picture dimensions in the CameraParameters object; 84 | CameraParameters mParameters; 85 | int mPreviewHeight; 86 | int mPreviewWidth; 87 | int mRawHeight; 88 | int mRawWidth; 89 | 90 | void receivePreviewFrame(camera_frame_type *frame); 91 | 92 | static void stop_camera_cb(camera_cb_type cb, 93 | const void *client_data, 94 | camera_func_type func, 95 | int32_t parm4); 96 | 97 | static void camera_cb(camera_cb_type cb, 98 | const void *client_data, 99 | camera_func_type func, 100 | int32_t parm4); 101 | 102 | // This class represents a heap which maintains several contiguous 103 | // buffers. The heap may be backed by pmem (when pmem_pool contains 104 | // the name of a /dev/pmem* file), or by ashmem (when pmem_pool == NULL). 105 | 106 | struct MemPool : public RefBase { 107 | MemPool(int buffer_size, int num_buffers, 108 | int frame_size, 109 | int frame_offset, 110 | const char *name); 111 | 112 | virtual ~MemPool() = 0; 113 | 114 | void completeInitialization(); 115 | bool initialized() const { 116 | return mHeap != NULL && mHeap->base() != MAP_FAILED; 117 | } 118 | 119 | virtual status_t dump(int fd, const Vector& args) const; 120 | 121 | int mBufferSize; 122 | int mNumBuffers; 123 | int mFrameSize; 124 | int mFrameOffset; 125 | sp mHeap; 126 | sp *mBuffers; 127 | 128 | const char *mName; 129 | }; 130 | 131 | struct AshmemPool : public MemPool { 132 | AshmemPool(int buffer_size, int num_buffers, 133 | int frame_size, 134 | int frame_offset, 135 | const char *name); 136 | }; 137 | 138 | struct PmemPool : public MemPool { 139 | PmemPool(const char *pmem_pool, 140 | int buffer_size, int num_buffers, 141 | int frame_size, 142 | int frame_offset, 143 | const char *name); 144 | virtual ~PmemPool() { } 145 | int mFd; 146 | uint32_t mAlignedSize; 147 | struct pmem_region mSize; 148 | }; 149 | 150 | struct PreviewPmemPool : public PmemPool { 151 | virtual ~PreviewPmemPool(); 152 | PreviewPmemPool(int buffer_size, int num_buffers, 153 | int frame_size, 154 | int frame_offset, 155 | const char *name); 156 | }; 157 | 158 | struct RawPmemPool : public PmemPool { 159 | virtual ~RawPmemPool(); 160 | RawPmemPool(const char *pmem_pool, 161 | int buffer_size, int num_buffers, 162 | int frame_size, 163 | int frame_offset, 164 | const char *name); 165 | }; 166 | 167 | sp mPreviewHeap; 168 | sp mRawHeap; 169 | sp mJpegHeap; 170 | 171 | void startCameraIfNecessary(); 172 | bool initPreview(); 173 | void deinitPreview(); 174 | bool initRaw(bool initJpegHeap); 175 | 176 | void initDefaultParameters(); 177 | void initCameraParameters(); 178 | void setCameraDimensions(); 179 | 180 | // The states described by qualcomm_camera_state are very similar to the 181 | // CAMERA_FUNC_xxx notifications reported by libqcamera. The differences 182 | // are that they reflect not only the response from libqcamera, but also 183 | // the requests made by the clients of this object. For example, 184 | // QCS_PREVIEW_REQUESTED is a state that we enter when we call 185 | // QualcommCameraHardware::startPreview(), and stay in until libqcamera 186 | // confirms that it has received the start-preview command (but not 187 | // actually initiated preview yet). 188 | // 189 | // NOTE: keep those values small; they are used internally as indices 190 | // into a array of strings. 191 | // NOTE: if you add to this enumeration, make sure you update 192 | // getCameraStateStr(). 193 | 194 | enum qualcomm_camera_state { 195 | QCS_INIT, 196 | QCS_IDLE, 197 | QCS_ERROR, 198 | QCS_PREVIEW_IN_PROGRESS, 199 | QCS_WAITING_RAW, 200 | QCS_WAITING_JPEG, 201 | /* internal states */ 202 | QCS_INTERNAL_PREVIEW_STOPPING, 203 | QCS_INTERNAL_PREVIEW_REQUESTED, 204 | QCS_INTERNAL_RAW_REQUESTED, 205 | QCS_INTERNAL_STOPPING, 206 | }; 207 | 208 | volatile qualcomm_camera_state mCameraState; 209 | static const char* const getCameraStateStr(qualcomm_camera_state s); 210 | qualcomm_camera_state change_state(qualcomm_camera_state new_state, 211 | bool lock = true); 212 | 213 | void notifyShutter(); 214 | void receiveJpegPictureFragment(JPEGENC_CBrtnType *encInfo); 215 | 216 | void receivePostLpmRawPicture(camera_frame_type *frame); 217 | void receiveRawPicture(camera_frame_type *frame); 218 | void receiveJpegPicture(void); 219 | 220 | Mutex mLock; // API lock -- all public methods 221 | Mutex mCallbackLock; 222 | Mutex mStateLock; 223 | Condition mStateWait; 224 | 225 | /* mJpegSize keeps track of the size of the accumulated JPEG. We clear it 226 | when we are about to take a picture, so at any time it contains either 227 | zero, or the size of the last JPEG picture taken. 228 | */ 229 | uint32_t mJpegSize; 230 | camera_handle_type camera_handle; 231 | camera_encode_properties_type encode_properties; 232 | camera_position_type pt; 233 | 234 | shutter_callback mShutterCallback; 235 | raw_callback mRawPictureCallback; 236 | jpeg_callback mJpegPictureCallback; 237 | void *mPictureCallbackCookie; 238 | 239 | autofocus_callback mAutoFocusCallback; 240 | void *mAutoFocusCallbackCookie; 241 | 242 | preview_callback mPreviewCallback; 243 | void *mPreviewCallbackCookie; 244 | recording_callback mRecordingCallback; 245 | void *mRecordingCallbackCookie; 246 | bool setCallbacks(preview_callback pcb, void *pu, 247 | recording_callback rcb, void *ru); 248 | 249 | int mPreviewFrameSize; 250 | int mRawSize; 251 | int mJpegMaxSize; 252 | 253 | // hack to prevent black frame on first preview 254 | int mPreviewCount; 255 | 256 | #if DLOPEN_LIBQCAMERA == 1 257 | void *libqcamera; 258 | #endif 259 | }; 260 | 261 | }; // namespace android 262 | 263 | #endif 264 | 265 | 266 | -------------------------------------------------------------------------------- /libopencorehw/android_surface_output_msm72xx.cpp: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------ 2 | * Copyright (C) 2009 Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 | * express or implied. 14 | * See the License for the specific language governing permissions 15 | * and limitations under the License. 16 | * ------------------------------------------------------------------- 17 | */ 18 | 19 | //#define LOG_NDEBUG 0 20 | #define LOG_TAG "VideoMio72xx" 21 | #include 22 | 23 | #include "android_surface_output_msm72xx.h" 24 | #include 25 | 26 | #define PLATFORM_PRIVATE_PMEM 1 27 | 28 | #if HAVE_ANDROID_OS 29 | #include 30 | #endif 31 | 32 | using namespace android; 33 | 34 | static const char* pmem_adsp = "/dev/pmem_adsp"; 35 | static const char* pmem = "/dev/pmem"; 36 | 37 | OSCL_EXPORT_REF AndroidSurfaceOutputMsm72xx::AndroidSurfaceOutputMsm72xx() : 38 | AndroidSurfaceOutput() 39 | { 40 | mHardwareCodec = false; 41 | } 42 | 43 | OSCL_EXPORT_REF AndroidSurfaceOutputMsm72xx::~AndroidSurfaceOutputMsm72xx() 44 | { 45 | } 46 | 47 | // create a frame buffer for software codecs 48 | OSCL_EXPORT_REF bool AndroidSurfaceOutputMsm72xx::initCheck() 49 | { 50 | 51 | // initialize only when we have all the required parameters 52 | if (((iVideoParameterFlags & VIDEO_SUBFORMAT_VALID) == 0) || !checkVideoParameterFlags()) 53 | return mInitialized; 54 | 55 | // release resources if previously initialized 56 | closeFrameBuf(); 57 | 58 | // reset flags in case display format changes in the middle of a stream 59 | resetVideoParameterFlags(); 60 | 61 | // copy parameters in case we need to adjust them 62 | int displayWidth = iVideoDisplayWidth; 63 | int displayHeight = iVideoDisplayHeight; 64 | int frameWidth = iVideoWidth; 65 | int frameHeight = iVideoHeight; 66 | int frameSize; 67 | 68 | // MSM72xx hardware codec uses semi-planar format 69 | if (iVideoSubFormat == PVMF_MIME_YUV420_SEMIPLANAR_YVU) { 70 | LOGV("using hardware codec"); 71 | mHardwareCodec = true; 72 | // Workaround for tearing from SF 73 | // But please make sure that the number of unique output 74 | // buffers are more than 2; otherwise, the video playback 75 | // will freeze due to starvation. 76 | mNumberOfFramesToHold = 2; 77 | } else { 78 | LOGV("using software codec"); 79 | 80 | // YUV420 frames are 1.5 bytes/pixel 81 | frameSize = (frameWidth * frameHeight * 3) / 2; 82 | 83 | // create frame buffer heap 84 | sp master = new MemoryHeapBase(pmem_adsp, frameSize * kBufferCount); 85 | if (master->heapID() < 0) { 86 | LOGE("Error creating frame buffer heap"); 87 | return false; 88 | } 89 | master->setDevice(pmem); 90 | sp heap = new MemoryHeapPmem(master, 0); 91 | heap->slap(); 92 | mBufferHeap = ISurface::BufferHeap(displayWidth, displayHeight, 93 | frameWidth, frameHeight, HAL_PIXEL_FORMAT_YCrCb_420_SP, heap); 94 | master.clear(); 95 | mSurface->registerBuffers(mBufferHeap); 96 | 97 | // create frame buffers 98 | for (int i = 0; i < kBufferCount; i++) { 99 | mFrameBuffers[i] = i * frameSize; 100 | } 101 | 102 | LOGV("video = %d x %d", displayWidth, displayHeight); 103 | LOGV("frame = %d x %d", frameWidth, frameHeight); 104 | LOGV("frame #bytes = %d", frameSize); 105 | 106 | // register frame buffers with SurfaceFlinger 107 | mFrameBufferIndex = 0; 108 | } 109 | 110 | mInitialized = true; 111 | LOGV("sendEvent(MEDIA_SET_VIDEO_SIZE, %d, %d)", iVideoDisplayWidth, iVideoDisplayHeight); 112 | mPvPlayer->sendEvent(MEDIA_SET_VIDEO_SIZE, iVideoDisplayWidth, iVideoDisplayHeight); 113 | return mInitialized; 114 | } 115 | 116 | PVMFStatus AndroidSurfaceOutputMsm72xx::writeFrameBuf(uint8* aData, uint32 aDataLen, const PvmiMediaXferHeader& data_header_info) 117 | { 118 | // OK to drop frames if no surface 119 | if (mSurface == 0) return PVMFSuccess; 120 | 121 | // hardware codec 122 | if (mHardwareCodec) { 123 | 124 | // initialize frame buffer heap 125 | if (mBufferHeap.heap == 0) { 126 | LOGV("initializing for hardware"); 127 | LOGV("private data pointer is 0%p\n", data_header_info.private_data_ptr); 128 | 129 | // check for correct video format 130 | if (iVideoSubFormat != PVMF_MIME_YUV420_SEMIPLANAR_YVU) return PVMFFailure; 131 | 132 | uint32 fd; 133 | if (!getPmemFd(data_header_info.private_data_ptr, &fd)) { 134 | LOGE("Error getting pmem heap from private_data_ptr"); 135 | return PVMFFailure; 136 | } 137 | 138 | // ugly hack to pass an sp as an int 139 | sp master = (MemoryHeapBase *) fd; 140 | master->setDevice(pmem); 141 | 142 | // create new reference 143 | uint32_t heap_flags = master->getFlags() & MemoryHeapBase::NO_CACHING; 144 | sp heap = new MemoryHeapPmem(master, heap_flags); 145 | heap->slap(); 146 | 147 | // register frame buffers with SurfaceFlinger 148 | mBufferHeap = ISurface::BufferHeap(iVideoDisplayWidth, iVideoDisplayHeight, 149 | iVideoWidth, iVideoHeight, HAL_PIXEL_FORMAT_YCrCb_420_SP, heap); 150 | master.clear(); 151 | mSurface->registerBuffers(mBufferHeap); 152 | } 153 | 154 | // get pmem offset and post to SurfaceFlinger 155 | if (!getOffset(data_header_info.private_data_ptr, &mOffset)) { 156 | LOGE("Error getting pmem offset from private_data_ptr"); 157 | return PVMFFailure; 158 | } 159 | mSurface->postBuffer(mOffset); 160 | } else { 161 | // software codec 162 | if (++mFrameBufferIndex == kBufferCount) mFrameBufferIndex = 0; 163 | convertFrame(aData, static_cast(mBufferHeap.heap->base()) + mFrameBuffers[mFrameBufferIndex], aDataLen); 164 | // post to SurfaceFlinger 165 | mSurface->postBuffer(mFrameBuffers[mFrameBufferIndex]); 166 | } 167 | 168 | return PVMFSuccess; 169 | } 170 | 171 | // post the last video frame to refresh screen after pause 172 | void AndroidSurfaceOutputMsm72xx::postLastFrame() 173 | { 174 | // ignore if no surface or heap 175 | if ((mSurface == NULL) || (mBufferHeap.heap == NULL)) return; 176 | 177 | if (mHardwareCodec) { 178 | mSurface->postBuffer(mOffset); 179 | } else { 180 | mSurface->postBuffer(mFrameBuffers[mFrameBufferIndex]); 181 | } 182 | } 183 | 184 | bool AndroidSurfaceOutputMsm72xx::getPmemFd(OsclAny *private_data_ptr, uint32 *pmemFD) 185 | { 186 | PLATFORM_PRIVATE_LIST *listPtr = NULL; 187 | PLATFORM_PRIVATE_PMEM_INFO *pmemInfoPtr = NULL; 188 | bool returnType = false; 189 | LOGV("in getPmemfd - privatedataptr=%p\n",private_data_ptr); 190 | listPtr = (PLATFORM_PRIVATE_LIST*) private_data_ptr; 191 | 192 | for (uint32 i=0;inEntries;i++) 193 | { 194 | if(listPtr->entryList->type == PLATFORM_PRIVATE_PMEM) 195 | { 196 | LOGV("in getPmemfd - entry type = %d\n",listPtr->entryList->type); 197 | pmemInfoPtr = (PLATFORM_PRIVATE_PMEM_INFO*) (listPtr->entryList->entry); 198 | returnType = true; 199 | if(pmemInfoPtr){ 200 | *pmemFD = pmemInfoPtr->pmem_fd; 201 | LOGV("in getPmemfd - pmemFD = %d\n",*pmemFD); 202 | } 203 | break; 204 | } 205 | } 206 | return returnType; 207 | } 208 | 209 | bool AndroidSurfaceOutputMsm72xx::getOffset(OsclAny *private_data_ptr, uint32 *offset) 210 | { 211 | PLATFORM_PRIVATE_LIST *listPtr = NULL; 212 | PLATFORM_PRIVATE_PMEM_INFO *pmemInfoPtr = NULL; 213 | bool returnType = false; 214 | 215 | listPtr = (PLATFORM_PRIVATE_LIST*) private_data_ptr; 216 | LOGV("in getOffset: listPtr = %p\n",listPtr); 217 | for (uint32 i=0;inEntries;i++) 218 | { 219 | if(listPtr->entryList->type == PLATFORM_PRIVATE_PMEM) 220 | { 221 | LOGV(" in getOffset: entrytype = %d\n",listPtr->entryList->type); 222 | 223 | pmemInfoPtr = (PLATFORM_PRIVATE_PMEM_INFO*) (listPtr->entryList->entry); 224 | returnType = true; 225 | if(pmemInfoPtr){ 226 | *offset = pmemInfoPtr->offset; 227 | LOGV("in getOffset: offset = %d\n",*offset); 228 | } 229 | break; 230 | } 231 | } 232 | return returnType; 233 | } 234 | 235 | static inline void* byteOffset(void* p, size_t offset) { return (void*)((uint8_t*)p + offset); } 236 | 237 | void AndroidSurfaceOutputMsm72xx::convertFrame(void* src, void* dst, size_t len) 238 | { 239 | // copy the Y plane 240 | size_t y_plane_size = iVideoWidth * iVideoHeight; 241 | //LOGV("len=%u, y_plane_size=%u", len, y_plane_size); 242 | memcpy(dst, src, y_plane_size + iVideoWidth); 243 | 244 | // re-arrange U's and V's 245 | uint16_t* pu = (uint16_t*)byteOffset(src, y_plane_size); 246 | uint16_t* pv = (uint16_t*)byteOffset(pu, y_plane_size / 4); 247 | uint32_t* p = (uint32_t*)byteOffset(dst, y_plane_size); 248 | 249 | int count = y_plane_size / 8; 250 | //LOGV("u = %p, v = %p, p = %p, count = %d", pu, pv, p, count); 251 | do { 252 | uint32_t u = *pu++; 253 | uint32_t v = *pv++; 254 | *p++ = ((u & 0xff) << 8) | ((u & 0xff00) << 16) | (v & 0xff) | ((v & 0xff00) << 8); 255 | } while (--count); 256 | } 257 | 258 | // factory function for playerdriver linkage 259 | extern "C" AndroidSurfaceOutputMsm72xx* createVideoMio() 260 | { 261 | return new AndroidSurfaceOutputMsm72xx(); 262 | } 263 | 264 | -------------------------------------------------------------------------------- /librpc/svc_clnt_common.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern int r_open(const char *router); 7 | extern void r_close(int handle); 8 | extern int r_read(int handle, char *buf, uint32 size); 9 | extern int r_write(int handle, const char *buf, uint32 size); 10 | extern int r_control(int handle, const uint32 cmd, void *arg); 11 | 12 | static void xdr_std_destroy(xdr_s_type *xdr) 13 | { 14 | /* whatever */ 15 | } 16 | 17 | static bool_t xdr_std_control(xdr_s_type *xdr, int request, void *info) 18 | { 19 | return r_control(xdr->fd, request, info); 20 | } 21 | 22 | static bool_t xdr_std_msg_done(xdr_s_type *xdr) 23 | { 24 | /* whatever */ 25 | return TRUE; 26 | } 27 | 28 | /* Outgoing message control functions */ 29 | static bool_t xdr_std_msg_start(xdr_s_type *xdr, 30 | rpc_msg_e_type rpc_msg_type) 31 | { 32 | 33 | /* xid is does not matter under our set of assumptions: that for a single 34 | * program/version channel, communication is synchronous. If several 35 | * processes attempt to call functions on a program, then the rpcrouter 36 | * driver will ensure that the calls are properly muxed, because the 37 | * processes will have separate PIDs, and the rpcrouter driver uses PIDs to 38 | * keep track of RPC transactions. For multiple threads in the same 39 | * process accessing the same program, we serialize access in clnt_call() 40 | * by locking a mutex around the RPC call. If threads in the same process 41 | * call into different programs, then there is no issue, again because of 42 | * the use of a mutex in clnt_call(). 43 | * 44 | * NOTE: This comment assumes that the only way we talk to the RPC router 45 | * from a client is by using clnt_call(), which is the case for all 46 | * client code generated by rpcgen(). 47 | * 48 | * NOTE: The RPC router driver will soon be able to open a separate device 49 | * file for each program/version channel. This will allow for 50 | * natural multiplexing among clients, as we won't have to rely on 51 | * the mutex for the case where different programs are being called 52 | * into by separate threads in the same process. When this happens, 53 | * we'll need to optimize the RPC library to add a separate mutex for 54 | * each program/version channel, which will require some sort of 55 | * registry. 56 | */ 57 | 58 | if (rpc_msg_type == RPC_MSG_CALL) xdr->xid++; 59 | 60 | /* We start writing into the outgoing-message buffer at index 32, because 61 | we need to write header information before we send the message. The 62 | header information includes the destination address and the pacmark 63 | header. 64 | */ 65 | xdr->out_next = (RPC_OFFSET+2)*sizeof(uint32); 66 | 67 | /* we write the pacmark header when we send the message. */ 68 | ((uint32 *)xdr->out_msg)[RPC_OFFSET] = htonl(xdr->xid); 69 | /* rpc call or reply? */ 70 | ((uint32 *)xdr->out_msg)[RPC_OFFSET+1] = htonl(rpc_msg_type); 71 | 72 | return TRUE; 73 | } 74 | 75 | static bool_t xdr_std_msg_abort(xdr_s_type *xdr) 76 | { 77 | /* dummy */ 78 | return TRUE; 79 | } 80 | 81 | /* Can be used to send both calls and replies. */ 82 | 83 | extern bool_t xdr_recv_reply_header(xdr_s_type *xdr, rpc_reply_header *reply); 84 | 85 | #include 86 | 87 | static bool_t xdr_std_msg_send(xdr_s_type *xdr) 88 | { 89 | /* Send the RPC packet. */ 90 | if (r_write(xdr->fd, (void *)xdr->out_msg, xdr->out_next) != 91 | xdr->out_next) 92 | return FALSE; 93 | 94 | return TRUE; 95 | } 96 | 97 | static bool_t xdr_std_read(xdr_s_type *xdr) 98 | { 99 | xdr->in_len = r_read(xdr->fd, (void *)xdr->in_msg, RPCROUTER_MSGSIZE_MAX); 100 | if (xdr->in_len < 0) return FALSE; 101 | 102 | if (xdr->in_len < (RPC_OFFSET+2)*4) { 103 | xdr->in_len = -1; 104 | return FALSE; 105 | } 106 | 107 | xdr->in_next = (RPC_OFFSET+2)*4; 108 | return TRUE; 109 | } 110 | 111 | /* Message data functions */ 112 | static bool_t xdr_std_send_uint32(xdr_s_type *xdr, const uint32 *value) 113 | { 114 | if (xdr->out_next >= RPCROUTER_MSGSIZE_MAX - 3) return FALSE; 115 | *(int32 *)(xdr->out_msg + xdr->out_next) = htonl(*value); 116 | xdr->out_next += 4; 117 | return TRUE; 118 | } 119 | 120 | static bool_t xdr_std_send_int8(xdr_s_type *xdr, const int8 *value) 121 | { 122 | uint32 val = *value; 123 | return xdr_std_send_uint32(xdr, &val); 124 | } 125 | 126 | static bool_t xdr_std_send_uint8(xdr_s_type *xdr, const uint8 *value) 127 | { 128 | uint32 val = *value; 129 | return xdr_std_send_uint32(xdr, &val); 130 | } 131 | 132 | static bool_t xdr_std_send_int16(xdr_s_type *xdr, const int16 *value) 133 | { 134 | uint32 val = *value; 135 | return xdr_std_send_uint32(xdr, &val); 136 | } 137 | 138 | static bool_t xdr_std_send_uint16(xdr_s_type *xdr, const uint16 *value) 139 | { 140 | uint32 val = *value; 141 | return xdr_std_send_uint32(xdr, &val); 142 | } 143 | 144 | static bool_t xdr_std_send_int32(xdr_s_type *xdr, const int32 *value) 145 | { 146 | return xdr_std_send_uint32(xdr, (uint32_t *)value); 147 | } 148 | 149 | static bool_t xdr_std_send_bytes(xdr_s_type *xdr, const uint8 *buf, 150 | uint32 len) 151 | { 152 | if (xdr->out_next + len > RPCROUTER_MSGSIZE_MAX) return FALSE; 153 | while(len--) 154 | xdr->out_msg[xdr->out_next++] = *buf++; 155 | while(xdr->out_next % 4) 156 | xdr->out_msg[xdr->out_next++] = 0; 157 | return TRUE; 158 | } 159 | 160 | #if 0 161 | #include 162 | typedef struct 163 | { 164 | size_t count; 165 | intptr_t* addrs; 166 | } stack_crawl_state_t; 167 | 168 | static _Unwind_Reason_Code trace_function(_Unwind_Context *context, void *arg) 169 | { 170 | stack_crawl_state_t* state = (stack_crawl_state_t*)arg; 171 | if (state->count) { 172 | intptr_t ip = (intptr_t)_Unwind_GetIP(context); 173 | if (ip) { 174 | state->addrs[0] = ip; 175 | state->addrs++; 176 | state->count--; 177 | } 178 | } 179 | return _URC_NO_REASON; 180 | } 181 | 182 | static inline 183 | int get_backtrace(intptr_t* addrs, size_t max_entries) 184 | { 185 | stack_crawl_state_t state; 186 | state.count = max_entries; 187 | state.addrs = (intptr_t*)addrs; 188 | _Unwind_Backtrace(trace_function, (void*)&state); 189 | return max_entries - state.count; 190 | } 191 | #endif 192 | 193 | static bool_t xdr_std_recv_uint32(xdr_s_type *xdr, uint32 *value) 194 | { 195 | #if 0 196 | intptr_t *trace[20], *tr; 197 | int nc = get_backtrace(trace, 20); 198 | tr = trace; 199 | while(nc--) 200 | D("\t%02d: %p\n", nc, *tr++); 201 | #endif 202 | 203 | if (xdr->in_next + 4 > xdr->in_len) { return FALSE; } 204 | if (value) *value = ntohl(*(uint32 *)(xdr->in_msg + xdr->in_next)); 205 | xdr->in_next += 4; 206 | return TRUE; 207 | } 208 | 209 | #define RECEIVE \ 210 | uint32 val; \ 211 | if (xdr_std_recv_uint32(xdr, &val)) { \ 212 | *value = val; \ 213 | return TRUE; \ 214 | } \ 215 | return FALSE 216 | 217 | static bool_t xdr_std_recv_int8(xdr_s_type *xdr, int8 *value) 218 | { 219 | RECEIVE; 220 | } 221 | 222 | static bool_t xdr_std_recv_uint8(xdr_s_type *xdr, uint8 *value) 223 | { 224 | RECEIVE; 225 | } 226 | 227 | static bool_t xdr_std_recv_int16(xdr_s_type *xdr, int16 *value) 228 | { 229 | RECEIVE; 230 | } 231 | 232 | static bool_t xdr_std_recv_uint16(xdr_s_type *xdr, uint16 *value) 233 | { 234 | RECEIVE; 235 | } 236 | 237 | #undef RECEIVE 238 | 239 | static bool_t xdr_std_recv_int32(xdr_s_type *xdr, int32 *value) 240 | { 241 | return xdr_std_recv_uint32(xdr, (uint32 * )value); 242 | } 243 | 244 | static bool_t xdr_std_recv_bytes(xdr_s_type *xdr, uint8 *buf, uint32 len) 245 | { 246 | if (xdr->in_next + (int)len > xdr->in_len) return FALSE; 247 | if (buf) memcpy(buf, &xdr->in_msg[xdr->in_next], len); 248 | xdr->in_next += len; 249 | xdr->in_next = (xdr->in_next + 3) & ~3; 250 | return TRUE; 251 | } 252 | 253 | const xdr_ops_s_type xdr_std_xops = { 254 | 255 | xdr_std_destroy, 256 | xdr_std_control, 257 | xdr_std_read, 258 | xdr_std_msg_done, 259 | xdr_std_msg_start, 260 | xdr_std_msg_abort, 261 | xdr_std_msg_send, 262 | 263 | xdr_std_send_int8, 264 | xdr_std_send_uint8, 265 | xdr_std_send_int16, 266 | xdr_std_send_uint16, 267 | xdr_std_send_int32, 268 | xdr_std_send_uint32, 269 | xdr_std_send_bytes, 270 | xdr_std_recv_int8, 271 | xdr_std_recv_uint8, 272 | xdr_std_recv_int16, 273 | xdr_std_recv_uint16, 274 | xdr_std_recv_int32, 275 | xdr_std_recv_uint32, 276 | xdr_std_recv_bytes, 277 | }; 278 | 279 | xdr_s_type *xdr_init_common(const char *router, int is_client) 280 | { 281 | xdr_s_type *xdr = (xdr_s_type *)calloc(1, sizeof(xdr_s_type)); 282 | 283 | xdr->xops = &xdr_std_xops; 284 | 285 | xdr->fd = r_open(router); 286 | if (xdr->fd < 0) { 287 | E("ERROR OPENING [%s]: %s\n", router, strerror(errno)); 288 | free(xdr); 289 | return NULL; 290 | } 291 | xdr->is_client = is_client; 292 | 293 | D("OPENED [%s] fd %d\n", router, xdr->fd); 294 | return xdr; 295 | } 296 | 297 | xdr_s_type *xdr_clone(xdr_s_type *other) 298 | { 299 | xdr_s_type *xdr = (xdr_s_type *)calloc(1, sizeof(xdr_s_type)); 300 | 301 | xdr->xops = &xdr_std_xops; 302 | 303 | xdr->fd = dup(other->fd); 304 | if (xdr->fd < 0) { 305 | E("ERROR DUPLICATING FD %d: %s\n", other->fd, strerror(errno)); 306 | free(xdr); 307 | return NULL; 308 | } 309 | 310 | xdr->xid = xdr->xid; 311 | xdr->x_prog = other->x_prog; 312 | xdr->x_vers = other->x_vers; 313 | xdr->is_client = other->is_client; 314 | 315 | D("CLONED fd %d --> %d\n", other->fd, xdr->fd); 316 | return xdr; 317 | } 318 | 319 | void xdr_destroy_common(xdr_s_type *xdr) 320 | { 321 | D("CLOSING fd %d\n", xdr->fd); 322 | r_close(xdr->fd); 323 | free(xdr); 324 | } 325 | -------------------------------------------------------------------------------- /libaudio/AudioHardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008, The Android Open-Source Project 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_AUDIO_HARDWARE_H 18 | #define ANDROID_AUDIO_HARDWARE_H 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | extern "C" { 29 | #include 30 | } 31 | 32 | namespace android { 33 | 34 | // ---------------------------------------------------------------------------- 35 | // Kernel driver interface 36 | // 37 | 38 | #define SAMP_RATE_INDX_8000 0 39 | #define SAMP_RATE_INDX_11025 1 40 | #define SAMP_RATE_INDX_12000 2 41 | #define SAMP_RATE_INDX_16000 3 42 | #define SAMP_RATE_INDX_22050 4 43 | #define SAMP_RATE_INDX_24000 5 44 | #define SAMP_RATE_INDX_32000 6 45 | #define SAMP_RATE_INDX_44100 7 46 | #define SAMP_RATE_INDX_48000 8 47 | 48 | #define EQ_MAX_BAND_NUM 12 49 | 50 | #define ADRC_ENABLE 0x0001 51 | #define ADRC_DISABLE 0x0000 52 | #define EQ_ENABLE 0x0002 53 | #define EQ_DISABLE 0x0000 54 | #define RX_IIR_ENABLE 0x0004 55 | #define RX_IIR_DISABLE 0x0000 56 | 57 | struct eq_filter_type { 58 | int16_t gain; 59 | uint16_t freq; 60 | uint16_t type; 61 | uint16_t qf; 62 | }; 63 | 64 | struct eqalizer { 65 | uint16_t bands; 66 | uint16_t params[132]; 67 | }; 68 | 69 | struct rx_iir_filter { 70 | uint16_t num_bands; 71 | uint16_t iir_params[48]; 72 | }; 73 | 74 | struct msm_audio_config { 75 | uint32_t buffer_size; 76 | uint32_t buffer_count; 77 | uint32_t channel_count; 78 | uint32_t sample_rate; 79 | uint32_t codec_type; 80 | uint32_t unused[3]; 81 | }; 82 | 83 | struct msm_audio_stats { 84 | uint32_t out_bytes; 85 | uint32_t unused[3]; 86 | }; 87 | 88 | #define CODEC_TYPE_PCM 0 89 | #define AUDIO_HW_NUM_OUT_BUF 2 // Number of buffers in audio driver for output 90 | // TODO: determine actual audio DSP and hardware latency 91 | #define AUDIO_HW_OUT_LATENCY_MS 0 // Additionnal latency introduced by audio DSP and hardware in ms 92 | 93 | #define AUDIO_HW_IN_SAMPLERATE 8000 // Default audio input sample rate 94 | #define AUDIO_HW_IN_CHANNELS (AudioSystem::CHANNEL_IN_MONO) // Default audio input channel mask 95 | #define AUDIO_HW_IN_BUFFERSIZE 2048 // Default audio input buffer size 96 | #define AUDIO_HW_IN_FORMAT (AudioSystem::PCM_16_BIT) // Default audio input sample format 97 | // ---------------------------------------------------------------------------- 98 | 99 | 100 | class AudioHardware : public AudioHardwareBase 101 | { 102 | class AudioStreamOutMSM72xx; 103 | class AudioStreamInMSM72xx; 104 | 105 | public: 106 | AudioHardware(); 107 | virtual ~AudioHardware(); 108 | virtual status_t initCheck(); 109 | 110 | virtual status_t setVoiceVolume(float volume); 111 | virtual status_t setMasterVolume(float volume); 112 | 113 | virtual status_t setMode(int mode); 114 | 115 | // mic mute 116 | virtual status_t setMicMute(bool state); 117 | virtual status_t getMicMute(bool* state); 118 | 119 | virtual status_t setParameters(const String8& keyValuePairs); 120 | virtual String8 getParameters(const String8& keys); 121 | 122 | // create I/O streams 123 | virtual AudioStreamOut* openOutputStream( 124 | uint32_t devices, 125 | int *format=0, 126 | uint32_t *channels=0, 127 | uint32_t *sampleRate=0, 128 | status_t *status=0); 129 | 130 | virtual AudioStreamIn* openInputStream( 131 | 132 | uint32_t devices, 133 | int *format, 134 | uint32_t *channels, 135 | uint32_t *sampleRate, 136 | status_t *status, 137 | AudioSystem::audio_in_acoustics acoustics); 138 | 139 | virtual void closeOutputStream(AudioStreamOut* out); 140 | virtual void closeInputStream(AudioStreamIn* in); 141 | 142 | virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount); 143 | void clearCurDevice() { mCurSndDevice = -1; } 144 | 145 | protected: 146 | virtual status_t dump(int fd, const Vector& args); 147 | 148 | private: 149 | 150 | status_t doAudioRouteOrMute(uint32_t device); 151 | status_t setMicMute_nosync(bool state); 152 | status_t checkMicMute(); 153 | status_t dumpInternals(int fd, const Vector& args); 154 | uint32_t getInputSampleRate(uint32_t sampleRate); 155 | bool checkOutputStandby(); 156 | status_t doRouting(); 157 | AudioStreamInMSM72xx* getActiveInput_l(); 158 | 159 | class AudioStreamOutMSM72xx : public AudioStreamOut { 160 | public: 161 | AudioStreamOutMSM72xx(); 162 | virtual ~AudioStreamOutMSM72xx(); 163 | status_t set(AudioHardware* mHardware, 164 | uint32_t devices, 165 | int *pFormat, 166 | uint32_t *pChannels, 167 | uint32_t *pRate); 168 | virtual uint32_t sampleRate() const { return 44100; } 169 | // must be 32-bit aligned - driver only seems to like 4800 170 | virtual size_t bufferSize() const { return 4800; } 171 | virtual uint32_t channels() const { return AudioSystem::CHANNEL_OUT_STEREO; } 172 | virtual int format() const { return AudioSystem::PCM_16_BIT; } 173 | virtual uint32_t latency() const { return (1000*AUDIO_HW_NUM_OUT_BUF*(bufferSize()/frameSize()))/sampleRate()+AUDIO_HW_OUT_LATENCY_MS; } 174 | virtual status_t setVolume(float left, float right) { return INVALID_OPERATION; } 175 | virtual ssize_t write(const void* buffer, size_t bytes); 176 | virtual status_t standby(); 177 | virtual status_t dump(int fd, const Vector& args); 178 | bool checkStandby(); 179 | virtual status_t setParameters(const String8& keyValuePairs); 180 | virtual String8 getParameters(const String8& keys); 181 | uint32_t devices() { return mDevices; } 182 | virtual status_t getRenderPosition(uint32_t *dspFrames); 183 | 184 | private: 185 | AudioHardware* mHardware; 186 | int mFd; 187 | int mStartCount; 188 | int mRetryCount; 189 | bool mStandby; 190 | uint32_t mDevices; 191 | }; 192 | 193 | class AudioStreamInMSM72xx : public AudioStreamIn { 194 | public: 195 | enum input_state { 196 | AUDIO_INPUT_CLOSED, 197 | AUDIO_INPUT_OPENED, 198 | AUDIO_INPUT_STARTED 199 | }; 200 | 201 | AudioStreamInMSM72xx(); 202 | virtual ~AudioStreamInMSM72xx(); 203 | status_t set(AudioHardware* mHardware, 204 | uint32_t devices, 205 | int *pFormat, 206 | uint32_t *pChannels, 207 | uint32_t *pRate, 208 | AudioSystem::audio_in_acoustics acoustics); 209 | virtual size_t bufferSize() const { return mBufferSize; } 210 | virtual uint32_t channels() const { return mChannels; } 211 | virtual int format() const { return mFormat; } 212 | virtual uint32_t sampleRate() const { return mSampleRate; } 213 | virtual status_t setGain(float gain) { return INVALID_OPERATION; } 214 | virtual ssize_t read(void* buffer, ssize_t bytes); 215 | virtual status_t dump(int fd, const Vector& args); 216 | virtual status_t standby(); 217 | virtual status_t setParameters(const String8& keyValuePairs); 218 | virtual String8 getParameters(const String8& keys); 219 | virtual unsigned int getInputFramesLost() const { return 0; } 220 | uint32_t devices() { return mDevices; } 221 | int state() const { return mState; } 222 | 223 | private: 224 | AudioHardware* mHardware; 225 | int mFd; 226 | int mState; 227 | int mRetryCount; 228 | int mFormat; 229 | uint32_t mChannels; 230 | uint32_t mSampleRate; 231 | size_t mBufferSize; 232 | AudioSystem::audio_in_acoustics mAcoustics; 233 | uint32_t mDevices; 234 | }; 235 | 236 | static const uint32_t inputSamplingRates[]; 237 | bool mInit; 238 | bool mMicMute; 239 | bool mBluetoothNrec; 240 | uint32_t mBluetoothId; 241 | AudioStreamOutMSM72xx* mOutput; 242 | SortedVector mInputs; 243 | 244 | msm_snd_endpoint *mSndEndpoints; 245 | int mNumSndEndpoints; 246 | int mCurSndDevice; 247 | 248 | friend class AudioStreamInMSM72xx; 249 | Mutex mLock; 250 | 251 | int SND_DEVICE_CURRENT; 252 | int SND_DEVICE_HANDSET; 253 | int SND_DEVICE_SPEAKER; 254 | int SND_DEVICE_HEADSET; 255 | int SND_DEVICE_BT; 256 | int SND_DEVICE_CARKIT; 257 | int SND_DEVICE_TTY_FULL; 258 | int SND_DEVICE_TTY_VCO; 259 | int SND_DEVICE_TTY_HCO; 260 | int SND_DEVICE_NO_MIC_HEADSET; 261 | int SND_DEVICE_FM_HEADSET; 262 | int SND_DEVICE_HEADSET_AND_SPEAKER; 263 | int SND_DEVICE_FM_SPEAKER; 264 | int SND_DEVICE_BT_EC_OFF; 265 | }; 266 | 267 | // ---------------------------------------------------------------------------- 268 | 269 | }; // namespace android 270 | 271 | #endif // ANDROID_AUDIO_HARDWARE_MSM72XX_H 272 | --------------------------------------------------------------------------------